Proportional Exit

LP withdrawal method receiving tokens in the pool's current ratio, avoiding swap fees and price impact.

A proportional exit allows liquidity providers to withdraw from a pool by receiving all constituent tokens in the same ratio as the pool's current composition. This exit method avoids swap fees and price impact, making it the most capital-efficient withdrawal mechanism.

How Proportional Exit Works

1Pool State:
2- 100 ETH (50%)
3- 200,000 USDC (50%)
4- Total LP tokens: 10,000
5
6User Exit: 1,000 LP tokens (10% of supply)
7
8Proportional Exit Receives:
9- 10 ETH (10% of 100)
10- 20,000 USDC (10% of 200,000)

Proportional vs Single-Asset Exit

AspectProportionalSingle-Asset
Tokens receivedAll pool tokensOne chosen token
Swap feesNoneIncurs swap fee
Price impactNoneDepends on size
Gas costLowerHigher (swap)
ComplexitySimpleComplex

Implementation

1function proportionalExit(uint256 lpAmount) external {
2 uint256 totalSupply = lpToken.totalSupply();
3
4 for (uint i = 0; i < tokens.length; i++) {
5 uint256 tokenBalance = tokens[i].balanceOf(address(this));
6 uint256 amountOut = tokenBalance * lpAmount / totalSupply;
7 tokens[i].transfer(msg.sender, amountOut);
8 }
9
10 lpToken.burn(msg.sender, lpAmount);
11}

Security Considerations

Rounding direction: Must round down (favor pool) to prevent extraction.

Order of operations: LP tokens should be burned before or atomically with transfers.

Reentrancy: External token transfers can trigger callbacks.

Balance manipulation: Donated tokens shouldn't inflate exit amounts.

When to Use Proportional Exit

Recommended when:

  • Withdrawing full position
  • Wanting to avoid swap fees
  • Pool is imbalanced (single-asset would incur high slippage)

Not ideal when:

  • Need only one specific token
  • Rebalancing to a different allocation

Proportional exits are the "safest" exit mechanism from a pricing perspective, as they don't change the pool's ratio and have no price impact.

Need expert guidance on Proportional 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