Skip to main content

Remove Liquidity

Remove liquidity is occurs in one asset. Let's have an example of Gas Token Index Pool (all native assets of each supported chain) with the following weights:

AssetWeight PointsShare
BNB10000,1428 %
AVAX10000,1428 %
ETH10000,1428 %
MATIC10000,1428 %
FTM10000,1428 %
ETH (arbitrum)10000,1428 %
ETH (optimism)10000,1428 %

Total Weight = 1000 * 7 = 7000

When Liquidity Provider wants to redeem his LPs for some token - you need to choose one of the asset to be used for redeem. Let's choose ETH once again.

  1. Liquidity Provider calls removeLiquidity() method on MasterRouter.sol on Avalanche network (considering as masterchain)

  2. MasterRouter.sol finds InterswapPool.sol by poolID using Factory.sol:

  • Reduces reserves of ETH in the pool state.
  • Reduces the weight of the ETH in the pool using formula in Dynamic Weights
  • Burns LP's.
  • Calculate the amount of token to be withdrawn
  1. MasterRouter.sol sends an Axelar message to ChildRouter.sol on Ethereum network with the following payload:
{
address pool,
uint256 lpAmount,
bytes[] calldata tokens,
string[] calldata chains,
bytes[] calldata receivers,
uint256[] calldata removeLiquidityFees ,
}
  1. ChildRouter.sol receives a message, calls a InterswapLock.sol by the address (the InterswapLock.sol address is determined by the poolID). And it unlocks ETH to receiver.

Let's take that ETH weight was decreased for 50 points. After removing liquidity we can see such a picture of pool structure:

AssetWeight PointsShare
BNB10000,1438 %
AVAX10000,1438 %
ETH9500,1366 %
MATIC10000,1438 %
FTM10000,1438 %
ETH (arbitrum)10000,1438 %
ETH (optimism)10000,1438 %

Total Weight = 6950