- Create shared MockVWAPTracker.sol to eliminate duplicate mock implementations - Add TestBase.sol with shared utilities (getDefaultParams, bp, denormTR) - Update CSVHelper.sol to use Forge's vm.toString() instead of manual conversion - Standardize tick calculation function names across test files - Update test files to use consolidated utilities - Remove helper function inventory (consolidation complete) Eliminates 200-300 lines of duplicate code while maintaining 100% test compatibility. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
44 lines
No EOL
1.5 KiB
Solidity
44 lines
No EOL
1.5 KiB
Solidity
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
pragma solidity ^0.8.19;
|
|
|
|
import "forge-std/Test.sol";
|
|
import "../../src/abstracts/ThreePositionStrategy.sol";
|
|
|
|
/**
|
|
* @title TestBase
|
|
* @notice Base contract providing shared utilities and default parameters for tests
|
|
* @dev Consolidates common test functionality to reduce code duplication
|
|
*/
|
|
abstract contract TestUtilities is Test {
|
|
/**
|
|
* @notice Returns default parameters for ThreePositionStrategy testing
|
|
* @return Default PositionParams structure with standard values
|
|
* @dev Used across multiple test files to ensure consistency
|
|
*/
|
|
function getDefaultParams() internal pure returns (ThreePositionStrategy.PositionParams memory) {
|
|
return ThreePositionStrategy.PositionParams({
|
|
capitalInefficiency: 5 * 10 ** 17, // 50%
|
|
anchorShare: 5 * 10 ** 17, // 50%
|
|
anchorWidth: 50, // 50%
|
|
discoveryDepth: 5 * 10 ** 17 // 50%
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @notice Helper function to convert value to basis points
|
|
* @param val Value to convert
|
|
* @return Value in basis points
|
|
*/
|
|
function bp(uint256 val) internal pure returns (uint256) {
|
|
return val / 1e15;
|
|
}
|
|
|
|
/**
|
|
* @notice Helper function to denormalize tax rate
|
|
* @param normalizedTaxRate Normalized tax rate
|
|
* @return Denormalized tax rate
|
|
*/
|
|
function denormTR(uint256 normalizedTaxRate) internal pure returns (uint256) {
|
|
return normalizedTaxRate * 97;
|
|
}
|
|
} |