@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.
- package/README.md +416 -0
- package/dist/accounts/index.cjs +258 -0
- package/dist/accounts/index.cjs.map +1 -0
- package/dist/accounts/index.d.cts +115 -0
- package/dist/accounts/index.d.ts +115 -0
- package/dist/accounts/index.js +245 -0
- package/dist/accounts/index.js.map +1 -0
- package/dist/constants/index.cjs +174 -0
- package/dist/constants/index.cjs.map +1 -0
- package/dist/constants/index.d.cts +143 -0
- package/dist/constants/index.d.ts +143 -0
- package/dist/constants/index.js +158 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/errors/index.cjs +177 -0
- package/dist/errors/index.cjs.map +1 -0
- package/dist/errors/index.d.cts +83 -0
- package/dist/errors/index.d.ts +83 -0
- package/dist/errors/index.js +170 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.cjs +2063 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +680 -0
- package/dist/index.d.ts +680 -0
- package/dist/index.js +1926 -0
- package/dist/index.js.map +1 -0
- package/dist/instructions/index.cjs +852 -0
- package/dist/instructions/index.cjs.map +1 -0
- package/dist/instructions/index.d.cts +452 -0
- package/dist/instructions/index.d.ts +452 -0
- package/dist/instructions/index.js +809 -0
- package/dist/instructions/index.js.map +1 -0
- package/dist/pdas/index.cjs +241 -0
- package/dist/pdas/index.cjs.map +1 -0
- package/dist/pdas/index.d.cts +171 -0
- package/dist/pdas/index.d.ts +171 -0
- package/dist/pdas/index.js +217 -0
- package/dist/pdas/index.js.map +1 -0
- package/dist/types/index.cjs +44 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +229 -0
- package/dist/types/index.d.ts +229 -0
- package/dist/types/index.js +39 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +130 -0
- package/src/accounts/index.ts +329 -0
- package/src/client.ts +715 -0
- package/src/constants/index.ts +205 -0
- package/src/errors/index.ts +222 -0
- package/src/events/index.ts +256 -0
- package/src/index.ts +253 -0
- package/src/instructions/index.ts +1504 -0
- package/src/pdas/index.ts +404 -0
- package/src/types/index.ts +267 -0
- package/src/utils/index.ts +277 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,680 @@
|
|
|
1
|
+
import { Program, AnchorProvider, BN } from '@coral-xyz/anchor';
|
|
2
|
+
export { BN } from '@coral-xyz/anchor';
|
|
3
|
+
import * as _solana_web3_js from '@solana/web3.js';
|
|
4
|
+
import { Connection, PublicKey, Keypair, TransactionSignature } from '@solana/web3.js';
|
|
5
|
+
export { Connection, Keypair, PublicKey } from '@solana/web3.js';
|
|
6
|
+
import { TokenomicsInput } from './instructions/index.cjs';
|
|
7
|
+
export { MAX_DEADLINE_DURATION_SECONDS, MIN_DEADLINE_DURATION_SECONDS_DEV, MIN_DEADLINE_DURATION_SECONDS_PROD, 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 } from './instructions/index.cjs';
|
|
8
|
+
import { MilestoneWithKey, InvestmentWithKey, VoteWithKey, TierConfig } from './types/index.cjs';
|
|
9
|
+
export { AdminConfigAccount, CreateMilestoneArgs, DepositTokensArgs, InitializeProjectArgs, InvestArgs, InvestmentAccount, InvestmentMadeEvent, MilestoneAccount, MilestoneState, MilestoneVoteCastEvent, MilestoneVoteFinalizedEvent, PivotProposalAccount, PivotState, ProjectAccount, ProjectCreatedEvent, ProjectState, ProposePivotArgs, SetTgeDateArgs, TgeEscrowAccount, Tier, VoteAccount, VoteChoice, VoteOnMilestoneArgs } from './types/index.cjs';
|
|
10
|
+
export { GOVERNANCE, InvestmentTier, NFT, SEEDS, TIER_CONSTRAINTS, TIER_MINIMUMS, TIER_TOKEN_MULTIPLIERS, TIER_VOTE_MULTIPLIERS, TIMING, USDC, VALIDATION, findTierIndex, getTierFromAmount, getTokenMultiplier, getVoteMultiplier } from './constants/index.cjs';
|
|
11
|
+
export { getAdminConfigPDA, getEscrowPDA, getFounderVaultPDA, getFounderVestingPDA, getInvestmentPDA, getInvestorVaultPDA, getLpTokenVaultPDA, getLpUsdcVaultPDA, getMilestonePDA, getNftMintPDA, getPivotProposalPDA, getProgramAuthorityPDA, getProjectPDA, getProjectPDAs, getScamReportPDA, getTgeEscrowPDA, getTokenMintPDA, getTokenVaultPDA, getTokenomicsPDA, getTreasuryVaultPDA, getVaultAuthorityPDA, getVotePDA } from './pdas/index.cjs';
|
|
12
|
+
export { accountExists, fetchAdminConfig, fetchAllInvestments, fetchAllMilestones, fetchAllVotes, fetchInvestment, fetchMilestone, fetchPivotProposal, fetchProject, fetchProjectByPda, fetchTgeEscrow, fetchVote } from './accounts/index.cjs';
|
|
13
|
+
export { ERROR_CODES, ERROR_MESSAGES, RaiseError, getErrorMessage, isRaiseError, parseError } from './errors/index.cjs';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Wallet interface required by the client
|
|
17
|
+
*/
|
|
18
|
+
interface Wallet {
|
|
19
|
+
publicKey: PublicKey;
|
|
20
|
+
signTransaction: <T>(tx: T) => Promise<T>;
|
|
21
|
+
signAllTransactions: <T>(txs: T[]) => Promise<T[]>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Main client for interacting with the Raise program
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* import { RaiseClient } from '@raise/sdk';
|
|
29
|
+
*
|
|
30
|
+
* const client = RaiseClient.load(connection, wallet);
|
|
31
|
+
*
|
|
32
|
+
* // Create a project
|
|
33
|
+
* const tx = await client.initializeProject({
|
|
34
|
+
* projectId: new BN(1),
|
|
35
|
+
* fundingGoal: new BN(100000000000), // 100,000 USDC
|
|
36
|
+
* metadataUri: 'https://example.com/project.json',
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* // Fetch project data
|
|
40
|
+
* const project = await client.fetchProject(new BN(1));
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare class RaiseClient {
|
|
44
|
+
readonly program: Program<any>;
|
|
45
|
+
readonly provider: AnchorProvider;
|
|
46
|
+
/**
|
|
47
|
+
* Create a new RaiseClient
|
|
48
|
+
*
|
|
49
|
+
* @param program - Anchor program instance
|
|
50
|
+
* @param provider - Anchor provider
|
|
51
|
+
*/
|
|
52
|
+
constructor(program: Program<any>, provider: AnchorProvider);
|
|
53
|
+
/**
|
|
54
|
+
* Load a new RaiseClient instance
|
|
55
|
+
*
|
|
56
|
+
* @param connection - Solana connection
|
|
57
|
+
* @param wallet - Wallet instance
|
|
58
|
+
* @param programId - Optional program ID override
|
|
59
|
+
* @returns Initialized RaiseClient
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const client = RaiseClient.load(connection, wallet);
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
static load(_connection: Connection, _wallet: Wallet, _programId?: PublicKey): RaiseClient;
|
|
67
|
+
/**
|
|
68
|
+
* Create client from an existing program instance
|
|
69
|
+
*
|
|
70
|
+
* @param program - Anchor program instance
|
|
71
|
+
* @returns Initialized RaiseClient
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* import idl from './idl/raise.json';
|
|
76
|
+
*
|
|
77
|
+
* const provider = new AnchorProvider(connection, wallet, {});
|
|
78
|
+
* const program = new Program(idl, provider);
|
|
79
|
+
* const client = RaiseClient.fromProgram(program);
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
static fromProgram(program: Program<any>): RaiseClient;
|
|
83
|
+
/**
|
|
84
|
+
* Get the program ID
|
|
85
|
+
*/
|
|
86
|
+
get programId(): PublicKey;
|
|
87
|
+
/**
|
|
88
|
+
* Get the connected wallet public key
|
|
89
|
+
*/
|
|
90
|
+
get walletPublicKey(): PublicKey;
|
|
91
|
+
getProjectPDA(projectId: BN): PublicKey;
|
|
92
|
+
getEscrowPDA(projectId: BN): PublicKey;
|
|
93
|
+
getMilestonePDA(projectPda: PublicKey, milestoneIndex: number): PublicKey;
|
|
94
|
+
getInvestmentPDA(projectPda: PublicKey, nftMint: PublicKey): PublicKey;
|
|
95
|
+
getVotePDA(milestonePda: PublicKey, voterKey: PublicKey, votingRound: number): PublicKey;
|
|
96
|
+
getPivotProposalPDA(projectPda: PublicKey, pivotCount: number): PublicKey;
|
|
97
|
+
getTgeEscrowPDA(projectPda: PublicKey): PublicKey;
|
|
98
|
+
getTgeEscrowVaultPDA(projectPda: PublicKey): PublicKey;
|
|
99
|
+
getAdminConfigPDA(): PublicKey;
|
|
100
|
+
fetchProject(projectId: BN): Promise<any>;
|
|
101
|
+
fetchMilestone(projectId: BN, milestoneIndex: number): Promise<any>;
|
|
102
|
+
fetchAllMilestones(projectId: BN): Promise<MilestoneWithKey[]>;
|
|
103
|
+
fetchInvestment(projectId: BN, nftMint: PublicKey): Promise<any>;
|
|
104
|
+
fetchAllInvestments(projectId: BN): Promise<InvestmentWithKey[]>;
|
|
105
|
+
fetchVote(projectId: BN, milestoneIndex: number, voterKey: PublicKey, votingRound: number): Promise<any>;
|
|
106
|
+
fetchAllVotes(projectId: BN, milestoneIndex: number): Promise<VoteWithKey[]>;
|
|
107
|
+
fetchPivotProposal(projectId: BN): Promise<any>;
|
|
108
|
+
fetchTgeEscrow(projectId: BN): Promise<any>;
|
|
109
|
+
fetchAdminConfig(): Promise<any>;
|
|
110
|
+
initializeAdmin(admin: PublicKey): Promise<string>;
|
|
111
|
+
transferAdmin(newAdmin: PublicKey, adminKeypair: Keypair): Promise<string>;
|
|
112
|
+
acceptAdmin(): Promise<string>;
|
|
113
|
+
initializeProject(args: {
|
|
114
|
+
projectId: BN;
|
|
115
|
+
fundingGoal: BN;
|
|
116
|
+
metadataUri: string;
|
|
117
|
+
tiers: TierConfig[];
|
|
118
|
+
/** ZTM v2.0: Tokenomics configuration */
|
|
119
|
+
tokenomics: TokenomicsInput;
|
|
120
|
+
/** Milestone 1 deadline - Unix timestamp (required) */
|
|
121
|
+
milestone1Deadline: BN;
|
|
122
|
+
}): Promise<string>;
|
|
123
|
+
submitForApproval(projectId: BN): Promise<string>;
|
|
124
|
+
approveProject(args: {
|
|
125
|
+
projectId: BN;
|
|
126
|
+
usdcMint: PublicKey;
|
|
127
|
+
}, adminKeypair: Keypair): Promise<string>;
|
|
128
|
+
createMilestone(args: {
|
|
129
|
+
projectId: BN;
|
|
130
|
+
milestoneIndex: number;
|
|
131
|
+
percentage: number;
|
|
132
|
+
description: string;
|
|
133
|
+
}): Promise<string>;
|
|
134
|
+
submitMilestone(projectId: BN, milestoneIndex: number): Promise<string>;
|
|
135
|
+
voteOnMilestone(args: {
|
|
136
|
+
projectId: BN;
|
|
137
|
+
milestoneIndex: number;
|
|
138
|
+
nftMint: PublicKey | string;
|
|
139
|
+
choice: {
|
|
140
|
+
good: object;
|
|
141
|
+
} | {
|
|
142
|
+
bad: object;
|
|
143
|
+
};
|
|
144
|
+
}): Promise<string>;
|
|
145
|
+
finalizeVoting(projectId: BN, milestoneIndex: number): Promise<string>;
|
|
146
|
+
/**
|
|
147
|
+
* Claim milestone funds (ZTM v2.0)
|
|
148
|
+
* - Regular milestones: Full payout to founder
|
|
149
|
+
* - Final milestone: LP USDC reserved for PCL, triggers MAE
|
|
150
|
+
*
|
|
151
|
+
* @param nextMilestoneDeadline - Deadline for next milestone (required for non-final milestones)
|
|
152
|
+
* Set to BN(0) for final milestone claims (no next milestone exists)
|
|
153
|
+
*/
|
|
154
|
+
claimMilestoneFunds(args: {
|
|
155
|
+
projectId: BN;
|
|
156
|
+
milestoneIndex: number;
|
|
157
|
+
founderUsdcAccount: PublicKey;
|
|
158
|
+
escrowTokenAccount: PublicKey;
|
|
159
|
+
/** Deadline for next milestone - required for non-final milestones, use BN(0) for final */
|
|
160
|
+
nextMilestoneDeadline: BN;
|
|
161
|
+
/** Next milestone PDA - optional, auto-derived if not provided */
|
|
162
|
+
nextMilestonePda?: PublicKey;
|
|
163
|
+
}): Promise<string>;
|
|
164
|
+
/**
|
|
165
|
+
* Resubmit a failed milestone for rework (Failed → InProgress)
|
|
166
|
+
*
|
|
167
|
+
* Allows founders to iterate on failed milestones. Clears voting state
|
|
168
|
+
* for a fresh voting cycle. consecutive_failures is NOT reset.
|
|
169
|
+
*/
|
|
170
|
+
resubmitMilestone(args: {
|
|
171
|
+
projectId: BN;
|
|
172
|
+
milestoneIndex: number;
|
|
173
|
+
}): Promise<string>;
|
|
174
|
+
/**
|
|
175
|
+
* Set milestone deadline for founder to commit submission date
|
|
176
|
+
*
|
|
177
|
+
* Founders must set deadlines for milestones to provide visibility to investors.
|
|
178
|
+
* Deadline must be at least 7 days from now and at most 1 year from now.
|
|
179
|
+
*/
|
|
180
|
+
setMilestoneDeadline(args: {
|
|
181
|
+
projectId: BN;
|
|
182
|
+
milestoneIndex: number;
|
|
183
|
+
/** Unix timestamp for the deadline */
|
|
184
|
+
deadline: BN;
|
|
185
|
+
}): Promise<string>;
|
|
186
|
+
/**
|
|
187
|
+
* Extend milestone deadline (max 3 extensions per milestone)
|
|
188
|
+
*
|
|
189
|
+
* Founders can extend a deadline up to 3 times before it passes.
|
|
190
|
+
* Must be called BEFORE the current deadline passes.
|
|
191
|
+
*/
|
|
192
|
+
extendMilestoneDeadline(args: {
|
|
193
|
+
projectId: BN;
|
|
194
|
+
milestoneIndex: number;
|
|
195
|
+
/** New deadline timestamp (must be > current deadline) */
|
|
196
|
+
newDeadline: BN;
|
|
197
|
+
}): Promise<string>;
|
|
198
|
+
invest(args: {
|
|
199
|
+
projectId: BN;
|
|
200
|
+
amount: BN;
|
|
201
|
+
investorTokenAccount: PublicKey;
|
|
202
|
+
escrowTokenAccount: PublicKey;
|
|
203
|
+
investmentCount: number;
|
|
204
|
+
}): Promise<string>;
|
|
205
|
+
cancelInvestment(args: {
|
|
206
|
+
projectId: BN;
|
|
207
|
+
nftMint: PublicKey;
|
|
208
|
+
investorNftAccount: PublicKey;
|
|
209
|
+
investorUsdcAccount: PublicKey;
|
|
210
|
+
escrowTokenAccount: PublicKey;
|
|
211
|
+
}): Promise<string>;
|
|
212
|
+
proposePivot(args: {
|
|
213
|
+
projectId: BN;
|
|
214
|
+
newMetadataUri: string;
|
|
215
|
+
newMilestones: Array<{
|
|
216
|
+
percentage: number;
|
|
217
|
+
description: string;
|
|
218
|
+
}>;
|
|
219
|
+
}): Promise<string>;
|
|
220
|
+
approvePivot(projectId: BN, adminKeypair: Keypair): Promise<string>;
|
|
221
|
+
withdrawFromPivot(args: {
|
|
222
|
+
projectId: BN;
|
|
223
|
+
pivotCount: number;
|
|
224
|
+
nftMint: PublicKey;
|
|
225
|
+
investorTokenAccount: PublicKey;
|
|
226
|
+
escrowTokenAccount: PublicKey;
|
|
227
|
+
milestoneAccounts: PublicKey[];
|
|
228
|
+
}): Promise<string>;
|
|
229
|
+
finalizePivot(args: {
|
|
230
|
+
projectId: BN;
|
|
231
|
+
pivotCount: number;
|
|
232
|
+
milestoneAccounts: PublicKey[];
|
|
233
|
+
}): Promise<string>;
|
|
234
|
+
setTgeDate(args: {
|
|
235
|
+
projectId: BN;
|
|
236
|
+
tgeDate: BN;
|
|
237
|
+
tokenMint: PublicKey;
|
|
238
|
+
}): Promise<string>;
|
|
239
|
+
depositTokens(args: {
|
|
240
|
+
projectId: BN;
|
|
241
|
+
amount: BN;
|
|
242
|
+
tokenMint: PublicKey;
|
|
243
|
+
founderTokenAccount: PublicKey;
|
|
244
|
+
}): Promise<string>;
|
|
245
|
+
claimTokens(args: {
|
|
246
|
+
projectId: BN;
|
|
247
|
+
nftMint: PublicKey;
|
|
248
|
+
investorNftAccount: PublicKey;
|
|
249
|
+
investorTokenAccount: PublicKey;
|
|
250
|
+
projectTokenVault: PublicKey;
|
|
251
|
+
}): Promise<string>;
|
|
252
|
+
reportScam(args: {
|
|
253
|
+
projectId: BN;
|
|
254
|
+
nftMint: PublicKey;
|
|
255
|
+
}): Promise<string>;
|
|
256
|
+
releaseHoldback(args: {
|
|
257
|
+
projectId: BN;
|
|
258
|
+
founderTokenAccount: PublicKey;
|
|
259
|
+
}): Promise<string>;
|
|
260
|
+
/**
|
|
261
|
+
* Claim investor tokens from a passed milestone (whitepaper: manual claim model)
|
|
262
|
+
*
|
|
263
|
+
* ZTM v2.0: Per whitepaper, investors manually claim their tokens after a milestone passes.
|
|
264
|
+
* This replaces the batch distribution model with investor-initiated per-NFT claims.
|
|
265
|
+
*/
|
|
266
|
+
claimInvestorTokens(args: {
|
|
267
|
+
projectId: BN;
|
|
268
|
+
milestoneIndex: number;
|
|
269
|
+
nftMint: PublicKey;
|
|
270
|
+
investorTokenAccount: PublicKey;
|
|
271
|
+
}): Promise<string>;
|
|
272
|
+
/**
|
|
273
|
+
* Distribute tokens to NFT holders for a milestone
|
|
274
|
+
*
|
|
275
|
+
* ZTM v2.0: Called by cranker after finalize_voting sets distribution_pending = true.
|
|
276
|
+
* Processes batch of investments, transferring unlocked tokens to NFT holders.
|
|
277
|
+
* Max batch size: 10 investments per call.
|
|
278
|
+
*
|
|
279
|
+
* @deprecated Use claimInvestorTokens instead (whitepaper manual claim model)
|
|
280
|
+
*/
|
|
281
|
+
distributeTokens(args: {
|
|
282
|
+
projectId: BN;
|
|
283
|
+
milestoneIndex: number;
|
|
284
|
+
investments: Array<{
|
|
285
|
+
investmentPda: PublicKey;
|
|
286
|
+
investorTokenAccount: PublicKey;
|
|
287
|
+
}>;
|
|
288
|
+
}): Promise<string>;
|
|
289
|
+
/**
|
|
290
|
+
* Complete token distribution for a milestone
|
|
291
|
+
*
|
|
292
|
+
* ZTM v2.0: Marks distribution as complete after all batches have been processed.
|
|
293
|
+
* Permissionless - anyone can call this to finalize a distribution.
|
|
294
|
+
*/
|
|
295
|
+
completeDistribution(args: {
|
|
296
|
+
projectId: BN;
|
|
297
|
+
milestoneIndex: number;
|
|
298
|
+
}): Promise<string>;
|
|
299
|
+
/**
|
|
300
|
+
* Initialize founder vesting after MAE (Market Access Event)
|
|
301
|
+
*
|
|
302
|
+
* ZTM v2.0: Creates FounderVesting PDA with vesting schedule from Tokenomics.
|
|
303
|
+
* Must be called after project reaches Completed state (all milestones done).
|
|
304
|
+
* Permissionless - anyone can pay to initialize.
|
|
305
|
+
*/
|
|
306
|
+
initializeFounderVesting(args: {
|
|
307
|
+
projectId: BN;
|
|
308
|
+
}): Promise<string>;
|
|
309
|
+
/**
|
|
310
|
+
* Claim vested tokens from founder vault
|
|
311
|
+
*
|
|
312
|
+
* ZTM v2.0: Founder claims tokens based on linear vesting schedule.
|
|
313
|
+
* Requires cliff period to pass before any tokens can be claimed.
|
|
314
|
+
*/
|
|
315
|
+
claimVestedTokens(args: {
|
|
316
|
+
projectId: BN;
|
|
317
|
+
founderTokenAccount: PublicKey;
|
|
318
|
+
}): Promise<string>;
|
|
319
|
+
/**
|
|
320
|
+
* Force complete a stuck distribution (admin only)
|
|
321
|
+
*
|
|
322
|
+
* ZTM v2.0: Circuit breaker for when token distribution is stuck for >7 days.
|
|
323
|
+
* Marks distribution as complete so project can continue.
|
|
324
|
+
* Affected investors can use claimMissedUnlock to get their tokens.
|
|
325
|
+
*/
|
|
326
|
+
forceCompleteDistribution(args: {
|
|
327
|
+
projectId: BN;
|
|
328
|
+
}, adminKeypair: Keypair): Promise<string>;
|
|
329
|
+
/**
|
|
330
|
+
* Claim missed token unlock after force-complete distribution
|
|
331
|
+
*
|
|
332
|
+
* ZTM v2.0: Allows investors to claim tokens they missed during a stuck
|
|
333
|
+
* distribution that was force-completed by admin.
|
|
334
|
+
*/
|
|
335
|
+
claimMissedUnlock(args: {
|
|
336
|
+
projectId: BN;
|
|
337
|
+
nftMint: PublicKey;
|
|
338
|
+
milestoneIndex: number;
|
|
339
|
+
claimerTokenAccount: PublicKey;
|
|
340
|
+
}): Promise<string>;
|
|
341
|
+
checkAbandonment(projectId: BN, milestoneIndex?: number): Promise<string>;
|
|
342
|
+
claimRefund(args: {
|
|
343
|
+
projectId: BN;
|
|
344
|
+
nftMint: PublicKey;
|
|
345
|
+
investorNftAccount: PublicKey;
|
|
346
|
+
investorUsdcAccount: PublicKey;
|
|
347
|
+
escrowTokenAccount: PublicKey;
|
|
348
|
+
milestoneCount?: number;
|
|
349
|
+
}): Promise<string>;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Raise Event Parsing
|
|
354
|
+
*
|
|
355
|
+
* Helpers for parsing program events from transaction logs.
|
|
356
|
+
*/
|
|
357
|
+
|
|
358
|
+
interface ProjectCreatedEvent {
|
|
359
|
+
name: 'ProjectCreated';
|
|
360
|
+
data: {
|
|
361
|
+
projectId: BN;
|
|
362
|
+
founder: PublicKey;
|
|
363
|
+
fundingGoal: BN;
|
|
364
|
+
metadataUri: string;
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
interface ProjectApprovedEvent {
|
|
368
|
+
name: 'ProjectApproved';
|
|
369
|
+
data: {
|
|
370
|
+
projectId: BN;
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
interface ProjectFundedEvent {
|
|
374
|
+
name: 'ProjectFunded';
|
|
375
|
+
data: {
|
|
376
|
+
projectId: BN;
|
|
377
|
+
amountRaised: BN;
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
interface InvestmentMadeEvent {
|
|
381
|
+
name: 'InvestmentMade';
|
|
382
|
+
data: {
|
|
383
|
+
projectId: BN;
|
|
384
|
+
investor: PublicKey;
|
|
385
|
+
amount: BN;
|
|
386
|
+
nftMint: PublicKey;
|
|
387
|
+
tier: number;
|
|
388
|
+
voteWeight: BN;
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
interface InvestmentCancelledEvent {
|
|
392
|
+
name: 'InvestmentCancelled';
|
|
393
|
+
data: {
|
|
394
|
+
projectId: BN;
|
|
395
|
+
investor: PublicKey;
|
|
396
|
+
amount: BN;
|
|
397
|
+
nftMint: PublicKey;
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
interface MilestoneCreatedEvent {
|
|
401
|
+
name: 'MilestoneCreated';
|
|
402
|
+
data: {
|
|
403
|
+
projectId: BN;
|
|
404
|
+
milestoneIndex: number;
|
|
405
|
+
percentage: number;
|
|
406
|
+
description: string;
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
interface MilestoneSubmittedEvent {
|
|
410
|
+
name: 'MilestoneSubmitted';
|
|
411
|
+
data: {
|
|
412
|
+
projectId: BN;
|
|
413
|
+
milestoneIndex: number;
|
|
414
|
+
votingEndsAt: BN;
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
interface VoteCastEvent {
|
|
418
|
+
name: 'VoteCast';
|
|
419
|
+
data: {
|
|
420
|
+
projectId: BN;
|
|
421
|
+
milestoneIndex: number;
|
|
422
|
+
voter: PublicKey;
|
|
423
|
+
choice: {
|
|
424
|
+
good: object;
|
|
425
|
+
} | {
|
|
426
|
+
bad: object;
|
|
427
|
+
};
|
|
428
|
+
weight: BN;
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
interface MilestoneVoteFinalizedEvent {
|
|
432
|
+
name: 'MilestoneVoteFinalized';
|
|
433
|
+
data: {
|
|
434
|
+
projectId: BN;
|
|
435
|
+
milestoneIndex: number;
|
|
436
|
+
passed: boolean;
|
|
437
|
+
yesVotes: BN;
|
|
438
|
+
noVotes: BN;
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
interface FundsUnlockedEvent {
|
|
442
|
+
name: 'FundsUnlocked';
|
|
443
|
+
data: {
|
|
444
|
+
projectId: BN;
|
|
445
|
+
milestoneIndex: number;
|
|
446
|
+
amount: BN;
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
interface TgeDateSetEvent {
|
|
450
|
+
name: 'TgeDateSet';
|
|
451
|
+
data: {
|
|
452
|
+
projectId: BN;
|
|
453
|
+
tgeDate: BN;
|
|
454
|
+
tokenMint: PublicKey;
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
interface TokensDepositedEvent {
|
|
458
|
+
name: 'TokensDeposited';
|
|
459
|
+
data: {
|
|
460
|
+
projectId: BN;
|
|
461
|
+
amount: BN;
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
interface TokensClaimedEvent {
|
|
465
|
+
name: 'TokensClaimed';
|
|
466
|
+
data: {
|
|
467
|
+
projectId: BN;
|
|
468
|
+
investor: PublicKey;
|
|
469
|
+
amount: BN;
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
interface RefundClaimedEvent {
|
|
473
|
+
name: 'RefundClaimed';
|
|
474
|
+
data: {
|
|
475
|
+
projectId: BN;
|
|
476
|
+
investor: PublicKey;
|
|
477
|
+
amount: BN;
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
interface PivotProposedEvent {
|
|
481
|
+
name: 'PivotProposed';
|
|
482
|
+
data: {
|
|
483
|
+
projectId: BN;
|
|
484
|
+
newMetadataUri: string;
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
interface PivotApprovedEvent {
|
|
488
|
+
name: 'PivotApproved';
|
|
489
|
+
data: {
|
|
490
|
+
projectId: BN;
|
|
491
|
+
withdrawalWindowEndsAt: BN;
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
interface PivotFinalizedEvent {
|
|
495
|
+
name: 'PivotFinalized';
|
|
496
|
+
data: {
|
|
497
|
+
projectId: BN;
|
|
498
|
+
withdrawnAmount: BN;
|
|
499
|
+
withdrawnCount: number;
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
interface MilestoneReworkedEvent {
|
|
503
|
+
name: 'MilestoneReworked';
|
|
504
|
+
data: {
|
|
505
|
+
projectId: BN;
|
|
506
|
+
milestoneIndex: number;
|
|
507
|
+
milestoneKey: PublicKey;
|
|
508
|
+
consecutiveFailures: number;
|
|
509
|
+
reworkedAt: BN;
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
type RaiseEvent = ProjectCreatedEvent | ProjectApprovedEvent | ProjectFundedEvent | InvestmentMadeEvent | InvestmentCancelledEvent | MilestoneCreatedEvent | MilestoneSubmittedEvent | VoteCastEvent | MilestoneVoteFinalizedEvent | FundsUnlockedEvent | TgeDateSetEvent | TokensDepositedEvent | TokensClaimedEvent | RefundClaimedEvent | PivotProposedEvent | PivotApprovedEvent | PivotFinalizedEvent | MilestoneReworkedEvent;
|
|
513
|
+
/**
|
|
514
|
+
* Event name constants
|
|
515
|
+
*/
|
|
516
|
+
declare const EVENT_NAMES: {
|
|
517
|
+
readonly ProjectCreated: "ProjectCreated";
|
|
518
|
+
readonly ProjectApproved: "ProjectApproved";
|
|
519
|
+
readonly ProjectFunded: "ProjectFunded";
|
|
520
|
+
readonly InvestmentMade: "InvestmentMade";
|
|
521
|
+
readonly InvestmentCancelled: "InvestmentCancelled";
|
|
522
|
+
readonly MilestoneCreated: "MilestoneCreated";
|
|
523
|
+
readonly MilestoneSubmitted: "MilestoneSubmitted";
|
|
524
|
+
readonly VoteCast: "VoteCast";
|
|
525
|
+
readonly MilestoneVoteFinalized: "MilestoneVoteFinalized";
|
|
526
|
+
readonly FundsUnlocked: "FundsUnlocked";
|
|
527
|
+
readonly TgeDateSet: "TgeDateSet";
|
|
528
|
+
readonly TokensDeposited: "TokensDeposited";
|
|
529
|
+
readonly TokensClaimed: "TokensClaimed";
|
|
530
|
+
readonly RefundClaimed: "RefundClaimed";
|
|
531
|
+
readonly PivotProposed: "PivotProposed";
|
|
532
|
+
readonly PivotApproved: "PivotApproved";
|
|
533
|
+
readonly PivotFinalized: "PivotFinalized";
|
|
534
|
+
readonly MilestoneReworked: "MilestoneReworked";
|
|
535
|
+
};
|
|
536
|
+
/**
|
|
537
|
+
* Filter events by name
|
|
538
|
+
*
|
|
539
|
+
* @param events - Array of events
|
|
540
|
+
* @param name - Event name to filter
|
|
541
|
+
* @returns Filtered events
|
|
542
|
+
*/
|
|
543
|
+
declare function filterEventsByName<T extends RaiseEvent>(events: RaiseEvent[], name: T['name']): T[];
|
|
544
|
+
/**
|
|
545
|
+
* Get the first event of a specific type
|
|
546
|
+
*
|
|
547
|
+
* @param events - Array of events
|
|
548
|
+
* @param name - Event name to find
|
|
549
|
+
* @returns First matching event or undefined
|
|
550
|
+
*/
|
|
551
|
+
declare function findEvent<T extends RaiseEvent>(events: RaiseEvent[], name: T['name']): T | undefined;
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Wait for transaction confirmation
|
|
555
|
+
*
|
|
556
|
+
* @param connection - Solana connection
|
|
557
|
+
* @param signature - Transaction signature
|
|
558
|
+
* @param commitment - Confirmation commitment level
|
|
559
|
+
* @returns Confirmation result
|
|
560
|
+
*/
|
|
561
|
+
declare function confirmTransaction(connection: Connection, signature: TransactionSignature, commitment?: 'confirmed' | 'finalized'): Promise<_solana_web3_js.RpcResponseAndContext<_solana_web3_js.SignatureResult>>;
|
|
562
|
+
/**
|
|
563
|
+
* Get transaction details with retry
|
|
564
|
+
*
|
|
565
|
+
* @param connection - Solana connection
|
|
566
|
+
* @param signature - Transaction signature
|
|
567
|
+
* @param maxRetries - Maximum number of retries
|
|
568
|
+
* @returns Transaction details
|
|
569
|
+
*/
|
|
570
|
+
declare function getTransactionWithRetry(connection: Connection, signature: TransactionSignature, maxRetries?: number): Promise<_solana_web3_js.VersionedTransactionResponse>;
|
|
571
|
+
/**
|
|
572
|
+
* Convert BN to number safely
|
|
573
|
+
*
|
|
574
|
+
* @param bn - BN value
|
|
575
|
+
* @returns Number value
|
|
576
|
+
* @throws If value is too large for safe integer
|
|
577
|
+
*/
|
|
578
|
+
declare function bnToNumber(bn: BN): number;
|
|
579
|
+
/**
|
|
580
|
+
* Convert BN to bigint
|
|
581
|
+
*
|
|
582
|
+
* @param bn - BN value
|
|
583
|
+
* @returns BigInt value
|
|
584
|
+
*/
|
|
585
|
+
declare function bnToBigInt(bn: BN): bigint;
|
|
586
|
+
/**
|
|
587
|
+
* Convert bigint to BN
|
|
588
|
+
*
|
|
589
|
+
* @param value - BigInt value
|
|
590
|
+
* @returns BN value
|
|
591
|
+
*/
|
|
592
|
+
declare function bigIntToBN(value: bigint): BN;
|
|
593
|
+
/**
|
|
594
|
+
* Get current Unix timestamp in seconds
|
|
595
|
+
*
|
|
596
|
+
* @returns Current timestamp
|
|
597
|
+
*/
|
|
598
|
+
declare function getCurrentTimestamp(): number;
|
|
599
|
+
/**
|
|
600
|
+
* Convert Unix timestamp to Date
|
|
601
|
+
*
|
|
602
|
+
* @param timestamp - Unix timestamp in seconds
|
|
603
|
+
* @returns Date object
|
|
604
|
+
*/
|
|
605
|
+
declare function timestampToDate(timestamp: number | BN): Date;
|
|
606
|
+
/**
|
|
607
|
+
* Check if a timestamp has passed
|
|
608
|
+
*
|
|
609
|
+
* @param timestamp - Unix timestamp in seconds
|
|
610
|
+
* @returns True if timestamp has passed
|
|
611
|
+
*/
|
|
612
|
+
declare function hasTimestampPassed(timestamp: number | BN): boolean;
|
|
613
|
+
/**
|
|
614
|
+
* Calculate time remaining until timestamp
|
|
615
|
+
*
|
|
616
|
+
* @param timestamp - Unix timestamp in seconds
|
|
617
|
+
* @returns Seconds remaining (0 if passed)
|
|
618
|
+
*/
|
|
619
|
+
declare function timeRemaining(timestamp: number | BN): number;
|
|
620
|
+
/**
|
|
621
|
+
* Format duration in human-readable format
|
|
622
|
+
*
|
|
623
|
+
* @param seconds - Duration in seconds
|
|
624
|
+
* @returns Formatted string (e.g., "2d 5h 30m")
|
|
625
|
+
*/
|
|
626
|
+
declare function formatDuration(seconds: number): string;
|
|
627
|
+
/**
|
|
628
|
+
* Calculate percentage from basis points
|
|
629
|
+
*
|
|
630
|
+
* @param bps - Basis points (1% = 100 bps)
|
|
631
|
+
* @returns Percentage as decimal
|
|
632
|
+
*/
|
|
633
|
+
declare function bpsToPercent(bps: number): number;
|
|
634
|
+
/**
|
|
635
|
+
* Calculate basis points from percentage
|
|
636
|
+
*
|
|
637
|
+
* @param percent - Percentage as decimal
|
|
638
|
+
* @returns Basis points
|
|
639
|
+
*/
|
|
640
|
+
declare function percentToBps(percent: number): number;
|
|
641
|
+
/**
|
|
642
|
+
* Calculate percentage of amount
|
|
643
|
+
*
|
|
644
|
+
* @param amount - Total amount
|
|
645
|
+
* @param percentage - Percentage (0-100)
|
|
646
|
+
* @returns Calculated amount
|
|
647
|
+
*/
|
|
648
|
+
declare function percentageOf(amount: bigint, percentage: number): bigint;
|
|
649
|
+
/**
|
|
650
|
+
* Validate milestone percentages sum to 100
|
|
651
|
+
*
|
|
652
|
+
* @param percentages - Array of percentage values
|
|
653
|
+
* @returns True if valid
|
|
654
|
+
*/
|
|
655
|
+
declare function validateMilestonePercentages(percentages: number[]): boolean;
|
|
656
|
+
/**
|
|
657
|
+
* Validate metadata URI format
|
|
658
|
+
*
|
|
659
|
+
* @param uri - URI string
|
|
660
|
+
* @param maxLength - Maximum allowed length
|
|
661
|
+
* @returns True if valid
|
|
662
|
+
*/
|
|
663
|
+
declare function validateMetadataUri(uri: string, maxLength?: number): boolean;
|
|
664
|
+
/**
|
|
665
|
+
* Check if a public key is valid
|
|
666
|
+
*
|
|
667
|
+
* @param pubkey - String or PublicKey
|
|
668
|
+
* @returns True if valid
|
|
669
|
+
*/
|
|
670
|
+
declare function isValidPublicKey(pubkey: string | PublicKey): boolean;
|
|
671
|
+
/**
|
|
672
|
+
* Shorten a public key for display
|
|
673
|
+
*
|
|
674
|
+
* @param pubkey - Public key
|
|
675
|
+
* @param chars - Number of characters to show on each end
|
|
676
|
+
* @returns Shortened string (e.g., "ABC...XYZ")
|
|
677
|
+
*/
|
|
678
|
+
declare function shortenPublicKey(pubkey: PublicKey | string, chars?: number): string;
|
|
679
|
+
|
|
680
|
+
export { EVENT_NAMES, type InvestmentMadeEvent as InvestmentMadeEventType, InvestmentWithKey, type MilestoneReworkedEvent as MilestoneReworkedEventType, type MilestoneVoteFinalizedEvent as MilestoneVoteFinalizedEventType, MilestoneWithKey, type ProjectCreatedEvent as ProjectCreatedEventType, RaiseClient, type RaiseEvent, TierConfig, TokenomicsInput, VoteWithKey, type Wallet, bigIntToBN, bnToBigInt, bnToNumber, bpsToPercent, confirmTransaction, filterEventsByName, findEvent, formatDuration, getCurrentTimestamp, getTransactionWithRetry, hasTimestampPassed, isValidPublicKey, percentToBps, percentageOf, shortenPublicKey, timeRemaining, timestampToDate, validateMetadataUri, validateMilestonePercentages };
|