Pool Exit

The process of withdrawing liquidity from an AMM pool by redeeming LP tokens for underlying assets.

Pool exit (or liquidity withdrawal) is the process of removing liquidity from an AMM pool. Liquidity providers burn their LP tokens and receive the underlying assets in return. The exit mechanism directly impacts user funds and is a critical security surface in DeFi protocols.

Exit Types

Proportional Exit

Receive tokens in the pool's current ratio:

1Pool: 60% ETH / 40% USDC
2Exit: 1000 LP tokens
3Receive: 60% of value in ETH, 40% in USDC

Single-Asset Exit

Receive only one token (incurs swap fees/slippage):

1Pool: 60% ETH / 40% USDC
2Exit: 1000 LP tokens → All in USDC
3Protocol swaps your ETH portion to USDC

Custom Exit

Specify exact amounts of each token (Balancer specialty).

Exit Calculation

1User LP tokens / Total LP supply × Pool reserves = Exit amount
2
3Example:
4- User LP: 1,000 tokens
5- Total supply: 100,000 tokens
6- Pool reserves: 500 ETH + 1,000,000 USDC
7
8Exit: (1,000/100,000) × reserves
9 = 1% × 500 ETH + 1% × 1,000,000 USDC
10 = 5 ETH + 10,000 USDC

Security Considerations

Reentrancy: Exit functions that send ETH can be exploited for reentrancy attacks.

Oracle manipulation: Price-based exits can be manipulated via flash loans.

Rounding: Integer division in share calculations can be exploited at scale.

Fee extraction: Exit fees must be calculated correctly to prevent drain.

Exit Fees

Many protocols charge exit fees:

  • Swap fee on single-asset exits
  • Protocol fee on all exits
  • Time-based fees (early exit penalties)

Best Practices for Auditors

  1. Verify LP token burn happens before asset transfer
  2. Check share calculations for rounding exploitation
  3. Test exits with dust amounts and maximum values
  4. Verify reentrancy guards on external calls
  5. Test exit during extreme pool states

Need expert guidance on Pool Exit?

Our team at Zealynx has deep expertise in blockchain security and DeFi protocols. Whether you need an audit or consultation, we're here to help.

Get a Quote

oog
zealynx

Subscribe to Our Newsletter

Stay updated with our latest security insights and blog posts

© 2024 Zealynx