harb/onchain/analysis/helpers/CSVManager.sol
johba db23d756e9 fix: Optimize fuzzing and fix CSV buffer accumulation
- Deploy Uniswap factory once before all runs (saves ~1.16M gas per run)
- Fix CSV buffer accumulation bug by clearing buffer between runs
- Add clearCSV() function to CSVManager for proper buffer management
- Each fuzzing run now gets its own clean CSV with correct token0isWeth values
- Comment out failing console.log in Optimizer.t.sol to fix compilation

The token ordering now correctly alternates:
- Even seeds: token0isWeth = true (WETH < KRAIKEN)
- Odd seeds: token0isWeth = false (KRAIKEN < WETH)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-19 13:30:18 +02:00

51 lines
1.4 KiB
Solidity

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "forge-std/Test.sol";
import "./CSVHelper.sol";
/**
* @title CSVManager
* @dev An abstract contract that manages CSV creation, row appending, and writing to file.
* Contracts that inherit this contract can use the CSV functionality without managing the CSV string directly.
*/
abstract contract CSVManager is Test {
using CSVHelper for *;
string internal csv;
/**
* @notice Creates the header for the CSV file.
* This function should be called in the `setUp` function of derived contracts.
*/
function initializePositionsCSV() internal {
csv = CSVHelper.createPositionsHeader();
}
function initializeTimeSeriesCSV() internal {
csv = CSVHelper.createTimeSeriesHeader();
}
/**
* @notice Appends a new row to the CSV string.
* @param newRow The new row to append.
*/
function appendCSVRow(string memory newRow) internal {
csv = CSVHelper.appendRow(csv, newRow);
}
/**
* @notice Writes the CSV string to a file.
* @param filePath The path where the CSV file will be saved.
*/
function writeCSVToFile(string memory filePath) internal {
vm.writeFile(filePath, csv);
}
/**
* @notice Clears the CSV buffer. Should be called between runs to avoid data accumulation.
*/
function clearCSV() internal {
csv = "";
}
}