StakePoolProgram.redelegate constructor

StakePoolProgram.redelegate({
  1. required SolAddress stakePool,
  2. required SolAddress staker,
  3. required SolAddress stakePoolWithdrawAuthority,
  4. required SolAddress validatorList,
  5. required SolAddress reserveStake,
  6. required SolAddress sourceValidatorStake,
  7. required SolAddress sourceTransientStake,
  8. required SolAddress ephemeralStake,
  9. required SolAddress destinationTransientStake,
  10. required SolAddress destinationValidatorStake,
  11. required SolAddress validator,
  12. required StakePoolReDelegateLayout layout,
})

(Staker only) Redelegate active stake on a validator, eventually moving it to another

Internally, this instruction splits a validator stake account into its corresponding transient stake account, redelegates it to an ephemeral stake account, then merges that stake into the destination 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 source transient stake account and ephemeral stake account do not exist.

The amount of lamports to move must be at least rent-exemption plus the minimum delegation amount. Rent-exemption plus minimum delegation is required for the destination ephemeral stake account.

The rent-exemption for the source transient account comes from the stake pool reserve, if needed.

Implementation

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

  /// Stake pool staker
  required SolAddress staker,

  /// Stake pool withdraw authority
  required SolAddress stakePoolWithdrawAuthority,

  /// Validator list
  required SolAddress validatorList,

  /// Reserve stake account, to withdraw rent exempt reserve
  required SolAddress reserveStake,

  /// Source canonical stake account to split from
  required SolAddress sourceValidatorStake,

  /// Source transient stake account to receive split and be
  /// redelegated
  required SolAddress sourceTransientStake,

  /// Uninitialized ephemeral stake account to receive redelegation
  required SolAddress ephemeralStake,

  /// Destination transient stake account to receive ephemeral stake
  /// by merge
  required SolAddress destinationTransientStake,

  /// Destination stake account to receive transient stake after
  /// activation
  required SolAddress destinationValidatorStake,

  /// Destination validator vote account
  required SolAddress validator,
  required StakePoolReDelegateLayout layout,
}) {
  return StakePoolProgram(
      layout: layout,
      keys: [
        stakePool.toReadOnly(),
        staker.toSigner(),
        stakePoolWithdrawAuthority.toReadOnly(),
        validatorList.toWritable(),
        reserveStake.toWritable(),
        sourceValidatorStake.toWritable(),
        sourceTransientStake.toWritable(),
        ephemeralStake.toWritable(),
        destinationTransientStake.toWritable(),
        destinationValidatorStake.toReadOnly(),
        validator.toReadOnly(),
        SystemProgramConst.sysvarClockPubkey.toReadOnly(),
        SystemProgramConst.sysvarStakeHistoryPubkey.toReadOnly(),
        StakeProgramConst.stakeConfigId.toReadOnly(),
        SystemProgramConst.programId.toReadOnly(),
        StakeProgramConst.programId.toReadOnly()
      ],
      programId: StakePoolProgramConst.programId);
}