Skip to content
Docs
Open app
Skip to Content

Stake SUI

Build a stake transaction that returns vSUI to the PTB, so you can transfer it or use it in the same transaction.

  • @mysten/sui 2.39.1npm 3.0.1
  • TypeScript
  • Sui mainnet

stake_pool::stake takes a Coin<SUI> and returns the minted vSUI as a Coin<CERT>. Wrapping it in a small builder keeps the object IDs in one place and lets you decide what happens to the vSUI.

stake.ts
import { Transaction, type TransactionObjectArgument } from '@mysten/sui/transactions';
import { VOLO } from './constants';

const MIN_STAKE = 100_000_000n; // 0.1 SUI

/** Appends a stake call and returns the minted vSUI coin. */
export function stakeSui(tx: Transaction, sui: TransactionObjectArgument) {
  const [vsui] = tx.moveCall({
    target: `${VOLO.packageId}::stake_pool::stake`,
    arguments: [tx.object(VOLO.stakePool), tx.object(VOLO.metadata), tx.object('0x5'), sui],
  });
  return vsui;
}

/** Stakes `amount` MIST from the gas coin and sends the vSUI to `owner`. */
export function buildStake(owner: string, amount: bigint) {
  if (amount < MIN_STAKE) throw new Error('Stake at least 0.1 SUI');
  const tx = new Transaction();
  tx.setSender(owner);
  const [sui] = tx.splitCoins(tx.gas, [amount]);
  const vsui = stakeSui(tx, sui);
  tx.transferObjects([vsui], owner);
  return tx;
}

VOLO comes from constants.ts. Sign and execute the returned transaction with your wallet adapter or keypair.

Use the vSUI in the same transaction

stakeSui returns the vSUI coin as a transaction result. Instead of transferring it, pass it to any Move call that accepts Coin<CERT>, such as a lending deposit or a liquidity position. Every call then succeeds or fails together.

To stake a coin other than the gas coin, for example SUI produced by an earlier call, pass that coin as sui.

Rules

RuleDetail
Minimum0.1 SUI (100_000_000 MIST) per call. Smaller amounts abort with EUnderMinAmount (30003).
OutputAbout amount / exchangeRate vSUI, less any stake fee. Quote it exactly with get_amount_out.
FeesThe stake fee is set by the pool and capped at 5% in the contract.
Paused poolStaking aborts with EIncompatiblePaused (50002) while the pool is paused.
Entry variantstake_entry does the same and transfers the vSUI to the sender. Use stake when you need the coin later in the PTB.

See Errors and limits for every abort you are likely to meet.

On this page