From ebca3e4b9c932d7d515c9b481b87c6d61da6caac Mon Sep 17 00:00:00 2001 From: jpe7s Date: Thu, 29 Aug 2024 15:04:30 -0500 Subject: [PATCH] fix javadoc warnings. --- settings.gradle | 2 +- .../AddressLookupTableProgram.java | 84 +- .../solana/programs/stake/StakeProgram.java | 364 +++--- .../solana/programs/stake/StakeStatus.java | 18 +- .../programs/stakepool/StakePoolProgram.java | 1121 ++++++++--------- .../solana/programs/system/SystemProgram.java | 208 +-- .../token/AssociatedTokenProgram.java | 76 +- .../solana/programs/token/TokenProgram.java | 756 +++++------ 8 files changed, 1314 insertions(+), 1315 deletions(-) diff --git a/settings.gradle b/settings.gradle index 36168d8..36c5e68 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,7 +11,7 @@ dependencyResolutionManagement { } versionCatalogs { libs { - from("software.sava:solana-version-catalog:0.0.4") + from("software.sava:solana-version-catalog:0.0.8") } } } \ No newline at end of file diff --git a/src/main/java/software/sava/solana/programs/address_lookup_table/AddressLookupTableProgram.java b/src/main/java/software/sava/solana/programs/address_lookup_table/AddressLookupTableProgram.java index 3c0a920..2bb0daf 100644 --- a/src/main/java/software/sava/solana/programs/address_lookup_table/AddressLookupTableProgram.java +++ b/src/main/java/software/sava/solana/programs/address_lookup_table/AddressLookupTableProgram.java @@ -20,61 +20,61 @@ public final class AddressLookupTableProgram { private enum Instructions implements Discriminator { - /// Create an address lookup table - /// - /// # Account references - /// 0. `[WRITE]` Uninitialized address lookup table account - /// 1. `[SIGNER]` Account used to derive and control the new address lookup table. - /// 2. `[SIGNER, WRITE]` Account that will fund the new address lookup table. - /// 3. `[]` System program for CPI. + // Create an address lookup table + // + // # Account references + // 0. '[WRITE]' Uninitialized address lookup table account + // 1. '[SIGNER]' Account used to derive and control the new address lookup table. + // 2. '[SIGNER, WRITE]' Account that will fund the new address lookup table. + // 3. '[]' System program for CPI. CreateLookupTable { - /// A recent slot must be used in the derivation path - /// for each initialized table. When closing table accounts, - /// the initialization slot must no longer be "recent" to prevent - /// address tables from being recreated with reordered or - /// otherwise malicious addresses. + // A recent slot must be used in the derivation path + // for each initialized table. When closing table accounts, + // the initialization slot must no longer be "recent" to prevent + // address tables from being recreated with reordered or + // otherwise malicious addresses. // recent_slot: Slot, -// /// Address tables are always initialized at program-derived -// /// addresses using the funding address, recent blockhash, and -// /// the user-passed `bump_seed`. +// // Address tables are always initialized at program-derived +// // addresses using the funding address, recent blockhash, and +// // the user-passed 'bump_seed'. // bump_seed: u8, }, - /// Permanently freeze an address lookup table, making it immutable. - /// - /// # Account references - /// 0. `[WRITE]` Address lookup table account to freeze - /// 1. `[SIGNER]` Current authority + // Permanently freeze an address lookup table, making it immutable. + // + // # Account references + // 0. '[WRITE]' Address lookup table account to freeze + // 1. '[SIGNER]' Current authority FreezeLookupTable, - /// Extend an address lookup table with new addresses. Funding account and - /// system program account references are only required if the lookup table - /// account requires additional lamports to cover the rent-exempt balance - /// after being extended. - /// - /// # Account references - /// 0. `[WRITE]` Address lookup table account to extend - /// 1. `[SIGNER]` Current authority - /// 2. `[SIGNER, WRITE, OPTIONAL]` Account that will fund the table reallocation - /// 3. `[OPTIONAL]` System program for CPI. + // Extend an address lookup table with new addresses. Funding account and + // system program account references are only required if the lookup table + // account requires additional lamports to cover the rent-exempt balance + // after being extended. + // + // # Account references + // 0. '[WRITE]' Address lookup table account to extend + // 1. '[SIGNER]' Current authority + // 2. '[SIGNER, WRITE, OPTIONAL]' Account that will fund the table reallocation + // 3. '[OPTIONAL]' System program for CPI. ExtendLookupTable { // new_addresses: Vec }, - /// Deactivate an address lookup table, making it unusable and - /// eligible for closure after a short period of time. - /// - /// # Account references - /// 0. `[WRITE]` Address lookup table account to deactivate - /// 1. `[SIGNER]` Current authority + // Deactivate an address lookup table, making it unusable and + // eligible for closure after a short period of time. + // + // # Account references + // 0. '[WRITE]' Address lookup table account to deactivate + // 1. '[SIGNER]' Current authority DeactivateLookupTable, - /// Close an address lookup table account - /// - /// # Account references - /// 0. `[WRITE]` Address lookup table account to close - /// 1. `[SIGNER]` Current authority - /// 2. `[WRITE]` Recipient of closed account lamports + // Close an address lookup table account + // + // # Account references + // 0. '[WRITE]' Address lookup table account to close + // 1. '[SIGNER]' Current authority + // 2. '[WRITE]' Recipient of closed account lamports CloseLookupTable; private final byte[] data; diff --git a/src/main/java/software/sava/solana/programs/stake/StakeProgram.java b/src/main/java/software/sava/solana/programs/stake/StakeProgram.java index 32ecfd4..f657d27 100644 --- a/src/main/java/software/sava/solana/programs/stake/StakeProgram.java +++ b/src/main/java/software/sava/solana/programs/stake/StakeProgram.java @@ -21,236 +21,236 @@ public final class StakeProgram { private enum Instructions implements Discriminator { - /// Initialize a stake with lockup and authorization information - /// - /// # Account references - /// 0. `[WRITE]` Uninitialized stake account - /// 1. `[]` Rent sysvar - /// - /// Authorized carries pub keys that must sign staker transactions - /// and withdrawer transactions. - /// Lockup carries information about withdrawal restrictions + // Initialize a stake with lockup and authorization information + // + // # Account references + // 0. '[WRITE]' Uninitialized stake account + // 1. '[]' Rent sysvar + // + // Authorized carries pub keys that must sign staker transactions + // and withdrawer transactions. + // Lockup carries information about withdrawal restrictions Initialize( // Authorized, Lockup ), - /// Authorize a key to manage stake or withdrawal - /// - /// # Account references - /// 0. `[WRITE]` Stake account to be updated - /// 1. `[]` Clock sysvar - /// 2. `[SIGNER]` The stake or withdraw authority - /// 3. Optional: `[SIGNER]` Lockup authority, if updating StakeAuthorize::Withdrawer before - /// lockup expiration + // Authorize a key to manage stake or withdrawal + // + // # Account references + // 0. '[WRITE]' Stake account to be updated + // 1. '[]' Clock sysvar + // 2. '[SIGNER]' The stake or withdraw authority + // 3. Optional: '[SIGNER]' Lockup authority, if updating StakeAuthorize::Withdrawer before + // lockup expiration Authorize( // Pubkey, StakeAuthorize ), - /// Delegate a stake to a particular vote account - /// - /// # Account references - /// 0. `[WRITE]` Initialized stake account to be delegated - /// 1. `[]` Vote account to which this stake will be delegated - /// 2. `[]` Clock sysvar - /// 3. `[]` Stake history sysvar that carries stake warmup/cooldown history - /// 4. `[]` Address of config account that carries stake config - /// 5. `[SIGNER]` Stake authority - /// - /// The entire balance of the staking account is staked. DelegateStake - /// can be called multiple times, but re-delegation is delayed - /// by one epoch + // Delegate a stake to a particular vote account + // + // # Account references + // 0. '[WRITE]' Initialized stake account to be delegated + // 1. '[]' Vote account to which this stake will be delegated + // 2. '[]' Clock sysvar + // 3. '[]' Stake history sysvar that carries stake warmup/cooldown history + // 4. '[]' Address of config account that carries stake config + // 5. '[SIGNER]' Stake authority + // + // The entire balance of the staking account is staked. DelegateStake + // can be called multiple times, but re-delegation is delayed + // by one epoch DelegateStake, - /// Split u64 tokens and stake off a stake account into another stake account. - /// - /// # Account references - /// 0. `[WRITE]` Stake account to be split; must be in the Initialized or Stake state - /// 1. `[WRITE]` Uninitialized stake account that will take the split-off amount - /// 2. `[SIGNER]` Stake authority + // Split u64 tokens and stake off a stake account into another stake account. + // + // # Account references + // 0. '[WRITE]' Stake account to be split; must be in the Initialized or Stake state + // 1. '[WRITE]' Uninitialized stake account that will take the split-off amount + // 2. '[SIGNER]' Stake authority Split( // u64 ), - /// Withdraw unstaked lamports from the stake account - /// - /// # Account references - /// 0. `[WRITE]` Stake account from which to withdraw - /// 1. `[WRITE]` Recipient account - /// 2. `[]` Clock sysvar - /// 3. `[]` Stake history sysvar that carries stake warmup/cooldown history - /// 4. `[SIGNER]` Withdraw authority - /// 5. Optional: `[SIGNER]` Lockup authority, if before lockup expiration - /// - /// The u64 is the portion of the stake account balance to be withdrawn, - /// must be `<= StakeAccount.lamports - staked_lamports`. + // Withdraw unstaked lamports from the stake account + // + // # Account references + // 0. '[WRITE]' Stake account from which to withdraw + // 1. '[WRITE]' Recipient account + // 2. '[]' Clock sysvar + // 3. '[]' Stake history sysvar that carries stake warmup/cooldown history + // 4. '[SIGNER]' Withdraw authority + // 5. Optional: '[SIGNER]' Lockup authority, if before lockup expiration + // + // The u64 is the portion of the stake account balance to be withdrawn, + // must be '<= StakeAccount.lamports - staked_lamports'. Withdraw( // u64 ), - /// Deactivates the stake in the account - /// - /// # Account references - /// 0. `[WRITE]` Delegated stake account - /// 1. `[]` Clock sysvar - /// 2. `[SIGNER]` Stake authority + // Deactivates the stake in the account + // + // # Account references + // 0. '[WRITE]' Delegated stake account + // 1. '[]' Clock sysvar + // 2. '[SIGNER]' Stake authority Deactivate, - /// Set stake lockup - /// - /// If a lockup is not active, the withdrawal authority may set a new lockup - /// If a lockup is active, the lockup custodian may update the lockup parameters - /// - /// # Account references - /// 0. `[WRITE]` Initialized stake account - /// 1. `[SIGNER]` Lockup authority or withdraw authority + // Set stake lockup + // + // If a lockup is not active, the withdrawal authority may set a new lockup + // If a lockup is active, the lockup custodian may update the lockup parameters + // + // # Account references + // 0. '[WRITE]' Initialized stake account + // 1. '[SIGNER]' Lockup authority or withdraw authority SetLockup( // LockupArgs ), - /// 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. - /// - /// # Account references - /// 0. `[WRITE]` Destination stake account for the merge - /// 1. `[WRITE]` Source stake account for to merge. This account will be drained - /// 2. `[]` Clock sysvar - /// 3. `[]` Stake history sysvar that carries stake warmup/cooldown history - /// 4. `[SIGNER]` Stake 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. + // + // # Account references + // 0. '[WRITE]' Destination stake account for the merge + // 1. '[WRITE]' Source stake account for to merge. This account will be drained + // 2. '[]' Clock sysvar + // 3. '[]' Stake history sysvar that carries stake warmup/cooldown history + // 4. '[SIGNER]' Stake authority Merge, - /// Authorize a key to manage stake or withdrawal with a derived key - /// - /// # Account references - /// 0. `[WRITE]` Stake account to be updated - /// 1. `[SIGNER]` Base key of stake or withdraw authority - /// 2. `[]` Clock sysvar - /// 3. Optional: `[SIGNER]` Lockup authority, if updating StakeAuthorize::Withdrawer before - /// lockup expiration + // Authorize a key to manage stake or withdrawal with a derived key + // + // # Account references + // 0. '[WRITE]' Stake account to be updated + // 1. '[SIGNER]' Base key of stake or withdraw authority + // 2. '[]' Clock sysvar + // 3. Optional: '[SIGNER]' Lockup authority, if updating StakeAuthorize::Withdrawer before + // lockup expiration AuthorizeWithSeed( // AuthorizeWithSeedArgs ), - /// Initialize a stake with authorization information - /// - /// This instruction is similar to `Initialize` except that the withdrawal authority - /// must be a signer, and no lockup is applied to the account. - /// - /// # Account references - /// 0. `[WRITE]` Uninitialized stake account - /// 1. `[]` Rent sysvar - /// 2. `[]` The stake authority - /// 3. `[SIGNER]` The withdrawal authority - /// + // Initialize a stake with authorization information + // + // This instruction is similar to 'Initialize' except that the withdrawal authority + // must be a signer, and no lockup is applied to the account. + // + // # Account references + // 0. '[WRITE]' Uninitialized stake account + // 1. '[]' Rent sysvar + // 2. '[]' The stake authority + // 3. '[SIGNER]' The withdrawal authority + // InitializeChecked, - /// Authorize a key to manage stake or withdrawal - /// - /// This instruction behaves like `Authorize` with the additional requirement that the new - /// stake or withdraw authority must also be a signer. - /// - /// # Account references - /// 0. `[WRITE]` Stake account to be updated - /// 1. `[]` Clock sysvar - /// 2. `[SIGNER]` The stake or withdraw authority - /// 3. `[SIGNER]` The new stake or withdraw authority - /// 4. Optional: `[SIGNER]` Lockup authority, if updating StakeAuthorize::Withdrawer before - /// lockup expiration + // Authorize a key to manage stake or withdrawal + // + // This instruction behaves like 'Authorize' with the additional requirement that the new + // stake or withdraw authority must also be a signer. + // + // # Account references + // 0. '[WRITE]' Stake account to be updated + // 1. '[]' Clock sysvar + // 2. '[SIGNER]' The stake or withdraw authority + // 3. '[SIGNER]' The new stake or withdraw authority + // 4. Optional: '[SIGNER]' Lockup authority, if updating StakeAuthorize::Withdrawer before + // lockup expiration AuthorizeChecked( // StakeAuthorize ), - /// Authorize a key to manage stake or withdrawal with a derived key - /// - /// This instruction behaves like `AuthorizeWithSeed` with the additional requirement that - /// the new stake or withdraw authority must also be a signer. - /// - /// # Account references - /// 0. `[WRITE]` Stake account to be updated - /// 1. `[SIGNER]` Base key of stake or withdraw authority - /// 2. `[]` Clock sysvar - /// 3. `[SIGNER]` The new stake or withdraw authority - /// 4. Optional: `[SIGNER]` Lockup authority, if updating StakeAuthorize::Withdrawer before - /// lockup expiration + // Authorize a key to manage stake or withdrawal with a derived key + // + // This instruction behaves like 'AuthorizeWithSeed' with the additional requirement that + // the new stake or withdraw authority must also be a signer. + // + // # Account references + // 0. '[WRITE]' Stake account to be updated + // 1. '[SIGNER]' Base key of stake or withdraw authority + // 2. '[]' Clock sysvar + // 3. '[SIGNER]' The new stake or withdraw authority + // 4. Optional: '[SIGNER]' Lockup authority, if updating StakeAuthorize::Withdrawer before + // lockup expiration AuthorizeCheckedWithSeed( // AuthorizeCheckedWithSeedArgs ), - /// Set stake lockup - /// - /// This instruction behaves like `SetLockup` with the additional requirement that - /// the new lockup authority also be a signer. - /// - /// If a lockup is not active, the withdrawal authority may set a new lockup - /// If a lockup is active, the lockup custodian may update the lockup parameters - /// - /// # Account references - /// 0. `[WRITE]` Initialized stake account - /// 1. `[SIGNER]` Lockup authority or withdraw authority - /// 2. Optional: `[SIGNER]` New lockup authority + // Set stake lockup + // + // This instruction behaves like 'SetLockup' with the additional requirement that + // the new lockup authority also be a signer. + // + // If a lockup is not active, the withdrawal authority may set a new lockup + // If a lockup is active, the lockup custodian may update the lockup parameters + // + // # Account references + // 0. '[WRITE]' Initialized stake account + // 1. '[SIGNER]' Lockup authority or withdraw authority + // 2. Optional: '[SIGNER]' New lockup authority SetLockupChecked( // LockupCheckedArgs ), - /// Get the minimum stake delegation, in lamports - /// - /// # Account references - /// None - /// - /// Returns the minimum delegation as a little-endian encoded u64 value. - /// Programs can use the [`get_minimum_delegation()`] helper function to invoke and - /// retrieve the return value for this instruction. - /// - /// [`get_minimum_delegation()`]: super::tools::get_minimum_delegation + // Get the minimum stake delegation, in lamports + // + // # Account references + // None + // + // Returns the minimum delegation as a little-endian encoded u64 value. + // Programs can use the ['get_minimum_delegation()'] helper function to invoke and + // retrieve the return value for this instruction. + // + // ['get_minimum_delegation()']: super::tools::get_minimum_delegation GetMinimumDelegation, - /// Deactivate stake delegated to a vote account that has been delinquent for at least - /// `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs. - /// - /// No signer is required for this instruction as it is a common good to deactivate abandoned - /// stake. - /// - /// # Account references - /// 0. `[WRITE]` Delegated stake account - /// 1. `[]` Delinquent vote account for the delegated stake account - /// 2. `[]` Reference vote account that has voted at least once in the last - /// `MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION` epochs + // Deactivate stake delegated to a vote account that has been delinquent for at least + // 'MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION' epochs. + // + // No signer is required for this instruction as it is a common good to deactivate abandoned + // stake. + // + // # Account references + // 0. '[WRITE]' Delegated stake account + // 1. '[]' Delinquent vote account for the delegated stake account + // 2. '[]' Reference vote account that has voted at least once in the last + // 'MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION' epochs DeactivateDelinquent, - /// Relegate activated stake to another vote account. - /// - /// Upon success: - /// * the balance of the delegated stake account will be reduced to the undelegated amount in - /// the account (rent exempt minimum and any additional lamports not part of the delegation), - /// and scheduled for deactivation. - /// * the provided uninitialized stake account will receive the original balance of the - /// delegated stake account, minus the rent exempt minimum, and scheduled for activation to - /// the provided vote account. Any existing lamports in the uninitialized stake account - /// will also be included in the re-delegation. - /// - /// # Account references - /// 0. `[WRITE]` Delegated stake account to be re-delegated. The account must be fully - /// activated and carry a balance greater than or equal to the minimum delegation amount - /// plus rent exempt minimum - /// 1. `[WRITE]` Uninitialized stake account that will hold the re-delegated stake - /// 2. `[]` Vote account to which this stake will be re-delegated - /// 3. `[]` Address of config account that carries stake config - /// 4. `[SIGNER]` Stake authority - /// + // Relegate activated stake to another vote account. + // + // Upon success: + // * the balance of the delegated stake account will be reduced to the undelegated amount in + // the account (rent exempt minimum and any additional lamports not part of the delegation), + // and scheduled for deactivation. + // * the provided uninitialized stake account will receive the original balance of the + // delegated stake account, minus the rent exempt minimum, and scheduled for activation to + // the provided vote account. Any existing lamports in the uninitialized stake account + // will also be included in the re-delegation. + // + // # Account references + // 0. '[WRITE]' Delegated stake account to be re-delegated. The account must be fully + // activated and carry a balance greater than or equal to the minimum delegation amount + // plus rent exempt minimum + // 1. '[WRITE]' Uninitialized stake account that will hold the re-delegated stake + // 2. '[]' Vote account to which this stake will be re-delegated + // 3. '[]' Address of config account that carries stake config + // 4. '[SIGNER]' Stake authority + // Redelegate; private final byte[] data; diff --git a/src/main/java/software/sava/solana/programs/stake/StakeStatus.java b/src/main/java/software/sava/solana/programs/stake/StakeStatus.java index 6979941..3e1d6c6 100644 --- a/src/main/java/software/sava/solana/programs/stake/StakeStatus.java +++ b/src/main/java/software/sava/solana/programs/stake/StakeStatus.java @@ -1,18 +1,18 @@ package software.sava.solana.programs.stake; public enum StakeStatus { - /// Stake account is active, there may be a transient stake as well + // Stake account is active, there may be a transient stake as well Active, - /// Only transient stake account exists, when a transient stake is - /// deactivating during validator removal + // Only transient stake account exists, when a transient stake is + // deactivating during validator removal DeactivatingTransient, - /// No more validator stake accounts exist, entry ready for removal during - /// `UpdateStakePoolBalance` + // No more validator stake accounts exist, entry ready for removal during + // 'UpdateStakePoolBalance' ReadyForRemoval, - /// Only the validator stake account is deactivating, no transient stake - /// account exists + // Only the validator stake account is deactivating, no transient stake + // account exists DeactivatingValidator, - /// Both the transient and validator stake account are deactivating, when - /// a validator is removed with a transient stake active + // Both the transient and validator stake account are deactivating, when + // a validator is removed with a transient stake active DeactivatingAll } diff --git a/src/main/java/software/sava/solana/programs/stakepool/StakePoolProgram.java b/src/main/java/software/sava/solana/programs/stakepool/StakePoolProgram.java index 15a84a3..e92c2d8 100644 --- a/src/main/java/software/sava/solana/programs/stakepool/StakePoolProgram.java +++ b/src/main/java/software/sava/solana/programs/stakepool/StakePoolProgram.java @@ -17,688 +17,687 @@ // https://github.com/igneous-labs/sanctum-spl-stake-pool/blob/sanctum-spl-pool-deploy/stake-pool/program/src/instruction.rs#L53 public final class StakePoolProgram { - private enum Instructions implements Discriminator { - /// Initializes a new StakePool. - /// - /// 0. `[w]` New StakePool to create. - /// 1. `[s]` Manager - /// 2. `[]` Staker - /// 3. `[]` Stake pool withdraw authority - /// 4. `[w]` Uninitialized validator stake list storage account - /// 5. `[]` Reserve stake account must be initialized, have zero balance, - /// and staker / withdrawer authority set to pool withdraw authority. - /// 6. `[]` Pool token mint. Must have zero supply, owned by withdraw - /// authority. - /// 7. `[]` Pool account to deposit the generated fee for manager. - /// 8. `[]` Token program id - /// 9. `[]` (Optional) Deposit authority that must sign all deposits. - /// Defaults to the program address generated using - /// `find_deposit_authority_program_address`, making deposits - /// permissionless. + // Initializes a new StakePool. + // + // 0. '[w]' New StakePool to create. + // 1. '[s]' Manager + // 2. '[]' Staker + // 3. '[]' Stake pool withdraw authority + // 4. '[w]' Uninitialized validator stake list storage account + // 5. '[]' Reserve stake account must be initialized, have zero balance, + // and staker / withdrawer authority set to pool withdraw authority. + // 6. '[]' Pool token mint. Must have zero supply, owned by withdraw + // authority. + // 7. '[]' Pool account to deposit the generated fee for manager. + // 8. '[]' Token program id + // 9. '[]' (Optional) Deposit authority that must sign all deposits. + // Defaults to the program address generated using + // 'find_deposit_authority_program_address', making deposits + // permissionless. Initialize { - /// Fee assessed as percentage of perceived rewards + // Fee assessed as percentage of perceived rewards // fee: Fee, -// /// Fee charged per withdrawal as percentage of withdrawal +// // Fee charged per withdrawal as percentage of withdrawal // withdrawal_fee: Fee, -// /// Fee charged per deposit as percentage of deposit +// // Fee charged per deposit as percentage of deposit // deposit_fee: Fee, -// /// Percentage [0-100] of deposit_fee that goes to referrer +// // Percentage [0-100] of deposit_fee that goes to referrer // referral_fee: u8, -// /// Maximum expected number of validators +// // Maximum expected number of validators // max_validators: u32, }, - /// (Staker only) Adds stake account delegated to validator to the pool's - /// list of managed validators. - /// - /// The stake account will have the rent-exempt amount plus - /// `max( - /// crate::MINIMUM_ACTIVE_STAKE, - /// solana_program::stake::tools::get_minimum_delegation() - /// )`. - /// It is funded from the stake pool reserve. - /// - /// 0. `[w]` Stake pool - /// 1. `[s]` Staker - /// 2. `[w]` Reserve stake account - /// 3. `[]` Stake pool withdraw authority - /// 4. `[w]` Validator stake list storage account - /// 5. `[w]` Stake account to add to the pool - /// 6. `[]` Validator this stake account will be delegated to - /// 7. `[]` Rent sysvar - /// 8. `[]` Clock sysvar - /// 9. '[]' Stake history sysvar - /// 10. '[]' Stake config sysvar - /// 11. `[]` System program - /// 12. `[]` Stake program - /// - /// userdata: optional non-zero u32 seed used for generating the validator - /// stake address + // (Staker only) Adds stake account delegated to validator to the pool's + // list of managed validators. + // + // The stake account will have the rent-exempt amount plus + // 'max( + // crate::MINIMUM_ACTIVE_STAKE, + // solana_program::stake::tools::get_minimum_delegation() + // )'. + // It is funded from the stake pool reserve. + // + // 0. '[w]' Stake pool + // 1. '[s]' Staker + // 2. '[w]' Reserve stake account + // 3. '[]' Stake pool withdraw authority + // 4. '[w]' Validator stake list storage account + // 5. '[w]' Stake account to add to the pool + // 6. '[]' Validator this stake account will be delegated to + // 7. '[]' Rent sysvar + // 8. '[]' Clock sysvar + // 9. '[]' Stake history sysvar + // 10. '[]' Stake config sysvar + // 11. '[]' System program + // 12. '[]' Stake program + // + // userdata: optional non-zero u32 seed used for generating the validator + // stake address AddValidatorToPool( // u32 ), - /// (Staker only) Removes validator from the pool, deactivating its stake - /// - /// Only succeeds if the validator stake account has the minimum of - /// `max(crate::MINIMUM_ACTIVE_STAKE, - /// solana_program::stake::tools::get_minimum_delegation())`. plus the - /// rent-exempt amount. - /// - /// 0. `[w]` Stake pool - /// 1. `[s]` Staker - /// 2. `[]` Stake pool withdraw authority - /// 3. `[w]` Validator stake list storage account - /// 4. `[w]` Stake account to remove from the pool - /// 5. `[w]` Transient stake account, to deactivate if necessary - /// 6. `[]` Sysvar clock - /// 7. `[]` Stake program id, + // (Staker only) Removes validator from the pool, deactivating its stake + // + // Only succeeds if the validator stake account has the minimum of + // 'max(crate::MINIMUM_ACTIVE_STAKE, + // solana_program::stake::tools::get_minimum_delegation())'. plus the + // rent-exempt amount. + // + // 0. '[w]' Stake pool + // 1. '[s]' Staker + // 2. '[]' Stake pool withdraw authority + // 3. '[w]' Validator stake list storage account + // 4. '[w]' Stake account to remove from the pool + // 5. '[w]' Transient stake account, to deactivate if necessary + // 6. '[]' Sysvar clock + // 7. '[]' Stake program id, RemoveValidatorFromPool, - /// NOTE: This instruction has been deprecated since version 0.7.0. Please - /// use `DecreaseValidatorStakeWithReserve` instead. - /// - /// (Staker only) Decrease active stake on a validator, eventually moving it - /// to the reserve - /// - /// Internally, this instruction splits a validator stake account into its - /// corresponding transient stake account and deactivates it. - /// - /// 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. The amount of lamports to move must be at least rent-exemption - /// plus `max(crate::MINIMUM_ACTIVE_STAKE, - /// solana_program::stake::tools::get_minimum_delegation())`. - /// - /// 0. `[]` Stake pool - /// 1. `[s]` Stake pool staker - /// 2. `[]` Stake pool withdraw authority - /// 3. `[w]` Validator list - /// 4. `[w]` Canonical stake account to split from - /// 5. `[w]` Transient stake account to receive split - /// 6. `[]` Clock sysvar - /// 7. `[]` Rent sysvar - /// 8. `[]` System program - /// 9. `[]` Stake program + // NOTE: This instruction has been deprecated since version 0.7.0. Please + // use 'DecreaseValidatorStakeWithReserve' instead. + // + // (Staker only) Decrease active stake on a validator, eventually moving it + // to the reserve + // + // Internally, this instruction splits a validator stake account into its + // corresponding transient stake account and deactivates it. + // + // 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. The amount of lamports to move must be at least rent-exemption + // plus 'max(crate::MINIMUM_ACTIVE_STAKE, + // solana_program::stake::tools::get_minimum_delegation())'. + // + // 0. '[]' Stake pool + // 1. '[s]' Stake pool staker + // 2. '[]' Stake pool withdraw authority + // 3. '[w]' Validator list + // 4. '[w]' Canonical stake account to split from + // 5. '[w]' Transient stake account to receive split + // 6. '[]' Clock sysvar + // 7. '[]' Rent sysvar + // 8. '[]' System program + // 9. '[]' Stake program DecreaseValidatorStake { - /// amount of lamports to split into the transient stake account + // amount of lamports to split into the transient stake account // lamports: u64, -// /// seed used to create transient stake account +// // seed used to create transient stake account // transient_stake_seed: u64, }, - /// (Staker only) Increase stake on a validator from the reserve account - /// - /// Internally, this instruction splits reserve stake into a transient stake - /// account and delegate to the appropriate validator. - /// `UpdateValidatorListBalance` will do the work of merging once it's - /// ready. - /// - /// This instruction only succeeds if the transient stake account does not - /// exist. The minimum amount to move is rent-exemption plus - /// `max(crate::MINIMUM_ACTIVE_STAKE, - /// solana_program::stake::tools::get_minimum_delegation())`. - /// - /// 0. `[]` Stake pool - /// 1. `[s]` Stake pool staker - /// 2. `[]` Stake pool withdraw authority - /// 3. `[w]` Validator list - /// 4. `[w]` Stake pool reserve stake - /// 5. `[w]` Transient stake account - /// 6. `[]` Validator stake account - /// 7. `[]` Validator vote account to delegate to - /// 8. '[]' Clock sysvar - /// 9. '[]' Rent sysvar - /// 10. `[]` Stake History sysvar - /// 11. `[]` Stake Config sysvar - /// 12. `[]` System program - /// 13. `[]` Stake program - /// userdata: amount of lamports to increase on the given validator. - /// The actual amount split into the transient stake account is: - /// `lamports + stake_rent_exemption` - /// The rent-exemption of the stake account is withdrawn back to the - /// reserve after it is merged. + // (Staker only) Increase stake on a validator from the reserve account + // + // Internally, this instruction splits reserve stake into a transient stake + // account and delegate to the appropriate validator. + // 'UpdateValidatorListBalance' will do the work of merging once it's + // ready. + // + // This instruction only succeeds if the transient stake account does not + // exist. The minimum amount to move is rent-exemption plus + // 'max(crate::MINIMUM_ACTIVE_STAKE, + // solana_program::stake::tools::get_minimum_delegation())'. + // + // 0. '[]' Stake pool + // 1. '[s]' Stake pool staker + // 2. '[]' Stake pool withdraw authority + // 3. '[w]' Validator list + // 4. '[w]' Stake pool reserve stake + // 5. '[w]' Transient stake account + // 6. '[]' Validator stake account + // 7. '[]' Validator vote account to delegate to + // 8. '[]' Clock sysvar + // 9. '[]' Rent sysvar + // 10. '[]' Stake History sysvar + // 11. '[]' Stake Config sysvar + // 12. '[]' System program + // 13. '[]' Stake program + // userdata: amount of lamports to increase on the given validator. + // The actual amount split into the transient stake account is: + // 'lamports + stake_rent_exemption' + // The rent-exemption of the stake account is withdrawn back to the + // reserve after it is merged. IncreaseValidatorStake { - /// amount of lamports to increase on the given validator + // amount of lamports to increase on the given validator // lamports: u64, -// /// seed used to create transient stake account +// // seed used to create transient stake account // transient_stake_seed: u64, }, - /// (Staker only) Set the preferred deposit or withdraw stake account for - /// the stake pool - /// - /// In order to avoid users abusing the stake pool as a free conversion - /// between SOL staked on different validators, the staker can force all - /// deposits and/or withdraws to go to one chosen account, or unset that - /// account. - /// - /// 0. `[w]` Stake pool - /// 1. `[s]` Stake pool staker - /// 2. `[]` Validator list - /// - /// Fails if the validator is not part of the stake pool. + // (Staker only) Set the preferred deposit or withdraw stake account for + // the stake pool + // + // In order to avoid users abusing the stake pool as a free conversion + // between SOL staked on different validators, the staker can force all + // deposits and/or withdraws to go to one chosen account, or unset that + // account. + // + // 0. '[w]' Stake pool + // 1. '[s]' Stake pool staker + // 2. '[]' Validator list + // + // Fails if the validator is not part of the stake pool. SetPreferredValidator { - /// Affected operation (deposit or withdraw) + // Affected operation (deposit or withdraw) // validator_type: PreferredValidatorType, -// /// Validator vote account that deposits or withdraws must go through, -// /// unset with None +// // Validator vote account that deposits or withdraws must go through, +// // unset with None // validator_vote_address: Option, }, - /// 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. - /// - /// 0. `[]` Stake pool - /// 1. `[]` Stake pool withdraw authority - /// 2. `[w]` Validator stake list storage account - /// 3. `[w]` Reserve stake account - /// 4. `[]` Sysvar clock - /// 5. `[]` Sysvar stake history - /// 6. `[]` Stake program - /// 7. ..7+2N ` [] N pairs of validator and transient stake accounts + // 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. + // + // 0. '[]' Stake pool + // 1. '[]' Stake pool withdraw authority + // 2. '[w]' Validator stake list storage account + // 3. '[w]' Reserve stake account + // 4. '[]' Sysvar clock + // 5. '[]' Sysvar stake history + // 6. '[]' Stake program + // 7. ..7+2N ' [] N pairs of validator and transient stake accounts UpdateValidatorListBalance { - /// Index to start updating on the validator list + // Index to start updating on the validator list // start_index: u32, -// /// If true, don't try merging transient stake accounts into the reserve -// /// or validator stake account. Useful for testing or if a -// /// particular stake account is in a bad state, but we still -// /// want to update +// // If true, don't try merging transient stake accounts into the reserve +// // or validator stake account. Useful for testing or if a +// // particular stake account is in a bad state, but we still +// // want to update // no_merge: bool, }, - /// Updates total pool balance based on balances in the reserve and - /// validator list - /// - /// 0. `[w]` Stake pool - /// 1. `[]` Stake pool withdraw authority - /// 2. `[w]` Validator stake list storage account - /// 3. `[]` Reserve stake account - /// 4. `[w]` Account to receive pool fee tokens - /// 5. `[w]` Pool mint account - /// 6. `[]` Pool token program + // Updates total pool balance based on balances in the reserve and + // validator list + // + // 0. '[w]' Stake pool + // 1. '[]' Stake pool withdraw authority + // 2. '[w]' Validator stake list storage account + // 3. '[]' Reserve stake account + // 4. '[w]' Account to receive pool fee tokens + // 5. '[w]' Pool mint account + // 6. '[]' Pool token program UpdateStakePoolBalance, - /// Cleans up validator stake account entries marked as `ReadyForRemoval` - /// - /// 0. `[]` Stake pool - /// 1. `[w]` Validator stake list storage account + // Cleans up validator stake account entries marked as 'ReadyForRemoval' + // + // 0. '[]' Stake pool + // 1. '[w]' Validator stake list storage account CleanupRemovedValidatorEntries, - /// Deposit some stake into the pool. The output is a "pool" token - /// representing ownership into the pool. Inputs are converted to the - /// current ratio. - /// - /// 0. `[w]` Stake pool - /// 1. `[w]` Validator stake list storage account - /// 2. `[s]/[]` Stake pool deposit authority - /// 3. `[]` Stake pool withdraw authority - /// 4. `[w]` Stake account to join the pool (withdraw authority for the - /// stake account should be first set to the stake pool deposit - /// authority) - /// 5. `[w]` Validator stake account for the stake account to be merged - /// with - /// 6. `[w]` Reserve stake account, to withdraw rent exempt reserve - /// 7. `[w]` User account to receive pool tokens - /// 8. `[w]` Account to receive pool fee tokens - /// 9. `[w]` Account to receive a portion of pool fee tokens as referral - /// fees - /// 10. `[w]` Pool token mint account - /// 11. '[]' Sysvar clock account - /// 12. '[]' Sysvar stake history account - /// 13. `[]` Pool token program id, - /// 14. `[]` Stake program id, + // Deposit some stake into the pool. The output is a "pool" token + // representing ownership into the pool. Inputs are converted to the + // current ratio. + // + // 0. '[w]' Stake pool + // 1. '[w]' Validator stake list storage account + // 2. '[s]/[]' Stake pool deposit authority + // 3. '[]' Stake pool withdraw authority + // 4. '[w]' Stake account to join the pool (withdraw authority for the + // stake account should be first set to the stake pool deposit + // authority) + // 5. '[w]' Validator stake account for the stake account to be merged + // with + // 6. '[w]' Reserve stake account, to withdraw rent exempt reserve + // 7. '[w]' User account to receive pool tokens + // 8. '[w]' Account to receive pool fee tokens + // 9. '[w]' Account to receive a portion of pool fee tokens as referral + // fees + // 10. '[w]' Pool token mint account + // 11. '[]' Sysvar clock account + // 12. '[]' Sysvar stake history account + // 13. '[]' Pool token program id, + // 14. '[]' Stake program id, DepositStake, - /// Withdraw the token from the pool at the current ratio. - /// - /// Succeeds if the stake account has enough SOL to cover the desired - /// amount of pool tokens, and if the withdrawal keeps the total - /// staked amount above the minimum of rent-exempt amount + `max( - /// crate::MINIMUM_ACTIVE_STAKE, - /// solana_program::stake::tools::get_minimum_delegation() - /// )`. - /// - /// When allowing withdrawals, the order of priority goes: - /// - /// * preferred withdraw validator stake account (if set) - /// * validator stake accounts - /// * transient stake accounts - /// * reserve stake account OR totally remove validator stake accounts - /// - /// A user can freely withdraw from a validator stake account, and if they - /// are all at the minimum, then they can withdraw from transient stake - /// accounts, and if they are all at minimum, then they can withdraw from - /// the reserve or remove any validator from the pool. - /// - /// 0. `[w]` Stake pool - /// 1. `[w]` Validator stake list storage account - /// 2. `[]` Stake pool withdraw authority - /// 3. `[w]` Validator or reserve stake account to split - /// 4. `[w]` Unitialized stake account to receive withdrawal - /// 5. `[]` User account to set as a new withdraw authority - /// 6. `[s]` User transfer authority, for pool token account - /// 7. `[w]` User account with pool tokens to burn from - /// 8. `[w]` Account to receive pool fee tokens - /// 9. `[w]` Pool token mint account - /// 10. `[]` Sysvar clock account (required) - /// 11. `[]` Pool token program id - /// 12. `[]` Stake program id, - /// userdata: amount of pool tokens to withdraw + // Withdraw the token from the pool at the current ratio. + // + // Succeeds if the stake account has enough SOL to cover the desired + // amount of pool tokens, and if the withdrawal keeps the total + // staked amount above the minimum of rent-exempt amount + 'max( + // crate::MINIMUM_ACTIVE_STAKE, + // solana_program::stake::tools::get_minimum_delegation() + // )'. + // + // When allowing withdrawals, the order of priority goes: + // + // * preferred withdraw validator stake account (if set) + // * validator stake accounts + // * transient stake accounts + // * reserve stake account OR totally remove validator stake accounts + // + // A user can freely withdraw from a validator stake account, and if they + // are all at the minimum, then they can withdraw from transient stake + // accounts, and if they are all at minimum, then they can withdraw from + // the reserve or remove any validator from the pool. + // + // 0. '[w]' Stake pool + // 1. '[w]' Validator stake list storage account + // 2. '[]' Stake pool withdraw authority + // 3. '[w]' Validator or reserve stake account to split + // 4. '[w]' Unitialized stake account to receive withdrawal + // 5. '[]' User account to set as a new withdraw authority + // 6. '[s]' User transfer authority, for pool token account + // 7. '[w]' User account with pool tokens to burn from + // 8. '[w]' Account to receive pool fee tokens + // 9. '[w]' Pool token mint account + // 10. '[]' Sysvar clock account (required) + // 11. '[]' Pool token program id + // 12. '[]' Stake program id, + // userdata: amount of pool tokens to withdraw WithdrawStake( // u64 ), - /// (Manager only) Update manager - /// - /// 0. `[w]` StakePool - /// 1. `[s]` Manager - /// 2. `[s]` New manager - /// 3. `[]` New manager fee account + // (Manager only) Update manager + // + // 0. '[w]' StakePool + // 1. '[s]' Manager + // 2. '[s]' New manager + // 3. '[]' New manager fee account SetManager, - /// (Manager only) Update fee - /// - /// 0. `[w]` StakePool - /// 1. `[s]` Manager + // (Manager only) Update fee + // + // 0. '[w]' StakePool + // 1. '[s]' Manager SetFee { - /// Type of fee to update and value to update it to + // Type of fee to update and value to update it to // fee: FeeType, }, - /// (Manager or staker only) Update staker - /// - /// 0. `[w]` StakePool - /// 1. `[s]` Manager or current staker - /// 2. '[]` New staker pubkey + // (Manager or staker only) Update staker + // + // 0. '[w]' StakePool + // 1. '[s]' Manager or current staker + // 2. '[]' New staker pubkey SetStaker, - /// Deposit SOL directly into the pool's reserve account. The output is a - /// "pool" token representing ownership into the pool. Inputs are - /// converted to the current ratio. - /// - /// 0. `[w]` Stake pool - /// 1. `[]` Stake pool withdraw authority - /// 2. `[w]` Reserve stake account, to deposit SOL - /// 3. `[s]` Account providing the lamports to be deposited into the pool - /// 4. `[w]` User account to receive pool tokens - /// 5. `[w]` Account to receive fee tokens - /// 6. `[w]` Account to receive a portion of fee as referral fees - /// 7. `[w]` Pool token mint account - /// 8. `[]` System program account - /// 9. `[]` Token program id - /// 10. `[s]` (Optional) Stake pool sol deposit authority. + // Deposit SOL directly into the pool's reserve account. The output is a + // "pool" token representing ownership into the pool. Inputs are + // converted to the current ratio. + // + // 0. '[w]' Stake pool + // 1. '[]' Stake pool withdraw authority + // 2. '[w]' Reserve stake account, to deposit SOL + // 3. '[s]' Account providing the lamports to be deposited into the pool + // 4. '[w]' User account to receive pool tokens + // 5. '[w]' Account to receive fee tokens + // 6. '[w]' Account to receive a portion of fee as referral fees + // 7. '[w]' Pool token mint account + // 8. '[]' System program account + // 9. '[]' Token program id + // 10. '[s]' (Optional) Stake pool sol deposit authority. DepositSol( // u64 ), - /// (Manager only) Update SOL deposit, stake deposit, or SOL withdrawal - /// authority. - /// - /// 0. `[w]` StakePool - /// 1. `[s]` Manager - /// 2. '[]` New authority pubkey or none + // (Manager only) Update SOL deposit, stake deposit, or SOL withdrawal + // authority. + // + // 0. '[w]' StakePool + // 1. '[s]' Manager + // 2. '[]' New authority pubkey or none SetFundingAuthority( // FundingType ), - /// Withdraw SOL directly from the pool's reserve account. Fails if the - /// reserve does not have enough SOL. - /// - /// 0. `[w]` Stake pool - /// 1. `[]` Stake pool withdraw authority - /// 2. `[s]` User transfer authority, for pool token account - /// 3. `[w]` User account to burn pool tokens - /// 4. `[w]` Reserve stake account, to withdraw SOL - /// 5. `[w]` Account receiving the lamports from the reserve, must be a - /// system account - /// 6. `[w]` Account to receive pool fee tokens - /// 7. `[w]` Pool token mint account - /// 8. '[]' Clock sysvar - /// 9. '[]' Stake history sysvar - /// 10. `[]` Stake program account - /// 11. `[]` Token program id - /// 12. `[s]` (Optional) Stake pool sol withdraw authority + // Withdraw SOL directly from the pool's reserve account. Fails if the + // reserve does not have enough SOL. + // + // 0. '[w]' Stake pool + // 1. '[]' Stake pool withdraw authority + // 2. '[s]' User transfer authority, for pool token account + // 3. '[w]' User account to burn pool tokens + // 4. '[w]' Reserve stake account, to withdraw SOL + // 5. '[w]' Account receiving the lamports from the reserve, must be a + // system account + // 6. '[w]' Account to receive pool fee tokens + // 7. '[w]' Pool token mint account + // 8. '[]' Clock sysvar + // 9. '[]' Stake history sysvar + // 10. '[]' Stake program account + // 11. '[]' Token program id + // 12. '[s]' (Optional) Stake pool sol withdraw authority WithdrawSol( // u64 ), - /// Create token metadata for the stake-pool token in the - /// metaplex-token program - /// 0. `[]` Stake pool - /// 1. `[s]` Manager - /// 2. `[]` Stake pool withdraw authority - /// 3. `[]` Pool token mint account - /// 4. `[s, w]` Payer for creation of token metadata account - /// 5. `[w]` Token metadata account - /// 6. `[]` Metadata program id - /// 7. `[]` System program id + // Create token metadata for the stake-pool token in the + // metaplex-token program + // 0. '[]' Stake pool + // 1. '[s]' Manager + // 2. '[]' Stake pool withdraw authority + // 3. '[]' Pool token mint account + // 4. '[s, w]' Payer for creation of token metadata account + // 5. '[w]' Token metadata account + // 6. '[]' Metadata program id + // 7. '[]' System program id CreateTokenMetadata { - /// Token name + // Token name // name: String, -// /// Token symbol e.g. stkSOL +// // Token symbol e.g. stkSOL // symbol: String, -// /// URI of the uploaded metadata of the spl-token +// // URI of the uploaded metadata of the spl-token // uri: String, }, - /// Update token metadata for the stake-pool token in the - /// metaplex-token program - /// - /// 0. `[]` Stake pool - /// 1. `[s]` Manager - /// 2. `[]` Stake pool withdraw authority - /// 3. `[w]` Token metadata account - /// 4. `[]` Metadata program id + // Update token metadata for the stake-pool token in the + // metaplex-token program + // + // 0. '[]' Stake pool + // 1. '[s]' Manager + // 2. '[]' Stake pool withdraw authority + // 3. '[w]' Token metadata account + // 4. '[]' Metadata program id UpdateTokenMetadata { - /// Token name + // Token name // name: String, -// /// Token symbol e.g. stkSOL +// // Token symbol e.g. stkSOL // symbol: String, -// /// URI of the uploaded metadata of the spl-token +// // URI of the uploaded metadata of the spl-token // uri: String, }, - /// (Staker only) Increase stake on a validator again in an epoch. - /// - /// Works regardless if the transient stake account exists. - /// - /// Internally, this instruction splits reserve stake into an ephemeral - /// stake account, activates it, then merges or splits it into the - /// transient stake account delegated to the appropriate validator. - /// `UpdateValidatorListBalance` will do the work of merging once it's - /// ready. - /// - /// The minimum amount to move is rent-exemption plus - /// `max(crate::MINIMUM_ACTIVE_STAKE, - /// solana_program::stake::tools::get_minimum_delegation())`. - /// - /// 0. `[]` Stake pool - /// 1. `[s]` Stake pool staker - /// 2. `[]` Stake pool withdraw authority - /// 3. `[w]` Validator list - /// 4. `[w]` Stake pool reserve stake - /// 5. `[w]` Uninitialized ephemeral stake account to receive stake - /// 6. `[w]` Transient stake account - /// 7. `[]` Validator stake account - /// 8. `[]` Validator vote account to delegate to - /// 9. '[]' Clock sysvar - /// 10. `[]` Stake History sysvar - /// 11. `[]` Stake Config sysvar - /// 12. `[]` System program - /// 13. `[]` Stake program - /// userdata: amount of lamports to increase on the given validator. - /// The actual amount split into the transient stake account is: - /// `lamports + stake_rent_exemption` - /// The rent-exemption of the stake account is withdrawn back to the - /// reserve after it is merged. + // (Staker only) Increase stake on a validator again in an epoch. + // + // Works regardless if the transient stake account exists. + // + // Internally, this instruction splits reserve stake into an ephemeral + // stake account, activates it, then merges or splits it into the + // transient stake account delegated to the appropriate validator. + // 'UpdateValidatorListBalance' will do the work of merging once it's + // ready. + // + // The minimum amount to move is rent-exemption plus + // 'max(crate::MINIMUM_ACTIVE_STAKE, + // solana_program::stake::tools::get_minimum_delegation())'. + // + // 0. '[]' Stake pool + // 1. '[s]' Stake pool staker + // 2. '[]' Stake pool withdraw authority + // 3. '[w]' Validator list + // 4. '[w]' Stake pool reserve stake + // 5. '[w]' Uninitialized ephemeral stake account to receive stake + // 6. '[w]' Transient stake account + // 7. '[]' Validator stake account + // 8. '[]' Validator vote account to delegate to + // 9. '[]' Clock sysvar + // 10. '[]' Stake History sysvar + // 11. '[]' Stake Config sysvar + // 12. '[]' System program + // 13. '[]' Stake program + // userdata: amount of lamports to increase on the given validator. + // The actual amount split into the transient stake account is: + // 'lamports + stake_rent_exemption' + // The rent-exemption of the stake account is withdrawn back to the + // reserve after it is merged. IncreaseAdditionalValidatorStake { - /// amount of lamports to increase on the given validator + // amount of lamports to increase on the given validator // lamports: u64, -// /// seed used to create transient stake account +// // seed used to create transient stake account // transient_stake_seed: u64, -// /// seed used to create ephemeral account. +// // seed used to create ephemeral account. // ephemeral_stake_seed: u64, }, - /// (Staker only) Decrease active stake again from a validator, eventually - /// moving it to the reserve - /// - /// Works regardless if the transient stake account already exists. - /// - /// Internally, this instruction: - /// * withdraws rent-exempt reserve lamports from the reserve into the - /// ephemeral stake - /// * splits a validator stake account into an ephemeral stake account - /// * deactivates the ephemeral account - /// * merges or splits the ephemeral account into the transient stake - /// account delegated to the appropriate validator - /// - /// The amount of lamports to move must be at least - /// `max(crate::MINIMUM_ACTIVE_STAKE, - /// solana_program::stake::tools::get_minimum_delegation())`. - /// - /// 0. `[]` Stake pool - /// 1. `[s]` Stake pool staker - /// 2. `[]` Stake pool withdraw authority - /// 3. `[w]` Validator list - /// 4. `[w]` Reserve stake account, to fund rent exempt reserve - /// 5. `[w]` Canonical stake account to split from - /// 6. `[w]` Uninitialized ephemeral stake account to receive stake - /// 7. `[w]` Transient stake account - /// 8. `[]` Clock sysvar - /// 9. '[]' Stake history sysvar - /// 10. `[]` System program - /// 11. `[]` Stake program + // (Staker only) Decrease active stake again from a validator, eventually + // moving it to the reserve + // + // Works regardless if the transient stake account already exists. + // + // Internally, this instruction: + // * withdraws rent-exempt reserve lamports from the reserve into the + // ephemeral stake + // * splits a validator stake account into an ephemeral stake account + // * deactivates the ephemeral account + // * merges or splits the ephemeral account into the transient stake + // account delegated to the appropriate validator + // + // The amount of lamports to move must be at least + // 'max(crate::MINIMUM_ACTIVE_STAKE, + // solana_program::stake::tools::get_minimum_delegation())'. + // + // 0. '[]' Stake pool + // 1. '[s]' Stake pool staker + // 2. '[]' Stake pool withdraw authority + // 3. '[w]' Validator list + // 4. '[w]' Reserve stake account, to fund rent exempt reserve + // 5. '[w]' Canonical stake account to split from + // 6. '[w]' Uninitialized ephemeral stake account to receive stake + // 7. '[w]' Transient stake account + // 8. '[]' Clock sysvar + // 9. '[]' Stake history sysvar + // 10. '[]' System program + // 11. '[]' Stake program DecreaseAdditionalValidatorStake { - /// amount of lamports to split into the transient stake account + // amount of lamports to split into the transient stake account // lamports: u64, -// /// seed used to create transient stake account +// // seed used to create transient stake account // transient_stake_seed: u64, -// /// seed used to create ephemeral account. +// // seed used to create ephemeral account. // ephemeral_stake_seed: u64, }, - /// (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. The amount of lamports to move must be at least rent-exemption - /// plus `max(crate::MINIMUM_ACTIVE_STAKE, - /// solana_program::stake::tools::get_minimum_delegation())`. - /// - /// 0. `[]` Stake pool - /// 1. `[s]` Stake pool staker - /// 2. `[]` Stake pool withdraw authority - /// 3. `[w]` Validator list - /// 4. `[w]` Reserve stake account, to fund rent exempt reserve - /// 5. `[w]` Canonical stake account to split from - /// 6. `[w]` Transient stake account to receive split - /// 7. `[]` Clock sysvar - /// 8. '[]' Stake history sysvar - /// 9. `[]` System program - /// 10. `[]` Stake program + // (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. The amount of lamports to move must be at least rent-exemption + // plus 'max(crate::MINIMUM_ACTIVE_STAKE, + // solana_program::stake::tools::get_minimum_delegation())'. + // + // 0. '[]' Stake pool + // 1. '[s]' Stake pool staker + // 2. '[]' Stake pool withdraw authority + // 3. '[w]' Validator list + // 4. '[w]' Reserve stake account, to fund rent exempt reserve + // 5. '[w]' Canonical stake account to split from + // 6. '[w]' Transient stake account to receive split + // 7. '[]' Clock sysvar + // 8. '[]' Stake history sysvar + // 9. '[]' System program + // 10. '[]' Stake program DecreaseValidatorStakeWithReserve { - /// amount of lamports to split into the transient stake account + // amount of lamports to split into the transient stake account // lamports: u64, -// /// seed used to create transient stake account +// // seed used to create transient stake account // transient_stake_seed: u64, }, - /// (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. - /// - /// The amount that arrives at the destination validator in the end is - /// `redelegate_lamports - rent_exemption` if the destination transient - /// account does *not* exist, and `redelegate_lamports` if the destination - /// transient account already exists. The `rent_exemption` is not activated - /// when creating the destination transient stake account, but if it already - /// exists, then the full amount is delegated. - /// - /// 0. `[]` Stake pool - /// 1. `[s]` Stake pool staker - /// 2. `[]` Stake pool withdraw authority - /// 3. `[w]` Validator list - /// 4. `[w]` Reserve stake account, to withdraw rent exempt reserve - /// 5. `[w]` Source canonical stake account to split from - /// 6. `[w]` Source transient stake account to receive split and be - /// redelegated - /// 7. `[w]` Uninitialized ephemeral stake account to receive redelegation - /// 8. `[w]` Destination transient stake account to receive ephemeral stake - /// by merge - /// 9. `[]` Destination stake account to receive transient stake after - /// activation - /// 10. `[]` Destination validator vote account - /// 11. `[]` Clock sysvar - /// 12. `[]` Stake History sysvar - /// 13. `[]` Stake Config sysvar - /// 14. `[]` System program - /// 15. `[]` Stake program + // (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. + // + // The amount that arrives at the destination validator in the end is + // 'redelegate_lamports - rent_exemption' if the destination transient + // account does *not* exist, and 'redelegate_lamports' if the destination + // transient account already exists. The 'rent_exemption' is not activated + // when creating the destination transient stake account, but if it already + // exists, then the full amount is delegated. + // + // 0. '[]' Stake pool + // 1. '[s]' Stake pool staker + // 2. '[]' Stake pool withdraw authority + // 3. '[w]' Validator list + // 4. '[w]' Reserve stake account, to withdraw rent exempt reserve + // 5. '[w]' Source canonical stake account to split from + // 6. '[w]' Source transient stake account to receive split and be + // redelegated + // 7. '[w]' Uninitialized ephemeral stake account to receive redelegation + // 8. '[w]' Destination transient stake account to receive ephemeral stake + // by merge + // 9. '[]' Destination stake account to receive transient stake after + // activation + // 10. '[]' Destination validator vote account + // 11. '[]' Clock sysvar + // 12. '[]' Stake History sysvar + // 13. '[]' Stake Config sysvar + // 14. '[]' System program + // 15. '[]' Stake program Redelegate { - /// Amount of lamports to redelegate + // Amount of lamports to redelegate // #[allow(dead_code)] // but it's not // lamports: u64, -// /// Seed used to create source transient stake account +// // Seed used to create source transient stake account // #[allow(dead_code)] // but it's not // source_transient_stake_seed: u64, -// /// Seed used to create destination ephemeral account. +// // Seed used to create destination ephemeral account. // #[allow(dead_code)] // but it's not // ephemeral_stake_seed: u64, -// /// Seed used to create destination transient stake account. If there is -// /// already transient stake, this must match the current seed, otherwise -// /// it can be anything +// // Seed used to create destination transient stake account. If there is +// // already transient stake, this must match the current seed, otherwise +// // it can be anything // #[allow(dead_code)] // but it's not // destination_transient_stake_seed: u64, }, - /// Deposit some stake into the pool, with a specified slippage - /// constraint. The output is a "pool" token representing ownership - /// into the pool. Inputs are converted at the current ratio. - /// - /// 0. `[w]` Stake pool - /// 1. `[w]` Validator stake list storage account - /// 2. `[s]/[]` Stake pool deposit authority - /// 3. `[]` Stake pool withdraw authority - /// 4. `[w]` Stake account to join the pool (withdraw authority for the - /// stake account should be first set to the stake pool deposit - /// authority) - /// 5. `[w]` Validator stake account for the stake account to be merged - /// with - /// 6. `[w]` Reserve stake account, to withdraw rent exempt reserve - /// 7. `[w]` User account to receive pool tokens - /// 8. `[w]` Account to receive pool fee tokens - /// 9. `[w]` Account to receive a portion of pool fee tokens as referral - /// fees - /// 10. `[w]` Pool token mint account - /// 11. '[]' Sysvar clock account - /// 12. '[]' Sysvar stake history account - /// 13. `[]` Pool token program id, - /// 14. `[]` Stake program id, + // Deposit some stake into the pool, with a specified slippage + // constraint. The output is a "pool" token representing ownership + // into the pool. Inputs are converted at the current ratio. + // + // 0. '[w]' Stake pool + // 1. '[w]' Validator stake list storage account + // 2. '[s]/[]' Stake pool deposit authority + // 3. '[]' Stake pool withdraw authority + // 4. '[w]' Stake account to join the pool (withdraw authority for the + // stake account should be first set to the stake pool deposit + // authority) + // 5. '[w]' Validator stake account for the stake account to be merged + // with + // 6. '[w]' Reserve stake account, to withdraw rent exempt reserve + // 7. '[w]' User account to receive pool tokens + // 8. '[w]' Account to receive pool fee tokens + // 9. '[w]' Account to receive a portion of pool fee tokens as referral + // fees + // 10. '[w]' Pool token mint account + // 11. '[]' Sysvar clock account + // 12. '[]' Sysvar stake history account + // 13. '[]' Pool token program id, + // 14. '[]' Stake program id, DepositStakeWithSlippage { - /// Minimum amount of pool tokens that must be received + // Minimum amount of pool tokens that must be received // minimum_pool_tokens_out: u64, }, - /// Withdraw the token from the pool at the current ratio, specifying a - /// minimum expected output lamport amount. - /// - /// Succeeds if the stake account has enough SOL to cover the desired - /// amount of pool tokens, and if the withdrawal keeps the total - /// staked amount above the minimum of rent-exempt amount + `max( - /// crate::MINIMUM_ACTIVE_STAKE, - /// solana_program::stake::tools::get_minimum_delegation() - /// )`. - /// - /// 0. `[w]` Stake pool - /// 1. `[w]` Validator stake list storage account - /// 2. `[]` Stake pool withdraw authority - /// 3. `[w]` Validator or reserve stake account to split - /// 4. `[w]` Unitialized stake account to receive withdrawal - /// 5. `[]` User account to set as a new withdraw authority - /// 6. `[s]` User transfer authority, for pool token account - /// 7. `[w]` User account with pool tokens to burn from - /// 8. `[w]` Account to receive pool fee tokens - /// 9. `[w]` Pool token mint account - /// 10. `[]` Sysvar clock account (required) - /// 11. `[]` Pool token program id - /// 12. `[]` Stake program id, - /// userdata: amount of pool tokens to withdraw + // Withdraw the token from the pool at the current ratio, specifying a + // minimum expected output lamport amount. + // + // Succeeds if the stake account has enough SOL to cover the desired + // amount of pool tokens, and if the withdrawal keeps the total + // staked amount above the minimum of rent-exempt amount + 'max( + // crate::MINIMUM_ACTIVE_STAKE, + // solana_program::stake::tools::get_minimum_delegation() + // )'. + // + // 0. '[w]' Stake pool + // 1. '[w]' Validator stake list storage account + // 2. '[]' Stake pool withdraw authority + // 3. '[w]' Validator or reserve stake account to split + // 4. '[w]' Unitialized stake account to receive withdrawal + // 5. '[]' User account to set as a new withdraw authority + // 6. '[s]' User transfer authority, for pool token account + // 7. '[w]' User account with pool tokens to burn from + // 8. '[w]' Account to receive pool fee tokens + // 9. '[w]' Pool token mint account + // 10. '[]' Sysvar clock account (required) + // 11. '[]' Pool token program id + // 12. '[]' Stake program id, + // userdata: amount of pool tokens to withdraw WithdrawStakeWithSlippage { - /// Pool tokens to burn in exchange for lamports + // Pool tokens to burn in exchange for lamports // pool_tokens_in: u64, -// /// Minimum amount of lamports that must be received +// // Minimum amount of lamports that must be received // minimum_lamports_out: u64, }, - /// Deposit SOL directly into the pool's reserve account, with a - /// specified slippage constraint. The output is a "pool" token - /// representing ownership into the pool. Inputs are converted at the - /// current ratio. - /// - /// 0. `[w]` Stake pool - /// 1. `[]` Stake pool withdraw authority - /// 2. `[w]` Reserve stake account, to deposit SOL - /// 3. `[s]` Account providing the lamports to be deposited into the pool - /// 4. `[w]` User account to receive pool tokens - /// 5. `[w]` Account to receive fee tokens - /// 6. `[w]` Account to receive a portion of fee as referral fees - /// 7. `[w]` Pool token mint account - /// 8. `[]` System program account - /// 9. `[]` Token program id - /// 10. `[s]` (Optional) Stake pool sol deposit authority. + // Deposit SOL directly into the pool's reserve account, with a + // specified slippage constraint. The output is a "pool" token + // representing ownership into the pool. Inputs are converted at the + // current ratio. + // + // 0. '[w]' Stake pool + // 1. '[]' Stake pool withdraw authority + // 2. '[w]' Reserve stake account, to deposit SOL + // 3. '[s]' Account providing the lamports to be deposited into the pool + // 4. '[w]' User account to receive pool tokens + // 5. '[w]' Account to receive fee tokens + // 6. '[w]' Account to receive a portion of fee as referral fees + // 7. '[w]' Pool token mint account + // 8. '[]' System program account + // 9. '[]' Token program id + // 10. '[s]' (Optional) Stake pool sol deposit authority. DepositSolWithSlippage { - /// Amount of lamports to deposit into the reserve + // Amount of lamports to deposit into the reserve // lamports_in: u64, -// /// Minimum amount of pool tokens that must be received +// // Minimum amount of pool tokens that must be received // minimum_pool_tokens_out: u64, }, - /// Withdraw SOL directly from the pool's reserve account. Fails if the - /// reserve does not have enough SOL or if the slippage constraint is not - /// met. - /// - /// 0. `[w]` Stake pool - /// 1. `[]` Stake pool withdraw authority - /// 2. `[s]` User transfer authority, for pool token account - /// 3. `[w]` User account to burn pool tokens - /// 4. `[w]` Reserve stake account, to withdraw SOL - /// 5. `[w]` Account receiving the lamports from the reserve, must be a - /// system account - /// 6. `[w]` Account to receive pool fee tokens - /// 7. `[w]` Pool token mint account - /// 8. '[]' Clock sysvar - /// 9. '[]' Stake history sysvar - /// 10. `[]` Stake program account - /// 11. `[]` Token program id - /// 12. `[s]` (Optional) Stake pool sol withdraw authority + // Withdraw SOL directly from the pool's reserve account. Fails if the + // reserve does not have enough SOL or if the slippage constraint is not + // met. + // + // 0. '[w]' Stake pool + // 1. '[]' Stake pool withdraw authority + // 2. '[s]' User transfer authority, for pool token account + // 3. '[w]' User account to burn pool tokens + // 4. '[w]' Reserve stake account, to withdraw SOL + // 5. '[w]' Account receiving the lamports from the reserve, must be a + // system account + // 6. '[w]' Account to receive pool fee tokens + // 7. '[w]' Pool token mint account + // 8. '[]' Clock sysvar + // 9. '[]' Stake history sysvar + // 10. '[]' Stake program account + // 11. '[]' Token program id + // 12. '[s]' (Optional) Stake pool sol withdraw authority WithdrawSolWithSlippage { - /// Pool tokens to burn in exchange for lamports + // Pool tokens to burn in exchange for lamports // pool_tokens_in: u64, -// /// Minimum amount of lamports that must be received +// // Minimum amount of lamports that must be received // minimum_lamports_out: u64, }; diff --git a/src/main/java/software/sava/solana/programs/system/SystemProgram.java b/src/main/java/software/sava/solana/programs/system/SystemProgram.java index 2679eec..2ed82ab 100644 --- a/src/main/java/software/sava/solana/programs/system/SystemProgram.java +++ b/src/main/java/software/sava/solana/programs/system/SystemProgram.java @@ -19,180 +19,180 @@ public final class SystemProgram { private enum Instructions implements Discriminator { - /// Create a new account - /// - /// # Account references - /// 0. `[WRITE, SIGNER]` Funding account - /// 1. `[WRITE, SIGNER]` New account + // Create a new account + // + // # Account references + // 0. '[WRITE, SIGNER]' Funding account + // 1. '[WRITE, SIGNER]' New account CreateAccount { - /// Number of lamports to transfer to the new account + // Number of lamports to transfer to the new account // lamports: u64, -// /// Number of bytes of memory to allocate +// // Number of bytes of memory to allocate // space: u64, -// /// Address of program that will own the new account +// // Address of program that will own the new account // owner: Pubkey, }, - /// Assign account to a program - /// - /// # Account references - /// 0. `[WRITE, SIGNER]` Assigned account public key + // Assign account to a program + // + // # Account references + // 0. '[WRITE, SIGNER]' Assigned account public key Assign { - /// Owner program account + // Owner program account // owner: Pubkey, }, - /// Transfer lamports - /// - /// # Account references - /// 0. `[WRITE, SIGNER]` Funding account - /// 1. `[WRITE]` Recipient account + // Transfer lamports + // + // # Account references + // 0. '[WRITE, SIGNER]' Funding account + // 1. '[WRITE]' Recipient account Transfer { // lamports: u64 }, - /// Create a new account at an address derived from a base pubkey and a seed - /// - /// # Account references - /// 0. `[WRITE, SIGNER]` Funding account - /// 1. `[WRITE]` Created account - /// 2. `[SIGNER]` (optional) Base account; the account matching the base Pubkey below must be - /// provided as a signer, but may be the same as the funding account - /// and provided as account 0 + // Create a new account at an address derived from a base pubkey and a seed + // + // # Account references + // 0. '[WRITE, SIGNER]' Funding account + // 1. '[WRITE]' Created account + // 2. '[SIGNER]' (optional) Base account; the account matching the base Pubkey below must be + // provided as a signer, but may be the same as the funding account + // and provided as account 0 CreateAccountWithSeed { - /// Base public key + // Base public key // base: Pubkey, // -// /// String of ASCII chars, no longer than `Pubkey::MAX_SEED_LEN` +// // String of ASCII chars, no longer than 'Pubkey::MAX_SEED_LEN' // seed: String, // -// /// Number of lamports to transfer to the new account +// // Number of lamports to transfer to the new account // lamports: u64, // -// /// Number of bytes of memory to allocate +// // Number of bytes of memory to allocate // space: u64, // -// /// Owner program account address +// // Owner program account address // owner: Pubkey, }, - /// Consumes a stored nonce, replacing it with a successor - /// - /// # Account references - /// 0. `[WRITE]` Nonce account - /// 1. `[]` RecentBlockhashes sysvar - /// 2. `[SIGNER]` Nonce authority + // Consumes a stored nonce, replacing it with a successor + // + // # Account references + // 0. '[WRITE]' Nonce account + // 1. '[]' RecentBlockhashes sysvar + // 2. '[SIGNER]' Nonce authority AdvanceNonceAccount, - /// Withdraw funds from a nonce account - /// - /// # Account references - /// 0. `[WRITE]` Nonce account - /// 1. `[WRITE]` Recipient account - /// 2. `[]` RecentBlockhashes sysvar - /// 3. `[]` Rent sysvar - /// 4. `[SIGNER]` Nonce authority - /// - /// The `u64` parameter is the lamports to withdraw, which must leave the - /// account balance above the rent exempt reserve or at zero. + // Withdraw funds from a nonce account + // + // # Account references + // 0. '[WRITE]' Nonce account + // 1. '[WRITE]' Recipient account + // 2. '[]' RecentBlockhashes sysvar + // 3. '[]' Rent sysvar + // 4. '[SIGNER]' Nonce authority + // + // The 'u64' parameter is the lamports to withdraw, which must leave the + // account balance above the rent exempt reserve or at zero. WithdrawNonceAccount( // u64 ), - /// Drive state of Uninitialized nonce account to Initialized, setting the nonce value - /// - /// # Account references - /// 0. `[WRITE]` Nonce account - /// 1. `[]` RecentBlockhashes sysvar - /// 2. `[]` Rent sysvar - /// - /// The `Pubkey` parameter specifies the entity authorized to execute nonce - /// instruction on the account - /// - /// No signatures are required to execute this instruction, enabling derived - /// nonce account addresses + // Drive state of Uninitialized nonce account to Initialized, setting the nonce value + // + // # Account references + // 0. '[WRITE]' Nonce account + // 1. '[]' RecentBlockhashes sysvar + // 2. '[]' Rent sysvar + // + // The 'Pubkey' parameter specifies the entity authorized to execute nonce + // instruction on the account + // + // No signatures are required to execute this instruction, enabling derived + // nonce account addresses InitializeNonceAccount( // Pubkey ), - /// Change the entity authorized to execute nonce instructions on the account - /// - /// # Account references - /// 0. `[WRITE]` Nonce account - /// 1. `[SIGNER]` Nonce authority - /// - /// The `Pubkey` parameter identifies the entity to authorize + // Change the entity authorized to execute nonce instructions on the account + // + // # Account references + // 0. '[WRITE]' Nonce account + // 1. '[SIGNER]' Nonce authority + // + // The 'Pubkey' parameter identifies the entity to authorize AuthorizeNonceAccount( // Pubkey ), - /// Allocate space in a (possibly new) account without funding - /// - /// # Account references - /// 0. `[WRITE, SIGNER]` New account + // Allocate space in a (possibly new) account without funding + // + // # Account references + // 0. '[WRITE, SIGNER]' New account Allocate { - /// Number of bytes of memory to allocate + // Number of bytes of memory to allocate // space: u64, }, - /// Allocate space for and assign an account at an address - /// derived from a base public key and a seed - /// - /// # Account references - /// 0. `[WRITE]` Allocated account - /// 1. `[SIGNER]` Base account + // Allocate space for and assign an account at an address + // derived from a base public key and a seed + // + // # Account references + // 0. '[WRITE]' Allocated account + // 1. '[SIGNER]' Base account AllocateWithSeed { - /// Base public key + // Base public key // base: Pubkey, // -// /// String of ASCII chars, no longer than `pubkey::MAX_SEED_LEN` +// // String of ASCII chars, no longer than 'pubkey::MAX_SEED_LEN' // seed: String, // -// /// Number of bytes of memory to allocate +// // Number of bytes of memory to allocate // space: u64, // -// /// Owner program account +// // Owner program account // owner: Pubkey, }, - /// Assign account to a program based on a seed - /// - /// # Account references - /// 0. `[WRITE]` Assigned account - /// 1. `[SIGNER]` Base account + // Assign account to a program based on a seed + // + // # Account references + // 0. '[WRITE]' Assigned account + // 1. '[SIGNER]' Base account AssignWithSeed { - /// Base public key + // Base public key // base: Pubkey, // -// /// String of ASCII chars, no longer than `pubkey::MAX_SEED_LEN` +// // String of ASCII chars, no longer than 'pubkey::MAX_SEED_LEN' // seed: String, // -// /// Owner program account +// // Owner program account // owner: Pubkey, }, - /// Transfer lamports from a derived address - /// - /// # Account references - /// 0. `[WRITE]` Funding account - /// 1. `[SIGNER]` Base for funding account - /// 2. `[WRITE]` Recipient account + // Transfer lamports from a derived address + // + // # Account references + // 0. '[WRITE]' Funding account + // 1. '[SIGNER]' Base for funding account + // 2. '[WRITE]' Recipient account TransferWithSeed { - /// Amount to transfer + // Amount to transfer // lamports: u64, // -// /// Seed to use to derive the funding account address +// // Seed to use to derive the funding account address // from_seed: String, // -// /// Owner to use to derive the funding account address +// // Owner to use to derive the funding account address // from_owner: Pubkey, }, - /// One-time idempotent upgrade of legacy nonce versions in order to bump - /// them out of chain blockhash domain. - /// - /// # Account references - /// 0. `[WRITE]` Nonce account + // One-time idempotent upgrade of legacy nonce versions in order to bump + // them out of chain blockhash domain. + // + // # Account references + // 0. '[WRITE]' Nonce account UpgradeNonceAccount; private final byte[] data; diff --git a/src/main/java/software/sava/solana/programs/token/AssociatedTokenProgram.java b/src/main/java/software/sava/solana/programs/token/AssociatedTokenProgram.java index 87718c6..4e6e163 100644 --- a/src/main/java/software/sava/solana/programs/token/AssociatedTokenProgram.java +++ b/src/main/java/software/sava/solana/programs/token/AssociatedTokenProgram.java @@ -16,46 +16,46 @@ private enum Instructions { // https://github.com/solana-labs/solana-program-library/blob/d0f48a6ba34acb01dd0fde5368e73b406c544837/associated-token-account/program/src/instruction.rs#L15 - /// Creates an associated token account for the given wallet address and - /// token mint Returns an error if the account exists. - /// - /// 0. `[writeable,signer]` Funding account (must be a system account) - /// 1. `[writeable]` Associated token account address to be created - /// 2. `[]` Wallet address for the new associated token account - /// 3. `[]` The token mint for the new associated token account - /// 4. `[]` System program - /// 5. `[]` SPL Token program + // Creates an associated token account for the given wallet address and + // token mint Returns an error if the account exists. + // + // 0. '[writeable,signer]' Funding account (must be a system account) + // 1. '[writeable]' Associated token account address to be created + // 2. '[]' Wallet address for the new associated token account + // 3. '[]' The token mint for the new associated token account + // 4. '[]' System program + // 5. '[]' SPL Token program Create, - /// Creates an associated token account for the given wallet address and - /// token mint, if it doesn't already exist. Returns an error if the - /// account exists, but with a different owner. - /// - /// 0. `[writeable,signer]` Funding account (must be a system account) - /// 1. `[writeable]` Associated token account address to be created - /// 2. `[]` Wallet address for the new associated token account - /// 3. `[]` The token mint for the new associated token account - /// 4. `[]` System program - /// 5. `[]` SPL Token program + // Creates an associated token account for the given wallet address and + // token mint, if it doesn't already exist. Returns an error if the + // account exists, but with a different owner. + // + // 0. '[writeable,signer]' Funding account (must be a system account) + // 1. '[writeable]' Associated token account address to be created + // 2. '[]' Wallet address for the new associated token account + // 3. '[]' The token mint for the new associated token account + // 4. '[]' System program + // 5. '[]' SPL Token program CreateIdempotent, - /// Transfers from and closes a nested associated token account: an - /// associated token account owned by an associated token account. - /// - /// The tokens are moved from the nested associated token account to the - /// wallet's associated token account, and the nested account lamports are - /// moved to the wallet. - /// - /// Note: Nested token accounts are an anti-pattern, and almost always - /// created unintentionally, so this instruction should only be used to - /// recover from errors. - /// - /// 0. `[writeable]` Nested associated token account, must be owned by `3` - /// 1. `[]` Token mint for the nested associated token account - /// 2. `[writeable]` Wallet's associated token account - /// 3. `[]` Owner associated token account address, must be owned by `5` - /// 4. `[]` Token mint for the owner associated token account - /// 5. `[writeable, signer]` Wallet address for the owner associated token - /// account - /// 6. `[]` SPL Token program + // Transfers from and closes a nested associated token account: an + // associated token account owned by an associated token account. + // + // The tokens are moved from the nested associated token account to the + // wallet's associated token account, and the nested account lamports are + // moved to the wallet. + // + // Note: Nested token accounts are an anti-pattern, and almost always + // created unintentionally, so this instruction should only be used to + // recover from errors. + // + // 0. '[writeable]' Nested associated token account, must be owned by '3' + // 1. '[]' Token mint for the nested associated token account + // 2. '[writeable]' Wallet's associated token account + // 3. '[]' Owner associated token account address, must be owned by '5' + // 4. '[]' Token mint for the owner associated token account + // 5. '[writeable, signer]' Wallet address for the owner associated token + // account + // 6. '[]' SPL Token program RecoverNested; private final byte[] discriminatorBytes; diff --git a/src/main/java/software/sava/solana/programs/token/TokenProgram.java b/src/main/java/software/sava/solana/programs/token/TokenProgram.java index 3b91b73..3ccc8d5 100644 --- a/src/main/java/software/sava/solana/programs/token/TokenProgram.java +++ b/src/main/java/software/sava/solana/programs/token/TokenProgram.java @@ -17,436 +17,436 @@ public final class TokenProgram { private enum TokenInstruction { - /// Initializes a new mint and optionally deposits all the newly minted - /// tokens in an account. - /// - /// The `InitializeMint` instruction requires no signers and MUST be - /// included within the same Transaction as the system program's - /// `CreateAccount` instruction that creates the account being initialized. - /// Otherwise another party can acquire ownership of the uninitialized - /// account. - /// - /// Accounts expected by this instruction: - /// - /// 0. `[writable]` The mint to initialize. - /// 1. `[]` Rent sysvar + // Initializes a new mint and optionally deposits all the newly minted + // tokens in an account. + // + // The 'InitializeMint' instruction requires no signers and MUST be + // included within the same Transaction as the system program's + // 'CreateAccount' instruction that creates the account being initialized. + // Otherwise another party can acquire ownership of the uninitialized + // account. + // + // Accounts expected by this instruction: + // + // 0. '[writable]' The mint to initialize. + // 1. '[]' Rent sysvar InitializeMint, - /// Number of base 10 digits to the right of the decimal place. + // Number of base 10 digits to the right of the decimal place. // decimals: u8, -// /// The authority/multisignature to mint tokens. +// // The authority/multisignature to mint tokens. // mint_authority: Pubkey, -// /// The freeze authority/multisignature of the mint. +// // The freeze authority/multisignature of the mint. // freeze_authority: COption - /// Initializes a new account to hold tokens. If this account is associated - /// with the native mint then the token balance of the initialized account - /// will be equal to the amount of SOL in the account. If this account is - /// associated with another mint, that mint must be initialized before this - /// command can succeed. - /// - /// The `InitializeAccount` instruction requires no signers and MUST be - /// included within the same Transaction as the system program's - /// `CreateAccount` instruction that creates the account being initialized. - /// Otherwise another party can acquire ownership of the uninitialized - /// account. - /// - /// Accounts expected by this instruction: - /// - /// 0. `[writable]` The account to initialize. - /// 1. `[]` The mint this account will be associated with. - /// 2. `[]` The new account's owner/multisignature. - /// 3. `[]` Rent sysvar + // Initializes a new account to hold tokens. If this account is associated + // with the native mint then the token balance of the initialized account + // will be equal to the amount of SOL in the account. If this account is + // associated with another mint, that mint must be initialized before this + // command can succeed. + // + // The 'InitializeAccount' instruction requires no signers and MUST be + // included within the same Transaction as the system program's + // 'CreateAccount' instruction that creates the account being initialized. + // Otherwise another party can acquire ownership of the uninitialized + // account. + // + // Accounts expected by this instruction: + // + // 0. '[writable]' The account to initialize. + // 1. '[]' The mint this account will be associated with. + // 2. '[]' The new account's owner/multisignature. + // 3. '[]' Rent sysvar InitializeAccount, - /// Initializes a multisignature account with N provided signers. - /// - /// Multisignature accounts can used in place of any single owner/delegate - /// accounts in any token instruction that require an owner/delegate to be - /// present. The variant field represents the number of signers (M) - /// required to validate this multisignature account. - /// - /// The `InitializeMultisig` instruction requires no signers and MUST be - /// included within the same Transaction as the system program's - /// `CreateAccount` instruction that creates the account being initialized. - /// Otherwise another party can acquire ownership of the uninitialized - /// account. - /// - /// Accounts expected by this instruction: - /// - /// 0. `[writable]` The multisignature account to initialize. - /// 1. `[]` Rent sysvar - /// 2. ..2+N. `[]` The signer accounts, must equal to N where 1 <= N <= - /// 11. + // Initializes a multisignature account with N provided signers. + // + // Multisignature accounts can used in place of any single owner/delegate + // accounts in any token instruction that require an owner/delegate to be + // present. The variant field represents the number of signers (M) + // required to validate this multisignature account. + // + // The 'InitializeMultisig' instruction requires no signers and MUST be + // included within the same Transaction as the system program's + // 'CreateAccount' instruction that creates the account being initialized. + // Otherwise another party can acquire ownership of the uninitialized + // account. + // + // Accounts expected by this instruction: + // + // 0. '[writable]' The multisignature account to initialize. + // 1. '[]' Rent sysvar + // 2. ..2+N. '[]' The signer accounts, must equal to N where 1 <= N <= + // 11. InitializeMultisig, - /// The number of signers (M) required to validate this multisignature - /// account. + // The number of signers (M) required to validate this multisignature + // account. // m: u8, - /// Transfers tokens from one account to another either directly or via a - /// delegate. If this account is associated with the native mint then equal - /// amounts of SOL and Tokens will be transferred to the destination - /// account. - /// - /// Accounts expected by this instruction: - /// - /// * Single owner/delegate - /// 0. `[writable]` The source account. - /// 1. `[writable]` The destination account. - /// 2. `[signer]` The source account's owner/delegate. - /// - /// * Multisignature owner/delegate - /// 0. `[writable]` The source account. - /// 1. `[writable]` The destination account. - /// 2. `[]` The source account's multisignature owner/delegate. - /// 3. ..3+M `[signer]` M signer accounts. + // Transfers tokens from one account to another either directly or via a + // delegate. If this account is associated with the native mint then equal + // amounts of SOL and Tokens will be transferred to the destination + // account. + // + // Accounts expected by this instruction: + // + // * Single owner/delegate + // 0. '[writable]' The source account. + // 1. '[writable]' The destination account. + // 2. '[signer]' The source account's owner/delegate. + // + // * Multisignature owner/delegate + // 0. '[writable]' The source account. + // 1. '[writable]' The destination account. + // 2. '[]' The source account's multisignature owner/delegate. + // 3. ..3+M '[signer]' M signer accounts. Transfer, - /// The amount of tokens to transfer. + // The amount of tokens to transfer. // amount: u64, - /// Approves a delegate. A delegate is given the authority over tokens on - /// behalf of the source account's owner. - /// - /// Accounts expected by this instruction: - /// - /// * Single owner - /// 0. `[writable]` The source account. - /// 1. `[]` The delegate. - /// 2. `[signer]` The source account owner. - /// - /// * Multisignature owner - /// 0. `[writable]` The source account. - /// 1. `[]` The delegate. - /// 2. `[]` The source account's multisignature owner. - /// 3. ..3+M `[signer]` M signer accounts + // Approves a delegate. A delegate is given the authority over tokens on + // behalf of the source account's owner. + // + // Accounts expected by this instruction: + // + // * Single owner + // 0. '[writable]' The source account. + // 1. '[]' The delegate. + // 2. '[signer]' The source account owner. + // + // * Multisignature owner + // 0. '[writable]' The source account. + // 1. '[]' The delegate. + // 2. '[]' The source account's multisignature owner. + // 3. ..3+M '[signer]' M signer accounts Approve, - /// The amount of tokens the delegate is approved for. + // The amount of tokens the delegate is approved for. // amount: u64, - /// Revokes the delegate's authority. - /// - /// Accounts expected by this instruction: - /// - /// * Single owner - /// 0. `[writable]` The source account. - /// 1. `[signer]` The source account owner. - /// - /// * Multisignature owner - /// 0. `[writable]` The source account. - /// 1. `[]` The source account's multisignature owner. - /// 2. ..2+M `[signer]` M signer accounts + // Revokes the delegate's authority. + // + // Accounts expected by this instruction: + // + // * Single owner + // 0. '[writable]' The source account. + // 1. '[signer]' The source account owner. + // + // * Multisignature owner + // 0. '[writable]' The source account. + // 1. '[]' The source account's multisignature owner. + // 2. ..2+M '[signer]' M signer accounts Revoke, - /// Sets a new authority of a mint or account. - /// - /// Accounts expected by this instruction: - /// - /// * Single authority - /// 0. `[writable]` The mint or account to change the authority of. - /// 1. `[signer]` The current authority of the mint or account. - /// - /// * Multisignature authority - /// 0. `[writable]` The mint or account to change the authority of. - /// 1. `[]` The mint's or account's current multisignature authority. - /// 2. ..2+M `[signer]` M signer accounts + // Sets a new authority of a mint or account. + // + // Accounts expected by this instruction: + // + // * Single authority + // 0. '[writable]' The mint or account to change the authority of. + // 1. '[signer]' The current authority of the mint or account. + // + // * Multisignature authority + // 0. '[writable]' The mint or account to change the authority of. + // 1. '[]' The mint's or account's current multisignature authority. + // 2. ..2+M '[signer]' M signer accounts SetAuthority, - /// The type of authority to update. + // The type of authority to update. // authority_type: AuthorityType, -// /// The new authority +// // The new authority // new_authority: COption, - /// Mints new tokens to an account. The native mint does not support - /// minting. - /// - /// Accounts expected by this instruction: - /// - /// * Single authority - /// 0. `[writable]` The mint. - /// 1. `[writable]` The account to mint tokens to. - /// 2. `[signer]` The mint's minting authority. - /// - /// * Multisignature authority - /// 0. `[writable]` The mint. - /// 1. `[writable]` The account to mint tokens to. - /// 2. `[]` The mint's multisignature mint-tokens authority. - /// 3. ..3+M `[signer]` M signer accounts. + // Mints new tokens to an account. The native mint does not support + // minting. + // + // Accounts expected by this instruction: + // + // * Single authority + // 0. '[writable]' The mint. + // 1. '[writable]' The account to mint tokens to. + // 2. '[signer]' The mint's minting authority. + // + // * Multisignature authority + // 0. '[writable]' The mint. + // 1. '[writable]' The account to mint tokens to. + // 2. '[]' The mint's multisignature mint-tokens authority. + // 3. ..3+M '[signer]' M signer accounts. MintTo, - /// The amount of new tokens to mint. + // The amount of new tokens to mint. // amount: u64, - /// Burns tokens by removing them from an account. `Burn` does not support - /// accounts associated with the native mint, use `CloseAccount` instead. - /// - /// Accounts expected by this instruction: - /// - /// * Single owner/delegate - /// 0. `[writable]` The account to burn from. - /// 1. `[writable]` The token mint. - /// 2. `[signer]` The account's owner/delegate. - /// - /// * Multisignature owner/delegate - /// 0. `[writable]` The account to burn from. - /// 1. `[writable]` The token mint. - /// 2. `[]` The account's multisignature owner/delegate. - /// 3. ..3+M `[signer]` M signer accounts. + // Burns tokens by removing them from an account. 'Burn' does not support + // accounts associated with the native mint, use 'CloseAccount' instead. + // + // Accounts expected by this instruction: + // + // * Single owner/delegate + // 0. '[writable]' The account to burn from. + // 1. '[writable]' The token mint. + // 2. '[signer]' The account's owner/delegate. + // + // * Multisignature owner/delegate + // 0. '[writable]' The account to burn from. + // 1. '[writable]' The token mint. + // 2. '[]' The account's multisignature owner/delegate. + // 3. ..3+M '[signer]' M signer accounts. Burn, - /// The amount of tokens to burn. + // The amount of tokens to burn. // amount: u64, - /// Close an account by transferring all its SOL to the destination account. - /// Non-native accounts may only be closed if its token amount is zero. - /// - /// Accounts expected by this instruction: - /// - /// * Single owner - /// 0. `[writable]` The account to close. - /// 1. `[writable]` The destination account. - /// 2. `[signer]` The account's owner. - /// - /// * Multisignature owner - /// 0. `[writable]` The account to close. - /// 1. `[writable]` The destination account. - /// 2. `[]` The account's multisignature owner. - /// 3. ..3+M `[signer]` M signer accounts. + // Close an account by transferring all its SOL to the destination account. + // Non-native accounts may only be closed if its token amount is zero. + // + // Accounts expected by this instruction: + // + // * Single owner + // 0. '[writable]' The account to close. + // 1. '[writable]' The destination account. + // 2. '[signer]' The account's owner. + // + // * Multisignature owner + // 0. '[writable]' The account to close. + // 1. '[writable]' The destination account. + // 2. '[]' The account's multisignature owner. + // 3. ..3+M '[signer]' M signer accounts. CloseAccount, - /// Freeze an Initialized account using the Mint's freeze_authority (if - /// set). - /// - /// Accounts expected by this instruction: - /// - /// * Single owner - /// 0. `[writable]` The account to freeze. - /// 1. `[]` The token mint. - /// 2. `[signer]` The mint freeze authority. - /// - /// * Multisignature owner - /// 0. `[writable]` The account to freeze. - /// 1. `[]` The token mint. - /// 2. `[]` The mint's multisignature freeze authority. - /// 3. ..3+M `[signer]` M signer accounts. + // Freeze an Initialized account using the Mint's freeze_authority (if + // set). + // + // Accounts expected by this instruction: + // + // * Single owner + // 0. '[writable]' The account to freeze. + // 1. '[]' The token mint. + // 2. '[signer]' The mint freeze authority. + // + // * Multisignature owner + // 0. '[writable]' The account to freeze. + // 1. '[]' The token mint. + // 2. '[]' The mint's multisignature freeze authority. + // 3. ..3+M '[signer]' M signer accounts. FreezeAccount, - /// Thaw a Frozen account using the Mint's freeze_authority (if set). - /// - /// Accounts expected by this instruction: - /// - /// * Single owner - /// 0. `[writable]` The account to freeze. - /// 1. `[]` The token mint. - /// 2. `[signer]` The mint freeze authority. - /// - /// * Multisignature owner - /// 0. `[writable]` The account to freeze. - /// 1. `[]` The token mint. - /// 2. `[]` The mint's multisignature freeze authority. - /// 3. ..3+M `[signer]` M signer accounts. + // Thaw a Frozen account using the Mint's freeze_authority (if set). + // + // Accounts expected by this instruction: + // + // * Single owner + // 0. '[writable]' The account to freeze. + // 1. '[]' The token mint. + // 2. '[signer]' The mint freeze authority. + // + // * Multisignature owner + // 0. '[writable]' The account to freeze. + // 1. '[]' The token mint. + // 2. '[]' The mint's multisignature freeze authority. + // 3. ..3+M '[signer]' M signer accounts. ThawAccount, - /// Transfers tokens from one account to another either directly or via a - /// delegate. If this account is associated with the native mint then equal - /// amounts of SOL and Tokens will be transferred to the destination - /// account. - /// - /// This instruction differs from Transfer in that the token mint and - /// decimals value is checked by the caller. This may be useful when - /// creating transactions offline or within a hardware wallet. - /// - /// Accounts expected by this instruction: - /// - /// * Single owner/delegate - /// 0. `[writable]` The source account. - /// 1. `[]` The token mint. - /// 2. `[writable]` The destination account. - /// 3. `[signer]` The source account's owner/delegate. - /// - /// * Multisignature owner/delegate - /// 0. `[writable]` The source account. - /// 1. `[]` The token mint. - /// 2. `[writable]` The destination account. - /// 3. `[]` The source account's multisignature owner/delegate. - /// 4. ..4+M `[signer]` M signer accounts. + // Transfers tokens from one account to another either directly or via a + // delegate. If this account is associated with the native mint then equal + // amounts of SOL and Tokens will be transferred to the destination + // account. + // + // This instruction differs from Transfer in that the token mint and + // decimals value is checked by the caller. This may be useful when + // creating transactions offline or within a hardware wallet. + // + // Accounts expected by this instruction: + // + // * Single owner/delegate + // 0. '[writable]' The source account. + // 1. '[]' The token mint. + // 2. '[writable]' The destination account. + // 3. '[signer]' The source account's owner/delegate. + // + // * Multisignature owner/delegate + // 0. '[writable]' The source account. + // 1. '[]' The token mint. + // 2. '[writable]' The destination account. + // 3. '[]' The source account's multisignature owner/delegate. + // 4. ..4+M '[signer]' M signer accounts. TransferChecked, - /// The amount of tokens to transfer. + // The amount of tokens to transfer. // amount: u64, -// /// Expected number of base 10 digits to the right of the decimal place. +// // Expected number of base 10 digits to the right of the decimal place. // decimals: u8, - /// Approves a delegate. A delegate is given the authority over tokens on - /// behalf of the source account's owner. - /// - /// This instruction differs from Approve in that the token mint and - /// decimals value is checked by the caller. This may be useful when - /// creating transactions offline or within a hardware wallet. - /// - /// Accounts expected by this instruction: - /// - /// * Single owner - /// 0. `[writable]` The source account. - /// 1. `[]` The token mint. - /// 2. `[]` The delegate. - /// 3. `[signer]` The source account owner. - /// - /// * Multisignature owner - /// 0. `[writable]` The source account. - /// 1. `[]` The token mint. - /// 2. `[]` The delegate. - /// 3. `[]` The source account's multisignature owner. - /// 4. ..4+M `[signer]` M signer accounts + // Approves a delegate. A delegate is given the authority over tokens on + // behalf of the source account's owner. + // + // This instruction differs from Approve in that the token mint and + // decimals value is checked by the caller. This may be useful when + // creating transactions offline or within a hardware wallet. + // + // Accounts expected by this instruction: + // + // * Single owner + // 0. '[writable]' The source account. + // 1. '[]' The token mint. + // 2. '[]' The delegate. + // 3. '[signer]' The source account owner. + // + // * Multisignature owner + // 0. '[writable]' The source account. + // 1. '[]' The token mint. + // 2. '[]' The delegate. + // 3. '[]' The source account's multisignature owner. + // 4. ..4+M '[signer]' M signer accounts ApproveChecked, - /// The amount of tokens the delegate is approved for. + // The amount of tokens the delegate is approved for. // amount: u64, -// /// Expected number of base 10 digits to the right of the decimal place. +// // Expected number of base 10 digits to the right of the decimal place. // decimals: u8, - /// Mints new tokens to an account. The native mint does not support - /// minting. - /// - /// This instruction differs from MintTo in that the decimals value is - /// checked by the caller. This may be useful when creating transactions - /// offline or within a hardware wallet. - /// - /// Accounts expected by this instruction: - /// - /// * Single authority - /// 0. `[writable]` The mint. - /// 1. `[writable]` The account to mint tokens to. - /// 2. `[signer]` The mint's minting authority. - /// - /// * Multisignature authority - /// 0. `[writable]` The mint. - /// 1. `[writable]` The account to mint tokens to. - /// 2. `[]` The mint's multisignature mint-tokens authority. - /// 3. ..3+M `[signer]` M signer accounts. + // Mints new tokens to an account. The native mint does not support + // minting. + // + // This instruction differs from MintTo in that the decimals value is + // checked by the caller. This may be useful when creating transactions + // offline or within a hardware wallet. + // + // Accounts expected by this instruction: + // + // * Single authority + // 0. '[writable]' The mint. + // 1. '[writable]' The account to mint tokens to. + // 2. '[signer]' The mint's minting authority. + // + // * Multisignature authority + // 0. '[writable]' The mint. + // 1. '[writable]' The account to mint tokens to. + // 2. '[]' The mint's multisignature mint-tokens authority. + // 3. ..3+M '[signer]' M signer accounts. MintToChecked, - /// The amount of new tokens to mint. + // The amount of new tokens to mint. // amount: u64, -// /// Expected number of base 10 digits to the right of the decimal place. +// // Expected number of base 10 digits to the right of the decimal place. // decimals: u8, - /// Burns tokens by removing them from an account. `BurnChecked` does not - /// support accounts associated with the native mint, use `CloseAccount` - /// instead. - /// - /// This instruction differs from Burn in that the decimals value is checked - /// by the caller. This may be useful when creating transactions offline or - /// within a hardware wallet. - /// - /// Accounts expected by this instruction: - /// - /// * Single owner/delegate - /// 0. `[writable]` The account to burn from. - /// 1. `[writable]` The token mint. - /// 2. `[signer]` The account's owner/delegate. - /// - /// * Multisignature owner/delegate - /// 0. `[writable]` The account to burn from. - /// 1. `[writable]` The token mint. - /// 2. `[]` The account's multisignature owner/delegate. - /// 3. ..3+M `[signer]` M signer accounts. + // Burns tokens by removing them from an account. 'BurnChecked' does not + // support accounts associated with the native mint, use 'CloseAccount' + // instead. + // + // This instruction differs from Burn in that the decimals value is checked + // by the caller. This may be useful when creating transactions offline or + // within a hardware wallet. + // + // Accounts expected by this instruction: + // + // * Single owner/delegate + // 0. '[writable]' The account to burn from. + // 1. '[writable]' The token mint. + // 2. '[signer]' The account's owner/delegate. + // + // * Multisignature owner/delegate + // 0. '[writable]' The account to burn from. + // 1. '[writable]' The token mint. + // 2. '[]' The account's multisignature owner/delegate. + // 3. ..3+M '[signer]' M signer accounts. BurnChecked, - /// The amount of tokens to burn. + // The amount of tokens to burn. // amount: u64, -// /// Expected number of base 10 digits to the right of the decimal place. +// // Expected number of base 10 digits to the right of the decimal place. // decimals: u8, - /// Like InitializeAccount, but the owner pubkey is passed via instruction - /// data rather than the accounts list. This variant may be preferable - /// when using Cross Program Invocation from an instruction that does - /// not need the owner's `AccountInfo` otherwise. - /// - /// Accounts expected by this instruction: - /// - /// 0. `[writable]` The account to initialize. - /// 1. `[]` The mint this account will be associated with. - /// 3. `[]` Rent sysvar + // Like InitializeAccount, but the owner pubkey is passed via instruction + // data rather than the accounts list. This variant may be preferable + // when using Cross Program Invocation from an instruction that does + // not need the owner's 'AccountInfo' otherwise. + // + // Accounts expected by this instruction: + // + // 0. '[writable]' The account to initialize. + // 1. '[]' The mint this account will be associated with. + // 3. '[]' Rent sysvar InitializeAccount2, - /// The new account's owner/multisignature. + // The new account's owner/multisignature. // owner: Pubkey, - /// Given a wrapped / native token account (a token account containing SOL) - /// updates its amount field based on the account's underlying `lamports`. - /// This is useful if a non-wrapped SOL account uses - /// `system_instruction::transfer` to move lamports to a wrapped token - /// account, and needs to have its token `amount` field updated. - /// - /// Accounts expected by this instruction: - /// - /// 0. `[writable]` The native token account to sync with its underlying - /// lamports. + // Given a wrapped / native token account (a token account containing SOL) + // updates its amount field based on the account's underlying 'lamports'. + // This is useful if a non-wrapped SOL account uses + // 'system_instruction::transfer' to move lamports to a wrapped token + // account, and needs to have its token 'amount' field updated. + // + // Accounts expected by this instruction: + // + // 0. '[writable]' The native token account to sync with its underlying + // lamports. SyncNative, - /// Like InitializeAccount2, but does not require the Rent sysvar to be - /// provided - /// - /// Accounts expected by this instruction: - /// - /// 0. `[writable]` The account to initialize. - /// 1. `[]` The mint this account will be associated with. + // Like InitializeAccount2, but does not require the Rent sysvar to be + // provided + // + // Accounts expected by this instruction: + // + // 0. '[writable]' The account to initialize. + // 1. '[]' The mint this account will be associated with. InitializeAccount3, - /// The new account's owner/multisignature. + // The new account's owner/multisignature. // owner: Pubkey, - /// Like InitializeMultisig, but does not require the Rent sysvar to be - /// provided - /// - /// Accounts expected by this instruction: - /// - /// 0. `[writable]` The multisignature account to initialize. - /// 1. ..1+N. `[]` The signer accounts, must equal to N where 1 <= N <= - /// 11. + // Like InitializeMultisig, but does not require the Rent sysvar to be + // provided + // + // Accounts expected by this instruction: + // + // 0. '[writable]' The multisignature account to initialize. + // 1. ..1+N. '[]' The signer accounts, must equal to N where 1 <= N <= + // 11. InitializeMultisig2, - /// The number of signers (M) required to validate this multisignature - /// account. + // The number of signers (M) required to validate this multisignature + // account. // m: u8, - /// Like [`InitializeMint`], but does not require the Rent sysvar to be - /// provided - /// - /// Accounts expected by this instruction: - /// - /// 0. `[writable]` The mint to initialize. + // Like ['InitializeMint'], but does not require the Rent sysvar to be + // provided + // + // Accounts expected by this instruction: + // + // 0. '[writable]' The mint to initialize. InitializeMint2, - /// Number of base 10 digits to the right of the decimal place. + // Number of base 10 digits to the right of the decimal place. // decimals: u8, -// /// The authority/multisignature to mint tokens. +// // The authority/multisignature to mint tokens. // mint_authority: Pubkey, -// /// The freeze authority/multisignature of the mint. +// // The freeze authority/multisignature of the mint. // freeze_authority: COption, - /// Gets the required size of an account for the given mint as a - /// little-endian `u64`. - /// - /// Return data can be fetched using `sol_get_return_data` and deserializing - /// the return data as a little-endian `u64`. - /// - /// Accounts expected by this instruction: - /// - /// 0. `[]` The mint to calculate for + // Gets the required size of an account for the given mint as a + // little-endian 'u64'. + // + // Return data can be fetched using 'sol_get_return_data' and deserializing + // the return data as a little-endian 'u64'. + // + // Accounts expected by this instruction: + // + // 0. '[]' The mint to calculate for GetAccountDataSize, // typically, there's also data, but this program ignores it - /// Initialize the Immutable Owner extension for the given token account - /// - /// Fails if the account has already been initialized, so must be called - /// before `InitializeAccount`. - /// - /// No-ops in this version of the program, but is included for compatibility - /// with the Associated Token Account program. - /// - /// Accounts expected by this instruction: - /// - /// 0. `[writable]` The account to initialize. - /// - /// Data expected by this instruction: - /// None + // Initialize the Immutable Owner extension for the given token account + // + // Fails if the account has already been initialized, so must be called + // before 'InitializeAccount'. + // + // No-ops in this version of the program, but is included for compatibility + // with the Associated Token Account program. + // + // Accounts expected by this instruction: + // + // 0. '[writable]' The account to initialize. + // + // Data expected by this instruction: + // None InitializeImmutableOwner, - /// Convert an Amount of tokens to a UiAmount `string`, using the given - /// mint. In this version of the program, the mint can only specify the - /// number of decimals. - /// - /// Fails on an invalid mint. - /// - /// Return data can be fetched using `sol_get_return_data` and deserialized - /// with `String::from_utf8`. - /// - /// Accounts expected by this instruction: - /// - /// 0. `[]` The mint to calculate for + // Convert an Amount of tokens to a UiAmount 'string', using the given + // mint. In this version of the program, the mint can only specify the + // number of decimals. + // + // Fails on an invalid mint. + // + // Return data can be fetched using 'sol_get_return_data' and deserialized + // with 'String::from_utf8'. + // + // Accounts expected by this instruction: + // + // 0. '[]' The mint to calculate for AmountToUiAmount, - /// The amount of tokens to reformat. + // The amount of tokens to reformat. // amount: u64, - /// Convert a UiAmount of tokens to a little-endian `u64` raw Amount, using - /// the given mint. In this version of the program, the mint can only - /// specify the number of decimals. - /// - /// Return data can be fetched using `sol_get_return_data` and deserializing - /// the return data as a little-endian `u64`. - /// - /// Accounts expected by this instruction: - /// - /// 0. `[]` The mint to calculate for + // Convert a UiAmount of tokens to a little-endian 'u64' raw Amount, using + // the given mint. In this version of the program, the mint can only + // specify the number of decimals. + // + // Return data can be fetched using 'sol_get_return_data' and deserializing + // the return data as a little-endian 'u64'. + // + // Accounts expected by this instruction: + // + // 0. '[]' The mint to calculate for UiAmountToAmount; - /// The ui_amount of tokens to reformat. + // The ui_amount of tokens to reformat. // ui_amount: &'a str, - // Any new variants also need to be added to program-2022 `TokenInstruction`, so that the + // Any new variants also need to be added to program-2022 'TokenInstruction', so that the // latter remains a superset of this instruction set. New variants also need to be added to // token/js/src/instructions/types.ts to maintain @solana/spl-token compatibility