Stakers Could Not Withdraw Their Assets
The LT.sol contract allows the staked token supply to become as low as 1, which prevents multiple stakers from withdrawing their assets because they cannot withdraw partial amounts. Stakers may also experience precision loss when the staked supply is small.
Source: https://github.com/sherlock-audit/2025-08-yield-basis-judging/issues/342
Found by
KupiaSec, ge6a
Summary
In the LT.sol contract, the protocol allows the staked tokens to become 1. This situation leads to the staked supply not being attributed to a single staker but rather to multiple stakers, resulting in the inability for stakers to withdraw their assets.
Root Cause
https://github.com/sherlock-audit/2025-08-yield-basis/blob/main/yb-core/contracts/LT.vy#L359-L361
359: # let's leave at least 1 LP token for staked and for total
360: if staked > 0:
361: token_reduction = min(token_reduction, staked - 1)
Internal pre-conditions
N/A
External pre-conditions
N/A
Attack Path
N/A
Impact
Stakers could not withdraw their assets. Stakers could experience precision loss due to the small value of staked_tokens.
PoC
When stakers attempt to unstake, if the staked_tokens is 1, the staker can only withdraw the entire amount and cannot withdraw a partial amount. This means that if there are several stakers, they would be unable to withdraw their assets. Even if the staked_tokens is not 1, if it is less than 10,000, they still experience a precision loss of more than 0.01%.
Mitigation
359: # let's leave at least 1 LP token for staked and for total
360: if staked > 0:
-361: token_reduction = min(token_reduction, staked - 1)
+361: token_reduction = min(token_reduction, staked - min(staked, MIN_SHARE_REMAINDER))
359: # let's leave at least 1 LP token for staked and for total
360: if staked > 0:
-361: token_reduction = min(token_reduction, staked - 1)
+361: token_reduction = min(token_reduction, staked - min(staked, MIN_SHARE_REMAINDER))
362: if supply > 0:
-363: token_reduction = min(token_reduction, supply - 1)
+363: token_reduction = min(token_reduction, supply - min(supply, MIN_SHARE_REMAINDER))
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 contract enforces a minimum remaining staked amount of only 1, which is too low to support fair proportional withdrawals when multiple stakers exist.
Impact
Stakers could not withdraw their assets, and they could experience precision loss due to the small value of staked_tokens.
What the attacker needed
Multiple stakers; staked supply becomes very small
The fix
The code should be changed to leave a larger minimum remainder (MIN_SHARE_REMAINDER) instead of 1, as shown in the mitigation.
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.
In a staking contract, users deposit tokens and receive shares representing their portion. If the total number of shares becomes extremely small (like 1), the system cannot fairly divide withdrawals among multiple users, so some users cannot take out their funds. This is a precision problem where small numbers cause rounding errors.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.