commit
function is called, which uses the Uniswap v3 TWAP feature to get the TWAP for the time period. This TWAP is added to the contract, which is then used to calculate the period's return and the pool's price volatility.function vol(address pool) public returns (uint256 stdev)
vol
function returns the volatility of a Uniswap pool for a 12-hour time period. Volatility is defined as the standard deviation of logarithmic returns.function annualizedVol(address pool) public returns (uint256 stdev)
annualizedVol
function annualizes the output from vol
and returns what is typically used as a Historical Volatility number in options exchanges.function getPremium(uint strike, uint expiryTimestamp, bool isPut) public returns (uint256 premium)
getPremium
function takes in the option's terms such as strike price, expiry and option type to determine the pricing of the option using the Black-Scholes model. Internally, it retrieves the spot price of the underlying asset from ChainLink and the annualized volatility from the VolOracle as additional inputs for Black-Scholes.strike
parameter is in the unit of 10**8
, so the strike price of $3000 is 3000 * 10**8
. The premium is in the unit of 10**18
.function getOptionDelta(uint strike, uint expiryTimestamp) public returns (uint256 delta)
getOptionDelta
function takes in the option's terms such as strike price and expiry to calculate the option's Greek delta value. The delta
value is in the unit of 10**5
.