hats-finance / Tokemak-0x4a2d708ea6b0c04186ecb774cfad1e50fb5efc0b

0 stars 0 forks source link

Possible rounding issue #13

Open hats-bug-reporter[bot] opened 5 months ago

hats-bug-reporter[bot] commented 5 months ago

Github username: -- Twitter username: -- Submission hash (on-chain): 0xdfcb7680f60a31235951712f2ff8cee290c974857b412632b341454222695d19 Severity: low

Description: Description\ Division by large numbers may result in the result being zero, due to solidity not supporting fractions. Consider requiring a minimum amount for the numerator to ensure that it is always larger than the denominator. Also, there is indication of multiplication and division without the use of parenthesis which could result in issues.

Instances (4):

File: LMPStrategy.sol

560:             return destValueAfterRebalance * 1e18 / lmpAssetsAfterRebalance >= trimAmount;

720:             result.baseApr = interimStats.baseApr / reservesTotal;

721:             result.priceReturn = interimStats.priceReturn / convertUintToInt(reservesTotal);

833:             return (totalRewards * 1e18) / totalSupplyInEth;
codenutt commented 5 months ago

The line 560: This is a 1e18 * 1e18 / 1e18 value, sufficiently large

The line 720: interimStats.baseApr is already an apr value multiplied by a 1e18 value number. It will be sufficiently large

The line 721: interimStats.priceReturn is already a 1e18 price multiplied by a 1e18 reserve value. It will be sufficiently large

The line 833: numerator is a 1e36 value divided by 1e18. sufficiently large

Given the padding that is already happening in the numerator for all of these instances if the denominator is still big enough to put the end result at 0 then 0 is the appropriate value.