Enum spl_stake_pool::instruction::StakePoolInstruction[][src]

#[repr(C)]
pub enum StakePoolInstruction {
Show variants Initialize { fee: Fee, max_validators: u32, }, CreateValidatorStakeAccount, AddValidatorToPool, RemoveValidatorFromPool, DecreaseValidatorStake(u64), IncreaseValidatorStake(u64), SetPreferredValidator { validator_type: PreferredValidatorType, validator_vote_address: Option<Pubkey>, }, UpdateValidatorListBalance { start_index: u32, no_merge: bool, }, UpdateStakePoolBalance, Deposit, Withdraw(u64), SetManager, SetFee { fee: Fee, }, SetStaker,
}
Expand description

Instructions supported by the StakePool program.

Variants

Initialize

Initializes a new StakePool.

  1. [w] New StakePool to create.
  2. [s] Manager
  3. [] Staker
  4. [w] Uninitialized validator stake list storage account
  5. [] Reserve stake account must be initialized, have zero balance, and staker / withdrawer authority set to pool withdraw authority.
  6. [] Pool token mint. Must have zero supply, owned by withdraw authority.
  7. [] Pool account to deposit the generated fee for manager.
  8. [] Clock sysvar
  9. [] Rent sysvar
  10. [] Token program id
  11. [] (Optional) Deposit authority that must sign all deposits. Defaults to the program address generated using find_deposit_authority_program_address, making deposits permissionless.
Show fields

Fields of Initialize

fee: Fee

Fee assessed as percentage of perceived rewards

max_validators: u32

Maximum expected number of validators

CreateValidatorStakeAccount

(Staker only) Creates new program account for accumulating stakes for a particular validator

  1. [] Stake pool account this stake will belong to
  2. [s] Staker
  3. [ws] Funding account (must be a system account)
  4. [w] Stake account to be created
  5. [] Validator this stake account will vote for
  6. [] Rent sysvar
  7. [] Stake History sysvar
  8. [] Stake Config sysvar
  9. [] System program
  10. [] Stake program
AddValidatorToPool

(Staker only) Adds stake account delegated to validator to the pool’s list of managed validators.

The stake account must have the rent-exempt amount plus at least 1 SOL, and at most 1.001 SOL.

Once we delegate even 1 SOL, it will accrue rewards one epoch later, so we’ll have more than 1 active SOL at this point. At 10% annualized rewards, 1 epoch of 2 days will accrue 0.000547945 SOL, so we check that it is at least 1 SOL, and at most 1.001 SOL.

  1. [w] Stake pool
  2. [s] Staker
  3. [] Stake pool withdraw authority
  4. [w] Validator stake list storage account
  5. [w] Stake account to add to the pool, its withdraw authority must be set to the staker
  6. [] Clock sysvar
  7. ‘[]’ Sysvar stake history account
  8. [] Stake program
RemoveValidatorFromPool

(Staker only) Removes validator from the pool

Only succeeds if the validator stake account has the minimum of 1 SOL plus the rent-exempt amount.

  1. [w] Stake pool
  2. [s] Staker
  3. [] Stake pool withdraw authority
  4. [] New withdraw/staker authority to set in the stake account
  5. [w] Validator stake list storage account
  6. [w] Stake account to remove from the pool
  7. [] Transient stake account, to check that that we’re not trying to activate
  8. ‘[]’ Sysvar clock
  9. [] Stake program id,
DecreaseValidatorStake(u64)

(Staker only) Decrease active stake on a validator, eventually moving it to the reserve

Internally, this instruction splits a validator stake account into its corresponding transient stake account and deactivates it.

In order to rebalance the pool without taking custody, the staker needs a way of reducing the stake on a stake account. This instruction splits some amount of stake, up to the total activated stake, from the canonical validator stake account, into its “transient” stake account.

The instruction only succeeds if the transient stake account does not exist. The amount of lamports to move must be at least rent-exemption plus 1 lamport.

  1. [] Stake pool
  2. [s] Stake pool staker
  3. [] Stake pool withdraw authority
  4. [w] Validator list
  5. [w] Canonical stake account to split from
  6. [w] Transient stake account to receive split
  7. [] Clock sysvar
  8. [] Rent sysvar
  9. [] System program
  10. [] Stake program userdata: amount of lamports to split into the transient stake account
IncreaseValidatorStake(u64)

(Staker only) Increase stake on a validator from the reserve account

Internally, this instruction splits reserve stake into a transient stake account and delegate to the appropriate validator. UpdateValidatorListBalance will do the work of merging once it’s ready.

This instruction only succeeds if the transient stake account does not exist. The minimum amount to move is rent-exemption plus 1 SOL in order to avoid issues on credits observed when merging active stakes later.

  1. [] Stake pool
  2. [s] Stake pool staker
  3. [] Stake pool withdraw authority
  4. [w] Validator list
  5. [w] Stake pool reserve stake
  6. [w] Transient stake account
  7. [] Validator vote account to delegate to
  8. ‘[]’ Clock sysvar
  9. ‘[]’ Rent sysvar
  10. [] Stake History sysvar
  11. [] Stake Config sysvar
  12. [] System program
  13. [] Stake program userdata: amount of lamports to split into the transient stake account
SetPreferredValidator

(Staker only) Set the preferred deposit or withdraw stake account for the stake pool

In order to avoid users abusing the stake pool as a free conversion between SOL staked on different validators, the staker can force all deposits and/or withdraws to go to one chosen account, or unset that account.

  1. [] Stake pool
  2. [s] Stake pool staker
  3. [w] Validator list

Fails if the validator is not part of the stake pool.

Show fields

Fields of SetPreferredValidator

validator_type: PreferredValidatorType

Affected operation (deposit or withdraw)

validator_vote_address: Option<Pubkey>

Validator vote account that deposits or withdraws must go through, unset with None

UpdateValidatorListBalance

Updates balances of validator and transient stake accounts in the pool

While going through the pairs of validator and transient stake accounts, if the transient stake is inactive, it is merged into the reserve stake account. If the transient stake is active and has matching credits observed, it is merged into the canonical validator stake account. In all other states, nothing is done, and the balance is simply added to the canonical stake account balance.

  1. [] Stake pool
  2. [] Stake pool withdraw authority
  3. [w] Validator stake list storage account
  4. [w] Reserve stake account
  5. [] Sysvar clock
  6. [] Sysvar stake history
  7. [] Stake program
  8. ..7+N ` [] N pairs of validator and transient stake accounts
Show fields

Fields of UpdateValidatorListBalance

start_index: u32

Index to start updating on the validator list

no_merge: bool

If true, don’t try merging transient stake accounts into the reserve or validator stake account. Useful for testing or if a particular stake account is in a bad state, but we still want to update

UpdateStakePoolBalance

Updates total pool balance based on balances in the reserve and validator list

  1. [w] Stake pool
  2. [] Stake pool withdraw authority
  3. [w] Validator stake list storage account
  4. [] Reserve stake account
  5. [w] Account to receive pool fee tokens
  6. [w] Pool mint account
  7. [] Sysvar clock account
  8. [] Pool token program
Deposit

Deposit some stake into the pool. The output is a “pool” token representing ownership into the pool. Inputs are converted to the current ratio.

  1. [w] Stake pool
  2. [w] Validator stake list storage account
  3. [] Stake pool deposit authority
  4. [] Stake pool withdraw authority
  5. [w] Stake account to join the pool (withdraw authority for the stake account should be first set to the stake pool deposit authority)
  6. [w] Validator stake account for the stake account to be merged with
  7. [w] Reserve stake account, to withdraw rent exempt reserve
  8. [w] User account to receive pool tokens
  9. [w] Pool token mint account
  10. ‘[]’ Sysvar clock account
  11. ‘[]’ Sysvar stake history account
  12. [] Pool token program id,
  13. [] Stake program id,
Withdraw(u64)

Withdraw the token from the pool at the current ratio.

Succeeds if the stake account has enough SOL to cover the desired amount of pool tokens, and if the withdrawal keeps the total staked amount above the minimum of rent-exempt amount + 1 SOL.

A validator stake account can be withdrawn from freely, and the reserve can only be drawn from if there is no active stake left, where all validator accounts are left with 1 lamport.

  1. [w] Stake pool
  2. [w] Validator stake list storage account
  3. [] Stake pool withdraw authority
  4. [w] Validator or reserve stake account to split
  5. [w] Unitialized stake account to receive withdrawal
  6. [] User account to set as a new withdraw authority
  7. [s] User transfer authority, for pool token account
  8. [w] User account with pool tokens to burn from
  9. [w] Pool token mint account
  10. [] Sysvar clock account (required)
  11. [] Pool token program id
  12. [] Stake program id, userdata: amount of pool tokens to withdraw
SetManager

(Manager only) Update manager

  1. [w] StakePool
  2. [s] Manager
  3. ’[]` New manager pubkey
  4. ’[]` New manager fee account
SetFee

(Manager only) Update fee

  1. [w] StakePool
  2. [s] Manager
  3. [] Sysvar clock
Show fields

Fields of SetFee

fee: Fee

Fee assessed as percentage of perceived rewards

SetStaker

(Manager or staker only) Update staker

  1. [w] StakePool
  2. [s] Manager or current staker
  3. ’[]` New staker pubkey

Trait Implementations

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes. Read more

Deserialize this instance from a slice of bytes.

Whether Self is u8. NOTE: Vec<u8> is the most common use-case for serialization and deserialization, it’s worth handling it as a special case to improve performance. It’s a workaround for specific Vec<u8> implementation versus generic Vec<T> implementation. See https://github.com/rust-lang/rfcs/pull/1210 for details. Read more

Get the name of the type without brackets.

Recursively, using DFS, add type definitions required for this type. For primitive types this is an empty map. Type definition explains how to serialize/deserialize a type. Read more

Helper method to add a single type definition to the map.

Serialize this instance into a vector of bytes.

Whether Self is u8. NOTE: Vec<u8> is the most common use-case for serialization and deserialization, it’s worth handling it as a special case to improve performance. It’s a workaround for specific Vec<u8> implementation versus generic Vec<T> implementation. See https://github.com/rust-lang/rfcs/pull/1210 for details. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.