@zemyth/raise-sdk 0.1.2 → 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 +9 -7
  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 +2 -1
  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
@@ -1,6 +1,6 @@
1
1
  import { Program, BN } from '@coral-xyz/anchor';
2
2
  import { PublicKey } from '@solana/web3.js';
3
- import { MilestoneWithKey, InvestmentWithKey, VoteWithKey } from '../types/index.js';
3
+ import { MilestoneWithKey, InvestmentWithKey, VoteWithKey, FundingRoundWithKey, AllocationProposalWithKey } from '../types/index.js';
4
4
 
5
5
  /**
6
6
  * Raise Account Fetchers
@@ -102,6 +102,14 @@ declare function fetchTgeEscrow(program: AnyProgram, projectId: BN): Promise<any
102
102
  * @returns AdminConfig account data
103
103
  */
104
104
  declare function fetchAdminConfig(program: AnyProgram): Promise<any>;
105
+ /**
106
+ * Fetch token vault account data
107
+ *
108
+ * @param program - Anchor program instance
109
+ * @param projectId - Project identifier
110
+ * @returns TokenVault account data or null if not found
111
+ */
112
+ declare function fetchTokenVault(program: AnyProgram, projectId: BN): Promise<any>;
105
113
  /**
106
114
  * Check if an account exists
107
115
  *
@@ -111,5 +119,302 @@ declare function fetchAdminConfig(program: AnyProgram): Promise<any>;
111
119
  * @returns True if account exists
112
120
  */
113
121
  declare function accountExists(program: AnyProgram, accountType: string, pda: PublicKey): Promise<boolean>;
122
+ /**
123
+ * Fetch tokenomics account data
124
+ *
125
+ * @param program - Anchor program instance
126
+ * @param projectId - Project identifier
127
+ * @returns Tokenomics account data or null if not found
128
+ */
129
+ declare function fetchTokenomics(program: AnyProgram, projectId: BN): Promise<any>;
130
+ /**
131
+ * Fetch allocation proposal account data
132
+ *
133
+ * @param program - Anchor program instance
134
+ * @param projectId - Project identifier
135
+ * @param proposalIndex - Proposal index
136
+ * @returns AllocationProposal account data or null if not found
137
+ */
138
+ declare function fetchAllocationProposal(program: AnyProgram, projectId: BN, proposalIndex: number): Promise<any>;
139
+ /**
140
+ * Fetch all allocation proposals for a project
141
+ *
142
+ * @param program - Anchor program instance
143
+ * @param projectId - Project identifier
144
+ * @returns Array of allocation proposal accounts with their public keys
145
+ */
146
+ declare function fetchAllAllocationProposals(program: AnyProgram, projectId: BN): Promise<AllocationProposalWithKey[]>;
147
+ /**
148
+ * Fetch allocation vote account data
149
+ *
150
+ * @param program - Anchor program instance
151
+ * @param projectId - Project identifier
152
+ * @param proposalIndex - Proposal index
153
+ * @param nftMint - NFT mint used for voting
154
+ * @returns AllocationVote account data or null if not found
155
+ */
156
+ declare function fetchAllocationVote(program: AnyProgram, projectId: BN, proposalIndex: number, nftMint: PublicKey): Promise<any>;
157
+ /**
158
+ * Fetch sub-allocation vesting account data
159
+ *
160
+ * @param program - Anchor program instance
161
+ * @param projectId - Project identifier
162
+ * @param subAllocationId - Sub-allocation ID (0-9)
163
+ * @returns SubAllocationVesting account data or null if not found
164
+ */
165
+ declare function fetchSubAllocationVesting(program: AnyProgram, projectId: BN, subAllocationId: number): Promise<any>;
166
+ /**
167
+ * Fetch investor milestone vesting account data
168
+ *
169
+ * Per-milestone vesting: Each investor has a separate vesting PDA for each
170
+ * milestone they claim tokens from.
171
+ *
172
+ * @param program - Anchor program instance
173
+ * @param projectId - Project identifier
174
+ * @param milestoneIndex - Milestone index
175
+ * @param nftMint - NFT mint that proves investment ownership
176
+ * @returns InvestorMilestoneVesting account data or null if not found
177
+ */
178
+ declare function fetchInvestorMilestoneVesting(program: AnyProgram, projectId: BN, milestoneIndex: number, nftMint: PublicKey): Promise<any>;
179
+ /**
180
+ * Fetch founder milestone vesting account data
181
+ *
182
+ * Per-milestone vesting: Each milestone has a separate vesting PDA for the
183
+ * founder's milestone-based allocation.
184
+ *
185
+ * @param program - Anchor program instance
186
+ * @param projectId - Project identifier
187
+ * @param milestoneIndex - Milestone index
188
+ * @returns FounderMilestoneVesting account data or null if not found
189
+ */
190
+ declare function fetchFounderMilestoneVesting(program: AnyProgram, projectId: BN, milestoneIndex: number): Promise<any>;
191
+ /** Early token cooling period in seconds (24 hours in production, 10s in dev) */
192
+ declare const EARLY_TOKEN_COOLING_PERIOD_SECONDS = 86400;
193
+ declare const EARLY_TOKEN_COOLING_PERIOD_SECONDS_DEV = 10;
194
+ /** Early token release percentage in basis points (500 = 5%) */
195
+ declare const EARLY_TOKEN_RELEASE_BPS = 500;
196
+ /**
197
+ * Check if an investor can claim early tokens
198
+ *
199
+ * Early Token Release: Investors can claim 5% of their token allocation
200
+ * 24 hours after investing. This helper checks eligibility.
201
+ *
202
+ * @param investment - Investment account data
203
+ * @param currentTimestamp - Current Unix timestamp (optional, uses Date.now() if not provided)
204
+ * @param isDev - Use dev mode (10s) or production mode (24h) cooling period
205
+ * @returns Object with canClaim boolean, reason if ineligible, and time remaining if cooling period not expired
206
+ */
207
+ declare function canClaimEarlyTokens(investment: {
208
+ earlyTokensClaimed: boolean;
209
+ investedAt: BN | number;
210
+ votingRightsActive?: boolean;
211
+ withdrawnFromPivot?: boolean;
212
+ }, currentTimestamp?: number, isDev?: boolean): {
213
+ canClaim: boolean;
214
+ reason?: string;
215
+ timeRemainingSeconds?: number;
216
+ };
217
+ /**
218
+ * Check if a founder can claim early tokens
219
+ *
220
+ * Early Token Release: Founders can claim 5% of their token allocation
221
+ * when the project becomes Funded. This helper checks eligibility.
222
+ *
223
+ * @param project - Project account data
224
+ * @returns Object with canClaim boolean and reason if ineligible
225
+ */
226
+ declare function canClaimFounderEarlyTokens(project: {
227
+ state: unknown;
228
+ founderEarlyTokensClaimed: boolean;
229
+ }): {
230
+ canClaim: boolean;
231
+ reason?: string;
232
+ };
233
+ /**
234
+ * Check if a founder can claim milestone-based tokens
235
+ *
236
+ * Early Token Release: Founders can claim milestone-based tokens when
237
+ * milestones are unlocked. This helper checks eligibility.
238
+ *
239
+ * @param milestone - Milestone account data
240
+ * @returns Object with canClaim boolean and reason if ineligible
241
+ */
242
+ declare function canClaimFounderMilestoneTokens(milestone: {
243
+ state: unknown;
244
+ }): {
245
+ canClaim: boolean;
246
+ reason?: string;
247
+ };
248
+ /**
249
+ * Check if an investor needs to burn tokens for a refund
250
+ *
251
+ * Early Token Release: If the project has no milestones claimed (cumulative_percentage == 0)
252
+ * AND the investor has claimed early tokens, they must burn those tokens to get a full refund.
253
+ *
254
+ * @param project - Project account data
255
+ * @param investment - Investment account data
256
+ * @returns Object indicating whether burn is required
257
+ */
258
+ declare function requiresBurnForRefund(project: {
259
+ cumulativePercentage: number;
260
+ }, investment: {
261
+ earlyTokensClaimed: boolean;
262
+ earlyTokensAmount: BN | number;
263
+ }): {
264
+ requiresBurn: boolean;
265
+ burnAmount: number;
266
+ };
267
+ /**
268
+ * Calculate early token amount for an investment
269
+ *
270
+ * @param tokensAllocated - Total tokens allocated to the investment
271
+ * @returns Early token amount (5% of allocation)
272
+ */
273
+ declare function calculateEarlyTokenAmount(tokensAllocated: BN | number): BN;
274
+ /**
275
+ * Calculate remaining token allocation after early tokens are claimed
276
+ *
277
+ * @param tokensAllocated - Total tokens allocated
278
+ * @returns Remaining allocation (95% of total)
279
+ */
280
+ declare function calculateRemainingAllocation(tokensAllocated: BN | number): BN;
281
+ /**
282
+ * Fetch FundingRound account data
283
+ *
284
+ * @param program - Anchor program instance
285
+ * @param projectId - Project identifier
286
+ * @param roundNumber - Round number (2, 3, 4...)
287
+ * @returns FundingRound account data or null if not found
288
+ */
289
+ declare function fetchFundingRound(program: AnyProgram, projectId: BN, roundNumber: number): Promise<any>;
290
+ /**
291
+ * Fetch all FundingRounds for a project
292
+ *
293
+ * @param program - Anchor program instance
294
+ * @param projectId - Project identifier
295
+ * @returns Array of FundingRound accounts with their public keys
296
+ */
297
+ declare function fetchAllFundingRounds(program: AnyProgram, projectId: BN): Promise<FundingRoundWithKey[]>;
298
+ /**
299
+ * Fetch round milestone account data
300
+ *
301
+ * @param program - Anchor program instance
302
+ * @param projectId - Project identifier
303
+ * @param roundNumber - Round number
304
+ * @param milestoneIndex - Milestone index
305
+ * @returns Milestone account data or null if not found
306
+ */
307
+ declare function fetchRoundMilestone(program: AnyProgram, projectId: BN, roundNumber: number, milestoneIndex: number): Promise<any>;
308
+ /**
309
+ * Fetch round investment account data
310
+ *
311
+ * @param program - Anchor program instance
312
+ * @param projectId - Project identifier
313
+ * @param roundNumber - Round number
314
+ * @param nftMint - Investment NFT mint address
315
+ * @returns Investment account data or null if not found
316
+ */
317
+ declare function fetchRoundInvestment(program: AnyProgram, projectId: BN, roundNumber: number, nftMint: PublicKey): Promise<any>;
318
+ /**
319
+ * Fetch round investor milestone vesting account data
320
+ *
321
+ * @param program - Anchor program instance
322
+ * @param projectId - Project identifier
323
+ * @param roundNumber - Round number
324
+ * @param milestoneIndex - Milestone index
325
+ * @param nftMint - NFT mint that proves investment ownership
326
+ * @returns InvestorMilestoneVesting account data or null if not found
327
+ */
328
+ declare function fetchRoundInvestorMilestoneVesting(program: AnyProgram, projectId: BN, roundNumber: number, milestoneIndex: number, nftMint: PublicKey): Promise<any>;
329
+ /**
330
+ * Fetch FutureRoundVault account data
331
+ *
332
+ * @param program - Anchor program instance
333
+ * @param projectId - Project identifier
334
+ * @returns FutureRoundVault account data or null if not found
335
+ */
336
+ declare function fetchFutureRoundVault(program: AnyProgram, projectId: BN): Promise<any>;
337
+ /**
338
+ * Check if an investor can claim R2+ early tokens
339
+ *
340
+ * @param investment - Investment account data (from R2+ round)
341
+ * @param currentTimestamp - Current Unix timestamp
342
+ * @param isDev - Use dev mode cooling period
343
+ * @returns Eligibility check result
344
+ */
345
+ declare function canClaimRoundEarlyTokens(investment: {
346
+ earlyTokensClaimed: boolean;
347
+ investedAt: BN | number;
348
+ votingRightsActive?: boolean;
349
+ roundNumber: number;
350
+ }, currentTimestamp?: number, isDev?: boolean): {
351
+ canClaim: boolean;
352
+ reason?: string;
353
+ timeRemainingSeconds?: number;
354
+ };
355
+ /**
356
+ * Check if R1 (Project-based round) is fully funded
357
+ *
358
+ * @param project - Project account data
359
+ * @returns True if total_raised >= funding_goal
360
+ */
361
+ declare function isR1FullyFunded(project: {
362
+ totalRaised: BN | number;
363
+ fundingGoal: BN | number;
364
+ }): boolean;
365
+ /**
366
+ * Check if a FundingRound (R2+) is fully funded
367
+ *
368
+ * A round is considered "fully funded" when it reaches the Funded, InProgress, or Completed state.
369
+ *
370
+ * @param fundingRound - FundingRound account data
371
+ * @returns True if round state is Funded, InProgress, or Completed
372
+ */
373
+ declare function isFundingRoundFullyFunded(fundingRound: {
374
+ state: unknown;
375
+ totalRaised?: BN | number;
376
+ fundingGoal?: BN | number;
377
+ }): boolean;
378
+ /**
379
+ * Check if a round (R1 or R2+) is fully funded
380
+ *
381
+ * For R1: Checks project.totalRaised >= project.fundingGoal
382
+ * For R2+: Checks fundingRound.state is Funded or beyond
383
+ *
384
+ * @param program - Anchor program instance
385
+ * @param projectId - Project identifier
386
+ * @param roundNumber - Round number (1 for R1, 2+ for subsequent rounds)
387
+ * @returns True if the round is fully funded
388
+ */
389
+ declare function isRoundFullyFunded(program: AnyProgram, projectId: BN, roundNumber: number): Promise<boolean>;
390
+ /**
391
+ * Check if a project can open the next funding round
392
+ *
393
+ * Requirements:
394
+ * 1. Project must be InProgress or Completed
395
+ * 2. At least 1 milestone must have passed (for InProgress projects)
396
+ * 3. Current round must be fully funded
397
+ * 4. No other round is currently in Open state
398
+ * 5. Future round allocation must be available
399
+ *
400
+ * @param program - Anchor program instance
401
+ * @param projectId - Project identifier
402
+ * @returns Eligibility check result with reason if ineligible
403
+ */
404
+ declare function canOpenNextRound(program: AnyProgram, projectId: BN): Promise<{
405
+ canOpen: boolean;
406
+ reason?: string;
407
+ nextRoundNumber?: number;
408
+ }>;
409
+ /**
410
+ * Get remaining future round allocation in basis points
411
+ *
412
+ * @param tokenomics - Tokenomics account data
413
+ * @returns Remaining allocation in BPS
414
+ */
415
+ declare function getRemainingFutureRoundAllocation(tokenomics: {
416
+ futureRoundAllocationBps: number;
417
+ usedFutureRoundBps?: number;
418
+ }): number;
114
419
 
115
- export { accountExists, fetchAdminConfig, fetchAllInvestments, fetchAllMilestones, fetchAllVotes, fetchInvestment, fetchMilestone, fetchPivotProposal, fetchProject, fetchProjectByPda, fetchTgeEscrow, fetchVote };
420
+ export { EARLY_TOKEN_COOLING_PERIOD_SECONDS, EARLY_TOKEN_COOLING_PERIOD_SECONDS_DEV, EARLY_TOKEN_RELEASE_BPS, accountExists, calculateEarlyTokenAmount, calculateRemainingAllocation, canClaimEarlyTokens, canClaimFounderEarlyTokens, canClaimFounderMilestoneTokens, canClaimRoundEarlyTokens, canOpenNextRound, fetchAdminConfig, fetchAllAllocationProposals, fetchAllFundingRounds, fetchAllInvestments, fetchAllMilestones, fetchAllVotes, fetchAllocationProposal, fetchAllocationVote, fetchFounderMilestoneVesting, fetchFundingRound, fetchFutureRoundVault, fetchInvestment, fetchInvestorMilestoneVesting, fetchMilestone, fetchPivotProposal, fetchProject, fetchProjectByPda, fetchRoundInvestment, fetchRoundInvestorMilestoneVesting, fetchRoundMilestone, fetchSubAllocationVesting, fetchTgeEscrow, fetchTokenVault, fetchTokenomics, fetchVote, getRemainingFutureRoundAllocation, isFundingRoundFullyFunded, isR1FullyFunded, isRoundFullyFunded, requiresBurnForRefund };