MCDEX
Search…
Removing Liquidity
This guide shows how to remove liquidity into pool by using the ILiquidityPoolFull interface.

Remove Liquidity

Function

removeLiquidity(int256 shareToRemove, int256 cashToReturn)
parameters
type
description
shareToRemove
int256
amount of share token to remove. The amount always use decimals 18.
cashToReturn
int256
amount of cash(collateral) to return. The amount always use decimals 18.
Notice
  • Remove liquidity from the liquidity pool.
  • Liquidity providers redeems share token then gets collateral back.
  • The amount of collateral retrieved may differ from the amount when adding liquidity, The index price, trading fee and positions holding by amm will affect the profitability of providers.
  • Can only be called when the pool is running.

Example

1
ILiquidityPoolFull liquidityPool = ILiquidityPoolFull(liquidityPoolAddress)
2
// Only assign one of shareToRemove or cashToReturn, like shareToRemove = toWei(10), cashToReturn = 0
3
liquidityPool.removeLiquidity(shareToRemove, cashToReturn)
Copied!

Sample Code

Github
Last modified 14d ago