From e4e449859222ac38eaf4b44bd20b2ea9c0265a3a Mon Sep 17 00:00:00 2001 From: chef-burger <137024020+chefburger@users.noreply.github.com> Date: Fri, 8 Nov 2024 10:33:30 +0800 Subject: [PATCH] optimization: [hexen-s8] added uncheck for binHelper#getSharesAndEffectiveAmountsIn (#208) --- .forge-snapshots/BinPoolManagerBytecodeSize.snap | 2 +- src/pool-bin/libraries/BinHelper.sol | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.forge-snapshots/BinPoolManagerBytecodeSize.snap b/.forge-snapshots/BinPoolManagerBytecodeSize.snap index 1eaaa9c3..c0501746 100644 --- a/.forge-snapshots/BinPoolManagerBytecodeSize.snap +++ b/.forge-snapshots/BinPoolManagerBytecodeSize.snap @@ -1 +1 @@ -23295 \ No newline at end of file +23287 \ No newline at end of file diff --git a/src/pool-bin/libraries/BinHelper.sol b/src/pool-bin/libraries/BinHelper.sol index c2856d00..651f6b9b 100644 --- a/src/pool-bin/libraries/BinHelper.sol +++ b/src/pool-bin/libraries/BinHelper.sol @@ -86,7 +86,9 @@ library BinHelper { uint256 deltaY = deltaLiquidity >> Constants.SCALE_OFFSET; deltaY = deltaY > y ? y : deltaY; - y -= deltaY; + unchecked { + y -= deltaY; + } deltaLiquidity -= deltaY << Constants.SCALE_OFFSET; } @@ -94,7 +96,9 @@ library BinHelper { uint256 deltaX = deltaLiquidity / price; deltaX = deltaX > x ? x : deltaX; - x -= deltaX; + unchecked { + x -= deltaX; + } } amountsIn = uint128(x).encode(uint128(y));