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
  • 1. Calculate factors
  • 1.1 Calculate Option Price
  • 1.2 Calculate the Pool's Value Factor ()
  • 1.3 Calculate multipliers
  • 1.4 Calculate withdrawal amount of each token
  • 1.5 Update new user balance for each token
  • 1.6 Update new deamortized balance for each token
  • 1.7 Update new pool balance for each token

Was this helpful?

  1. Options AMM
  2. Options AMM
  3. Functions

Remove Liquidity

Calculating what proportion of each token users are eligible to withdraw based on the liquidity they provided initially.

PreviousTradeNextPricing

Last updated 3 years ago

Was this helpful?

Disclaimer: with the current UI, users can only provide or remove liquidity equally on both sides

Single-sided liquidity provision Quick recap: it is possible to add liquidity on one side of the pool. The pool will track the user's initial exposure, and by the time the user removes liquidity, the withdrawal position will reflect the initial exposure within a new distribution of assets. It means that it is possible (and likely) to withdraw percentages of both assets. The remove liquidity function allows users to choose what percentage of the amount provided they wish to withdraw at a given instant iii . The only user who can remove liquidity is a user who provided liquidity before and still has funds in the pool. rrr is the proportion of the user's initial deposit that it wishes to withdraw now. Removing "1" corresponds to remove 100% of the funds previously added.

rA≤1r_A≤1rA​≤1 and rB≤1r_B≤ 1rB​≤1

The event of removing liquidity requires the following information: 1. rAr_ArA​Proportion of initial exposure of token A that wants to withdraw. 2. rBr_BrB​ Proportion of initial exposure of token B that wants to withdraw.

1. Calculate factors

1.1 Calculate Option Price

For simplicity, let's acknowledge that the option price is a function that required a MarketDataMarketDataMarketData and an internal vector (IVIVIV) as input.

Pi=fp(IVi−1,MarketDatai)P_i=f_p(IV_{i-1},MarketData_i)Pi​=fp​(IVi−1​,MarketDatai​)

For more details about the pricing formula and its contract implementation, check .

1.2 Calculate the Pool's Value Factor (FviF_{v_i}Fvi​​)

Fvi=TBAi−1⋅Pi+TBBi−1DBAi−1⋅Pi+DBBi−1\displaystyle Fv_i= \frac{TB_{A_{i-1}}\cdot P_i+TB_{B_{i-1}}}{DB_{A_{i-1}} \cdot P_i+DB_{B_{i-1}}}Fvi​=DBAi−1​​⋅Pi​+DBBi−1​​TBAi−1​​⋅Pi​+TBBi−1​​​

The pool's opening factor works as a factor that will update the pool's amortization as time passes.

1.3 Calculate multipliers

The redemption multipliers are defined as:

mAAi=min(Fvi⋅DBAi−1;TBAi−1)DBAi−1\displaystyle mAA_i= \frac{min(Fv_i\cdot DB_{A_{i-1}};TB_{A_{i-1}})}{DB_{A_{i-1}}}mAAi​=DBAi−1​​min(Fvi​⋅DBAi−1​​;TBAi−1​​)​

mBBi=min(Fvi⋅DBBi−1;TBBi−1)DBBi−1\displaystyle mBB_i= \frac{min(Fv_i\cdot DB_{B_{i-1}};TB_{B_{i-1}})}{DB_{B_{i-1}}}mBBi​=DBBi−1​​min(Fvi​⋅DBBi−1​​;TBBi−1​​)​

mABi=TBBi−1−mBBi⋅DBBi−1DBAi−1\displaystyle mAB_i= \frac{TB_{B_{i-1}}-mBB_i\cdot DB_{B_{i-1}}}{DB_{A_{i-1}}}mABi​=DBAi−1​​TBBi−1​​−mBBi​⋅DBBi−1​​​

mBAi=TBAi−1−mAAi⋅DBAi−1DBBi−1\displaystyle mBA_i= \frac{TB_{A_{i-1}}-mAA_i\cdot DB_{A_{i-1}}}{DB_{B_{i-1}}}mBAi​=DBBi−1​​TBAi−1​​−mAAi​⋅DBAi−1​​​

1.4 Calculate withdrawal amount of each token

Ai=−[mAAi⋅rA⋅UBAuFvdu+mBAi⋅rB⋅UBBuFvdu]\displaystyle A_i=-[mAA_i\cdot r_A\cdot \frac{UB_{A_{u}}}{F_{v_{du}}}+mBA_i\cdot r_B\cdot \frac {UB_{B_{u}}}{F_{v_{du}}}]Ai​=−[mAAi​⋅rA​⋅Fvdu​​UBAu​​​+mBAi​⋅rB​⋅Fvdu​​UBBu​​​]

Bi=−[mBBi⋅rB⋅UBBuFvdu+mABi⋅rA⋅UBAuFvdu]\displaystyle B_i=-[mBB_i\cdot r_B\cdot \frac{UB_{B_{u}}}{F_{v_{du}}} + mAB_i \cdot r_A\cdot \frac {UB_{A_{u}}}{F_{v_{du}}}] Bi​=−[mBBi​⋅rB​⋅Fvdu​​UBBu​​​+mABi​⋅rA​⋅Fvdu​​UBAu​​​]

1.5 Update new user balance for each token

After the withdraw, the contract calculates the updated user balance for each token.

UBAu=UBAui−1⋅(1−rA)UB_{A_u}=UB_{A_{u_{i-1}}}\cdot (1-r_A)UBAu​​=UBAui−1​​​⋅(1−rA​)

UBBu=UBBui−1⋅(1−rB)UB_{B_u}=UB_{B_{u_{i-1}}}\cdot (1-r_B)UBBu​​=UBBui−1​​​⋅(1−rB​)

1.6 Update new deamortized balance for each token

DBAi=DBAi−1−rA⋅UBAui−1Fvdu\displaystyle DB_{A_i}=DB_{A_{i-1}}-r_A\cdot \frac{UB_{A_{u_{i-1}}}}{F_{v_{du}}}DBAi​​=DBAi−1​​−rA​⋅Fvdu​​UBAui−1​​​​

DBBi=DBBi−1−rB⋅UBBui−1Fvdu\displaystyle DB_{B_i}=DB_{B_{i-1}}-r_B\cdot \frac{UB_{B_{u_{i-1}}}}{F_{v_{du}}}DBBi​​=DBBi−1​​−rB​⋅Fvdu​​UBBui−1​​​​

1.7 Update new pool balance for each token

The contract will calculate the new total balance for each token considering the recent withdrawal.

TBAi=TBAi−1+AiTB_{A_{i}}=TB_{A_{i-1}}+A_iTBAi​​=TBAi−1​​+Ai​

TBBi=TBBi−1+BiTB_{B_i}=TB_{B_{i-1}}+B_iTBBi​​=TBBi−1​​+Bi​

At the contract level, an ERC20 transfer is happening. Total balance (TB) is just a mathematical representation. The Total balance is checked by consulting the balanceOf() of the pool contract of the respective token (tokenA or tokenB)

Remove Liquidity ✅

this section
ABPrice variable on _addLiquidity at AMM.sol
getting multiplier struct on _removeLiquidity at AMM.sol
function _getMultiplers responsible for
on _removeLiquidity at AMM.sol
on _removeLiquidity at AMM.sol
on _removeLiquidity at AMM.sol
on _removeLiquidity at AMM.sol