From 980f2c5e3e1e8fa912d0405b222cbdf36f14e548 Mon Sep 17 00:00:00 2001 From: chefburger Date: Thu, 7 Nov 2024 14:39:56 +0800 Subject: [PATCH] optimization: [hexen-s8] added uncheck for binHelper#getSharesAndEffectiveAmountsIn --- .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 0c82ed5b..a9cd8aa0 100644 --- a/.forge-snapshots/BinPoolManagerBytecodeSize.snap +++ b/.forge-snapshots/BinPoolManagerBytecodeSize.snap @@ -1 +1 @@ -23296 \ No newline at end of file +23288 \ 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));