StakePoolProgram.decreaseValidatorStake constructor

StakePoolProgram.decreaseValidatorStake({
  1. required SolAddress stakePool,
  2. required SolAddress staker,
  3. required SolAddress withdrawAuthority,
  4. required SolAddress validatorList,
  5. required SolAddress validatorStake,
  6. required SolAddress transientStake,
  7. required StakePoolDecreaseValidatorStakeLayout layout,
})

(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.

Implementation

factory StakePoolProgram.decreaseValidatorStake({
  /// Stake pool
  required SolAddress stakePool,

  /// Stake pool staker
  required SolAddress staker,

  /// Stake pool withdraw authority
  required SolAddress withdrawAuthority,

  /// Validator list
  required SolAddress validatorList,

  /// Canonical stake account to split from
  required SolAddress validatorStake,

  /// Transient stake account to receive split
  required SolAddress transientStake,
  required StakePoolDecreaseValidatorStakeLayout layout,
}) {
  return StakePoolProgram(
    layout: layout,
    keys: [
      stakePool.toReadOnly(),
      staker.toSigner(),
      withdrawAuthority.toReadOnly(),
      validatorList.toWritable(),
      validatorStake.toWritable(),
      transientStake.toWritable(),
      SystemProgramConst.sysvarClockPubkey.toReadOnly(),
      SystemProgramConst.sysvarRentPubkey.toReadOnly(),
      SystemProgramConst.programId.toReadOnly(),
      StakeProgramConst.programId.toReadOnly(),
    ],
    programId: StakePoolProgramConst.programId,
  );
}