From b17719aae32546a2e3686cf006849a4030281f0f Mon Sep 17 00:00:00 2001 From: dianakocsis Date: Thu, 5 Sep 2024 15:57:30 -0400 Subject: [PATCH] format --- src/V4Router.sol | 22 ++++++++++++++-------- src/libraries/SlippageCheck.sol | 8 ++++++-- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/V4Router.sol b/src/V4Router.sol index 629a3bb4..fb806eb4 100644 --- a/src/V4Router.sol +++ b/src/V4Router.sol @@ -122,14 +122,18 @@ abstract contract V4Router is IV4Router, BaseActionsRouter, DeltaResolver { function _swapExactOutputSingle(IV4Router.ExactOutputSingleParams calldata params) private { uint128 amountIn = ( - uint256(-int256(_swap( - params.poolKey, - params.zeroForOne, - int256(uint256(params.amountOut)), - params.sqrtPriceLimitX96, - params.hookData + uint256( + -int256( + _swap( + params.poolKey, + params.zeroForOne, + int256(uint256(params.amountOut)), + params.sqrtPriceLimitX96, + params.hookData + ) + ) ) - ))).toUint128(); + ).toUint128(); if (amountIn > params.amountInMaximum) revert V4TooMuchRequested(params.amountInMaximum, amountIn); } @@ -146,7 +150,9 @@ abstract contract V4Router is IV4Router, BaseActionsRouter, DeltaResolver { pathKey = params.path[i - 1]; (PoolKey memory poolKey, bool oneForZero) = pathKey.getPoolAndSwapDirection(currencyOut); // The output delta will always be negative, except for when interacting with certain hook pools - amountIn = (uint256(-int256(_swap(poolKey, !oneForZero, int256(uint256(amountOut)), 0, pathKey.hookData)))).toUint128(); + amountIn = ( + uint256(-int256(_swap(poolKey, !oneForZero, int256(uint256(amountOut)), 0, pathKey.hookData))) + ).toUint128(); amountOut = amountIn; currencyOut = pathKey.intermediateCurrency; diff --git a/src/libraries/SlippageCheck.sol b/src/libraries/SlippageCheck.sol index 0963294f..39e74afc 100644 --- a/src/libraries/SlippageCheck.sol +++ b/src/libraries/SlippageCheck.sol @@ -43,7 +43,11 @@ library SlippageCheck { // This means this contract will NOT support _positive_ slippage checks (minAmountOut checks) on pools where the hook returns a positive delta on mint/increase. int256 amount0 = delta.amount0(); int256 amount1 = delta.amount1(); - if (amount0 < 0 && amount0Max < uint256(-amount0)) revert MaximumAmountExceeded(uint256(amount0Max), uint256(-amount0)); - if (amount1 < 0 && amount1Max < uint256(-amount1)) revert MaximumAmountExceeded(uint256(amount1Max), uint256(-amount1)); + if (amount0 < 0 && amount0Max < uint256(-amount0)) { + revert MaximumAmountExceeded(uint256(amount0Max), uint256(-amount0)); + } + if (amount1 < 0 && amount1Max < uint256(-amount1)) { + revert MaximumAmountExceeded(uint256(amount1Max), uint256(-amount1)); + } } }