#[repr(C)]
pub enum StakePoolInstruction {
Show 17 variants Initialize { fee: Fee, withdrawal_fee: Fee, deposit_fee: Fee, referral_fee: u8, max_validators: u32, }, AddValidatorToPool, RemoveValidatorFromPool, DecreaseValidatorStake { lamports: u64, transient_stake_seed: u64, }, IncreaseValidatorStake { lamports: u64, transient_stake_seed: u64, }, SetPreferredValidator { validator_type: PreferredValidatorType, validator_vote_address: Option<Pubkey>, }, UpdateValidatorListBalance { start_index: u32, no_merge: bool, }, UpdateStakePoolBalance, CleanupRemovedValidatorEntries, DepositStake, WithdrawStake(u64), SetManager, SetFee { fee: FeeType, }, SetStaker, DepositSol(u64), SetFundingAuthority(FundingType), WithdrawSol(u64),
}
Expand description

Instructions supported by the StakePool program.

Variants

Initialize

Fields

fee: Fee

Fee assessed as percentage of perceived rewards

withdrawal_fee: Fee

Fee charged per withdrawal as percentage of withdrawal

deposit_fee: Fee

Fee charged per deposit as percentage of deposit

referral_fee: u8

Percentage [0-100] of deposit_fee that goes to referrer

max_validators: u32

Maximum expected number of validators

Initializes a new StakePool.

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

AddValidatorToPool

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

The stake account will have the rent-exempt amount plus crate::MINIMUM_ACTIVE_STAKE (currently 0.001 SOL).

  1. [w] Stake pool
  2. [s] Staker
  3. [ws] Funding account (must be a system account)
  4. [] Stake pool withdraw authority
  5. [w] Validator stake list storage account
  6. [w] Stake account to add to the pool
  7. [] Validator this stake account will be delegated to
  8. [] Rent sysvar
  9. [] Clock sysvar
  10. ‘[]’ Stake history sysvar
  11. ‘[]’ Stake config sysvar
  12. [] System program
  13. [] Stake program

RemoveValidatorFromPool

(Staker only) Removes validator from the pool

Only succeeds if the validator stake account has the minimum of crate::MINIMUM_ACTIVE_STAKE (currently 0.001 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. [w] Destination stake account, to receive the minimum SOL from the validator stake account
  9. [] Sysvar clock
  10. [] Stake program id,

DecreaseValidatorStake

Fields

lamports: u64

amount of lamports to split into the transient stake account

transient_stake_seed: u64

seed used to create transient stake account

(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

IncreaseValidatorStake

Fields

lamports: u64

amount of lamports to increase on the given validator

transient_stake_seed: u64

seed used to create transient stake account

(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 crate::MINIMUM_ACTIVE_STAKE (currently 0.001 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 increase on the given validator. The actual amount split into the transient stake account is: lamports + stake_rent_exemption The rent-exemption of the stake account is withdrawn back to the reserve after it is merged.

SetPreferredValidator

Fields

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

(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. [w] Stake pool
  2. [s] Stake pool staker
  3. [] Validator list

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

UpdateValidatorListBalance

Fields

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

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

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. [] Pool token program

CleanupRemovedValidatorEntries

Cleans up validator stake account entries marked as ReadyForRemoval

  1. [] Stake pool
  2. [w] Validator stake list storage account

DepositStake

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. [s]/[] 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] Account to receive pool fee tokens
  10. [w] Account to receive a portion of pool fee tokens as referral fees
  11. [w] Pool token mint account
  12. ‘[]’ Sysvar clock account
  13. ‘[]’ Sysvar stake history account
  14. [] Pool token program id,
  15. [] Stake program id,

WithdrawStake(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 + 0.001 SOL.

When allowing withdrawals, the order of priority goes:

  • preferred withdraw validator stake account (if set)
  • validator stake accounts
  • transient stake accounts
  • reserve stake account

A user can freely withdraw from a validator stake account, and if they are all at the minimum, then they can withdraw from transient stake accounts, and if they are all at minimum, then they can withdraw from the reserve.

  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] Account to receive pool fee tokens
  10. [w] Pool token mint account
  11. [] Sysvar clock account (required)
  12. [] Pool token program id
  13. [] Stake program id, userdata: amount of pool tokens to withdraw

SetManager

(Manager only) Update manager

  1. [w] StakePool
  2. [s] Manager
  3. [s] New manager
  4. [] New manager fee account

SetFee

Fields

fee: FeeType

Type of fee to update and value to update it to

(Manager only) Update fee

  1. [w] StakePool
  2. [s] Manager

SetStaker

(Manager or staker only) Update staker

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

DepositSol(u64)

Deposit SOL directly into the pool’s reserve account. The output is a “pool” token representing ownership into the pool. Inputs are converted to the current ratio.

  1. [w] Stake pool
  2. [] Stake pool withdraw authority
  3. [w] Reserve stake account, to deposit SOL
  4. [s] Account providing the lamports to be deposited into the pool
  5. [w] User account to receive pool tokens
  6. [w] Account to receive fee tokens
  7. [w] Account to receive a portion of fee as referral fees
  8. [w] Pool token mint account
  9. [] System program account
  10. [] Token program id
  11. [s] (Optional) Stake pool sol deposit authority.

SetFundingAuthority(FundingType)

(Manager only) Update SOL deposit authority

  1. [w] StakePool
  2. [s] Manager
  3. ’[]` New authority pubkey or none

WithdrawSol(u64)

Withdraw SOL directly from the pool’s reserve account. Fails if the reserve does not have enough SOL.

  1. [w] Stake pool
  2. [] Stake pool withdraw authority
  3. [s] User transfer authority, for pool token account
  4. [w] User account to burn pool tokens
  5. [w] Reserve stake account, to withdraw SOL
  6. [w] Account receiving the lamports from the reserve, must be a system account
  7. [w] Account to receive pool fee tokens
  8. [w] Pool token mint account
  9. ‘[]’ Clock sysvar
  10. ‘[]’ Stake history sysvar
  11. [] Stake program account
  12. [] Token program id
  13. [s] (Optional) Stake pool sol withdraw authority

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.

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.

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

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)

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.