increaseValidatorStake static method

TransactionInstruction increaseValidatorStake({
  1. required Pubkey stakePoolAddress,
  2. required Pubkey staker,
  3. required Pubkey withdrawAuthority,
  4. required Pubkey validatorList,
  5. required Pubkey reserveStake,
  6. required Pubkey transientStakeAccount,
  7. required Pubkey validatorStakeAccount,
  8. required Pubkey validatorVoteAccount,
  9. required bu64 lamports,
  10. required bu64 transientStakeSeed,
})

(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 max(crate::MINIMUM_ACTIVE_STAKE, solana_program::stake::tools::get_minimum_delegation()).

Keys:

  • [] stakePoolAddress - Stake pool.
  • [s] staker - Stake pool staker.
  • [] withdrawAuthority - Stake pool withdraw authority.
  • [w] validatorList - Validator list.
  • [w] reserveStake - Stake pool reserve stake.
  • [w] transientStakeAccount - Transient stake account.
  • [] validatorStakeAccount - Validator stake account.
  • [] validatorVoteAccount - Validator vote account to delegate to.

Data:

  • lamports - 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.
  • transientStakeSeed - Seed used to create transient stake account.

Implementation

static TransactionInstruction increaseValidatorStake({
  // Keys
  required final Pubkey stakePoolAddress,
  required final Pubkey staker,
  required final Pubkey withdrawAuthority,
  required final Pubkey validatorList,
  required final Pubkey reserveStake,
  required final Pubkey transientStakeAccount,
  required final Pubkey validatorStakeAccount,
  required final Pubkey validatorVoteAccount,
  // Data
  required final bu64 lamports,
  required final bu64 transientStakeSeed,
}) {
  //  0. `[]` Stake pool
  //  1. `[s]` Stake pool staker
  //  2. `[]` Stake pool withdraw authority
  //  3. `[w]` Validator list
  //  4. `[w]` Stake pool reserve stake
  //  5. `[w]` Transient stake account
  //  6. `[]` Validator 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
  final List<AccountMeta> keys = [
    AccountMeta(stakePoolAddress),
    AccountMeta.signer(staker),
    AccountMeta(withdrawAuthority),
    AccountMeta.writable(validatorList),
    AccountMeta.writable(reserveStake),
    AccountMeta.writable(transientStakeAccount),
    AccountMeta(validatorStakeAccount),
    AccountMeta(validatorVoteAccount),
    AccountMeta(sysvarClockPubkey),
    AccountMeta(sysvarRentPubkey),
    AccountMeta(sysvarStakeHistoryPubkey),
    AccountMeta(StakeProgram.configId),
    AccountMeta(SystemProgram.programId),
    AccountMeta(StakeProgram.programId),
  ];

  final List<Iterable<int>> data = [
    borsh.u64.encode(lamports),
    borsh.u64.encode(transientStakeSeed),
  ];

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