2025-07-08 11:59:26 +02:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
pragma solidity ^0.8.19;
|
|
|
|
|
|
|
|
|
|
import "forge-std/Test.sol";
|
|
|
|
|
import "../src/libraries/UniswapMath.sol";
|
|
|
|
|
import "../src/abstracts/PriceOracle.sol";
|
|
|
|
|
import "../src/abstracts/ThreePositionStrategy.sol";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @title Modular Components Test
|
|
|
|
|
* @notice Quick validation that all modular components compile and basic functions work
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Simple test implementations
|
2025-07-15 11:57:28 +02:00
|
|
|
contract TestUniswapMath is UniswapMath, Test {
|
|
|
|
|
function testTickAtPrice(bool t0isWeth, uint256 tokenAmount, uint256 ethAmount) external {
|
|
|
|
|
// Bound inputs to reasonable ranges to avoid overflow in ABDKMath64x64 conversions
|
|
|
|
|
tokenAmount = bound(tokenAmount, 1, 1e18);
|
|
|
|
|
ethAmount = bound(ethAmount, 1, 1e18);
|
|
|
|
|
|
|
|
|
|
int24 tick = _tickAtPrice(t0isWeth, tokenAmount, ethAmount);
|
|
|
|
|
|
|
|
|
|
// Verify tick is within valid bounds
|
|
|
|
|
assertGe(tick, -887272, "Tick should be >= MIN_TICK");
|
|
|
|
|
assertLe(tick, 887272, "Tick should be <= MAX_TICK");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getTickAtPrice(bool t0isWeth, uint256 tokenAmount, uint256 ethAmount) external pure returns (int24) {
|
2025-07-08 11:59:26 +02:00
|
|
|
return _tickAtPrice(t0isWeth, tokenAmount, ethAmount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
contract ModularComponentsTest is Test {
|
|
|
|
|
TestUniswapMath testMath;
|
|
|
|
|
|
|
|
|
|
function setUp() public {
|
|
|
|
|
testMath = new TestUniswapMath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function testUniswapMathCompilation() public {
|
|
|
|
|
// Test that mathematical utilities work
|
2025-07-15 11:57:28 +02:00
|
|
|
int24 tick = testMath.getTickAtPrice(true, 1 ether, 1 ether);
|
2025-07-08 11:59:26 +02:00
|
|
|
|
|
|
|
|
// Should get a reasonable tick for 1:1 ratio
|
|
|
|
|
assertGt(tick, -10000, "Tick should be reasonable");
|
|
|
|
|
assertLt(tick, 10000, "Tick should be reasonable");
|
|
|
|
|
|
|
|
|
|
console.log("UniswapMath component test passed");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function testModularArchitectureCompiles() public {
|
|
|
|
|
// If this test runs, it means all modular components compiled successfully
|
|
|
|
|
assertTrue(true, "Modular architecture compiles successfully");
|
|
|
|
|
console.log("All modular components compiled successfully");
|
|
|
|
|
}
|
|
|
|
|
}
|