@zemyth/raise-sdk 0.1.7 → 0.3.0

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.
@@ -634,6 +634,8 @@ declare function claimSubAllocationTokens(program: AnyProgram, args: {
634
634
  */
635
635
  declare function claimMilestoneInstantTokens(program: AnyProgram, args: {
636
636
  projectId: BN;
637
+ /** Round number the investment belongs to */
638
+ roundNumber: number;
637
639
  /** Milestone index to claim instant tokens from */
638
640
  milestoneIndex: number;
639
641
  /** NFT mint that proves investment ownership */
@@ -659,6 +661,8 @@ declare function claimMilestoneInstantTokens(program: AnyProgram, args: {
659
661
  */
660
662
  declare function claimMilestoneVestedTokens(program: AnyProgram, args: {
661
663
  projectId: BN;
664
+ /** Round number the investment belongs to */
665
+ roundNumber: number;
662
666
  /** Milestone index to claim vested tokens from */
663
667
  milestoneIndex: number;
664
668
  /** NFT mint that proves investment ownership */
@@ -634,6 +634,8 @@ declare function claimSubAllocationTokens(program: AnyProgram, args: {
634
634
  */
635
635
  declare function claimMilestoneInstantTokens(program: AnyProgram, args: {
636
636
  projectId: BN;
637
+ /** Round number the investment belongs to */
638
+ roundNumber: number;
637
639
  /** Milestone index to claim instant tokens from */
638
640
  milestoneIndex: number;
639
641
  /** NFT mint that proves investment ownership */
@@ -659,6 +661,8 @@ declare function claimMilestoneInstantTokens(program: AnyProgram, args: {
659
661
  */
660
662
  declare function claimMilestoneVestedTokens(program: AnyProgram, args: {
661
663
  projectId: BN;
664
+ /** Round number the investment belongs to */
665
+ roundNumber: number;
662
666
  /** Milestone index to claim vested tokens from */
663
667
  milestoneIndex: number;
664
668
  /** NFT mint that proves investment ownership */
@@ -11,6 +11,7 @@ var SEEDS = {
11
11
  INVESTMENT: "investment",
12
12
  VOTE: "vote",
13
13
  ESCROW: "escrow",
14
+ ESCROW_TOKEN: "escrow_token",
14
15
  PIVOT: "pivot",
15
16
  TGE_ESCROW: "tge_escrow",
16
17
  ADMIN_CONFIG: "admin-config",
@@ -47,6 +48,13 @@ function getEscrowPDA(projectId, programId) {
47
48
  );
48
49
  return pda;
49
50
  }
51
+ function getEscrowTokenAccountPDA(projectPda, programId) {
52
+ const [pda] = PublicKey.findProgramAddressSync(
53
+ [Buffer.from(SEEDS.ESCROW_TOKEN), projectPda.toBuffer()],
54
+ programId
55
+ );
56
+ return pda;
57
+ }
50
58
  function getMilestonePDA(projectPda, milestoneIndex, programId) {
51
59
  const [pda] = PublicKey.findProgramAddressSync(
52
60
  [
@@ -226,18 +234,6 @@ function getSubAllocationVestingPDA(projectPda, subAllocationId, programId) {
226
234
  );
227
235
  return pda;
228
236
  }
229
- function getInvestorMilestoneVestingPDA(projectPda, milestoneIndex, investmentPda, programId) {
230
- const [pda] = PublicKey.findProgramAddressSync(
231
- [
232
- Buffer.from("investor_ms_vesting"),
233
- projectPda.toBuffer(),
234
- Buffer.from([milestoneIndex]),
235
- investmentPda.toBuffer()
236
- ],
237
- programId
238
- );
239
- return pda;
240
- }
241
237
  function getFounderMilestoneVestingPDA(projectPda, milestoneIndex, programId) {
242
238
  const [pda] = PublicKey.findProgramAddressSync(
243
239
  [
@@ -459,6 +455,8 @@ async function approveProject(program, args, admin) {
459
455
  const lpUsdcVaultPda = getLpUsdcVaultPDA(projectPda, program.programId);
460
456
  const futureRoundTokenVaultPda = getFutureRoundTokenVaultPDA(projectPda, program.programId);
461
457
  const futureRoundVaultPda = getFutureRoundVaultPDA(projectPda, program.programId);
458
+ const escrowPda = getEscrowPDA(args.projectId, program.programId);
459
+ const escrowTokenAccountPda = getEscrowTokenAccountPDA(projectPda, program.programId);
462
460
  const computeBudgetIx = ComputeBudgetProgram.setComputeUnitLimit({
463
461
  units: 4e5
464
462
  });
@@ -476,6 +474,8 @@ async function approveProject(program, args, admin) {
476
474
  futureRoundTokenVault: futureRoundTokenVaultPda,
477
475
  futureRoundVault: futureRoundVaultPda,
478
476
  usdcMint: args.usdcMint,
477
+ escrowPda,
478
+ escrowTokenAccount: escrowTokenAccountPda,
479
479
  authority: adminPubkey,
480
480
  payer: adminPubkey
481
481
  }).preInstructions([computeBudgetIx]);
@@ -549,7 +549,8 @@ async function claimMilestoneFunds(program, args, founder) {
549
549
  const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
550
550
  const tokenomicsPda = getTokenomicsPDA(projectPda, program.programId);
551
551
  const lpUsdcVaultPda = getLpUsdcVaultPDA(projectPda, program.programId);
552
- const nextMilestonePda = args.nextMilestonePda ?? (args.nextMilestoneDeadline.gt(new BN(0)) ? getMilestonePDA(projectPda, args.milestoneIndex + 1, program.programId) : null);
552
+ const isFinal = args.nextMilestoneDeadline.eq(new BN(0));
553
+ const nextMilestonePda = args.nextMilestonePda ?? (!isFinal ? getMilestonePDA(projectPda, args.milestoneIndex + 1, program.programId) : null);
553
554
  return getMethods(program).claimMilestoneFunds({ nextMilestoneDeadline: args.nextMilestoneDeadline }).accountsPartial({
554
555
  milestone: milestonePda,
555
556
  project: projectPda,
@@ -561,6 +562,7 @@ async function claimMilestoneFunds(program, args, founder) {
561
562
  tokenomics: tokenomicsPda,
562
563
  lpUsdcVault: lpUsdcVaultPda,
563
564
  nextMilestone: nextMilestonePda,
565
+ // null for final → Anchor uses programId sentinel
564
566
  systemProgram: SystemProgram.programId,
565
567
  tokenProgram: TOKEN_PROGRAM_ID
566
568
  }).rpc();
@@ -1141,7 +1143,7 @@ async function claimMilestoneInstantTokens(program, args, investor) {
1141
1143
  const milestonePda = getMilestonePDA(projectPda, args.milestoneIndex, program.programId);
1142
1144
  const investmentPda = getInvestmentPDA(projectPda, nftMintPubkey, program.programId);
1143
1145
  const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
1144
- const vestingPda = getInvestorMilestoneVestingPDA(projectPda, args.milestoneIndex, investmentPda, program.programId);
1146
+ const vestingPda = getRoundInvestorMilestoneVestingPDA(projectPda, args.roundNumber, args.milestoneIndex, investmentPda, program.programId);
1145
1147
  const investorVaultPda = getInvestorVaultPDA(projectPda, program.programId);
1146
1148
  const vaultAuthorityPda = getVaultAuthorityPDA(projectPda, program.programId);
1147
1149
  const investorNftAccount = getAssociatedTokenAddressSync(
@@ -1172,7 +1174,7 @@ async function claimMilestoneVestedTokens(program, args, investor) {
1172
1174
  const milestonePda = getMilestonePDA(projectPda, args.milestoneIndex, program.programId);
1173
1175
  const investmentPda = getInvestmentPDA(projectPda, nftMintPubkey, program.programId);
1174
1176
  const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
1175
- const vestingPda = getInvestorMilestoneVestingPDA(projectPda, args.milestoneIndex, investmentPda, program.programId);
1177
+ const vestingPda = getRoundInvestorMilestoneVestingPDA(projectPda, args.roundNumber, args.milestoneIndex, investmentPda, program.programId);
1176
1178
  const investorVaultPda = getInvestorVaultPDA(projectPda, program.programId);
1177
1179
  const vaultAuthorityPda = getVaultAuthorityPDA(projectPda, program.programId);
1178
1180
  const investorNftAccount = getAssociatedTokenAddressSync(