Skip to content

Commit

Permalink
optimization: [hexen-s8] added uncheck for binHelper#getSharesAndEffe…
Browse files Browse the repository at this point in the history
…ctiveAmountsIn (#208)
  • Loading branch information
chefburger authored Nov 8, 2024
1 parent 11cb533 commit e4e4498
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
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

0 comments on commit e4e4498

Please sign in to comment.