Execution of orders would revert unexpectedly while baseFee or pairBasedFee equals to MAX_FEE
Summary
The baseFee and pairBasedFee are allowed to set as up to MAX_FEE, but orders would revert unexpectedly due to inconsistent precision processing while calculating fee amount.
Vulnerability Detail
Let's see the case that fee == MAX_FEE (L126) and bFee == MAX_FEE (L133) are allowed.
KingNFT
medium
Execution of orders would revert unexpectedly while
baseFee
orpairBasedFee
equals toMAX_FEE
Summary
The
baseFee
andpairBasedFee
are allowed to set as up toMAX_FEE
, but orders would revert unexpectedly due to inconsistent precision processing while calculating fee amount.Vulnerability Detail
Let's see the case that
fee == MAX_FEE
(L126) andbFee == MAX_FEE
(L133) are allowed.And we can also find the
feeAmount
is rounded up while calculatinggetFeeOutputs()
(L082\~L083).But during check stage, it's rounded down (L090), a Off-by-one error occurs here, which would trigger revert on L091.
Impact
Execution of orders would revert unexpectedly, break of core functionality.
Code Snippet
https://github.com/sherlock-audit/2024-02-rubicon-finance/blob/11cac67919e8a1303b3a3177291b88c0c70bf03b/gladius-contracts-internal/src/fee-controllers/RubiconFeeController.sol#L82
Tool used
Manual Review
Recommendation
Keep the consistent round direction while calculating fee amount
Duplicate of #51