Beginner FriendlyFoundryDeFiOracle
100 EXP
View results
Submission Details
Severity: low
Invalid

`getCalculatedFee` function calculates a fee for flash loans based on the input parameters and the `s_feePrecision` variable

Summary

The contract's getCalculatedFee function calculates a flash loan fee using the s_feePrecision variable. If s_feePrecision is not set correctly during contract deployment, it can lead to inaccurate fee calculations during flash loans.

Vulnerability Details

The getCalculatedFee function calculates a fee for flash loans based on the input parameters and the s_feePrecision variable.

function getCalculatedFee(IERC20 token, uint256 amount) public view returns (uint256 fee) {
uint256 valueOfBorrowedToken = (amount * getPriceInWeth(address(token))) / s_feePrecision;
fee = (valueOfBorrowedToken * s_flashLoanFee) / s_feePrecision;
}

The s_feePrecision variable is intended to define the precision for calculating fees. However, if it's set incorrectly during contract deployment, it can lead to inaccurate fee calculations, potentially causing flash loan fees to be significantly different from what is expected.

Impact

The impact of the flash loan fee precision issue can be significant:

  • Inaccurate Fee Calculation: If s_feePrecision is set to an incorrect value during contract deployment, it can result in inaccurate fee calculations for flash loans. Users may be charged fees that are significantly different from what they anticipate.

  • Financial Loss: Users relying on accurate fee calculations may experience financial losses if fees are miscalculated.

Tools Used

Manual

Recommendations

  1. Initialize s_feePrecision with Correct Value: During contract deployment, ensure that the s_feePrecision state variable is initialized with the correct value, defining the precision for fee calculations.
    correctly setting s_feePrecision, you ensure that flash loan fees are accurately calculated, reducing the risk of financial losses for users.

    constructor() {
    s_feePrecision = 1e18; // Set the appropriate precision value (e.g., 1e18 for 18 decimals)
    s_flashLoanFee = 3e15; // Set the appropriate flash loan fee
    }
Updates

Lead Judging Commences

0xnevi Lead Judge
over 1 year ago
0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Other

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.