Skip to content

Commit

Permalink
add suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
nishim3 committed Mar 27, 2024
2 parents 86a167b + e4d9d90 commit 06bb849
Show file tree
Hide file tree
Showing 22 changed files with 26 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
140965
141181
2 changes: 1 addition & 1 deletion .forge-snapshots/DynamicFees.swap_withDynamicFee.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
89960
90176
2 changes: 1 addition & 1 deletion .forge-snapshots/PoolManager.addLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
145779
145959
Original file line number Diff line number Diff line change
@@ -1 +1 @@
265619
265799
2 changes: 1 addition & 1 deletion .forge-snapshots/PoolManager.addLiquidity_withNative.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
140462
140642
2 changes: 1 addition & 1 deletion .forge-snapshots/PoolManager.bytecodeSize.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22999
23026
2 changes: 1 addition & 1 deletion .forge-snapshots/PoolManager.donate_gasWith1Token.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
101510
101654
2 changes: 1 addition & 1 deletion .forge-snapshots/PoolManager.donate_gasWith2Tokens.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
128451
128667
2 changes: 1 addition & 1 deletion .forge-snapshots/PoolManager.removeLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
150044
150224
Original file line number Diff line number Diff line change
@@ -1 +1 @@
56394
56574
Original file line number Diff line number Diff line change
@@ -1 +1 @@
148580
148760
2 changes: 1 addition & 1 deletion .forge-snapshots/PoolManager.swap_againstLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
60658
60874
Original file line number Diff line number Diff line change
@@ -1 +1 @@
72652
72868
2 changes: 1 addition & 1 deletion .forge-snapshots/PoolManager.swap_burn6909ForInput.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
80772
80988
Original file line number Diff line number Diff line change
@@ -1 +1 @@
76727
76943
Original file line number Diff line number Diff line change
@@ -1 +1 @@
139052
139268
2 changes: 1 addition & 1 deletion .forge-snapshots/PoolManager.swap_mintOutputAs6909.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
155861
156077
2 changes: 1 addition & 1 deletion .forge-snapshots/PoolManager.swap_simple.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
147069
147285
2 changes: 1 addition & 1 deletion .forge-snapshots/PoolManager.swap_simpleWithNative.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
133193
133409
2 changes: 1 addition & 1 deletion .forge-snapshots/PoolManager.swap_withHooks.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
60633
60849
7 changes: 4 additions & 3 deletions src/PoolManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ contract PoolManager is IPoolManager, ProtocolFees, NoDelegateCall, ERC6909Claim
using Hooks for IHooks;
using Position for mapping(bytes32 => Position.Info);
using CurrencyLibrary for Currency;
using CurrencyDelta for Currency;
using SwapFeeLibrary for uint24;
using PoolGetters for Pool.State;

Expand Down Expand Up @@ -85,7 +86,7 @@ contract PoolManager is IPoolManager, ProtocolFees, NoDelegateCall, ERC6909Claim

/// @inheritdoc IPoolManager
function currencyDelta(address caller, Currency currency) external view returns (int256) {
return CurrencyDelta.get(caller, currency);
return currency.getDelta(caller);
}

/// @inheritdoc IPoolManager
Expand Down Expand Up @@ -142,7 +143,7 @@ contract PoolManager is IPoolManager, ProtocolFees, NoDelegateCall, ERC6909Claim
function _accountDelta(Currency currency, int128 delta) internal {
if (delta == 0) return;

int256 current = CurrencyDelta.get(msg.sender, currency);
int256 current = currency.getDelta(msg.sender);
int256 next = current + delta;

unchecked {
Expand All @@ -153,7 +154,7 @@ contract PoolManager is IPoolManager, ProtocolFees, NoDelegateCall, ERC6909Claim
}
}

CurrencyDelta.set(msg.sender, currency, next);
currency.setDelta(msg.sender, next);
}

/// @dev Accumulates a balance change to a map of currency to balance changes
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/CurrencyDelta.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ library CurrencyDelta {
}
}

function set(address caller, Currency currency, int256 delta) internal {
function setDelta(Currency currency, address caller, int256 delta) internal {
bytes32 hashSlot = _computeSlot(caller, currency);

assembly {
tstore(hashSlot, delta)
}
}

function get(address caller, Currency currency) internal view returns (int256 delta) {
function getDelta(Currency currency, address caller) internal view returns (int256 delta) {
bytes32 hashSlot = _computeSlot(caller, currency);

assembly {
Expand Down

0 comments on commit 06bb849

Please sign in to comment.