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
  • Numerical Methods
  • Our Numerical Method
  • How to avoid high gas costs

Was this helpful?

  1. Options AMM
  2. Options AMM

Find The Next IV

This section explains how the protocol implemented a numeric method to find the next IV considering a new pool imbalance.

PreviousPricingNextFees

Last updated 4 years ago

Was this helpful?

Numerical Methods

As you read in the Pricing section, the AMM uses an algorithm to update the options price based on factors such as the spot price of the underlying asset, time to maturity, and implied volatility. This section explains how to programmatically estimate the implied volatility based on the new pool position considering the trade that will happen.

The new sigma is how we refer to implied volatility, and the system calculates it based on the new option target price (which is the new "equilibrium BlackScholes price") for the pool.

The algorithm uses a numerical method to do that.

Numerical methods are mathematical ways to solve particular problems. They allow us to approximately solve math problems, specifically ones we can not solve analytically (or at least not quickly).

In our case, the Black Scholes formula is one example of an equation that can be analytically solved when calculating the option price. Still, it is tough when you already have the option price (in this case, "the equilibrium price of the pool") and want to find one of the variables missing that resulted in this price. In this case, the missing variable at that point is the new sigma (IV).

Our Numerical Method

In our case, the numeric method used is proposed by Yan Wang in his paper called .

For those familiar with search algorithms, this method resembles a , where you should first define upper and bottom boundaries. After that, your next guess will be somewhere between those boundaries. If you have not found the target result inside this loop, the result found becomes one of the boundaries, and then we repeat the process.

Find below the steps the algorithm takes to find the new sigma applying Yan Wang numeric method.

a) Defining the boundaries

We need to define the upper and bottom boundaries for the sigmaσ\sigmaσand its respective option price. We call these variables σhigher\sigma_{higher}σhigher​, σlower\sigma_{lower}σlower​, pricehigherprice_{higher}pricehigher​and pricelowerprice_{lower}pricelower​.

There is no magic trick to define the initial boundaries. You can guess a very high sigma, calculate the Black Scholes equation using this sigma, and then check if the price is higher than the new target price. If the price you found is higher than the target price, this price became your initial upper boundary. To find the bottom boundary, repeat the same process with a very low sigma.

b) Find the next sigma

To find the following result of this loop we use the following equation:

σnext=σlower+(pricetarget−pricelower)∗(σhigher−σlower)pricehigher−pricelower\displaystyle \sigma_{next}=\sigma_{lower}+\frac{(price_{target}-price_{lower}) *(\sigma_{higher} - \sigma_{lower} )}{price_{higher}-price_{lower}}σnext​=σlower​+pricehigher​−pricelower​(pricetarget​−pricelower​)∗(σhigher​−σlower​)​

c) Run Black Scholes and compare results

Now that we have found our nextSigma σnext\sigma_{next}σnext​, we can re-calculate the Black Scholes and check if the calculated price is equal enough to the target price. In our case, we define that we accept 1% difference tolerance. This means that if the calculated price matches the target price within a 1% range, we accept them as "equal."

d) Repeat if needed

Suppose the calculated price differs more than 1% compared to the target price. We need to repeat the process, redefining the new boundaries. That is relatively straightforward. If the calculated price is below the target price, then the calculated price (and the respective sigma) became the lower boundary. If not, the calculated price became the upper boundary.

How to avoid high gas costs

In environments such as Ethereum, you need to aim for efficient algorithms, otherwise, you will end up paying a lot to run a transaction.

We work around this problem by running the sigmaInitialGuess contract before executing the transaction. You can perform a call() method with the trade that you want to execute.

Since call()methods are free, we run this numeric method and return thenextIVto the caller. Then, when he does the actual trade, he can pass thesigmaInitialGuessas a parameter that will be used as one of the initial boundaries or even be the right answer before even running this process.

A Well-Posed Algorithm to Recover Implied Volatility
Binary Search
In the SigmaGuesser contract, you can find this equation