lib.rs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
  1. // This file is autogenerated with https://github.com/acheroncrypto/native-to-anchor
  2. use anchor_lang::prelude::*;
  3. declare_id!("11111111111111111111111111111111");
  4. #[program]
  5. pub mod spl_stake_pool {
  6. use super::*;
  7. pub fn initialize(
  8. ctx: Context<Initialize>,
  9. fee: Fee,
  10. withdrawal_fee: Fee,
  11. deposit_fee: Fee,
  12. referral_fee: u8,
  13. max_validators: u32,
  14. ) -> Result<()> {
  15. Ok(())
  16. }
  17. pub fn add_validator_to_pool(ctx: Context<AddValidatorToPool>) -> Result<()> {
  18. Ok(())
  19. }
  20. pub fn remove_validator_from_pool(ctx: Context<RemoveValidatorFromPool>) -> Result<()> {
  21. Ok(())
  22. }
  23. pub fn decrease_validator_stake(
  24. ctx: Context<DecreaseValidatorStake>,
  25. lamports: u64,
  26. transient_stake_seed: u64,
  27. ) -> Result<()> {
  28. Ok(())
  29. }
  30. pub fn increase_validator_stake(
  31. ctx: Context<IncreaseValidatorStake>,
  32. lamports: u64,
  33. transient_stake_seed: u64,
  34. ) -> Result<()> {
  35. Ok(())
  36. }
  37. pub fn set_preferred_validator(
  38. ctx: Context<SetPreferredValidator>,
  39. validator_type: PreferredValidatorType,
  40. validator_vote_address: Option<Pubkey>,
  41. ) -> Result<()> {
  42. Ok(())
  43. }
  44. pub fn update_validator_list_balance(
  45. ctx: Context<UpdateValidatorListBalance>,
  46. start_index: u32,
  47. no_merge: bool,
  48. ) -> Result<()> {
  49. Ok(())
  50. }
  51. pub fn update_stake_pool_balance(ctx: Context<UpdateStakePoolBalance>) -> Result<()> {
  52. Ok(())
  53. }
  54. pub fn cleanup_removed_validator_entries(
  55. ctx: Context<CleanupRemovedValidatorEntries>,
  56. ) -> Result<()> {
  57. Ok(())
  58. }
  59. pub fn deposit_stake(ctx: Context<DepositStake>) -> Result<()> {
  60. Ok(())
  61. }
  62. pub fn withdraw_stake(ctx: Context<WithdrawStake>, arg: u64) -> Result<()> {
  63. Ok(())
  64. }
  65. pub fn set_manager(ctx: Context<SetManager>) -> Result<()> {
  66. Ok(())
  67. }
  68. pub fn set_fee(ctx: Context<SetFee>, fee: FeeType) -> Result<()> {
  69. Ok(())
  70. }
  71. pub fn set_staker(ctx: Context<SetStaker>) -> Result<()> {
  72. Ok(())
  73. }
  74. pub fn deposit_sol(ctx: Context<DepositSol>, arg: u64) -> Result<()> {
  75. Ok(())
  76. }
  77. pub fn set_funding_authority(
  78. ctx: Context<SetFundingAuthority>,
  79. arg: FundingType,
  80. ) -> Result<()> {
  81. Ok(())
  82. }
  83. pub fn withdraw_sol(ctx: Context<WithdrawSol>, arg: u64) -> Result<()> {
  84. Ok(())
  85. }
  86. pub fn create_token_metadata(
  87. ctx: Context<CreateTokenMetadata>,
  88. name: String,
  89. symbol: String,
  90. uri: String,
  91. ) -> Result<()> {
  92. Ok(())
  93. }
  94. pub fn update_token_metadata(
  95. ctx: Context<UpdateTokenMetadata>,
  96. name: String,
  97. symbol: String,
  98. uri: String,
  99. ) -> Result<()> {
  100. Ok(())
  101. }
  102. }
  103. #[derive(Accounts)]
  104. pub struct Initialize<'info> {
  105. #[account(mut)]
  106. stake_pool: AccountInfo<'info>,
  107. manager: Signer<'info>,
  108. staker: AccountInfo<'info>,
  109. stake_pool_withdraw_authority: AccountInfo<'info>,
  110. #[account(mut)]
  111. validator_list: AccountInfo<'info>,
  112. reserve_stake: AccountInfo<'info>,
  113. #[account(mut)]
  114. pool_mint: AccountInfo<'info>,
  115. #[account(mut)]
  116. manager_pool_account: AccountInfo<'info>,
  117. token_program: Program<'info, Token>,
  118. // optional_deposit_authority: Signer<'info>,
  119. }
  120. #[derive(Accounts)]
  121. pub struct AddValidatorToPool<'info> {
  122. #[account(mut)]
  123. stake_pool: AccountInfo<'info>,
  124. staker: Signer<'info>,
  125. #[account(mut)]
  126. funder: Signer<'info>,
  127. stake_pool_withdraw: AccountInfo<'info>,
  128. #[account(mut)]
  129. validator_list: AccountInfo<'info>,
  130. #[account(mut)]
  131. stake: AccountInfo<'info>,
  132. validator: AccountInfo<'info>,
  133. rent: Sysvar<'info, Rent>,
  134. clock: Sysvar<'info, Clock>,
  135. sysvar_stake_history: AccountInfo<'info>,
  136. stake_config: AccountInfo<'info>,
  137. system_program: Program<'info, System>,
  138. stake_program: AccountInfo<'info>,
  139. }
  140. #[derive(Accounts)]
  141. pub struct RemoveValidatorFromPool<'info> {
  142. #[account(mut)]
  143. stake_pool: AccountInfo<'info>,
  144. staker: Signer<'info>,
  145. stake_pool_withdraw: AccountInfo<'info>,
  146. new_stake_authority: AccountInfo<'info>,
  147. #[account(mut)]
  148. validator_list: AccountInfo<'info>,
  149. #[account(mut)]
  150. stake_account: AccountInfo<'info>,
  151. transient_stake_account: AccountInfo<'info>,
  152. #[account(mut)]
  153. destination_stake_account: AccountInfo<'info>,
  154. clock: Sysvar<'info, Clock>,
  155. stake_program: AccountInfo<'info>,
  156. }
  157. #[derive(Accounts)]
  158. pub struct DecreaseValidatorStake<'info> {
  159. stake_pool: AccountInfo<'info>,
  160. staker: Signer<'info>,
  161. stake_pool_withdraw_authority: AccountInfo<'info>,
  162. #[account(mut)]
  163. validator_list: AccountInfo<'info>,
  164. #[account(mut)]
  165. validator_stake: AccountInfo<'info>,
  166. #[account(mut)]
  167. transient_stake: AccountInfo<'info>,
  168. clock: Sysvar<'info, Clock>,
  169. rent: Sysvar<'info, Rent>,
  170. system_program: Program<'info, System>,
  171. stake_program: AccountInfo<'info>,
  172. }
  173. #[derive(Accounts)]
  174. pub struct IncreaseValidatorStake<'info> {
  175. stake_pool: AccountInfo<'info>,
  176. staker: Signer<'info>,
  177. stake_pool_withdraw_authority: AccountInfo<'info>,
  178. #[account(mut)]
  179. validator_list: AccountInfo<'info>,
  180. #[account(mut)]
  181. reserve_stake: AccountInfo<'info>,
  182. #[account(mut)]
  183. transient_stake: AccountInfo<'info>,
  184. validator_stake: AccountInfo<'info>,
  185. validator: AccountInfo<'info>,
  186. clock: Sysvar<'info, Clock>,
  187. rent: Sysvar<'info, Rent>,
  188. sysvar_stake_history: AccountInfo<'info>,
  189. stake_config: AccountInfo<'info>,
  190. system_program: Program<'info, System>,
  191. stake_program: AccountInfo<'info>,
  192. }
  193. #[derive(Accounts)]
  194. pub struct SetPreferredValidator<'info> {
  195. #[account(mut)]
  196. stake_pool_address: AccountInfo<'info>,
  197. staker: Signer<'info>,
  198. validator_list_address: AccountInfo<'info>,
  199. }
  200. #[derive(Accounts)]
  201. pub struct UpdateValidatorListBalance<'info> {
  202. stake_pool: AccountInfo<'info>,
  203. stake_pool_withdraw_authority: AccountInfo<'info>,
  204. #[account(mut)]
  205. validator_list_address: AccountInfo<'info>,
  206. #[account(mut)]
  207. reserve_stake: AccountInfo<'info>,
  208. clock: Sysvar<'info, Clock>,
  209. sysvar_stake_history: AccountInfo<'info>,
  210. stake_program: AccountInfo<'info>,
  211. // #[account(mut)]
  212. // optional_validator_stake_account: AccountInfo<'info>,
  213. // #[account(mut)]
  214. // optional_transient_stake_account: AccountInfo<'info>,
  215. }
  216. #[derive(Accounts)]
  217. pub struct UpdateStakePoolBalance<'info> {
  218. #[account(mut)]
  219. stake_pool: AccountInfo<'info>,
  220. withdraw_authority: AccountInfo<'info>,
  221. #[account(mut)]
  222. validator_list_storage: AccountInfo<'info>,
  223. reserve_stake: AccountInfo<'info>,
  224. #[account(mut)]
  225. manager_fee_account: AccountInfo<'info>,
  226. #[account(mut)]
  227. stake_pool_mint: AccountInfo<'info>,
  228. token_program: Program<'info, Token>,
  229. }
  230. #[derive(Accounts)]
  231. pub struct CleanupRemovedValidatorEntries<'info> {
  232. stake_pool: AccountInfo<'info>,
  233. #[account(mut)]
  234. validator_list_storage: AccountInfo<'info>,
  235. }
  236. #[derive(Accounts)]
  237. pub struct DepositStake<'info> {
  238. #[account(mut)]
  239. stake_pool: AccountInfo<'info>,
  240. #[account(mut)]
  241. validator_list_storage: AccountInfo<'info>,
  242. stake_pool_deposit_authority: AccountInfo<'info>,
  243. stake_pool_withdraw_authority: AccountInfo<'info>,
  244. #[account(mut)]
  245. deposit_stake_address: AccountInfo<'info>,
  246. #[account(mut)]
  247. validator_stake_account: AccountInfo<'info>,
  248. #[account(mut)]
  249. reserve_stake_account: AccountInfo<'info>,
  250. #[account(mut)]
  251. pool_tokens_to: AccountInfo<'info>,
  252. #[account(mut)]
  253. manager_fee_account: AccountInfo<'info>,
  254. #[account(mut)]
  255. referrer_pool_tokens_account: AccountInfo<'info>,
  256. #[account(mut)]
  257. pool_mint: AccountInfo<'info>,
  258. clock: Sysvar<'info, Clock>,
  259. sysvar_stake_history: AccountInfo<'info>,
  260. token_program: Program<'info, Token>,
  261. stake_program: AccountInfo<'info>,
  262. }
  263. #[derive(Accounts)]
  264. pub struct WithdrawStake<'info> {
  265. #[account(mut)]
  266. stake_pool: AccountInfo<'info>,
  267. #[account(mut)]
  268. validator_list_storage: AccountInfo<'info>,
  269. stake_pool_withdraw: AccountInfo<'info>,
  270. #[account(mut)]
  271. stake_to_split: AccountInfo<'info>,
  272. #[account(mut)]
  273. stake_to_receive: AccountInfo<'info>,
  274. user_stake_authority: AccountInfo<'info>,
  275. user_transfer_authority: Signer<'info>,
  276. #[account(mut)]
  277. user_pool_token_account: AccountInfo<'info>,
  278. #[account(mut)]
  279. manager_fee_account: AccountInfo<'info>,
  280. #[account(mut)]
  281. pool_mint: AccountInfo<'info>,
  282. clock: Sysvar<'info, Clock>,
  283. token_program: Program<'info, Token>,
  284. stake_program: AccountInfo<'info>,
  285. }
  286. #[derive(Accounts)]
  287. pub struct SetManager<'info> {
  288. #[account(mut)]
  289. stake_pool: AccountInfo<'info>,
  290. manager: Signer<'info>,
  291. new_manager: Signer<'info>,
  292. new_fee_receiver: AccountInfo<'info>,
  293. }
  294. #[derive(Accounts)]
  295. pub struct SetFee<'info> {
  296. #[account(mut)]
  297. stake_pool: AccountInfo<'info>,
  298. manager: Signer<'info>,
  299. }
  300. #[derive(Accounts)]
  301. pub struct SetStaker<'info> {
  302. #[account(mut)]
  303. stake_pool: AccountInfo<'info>,
  304. set_staker_authority: Signer<'info>,
  305. new_staker: AccountInfo<'info>,
  306. }
  307. #[derive(Accounts)]
  308. pub struct DepositSol<'info> {
  309. #[account(mut)]
  310. stake_pool: AccountInfo<'info>,
  311. stake_pool_withdraw_authority: AccountInfo<'info>,
  312. #[account(mut)]
  313. reserve_stake_account: AccountInfo<'info>,
  314. #[account(mut)]
  315. lamports_from: Signer<'info>,
  316. #[account(mut)]
  317. pool_tokens_to: AccountInfo<'info>,
  318. #[account(mut)]
  319. manager_fee_account: AccountInfo<'info>,
  320. #[account(mut)]
  321. referrer_pool_tokens_account: AccountInfo<'info>,
  322. #[account(mut)]
  323. pool_mint: AccountInfo<'info>,
  324. system_program: Program<'info, System>,
  325. token_program: Program<'info, Token>,
  326. }
  327. #[derive(Accounts)]
  328. pub struct SetFundingAuthority<'info> {
  329. #[account(mut)]
  330. stake_pool: AccountInfo<'info>,
  331. manager: Signer<'info>,
  332. // optional_auth: AccountInfo<'info>,
  333. }
  334. #[derive(Accounts)]
  335. pub struct WithdrawSol<'info> {
  336. #[account(mut)]
  337. stake_pool: AccountInfo<'info>,
  338. stake_pool_withdraw_authority: AccountInfo<'info>,
  339. user_transfer_authority: Signer<'info>,
  340. #[account(mut)]
  341. pool_tokens_from: AccountInfo<'info>,
  342. #[account(mut)]
  343. reserve_stake_account: AccountInfo<'info>,
  344. #[account(mut)]
  345. lamports_to: AccountInfo<'info>,
  346. #[account(mut)]
  347. manager_fee_account: AccountInfo<'info>,
  348. #[account(mut)]
  349. pool_mint: AccountInfo<'info>,
  350. clock: Sysvar<'info, Clock>,
  351. sysvar_stake_history: AccountInfo<'info>,
  352. stake_program: AccountInfo<'info>,
  353. token_program: Program<'info, Token>,
  354. }
  355. #[derive(Accounts)]
  356. pub struct CreateTokenMetadata<'info> {
  357. stake_pool: AccountInfo<'info>,
  358. manager: Signer<'info>,
  359. stake_pool_withdraw_authority: AccountInfo<'info>,
  360. pool_mint: AccountInfo<'info>,
  361. #[account(mut)]
  362. payer: Signer<'info>,
  363. #[account(mut)]
  364. token_metadata: AccountInfo<'info>,
  365. mpl_token_metadata: AccountInfo<'info>,
  366. system_program: Program<'info, System>,
  367. rent: Sysvar<'info, Rent>,
  368. }
  369. #[derive(Accounts)]
  370. pub struct UpdateTokenMetadata<'info> {
  371. stake_pool: AccountInfo<'info>,
  372. manager: Signer<'info>,
  373. stake_pool_withdraw_authority: AccountInfo<'info>,
  374. #[account(mut)]
  375. token_metadata: AccountInfo<'info>,
  376. mpl_token_metadata: AccountInfo<'info>,
  377. }
  378. #[account]
  379. pub struct StakePool {
  380. /// Account type, must be StakePool currently
  381. pub account_type: AccountType,
  382. /// Manager authority, allows for updating the staker, manager, and fee account
  383. pub manager: Pubkey,
  384. /// Staker authority, allows for adding and removing validators, and managing stake
  385. /// distribution
  386. pub staker: Pubkey,
  387. /// Stake deposit authority
  388. ///
  389. /// If a depositor pubkey is specified on initialization, then deposits must be
  390. /// signed by this authority. If no deposit authority is specified,
  391. /// then the stake pool will default to the result of:
  392. /// `Pubkey::find_program_address(
  393. /// &[&stake_pool_address.to_bytes()[..32], b"deposit"],
  394. /// program_id,
  395. /// )`
  396. pub stake_deposit_authority: Pubkey,
  397. /// Stake withdrawal authority bump seed
  398. /// for `create_program_address(&[state::StakePool account, "withdrawal"])`
  399. pub stake_withdraw_bump_seed: u8,
  400. /// Validator stake list storage account
  401. pub validator_list: Pubkey,
  402. /// Reserve stake account, holds deactivated stake
  403. pub reserve_stake: Pubkey,
  404. /// Pool Mint
  405. pub pool_mint: Pubkey,
  406. /// Manager fee account
  407. pub manager_fee_account: Pubkey,
  408. /// Pool token program id
  409. pub token_program_id: Pubkey,
  410. /// Total stake under management.
  411. /// Note that if `last_update_epoch` does not match the current epoch then
  412. /// this field may not be accurate
  413. pub total_lamports: u64,
  414. /// Total supply of pool tokens (should always match the supply in the Pool Mint)
  415. pub pool_token_supply: u64,
  416. /// Last epoch the `total_lamports` field was updated
  417. pub last_update_epoch: u64,
  418. /// Lockup that all stakes in the pool must have
  419. pub lockup: Lockup,
  420. /// Fee taken as a proportion of rewards each epoch
  421. pub epoch_fee: Fee,
  422. /// Fee for next epoch
  423. pub next_epoch_fee: Option<Fee>,
  424. /// Preferred deposit validator vote account pubkey
  425. pub preferred_deposit_validator_vote_address: Option<Pubkey>,
  426. /// Preferred withdraw validator vote account pubkey
  427. pub preferred_withdraw_validator_vote_address: Option<Pubkey>,
  428. /// Fee assessed on stake deposits
  429. pub stake_deposit_fee: Fee,
  430. /// Fee assessed on withdrawals
  431. pub stake_withdrawal_fee: Fee,
  432. /// Future stake withdrawal fee, to be set for the following epoch
  433. pub next_stake_withdrawal_fee: Option<Fee>,
  434. /// Fees paid out to referrers on referred stake deposits.
  435. /// Expressed as a percentage (0 - 100) of deposit fees.
  436. /// i.e. `stake_deposit_fee`% of stake deposited is collected as deposit fees for every deposit
  437. /// and `stake_referral_fee`% of the collected stake deposit fees is paid out to the referrer
  438. pub stake_referral_fee: u8,
  439. /// Toggles whether the `DepositSol` instruction requires a signature from
  440. /// this `sol_deposit_authority`
  441. pub sol_deposit_authority: Option<Pubkey>,
  442. /// Fee assessed on SOL deposits
  443. pub sol_deposit_fee: Fee,
  444. /// Fees paid out to referrers on referred SOL deposits.
  445. /// Expressed as a percentage (0 - 100) of SOL deposit fees.
  446. /// i.e. `sol_deposit_fee`% of SOL deposited is collected as deposit fees for every deposit
  447. /// and `sol_referral_fee`% of the collected SOL deposit fees is paid out to the referrer
  448. pub sol_referral_fee: u8,
  449. /// Toggles whether the `WithdrawSol` instruction requires a signature from
  450. /// the `deposit_authority`
  451. pub sol_withdraw_authority: Option<Pubkey>,
  452. /// Fee assessed on SOL withdrawals
  453. pub sol_withdrawal_fee: Fee,
  454. /// Future SOL withdrawal fee, to be set for the following epoch
  455. pub next_sol_withdrawal_fee: Option<Fee>,
  456. /// Last epoch's total pool tokens, used only for APR estimation
  457. pub last_epoch_pool_token_supply: u64,
  458. /// Last epoch's total lamports, used only for APR estimation
  459. pub last_epoch_total_lamports: u64,
  460. }
  461. #[account]
  462. pub struct ValidatorStakeInfo {
  463. /// Amount of active stake delegated to this validator, minus the minimum
  464. /// required stake amount of rent-exemption + `crate::MINIMUM_ACTIVE_STAKE`
  465. /// (currently 1 SOL).
  466. ///
  467. /// Note that if `last_update_epoch` does not match the current epoch then
  468. /// this field may not be accurate
  469. pub active_stake_lamports: u64,
  470. /// Amount of transient stake delegated to this validator
  471. ///
  472. /// Note that if `last_update_epoch` does not match the current epoch then
  473. /// this field may not be accurate
  474. pub transient_stake_lamports: u64,
  475. /// Last epoch the active and transient stake lamports fields were updated
  476. pub last_update_epoch: u64,
  477. /// Start of the validator transient account seed suffixess
  478. pub transient_seed_suffix_start: u64,
  479. /// End of the validator transient account seed suffixes
  480. pub transient_seed_suffix_end: u64,
  481. /// Status of the validator stake account
  482. pub status: StakeStatus,
  483. /// Validator vote account address
  484. pub vote_account_address: Pubkey,
  485. }
  486. #[account]
  487. pub struct ValidatorList {
  488. /// Data outside of the validator list, separated out for cheaper deserializations
  489. pub header: ValidatorListHeader,
  490. /// List of stake info for each validator in the pool
  491. pub validators: Vec<ValidatorStakeInfo>,
  492. }
  493. #[derive(AnchorSerialize, AnchorDeserialize)]
  494. pub enum AccountType {
  495. /// If the account has not been initialized, the enum will be 0
  496. Uninitialized,
  497. /// Stake pool
  498. StakePool,
  499. /// Validator stake list
  500. ValidatorList,
  501. }
  502. #[derive(AnchorSerialize, AnchorDeserialize)]
  503. pub struct Fee {
  504. /// denominator of the fee ratio
  505. pub denominator: u64,
  506. /// numerator of the fee ratio
  507. pub numerator: u64,
  508. }
  509. #[derive(AnchorSerialize, AnchorDeserialize)]
  510. pub struct ValidatorListHeader {
  511. /// Account type, must be ValidatorList currently
  512. pub account_type: AccountType,
  513. /// Maximum allowable number of validators
  514. pub max_validators: u32,
  515. }
  516. #[derive(AnchorSerialize, AnchorDeserialize)]
  517. pub enum StakeStatus {
  518. /// Stake account is active, there may be a transient stake as well
  519. Active,
  520. /// Only transient stake account exists, when a transient stake is
  521. /// deactivating during validator removal
  522. DeactivatingTransient,
  523. /// No more validator stake accounts exist, entry ready for removal during
  524. /// `UpdateStakePoolBalance`
  525. ReadyForRemoval,
  526. }
  527. #[error_code]
  528. pub enum StakePoolError {
  529. // 0.
  530. /// The account cannot be initialized because it is already being used.
  531. #[msg("AlreadyInUse")]
  532. AlreadyInUse,
  533. /// The program address provided doesn't match the value generated by the program.
  534. #[msg("InvalidProgramAddress")]
  535. InvalidProgramAddress,
  536. /// The stake pool state is invalid.
  537. #[msg("InvalidState")]
  538. InvalidState,
  539. /// The calculation failed.
  540. #[msg("CalculationFailure")]
  541. CalculationFailure,
  542. /// Stake pool fee > 1.
  543. #[msg("FeeTooHigh")]
  544. FeeTooHigh,
  545. // 5.
  546. /// Token account is associated with the wrong mint.
  547. #[msg("WrongAccountMint")]
  548. WrongAccountMint,
  549. /// Wrong pool manager account.
  550. #[msg("WrongManager")]
  551. WrongManager,
  552. /// Required signature is missing.
  553. #[msg("SignatureMissing")]
  554. SignatureMissing,
  555. /// Invalid validator stake list account.
  556. #[msg("InvalidValidatorStakeList")]
  557. InvalidValidatorStakeList,
  558. /// Invalid manager fee account.
  559. #[msg("InvalidFeeAccount")]
  560. InvalidFeeAccount,
  561. // 10.
  562. /// Specified pool mint account is wrong.
  563. #[msg("WrongPoolMint")]
  564. WrongPoolMint,
  565. /// Stake account is not in the state expected by the program.
  566. #[msg("WrongStakeState")]
  567. WrongStakeState,
  568. /// User stake is not active
  569. #[msg("UserStakeNotActive")]
  570. UserStakeNotActive,
  571. /// Stake account voting for this validator already exists in the pool.
  572. #[msg("ValidatorAlreadyAdded")]
  573. ValidatorAlreadyAdded,
  574. /// Stake account for this validator not found in the pool.
  575. #[msg("ValidatorNotFound")]
  576. ValidatorNotFound,
  577. // 15.
  578. /// Stake account address not properly derived from the validator address.
  579. #[msg("InvalidStakeAccountAddress")]
  580. InvalidStakeAccountAddress,
  581. /// Identify validator stake accounts with old balances and update them.
  582. #[msg("StakeListOutOfDate")]
  583. StakeListOutOfDate,
  584. /// First update old validator stake account balances and then pool stake balance.
  585. #[msg("StakeListAndPoolOutOfDate")]
  586. StakeListAndPoolOutOfDate,
  587. /// Validator stake account is not found in the list storage.
  588. #[msg("UnknownValidatorStakeAccount")]
  589. UnknownValidatorStakeAccount,
  590. /// Wrong minting authority set for mint pool account
  591. #[msg("WrongMintingAuthority")]
  592. WrongMintingAuthority,
  593. // 20.
  594. /// The size of the given validator stake list does match the expected amount
  595. #[msg("UnexpectedValidatorListAccountSize")]
  596. UnexpectedValidatorListAccountSize,
  597. /// Wrong pool staker account.
  598. #[msg("WrongStaker")]
  599. WrongStaker,
  600. /// Pool token supply is not zero on initialization
  601. #[msg("NonZeroPoolTokenSupply")]
  602. NonZeroPoolTokenSupply,
  603. /// The lamports in the validator stake account is not equal to the minimum
  604. #[msg("StakeLamportsNotEqualToMinimum")]
  605. StakeLamportsNotEqualToMinimum,
  606. /// The provided deposit stake account is not delegated to the preferred deposit vote account
  607. #[msg("IncorrectDepositVoteAddress")]
  608. IncorrectDepositVoteAddress,
  609. // 25.
  610. /// The provided withdraw stake account is not the preferred deposit vote account
  611. #[msg("IncorrectWithdrawVoteAddress")]
  612. IncorrectWithdrawVoteAddress,
  613. /// The mint has an invalid freeze authority
  614. #[msg("InvalidMintFreezeAuthority")]
  615. InvalidMintFreezeAuthority,
  616. /// Proposed fee increase exceeds stipulated ratio
  617. #[msg("FeeIncreaseTooHigh")]
  618. FeeIncreaseTooHigh,
  619. /// Not enough pool tokens provided to withdraw stake with one lamport
  620. #[msg("WithdrawalTooSmall")]
  621. WithdrawalTooSmall,
  622. /// Not enough lamports provided for deposit to result in one pool token
  623. #[msg("DepositTooSmall")]
  624. DepositTooSmall,
  625. // 30.
  626. /// Provided stake deposit authority does not match the program's
  627. #[msg("InvalidStakeDepositAuthority")]
  628. InvalidStakeDepositAuthority,
  629. /// Provided sol deposit authority does not match the program's
  630. #[msg("InvalidSolDepositAuthority")]
  631. InvalidSolDepositAuthority,
  632. /// Provided preferred validator is invalid
  633. #[msg("InvalidPreferredValidator")]
  634. InvalidPreferredValidator,
  635. /// Provided validator stake account already has a transient stake account in use
  636. #[msg("TransientAccountInUse")]
  637. TransientAccountInUse,
  638. /// Provided sol withdraw authority does not match the program's
  639. #[msg("InvalidSolWithdrawAuthority")]
  640. InvalidSolWithdrawAuthority,
  641. // 35.
  642. /// Too much SOL withdrawn from the stake pool's reserve account
  643. #[msg("SolWithdrawalTooLarge")]
  644. SolWithdrawalTooLarge,
  645. /// Provided metadata account does not match metadata account derived for pool mint
  646. #[msg("InvalidMetadataAccount")]
  647. InvalidMetadataAccount,
  648. }
  649. #[derive(AnchorSerialize, AnchorDeserialize)]
  650. pub enum PreferredValidatorType {
  651. /// Set preferred validator for deposits
  652. Deposit,
  653. /// Set preferred validator for withdraws
  654. Withdraw,
  655. }
  656. #[derive(AnchorSerialize, AnchorDeserialize)]
  657. pub enum FeeType {
  658. /// Referral fees for SOL deposits
  659. SolReferral(u8),
  660. /// Referral fees for stake deposits
  661. StakeReferral(u8),
  662. /// Management fee paid per epoch
  663. Epoch(Fee),
  664. /// Stake withdrawal fee
  665. StakeWithdrawal(Fee),
  666. /// Deposit fee for SOL deposits
  667. SolDeposit(Fee),
  668. /// Deposit fee for stake deposits
  669. StakeDeposit(Fee),
  670. /// SOL withdrawal fee
  671. SolWithdrawal(Fee),
  672. }
  673. #[derive(AnchorSerialize, AnchorDeserialize)]
  674. pub enum FundingType {
  675. /// Sets the stake deposit authority
  676. StakeDeposit,
  677. /// Sets the SOL deposit authority
  678. SolDeposit,
  679. /// Sets the SOL withdraw authority
  680. SolWithdraw,
  681. }