StakePoolProgram.updateValidatorListBalance constructor

StakePoolProgram.updateValidatorListBalance({
  1. required SolAddress stakePool,
  2. required SolAddress withdrawAuthority,
  3. required SolAddress validatorList,
  4. required SolAddress reserveStake,
  5. required List<SolAddress> validatorAndTransientStakePairs,
  6. required StakePoolUpdateValidatorListBalanceLayout layout,
})

Updates balances of validator and transient stake accounts in the pool

While going through the pairs of validator and transient stake accounts, if the transient stake is inactive, it is merged into the reserve stake account. If the transient stake is active and has matching credits observed, it is merged into the canonical validator stake account. In all other states, nothing is done, and the balance is simply added to the canonical stake account balance.

Implementation

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

  /// Stake pool withdraw authority
  required SolAddress withdrawAuthority,

  /// Validator stake list storage account
  required SolAddress validatorList,

  /// Reserve stake account
  required SolAddress reserveStake,

  /// pairs of validator and transient stake accounts
  required List<SolAddress> validatorAndTransientStakePairs,
  required StakePoolUpdateValidatorListBalanceLayout layout,
}) {
  return StakePoolProgram(
      layout: layout,
      keys: [
        stakePool.toReadOnly(),
        withdrawAuthority.toReadOnly(),
        validatorList.toWritable(),
        reserveStake.toWritable(),
        SystemProgramConst.sysvarClockPubkey.toReadOnly(),
        SystemProgramConst.sysvarStakeHistoryPubkey.toReadOnly(),
        StakeProgramConst.programId.toReadOnly(),
        ...validatorAndTransientStakePairs.map((e) => e.toWritable())
      ],
      programId: StakePoolProgramConst.programId);
}