-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTickMathTest.sol
34 lines (27 loc) · 1.06 KB
/
TickMathTest.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// 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;
}
}