Skip to content
Business logic Audit finding Intermediate

There is no way for the `admin` to sweep `rewards` lost due to precision

When reward tokens are streamed, integer division when computing the reward rate leaves small amounts of tokens stranded in the contract. Because no sweep function exists, those leftover tokens can never be recovered by the admin.

0xShoonya Follow with BADROBINX, ExtraCaterpillar and 9 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-08-usg-tangent-judging/issues/432

This issue has been acknowledged by the team but won't be fixed at this time.

Found by

0xShoonya, BADROBINX, ExtraCaterpillar, Obsidian, Pianist, VictorUbi, ami, joicygiore, silver_eth, v1c7, wickie, yaioxy

Summary

When Rewards are being distributed, Precision will take place, and when it does, those tokens will be stuck in that contract with no way of being recovered, since there is no function to get them back

Root Cause

The contract has no function to recover tokens lost due to precision.

Attack Path

  1. VsTAN::processRewards is called by the owner and adding 10000 USG
  2. Resulting in 165 343 915 343 915 rewardRate.
  3. As this will go on for 7 days, which means per Second' 16 534 391 534 391 534 is given.
  4. Let's say there was only 1e18 supply and no update rewards have not been called for 7 days for simplicity, which calculates this
Solidity
(((_lastTimeRewardApplicable(rewardData[_rewardToken].periodFinish) - rewardData[_rewardToken].lastUpdateTime) * rewardData[_rewardToken].rewardRate * 1e18) /
                totalSupplyVsTan)
Solidity
((((block.timestamp) - ((block.timestamp - 7 days))) * 16534391534391534) * 1e18 /
                1e18)
  • Answer: 9999999999999999763200.. Loss = 236 800
  1. Now this precision value gets bigger when it comes to low decimal tokens like USDC, which would cause rewardRate to be 16 534.
  2. The loss for 6 decimal token is = 236 800.. which in 5 cycles is more than $1.. Also happens in AccumulatorReward
  3. With RewardAccumulator holding all rewards and updating of rewards, precision will happen, but those tokens won't be able to get recovered

Code

<details> <summary>Click to Show</summary>
Solidity
if (block.timestamp >= rData.periodFinish) {
            rData.rewardRate = rewardAmountStreamed / REWARDS_DURATION;
        } else {
            rData.rewardRate = (rewardAmountStreamed + (rData.periodFinish - block.timestamp) * rData.rewardRate) / REWARDS_DURATION;
        }
</details> <details> <summary>Click to Show</summary>
Solidity
       if (timestamp >= rData.periodFinish) {
                rewardData[rewardToken].rewardRate = amount / ONE_WEEK;
            } else {
                uint256 leftover = (rData.periodFinish - timestamp) * rData.rewardRate;
                rewardData[rewardToken].rewardRate = (amount + leftover) / ONE_WEEK;
            }
</details>

Impact

The funds lost to precision cannot be recovered

Recommendation

Add a function that would be able to sweep Reward Tokens stuck in a contract

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

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

Impact

Small amounts of reward tokens are permanently stranded in the contract, and the loss grows with low-decimal tokens and repeated cycles.

What the attacker needed

Owner distributes rewards; reward amount not divisible evenly

The fix

A sweep function should be added so the admin can recover reward tokens left in the contract.

How it was found

  1. The owner calls the reward processing function and adds a reward amount.
  2. The contract divides the amount by the reward duration to get a per-second reward rate.
  3. The division truncates, so the total streamed is slightly less than the amount added.
  4. The difference stays in the contract with no function to withdraw it.

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 smart contract often splits a pot of tokens across many seconds by dividing the total by the duration. Whole-number maths throws away the remainder, so a tiny amount of tokens stays in the contract. Here nothing lets the owner withdraw that leftover, so it is stuck forever.

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 0xShoonya

View all

8 more disclosed reports, best first.

More from USG - Tangent

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.