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
  • Withdraw
  • 1) Consult Balances
  • 1.1) Consult Current
  • 1.2) Consult Current
  • 2.1) Calculate
  • 2.2) Calculate
  • 3) Updates
  • 3.1) Update
  • 3.2) Update
  • 3.3) Update
  • 3.4) Update

Was this helpful?

  1. Options
  2. Options Instrument
  3. Functions

Withdraw

Same process as unmint, but considering 100% of the funds and after exercise window.

PreviousUnmintNextExercise

Last updated 4 years ago

Was this helpful?

Withdraw

The event of withdrawing funds from expired options doesn't require any parameters. It will unlock 100% of the seller's funds, which may be composed of a combination of strike assets and the underlying asset, depending on how many options were exercised.

There is no race condition on withdrawing funds. That means that it does not matter the order/moment you withdraw. The assets will be distributed evenly and proportionally between the owners.

The withdrawal function will perform the following actions after expiration.

1) Consult Balances

1.1) Consult Current StrikeReservesnStrikeReserves_nStrikeReservesn​

This step will fit its purpose better in a put option where the collateral is in strike asset.

This balance should reflect the new current StrikeReservesStrikeReservesStrikeReserves, considering the interest that accrued in the meanwhile.

1.2) Consult Current UnderlyingReservesnUnderlyingReserves_nUnderlyingReservesn​

UnderlyingReservesnUnderlyingReserves_nUnderlyingReservesn​ is a variable where we store the total amount of underlying assets currently locked in the protocol. This function has a precise fit with call options since, in call options, the underlying asset is the asset locked as collateral.

2.1) Calculate StrikeToSendStrikeToSendStrikeToSend

This step calculates the amount of strike asset an owner needs to receive for this withdrawal process.

StrikeToSend=OwnerSharest⋅StrikeReservesnTotalSharesi−1\displaystyle StrikeToSend=\frac{OwnerShares_t\cdot StrikeReserves_n}{TotalShares_{i-1}}StrikeToSend=TotalSharesi−1​OwnerSharest​⋅StrikeReservesn​​

2.2) Calculate UnderlyingToSendUnderlyingToSendUnderlyingToSend

This step calculates the amount of underlying asset an owner needs to receive to complete the withdrawal.

3) Updates

Notice that the negative sign here is different from the pure mint function since it removed funds and, therefore, removed the weighted impact.

This factor updates the current total amount of owner shares. This factor will store that the funds were withdrawn from the contract by setting it to zero.

This session described mathematically how the contract logic works. It is not needed to update the total ERC20 balances at the code level since tokens transfer to or from the contract is automatically updated with the ERC20 implementation.

This session described mathematically how the contract logic works. It is not needed to update the total ERC20 balances at the code level since tokens transfer to or from the contract is automatically updated with the ERC20 implementation.

Withdraw options ✅

UnderlyingToSend=OwnerSharest⋅UnderlyingReservesnTotalSharesi−1\displaystyle UnderlyingToSend=\frac{OwnerShares_t\cdot UnderlyingReserves_n}{TotalShares_{i-1}}UnderlyingToSend=TotalSharesi−1​OwnerSharest​⋅UnderlyingReservesn​​

3.1) Update TotalSharesiTotalShares_iTotalSharesi​

TotalSharesiTotalShares_iTotalSharesi​ is the sum of all the owner's shares.

TotalSharesi=TotalSharesi−1−OwnerSharestTotalShares_i = TotalShares_{i-1} -OwnerShares_tTotalSharesi​=TotalSharesi−1​−OwnerSharest​

3.2) Update OwnerSharestOwnerShares_tOwnerSharest​

OwnerSharest=0OwnerShares_t=0OwnerSharest​=0

3.3) Update strikeReservesistrikeReserves_istrikeReservesi​

Using StrikeReservesnStrikeReserves_nStrikeReservesn​ (accrued with interest from the last period), we'll deduct the amount of StrikeToSendStrikeToSendStrikeToSendused while minting this option.

StrikeReservesi=StrikeReservesn−StrikeToSendStrikeReserves_i=StrikeReserves_n-StrikeToSendStrikeReservesi​=StrikeReservesn​−StrikeToSend

3.4) Update UnderlyingReservesiUnderlyingReserves_iUnderlyingReservesi​

Using UnderlyingReservesnUnderlyingReserves_nUnderlyingReservesn​ (accrued with interest from the last period), we'll deduct the amount of UnderlyingToSendUnderlyingToSendUnderlyingToSend used while minting this option.

UnderlyingReservesi=UnderlyingReservesn−UnderlyingToSendUnderlyingReserves_i=UnderlyingReserves_n-UnderlyingToSendUnderlyingReservesi​=UnderlyingReservesn​−UnderlyingToSend