forked from Uniswap/v3-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTickTest.sol
79 lines (70 loc) · 2.21 KB
/
TickTest.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
pragma abicoder v2;
import '../libraries/Tick.sol';
contract TickTest {
using Tick for mapping(int24 => Tick.Info);
mapping(int24 => Tick.Info) public ticks;
function tickSpacingToMaxLiquidityPerTick(int24 tickSpacing) external pure returns (uint128) {
return Tick.tickSpacingToMaxLiquidityPerTick(tickSpacing);
}
function setTick(int24 tick, Tick.Info memory info) external {
ticks[tick] = info;
}
function getFeeGrowthInside(
int24 tickLower,
int24 tickUpper,
int24 tickCurrent,
uint256 feeGrowthGlobal0X128,
uint256 feeGrowthGlobal1X128
) external view returns (uint256 feeGrowthInside0X128, uint256 feeGrowthInside1X128) {
return ticks.getFeeGrowthInside(tickLower, tickUpper, tickCurrent, feeGrowthGlobal0X128, feeGrowthGlobal1X128);
}
function update(
int24 tick,
int24 tickCurrent,
int128 liquidityDelta,
uint256 feeGrowthGlobal0X128,
uint256 feeGrowthGlobal1X128,
uint160 secondsPerLiquidityCumulativeX128,
int56 tickCumulative,
uint32 time,
bool upper,
uint128 maxLiquidity
) external returns (bool flipped) {
return
ticks.update(
tick,
tickCurrent,
liquidityDelta,
feeGrowthGlobal0X128,
feeGrowthGlobal1X128,
secondsPerLiquidityCumulativeX128,
tickCumulative,
time,
upper,
maxLiquidity
);
}
function clear(int24 tick) external {
ticks.clear(tick);
}
function cross(
int24 tick,
uint256 feeGrowthGlobal0X128,
uint256 feeGrowthGlobal1X128,
uint160 secondsPerLiquidityCumulativeX128,
int56 tickCumulative,
uint32 time
) external returns (int128 liquidityNet) {
return
ticks.cross(
tick,
feeGrowthGlobal0X128,
feeGrowthGlobal1X128,
secondsPerLiquidityCumulativeX128,
tickCumulative,
time
);
}
}