FV-SOL-5-C1 Boundary Misalignment
TLDR
Occurs when code fails to respect predefined boundaries or intervals (e.g., epochs, time windows, thresholds)
Game
Examine how setRewardTier
assigns reward tiers based on the score
value. Can you identify any boundary misalignments in the conditions that might cause scores on the boundary to be assigned incorrectly?
// 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!
pragma solidity ^0.8.0;
contract BoundaryMisalignmentGame {
uint256 public rewardTier;
// Function to assign a reward tier based on score
function setRewardTier(uint256 score) public {
if (score < 50) {
rewardTier = 1;
} else if (score <= 100) {
rewardTier = 2;
} else if (score < 150) {
rewardTier = 3;
} else {
rewardTier = 4;
}
}
}
Last updated
Was this helpful?