Margin Trading

Trade with DEX Liquidity

OpenLeverage smart contract integrates with external DEXs, such as Uniswap, for swapping between assets. Every time a trade is made on OpenLeverage, the trade will be executed on a DEX, and the AMM calculates the entry or exit price in the same way prices are calculated on Uniswap.
Liquidity and Slippage
You need to pay attention to the liquidity depth and stability of the target trading pair on DEX. When the liquidity provision is low, your trade will have bigger slippage on trading, or in extreme market conditions, you may not be able to close your position or be liquidated.

Collateral Ratio

The OpenLeverage Protocol allows traders to leverage by backing a position with collateral worth less than the total position size. It requires maintaining its collateral ratio above the market limit; otherwise, it could be liquidated.
All asset pairs experience different volatility by nature. To support a permissionless margin trading market, isolated pools are needed with risk parameters associated with the pair. Each pair has its collateral ratio, according to the pair's volatility and the block time and throughput of the chain.
The governance process can change the collateral ratio for each market to protect the lender in the best interest.
The collateral ratio is calculated by adding your collateral value in the borrow token and real-time PnL (Profit and Loss) for a given position and dividing by the borrow notional. Note that the collateral ratio is calculated with real-time prices from the DEXs.
collateralRatio=collateralValue+unrealizedPnlborrowNotional+interestAccruedcollateralRatio = \frac{collateralValue+unrealizedPnl}{borrowNotional+interestAccrued}

Leverage

As long as the trader can keep the position's collateral ratio above the market limit, traders can open positions with leverage from 1.1x to 2.4x.
The recommended max leverage for a trading pair is:
maxLeverage=1collateralRatio1.66maxLeverage = \frac{1}{collateralRatio*1.66}
Leveraged trading puts your funds at risk of liquidation at any time. Be sure you understand the risks of leveraged trading before proceeding.

Fees

There is a 0.22% Transaction Fee, in addition to the fees charged by the DEX.
Transaction fees are distributed to the following:
  • 33.33% of fees will be deposited into the isolated insurance fund to cover unexpected losses to the lender.
  • 46.67% of fees will go towards the staking reward program.
  • 20% of fees will go to the dev fund for sustainable development.
Fees and fee allocation can be adjusted through governance to keep the protocol competitive in the market.

Borrowing Interest Rate

By opening a leveraged position, both long and short, you will be paying interest to the borrowing fund from the lending pool. The interest rate is dynamic, based on the utilization of the pool, which means the rate when you are getting into a position isn't always the same through the holding period.
The interest rate is annualized and counted on a block-by-block basis. For example, if you are paying a 30% annualized rate, which means you are paying approximately 0.000000009512938 of the borrowing unit per second.

Example

A trader can open an ETH long position worth 600 USDC backed by collateral of 200 USDC, borrowing 400 USDC from the lending pool. The smart contract executes a swap from USDC to ETH via Uniswap and keeps the position under the contract. The collateral ratio is 50%, equivalent to a leverage of 3X.
If ETH falls in value, he loses money, resulting in a negative PNL. PNL is added to the margin, so in our example, the margin will start to go below 100 USDC, decreasing the collateral ratio to 25%. If the trader closes this position, he would instruct the contract to swap the current ETH holding back to USDC, repay the loan with interests, and have the remaining PnL back in his wallet.
Open WETH 3x long position, assuming WETH price is 1000 USDC
Close WETH 3x long position, assuming WETH price drops to 833.33 USDC

PNL (Profit and Loss) Formula

PNL=HeldAssetsBorrowedAssetsCollateralPNL = Held Assets - Borrowed Assets - Collateral

Long Position Example:

A trader opens an ETH 3x long position on the ETH-USDT pair when 1 ETH is valued at 3,000 USDT. If the ETH price rises to 4,100 USDT, there are two methods to calculate the PNL according to the collateral token:
  • Method 1 (Calculating ETH):
Leverage: 3x long Your Collateral: 1 ETH Your Borrowing: 6,000 USDT Your Held Amount: 3 ETH
PNL (ETH) = 3 - (6,000/4,100) - 1 = 0.536ETH PNL (%) = 0.536/1 * 100% = 53.66%
  • Method 2 (Calculating USDT):
Leverage: 3x long Your Collateral: 3,000 USDT Your Borrowing: 6,000 USDT Your held Amount: 3 ETH
PNL (USDT) = 3 * 4,100 - 6,000 - 3,000 = 3,300 USDT PNL (%) = 3,300/3,000 * 100% = 110%
Even though PNL percentages are different, your profits will be the same.

Short Position Example:

A trader opens an ETH 3x short position on the ETH-USDT pair when 1 ETH is valued at 3,000 USDT. If the ETH price rises to 4,100 USDT, there are two methods to calculate the PNL according to the collateral token:
  • Method 1 (Calculating ETH):
Leverage: 3x short Your Collateral: 1 ETH Your Borrowing: 2 ETH Your held Amount: 9,000 USDT
PNL (ETH) = 9,000/4,100 - 2 - 1 = -0.805 ETH PNL (%) = -0.804/1 * 100% = -80.49%
  • Method 2 (Calculating USDT):
Leverage: 3x short Your Collateral: 3,000 USDT Your Borrowing: 2 ETH Your held Amount: 9,000 USDT
PNL (USDT) = 9,000-2 * 4,100-3,000 = -2,200USDT PNL (%) = -2,200/3,000 * 100%=-73.33%
Even though PNL percentages are different, your losses will be the same.