From 6b718c771897a6d73079fe007d1605a57dbf473e Mon Sep 17 00:00:00 2001 From: chefburger Date: Tue, 12 Nov 2024 11:22:25 +0800 Subject: [PATCH] optimization: minor adjust per comment --- .forge-snapshots/BinHookTest#testSwapSucceedsWithHook.snap | 2 +- .forge-snapshots/BinPoolManagerBytecodeSize.snap | 2 +- .../BinPoolManagerTest#testGasSwapMultipleBins.snap | 2 +- .../BinPoolManagerTest#testGasSwapOverBigBinIdGate.snap | 2 +- .../BinPoolManagerTest#testGasSwapSingleBin.snap | 2 +- src/pool-bin/libraries/BinPool.sol | 6 +++--- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.forge-snapshots/BinHookTest#testSwapSucceedsWithHook.snap b/.forge-snapshots/BinHookTest#testSwapSucceedsWithHook.snap index 78731c4c..1c4f322d 100644 --- a/.forge-snapshots/BinHookTest#testSwapSucceedsWithHook.snap +++ b/.forge-snapshots/BinHookTest#testSwapSucceedsWithHook.snap @@ -1 +1 @@ -190198 \ No newline at end of file +190107 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerBytecodeSize.snap b/.forge-snapshots/BinPoolManagerBytecodeSize.snap index 270abcbb..e8a0dfb4 100644 --- a/.forge-snapshots/BinPoolManagerBytecodeSize.snap +++ b/.forge-snapshots/BinPoolManagerBytecodeSize.snap @@ -1 +1 @@ -23602 \ No newline at end of file +23558 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasSwapMultipleBins.snap b/.forge-snapshots/BinPoolManagerTest#testGasSwapMultipleBins.snap index 192e1ca9..14c6b9fb 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasSwapMultipleBins.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasSwapMultipleBins.snap @@ -1 +1 @@ -178883 \ No newline at end of file +178450 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasSwapOverBigBinIdGate.snap b/.forge-snapshots/BinPoolManagerTest#testGasSwapOverBigBinIdGate.snap index b2772897..a581a4bc 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasSwapOverBigBinIdGate.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasSwapOverBigBinIdGate.snap @@ -1 +1 @@ -185165 \ No newline at end of file +184732 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasSwapSingleBin.snap b/.forge-snapshots/BinPoolManagerTest#testGasSwapSingleBin.snap index 95111a71..33b2736b 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasSwapSingleBin.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasSwapSingleBin.snap @@ -1 +1 @@ -133876 \ No newline at end of file +133785 \ No newline at end of file diff --git a/src/pool-bin/libraries/BinPool.sol b/src/pool-bin/libraries/BinPool.sol index b16ababa..4cdc6455 100644 --- a/src/pool-bin/libraries/BinPool.sol +++ b/src/pool-bin/libraries/BinPool.sol @@ -169,15 +169,15 @@ library BinPool { amountsInWithFees = amountsInWithFees.sub(pFee); } + self.reserveOfBin[swapState.activeId] = binReserves.add(amountsInWithFees).sub(amountsOutOfBin); + if ( - (binReserves.add(amountsInWithFees).sub(amountsOutOfBin)).getLiquidity( + self.reserveOfBin[swapState.activeId].getLiquidity( swapState.activeId.getPriceFromId(params.binStep) ) > Constants.MAX_LIQUIDITY_PER_BIN ) { revert BinPool__MaxLiquidityPerBinExceeded(); } - - self.reserveOfBin[swapState.activeId] = binReserves.add(amountsInWithFees).sub(amountsOutOfBin); } }