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
  • Black Scholes
  • Assumptions
  • Original Formula
  • Parameters
  • Initial IV
  • Internal Oracle for Implied Volatility
  • AMM's Price Discovery
  • Logic Overview
  • Detailed Pricing
  • 1. Checks
  • 2. Calculating Black Scholes Theoretical price
  • 3. Applying trade amount to constant product
  • 4. Calculate new virtual price
  • 5. Guess the new IV () and store it in the contract for the next trade
  • Pricing Flow

Was this helpful?

  1. Options AMM
  2. Options AMM

Pricing

Pods Options AMM implements Black Scholes to price the options algorithmically.

PreviousRemove LiquidityNextFind The Next IV

Last updated 3 years ago

Was this helpful?

Black Scholes

There are multiple models for options pricing. The most widely used model is called . It calculates European options' theoretical value using the current underlying asset price, option's strike price, expected risk-free interest rate, time to expiration, and expected volatility.

Although the Options Instrument allows American options series to be created, it is not recommended to implement them using the AMM current pricing model. Bear in mind that the options are represented in ERC20 tokens and can be sold anywhere (not necessarily in the options AMM) so one can still put together an American option and use it elsewhere.

Assumptions

The AMM's implementation of the model makes certain assumptions:

  • European Options (exercised only during the expiration window)

  • No dividends are paid out during the option lifetime

  • Markets are efficient (moves cannot be predicted, and arbitrage opportunities will be taken instantly)

  • The risk-free rate is accounted as 0% at this point

  • Changes in supply and demand for tokens reflected in the pool are expressed as changes to the implied volatility in the model for future pricing.

An option price translates the exercise's possibility based on probability and market sentiment towards the amplitude of change the underlying asset can have. The model describes what should be the correct price of an option today that expresses the correct probability of this event happening in the future so that, if the option is correctly price, there is no space for arbitrage.

The model assumes the underlying asset follows a distribution since asset prices cannot be negative (they are bounded by zero). The lognormal distribution is asymmetrical and creates a right-skewed curve. The represents the degree of distortion from the symmetrical bell curve in a probability distribution. Data on both sides of the skew are also referred to as "tail."

The Black Scholes model allows for discovering a new price based on current and past values.

Original Formula

The put option pricing formula is calculated as follows:

ccc = Call option price

ppp = Put option price

SSS= Current Underlying Asset Spot Price

KKK = Option's Strike price

rrr = Risk-Free Rate

ttt = Time to Maturity

NNN = A normal distribution

Parameters

Initial IV

To create a pool, the creator has to define the initial price of the pool. The user is also defining the implied volatility of the pool opening moment (IViIV_iIVi​).

One could think of the IV as a factor that is guessed by the contract to fulfill the following:

Applying the implemented formula, what IV generates this option price (the initial price defined by the option creator), considering the current market conditions?

The contracts accept the first IV that generates a price range of {-0.1;+0.1} to avoid infinite calculations.

Once this initial IV is guessed, the contract will store this as the pool's initial level in terms of supply and demand.

Internal Oracle for Implied Volatility

The creator of the option also defines the internal IV oracle. At this point, this is a stable (and updatable) number that will be used to smooth the IV fluctuations with trading activity and provide a more accurate price for users.

The oracle will feed the calculation of a Weighted Average IV, together with the IV generated by the trading activity according to the formula:

WeightedIV=(3∗oracleIV+IVi)4\displaystyle WeightedIV=\frac{(3*oracleIV + IV_i)}{4}WeightedIV=4(3∗oracleIV+IVi​)​

AMM's Price Discovery

Logic Overview

The trading activity major outputs for the AMM are the pool imbalance and the new price. As we mentioned before, options prices rely on many factors and the premium alone is not representative from one period to the other. The important information on an options trading activity is the resulting implied volatility.

If traders sell a significant amount of options at a certain level this translates into a decrease in the volatility for that option series. The opposite is also true. If traders buy a significant amount of options for a specific option series the implied volatility will rise.

Whenever a trade is initiated, Pods AMM will calculate the current theoretical Black Scholes price considering the updated external information (like spot price and time to maturity) and use this information to quote the total cost of the operation. After quoting the total cost of the operation, the AMM has a new pool condition, an imbalance. This translates into a "new virtual unit price". According to Black Scholes, this virtual price has a corresponding implied volatility. Then, Pods AMM will find and store that implied volatility so it can pass this market information along to the next period.

Detailed Pricing

Within a trade, the price update has five phases: 1. Checks 2. Calculating the theoretical Black Scholes price, 3. Calculating the total cost of the trade, considering a product constant formula, 4. Calculating the new virtual price in the AMM right after the trade, 5. Guessing the implied volatility that corresponds to the new virtual price.

1. Checks

In a given instant iii a trade can be initiated, the contract will check the following parameters to proceed:

  • Trade direction (from token A to token B or the opposite)

  • How many tokens A will deliver (or how many tokens B wants to receive) exactAInput exactBoutput

  • What total slippage accepted

  • Owner

2. Calculating Black Scholes Theoretical price

a) Update underlying asset spot price

We're leveraging Chainlink to update the underlying asset spot price.

b) Calculate new time to maturity

The contract will calculate how long it will take until the expiration date.

c) Check latest IV (IVi−1IV_{i-1}IVi−1​) or Updated Weighted Average IV

The previous (or initial) calculated price saved an IViIV_iIVi​ factor of that time. This IV factor now is IVi−1IV_{i-1}IVi−1​since a period has passed. This IV will be used in the Weighted Average IV calculation and the result of the weighted average will calculate the new option theoretical Black Scholes price.

d) Input strike price

Check the options parameter and use it as an input.

e) Input risk-free rate

As mentioned above, the risk-free rate is fixed at 0% at this point.

The contract will gather this information to feed the Black Scholes contract. This will result in a theoretical Blach Scholes price for the option at that time.

The next steps will apply the theoretical Black Scholes price (also referred to as ABprice in the contracts) to the pool conditions to quote the trade cost.

3. Applying trade amount to constant product

Calculate the total cost for the trade considering the theoretical Black Scholes price.

a) Calculate pool amounts for each token:

poolAmountA=min⁡{TBA;TBBPi}\displaystyle poolAmountA = \min\left\{TB_{A};\frac{TB_{B}}{P_i}\right\}poolAmountA=min{TBA​;Pi​TBB​​}

poolAmountB=min⁡{TBB;TBA⋅Pi}\displaystyle poolAmountB = \min\left\{TB_{B};{TB_{A}}\cdot {P_i}\right\}poolAmountB=min{TBB​;TBA​⋅Pi​}

b) Calculate product constant

k=poolAmountA∗poolAmountBk=poolAmountA*poolAmountBk=poolAmountA∗poolAmountB

c) Calculate total transaction price, in terms of B

Bi=k(poolAmountA−tradeAmountA)−poolAmountB\displaystyle B_i=\frac{k}{(poolAmountA-tradeAmountA)}-poolAmountBBi​=(poolAmountA−tradeAmountA)k​−poolAmountB

4. Calculate new virtual price

Calculating the new virtual price (aka target price) based on the inventory imbalance after the trade.

TargetPricei=poolAmountB−BipoolAmountA+Ai\displaystyle TargetPrice_i=\frac{poolAmountB-B_i}{poolAmountA+A_i}TargetPricei​=poolAmountA+Ai​poolAmountB−Bi​​

The target price will be the input for the IVGuesser contract.

Note that on the contract level, for each of our 4 trade functions (exactAInput / exactAOutput / exactBInput / exactBOutput) the functions above are slightly different.

5. Guess the new IV (IViIV_iIVi​) and store it in the contract for the next trade

At this point, the pool's inventory changed, and it represents a new "virtual price." The IV corresponding to this new virtual price reflects market information of supply and demand for this option.

The IV found will be stored in the contracts to later feed the Weighted Average with 25% weight.

Pricing Flow

See below a diagram that explains the pricing flow when there is a trade happening.

The factor discounts the strike price to present value at a risk-free rate. In our implementation, the risk-free rate is 0%, and for this reason the factor er=1e^r=1er=1. This means that we are not impacting the time value of the money into the strike price. The understanding that drives this decision is that there is no consensus on a risk-free rate for DeFi at this point.

The factor calculates the probability that the underlying asset will be at or above the strike price by expiration.

The factor calculates the future underlying asset price if the asset is above the strike by expiration.

So the AMM will input the new target price in the Black Scholes formula and find the new correspondent IV for this price. It uses a specific numerical method applied to Black Scholes. If you want to deep dive into how it works, explore

Black Scholes
lognormal
skewness
Find next IV.
2MB
Pricing flow.pdf
pdf
Pricing flow in PDF
_getPoolAmounts at OptionAMMPool.sol
Pricing flow during trades.