VolatilityOracle
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
Name | Type | Description |
---|---|---|
params | int256[5] | Parameters of IV model to pack |
Returns
Name | Type | Description |
---|---|---|
result | bytes32 | The 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
Name | Type | Description |
---|---|---|
input | bytes32 | Packed IV model parameters to unpack |
Returns
Name | Type | Description |
---|---|---|
params | int256[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
Name | Type | Description |
---|---|---|
tokens | address[] | List of the base tokens |
tau | bytes32[] | List of maturities |
theta | bytes32[] | List of ATM total implied variance curves |
psi | bytes32[] | List of ATM skew curves |
rho | bytes32[] | List of rho curves |
riskFreeRate | UD60x18 | The risk-free rate |
getParams
Get the IV model parameters of a token pair
function getParams(address token) external view returns (VolatilityOracleStorage.Update memory);
Parameters
Name | Type | Description |
---|---|---|
token | address | The token address |
Returns
Name | Type | Description |
---|---|---|
<none> | VolatilityOracleStorage.Update | The IV model parameters |
getParamsUnpacked
Get unpacked IV model parameters
function getParamsUnpacked(address token) external view returns (VolatilityOracleStorage.Params memory);
Parameters
Name | Type | Description |
---|---|---|
token | address | The token address |
Returns
Name | Type | Description |
---|---|---|
<none> | VolatilityOracleStorage.Params | The 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
Name | Type | Description |
---|---|---|
arr | SD59x18[5] | The array of cutoff points that define the intervals |
value | SD59x18 | The value to find the interval for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The 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
Name | Type | Description |
---|---|---|
src | int256[5] | The array to be converted |
Returns
Name | Type | Description |
---|---|---|
tgt | SD59x18[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
Name | Type | Description |
---|---|---|
token | address | The token address |
spot | UD60x18 | The spot price of the token |
strike | UD60x18 | The strike price of the option |
timeToMaturity | UD60x18 | The time until maturity (denominated in years) |
Returns
Name | Type | Description |
---|---|---|
<none> | UD60x18 | The 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;
}