Math error in getPrice
when sale option is 2
#825
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-746
sponsor disputed
Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
sufficient quality report
This report is of sufficient quality
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2023-10-nextgen/blob/2467db02cc446374ab9154dde98f7e931d71584d/smart-contracts/MinterContract.sol#L540-L551
Vulnerability details
Impact
Math error in
getPrice
when sale option is 2, get price return wrong value.Proof of Concept
When saleoption is 2 and rate is 0,let's take a look at this calcution.
decreaserate = ((price - (collectionPhases[_collectionId].collectionMintCost / (tDiff + 2))) / collectionPhases[_collectionId].timePeriod) * ((block.timestamp - (tDiff * collectionPhases[_collectionId].timePeriod) - collectionPhases[_collectionId].allowlistStartTime));
I try to simplify this formula.
Fist,we set some values:
Now we look at this formula.
decreaserate is always
0 and price will not change.Poc:
logs: notice price at end and current will not change
crate a new file and paste it
Tools Used
hardhat
Recommended Mitigation Steps
modify formula
Assessed type
Math
The text was updated successfully, but these errors were encountered: