-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decrease rate for Exponential Descending Sales is always zero #746
Comments
141345 marked the issue as primary issue |
a2rocket (sponsor) disputed |
price changes based on this price = collectionPhases[_collectionId].collectionMintCost / (tDiff + 1); so if decreaserate = 0 it does not return the collectionmintingcost. |
141345 marked the issue as sufficient quality report |
The Warden specifies that prices are incorrectly calculated, however, they apply a calculation elimination that is incompatible with Solidity due to mathematical truncation. Specifically, the statement As such, I consider this exhibit to be invalid. EDIT: After further analyzing the code, my verdict stands. Apart from the numerator and denominator nullification that was incorrectly carried out, the base price calculation is
As such, a Sure, there may be a better way to represent the calculations but they are presently correct. |
alex-ppg marked the issue as unsatisfactory: |
alex-ppg marked the issue as unsatisfactory: |
Lines of code
https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/MinterContract.sol#L551
https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/MinterContract.sol#L559-L560
Vulnerability details
Summary
There is an error in the calculation that makes the decrease rate to always be zero when calculating the price of exponential descending mintings.
This report is aware about the comment on the Readme regarding rounding errors, but it is not related to the finding being presented here, as this is regardless
Impact
Exponential Descending Sales will always be priced at their initial price, which is the highest expected for this kind of sale.
This will affect all NFTs sales using this model, discouraging all sales, as the price will always be at its maximum.
Proof of Concept
If the decrease rate is zero for exponential descending sales, it will always return the maximum price, which is used for token minting/sales:
The formula is defined as:
Let's replace the variables with easier to read ones:
We'll show how the right-most term is zero:
((NOW - (tDiff * TIME_PERIOD) - START_TIME)) == 0
, meaning that regardless of the rest,decreaserate
will be zero.In other words:
Let's verify how
NOW - (tDiff * TIME_PERIOD) - START_TIME
is always zero, by replacingtDiff
in the equation:The
TIME_PERIOD
term can be canceled:Removing the parenthesis (and operating the substraction):
We're mindful of Solidity precision errors, but as shown above, this is not the case here, but an error in the calculations making the decrease rate be always zero, or towards zero at most.
Tools Used
Manual Review
Recommended Mitigation Steps
Review the implemented formula to implement an exponential descending model correctly. Separate internal calculations to make clear what they actually do. Here's a debate on how ENS does it: https://discuss.ens.domains/t/exponential-price-decay-contract/10125.
Assessed type
Math
The text was updated successfully, but these errors were encountered: