Skip to content

Commit

Permalink
fix: forge coverage stack too deep
Browse files Browse the repository at this point in the history
  • Loading branch information
chefburger committed Nov 11, 2024
1 parent 8c00656 commit 9c8fa74
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/BinHookTest#testSwapSucceedsWithHook.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
189959
190198
2 changes: 1 addition & 1 deletion .forge-snapshots/BinPoolManagerBytecodeSize.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
23548
23602
Original file line number Diff line number Diff line change
@@ -1 +1 @@
177927
178883
Original file line number Diff line number Diff line change
@@ -1 +1 @@
184209
185165
Original file line number Diff line number Diff line change
@@ -1 +1 @@
133637
133876
11 changes: 5 additions & 6 deletions src/pool-bin/libraries/BinPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@ library BinPool {
amountsInWithFees = amountsInWithFees.sub(pFee);
}

bytes32 newReserve = binReserves.add(amountsInWithFees).sub(amountsOutOfBin);
if (
newReserve.getLiquidity(swapState.activeId.getPriceFromId(params.binStep))
> Constants.MAX_LIQUIDITY_PER_BIN
(binReserves.add(amountsInWithFees).sub(amountsOutOfBin)).getLiquidity(
swapState.activeId.getPriceFromId(params.binStep)
) > Constants.MAX_LIQUIDITY_PER_BIN
) {
revert BinPool__MaxLiquidityPerBinExceeded();
}

self.reserveOfBin[swapState.activeId] = newReserve;
self.reserveOfBin[swapState.activeId] = binReserves.add(amountsInWithFees).sub(amountsOutOfBin);
}
}

Expand Down Expand Up @@ -357,8 +357,7 @@ library BinPool {
/// @dev overflow check on total reserves and the resulting liquidity
uint256 price = activeId.getPriceFromId(binStep);
bytes32 newReserves = binReserves.add(amountIn);
uint256 liquidity = newReserves.getLiquidity(price);
if (liquidity > Constants.MAX_LIQUIDITY_PER_BIN) {
if (newReserves.getLiquidity(price) > Constants.MAX_LIQUIDITY_PER_BIN) {
revert BinPool__MaxLiquidityPerBinExceeded();
}

Expand Down

0 comments on commit 9c8fa74

Please sign in to comment.