@zemyth/raise-sdk 0.1.1 → 0.1.3

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.
Files changed (47) hide show
  1. package/README.md +11 -9
  2. package/dist/accounts/index.cjs +531 -3
  3. package/dist/accounts/index.cjs.map +1 -1
  4. package/dist/accounts/index.d.cts +307 -2
  5. package/dist/accounts/index.d.ts +307 -2
  6. package/dist/accounts/index.js +503 -4
  7. package/dist/accounts/index.js.map +1 -1
  8. package/dist/constants/index.cjs +41 -3
  9. package/dist/constants/index.cjs.map +1 -1
  10. package/dist/constants/index.d.cts +38 -3
  11. package/dist/constants/index.d.ts +38 -3
  12. package/dist/constants/index.js +40 -4
  13. package/dist/constants/index.js.map +1 -1
  14. package/dist/index.cjs +2297 -361
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +566 -7
  17. package/dist/index.d.ts +566 -7
  18. package/dist/index.js +2279 -379
  19. package/dist/index.js.map +1 -1
  20. package/dist/instructions/index.cjs +783 -40
  21. package/dist/instructions/index.cjs.map +1 -1
  22. package/dist/instructions/index.d.cts +492 -6
  23. package/dist/instructions/index.d.ts +492 -6
  24. package/dist/instructions/index.js +762 -42
  25. package/dist/instructions/index.js.map +1 -1
  26. package/dist/pdas/index.cjs +163 -1
  27. package/dist/pdas/index.cjs.map +1 -1
  28. package/dist/pdas/index.d.cts +131 -1
  29. package/dist/pdas/index.d.ts +131 -1
  30. package/dist/pdas/index.js +151 -2
  31. package/dist/pdas/index.js.map +1 -1
  32. package/dist/types/index.cjs +9 -0
  33. package/dist/types/index.cjs.map +1 -1
  34. package/dist/types/index.d.cts +586 -3
  35. package/dist/types/index.d.ts +586 -3
  36. package/dist/types/index.js +9 -1
  37. package/dist/types/index.js.map +1 -1
  38. package/package.json +5 -3
  39. package/src/__tests__/dynamic-tokenomics.test.ts +358 -0
  40. package/src/accounts/index.ts +852 -1
  41. package/src/client.ts +1130 -1
  42. package/src/constants/index.ts +48 -2
  43. package/src/index.ts +58 -0
  44. package/src/instructions/index.ts +1383 -40
  45. package/src/pdas/index.ts +346 -0
  46. package/src/types/index.ts +698 -2
  47. package/src/utils/index.ts +90 -0
package/src/pdas/index.ts CHANGED
@@ -402,3 +402,349 @@ export function getFounderVestingPDA(projectPda: PublicKey, programId: PublicKey
402
402
  );
403
403
  return pda;
404
404
  }
405
+
406
+ // =============================================================================
407
+ // Dynamic Tokenomics PDAs
408
+ // =============================================================================
409
+
410
+ /**
411
+ * Derive Allocation Proposal PDA
412
+ *
413
+ * @param projectPda - Project account PDA
414
+ * @param proposalIndex - Proposal index (from tokenomics.proposal_count)
415
+ * @param programId - Raise program ID
416
+ * @returns Allocation proposal PDA
417
+ */
418
+ export function getAllocationProposalPDA(
419
+ projectPda: PublicKey,
420
+ proposalIndex: number,
421
+ programId: PublicKey
422
+ ): PublicKey {
423
+ const [pda] = PublicKey.findProgramAddressSync(
424
+ [
425
+ Buffer.from('allocation_proposal'),
426
+ projectPda.toBuffer(),
427
+ Buffer.from([proposalIndex]),
428
+ ],
429
+ programId
430
+ );
431
+ return pda;
432
+ }
433
+
434
+ /**
435
+ * Derive Allocation Vote PDA
436
+ *
437
+ * @param proposalPda - Allocation proposal PDA
438
+ * @param nftMint - NFT mint used for voting
439
+ * @param programId - Raise program ID
440
+ * @returns Allocation vote PDA
441
+ */
442
+ export function getAllocationVotePDA(
443
+ proposalPda: PublicKey,
444
+ nftMint: PublicKey,
445
+ programId: PublicKey
446
+ ): PublicKey {
447
+ const [pda] = PublicKey.findProgramAddressSync(
448
+ [
449
+ Buffer.from('allocation_vote'),
450
+ proposalPda.toBuffer(),
451
+ nftMint.toBuffer(),
452
+ ],
453
+ programId
454
+ );
455
+ return pda;
456
+ }
457
+
458
+ /**
459
+ * Derive Sub-Allocation Vesting PDA
460
+ *
461
+ * @param projectPda - Project account PDA
462
+ * @param subAllocationId - Sub-allocation ID (0-9)
463
+ * @param programId - Raise program ID
464
+ * @returns Sub-allocation vesting PDA
465
+ */
466
+ export function getSubAllocationVestingPDA(
467
+ projectPda: PublicKey,
468
+ subAllocationId: number,
469
+ programId: PublicKey
470
+ ): PublicKey {
471
+ const [pda] = PublicKey.findProgramAddressSync(
472
+ [
473
+ Buffer.from('sub_allocation_vesting'),
474
+ projectPda.toBuffer(),
475
+ Buffer.from([subAllocationId]),
476
+ ],
477
+ programId
478
+ );
479
+ return pda;
480
+ }
481
+
482
+ // =============================================================================
483
+ // Per-Milestone Vesting PDAs (add-per-milestone-vesting)
484
+ // =============================================================================
485
+
486
+ /**
487
+ * Derive InvestorMilestoneVesting PDA
488
+ * Tracks investor vesting for a specific milestone with configurable schedules
489
+ *
490
+ * @param projectPda - Project account PDA
491
+ * @param milestoneIndex - Milestone index
492
+ * @param investmentPda - Investment account PDA
493
+ * @param programId - Raise program ID
494
+ * @returns Investor milestone vesting PDA
495
+ */
496
+ export function getInvestorMilestoneVestingPDA(
497
+ projectPda: PublicKey,
498
+ milestoneIndex: number,
499
+ investmentPda: PublicKey,
500
+ programId: PublicKey
501
+ ): PublicKey {
502
+ const [pda] = PublicKey.findProgramAddressSync(
503
+ [
504
+ Buffer.from('investor_ms_vesting'),
505
+ projectPda.toBuffer(),
506
+ Buffer.from([milestoneIndex]),
507
+ investmentPda.toBuffer(),
508
+ ],
509
+ programId
510
+ );
511
+ return pda;
512
+ }
513
+
514
+ /**
515
+ * Derive FounderMilestoneVesting PDA
516
+ * Tracks founder milestone-based vesting with configurable schedules
517
+ *
518
+ * @param projectPda - Project account PDA
519
+ * @param milestoneIndex - Milestone index
520
+ * @param programId - Raise program ID
521
+ * @returns Founder milestone vesting PDA
522
+ */
523
+ export function getFounderMilestoneVestingPDA(
524
+ projectPda: PublicKey,
525
+ milestoneIndex: number,
526
+ programId: PublicKey
527
+ ): PublicKey {
528
+ const [pda] = PublicKey.findProgramAddressSync(
529
+ [
530
+ Buffer.from('founder_ms_vesting'),
531
+ projectPda.toBuffer(),
532
+ Buffer.from([milestoneIndex]),
533
+ ],
534
+ programId
535
+ );
536
+ return pda;
537
+ }
538
+
539
+ // =============================================================================
540
+ // Future Round Allocation PDAs (add-future-round-allocation)
541
+ // =============================================================================
542
+
543
+ /**
544
+ * Derive FutureRoundTokenVault PDA - Token account holding reserved tokens
545
+ *
546
+ * @param projectPda - Project account PDA
547
+ * @param programId - Raise program ID
548
+ * @returns Future round token vault PDA
549
+ */
550
+ export function getFutureRoundTokenVaultPDA(
551
+ projectPda: PublicKey,
552
+ programId: PublicKey
553
+ ): PublicKey {
554
+ const [pda] = PublicKey.findProgramAddressSync(
555
+ [Buffer.from(SEEDS.FUTURE_ROUND_VAULT), projectPda.toBuffer()],
556
+ programId
557
+ );
558
+ return pda;
559
+ }
560
+
561
+ /**
562
+ * Derive FutureRoundVault state PDA - Tracks future round token usage
563
+ *
564
+ * @param projectPda - Project account PDA
565
+ * @param programId - Raise program ID
566
+ * @returns Future round vault state PDA
567
+ */
568
+ export function getFutureRoundVaultPDA(
569
+ projectPda: PublicKey,
570
+ programId: PublicKey
571
+ ): PublicKey {
572
+ const [pda] = PublicKey.findProgramAddressSync(
573
+ [Buffer.from(SEEDS.FUTURE_ROUND_STATE), projectPda.toBuffer()],
574
+ programId
575
+ );
576
+ return pda;
577
+ }
578
+
579
+ // =============================================================================
580
+ // Multi-Round Fundraising PDAs (add-second-round-fundraising)
581
+ // =============================================================================
582
+
583
+ /**
584
+ * Derive FundingRound PDA
585
+ * Each round (R2, R3, R4...) has its own FundingRound account
586
+ *
587
+ * @param projectPda - Project account PDA
588
+ * @param roundNumber - Round number (2, 3, 4...)
589
+ * @param programId - Raise program ID
590
+ * @returns Funding round PDA
591
+ */
592
+ export function getFundingRoundPDA(
593
+ projectPda: PublicKey,
594
+ roundNumber: number,
595
+ programId: PublicKey
596
+ ): PublicKey {
597
+ const [pda] = PublicKey.findProgramAddressSync(
598
+ [
599
+ Buffer.from(SEEDS.FUNDING_ROUND),
600
+ projectPda.toBuffer(),
601
+ Buffer.from([roundNumber]),
602
+ ],
603
+ programId
604
+ );
605
+ return pda;
606
+ }
607
+
608
+ /**
609
+ * Derive Round Escrow PDA
610
+ * Each round has its own USDC escrow account
611
+ *
612
+ * @param projectPda - Project account PDA
613
+ * @param roundNumber - Round number (2, 3, 4...)
614
+ * @param programId - Raise program ID
615
+ * @returns Round escrow PDA
616
+ */
617
+ export function getRoundEscrowPDA(
618
+ projectPda: PublicKey,
619
+ roundNumber: number,
620
+ programId: PublicKey
621
+ ): PublicKey {
622
+ const [pda] = PublicKey.findProgramAddressSync(
623
+ [
624
+ Buffer.from(SEEDS.ROUND_ESCROW),
625
+ projectPda.toBuffer(),
626
+ Buffer.from([roundNumber]),
627
+ ],
628
+ programId
629
+ );
630
+ return pda;
631
+ }
632
+
633
+ /**
634
+ * Derive Round Milestone PDA
635
+ * Each round has its own milestones (R2M1, R2M2, etc.)
636
+ *
637
+ * @param projectPda - Project account PDA
638
+ * @param roundNumber - Round number (2, 3, 4...)
639
+ * @param milestoneIndex - Milestone index (0-based)
640
+ * @param programId - Raise program ID
641
+ * @returns Round milestone PDA
642
+ */
643
+ export function getRoundMilestonePDA(
644
+ projectPda: PublicKey,
645
+ roundNumber: number,
646
+ milestoneIndex: number,
647
+ programId: PublicKey
648
+ ): PublicKey {
649
+ const [pda] = PublicKey.findProgramAddressSync(
650
+ [
651
+ Buffer.from(SEEDS.MILESTONE),
652
+ projectPda.toBuffer(),
653
+ Buffer.from([roundNumber]),
654
+ Buffer.from([milestoneIndex]),
655
+ ],
656
+ programId
657
+ );
658
+ return pda;
659
+ }
660
+
661
+ /**
662
+ * Derive Round NFT Mint PDA
663
+ * NFT mints for R2+ investments include round_number in seeds
664
+ *
665
+ * @param projectId - Project identifier
666
+ * @param roundNumber - Round number (2, 3, 4...)
667
+ * @param investor - Investor's public key
668
+ * @param investmentCount - Investment count
669
+ * @param programId - Raise program ID
670
+ * @returns Round NFT mint PDA and bump
671
+ */
672
+ export function getRoundNftMintPDA(
673
+ projectId: BN | number | string,
674
+ roundNumber: number,
675
+ investor: PublicKey,
676
+ investmentCount: BN | number,
677
+ programId: PublicKey
678
+ ): [PublicKey, number] {
679
+ const projectIdBN = ensureBN(projectId);
680
+ const countBN = ensureBN(investmentCount);
681
+ return PublicKey.findProgramAddressSync(
682
+ [
683
+ Buffer.from(SEEDS.NFT_MINT),
684
+ projectIdBN.toArrayLike(Buffer, 'le', 8),
685
+ Buffer.from([roundNumber]),
686
+ investor.toBuffer(),
687
+ countBN.toArrayLike(Buffer, 'le', 8),
688
+ ],
689
+ programId
690
+ );
691
+ }
692
+
693
+ /**
694
+ * Derive Round Investment PDA
695
+ * R2+ investments include round_number in seeds
696
+ *
697
+ * @param projectPda - Project account PDA
698
+ * @param roundNumber - Round number (2, 3, 4...)
699
+ * @param nftMint - Investment NFT mint address
700
+ * @param programId - Raise program ID
701
+ * @returns Round investment PDA
702
+ */
703
+ export function getRoundInvestmentPDA(
704
+ projectPda: PublicKey,
705
+ roundNumber: number,
706
+ nftMint: PublicKey,
707
+ programId: PublicKey
708
+ ): PublicKey {
709
+ const [pda] = PublicKey.findProgramAddressSync(
710
+ [
711
+ Buffer.from(SEEDS.INVESTMENT),
712
+ projectPda.toBuffer(),
713
+ Buffer.from([roundNumber]),
714
+ nftMint.toBuffer(),
715
+ ],
716
+ programId
717
+ );
718
+ return pda;
719
+ }
720
+
721
+ /**
722
+ * Derive Round Investor Milestone Vesting PDA
723
+ * R2+ investor vesting includes round_number in seeds
724
+ *
725
+ * @param projectPda - Project account PDA
726
+ * @param roundNumber - Round number (2, 3, 4...)
727
+ * @param milestoneIndex - Milestone index
728
+ * @param investmentPda - Investment account PDA
729
+ * @param programId - Raise program ID
730
+ * @returns Round investor milestone vesting PDA
731
+ */
732
+ export function getRoundInvestorMilestoneVestingPDA(
733
+ projectPda: PublicKey,
734
+ roundNumber: number,
735
+ milestoneIndex: number,
736
+ investmentPda: PublicKey,
737
+ programId: PublicKey
738
+ ): PublicKey {
739
+ const [pda] = PublicKey.findProgramAddressSync(
740
+ [
741
+ Buffer.from(SEEDS.INVESTOR_MS_VESTING),
742
+ projectPda.toBuffer(),
743
+ Buffer.from([roundNumber]),
744
+ Buffer.from([milestoneIndex]),
745
+ investmentPda.toBuffer(),
746
+ ],
747
+ programId
748
+ );
749
+ return pda;
750
+ }