Trading on the DEXs
Understanding how margin trading works on Decentralized Exchanges
Margin Trading on DEXs starts with the creation of lending pools that will be used for capital deployment on the platform. Isolated pools of assets can be created for users to lend or borrow for margin trades.
Those who supply their assets in a lending pool will earn a variable Rate of Interest as Income based on the pool’s utilization. Similar to how a lending protocol works.
Traders have the choice of borrowing from the lending pool to swap to another token as a leveraged position. Margin Trading platforms will take advantage of the liquidity on a DEX, and do not need to create separate liquidity or order books for the leverage trading.
Opening a trade
- A trader can open a long position of an asset say MATIC worth 1000 USDC backed by collateral of say 500 USDC
- This will prompt him to borrow 500 USDC from the lending pool
- The smart contract on the on-chain margin trading platform executes a swap from USDC to MATIC via the DEX — in this case QuickSwap
- It keeps the position under the contract
- If the collateral ratio assumed here is 50%, that provides a leverage equivalent to 3X
Closing a trade
- Now lets say, the MATIC falls in value — this means the trader will lose his money, thus resulting in a negative P&L
- The P&L is added to the margin, and as per our example here, say the margin start to fall below 100 USDC
- This will decrease the collateral ratio to 25%
- The trader may opt to close this position
- This means the trader would essentially instruct the contract to swap the current MATIC holding back to USDC, repay the loan with interests, and have the remaining P&L back in the wallet.
Profit & Loss Calculation
Profit & Loss for DEX-based margin trades are calculated based on the total value of assets held by the person minus the total value of collateral and assets borrowed by the trader.
P&L of a trade can be positive or negative and based on whether the leverage was on a long or short position. This can be calculated using either asset in the trading pair.
The process of liquidation in margin trading is when the price of an asset you borrowed drops below the outstanding balance. In this case the platform will sell the collateral unless the borrower pays the loan or adds more margin.
Liquidation in Crypto — It happens mainly due to the forced closing of a trader’s position due to the partial or total loss of the trader’s initial margin.
When conducting margin trades on DEXs, liquidity depth and price stability of the target trading pair matters a lot. Attention needs to be paid to this because if the liquidity provision is low, the trade will tend to have bigger slippages resulting in losses or in extreme market conditions — total liquidation.
What is Slippage — Slippage refers to the difference between the expected price of a trade and the price at which the trade is actually executed.
Slippages in Crypto are high due to the volatility of crypto assets and depend on trade volumes and activities on that asset at any given point in time.
Norms of Margin Trades
Funds on centralized crypto markets are usually provided by an intermediate, e.g., a broker or CEX. In the event of a decentralized crypto-trading environment, the funds are usually provided by an anonymous user / institution that earns an interest on the margin fund based on market demand.
In case of decentralized margin trades:
- Borrowers and trades will be Peer-to-Peer
- Trade transactions will be transparent and executed as per rules defined in smart contracts.
- All funds will be held in smart contracts until all defined conditions towards closing of trade and lending positions are met.
Note: DEXs do not execute fiat and crypto transactions; instead, they exclusively conduct crypto-to-crypto trades.
EasyFi Network is a universal layer-2 multi-chain money market protocol for digital assets with focus on liquidity sourcing & capital efficiency for structured lending in a non-custodial manner. The Protocol is currently live on Polygon, Binance Smart Chain and Ethereum.
To learn more about $EZ and EasyFi, please go through our whitepaper and other articles on this publication. Stay tuned for more news & updates on our Telegram channel and join the official group. You can also follow us on Twitter.