The getInputAmountBasedOnOutput function miscalculates the fee by scaling the amount by 10,000 instead of 1,000, causing the protocol to take more tokens from users than intended.
The function getInputAmountBasedOnOutput calculates the input amount required to receive a specified output amount of tokens. During this calculation, the function applies a fee by scaling the output amount by 10,000 instead of the correct value of 1,000. This incorrect scaling results in the protocol charging users higher fees than expected.
The incorrect fee calculation results in users being charged more tokens than necessary, leading to lost fees for the users and potentially reducing their trust in the protocol. This overcharging can significantly affect user experience and the overall usability of the platform.
//(((1000 * 100) * 10000) / ((1000 - 100) * 997)) === 1114.45447453
//(((1000 * 100) * 1000) / ((1000 - 100) * 997)) === 111.445447453
Manual Code Review + foundry Unit Test .
Correct the fee scaling factor in the getInputAmountBasedOnOutput function from 10,000 to 1,000. This adjustment ensures the protocol charges the appropriate fee and maintains user trust.
Proposed implementation:
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.