Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: low
Valid

Inconsistent `rarity` distribution

The constants suggest the following rarity distribution:

uint256 public constant COMMON_RARITY = 70;
uint256 public constant RARE_RARITY = 25;
uint256 public constant LEGENDARY_RARITY = 5;

which leads to an intended likelihood of:

  • Common: 70%

  • Rare: 25%

  • Legendary: 5%

However, the implementation dictates the following logic of receiving the following rarity of NFT:

if (rarity <= COMMON_RARITY) {
tokenIdToRarity[tokenId] = COMMON_RARITY;
} else if (rarity <= COMMON_RARITY + RARE_RARITY) {
tokenIdToRarity[tokenId] = RARE_RARITY;
} else {
tokenIdToRarity[tokenId] = LEGENDARY_RARITY;
}

Which leads to an actual likelihood:

  • Common: 71%

  • Rare: 25%

  • Lenendary: 4%

Impact

This is nothigh impact however to be consistent with the perceived intended behavior. This is therefore a low-severity finding.

Recommended Mitigation

Modify the comparison logic to be be strictly less, <, rather than less than or equal to, <=.

Updates

Lead Judging Commences

Hamiltonite Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

wrong nft rarity

71% 25% 4%

Support

FAQs

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