Skip to content

Commit

Permalink
feat: Rename IdSlippageCaught error (#51)
Browse files Browse the repository at this point in the history
* feat: Rename IdSlippageCaught error

* feat: Update

* feat: include gas snapshot

* feat: updated snapshot after merge

* feat: Update

---------

Co-authored-by: ChefMist <[email protected]>
  • Loading branch information
chef-omelette and ChefMist authored Nov 11, 2024
1 parent 7f4a38e commit 72633c4
Show file tree
Hide file tree
Showing 20 changed files with 29 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1184780
1184790
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1050833
1050843
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1093093
1093103
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1257134
1257144
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1123276
1123286
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1159530
1159540
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1184780
1184790
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1050833
1050843
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1093089
1093099
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1255116
1255126
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1121258
1121268
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1157508
1157518
Original file line number Diff line number Diff line change
@@ -1 +1 @@
296697
296707
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1135172
1135182
Original file line number Diff line number Diff line change
@@ -1 +1 @@
541453
541463
Original file line number Diff line number Diff line change
@@ -1 +1 @@
915904
915914
Original file line number Diff line number Diff line change
@@ -1 +1 @@
865941
865951
8 changes: 6 additions & 2 deletions src/pool-bin/BinPositionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,12 @@ contract BinPositionManager is
/// @dev Checks if the activeId is within slippage before calling mint. If user mint to activeId and there
// was a swap in hook.beforeMint() which changes the activeId, user txn will fail
(uint24 activeId,,) = binPoolManager.getSlot0(params.poolKey.toId());
if (params.activeIdDesired + params.idSlippage < activeId) revert IdDesiredOverflows(activeId);
if (params.activeIdDesired - params.idSlippage > activeId) revert IdDesiredOverflows(activeId);
if (params.activeIdDesired + params.idSlippage < activeId) {
revert IdSlippageCaught(params.activeIdDesired, params.idSlippage, activeId);
}
if (params.activeIdDesired - params.idSlippage > activeId) {
revert IdSlippageCaught(params.activeIdDesired, params.idSlippage, activeId);
}

bytes32[] memory liquidityConfigs = new bytes32[](deltaLen);
for (uint256 i; i < liquidityConfigs.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/pool-bin/interfaces/IBinPositionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {IPositionManager} from "../../interfaces/IPositionManager.sol";

interface IBinPositionManager is IPositionManager {
error IdOverflows(int256);
error IdDesiredOverflows(uint24);
error IdSlippageCaught(uint256 activeIdDesired, uint256 idSlippage, uint24 activeId);
error AddLiquidityInputActiveIdMismath();

/// @notice BinAddLiquidityParams
Expand Down
6 changes: 5 additions & 1 deletion test/pool-bin/BinPositionManager_ModifyLiquidites.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ contract BinPositionManager_ModifyLiquidityTest is BinLiquidityHelper, GasSnapsh
_getAddParams(key1, binIds, 1 ether, 1 ether, activeId, alice);
param.activeIdDesired = activeId - 1;
bytes memory payload = Planner.init().add(Actions.BIN_ADD_LIQUIDITY, abi.encode(param)).encode();
vm.expectRevert(abi.encodeWithSelector(IBinPositionManager.IdDesiredOverflows.selector, activeId));
vm.expectRevert(
abi.encodeWithSelector(
IBinPositionManager.IdSlippageCaught.selector, param.activeIdDesired, param.idSlippage, activeId
)
);
binPm.modifyLiquidities(payload, _deadline);
}

Expand Down

0 comments on commit 72633c4

Please sign in to comment.