🔬
InterSwap Docs
  • Welcome
  • Protocol Level
    • Liquidity Pools
      • Weighted Pools
      • Stable Pools
      • Dynamic Weights
      • Gas Tokens Index(GTI)
    • Add/Remove Liquidity
      • New Pool Creation
      • Add Liquidity
      • Remove Liquidity
    • Swap
  • Integration Level
    • You Integrate us
    • We Integrate you
    • Cross-Chain Smart Routing
  • Supported networks
  • How To
    • Setting Up a Wallet
      • Creating a New Wallet
      • Adding Networks to Metamask
      • Connecting Your Wallet
    • Swap
    • Add Liquidity
    • Remove Liquidity
  • Security
    • Audits
    • Bug Bounty
    • Deployed Contracts
  • TOKENOMICS & GOVERNANCE
    • Allocation & Lockups
    • Token Value Accrual
    • Fees
    • Governance Model
    • Proposals & Voting
  • Information
    • FAQ
Powered by GitBook
On this page
  1. Protocol Level
  2. Add/Remove Liquidity

Remove Liquidity

PreviousAdd LiquidityNextSwap

Last updated 2 years ago

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

Asset
Weight Points
Share

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:

{    
    uint8 method, // REMOVE_LIQUIDITY_TYPE = 3
    uint256 poolId, // id of the pool, genesis pool = 0
    address token, // token to receive in exchange for LP
    uint256 amount, // amount of token
    address from, // msg.sender
    address to, // address of receiver, token will be sended who
    bytes memory data // arbitrary data for post-action integrations
}

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:

Asset
Weight Points
Share

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

Gas Token Index Pool
Dynamic Weights