The calculateAmountsFromFee
function in the Helpers
library, which calculates a fee and net amount based on an input totalAmount
and a fee rate (fee
). It was identified that inconsistent or varying fee rates can be applied to the same totalAmount
, resulting in distinct outputs for different fee rates. This behaviour, though technically functional, could be problematic when higher or lower fee rates are applied leading to users paying varying fees for the same amounts.
The function calculateAmountsFromFee
calculates a fee based on a provided feeRate
and a totalAmount
. The library does not enforce any restrictions or validation on the feeRate
parameter, allowing different fee rates to be applied to the same totalAmount
. This inconsistency can be problematic in cases where a fixed or standard fee rate is expected.
Please the test below in your test file
This vulnerability could result in inconsistent user experiences, as users may encounter varying fee calculations on identical amounts, leading to confusion and reduced trust in the protocol. Additionally, it opens the door to potential arbitrage, where users might exploit adjustable fee rates to minimize fees, ultimately creating revenue inconsistencies for the protocol as users manipulate rates to lower their obligations.
Manual Review
It is recommended the following actions be taken:
Implement Fixed Fee Rate: If a consistent fee rate is expected, consider hard-coding or standardizing the feeRate
value within the contract rather than passing it as a parameter.
Add Validation Checks: To prevent unintended fee rate values, add checks that enforce acceptable ranges for feeRate
. This can reduce the risk of extreme values leading to unexpected feeAmount
and netAmount
results.
While the calculateAmountsFromFee
function works as intended, its flexibility in accepting different feeRate
values can lead to inconsistencies that may affect user experience and protocol revenue. Applying the recommended fixes will help ensure consistent fee calculations and a more predictable protocol behavior.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.