Last Man Standing

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

## Incorrect payment for previous king in claimThrone() ## [ Previous king gets no payout ]

Root + Impact

Description

The claimThrone function breaks the intended game logic. According to the project documentation:

“A small portion of the new claim fee is sent to the previous king.”

However, the current implementation does not send any payout to the dethroned king when a new player claims the throne. This results in economic unfairness, where the dethroned king loses their entire claim fee without compensation.

The previous king gets no payout, even though the project description says they should.


Risk

Likelihood: High

This occurs every time a new player claims the throne and dethrones a previous king.


Impact:

  • Previous kings do not receive their intended reward

  • Game dynamics become harsh and less rewarding

Proof of Concept

Player A is king
Player B pays claimFee and successfully calls claimThrone()
Before setting currentKing = msg.sender
A small portion of Player B's fee should go to Player A, but receives nothing

Recommended Mitigation

Recommended Code Fix:

+ address previousKing = newKing;
- require(msg.sender == newKing, "Game: You are already the king. No need to re-claim.");
+ require(msg.sender == newKing, "Game: You are already the king. No need to re-claim.");
// Payout to previous king
+ uint256 public previousKingPayoutPercentage = 10; // example: 10%
+ if (previousKing != address(0)) {
+ previousKingPayout = (sentAmount * previousKingPayoutPercentage) / 100;
+ payable(previousKing).transfer(previousKingPayout);
+ }
// Calculate platform fee
currentPlatformFee = (sentAmount * platformFeePercentage) / 100;
+ uint256 remainingAfterPayout = setAmount - previousKingPayout;
+ if (currentPlatformFee > remainingAfterPayout) {
+ currentPlatformFee = remainingAfterPayout;
+ }
+ platformFeesBalance += currentPlatformFee;
+ amountToPot = remainingAfterPayout - currentPlatformFee;
+ pot += amountToPot;
Updates

Appeal created

inallhonesty Lead Judge about 1 month 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.