EIPs Explained

ERC-7254 · Draft · ERC · 2023-06-29

ERC-7254: Token Revenue Sharing

A Draft extension to ERC-20 that lets a project push revenue (in one or more reward tokens) to all holders pro rata, without them having to stake, lock or farm.

What problem does it solve?

Projects that want to share profits with token holders usually build a separate staking or farming contract: users must deposit their tokens, wait, and later claim. That adds friction, extra contracts and extra risk, and holders who simply keep tokens in their wallet get nothing.

ERC-7254 proposes building the payout logic directly into the ERC-20 token. Whenever the project earns revenue (marketplace fees, AMM fees, game income, company dividends) it can deposit it into the token contract, and every holder accrues a share in proportion to their balance, which they can withdraw at any time.

How it works

The token tracks a reward per share for each reward token it distributes. The classic "accumulated reward per share" accounting trick is used, so distributing revenue costs the same gas no matter how many holders there are:

  • updateReward(tokens[], amounts[]) deposits revenue and increases rewardPerShare += amount / totalSupply() for each reward token.
  • Each account has a UserInformation record with inReward, outReward and withdraw. When a balance goes up or down (transfer, mint, burn), these are adjusted so that the holder is credited only for revenue that arrived while they actually held the tokens.
  • viewReward(account) returns the pending amount for each reward token; getReward(tokens[]) pays it out.
  • tokenReward() lists the reward tokens, existsTokenReward(token) checks one, getRewardPerShare(token) reads the accumulator, and maxTokenReward() returns the configured maximum for reward tokens (the spec does not define it further).
  • informationOf(token, account) and informationOfBatch(account) expose the raw accounting records.

Because the reward hooks run on every balance change, a holder can move tokens freely; rewards already earned stay claimable by the old holder.

Sample code

Depositing revenue and letting a holder claim it (ethers v6):

import { Contract, Wallet, JsonRpcProvider, parseUnits } from "ethers";

const abi = [
  "function updateReward(address[] token, uint256[] amount)",
  "function viewReward(address account) view returns (uint256[])",
  "function getReward(address[] token)",
  "function tokenReward() view returns (address[])",
];

const provider = new JsonRpcProvider(process.env.RPC_URL);
const treasury = new Wallet(process.env.TREASURY_KEY!, provider);
const revToken = new Contract(process.env.REV_TOKEN!, abi, treasury);

// 1. Treasury approves the reward token, then distributes 1,000 units of it
const usdc = new Contract(process.env.USDC!, ["function approve(address,uint256)"], treasury);
await (await usdc.approve(revToken.target, parseUnits("1000", 6))).wait();
await (await revToken.updateReward([process.env.USDC!], [parseUnits("1000", 6)])).wait();

// 2. A holder checks and claims what they are owed
const holderWallet = new Wallet(process.env.HOLDER_KEY!, provider);
const holder = revToken.connect(holderWallet) as Contract;
const rewards: string[] = await holder.tokenReward();
console.log(await holder.viewReward(holderWallet.address)); // pending, per reward token
await (await holder.getReward(rewards)).wait();

Whether updateReward pulls tokens via transferFrom (as assumed above) is an implementation detail; check the contract you integrate with.

Things to know

  • Status: Draft. The Rationale section is still "TBD" and Security Considerations say "Needs discussion", so the interface may change.
  • Contracts that hold the token (DEX pools, lending markets, bridges) also accrue rewards. Unless they call getReward, that revenue sits unclaimed, so holders who deposit into DeFi may lose their share.
  • Rewards are per unit of supply at the moment of each deposit, so someone who buys just before a large updateReward gets a full share. Projects should think about front-running of announced distributions.
  • Revenue distribution to holders can have legal and securities implications depending on jurisdiction; that is outside the scope of the standard.
  • For yield that accrues through a share price rather than claimable payouts, compare the tokenized vault model in ERC-4626.

#token #erc20 #revenue #dividends #rewards

Details

Authors
Quy Phan (@quyphandang), Quy Phan <[email protected]>
Status
Draft
Type
Standards Track / ERC
Created
2023-06-29

Machine-readable: Markdown · JSON