---
eip: 2917
label: ERC-2917
title: Staking Reward Calculation
status: Stagnant
type: Standards Track
category: ERC
created: 2020-08-28
official: https://eips.ethereum.org/EIPS/eip-2917
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-2917.md
canonical: https://eips.huatuo.xyz/eip-2917/
lang: en
tldr: "A proposed interface for calculating staking rewards fully on-chain, paying each user a share of per-block interest proportional to their 'productivity' (stake) over time."
tags: [staking, rewards, defi, erc-20, interface]
---

# ERC-2917: Staking Reward Calculation

> ERC2917 is a new standardization for on-chain calculation of staking reward.

**TL;DR:** A proposed interface for calculating staking rewards fully on-chain, paying each user a share of per-block interest proportional to their 'productivity' (stake) over time.

## What problem does it solve?

Early DeFi reward schemes tended to fall into two camps, according to the spec: either rewards were only distributed once everyone exited the contract, or the project collected data on-chain, computed rewards off-chain, and pushed the results back. The first is slow and forces users to withdraw collateral; the second relies on trusting the operator's calculation.

ERC-2917 proposes a standard, fully on-chain way to compute rewards at any block, plus a common interface so wallets can show users how much they have earned, how it is calculated, and what share of the total they contribute.

## How it works

The contract mints a fixed amount of interest per block (`interestsPerBlock`). Each user has a **productivity** value (typically their effective stake) and the contract tracks the **global productivity**. For every stretch of blocks in which nobody's productivity changes, a user earns:

```text
reward_i = interestsPerBlock × blocks_in_period × (user_productivity / global_productivity)
```

A user's total reward is the sum over all such periods. The calculation is updated whenever a user's productivity increases or decreases, and when they withdraw, so joining late or leaving early gives no advantage.

The interface (the reward token itself is an ERC-20):

| Function / event | Purpose |
| --- | --- |
| `interestsPerBlock()` | Interest produced per block |
| `changeInterestRatePerBlock(v)` | Change the rate (should be restricted) |
| `getProductivity(user)` | User's and global productivity |
| `increaseProductivity(user, v)` / `decreaseProductivity(user, v)` | Adjust a user's stake (should be restricted to the staking contract) |
| `take()` / `takeWithBlock()` | Rewards claimable by the caller now (and at which block) |
| `mint()` | Mint the caller's accrued rewards to them |
| `InterestRatePerBlockChanged`, `ProductivityIncreased`, `ProductivityDecreased` | Events |

## Sample code

The usual way to implement this formula efficiently is an "accumulated reward per unit of productivity" counter, so no loop over periods is needed:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract RewardAccounting {
    uint256 public interestsPerBlock;
    uint256 public totalProductivity;
    uint256 public accPerShare;      // scaled by 1e18
    uint256 public lastBlock;

    mapping(address => uint256) public productivity;
    mapping(address => uint256) public rewardDebt;
    mapping(address => uint256) public pending;

    function _update() internal {
        if (block.number > lastBlock && totalProductivity > 0) {
            uint256 reward = (block.number - lastBlock) * interestsPerBlock;
            accPerShare += reward * 1e18 / totalProductivity;
        }
        lastBlock = block.number;
    }

    function _settle(address user) internal {
        pending[user] += productivity[user] * accPerShare / 1e18 - rewardDebt[user];
    }

    function _increase(address user, uint256 value) internal {
        _update();
        _settle(user);
        productivity[user] += value;
        totalProductivity += value;
        rewardDebt[user] = productivity[user] * accPerShare / 1e18;
    }
}
```

## Things to know

- **Status: Stagnant.** The Rationale and Security Considerations sections were never written, and the standard was not finalized.
- The spec's own wording calls these "interests", but the mechanism is a reward emission, not interest in a financial sense; the emitted token's value depends entirely on the project.
- `increaseProductivity`, `decreaseProductivity` and `changeInterestRatePerBlock` must be access-controlled. If anyone can call them, anyone can mint rewards.
- The same accumulator pattern is widely used in staking and liquidity-mining contracts that never referenced this ERC.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-2917
