-
Notifications
You must be signed in to change notification settings - Fork 505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix tests and use BalanceDeltas #130
Merged
snreynolds
merged 8 commits into
sra/addLiq-accounting-updates
from
sauce/addLiq-accounting-updates-cleanup
Jun 26, 2024
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e605af4
fix some assertions
saucepoint e12a3fb
use BalanceDeltas for arithmetic
saucepoint 0d85aca
cleanest code in the game???
saucepoint eb85ede
additional cleaning
saucepoint 3ba713d
typo lol
saucepoint a98bb14
autocompound gas benchmarks
saucepoint 4bc5851
autocompound excess credit gas benchmark
saucepoint b382a1e
save 600 gas, cleaner code when moving caller delta to tokensOwed
saucepoint File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
258477 |
1 change: 1 addition & 0 deletions
1
.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 |
---|---|---|
@@ -0,0 +1 @@ | ||
190850 |
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 @@ | ||
279016 |
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 @@ | ||
176386 | ||
171241 |
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 @@ | ||
151968 | ||
146823 |
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 @@ | ||
471675 | ||
466530 |
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,53 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import {BalanceDelta} from "@uniswap/v4-core/src/types/BalanceDelta.sol"; | ||
|
||
library BalanceDeltaExtensionLibrary { | ||
function setAmount0(BalanceDelta a, int128 amount0) internal pure returns (BalanceDelta) { | ||
assembly { | ||
// set the upper 128 bits of a to amount0 | ||
a := or(shl(128, amount0), and(sub(shl(128, 1), 1), a)) | ||
} | ||
return a; | ||
} | ||
|
||
function setAmount1(BalanceDelta a, int128 amount1) internal pure returns (BalanceDelta) { | ||
assembly { | ||
// set the lower 128 bits of a to amount1 | ||
a := or(and(shl(128, sub(shl(128, 1), 1)), a), amount1) | ||
} | ||
return a; | ||
} | ||
|
||
function addAmount0(BalanceDelta a, int128 amount0) internal pure returns (BalanceDelta) { | ||
assembly { | ||
let a0 := sar(128, a) | ||
let res0 := add(a0, amount0) | ||
a := or(shl(128, res0), and(sub(shl(128, 1), 1), a)) | ||
} | ||
return a; | ||
} | ||
|
||
function addAmount1(BalanceDelta a, int128 amount1) internal pure returns (BalanceDelta) { | ||
assembly { | ||
let a1 := signextend(15, a) | ||
let res1 := add(a1, amount1) | ||
a := or(and(shl(128, sub(shl(128, 1), 1)), a), res1) | ||
} | ||
return a; | ||
} | ||
|
||
function addAndAssign(BalanceDelta a, BalanceDelta b) internal pure returns (BalanceDelta) { | ||
assembly { | ||
let a0 := sar(128, a) | ||
let a1 := signextend(15, a) | ||
let b0 := sar(128, b) | ||
let b1 := signextend(15, b) | ||
let res0 := add(a0, b0) | ||
let res1 := add(a1, b1) | ||
a := or(shl(128, res0), and(sub(shl(128, 1), 1), res1)) | ||
} | ||
return a; | ||
} | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we can get rid of this function when we move to transient stuff but fine for now