1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492
pub use crate::processor::{
activate_stake_pool, admin_freeze, admin_mint, change_central_state_authority,
change_inflation, change_pool_minimum, change_pool_multiplier, claim_bond, claim_bond_rewards,
claim_pool_rewards, claim_rewards, close_stake_account, close_stake_pool, crank, create_bond,
create_central_state, create_stake_account, create_stake_pool, edit_metadata, sign_bond, stake,
unlock_bond_tokens, unstake,
};
use bonfida_utils::InstructionsAccount;
use borsh::{BorshDeserialize, BorshSerialize};
use num_derive::FromPrimitive;
use solana_program::{instruction::Instruction, pubkey::Pubkey};
#[allow(missing_docs)]
#[derive(BorshDeserialize, BorshSerialize, FromPrimitive)]
pub enum ProgramInstruction {
/// Create central state
///
/// | Index | Writable | Signer | Description |
/// | -------------------------------------------------------- |
/// | 0 | ✅ | ❌ | The central state account |
/// | 1 | ❌ | ❌ | The system program account |
/// | 2 | ✅ | ✅ | The fee payer account |
/// | 3 | ❌ | ❌ | The mint of the ACCESS token |
CreateCentralState,
/// Create stake pool
///
/// | Index | Writable | Signer | Description |
/// | -------------------------------------------------------- |
/// | 0 | ✅ | ❌ | The stake pool account |
/// | 1 | ❌ | ❌ | The system program account |
/// | 2 | ✅ | ✅ | The fee payer account |
/// | 3 | ❌ | ❌ | The stake pool vault account |
CreateStakePool,
/// Activate a stake pool
///
/// | Index | Writable | Signer | Description |
/// | ------------------------------------------------------------ |
/// | 0 | ❌ | ✅ | The central state authority |
/// | 1 | ✅ | ❌ | The stake pool to activate |
/// | 2 | ❌ | ❌ | The account of the central state |
ActivateStakePool,
/// Create stake account
///
/// | Index | Writable | Signer | Description |
/// | ------------------------------------------------------ |
/// | 0 | ✅ | ❌ | The stake account |
/// | 1 | ❌ | ❌ | The system program account |
/// | 2 | ❌ | ❌ | The stake pool account |
/// | 3 | ✅ | ✅ | The fee payer account |
CreateStakeAccount,
/// Stake
///
/// | Index | Writable | Signer | Description |
/// | --------------------------------------------------------------------------------------- |
/// | 0 | ✅ | ❌ | The central state account |
/// | 1 | ✅ | ❌ | The stake account |
/// | 2 | ✅ | ❌ | The stake pool account |
/// | 3 | ❌ | ✅ | The owner of the stake account |
/// | 4 | ✅ | ❌ | The source account of the stake tokens |
/// | 5 | ❌ | ❌ | The SPL token program account |
/// | 6 | ✅ | ❌ | The stake pool vault account |
/// | 7 | ✅ | ❌ | The stake fee account |
/// | 8 | ❌ | ❌ | Optional bond account to be able to stake under the minimum |
Stake,
/// Unstake
///
/// | Index | Writable | Signer | Description |
/// | --------------------------------------------------------------------------------------- |
/// | 0 | ✅ | ❌ | The central state account |
/// | 1 | ✅ | ❌ | The stake account |
/// | 2 | ✅ | ❌ | The stake pool account |
/// | 3 | ❌ | ✅ | The owner of the stake account |
/// | 4 | ✅ | ❌ | The destination of the staked tokens |
/// | 5 | ❌ | ❌ | The SPL token program account |
/// | 6 | ✅ | ❌ | The stake pool vault |
/// | 7 | ❌ | ❌ | Optional bond account to be able to stake under the minimum |
Unstake,
/// Claim rewards of a stake pool
/// This instruction is used by stake pool owner for claiming their staking rewards
///
/// | Index | Writable | Signer | Description |
/// | ---------------------------------------------------------------- |
/// | 0 | ✅ | ❌ | The stake pool account |
/// | 1 | ❌ | ✅ | The stake pool owner account |
/// | 2 | ✅ | ❌ | The rewards destination |
/// | 3 | ❌ | ❌ | The central state account |
/// | 4 | ✅ | ❌ | The mint address of the ACCESS token |
/// | 5 | ❌ | ❌ | The SPL token program account |
ClaimPoolRewards,
/// Claim rewards of a stake account
/// This instruction can be used by stakers to claim their staking rewards
///
/// | Index | Writable | Signer | Description |
/// | ---------------------------------------------------------------- |
/// | 0 | ✅ | ❌ | The stake pool account |
/// | 1 | ✅ | ❌ | The stake account |
/// | 2 | ❌ | ✅ | The owner of the stake account |
/// | 3 | ✅ | ❌ | The rewards destination |
/// | 4 | ❌ | ❌ | The central state account |
/// | 5 | ✅ | ❌ | The mint address of the ACCESS token |
/// | 6 | ❌ | ❌ | The SPL token program account |
ClaimRewards,
/// Permissionless crank to update the stake pool rewards
/// This instructions updates the circular buffer with the pool balances multiplied by the current inflation
///
/// | Index | Writable | Signer | Description |
/// | ------------------------------------------------------------ |
/// | 0 | ✅ | ❌ | The stake pool account |
/// | 1 | ✅ | ❌ | The account of the central state |
Crank,
/// Close a stake pool
/// This instruction can be used to close an empty stake pool and collect the lamports
///
/// | Index | Writable | Signer | Description |
/// | --------------------------------------------------------- |
/// | 0 | ✅ | ❌ | The account of the stake pool |
/// | 1 | ❌ | ❌ | Pool vault |
/// | 2 | ✅ | ✅ | The owner of the stake pool |
CloseStakePool,
/// Close a stake account
/// This instruction can be used to close an empty stake account and collect the lamports
///
/// | Index | Writable | Signer | Description |
/// | ---------------------------------------------------------- |
/// | 0 | ✅ | ❌ | The stake account |
/// | 1 | ✅ | ✅ | The owner of the stake account |
CloseStakeAccount,
/// Change central state inflation
///
/// | Index | Writable | Signer | Description |
/// | ---------------------------------------------------------------------- |
/// | 0 | ✅ | ❌ | The account of the central state |
/// | 1 | ❌ | ✅ | The account of the central state authority |
ChangeInflation,
/// Create a bond
/// This instruction can be used by authorized sellers to create a bond
///
/// | Index | Writable | Signer | Description |
/// | ------------------------------------------------------ |
/// | 0 | ✅ | ✅ | The bond seller account |
/// | 1 | ✅ | ❌ | The bond account |
/// | 2 | ❌ | ❌ | |
/// | 3 | ❌ | ❌ | The system program account |
/// | 4 | ✅ | ✅ | The fee account |
CreateBond,
/// Sign a bond
/// This instruction is used by authorized sellers to approve the creation of a bond
///
/// | Index | Writable | Signer | Description |
/// | --------------------------------------- |
/// | 0 | ❌ | ✅ | |
/// | 1 | ✅ | ❌ | |
SignBond,
/// Unlock ACCESS tokens bought through a bond account
/// When tokens are unlocked they are withdrawn from the pool and are not considered staked anymore
///
/// | Index | Writable | Signer | Description |
/// | ------------------------------------------------------------ |
/// | 0 | ✅ | ❌ | The bond account |
/// | 1 | ❌ | ✅ | The account of the bond owner |
/// | 2 | ❌ | ❌ | The ACCESS mint token |
/// | 3 | ✅ | ❌ | The ACCESS token destination |
/// | 4 | ✅ | ❌ | The account of the central state |
/// | 5 | ✅ | ❌ | The account of the staking pool |
/// | 6 | ✅ | ❌ | The vault of the staking pool |
/// | 7 | ❌ | ❌ | The SPL token program account |
UnlockBondTokens,
/// Claim bond
/// This instruction allows a buyer to claim a bond once it has been signed by enough DAO members.
///
/// | Index | Writable | Signer | Description |
/// | ---------------------------------------------------------------------------- |
/// | 0 | ✅ | ❌ | The bond account |
/// | 1 | ❌ | ✅ | The account of the bond buyer |
/// | 2 | ✅ | ❌ | The token account used to purchase the bond |
/// | 3 | ✅ | ❌ | The token account where the sell proceed is sent |
/// | 4 | ✅ | ❌ | The stake pool account |
/// | 5 | ✅ | ❌ | The mint of the ACCESS token |
/// | 6 | ✅ | ❌ | The vault of the stake pool |
/// | 7 | ✅ | ❌ | The central state account |
/// | 8 | ❌ | ❌ | The SPL token program account |
ClaimBond,
/// Claim bond rewards
/// This Instruction allows bond owners to claim their staking rewards
///
/// | Index | Writable | Signer | Description |
/// | ---------------------------------------------------------------- |
/// | 0 | ✅ | ❌ | The stake pool account |
/// | 1 | ✅ | ❌ | The bond account |
/// | 2 | ❌ | ✅ | The bond account owner |
/// | 3 | ✅ | ❌ | The rewards destination |
/// | 4 | ❌ | ❌ | The central state account |
/// | 5 | ✅ | ❌ | The mint address of the ACCESS token |
/// | 6 | ❌ | ❌ | The SPL token program account |
ClaimBondRewards,
/// Change the minimum stakeable amount of a pool
/// This instruction allows a pool owner to adjust the price of its subscription for new joiners without impacting people who already subscribed
///
/// | Index | Writable | Signer | Description |
/// | -------------------------------------------------------- |
/// | 0 | ✅ | ❌ | The stake pool account |
/// | 1 | ❌ | ✅ | The stake pool owner account |
ChangePoolMinimum,
/// Allows central state authority to mint ACCESS tokens
///
/// | Index | Writable | Signer | Description |
/// | ------------------------------------------------------------ |
/// | 0 | ❌ | ✅ | The central state authority |
/// | 1 | ✅ | ❌ | The ACCESS mint token |
/// | 2 | ✅ | ❌ | The ACCESS token destination |
/// | 3 | ❌ | ❌ | The account of the central state |
/// | 4 | ❌ | ❌ | The SPL token program account |
AdminMint,
/// Freeze and unfreeze a program account
/// This admin instruction can be dangereous 💀
///
/// | Index | Writable | Signer | Description |
/// | --------------------------------------------------------------- |
/// | 0 | ❌ | ✅ | The central state authority |
/// | 1 | ✅ | ❌ | The account to freeze (or unfreeze) |
/// | 2 | ❌ | ❌ | The account of the central state |
AdminFreeze,
///
/// | Index | Writable | Signer | Description |
/// | -------------------------------------------------------- |
/// | 0 | ✅ | ❌ | The stake pool account |
/// | 1 | ❌ | ✅ | The stake pool owner account |
ChangePoolMultiplier,
/// Change central state authority
///
/// | Index | Writable | Signer | Description |
/// | ---------------------------------------------------------------------- |
/// | 0 | ✅ | ❌ | The account of the central state |
/// | 1 | ❌ | ✅ | The account of the central state authority |
ChangeCentralStateAuthority,
/// Edit metadata
///
/// | Index | Writable | Signer | Description |
/// | ---------------------------------------------------------------------- |
/// | 0 | ❌ | ❌ | The central state account |
/// | 1 | ❌ | ✅ | The account of the central state authority |
/// | 2 | ✅ | ❌ | The metadata account |
/// | 3 | ❌ | ❌ | The metadata program account |
EditMetadata,
}
#[allow(missing_docs)]
pub fn create_central_state(
program_id: Pubkey,
accounts: create_central_state::Accounts<Pubkey>,
params: create_central_state::Params,
) -> Instruction {
accounts.get_instruction(
program_id,
ProgramInstruction::CreateCentralState as u8,
params,
)
}
#[allow(missing_docs)]
pub fn create_stake_pool(
program_id: Pubkey,
accounts: create_stake_pool::Accounts<Pubkey>,
params: create_stake_pool::Params,
) -> Instruction {
accounts.get_instruction(
program_id,
ProgramInstruction::CreateStakePool as u8,
params,
)
}
#[allow(missing_docs)]
pub fn create_stake_account(
program_id: Pubkey,
accounts: create_stake_account::Accounts<Pubkey>,
params: create_stake_account::Params,
) -> Instruction {
accounts.get_instruction(
program_id,
ProgramInstruction::CreateStakeAccount as u8,
params,
)
}
#[allow(missing_docs)]
pub fn stake(
program_id: Pubkey,
accounts: stake::Accounts<Pubkey>,
params: stake::Params,
) -> Instruction {
accounts.get_instruction(program_id, ProgramInstruction::Stake as u8, params)
}
#[allow(missing_docs)]
pub fn unstake(
program_id: Pubkey,
accounts: unstake::Accounts<Pubkey>,
params: unstake::Params,
) -> Instruction {
accounts.get_instruction(program_id, ProgramInstruction::Unstake as u8, params)
}
#[allow(missing_docs)]
pub fn claim_pool_rewards(
program_id: Pubkey,
accounts: claim_pool_rewards::Accounts<Pubkey>,
params: claim_pool_rewards::Params,
owner_must_sign: bool,
) -> Instruction {
let mut ix = accounts.get_instruction(
program_id,
ProgramInstruction::ClaimPoolRewards as u8,
params,
);
if let Some(acc) = ix.accounts.get_mut(1) {
acc.is_signer = owner_must_sign
}
ix
}
#[allow(missing_docs)]
pub fn claim_rewards(
program_id: Pubkey,
accounts: claim_rewards::Accounts<Pubkey>,
params: claim_rewards::Params,
owner_must_sign: bool,
) -> Instruction {
let mut ix =
accounts.get_instruction(program_id, ProgramInstruction::ClaimRewards as u8, params);
if let Some(acc) = ix.accounts.get_mut(2) {
acc.is_signer = owner_must_sign
}
ix
}
#[allow(missing_docs)]
pub fn crank(
program_id: Pubkey,
accounts: crank::Accounts<Pubkey>,
params: crank::Params,
) -> Instruction {
accounts.get_instruction(program_id, ProgramInstruction::Crank as u8, params)
}
#[allow(missing_docs)]
pub fn close_stake_pool(
program_id: Pubkey,
accounts: close_stake_pool::Accounts<Pubkey>,
params: close_stake_pool::Params,
) -> Instruction {
accounts.get_instruction(program_id, ProgramInstruction::CloseStakePool as u8, params)
}
#[allow(missing_docs)]
pub fn close_stake_account(
program_id: Pubkey,
accounts: close_stake_account::Accounts<Pubkey>,
params: close_stake_account::Params,
) -> Instruction {
accounts.get_instruction(
program_id,
ProgramInstruction::CloseStakeAccount as u8,
params,
)
}
#[allow(missing_docs)]
pub fn change_inflation(
program_id: Pubkey,
accounts: change_inflation::Accounts<Pubkey>,
params: change_inflation::Params,
) -> Instruction {
accounts.get_instruction(
program_id,
ProgramInstruction::ChangeInflation as u8,
params,
)
}
#[allow(missing_docs)]
pub fn create_bond(
program_id: Pubkey,
accounts: create_bond::Accounts<Pubkey>,
params: create_bond::Params,
) -> Instruction {
accounts.get_instruction(program_id, ProgramInstruction::CreateBond as u8, params)
}
#[allow(missing_docs)]
pub fn sign_bond(
program_id: Pubkey,
accounts: sign_bond::Accounts<Pubkey>,
params: sign_bond::Params,
) -> Instruction {
accounts.get_instruction(program_id, ProgramInstruction::SignBond as u8, params)
}
#[allow(missing_docs)]
pub fn unlock_bond_tokens(
program_id: Pubkey,
accounts: unlock_bond_tokens::Accounts<Pubkey>,
params: unlock_bond_tokens::Params,
) -> Instruction {
accounts.get_instruction(
program_id,
ProgramInstruction::UnlockBondTokens as u8,
params,
)
}
#[allow(missing_docs)]
pub fn claim_bond(
program_id: Pubkey,
accounts: claim_bond::Accounts<Pubkey>,
params: claim_bond::Params,
) -> Instruction {
accounts.get_instruction(program_id, ProgramInstruction::ClaimBond as u8, params)
}
#[allow(missing_docs)]
pub fn claim_bond_rewards(
program_id: Pubkey,
accounts: claim_bond_rewards::Accounts<Pubkey>,
params: claim_bond_rewards::Params,
owner_must_sign: bool,
) -> Instruction {
let mut ix = accounts.get_instruction(
program_id,
ProgramInstruction::ClaimBondRewards as u8,
params,
);
if let Some(acc) = ix.accounts.get_mut(2) {
acc.is_signer = owner_must_sign
}
ix
}
#[allow(missing_docs)]
pub fn change_pool_minimum(
program_id: Pubkey,
accounts: change_pool_minimum::Accounts<Pubkey>,
params: change_pool_minimum::Params,
) -> Instruction {
accounts.get_instruction(
program_id,
ProgramInstruction::ChangePoolMinimum as u8,
params,
)
}
#[allow(missing_docs)]
pub fn admin_mint(
program_id: Pubkey,
accounts: admin_mint::Accounts<Pubkey>,
params: admin_mint::Params,
) -> Instruction {
accounts.get_instruction(program_id, ProgramInstruction::AdminMint as u8, params)
}
#[allow(missing_docs)]
pub fn admin_freeze(
program_id: Pubkey,
accounts: admin_freeze::Accounts<Pubkey>,
params: admin_freeze::Params,
) -> Instruction {
accounts.get_instruction(program_id, ProgramInstruction::AdminFreeze as u8, params)
}
#[allow(missing_docs)]
pub fn activate_stake_pool(
program_id: Pubkey,
accounts: activate_stake_pool::Accounts<Pubkey>,
params: activate_stake_pool::Params,
) -> Instruction {
accounts.get_instruction(
program_id,
ProgramInstruction::ActivateStakePool as u8,
params,
)
}
#[allow(missing_docs)]
pub fn change_pool_multiplier(
program_id: Pubkey,
accounts: change_pool_multiplier::Accounts<Pubkey>,
params: change_pool_multiplier::Params,
) -> Instruction {
accounts.get_instruction(
program_id,
ProgramInstruction::ChangePoolMultiplier as u8,
params,
)
}
#[allow(missing_docs)]
pub fn change_central_state_authority(
program_id: Pubkey,
accounts: change_central_state_authority::Accounts<Pubkey>,
params: change_central_state_authority::Params,
) -> Instruction {
accounts.get_instruction(
program_id,
ProgramInstruction::ChangeCentralStateAuthority as u8,
params,
)
}
#[allow(missing_docs)]
pub fn edit_metadata(
program_id: Pubkey,
accounts: edit_metadata::Accounts<Pubkey>,
params: edit_metadata::Params,
) -> Instruction {
accounts.get_instruction(program_id, ProgramInstruction::EditMetadata as u8, params)
}