Skip to content
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

optimization: [hexen-s8] added uncheck for binHelper#getSharesAndEffectiveAmountsIn #208

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .forge-snapshots/BinPoolManagerBytecodeSize.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
23295
23287
8 changes: 6 additions & 2 deletions src/pool-bin/libraries/BinHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,19 @@ library BinHelper {
uint256 deltaY = deltaLiquidity >> Constants.SCALE_OFFSET;
deltaY = deltaY > y ? y : deltaY;

y -= deltaY;
unchecked {
y -= deltaY;
}
deltaLiquidity -= deltaY << Constants.SCALE_OFFSET;
}

if (deltaLiquidity >= price) {
uint256 deltaX = deltaLiquidity / price;
deltaX = deltaX > x ? x : deltaX;

x -= deltaX;
unchecked {
x -= deltaX;
}
}

amountsIn = uint128(x).encode(uint128(y));
Expand Down
Loading