@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
|
@@ -0,0 +1,809 @@
|
|
|
1
|
+
import { BN } from '@coral-xyz/anchor';
|
|
2
|
+
import { PublicKey, SystemProgram, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RENT_PUBKEY, ComputeBudgetProgram, SYSVAR_CLOCK_PUBKEY } from '@solana/web3.js';
|
|
3
|
+
import { getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID } from '@solana/spl-token';
|
|
4
|
+
|
|
5
|
+
// src/instructions/index.ts
|
|
6
|
+
|
|
7
|
+
// src/constants/index.ts
|
|
8
|
+
var SEEDS = {
|
|
9
|
+
PROJECT: "project",
|
|
10
|
+
MILESTONE: "milestone",
|
|
11
|
+
INVESTMENT: "investment",
|
|
12
|
+
VOTE: "vote",
|
|
13
|
+
ESCROW: "escrow",
|
|
14
|
+
PIVOT: "pivot",
|
|
15
|
+
TGE_ESCROW: "tge_escrow",
|
|
16
|
+
ADMIN_CONFIG: "admin-config",
|
|
17
|
+
NFT_MINT: "nft_mint",
|
|
18
|
+
AUTHORITY: "authority"
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// src/pdas/index.ts
|
|
22
|
+
function ensureBN(value) {
|
|
23
|
+
if (value && typeof value.toArrayLike === "function") {
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
return new BN(String(value));
|
|
27
|
+
}
|
|
28
|
+
function getProjectPDA(projectId, programId) {
|
|
29
|
+
const projectIdBN = ensureBN(projectId);
|
|
30
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
31
|
+
[Buffer.from(SEEDS.PROJECT), projectIdBN.toArrayLike(Buffer, "le", 8)],
|
|
32
|
+
programId
|
|
33
|
+
);
|
|
34
|
+
return pda;
|
|
35
|
+
}
|
|
36
|
+
function getEscrowPDA(projectId, programId) {
|
|
37
|
+
const projectIdBN = ensureBN(projectId);
|
|
38
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
39
|
+
[Buffer.from(SEEDS.ESCROW), projectIdBN.toArrayLike(Buffer, "le", 8)],
|
|
40
|
+
programId
|
|
41
|
+
);
|
|
42
|
+
return pda;
|
|
43
|
+
}
|
|
44
|
+
function getMilestonePDA(projectPda, milestoneIndex, programId) {
|
|
45
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
46
|
+
[
|
|
47
|
+
Buffer.from(SEEDS.MILESTONE),
|
|
48
|
+
projectPda.toBuffer(),
|
|
49
|
+
Buffer.from([milestoneIndex])
|
|
50
|
+
],
|
|
51
|
+
programId
|
|
52
|
+
);
|
|
53
|
+
return pda;
|
|
54
|
+
}
|
|
55
|
+
function getInvestmentPDA(projectPda, nftMint, programId) {
|
|
56
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
57
|
+
[
|
|
58
|
+
Buffer.from(SEEDS.INVESTMENT),
|
|
59
|
+
projectPda.toBuffer(),
|
|
60
|
+
nftMint.toBuffer()
|
|
61
|
+
],
|
|
62
|
+
programId
|
|
63
|
+
);
|
|
64
|
+
return pda;
|
|
65
|
+
}
|
|
66
|
+
function getVotePDA(milestonePda, voterKey, votingRound, programId) {
|
|
67
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
68
|
+
[Buffer.from(SEEDS.VOTE), milestonePda.toBuffer(), voterKey.toBuffer(), Buffer.from([votingRound])],
|
|
69
|
+
programId
|
|
70
|
+
);
|
|
71
|
+
return pda;
|
|
72
|
+
}
|
|
73
|
+
function getPivotProposalPDA(projectPda, pivotCount, programId) {
|
|
74
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
75
|
+
[
|
|
76
|
+
Buffer.from(SEEDS.PIVOT),
|
|
77
|
+
// Use PIVOT seed, not PIVOT_PROPOSAL
|
|
78
|
+
projectPda.toBuffer(),
|
|
79
|
+
Buffer.from([pivotCount])
|
|
80
|
+
// pivot_count is u8 (1 byte) on-chain
|
|
81
|
+
],
|
|
82
|
+
programId
|
|
83
|
+
);
|
|
84
|
+
return pda;
|
|
85
|
+
}
|
|
86
|
+
function getTgeEscrowPDA(projectPda, programId) {
|
|
87
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
88
|
+
[Buffer.from(SEEDS.TGE_ESCROW), projectPda.toBuffer()],
|
|
89
|
+
programId
|
|
90
|
+
);
|
|
91
|
+
return pda;
|
|
92
|
+
}
|
|
93
|
+
function getTokenVaultPDA(projectPda, programId) {
|
|
94
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
95
|
+
[Buffer.from("token_vault"), projectPda.toBuffer()],
|
|
96
|
+
programId
|
|
97
|
+
);
|
|
98
|
+
return pda;
|
|
99
|
+
}
|
|
100
|
+
function getAdminConfigPDA(programId) {
|
|
101
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
102
|
+
[Buffer.from(SEEDS.ADMIN_CONFIG)],
|
|
103
|
+
programId
|
|
104
|
+
);
|
|
105
|
+
return pda;
|
|
106
|
+
}
|
|
107
|
+
function getNftMintPDA(projectId, investor, investmentCount, programId) {
|
|
108
|
+
const projectIdBN = ensureBN(projectId);
|
|
109
|
+
const countBN = ensureBN(investmentCount);
|
|
110
|
+
return PublicKey.findProgramAddressSync(
|
|
111
|
+
[
|
|
112
|
+
Buffer.from(SEEDS.NFT_MINT),
|
|
113
|
+
projectIdBN.toArrayLike(Buffer, "le", 8),
|
|
114
|
+
investor.toBuffer(),
|
|
115
|
+
countBN.toArrayLike(Buffer, "le", 8)
|
|
116
|
+
// u64 is 8 bytes LE
|
|
117
|
+
],
|
|
118
|
+
programId
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
function getProgramAuthorityPDA(programId) {
|
|
122
|
+
return PublicKey.findProgramAddressSync(
|
|
123
|
+
[Buffer.from(SEEDS.AUTHORITY)],
|
|
124
|
+
programId
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
function getTokenomicsPDA(projectPda, programId) {
|
|
128
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
129
|
+
[Buffer.from("tokenomics"), projectPda.toBuffer()],
|
|
130
|
+
programId
|
|
131
|
+
);
|
|
132
|
+
return pda;
|
|
133
|
+
}
|
|
134
|
+
function getTokenMintPDA(projectPda, programId) {
|
|
135
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
136
|
+
[Buffer.from("token_mint"), projectPda.toBuffer()],
|
|
137
|
+
programId
|
|
138
|
+
);
|
|
139
|
+
return pda;
|
|
140
|
+
}
|
|
141
|
+
function getVaultAuthorityPDA(projectPda, programId) {
|
|
142
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
143
|
+
[Buffer.from("vault_authority"), projectPda.toBuffer()],
|
|
144
|
+
programId
|
|
145
|
+
);
|
|
146
|
+
return pda;
|
|
147
|
+
}
|
|
148
|
+
function getInvestorVaultPDA(projectPda, programId) {
|
|
149
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
150
|
+
[Buffer.from("investor_vault"), projectPda.toBuffer()],
|
|
151
|
+
programId
|
|
152
|
+
);
|
|
153
|
+
return pda;
|
|
154
|
+
}
|
|
155
|
+
function getFounderVaultPDA(projectPda, programId) {
|
|
156
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
157
|
+
[Buffer.from("founder_vault"), projectPda.toBuffer()],
|
|
158
|
+
programId
|
|
159
|
+
);
|
|
160
|
+
return pda;
|
|
161
|
+
}
|
|
162
|
+
function getLpTokenVaultPDA(projectPda, programId) {
|
|
163
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
164
|
+
[Buffer.from("lp_token_vault"), projectPda.toBuffer()],
|
|
165
|
+
programId
|
|
166
|
+
);
|
|
167
|
+
return pda;
|
|
168
|
+
}
|
|
169
|
+
function getTreasuryVaultPDA(projectPda, programId) {
|
|
170
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
171
|
+
[Buffer.from("treasury_vault"), projectPda.toBuffer()],
|
|
172
|
+
programId
|
|
173
|
+
);
|
|
174
|
+
return pda;
|
|
175
|
+
}
|
|
176
|
+
function getLpUsdcVaultPDA(projectPda, programId) {
|
|
177
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
178
|
+
[Buffer.from("lp_usdc_vault"), projectPda.toBuffer()],
|
|
179
|
+
programId
|
|
180
|
+
);
|
|
181
|
+
return pda;
|
|
182
|
+
}
|
|
183
|
+
function getFounderVestingPDA(projectPda, programId) {
|
|
184
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
185
|
+
[Buffer.from("founder_vesting"), projectPda.toBuffer()],
|
|
186
|
+
programId
|
|
187
|
+
);
|
|
188
|
+
return pda;
|
|
189
|
+
}
|
|
190
|
+
var TOKEN_METADATA_PROGRAM_ID = new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");
|
|
191
|
+
function ensurePublicKey(value) {
|
|
192
|
+
if (value instanceof PublicKey) {
|
|
193
|
+
return value;
|
|
194
|
+
}
|
|
195
|
+
return new PublicKey(String(value));
|
|
196
|
+
}
|
|
197
|
+
function getMethods(program) {
|
|
198
|
+
return program.methods;
|
|
199
|
+
}
|
|
200
|
+
function getAccountNamespace(program) {
|
|
201
|
+
return program.account;
|
|
202
|
+
}
|
|
203
|
+
async function initializeAdmin(program, admin, payer) {
|
|
204
|
+
return getMethods(program).initializeAdmin().accounts({
|
|
205
|
+
admin,
|
|
206
|
+
payer
|
|
207
|
+
}).rpc();
|
|
208
|
+
}
|
|
209
|
+
async function transferAdmin(program, adminKeypair, newAdmin) {
|
|
210
|
+
return getMethods(program).transferAdmin().accounts({
|
|
211
|
+
authority: adminKeypair.publicKey,
|
|
212
|
+
newAdmin
|
|
213
|
+
}).signers([adminKeypair]).rpc();
|
|
214
|
+
}
|
|
215
|
+
async function acceptAdmin(program, newAuthority) {
|
|
216
|
+
return getMethods(program).acceptAdmin().accounts({
|
|
217
|
+
newAuthority
|
|
218
|
+
}).rpc();
|
|
219
|
+
}
|
|
220
|
+
function symbolToBytes(symbol) {
|
|
221
|
+
const bytes = new Array(8).fill(0);
|
|
222
|
+
const chars = symbol.toUpperCase().slice(0, 8);
|
|
223
|
+
for (let i = 0; i < chars.length; i++) {
|
|
224
|
+
bytes[i] = chars.charCodeAt(i);
|
|
225
|
+
}
|
|
226
|
+
return bytes;
|
|
227
|
+
}
|
|
228
|
+
var MIN_DEADLINE_DURATION_SECONDS_PROD = 604800;
|
|
229
|
+
var MIN_DEADLINE_DURATION_SECONDS_DEV = 60;
|
|
230
|
+
var MAX_DEADLINE_DURATION_SECONDS = 31536e3;
|
|
231
|
+
function calculateDeadline(daysFromNow, isDev = false) {
|
|
232
|
+
const nowSeconds = Math.floor(Date.now() / 1e3);
|
|
233
|
+
const minDuration = isDev ? MIN_DEADLINE_DURATION_SECONDS_DEV : MIN_DEADLINE_DURATION_SECONDS_PROD;
|
|
234
|
+
const daysInSeconds = daysFromNow * 24 * 60 * 60;
|
|
235
|
+
const deadlineSeconds = nowSeconds + Math.max(daysInSeconds, minDuration);
|
|
236
|
+
const maxDeadline = nowSeconds + MAX_DEADLINE_DURATION_SECONDS;
|
|
237
|
+
return new BN(Math.min(deadlineSeconds, maxDeadline));
|
|
238
|
+
}
|
|
239
|
+
function minDeadline(isDev = false) {
|
|
240
|
+
const nowSeconds = Math.floor(Date.now() / 1e3);
|
|
241
|
+
const minDuration = isDev ? MIN_DEADLINE_DURATION_SECONDS_DEV : MIN_DEADLINE_DURATION_SECONDS_PROD;
|
|
242
|
+
return new BN(nowSeconds + minDuration + 1);
|
|
243
|
+
}
|
|
244
|
+
function validateDeadline(deadline, isDev = false) {
|
|
245
|
+
const nowSeconds = Math.floor(Date.now() / 1e3);
|
|
246
|
+
const deadlineSeconds = deadline.toNumber();
|
|
247
|
+
const minDuration = isDev ? MIN_DEADLINE_DURATION_SECONDS_DEV : MIN_DEADLINE_DURATION_SECONDS_PROD;
|
|
248
|
+
const minDeadline2 = nowSeconds + minDuration;
|
|
249
|
+
const maxDeadline = nowSeconds + MAX_DEADLINE_DURATION_SECONDS;
|
|
250
|
+
if (deadlineSeconds < minDeadline2) {
|
|
251
|
+
const minDays = isDev ? "60 seconds" : "7 days";
|
|
252
|
+
return {
|
|
253
|
+
valid: false,
|
|
254
|
+
error: `Deadline must be at least ${minDays} from now`
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
if (deadlineSeconds > maxDeadline) {
|
|
258
|
+
return {
|
|
259
|
+
valid: false,
|
|
260
|
+
error: "Deadline must be within 1 year from now"
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
return { valid: true };
|
|
264
|
+
}
|
|
265
|
+
async function initializeProject(program, args, founder) {
|
|
266
|
+
return getMethods(program).initializeProject({
|
|
267
|
+
projectId: args.projectId,
|
|
268
|
+
fundingGoal: args.fundingGoal,
|
|
269
|
+
metadataUri: args.metadataUri,
|
|
270
|
+
tiers: args.tiers,
|
|
271
|
+
tokenomics: {
|
|
272
|
+
tokenSymbol: args.tokenomics.tokenSymbol,
|
|
273
|
+
totalSupply: args.tokenomics.totalSupply,
|
|
274
|
+
investorAllocationBps: args.tokenomics.investorAllocationBps,
|
|
275
|
+
lpTokenAllocationBps: args.tokenomics.lpTokenAllocationBps,
|
|
276
|
+
lpUsdcAllocationBps: args.tokenomics.lpUsdcAllocationBps,
|
|
277
|
+
founderAllocationBps: args.tokenomics.founderAllocationBps ?? null,
|
|
278
|
+
treasuryAllocationBps: args.tokenomics.treasuryAllocationBps ?? null,
|
|
279
|
+
founderWallet: args.tokenomics.founderWallet ?? null,
|
|
280
|
+
vestingDurationMonths: args.tokenomics.vestingDurationMonths ?? null,
|
|
281
|
+
cliffMonths: args.tokenomics.cliffMonths ?? null
|
|
282
|
+
},
|
|
283
|
+
milestone1Deadline: args.milestone1Deadline
|
|
284
|
+
}).accounts({
|
|
285
|
+
founder
|
|
286
|
+
}).rpc();
|
|
287
|
+
}
|
|
288
|
+
async function submitForApproval(program, projectId, founder) {
|
|
289
|
+
const projectPda = getProjectPDA(projectId, program.programId);
|
|
290
|
+
return getMethods(program).submitForApproval().accounts({
|
|
291
|
+
project: projectPda,
|
|
292
|
+
founder
|
|
293
|
+
}).rpc();
|
|
294
|
+
}
|
|
295
|
+
async function approveProject(program, args, adminKeypair) {
|
|
296
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
297
|
+
const tokenomicsPda = getTokenomicsPDA(projectPda, program.programId);
|
|
298
|
+
const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
|
|
299
|
+
const tokenMintPda = getTokenMintPDA(projectPda, program.programId);
|
|
300
|
+
const vaultAuthorityPda = getVaultAuthorityPDA(projectPda, program.programId);
|
|
301
|
+
const investorVaultPda = getInvestorVaultPDA(projectPda, program.programId);
|
|
302
|
+
const founderVaultPda = getFounderVaultPDA(projectPda, program.programId);
|
|
303
|
+
const lpTokenVaultPda = getLpTokenVaultPDA(projectPda, program.programId);
|
|
304
|
+
const treasuryVaultPda = getTreasuryVaultPDA(projectPda, program.programId);
|
|
305
|
+
const lpUsdcVaultPda = getLpUsdcVaultPDA(projectPda, program.programId);
|
|
306
|
+
return getMethods(program).approveProject().accounts({
|
|
307
|
+
project: projectPda,
|
|
308
|
+
tokenomics: tokenomicsPda,
|
|
309
|
+
tokenVault: tokenVaultPda,
|
|
310
|
+
tokenMint: tokenMintPda,
|
|
311
|
+
vaultAuthority: vaultAuthorityPda,
|
|
312
|
+
investorVault: investorVaultPda,
|
|
313
|
+
founderVault: founderVaultPda,
|
|
314
|
+
lpTokenVault: lpTokenVaultPda,
|
|
315
|
+
treasuryVault: treasuryVaultPda,
|
|
316
|
+
lpUsdcVault: lpUsdcVaultPda,
|
|
317
|
+
usdcMint: args.usdcMint,
|
|
318
|
+
authority: adminKeypair.publicKey,
|
|
319
|
+
payer: adminKeypair.publicKey
|
|
320
|
+
}).signers([adminKeypair]).rpc();
|
|
321
|
+
}
|
|
322
|
+
async function createMilestone(program, args, founder) {
|
|
323
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
324
|
+
const milestonePda = getMilestonePDA(projectPda, args.milestoneIndex, program.programId);
|
|
325
|
+
return getMethods(program).createMilestone({
|
|
326
|
+
milestoneIndex: args.milestoneIndex,
|
|
327
|
+
percentage: args.percentage,
|
|
328
|
+
description: args.description
|
|
329
|
+
}).accounts({
|
|
330
|
+
project: projectPda,
|
|
331
|
+
milestone: milestonePda,
|
|
332
|
+
founder
|
|
333
|
+
}).rpc();
|
|
334
|
+
}
|
|
335
|
+
async function submitMilestone(program, projectId, milestoneIndex, founder) {
|
|
336
|
+
const projectPda = getProjectPDA(projectId, program.programId);
|
|
337
|
+
const milestonePda = getMilestonePDA(projectPda, milestoneIndex, program.programId);
|
|
338
|
+
return getMethods(program).submitMilestone().accounts({
|
|
339
|
+
project: projectPda,
|
|
340
|
+
milestone: milestonePda,
|
|
341
|
+
founder
|
|
342
|
+
}).rpc();
|
|
343
|
+
}
|
|
344
|
+
async function voteOnMilestone(program, args, voter) {
|
|
345
|
+
const nftMintPubkey = ensurePublicKey(args.nftMint);
|
|
346
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
347
|
+
const milestonePda = getMilestonePDA(projectPda, args.milestoneIndex, program.programId);
|
|
348
|
+
const investmentPda = getInvestmentPDA(projectPda, nftMintPubkey, program.programId);
|
|
349
|
+
const milestone = await getAccountNamespace(program).milestone.fetch(milestonePda);
|
|
350
|
+
const votingRound = milestone.votingRound ?? 0;
|
|
351
|
+
const votePda = getVotePDA(milestonePda, voter, votingRound, program.programId);
|
|
352
|
+
const voterNftAccount = getAssociatedTokenAddressSync(
|
|
353
|
+
nftMintPubkey,
|
|
354
|
+
voter,
|
|
355
|
+
false,
|
|
356
|
+
// allowOwnerOffCurve
|
|
357
|
+
TOKEN_PROGRAM_ID
|
|
358
|
+
);
|
|
359
|
+
return getMethods(program).voteOnMilestone({ choice: args.choice }).accounts({
|
|
360
|
+
milestone: milestonePda,
|
|
361
|
+
project: projectPda,
|
|
362
|
+
investment: investmentPda,
|
|
363
|
+
vote: votePda,
|
|
364
|
+
nftMint: nftMintPubkey,
|
|
365
|
+
voterNftAccount,
|
|
366
|
+
voter
|
|
367
|
+
}).rpc();
|
|
368
|
+
}
|
|
369
|
+
async function finalizeVoting(program, projectId, milestoneIndex) {
|
|
370
|
+
const projectPda = getProjectPDA(projectId, program.programId);
|
|
371
|
+
const milestonePda = getMilestonePDA(projectPda, milestoneIndex, program.programId);
|
|
372
|
+
return getMethods(program).finalizeVoting().accounts({
|
|
373
|
+
project: projectPda,
|
|
374
|
+
milestone: milestonePda
|
|
375
|
+
}).rpc();
|
|
376
|
+
}
|
|
377
|
+
async function claimMilestoneFunds(program, args, founder) {
|
|
378
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
379
|
+
const milestonePda = getMilestonePDA(projectPda, args.milestoneIndex, program.programId);
|
|
380
|
+
const escrowPda = getEscrowPDA(args.projectId, program.programId);
|
|
381
|
+
const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
|
|
382
|
+
const tokenomicsPda = getTokenomicsPDA(projectPda, program.programId);
|
|
383
|
+
const lpUsdcVaultPda = getLpUsdcVaultPDA(projectPda, program.programId);
|
|
384
|
+
const nextMilestonePda = args.nextMilestonePda ?? (args.nextMilestoneDeadline.gt(new BN(0)) ? getMilestonePDA(projectPda, args.milestoneIndex + 1, program.programId) : null);
|
|
385
|
+
return getMethods(program).claimMilestoneFunds({ nextMilestoneDeadline: args.nextMilestoneDeadline }).accounts({
|
|
386
|
+
milestone: milestonePda,
|
|
387
|
+
project: projectPda,
|
|
388
|
+
founder,
|
|
389
|
+
projectEscrow: args.escrowTokenAccount,
|
|
390
|
+
founderUsdcAccount: args.founderUsdcAccount,
|
|
391
|
+
escrowPda,
|
|
392
|
+
tokenVault: tokenVaultPda,
|
|
393
|
+
tokenomics: tokenomicsPda,
|
|
394
|
+
lpUsdcVault: lpUsdcVaultPda,
|
|
395
|
+
nextMilestone: nextMilestonePda,
|
|
396
|
+
systemProgram: SystemProgram.programId,
|
|
397
|
+
tokenProgram: TOKEN_PROGRAM_ID
|
|
398
|
+
}).rpc();
|
|
399
|
+
}
|
|
400
|
+
async function resubmitMilestone(program, args, founder) {
|
|
401
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
402
|
+
const milestonePda = getMilestonePDA(projectPda, args.milestoneIndex, program.programId);
|
|
403
|
+
return getMethods(program).resubmitMilestone().accounts({
|
|
404
|
+
project: projectPda,
|
|
405
|
+
milestone: milestonePda,
|
|
406
|
+
founder
|
|
407
|
+
}).rpc();
|
|
408
|
+
}
|
|
409
|
+
async function setMilestoneDeadline(program, args, founder) {
|
|
410
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
411
|
+
const milestonePda = getMilestonePDA(projectPda, args.milestoneIndex, program.programId);
|
|
412
|
+
return getMethods(program).setMilestoneDeadline({
|
|
413
|
+
milestoneIndex: args.milestoneIndex,
|
|
414
|
+
deadline: args.deadline
|
|
415
|
+
}).accounts({
|
|
416
|
+
project: projectPda,
|
|
417
|
+
milestone: milestonePda,
|
|
418
|
+
founder
|
|
419
|
+
}).rpc();
|
|
420
|
+
}
|
|
421
|
+
async function extendMilestoneDeadline(program, args, founder) {
|
|
422
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
423
|
+
const milestonePda = getMilestonePDA(projectPda, args.milestoneIndex, program.programId);
|
|
424
|
+
return getMethods(program).extendMilestoneDeadline({
|
|
425
|
+
milestoneIndex: args.milestoneIndex,
|
|
426
|
+
newDeadline: args.newDeadline
|
|
427
|
+
}).accounts({
|
|
428
|
+
project: projectPda,
|
|
429
|
+
milestone: milestonePda,
|
|
430
|
+
founder
|
|
431
|
+
}).rpc();
|
|
432
|
+
}
|
|
433
|
+
function getMetadataPDA(mint) {
|
|
434
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
435
|
+
[
|
|
436
|
+
Buffer.from("metadata"),
|
|
437
|
+
TOKEN_METADATA_PROGRAM_ID.toBuffer(),
|
|
438
|
+
mint.toBuffer()
|
|
439
|
+
],
|
|
440
|
+
TOKEN_METADATA_PROGRAM_ID
|
|
441
|
+
);
|
|
442
|
+
return pda;
|
|
443
|
+
}
|
|
444
|
+
function getMasterEditionPDA(mint) {
|
|
445
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
446
|
+
[
|
|
447
|
+
Buffer.from("metadata"),
|
|
448
|
+
TOKEN_METADATA_PROGRAM_ID.toBuffer(),
|
|
449
|
+
mint.toBuffer(),
|
|
450
|
+
Buffer.from("edition")
|
|
451
|
+
],
|
|
452
|
+
TOKEN_METADATA_PROGRAM_ID
|
|
453
|
+
);
|
|
454
|
+
return pda;
|
|
455
|
+
}
|
|
456
|
+
async function invest(program, args, investor) {
|
|
457
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
458
|
+
const [nftMint] = getNftMintPDA(args.projectId, investor, args.investmentCount, program.programId);
|
|
459
|
+
const investmentPda = getInvestmentPDA(projectPda, nftMint, program.programId);
|
|
460
|
+
const investorNftAccount = getAssociatedTokenAddressSync(nftMint, investor);
|
|
461
|
+
const metadataAccount = getMetadataPDA(nftMint);
|
|
462
|
+
const masterEdition = getMasterEditionPDA(nftMint);
|
|
463
|
+
const [programAuthority] = getProgramAuthorityPDA(program.programId);
|
|
464
|
+
const firstMilestonePda = getMilestonePDA(projectPda, 0, program.programId);
|
|
465
|
+
return getMethods(program).invest({ amount: args.amount }).accounts({
|
|
466
|
+
project: projectPda,
|
|
467
|
+
firstMilestone: firstMilestonePda,
|
|
468
|
+
nftMint,
|
|
469
|
+
investment: investmentPda,
|
|
470
|
+
investorNftAccount,
|
|
471
|
+
metadataAccount,
|
|
472
|
+
masterEdition,
|
|
473
|
+
escrowTokenAccount: args.escrowTokenAccount,
|
|
474
|
+
investorTokenAccount: args.investorTokenAccount,
|
|
475
|
+
programAuthority,
|
|
476
|
+
investor,
|
|
477
|
+
tokenProgram: TOKEN_PROGRAM_ID,
|
|
478
|
+
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
479
|
+
systemProgram: SystemProgram.programId,
|
|
480
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
481
|
+
tokenMetadataProgram: TOKEN_METADATA_PROGRAM_ID,
|
|
482
|
+
sysvarInstructions: SYSVAR_INSTRUCTIONS_PUBKEY
|
|
483
|
+
}).preInstructions([
|
|
484
|
+
ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 })
|
|
485
|
+
]).rpc();
|
|
486
|
+
}
|
|
487
|
+
async function cancelInvestment(program, args, investor) {
|
|
488
|
+
const nftMintPubkey = ensurePublicKey(args.nftMint);
|
|
489
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
490
|
+
const investmentPda = getInvestmentPDA(projectPda, nftMintPubkey, program.programId);
|
|
491
|
+
const escrowPda = getEscrowPDA(args.projectId, program.programId);
|
|
492
|
+
return getMethods(program).cancelInvestment().accounts({
|
|
493
|
+
investor,
|
|
494
|
+
project: projectPda,
|
|
495
|
+
investment: investmentPda,
|
|
496
|
+
nftMint: nftMintPubkey,
|
|
497
|
+
investorNftAccount: args.investorNftAccount,
|
|
498
|
+
projectEscrow: args.escrowTokenAccount,
|
|
499
|
+
investorUsdcAccount: args.investorUsdcAccount,
|
|
500
|
+
escrowPda
|
|
501
|
+
}).rpc();
|
|
502
|
+
}
|
|
503
|
+
async function proposePivot(program, args, founder) {
|
|
504
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
505
|
+
const projectAccount = await getAccountNamespace(program).project.fetch(projectPda);
|
|
506
|
+
const pivotCount = projectAccount.pivotCount || 0;
|
|
507
|
+
const pivotProposalPda = getPivotProposalPDA(projectPda, pivotCount, program.programId);
|
|
508
|
+
return getMethods(program).proposePivot({
|
|
509
|
+
newMetadataUri: args.newMetadataUri,
|
|
510
|
+
newMilestones: args.newMilestones
|
|
511
|
+
}).accounts({
|
|
512
|
+
project: projectPda,
|
|
513
|
+
founder,
|
|
514
|
+
pivotProposal: pivotProposalPda,
|
|
515
|
+
systemProgram: SystemProgram.programId,
|
|
516
|
+
clock: SYSVAR_CLOCK_PUBKEY
|
|
517
|
+
}).rpc();
|
|
518
|
+
}
|
|
519
|
+
async function approvePivot(program, projectId, adminKeypair) {
|
|
520
|
+
const projectPda = getProjectPDA(projectId, program.programId);
|
|
521
|
+
const projectAccount = await getAccountNamespace(program).project.fetch(projectPda);
|
|
522
|
+
let pivotProposalPda;
|
|
523
|
+
if (projectAccount.activePivot) {
|
|
524
|
+
pivotProposalPda = projectAccount.activePivot;
|
|
525
|
+
} else {
|
|
526
|
+
const pivotCount = projectAccount.pivotCount || 0;
|
|
527
|
+
pivotProposalPda = getPivotProposalPDA(projectPda, pivotCount, program.programId);
|
|
528
|
+
}
|
|
529
|
+
return getMethods(program).approvePivot().accounts({
|
|
530
|
+
moderator: adminKeypair.publicKey,
|
|
531
|
+
project: projectPda,
|
|
532
|
+
pivotProposal: pivotProposalPda
|
|
533
|
+
}).signers([adminKeypair]).rpc();
|
|
534
|
+
}
|
|
535
|
+
async function withdrawFromPivot(program, args, investor) {
|
|
536
|
+
const nftMintPubkey = ensurePublicKey(args.nftMint);
|
|
537
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
538
|
+
const investmentPda = getInvestmentPDA(projectPda, nftMintPubkey, program.programId);
|
|
539
|
+
const escrowPda = getEscrowPDA(args.projectId, program.programId);
|
|
540
|
+
const pivotProposalPda = getPivotProposalPDA(projectPda, args.pivotCount, program.programId);
|
|
541
|
+
const investorNftAccount = getAssociatedTokenAddressSync(
|
|
542
|
+
nftMintPubkey,
|
|
543
|
+
investor,
|
|
544
|
+
false,
|
|
545
|
+
TOKEN_PROGRAM_ID
|
|
546
|
+
);
|
|
547
|
+
const remainingAccounts = args.milestoneAccounts.map((pubkey) => ({
|
|
548
|
+
pubkey: ensurePublicKey(pubkey),
|
|
549
|
+
isSigner: false,
|
|
550
|
+
isWritable: false
|
|
551
|
+
}));
|
|
552
|
+
return getMethods(program).withdrawFromPivot().accounts({
|
|
553
|
+
investor,
|
|
554
|
+
project: projectPda,
|
|
555
|
+
pivotProposal: pivotProposalPda,
|
|
556
|
+
investment: investmentPda,
|
|
557
|
+
nftMint: nftMintPubkey,
|
|
558
|
+
investorNftAccount,
|
|
559
|
+
escrowTokenAccount: args.escrowTokenAccount,
|
|
560
|
+
investorTokenAccount: args.investorTokenAccount,
|
|
561
|
+
escrow: escrowPda
|
|
562
|
+
}).remainingAccounts(remainingAccounts).rpc();
|
|
563
|
+
}
|
|
564
|
+
async function finalizePivot(program, args, authority) {
|
|
565
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
566
|
+
const pivotProposalPda = getPivotProposalPDA(projectPda, args.pivotCount, program.programId);
|
|
567
|
+
const remainingAccounts = args.milestoneAccounts.map((pubkey) => ({
|
|
568
|
+
pubkey,
|
|
569
|
+
isSigner: false,
|
|
570
|
+
isWritable: true
|
|
571
|
+
}));
|
|
572
|
+
return getMethods(program).finalizePivot().accounts({
|
|
573
|
+
authority,
|
|
574
|
+
project: projectPda,
|
|
575
|
+
pivotProposal: pivotProposalPda
|
|
576
|
+
}).remainingAccounts(remainingAccounts).rpc();
|
|
577
|
+
}
|
|
578
|
+
async function setTgeDate(program, args, founder) {
|
|
579
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
580
|
+
return getMethods(program).setTgeDate({
|
|
581
|
+
tgeDate: args.tgeDate,
|
|
582
|
+
tokenMint: args.tokenMint
|
|
583
|
+
}).accounts({
|
|
584
|
+
project: projectPda,
|
|
585
|
+
founder
|
|
586
|
+
}).rpc();
|
|
587
|
+
}
|
|
588
|
+
async function depositTokens(program, args, founder) {
|
|
589
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
590
|
+
return getMethods(program).depositTokens({ amount: args.amount }).accounts({
|
|
591
|
+
project: projectPda,
|
|
592
|
+
tokenMint: args.tokenMint,
|
|
593
|
+
founderTokenAccount: args.founderTokenAccount,
|
|
594
|
+
founder
|
|
595
|
+
}).rpc();
|
|
596
|
+
}
|
|
597
|
+
async function claimTokens(program, args, investor) {
|
|
598
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
599
|
+
const investmentPda = getInvestmentPDA(projectPda, args.nftMint, program.programId);
|
|
600
|
+
const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
|
|
601
|
+
return getMethods(program).claimTokens().accounts({
|
|
602
|
+
investor,
|
|
603
|
+
project: projectPda,
|
|
604
|
+
investment: investmentPda,
|
|
605
|
+
investorNftAccount: args.investorNftAccount,
|
|
606
|
+
projectTokenVault: args.projectTokenVault,
|
|
607
|
+
investorTokenAccount: args.investorTokenAccount,
|
|
608
|
+
tokenVaultPda,
|
|
609
|
+
tokenProgram: TOKEN_PROGRAM_ID
|
|
610
|
+
}).rpc();
|
|
611
|
+
}
|
|
612
|
+
async function reportScam(program, args, reporter) {
|
|
613
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
614
|
+
const tgeEscrowPda = getTgeEscrowPDA(projectPda, program.programId);
|
|
615
|
+
const investmentPda = getInvestmentPDA(projectPda, args.nftMint, program.programId);
|
|
616
|
+
return getMethods(program).reportScam().accounts({
|
|
617
|
+
tgeEscrow: tgeEscrowPda,
|
|
618
|
+
project: projectPda,
|
|
619
|
+
investment: investmentPda,
|
|
620
|
+
nftMint: args.nftMint,
|
|
621
|
+
reporter
|
|
622
|
+
}).rpc();
|
|
623
|
+
}
|
|
624
|
+
async function releaseHoldback(program, args) {
|
|
625
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
626
|
+
const tgeEscrowPda = getTgeEscrowPDA(projectPda, program.programId);
|
|
627
|
+
return getMethods(program).releaseHoldback().accounts({
|
|
628
|
+
tgeEscrow: tgeEscrowPda,
|
|
629
|
+
project: projectPda,
|
|
630
|
+
founderTokenAccount: args.founderTokenAccount
|
|
631
|
+
}).rpc();
|
|
632
|
+
}
|
|
633
|
+
async function checkAbandonment(program, projectId, milestoneIndex = 0) {
|
|
634
|
+
const projectPda = getProjectPDA(projectId, program.programId);
|
|
635
|
+
const milestonePda = getMilestonePDA(projectPda, milestoneIndex, program.programId);
|
|
636
|
+
return getMethods(program).checkAbandonment().accounts({
|
|
637
|
+
project: projectPda,
|
|
638
|
+
milestone: milestonePda
|
|
639
|
+
}).rpc();
|
|
640
|
+
}
|
|
641
|
+
async function claimRefund(program, args, investor) {
|
|
642
|
+
const nftMintPubkey = ensurePublicKey(args.nftMint);
|
|
643
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
644
|
+
const investmentPda = getInvestmentPDA(projectPda, nftMintPubkey, program.programId);
|
|
645
|
+
const milestoneCount = args.milestoneCount ?? 1;
|
|
646
|
+
const remainingAccounts = [];
|
|
647
|
+
for (let i = 0; i < milestoneCount; i++) {
|
|
648
|
+
const milestonePda = getMilestonePDA(projectPda, i, program.programId);
|
|
649
|
+
remainingAccounts.push({
|
|
650
|
+
pubkey: milestonePda,
|
|
651
|
+
isWritable: false,
|
|
652
|
+
isSigner: false
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
return getMethods(program).claimRefund().accounts({
|
|
656
|
+
project: projectPda,
|
|
657
|
+
investment: investmentPda,
|
|
658
|
+
nftMint: nftMintPubkey,
|
|
659
|
+
investorNftAccount: args.investorNftAccount,
|
|
660
|
+
investor,
|
|
661
|
+
investorTokenAccount: args.investorUsdcAccount,
|
|
662
|
+
escrowTokenAccount: args.escrowTokenAccount
|
|
663
|
+
}).remainingAccounts(remainingAccounts).rpc();
|
|
664
|
+
}
|
|
665
|
+
async function claimInvestorTokens(program, args, investor) {
|
|
666
|
+
const nftMintPubkey = ensurePublicKey(args.nftMint);
|
|
667
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
668
|
+
const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
|
|
669
|
+
const investmentPda = getInvestmentPDA(projectPda, nftMintPubkey, program.programId);
|
|
670
|
+
const investorVaultPda = getInvestorVaultPDA(projectPda, program.programId);
|
|
671
|
+
const vaultAuthorityPda = getVaultAuthorityPDA(projectPda, program.programId);
|
|
672
|
+
const investorNftAccount = getAssociatedTokenAddressSync(
|
|
673
|
+
nftMintPubkey,
|
|
674
|
+
investor,
|
|
675
|
+
false,
|
|
676
|
+
TOKEN_PROGRAM_ID
|
|
677
|
+
);
|
|
678
|
+
return getMethods(program).claimInvestorTokens({ milestoneIndex: args.milestoneIndex }).accounts({
|
|
679
|
+
investor,
|
|
680
|
+
project: projectPda,
|
|
681
|
+
tokenVault: tokenVaultPda,
|
|
682
|
+
investment: investmentPda,
|
|
683
|
+
nftMint: nftMintPubkey,
|
|
684
|
+
investorNftAccount,
|
|
685
|
+
investorVault: investorVaultPda,
|
|
686
|
+
investorTokenAccount: args.investorTokenAccount,
|
|
687
|
+
vaultAuthority: vaultAuthorityPda,
|
|
688
|
+
tokenProgram: TOKEN_PROGRAM_ID
|
|
689
|
+
}).rpc();
|
|
690
|
+
}
|
|
691
|
+
async function distributeTokens(program, args, payer) {
|
|
692
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
693
|
+
const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
|
|
694
|
+
const investorVaultPda = getInvestorVaultPDA(projectPda, program.programId);
|
|
695
|
+
const vaultAuthorityPda = getVaultAuthorityPDA(projectPda, program.programId);
|
|
696
|
+
const remainingAccounts = args.investments.flatMap((inv) => [
|
|
697
|
+
{ pubkey: inv.investmentPda, isSigner: false, isWritable: true },
|
|
698
|
+
{ pubkey: inv.investorTokenAccount, isSigner: false, isWritable: true }
|
|
699
|
+
]);
|
|
700
|
+
return getMethods(program).distributeTokens({ milestoneIndex: args.milestoneIndex }).accounts({
|
|
701
|
+
project: projectPda,
|
|
702
|
+
tokenVault: tokenVaultPda,
|
|
703
|
+
investorVault: investorVaultPda,
|
|
704
|
+
vaultAuthority: vaultAuthorityPda,
|
|
705
|
+
payer,
|
|
706
|
+
tokenProgram: TOKEN_PROGRAM_ID
|
|
707
|
+
}).remainingAccounts(remainingAccounts).rpc();
|
|
708
|
+
}
|
|
709
|
+
async function completeDistribution(program, args, payer) {
|
|
710
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
711
|
+
const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
|
|
712
|
+
return getMethods(program).completeDistribution({ milestoneIndex: args.milestoneIndex }).accounts({
|
|
713
|
+
project: projectPda,
|
|
714
|
+
tokenVault: tokenVaultPda,
|
|
715
|
+
payer
|
|
716
|
+
}).rpc();
|
|
717
|
+
}
|
|
718
|
+
async function claimExitWindowRefund(program, args, investor) {
|
|
719
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
720
|
+
const investmentPda = getInvestmentPDA(projectPda, args.nftMint, program.programId);
|
|
721
|
+
const escrowPda = getEscrowPDA(args.projectId, program.programId);
|
|
722
|
+
const remainingAccounts = (args.milestoneAccounts || []).map((pubkey) => ({
|
|
723
|
+
pubkey,
|
|
724
|
+
isSigner: false,
|
|
725
|
+
isWritable: false
|
|
726
|
+
}));
|
|
727
|
+
return getMethods(program).claimExitWindowRefund().accountsPartial({
|
|
728
|
+
project: projectPda,
|
|
729
|
+
investment: investmentPda,
|
|
730
|
+
nftMint: args.nftMint,
|
|
731
|
+
investorNftAccount: args.investorNftAccount,
|
|
732
|
+
escrowTokenAccount: args.escrowTokenAccount,
|
|
733
|
+
investorTokenAccount: args.investorTokenAccount,
|
|
734
|
+
escrowPda,
|
|
735
|
+
investor
|
|
736
|
+
}).remainingAccounts(remainingAccounts).rpc();
|
|
737
|
+
}
|
|
738
|
+
async function initializeFounderVesting(program, args, payer) {
|
|
739
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
740
|
+
const tokenomicsPda = getTokenomicsPDA(projectPda, program.programId);
|
|
741
|
+
const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
|
|
742
|
+
const founderVestingPda = getFounderVestingPDA(projectPda, program.programId);
|
|
743
|
+
return getMethods(program).initializeFounderVesting().accounts({
|
|
744
|
+
project: projectPda,
|
|
745
|
+
tokenomics: tokenomicsPda,
|
|
746
|
+
tokenVault: tokenVaultPda,
|
|
747
|
+
founderVesting: founderVestingPda,
|
|
748
|
+
payer,
|
|
749
|
+
systemProgram: SystemProgram.programId
|
|
750
|
+
}).rpc();
|
|
751
|
+
}
|
|
752
|
+
async function claimVestedTokens(program, args, founder) {
|
|
753
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
754
|
+
const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
|
|
755
|
+
const founderVestingPda = getFounderVestingPDA(projectPda, program.programId);
|
|
756
|
+
const founderVaultPda = getFounderVaultPDA(projectPda, program.programId);
|
|
757
|
+
const vaultAuthorityPda = getVaultAuthorityPDA(projectPda, program.programId);
|
|
758
|
+
return getMethods(program).claimVestedTokens().accounts({
|
|
759
|
+
project: projectPda,
|
|
760
|
+
tokenVault: tokenVaultPda,
|
|
761
|
+
founderVesting: founderVestingPda,
|
|
762
|
+
founderVault: founderVaultPda,
|
|
763
|
+
vaultAuthority: vaultAuthorityPda,
|
|
764
|
+
founderTokenAccount: args.founderTokenAccount,
|
|
765
|
+
founder,
|
|
766
|
+
tokenProgram: TOKEN_PROGRAM_ID
|
|
767
|
+
}).rpc();
|
|
768
|
+
}
|
|
769
|
+
async function forceCompleteDistribution(program, args, adminKeypair) {
|
|
770
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
771
|
+
const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
|
|
772
|
+
const adminConfigPda = getAdminConfigPDA(program.programId);
|
|
773
|
+
return getMethods(program).forceCompleteDistribution().accounts({
|
|
774
|
+
admin: adminKeypair.publicKey,
|
|
775
|
+
adminConfig: adminConfigPda,
|
|
776
|
+
project: projectPda,
|
|
777
|
+
tokenVault: tokenVaultPda
|
|
778
|
+
}).signers([adminKeypair]).rpc();
|
|
779
|
+
}
|
|
780
|
+
async function claimMissedUnlock(program, args, claimer) {
|
|
781
|
+
const nftMintPubkey = ensurePublicKey(args.nftMint);
|
|
782
|
+
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
783
|
+
const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
|
|
784
|
+
const investmentPda = getInvestmentPDA(projectPda, nftMintPubkey, program.programId);
|
|
785
|
+
const investorVaultPda = getInvestorVaultPDA(projectPda, program.programId);
|
|
786
|
+
const vaultAuthorityPda = getVaultAuthorityPDA(projectPda, program.programId);
|
|
787
|
+
const claimerNftAccount = getAssociatedTokenAddressSync(
|
|
788
|
+
nftMintPubkey,
|
|
789
|
+
claimer,
|
|
790
|
+
false,
|
|
791
|
+
TOKEN_PROGRAM_ID
|
|
792
|
+
);
|
|
793
|
+
return getMethods(program).claimMissedUnlock({ milestoneIndex: args.milestoneIndex }).accounts({
|
|
794
|
+
claimer,
|
|
795
|
+
project: projectPda,
|
|
796
|
+
tokenVault: tokenVaultPda,
|
|
797
|
+
investment: investmentPda,
|
|
798
|
+
nftMint: nftMintPubkey,
|
|
799
|
+
claimerNftAccount,
|
|
800
|
+
investorVault: investorVaultPda,
|
|
801
|
+
claimerTokenAccount: args.claimerTokenAccount,
|
|
802
|
+
vaultAuthority: vaultAuthorityPda,
|
|
803
|
+
tokenProgram: TOKEN_PROGRAM_ID
|
|
804
|
+
}).rpc();
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
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 };
|
|
808
|
+
//# sourceMappingURL=index.js.map
|
|
809
|
+
//# sourceMappingURL=index.js.map
|