Skip to content

FOR DEVELOPERS · CONTRACTS

Staking integration

The StakingRewards contract: reading pools and positions, staking from your own app, and following payouts.

Staking tokens are registered with StakingRewards (0xD74c25B9D3C810B51e6032A288EfeB6484BB1fE7) when they launch. It holds stakes and keeps the reward accounting; the reward funds themselves sit in the FeeDistributor (0x588cBBD7D69821D05aEaF18237c44eea3C7261D5), which pays them out when a staker claims. For the rules in plain words, see Mechanisms: Staking.

Pool parameters

Each token copies the contract's default parameters when it is registered. Read them per token with paramsOf(token); defaultParams() returns what new tokens get.

FieldProduction valueMeaning
minStake100e18 (100 tokens)A stake below this has zero weight
cooldown86400 (24 h)Wait between requestWithdraw and withdraw
instantExitBurnBps2000 (20%)Burned on withdrawEarly and on an immature withdrawRequestEarly
maxPending16Pending withdrawal requests per staker
BOOST_BURN_BPS (constant)1500 (15%)Burned share of committed tokens that gives the full 2× boost

The staking share lives in the FeeDistributor: stakingShareOf(token) returns it in bps; SENTO keeps it between 1,000 and 4,000 (10–40%). Changes emit StakingShareUpdated(token, shareBps).

Weight and boost

Rewards are split by shares, the boosted weight of each position. The contract computes it as below; stakeOf(token, user).shares returns the current value and totalShares(token) the pool total.

Weight formula
function weight(staked: bigint, burned: bigint, minStake: bigint): bigint {
  if (staked < minStake) return 0n;
  const cap = (staked + burned) * 1500n;   // BOOST_BURN_BPS
  const b = burned * 10000n;
  if (b >= cap) return 2n * staked;        // full 2x boost
  return staked + (staked * b) / cap;      // linear up to 2x
}

// How much more may be burned (same as boostRemaining(token, user)):
const burnCap = ((staked + burned) * 1500n + 9999n) / 10000n; // ceil
const remaining = burnCap > burned ? burnCap - burned : 0n;

Tokens in a pending withdrawal request (cooling) carry no weight. burnForBoost reverts with BurnCapExceeded(remaining) past the cap; it does not enforce minStake on what is left, so check that yourself or the position stops earning.

Reading a pool and a position

Read staking state
import { parseAbi } from "viem";
import { client, SENTO } from "./client";

const stakingAbi = parseAbi([
  "function paramsOf(address token) view returns ((uint128 minStake, uint32 cooldown, uint16 instantExitBurnBps, uint8 maxPending))",
  "function isRegistered(address token) view returns (bool)",
  "function totalStaked(address token) view returns (uint256)",
  "function totalShares(address token) view returns (uint256)",
  "function rewardTokens(address token) view returns (address[])",
  "function stakeOf(address token, address user) view returns ((uint256 staked, uint256 cooling, uint256 burned, uint256 shares))",
  "function withdrawRequests(address token, address user) view returns ((uint64 id, uint64 readyAt, uint256 amount)[])",
  "function earned(address token, address user, address asset) view returns (uint256)",
  "function boostRemaining(address token, address user) view returns (uint256)",
]);
const feeAbi = parseAbi([
  "function stakingShareOf(address token) view returns (uint16)",
  "function treasuryBalance(address token, address asset) view returns (uint256)",
  "function buybackBudget(address token, address asset) view returns (uint256)",
]);

const s = (functionName, args) => client.readContract({ address: SENTO.stakingRewards, abi: stakingAbi, functionName, args });
const f = (functionName, args) => client.readContract({ address: SENTO.feeDistributor, abi: feeAbi, functionName, args });

const [position, requests, totalShares, assets, shareBps] = await Promise.all([
  s("stakeOf", [token, user]),
  s("withdrawRequests", [token, user]),  // sorted by id; readyAt is a unix timestamp
  s("totalShares", [token]),
  s("rewardTokens", [token]),            // assets that have paid rewards so far (the quote asset)
  f("stakingShareOf", [token]),
]);

const poolShare = totalShares === 0n ? 0 : Number(position.shares) / Number(totalShares);
const claimable = await Promise.all(assets.map((asset) => s("earned", [token, user, asset])));

rewardTokens is empty until the first reward is paid. For a fresh pool, use the token's quote asset from Launchpad.tokenInfo(token).pools[0].quote instead.

Staking from your own app

All calls take the token address first. Amounts are in token units (18 decimals). stake pulls tokens with transferFrom, so the staker approves StakingRewards first.

CallEffect
stake(token, amount)Adds to the stake. Needs an ERC-20 approval to StakingRewards.
burnForBoost(token, amount)Sends amount of the stake to 0x…dEaD and raises the multiplier.
requestWithdraw(token, amount) → idMoves amount to cooling; claimable with withdraw after cooldown.
cancelWithdraw(token, id)Puts a pending request back into the stake.
withdraw(token, id)Pays out a matured request in full. Reverts CooldownActive(readyAt) before.
withdrawEarly(token, amount)Exits straight from the stake; instantExitBurnBps of it is burned.
withdrawRequestEarly(token, id)Exits a pending request now: burned if immature, in full if matured.
claim(token)Pays every reward asset owed. claim(token, asset) pays one. Reverts NothingToClaim() if zero.
Approve and stake
import { erc20Abi, parseAbi, parseUnits } from "viem";

const stakingWriteAbi = parseAbi([
  "function stake(address token, uint256 amount)",
  "function claim(address token)",
]);

const amount = parseUnits("1000", 18);

await wallet.writeContract({ address: token, abi: erc20Abi, functionName: "approve", args: [SENTO.stakingRewards, amount] });
await wallet.writeContract({ address: SENTO.stakingRewards, abi: stakingWriteAbi, functionName: "stake", args: [token, amount] });

// later
await wallet.writeContract({ address: SENTO.stakingRewards, abi: stakingWriteAbi, functionName: "claim", args: [token] });

Other reverts to handle: NotRegistered(token) (not a Staking token), ZeroAmount(), InsufficientStake(), TooManyRequests() (16 pending) and RequestNotFound(id).

How rewards are accounted

  • On every trade of a Staking token, the stakers' part of the treasury inflow (stakingShareOf(token)) is credited to stakers pro rata to shares, and RewardAdded is emitted. earned(token, user, asset) returns a position's unclaimed amount.
  • Weight changes (stake, burn, request, cancel) settle what was earned before, so nothing earned is lost when a position shrinks or exits.
  • If totalShares is zero, the amount stays in the token's treasury and StakingRewardsUnallocated is emitted. Read the treasury with treasuryBalance(token, asset).
  • Reward funds are held by the FeeDistributor until claimed; claim pays them out, in native ETH for ETH-quoted tokens.
  • The buyback part accrues as buybackBudget(token, asset) and is spent on the token's v4 pool after graduation; each run emits BuybackExecuted.

Staking events

ContractEventtopic0
StakingRewardsStakeAdded(token, user, amount, balance, shares)0xd31a14b3c81fb59449d940984e7ae5800af8ca159762a73a59689a2d47988f89
StakingRewardsBurnedForBoost(token, user, amount, burned, balance, shares)0x038f53f8b41aff770feaea62c79557e3f2c55aa9963ed779062111f82bef65ee
StakingRewardsWithdrawRequested(token, user, id, amount, readyAt)0x532c7cec66d302dd987cc5da427536c2715be3ad0a39602ad96a85ece7bb8dd4
StakingRewardsWithdrawCancelled(token, user, id, amount)0xd621720b1c452030964b5e4add0f0980a0a65d582b6dd66acf04b007eaa316a0
StakingRewardsWithdrawn(token, user, id, amount)0xd22ba8ade41650d0e2a4cd2fc2b5e6a6618229ced678f15a0f423d54efa8adb7
StakingRewardsEarlyWithdrawn(token, user, id, amount, penalty) (id 0 = straight from the stake)0xeddc0839d15e193d3be6c77f41a14b879d0bb7b34b8dbe0ddded19897318cc22
StakingRewardsRewardAdded(token, asset, amount, rewardPerTokenStored)0xd788be73362710455c53c86bf25cb901f5950cb2f35141025e055657332e1f7b
StakingRewardsRewardPaid(token, user, asset, amount)0xce405e67b4d6e56e438257e15f160ae28b450e6e7659bbc4c1f4e09a1ac846cb
FeeDistributorStakingRewardsFunded(token, asset, amount, total)0x9d9353e6a70ceb62dd792e58810cc0187640734321089158f6215b2a5c200c92
FeeDistributorStakingRewardsUnallocated(token, asset, amount)0x1b7790c78bc748d6e7d93ff1bc38b7a2206a4d49f62a6e31191059fc42b1d099
FeeDistributorTreasuryFunded(token, asset, amount, total)0x30c9442ecb4380eb50f3f352088c280c0f44276c229453d346e3b489f63dc99f
FeeDistributorStakingShareUpdated(token, shareBps)0x8c1dd097511ef34b927e7951cad08011d52416d5a9ec03f8b12540041330a9b9
BuybackBuybackExecuted(token, asset, amountIn, amountBurned)0xe805d71b9893d9c26b5997aeb796b1b001a9e48e08b79aac63b2c68bc344eb20

token, user and asset are indexed wherever they appear, and so is id in WithdrawRequested, WithdrawCancelled and Withdrawn. A staking dashboard can be rebuilt from these events alone: sum RewardPaid for payouts, RewardAdded for paid-in rewards, and replay the position events for stakes.