Stake

Stake behind a solver

Choose a solver, send the stake instruction, and read what the stake became.

A stake is a deposit of SOL or a listed liquid staking token behind one solver. It becomes part of that solver's bond, and it earns a share of the clearing fee of every batch the solver proves. This page goes from choosing a solver to a stake that is earning.

Choose a solver

A stake follows its solver: it earns what the solver's batches pay, and it carries the solver's slashes. /stake lists every registered solver, and /solvers/[address] shows one in full. una.solvers() and una.solver(address) return the same figures.

In the appFieldWhat it tells a staker
Stake, Stake behind ittotalStakeLamportsAll stake behind the solver, in lamports at current rates. A new stake earns its part of the fees against this total.
Bond freebondFreeLamportsStake not locked behind a batch and not in a cooldown. The solver can clear a batch that moves up to this much.
Bond in use, Bond lockedbondLockedLamportsStake locked behind cleared batches whose proofs have not landed yet.
CommissioncommissionBpsThe part of the solver's clearing fees the operator keeps, in basis points. The rest goes to stakers.
Batches clearedbatchesClearedBatches the solver has cleared.
Batches provenbatchesProvenOf those, the ones whose proof verified. Each proven batch pays its clearing fee.
Median time to proofmedianProofTimeMsHalf of its recent batches were proven faster than this. It is on the solver's page and in una.solver.
Fees paid to stakersfeesPaidToStakersLamportsClearing fees credited to its stakers so far.
SlashesslashCount, slashesBatches the solver cleared and did not prove in time, each with the bond that moved to cover and the transaction. A solver with none shows Never slashed.

una.solver takes the solver's account address or its operator's wallet address. It adds recentBatches, slashes and acceptedBondMints to the summary. The fields are in the API reference under SolverSummary and SolverDetail.

TypeScript
const { items: solvers } = await una.solvers({ limit: 50 })
for (const s of solvers) {
  console.log(s.address, `commission ${s.commissionBps} bps`, `free ${s.bondFreeLamports}`, `locked ${s.bondLockedLamports}`, `proven ${s.batchesProven} of ${s.batchesCleared}`, `slashed ${s.slashCount}`)
}

const solver = await una.solver(solvers[0]!.address)
console.log(`median time to proof ${solver.medianProofTimeMs} ms, ${solver.slashes.length} slashes`)

The mints a stake can be in

The program keeps a list of bond mints in its Config, at most 4, each with its mint, its token program, its decimals and, for a liquid staking token, the address of its SPL stake pool. The admin sets the list with set_config. una.protocol() returns the live list as bondMints, and una.solver(address) returns the same list as acceptedBondMints. Each entry is a BondMint with the mint, its symbol, and its rate in SOL as solPerTokenQ64 and solPerTokenUi.

A stake is counted in lamports:

  • A mint listed with no stake pool is SOL, held as wrapped SOL. One atom counts as one lamport.
  • A liquid staking token counts at its stake pool's own rate. The program reads the pool's account in the same instruction and takes total_lamports and pool_token_supply from it.
Text
lamport_value = floor(amount * total_lamports / pool_token_supply)

Before using the rate the program checks the pool account: it is the account the Config lists for that mint, the SPL Stake Pool program SPoo1Ku8WFXoNDMHPsrGSTSG1Y47rzgn41SLUNakuHy owns it, it is a stake pool account, its pool mint is the bond mint, and both figures are above zero.

With sample inputs: a pool that holds 115,000,000,000 lamports against a supply of 100,000,000,000 pool tokens gives a rate of 1.15 SOL per token, and a stake of 1,000,000,000 atoms counts as 1,150,000,000 lamports.

Stake

  1. Open the solver

    On /stake, press Stake on a solver's row. It opens /solvers/[address] at the stake form.

  2. Enter the amount

    Pick the bond token and type the amount. Balance fills in everything the wallet holds of that token. The form shows Counts as bond, the amount in SOL at the current rate, and for a liquid staking token the Stake pool rate.

  3. Press Stake

    The button moves through Preparing, Sign in your wallet, and Sent, confirming. When it confirms, the stake appears under Your stake here with the status Staked, and on /stake under Your stakes.

The stake instruction

Arguments

bond_mint_idxu8required
The position of the mint in the Config's bond mint list, from 0.
amountu64required
Atoms of the bond mint. Above zero.

The owner signs. The program then does five things in order.

  1. It checks the mint: bond_mint_idx is inside the list and active, and the mint and token program passed are the ones listed.
  2. It reads the rate, 1 for SOL and the stake pool's for a liquid staking token.
  3. It moves amount atoms from the owner's token account to the solver's vault for that mint, with transfer_checked.
  4. It mints shares of the solver's pool for that mint and adds amount to the pool.
  5. It adds lamport_value to the stake's reward weight and to the solver's total.

Accounts it creates

AccountSeedsCreated
Stake"stake", solver, owner, bond_mint_idxOn the first stake of that owner behind that solver in that mint. 888 bytes, rent paid by the owner.
Solver vault"solver_vault", solver, bond_mint_idxOn the first stake in that mint behind that solver, by whoever sends it. A token account of 165 bytes, held by the program.

One wallet has one stake per solver and mint. Staking again in the same mint adds to it, after the program credits the rewards the stake has earned so far.

Shares

Each solver has one pool per bond mint, with an amount in atoms and a number of shares.

Text
shares = amount                                      // the pool is empty
shares = floor(amount * pool_shares / pool_amount)   // otherwise

A stake is worth its part of the pool:

Text
staked amount = floor(stake_shares * pool_amount / pool_shares)

Staking and withdrawing change the amount and the shares together, so they leave the worth of other stakes as it was. A slash takes from the amount and leaves the shares, so every share in the pool is worth less by the same fraction. una.stakes() returns both for each stake, as shares and stakedAmount.

Reward weight

lamport_value, the stake's worth in lamports at the moment it is deposited, is added to the stake's reward_weight. Rewards are shared by weight across all of a solver's stakes, whatever mint they are in. Rewards has the arithmetic. A new stake starts counting from the next batch its solver proves.

What it emits

Staked with stake, solver, owner, bond_mint_idx, amount, shares and lamport_value.

Errors

ErrorRaised when
ZeroLiquidityamount is 0, or the amount is so small against the pool that it mints 0 shares.
UnsupportedBondMintbond_mint_idx is outside the list, the entry is inactive, or the mint or token program passed is not the one listed.
InvalidStakePoolThe mint is a liquid staking token and the stake pool account passed is not the one listed, is not owned by the SPL Stake Pool program, is not a stake pool, has another pool mint, or reports zero lamports or zero supply.
UnauthorizedThe stake account belongs to another owner.
MathOverflowA sum or product leaves 64 bits.

Through the SDK a refused transaction rejects with UnaTxError. Its failure.stage names where it stopped and failure.program.name carries the program's error name.

TypeScript
try {
  await una.stake({ solver: solver.address, bondMint: bond.mint, amount: amount.toString() })
} catch (e) {
  if (e instanceof UnaTxError) console.error(e.failure.stage, e.failure.program?.name, e.failure.message)
  else if (e instanceof ApiClientError) console.error(e.code, e.message)
  else throw e
}

The API answers VALIDATION_ERROR before building anything when bondMint is not on the list.

What it costs

The program takes no fee on a stake. The owner pays the network fee, the rent of the stake account the first time, and the rent of the solver's vault when the stake is the first in that mint behind that solver.

Read the stake

TypeScript
const { items: stakes } = await una.stakes({ solver: solver.address })
const stake = stakes.find((s) => s.bondMint === bond.mint)!
console.log(`stake ${stake.address}: ${stake.shares} shares worth ${stake.stakedAmount} atoms, ${stake.status}`)

una.stakes() returns the wallet's stakes, each a StakePosition. The app shows the same rows under Your stakes: the solver, the staked amount, the rewards, the status and the one action the status allows.