Skip to content

Commit

Permalink
linters
Browse files Browse the repository at this point in the history
  • Loading branch information
dianakocsis committed May 28, 2024
1 parent 92145ff commit 4017e1d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/libraries/Pool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ library Pool {
/// @notice Donates the given amount of currency0 and currency1 to the pool
function donate(State storage self, uint256 amount0, uint256 amount1) internal returns (BalanceDelta delta) {
uint128 liquidity = self.liquidity;
if (liquidity == 0) revert NoLiquidityToReceiveFees();
if (liquidity == 0) NoLiquidityToReceiveFees.selector.revertWith();
unchecked {
// negation safe as amount0 and amount1 are always positive
delta = toBalanceDelta(-(amount0.toInt128()), -(amount1.toInt128()));
Expand Down
45 changes: 19 additions & 26 deletions test/libraries/Pool.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,22 @@ contract PoolTest is Test, GasSnapshot {
vm.expectRevert(abi.encodeWithSelector(Pool.TickLowerOutOfBounds.selector, params.tickLower));
} else if (params.tickUpper > TickMath.MAX_TICK) {
vm.expectRevert(abi.encodeWithSelector(Pool.TickUpperOutOfBounds.selector, params.tickUpper));
} else if (params.liquidityDelta < 0) { // can't remove liquidity before adding it
} else if (params.liquidityDelta < 0) {
// can't remove liquidity before adding it
vm.expectRevert(SafeCast.SafeCastOverflow.selector);
} else if (params.liquidityDelta == 0) { // b/c position is empty
} else if (params.liquidityDelta == 0) {
// b/c position is empty
vm.expectRevert(Position.CannotUpdateEmptyPosition.selector);
} else if (params.liquidityDelta > int128(Pool.tickSpacingToMaxLiquidityPerTick(params.tickSpacing))) { // b/c liquidity before starts at 0
} else if (params.liquidityDelta > int128(Pool.tickSpacingToMaxLiquidityPerTick(params.tickSpacing))) {
// b/c liquidity before starts at 0
vm.expectRevert(abi.encodeWithSelector(Pool.TickLiquidityOverflow.selector, params.tickLower));
} else if (params.tickLower % params.tickSpacing != 0) { // since tick will always be flipped first time
} else if (params.tickLower % params.tickSpacing != 0) {
// since tick will always be flipped first time
vm.expectRevert(
abi.encodeWithSelector(TickBitmap.TickMisaligned.selector, params.tickLower, params.tickSpacing)
);
} else if (params.tickUpper % params.tickSpacing != 0) { // since tick will always be flipped first time
} else if (params.tickUpper % params.tickSpacing != 0) {
// since tick will always be flipped first time
vm.expectRevert(
abi.encodeWithSelector(TickBitmap.TickMisaligned.selector, params.tickUpper, params.tickSpacing)
);
Expand Down Expand Up @@ -311,9 +316,11 @@ contract PoolTest is Test, GasSnapshot {

if (params.amountSpecified == 0) {
assertEq(sqrtPriceBefore, state.slot0.sqrtPriceX96(), "amountSpecified == 0");
} else if (params.zeroForOne) { // fuzz test not checking this, checking in unit test: test_swap_zeroForOne_priceGreaterThanOrEqualToLimit
} else if (params.zeroForOne) {
// fuzz test not checking this, checking in unit test: test_swap_zeroForOne_priceGreaterThanOrEqualToLimit
assertGe(state.slot0.sqrtPriceX96(), params.sqrtPriceLimitX96, "zeroForOne");
} else { // fuzz test not checking this, checking in unit test: test_swap_oneForZero_priceLessThanOrEqualToLimit
} else {
// fuzz test not checking this, checking in unit test: test_swap_oneForZero_priceLessThanOrEqualToLimit
assertLe(state.slot0.sqrtPriceX96(), params.sqrtPriceLimitX96, "oneForZero");
}
}
Expand Down Expand Up @@ -379,9 +386,7 @@ contract PoolTest is Test, GasSnapshot {

vm.expectRevert(
abi.encodeWithSelector(
Pool.PriceLimitAlreadyExceeded.selector,
state.slot0.sqrtPriceX96(),
params.sqrtPriceLimitX96
Pool.PriceLimitAlreadyExceeded.selector, state.slot0.sqrtPriceX96(), params.sqrtPriceLimitX96
)
);
state.swap(params);
Expand All @@ -395,7 +400,7 @@ contract PoolTest is Test, GasSnapshot {
tickSpacing: TickMath.MIN_TICK_SPACING,
zeroForOne: true,
amountSpecified: 2459,
sqrtPriceLimitX96: TickMath.MIN_SQRT_PRICE ,
sqrtPriceLimitX96: TickMath.MIN_SQRT_PRICE,
lpFeeOverride: 0
});
params.tickSpacing = int24(bound(params.tickSpacing, TickMath.MIN_TICK_SPACING, TickMath.MAX_TICK_SPACING));
Expand All @@ -415,12 +420,7 @@ contract PoolTest is Test, GasSnapshot {
})
);

vm.expectRevert(
abi.encodeWithSelector(
Pool.PriceLimitOutOfBounds.selector,
params.sqrtPriceLimitX96
)
);
vm.expectRevert(abi.encodeWithSelector(Pool.PriceLimitOutOfBounds.selector, params.sqrtPriceLimitX96));
state.swap(params);
}

Expand Down Expand Up @@ -454,9 +454,7 @@ contract PoolTest is Test, GasSnapshot {

vm.expectRevert(
abi.encodeWithSelector(
Pool.PriceLimitAlreadyExceeded.selector,
state.slot0.sqrtPriceX96(),
params.sqrtPriceLimitX96
Pool.PriceLimitAlreadyExceeded.selector, state.slot0.sqrtPriceX96(), params.sqrtPriceLimitX96
)
);
state.swap(params);
Expand Down Expand Up @@ -490,12 +488,7 @@ contract PoolTest is Test, GasSnapshot {
})
);

vm.expectRevert(
abi.encodeWithSelector(
Pool.PriceLimitOutOfBounds.selector,
params.sqrtPriceLimitX96
)
);
vm.expectRevert(abi.encodeWithSelector(Pool.PriceLimitOutOfBounds.selector, params.sqrtPriceLimitX96));
state.swap(params);
}

Expand Down

0 comments on commit 4017e1d

Please sign in to comment.