squeeth-vol-oracle
squeeth-vol-oracle copied to clipboard
on-chain vol oracle from squeeth
Deployments
The contract is deployed on Goerli and Mainnet:
| Chain | Address |
|---|---|
| Mainnet | 0x5caec004f1378fbfd54a11e9f00e2aad32796b33 |
| Goerli | 0x5caec004f1378fbfd54a11e9f00e2aad32796b33 |
Using the contract
You can use cast to directly query the value as follow (mainnet rpc example):
cast call 0x5caec004f1378fbfd54a11e9f00e2aad32796b33 "getEthTwaIV(uint32)(uint256)" 120 --rpc-url https://rpc.ankr.com/eth
Development
Getting Started
Compile and run tests
forge build
forge test
Estimation
You can clone the contract, tune in a bit and use the following script to estimate real world vol value.
forge script scripts/Deploy.sol --fork-url <mainnet rpc>
Output:
== Logs ==
implied volatility: 959347350657613352
gas cost: 97612
implied funding: 2521499559489813
Gas Cost
The gas cost is around 46K ~ 140K, depends on:
secondsAgoto calculate twap- current state of Uniswap pool, how many records are in the last
secondsAgoseconds
It costs least (around 46K) while querying the implied vol by the current spot price.
Contract Interface
/// @dev return implied vol with 18 decimals (1e18 = 100%)
function getEthTwaIV(uint256 secondsAgo) external view returns (uint256 vol);
/// @dev return daily implied funding with 18 decimals (1e18 = 100%)
function getImpliedFunding(uint32 secondsAgo) external view returns (uint256 impliedFunding);