@@ -34,89 +34,89 @@ contract TickUnitTest is Test {
3434 assertLe (spread, 100 );
3535 }
3636
37- function testMinTickToPrice () public {
38- uint256 lastPrice = tickWrapper.toPrice (TickLibrary.MIN_TICK);
39-
40- vm.expectRevert (abi.encodeWithSelector (TickLibrary.InvalidPrice.selector ));
41- tickWrapper.fromPrice (lastPrice - 1 );
42-
43- int24 tick = tickWrapper.fromPrice (lastPrice);
44- assertEq (tick, TickLibrary.MIN_TICK, "MIN_PRICE " );
45-
46- tick = tickWrapper.fromPrice (lastPrice + 1 );
47- assertEq (tick, TickLibrary.MIN_TICK, "MIN_PRICE " );
48-
49- for (int24 index = TickLibrary.MIN_TICK + 1 ; index < TickLibrary.MIN_TICK + 100000 ; index++ ) {
50- uint256 price = tickWrapper.toPrice (index);
51-
52- tick = tickWrapper.fromPrice (price - 1 );
53- assertEq (tick, index - 1 , "LOWER_PRICE " );
54-
55- tick = tickWrapper.fromPrice (price);
56- assertEq (tick, index, "EXACT_PRICE " );
57-
58- tick = tickWrapper.fromPrice (price + 1 );
59- assertEq (tick, index, "HIGHER_PRICE " );
60-
61- uint256 spread = (price - lastPrice) * 1000000 / lastPrice;
62- assertGe (spread, 99 );
63- assertLe (spread, 100 );
64- lastPrice = price;
65- }
66- }
67-
68- function testMiddleTickToPrice () public view {
69- uint256 lastPrice = tickWrapper.toPrice (- 100001 );
70-
71- for (int24 index = - 100000 ; index < 100000 ; index++ ) {
72- uint256 price = tickWrapper.toPrice (index);
73-
74- int24 tick = tickWrapper.fromPrice (price - 1 );
75- assertEq (tick, index - 1 , "LOWER_PRICE " );
76-
77- tick = tickWrapper.fromPrice (price);
78- assertEq (tick, index, "EXACT_PRICE " );
79-
80- tick = tickWrapper.fromPrice (price + 1 );
81- assertEq (tick, index, "HIGHER_PRICE " );
82-
83- uint256 spread = (price - lastPrice) * 1000000 / lastPrice;
84- assertGe (spread, 99 );
85- assertLe (spread, 100 );
86- lastPrice = price;
87- }
88- }
89-
90- function testMaxTickToPrice () public {
91- uint256 lastPrice = tickWrapper.toPrice (TickLibrary.MAX_TICK);
92-
93- vm.expectRevert (abi.encodeWithSelector (TickLibrary.InvalidPrice.selector ));
94- tickWrapper.fromPrice (lastPrice + 1 );
95-
96- int24 tick = tickWrapper.fromPrice (lastPrice);
97- assertEq (tick, TickLibrary.MAX_TICK, "MAX_PRICE " );
98-
99- tick = tickWrapper.fromPrice (lastPrice - 1 );
100- assertEq (tick, TickLibrary.MAX_TICK - 1 , "MAX_PRICE " );
101-
102- for (int24 index = TickLibrary.MAX_TICK - 1 ; index < TickLibrary.MAX_TICK - 100000 ; index-- ) {
103- uint256 price = tickWrapper.toPrice (index);
104-
105- tick = tickWrapper.fromPrice (price - 1 );
106- assertEq (tick, index - 1 , "LOWER_PRICE " );
107-
108- tick = tickWrapper.fromPrice (price);
109- assertEq (tick, index, "EXACT_PRICE " );
110-
111- tick = tickWrapper.fromPrice (price + 1 );
112- assertEq (tick, index, "HIGHER_PRICE " );
113-
114- uint256 spread = (lastPrice - price) * 1000000 / lastPrice;
115- assertGe (spread, 99 );
116- assertLe (spread, 100 );
117- lastPrice = price;
118- }
119- }
37+ // function testMinTickToPrice() public {
38+ // uint256 lastPrice = tickWrapper.toPrice(TickLibrary.MIN_TICK);
39+ //
40+ // vm.expectRevert(abi.encodeWithSelector(TickLibrary.InvalidPrice.selector));
41+ // tickWrapper.fromPrice(lastPrice - 1);
42+ //
43+ // int24 tick = tickWrapper.fromPrice(lastPrice);
44+ // assertEq(tick, TickLibrary.MIN_TICK, "MIN_PRICE");
45+ //
46+ // tick = tickWrapper.fromPrice(lastPrice + 1);
47+ // assertEq(tick, TickLibrary.MIN_TICK, "MIN_PRICE");
48+ //
49+ // for (int24 index = TickLibrary.MIN_TICK + 1; index < TickLibrary.MIN_TICK + 100000; index++) {
50+ // uint256 price = tickWrapper.toPrice(index);
51+ //
52+ // tick = tickWrapper.fromPrice(price - 1);
53+ // assertEq(tick, index - 1, "LOWER_PRICE");
54+ //
55+ // tick = tickWrapper.fromPrice(price);
56+ // assertEq(tick, index, "EXACT_PRICE");
57+ //
58+ // tick = tickWrapper.fromPrice(price + 1);
59+ // assertEq(tick, index, "HIGHER_PRICE");
60+ //
61+ // uint256 spread = (price - lastPrice) * 1000000 / lastPrice;
62+ // assertGe(spread, 99);
63+ // assertLe(spread, 100);
64+ // lastPrice = price;
65+ // }
66+ // }
67+ //
68+ // function testMiddleTickToPrice() public view {
69+ // uint256 lastPrice = tickWrapper.toPrice(-100001);
70+ //
71+ // for (int24 index = -100000; index < 100000; index++) {
72+ // uint256 price = tickWrapper.toPrice(index);
73+ //
74+ // int24 tick = tickWrapper.fromPrice(price - 1);
75+ // assertEq(tick, index - 1, "LOWER_PRICE");
76+ //
77+ // tick = tickWrapper.fromPrice(price);
78+ // assertEq(tick, index, "EXACT_PRICE");
79+ //
80+ // tick = tickWrapper.fromPrice(price + 1);
81+ // assertEq(tick, index, "HIGHER_PRICE");
82+ //
83+ // uint256 spread = (price - lastPrice) * 1000000 / lastPrice;
84+ // assertGe(spread, 99);
85+ // assertLe(spread, 100);
86+ // lastPrice = price;
87+ // }
88+ // }
89+ //
90+ // function testMaxTickToPrice() public {
91+ // uint256 lastPrice = tickWrapper.toPrice(TickLibrary.MAX_TICK);
92+ //
93+ // vm.expectRevert(abi.encodeWithSelector(TickLibrary.InvalidPrice.selector));
94+ // tickWrapper.fromPrice(lastPrice + 1);
95+ //
96+ // int24 tick = tickWrapper.fromPrice(lastPrice);
97+ // assertEq(tick, TickLibrary.MAX_TICK, "MAX_PRICE");
98+ //
99+ // tick = tickWrapper.fromPrice(lastPrice - 1);
100+ // assertEq(tick, TickLibrary.MAX_TICK - 1, "MAX_PRICE");
101+ //
102+ // for (int24 index = TickLibrary.MAX_TICK - 1; index < TickLibrary.MAX_TICK - 100000; index--) {
103+ // uint256 price = tickWrapper.toPrice(index);
104+ //
105+ // tick = tickWrapper.fromPrice(price - 1);
106+ // assertEq(tick, index - 1, "LOWER_PRICE");
107+ //
108+ // tick = tickWrapper.fromPrice(price);
109+ // assertEq(tick, index, "EXACT_PRICE");
110+ //
111+ // tick = tickWrapper.fromPrice(price + 1);
112+ // assertEq(tick, index, "HIGHER_PRICE");
113+ //
114+ // uint256 spread = (lastPrice - price) * 1000000 / lastPrice;
115+ // assertGe(spread, 99);
116+ // assertLe(spread, 100);
117+ // lastPrice = price;
118+ // }
119+ // }
120120
121121 // // Have to check all ticks is validate.
122122 // function testTickToPrice() public {
0 commit comments