2024-11-07 15:33:40 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
pragma solidity ^0.8.19;
|
|
|
|
|
|
2025-07-18 20:30:50 +02:00
|
|
|
import "forge-std/Test.sol";
|
|
|
|
|
import "forge-std/Vm.sol";
|
|
|
|
|
|
2024-11-07 15:33:40 +00:00
|
|
|
/**
|
|
|
|
|
* @title CSVHelper
|
|
|
|
|
* @dev Library for managing CSV data in Solidity, including converting values to strings and writing CSV data.
|
|
|
|
|
*/
|
|
|
|
|
library CSVHelper {
|
|
|
|
|
/**
|
|
|
|
|
* @notice Creates a standard CSV header for liquidity position data.
|
|
|
|
|
* @return The CSV header as a string.
|
|
|
|
|
*/
|
|
|
|
|
function createPositionsHeader() internal pure returns (string memory) {
|
2025-07-08 10:33:10 +02:00
|
|
|
return
|
2025-07-17 21:35:18 +02:00
|
|
|
"precedingAction, currentTick, floorTickLower, floorTickUpper, floorEth, floorHarb, anchorTickLower, anchorTickUpper, anchorEth, anchorHarb, discoveryTickLower, discoveryTickUpper, discoveryEth, discoveryHarb, token0isWeth";
|
2024-11-07 15:33:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createTimeSeriesHeader() internal pure returns (string memory) {
|
|
|
|
|
return "time, price, harbTotalSupply, supplyChange, stakeOutstandingShares, avgTaxRate, sentiment, taxCollected";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notice Appends new CSV data to the existing CSV string.
|
|
|
|
|
* @param csv The current CSV string.
|
|
|
|
|
* @param newRow The new row to append.
|
|
|
|
|
* @return The updated CSV string.
|
|
|
|
|
*/
|
|
|
|
|
function appendRow(string memory csv, string memory newRow) internal pure returns (string memory) {
|
|
|
|
|
return string(abi.encodePacked(csv, "\n", newRow));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2025-07-18 20:30:50 +02:00
|
|
|
* @notice Converts a `uint256` to a string using Forge's built-in vm.toString()
|
|
|
|
|
* @param vm The Forge VM instance
|
2024-11-07 15:33:40 +00:00
|
|
|
* @param _i The integer to convert.
|
|
|
|
|
* @return The string representation of the integer.
|
2025-07-18 20:30:50 +02:00
|
|
|
* @dev This function is a wrapper around vm.toString() for consistency with the library interface.
|
|
|
|
|
* In practice, use vm.toString() directly in test files.
|
2024-11-07 15:33:40 +00:00
|
|
|
*/
|
2025-07-18 20:30:50 +02:00
|
|
|
function uintToStr(Vm vm, uint256 _i) internal pure returns (string memory) {
|
|
|
|
|
// Note: This function is kept for API compatibility but should not be used in new code.
|
|
|
|
|
// Use vm.toString() directly instead.
|
|
|
|
|
return vm.toString(_i);
|
2024-11-07 15:33:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2025-07-18 20:30:50 +02:00
|
|
|
* @notice Converts an `int256` to a string using Forge's built-in vm.toString()
|
|
|
|
|
* @param vm The Forge VM instance
|
2024-11-07 15:33:40 +00:00
|
|
|
* @param _i The integer to convert.
|
|
|
|
|
* @return The string representation of the integer.
|
2025-07-18 20:30:50 +02:00
|
|
|
* @dev This function is a wrapper around vm.toString() for consistency with the library interface.
|
|
|
|
|
* In practice, use vm.toString() directly in test files.
|
2024-11-07 15:33:40 +00:00
|
|
|
*/
|
2025-07-18 20:30:50 +02:00
|
|
|
function intToStr(Vm vm, int256 _i) internal pure returns (string memory) {
|
|
|
|
|
// Note: This function is kept for API compatibility but should not be used in new code.
|
|
|
|
|
// Use vm.toString() directly instead.
|
|
|
|
|
return vm.toString(_i);
|
2024-11-07 15:33:40 +00:00
|
|
|
}
|
|
|
|
|
}
|