VolatilityOracle

Git Source

Inherits: IVolatilityOracle, ReentrancyGuard, RelayerAccessManager

State Variables

DECIMALS

uint256 private constant DECIMALS = 12;

Functions

formatParams

Pack IV model parameters into a single bytes32

This function is used to pack the parameters into a single variable, which is then used as input in update

function formatParams(int256[5] calldata params) external pure returns (bytes32 result);

Parameters

NameTypeDescription
paramsint256[5]Parameters of IV model to pack

Returns

NameTypeDescription
resultbytes32The packed parameters of IV model

parseParams

Unpack IV model parameters from a bytes32

function parseParams(bytes32 input) external pure returns (int256[5] memory params);

Parameters

NameTypeDescription
inputbytes32Packed IV model parameters to unpack

Returns

NameTypeDescription
paramsint256[5]The unpacked parameters of the IV model

updateParams

Update a list of Anchored eSSVI model parameters

function updateParams(
    address[] calldata tokens,
    bytes32[] calldata tau,
    bytes32[] calldata theta,
    bytes32[] calldata psi,
    bytes32[] calldata rho,
    UD60x18 riskFreeRate
) external nonReentrant;

Parameters

NameTypeDescription
tokensaddress[]List of the base tokens
taubytes32[]List of maturities
thetabytes32[]List of ATM total implied variance curves
psibytes32[]List of ATM skew curves
rhobytes32[]List of rho curves
riskFreeRateUD60x18The risk-free rate

getParams

Get the IV model parameters of a token pair

function getParams(address token) external view returns (VolatilityOracleStorage.Update memory);

Parameters

NameTypeDescription
tokenaddressThe token address

Returns

NameTypeDescription
<none>VolatilityOracleStorage.UpdateThe IV model parameters

getParamsUnpacked

Get unpacked IV model parameters

function getParamsUnpacked(address token) external view returns (VolatilityOracleStorage.Params memory);

Parameters

NameTypeDescription
tokenaddressThe token address

Returns

NameTypeDescription
<none>VolatilityOracleStorage.ParamsThe unpacked IV model parameters

_findInterval

Finds the interval a particular value is located in.

function _findInterval(SD59x18[5] memory arr, SD59x18 value) internal pure returns (uint256);

Parameters

NameTypeDescription
arrSD59x18[5]The array of cutoff points that define the intervals
valueSD59x18The value to find the interval for

Returns

NameTypeDescription
<none>uint256The interval index that corresponds the value

_toArray59x18

Convert an int256[] array to a SD59x18[] array

function _toArray59x18(int256[5] memory src) internal pure returns (SD59x18[5] memory tgt);

Parameters

NameTypeDescription
srcint256[5]The array to be converted

Returns

NameTypeDescription
tgtSD59x18[5]The input array converted to a SD59x18[] array

_weightedAvg

function _weightedAvg(SD59x18 lam, SD59x18 value1, SD59x18 value2) internal pure returns (SD59x18);

getVolatility

Calculate the annualized volatility for given set of parameters

function getVolatility(address token, UD60x18 spot, UD60x18 strike, UD60x18 timeToMaturity)
    public
    view
    virtual
    returns (UD60x18);

Parameters

NameTypeDescription
tokenaddressThe token address
spotUD60x18The spot price of the token
strikeUD60x18The strike price of the option
timeToMaturityUD60x18The time until maturity (denominated in years)

Returns

NameTypeDescription
<none>UD60x18The annualized implied volatility, where 1 is defined as 100%

getVolatility

function getVolatility(address token, UD60x18 spot, UD60x18[] memory strike, UD60x18[] memory timeToMaturity)
    external
    view
    virtual
    returns (UD60x18[] memory);

getRiskFreeRate

function getRiskFreeRate() external view virtual returns (UD60x18);

Structs

Params

struct Params {
    SD59x18[5] tau;
    SD59x18[5] theta;
    SD59x18[5] psi;
    SD59x18[5] rho;
}

SliceInfo

struct SliceInfo {
    SD59x18 theta;
    SD59x18 psi;
    SD59x18 rho;
}