Skip to content
Business logic Audit finding Intermediate

Incorrect calculation of deposited rewards yeet leads to Staker's not being able to get their staked amount back

The reward-accumulation function counts tokens that a staker has queued for unstaking as undistributed rewards, because the unstake amount is removed from totalSupply but not from the contract balance. The manager then distributes those tokens as rewards, leaving too little in the contract for the staker to withdraw their stake.

Oxgritty Follow

Originally disclosed on Immunefi

Critical View original
  • Disclosed after under an hour

#41894 [SC-Critical] Incorrect calculation of deposited rewards yeet leads to Staker's not being able to get their staked amount back

Submitted on Mar 19th 2025 at 08:41:12 UTC by @Oxgritty for Audit Comp | Yeet

Description

Brief/Intro

  • StakingV2::accumulatedDeptRewardsYeet is used to calculate the amount of accumulated rewards in yeet that are not distributed yet.
  • The problem here is that, this function doesn't account for the fact that when a staker calls StakingV2::startUnstake to start unstaking, their balance is still in the contract but subtracted from the totalSupply, so StakingV2::accumulatedDeptRewardsYeet mistakes the unstake amount as undistributed rewards.

Vulnerability Details

  • When the manager would want to distribute rewards through StakingV2::executeRewardDistributionYeet, he would first call the StakingV2::accumulatedDeptRewardsYeet to know the amount available for distribution. This function would return an amount which includes the unStakeAmount, which staker unstaked by calling StakingV2::startUnstake.
  • When the manager will call StakingV2::executeRewardDistributionYeet, it will convert (undistributed rewards + unStakeAmount) into vaultShares, meaning when the staker would call StakingV2::unstake to get his unStakeAmount amount back, this contract won't have enough unStakeAmount of stakingToken and function will revert.

Impact Details

Stakers not being able to withdraw their staked amount as the contract will not have enough funds.

References

  • When a staker calls StakingV2::startUnstake his unstake amount will be deducted from the totalSupply.
  • This unstake amount is not deducted in StakingV2::accumulatedDeptRewardsYeet.

Proof of Concept

POC: (NOTE: StakingToken is YEET)

Step 0: Checking Current Balances

  • totalSupply = 0
  • stakingToken.balanceOf(address(this)) = 0

Step 1: Staking

  1. Alice(a staker) calls StakingV2::stake to stake 100e18 Yeet.
  2. Bob(another staker) calls StakingV2::stake to stake 50e18 Yeet.

Current Balances:

  • totalSupply = 150e18
  • stakingToken.balanceOf(address(this)) = 150e18

Step 2: Initiating Unstaking process

Alice initiates unstaking process by calling StakingV2::startUnstake where unStakeAmount=100e18

Current Balances:

  • totalSupply = 50e18
  • stakingToken.balanceOf(address(this)) = 150e18

Step 3: Manager checks amount of stakingToken available for distribution by calling StakingV2::accumulatedDeptRewardsYeet. This function will return 100e18(150e18 - 50e18).

Step 4: Manager calls StakingV2::executeRewardDistributionYeet to distribute yeet rewards.

Here the value of (stakingParams.amount0Max + swapData.inputAmount would be equal to 100e18). After the execution of this function, the contract would have 100e18 yeet worth of vault Shares and 50e18 Yeet.

Current Balance:

  • totalSupply = 50e18
  • stakingToken.balanceOf(address(this)) = 50e18

Step 5: Finalize unstaking and get unStakeAmount back

Alice calls StakingV2::unstake to get her unStakeAmount(100e18) back.
This function will fail because StakingV2.sol has only 50e18 Yeet.

The original report as published on Immunefi, by Oxgritty. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the accumulated-rewards calculation derives available rewards from totalSupply rather than the actual token balance, so tokens held for pending unstakes are counted as distributable rewards.

Impact

Stakers cannot withdraw their staked amount because the contract no longer holds enough tokens, which the report describes as protocol insolvency.

What the attacker needed

A staker queues an unstake; manager distributes rewards before it finalises

How it was found

  1. Alice stakes 100e18 Yeet and Bob stakes 50e18 Yeet, so totalSupply and the contract balance are both 150e18.
  2. Alice calls startUnstake for 100e18, which lowers totalSupply to 50e18 while the contract still holds 150e18.
  3. The manager calls accumulatedDeptRewardsYeet, which returns 100e18 because it subtracts totalSupply from the balance.
  4. The manager calls executeRewardDistributionYeet, converting that 100e18 into vault shares and leaving only 50e18 Yeet in the contract.
  5. Alice calls unstake for her 100e18 and the transaction reverts because the contract holds only 50e18.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A staking contract holds people's tokens and also pays out rewards. When someone asks to unstake, their tokens stay in the contract for a while but are no longer counted as 'staked'. The reward calculation wrongly treats those waiting tokens as spare rewards and hands them out, so the original owner cannot get their money back.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by Oxgritty

View all

5 more disclosed reports, best first.

More from Yeet

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.