Symmetry
  • 🚀Welcome to Symmetry
  • 💡Getting Started
  • Guides and FAQs
    • 📜Dashboard
    • 📈Trade
      • 🧑‍🏫Risk Management Measurements
        • Funding
        • Position Financial Cost Mechanism
        • "Adjusted" AMM
      • 💣Case Studies - Liquidation
      • 👩‍🏫USD Settlement & Interest Rate Model
    • 🐳Liquidity
      • Mint and redeem of LP tokens
    • 🎰Coupons
  • Developers
    • Deployed Contracts
  • Links
    • Symmetry Website
    • Github
    • Twitter
    • Discord
    • Telegram
    • Medium
Powered by GitBook
On this page
  • Case 1: Single Open Position
  • Case 2: Multiple Open Positions
  1. Guides and FAQs
  2. Trade

Case Studies - Liquidation

Examples and calculations

To help users better understand the cause and process of liquidation, we've prepared two sets of examples, one with a single position and the other one with multiple open positions. In both examples, we further list down all possible cases when liquidation is triggered.

General setting:

Alex deposits 1,000 USDC into Symmetry Trade and wants to open positions. The oracle price of BTC is $25,000 and the oracle price of ETH is $2,000 now.

Case 1: Single Open Position

Alex opens +0.2 BTCUSDC position at the execution price of $25,200, Keeperfeemin=$1Keeperfee_{min} = \$1Keeperfeemin​=$1, UserInputfee=$10UserInputfee = \$10UserInputfee=$10, trading fee rate 0.1%. Minimum margin deposit $50.

Scene 1: BTC Oracle price drops from $25,000 to $24,000, Funding = $-20, \sum FinancialCosts = $0.

Now,

Keeper fee is $10.

Alex PnL is 0.2×(24,000−25,200×(1+0.1%))−10=$−255.040.2 \times (24,000-25,200 \times (1+0.1\%))-10 = \$-255.040.2×(24,000−25,200×(1+0.1%))−10=$−255.04.

Margin balance is 1000−255.04−20=$724.961000-255.04-20=\$724.961000−255.04−20=$724.96.

Available margin is 724.96−0.2×24,00025−50=$482.96724.96-\frac {0.2 \times 24,000} {25} -50=\$ 482.96724.96−250.2×24,000​−50=$482.96.

Buying power is (482.96+50)×25=$13,324(482.96+50)\times 25 = \$13,324(482.96+50)×25=$13,324.

Maintenance margin is 0.2×24,000×2%=$960.2 \times 24,000 \times 2\% = \$960.2×24,000×2%=$96.

Maintenance margin ratio is 724.9696=7.55>1\frac {724.96} {96}=7.55 > 196724.96​=7.55>1.

Scene 2: BTC Oracle price drops from $25,000 to $20,500, $Funding = $50, ∑FinancialCosts=$0\sum FinancialCosts = \$0∑FinancialCosts=$0.

Now,

Alex PnL is 0.2×(20,500−25,200×(1+0.1%))−10=$−955.040.2 \times (20,500-25,200\times (1+0.1\%)) -10= \$-955.040.2×(20,500−25,200×(1+0.1%))−10=$−955.04.

Margin balance is 1000−955.04+50=$94.961000-955.04+50=\$94.961000−955.04+50=$94.96.

94.96−0.2×20,50025−50<094.96-\frac {0.2 \times 20,500} {25}-50<094.96−250.2×20,500​−50<0, therefore available margin is 0, trader could not withdraw any money.

Buying power is 0.

Maintenance margin is 0.2×20,500×2%=$820.2 \times 20,500 \times 2\% = \$820.2×20,500×2%=$82.

Maintenance margin ratio is 94.9682=1.16>1\frac {94.96} {82}=1.16 > 18294.96​=1.16>1.

Scene 3: BTC Oracle price drops from $25,000 to $20,500, Funding = $30, ∑FinancialCosts=$0\sum FinancialCosts = \$0∑FinancialCosts=$0.

Now,

Alex PnL is 0.2×(20,500−25,200×(1+0.1%))−10=$−955.040.2 \times (20,500-25,200\times (1+0.1\%)) -10= \$-955.040.2×(20,500−25,200×(1+0.1%))−10=$−955.04.

Margin balance is 1000−955.04+30=$74.961000-955.04+30=\$74.961000−955.04+30=$74.96.

74.96−0.2×20,50025−50<074.96-\frac {0.2 \times 20,500} {25}-50<074.96−250.2×20,500​−50<0, therefore available margin is 0, trader could not withdraw any money.

Buying power is 0.

Maintenance margin is 0.2 \times 20,500 \times 2\% = \$82.

Maintenance margin ratio is 74.9682=0.91<1\frac {74.96} {82}=0.91 <18274.96​=0.91<1.

Out of the three possibilities listed above, Scene 3 would trigger the liquidation process. For the process, we have four different scenarios, categorized by the price at which all BTC/USDC positions are closed:

Then,

Liquidation keeper fee is 0.2×20,500×0.35%=$14.35<$10000.2 \times 20,500 \times 0.35\% = \$14.35<\$10000.2×20,500×0.35%=$14.35<$1000 .

Alex PnL is 0.2×(20,450×(1−0.1%)−25,200×(1+0.1%))−10−14.35=$−983.480.2 \times (20,450\times (1-0.1\%)-25,200\times (1+0.1\%))-10-14.35 = \$-983.480.2×(20,450×(1−0.1%)−25,200×(1+0.1%))−10−14.35=$−983.48.

Margin balance is 1000−983.48+30=$46.521000-983.48+30=\$46.521000−983.48+30=$46.52.

Penalty fee is 0.2×20,500×1%=$410.2 \times 20,500 \times 1\% =\$410.2×20,500×1%=$41.

User asset is 46.52−41=$5.52.46.52 -41 = \$5.52. 46.52−41=$5.52. $5.52\$5.52$5.52 will be returned to user.

Then,

Liquidation keeper fee is 0.2×20,500×0.35%=$14.35<$10000.2 \times 20,500 \times 0.35\% = \$14.35<\$10000.2×20,500×0.35%=$14.35<$1000.

Alex PnL is 0.2×(20,300×(1−0.1%)−25,200×(1+0.1%))−10−14.35=$−1013.450.2 \times (20,300\times (1-0.1\%)-25,200\times (1+0.1\%)) -10-14.35= \$-1013.450.2×(20,300×(1−0.1%)−25,200×(1+0.1%))−10−14.35=$−1013.45.

Margin balance is 1000−1013.45+30=$16.551000-1013.45+30=\$16.551000−1013.45+30=$16.55.

Penalty fee is 0.2×20,500×1%=$410.2 \times 20,500 \times 1\% =\$410.2×20,500×1%=$41.

After paying all fees, only $16.55 will be credited to the insurance account, user asset is 0.

Then,

Liquidation keeper fee is 0.2×20,500×0.35%=$14.35<$10000.2 \times 20,500 \times 0.35\% = \$14.35<\$10000.2×20,500×0.35%=$14.35<$1000.

Alex PnL is 0.2×(20,200×(1−0.1%)−25,200×(1+0.1%))−10−14.35=$−1033.430.2 \times (20,200\times (1-0.1\%)-25,200\times (1+0.1\%))-10-14.35 = \$-1033.430.2×(20,200×(1−0.1%)−25,200×(1+0.1%))−10−14.35=$−1033.43.

Margin balance is 1000−1033.43+30=$−3.43<01000-1033.43+30=\$-3.43<01000−1033.43+30=$−3.43<0.

Penalty fee is 0.2×20,500×1%=$410.2 \times 20,500 \times 1\% =\$410.2×20,500×1%=$41.

Insurance account pay $3.43 to LP, user asset is 0.

Then,

Liquidation keeper fee is 0.2×20,500×0.35%=$14.35<$10000.2 \times 20,500 \times 0.35\% = \$14.35<\$10000.2×20,500×0.35%=$14.35<$1000.

Alex PnL is 0.2×(20,000×(1−0.1%)−25,200×(1+0.1%))−10−14.35=$−1073.390.2 \times (20,000\times (1-0.1\%)-25,200\times (1+0.1\%))-10-14.35 = \$-1073.390.2×(20,000×(1−0.1%)−25,200×(1+0.1%))−10−14.35=$−1073.39.

Margin balance is 1000−1073.39+30=$−43.39<01000-1073.39+30=\$-43.39 <01000−1073.39+30=$−43.39<0.

Then insurance account will pay $43.39 to the keeper bot, LP and protocol, user asset is 0.

Case 2: Multiple Open Positions

Alex opens +0.2 BTC/USDC position at the execution price of $25,200 and opens -2 ETH/USDC position at the execution price of $1,990. For each trade, Keeperfeemin=$1Keeperfee_{min} = \$1Keeperfeemin​=$1, UserInputfee=$10UserInputfee = \$10UserInputfee=$10. Trading fee rate 0.1\%. Minimum margin deposit $50.

Scene 1: BTC Oracle price drops from $25,000 to $24,000, and ETH Oracle price drops from $2,000 to $1,900, ∑Funding=$−50\sum Funding = \$-50∑Funding=$−50, ∑FinancialCosts=$0\sum FinancialCosts = \$0∑FinancialCosts=$0.

Now,

Alex PnL is 0.2×(24,000−25,200×(1+0.1%))−2×(1,900−1,990×(1−0.1%))−20=$−89.020.2 \times (24,000-25,200\times (1+0.1\%)) - 2 \times(1,900-1,990\times (1-0.1\%))-20 = \$-89.020.2×(24,000−25,200×(1+0.1%))−2×(1,900−1,990×(1−0.1%))−20=$−89.02

Margin balance is 1000−89.02−50=$860.981000-89.02-50=\$860.981000−89.02−50=$860.98.

Available margin is 860.98−0.2×24,000+2×1,90025−50=$466.98860.98-\frac {0.2 \times 24,000+2 \times 1,900} {25}-50=\$ 466.98860.98−250.2×24,000+2×1,900​−50=$466.98.

Buying power is (466.98+50)×25=$12,924.5(466.98+50)\times 25 = \$12,924.5(466.98+50)×25=$12,924.5.

Maintenance margin is (0.2×24,000+2×1,900)×2%=$172(0.2 \times 24,000 + 2 \times 1,900) \times 2\% = \$172(0.2×24,000+2×1,900)×2%=$172.

Maintenance margin ratio is 860.98172=5.0>1\frac {860.98} {172}=5.0 > 1172860.98​=5.0>1

Scene 2: BTC Oracle price drops from $25,000 to $24,000, and ETH Oracle price increases from $2,000 to $2,300, ∑Funding=$70\sum Funding = \$70∑Funding=$70, ∑FinancialCosts=$0\sum FinancialCosts = \$0∑FinancialCosts=$0.

Now,

Alex PnL is 0.2×(24,000−25,200×(1+0.1%))−2×(2,300−1,990×(1−0.1%))−20=$−889.020.2 \times (24,000-25,200\times (1+0.1\%)) - 2 \times(2,300-1,990\times (1-0.1\%)) -20= \$-889.020.2×(24,000−25,200×(1+0.1%))−2×(2,300−1,990×(1−0.1%))−20=$−889.02

Margin balance is 1000−889.02+70=$180.981000-889.02+70=\$180.981000−889.02+70=$180.98.

180.98−0.2×24,000+2×2,30025−50<0180.98-\frac {0.2 \times 24,000+2 \times 2,300} {25}-50<0180.98−250.2×24,000+2×2,300​−50<0, therefore available margin is 0, trader could not withdraw any money.

Buying power is 0.

Maintenance margin is (0.2×24,000+2,300×2)×2%=$188(0.2 \times 24,000 + 2,300 \times 2) \times 2\% = \$188(0.2×24,000+2,300×2)×2%=$188.

Maintenance margin ratio is 180.98188=0.96<1\frac {180.98} {188}=0.96 < 1188180.98​=0.96<1.

Out of the two possibilities listed above, Scene 2 would trigger the liquidation process. For the process, we have two different scenarios, categorized by the price at which all BTC/USDC positions are closed (as BTC/USDC would be the first position to close, ETH/USDC follows):

Then,

Liquidation keeper fee is 0.2×24,000×0.35%=$16.8<$10000.2 \times 24,000 \times 0.35\% = \$16.8<\$10000.2×24,000×0.35%=$16.8<$1000.

Alex PnL is 0.2×(24,000×(1−0.1%)−25,200×(1+0.1%))−2×(2,300−1,990×(1−0.1%))−20−16.8=$−910.620.2 \times (24,000\times (1-0.1\%)-25,200\times (1+0.1\%)) - 2 \times(2,300-1,990\times (1-0.1\%)) -20 -16.8= \$-910.620.2×(24,000×(1−0.1%)−25,200×(1+0.1%))−2×(2,300−1,990×(1−0.1%))−20−16.8=$−910.62

Penalty fee is 0.2×24,000×1%=$480.2 \times 24,000 \times 1\% =\$480.2×24,000×1%=$48.

Margin balance is 1000−910.62+70−48=$111.381000-910.62+70 -48 = \$111.381000−910.62+70−48=$111.38.

Maintenance margin is 2×2,300×2%=$922 \times 2,300 \times 2\% = \$922×2,300×2%=$92.

Maintenance margin ratio is now 111.3892=1.21>1\frac {111.38} {92}=1.21 > 192111.38​=1.21>1 .

No need to further liquidate the ETH/USDC positions now.

Then,

Liquidation keeper fee is 0.2×24,000×0.35%=$16.8<$10000.2 \times 24,000 \times 0.35\% = \$16.8<\$10000.2×24,000×0.35%=$16.8<$1000.

Alex PnL is 0.2×(23,500×(1−0.1%)−25,200×(1+0.1%))−2×(2,300−1,990×(1−0.1%))−20−16.8=$−1,010.520.2 \times (23,500\times (1-0.1\%)-25,200\times (1+0.1\%)) - 2 \times(2,300-1,990\times (1-0.1\%))-20-16.8 = \$-1,010.520.2×(23,500×(1−0.1%)−25,200×(1+0.1%))−2×(2,300−1,990×(1−0.1%))−20−16.8=$−1,010.52

Penalty fee is 0.2×24,000×1%=$480.2 \times 24,000 \times 1\% =\$480.2×24,000×1%=$48.

Margin balance is 1000−1,010.52+70−48=$11.481000-1,010.52+70-48 = \$11.481000−1,010.52+70−48=$11.48.

Maintenance margin is 2×2,300×2%=$922 \times 2,300 \times 2\% = \$922×2,300×2%=$92.

Maintenance margin ratio is 11.4892=0.12<1\frac {11.48} {92}=0.12< 19211.48​=0.12<1.

Because the maintenance margin ratio is still below 1, the ETH/USDC position also needs to be liquidated.

All ETH/USDC positions are closed at $2,300. Assume all funding incomes come from BTC/USDC position.

After closing BTC/USDC position, USDC deposit is 1000−0.2×(23,500×(1−0.1%)−25,200×(1+0.1%))−10−16.8+70−48=$645.461000-0.2 \times (23,500\times (1-0.1\%)-25,200\times (1+0.1\%))-10-16.8+70-48 = \$645.461000−0.2×(23,500×(1−0.1%)−25,200×(1+0.1%))−10−16.8+70−48=$645.46

Liquidation keeper fee is 2×2,300×0.35%=$16.1<$10002 \times 2,300 \times 0.35\% = \$16.1<\$10002×2,300×0.35%=$16.1<$1000.

Alex PnL is −2×(2,300×(1+0.1%)−1,990×(1−0.1%))−10−16.1=$−654.68- 2 \times(2,300\times (1+0.1\%)-1,990\times (1-0.1\%)) -10-16.1= \$-654.68−2×(2,300×(1+0.1%)−1,990×(1−0.1%))−10−16.1=$−654.68.

ETH position penalty fee is 2×2,300×1%=$462 \times 2,300 \times 1\% =\$462×2,300×1%=$46.

Margin balance is 645.46−654.68−46=−$55.22<0645.46-654.68-46 = -\$55.22<0645.46−654.68−46=−$55.22<0.

Therefore, insurance account needs to pay ∣645.46−654.68∣=$9.22|645.46-654.68| = \$9.22∣645.46−654.68∣=$9.22 to keeper bot, LP & protocol, taker has no asset left.

Previous"Adjusted" AMMNextUSD Settlement & Interest Rate Model

Last updated 1 year ago

📈
💣