Skip to content

Commit

Permalink
optimization: inline literal number to avoid runtime hash calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
chefburger committed Apr 3, 2024
1 parent ae7b6c3 commit 09d4460
Show file tree
Hide file tree
Showing 42 changed files with 49 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
92245
90458
Original file line number Diff line number Diff line change
@@ -1 +1 @@
67437
65650
Original file line number Diff line number Diff line change
@@ -1 +1 @@
150992
149205
2 changes: 1 addition & 1 deletion .forge-snapshots/BinPoolManagerTest#testGasBurnOneBin.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
68616
66829
2 changes: 1 addition & 1 deletion .forge-snapshots/BinPoolManagerTest#testGasDonate.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
53952
52163
Original file line number Diff line number Diff line change
@@ -1 +1 @@
968047
966258
Original file line number Diff line number Diff line change
@@ -1 +1 @@
121561
119772
Original file line number Diff line number Diff line change
@@ -1 +1 @@
337237
335448
Original file line number Diff line number Diff line change
@@ -1 +1 @@
56298
54509
Original file line number Diff line number Diff line change
@@ -1 +1 @@
93040
91252
Original file line number Diff line number Diff line change
@@ -1 +1 @@
95025
93237
Original file line number Diff line number Diff line change
@@ -1 +1 @@
74469
72681
Original file line number Diff line number Diff line change
@@ -1 +1 @@
318945
317156
2 changes: 1 addition & 1 deletion .forge-snapshots/BinPoolManagerTest#testNoOpGas_Burn.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
41876
41481
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19493
19098
2 changes: 1 addition & 1 deletion .forge-snapshots/BinPoolManagerTest#testNoOpGas_Mint.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
37345
36950
2 changes: 1 addition & 1 deletion .forge-snapshots/BinPoolManagerTest#testNoOpGas_Swap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22699
22304
Original file line number Diff line number Diff line change
@@ -1 +1 @@
348452
346663
Original file line number Diff line number Diff line change
@@ -1 +1 @@
61000
59211
Original file line number Diff line number Diff line change
@@ -1 +1 @@
241390
240256
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPoolManagerTest#donateBothTokens.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
84138
82349
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPoolManagerTest#gasDonateOneToken.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
53445
52311
Original file line number Diff line number Diff line change
@@ -1 +1 @@
43322
42189
Original file line number Diff line number Diff line change
@@ -1 +1 @@
56445
54657
Original file line number Diff line number Diff line change
@@ -1 +1 @@
104543
102755
Original file line number Diff line number Diff line change
@@ -1 +1 @@
25044269
25042481
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPoolManagerTest#swap_simple.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
36336
35857
Original file line number Diff line number Diff line change
@@ -1 +1 @@
103041
101254
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPoolManagerTest#swap_withHooks.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
41986
41507
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPoolManagerTest#swap_withNative.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
36339
35860
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19448
19053
Original file line number Diff line number Diff line change
@@ -1 +1 @@
27615
27220
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPoolManagerTest#testNoOp_gas_Swap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
21897
21502
2 changes: 1 addition & 1 deletion .forge-snapshots/VaultTest#Vault.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7033
7180
Original file line number Diff line number Diff line change
@@ -1 +1 @@
122519
120730
2 changes: 1 addition & 1 deletion .forge-snapshots/VaultTest#lockSettledWhenFlashloan.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
158811
156938
Original file line number Diff line number Diff line change
@@ -1 +1 @@
46974
45186
2 changes: 1 addition & 1 deletion .forge-snapshots/VaultTest#lockSettledWhenSwap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
46973
45185
2 changes: 1 addition & 1 deletion .forge-snapshots/VaultTest#testLock_NoOp.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11627
11232
Original file line number Diff line number Diff line change
@@ -1 +1 @@
72506
71681
Original file line number Diff line number Diff line change
@@ -1 +1 @@
34113
33288
11 changes: 8 additions & 3 deletions src/libraries/SettlementGuard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ import {IVault} from "../interfaces/IVault.sol";
/// - 1: uint256 unsettledDeltasCount
/// - 2: mapping(address, mapping(Currency => int256)) currencyDelta
library SettlementGuard {
uint256 constant LOCKER_SLOT = uint256(keccak256("SETTLEMENT_LOCKER")) - 1;
uint256 constant UNSETTLED_DELTAS_COUNT = uint256(keccak256("SETTLEMENT_UNSETTLEMENTD_DELTAS_COUNT")) - 1;
uint256 constant CURRENCY_DELTA = uint256(keccak256("SETTLEMENT_CURRENCY_DELTA")) - 1;
// uint256 constant LOCKER_SLOT = uint256(keccak256("SETTLEMENT_LOCKER")) - 1;
uint256 constant LOCKER_SLOT = 0xedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d70;

// uint256 constant UNSETTLED_DELTAS_COUNT = uint256(keccak256("SETTLEMENT_UNSETTLEMENTD_DELTAS_COUNT")) - 1;
uint256 constant UNSETTLED_DELTAS_COUNT = 0xa88ffc6a483ae852b901fb1c3a0df606e2e4461b493434e6643ebdc3ffabd151;

// uint256 constant CURRENCY_DELTA = uint256(keccak256("SETTLEMENT_CURRENCY_DELTA")) - 1;
uint256 constant CURRENCY_DELTA = 0x6dc13502b9ba2a9e8e42c53a1856d632b29d5aab3bcb4a2476bfec06cbd9cf22;

function setLocker(address newLocker) internal {
address currentLocker = getLocker();
Expand Down

0 comments on commit 09d4460

Please sign in to comment.