@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
@@ -17,7 +17,13 @@ var SEEDS = {
17
17
  TGE_ESCROW: "tge_escrow",
18
18
  ADMIN_CONFIG: "admin-config",
19
19
  NFT_MINT: "nft_mint",
20
- AUTHORITY: "authority"
20
+ AUTHORITY: "authority",
21
+ FUTURE_ROUND_VAULT: "future_round_vault",
22
+ FUTURE_ROUND_STATE: "future_round_state",
23
+ // Multi-Round Fundraising seeds
24
+ FUNDING_ROUND: "funding_round",
25
+ ROUND_ESCROW: "round_escrow",
26
+ INVESTOR_MS_VESTING: "investor_ms_vesting"
21
27
  };
22
28
 
23
29
  // src/pdas/index.ts
@@ -189,6 +195,149 @@ function getFounderVestingPDA(projectPda, programId) {
189
195
  );
190
196
  return pda;
191
197
  }
198
+ function getAllocationProposalPDA(projectPda, proposalIndex, programId) {
199
+ const [pda] = web3_js.PublicKey.findProgramAddressSync(
200
+ [
201
+ Buffer.from("allocation_proposal"),
202
+ projectPda.toBuffer(),
203
+ Buffer.from([proposalIndex])
204
+ ],
205
+ programId
206
+ );
207
+ return pda;
208
+ }
209
+ function getAllocationVotePDA(proposalPda, nftMint, programId) {
210
+ const [pda] = web3_js.PublicKey.findProgramAddressSync(
211
+ [
212
+ Buffer.from("allocation_vote"),
213
+ proposalPda.toBuffer(),
214
+ nftMint.toBuffer()
215
+ ],
216
+ programId
217
+ );
218
+ return pda;
219
+ }
220
+ function getSubAllocationVestingPDA(projectPda, subAllocationId, programId) {
221
+ const [pda] = web3_js.PublicKey.findProgramAddressSync(
222
+ [
223
+ Buffer.from("sub_allocation_vesting"),
224
+ projectPda.toBuffer(),
225
+ Buffer.from([subAllocationId])
226
+ ],
227
+ programId
228
+ );
229
+ return pda;
230
+ }
231
+ function getInvestorMilestoneVestingPDA(projectPda, milestoneIndex, investmentPda, programId) {
232
+ const [pda] = web3_js.PublicKey.findProgramAddressSync(
233
+ [
234
+ Buffer.from("investor_ms_vesting"),
235
+ projectPda.toBuffer(),
236
+ Buffer.from([milestoneIndex]),
237
+ investmentPda.toBuffer()
238
+ ],
239
+ programId
240
+ );
241
+ return pda;
242
+ }
243
+ function getFounderMilestoneVestingPDA(projectPda, milestoneIndex, programId) {
244
+ const [pda] = web3_js.PublicKey.findProgramAddressSync(
245
+ [
246
+ Buffer.from("founder_ms_vesting"),
247
+ projectPda.toBuffer(),
248
+ Buffer.from([milestoneIndex])
249
+ ],
250
+ programId
251
+ );
252
+ return pda;
253
+ }
254
+ function getFutureRoundTokenVaultPDA(projectPda, programId) {
255
+ const [pda] = web3_js.PublicKey.findProgramAddressSync(
256
+ [Buffer.from(SEEDS.FUTURE_ROUND_VAULT), projectPda.toBuffer()],
257
+ programId
258
+ );
259
+ return pda;
260
+ }
261
+ function getFutureRoundVaultPDA(projectPda, programId) {
262
+ const [pda] = web3_js.PublicKey.findProgramAddressSync(
263
+ [Buffer.from(SEEDS.FUTURE_ROUND_STATE), projectPda.toBuffer()],
264
+ programId
265
+ );
266
+ return pda;
267
+ }
268
+ function getFundingRoundPDA(projectPda, roundNumber, programId) {
269
+ const [pda] = web3_js.PublicKey.findProgramAddressSync(
270
+ [
271
+ Buffer.from(SEEDS.FUNDING_ROUND),
272
+ projectPda.toBuffer(),
273
+ Buffer.from([roundNumber])
274
+ ],
275
+ programId
276
+ );
277
+ return pda;
278
+ }
279
+ function getRoundEscrowPDA(projectPda, roundNumber, programId) {
280
+ const [pda] = web3_js.PublicKey.findProgramAddressSync(
281
+ [
282
+ Buffer.from(SEEDS.ROUND_ESCROW),
283
+ projectPda.toBuffer(),
284
+ Buffer.from([roundNumber])
285
+ ],
286
+ programId
287
+ );
288
+ return pda;
289
+ }
290
+ function getRoundMilestonePDA(projectPda, roundNumber, milestoneIndex, programId) {
291
+ const [pda] = web3_js.PublicKey.findProgramAddressSync(
292
+ [
293
+ Buffer.from(SEEDS.MILESTONE),
294
+ projectPda.toBuffer(),
295
+ Buffer.from([roundNumber]),
296
+ Buffer.from([milestoneIndex])
297
+ ],
298
+ programId
299
+ );
300
+ return pda;
301
+ }
302
+ function getRoundNftMintPDA(projectId, roundNumber, investor, investmentCount, programId) {
303
+ const projectIdBN = ensureBN(projectId);
304
+ const countBN = ensureBN(investmentCount);
305
+ return web3_js.PublicKey.findProgramAddressSync(
306
+ [
307
+ Buffer.from(SEEDS.NFT_MINT),
308
+ projectIdBN.toArrayLike(Buffer, "le", 8),
309
+ Buffer.from([roundNumber]),
310
+ investor.toBuffer(),
311
+ countBN.toArrayLike(Buffer, "le", 8)
312
+ ],
313
+ programId
314
+ );
315
+ }
316
+ function getRoundInvestmentPDA(projectPda, roundNumber, nftMint, programId) {
317
+ const [pda] = web3_js.PublicKey.findProgramAddressSync(
318
+ [
319
+ Buffer.from(SEEDS.INVESTMENT),
320
+ projectPda.toBuffer(),
321
+ Buffer.from([roundNumber]),
322
+ nftMint.toBuffer()
323
+ ],
324
+ programId
325
+ );
326
+ return pda;
327
+ }
328
+ function getRoundInvestorMilestoneVestingPDA(projectPda, roundNumber, milestoneIndex, investmentPda, programId) {
329
+ const [pda] = web3_js.PublicKey.findProgramAddressSync(
330
+ [
331
+ Buffer.from(SEEDS.INVESTOR_MS_VESTING),
332
+ projectPda.toBuffer(),
333
+ Buffer.from([roundNumber]),
334
+ Buffer.from([milestoneIndex]),
335
+ investmentPda.toBuffer()
336
+ ],
337
+ programId
338
+ );
339
+ return pda;
340
+ }
192
341
  var TOKEN_METADATA_PROGRAM_ID = new web3_js.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");
193
342
  function ensurePublicKey(value) {
194
343
  if (value instanceof web3_js.PublicKey) {
@@ -203,19 +352,19 @@ function getAccountNamespace(program) {
203
352
  return program.account;
204
353
  }
205
354
  async function initializeAdmin(program, admin, payer) {
206
- return getMethods(program).initializeAdmin().accounts({
355
+ return getMethods(program).initializeAdmin().accountsPartial({
207
356
  admin,
208
357
  payer
209
358
  }).rpc();
210
359
  }
211
360
  async function transferAdmin(program, adminKeypair, newAdmin) {
212
- return getMethods(program).transferAdmin().accounts({
361
+ return getMethods(program).transferAdmin().accountsPartial({
213
362
  authority: adminKeypair.publicKey,
214
363
  newAdmin
215
364
  }).signers([adminKeypair]).rpc();
216
365
  }
217
366
  async function acceptAdmin(program, newAuthority) {
218
- return getMethods(program).acceptAdmin().accounts({
367
+ return getMethods(program).acceptAdmin().accountsPartial({
219
368
  newAuthority
220
369
  }).rpc();
221
370
  }
@@ -277,19 +426,23 @@ async function initializeProject(program, args, founder) {
277
426
  lpTokenAllocationBps: args.tokenomics.lpTokenAllocationBps,
278
427
  lpUsdcAllocationBps: args.tokenomics.lpUsdcAllocationBps,
279
428
  founderAllocationBps: args.tokenomics.founderAllocationBps ?? null,
280
- treasuryAllocationBps: args.tokenomics.treasuryAllocationBps ?? null,
429
+ zemythAllocationBps: args.tokenomics.zemythAllocationBps ?? null,
281
430
  founderWallet: args.tokenomics.founderWallet ?? null,
282
431
  vestingDurationMonths: args.tokenomics.vestingDurationMonths ?? null,
283
- cliffMonths: args.tokenomics.cliffMonths ?? null
432
+ cliffMonths: args.tokenomics.cliffMonths ?? null,
433
+ founderMilestoneVestingBps: args.tokenomics.founderMilestoneVestingBps ?? null,
434
+ founderTimeVestingBps: args.tokenomics.founderTimeVestingBps ?? null,
435
+ futureRoundAllocationBps: args.tokenomics.futureRoundAllocationBps ?? null
284
436
  },
285
- milestone1Deadline: args.milestone1Deadline
286
- }).accounts({
437
+ milestone1Deadline: args.milestone1Deadline,
438
+ priceMultipliers: args.priceMultipliers ?? null
439
+ }).accountsPartial({
287
440
  founder
288
441
  }).rpc();
289
442
  }
290
443
  async function submitForApproval(program, projectId, founder) {
291
444
  const projectPda = getProjectPDA(projectId, program.programId);
292
- return getMethods(program).submitForApproval().accounts({
445
+ return getMethods(program).submitForApproval().accountsPartial({
293
446
  project: projectPda,
294
447
  founder
295
448
  }).rpc();
@@ -305,7 +458,12 @@ async function approveProject(program, args, adminKeypair) {
305
458
  const lpTokenVaultPda = getLpTokenVaultPDA(projectPda, program.programId);
306
459
  const treasuryVaultPda = getTreasuryVaultPDA(projectPda, program.programId);
307
460
  const lpUsdcVaultPda = getLpUsdcVaultPDA(projectPda, program.programId);
308
- return getMethods(program).approveProject().accounts({
461
+ const futureRoundTokenVaultPda = getFutureRoundTokenVaultPDA(projectPda, program.programId);
462
+ const futureRoundVaultPda = getFutureRoundVaultPDA(projectPda, program.programId);
463
+ const computeBudgetIx = web3_js.ComputeBudgetProgram.setComputeUnitLimit({
464
+ units: 4e5
465
+ });
466
+ return getMethods(program).approveProject().accountsPartial({
309
467
  project: projectPda,
310
468
  tokenomics: tokenomicsPda,
311
469
  tokenVault: tokenVaultPda,
@@ -316,10 +474,12 @@ async function approveProject(program, args, adminKeypair) {
316
474
  lpTokenVault: lpTokenVaultPda,
317
475
  treasuryVault: treasuryVaultPda,
318
476
  lpUsdcVault: lpUsdcVaultPda,
477
+ futureRoundTokenVault: futureRoundTokenVaultPda,
478
+ futureRoundVault: futureRoundVaultPda,
319
479
  usdcMint: args.usdcMint,
320
480
  authority: adminKeypair.publicKey,
321
481
  payer: adminKeypair.publicKey
322
- }).signers([adminKeypair]).rpc();
482
+ }).preInstructions([computeBudgetIx]).signers([adminKeypair]).rpc();
323
483
  }
324
484
  async function createMilestone(program, args, founder) {
325
485
  const projectPda = getProjectPDA(args.projectId, program.programId);
@@ -327,8 +487,11 @@ async function createMilestone(program, args, founder) {
327
487
  return getMethods(program).createMilestone({
328
488
  milestoneIndex: args.milestoneIndex,
329
489
  percentage: args.percentage,
330
- description: args.description
331
- }).accounts({
490
+ description: args.description,
491
+ vestingDurationMonths: args.vestingDurationMonths ?? null,
492
+ cliffMonths: args.cliffMonths ?? null,
493
+ instantReleaseBps: args.instantReleaseBps ?? null
494
+ }).accountsPartial({
332
495
  project: projectPda,
333
496
  milestone: milestonePda,
334
497
  founder
@@ -337,7 +500,7 @@ async function createMilestone(program, args, founder) {
337
500
  async function submitMilestone(program, projectId, milestoneIndex, founder) {
338
501
  const projectPda = getProjectPDA(projectId, program.programId);
339
502
  const milestonePda = getMilestonePDA(projectPda, milestoneIndex, program.programId);
340
- return getMethods(program).submitMilestone().accounts({
503
+ return getMethods(program).submitMilestone().accountsPartial({
341
504
  project: projectPda,
342
505
  milestone: milestonePda,
343
506
  founder
@@ -358,7 +521,7 @@ async function voteOnMilestone(program, args, voter) {
358
521
  // allowOwnerOffCurve
359
522
  splToken.TOKEN_PROGRAM_ID
360
523
  );
361
- return getMethods(program).voteOnMilestone({ choice: args.choice }).accounts({
524
+ return getMethods(program).voteOnMilestone({ choice: args.choice }).accountsPartial({
362
525
  milestone: milestonePda,
363
526
  project: projectPda,
364
527
  investment: investmentPda,
@@ -371,7 +534,7 @@ async function voteOnMilestone(program, args, voter) {
371
534
  async function finalizeVoting(program, projectId, milestoneIndex) {
372
535
  const projectPda = getProjectPDA(projectId, program.programId);
373
536
  const milestonePda = getMilestonePDA(projectPda, milestoneIndex, program.programId);
374
- return getMethods(program).finalizeVoting().accounts({
537
+ return getMethods(program).finalizeVoting().accountsPartial({
375
538
  project: projectPda,
376
539
  milestone: milestonePda
377
540
  }).rpc();
@@ -384,7 +547,7 @@ async function claimMilestoneFunds(program, args, founder) {
384
547
  const tokenomicsPda = getTokenomicsPDA(projectPda, program.programId);
385
548
  const lpUsdcVaultPda = getLpUsdcVaultPDA(projectPda, program.programId);
386
549
  const nextMilestonePda = args.nextMilestonePda ?? (args.nextMilestoneDeadline.gt(new anchor.BN(0)) ? getMilestonePDA(projectPda, args.milestoneIndex + 1, program.programId) : null);
387
- return getMethods(program).claimMilestoneFunds({ nextMilestoneDeadline: args.nextMilestoneDeadline }).accounts({
550
+ return getMethods(program).claimMilestoneFunds({ nextMilestoneDeadline: args.nextMilestoneDeadline }).accountsPartial({
388
551
  milestone: milestonePda,
389
552
  project: projectPda,
390
553
  founder,
@@ -402,7 +565,7 @@ async function claimMilestoneFunds(program, args, founder) {
402
565
  async function resubmitMilestone(program, args, founder) {
403
566
  const projectPda = getProjectPDA(args.projectId, program.programId);
404
567
  const milestonePda = getMilestonePDA(projectPda, args.milestoneIndex, program.programId);
405
- return getMethods(program).resubmitMilestone().accounts({
568
+ return getMethods(program).resubmitMilestone().accountsPartial({
406
569
  project: projectPda,
407
570
  milestone: milestonePda,
408
571
  founder
@@ -414,7 +577,7 @@ async function setMilestoneDeadline(program, args, founder) {
414
577
  return getMethods(program).setMilestoneDeadline({
415
578
  milestoneIndex: args.milestoneIndex,
416
579
  deadline: args.deadline
417
- }).accounts({
580
+ }).accountsPartial({
418
581
  project: projectPda,
419
582
  milestone: milestonePda,
420
583
  founder
@@ -426,7 +589,7 @@ async function extendMilestoneDeadline(program, args, founder) {
426
589
  return getMethods(program).extendMilestoneDeadline({
427
590
  milestoneIndex: args.milestoneIndex,
428
591
  newDeadline: args.newDeadline
429
- }).accounts({
592
+ }).accountsPartial({
430
593
  project: projectPda,
431
594
  milestone: milestonePda,
432
595
  founder
@@ -464,7 +627,7 @@ async function invest(program, args, investor) {
464
627
  const masterEdition = getMasterEditionPDA(nftMint);
465
628
  const [programAuthority] = getProgramAuthorityPDA(program.programId);
466
629
  const firstMilestonePda = getMilestonePDA(projectPda, 0, program.programId);
467
- return getMethods(program).invest({ amount: args.amount }).accounts({
630
+ return getMethods(program).invest({ amount: args.amount }).accountsPartial({
468
631
  project: projectPda,
469
632
  firstMilestone: firstMilestonePda,
470
633
  nftMint,
@@ -491,7 +654,7 @@ async function cancelInvestment(program, args, investor) {
491
654
  const projectPda = getProjectPDA(args.projectId, program.programId);
492
655
  const investmentPda = getInvestmentPDA(projectPda, nftMintPubkey, program.programId);
493
656
  const escrowPda = getEscrowPDA(args.projectId, program.programId);
494
- return getMethods(program).cancelInvestment().accounts({
657
+ return getMethods(program).cancelInvestment().accountsPartial({
495
658
  investor,
496
659
  project: projectPda,
497
660
  investment: investmentPda,
@@ -510,7 +673,7 @@ async function proposePivot(program, args, founder) {
510
673
  return getMethods(program).proposePivot({
511
674
  newMetadataUri: args.newMetadataUri,
512
675
  newMilestones: args.newMilestones
513
- }).accounts({
676
+ }).accountsPartial({
514
677
  project: projectPda,
515
678
  founder,
516
679
  pivotProposal: pivotProposalPda,
@@ -528,7 +691,7 @@ async function approvePivot(program, projectId, adminKeypair) {
528
691
  const pivotCount = projectAccount.pivotCount || 0;
529
692
  pivotProposalPda = getPivotProposalPDA(projectPda, pivotCount, program.programId);
530
693
  }
531
- return getMethods(program).approvePivot().accounts({
694
+ return getMethods(program).approvePivot().accountsPartial({
532
695
  moderator: adminKeypair.publicKey,
533
696
  project: projectPda,
534
697
  pivotProposal: pivotProposalPda
@@ -551,7 +714,7 @@ async function withdrawFromPivot(program, args, investor) {
551
714
  isSigner: false,
552
715
  isWritable: false
553
716
  }));
554
- return getMethods(program).withdrawFromPivot().accounts({
717
+ return getMethods(program).withdrawFromPivot().accountsPartial({
555
718
  investor,
556
719
  project: projectPda,
557
720
  pivotProposal: pivotProposalPda,
@@ -571,7 +734,7 @@ async function finalizePivot(program, args, authority) {
571
734
  isSigner: false,
572
735
  isWritable: true
573
736
  }));
574
- return getMethods(program).finalizePivot().accounts({
737
+ return getMethods(program).finalizePivot().accountsPartial({
575
738
  authority,
576
739
  project: projectPda,
577
740
  pivotProposal: pivotProposalPda
@@ -582,14 +745,14 @@ async function setTgeDate(program, args, founder) {
582
745
  return getMethods(program).setTgeDate({
583
746
  tgeDate: args.tgeDate,
584
747
  tokenMint: args.tokenMint
585
- }).accounts({
748
+ }).accountsPartial({
586
749
  project: projectPda,
587
750
  founder
588
751
  }).rpc();
589
752
  }
590
753
  async function depositTokens(program, args, founder) {
591
754
  const projectPda = getProjectPDA(args.projectId, program.programId);
592
- return getMethods(program).depositTokens({ amount: args.amount }).accounts({
755
+ return getMethods(program).depositTokens({ amount: args.amount }).accountsPartial({
593
756
  project: projectPda,
594
757
  tokenMint: args.tokenMint,
595
758
  founderTokenAccount: args.founderTokenAccount,
@@ -600,7 +763,7 @@ async function claimTokens(program, args, investor) {
600
763
  const projectPda = getProjectPDA(args.projectId, program.programId);
601
764
  const investmentPda = getInvestmentPDA(projectPda, args.nftMint, program.programId);
602
765
  const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
603
- return getMethods(program).claimTokens().accounts({
766
+ return getMethods(program).claimTokens().accountsPartial({
604
767
  investor,
605
768
  project: projectPda,
606
769
  investment: investmentPda,
@@ -615,7 +778,7 @@ async function reportScam(program, args, reporter) {
615
778
  const projectPda = getProjectPDA(args.projectId, program.programId);
616
779
  const tgeEscrowPda = getTgeEscrowPDA(projectPda, program.programId);
617
780
  const investmentPda = getInvestmentPDA(projectPda, args.nftMint, program.programId);
618
- return getMethods(program).reportScam().accounts({
781
+ return getMethods(program).reportScam().accountsPartial({
619
782
  tgeEscrow: tgeEscrowPda,
620
783
  project: projectPda,
621
784
  investment: investmentPda,
@@ -626,7 +789,7 @@ async function reportScam(program, args, reporter) {
626
789
  async function releaseHoldback(program, args) {
627
790
  const projectPda = getProjectPDA(args.projectId, program.programId);
628
791
  const tgeEscrowPda = getTgeEscrowPDA(projectPda, program.programId);
629
- return getMethods(program).releaseHoldback().accounts({
792
+ return getMethods(program).releaseHoldback().accountsPartial({
630
793
  tgeEscrow: tgeEscrowPda,
631
794
  project: projectPda,
632
795
  founderTokenAccount: args.founderTokenAccount
@@ -635,7 +798,7 @@ async function releaseHoldback(program, args) {
635
798
  async function checkAbandonment(program, projectId, milestoneIndex = 0) {
636
799
  const projectPda = getProjectPDA(projectId, program.programId);
637
800
  const milestonePda = getMilestonePDA(projectPda, milestoneIndex, program.programId);
638
- return getMethods(program).checkAbandonment().accounts({
801
+ return getMethods(program).checkAbandonment().accountsPartial({
639
802
  project: projectPda,
640
803
  milestone: milestonePda
641
804
  }).rpc();
@@ -654,7 +817,7 @@ async function claimRefund(program, args, investor) {
654
817
  isSigner: false
655
818
  });
656
819
  }
657
- return getMethods(program).claimRefund().accounts({
820
+ return getMethods(program).claimRefund().accountsPartial({
658
821
  project: projectPda,
659
822
  investment: investmentPda,
660
823
  nftMint: nftMintPubkey,
@@ -677,7 +840,7 @@ async function claimInvestorTokens(program, args, investor) {
677
840
  false,
678
841
  splToken.TOKEN_PROGRAM_ID
679
842
  );
680
- return getMethods(program).claimInvestorTokens({ milestoneIndex: args.milestoneIndex }).accounts({
843
+ return getMethods(program).claimInvestorTokens({ milestoneIndex: args.milestoneIndex }).accountsPartial({
681
844
  investor,
682
845
  project: projectPda,
683
846
  tokenVault: tokenVaultPda,
@@ -699,7 +862,7 @@ async function distributeTokens(program, args, payer) {
699
862
  { pubkey: inv.investmentPda, isSigner: false, isWritable: true },
700
863
  { pubkey: inv.investorTokenAccount, isSigner: false, isWritable: true }
701
864
  ]);
702
- return getMethods(program).distributeTokens({ milestoneIndex: args.milestoneIndex }).accounts({
865
+ return getMethods(program).distributeTokens({ milestoneIndex: args.milestoneIndex }).accountsPartial({
703
866
  project: projectPda,
704
867
  tokenVault: tokenVaultPda,
705
868
  investorVault: investorVaultPda,
@@ -711,7 +874,7 @@ async function distributeTokens(program, args, payer) {
711
874
  async function completeDistribution(program, args, payer) {
712
875
  const projectPda = getProjectPDA(args.projectId, program.programId);
713
876
  const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
714
- return getMethods(program).completeDistribution({ milestoneIndex: args.milestoneIndex }).accounts({
877
+ return getMethods(program).completeDistribution({ milestoneIndex: args.milestoneIndex }).accountsPartial({
715
878
  project: projectPda,
716
879
  tokenVault: tokenVaultPda,
717
880
  payer
@@ -742,7 +905,7 @@ async function initializeFounderVesting(program, args, payer) {
742
905
  const tokenomicsPda = getTokenomicsPDA(projectPda, program.programId);
743
906
  const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
744
907
  const founderVestingPda = getFounderVestingPDA(projectPda, program.programId);
745
- return getMethods(program).initializeFounderVesting().accounts({
908
+ return getMethods(program).initializeFounderVesting().accountsPartial({
746
909
  project: projectPda,
747
910
  tokenomics: tokenomicsPda,
748
911
  tokenVault: tokenVaultPda,
@@ -757,7 +920,7 @@ async function claimVestedTokens(program, args, founder) {
757
920
  const founderVestingPda = getFounderVestingPDA(projectPda, program.programId);
758
921
  const founderVaultPda = getFounderVaultPDA(projectPda, program.programId);
759
922
  const vaultAuthorityPda = getVaultAuthorityPDA(projectPda, program.programId);
760
- return getMethods(program).claimVestedTokens().accounts({
923
+ return getMethods(program).claimVestedTokens().accountsPartial({
761
924
  project: projectPda,
762
925
  tokenVault: tokenVaultPda,
763
926
  founderVesting: founderVestingPda,
@@ -772,7 +935,7 @@ async function forceCompleteDistribution(program, args, adminKeypair) {
772
935
  const projectPda = getProjectPDA(args.projectId, program.programId);
773
936
  const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
774
937
  const adminConfigPda = getAdminConfigPDA(program.programId);
775
- return getMethods(program).forceCompleteDistribution().accounts({
938
+ return getMethods(program).forceCompleteDistribution().accountsPartial({
776
939
  admin: adminKeypair.publicKey,
777
940
  adminConfig: adminConfigPda,
778
941
  project: projectPda,
@@ -792,7 +955,7 @@ async function claimMissedUnlock(program, args, claimer) {
792
955
  false,
793
956
  splToken.TOKEN_PROGRAM_ID
794
957
  );
795
- return getMethods(program).claimMissedUnlock({ milestoneIndex: args.milestoneIndex }).accounts({
958
+ return getMethods(program).claimMissedUnlock({ milestoneIndex: args.milestoneIndex }).accountsPartial({
796
959
  claimer,
797
960
  project: projectPda,
798
961
  tokenVault: tokenVaultPda,
@@ -805,36 +968,613 @@ async function claimMissedUnlock(program, args, claimer) {
805
968
  tokenProgram: splToken.TOKEN_PROGRAM_ID
806
969
  }).rpc();
807
970
  }
971
+ async function addSubAllocation(program, args, founder) {
972
+ const projectPda = getProjectPDA(args.projectId, program.programId);
973
+ const tokenomicsPda = getTokenomicsPDA(projectPda, program.programId);
974
+ return getMethods(program).addSubAllocation({
975
+ name: args.name,
976
+ bps: args.bps,
977
+ recipient: args.recipient,
978
+ vestingMonths: args.vestingMonths,
979
+ cliffMonths: args.cliffMonths
980
+ }).accountsPartial({
981
+ project: projectPda,
982
+ tokenomics: tokenomicsPda,
983
+ founder
984
+ }).rpc();
985
+ }
986
+ async function proposeAllocationChange(program, args, founder) {
987
+ const projectPda = getProjectPDA(args.projectId, program.programId);
988
+ const tokenomicsPda = getTokenomicsPDA(projectPda, program.programId);
989
+ const tokenomics = await getAccountNamespace(program).tokenomics.fetch(tokenomicsPda);
990
+ const proposalIndex = tokenomics.proposalCount || 0;
991
+ const proposalPda = getAllocationProposalPDA(projectPda, proposalIndex, program.programId);
992
+ return getMethods(program).proposeAllocationChange({
993
+ name: args.name,
994
+ bps: args.bps,
995
+ recipient: args.recipient,
996
+ vestingMonths: args.vestingMonths,
997
+ cliffMonths: args.cliffMonths
998
+ }).accountsPartial({
999
+ project: projectPda,
1000
+ tokenomics: tokenomicsPda,
1001
+ proposal: proposalPda,
1002
+ founder,
1003
+ systemProgram: web3_js.SystemProgram.programId
1004
+ }).rpc();
1005
+ }
1006
+ async function voteAllocationChange(program, args, voter) {
1007
+ const nftMintPubkey = ensurePublicKey(args.nftMint);
1008
+ const projectPda = getProjectPDA(args.projectId, program.programId);
1009
+ const proposalPda = getAllocationProposalPDA(projectPda, args.proposalIndex, program.programId);
1010
+ const investmentPda = getInvestmentPDA(projectPda, nftMintPubkey, program.programId);
1011
+ const votePda = getAllocationVotePDA(proposalPda, nftMintPubkey, program.programId);
1012
+ const investorNftAccount = splToken.getAssociatedTokenAddressSync(
1013
+ nftMintPubkey,
1014
+ voter,
1015
+ false,
1016
+ splToken.TOKEN_PROGRAM_ID
1017
+ );
1018
+ return getMethods(program).voteAllocationChange({ voteFor: args.voteFor }).accountsPartial({
1019
+ project: projectPda,
1020
+ proposal: proposalPda,
1021
+ investment: investmentPda,
1022
+ nftMint: nftMintPubkey,
1023
+ investorNftAccount,
1024
+ voteRecord: votePda,
1025
+ voter,
1026
+ systemProgram: web3_js.SystemProgram.programId
1027
+ }).rpc();
1028
+ }
1029
+ async function executeAllocationChange(program, args, executor) {
1030
+ const projectPda = getProjectPDA(args.projectId, program.programId);
1031
+ const tokenomicsPda = getTokenomicsPDA(projectPda, program.programId);
1032
+ const proposalPda = getAllocationProposalPDA(projectPda, args.proposalIndex, program.programId);
1033
+ return getMethods(program).executeAllocationChange().accountsPartial({
1034
+ project: projectPda,
1035
+ tokenomics: tokenomicsPda,
1036
+ proposal: proposalPda,
1037
+ executor
1038
+ }).rpc();
1039
+ }
1040
+ async function claimEarlyTokens(program, args, investor) {
1041
+ const nftMintPubkey = ensurePublicKey(args.nftMint);
1042
+ const projectPda = getProjectPDA(args.projectId, program.programId);
1043
+ const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
1044
+ const investmentPda = getInvestmentPDA(projectPda, nftMintPubkey, program.programId);
1045
+ const investorVaultPda = getInvestorVaultPDA(projectPda, program.programId);
1046
+ const vaultAuthorityPda = getVaultAuthorityPDA(projectPda, program.programId);
1047
+ const investorNftAccount = splToken.getAssociatedTokenAddressSync(
1048
+ nftMintPubkey,
1049
+ investor,
1050
+ false,
1051
+ splToken.TOKEN_PROGRAM_ID
1052
+ );
1053
+ return getMethods(program).claimEarlyTokens().accountsPartial({
1054
+ investor,
1055
+ project: projectPda,
1056
+ tokenVault: tokenVaultPda,
1057
+ investment: investmentPda,
1058
+ nftMint: nftMintPubkey,
1059
+ investorNftAccount,
1060
+ investorVault: investorVaultPda,
1061
+ investorTokenAccount: args.investorTokenAccount,
1062
+ vaultAuthority: vaultAuthorityPda,
1063
+ tokenProgram: splToken.TOKEN_PROGRAM_ID
1064
+ }).rpc();
1065
+ }
1066
+ async function claimFounderEarlyTokens(program, args, founder) {
1067
+ const projectPda = getProjectPDA(args.projectId, program.programId);
1068
+ const tokenomicsPda = getTokenomicsPDA(projectPda, program.programId);
1069
+ const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
1070
+ const founderVaultPda = getFounderVaultPDA(projectPda, program.programId);
1071
+ const vaultAuthorityPda = getVaultAuthorityPDA(projectPda, program.programId);
1072
+ return getMethods(program).claimFounderEarlyTokens().accountsPartial({
1073
+ founder,
1074
+ project: projectPda,
1075
+ tokenomics: tokenomicsPda,
1076
+ tokenVault: tokenVaultPda,
1077
+ founderVault: founderVaultPda,
1078
+ founderTokenAccount: args.founderTokenAccount,
1079
+ vaultAuthority: vaultAuthorityPda,
1080
+ tokenProgram: splToken.TOKEN_PROGRAM_ID
1081
+ }).rpc();
1082
+ }
1083
+ async function claimFounderMilestoneTokens(program, args, founder) {
1084
+ const projectPda = getProjectPDA(args.projectId, program.programId);
1085
+ const milestonePda = getMilestonePDA(projectPda, args.milestoneIndex, program.programId);
1086
+ const tokenomicsPda = getTokenomicsPDA(projectPda, program.programId);
1087
+ const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
1088
+ const founderVaultPda = getFounderVaultPDA(projectPda, program.programId);
1089
+ const vaultAuthorityPda = getVaultAuthorityPDA(projectPda, program.programId);
1090
+ return getMethods(program).claimFounderMilestoneTokens({ milestoneIndex: args.milestoneIndex }).accountsPartial({
1091
+ founder,
1092
+ project: projectPda,
1093
+ milestone: milestonePda,
1094
+ tokenomics: tokenomicsPda,
1095
+ tokenVault: tokenVaultPda,
1096
+ founderVault: founderVaultPda,
1097
+ founderTokenAccount: args.founderTokenAccount,
1098
+ vaultAuthority: vaultAuthorityPda,
1099
+ tokenProgram: splToken.TOKEN_PROGRAM_ID
1100
+ }).rpc();
1101
+ }
1102
+ async function initializeSubAllocationVesting(program, args, payer) {
1103
+ const projectPda = getProjectPDA(args.projectId, program.programId);
1104
+ const tokenomicsPda = getTokenomicsPDA(projectPda, program.programId);
1105
+ const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
1106
+ const subAllocationVestingPda = getSubAllocationVestingPDA(projectPda, args.subAllocationId, program.programId);
1107
+ return getMethods(program).initializeSubAllocationVesting({ subAllocationId: args.subAllocationId }).accountsPartial({
1108
+ project: projectPda,
1109
+ tokenomics: tokenomicsPda,
1110
+ tokenVault: tokenVaultPda,
1111
+ subAllocationVesting: subAllocationVestingPda,
1112
+ payer,
1113
+ systemProgram: web3_js.SystemProgram.programId
1114
+ }).rpc();
1115
+ }
1116
+ async function claimSubAllocationTokens(program, args, recipient) {
1117
+ const projectPda = getProjectPDA(args.projectId, program.programId);
1118
+ const tokenomicsPda = getTokenomicsPDA(projectPda, program.programId);
1119
+ const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
1120
+ const subAllocationVestingPda = getSubAllocationVestingPDA(projectPda, args.subAllocationId, program.programId);
1121
+ const treasuryVaultPda = getTreasuryVaultPDA(projectPda, program.programId);
1122
+ const vaultAuthorityPda = getVaultAuthorityPDA(projectPda, program.programId);
1123
+ return getMethods(program).claimSubAllocationTokens({ subAllocationId: args.subAllocationId }).accountsPartial({
1124
+ project: projectPda,
1125
+ tokenomics: tokenomicsPda,
1126
+ tokenVault: tokenVaultPda,
1127
+ subAllocationVesting: subAllocationVestingPda,
1128
+ reserveVault: treasuryVaultPda,
1129
+ vaultAuthority: vaultAuthorityPda,
1130
+ recipientTokenAccount: args.recipientTokenAccount,
1131
+ recipient,
1132
+ tokenProgram: splToken.TOKEN_PROGRAM_ID
1133
+ }).rpc();
1134
+ }
1135
+ async function claimMilestoneInstantTokens(program, args, investor) {
1136
+ const nftMintPubkey = ensurePublicKey(args.nftMint);
1137
+ const projectPda = getProjectPDA(args.projectId, program.programId);
1138
+ const milestonePda = getMilestonePDA(projectPda, args.milestoneIndex, program.programId);
1139
+ const investmentPda = getInvestmentPDA(projectPda, nftMintPubkey, program.programId);
1140
+ const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
1141
+ const vestingPda = getInvestorMilestoneVestingPDA(projectPda, args.milestoneIndex, investmentPda, program.programId);
1142
+ const investorVaultPda = getInvestorVaultPDA(projectPda, program.programId);
1143
+ const vaultAuthorityPda = getVaultAuthorityPDA(projectPda, program.programId);
1144
+ const investorNftAccount = splToken.getAssociatedTokenAddressSync(
1145
+ nftMintPubkey,
1146
+ investor,
1147
+ false,
1148
+ splToken.TOKEN_PROGRAM_ID
1149
+ );
1150
+ return getMethods(program).claimMilestoneInstantTokens({ milestoneIndex: args.milestoneIndex }).accountsPartial({
1151
+ investor,
1152
+ project: projectPda,
1153
+ milestone: milestonePda,
1154
+ investment: investmentPda,
1155
+ tokenVault: tokenVaultPda,
1156
+ vesting: vestingPda,
1157
+ nftMint: nftMintPubkey,
1158
+ investorNftAccount,
1159
+ investorVault: investorVaultPda,
1160
+ investorTokenAccount: args.investorTokenAccount,
1161
+ vaultAuthority: vaultAuthorityPda,
1162
+ tokenProgram: splToken.TOKEN_PROGRAM_ID,
1163
+ systemProgram: web3_js.SystemProgram.programId
1164
+ }).rpc();
1165
+ }
1166
+ async function claimMilestoneVestedTokens(program, args, investor) {
1167
+ const nftMintPubkey = ensurePublicKey(args.nftMint);
1168
+ const projectPda = getProjectPDA(args.projectId, program.programId);
1169
+ const milestonePda = getMilestonePDA(projectPda, args.milestoneIndex, program.programId);
1170
+ const investmentPda = getInvestmentPDA(projectPda, nftMintPubkey, program.programId);
1171
+ const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
1172
+ const vestingPda = getInvestorMilestoneVestingPDA(projectPda, args.milestoneIndex, investmentPda, program.programId);
1173
+ const investorVaultPda = getInvestorVaultPDA(projectPda, program.programId);
1174
+ const vaultAuthorityPda = getVaultAuthorityPDA(projectPda, program.programId);
1175
+ const investorNftAccount = splToken.getAssociatedTokenAddressSync(
1176
+ nftMintPubkey,
1177
+ investor,
1178
+ false,
1179
+ splToken.TOKEN_PROGRAM_ID
1180
+ );
1181
+ return getMethods(program).claimMilestoneVestedTokens({ milestoneIndex: args.milestoneIndex }).accountsPartial({
1182
+ investor,
1183
+ project: projectPda,
1184
+ milestone: milestonePda,
1185
+ investment: investmentPda,
1186
+ tokenVault: tokenVaultPda,
1187
+ vesting: vestingPda,
1188
+ nftMint: nftMintPubkey,
1189
+ investorNftAccount,
1190
+ investorVault: investorVaultPda,
1191
+ investorTokenAccount: args.investorTokenAccount,
1192
+ vaultAuthority: vaultAuthorityPda,
1193
+ tokenProgram: splToken.TOKEN_PROGRAM_ID
1194
+ }).rpc();
1195
+ }
1196
+ async function claimFounderMsInstantTokens(program, args, founder) {
1197
+ const projectPda = getProjectPDA(args.projectId, program.programId);
1198
+ const milestonePda = getMilestonePDA(projectPda, args.milestoneIndex, program.programId);
1199
+ const tokenomicsPda = getTokenomicsPDA(projectPda, program.programId);
1200
+ const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
1201
+ const vestingPda = getFounderMilestoneVestingPDA(projectPda, args.milestoneIndex, program.programId);
1202
+ const founderVaultPda = getFounderVaultPDA(projectPda, program.programId);
1203
+ const vaultAuthorityPda = getVaultAuthorityPDA(projectPda, program.programId);
1204
+ return getMethods(program).claimFounderMsInstantTokens({ milestoneIndex: args.milestoneIndex }).accountsPartial({
1205
+ founder,
1206
+ project: projectPda,
1207
+ tokenomics: tokenomicsPda,
1208
+ milestone: milestonePda,
1209
+ tokenVault: tokenVaultPda,
1210
+ vesting: vestingPda,
1211
+ founderVault: founderVaultPda,
1212
+ founderTokenAccount: args.founderTokenAccount,
1213
+ vaultAuthority: vaultAuthorityPda,
1214
+ tokenProgram: splToken.TOKEN_PROGRAM_ID,
1215
+ systemProgram: web3_js.SystemProgram.programId
1216
+ }).rpc();
1217
+ }
1218
+ async function claimFounderMsVestedTokens(program, args, founder) {
1219
+ const projectPda = getProjectPDA(args.projectId, program.programId);
1220
+ const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
1221
+ const vestingPda = getFounderMilestoneVestingPDA(projectPda, args.milestoneIndex, program.programId);
1222
+ const founderVaultPda = getFounderVaultPDA(projectPda, program.programId);
1223
+ const vaultAuthorityPda = getVaultAuthorityPDA(projectPda, program.programId);
1224
+ return getMethods(program).claimFounderMsVestedTokens({ milestoneIndex: args.milestoneIndex }).accountsPartial({
1225
+ founder,
1226
+ project: projectPda,
1227
+ tokenVault: tokenVaultPda,
1228
+ vesting: vestingPda,
1229
+ founderVault: founderVaultPda,
1230
+ founderTokenAccount: args.founderTokenAccount,
1231
+ vaultAuthority: vaultAuthorityPda,
1232
+ tokenProgram: splToken.TOKEN_PROGRAM_ID
1233
+ }).rpc();
1234
+ }
1235
+ function getRoundEscrowAuthorityPDA(projectPda, roundNumber, programId) {
1236
+ return web3_js.PublicKey.findProgramAddressSync(
1237
+ [
1238
+ Buffer.from("round_escrow"),
1239
+ projectPda.toBuffer(),
1240
+ Buffer.from([roundNumber]),
1241
+ Buffer.from("authority")
1242
+ ],
1243
+ programId
1244
+ );
1245
+ }
1246
+ async function openFundingRound(program, args, founder) {
1247
+ const projectPda = getProjectPDA(args.projectId, program.programId);
1248
+ const tokenomicsPda = getTokenomicsPDA(projectPda, program.programId);
1249
+ const project = await getAccountNamespace(program).project.fetch(projectPda);
1250
+ const newRoundNumber = (project.roundCount || 1) + 1;
1251
+ const fundingRoundPda = getFundingRoundPDA(projectPda, newRoundNumber, program.programId);
1252
+ const roundEscrowPda = getRoundEscrowPDA(projectPda, newRoundNumber, program.programId);
1253
+ const [roundEscrowAuthorityPda] = getRoundEscrowAuthorityPDA(projectPda, newRoundNumber, program.programId);
1254
+ const remainingAccounts = args.milestones.map((_, i) => {
1255
+ const milestonePda = getRoundMilestonePDA(projectPda, newRoundNumber, i, program.programId);
1256
+ return {
1257
+ pubkey: milestonePda,
1258
+ isSigner: false,
1259
+ isWritable: true
1260
+ };
1261
+ });
1262
+ const milestonesParam = args.milestones.map((m) => ({
1263
+ percentage: m.percentage,
1264
+ description: m.description,
1265
+ vestingDurationMonths: m.vestingDurationMonths ?? null,
1266
+ cliffMonths: m.cliffMonths ?? null,
1267
+ instantReleaseBps: m.instantReleaseBps ?? null
1268
+ }));
1269
+ return getMethods(program).openFundingRound({
1270
+ roundAllocationBps: args.roundAllocationBps,
1271
+ fundingGoal: args.fundingGoal,
1272
+ tiers: args.tiers,
1273
+ milestones: milestonesParam
1274
+ }).accountsPartial({
1275
+ project: projectPda,
1276
+ tokenomics: tokenomicsPda,
1277
+ fundingRound: fundingRoundPda,
1278
+ roundEscrow: roundEscrowPda,
1279
+ roundEscrowAuthority: roundEscrowAuthorityPda,
1280
+ usdcMint: args.usdcMint,
1281
+ previousFundingRound: args.previousFundingRoundPda ?? null,
1282
+ founder,
1283
+ tokenProgram: splToken.TOKEN_PROGRAM_ID,
1284
+ systemProgram: web3_js.SystemProgram.programId,
1285
+ rent: web3_js.SYSVAR_RENT_PUBKEY
1286
+ }).remainingAccounts(remainingAccounts).rpc();
1287
+ }
1288
+ async function investInRound(program, args, investor) {
1289
+ const projectPda = getProjectPDA(args.projectId, program.programId);
1290
+ const fundingRoundPda = getFundingRoundPDA(projectPda, args.roundNumber, program.programId);
1291
+ const roundEscrowPda = getRoundEscrowPDA(projectPda, args.roundNumber, program.programId);
1292
+ const firstRoundMilestonePda = getRoundMilestonePDA(projectPda, args.roundNumber, 0, program.programId);
1293
+ const [nftMint] = getRoundNftMintPDA(args.projectId, args.roundNumber, investor, args.investmentCount, program.programId);
1294
+ const investmentPda = getRoundInvestmentPDA(projectPda, args.roundNumber, nftMint, program.programId);
1295
+ const investorNftAccount = splToken.getAssociatedTokenAddressSync(nftMint, investor);
1296
+ const metadataAccount = getMetadataPDA(nftMint);
1297
+ const masterEdition = getMasterEditionPDA(nftMint);
1298
+ const [programAuthority] = getProgramAuthorityPDA(program.programId);
1299
+ return getMethods(program).investInRound({ amount: args.amount }).accountsPartial({
1300
+ project: projectPda,
1301
+ fundingRound: fundingRoundPda,
1302
+ firstRoundMilestone: firstRoundMilestonePda,
1303
+ nftMint,
1304
+ investment: investmentPda,
1305
+ investorNftAccount,
1306
+ metadataAccount,
1307
+ masterEdition,
1308
+ roundEscrow: roundEscrowPda,
1309
+ investorTokenAccount: args.investorTokenAccount,
1310
+ programAuthority,
1311
+ investor,
1312
+ tokenProgram: splToken.TOKEN_PROGRAM_ID,
1313
+ associatedTokenProgram: splToken.ASSOCIATED_TOKEN_PROGRAM_ID,
1314
+ systemProgram: web3_js.SystemProgram.programId,
1315
+ rent: web3_js.SYSVAR_RENT_PUBKEY,
1316
+ tokenMetadataProgram: TOKEN_METADATA_PROGRAM_ID,
1317
+ sysvarInstructions: web3_js.SYSVAR_INSTRUCTIONS_PUBKEY
1318
+ }).preInstructions([
1319
+ web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 })
1320
+ ]).rpc();
1321
+ }
1322
+ async function cancelRoundInvestment(program, args, investor) {
1323
+ const nftMintPubkey = ensurePublicKey(args.nftMint);
1324
+ const projectPda = getProjectPDA(args.projectId, program.programId);
1325
+ const fundingRoundPda = getFundingRoundPDA(projectPda, args.roundNumber, program.programId);
1326
+ const investmentPda = getRoundInvestmentPDA(projectPda, args.roundNumber, nftMintPubkey, program.programId);
1327
+ const roundEscrowPda = getRoundEscrowPDA(projectPda, args.roundNumber, program.programId);
1328
+ const [roundEscrowAuthorityPda] = getRoundEscrowAuthorityPDA(projectPda, args.roundNumber, program.programId);
1329
+ return getMethods(program).cancelRoundInvestment().accountsPartial({
1330
+ investor,
1331
+ project: projectPda,
1332
+ fundingRound: fundingRoundPda,
1333
+ investment: investmentPda,
1334
+ nftMint: nftMintPubkey,
1335
+ investorNftAccount: args.investorNftAccount,
1336
+ roundEscrow: roundEscrowPda,
1337
+ roundEscrowAuthority: roundEscrowAuthorityPda,
1338
+ investorUsdcAccount: args.investorUsdcAccount,
1339
+ tokenProgram: splToken.TOKEN_PROGRAM_ID
1340
+ }).rpc();
1341
+ }
1342
+ async function submitRoundMilestone(program, args, founder) {
1343
+ const projectPda = getProjectPDA(args.projectId, program.programId);
1344
+ const fundingRoundPda = getFundingRoundPDA(projectPda, args.roundNumber, program.programId);
1345
+ const milestonePda = getRoundMilestonePDA(projectPda, args.roundNumber, args.milestoneIndex, program.programId);
1346
+ return getMethods(program).submitRoundMilestone().accountsPartial({
1347
+ founder,
1348
+ project: projectPda,
1349
+ fundingRound: fundingRoundPda,
1350
+ milestone: milestonePda,
1351
+ clock: web3_js.SYSVAR_CLOCK_PUBKEY
1352
+ }).rpc();
1353
+ }
1354
+ async function voteOnRoundMilestone(program, args, voter) {
1355
+ const nftMintPubkey = ensurePublicKey(args.nftMint);
1356
+ const projectPda = getProjectPDA(args.projectId, program.programId);
1357
+ const fundingRoundPda = getFundingRoundPDA(projectPda, args.roundNumber, program.programId);
1358
+ const milestonePda = getRoundMilestonePDA(projectPda, args.roundNumber, args.milestoneIndex, program.programId);
1359
+ let investmentPda;
1360
+ if (args.investmentRoundNumber === 1) {
1361
+ investmentPda = getInvestmentPDA(projectPda, nftMintPubkey, program.programId);
1362
+ } else {
1363
+ investmentPda = getRoundInvestmentPDA(projectPda, args.investmentRoundNumber, nftMintPubkey, program.programId);
1364
+ }
1365
+ const milestone = await getAccountNamespace(program).milestone.fetch(milestonePda);
1366
+ const votingRound = milestone.votingRound ?? 0;
1367
+ const votePda = getVotePDA(milestonePda, voter, votingRound, program.programId);
1368
+ const voterNftAccount = splToken.getAssociatedTokenAddressSync(
1369
+ nftMintPubkey,
1370
+ voter,
1371
+ false,
1372
+ splToken.TOKEN_PROGRAM_ID
1373
+ );
1374
+ return getMethods(program).voteOnRoundMilestone({ choice: args.choice }).accountsPartial({
1375
+ vote: votePda,
1376
+ project: projectPda,
1377
+ fundingRound: fundingRoundPda,
1378
+ milestone: milestonePda,
1379
+ investment: investmentPda,
1380
+ nftMint: nftMintPubkey,
1381
+ voterNftAccount,
1382
+ voter,
1383
+ systemProgram: web3_js.SystemProgram.programId
1384
+ }).rpc();
1385
+ }
1386
+ async function finalizeRoundVoting(program, args) {
1387
+ const projectPda = getProjectPDA(args.projectId, program.programId);
1388
+ const fundingRoundPda = getFundingRoundPDA(projectPda, args.roundNumber, program.programId);
1389
+ const milestonePda = getRoundMilestonePDA(projectPda, args.roundNumber, args.milestoneIndex, program.programId);
1390
+ return getMethods(program).finalizeRoundVoting().accountsPartial({
1391
+ project: projectPda,
1392
+ fundingRound: fundingRoundPda,
1393
+ milestone: milestonePda,
1394
+ clock: web3_js.SYSVAR_CLOCK_PUBKEY
1395
+ }).rpc();
1396
+ }
1397
+ async function claimRoundMilestoneFunds(program, args, founder) {
1398
+ const projectPda = getProjectPDA(args.projectId, program.programId);
1399
+ const fundingRoundPda = getFundingRoundPDA(projectPda, args.roundNumber, program.programId);
1400
+ const milestonePda = getRoundMilestonePDA(projectPda, args.roundNumber, args.milestoneIndex, program.programId);
1401
+ const roundEscrowPda = getRoundEscrowPDA(projectPda, args.roundNumber, program.programId);
1402
+ const [roundEscrowAuthorityPda] = getRoundEscrowAuthorityPDA(projectPda, args.roundNumber, program.programId);
1403
+ const nextMilestonePda = args.nextMilestoneDeadline.gt(new anchor.BN(0)) ? getRoundMilestonePDA(projectPda, args.roundNumber, args.milestoneIndex + 1, program.programId) : null;
1404
+ return getMethods(program).claimRoundMilestoneFunds({ nextMilestoneDeadline: args.nextMilestoneDeadline }).accountsPartial({
1405
+ project: projectPda,
1406
+ fundingRound: fundingRoundPda,
1407
+ milestone: milestonePda,
1408
+ founder,
1409
+ roundEscrow: roundEscrowPda,
1410
+ roundEscrowAuthority: roundEscrowAuthorityPda,
1411
+ founderUsdcAccount: args.founderUsdcAccount,
1412
+ nextMilestone: nextMilestonePda,
1413
+ systemProgram: web3_js.SystemProgram.programId,
1414
+ tokenProgram: splToken.TOKEN_PROGRAM_ID
1415
+ }).rpc();
1416
+ }
1417
+ async function claimRoundInstantTokens(program, args, investor) {
1418
+ const nftMintPubkey = ensurePublicKey(args.nftMint);
1419
+ const projectPda = getProjectPDA(args.projectId, program.programId);
1420
+ const fundingRoundPda = getFundingRoundPDA(projectPda, args.roundNumber, program.programId);
1421
+ const milestonePda = getRoundMilestonePDA(projectPda, args.roundNumber, args.milestoneIndex, program.programId);
1422
+ const investmentPda = getRoundInvestmentPDA(projectPda, args.roundNumber, nftMintPubkey, program.programId);
1423
+ const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
1424
+ const futureRoundVaultPda = getFutureRoundVaultPDA(projectPda, program.programId);
1425
+ const futureRoundTokenVaultPda = getFutureRoundTokenVaultPDA(projectPda, program.programId);
1426
+ const vaultAuthorityPda = getVaultAuthorityPDA(projectPda, program.programId);
1427
+ const vestingPda = getRoundInvestorMilestoneVestingPDA(
1428
+ projectPda,
1429
+ args.roundNumber,
1430
+ args.milestoneIndex,
1431
+ investmentPda,
1432
+ program.programId
1433
+ );
1434
+ const investorNftAccount = splToken.getAssociatedTokenAddressSync(
1435
+ nftMintPubkey,
1436
+ investor,
1437
+ false,
1438
+ splToken.TOKEN_PROGRAM_ID
1439
+ );
1440
+ return getMethods(program).claimRoundInstantTokens({ milestoneIndex: args.milestoneIndex }).accountsPartial({
1441
+ investor,
1442
+ project: projectPda,
1443
+ fundingRound: fundingRoundPda,
1444
+ milestone: milestonePda,
1445
+ investment: investmentPda,
1446
+ tokenVault: tokenVaultPda,
1447
+ futureRoundVault: futureRoundVaultPda,
1448
+ vesting: vestingPda,
1449
+ nftMint: nftMintPubkey,
1450
+ investorNftAccount,
1451
+ futureRoundTokenVault: futureRoundTokenVaultPda,
1452
+ investorTokenAccount: args.investorTokenAccount,
1453
+ vaultAuthority: vaultAuthorityPda,
1454
+ tokenProgram: splToken.TOKEN_PROGRAM_ID,
1455
+ systemProgram: web3_js.SystemProgram.programId
1456
+ }).rpc();
1457
+ }
1458
+ async function claimRoundVestedTokens(program, args, investor) {
1459
+ const nftMintPubkey = ensurePublicKey(args.nftMint);
1460
+ const projectPda = getProjectPDA(args.projectId, program.programId);
1461
+ const fundingRoundPda = getFundingRoundPDA(projectPda, args.roundNumber, program.programId);
1462
+ const milestonePda = getRoundMilestonePDA(projectPda, args.roundNumber, args.milestoneIndex, program.programId);
1463
+ const investmentPda = getRoundInvestmentPDA(projectPda, args.roundNumber, nftMintPubkey, program.programId);
1464
+ const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
1465
+ const futureRoundVaultPda = getFutureRoundVaultPDA(projectPda, program.programId);
1466
+ const futureRoundTokenVaultPda = getFutureRoundTokenVaultPDA(projectPda, program.programId);
1467
+ const vaultAuthorityPda = getVaultAuthorityPDA(projectPda, program.programId);
1468
+ const vestingPda = getRoundInvestorMilestoneVestingPDA(
1469
+ projectPda,
1470
+ args.roundNumber,
1471
+ args.milestoneIndex,
1472
+ investmentPda,
1473
+ program.programId
1474
+ );
1475
+ const investorNftAccount = splToken.getAssociatedTokenAddressSync(
1476
+ nftMintPubkey,
1477
+ investor,
1478
+ false,
1479
+ splToken.TOKEN_PROGRAM_ID
1480
+ );
1481
+ return getMethods(program).claimRoundVestedTokens({ milestoneIndex: args.milestoneIndex }).accountsPartial({
1482
+ investor,
1483
+ project: projectPda,
1484
+ fundingRound: fundingRoundPda,
1485
+ milestone: milestonePda,
1486
+ investment: investmentPda,
1487
+ tokenVault: tokenVaultPda,
1488
+ futureRoundVault: futureRoundVaultPda,
1489
+ vesting: vestingPda,
1490
+ nftMint: nftMintPubkey,
1491
+ investorNftAccount,
1492
+ futureRoundTokenVault: futureRoundTokenVaultPda,
1493
+ investorTokenAccount: args.investorTokenAccount,
1494
+ vaultAuthority: vaultAuthorityPda,
1495
+ tokenProgram: splToken.TOKEN_PROGRAM_ID
1496
+ }).rpc();
1497
+ }
1498
+ async function claimRoundEarlyTokens(program, args, investor) {
1499
+ const nftMintPubkey = ensurePublicKey(args.nftMint);
1500
+ const projectPda = getProjectPDA(args.projectId, program.programId);
1501
+ const fundingRoundPda = getFundingRoundPDA(projectPda, args.roundNumber, program.programId);
1502
+ const investmentPda = getRoundInvestmentPDA(projectPda, args.roundNumber, nftMintPubkey, program.programId);
1503
+ const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
1504
+ const futureRoundVaultPda = getFutureRoundVaultPDA(projectPda, program.programId);
1505
+ const futureRoundTokenVaultPda = getFutureRoundTokenVaultPDA(projectPda, program.programId);
1506
+ const vaultAuthorityPda = getVaultAuthorityPDA(projectPda, program.programId);
1507
+ const investorNftAccount = splToken.getAssociatedTokenAddressSync(
1508
+ nftMintPubkey,
1509
+ investor,
1510
+ false,
1511
+ splToken.TOKEN_PROGRAM_ID
1512
+ );
1513
+ return getMethods(program).claimRoundEarlyTokens().accountsPartial({
1514
+ investor,
1515
+ project: projectPda,
1516
+ fundingRound: fundingRoundPda,
1517
+ investment: investmentPda,
1518
+ tokenVault: tokenVaultPda,
1519
+ futureRoundVault: futureRoundVaultPda,
1520
+ nftMint: nftMintPubkey,
1521
+ investorNftAccount,
1522
+ futureRoundTokenVault: futureRoundTokenVaultPda,
1523
+ investorTokenAccount: args.investorTokenAccount,
1524
+ vaultAuthority: vaultAuthorityPda,
1525
+ tokenProgram: splToken.TOKEN_PROGRAM_ID
1526
+ }).rpc();
1527
+ }
808
1528
 
809
1529
  exports.MAX_DEADLINE_DURATION_SECONDS = MAX_DEADLINE_DURATION_SECONDS;
810
1530
  exports.MIN_DEADLINE_DURATION_SECONDS_DEV = MIN_DEADLINE_DURATION_SECONDS_DEV;
811
1531
  exports.MIN_DEADLINE_DURATION_SECONDS_PROD = MIN_DEADLINE_DURATION_SECONDS_PROD;
812
1532
  exports.acceptAdmin = acceptAdmin;
1533
+ exports.addSubAllocation = addSubAllocation;
813
1534
  exports.approvePivot = approvePivot;
814
1535
  exports.approveProject = approveProject;
815
1536
  exports.calculateDeadline = calculateDeadline;
816
1537
  exports.cancelInvestment = cancelInvestment;
1538
+ exports.cancelRoundInvestment = cancelRoundInvestment;
817
1539
  exports.checkAbandonment = checkAbandonment;
1540
+ exports.claimEarlyTokens = claimEarlyTokens;
818
1541
  exports.claimExitWindowRefund = claimExitWindowRefund;
1542
+ exports.claimFounderEarlyTokens = claimFounderEarlyTokens;
1543
+ exports.claimFounderMilestoneTokens = claimFounderMilestoneTokens;
1544
+ exports.claimFounderMsInstantTokens = claimFounderMsInstantTokens;
1545
+ exports.claimFounderMsVestedTokens = claimFounderMsVestedTokens;
819
1546
  exports.claimInvestorTokens = claimInvestorTokens;
820
1547
  exports.claimMilestoneFunds = claimMilestoneFunds;
1548
+ exports.claimMilestoneInstantTokens = claimMilestoneInstantTokens;
1549
+ exports.claimMilestoneVestedTokens = claimMilestoneVestedTokens;
821
1550
  exports.claimMissedUnlock = claimMissedUnlock;
822
1551
  exports.claimRefund = claimRefund;
1552
+ exports.claimRoundEarlyTokens = claimRoundEarlyTokens;
1553
+ exports.claimRoundInstantTokens = claimRoundInstantTokens;
1554
+ exports.claimRoundMilestoneFunds = claimRoundMilestoneFunds;
1555
+ exports.claimRoundVestedTokens = claimRoundVestedTokens;
1556
+ exports.claimSubAllocationTokens = claimSubAllocationTokens;
823
1557
  exports.claimTokens = claimTokens;
824
1558
  exports.claimVestedTokens = claimVestedTokens;
825
1559
  exports.completeDistribution = completeDistribution;
826
1560
  exports.createMilestone = createMilestone;
827
1561
  exports.depositTokens = depositTokens;
828
1562
  exports.distributeTokens = distributeTokens;
1563
+ exports.executeAllocationChange = executeAllocationChange;
829
1564
  exports.extendMilestoneDeadline = extendMilestoneDeadline;
830
1565
  exports.finalizePivot = finalizePivot;
1566
+ exports.finalizeRoundVoting = finalizeRoundVoting;
831
1567
  exports.finalizeVoting = finalizeVoting;
832
1568
  exports.forceCompleteDistribution = forceCompleteDistribution;
833
1569
  exports.initializeAdmin = initializeAdmin;
834
1570
  exports.initializeFounderVesting = initializeFounderVesting;
835
1571
  exports.initializeProject = initializeProject;
1572
+ exports.initializeSubAllocationVesting = initializeSubAllocationVesting;
836
1573
  exports.invest = invest;
1574
+ exports.investInRound = investInRound;
837
1575
  exports.minDeadline = minDeadline;
1576
+ exports.openFundingRound = openFundingRound;
1577
+ exports.proposeAllocationChange = proposeAllocationChange;
838
1578
  exports.proposePivot = proposePivot;
839
1579
  exports.releaseHoldback = releaseHoldback;
840
1580
  exports.reportScam = reportScam;
@@ -843,10 +1583,13 @@ exports.setMilestoneDeadline = setMilestoneDeadline;
843
1583
  exports.setTgeDate = setTgeDate;
844
1584
  exports.submitForApproval = submitForApproval;
845
1585
  exports.submitMilestone = submitMilestone;
1586
+ exports.submitRoundMilestone = submitRoundMilestone;
846
1587
  exports.symbolToBytes = symbolToBytes;
847
1588
  exports.transferAdmin = transferAdmin;
848
1589
  exports.validateDeadline = validateDeadline;
1590
+ exports.voteAllocationChange = voteAllocationChange;
849
1591
  exports.voteOnMilestone = voteOnMilestone;
1592
+ exports.voteOnRoundMilestone = voteOnRoundMilestone;
850
1593
  exports.withdrawFromPivot = withdrawFromPivot;
851
1594
  //# sourceMappingURL=index.cjs.map
852
1595
  //# sourceMappingURL=index.cjs.map