fix: address review feedback on BaselineStrategies and Reporter
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
77f0fd82fd
commit
af86ca1226
3 changed files with 130 additions and 55 deletions
|
|
@ -157,11 +157,12 @@ contract BacktestRunner is Script {
|
|||
new BaselineStrategies(sp.pool, MockToken(sp.token0), MockToken(sp.token1), token0isWeth, recenterInterval);
|
||||
baselines.initialize(initialCapital);
|
||||
|
||||
// Deploy Reporter (no broadcast needed — it only writes files).
|
||||
Reporter reporter = new Reporter();
|
||||
|
||||
vm.stopBroadcast();
|
||||
|
||||
// Reporter uses Foundry cheatcodes (vm.writeFile) — must live outside the broadcast
|
||||
// block so it is never sent as a real transaction on a live fork.
|
||||
Reporter reporter = new Reporter();
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// EventReplayer is instantiated outside the broadcast block because
|
||||
// it uses Foundry cheat codes (vm.readLine, vm.roll, vm.warp) that
|
||||
|
|
@ -231,19 +232,21 @@ contract BacktestRunner is Script {
|
|||
console2.log("Total events: ", totalEvents);
|
||||
replayer.replay(eventsFile, totalEvents, executor, baselines);
|
||||
|
||||
// Print final strategy summaries.
|
||||
// Print final KrAIken strategy summary.
|
||||
executor.logSummary();
|
||||
|
||||
// Materialize open-position fees for both LP baselines before summary/reporting.
|
||||
baselines.collectFinalFees();
|
||||
|
||||
// Print baseline summaries (now have complete fee data).
|
||||
baselines.logFinalSummary();
|
||||
|
||||
// Generate comparison report (Markdown + JSON).
|
||||
// Use fwTotalBlocks as the total replay duration (every unique block processed).
|
||||
// Approximate period length at ~2 s/block.
|
||||
// firstUpdateBlock and lastNotifiedBlock are the actual block numbers from the
|
||||
// events file — use them directly for an accurate period estimate.
|
||||
uint256 startBlock = baselines.firstUpdateBlock();
|
||||
uint256 endBlock = executor.tracker().lastNotifiedBlock();
|
||||
uint256 totalBlocksElapsed = baselines.fwTotalBlocks();
|
||||
uint256 startBlock = totalBlocksElapsed > 0 && endBlock > totalBlocksElapsed
|
||||
? endBlock - totalBlocksElapsed
|
||||
: endBlock;
|
||||
uint256 periodDays = (totalBlocksElapsed * 2) / 86_400;
|
||||
uint256 periodDays = endBlock > startBlock ? ((endBlock - startBlock) * 2) / 86_400 : 0;
|
||||
|
||||
reporter.generate(
|
||||
executor,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue