How To Remove Liquidity

In order to remove liquidity, you will need to pass as inputs to the contract the percentage of the exposition on the options side and the token side you want to withdraw.

But how are you going to know how much real assets you will get in exchange for that initial exposure? First of all, you can call the function getRemoveLiquidityAmounts passing the same percentages. This function will return the withdrawal amounts of options and tokens. If you want to understand deeper the topic about exposure and position, check this section.

Keep in mind that the withdrawal amounts between calling the getRemoveLiquidityAmounts and removeLiquiditymay change due to market changes.

Example 1 - Full Liquidity Remove

Imagine you have added some amount of liquidity of options and some liquidity of tokenB. Now you want to remove 100% of your exposition of both tokens. The steps you should do are:

1) Call getRemoveLiquidityAmounts first in order to estimate the withdrawal amounts 2) Call removeLiquidty on OptionAMMPoolwith the percents that you want to remove your exposition.

// 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);

    

Last updated