infrastructure-upgrade/lib/v3-core/contracts/test/TickMathTest.sol

35 lines
1.1 KiB
Solidity
Raw Permalink Normal View History

2023-04-08 21:46:18 +03:00
// 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;
}
}