hats-finance / Tokemak-0x4a2d708ea6b0c04186ecb774cfad1e50fb5efc0b

0 stars 0 forks source link

Division by zero not prevented #11

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

The divisions below take an input parameter which does not have any zero-value checks, which may lead to the functions reverting when zero is passed.

Instances (13):

File: LMPStrategy.sol

399:         uint256 slippage = outEthValue == 0 ? 0 : swapCost * 1e18 / outEthValue;

435:                     if (((priceSafe * 1.0e18 / priceSpot - 1.0e18) * 10_000) / 1.0e18 > tolerance) {

454:                 if (((priceSpot * 1.0e18 / priceSafe - 1.0e18) * 10_000) / 1.0e18 > tolerance) {

515:             destInfo.ownedShares == 0 ? 0 : ((destInfo.currentDebt * currentShares) / destInfo.ownedShares);

544:             destInfo.ownedShares == 0 ? 0 : destInfo.currentDebt * currentShares / destInfo.ownedShares;

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

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

798:                         totalRewards += rewardRate * tokenPrice / rewardDivisor;

811:                         totalRewards += rewardRate * tokenPrice / rewardDivisor;

826:             totalSupplyInEth = stats.safeTotalSupply * lpPrice / lpTokenDivisor;

833:             return (totalRewards * 1e18) / totalSupplyInEth;

876:                         scalingFactor >>= (timeSinceDiscountSec / halfLifeSec);

972:             : (uint40(block.timestamp) - lastRebalanceTimestamp) / 1 days / uint40(swapCostOffsetRelaxThresholdInDays);
codenutt commented 5 months ago

All referenced lines have 0 value checks in one form or another