How OpenLeverage Works

Decentralized Margin Trading

Margin trading is a method of trading assets using funds provided by a third party. Compared to regular trading accounts, margin accounts allow traders to access greater sums of capital, allowing them to leverage their positions. Essentially, margin trading amplifies trading results so that traders can realize bigger profits on successful trades.
In centralized crypto markets, the borrowed funds are usually provided by an intermediate, for example, centralized exchange or broker. In a decentralized cryptocurrency trading environment, however, funds are often provided by other anonymous users, who earn interest based on market demand for margin funds. Borrowers and trades will be anonymous but transparent and align with the rules defined in smart contracts. All funds are held in smart contracts until all conditions are met to close the trading and lending positions accordingly.

Example Walkthrough

Anyone can create lending pools for a specific pair on a DEX. For example, someone might be interested in doing leverage trading on the FEI/USDC pair, so they create two lending pools for the FEI/USDC pair from Uniswap. Anyone can create isolated pools for users to lend or borrow for margin trades.
Next, a user can provide liquidity in the FEI → USDC pool, providing FEI to be borrowed to buy USDC. Or users can choose to provide liquidity in the USDC → FEI pool instead. Lenders will receive variable interest based on the pool’s utilization. This process is similar to how the Compound protocol works.
Lenders receive LToken of the pool as an interest-bearing token, which can then be re-staked to other yield farms to receive further rewards.
Traders can choose to borrow from either pool to swap to another token as a leveraged position. In this example, the trader borrows USDC by putting down the same amount of USDC as collateral to make a 2X margin trade, swapped into FEI position with the liquidity pools of Uniswap, and locked in the smart contract. By taking advantage of liquidity on a DEX, we don’t have to create separate liquidity or an order book for leverage trading.
Once the trader closes the position, the protocol swaps the FEI position back to USDC by repaying the loan with interest, which returns the deposit plus or minus any profit or loss back to the trader.