Skip to content

Commit

Permalink
Optimize even more and reduce bytecode size
Browse files Browse the repository at this point in the history
  • Loading branch information
shuhuiluo committed May 21, 2024
1 parent 392f403 commit 9bebbae
Show file tree
Hide file tree
Showing 32 changed files with 32 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/TickMathGetSqrtPriceAtTick.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
78082
77382
2 changes: 1 addition & 1 deletion .forge-snapshots/TickMathGetTickAtSqrtPrice.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
225786
225156
Original file line number Diff line number Diff line change
@@ -1 +1 @@
153432
153430
2 changes: 1 addition & 1 deletion .forge-snapshots/addLiquidity CA fee.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
331098
331096
2 changes: 1 addition & 1 deletion .forge-snapshots/addLiquidity with empty hook.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
286091
286089
2 changes: 1 addition & 1 deletion .forge-snapshots/addLiquidity with native token.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
143642
143640
Original file line number Diff line number Diff line change
@@ -1 +1 @@
301610
301608
2 changes: 1 addition & 1 deletion .forge-snapshots/initialize.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
61780
61779
2 changes: 1 addition & 1 deletion .forge-snapshots/poolManager bytecode size.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
21668
21636
2 changes: 1 addition & 1 deletion .forge-snapshots/removeLiquidity CA fee.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
186564
186562
2 changes: 1 addition & 1 deletion .forge-snapshots/removeLiquidity with empty hook.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
122932
122930
2 changes: 1 addition & 1 deletion .forge-snapshots/removeLiquidity with native token.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
119719
119717
Original file line number Diff line number Diff line change
@@ -1 +1 @@
104746
104744
2 changes: 1 addition & 1 deletion .forge-snapshots/simple addLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
167238
167236
Original file line number Diff line number Diff line change
@@ -1 +1 @@
98343
98341
2 changes: 1 addition & 1 deletion .forge-snapshots/simple removeLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
90383
90381
2 changes: 1 addition & 1 deletion .forge-snapshots/simple swap with native.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
116570
116567
2 changes: 1 addition & 1 deletion .forge-snapshots/simple swap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
131731
131728
2 changes: 1 addition & 1 deletion .forge-snapshots/swap CA fee on unspecified.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
182869
182866
Original file line number Diff line number Diff line change
@@ -1 +1 @@
112373
112371
2 changes: 1 addition & 1 deletion .forge-snapshots/swap against liquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
123716
123714
2 changes: 1 addition & 1 deletion .forge-snapshots/swap burn 6909 for input.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
135723
135721
2 changes: 1 addition & 1 deletion .forge-snapshots/swap burn native 6909 for input.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
124976
124974
2 changes: 1 addition & 1 deletion .forge-snapshots/swap mint native output as 6909.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
146980
146978
2 changes: 1 addition & 1 deletion .forge-snapshots/swap mint output as 6909.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
163585
163582
Original file line number Diff line number Diff line change
@@ -1 +1 @@
221767
221762
2 changes: 1 addition & 1 deletion .forge-snapshots/swap with dynamic fee.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
147786
147783
2 changes: 1 addition & 1 deletion .forge-snapshots/swap with hooks.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
123728
123726
2 changes: 1 addition & 1 deletion .forge-snapshots/swap with lp fee and protocol fee.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
179966
179963
2 changes: 1 addition & 1 deletion .forge-snapshots/swap with return dynamic fee.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
155645
155642
2 changes: 1 addition & 1 deletion .forge-snapshots/update dynamic fee in before swap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
158248
158245
11 changes: 1 addition & 10 deletions src/libraries/TickMath.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,7 @@ library TickMath {
// or price = int(2**128 / sqrt(1.0001)) if (absTick & 0x1) else 1 << 128
uint256 price;
assembly {
price :=
and(
shr(
// 128 if absTick & 0x1 else 0
shl(7, and(absTick, 0x1)),
// upper 128 bits of 2**256 / sqrt(1.0001) where the 128th bit is 1
0xfffcb933bd6fad37aa2d162d1a59400100000000000000000000000000000000
),
sub(shl(130, 1), 1) // mask lower 129 bits
)
price := xor(shl(128, 1), mul(xor(shl(128, 1), 0xfffcb933bd6fad37aa2d162d1a594001), and(absTick, 0x1)))
}
if (absTick & 0x2 != 0) price = (price * 0xfff97272373d413259a46990580e213a) >> 128;
if (absTick & 0x4 != 0) price = (price * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;
Expand Down

0 comments on commit 9bebbae

Please sign in to comment.