Staking vaults
LockupVault staking and vault-backed validators, covering tiers and APY, the 1,000 AMA vault minimum and the 1M AMA validator stake, unlocking, commission, and how to read vault state.
A staking vault locks AMA in the LockupVault contract. The vault earns the APY of its tier and can back a validator. Every key backed by at least 1,000,000 AMA in vaults joins the validator set, next to the top solvers described in Building your Score.
In node v1.6.5, LockupVault.create fails on mainnet with vault_creation_disabled. On testnet it works. Mainnet vaults that already exist can still use every other function on this page.
Tiers
The tier fixes the APY and the minimum lock when the vault is created. A month is 30 days, and the lock is rounded up to whole epochs.
| Tier | APY | Lock |
|---|---|---|
og | 0% | None, or months you choose (up to 1,200) |
3m | 5% | 90 days (156 epochs) |
6m | 10% | 180 days (312 epochs) |
12m | 15%, plus a 5% bonus for vaults created before epoch 1150 | 360 days (623 epochs) |
Limits:
- A vault holds at least 1,000 AMA.
- A validator needs at least 1,000,000 AMA of backing: the amount plus accrued yield of every vault that names it as validator.
How vault yield is paid
At the end of each epoch, every vault whose validator is in that epoch's validator set earns:
yield = (amount + accrued) × rate_bps / 6,307,200
6,307,200 is 10,000 basis points times 630.72 epochs per year. Vaults without a validator, or whose validator is not in the set, earn nothing that epoch. A validator removed by a slashing motion is not in the set, so its vaults earn nothing for that epoch.
From the gross yield:
- The validator's commission is taken first and paid to the validator's emission address, or to the validator key when none is set.
- The rest goes to the vault's payout address. With no payout address, it is added to
accrued, so it compounds and counts toward the validator's stake.
Vault yield comes from the vault half of the epoch emission plus a carried-over pool. If the total due is larger than that budget, every vault is paid pro rata. From epoch 1150 on, vault yield is also scaled by network participation, like the solver half. See How emissions are paid.
Contract functions
Each function is a call to the LockupVault contract, signed by the vault owner unless noted. A vault is identified by its owner and its index, a number that is unique across the whole chain.
| Function | Arguments | What it does |
|---|---|---|
create | One VecPak map: amount (base units) and tier, plus optional validator, payout_address, owner, unlock_epoch, months (og only) | Moves amount from the caller into a new vault. owner lets the caller fund a vault held by another key. unlock_epoch can only push maturity later than the tier's lock. A validator given here enters the same two-epoch queue as set_validator. Testnet only for now. |
unlock | vault index | Allowed once the vault has matured. Starts the 21-day (37-epoch) unlock period. When it ends, at the next epoch boundary, amount plus accrued is credited to the owner and the vault is closed. |
set_validator | vault index, validator public key | Delegates the vault. The validator must have a proof of possession on chain. The change goes live two epochs after the call. |
clear_validator | vault index | Removes the delegation, with the same two-epoch delay. If a move to a new validator is still queued, it cancels that move immediately instead. |
set_payout_address | vault index, public key | Pays future net yield to this address instead of compounding it. |
clear_payout_address | vault index | Goes back to compounding. |
change_owner | vault index, new owner public key | Moves the vault to another owner. It keeps its index. |
extend_lock | vault index, number of epochs (as a string) | Pushes maturity later by that many epochs. |
set_commission | basis points as a string, 0 to 10000 | Signed by the validator. Sets the share of vault yield it keeps. A cut applies at once; a raise applies three epochs later. Setting the current rate again cancels a queued raise. |
set_payout_address, clear_payout_address, change_owner and extend_lock fail with vault_is_unlocking once unlock has been called. A vault that is unlocking still earns yield and still counts toward its validator's stake until it closes.
Become a vault-backed validator
-
Run a node whose
seedsfile holds the validator key, and keep it reliable. See Running a Node and Risks of validating. -
Put the key's proof of possession on chain. The first sol the key submits does this. Without solving, send
Epoch.register_popwith the key and its proof. In the node's REPL, for the node's first key:key = Application.fetch_env!(:ama, :keys) |> hd()tx_packed = TX.build(key.seed, "Epoch", "register_pop", [key.pk, key.pop])TXPool.insert_and_broadcast(tx_packed)API.Epoch.get_pop("<pk>")returns the recorded proof, ornil. -
Vault owners point their vaults at the key with
set_validator, or passvalidatortocreate. -
Set your commission with
set_commission. Until you set it, it is 0. -
At each epoch boundary the chain adds up the live backing of every key. Once it reaches 1,000,000 AMA, the key is in the next epoch's validator set.
Optionally, send your commission (and any solver emission) to another wallet with Epoch.set_emission_address. See Send rewards to a cold wallet.
Use vaults from the node REPL
The node ships two sets of helpers, with the same functions as the contract:
API.Vault.*signs the transaction and broadcasts it through your own node, then returns it without waiting.RPC.API.Vault.*signs locally, submits toRPC_URLand waits for finality. This works from an offline node.
Both take the seed as raw bytes or Base58. The amount is read as AMA when you pass a float and as base units when you pass an integer, so 1000.0 is 1,000 AMA and 1000 is 0.000001 AMA (below the minimum).
seed = "<seed in Base58>"
validator_pk = "<validator public key>"
# 1,000 AMA in the 3m tier, delegated to validator_pk
RPC.API.Vault.create(seed, 1000.0, "3m", validator: validator_pk)
RPC.API.Vault.set_payout_address(seed, 42, "<payout public key>")
RPC.API.Vault.unlock(seed, 42)
# signed by the validator; 500 bps = 5%
validator_seed = "<validator seed in Base58>"
RPC.API.Vault.set_commission(validator_seed, 500)
# vaults owned by a key, read from this node's own chain state
API.Vault.by_owner("<owner public key>")
The node signs transactions with the testnet domain only when TESTNET is set. To manage testnet vaults from a REPL, start an offline node in its own work folder that points at the testnet RPC:
OFFLINE=1 TESTNET=1 RPC_URL=https://testnet-rpc.ama.one WORKFOLDER=~/.cache/amadeusd-testnet ./amadeusd
extend_lock takes epochsThe REPL helper is declared as extend_lock(seed, vault_index, months), but the contract adds the number to the maturity epoch as epochs. extend_lock(seed, 42, 3) extends the lock by 3 epochs (about 1.7 days), not 3 months.
Read vaults with the SDK
@amadeus-protocol/sdk reads vault state through sdk.staking. This lists the keys that currently have 1,000,000 AMA or more of live backing, with their commission:
import { AmadeusSDK, VALIDATOR_MIN_STAKE_FLAT, flatToAma } from '@amadeus-protocol/sdk'
const sdk = new AmadeusSDK({ baseUrl: 'https://mainnet-rpc.ama.one/api' })
const currentEpoch = await sdk.staking.getCurrentEpoch()
const vaults = await sdk.staking.getAllVaults({ currentEpoch })
const commissions = await sdk.staking.getValidatorCommissions({ currentEpoch })
// Stake counts toward the validator that is live now, not a queued change
const stakeByValidator = vaults.reduce((totals, vault) => {
if (vault.validator === null) return totals
const previous = totals.get(vault.validator) ?? 0n
return totals.set(vault.validator, previous + vault.totalFlat)
}, new Map<string, bigint>())
const eligible = [...stakeByValidator].filter(([, stake]) => stake >= VALIDATOR_MIN_STAKE_FLAT)
console.log(`epoch ${currentEpoch}: ${vaults.length} vaults, ${eligible.length} validators at or above 1M AMA`)
for (const [validator, stake] of eligible.slice(0, 3)) {
const commissionBps = commissions[validator]?.bps ?? 0
console.log(validator, `${flatToAma(stake)} AMA`, `commission ${commissionBps / 100}%`)
}
For one owner, sdk.staking.getPosition(publicKey) returns the vaults plus totals:
import { AmadeusSDK } from '@amadeus-protocol/sdk'
const sdk = new AmadeusSDK({ baseUrl: 'https://testnet-rpc.ama.one/api' })
const position = await sdk.staking.getPosition('5kizwGYhCDy8Dev7Qw31aVutXwk4sZCK18hVwWqUdLx8X6oG338XpoSR7X9c1fMg5o')
console.log(`${position.totalStaked} AMA in ${position.vaultCount} vaults at epoch ${position.epoch}`)
for (const vault of position.vaults) {
console.log(vault.index, vault.tier, `${vault.rateBps / 100}%`, {
validator: vault.validator,
pendingValidator: vault.pendingValidator,
matureEpoch: vault.matureEpoch,
unlockAtEpoch: vault.unlockAtEpoch
})
}
Without the SDK, /api/chain/stats includes staked and commission_bps for every validator and staked key:
curl -s https://mainnet-rpc.ama.one/api/chain/stats \
| jq '[.stats.validators | to_entries[] | select(.value.staked >= 1000000) | {pk: .key, staked: .value.staked, commission_bps: .value.commission_bps}]'