Loading and streaming events into a pool
Suppose a quant developer is going to backtest some strategy on mainnet pool.
This includes the following steps:
Using mainnet data to initialize a core pool
Replaying events up to a certain block as a checkpoint
Do some interaction as the strategy asks as interpolation to real transactions
Replaying events until the next checkpoint
Repeat step3-4 until events are run out
Evaluate performance of the strategy
Tuner has offered an example project called uniswap-v3-bot
. It similarly follow the process above to build a strategy platform for backtesting, dry-run and run, where a user adds a new strategy by implementing some callback interfaces(trigger
, cache
, act
and evaluate
). See Uniswap-v3-Strategy-Backtest.
When getting a core pool instance by clientInstance.initCorePoolFromMainnet
or clientInstance.recoverFromMainnetEventDBFile
, Tuner has already automatically replayed events from the first record to the last one in endBlock
. For replaying following events, you can load them by EventDBManager
, and decide how to use them on your own.
An example of streaming process will be:
Note: Tuner doesn't export LiquidityEvent
| SwapEvent
directly but you can sitll use them. For external data(event logs), we recommend you to implement your EventDBManager
to load and manage event logs, according to your context.
Last updated