harb/onchain/analysis/helpers/CSVHelper.sol

36 lines
1.3 KiB
Solidity
Raw Normal View History

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "forge-std/Test.sol";
import "forge-std/Vm.sol";
/**
* @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) {
return
"precedingAction, currentTick, floorTickLower, floorTickUpper, floorLiquidity, anchorTickLower, anchorTickUpper, anchorLiquidity, discoveryTickLower, discoveryTickUpper, discoveryLiquidity, token0isWeth, percentageStaked, avgTaxRate";
}
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));
}
}