DeFiHardhatFoundry
250,000 USDC
View results
Submission Details
Severity: low
Invalid

Mismatch between comments and functionality of `Sun:stepSun`

Summary

The stepSun function within the Sun contract is responsible for adjusting the Soil supply based on the output of an oracle (Oracle.stepOracle) and a weather calculation (Weather.calcCaseId).

Vulnerability Details

See the following code:

function stepSun(int256 deltaB, uint256 caseId) internal {
// Above peg
if (deltaB > 0) {
uint256 priorHarvestable = s.sys.fields[s.sys.activeField].harvestable;
C.bean().mint(address(this), uint256(deltaB));
LibShipping.ship(uint256(deltaB));
setSoilAbovePeg(s.sys.fields[s.sys.activeField].harvestable - priorHarvestable, caseId);
s.sys.season.abovePeg = true;
}
// Below peg
else {
setSoil(uint256(-deltaB));
s.sys.season.abovePeg = false;
}
}

The issue in the stepSun function revolves around the condition for minting Soil (setSoilAbovePeg) based on the deltaB parameter:

  • The comment and logic suggest that Soil should be minted when deltaB > 0 (indicating a surplus scenario). However, the comment incorrectly states that deltaB >= 0 should be used. This discrepancy can lead to confusion and incorrect minting decisions.

  • Depending on the actual implementation and the expected behavior during different conditions (deltaB > 0 vs deltaB <= 0), the logic might not accurately reflect the intended minting behavior of Soil. This can lead to unexpected changes in Soil supply, affecting the overall stability and functionality of the contract.

Impact

Incorrect minting decisions based on deltaB can lead to inaccuracies in Soil supply, potentially disrupting the intended economic model of the Sun contract. If deltaB conditions are not correctly handled, it could open up the contract to unintended scenarios where Soil is minted incorrectly, possibly impacting the financial integrity or stability of the application.

Tools Used

Manual Review

Recommendations

Ensure that the comments and the actual condition (deltaB > 0) align with the intended logic for minting Soil. Correct any discrepancies in the comments to accurately reflect the implemented logic.

Updates

Lead Judging Commences

inallhonesty Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational/Gas

Invalid as per docs https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity

Support

FAQs

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