-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix bubbling different return types because of recursive calls
- Loading branch information
1 parent
635ebe3
commit 406506f
Showing
11 changed files
with
83 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
262492 | ||
262501 |
2 changes: 1 addition & 1 deletion
2
.forge-snapshots/autocompound_exactUnclaimedFees_exactCustodiedFees.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
194865 | ||
194874 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
283031 | ||
283040 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
180845 | ||
180891 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
180857 | ||
180903 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
175249 | ||
175258 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
150838 | ||
150847 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
600177 | ||
472846 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.24; | ||
|
||
import {BalanceDelta} from "@uniswap/v4-core/src/types/BalanceDelta.sol"; | ||
import {Currency} from "@uniswap/v4-core/src/types/Currency.sol"; | ||
|
||
/// @title a library to store callers' currency deltas in transient storage | ||
/// @dev this library implements the equivalent of a mapping, as transient storage can only be accessed in assembly | ||
library TransientLiquidityDelta { | ||
/// @notice calculates which storage slot a delta should be stored in for a given caller and currency | ||
function _computeSlot(address caller_, Currency currency) internal pure returns (bytes32 hashSlot) { | ||
assembly { | ||
mstore(0, caller_) | ||
mstore(32, currency) | ||
hashSlot := keccak256(0, 64) | ||
} | ||
} | ||
|
||
/// @notice Flush a BalanceDelta into transient storage for a given holder | ||
function flush(BalanceDelta delta, address holder, Currency currency0, Currency currency1) internal { | ||
setDelta(currency0, holder, delta.amount0()); | ||
setDelta(currency1, holder, delta.amount1()); | ||
} | ||
|
||
function addDelta(Currency currency, address caller, int128 delta) internal { | ||
bytes32 hashSlot = _computeSlot(caller, currency); | ||
assembly { | ||
let oldValue := tload(hashSlot) | ||
let newValue := add(oldValue, delta) | ||
tstore(hashSlot, newValue) | ||
} | ||
} | ||
|
||
function subDelta(Currency currency, address caller, int128 delta) internal { | ||
bytes32 hashSlot = _computeSlot(caller, currency); | ||
assembly { | ||
let oldValue := tload(hashSlot) | ||
let newValue := sub(oldValue, delta) | ||
tstore(hashSlot, newValue) | ||
} | ||
} | ||
|
||
/// @notice sets a new currency delta for a given caller and currency | ||
function setDelta(Currency currency, address caller, int256 delta) internal { | ||
bytes32 hashSlot = _computeSlot(caller, currency); | ||
|
||
assembly { | ||
tstore(hashSlot, delta) | ||
} | ||
} | ||
|
||
/// @notice gets a new currency delta for a given caller and currency | ||
function getDelta(Currency currency, address caller) internal view returns (int256 delta) { | ||
bytes32 hashSlot = _computeSlot(caller, currency); | ||
|
||
assembly { | ||
delta := tload(hashSlot) | ||
} | ||
} | ||
} |