Errors from improper indexing or referencing in mappings, often due to incorrect key choices or updates
Game
Review the calculation order in calculateReward
// SPDX-License-Identifier: MIT// Open me in VSCode and really think before opening the hints!// Add @audit tags wherever suspicious// Go to the solidity docs to complete missing knowledge of what's happening here// Solve by drafting a fix!pragmasolidity ^0.8.0;contract LogicMisorderGame {uint256public finalReward;uint256publicconstant BONUS =50;uint256publicconstant TAX_PERCENT =10;// Function to calculate the final reward based on balance with bonus and tax appliedfunctioncalculateReward(uint256 balance) public {uint256 doubledBalance = balance *2;uint256 rewardWithBonus = doubledBalance + BONUS; finalReward = rewardWithBonus - (rewardWithBonus * TAX_PERCENT /100); }}
Think about whether the bonus should be taxed or only the userโs balance. Should the bonus be added before or after applying the tax?
Consider how adding the bonus after applying the tax might better align with the intended logic of rewarding the userโs balance.