StakeInstruction.merge constructor

StakeInstruction.merge({
  1. required Ed25519HDPublicKey sourceStake,
  2. required Ed25519HDPublicKey destinationStake,
  3. required Ed25519HDPublicKey authority,
})

Merge two stake accounts.

Both accounts must have identical lockup and authority keys. A merge is possible between two stakes in the following states with no additional conditions:

  • two deactivated stakes
  • an inactive stake into an activating stake during its activation epoch

For the following cases, the voter pubkey and vote credits observed must match:

  • two activated stakes
  • two activating accounts that share an activation epoch, during the activation epoch

All other combinations of stake states will fail to merge, including all "transient" states, where a stake is activating or deactivating with a non-zero effective stake.

Implementation

factory StakeInstruction.merge({
  required Ed25519HDPublicKey sourceStake,
  required Ed25519HDPublicKey destinationStake,
  required Ed25519HDPublicKey authority,
}) =>
    StakeInstruction._(
      accounts: [
        AccountMeta.writeable(
          pubKey: destinationStake,
          isSigner: false,
        ),
        AccountMeta.writeable(pubKey: sourceStake, isSigner: false),
        AccountMeta.readonly(
          pubKey: Ed25519HDPublicKey.fromBase58(Sysvar.clock),
          isSigner: false,
        ),
        AccountMeta.readonly(
          pubKey: Ed25519HDPublicKey.fromBase58(Sysvar.stakeHistory),
          isSigner: false,
        ),
        AccountMeta.readonly(pubKey: authority, isSigner: true),
      ],
      data: StakeProgram.mergeInstructionIndex,
    );