Risk Management Overview

This section describes how Marginly manages risks

Risk framework

The Marginly v1 risk framework achieves the following:

  1. Maximizes capital efficiency through leveraged trading activity.

  2. Optimizes on-chain handling of the framework parameters.

  3. Minimizes the probability of pool insolvency.

By implementing the loan pricing mechanism in the previous section, Marginly incorporates risk framework directly into the smart contract business logic:

  • Marginly v1 uses the base asset (ETH) volatility as a risk proxy.

  • Marginly v1 prices long and short positions in aggregate: protocol calculates long and short leverage of the entire pool and uses them to scale long and short interest rates.

  • Marginly v1 updates users' positions on-action basis where each public method in smart contracts firstly accrues user debts (recalculates compounded interest), recalculates leverage, and performs liquidations if needed.

  • Marginly v1 implements a decentralized price oracle and uses Uniswap v3's TWAP to calculate and update user positions.

  • Marginly v1 stores two max-heaps of long and short users' leverages in a smart contract where each public method always tries to margin call the top 1 position if its leverage is > 20 and update the heap.

  • Marginly v1 implements a public receive_position() method, which allows calling for margin in any liquidating position with outside liquidity.

  • Marginly v1 implements additional deleveraging functionality, which allows long buyers to absorb liquidating short positions and vice-versa.

Risk management

Marginly further enhances risk management by closely considering the following two broad risk categories related to spot-leveraged trading:

Last updated