Incorrect Calculation of Mint Price When Mint Count Equals Max Tokens Per Generation #977
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-564
edited-by-warden
🤖_03_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-07-traitforge/blob/279b2887e3d38bc219a05d332cbcb0655b2dc644/contracts/TraitForgeNft/TraitForgeNft.sol#L227-L232
https://github.com/code-423n4/2024-07-traitforge/blob/279b2887e3d38bc219a05d332cbcb0655b2dc644/contracts/TraitForgeNft/TraitForgeNft.sol#L280-L309
Vulnerability details
Impact
The
_mintInternal
function does not correctly handle the case when the number of minted tokens in the current generation equalsmaxTokensPerGen
. This can lead to incorrect mint price calculations when the generation is incremented.As a result, users might encounter errors such as 'Insufficient ETH send for minting.' due to mismatches between the expected and actual mint price.
Proof of Concept
In the provided test code, the issue manifests as follows:
This test reveals that after minting the maximum number of tokens, the next mint attempt fails due to incorrect price calculation.
Tools Used
Manual code review
Recommended Mitigation Steps
This is the mitigated code.
Assessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: