This solution gives the realized volatility to a smart contract, without relying on Oracles, by using SNARKs with SP1.
The workflow goes as follows:
-
Data for calculating realized volatility is parsed using a substream. This data in specific is composed by events from a
UniswapV3Pool
contract. In this contract, we are particularly interested in theticks
orsqrtPriceX96
values. For more details, check therealized_volatility_substream
folder. -
This data is fed into sp1 program to generate a proof that the realized volatility calculation was done correctly. Check how it is done is in
sp1
folder. -
Then, the proof is verified onchain, via a
SP1Verifier
smart contract. A proof is written in.json
and can be generated from thesp1
folder script. Check theVolatilityHook-UniV4
for the contracts tests and integrations.