decreaseAdditionalValidatorStake static method

TransactionInstruction decreaseAdditionalValidatorStake({
  1. required Pubkey stakePoolAddress,
  2. required Pubkey staker,
  3. required Pubkey withdrawAuthority,
  4. required Pubkey validatorList,
  5. required Pubkey stakeAccount,
  6. required Pubkey uninitializedStakeAccount,
  7. required Pubkey transientStakeAccount,
  8. required bu64 lamports,
  9. required bu64 transientStakeSeed,
  10. required bu64 ephemeralStakeSeed,
})

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

Works regardless if the transient stake account already exists.

Internally, this instruction splits a validator stake account into an ephemeral stake account, deactivates it, then merges or splits it into the transient stake account delegated to the appropriate validator.

The amount of lamports to move must be at least 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] stakeAccount - Canonical stake account to split from.
  • [w] uninitializedStakeAccount - Uninitialized ephemeral stake account to receive stake.
  • [w] transientStakeAccount - Transient stake account.

Data:

  • lamports - Amount of lamports to split into the transient stake account.
  • transientStakeSeed - Seed used to create transient stake account.
  • ephemeralStakeSeed - Seed used to create ephemeral account.

Implementation

static TransactionInstruction decreaseAdditionalValidatorStake({
  // Keys
  required final Pubkey stakePoolAddress,
  required final Pubkey staker,
  required final Pubkey withdrawAuthority,
  required final Pubkey validatorList,
  required final Pubkey stakeAccount,
  required final Pubkey uninitializedStakeAccount,
  required final Pubkey transientStakeAccount,
  // Data
  required final bu64 lamports,
  required final bu64 transientStakeSeed,
  required final bu64 ephemeralStakeSeed,
}) {
  //  0. `[]` Stake pool
  //  1. `[s]` Stake pool staker
  //  2. `[]` Stake pool withdraw authority
  //  3. `[w]` Validator list
  //  4. `[w]` Canonical stake account to split from
  //  5. `[w]` Uninitialized ephemeral stake account to receive stake
  //  6. `[w]` Transient stake account
  //  7. `[]` Clock sysvar
  //  8. '[]' Stake history sysvar
  //  9. `[]` System program
  // 10. `[]` Stake program
  final List<AccountMeta> keys = [
    AccountMeta(stakePoolAddress),
    AccountMeta.signer(staker),
    AccountMeta(withdrawAuthority),
    AccountMeta.writable(validatorList),
    AccountMeta.writable(stakeAccount),
    AccountMeta.writable(uninitializedStakeAccount),
    AccountMeta.writable(transientStakeAccount),
    AccountMeta(sysvarClockPubkey),
    AccountMeta(sysvarStakeHistoryPubkey),
    AccountMeta(SystemProgram.programId),
    AccountMeta(StakeProgram.programId),
  ];

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

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