The calculation of the Stalk reward is based on the start stems, end stems, and the amount of BDV deposited. The comment states that 'endStem must be larger than startStem.', however there is no check to ensure endStem is larger than startStem. When endStem is less than startStem, resulting in a negative value for endStem.sub(startStem). When the calculation converts a negative int96 value to uint96, it leads to an unexpected large positive value due to how unsigned integers handle negative values. This can cause the calculation to produce incorrect results.
Test:
Result:
When the calculation converts a negative int96 value to uint96, it leads to an unexpected large positive reward. This can cause the calculation to produce incorrect results.
Manual review & Foundry
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.