StakePoolProgram.decreaseValidatorStakeWithReserve constructor

StakePoolProgram.decreaseValidatorStakeWithReserve({
  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 SolAddress reserveStake,
  8. required StakePoolDecreaseValidatorStakeWithReserveLayout layout,
})

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

Internally, this instruction:

  • withdraws enough lamports to make the transient account rent-exempt
  • splits from a validator stake account into a transient stake account
  • deactivates the transient stake account

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.

Implementation

factory StakePoolProgram.decreaseValidatorStakeWithReserve({
  /// 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,

  /// Reserve stake account, to fund rent exempt reserve
  required SolAddress reserveStake,
  required StakePoolDecreaseValidatorStakeWithReserveLayout layout,
}) {
  return StakePoolProgram(
      layout: layout,
      keys: [
        stakePool.toReadOnly(),
        staker.toSigner(),
        withdrawAuthority.toReadOnly(),
        validatorList.toWritable(),
        reserveStake.toWritable(),
        validatorStake.toWritable(),
        transientStake.toWritable(),
        SystemProgramConst.sysvarClockPubkey.toReadOnly(),
        SystemProgramConst.sysvarStakeHistoryPubkey.toReadOnly(),
        SystemProgramConst.programId.toReadOnly(),
        StakeProgramConst.programId.toReadOnly(),
      ],
      programId: StakePoolProgramConst.programId);
}