addValidatorToPool static method

TransactionInstruction addValidatorToPool({
  1. required Pubkey stakePoolAddress,
  2. required Pubkey staker,
  3. required Pubkey reserveStake,
  4. required Pubkey withdrawAuthority,
  5. required Pubkey validatorList,
  6. required Pubkey stakeAccount,
  7. required Pubkey voteAccount,
  8. u32? seed,
})

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

The stake account will have the rent-exempt amount plus max(crate::MINIMUM_ACTIVE_STAKE, solana_program::stake::tools::get_minimum_delegation()). It is funded from the stake pool reserve.

Keys:

  • [w] stakePoolAddress - Stake pool address.
  • [s] staker - Staker.
  • [w] reserveStake - Reserve stake account.
  • [] withdrawAuthority - Stake pool withdraw authority.
  • [w] validatorList - Validator stake list storage account.
  • [w] stakeAccount - Stake account to add to the pool.
  • [] voteAccount - Validator this stake account will be delegated to.

Data:

  • seed - Optional non-zero u32 seed used for generating the validator stake address.

Implementation

static TransactionInstruction addValidatorToPool({
  // Keys
  required final Pubkey stakePoolAddress,
  required final Pubkey staker,
  required final Pubkey reserveStake,
  required final Pubkey withdrawAuthority,
  required final Pubkey validatorList,
  required final Pubkey stakeAccount,
  required final Pubkey voteAccount,
  // Data
  final u32? seed,
}) {
  //  0. `[w]` Stake pool
  //  1. `[s]` Staker
  //  2. `[w]` Reserve stake account
  //  3. `[]` Stake pool withdraw authority
  //  4. `[w]` Validator stake list storage account
  //  5. `[w]` Stake account to add to the pool
  //  6. `[]` Validator this stake account will be delegated to
  //  7. `[]` Rent sysvar
  //  8. `[]` Clock sysvar
  //  9. '[]' Stake history sysvar
  // 10. '[]' Stake config sysvar
  // 11. `[]` System program
  // 12. `[]` Stake program
  final List<AccountMeta> keys = [
    AccountMeta.writable(stakePoolAddress),
    AccountMeta.signer(staker),
    AccountMeta.writable(reserveStake),
    AccountMeta(withdrawAuthority),
    AccountMeta.writable(validatorList),
    AccountMeta.writable(stakeAccount),
    AccountMeta(voteAccount),
    AccountMeta(sysvarRentPubkey),
    AccountMeta(sysvarClockPubkey),
    AccountMeta(sysvarStakeHistoryPubkey),
    AccountMeta(StakeProgram.configId),
    AccountMeta(SystemProgram.programId),
    AccountMeta(StakeProgram.programId),
  ];

  final List<Iterable<int>> data = [
    borsh.u32.option().encode(seed),
  ];

  return _instance.createTransactionIntruction(
    StakePoolInstruction.addValidatorToPool,
    keys: keys,
    data: data,
  );
}