# checkpoint function is not called before staking which can cause loss of rewards for already staked services

Olas staking contract's stake() omits checkpoint(), so a new service joins before rewards are distributed, diluting rewards owed to already-staked services.

- Payout: Audit contest
- Severity: medium
- Program: Olas
- Found by: Varun\_05
- Disclosed: 2024-08-06
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-05-olas-findings/issues/89
- Library page: https://bugbountylibrary.com/r/c4%3A2024-05-olas%3AM-01
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:medium tech:evm tech:solidity vuln:accounting-error vuln:reward-distribution

**Target:** Solidity staking contract (stake/checkpoint reward accounting)
**Root cause:** stake() does not call checkpoint() before admitting a new service, so pending rewards for existing services are not settled and the new service shares in rewards it did not earn.
**Steps:**
1. Observe stake() checks availableRewards==0 but never calls checkpoint() first.
2. Have 3 services staked with 300 rewards pending and liveness period elapsed without checkpoint.
3. Call stake(newServiceId) so a 4th service is added before rewards are settled.
4. Later call checkpoint(): new service accrues rewards for its short staking window, diluting the original three services' share (e.g. 90 vs 100 each).
**How found:** Code reading of stake() noting the availableRewards==0 guard but absence of checkpoint(), then reasoning through a numeric example of reward dilution.
**Exploitation:** Attacker stakes a fresh service just before a checkpoint when rewards are nearly exhausted, capturing a share of rewards at the expense of existing stakers; no capital beyond staking requirements.
**Insight:** When a staking/reward contract gates entry on a cached reward balance, check whether the accrual checkpoint is invoked before admission; stale accounting lets late joiners dilute existing stakers.

