Pods Options
app.pods.financeGithubBlogDiscord
  • Getting Started
  • Understand Options
    • What are options?
    • How do options work?
    • Pricing Options
  • The Protocol
    • Overview
    • Safety Measures
    • Ecosystem Participants
    • Use Cases
  • Options
    • Overview
    • Options Instrument
      • Variables
      • Functions
        • Mint
        • Unmint
        • Withdraw
        • Exercise
    • Smart Contracts
      • OptionFactory
      • PodPut
      • WPodPut
      • PodCall
      • WPodCall
    • Applied Use Cases
    • Understanding Returns
  • Options AMM
    • Overview
    • Options AMM
      • Variables
      • Components
      • Functions
        • Add Liquidity
        • Re-add Liquidity
        • Trade
        • Remove Liquidity
      • Pricing
      • Find The Next IV
      • Fees
      • Scenarios
        • LP Simulations
    • Smart Contracts
      • OptionAMMPool
      • OptionAMMFactory
      • OptionPoolRegistry
    • Applied Math
  • Developers
    • System Overview
    • Deployed Contracts
    • Dev Environment
  • Interfacing with Pods
    • Brand Assets
  • Code Integration Guides
    • Integrating with Pods (video)
    • How To Create Your Own Option
    • How To Create Your Own Pool
    • How To Trade (Buy/Sell)
    • How To Exercise
    • How To Remove Liquidity
  • User Guides
    • Videos
  • Security
    • Audits
  • APPENDIX
    • FAQ
    • Glossary of Terms
  • Additional Resources
  • app.pods.finance
  • Github
  • Blog
  • Discord
  • Twitter
  • Pods v0 Docs
Powered by GitBook
On this page

Was this helpful?

  1. Code Integration Guides

How To Remove Liquidity

PreviousHow To ExerciseNextVideos

Last updated 4 years ago

Was this helpful?

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,

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

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

check this section.