Stake Pool

The Stake pool program is the base component of Cardinal Staking. A stake pool, as it sounds, is a PDA owned by the Stake Pool program containing the following fields.
pub struct StakePool {
pub bump: u8,
pub identifier: u64,
pub authority: Pubkey,
pub requires_creators: Vec<Pubkey>,
pub requires_collections: Vec<Pubkey>,
pub requires_authorization: bool,
pub overlay_text: String,
pub image_uri: String,
requires_creators, requires_collections, and requires_authorization are the 3 different ways that a stake pool can gate which NFTs can be staked in the pool.
  • As it sounds, this is a filter on the NFT "creators" array (as stored in metaplex metadata
  • If this is set, any NFT with a creator that is listed in the array will be allowed to stake in the pool.
  • If your NFT was minted via Metaplex Candy Machine, you will likely want to use the candy machine ID in the requires_creator array.
  • If none of the above checks pass, a final check can be made to allow-list arbitrary mintIDs. The authority of a pool can set requires_authorization to TRUE and then allow-list any mint using the authorize_mint instruction.
  • This is purely additive, so if you want add more mints in addition to those passing the creators/collections check, you can leverage this feature.
  • Requires authorization can be used when the requires_creators and requires_collections arrays are empty to enforce a random mint list.
A stake pool is a collection of stake entries, each of which stores information related to a specific NFT and how long it has been staked in the pool.
pub struct StakeEntry {
pub bump: u8,
pub pool: Pubkey,
pub amount: u64,
pub original_mint: Pubkey,
pub original_mint_claimed: bool,
pub last_staker: Pubkey,
pub last_staked_at: i64,
pub total_stake_seconds: i128,
pub stake_mint_claimed: bool,
pub kind: u8,
pub stake_mint: Option<Pubkey>,
Every time a new NFT is staked, a stake entry must first be created. This can happen in a single transaction by combining the init_entry with stake instructions. If a receipt mint (see Stake Receipt section) is created, the current client will do this in two transactions due to compute limitations.
Stake entries also retain ownership of the given mint(s) while it is staked.
There are separate instructions for stake and claim_receipt_mint. The client will automatically stake the NFT and then optionally claim a receipt that can either contain the "original" mint OR a dynamic/mutable copy receipt mint.
Either or both of these mints must be returned to the stake_entry before the user can unstake. This will be done automatically when calling the unstake API.