Last Man Standing

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

Previous King Payout Missing

Description

  • In the intended game design, when a player claims the throne, a portion of their claim fee should be paid to the previous king. This incentivizes participation and rewards dethroned kings.

  • However, the code does not implement this mechanic. The variable previousKingPayout is defined but never assigned or used, resulting in no payout for dethroned kings.

function claimThrone() external payable gameNotEnded nonReentrant {
// ...snip...
uint256 previousKingPayout = 0; // <-- always zero, never assigned
// ...snip...
// Defensive check to ensure platformFee doesn't exceed available amount after previousKingPayout
if (currentPlatformFee > (sentAmount - previousKingPayout)) {
currentPlatformFee = sentAmount - previousKingPayout;
}
platformFeesBalance = platformFeesBalance + currentPlatformFee;
// Remaining amount goes to the pot
amountToPot = sentAmount - currentPlatformFee;
pot = pot + amountToPot;
// ...snip...
}

Risk

Likelihood:

  • This will occur every time a new player claims the throne after the initial round.

  • No dethroned king will ever receive their intended payout.

Impact:

  • Dethroned kings have no financial incentive to participate further.

  • The absence of this reward undermines engagement, game fairness, and retention.

Proof of Concept

// previousKingPayout is always zero, no transfer to previous king
uint256 previousKingPayout = 0; // <-- always zero, never assigned

Explanation:
The payout logic is missing. Even though the variable exists, it is never set to a meaningful value nor used to update balances for the previous king. The code thus breaks a fundamental incentive of the game.

Recommended Mitigation

- uint256 previousKingPayout = 0;
+ uint256 previousKingPayout = (sentAmount * previousKingPercentage) / 100;
+ if (currentKing != address(0)) {
+ pendingWinnings[currentKing] += previousKingPayout;
+ }

Mitigation Explanation:
Add a configurable percentage (previousKingPercentage) and update the previous king's pending winnings. This restores the intended payout mechanic and aligns incentives with the game’s design.

Updates

Appeal created

inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Missing Previous King Payout Functionality

Support

FAQs

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

Give us feedback!