Black-Scholes Model
Option pricing algorithm and Greeks formulas
Diffusal uses the Black-Scholes model for European option pricing. This page covers the mathematical formulas and Greeks calculations.
For implementation details including fixed-point arithmetic and Solidity code, see Solidity Math.
The Black-Scholes Formula
Call Option
Put Option
d1 and d2
Where:
- S = Spot price (current underlying price)
- K = Strike price
- r = Risk-free interest rate
- σ (sigma) = Volatility (annualized)
- T = Time to expiry (in years)
- N(x) = Cumulative normal distribution function
Parameters
| Symbol | Name | Source | Format |
|---|---|---|---|
| S | Spot Price | Price Oracle (Pyth) | 8 decimals |
| K | Strike Price | User input | WAD (1e18) |
| r | Risk-free Rate | DiffusalOracle | 8 decimals |
| σ | Volatility | DiffusalOracle | 8 decimals |
| T | Time to Expiry | Calculated | WAD (years) |
Greeks
The implementation calculates all primary Greeks alongside the option price.
Delta (Δ)
Rate of change of option price with respect to underlying price.
Range: Calls: 0 to 1, Puts: -1 to 0
Gamma (Γ)
Rate of change of Delta with respect to underlying price.
Same for both calls and puts. Always positive.
Vega (ν)
Sensitivity to volatility changes.
Same for both calls and puts. Always positive.
Theta (Θ)
Time decay - rate of change with respect to time.
Usually negative (options lose value over time).
Rho (ρ)
Sensitivity to interest rate changes.
Example Calculation
Inputs:
- Spot (S): $3,000
- Strike (K): $3,000
- Rate (r): 5%
- Volatility (σ): 50%
- Time (T): 30 days = 0.0822 years
Calculation:
To get this quote on-chain, call quoter.getOptionQuote() with an OptionRequest containing the pairId, strike (3000e18), expiry (30 days from now), and isCall = true. The returned quote price will be approximately 176.7e18.
Limitations
European Options Only
The Black-Scholes model assumes:
- No early exercise (European style)
- Constant volatility
- Log-normal price distribution
- No dividends
Edge Cases
| Condition | Behavior |
|---|---|
| T = 0 (at expiry) | Reverts with OptionExpired |
| σ = 0 (no volatility) | May cause division by zero |
| S or K = 0 | Undefined behavior |
| Very long expiry | May overflow in time calculation |
Implementation
The Black-Scholes model is implemented in Solidity using 64.64 fixed-point arithmetic for precision:
| Library | Purpose |
|---|---|
| BlackScholesLib | Core pricing in 64.64 format |
| BlackScholesWad | WAD adapter for external interface |
| Math64x64Extended | normalCdf approximation (Abramowitz-Stegun) |
The quoter contract provides the public API:
- DiffusalOptionsQuoter —
getOptionQuote()andgetOptionQuoteWithGreeks()
Related
- Solidity Math — Fixed-point arithmetic and precision handling
- Margin System — How option prices affect margin requirements
- DiffusalOracle — Source of volatility and risk-free rate