From 87906eab43b7a289fe9d65df321d507162722a10 Mon Sep 17 00:00:00 2001 From: ChefMist <133624774+ChefMist@users.noreply.github.com> Date: Tue, 12 Nov 2024 09:32:50 +0800 Subject: [PATCH] feat: optimise add_share --- .forge-snapshots/BinHookTest#testMintSucceedsWithHook.snap | 2 +- .forge-snapshots/BinMintBurnFeeHookTest#test_Mint.snap | 2 +- .forge-snapshots/BinPoolManagerBytecodeSize.snap | 2 +- .forge-snapshots/BinPoolManagerTest#testGasMintNneBins-1.snap | 2 +- .forge-snapshots/BinPoolManagerTest#testGasMintNneBins-2.snap | 2 +- .forge-snapshots/BinPoolManagerTest#testGasMintOneBin-1.snap | 2 +- .forge-snapshots/BinPoolManagerTest#testGasMintOneBin-2.snap | 2 +- .forge-snapshots/BinPoolManagerTest#testMintNativeCurrency.snap | 2 +- src/pool-bin/libraries/BinPool.sol | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.forge-snapshots/BinHookTest#testMintSucceedsWithHook.snap b/.forge-snapshots/BinHookTest#testMintSucceedsWithHook.snap index d13c499..e3356bf 100644 --- a/.forge-snapshots/BinHookTest#testMintSucceedsWithHook.snap +++ b/.forge-snapshots/BinHookTest#testMintSucceedsWithHook.snap @@ -1 +1 @@ -311512 \ No newline at end of file +311472 \ No newline at end of file diff --git a/.forge-snapshots/BinMintBurnFeeHookTest#test_Mint.snap b/.forge-snapshots/BinMintBurnFeeHookTest#test_Mint.snap index 043cb3e..5a6422d 100644 --- a/.forge-snapshots/BinMintBurnFeeHookTest#test_Mint.snap +++ b/.forge-snapshots/BinMintBurnFeeHookTest#test_Mint.snap @@ -1 +1 @@ -410594 \ No newline at end of file +410554 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerBytecodeSize.snap b/.forge-snapshots/BinPoolManagerBytecodeSize.snap index 0aaf9fa..3eceacd 100644 --- a/.forge-snapshots/BinPoolManagerBytecodeSize.snap +++ b/.forge-snapshots/BinPoolManagerBytecodeSize.snap @@ -1 +1 @@ -23406 \ No newline at end of file +23421 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-1.snap b/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-1.snap index 1b9ec10..b285a5a 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-1.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-1.snap @@ -1 +1 @@ -970797 \ No newline at end of file +970437 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-2.snap b/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-2.snap index 7633e95..4442fbd 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-2.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-2.snap @@ -1 +1 @@ -330109 \ No newline at end of file +329749 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-1.snap b/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-1.snap index ab8d17c..7e9f16b 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-1.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-1.snap @@ -1 +1 @@ -337769 \ No newline at end of file +337729 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-2.snap b/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-2.snap index cf9fd88..36edafd 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-2.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-2.snap @@ -1 +1 @@ -140320 \ No newline at end of file +140280 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testMintNativeCurrency.snap b/.forge-snapshots/BinPoolManagerTest#testMintNativeCurrency.snap index 673fb81..cb4c7ae 100644 --- a/.forge-snapshots/BinPoolManagerTest#testMintNativeCurrency.snap +++ b/.forge-snapshots/BinPoolManagerTest#testMintNativeCurrency.snap @@ -1 +1 @@ -304808 \ No newline at end of file +304768 \ No newline at end of file diff --git a/src/pool-bin/libraries/BinPool.sol b/src/pool-bin/libraries/BinPool.sol index 5fc6949..0486b8e 100644 --- a/src/pool-bin/libraries/BinPool.sol +++ b/src/pool-bin/libraries/BinPool.sol @@ -485,7 +485,7 @@ library BinPool { /// to discuss if we want to enforce this -- otherwise user can potentially add below 1e9 liquidity /// but can't withdraw if there's no other lp to help push the min share up uint256 balanceShare = self.shareOfBin[binId]; - if (balanceShare > 0 && balanceShare < MINIMUM_SHARE) { + if (balanceShare < MINIMUM_SHARE) { revert BinPool__BelowMinimumShare(balanceShare); } }