@streamflow/distributor 8.0.1-alpha.p287.54fe41f → 8.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
1
  import { PublicKey, TransactionInstruction, Connection, SystemProgram } from '@solana/web3.js';
2
2
  import '@solana/wallet-adapter-base';
3
3
  import { ICluster, ContractError, divCeilN, invariant, getNumberFromBN, getBN } from '@streamflow/common';
4
- import { signAndExecuteTransaction, buildSendThrottler, prepareBaseInstructions, getMintAndProgram, ata, prepareWrappedAccount, createAndEstimateTransaction, prepareTransaction, checkOrCreateAtaBatch, pk, unwrapExecutionParams } from '@streamflow/common/solana';
4
+ import { signAndExecuteTransaction, buildSendThrottler, prepareBaseInstructions, getMintAndProgram, ata, prepareWrappedAccount, prepareTransaction, checkOrCreateAtaBatch, pk } from '@streamflow/common/solana';
5
5
  import { Program } from '@coral-xyz/anchor';
6
- import * as borsh7 from '@coral-xyz/borsh';
6
+ import * as borsh8 from '@coral-xyz/borsh';
7
7
  import { Buffer as Buffer$1 } from 'buffer';
8
- import BN5 from 'bn.js';
8
+ import BN6 from 'bn.js';
9
9
  import { NATIVE_MINT, getTransferFeeConfig, ASSOCIATED_TOKEN_PROGRAM_ID, createTransferCheckedWithFeeInstruction, createTransferCheckedInstruction } from '@solana/spl-token';
10
10
  import bs58 from 'bs58';
11
11
 
@@ -99,21 +99,21 @@ var PROGRAM_ID_CLI = new PublicKey("MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N"
99
99
  var PROGRAM_ID = PROGRAM_ID_CLI;
100
100
 
101
101
  // solana/generated/instructions/newDistributor.ts
102
- var layout = borsh7.struct([
103
- borsh7.u64("version"),
104
- borsh7.array(borsh7.u8(), 32, "root"),
105
- borsh7.u64("maxTotalClaim"),
106
- borsh7.u64("maxNumNodes"),
107
- borsh7.u64("unlockPeriod"),
108
- borsh7.u64("startVestingTs"),
109
- borsh7.u64("endVestingTs"),
110
- borsh7.u64("clawbackStartTs"),
111
- borsh7.bool("claimsClosableByAdmin"),
112
- borsh7.option(borsh7.bool(), "canUpdateDuration"),
113
- borsh7.option(borsh7.u64(), "totalAmountUnlocked"),
114
- borsh7.option(borsh7.u64(), "totalAmountLocked"),
115
- borsh7.option(borsh7.bool(), "claimsClosableByClaimant"),
116
- borsh7.option(borsh7.u16(), "claimsLimit")
102
+ var layout = borsh8.struct([
103
+ borsh8.u64("version"),
104
+ borsh8.array(borsh8.u8(), 32, "root"),
105
+ borsh8.u64("maxTotalClaim"),
106
+ borsh8.u64("maxNumNodes"),
107
+ borsh8.u64("unlockPeriod"),
108
+ borsh8.u64("startVestingTs"),
109
+ borsh8.u64("endVestingTs"),
110
+ borsh8.u64("clawbackStartTs"),
111
+ borsh8.bool("claimsClosableByAdmin"),
112
+ borsh8.option(borsh8.bool(), "canUpdateDuration"),
113
+ borsh8.option(borsh8.u64(), "totalAmountUnlocked"),
114
+ borsh8.option(borsh8.u64(), "totalAmountLocked"),
115
+ borsh8.option(borsh8.bool(), "claimsClosableByClaimant"),
116
+ borsh8.option(borsh8.u16(), "claimsLimit")
117
117
  ]);
118
118
  function newDistributor(args, accounts, programId = PROGRAM_ID) {
119
119
  const keys = [
@@ -155,10 +155,10 @@ function newDistributor(args, accounts, programId = PROGRAM_ID) {
155
155
  const ix = new TransactionInstruction({ keys, programId, data });
156
156
  return ix;
157
157
  }
158
- var layout2 = borsh7.struct([
159
- borsh7.u64("amountUnlocked"),
160
- borsh7.u64("amountLocked"),
161
- borsh7.vec(borsh7.array(borsh7.u8(), 32), "proof")
158
+ var layout2 = borsh8.struct([
159
+ borsh8.u64("amountUnlocked"),
160
+ borsh8.u64("amountLocked"),
161
+ borsh8.vec(borsh8.array(borsh8.u8(), 32), "proof")
162
162
  ]);
163
163
  function newClaim(args, accounts, programId = PROGRAM_ID) {
164
164
  const keys = [
@@ -219,10 +219,10 @@ function clawback(accounts, programId = PROGRAM_ID) {
219
219
  const ix = new TransactionInstruction({ keys, programId, data });
220
220
  return ix;
221
221
  }
222
- var layout3 = borsh7.struct([
223
- borsh7.option(borsh7.u64(), "amountUnlocked"),
224
- borsh7.option(borsh7.u64(), "amountLocked"),
225
- borsh7.option(borsh7.vec(borsh7.array(borsh7.u8(), 32)), "proof")
222
+ var layout3 = borsh8.struct([
223
+ borsh8.option(borsh8.u64(), "amountUnlocked"),
224
+ borsh8.option(borsh8.u64(), "amountLocked"),
225
+ borsh8.option(borsh8.vec(borsh8.array(borsh8.u8(), 32)), "proof")
226
226
  ]);
227
227
  function closeClaim(args, accounts, programId = PROGRAM_ID) {
228
228
  const keys = [
@@ -271,1316 +271,6 @@ function setAdmin(accounts, programId = PROGRAM_ID) {
271
271
  return ix;
272
272
  }
273
273
 
274
- // solana/descriptor/idl/merkle_distributor.json
275
- var merkle_distributor_default = {
276
- address: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
277
- metadata: {
278
- name: "merkle_distributor",
279
- version: "1.5.0",
280
- spec: "0.1.0",
281
- description: "A Solana program for distributing tokens according to a Merkle root.",
282
- repository: "https://github.com/streamflow-finance/distributor"
283
- },
284
- instructions: [
285
- {
286
- name: "_expose_claim",
287
- discriminator: [103, 233, 83, 69, 115, 199, 128, 249],
288
- accounts: [
289
- {
290
- name: "distributor",
291
- docs: ["The [MerkleDistributor]."]
292
- },
293
- {
294
- name: "claim_status",
295
- docs: ["Claim Status PDA"],
296
- optional: true,
297
- pda: {
298
- seeds: [
299
- {
300
- kind: "const",
301
- value: [67, 108, 97, 105, 109, 83, 116, 97, 116, 117, 115]
302
- },
303
- {
304
- kind: "account",
305
- path: "claimant"
306
- },
307
- {
308
- kind: "account",
309
- path: "distributor"
310
- }
311
- ]
312
- }
313
- },
314
- {
315
- name: "compressed_claim_status",
316
- docs: ["Compress Claim Status PDA"],
317
- optional: true,
318
- pda: {
319
- seeds: [
320
- {
321
- kind: "const",
322
- value: [67, 108, 97, 105, 109, 83, 116, 97, 116, 117, 115]
323
- },
324
- {
325
- kind: "account",
326
- path: "claimant"
327
- },
328
- {
329
- kind: "account",
330
- path: "distributor"
331
- }
332
- ]
333
- }
334
- },
335
- {
336
- name: "claimant",
337
- docs: ["Who is claiming the tokens."],
338
- signer: true
339
- }
340
- ],
341
- args: []
342
- },
343
- {
344
- name: "claim_locked",
345
- discriminator: [34, 206, 181, 23, 11, 207, 147, 90],
346
- accounts: [
347
- {
348
- name: "distributor",
349
- docs: ["The [MerkleDistributor]."],
350
- writable: true
351
- },
352
- {
353
- name: "claim_status",
354
- writable: true,
355
- pda: {
356
- seeds: [
357
- {
358
- kind: "const",
359
- value: [67, 108, 97, 105, 109, 83, 116, 97, 116, 117, 115]
360
- },
361
- {
362
- kind: "account",
363
- path: "claimant"
364
- },
365
- {
366
- kind: "account",
367
- path: "distributor"
368
- }
369
- ]
370
- }
371
- },
372
- {
373
- name: "from",
374
- docs: ["Distributor ATA containing the tokens to distribute."],
375
- writable: true,
376
- pda: {
377
- seeds: [
378
- {
379
- kind: "account",
380
- path: "distributor"
381
- },
382
- {
383
- kind: "account",
384
- path: "token_program"
385
- },
386
- {
387
- kind: "account",
388
- path: "distributor.mint",
389
- account: "MerkleDistributor"
390
- }
391
- ],
392
- program: {
393
- kind: "const",
394
- value: [
395
- 140,
396
- 151,
397
- 37,
398
- 143,
399
- 78,
400
- 36,
401
- 137,
402
- 241,
403
- 187,
404
- 61,
405
- 16,
406
- 41,
407
- 20,
408
- 142,
409
- 13,
410
- 131,
411
- 11,
412
- 90,
413
- 19,
414
- 153,
415
- 218,
416
- 255,
417
- 16,
418
- 132,
419
- 4,
420
- 142,
421
- 123,
422
- 216,
423
- 219,
424
- 233,
425
- 248,
426
- 89
427
- ]
428
- }
429
- }
430
- },
431
- {
432
- name: "to",
433
- docs: [
434
- "Account to send the claimed tokens to.",
435
- "Claimant must sign the transaction and can only claim on behalf of themself"
436
- ],
437
- writable: true
438
- },
439
- {
440
- name: "claimant",
441
- docs: ["Who is claiming the tokens."],
442
- writable: true,
443
- signer: true
444
- },
445
- {
446
- name: "mint",
447
- docs: ["The mint to claim."],
448
- relations: ["distributor"]
449
- },
450
- {
451
- name: "token_program",
452
- docs: ["SPL [Token] program."]
453
- },
454
- {
455
- name: "event_authority",
456
- pda: {
457
- seeds: [
458
- {
459
- kind: "const",
460
- value: [95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121]
461
- }
462
- ]
463
- }
464
- },
465
- {
466
- name: "program"
467
- }
468
- ],
469
- args: []
470
- },
471
- {
472
- name: "clawback",
473
- discriminator: [111, 92, 142, 79, 33, 234, 82, 27],
474
- accounts: [
475
- {
476
- name: "distributor",
477
- docs: ["The [MerkleDistributor]."],
478
- writable: true
479
- },
480
- {
481
- name: "from",
482
- docs: ["Distributor ATA containing the tokens to distribute."],
483
- writable: true
484
- },
485
- {
486
- name: "to",
487
- docs: ["The Clawback token account."],
488
- writable: true
489
- },
490
- {
491
- name: "admin",
492
- docs: ["Only Admin can trigger the clawback of funds"],
493
- writable: true,
494
- signer: true
495
- },
496
- {
497
- name: "mint"
498
- },
499
- {
500
- name: "system_program",
501
- docs: ["The [System] program."],
502
- address: "11111111111111111111111111111111"
503
- },
504
- {
505
- name: "token_program",
506
- docs: ["SPL [Token] program."]
507
- }
508
- ],
509
- args: []
510
- },
511
- {
512
- name: "close_claim",
513
- discriminator: [42, 177, 165, 35, 213, 179, 211, 19],
514
- accounts: [
515
- {
516
- name: "distributor",
517
- docs: ["The [MerkleDistributor]."],
518
- writable: true
519
- },
520
- {
521
- name: "admin_or_claimant",
522
- docs: ["Admin signer"],
523
- writable: true,
524
- signer: true
525
- },
526
- {
527
- name: "claimant",
528
- writable: true
529
- },
530
- {
531
- name: "claim_status",
532
- writable: true,
533
- pda: {
534
- seeds: [
535
- {
536
- kind: "const",
537
- value: [67, 108, 97, 105, 109, 83, 116, 97, 116, 117, 115]
538
- },
539
- {
540
- kind: "account",
541
- path: "claimant"
542
- },
543
- {
544
- kind: "account",
545
- path: "distributor"
546
- }
547
- ]
548
- }
549
- },
550
- {
551
- name: "system_program",
552
- docs: ["The [System] program."],
553
- address: "11111111111111111111111111111111"
554
- },
555
- {
556
- name: "event_authority",
557
- pda: {
558
- seeds: [
559
- {
560
- kind: "const",
561
- value: [95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121]
562
- }
563
- ]
564
- }
565
- },
566
- {
567
- name: "program"
568
- }
569
- ],
570
- args: [
571
- {
572
- name: "amount_unlocked",
573
- type: {
574
- option: "u64"
575
- }
576
- },
577
- {
578
- name: "amount_locked",
579
- type: {
580
- option: "u64"
581
- }
582
- },
583
- {
584
- name: "proof",
585
- type: {
586
- option: {
587
- vec: {
588
- array: ["u8", 32]
589
- }
590
- }
591
- }
592
- }
593
- ]
594
- },
595
- {
596
- name: "compress_claim",
597
- discriminator: [219, 45, 247, 134, 71, 119, 125, 89],
598
- accounts: [
599
- {
600
- name: "distributor",
601
- docs: ["The [MerkleDistributor]."],
602
- writable: true
603
- },
604
- {
605
- name: "claim_status",
606
- writable: true,
607
- pda: {
608
- seeds: [
609
- {
610
- kind: "const",
611
- value: [67, 108, 97, 105, 109, 83, 116, 97, 116, 117, 115]
612
- },
613
- {
614
- kind: "account",
615
- path: "claimant"
616
- },
617
- {
618
- kind: "account",
619
- path: "distributor"
620
- }
621
- ]
622
- }
623
- },
624
- {
625
- name: "signer",
626
- docs: ["Signer account"],
627
- writable: true,
628
- signer: true
629
- },
630
- {
631
- name: "claimant"
632
- },
633
- {
634
- name: "system_program",
635
- docs: ["The [System] program."],
636
- address: "11111111111111111111111111111111"
637
- }
638
- ],
639
- args: []
640
- },
641
- {
642
- name: "new_claim",
643
- discriminator: [78, 177, 98, 123, 210, 21, 187, 83],
644
- accounts: [
645
- {
646
- name: "distributor",
647
- docs: ["The [MerkleDistributor]."],
648
- writable: true
649
- },
650
- {
651
- name: "claim_status",
652
- writable: true,
653
- pda: {
654
- seeds: [
655
- {
656
- kind: "const",
657
- value: [67, 108, 97, 105, 109, 83, 116, 97, 116, 117, 115]
658
- },
659
- {
660
- kind: "account",
661
- path: "claimant"
662
- },
663
- {
664
- kind: "account",
665
- path: "distributor"
666
- }
667
- ]
668
- }
669
- },
670
- {
671
- name: "from",
672
- docs: ["Distributor ATA containing the tokens to distribute."],
673
- writable: true,
674
- pda: {
675
- seeds: [
676
- {
677
- kind: "account",
678
- path: "distributor"
679
- },
680
- {
681
- kind: "account",
682
- path: "token_program"
683
- },
684
- {
685
- kind: "account",
686
- path: "distributor.mint",
687
- account: "MerkleDistributor"
688
- }
689
- ],
690
- program: {
691
- kind: "const",
692
- value: [
693
- 140,
694
- 151,
695
- 37,
696
- 143,
697
- 78,
698
- 36,
699
- 137,
700
- 241,
701
- 187,
702
- 61,
703
- 16,
704
- 41,
705
- 20,
706
- 142,
707
- 13,
708
- 131,
709
- 11,
710
- 90,
711
- 19,
712
- 153,
713
- 218,
714
- 255,
715
- 16,
716
- 132,
717
- 4,
718
- 142,
719
- 123,
720
- 216,
721
- 219,
722
- 233,
723
- 248,
724
- 89
725
- ]
726
- }
727
- }
728
- },
729
- {
730
- name: "to",
731
- docs: ["Account to send the claimed tokens to."],
732
- writable: true
733
- },
734
- {
735
- name: "claimant",
736
- docs: ["Who is claiming the tokens."],
737
- writable: true,
738
- signer: true
739
- },
740
- {
741
- name: "mint",
742
- docs: ["The mint to claim."],
743
- relations: ["distributor"]
744
- },
745
- {
746
- name: "token_program",
747
- docs: ["SPL [Token] program."]
748
- },
749
- {
750
- name: "system_program",
751
- docs: ["The [System] program."],
752
- address: "11111111111111111111111111111111"
753
- },
754
- {
755
- name: "event_authority",
756
- pda: {
757
- seeds: [
758
- {
759
- kind: "const",
760
- value: [95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121]
761
- }
762
- ]
763
- }
764
- },
765
- {
766
- name: "program"
767
- }
768
- ],
769
- args: [
770
- {
771
- name: "amount_unlocked",
772
- type: "u64"
773
- },
774
- {
775
- name: "amount_locked",
776
- type: "u64"
777
- },
778
- {
779
- name: "proof",
780
- type: {
781
- vec: {
782
- array: ["u8", 32]
783
- }
784
- }
785
- }
786
- ]
787
- },
788
- {
789
- name: "new_distributor",
790
- docs: [
791
- "READ THE FOLLOWING:",
792
- "",
793
- "This instruction is susceptible to frontrunning that could result in loss of funds if not handled properly.",
794
- "",
795
- "An attack could look like:",
796
- "- A legitimate user opens a new distributor.",
797
- "- Someone observes the call to this instruction.",
798
- "- They replace the clawback_receiver, admin, or time parameters with their own.",
799
- "",
800
- "One situation that could happen here is the attacker replaces the admin and clawback_receiver with their own",
801
- "and sets the clawback_start_ts with the minimal time allowed. After clawback_start_ts has elapsed,",
802
- "the attacker can steal all funds from the distributor to their own clawback_receiver account.",
803
- "",
804
- "HOW TO AVOID:",
805
- "- When you call into this instruction, ensure your transaction succeeds.",
806
- "- To be extra safe, after your transaction succeeds, read back the state of the created MerkleDistributor account and",
807
- "assert the parameters are what you expect, most importantly the clawback_receiver and admin.",
808
- "- If your transaction fails, double check the value on-chain matches what you expect."
809
- ],
810
- discriminator: [32, 139, 112, 171, 0, 2, 225, 155],
811
- accounts: [
812
- {
813
- name: "distributor",
814
- docs: ["[MerkleDistributor]."],
815
- writable: true,
816
- pda: {
817
- seeds: [
818
- {
819
- kind: "const",
820
- value: [77, 101, 114, 107, 108, 101, 68, 105, 115, 116, 114, 105, 98, 117, 116, 111, 114]
821
- },
822
- {
823
- kind: "account",
824
- path: "mint"
825
- },
826
- {
827
- kind: "arg",
828
- path: "version"
829
- }
830
- ]
831
- }
832
- },
833
- {
834
- name: "clawback_receiver",
835
- docs: ["Clawback receiver token account"],
836
- writable: true
837
- },
838
- {
839
- name: "mint",
840
- docs: ["The mint to distribute."]
841
- },
842
- {
843
- name: "token_vault",
844
- docs: ["Token vault"],
845
- writable: true,
846
- pda: {
847
- seeds: [
848
- {
849
- kind: "account",
850
- path: "distributor"
851
- },
852
- {
853
- kind: "account",
854
- path: "token_program"
855
- },
856
- {
857
- kind: "account",
858
- path: "mint"
859
- }
860
- ],
861
- program: {
862
- kind: "const",
863
- value: [
864
- 140,
865
- 151,
866
- 37,
867
- 143,
868
- 78,
869
- 36,
870
- 137,
871
- 241,
872
- 187,
873
- 61,
874
- 16,
875
- 41,
876
- 20,
877
- 142,
878
- 13,
879
- 131,
880
- 11,
881
- 90,
882
- 19,
883
- 153,
884
- 218,
885
- 255,
886
- 16,
887
- 132,
888
- 4,
889
- 142,
890
- 123,
891
- 216,
892
- 219,
893
- 233,
894
- 248,
895
- 89
896
- ]
897
- }
898
- }
899
- },
900
- {
901
- name: "admin",
902
- docs: [
903
- "Admin wallet, responsible for creating the distributor and paying for the transaction.",
904
- "Also has the authority to set the clawback receiver and change itself."
905
- ],
906
- writable: true,
907
- signer: true
908
- },
909
- {
910
- name: "system_program",
911
- docs: ["The [System] program."],
912
- address: "11111111111111111111111111111111"
913
- },
914
- {
915
- name: "associated_token_program",
916
- docs: ["The [Associated Token] program."],
917
- address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
918
- },
919
- {
920
- name: "token_program",
921
- docs: ["The [Token] program."]
922
- }
923
- ],
924
- args: [
925
- {
926
- name: "version",
927
- type: "u64"
928
- },
929
- {
930
- name: "root",
931
- type: {
932
- array: ["u8", 32]
933
- }
934
- },
935
- {
936
- name: "max_total_claim",
937
- type: "u64"
938
- },
939
- {
940
- name: "max_num_nodes",
941
- type: "u64"
942
- },
943
- {
944
- name: "unlock_period",
945
- type: "u64"
946
- },
947
- {
948
- name: "start_vesting_ts",
949
- type: "u64"
950
- },
951
- {
952
- name: "end_vesting_ts",
953
- type: "u64"
954
- },
955
- {
956
- name: "clawback_start_ts",
957
- type: "u64"
958
- },
959
- {
960
- name: "claims_closable_by_admin",
961
- type: "bool"
962
- },
963
- {
964
- name: "can_update_duration",
965
- type: {
966
- option: "bool"
967
- }
968
- },
969
- {
970
- name: "total_amount_unlocked",
971
- type: {
972
- option: "u64"
973
- }
974
- },
975
- {
976
- name: "total_amount_locked",
977
- type: {
978
- option: "u64"
979
- }
980
- },
981
- {
982
- name: "claims_closable_by_claimant",
983
- type: {
984
- option: "bool"
985
- }
986
- },
987
- {
988
- name: "claims_limit",
989
- type: {
990
- option: "u16"
991
- }
992
- }
993
- ]
994
- },
995
- {
996
- name: "refund_claim",
997
- discriminator: [157, 23, 164, 146, 176, 53, 147, 143],
998
- accounts: [
999
- {
1000
- name: "distributor",
1001
- docs: ["The [MerkleDistributor]."],
1002
- writable: true
1003
- },
1004
- {
1005
- name: "claim_status",
1006
- writable: true,
1007
- pda: {
1008
- seeds: [
1009
- {
1010
- kind: "const",
1011
- value: [67, 108, 97, 105, 109, 83, 116, 97, 116, 117, 115]
1012
- },
1013
- {
1014
- kind: "account",
1015
- path: "claimant"
1016
- },
1017
- {
1018
- kind: "account",
1019
- path: "distributor"
1020
- }
1021
- ]
1022
- }
1023
- },
1024
- {
1025
- name: "signer",
1026
- docs: ["Signer account"],
1027
- writable: true,
1028
- signer: true
1029
- },
1030
- {
1031
- name: "claimant"
1032
- },
1033
- {
1034
- name: "streamflow_treasury",
1035
- writable: true,
1036
- address: "5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw"
1037
- },
1038
- {
1039
- name: "system_program",
1040
- docs: ["The [System] program."],
1041
- address: "11111111111111111111111111111111"
1042
- }
1043
- ],
1044
- args: []
1045
- },
1046
- {
1047
- name: "set_admin",
1048
- discriminator: [251, 163, 0, 52, 91, 194, 187, 92],
1049
- accounts: [
1050
- {
1051
- name: "distributor",
1052
- docs: ["The [MerkleDistributor]."],
1053
- writable: true
1054
- },
1055
- {
1056
- name: "admin",
1057
- docs: ["Admin signer"],
1058
- writable: true,
1059
- signer: true
1060
- },
1061
- {
1062
- name: "new_admin",
1063
- docs: ["New admin account"],
1064
- writable: true
1065
- }
1066
- ],
1067
- args: []
1068
- },
1069
- {
1070
- name: "set_clawback_receiver",
1071
- discriminator: [153, 217, 34, 20, 19, 29, 229, 75],
1072
- accounts: [
1073
- {
1074
- name: "distributor",
1075
- docs: ["The [MerkleDistributor]."],
1076
- writable: true
1077
- },
1078
- {
1079
- name: "new_clawback_account",
1080
- docs: ["New clawback account"]
1081
- },
1082
- {
1083
- name: "admin",
1084
- docs: ["Admin signer"],
1085
- writable: true,
1086
- signer: true
1087
- }
1088
- ],
1089
- args: []
1090
- },
1091
- {
1092
- name: "update",
1093
- discriminator: [219, 200, 88, 176, 158, 63, 253, 127],
1094
- accounts: [
1095
- {
1096
- name: "distributor",
1097
- docs: ["The [MerkleDistributor]."],
1098
- writable: true
1099
- },
1100
- {
1101
- name: "admin",
1102
- docs: ["Only Admin can trigger the clawback of funds"],
1103
- writable: true,
1104
- signer: true
1105
- },
1106
- {
1107
- name: "system_program",
1108
- docs: ["The [System] program."],
1109
- address: "11111111111111111111111111111111"
1110
- }
1111
- ],
1112
- args: [
1113
- {
1114
- name: "end_ts",
1115
- type: {
1116
- option: "u64"
1117
- }
1118
- }
1119
- ]
1120
- }
1121
- ],
1122
- accounts: [
1123
- {
1124
- name: "ClaimStatus",
1125
- discriminator: [22, 183, 249, 157, 247, 95, 150, 96]
1126
- },
1127
- {
1128
- name: "CompressedClaimStatus",
1129
- discriminator: [53, 68, 161, 131, 212, 106, 98, 48]
1130
- },
1131
- {
1132
- name: "MerkleDistributor",
1133
- discriminator: [77, 119, 139, 70, 84, 247, 12, 26]
1134
- }
1135
- ],
1136
- events: [
1137
- {
1138
- name: "ClaimClosedEvent",
1139
- discriminator: [139, 166, 215, 195, 184, 233, 26, 217]
1140
- },
1141
- {
1142
- name: "ClaimedEvent",
1143
- discriminator: [144, 172, 209, 86, 144, 87, 84, 115]
1144
- },
1145
- {
1146
- name: "NewClaimEvent",
1147
- discriminator: [244, 3, 231, 151, 60, 101, 55, 55]
1148
- }
1149
- ],
1150
- errors: [
1151
- {
1152
- code: 6e3,
1153
- name: "InsufficientUnlockedTokens",
1154
- msg: "Insufficient unlocked tokens"
1155
- },
1156
- {
1157
- code: 6001,
1158
- name: "InvalidProof",
1159
- msg: "Invalid Merkle proof"
1160
- },
1161
- {
1162
- code: 6002,
1163
- name: "ExceededMaxClaim",
1164
- msg: "Exceeded maximum claim amount"
1165
- },
1166
- {
1167
- code: 6003,
1168
- name: "MaxNodesExceeded",
1169
- msg: "Exceeded maximum node count"
1170
- },
1171
- {
1172
- code: 6004,
1173
- name: "Unauthorized",
1174
- msg: "Account is not authorized to execute this instruction"
1175
- },
1176
- {
1177
- code: 6005,
1178
- name: "OwnerMismatch",
1179
- msg: "Token account owner did not match intended owner"
1180
- },
1181
- {
1182
- code: 6006,
1183
- name: "ClawbackBeforeStart",
1184
- msg: "Attempted clawback before start"
1185
- },
1186
- {
1187
- code: 6007,
1188
- name: "ClawbackAlreadyClaimed",
1189
- msg: "Clawback already claimed"
1190
- },
1191
- {
1192
- code: 6008,
1193
- name: "SameClawbackReceiver",
1194
- msg: "New and old Clawback receivers are identical"
1195
- },
1196
- {
1197
- code: 6009,
1198
- name: "ClawbackReceiverIsTokenVault",
1199
- msg: "Clawback receiver can not be the Token Vault"
1200
- },
1201
- {
1202
- code: 6010,
1203
- name: "SameAdmin",
1204
- msg: "New and old admin are identical"
1205
- },
1206
- {
1207
- code: 6011,
1208
- name: "ClaimExpired",
1209
- msg: "Claim window expired"
1210
- },
1211
- {
1212
- code: 6012,
1213
- name: "ArithmeticError",
1214
- msg: "Arithmetic Error (overflow/underflow)"
1215
- },
1216
- {
1217
- code: 6013,
1218
- name: "StartTimestampAfterEnd",
1219
- msg: "Start Timestamp cannot be after end Timestamp"
1220
- },
1221
- {
1222
- code: 6014,
1223
- name: "TimestampsNotInFuture",
1224
- msg: "Timestamps cannot be in the past"
1225
- },
1226
- {
1227
- code: 6015,
1228
- name: "InvalidMint",
1229
- msg: "Invalid Mint"
1230
- },
1231
- {
1232
- code: 6016,
1233
- name: "ClaimIsClosed",
1234
- msg: "Claim is closed"
1235
- },
1236
- {
1237
- code: 6017,
1238
- name: "ClaimsAreNotClosable",
1239
- msg: "Claims are not closable"
1240
- },
1241
- {
1242
- code: 6018,
1243
- name: "InvalidUnlockPeriod",
1244
- msg: "Invalid unlock period"
1245
- },
1246
- {
1247
- code: 6019,
1248
- name: "DurationUpdateNotAllowed",
1249
- msg: "Duration update is not allowed"
1250
- },
1251
- {
1252
- code: 6020,
1253
- name: "NoVestingAmount",
1254
- msg: "Vesting amounts are not set"
1255
- },
1256
- {
1257
- code: 6021,
1258
- name: "VestingAlreadyFinished",
1259
- msg: "Vesting already finished"
1260
- },
1261
- {
1262
- code: 6022,
1263
- name: "InvalidAmounts",
1264
- msg: "Provided amounts are invalid"
1265
- },
1266
- {
1267
- code: 6023,
1268
- name: "ClaimsLimitReached",
1269
- msg: "Claims limit has been reached"
1270
- }
1271
- ],
1272
- types: [
1273
- {
1274
- name: "ClaimClosedEvent",
1275
- docs: ["Emitted when a new claim is created."],
1276
- type: {
1277
- kind: "struct",
1278
- fields: [
1279
- {
1280
- name: "claimant",
1281
- docs: ["User that claimed."],
1282
- type: "pubkey"
1283
- },
1284
- {
1285
- name: "timestamp",
1286
- docs: ["Timestamp."],
1287
- type: "u64"
1288
- }
1289
- ]
1290
- }
1291
- },
1292
- {
1293
- name: "ClaimStatus",
1294
- docs: ["Holds whether or not a claimant has claimed tokens."],
1295
- type: {
1296
- kind: "struct",
1297
- fields: [
1298
- {
1299
- name: "claimant",
1300
- docs: ["Authority that claimed the tokens."],
1301
- type: "pubkey"
1302
- },
1303
- {
1304
- name: "locked_amount",
1305
- docs: ["Locked amount"],
1306
- type: "u64"
1307
- },
1308
- {
1309
- name: "locked_amount_withdrawn",
1310
- docs: ["Locked amount withdrawn"],
1311
- type: "u64"
1312
- },
1313
- {
1314
- name: "unlocked_amount",
1315
- docs: ["Unlocked amount"],
1316
- type: "u64"
1317
- },
1318
- {
1319
- name: "last_claim_ts",
1320
- docs: ["Last claim time"],
1321
- type: "u64"
1322
- },
1323
- {
1324
- name: "last_amount_per_unlock",
1325
- docs: ["Track amount per unlock, can be useful for non-linear vesting"],
1326
- type: "u64"
1327
- },
1328
- {
1329
- name: "closed",
1330
- docs: ["Whether claim is closed"],
1331
- type: "bool"
1332
- },
1333
- {
1334
- name: "distributor",
1335
- docs: [
1336
- "Distributor account for which ClaimStatus was created, useful to filter by in get_program_accounts"
1337
- ],
1338
- type: "pubkey"
1339
- },
1340
- {
1341
- name: "claims_count",
1342
- docs: ["Number of time amount has been claimed"],
1343
- type: "u16"
1344
- },
1345
- {
1346
- name: "closed_ts",
1347
- docs: ["Time when claim has been closed"],
1348
- type: "u64"
1349
- },
1350
- {
1351
- name: "buffer_2",
1352
- docs: ["Buffer for additional fields"],
1353
- type: {
1354
- array: ["u8", 22]
1355
- }
1356
- }
1357
- ]
1358
- }
1359
- },
1360
- {
1361
- name: "ClaimedEvent",
1362
- docs: ["Emitted when tokens are claimed."],
1363
- type: {
1364
- kind: "struct",
1365
- fields: [
1366
- {
1367
- name: "claimant",
1368
- docs: ["User that claimed."],
1369
- type: "pubkey"
1370
- },
1371
- {
1372
- name: "amount",
1373
- docs: ["Amount of tokens to distribute."],
1374
- type: "u64"
1375
- }
1376
- ]
1377
- }
1378
- },
1379
- {
1380
- name: "CompressedClaimStatus",
1381
- docs: ["Holds whether or not a claimant has claimed tokens."],
1382
- type: {
1383
- kind: "struct",
1384
- fields: [
1385
- {
1386
- name: "state",
1387
- type: {
1388
- defined: {
1389
- name: "State"
1390
- }
1391
- }
1392
- }
1393
- ]
1394
- }
1395
- },
1396
- {
1397
- name: "MerkleDistributor",
1398
- docs: ["State for the account which distributes tokens."],
1399
- type: {
1400
- kind: "struct",
1401
- fields: [
1402
- {
1403
- name: "bump",
1404
- docs: ["Bump seed."],
1405
- type: "u8"
1406
- },
1407
- {
1408
- name: "version",
1409
- docs: ["Version of the airdrop"],
1410
- type: "u64"
1411
- },
1412
- {
1413
- name: "root",
1414
- docs: ["The 256-bit merkle root."],
1415
- type: {
1416
- array: ["u8", 32]
1417
- }
1418
- },
1419
- {
1420
- name: "mint",
1421
- docs: ["[Mint] of the token to be distributed."],
1422
- type: "pubkey"
1423
- },
1424
- {
1425
- name: "token_vault",
1426
- docs: ["Token Address of the vault"],
1427
- type: "pubkey"
1428
- },
1429
- {
1430
- name: "max_total_claim",
1431
- docs: ["Maximum number of tokens that can ever be claimed from this [MerkleDistributor]."],
1432
- type: "u64"
1433
- },
1434
- {
1435
- name: "max_num_nodes",
1436
- docs: ["Maximum number of nodes in [MerkleDistributor]."],
1437
- type: "u64"
1438
- },
1439
- {
1440
- name: "unlock_period",
1441
- docs: ["Time step (period) in seconds per which the unlock occurs"],
1442
- type: "u64"
1443
- },
1444
- {
1445
- name: "total_amount_claimed",
1446
- docs: ["Total amount of tokens that have been claimed."],
1447
- type: "u64"
1448
- },
1449
- {
1450
- name: "num_nodes_claimed",
1451
- docs: ["Number of nodes that have been claimed."],
1452
- type: "u64"
1453
- },
1454
- {
1455
- name: "start_ts",
1456
- docs: ["Lockup time start (Unix Timestamp)"],
1457
- type: "u64"
1458
- },
1459
- {
1460
- name: "end_ts",
1461
- docs: ["Lockup time end (Unix Timestamp)"],
1462
- type: "u64"
1463
- },
1464
- {
1465
- name: "clawback_start_ts",
1466
- docs: ["Clawback start (Unix Timestamp)"],
1467
- type: "u64"
1468
- },
1469
- {
1470
- name: "clawback_receiver",
1471
- docs: ["Clawback receiver"],
1472
- type: "pubkey"
1473
- },
1474
- {
1475
- name: "admin",
1476
- docs: ["Admin wallet"],
1477
- type: "pubkey"
1478
- },
1479
- {
1480
- name: "clawed_back",
1481
- docs: ["Whether or not the distributor has been clawed back"],
1482
- type: "bool"
1483
- },
1484
- {
1485
- name: "claims_closable_by_admin",
1486
- docs: ["Whether claims are closable by the admin or not"],
1487
- type: "bool"
1488
- },
1489
- {
1490
- name: "can_update_duration",
1491
- docs: ["Whether admin can update vesting duration"],
1492
- type: "bool"
1493
- },
1494
- {
1495
- name: "total_amount_unlocked",
1496
- docs: ["Total amount of funds unlocked (cliff/instant)"],
1497
- type: "u64"
1498
- },
1499
- {
1500
- name: "total_amount_locked",
1501
- docs: ["Total amount of funds locked (vested)"],
1502
- type: "u64"
1503
- },
1504
- {
1505
- name: "last_duration_update_ts",
1506
- docs: ["Timestamp when update was last called"],
1507
- type: "u64"
1508
- },
1509
- {
1510
- name: "total_claimable_pre_update",
1511
- docs: [
1512
- "Total amount of locked amount claimable as of last duration update, ever increasing total, accumulates with each update"
1513
- ],
1514
- type: "u64"
1515
- },
1516
- {
1517
- name: "clawed_back_ts",
1518
- docs: ["Timestamp when funds were clawed back"],
1519
- type: "u64"
1520
- },
1521
- {
1522
- name: "claims_closable_by_claimant",
1523
- docs: ["Whether claims are closable by claimant or not"],
1524
- type: "bool"
1525
- },
1526
- {
1527
- name: "claims_limit",
1528
- docs: ["Limit number of claims"],
1529
- type: "u16"
1530
- },
1531
- {
1532
- name: "buffer_2",
1533
- docs: ["Buffer for additional fields"],
1534
- type: {
1535
- array: ["u8", 20]
1536
- }
1537
- },
1538
- {
1539
- name: "buffer_3",
1540
- docs: ["Buffer for additional fields"],
1541
- type: {
1542
- array: ["u8", 32]
1543
- }
1544
- }
1545
- ]
1546
- }
1547
- },
1548
- {
1549
- name: "NewClaimEvent",
1550
- docs: ["Emitted when a new claim is created."],
1551
- type: {
1552
- kind: "struct",
1553
- fields: [
1554
- {
1555
- name: "claimant",
1556
- docs: ["User that claimed."],
1557
- type: "pubkey"
1558
- },
1559
- {
1560
- name: "timestamp",
1561
- docs: ["Timestamp."],
1562
- type: "u64"
1563
- }
1564
- ]
1565
- }
1566
- },
1567
- {
1568
- name: "State",
1569
- type: {
1570
- kind: "enum",
1571
- variants: [
1572
- {
1573
- name: "Claimed"
1574
- },
1575
- {
1576
- name: "Closed"
1577
- }
1578
- ]
1579
- }
1580
- }
1581
- ]
1582
- };
1583
-
1584
274
  // solana/constants.ts
1585
275
  var constants_exports = {};
1586
276
  __export(constants_exports, {
@@ -1621,6 +311,107 @@ var DISTRIBUTOR_PROGRAM_ID = {
1621
311
  [ICluster.Testnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
1622
312
  [ICluster.Local]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N"
1623
313
  };
314
+ var _ClaimStatus = class _ClaimStatus {
315
+ constructor(fields) {
316
+ this.claimant = fields.claimant;
317
+ this.lockedAmount = fields.lockedAmount;
318
+ this.lockedAmountWithdrawn = fields.lockedAmountWithdrawn;
319
+ this.unlockedAmount = fields.unlockedAmount;
320
+ this.lastClaimTs = fields.lastClaimTs;
321
+ this.lastAmountPerUnlock = fields.lastAmountPerUnlock;
322
+ this.closed = fields.closed;
323
+ this.distributor = fields.distributor;
324
+ this.claimsCount = fields.claimsCount;
325
+ this.closedTs = fields.closedTs;
326
+ this.buffer2 = fields.buffer2;
327
+ }
328
+ static async fetch(c, address, programId = PROGRAM_ID) {
329
+ const info = await c.getAccountInfo(address);
330
+ if (info === null) {
331
+ return null;
332
+ }
333
+ if (!info.owner.equals(programId)) {
334
+ throw new Error("account doesn't belong to this program");
335
+ }
336
+ return this.decode(info.data);
337
+ }
338
+ static async fetchMultiple(c, addresses, programId = PROGRAM_ID) {
339
+ const infos = await c.getMultipleAccountsInfo(addresses);
340
+ return infos.map((info) => {
341
+ if (info === null) {
342
+ return null;
343
+ }
344
+ if (!info.owner.equals(programId)) {
345
+ throw new Error("account doesn't belong to this program");
346
+ }
347
+ return this.decode(info.data);
348
+ });
349
+ }
350
+ static decode(data) {
351
+ if (!data.slice(0, 8).equals(_ClaimStatus.discriminator)) {
352
+ throw new Error("invalid account discriminator");
353
+ }
354
+ const dec = _ClaimStatus.layout.decode(data.slice(8));
355
+ return new _ClaimStatus({
356
+ claimant: dec.claimant,
357
+ lockedAmount: dec.lockedAmount,
358
+ lockedAmountWithdrawn: dec.lockedAmountWithdrawn,
359
+ unlockedAmount: dec.unlockedAmount,
360
+ lastClaimTs: dec.lastClaimTs,
361
+ lastAmountPerUnlock: dec.lastAmountPerUnlock,
362
+ closed: dec.closed,
363
+ distributor: dec.distributor,
364
+ claimsCount: dec.claimsCount,
365
+ closedTs: dec.closedTs,
366
+ buffer2: dec.buffer2
367
+ });
368
+ }
369
+ toJSON() {
370
+ return {
371
+ claimant: this.claimant.toString(),
372
+ lockedAmount: this.lockedAmount.toString(),
373
+ lockedAmountWithdrawn: this.lockedAmountWithdrawn.toString(),
374
+ unlockedAmount: this.unlockedAmount.toString(),
375
+ lastClaimTs: this.lastClaimTs.toString(),
376
+ lastAmountPerUnlock: this.lastAmountPerUnlock.toString(),
377
+ closed: this.closed,
378
+ distributor: this.distributor.toString(),
379
+ claimsCount: this.claimsCount,
380
+ closedTs: this.closedTs.toString(),
381
+ buffer2: this.buffer2
382
+ };
383
+ }
384
+ static fromJSON(obj) {
385
+ return new _ClaimStatus({
386
+ claimant: new PublicKey(obj.claimant),
387
+ lockedAmount: new BN6(obj.lockedAmount),
388
+ lockedAmountWithdrawn: new BN6(obj.lockedAmountWithdrawn),
389
+ unlockedAmount: new BN6(obj.unlockedAmount),
390
+ lastClaimTs: new BN6(obj.lastClaimTs),
391
+ lastAmountPerUnlock: new BN6(obj.lastAmountPerUnlock),
392
+ closed: obj.closed,
393
+ distributor: new PublicKey(obj.distributor),
394
+ claimsCount: obj.claimsCount,
395
+ closedTs: new BN6(obj.closedTs),
396
+ buffer2: obj.buffer2
397
+ });
398
+ }
399
+ };
400
+ _ClaimStatus.discriminator = Buffer.from([22, 183, 249, 157, 247, 95, 150, 96]);
401
+ _ClaimStatus.layout = borsh8.struct([
402
+ borsh8.publicKey("claimant"),
403
+ borsh8.u64("lockedAmount"),
404
+ borsh8.u64("lockedAmountWithdrawn"),
405
+ borsh8.u64("unlockedAmount"),
406
+ borsh8.u64("lastClaimTs"),
407
+ borsh8.u64("lastAmountPerUnlock"),
408
+ borsh8.bool("closed"),
409
+ borsh8.publicKey("distributor"),
410
+ borsh8.u16("claimsCount"),
411
+ borsh8.u64("closedTs"),
412
+ borsh8.array(borsh8.u8(), 22, "buffer2")
413
+ ]);
414
+ var ClaimStatus = _ClaimStatus;
1624
415
  var _MerkleDistributor = class _MerkleDistributor {
1625
416
  constructor(fields) {
1626
417
  this.bump = fields.bump;
@@ -1742,28 +533,28 @@ var _MerkleDistributor = class _MerkleDistributor {
1742
533
  static fromJSON(obj) {
1743
534
  return new _MerkleDistributor({
1744
535
  bump: obj.bump,
1745
- version: new BN5(obj.version),
536
+ version: new BN6(obj.version),
1746
537
  root: obj.root,
1747
538
  mint: new PublicKey(obj.mint),
1748
539
  tokenVault: new PublicKey(obj.tokenVault),
1749
- maxTotalClaim: new BN5(obj.maxTotalClaim),
1750
- maxNumNodes: new BN5(obj.maxNumNodes),
1751
- unlockPeriod: new BN5(obj.unlockPeriod),
1752
- totalAmountClaimed: new BN5(obj.totalAmountClaimed),
1753
- numNodesClaimed: new BN5(obj.numNodesClaimed),
1754
- startTs: new BN5(obj.startTs),
1755
- endTs: new BN5(obj.endTs),
1756
- clawbackStartTs: new BN5(obj.clawbackStartTs),
540
+ maxTotalClaim: new BN6(obj.maxTotalClaim),
541
+ maxNumNodes: new BN6(obj.maxNumNodes),
542
+ unlockPeriod: new BN6(obj.unlockPeriod),
543
+ totalAmountClaimed: new BN6(obj.totalAmountClaimed),
544
+ numNodesClaimed: new BN6(obj.numNodesClaimed),
545
+ startTs: new BN6(obj.startTs),
546
+ endTs: new BN6(obj.endTs),
547
+ clawbackStartTs: new BN6(obj.clawbackStartTs),
1757
548
  clawbackReceiver: new PublicKey(obj.clawbackReceiver),
1758
549
  admin: new PublicKey(obj.admin),
1759
550
  clawedBack: obj.clawedBack,
1760
551
  claimsClosableByAdmin: obj.claimsClosableByAdmin,
1761
552
  canUpdateDuration: obj.canUpdateDuration,
1762
- totalAmountUnlocked: new BN5(obj.totalAmountUnlocked),
1763
- totalAmountLocked: new BN5(obj.totalAmountLocked),
1764
- lastDurationUpdateTs: new BN5(obj.lastDurationUpdateTs),
1765
- totalClaimablePreUpdate: new BN5(obj.totalClaimablePreUpdate),
1766
- clawedBackTs: new BN5(obj.clawedBackTs),
553
+ totalAmountUnlocked: new BN6(obj.totalAmountUnlocked),
554
+ totalAmountLocked: new BN6(obj.totalAmountLocked),
555
+ lastDurationUpdateTs: new BN6(obj.lastDurationUpdateTs),
556
+ totalClaimablePreUpdate: new BN6(obj.totalClaimablePreUpdate),
557
+ clawedBackTs: new BN6(obj.clawedBackTs),
1767
558
  claimsClosableByClaimant: obj.claimsClosableByClaimant,
1768
559
  claimsLimit: obj.claimsLimit,
1769
560
  buffer2: obj.buffer2,
@@ -1772,34 +563,34 @@ var _MerkleDistributor = class _MerkleDistributor {
1772
563
  }
1773
564
  };
1774
565
  _MerkleDistributor.discriminator = Buffer.from([77, 119, 139, 70, 84, 247, 12, 26]);
1775
- _MerkleDistributor.layout = borsh7.struct([
1776
- borsh7.u8("bump"),
1777
- borsh7.u64("version"),
1778
- borsh7.array(borsh7.u8(), 32, "root"),
1779
- borsh7.publicKey("mint"),
1780
- borsh7.publicKey("tokenVault"),
1781
- borsh7.u64("maxTotalClaim"),
1782
- borsh7.u64("maxNumNodes"),
1783
- borsh7.u64("unlockPeriod"),
1784
- borsh7.u64("totalAmountClaimed"),
1785
- borsh7.u64("numNodesClaimed"),
1786
- borsh7.u64("startTs"),
1787
- borsh7.u64("endTs"),
1788
- borsh7.u64("clawbackStartTs"),
1789
- borsh7.publicKey("clawbackReceiver"),
1790
- borsh7.publicKey("admin"),
1791
- borsh7.bool("clawedBack"),
1792
- borsh7.bool("claimsClosableByAdmin"),
1793
- borsh7.bool("canUpdateDuration"),
1794
- borsh7.u64("totalAmountUnlocked"),
1795
- borsh7.u64("totalAmountLocked"),
1796
- borsh7.u64("lastDurationUpdateTs"),
1797
- borsh7.u64("totalClaimablePreUpdate"),
1798
- borsh7.u64("clawedBackTs"),
1799
- borsh7.bool("claimsClosableByClaimant"),
1800
- borsh7.u16("claimsLimit"),
1801
- borsh7.array(borsh7.u8(), 20, "buffer2"),
1802
- borsh7.array(borsh7.u8(), 32, "buffer3")
566
+ _MerkleDistributor.layout = borsh8.struct([
567
+ borsh8.u8("bump"),
568
+ borsh8.u64("version"),
569
+ borsh8.array(borsh8.u8(), 32, "root"),
570
+ borsh8.publicKey("mint"),
571
+ borsh8.publicKey("tokenVault"),
572
+ borsh8.u64("maxTotalClaim"),
573
+ borsh8.u64("maxNumNodes"),
574
+ borsh8.u64("unlockPeriod"),
575
+ borsh8.u64("totalAmountClaimed"),
576
+ borsh8.u64("numNodesClaimed"),
577
+ borsh8.u64("startTs"),
578
+ borsh8.u64("endTs"),
579
+ borsh8.u64("clawbackStartTs"),
580
+ borsh8.publicKey("clawbackReceiver"),
581
+ borsh8.publicKey("admin"),
582
+ borsh8.bool("clawedBack"),
583
+ borsh8.bool("claimsClosableByAdmin"),
584
+ borsh8.bool("canUpdateDuration"),
585
+ borsh8.u64("totalAmountUnlocked"),
586
+ borsh8.u64("totalAmountLocked"),
587
+ borsh8.u64("lastDurationUpdateTs"),
588
+ borsh8.u64("totalClaimablePreUpdate"),
589
+ borsh8.u64("clawedBackTs"),
590
+ borsh8.bool("claimsClosableByClaimant"),
591
+ borsh8.u16("claimsLimit"),
592
+ borsh8.array(borsh8.u8(), 20, "buffer2"),
593
+ borsh8.array(borsh8.u8(), 32, "buffer3")
1803
594
  ]);
1804
595
  var MerkleDistributor = _MerkleDistributor;
1805
596
 
@@ -2811,9 +1602,9 @@ function getEventAuthorityPda(programId) {
2811
1602
  const seeds = [Buffer$1.from("__event_authority")];
2812
1603
  return PublicKey.findProgramAddressSync(seeds, programId)[0];
2813
1604
  }
2814
- async function wrappedSignAndExecuteTransaction(...args) {
1605
+ async function wrappedSignAndExecuteTransaction(connection, invoker, tx, confirmationParams, throttleParams) {
2815
1606
  try {
2816
- return await signAndExecuteTransaction(...args);
1607
+ return await signAndExecuteTransaction(connection, invoker, tx, confirmationParams, throttleParams);
2817
1608
  } catch (err) {
2818
1609
  if (err instanceof Error) {
2819
1610
  const parsed = fromTxError(err);
@@ -2854,10 +1645,6 @@ var BaseDistributorClient = class {
2854
1645
  this.connection = new Connection(clusterUrl, this.commitment);
2855
1646
  this.programId = programId !== "" ? new PublicKey(programId) : new PublicKey(DISTRIBUTOR_PROGRAM_ID[cluster]);
2856
1647
  this.sendThrottler = sendThrottler ?? buildSendThrottler(sendRate);
2857
- const merkleDistributorProgram = {
2858
- ...merkle_distributor_default
2859
- };
2860
- this.merkleDistributorProgram = new Program(merkleDistributorProgram, { connection: this.connection });
2861
1648
  }
2862
1649
  getConnection() {
2863
1650
  return this.connection;
@@ -2892,7 +1679,7 @@ var BaseDistributorClient = class {
2892
1679
  };
2893
1680
  if (extParams.isNative) {
2894
1681
  ixs.push(
2895
- ...await prepareWrappedAccount(this.connection, extParams.invoker.publicKey, new BN5(data.maxTotalClaim))
1682
+ ...await prepareWrappedAccount(this.connection, extParams.invoker.publicKey, new BN6(data.maxTotalClaim))
2896
1683
  );
2897
1684
  }
2898
1685
  const newDistributorInstruction = await this.getNewDistributorInstruction(data, accounts);
@@ -2933,14 +1720,7 @@ var BaseDistributorClient = class {
2933
1720
  return { distributorPublicKey, ixs };
2934
1721
  }
2935
1722
  async create(data, extParams) {
2936
- const invoker = extParams.invoker.publicKey;
2937
- invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
2938
- const executionParams = this.unwrapExecutionParams(extParams);
2939
- const { ixs, distributorPublicKey } = await createAndEstimateTransaction(
2940
- (params) => this.prepareCreateInstructions(data, params),
2941
- executionParams,
2942
- (q) => q.ixs
2943
- );
1723
+ const { ixs, distributorPublicKey } = await this.prepareCreateInstructions(data, extParams);
2944
1724
  const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
2945
1725
  const signature = await wrappedSignAndExecuteTransaction(
2946
1726
  this.connection,
@@ -2951,7 +1731,7 @@ var BaseDistributorClient = class {
2951
1731
  context,
2952
1732
  commitment: this.getCommitment()
2953
1733
  },
2954
- { sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
1734
+ { sendThrottler: this.sendThrottler }
2955
1735
  );
2956
1736
  return {
2957
1737
  ixs,
@@ -2959,29 +1739,23 @@ var BaseDistributorClient = class {
2959
1739
  metadataId: distributorPublicKey.toBase58()
2960
1740
  };
2961
1741
  }
2962
- async claim(data, extParams, _serviceTransfer) {
2963
- const executionParams = this.unwrapExecutionParams(extParams);
2964
- const invoker = executionParams.invoker.publicKey;
2965
- invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
2966
- const ixs = await createAndEstimateTransaction(
2967
- (params) => this.prepareClaimInstructions(data, params, _serviceTransfer),
2968
- executionParams
2969
- );
2970
- const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
1742
+ async claim(data, extParams) {
1743
+ const ixs = await this.prepareClaimInstructions(data, extParams);
1744
+ const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
2971
1745
  const signature = await wrappedSignAndExecuteTransaction(
2972
1746
  this.connection,
2973
- executionParams.invoker,
1747
+ extParams.invoker,
2974
1748
  tx,
2975
1749
  {
2976
1750
  hash,
2977
1751
  context,
2978
1752
  commitment: this.getCommitment()
2979
1753
  },
2980
- { sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
1754
+ { sendThrottler: this.sendThrottler }
2981
1755
  );
2982
1756
  return { ixs, txId: signature };
2983
1757
  }
2984
- async prepareClaimInstructions(data, extParams, _serviceTransfer) {
1758
+ async prepareClaimInstructions(data, extParams) {
2985
1759
  if (!extParams.invoker.publicKey) {
2986
1760
  throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
2987
1761
  }
@@ -3008,7 +1782,7 @@ var BaseDistributorClient = class {
3008
1782
  extParams.invoker.publicKey
3009
1783
  );
3010
1784
  const eventAuthorityPublicKey = getEventAuthorityPda(this.programId);
3011
- const claimStatus = await this.getClaim(claimStatusPublicKey);
1785
+ const claimStatus = await ClaimStatus.fetch(this.connection, claimStatusPublicKey);
3012
1786
  const accounts = {
3013
1787
  distributor: distributorPublicKey,
3014
1788
  claimStatus: claimStatusPublicKey,
@@ -3023,43 +1797,32 @@ var BaseDistributorClient = class {
3023
1797
  };
3024
1798
  if (!claimStatus) {
3025
1799
  const args = {
3026
- amountLocked: new BN5(data.amountLocked),
3027
- amountUnlocked: new BN5(data.amountUnlocked),
1800
+ amountLocked: new BN6(data.amountLocked),
1801
+ amountUnlocked: new BN6(data.amountUnlocked),
3028
1802
  proof: data.proof
3029
1803
  };
3030
1804
  ixs.push(newClaim(args, accounts, this.programId));
3031
1805
  }
3032
- const nowTs = new BN5(Math.floor(Date.now() / 1e3));
3033
- if (claimStatus || new BN5(data.amountLocked).gtn(0) && nowTs.sub(distributor.startTs).gte(distributor.unlockPeriod)) {
1806
+ const nowTs = new BN6(Math.floor(Date.now() / 1e3));
1807
+ if (claimStatus || new BN6(data.amountLocked).gtn(0) && nowTs.sub(distributor.startTs).gte(distributor.unlockPeriod)) {
3034
1808
  ixs.push(claimLocked(accounts, this.programId));
3035
1809
  }
3036
- ixs.push(
3037
- this.prepareClaimFeeInstruction(
3038
- extParams.invoker.publicKey,
3039
- typeof _serviceTransfer === "bigint" ? _serviceTransfer : void 0
3040
- )
3041
- );
1810
+ ixs.push(this.prepareClaimFeeInstruction(extParams.invoker.publicKey));
3042
1811
  return ixs;
3043
1812
  }
3044
1813
  async closeClaim(data, extParams) {
3045
- const executionParams = this.unwrapExecutionParams(extParams);
3046
- const invoker = executionParams.invoker.publicKey;
3047
- invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3048
- const ixs = await createAndEstimateTransaction(
3049
- (params) => this.prepareCloseClaimInstructions(data, params),
3050
- executionParams
3051
- );
3052
- const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
1814
+ const ixs = await this.prepareCloseClaimInstructions(data, extParams);
1815
+ const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
3053
1816
  const signature = await wrappedSignAndExecuteTransaction(
3054
1817
  this.connection,
3055
- executionParams.invoker,
1818
+ extParams.invoker,
3056
1819
  tx,
3057
1820
  {
3058
1821
  hash,
3059
1822
  context,
3060
1823
  commitment: this.getCommitment()
3061
1824
  },
3062
- { sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
1825
+ { sendThrottler: this.sendThrottler }
3063
1826
  );
3064
1827
  return { ixs, txId: signature };
3065
1828
  }
@@ -3086,8 +1849,8 @@ var BaseDistributorClient = class {
3086
1849
  program: this.programId
3087
1850
  };
3088
1851
  const closeClaimArgs = {
3089
- amountLocked: data.amountLocked ? new BN5(data.amountLocked) : void 0,
3090
- amountUnlocked: data.amountUnlocked ? new BN5(data.amountUnlocked) : void 0,
1852
+ amountLocked: data.amountLocked ? new BN6(data.amountLocked) : void 0,
1853
+ amountUnlocked: data.amountUnlocked ? new BN6(data.amountUnlocked) : void 0,
3091
1854
  proof: data.proof
3092
1855
  };
3093
1856
  ixs.push(closeClaim(closeClaimArgs, closeClaimAccounts, this.programId));
@@ -3127,37 +1890,26 @@ var BaseDistributorClient = class {
3127
1890
  return ixs;
3128
1891
  }
3129
1892
  async clawback(data, extParams) {
3130
- const executionParams = this.unwrapExecutionParams(extParams);
3131
- const invoker = executionParams.invoker.publicKey;
3132
- invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3133
- const ixs = await createAndEstimateTransaction(
3134
- (params) => this.prepareClawbackInstructions(data, params),
3135
- executionParams
3136
- );
3137
- const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
1893
+ const ixs = await this.prepareClawbackInstructions(data, extParams);
1894
+ const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
3138
1895
  const signature = await wrappedSignAndExecuteTransaction(
3139
1896
  this.connection,
3140
- executionParams.invoker,
1897
+ extParams.invoker,
3141
1898
  tx,
3142
1899
  {
3143
1900
  hash,
3144
1901
  context,
3145
1902
  commitment: this.getCommitment()
3146
1903
  },
3147
- { sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
1904
+ { sendThrottler: this.sendThrottler }
3148
1905
  );
3149
1906
  return { ixs, txId: signature };
3150
1907
  }
3151
- async getClaim(claimStatus) {
3152
- return this.connection.getAccountInfo(pk(claimStatus)).then((account) => this.decodeClaimStatus(account));
3153
- }
3154
1908
  async getClaims(data) {
3155
1909
  const claimStatusPublicKeys = data.map(({ id, recipient }) => {
3156
1910
  return getClaimantStatusPda(this.programId, new PublicKey(id), new PublicKey(recipient));
3157
1911
  });
3158
- return this.connection.getMultipleAccountsInfo(claimStatusPublicKeys).then((accounts) => {
3159
- return accounts.map((account) => this.decodeClaimStatus(account));
3160
- });
1912
+ return ClaimStatus.fetchMultiple(this.connection, claimStatusPublicKeys, this.programId);
3161
1913
  }
3162
1914
  async getDistributors(data) {
3163
1915
  const distributorPublicKeys = data.ids.map((distributorId) => new PublicKey(distributorId));
@@ -3187,28 +1939,28 @@ var BaseDistributorClient = class {
3187
1939
  account: MerkleDistributor.decode(account.data)
3188
1940
  }));
3189
1941
  }
3190
- prepareClaimFeeInstruction(payer, fee = AIRDROP_CLAIM_FEE) {
1942
+ prepareClaimFeeInstruction(payer) {
3191
1943
  return SystemProgram.transfer({
3192
1944
  fromPubkey: payer,
3193
1945
  toPubkey: STREAMFLOW_TREASURY_PUBLIC_KEY,
3194
- lamports: fee
1946
+ lamports: AIRDROP_CLAIM_FEE
3195
1947
  });
3196
1948
  }
3197
1949
  getNewDistributorArgs(data) {
3198
1950
  const args = {
3199
- version: new BN5(data.version),
1951
+ version: new BN6(data.version),
3200
1952
  root: data.root,
3201
- maxTotalClaim: new BN5(data.maxTotalClaim),
3202
- maxNumNodes: new BN5(data.maxNumNodes),
3203
- unlockPeriod: new BN5(data.unlockPeriod),
3204
- startVestingTs: new BN5(data.startVestingTs),
3205
- endVestingTs: new BN5(data.endVestingTs),
3206
- clawbackStartTs: new BN5(data.clawbackStartTs),
1953
+ maxTotalClaim: new BN6(data.maxTotalClaim),
1954
+ maxNumNodes: new BN6(data.maxNumNodes),
1955
+ unlockPeriod: new BN6(data.unlockPeriod),
1956
+ startVestingTs: new BN6(data.startVestingTs),
1957
+ endVestingTs: new BN6(data.endVestingTs),
1958
+ clawbackStartTs: new BN6(data.clawbackStartTs),
3207
1959
  claimsClosableByAdmin: data.claimsClosableByAdmin,
3208
1960
  claimsClosableByClaimant: data.claimsClosableByClaimant,
3209
1961
  claimsLimit: data.claimsLimit
3210
1962
  };
3211
- const nowTs = new BN5(Math.floor(Date.now() / 1e3));
1963
+ const nowTs = new BN6(Math.floor(Date.now() / 1e3));
3212
1964
  const endVestingTs = args.endVestingTs.isZero() ? nowTs : args.endVestingTs;
3213
1965
  const startVestingTs = args.startVestingTs.isZero() ? nowTs : args.startVestingTs;
3214
1966
  if (endVestingTs.gt(startVestingTs) && endVestingTs.sub(startVestingTs).lt(args.unlockPeriod)) {
@@ -3216,34 +1968,7 @@ var BaseDistributorClient = class {
3216
1968
  }
3217
1969
  return args;
3218
1970
  }
3219
- unwrapExecutionParams(extParams) {
3220
- return unwrapExecutionParams(extParams, this.connection);
3221
- }
3222
- decodeClaimStatus(account) {
3223
- if (!account) {
3224
- return account;
3225
- }
3226
- try {
3227
- return decode(this.merkleDistributorProgram, "claimStatus", account.data);
3228
- } catch (baseClaimStatusError) {
3229
- try {
3230
- return decode(this.merkleDistributorProgram, "compressedClaimStatus", account.data);
3231
- } catch (compressedClaimStatusError) {
3232
- throw new Error("Couldn't decode claim status");
3233
- }
3234
- }
3235
- }
3236
1971
  };
3237
- function decode(program, accountName, accInfo, programKey) {
3238
- const programId = program.programId?.toBase58() ?? "N/A";
3239
- invariant(program, `Decoding program with key ${programId} is not available`);
3240
- const accountEntity = program.idl.accounts?.find((acc) => acc.name === accountName);
3241
- invariant(
3242
- !!accountEntity,
3243
- `Decoding program with key ${programId} doesn't specify account with name ${String(accountName)}`
3244
- );
3245
- return program.coder.accounts.decode(accountName, accInfo);
3246
- }
3247
1972
 
3248
1973
  // solana/clients/SolanaDistributorClient.ts
3249
1974
  var SolanaDistributorClient = class extends BaseDistributorClient {
@@ -3261,7 +1986,7 @@ var aligned_distributor_default = {
3261
1986
  address: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
3262
1987
  metadata: {
3263
1988
  name: "aligned_distributor",
3264
- version: "1.5.0",
1989
+ version: "1.3.2",
3265
1990
  spec: "0.1.0",
3266
1991
  description: "Proxy for merkle distributor that updates Vesting duration according to token market performance."
3267
1992
  },
@@ -3405,48 +2130,6 @@ var aligned_distributor_default = {
3405
2130
  }
3406
2131
  ]
3407
2132
  },
3408
- {
3409
- name: "migrate_test_oracle",
3410
- discriminator: [203, 254, 19, 3, 172, 185, 85, 190],
3411
- accounts: [
3412
- {
3413
- name: "payer",
3414
- writable: true,
3415
- signer: true
3416
- },
3417
- {
3418
- name: "mint"
3419
- },
3420
- {
3421
- name: "creator"
3422
- },
3423
- {
3424
- name: "test_oracle",
3425
- writable: true,
3426
- pda: {
3427
- seeds: [
3428
- {
3429
- kind: "const",
3430
- value: [116, 101, 115, 116, 45, 111, 114, 97, 99, 108, 101]
3431
- },
3432
- {
3433
- kind: "account",
3434
- path: "mint"
3435
- },
3436
- {
3437
- kind: "account",
3438
- path: "creator"
3439
- }
3440
- ]
3441
- }
3442
- },
3443
- {
3444
- name: "system_program",
3445
- address: "11111111111111111111111111111111"
3446
- }
3447
- ],
3448
- args: []
3449
- },
3450
2133
  {
3451
2134
  name: "new_distributor",
3452
2135
  discriminator: [32, 139, 112, 171, 0, 2, 225, 155],
@@ -3532,48 +2215,6 @@ var aligned_distributor_default = {
3532
2215
  }
3533
2216
  ]
3534
2217
  },
3535
- {
3536
- name: "realloc_test_oracle",
3537
- discriminator: [234, 221, 116, 4, 198, 251, 244, 206],
3538
- accounts: [
3539
- {
3540
- name: "payer",
3541
- writable: true,
3542
- signer: true
3543
- },
3544
- {
3545
- name: "mint"
3546
- },
3547
- {
3548
- name: "creator"
3549
- },
3550
- {
3551
- name: "test_oracle",
3552
- writable: true,
3553
- pda: {
3554
- seeds: [
3555
- {
3556
- kind: "const",
3557
- value: [116, 101, 115, 116, 45, 111, 114, 97, 99, 108, 101]
3558
- },
3559
- {
3560
- kind: "account",
3561
- path: "mint"
3562
- },
3563
- {
3564
- kind: "account",
3565
- path: "creator"
3566
- }
3567
- ]
3568
- }
3569
- },
3570
- {
3571
- name: "system_program",
3572
- address: "11111111111111111111111111111111"
3573
- }
3574
- ],
3575
- args: []
3576
- },
3577
2218
  {
3578
2219
  name: "set_admin",
3579
2220
  discriminator: [251, 163, 0, 52, 91, 194, 187, 92],
@@ -4359,20 +3000,20 @@ var SolanaAlignedDistributorClient = class extends BaseDistributorClient {
4359
3000
  unlockPeriod
4360
3001
  } = data;
4361
3002
  return {
4362
- totalAmountLocked: new BN5(totalAmountLocked),
4363
- totalAmountUnlocked: new BN5(totalAmountUnlocked),
3003
+ totalAmountLocked: new BN6(totalAmountLocked),
3004
+ totalAmountUnlocked: new BN6(totalAmountUnlocked),
4364
3005
  oracleType: !!oracleType ? { [oracleType]: {} } : { none: {} },
4365
3006
  minPrice: getBN(minPrice, ALIGNED_PRECISION_FACTOR_POW),
4366
3007
  maxPrice: getBN(maxPrice, ALIGNED_PRECISION_FACTOR_POW),
4367
3008
  minPercentage: getBN(minPercentage, ALIGNED_PRECISION_FACTOR_POW),
4368
3009
  maxPercentage: getBN(maxPercentage, ALIGNED_PRECISION_FACTOR_POW),
4369
- tickSize: new BN5(tickSize || 1),
3010
+ tickSize: new BN6(tickSize || 1),
4370
3011
  skipInitial: skipInitial ?? false,
4371
- updatePeriod: unlockPeriod < 30 ? new BN5(30) : new BN5(unlockPeriod)
3012
+ updatePeriod: unlockPeriod < 30 ? new BN6(30) : new BN6(unlockPeriod)
4372
3013
  };
4373
3014
  }
4374
3015
  };
4375
3016
 
4376
- export { AnchorErrorCode, ContractErrorCode, MerkleDistributor, SolanaAlignedDistributorClient, SolanaDistributorClient, calculateAmountWithTransferFees, claimLocked, clawback, closeClaim, constants_exports as constants, fromCode3 as fromCode, fromTxError, getAlignedDistributorPda, getClaimantStatusPda, getDistributorPda, getEventAuthorityPda, getTestOraclePda, newClaim, newDistributor, setAdmin, setClawbackReceiver, wrappedSignAndExecuteTransaction };
3017
+ export { AnchorErrorCode, ClaimStatus, ContractErrorCode, MerkleDistributor, SolanaAlignedDistributorClient, SolanaDistributorClient, calculateAmountWithTransferFees, claimLocked, clawback, closeClaim, constants_exports as constants, fromCode3 as fromCode, fromTxError, getAlignedDistributorPda, getClaimantStatusPda, getDistributorPda, getEventAuthorityPda, getTestOraclePda, newClaim, newDistributor, setAdmin, setClawbackReceiver, wrappedSignAndExecuteTransaction };
4377
3018
  //# sourceMappingURL=index.js.map
4378
3019
  //# sourceMappingURL=index.js.map