@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.
- package/dist/accounts/index.cjs +2 -14
- package/dist/accounts/index.cjs.map +1 -1
- package/dist/accounts/index.d.cts +2 -1
- package/dist/accounts/index.d.ts +2 -1
- package/dist/accounts/index.js +2 -14
- package/dist/accounts/index.js.map +1 -1
- package/dist/constants/index.cjs +1 -0
- package/dist/constants/index.cjs.map +1 -1
- package/dist/constants/index.d.cts +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +1 -0
- package/dist/constants/index.js.map +1 -1
- package/dist/index.cjs +26 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +26 -8
- package/dist/index.js.map +1 -1
- package/dist/instructions/index.cjs +17 -15
- package/dist/instructions/index.cjs.map +1 -1
- package/dist/instructions/index.d.cts +4 -0
- package/dist/instructions/index.d.ts +4 -0
- package/dist/instructions/index.js +17 -15
- package/dist/instructions/index.js.map +1 -1
- package/dist/pdas/index.cjs +9 -0
- package/dist/pdas/index.cjs.map +1 -1
- package/dist/pdas/index.d.cts +15 -1
- package/dist/pdas/index.d.ts +15 -1
- package/dist/pdas/index.js +9 -1
- package/dist/pdas/index.js.map +1 -1
- package/package.json +1 -1
- package/src/accounts/index.ts +3 -2
- package/src/client.ts +9 -2
- package/src/constants/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/instructions/index.ts +17 -6
- package/src/pdas/index.ts +21 -0
package/src/client.ts
CHANGED
|
@@ -130,6 +130,10 @@ export class RaiseClient {
|
|
|
130
130
|
return pdas.getEscrowPDA(projectId, this.programId);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
getEscrowTokenAccountPDA(projectPda: PublicKey): PublicKey {
|
|
134
|
+
return pdas.getEscrowTokenAccountPDA(projectPda, this.programId);
|
|
135
|
+
}
|
|
136
|
+
|
|
133
137
|
getMilestonePDA(projectPda: PublicKey, milestoneIndex: number): PublicKey {
|
|
134
138
|
return pdas.getMilestonePDA(projectPda, milestoneIndex, this.programId);
|
|
135
139
|
}
|
|
@@ -175,6 +179,7 @@ export class RaiseClient {
|
|
|
175
179
|
}
|
|
176
180
|
|
|
177
181
|
// Per-Milestone Vesting PDAs
|
|
182
|
+
/** @deprecated Use {@link getRoundInvestorMilestoneVestingPDA} instead */
|
|
178
183
|
getInvestorMilestoneVestingPDA(projectPda: PublicKey, milestoneIndex: number, investmentPda: PublicKey): PublicKey {
|
|
179
184
|
return pdas.getInvestorMilestoneVestingPDA(projectPda, milestoneIndex, investmentPda, this.programId);
|
|
180
185
|
}
|
|
@@ -251,8 +256,8 @@ export class RaiseClient {
|
|
|
251
256
|
return accounts.fetchSubAllocationVesting(this.program, projectId, subAllocationId);
|
|
252
257
|
}
|
|
253
258
|
|
|
254
|
-
async fetchInvestorMilestoneVesting(projectId: BN, milestoneIndex: number, nftMint: PublicKey) {
|
|
255
|
-
return accounts.fetchInvestorMilestoneVesting(this.program, projectId, milestoneIndex, nftMint);
|
|
259
|
+
async fetchInvestorMilestoneVesting(projectId: BN, roundNumber: number, milestoneIndex: number, nftMint: PublicKey) {
|
|
260
|
+
return accounts.fetchInvestorMilestoneVesting(this.program, projectId, roundNumber, milestoneIndex, nftMint);
|
|
256
261
|
}
|
|
257
262
|
|
|
258
263
|
async fetchFounderMilestoneVesting(projectId: BN, milestoneIndex: number) {
|
|
@@ -834,6 +839,7 @@ export class RaiseClient {
|
|
|
834
839
|
*/
|
|
835
840
|
async claimMilestoneInstantTokens(args: {
|
|
836
841
|
projectId: BN;
|
|
842
|
+
roundNumber: number;
|
|
837
843
|
milestoneIndex: number;
|
|
838
844
|
nftMint: PublicKey;
|
|
839
845
|
investorTokenAccount: PublicKey;
|
|
@@ -858,6 +864,7 @@ export class RaiseClient {
|
|
|
858
864
|
*/
|
|
859
865
|
async claimMilestoneVestedTokens(args: {
|
|
860
866
|
projectId: BN;
|
|
867
|
+
roundNumber: number;
|
|
861
868
|
milestoneIndex: number;
|
|
862
869
|
nftMint: PublicKey;
|
|
863
870
|
investorTokenAccount: PublicKey;
|
package/src/constants/index.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { PublicKey, Keypair, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RENT_PUBKEY, SYS
|
|
|
10
10
|
import {
|
|
11
11
|
getProjectPDA,
|
|
12
12
|
getEscrowPDA,
|
|
13
|
+
getEscrowTokenAccountPDA,
|
|
13
14
|
getMilestonePDA,
|
|
14
15
|
getInvestmentPDA,
|
|
15
16
|
getVotePDA,
|
|
@@ -31,7 +32,6 @@ import {
|
|
|
31
32
|
getFounderVestingPDA,
|
|
32
33
|
getSubAllocationVestingPDA,
|
|
33
34
|
// Per-Milestone Vesting PDAs
|
|
34
|
-
getInvestorMilestoneVestingPDA,
|
|
35
35
|
getFounderMilestoneVestingPDA,
|
|
36
36
|
// Future Round PDAs
|
|
37
37
|
getFutureRoundTokenVaultPDA,
|
|
@@ -379,8 +379,10 @@ export async function approveProject(
|
|
|
379
379
|
const lpUsdcVaultPda = getLpUsdcVaultPDA(projectPda, program.programId);
|
|
380
380
|
const futureRoundTokenVaultPda = getFutureRoundTokenVaultPDA(projectPda, program.programId);
|
|
381
381
|
const futureRoundVaultPda = getFutureRoundVaultPDA(projectPda, program.programId);
|
|
382
|
+
const escrowPda = getEscrowPDA(args.projectId, program.programId);
|
|
383
|
+
const escrowTokenAccountPda = getEscrowTokenAccountPDA(projectPda, program.programId);
|
|
382
384
|
|
|
383
|
-
// Request 400k CUs - this instruction creates
|
|
385
|
+
// Request 400k CUs - this instruction creates 11 accounts + 7 CPIs + 5 events
|
|
384
386
|
const computeBudgetIx = ComputeBudgetProgram.setComputeUnitLimit({
|
|
385
387
|
units: 400_000,
|
|
386
388
|
});
|
|
@@ -401,6 +403,8 @@ export async function approveProject(
|
|
|
401
403
|
futureRoundTokenVault: futureRoundTokenVaultPda,
|
|
402
404
|
futureRoundVault: futureRoundVaultPda,
|
|
403
405
|
usdcMint: args.usdcMint,
|
|
406
|
+
escrowPda,
|
|
407
|
+
escrowTokenAccount: escrowTokenAccountPda,
|
|
404
408
|
authority: adminPubkey,
|
|
405
409
|
payer: adminPubkey,
|
|
406
410
|
})
|
|
@@ -584,11 +588,14 @@ export async function claimMilestoneFunds(
|
|
|
584
588
|
const lpUsdcVaultPda = getLpUsdcVaultPDA(projectPda, program.programId);
|
|
585
589
|
|
|
586
590
|
// For non-final milestones, derive next milestone PDA if not provided
|
|
591
|
+
const isFinal = args.nextMilestoneDeadline.eq(new BN(0));
|
|
587
592
|
const nextMilestonePda = args.nextMilestonePda ??
|
|
588
|
-
(
|
|
593
|
+
(!isFinal
|
|
589
594
|
? getMilestonePDA(projectPda, args.milestoneIndex + 1, program.programId)
|
|
590
595
|
: null);
|
|
591
596
|
|
|
597
|
+
// Pass null for optional next_milestone on final milestone —
|
|
598
|
+
// Anchor's resolveOptionals converts null → programId sentinel for Option<Account> = None
|
|
592
599
|
return getMethods(program)
|
|
593
600
|
.claimMilestoneFunds({ nextMilestoneDeadline: args.nextMilestoneDeadline })
|
|
594
601
|
.accountsPartial({
|
|
@@ -601,7 +608,7 @@ export async function claimMilestoneFunds(
|
|
|
601
608
|
tokenVault: tokenVaultPda,
|
|
602
609
|
tokenomics: tokenomicsPda,
|
|
603
610
|
lpUsdcVault: lpUsdcVaultPda,
|
|
604
|
-
nextMilestone: nextMilestonePda,
|
|
611
|
+
nextMilestone: nextMilestonePda, // null for final → Anchor uses programId sentinel
|
|
605
612
|
systemProgram: SystemProgram.programId,
|
|
606
613
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
607
614
|
})
|
|
@@ -1990,6 +1997,8 @@ export async function claimMilestoneInstantTokens(
|
|
|
1990
1997
|
program: AnyProgram,
|
|
1991
1998
|
args: {
|
|
1992
1999
|
projectId: BN;
|
|
2000
|
+
/** Round number the investment belongs to */
|
|
2001
|
+
roundNumber: number;
|
|
1993
2002
|
/** Milestone index to claim instant tokens from */
|
|
1994
2003
|
milestoneIndex: number;
|
|
1995
2004
|
/** NFT mint that proves investment ownership */
|
|
@@ -2004,7 +2013,7 @@ export async function claimMilestoneInstantTokens(
|
|
|
2004
2013
|
const milestonePda = getMilestonePDA(projectPda, args.milestoneIndex, program.programId);
|
|
2005
2014
|
const investmentPda = getInvestmentPDA(projectPda, nftMintPubkey, program.programId);
|
|
2006
2015
|
const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
|
|
2007
|
-
const vestingPda =
|
|
2016
|
+
const vestingPda = getRoundInvestorMilestoneVestingPDA(projectPda, args.roundNumber, args.milestoneIndex, investmentPda, program.programId);
|
|
2008
2017
|
const investorVaultPda = getInvestorVaultPDA(projectPda, program.programId);
|
|
2009
2018
|
const vaultAuthorityPda = getVaultAuthorityPDA(projectPda, program.programId);
|
|
2010
2019
|
|
|
@@ -2056,6 +2065,8 @@ export async function claimMilestoneVestedTokens(
|
|
|
2056
2065
|
program: AnyProgram,
|
|
2057
2066
|
args: {
|
|
2058
2067
|
projectId: BN;
|
|
2068
|
+
/** Round number the investment belongs to */
|
|
2069
|
+
roundNumber: number;
|
|
2059
2070
|
/** Milestone index to claim vested tokens from */
|
|
2060
2071
|
milestoneIndex: number;
|
|
2061
2072
|
/** NFT mint that proves investment ownership */
|
|
@@ -2070,7 +2081,7 @@ export async function claimMilestoneVestedTokens(
|
|
|
2070
2081
|
const milestonePda = getMilestonePDA(projectPda, args.milestoneIndex, program.programId);
|
|
2071
2082
|
const investmentPda = getInvestmentPDA(projectPda, nftMintPubkey, program.programId);
|
|
2072
2083
|
const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
|
|
2073
|
-
const vestingPda =
|
|
2084
|
+
const vestingPda = getRoundInvestorMilestoneVestingPDA(projectPda, args.roundNumber, args.milestoneIndex, investmentPda, program.programId);
|
|
2074
2085
|
const investorVaultPda = getInvestorVaultPDA(projectPda, program.programId);
|
|
2075
2086
|
const vaultAuthorityPda = getVaultAuthorityPDA(projectPda, program.programId);
|
|
2076
2087
|
|
package/src/pdas/index.ts
CHANGED
|
@@ -57,6 +57,24 @@ export function getEscrowPDA(projectId: BN | number | string, programId: PublicK
|
|
|
57
57
|
return pda;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Derive Escrow Token Account PDA from project PDA
|
|
62
|
+
*
|
|
63
|
+
* This is the USDC token account owned by the escrow PDA,
|
|
64
|
+
* created during approveProject.
|
|
65
|
+
*
|
|
66
|
+
* @param projectPda - Project account PDA
|
|
67
|
+
* @param programId - Raise program ID
|
|
68
|
+
* @returns Escrow token account PDA
|
|
69
|
+
*/
|
|
70
|
+
export function getEscrowTokenAccountPDA(projectPda: PublicKey, programId: PublicKey): PublicKey {
|
|
71
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
72
|
+
[Buffer.from(SEEDS.ESCROW_TOKEN), projectPda.toBuffer()],
|
|
73
|
+
programId
|
|
74
|
+
);
|
|
75
|
+
return pda;
|
|
76
|
+
}
|
|
77
|
+
|
|
60
78
|
/**
|
|
61
79
|
* Derive Milestone PDA from project PDA and milestone index
|
|
62
80
|
*
|
|
@@ -487,6 +505,9 @@ export function getSubAllocationVestingPDA(
|
|
|
487
505
|
* Derive InvestorMilestoneVesting PDA
|
|
488
506
|
* Tracks investor vesting for a specific milestone with configurable schedules
|
|
489
507
|
*
|
|
508
|
+
* @deprecated Use {@link getRoundInvestorMilestoneVestingPDA} instead, which includes the `roundNumber` seed
|
|
509
|
+
* for correct multi-round PDA derivation.
|
|
510
|
+
*
|
|
490
511
|
* @param projectPda - Project account PDA
|
|
491
512
|
* @param milestoneIndex - Milestone index
|
|
492
513
|
* @param investmentPda - Investment account PDA
|