Last Man Standing

First Flight #45
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Severity: low
Valid

Integer Division Truncation in Fee Calculation

Integer Division Truncation Prevents Claim Fee From Increasing, Breaking Game Progression

Description

  • Solidity performs integer division, which truncates any fractional results. When small values are involved, this truncation can cause calculations to result in zero when a non-zero value was expected.

  • In the current implementation, claimFee is increased using the formula:

  • If claimFee is small (e.g., 5 wei) and feeIncreasePercentage is 1, the resulting increase becomes zero due to truncation.

  • (5 * 1) / 100 = 0

claimFee = claimFee + (claimFee * @>feeIncreasePercentage<@) / 100;

Risk

Likelihood:

  • Occurs whenever claimFee or feeIncreasePercentage are small, which is especially likely during the early phase of the game or with precision-sensitive tokens.

Impact:

  • Fee does not increase as intended, breaking core game mechanics

  • Could allow players to bypass economic friction, potentially exploiting game rules.

Proof of Concept

uint256 claimFee = 5;
uint256 feeIncreasePercentage = 1;
claimFee = claimFee + (claimFee * feeIncreasePercentage) / 100;
// Result: claimFee remains 5 due to (5 * 1) / 100 == 0

Recommended Mitigation

- claimFee = claimFee + (claimFee * feeIncreasePercentage) / 100;
+ claimFee = claimFee + ((claimFee * feeIncreasePercentage + 99) / 100); // Round up
Or consider enforcing a minimum increment using max() utility:
+ uint256 increase = (claimFee * feeIncreasePercentage) / 100;
+ if (increase == 0) increase = 1; // Ensure at least 1 wei increase
+ claimFee = claimFee + increase;
Updates

Appeal created

inallhonesty Lead Judge about 1 month ago
Submission Judgement Published
Validated
Assigned finding tags:

Precision loss in fee calc

Support

FAQs

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