From d4b7da89d22b3da56b21c45b5249e97a11c4af6f Mon Sep 17 00:00:00 2001 From: Eric Zhong Date: Fri, 2 Aug 2024 11:21:06 -0400 Subject: [PATCH] wrap input scale in unchecked block (#264) --- ...riorityOrderReactor-BaseExecuteSingleWithFee.snap | 2 +- .../Base-PriorityOrderReactor-ExecuteBatch.snap | 2 +- ...rityOrderReactor-ExecuteBatchMultipleOutputs.snap | 2 +- ...r-ExecuteBatchMultipleOutputsDifferentTokens.snap | 2 +- ...riorityOrderReactor-ExecuteBatchNativeOutput.snap | 2 +- .../Base-PriorityOrderReactor-ExecuteSingle.snap | 2 +- ...iorityOrderReactor-ExecuteSingleNativeOutput.snap | 2 +- ...PriorityOrderReactor-ExecuteSingleValidation.snap | 2 +- .../Base-PriorityOrderReactor-InputPriorityFee.snap | 2 +- .../Base-PriorityOrderReactor-OutputPriorityFee.snap | 2 +- ...ctor-OutputPriorityFeeAndBaselinePriorityFee.snap | 2 +- ...orityOrderReactor-OverrideAuctionTargetBlock.snap | 2 +- src/lib/PriorityFeeLib.sol | 12 +++++++----- 13 files changed, 19 insertions(+), 17 deletions(-) diff --git a/.forge-snapshots/Base-PriorityOrderReactor-BaseExecuteSingleWithFee.snap b/.forge-snapshots/Base-PriorityOrderReactor-BaseExecuteSingleWithFee.snap index 13b30f54..9b35f8dc 100644 --- a/.forge-snapshots/Base-PriorityOrderReactor-BaseExecuteSingleWithFee.snap +++ b/.forge-snapshots/Base-PriorityOrderReactor-BaseExecuteSingleWithFee.snap @@ -1 +1 @@ -184811 \ No newline at end of file +184760 \ No newline at end of file diff --git a/.forge-snapshots/Base-PriorityOrderReactor-ExecuteBatch.snap b/.forge-snapshots/Base-PriorityOrderReactor-ExecuteBatch.snap index c8bd3714..6145fbbf 100644 --- a/.forge-snapshots/Base-PriorityOrderReactor-ExecuteBatch.snap +++ b/.forge-snapshots/Base-PriorityOrderReactor-ExecuteBatch.snap @@ -1 +1 @@ -202966 \ No newline at end of file +202864 \ No newline at end of file diff --git a/.forge-snapshots/Base-PriorityOrderReactor-ExecuteBatchMultipleOutputs.snap b/.forge-snapshots/Base-PriorityOrderReactor-ExecuteBatchMultipleOutputs.snap index 2aa5ecd1..4dffb943 100644 --- a/.forge-snapshots/Base-PriorityOrderReactor-ExecuteBatchMultipleOutputs.snap +++ b/.forge-snapshots/Base-PriorityOrderReactor-ExecuteBatchMultipleOutputs.snap @@ -1 +1 @@ -212779 \ No newline at end of file +212677 \ No newline at end of file diff --git a/.forge-snapshots/Base-PriorityOrderReactor-ExecuteBatchMultipleOutputsDifferentTokens.snap b/.forge-snapshots/Base-PriorityOrderReactor-ExecuteBatchMultipleOutputsDifferentTokens.snap index 97418d55..c08ba595 100644 --- a/.forge-snapshots/Base-PriorityOrderReactor-ExecuteBatchMultipleOutputsDifferentTokens.snap +++ b/.forge-snapshots/Base-PriorityOrderReactor-ExecuteBatchMultipleOutputsDifferentTokens.snap @@ -1 +1 @@ -266488 \ No newline at end of file +266386 \ No newline at end of file diff --git a/.forge-snapshots/Base-PriorityOrderReactor-ExecuteBatchNativeOutput.snap b/.forge-snapshots/Base-PriorityOrderReactor-ExecuteBatchNativeOutput.snap index fd09a5dd..35b655a6 100644 --- a/.forge-snapshots/Base-PriorityOrderReactor-ExecuteBatchNativeOutput.snap +++ b/.forge-snapshots/Base-PriorityOrderReactor-ExecuteBatchNativeOutput.snap @@ -1 +1 @@ -196492 \ No newline at end of file +196390 \ No newline at end of file diff --git a/.forge-snapshots/Base-PriorityOrderReactor-ExecuteSingle.snap b/.forge-snapshots/Base-PriorityOrderReactor-ExecuteSingle.snap index b64a4535..0ae03c94 100644 --- a/.forge-snapshots/Base-PriorityOrderReactor-ExecuteSingle.snap +++ b/.forge-snapshots/Base-PriorityOrderReactor-ExecuteSingle.snap @@ -1 +1 @@ -151202 \ No newline at end of file +151151 \ No newline at end of file diff --git a/.forge-snapshots/Base-PriorityOrderReactor-ExecuteSingleNativeOutput.snap b/.forge-snapshots/Base-PriorityOrderReactor-ExecuteSingleNativeOutput.snap index 3b4c240d..1b224553 100644 --- a/.forge-snapshots/Base-PriorityOrderReactor-ExecuteSingleNativeOutput.snap +++ b/.forge-snapshots/Base-PriorityOrderReactor-ExecuteSingleNativeOutput.snap @@ -1 +1 @@ -136764 \ No newline at end of file +136713 \ No newline at end of file diff --git a/.forge-snapshots/Base-PriorityOrderReactor-ExecuteSingleValidation.snap b/.forge-snapshots/Base-PriorityOrderReactor-ExecuteSingleValidation.snap index 1f90615f..a58b8c1e 100644 --- a/.forge-snapshots/Base-PriorityOrderReactor-ExecuteSingleValidation.snap +++ b/.forge-snapshots/Base-PriorityOrderReactor-ExecuteSingleValidation.snap @@ -1 +1 @@ -160512 \ No newline at end of file +160461 \ No newline at end of file diff --git a/.forge-snapshots/Base-PriorityOrderReactor-InputPriorityFee.snap b/.forge-snapshots/Base-PriorityOrderReactor-InputPriorityFee.snap index 68759ed6..a947c028 100644 --- a/.forge-snapshots/Base-PriorityOrderReactor-InputPriorityFee.snap +++ b/.forge-snapshots/Base-PriorityOrderReactor-InputPriorityFee.snap @@ -1 +1 @@ -153387 \ No newline at end of file +153336 \ No newline at end of file diff --git a/.forge-snapshots/Base-PriorityOrderReactor-OutputPriorityFee.snap b/.forge-snapshots/Base-PriorityOrderReactor-OutputPriorityFee.snap index 7abf3b49..aefb4511 100644 --- a/.forge-snapshots/Base-PriorityOrderReactor-OutputPriorityFee.snap +++ b/.forge-snapshots/Base-PriorityOrderReactor-OutputPriorityFee.snap @@ -1 +1 @@ -153196 \ No newline at end of file +153145 \ No newline at end of file diff --git a/.forge-snapshots/Base-PriorityOrderReactor-OutputPriorityFeeAndBaselinePriorityFee.snap b/.forge-snapshots/Base-PriorityOrderReactor-OutputPriorityFeeAndBaselinePriorityFee.snap index 572ffae6..4d84b09c 100644 --- a/.forge-snapshots/Base-PriorityOrderReactor-OutputPriorityFeeAndBaselinePriorityFee.snap +++ b/.forge-snapshots/Base-PriorityOrderReactor-OutputPriorityFeeAndBaselinePriorityFee.snap @@ -1 +1 @@ -153190 \ No newline at end of file +153139 \ No newline at end of file diff --git a/.forge-snapshots/Base-PriorityOrderReactor-OverrideAuctionTargetBlock.snap b/.forge-snapshots/Base-PriorityOrderReactor-OverrideAuctionTargetBlock.snap index f3237257..d7955f10 100644 --- a/.forge-snapshots/Base-PriorityOrderReactor-OverrideAuctionTargetBlock.snap +++ b/.forge-snapshots/Base-PriorityOrderReactor-OverrideAuctionTargetBlock.snap @@ -1 +1 @@ -130640 \ No newline at end of file +130589 \ No newline at end of file diff --git a/src/lib/PriorityFeeLib.sol b/src/lib/PriorityFeeLib.sol index 14f09e15..4dabed80 100644 --- a/src/lib/PriorityFeeLib.sol +++ b/src/lib/PriorityFeeLib.sol @@ -24,11 +24,13 @@ library PriorityFeeLib { if (scalingFactor >= MPS) { return InputToken({token: input.token, amount: 0, maxAmount: input.amount}); } - return InputToken({ - token: input.token, - amount: input.amount.mulDivDown((MPS - scalingFactor), MPS), - maxAmount: input.amount - }); + unchecked { + return InputToken({ + token: input.token, + amount: input.amount.mulDivDown((MPS - scalingFactor), MPS), + maxAmount: input.amount + }); + } } /// @notice returns a scaled output using the current priority fee and mpsPerPriorityFeeWei