sherlock-audit / 2024-08-saffron-finance-judging

9 stars 5 forks source link

0xMaroutis - Incorrect `FixedEarlyExitFees` calculation leads to significantly reduced fees #88

Open sherlock-admin2 opened 2 months ago

sherlock-admin2 commented 2 months ago

0xMaroutis

Medium

Incorrect FixedEarlyExitFees calculation leads to significantly reduced fees

Summary

The calculateFixedEarlyExitFees function has an error in the percentage calculation for early exit fees, potentially resulting in significantly lower fees than intended.

Vulnerability Detail

In the calculateFixedEarlyExitFees function, the early exit fee is calculated using the following formula:

uint256 earlyExitFees = upfrontPremium.mulDiv((1 + earlyExitFeeBps).mulDiv(remainingProportion, 1e18), 10000);

The intention is to calculate a yield using the formula (1 + r), where r is the rate expressed in basis points. However, since the calculation works in basis points, the "1" in this formula should actually be represented as 10,000 basis points.

Impact

Code Snippet

https://github.com/sherlock-audit/2024-08-saffron-finance/blob/38dd9c8436db341c331f1b14545770c1766fc0ee/lido-fiv/contracts/LidoVault.sol#L992

Tool used

Manual Review

Recommendation

Implement the following :

uint256 earlyExitFees = upfrontPremium.mulDiv((10_000 + earlyExitFeeBps).mulDiv(remainingProportion, 1e18), 10000);