# Stargate `STG` rewards are accounted incorrectly by `StakedStargateAM.sol`

StakedStargateAM fails to reset lastRewardGlobal after Stargate pays out rewards on deposit, causing underflow reverts and lost rewards in reward accounting.

- Payout: Contest reward
- Severity: medium
- Program: Arcadia
- Credited: 0xVolodya
- Disclosed: 2023-12-17
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2023-12-arcadia-judging/issues/38
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-12-arcadia%3AM-1
- Tags: domain:web3 impact:dos impact:funds-loss kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:business-logic vuln:dos vuln:reward-distribution

**Target:** StakedStargateAM asset module / AbstractStakingAM reward accounting
**Root cause:** Stargate's LP_STAKING_TIME.deposit() clears and sends pending rewards to the caller, but StakedStargateAM does not reset assetState[asset].lastRewardGlobal to 0 after mint/increaseLiquidity, so the next _getRewardBalances computes deltaReward = currentRewardGlobal - lastRewardGlobal with a stale, larger lastRewardGlobal.
**Steps:**
1. Deploy fork test in USDbCPool.fork.t.sol; user adds USDbC liquidity to Stargate pool to get LP tokens.
2. Approve and call `stakedStargateAM.mint(address(pool), stakedAmount/4)` to stake LP.
3. `vm.warp(block.timestamp + 10 days)` to accrue STG rewards.
4. Call `stakedStargateAM.increaseLiquidity(tokenId, 1)` — Stargate pays out rewards but lastRewardGlobal stays stale.
5. Call `stakedStargateAM.burn(tokenId)` — reverts due to underflow in `currentRewardGlobal - assetState_.lastRewardGlobal`.
6. Warp another 10 days; burn succeeds but `currentRewards - initialRewards < 1e10`, showing rewards from the blocked period are lost.
**How found:** Code reading of Stargate LP_STAKING_TIME.deposit() behavior (clears and sends rewards to caller) compared against AbstractStakingAM._getRewardBalances() which subtracts a persisted lastRewardGlobal that is never reset after payout.
**Exploitation:** Any user staking via StakedStargateAM triggers reward payout on mint/increaseLiquidity; subsequent actions revert until currentRewardGlobal catches up to the stale lastRewardGlobal, and accrued rewards during that window are effectively nullified. If the position is used as collateral, rewardOf() reverts and DoSes the lending/borrowing system.
**Escalation:** Collateral valuation via rewardOf() reverts, DoSing Arcadia accounts that use Stargate positions as collateral.
**Insight:** When integrating external staking contracts, verify whether deposit/withdraw side-effects (like auto-claiming rewards) reset the integrator's cached accounting baseline; a stale global accumulator causes underflow reverts and silent reward loss.
