Sharwa.Finance Documentation
  • 💼Margin Account
    • Liquidity Providers
      • Insurance Pool
    • Liquidation
    • Fees
    • Allowed Assets
    • Security
    • Links
  • 🪙Tokenomics
    • We don't have a token
  • 🦾FOR DEVS
    • Margin Account
      • Core Contracts
        • MarginTrading.sol
        • MarginAccountManager.sol
        • LiquidityPool.sol
        • ModularSwapRouter
          • HegicModule.sol
      • Toolkits and other contracts
        • OneClick Contracts
      • HegicStopOrders
        • HegicStopOrders SDK
  • 📚Guide
    • How To Trade on Sharwa
Powered by GitBook
On this page
  • How Liquidation Works
  • Here’s how it works:
  • Order of Liquidation in a Margin Account
  • Who triggers liquidations
  1. Margin Account

Liquidation

To avoid liquidations traders must keep the margin ratio of their margin account above 105%, otherwise account will be liquidated.

How Liquidation Works

When the margin ratio of a margin account falls below 105%, the account will be liquidated.

Here’s how it works:

As long as the total value of all assets in your margin account (denominated in $USDC) exceeds your total debt ( in $USDC) by at least 5%, your account remains safe.

If the margin ratio drops below 105%, liquidation will occur.

Example:

  • Your margin account value: 110,000 $USDC

  • Your aggregated debt: 100,000 $USDC

  • Margin ratio: 110% → Your account is safe. You can reduce your debt but cannot increase leverage.

Now, imagine that prices change, and your account value decreases:

  • New margin account value: 104,999 $USDC

  • New aggregated debt: 100,000 $USDC

  • New margin ratio: 104.99% → This is below the 105% threshold, triggering liquidation.

At this point, Sharwa will liquidate your positions to cover the debt, ensuring the system remains solvent.

Order of Liquidation in a Margin Account

1. Sell all ERC-20 tokens (e.g., $WETH, $WBTC) for $USDC

2. Exercise option position to receive $USDC.e (Hegic options payoffs in $USDC.e).

3. Swap $USDC.e for $USDC

4. Use $USDC to buy back $ETH: USDC obtained from the previous steps is used to buy back the equivalent of $ETH (including debt and interest) to repay the debt to liquidity providers in the ETH liquidity pool (if applicable).

5. Use $USDC to buy back $WBTC: Similarly, $USDC is used to buy back $WBTC (including debt and interest) to repay the debt to liquidity providers in the $WBTC liquidity pool (if applicable).

6. Repay $USDC debt: If there’s any remaining $USDC debt, it is repaid using the $USDC from the previous steps.

7. Remaining $USDC after repaying debts is returned to the margin account, allowing the trader to withdraw or use the funds to open new debts.

Who triggers liquidations

To make sure margin accounts are liquidated promptly, we’ve set up two separate liquidation systems to monitor and act on all margin accounts:

  • Server-Side Script: A classic script runs on a server, continuously pulling real-time data. When a margin account becomes eligible for liquidation, the script automatically triggers the liquidation mechanism.

  • Chainlink Automation: This decentralized solution adds another level of reliability. When a margin account is ready for liquidation, Chainlink Automation steps in and triggers the liquidation process.

PreviousInsurance PoolNextFees

Last updated 3 months ago

💼