@zemyth/raise-sdk 0.1.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.
Files changed (54) hide show
  1. package/README.md +416 -0
  2. package/dist/accounts/index.cjs +258 -0
  3. package/dist/accounts/index.cjs.map +1 -0
  4. package/dist/accounts/index.d.cts +115 -0
  5. package/dist/accounts/index.d.ts +115 -0
  6. package/dist/accounts/index.js +245 -0
  7. package/dist/accounts/index.js.map +1 -0
  8. package/dist/constants/index.cjs +174 -0
  9. package/dist/constants/index.cjs.map +1 -0
  10. package/dist/constants/index.d.cts +143 -0
  11. package/dist/constants/index.d.ts +143 -0
  12. package/dist/constants/index.js +158 -0
  13. package/dist/constants/index.js.map +1 -0
  14. package/dist/errors/index.cjs +177 -0
  15. package/dist/errors/index.cjs.map +1 -0
  16. package/dist/errors/index.d.cts +83 -0
  17. package/dist/errors/index.d.ts +83 -0
  18. package/dist/errors/index.js +170 -0
  19. package/dist/errors/index.js.map +1 -0
  20. package/dist/index.cjs +2063 -0
  21. package/dist/index.cjs.map +1 -0
  22. package/dist/index.d.cts +680 -0
  23. package/dist/index.d.ts +680 -0
  24. package/dist/index.js +1926 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/instructions/index.cjs +852 -0
  27. package/dist/instructions/index.cjs.map +1 -0
  28. package/dist/instructions/index.d.cts +452 -0
  29. package/dist/instructions/index.d.ts +452 -0
  30. package/dist/instructions/index.js +809 -0
  31. package/dist/instructions/index.js.map +1 -0
  32. package/dist/pdas/index.cjs +241 -0
  33. package/dist/pdas/index.cjs.map +1 -0
  34. package/dist/pdas/index.d.cts +171 -0
  35. package/dist/pdas/index.d.ts +171 -0
  36. package/dist/pdas/index.js +217 -0
  37. package/dist/pdas/index.js.map +1 -0
  38. package/dist/types/index.cjs +44 -0
  39. package/dist/types/index.cjs.map +1 -0
  40. package/dist/types/index.d.cts +229 -0
  41. package/dist/types/index.d.ts +229 -0
  42. package/dist/types/index.js +39 -0
  43. package/dist/types/index.js.map +1 -0
  44. package/package.json +130 -0
  45. package/src/accounts/index.ts +329 -0
  46. package/src/client.ts +715 -0
  47. package/src/constants/index.ts +205 -0
  48. package/src/errors/index.ts +222 -0
  49. package/src/events/index.ts +256 -0
  50. package/src/index.ts +253 -0
  51. package/src/instructions/index.ts +1504 -0
  52. package/src/pdas/index.ts +404 -0
  53. package/src/types/index.ts +267 -0
  54. package/src/utils/index.ts +277 -0
@@ -0,0 +1,452 @@
1
+ import { BN, Program } from '@coral-xyz/anchor';
2
+ import { PublicKey, Keypair } from '@solana/web3.js';
3
+
4
+ /**
5
+ * Raise Instruction Builders
6
+ *
7
+ * All instruction builder functions for the Raise program.
8
+ * These return transaction signatures when called with RPC.
9
+ */
10
+
11
+ type AnyProgram = Program<any>;
12
+ /**
13
+ * Initialize admin config (deploy-time only)
14
+ */
15
+ declare function initializeAdmin(program: AnyProgram, admin: PublicKey, payer: PublicKey): Promise<string>;
16
+ /**
17
+ * Propose admin transfer to new admin
18
+ */
19
+ declare function transferAdmin(program: AnyProgram, adminKeypair: Keypair, newAdmin: PublicKey): Promise<string>;
20
+ /**
21
+ * Accept admin transfer
22
+ */
23
+ declare function acceptAdmin(program: AnyProgram, newAuthority: PublicKey): Promise<string>;
24
+ /**
25
+ * TierConfig input type for initializeProject
26
+ * Matches the on-chain TierConfig struct
27
+ */
28
+ interface TierConfigInput {
29
+ /** USDC amount per lot */
30
+ amount: BN;
31
+ /** Maximum lots available */
32
+ maxLots: number;
33
+ /** Token allocation per $1 invested */
34
+ tokenRatio: BN;
35
+ /** Vote weight multiplier (basis points, 100 = 1.0x) */
36
+ voteMultiplier: number;
37
+ }
38
+ /**
39
+ * TokenomicsArgs input type for initializeProject (ZTM v2.0)
40
+ * Matches the on-chain TokenomicsArgs struct
41
+ */
42
+ interface TokenomicsInput {
43
+ /** Token symbol as 8-byte array (2-8 chars uppercase, padded with 0s) */
44
+ tokenSymbol: number[];
45
+ /** Total token supply */
46
+ totalSupply: BN;
47
+ /** Investor allocation in basis points (e.g., 4000 = 40%) */
48
+ investorAllocationBps: number;
49
+ /** LP token allocation in basis points */
50
+ lpTokenAllocationBps: number;
51
+ /** LP USDC allocation in basis points (min 500 = 5% of raised USDC) */
52
+ lpUsdcAllocationBps: number;
53
+ /** Founder allocation in basis points (optional) */
54
+ founderAllocationBps?: number | null;
55
+ /** Treasury allocation in basis points (optional) */
56
+ treasuryAllocationBps?: number | null;
57
+ /** Founder wallet for vesting (required if founder_allocation_bps > 0) */
58
+ founderWallet?: PublicKey | null;
59
+ /** Vesting duration in months (required if founder_allocation_bps > 0) */
60
+ vestingDurationMonths?: number | null;
61
+ /** Cliff period in months (optional) */
62
+ cliffMonths?: number | null;
63
+ }
64
+ /**
65
+ * Helper to convert string symbol to 8-byte array
66
+ */
67
+ declare function symbolToBytes(symbol: string): number[];
68
+ /** Minimum deadline duration from current time (7 days in production, 60s in dev) */
69
+ declare const MIN_DEADLINE_DURATION_SECONDS_PROD = 604800;
70
+ declare const MIN_DEADLINE_DURATION_SECONDS_DEV = 60;
71
+ /** Maximum deadline duration from current time (1 year) */
72
+ declare const MAX_DEADLINE_DURATION_SECONDS = 31536000;
73
+ /**
74
+ * Calculate a valid milestone deadline
75
+ *
76
+ * @param daysFromNow - Number of days from now to set deadline
77
+ * @param isDev - Use dev mode (60s min) or production mode (7 days min)
78
+ * @returns BN timestamp for the deadline
79
+ */
80
+ declare function calculateDeadline(daysFromNow: number, isDev?: boolean): BN;
81
+ /**
82
+ * Create a deadline that's the minimum allowed duration from now
83
+ *
84
+ * @param isDev - Use dev mode (60s min) or production mode (7 days min)
85
+ * @returns BN timestamp for the minimum valid deadline
86
+ */
87
+ declare function minDeadline(isDev?: boolean): BN;
88
+ /**
89
+ * Validate a deadline is within allowed bounds
90
+ *
91
+ * @param deadline - BN timestamp to validate
92
+ * @param isDev - Use dev mode (60s min) or production mode (7 days min)
93
+ * @returns { valid: boolean, error?: string }
94
+ */
95
+ declare function validateDeadline(deadline: BN, isDev?: boolean): {
96
+ valid: boolean;
97
+ error?: string;
98
+ };
99
+ /**
100
+ * Initialize a new project with founder-configured tiers and tokenomics (ZTM v2.0)
101
+ *
102
+ * @param milestone1Deadline - Unix timestamp for M1 deadline (required)
103
+ * Must be >= current_time + MIN_DEADLINE_DURATION_SECONDS (7 days prod, 60s dev)
104
+ * Must be <= current_time + MAX_DEADLINE_DURATION_SECONDS (1 year)
105
+ */
106
+ declare function initializeProject(program: AnyProgram, args: {
107
+ projectId: BN;
108
+ fundingGoal: BN;
109
+ metadataUri: string;
110
+ /** Founder-configured tiers (1-10 tiers, sorted ascending by amount) */
111
+ tiers: TierConfigInput[];
112
+ /** ZTM v2.0: Tokenomics configuration */
113
+ tokenomics: TokenomicsInput;
114
+ /** Milestone 1 deadline - Unix timestamp (required) */
115
+ milestone1Deadline: BN;
116
+ }, founder: PublicKey): Promise<string>;
117
+ /**
118
+ * Submit project for approval
119
+ */
120
+ declare function submitForApproval(program: AnyProgram, projectId: BN, founder: PublicKey): Promise<string>;
121
+ /**
122
+ * Approve project (admin only)
123
+ * ZTM v2.0: This now deploys the token and creates all vaults
124
+ */
125
+ declare function approveProject(program: AnyProgram, args: {
126
+ projectId: BN;
127
+ /** USDC mint address (for creating lp_usdc_vault) */
128
+ usdcMint: PublicKey;
129
+ }, adminKeypair: Keypair): Promise<string>;
130
+ /**
131
+ * Create a milestone for a project
132
+ */
133
+ declare function createMilestone(program: AnyProgram, args: {
134
+ projectId: BN;
135
+ milestoneIndex: number;
136
+ percentage: number;
137
+ description: string;
138
+ }, founder: PublicKey): Promise<string>;
139
+ /**
140
+ * Submit milestone for review
141
+ */
142
+ declare function submitMilestone(program: AnyProgram, projectId: BN, milestoneIndex: number, founder: PublicKey): Promise<string>;
143
+ /**
144
+ * Vote on a milestone
145
+ *
146
+ * Automatically fetches the milestone to get the current voting_round
147
+ * for proper vote PDA derivation. This supports re-voting after milestone failure.
148
+ */
149
+ declare function voteOnMilestone(program: AnyProgram, args: {
150
+ projectId: BN;
151
+ milestoneIndex: number;
152
+ nftMint: PublicKey | string;
153
+ choice: {
154
+ good: object;
155
+ } | {
156
+ bad: object;
157
+ };
158
+ }, voter: PublicKey): Promise<string>;
159
+ /**
160
+ * Finalize voting on a milestone
161
+ */
162
+ declare function finalizeVoting(program: AnyProgram, projectId: BN, milestoneIndex: number): Promise<string>;
163
+ /**
164
+ * Claim milestone funds (for founders)
165
+ *
166
+ * ZTM v2.0: Transfers USDC from escrow to founder's account.
167
+ * - Regular milestones: Full payout to founder (no LP deduction)
168
+ * - Final milestone: LP USDC reserved for PCL, triggers MAE
169
+ *
170
+ * @param nextMilestoneDeadline - Deadline for next milestone (required for non-final milestones)
171
+ * Must be >= current_time + MIN_DEADLINE_DURATION_SECONDS (7 days prod, 60s dev)
172
+ * Must be <= current_time + MAX_DEADLINE_DURATION_SECONDS (1 year)
173
+ * Set to BN(0) for final milestone claims (no next milestone exists)
174
+ */
175
+ declare function claimMilestoneFunds(program: AnyProgram, args: {
176
+ projectId: BN;
177
+ milestoneIndex: number;
178
+ founderUsdcAccount: PublicKey;
179
+ escrowTokenAccount: PublicKey;
180
+ /** Deadline for next milestone - required for non-final milestones, use BN(0) for final */
181
+ nextMilestoneDeadline: BN;
182
+ /** Next milestone PDA - required for non-final milestones */
183
+ nextMilestonePda?: PublicKey;
184
+ }, founder: PublicKey): Promise<string>;
185
+ /**
186
+ * Resubmit a failed milestone for rework (Failed → InProgress)
187
+ *
188
+ * This allows founders to iterate on a failed milestone by transitioning it
189
+ * back to InProgress state with cleared voting state for a fresh voting cycle.
190
+ * The consecutive_failures counter is NOT reset (tracked at project level).
191
+ * Unlimited rework attempts are allowed.
192
+ */
193
+ declare function resubmitMilestone(program: AnyProgram, args: {
194
+ projectId: BN;
195
+ milestoneIndex: number;
196
+ }, founder: PublicKey): Promise<string>;
197
+ /**
198
+ * Set milestone deadline for founder to commit submission date
199
+ *
200
+ * Founders must set deadlines for milestones to provide visibility to investors.
201
+ * Deadline must be at least 7 days from now and at most 1 year from now.
202
+ * Can only be set on Proposed, Approved, or InProgress milestones.
203
+ */
204
+ declare function setMilestoneDeadline(program: AnyProgram, args: {
205
+ projectId: BN;
206
+ milestoneIndex: number;
207
+ /** Unix timestamp for the deadline */
208
+ deadline: BN;
209
+ }, founder: PublicKey): Promise<string>;
210
+ /**
211
+ * Extend milestone deadline (max 3 extensions per milestone)
212
+ *
213
+ * Founders can extend a deadline up to 3 times before it passes.
214
+ * Must be called BEFORE the current deadline passes.
215
+ * New deadline must be later than current deadline.
216
+ */
217
+ declare function extendMilestoneDeadline(program: AnyProgram, args: {
218
+ projectId: BN;
219
+ milestoneIndex: number;
220
+ /** New deadline timestamp (must be > current deadline) */
221
+ newDeadline: BN;
222
+ }, founder: PublicKey): Promise<string>;
223
+ /**
224
+ * Invest in a project
225
+ *
226
+ * This creates an investment NFT and transfers USDC to the project escrow.
227
+ * The investmentCount should be fetched from the project account before calling.
228
+ */
229
+ declare function invest(program: AnyProgram, args: {
230
+ projectId: BN;
231
+ amount: BN;
232
+ investorTokenAccount: PublicKey;
233
+ escrowTokenAccount: PublicKey;
234
+ investmentCount: number;
235
+ }, investor: PublicKey): Promise<string>;
236
+ /**
237
+ * Cancel investment within 24-hour cooling-off period
238
+ */
239
+ declare function cancelInvestment(program: AnyProgram, args: {
240
+ projectId: BN;
241
+ nftMint: PublicKey;
242
+ investorNftAccount: PublicKey;
243
+ investorUsdcAccount: PublicKey;
244
+ escrowTokenAccount: PublicKey;
245
+ }, investor: PublicKey): Promise<string>;
246
+ /**
247
+ * Propose a pivot
248
+ */
249
+ declare function proposePivot(program: AnyProgram, args: {
250
+ projectId: BN;
251
+ newMetadataUri: string;
252
+ newMilestones: Array<{
253
+ percentage: number;
254
+ description: string;
255
+ }>;
256
+ }, founder: PublicKey): Promise<string>;
257
+ /**
258
+ * Approve pivot proposal (admin only)
259
+ */
260
+ declare function approvePivot(program: AnyProgram, projectId: BN, adminKeypair: Keypair): Promise<string>;
261
+ /**
262
+ * Withdraw from pivot during 7-day window
263
+ */
264
+ declare function withdrawFromPivot(program: AnyProgram, args: {
265
+ projectId: BN;
266
+ pivotCount: number;
267
+ nftMint: PublicKey;
268
+ investorTokenAccount: PublicKey;
269
+ escrowTokenAccount: PublicKey;
270
+ milestoneAccounts: PublicKey[];
271
+ }, investor: PublicKey): Promise<string>;
272
+ /**
273
+ * Finalize pivot after 7-day window
274
+ *
275
+ * IMPORTANT: When old_milestone_count == new_milestone_count, the milestone PDAs are
276
+ * the same and get reinitialized in-place. In this case, only pass the milestone
277
+ * accounts once (not twice as old+new).
278
+ */
279
+ declare function finalizePivot(program: AnyProgram, args: {
280
+ projectId: BN;
281
+ pivotCount: number;
282
+ milestoneAccounts: PublicKey[];
283
+ }, authority: PublicKey): Promise<string>;
284
+ /**
285
+ * Set TGE date and token mint
286
+ */
287
+ declare function setTgeDate(program: AnyProgram, args: {
288
+ projectId: BN;
289
+ tgeDate: BN;
290
+ tokenMint: PublicKey;
291
+ }, founder: PublicKey): Promise<string>;
292
+ /**
293
+ * Deposit tokens for investor distribution
294
+ */
295
+ declare function depositTokens(program: AnyProgram, args: {
296
+ projectId: BN;
297
+ amount: BN;
298
+ tokenMint: PublicKey;
299
+ founderTokenAccount: PublicKey;
300
+ }, founder: PublicKey): Promise<string>;
301
+ /**
302
+ * Claim project tokens using Investment NFT
303
+ */
304
+ declare function claimTokens(program: AnyProgram, args: {
305
+ projectId: BN;
306
+ nftMint: PublicKey;
307
+ investorNftAccount: PublicKey;
308
+ investorTokenAccount: PublicKey;
309
+ projectTokenVault: PublicKey;
310
+ }, investor: PublicKey): Promise<string>;
311
+ /**
312
+ * Report scam during 30-day post-TGE window
313
+ */
314
+ declare function reportScam(program: AnyProgram, args: {
315
+ projectId: BN;
316
+ nftMint: PublicKey;
317
+ }, reporter: PublicKey): Promise<string>;
318
+ /**
319
+ * Release 10% holdback to founder after 30 days
320
+ */
321
+ declare function releaseHoldback(program: AnyProgram, args: {
322
+ projectId: BN;
323
+ founderTokenAccount: PublicKey;
324
+ }): Promise<string>;
325
+ /**
326
+ * Check for abandonment (90 days inactivity)
327
+ */
328
+ declare function checkAbandonment(program: AnyProgram, projectId: BN, milestoneIndex?: number): Promise<string>;
329
+ /**
330
+ * Claim refund after abandonment
331
+ *
332
+ * @param milestoneCount - Number of milestones in the project (used to derive milestone PDAs for remainingAccounts)
333
+ * The program calculates unreleased funds by iterating through milestone accounts.
334
+ */
335
+ declare function claimRefund(program: AnyProgram, args: {
336
+ projectId: BN;
337
+ nftMint: PublicKey;
338
+ investorNftAccount: PublicKey;
339
+ investorUsdcAccount: PublicKey;
340
+ escrowTokenAccount: PublicKey;
341
+ milestoneCount?: number;
342
+ }, investor: PublicKey): Promise<string>;
343
+ /**
344
+ * Claim investor tokens from a passed milestone (whitepaper: manual claim model)
345
+ *
346
+ * ZTM v2.0: Per whitepaper, investors manually claim their tokens after a milestone passes.
347
+ * This replaces the batch distribution model with investor-initiated per-NFT claims.
348
+ *
349
+ * @param milestoneIndex - The milestone index to claim tokens from
350
+ * @param nftMint - The NFT mint that proves investment ownership
351
+ * @param investorTokenAccount - Investor's token account to receive claimed tokens
352
+ */
353
+ declare function claimInvestorTokens(program: AnyProgram, args: {
354
+ projectId: BN;
355
+ /** Milestone index to claim tokens from */
356
+ milestoneIndex: number;
357
+ /** NFT mint that proves investment ownership */
358
+ nftMint: PublicKey;
359
+ /** Investor's token account to receive claimed tokens */
360
+ investorTokenAccount: PublicKey;
361
+ }, investor: PublicKey): Promise<string>;
362
+ /**
363
+ * Distribute tokens to NFT holders for a milestone
364
+ *
365
+ * ZTM v2.0: Called by cranker after finalize_voting sets distribution_pending = true.
366
+ * Processes batch of investments, transferring unlocked tokens to NFT holders.
367
+ *
368
+ * @deprecated Use claimInvestorTokens instead (whitepaper manual claim model)
369
+ *
370
+ * @param investments - Array of { investmentPda, investorTokenAccount } pairs
371
+ * Each pair represents an investor's investment and their token account to receive tokens.
372
+ * Max batch size: 10 investments per call.
373
+ */
374
+ declare function distributeTokens(program: AnyProgram, args: {
375
+ projectId: BN;
376
+ milestoneIndex: number;
377
+ /** Investment and token account pairs to process */
378
+ investments: Array<{
379
+ investmentPda: PublicKey;
380
+ investorTokenAccount: PublicKey;
381
+ }>;
382
+ }, payer: PublicKey): Promise<string>;
383
+ /**
384
+ * Complete token distribution for a milestone
385
+ *
386
+ * ZTM v2.0: Marks distribution as complete after all batches have been processed.
387
+ * Permissionless - anyone can call this to finalize a distribution.
388
+ */
389
+ declare function completeDistribution(program: AnyProgram, args: {
390
+ projectId: BN;
391
+ milestoneIndex: number;
392
+ }, payer: PublicKey): Promise<string>;
393
+ /**
394
+ * Claim exit window refund during 3-failure voluntary exit window
395
+ * Per whitepaper: 3 consecutive failures trigger 7-day voluntary exit window
396
+ * Investors can claim proportional share of unreleased USDC escrow funds
397
+ */
398
+ declare function claimExitWindowRefund(program: AnyProgram, args: {
399
+ projectId: BN;
400
+ nftMint: PublicKey;
401
+ investorNftAccount: PublicKey;
402
+ escrowTokenAccount: PublicKey;
403
+ investorTokenAccount: PublicKey;
404
+ milestoneAccounts?: PublicKey[];
405
+ }, investor: PublicKey): Promise<string>;
406
+ /**
407
+ * Initialize founder vesting after MAE (Market Access Event)
408
+ *
409
+ * ZTM v2.0: Creates FounderVesting PDA with vesting schedule from Tokenomics.
410
+ * Must be called after project reaches Completed state (all milestones done).
411
+ * Permissionless - anyone can pay to initialize.
412
+ */
413
+ declare function initializeFounderVesting(program: AnyProgram, args: {
414
+ projectId: BN;
415
+ }, payer: PublicKey): Promise<string>;
416
+ /**
417
+ * Claim vested tokens from founder vault
418
+ *
419
+ * ZTM v2.0: Founder claims tokens based on linear vesting schedule.
420
+ * Requires cliff period to pass before any tokens can be claimed.
421
+ */
422
+ declare function claimVestedTokens(program: AnyProgram, args: {
423
+ projectId: BN;
424
+ /** Founder's token account to receive vested tokens */
425
+ founderTokenAccount: PublicKey;
426
+ }, founder: PublicKey): Promise<string>;
427
+ /**
428
+ * Force complete a stuck distribution (admin only)
429
+ *
430
+ * ZTM v2.0: Circuit breaker for when token distribution is stuck for >7 days.
431
+ * Marks distribution as complete so project can continue.
432
+ * Affected investors can use claimMissedUnlock to get their tokens.
433
+ */
434
+ declare function forceCompleteDistribution(program: AnyProgram, args: {
435
+ projectId: BN;
436
+ }, adminKeypair: Keypair): Promise<string>;
437
+ /**
438
+ * Claim missed token unlock after force-complete distribution
439
+ *
440
+ * ZTM v2.0: Allows investors to claim tokens they missed during a stuck
441
+ * distribution that was force-completed by admin.
442
+ */
443
+ declare function claimMissedUnlock(program: AnyProgram, args: {
444
+ projectId: BN;
445
+ nftMint: PublicKey;
446
+ /** Milestone index to claim for */
447
+ milestoneIndex: number;
448
+ /** Claimer's token account to receive tokens */
449
+ claimerTokenAccount: PublicKey;
450
+ }, claimer: PublicKey): Promise<string>;
451
+
452
+ export { MAX_DEADLINE_DURATION_SECONDS, MIN_DEADLINE_DURATION_SECONDS_DEV, MIN_DEADLINE_DURATION_SECONDS_PROD, type TokenomicsInput, acceptAdmin, approvePivot, approveProject, calculateDeadline, cancelInvestment, checkAbandonment, claimExitWindowRefund, claimInvestorTokens, claimMilestoneFunds, claimMissedUnlock, claimRefund, claimTokens, claimVestedTokens, completeDistribution, createMilestone, depositTokens, distributeTokens, extendMilestoneDeadline, finalizePivot, finalizeVoting, forceCompleteDistribution, initializeAdmin, initializeFounderVesting, initializeProject, invest, minDeadline, proposePivot, releaseHoldback, reportScam, resubmitMilestone, setMilestoneDeadline, setTgeDate, submitForApproval, submitMilestone, symbolToBytes, transferAdmin, validateDeadline, voteOnMilestone, withdrawFromPivot };