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
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
use bonfida_utils::{BorshSize, InstructionsAccount};
use borsh::{BorshDeserialize, BorshSerialize};
use num_derive::FromPrimitive;
use solana_program::{instruction::Instruction, pubkey::Pubkey};

pub use crate::processor::{
    activate_stake_pool, add_to_bond_v2, admin_change_freeze_authority, admin_freeze, admin_mint,
    admin_program_freeze, admin_renounce, admin_set_protocol_fee, admin_setup_fee_split,
    change_central_state_authority, change_inflation, change_pool_minimum, change_pool_multiplier, claim_bond,
    claim_bond_rewards, claim_bond_v2_rewards, claim_pool_rewards, claim_rewards,
    close_stake_account, close_stake_pool, crank, create_bond, create_bond_v2,
    create_central_state, create_stake_account, create_stake_pool, distribute_fees,
    edit_metadata, migrate_central_state_v2, sign_bond, stake, unlock_bond_tokens, unlock_bond_v2,
    unstake, create_royalty_account, close_royalty_account
};

// todo regenerate
#[allow(missing_docs)]
#[derive(BorshDeserialize, BorshSerialize, BorshSize, FromPrimitive, Copy, Clone)]
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 |
    /// | 4     | ❌        | ❌      | The central state account    |
    CreateStakePool,
    /// Activate a stake pool
    ///
    /// | Index | Writable | Signer | Description                |
    /// | ------------------------------------------------------ |
    /// | 0     | ✅        | ❌      | The stake pool to activate |
    /// | 1     | ❌        | ❌      | The central state account  |
    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      |
    /// | 4     | ❌        | ❌      | The central state 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 central state ATA                  |
    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                 |
    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 ACS 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 central state account |
    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   |
    /// | 3     | ❌        | ❌      | The central state account     |
    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 |
    /// | 2     | ❌        | ❌      | The central state account      |
    CloseStakeAccount,
    /// Change central state inflation
    ///
    /// | Index | Writable | Signer | Description                          |
    /// | ---------------------------------------------------------------- |
    /// | 0     | ✅        | ❌      | The central state account            |
    /// | 1     | ❌        | ✅      | The central state account authority  |
    /// | 2     | ❌        | ❌      | The mint address of the ACCESS token |
    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            |
    /// | 5     | ❌        | ❌      | The central state 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     | ✅        | ❌      |             |
    /// | 2     | ❌        | ❌      |             |
    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 central state account       |
    /// | 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 |
    /// | 2     | ❌        | ❌      | The central state 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 central state account     |
    /// | 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 central state account           |
    AdminFreeze,
    ///
    /// | Index | Writable | Signer | Description                  |
    /// | -------------------------------------------------------- |
    /// | 0     | ✅        | ❌      | The stake pool account       |
    /// | 1     | ❌        | ✅      | The stake pool owner account |
    /// | 2     | ❌        | ❌      | The central state account    |
    ChangePoolMultiplier,
    /// Change central state authority
    ///
    /// | Index | Writable | Signer | Description                         |
    /// | --------------------------------------------------------------- |
    /// | 0     | ✅        | ❌      | The central state account           |
    /// | 1     | ❌        | ✅      | The central state account authority |
    ChangeCentralStateAuthority,
    /// Edit metadata
    ///
    /// | Index | Writable | Signer | Description                         |
    /// | --------------------------------------------------------------- |
    /// | 0     | ❌        | ❌      | The central state account           |
    /// | 1     | ❌        | ✅      | The central state account authority |
    /// | 2     | ✅        | ❌      | The metadata account                |
    /// | 3     | ❌        | ❌      | The metadata program account        |
    EditMetadata,
    /// Create a Bond V2
    ///
    /// | Index | Writable | Signer | Description                       |
    /// | ------------------------------------------------------------- |
    /// | 0     | ✅        | ✅      | The fee account                   |
    /// | 1     | ✅        | ✅      | The bond seller account           |
    /// | 2     | ✅        | ❌      | From ATA                          |
    /// | 3     | ❌        | ❌      | The bond recipient wallet         |
    /// | 4     | ✅        | ❌      | The bond account                  |
    /// | 5     | ✅        | ❌      | Central state                     |
    /// | 6     | ✅        | ❌      | The vault of the central state    |
    /// | 7     | ✅        | ❌      | The pool account                  |
    /// | 8     | ✅        | ❌      | The vault of the pool             |
    /// | 9     | ✅        | ❌      | The mint address of the ACS token |
    /// | 10    | ❌        | ❌      | The SPL token program account     |
    /// | 11    | ❌        | ❌      | The system program account        |
    CreateBondV2,
    /// Add more tokens to an existing Bond V2
    ///
    /// | Index | Writable | Signer | Description                       |
    /// | ------------------------------------------------------------- |
    /// | 0     | ✅        | ✅      | The bond seller account           |
    /// | 1     | ✅        | ❌      | From ATA                          |
    /// | 2     | ✅        | ❌      | The bond account                  |
    /// | 3     | ✅        | ❌      | Central state                     |
    /// | 4     | ✅        | ❌      | The vault of the central state    |
    /// | 5     | ✅        | ❌      | The pool account                  |
    /// | 6     | ✅        | ❌      | The vault of the pool             |
    /// | 7     | ✅        | ❌      | The mint address of the ACS token |
    /// | 8     | ❌        | ❌      | The SPL token program account     |
    /// | 9     | ❌        | ❌      | The system program account        |
    AddToBondV2,
    /// Claim rewards of a bond V2
    ///
    /// | Index | Writable | Signer | Description                       |
    /// | ------------------------------------------------------------- |
    /// | 0     | ✅        | ❌      | The stake pool account            |
    /// | 1     | ✅        | ❌      | The Bond V2 account               |
    /// | 2     | ❌        | ✅      | The owner of the Bond V2 account  |
    /// | 3     | ✅        | ❌      | The rewards destination           |
    /// | 4     | ❌        | ❌      | The central state account         |
    /// | 5     | ✅        | ❌      | The mint address of the ACS token |
    /// | 6     | ❌        | ❌      | The SPL token program account     |
    ClaimBondV2Rewards,
    /// Unlock bond v2
    ///
    /// | Index | Writable | Signer | Description                          |
    /// | ---------------------------------------------------------------- |
    /// | 0     | ✅        | ❌      | The central state account            |
    /// | 1     | ✅        | ❌      | The bond account                     |
    /// | 2     | ❌        | ✅      | The owner of the bond V2 account     |
    /// | 3     | ✅        | ❌      | The destination of the locked tokens |
    /// | 4     | ✅        | ❌      | The pool account                     |
    /// | 5     | ✅        | ❌      | The pool vault                       |
    /// | 6     | ❌        | ❌      | The SPL token program account        |
    UnlockBondV2,
    /// Setup fee split
    ///
    /// | Index | Writable | Signer | Description                 |
    /// | ------------------------------------------------------- |
    /// | 0     | ❌        | ✅      | The central state authority |
    /// | 1     | ✅        | ❌      | The central state account   |
    /// | 2     | ❌        | ❌      | The system program account  |
    AdminSetupFeeSplit,
    /// Distribute fees to the recipients
    ///
    /// | Index    | Writable | Signer | Description                                  |
    /// | --------------------------------------------------------------------------- |
    /// | 0        | ✅        | ❌      | The central state account                    |
    /// | 1        | ✅        | ❌      | The central state ATA                        |
    /// | 2        | ❌        | ❌      | The SPL token program account                |
    /// | 3        | ✅        | ❌      | The mint address of the ACS token            |
    /// | 4..4 + N | ✅        | ❌      | The token accounts to distribute the fees to |
    DistributeFees,
    /// Admin set protocol fee
    ///
    /// | Index | Writable | Signer | Description                 |
    /// | ------------------------------------------------------- |
    /// | 0     | ❌        | ✅      | The central state authority |
    /// | 1     | ✅        | ❌      | The central state account   |
    AdminSetProtocolFee,
    /// Migrate the central state to the v2 format
    ///
    /// | Index | Writable | Signer | Description                |
    /// | ------------------------------------------------------ |
    /// | 0     | ✅        | ❌      | The central state account  |
    /// | 1     | ❌        | ❌      | The system program account |
    /// | 2     | ✅        | ✅      | The fee payer account      |
    MigrateCentralStateV2,
    /// Admin program freeze instruction.
    ///
    /// | Index | Writable | Signer | Description                         |
    /// | --------------------------------------------------------------- |
    /// | 0     | ✅        | ❌      | The central state account           |
    /// | 1     | ❌        | ✅      | The central state account authority |
    AdminProgramFreeze,
    /// Admin renounce functionality
    ///
    /// | Index | Writable | Signer | Description                         |
    /// | --------------------------------------------------------------- |
    /// | 0     | ✅        | ❌      | The central state account           |
    /// | 1     | ❌        | ✅      | The central state account authority |
    AdminRenounce,
    /// Change freeze authority
    ///
    /// | Index | Writable | Signer | Description                         |
    /// | --------------------------------------------------------------- |
    /// | 0     | ✅        | ❌      | The central state account           |
    /// | 1     | ❌        | ✅      | The central state account authority |
    AdminChangeFreezeAuthority,
    // todo doc
    CreateRoyaltyAccount,
    CloseRoyaltyAccount,
}

#[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 create_bond_v2(
    program_id: Pubkey,
    accounts: create_bond_v2::Accounts<Pubkey>,
    params: create_bond_v2::Params,
) -> Instruction {
    accounts.get_instruction(program_id, ProgramInstruction::CreateBondV2 as u8, params)
}

#[allow(missing_docs)]
pub fn add_to_bond_v2(
    program_id: Pubkey,
    accounts: add_to_bond_v2::Accounts<Pubkey>,
    params: add_to_bond_v2::Params,
) -> Instruction {
    accounts.get_instruction(program_id, ProgramInstruction::AddToBondV2 as u8, params)
}

#[allow(missing_docs)]
pub fn claim_bond_v2_rewards(
    program_id: Pubkey,
    accounts: claim_bond_v2_rewards::Accounts<Pubkey>,
    params: claim_bond_v2_rewards::Params,
    owner_must_sign: bool,
) -> Instruction {
    let mut ix = accounts.get_instruction(
        program_id,
        ProgramInstruction::ClaimBondV2Rewards as u8,
        params,
    );
    if let Some(acc) = ix.accounts.get_mut(2) {
        acc.is_signer = owner_must_sign
    }
    ix
}

#[allow(missing_docs)]
pub fn unlock_bond_v2(
    program_id: Pubkey,
    accounts: unlock_bond_v2::Accounts<Pubkey>,
    params: unlock_bond_v2::Params,
) -> Instruction {
    accounts.get_instruction(program_id, ProgramInstruction::UnlockBondV2 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)
}

#[allow(missing_docs)]
pub fn admin_setup_fee_split(
    program_id: Pubkey,
    accounts: admin_setup_fee_split::Accounts<Pubkey>,
    params: admin_setup_fee_split::Params,
) -> Instruction {
    accounts.get_instruction(
        program_id,
        ProgramInstruction::AdminSetupFeeSplit as u8,
        params,
    )
}

#[allow(missing_docs)]
pub fn distribute_fees(
    program_id: Pubkey,
    accounts: distribute_fees::Accounts<Pubkey>,
    params: distribute_fees::Params,
) -> Instruction {
    accounts.get_instruction(program_id, ProgramInstruction::DistributeFees as u8, params)
}

#[allow(missing_docs)]
pub fn admin_set_protocol_fee(
    program_id: Pubkey,
    accounts: admin_set_protocol_fee::Accounts<Pubkey>,
    params: admin_set_protocol_fee::Params,
) -> Instruction {
    accounts.get_instruction(
        program_id,
        ProgramInstruction::AdminSetProtocolFee as u8,
        params,
    )
}

#[allow(missing_docs)]
pub fn migrate_central_state_v2(
    program_id: Pubkey,
    accounts: migrate_central_state_v2::Accounts<Pubkey>,
    params: migrate_central_state_v2::Params,
) -> Instruction {
    accounts.get_instruction(
        program_id,
        ProgramInstruction::MigrateCentralStateV2 as u8,
        params,
    )
}

#[allow(missing_docs)]
pub fn admin_program_freeze(
    program_id: Pubkey,
    accounts: admin_program_freeze::Accounts<Pubkey>,
    params: admin_program_freeze::Params,
) -> Instruction {
    accounts.get_instruction(
        program_id,
        ProgramInstruction::AdminProgramFreeze as u8,
        params,
    )
}

#[allow(missing_docs)]
pub fn admin_renounce(
    program_id: Pubkey,
    accounts: admin_renounce::Accounts<Pubkey>,
    params: admin_renounce::Params,
) -> Instruction {
    accounts.get_instruction(program_id, ProgramInstruction::AdminRenounce as u8, params)
}

#[allow(missing_docs)]
pub fn admin_change_freeze_authority(
    program_id: Pubkey,
    accounts: admin_change_freeze_authority::Accounts<Pubkey>,
    params: admin_change_freeze_authority::Params,
) -> Instruction {
    accounts.get_instruction(
        program_id,
        ProgramInstruction::AdminChangeFreezeAuthority as u8,
        params,
    )
}

#[allow(missing_docs)]
pub fn create_royalty_account(
    program_id: Pubkey,
    accounts: create_royalty_account::Accounts<Pubkey>,
    params: create_royalty_account::Params,
) -> Instruction {
    accounts.get_instruction(
        program_id,
        ProgramInstruction::CreateRoyaltyAccount as u8,
        params,
    )
}

#[allow(missing_docs)]
pub fn close_royalty_account(
    program_id: Pubkey,
    accounts: close_royalty_account::Accounts<Pubkey>,
    params: close_royalty_account::Params,
) -> Instruction {
    accounts.get_instruction(
        program_id,
        ProgramInstruction::CloseRoyaltyAccount as u8,
        params,
    )
}