How To Remove Liquidity
Example 1 - Full Liquidity Remove
// Instantiate OptionAMMPool
OptionAMMPool optionAMMPool = optionAMMPool("/*address*/");
uint256 percentA = 100 // if you want to remove 100%
uint256 percentB = 100 // if you want to remove 100%
// You can check with getRemoveLiquidityAmounts to estimate the amount of assets you will remove
(uint256 withdrawAmountA, uint256 withdrawAmountB) = optionAMMPool.getRemoveLiquidityAmounts(percentA, percentB);
optionAMMPool.removeLiquidity(percentA, percentB);
// Parameters example
const owner = '0x3ab...';
const optionAMMPoolAddress = '0x3c...'
/////////////
// Web3.js
// Instantiate contract
const optionAMMPool = await web3.eth.Contract('Contract ABI', optionAMMPoolAddress)
const [withdrawAmountOptions, withdrawTokenB] = await optionAMMPool.methods.getRemoveLiquidityAmounts(percentA, percentB).call()
await optionAMMPool.methods.removeLiquidity(percentA, percentB).send({})
/////////////
// Ethers.js
// Instantiate contract
const optionAMMPool = await ethers.getContractAt(optionAMMPoolAddress, 'Contract ABI')
const [withdrawAmountOptions, withdrawTokenB] = await optionAMMPool.getRemoveLiquidityAmounts(percentA, percentB)
await optionAMMPool.removeLiquidity(percentA, percentB)Last updated