infrastructure-upgrade/lib/v3-core/contracts/test/TickMathTest.sol
T-Hax 735546619e
init
Signed-off-by: T-Hax <>
2023-04-08 18:46:18 +00:00

35 lines
1.1 KiB
Solidity

// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
import '../libraries/TickMath.sol';
contract TickMathTest {
function getSqrtRatioAtTick(int24 tick) external pure returns (uint160) {
return TickMath.getSqrtRatioAtTick(tick);
}
function getGasCostOfGetSqrtRatioAtTick(int24 tick) external view returns (uint256) {
uint256 gasBefore = gasleft();
TickMath.getSqrtRatioAtTick(tick);
return gasBefore - gasleft();
}
function getTickAtSqrtRatio(uint160 sqrtPriceX96) external pure returns (int24) {
return TickMath.getTickAtSqrtRatio(sqrtPriceX96);
}
function getGasCostOfGetTickAtSqrtRatio(uint160 sqrtPriceX96) external view returns (uint256) {
uint256 gasBefore = gasleft();
TickMath.getTickAtSqrtRatio(sqrtPriceX96);
return gasBefore - gasleft();
}
function MIN_SQRT_RATIO() external pure returns (uint160) {
return TickMath.MIN_SQRT_RATIO;
}
function MAX_SQRT_RATIO() external pure returns (uint160) {
return TickMath.MAX_SQRT_RATIO;
}
}