https://github.com/antoncoding/squeeth-vol-oracle
on-chain vol oracle from squeeth
https://github.com/antoncoding/squeeth-vol-oracle
Last synced: 11 months ago
JSON representation
on-chain vol oracle from squeeth
- Host: GitHub
- URL: https://github.com/antoncoding/squeeth-vol-oracle
- Owner: antoncoding
- License: mit
- Created: 2022-08-17T14:55:50.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-10-24T07:53:10.000Z (over 3 years ago)
- Last Synced: 2025-02-28T23:52:36.057Z (12 months ago)
- Language: Solidity
- Size: 192 KB
- Stars: 25
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Deployments
The contract is deployed on Goerli and Mainnet:
| Chain | Address |
| -------- | -------- |
| Mainnet | [0x5caec004f1378fbfd54a11e9f00e2aad32796b33](https://etherscan.io/address/0x5caec004f1378fbfd54a11e9f00e2aad32796b33#readContract) |
| Goerli | [0x5caec004f1378fbfd54a11e9f00e2aad32796b33](https://goerli.etherscan.io/address/0x5caec004f1378fbfd54a11e9f00e2aad32796b33#readContract) |
### 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
```sh
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.
```shell
forge script scripts/Deploy.sol --fork-url
```
Output:
```shell
== Logs ==
implied volatility: 959347350657613352
gas cost: 97612
implied funding: 2521499559489813
```
#### Gas Cost
The gas cost is around 46K ~ 140K, depends on:
- `secondsAgo` to calculate twap
- current state of Uniswap pool, how many records are in the last `secondsAgo` seconds
It costs least (around 46K) while querying the implied vol by the current spot price.
### Contract Interface
```solidity
/// @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);
```