A tool for conducting large-scale simulations of Algebra Integral volatility oracle and adaptive fee behavior using historical data.
Forked from https://github.com/primitivefinance/arbiter-template
Tool expects swaps.json
file in input
directory. File must contain one array with Swap
event structs, sorted by time and event order in tx/block.
Each even must contain following fields:
timestamp
- in seconds, since start of UNIX time (same asblock.timestamp
for almost every EVM-compatible chain)tick
- tick in the pool after the swap (This value is present in theSwap
event, which is emitted by the pool after the swap)
The easiest way to get the required data is to download swap events for a UniswapV3 or Algebra pool and then add timestamps to them.
Tool will generate result.json
file in output
directory. File will contain one array with structures, sorted by timestamps.
Structures will contain following fields:
timestamp
- in seconds, since start of UNIX time (same asblock.timestamp
for almost every EVM-compatible chain)tickAverage
- average tick for 24h windowfee
- adaptive fee value for this timestamp (with default configuration)volatilityAverage
- average volatility for 24h windowtick
- the tick at the start of this block (before any swaps)gasUsed
- gas used for write
The obtained data, in particular, about the average volatility, can be conveniently used to compare adaptive fee values for different adaptive fee configurations.
- Clone this repository
git clone https://github.com/cryptoalgebra/IntegralFeeSimulation.git --recursive
cd IntegralFeeSimulation
- Install foundry
curl -L https://foundry.paradigm.xyz | bash
foundryup
- Install forge libraries
forge install
- Generate bindings
forge bind --revert-strings debug -b src/bindings/ --module --overwrite
-
Put input data in
input/swaps.json
-
Run the project
cargo run
- Output data will be in
output/result.json