Remove Liquidity
Last updated
Last updated
Remove liquidity is occurs in one asset. Let's have an example of (all native assets of each supported chain) with the following weights:
BNB
1000
0,1428 %
AVAX
1000
0,1428 %
ETH
1000
0,1428 %
MATIC
1000
0,1428 %
FTM
1000
0,1428 %
ETH (arbitrum)
1000
0,1428 %
ETH (optimism)
1000
0,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 MasterCommunicator.sol on Avalanche network (considering as masterchain)
2. MasterCommunicator.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 - Burns LP's. - Calculate the amount of token to be withdrawn.
3. MasterCommunicator.sol sends a LayerZero message to ChildCommunicator.sol on Ethereum network with the following payload:
4. ChildCommunicator.sol receives a message, calls a Lock.sol by the address (the Lock.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:
BNB
1000
0,1438 %
AVAX
1000
0,1438 %
ETH
950
0,1366 %
MATIC
1000
0,1438 %
FTM
1000
0,1438 %
ETH (arbitrum)
1000
0,1438 %
ETH (optimism)
1000
0,1438 %
Total Weight = 6950