@streamflow/launchpad 7.5.3 → 8.0.0-alpha.p284.726ba98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +1502 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +148 -0
- package/dist/cjs/solana/descriptor/streamflow_launchpad.cjs +4 -0
- package/dist/cjs/solana/descriptor/streamflow_launchpad.cjs.map +1 -0
- package/dist/cjs/solana/descriptor/streamflow_launchpad.d.cts +1135 -0
- package/dist/esm/index.d.ts +148 -4
- package/dist/esm/index.js +1492 -4
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/solana/descriptor/idl/streamflow_launchpad.json +930 -1391
- package/dist/esm/solana/descriptor/streamflow_launchpad.d.ts +3 -1
- package/dist/esm/solana/descriptor/streamflow_launchpad.js +3 -1
- package/dist/esm/solana/descriptor/streamflow_launchpad.js.map +1 -0
- package/package.json +38 -18
- package/dist/cjs/index.js +0 -34
- package/dist/cjs/solana/client.js +0 -261
- package/dist/cjs/solana/constants.js +0 -20
- package/dist/cjs/solana/descriptor/idl/streamflow_launchpad.json +0 -1468
- package/dist/cjs/solana/descriptor/streamflow_launchpad.js +0 -2
- package/dist/cjs/solana/lib/derive-accounts.js +0 -22
- package/dist/cjs/solana/types.js +0 -2
- package/dist/esm/solana/client.d.ts +0 -62
- package/dist/esm/solana/client.js +0 -261
- package/dist/esm/solana/constants.d.ts +0 -12
- package/dist/esm/solana/constants.js +0 -17
- package/dist/esm/solana/lib/derive-accounts.d.ts +0 -4
- package/dist/esm/solana/lib/derive-accounts.js +0 -13
- package/dist/esm/solana/types.d.ts +0 -61
- package/dist/esm/solana/types.js +0 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,1492 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Program, translateError, parseIdlErrors } from '@coral-xyz/anchor';
|
|
2
|
+
import { getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID, createTransferCheckedInstruction } from '@solana/spl-token';
|
|
3
|
+
import { PublicKey, clusterApiUrl, Connection, TransactionInstruction, Keypair } from '@solana/web3.js';
|
|
4
|
+
import { ICluster, invariant, getBN, ContractError } from '@streamflow/common';
|
|
5
|
+
import { buildSendThrottler, pk, getFilters, getMintAndProgram, checkOrCreateAtaBatch, prepareBaseInstructions, prepareTransaction, signAndExecuteTransaction } from '@streamflow/common/solana';
|
|
6
|
+
import { constants, deriveTestOraclePDA, deriveContractPDA, deriveEscrowPDA } from '@streamflow/stream/solana';
|
|
7
|
+
import BN2 from 'bn.js';
|
|
8
|
+
import '@solana/wallet-adapter-base';
|
|
9
|
+
import '@streamflow/stream';
|
|
10
|
+
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// solana/constants.ts
|
|
18
|
+
var constants_exports = {};
|
|
19
|
+
__export(constants_exports, {
|
|
20
|
+
ANCHOR_DISCRIMINATOR_OFFSET: () => ANCHOR_DISCRIMINATOR_OFFSET,
|
|
21
|
+
DEPOSIT_PREFIX: () => DEPOSIT_PREFIX,
|
|
22
|
+
LAUNCHPAD_BASE_MINT_OFFSET: () => LAUNCHPAD_BASE_MINT_OFFSET,
|
|
23
|
+
LAUNCHPAD_BYTE_OFFSETS: () => LAUNCHPAD_BYTE_OFFSETS,
|
|
24
|
+
LAUNCHPAD_PREFIX: () => LAUNCHPAD_PREFIX,
|
|
25
|
+
LAUNCHPAD_QUOTE_MINT_OFFSET: () => LAUNCHPAD_QUOTE_MINT_OFFSET,
|
|
26
|
+
PROGRAM_ID: () => PROGRAM_ID,
|
|
27
|
+
VAULT_PREFIX: () => VAULT_PREFIX
|
|
28
|
+
});
|
|
29
|
+
var LAUNCHPAD_PREFIX = Buffer.from("launchpad", "utf-8");
|
|
30
|
+
var VAULT_PREFIX = Buffer.from("vault", "utf-8");
|
|
31
|
+
var DEPOSIT_PREFIX = Buffer.from("deposit", "utf-8");
|
|
32
|
+
var ANCHOR_DISCRIMINATOR_OFFSET = 8;
|
|
33
|
+
var LAUNCHPAD_BASE_MINT_OFFSET = ANCHOR_DISCRIMINATOR_OFFSET + 8;
|
|
34
|
+
var LAUNCHPAD_QUOTE_MINT_OFFSET = ANCHOR_DISCRIMINATOR_OFFSET + 32;
|
|
35
|
+
var LAUNCHPAD_BYTE_OFFSETS = {
|
|
36
|
+
baseMint: LAUNCHPAD_BASE_MINT_OFFSET,
|
|
37
|
+
quoteMint: LAUNCHPAD_QUOTE_MINT_OFFSET
|
|
38
|
+
};
|
|
39
|
+
var PROGRAM_ID = {
|
|
40
|
+
[ICluster.Mainnet]: "BUYfFzeTWeRW5JrPjCutbsvzjA5ERS8EnGujJjfmnJu6",
|
|
41
|
+
[ICluster.Devnet]: "BUYfFzeTWeRW5JrPjCutbsvzjA5ERS8EnGujJjfmnJu6",
|
|
42
|
+
[ICluster.Testnet]: "BUYfFzeTWeRW5JrPjCutbsvzjA5ERS8EnGujJjfmnJu6",
|
|
43
|
+
[ICluster.Local]: "BUYfFzeTWeRW5JrPjCutbsvzjA5ERS8EnGujJjfmnJu6"
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// solana/descriptor/idl/streamflow_launchpad.json
|
|
47
|
+
var streamflow_launchpad_default = {
|
|
48
|
+
address: "BUYfFzeTWeRW5JrPjCutbsvzjA5ERS8EnGujJjfmnJu6",
|
|
49
|
+
metadata: {
|
|
50
|
+
name: "streamflow_launchpad",
|
|
51
|
+
version: "1.0.0",
|
|
52
|
+
spec: "0.1.0",
|
|
53
|
+
description: "A Launchpad for a pre-sale"
|
|
54
|
+
},
|
|
55
|
+
instructions: [
|
|
56
|
+
{
|
|
57
|
+
name: "claim_allocated_instant",
|
|
58
|
+
docs: ["Claim allocated funds instantly in case vesting schedule is not set"],
|
|
59
|
+
discriminator: [49, 89, 180, 221, 1, 139, 121, 192],
|
|
60
|
+
accounts: [
|
|
61
|
+
{
|
|
62
|
+
name: "launchpad",
|
|
63
|
+
docs: ["[Launchpad]."],
|
|
64
|
+
writable: true,
|
|
65
|
+
relations: ["deposit_account"]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "deposit_account",
|
|
69
|
+
docs: ["Reward Entry that stores metadata about claimed rewards"],
|
|
70
|
+
writable: true
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "from",
|
|
74
|
+
docs: ["Vault that stores Base tokens"],
|
|
75
|
+
writable: true,
|
|
76
|
+
pda: {
|
|
77
|
+
seeds: [
|
|
78
|
+
{
|
|
79
|
+
kind: "account",
|
|
80
|
+
path: "launchpad"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
kind: "account",
|
|
84
|
+
path: "token_program"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
kind: "account",
|
|
88
|
+
path: "base_mint"
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
program: {
|
|
92
|
+
kind: "const",
|
|
93
|
+
value: [
|
|
94
|
+
140,
|
|
95
|
+
151,
|
|
96
|
+
37,
|
|
97
|
+
143,
|
|
98
|
+
78,
|
|
99
|
+
36,
|
|
100
|
+
137,
|
|
101
|
+
241,
|
|
102
|
+
187,
|
|
103
|
+
61,
|
|
104
|
+
16,
|
|
105
|
+
41,
|
|
106
|
+
20,
|
|
107
|
+
142,
|
|
108
|
+
13,
|
|
109
|
+
131,
|
|
110
|
+
11,
|
|
111
|
+
90,
|
|
112
|
+
19,
|
|
113
|
+
153,
|
|
114
|
+
218,
|
|
115
|
+
255,
|
|
116
|
+
16,
|
|
117
|
+
132,
|
|
118
|
+
4,
|
|
119
|
+
142,
|
|
120
|
+
123,
|
|
121
|
+
216,
|
|
122
|
+
219,
|
|
123
|
+
233,
|
|
124
|
+
248,
|
|
125
|
+
89
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: "to",
|
|
132
|
+
docs: ["Token Account to which tokens will be transferred"],
|
|
133
|
+
writable: true,
|
|
134
|
+
pda: {
|
|
135
|
+
seeds: [
|
|
136
|
+
{
|
|
137
|
+
kind: "account",
|
|
138
|
+
path: "owner"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
kind: "account",
|
|
142
|
+
path: "token_program"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
kind: "account",
|
|
146
|
+
path: "base_mint"
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
program: {
|
|
150
|
+
kind: "const",
|
|
151
|
+
value: [
|
|
152
|
+
140,
|
|
153
|
+
151,
|
|
154
|
+
37,
|
|
155
|
+
143,
|
|
156
|
+
78,
|
|
157
|
+
36,
|
|
158
|
+
137,
|
|
159
|
+
241,
|
|
160
|
+
187,
|
|
161
|
+
61,
|
|
162
|
+
16,
|
|
163
|
+
41,
|
|
164
|
+
20,
|
|
165
|
+
142,
|
|
166
|
+
13,
|
|
167
|
+
131,
|
|
168
|
+
11,
|
|
169
|
+
90,
|
|
170
|
+
19,
|
|
171
|
+
153,
|
|
172
|
+
218,
|
|
173
|
+
255,
|
|
174
|
+
16,
|
|
175
|
+
132,
|
|
176
|
+
4,
|
|
177
|
+
142,
|
|
178
|
+
123,
|
|
179
|
+
216,
|
|
180
|
+
219,
|
|
181
|
+
233,
|
|
182
|
+
248,
|
|
183
|
+
89
|
|
184
|
+
]
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: "payer",
|
|
190
|
+
docs: ["Rent payer"],
|
|
191
|
+
writable: true,
|
|
192
|
+
signer: true
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: "owner"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: "base_mint",
|
|
199
|
+
docs: ["Base Mint of the Launchpad"],
|
|
200
|
+
relations: ["launchpad"]
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
name: "system_program",
|
|
204
|
+
docs: ["The [System] program."],
|
|
205
|
+
address: "11111111111111111111111111111111"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
name: "associated_token_program",
|
|
209
|
+
docs: ["The [Associated Token] program."],
|
|
210
|
+
address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
name: "token_program",
|
|
214
|
+
docs: ["The [Token] program."]
|
|
215
|
+
}
|
|
216
|
+
],
|
|
217
|
+
args: []
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
name: "claim_allocated_vested",
|
|
221
|
+
docs: ["Claim allocated funds in a vested manner in case vesting schedule has been set"],
|
|
222
|
+
discriminator: [14, 116, 137, 52, 178, 218, 187, 229],
|
|
223
|
+
accounts: [
|
|
224
|
+
{
|
|
225
|
+
name: "launchpad",
|
|
226
|
+
docs: ["[Launchpad]."],
|
|
227
|
+
writable: true,
|
|
228
|
+
relations: ["deposit_account"]
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: "deposit_account",
|
|
232
|
+
docs: ["Reward Entry that stores metadata about claimed rewards"],
|
|
233
|
+
writable: true
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
name: "from",
|
|
237
|
+
docs: ["Vault that stores Base tokens"],
|
|
238
|
+
writable: true,
|
|
239
|
+
pda: {
|
|
240
|
+
seeds: [
|
|
241
|
+
{
|
|
242
|
+
kind: "account",
|
|
243
|
+
path: "launchpad"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
kind: "account",
|
|
247
|
+
path: "token_program"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
kind: "account",
|
|
251
|
+
path: "base_mint"
|
|
252
|
+
}
|
|
253
|
+
],
|
|
254
|
+
program: {
|
|
255
|
+
kind: "const",
|
|
256
|
+
value: [
|
|
257
|
+
140,
|
|
258
|
+
151,
|
|
259
|
+
37,
|
|
260
|
+
143,
|
|
261
|
+
78,
|
|
262
|
+
36,
|
|
263
|
+
137,
|
|
264
|
+
241,
|
|
265
|
+
187,
|
|
266
|
+
61,
|
|
267
|
+
16,
|
|
268
|
+
41,
|
|
269
|
+
20,
|
|
270
|
+
142,
|
|
271
|
+
13,
|
|
272
|
+
131,
|
|
273
|
+
11,
|
|
274
|
+
90,
|
|
275
|
+
19,
|
|
276
|
+
153,
|
|
277
|
+
218,
|
|
278
|
+
255,
|
|
279
|
+
16,
|
|
280
|
+
132,
|
|
281
|
+
4,
|
|
282
|
+
142,
|
|
283
|
+
123,
|
|
284
|
+
216,
|
|
285
|
+
219,
|
|
286
|
+
233,
|
|
287
|
+
248,
|
|
288
|
+
89
|
|
289
|
+
]
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
name: "to",
|
|
295
|
+
docs: ["Token Account to which tokens will be vested"],
|
|
296
|
+
writable: true,
|
|
297
|
+
pda: {
|
|
298
|
+
seeds: [
|
|
299
|
+
{
|
|
300
|
+
kind: "account",
|
|
301
|
+
path: "owner"
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
kind: "account",
|
|
305
|
+
path: "token_program"
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
kind: "account",
|
|
309
|
+
path: "base_mint"
|
|
310
|
+
}
|
|
311
|
+
],
|
|
312
|
+
program: {
|
|
313
|
+
kind: "const",
|
|
314
|
+
value: [
|
|
315
|
+
140,
|
|
316
|
+
151,
|
|
317
|
+
37,
|
|
318
|
+
143,
|
|
319
|
+
78,
|
|
320
|
+
36,
|
|
321
|
+
137,
|
|
322
|
+
241,
|
|
323
|
+
187,
|
|
324
|
+
61,
|
|
325
|
+
16,
|
|
326
|
+
41,
|
|
327
|
+
20,
|
|
328
|
+
142,
|
|
329
|
+
13,
|
|
330
|
+
131,
|
|
331
|
+
11,
|
|
332
|
+
90,
|
|
333
|
+
19,
|
|
334
|
+
153,
|
|
335
|
+
218,
|
|
336
|
+
255,
|
|
337
|
+
16,
|
|
338
|
+
132,
|
|
339
|
+
4,
|
|
340
|
+
142,
|
|
341
|
+
123,
|
|
342
|
+
216,
|
|
343
|
+
219,
|
|
344
|
+
233,
|
|
345
|
+
248,
|
|
346
|
+
89
|
|
347
|
+
]
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
name: "payer",
|
|
353
|
+
docs: ["Rent payer"],
|
|
354
|
+
writable: true,
|
|
355
|
+
signer: true
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
name: "owner",
|
|
359
|
+
relations: ["deposit_account"]
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
name: "base_mint",
|
|
363
|
+
docs: ["Base Mint of the Launchpad"],
|
|
364
|
+
relations: ["launchpad"]
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
name: "price_oracle",
|
|
368
|
+
relations: ["launchpad"]
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
name: "authority",
|
|
372
|
+
relations: ["launchpad"]
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
name: "proxy_metadata",
|
|
376
|
+
writable: true
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
name: "proxy_tokens",
|
|
380
|
+
docs: ["Vault that stores Base tokens"],
|
|
381
|
+
writable: true
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
name: "stream_metadata",
|
|
385
|
+
writable: true,
|
|
386
|
+
signer: true
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
name: "escrow_tokens",
|
|
390
|
+
writable: true
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
name: "withdrawor",
|
|
394
|
+
writable: true
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
name: "proxy_program",
|
|
398
|
+
address: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH"
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
name: "streamflow_program",
|
|
402
|
+
address: "strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m"
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
name: "fee_oracle"
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
name: "rent",
|
|
409
|
+
docs: ["Rent account required by streamflow protocol"],
|
|
410
|
+
address: "SysvarRent111111111111111111111111111111111"
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
name: "associated_token_program",
|
|
414
|
+
docs: ["The [Associated Token] program."],
|
|
415
|
+
address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
name: "token_program",
|
|
419
|
+
docs: ["The [Token] program."]
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
name: "system_program",
|
|
423
|
+
docs: ["The [System] program."],
|
|
424
|
+
address: "11111111111111111111111111111111"
|
|
425
|
+
}
|
|
426
|
+
],
|
|
427
|
+
args: []
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
name: "claim_deposits",
|
|
431
|
+
docs: ["Claim deposited funds to pre-configured `receiver` account"],
|
|
432
|
+
discriminator: [69, 159, 225, 170, 28, 44, 76, 102],
|
|
433
|
+
accounts: [
|
|
434
|
+
{
|
|
435
|
+
name: "launchpad",
|
|
436
|
+
docs: ["[Launchpad]."],
|
|
437
|
+
writable: true
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
name: "receiver",
|
|
441
|
+
docs: ["Deposits receiver token account"],
|
|
442
|
+
writable: true,
|
|
443
|
+
relations: ["launchpad"]
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
name: "vault",
|
|
447
|
+
docs: ["Launchpad Vault that stores deposited tokens"],
|
|
448
|
+
writable: true,
|
|
449
|
+
relations: ["launchpad"]
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
name: "authority",
|
|
453
|
+
docs: ["Launchpad authority"],
|
|
454
|
+
writable: true,
|
|
455
|
+
signer: true
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
name: "quote_mint",
|
|
459
|
+
docs: ["Quote Mint of the Launchpad"],
|
|
460
|
+
relations: ["launchpad"]
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
name: "token_program",
|
|
464
|
+
docs: ["The [Token] program."]
|
|
465
|
+
}
|
|
466
|
+
],
|
|
467
|
+
args: []
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
name: "create_launchpad",
|
|
471
|
+
docs: ["Create new Launchpad for `base_mint` <-> `quote_mint` pair"],
|
|
472
|
+
discriminator: [193, 189, 26, 187, 44, 137, 43, 190],
|
|
473
|
+
accounts: [
|
|
474
|
+
{
|
|
475
|
+
name: "launchpad",
|
|
476
|
+
docs: ["[Launchpad]."],
|
|
477
|
+
writable: true,
|
|
478
|
+
pda: {
|
|
479
|
+
seeds: [
|
|
480
|
+
{
|
|
481
|
+
kind: "const",
|
|
482
|
+
value: [108, 97, 117, 110, 99, 104, 112, 97, 100]
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
kind: "account",
|
|
486
|
+
path: "base_mint"
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
kind: "arg",
|
|
490
|
+
path: "ix.nonce"
|
|
491
|
+
}
|
|
492
|
+
]
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
name: "vault",
|
|
497
|
+
docs: ["Escrow Account that will store deposits"],
|
|
498
|
+
writable: true,
|
|
499
|
+
pda: {
|
|
500
|
+
seeds: [
|
|
501
|
+
{
|
|
502
|
+
kind: "const",
|
|
503
|
+
value: [118, 97, 117, 108, 116]
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
kind: "account",
|
|
507
|
+
path: "launchpad"
|
|
508
|
+
}
|
|
509
|
+
]
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
name: "base_mint",
|
|
514
|
+
docs: ["Base Mint of the Launchpad"]
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
name: "quote_mint",
|
|
518
|
+
docs: ["Quote Mint for deposits"]
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
name: "price_oracle"
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
name: "authority",
|
|
525
|
+
docs: [
|
|
526
|
+
"Admin wallet, responsible for creating the launchpad and paying for the transaction.",
|
|
527
|
+
"Also is the authority"
|
|
528
|
+
],
|
|
529
|
+
writable: true,
|
|
530
|
+
signer: true
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
name: "receiver",
|
|
534
|
+
docs: ["Deposits receiver token account"],
|
|
535
|
+
writable: true
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
name: "system_program",
|
|
539
|
+
docs: ["The [System] program."],
|
|
540
|
+
address: "11111111111111111111111111111111"
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
name: "token_program",
|
|
544
|
+
docs: ["The [Token] program."]
|
|
545
|
+
}
|
|
546
|
+
],
|
|
547
|
+
args: [
|
|
548
|
+
{
|
|
549
|
+
name: "ix",
|
|
550
|
+
type: {
|
|
551
|
+
defined: {
|
|
552
|
+
name: "CreateLaunchpadIx"
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
]
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
name: "deposit",
|
|
560
|
+
docs: ["Deposit funds to receive allocation"],
|
|
561
|
+
discriminator: [242, 35, 198, 137, 82, 225, 242, 182],
|
|
562
|
+
accounts: [
|
|
563
|
+
{
|
|
564
|
+
name: "launchpad",
|
|
565
|
+
docs: ["[Launchpad]."],
|
|
566
|
+
writable: true
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
name: "deposit_account",
|
|
570
|
+
docs: ["Reward Entry that stores metadata about claimed rewards"],
|
|
571
|
+
writable: true,
|
|
572
|
+
pda: {
|
|
573
|
+
seeds: [
|
|
574
|
+
{
|
|
575
|
+
kind: "const",
|
|
576
|
+
value: [100, 101, 112, 111, 115, 105, 116]
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
kind: "account",
|
|
580
|
+
path: "launchpad"
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
kind: "account",
|
|
584
|
+
path: "owner"
|
|
585
|
+
}
|
|
586
|
+
]
|
|
587
|
+
}
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
name: "from",
|
|
591
|
+
docs: ["Token Account from which stake tokens will be transferred"],
|
|
592
|
+
writable: true
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
name: "vault",
|
|
596
|
+
docs: ["Stake Pool Vault that stores staked tokens"],
|
|
597
|
+
writable: true,
|
|
598
|
+
relations: ["launchpad"]
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
name: "payer",
|
|
602
|
+
docs: ["Rent payer"],
|
|
603
|
+
writable: true,
|
|
604
|
+
signer: true
|
|
605
|
+
},
|
|
606
|
+
{
|
|
607
|
+
name: "owner"
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
name: "base_mint",
|
|
611
|
+
docs: ["Base Mint of the Launchpad"],
|
|
612
|
+
relations: ["launchpad"]
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
name: "quote_mint",
|
|
616
|
+
docs: ["Quote Mint of the Launchpad"],
|
|
617
|
+
relations: ["launchpad"]
|
|
618
|
+
},
|
|
619
|
+
{
|
|
620
|
+
name: "system_program",
|
|
621
|
+
docs: ["The [System] program."],
|
|
622
|
+
address: "11111111111111111111111111111111"
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
name: "token_program",
|
|
626
|
+
docs: ["The [Token] program."]
|
|
627
|
+
}
|
|
628
|
+
],
|
|
629
|
+
args: [
|
|
630
|
+
{
|
|
631
|
+
name: "ix",
|
|
632
|
+
type: {
|
|
633
|
+
defined: {
|
|
634
|
+
name: "DepositIx"
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
]
|
|
639
|
+
}
|
|
640
|
+
],
|
|
641
|
+
accounts: [
|
|
642
|
+
{
|
|
643
|
+
name: "DepositAccount",
|
|
644
|
+
discriminator: [148, 37, 207, 116, 61, 33, 53, 179]
|
|
645
|
+
},
|
|
646
|
+
{
|
|
647
|
+
name: "Launchpad",
|
|
648
|
+
discriminator: [247, 20, 16, 242, 203, 38, 169, 160]
|
|
649
|
+
}
|
|
650
|
+
],
|
|
651
|
+
errors: [
|
|
652
|
+
{
|
|
653
|
+
code: 6e3,
|
|
654
|
+
name: "Unauthorized",
|
|
655
|
+
msg: "Authority does not have permission for this action"
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
code: 6001,
|
|
659
|
+
name: "ArithmeticError",
|
|
660
|
+
msg: "Arithmetic error"
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
code: 6002,
|
|
664
|
+
name: "InvalidMemo",
|
|
665
|
+
msg: "Provided memo is invalid or not provided"
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
code: 6003,
|
|
669
|
+
name: "InvalidParams",
|
|
670
|
+
msg: "Invalid Parameters provided"
|
|
671
|
+
},
|
|
672
|
+
{
|
|
673
|
+
code: 6004,
|
|
674
|
+
name: "InvalidBaseMint",
|
|
675
|
+
msg: "Invalid Base Mint"
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
code: 6005,
|
|
679
|
+
name: "InvalidQuoteMint",
|
|
680
|
+
msg: "Invalid Quote Mint"
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
code: 6006,
|
|
684
|
+
name: "InvalidVault",
|
|
685
|
+
msg: "Invalid Vault"
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
code: 6007,
|
|
689
|
+
name: "InvalidLaunchpad",
|
|
690
|
+
msg: "Invalid Launchpad"
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
code: 6008,
|
|
694
|
+
name: "InvalidReceiver",
|
|
695
|
+
msg: "Invalid Receiver provided"
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
code: 6009,
|
|
699
|
+
name: "DepositingNotStarted",
|
|
700
|
+
msg: "Depositing has not started yet"
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
code: 6010,
|
|
704
|
+
name: "DepositingEnded",
|
|
705
|
+
msg: "Depositing period has ended"
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
code: 6011,
|
|
709
|
+
name: "LaunchpadCancelled",
|
|
710
|
+
msg: "Launchpad has been cancelled"
|
|
711
|
+
},
|
|
712
|
+
{
|
|
713
|
+
code: 6012,
|
|
714
|
+
name: "AmountMoreThanIndividualCap",
|
|
715
|
+
msg: "Deposit amount is more than Individual Cap"
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
code: 6013,
|
|
719
|
+
name: "AmountMoreThanMaxCap",
|
|
720
|
+
msg: "Deposit amount is more than Max Cap"
|
|
721
|
+
},
|
|
722
|
+
{
|
|
723
|
+
code: 6014,
|
|
724
|
+
name: "DepositingNotEnded",
|
|
725
|
+
msg: "Depositing period has not ended yet"
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
code: 6015,
|
|
729
|
+
name: "DepositsAlreadyClaimed",
|
|
730
|
+
msg: "Deposits has been already claimed"
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
code: 6016,
|
|
734
|
+
name: "VestingNotStarted",
|
|
735
|
+
msg: "Vesting period has not started yet"
|
|
736
|
+
},
|
|
737
|
+
{
|
|
738
|
+
code: 6017,
|
|
739
|
+
name: "VestingAlreadyClaimed",
|
|
740
|
+
msg: "Allocated amount has been claimed already"
|
|
741
|
+
},
|
|
742
|
+
{
|
|
743
|
+
code: 6018,
|
|
744
|
+
name: "InstantClaimNotAllowed",
|
|
745
|
+
msg: "Instant claiming not allowed"
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
code: 6019,
|
|
749
|
+
name: "VestedClaimNotAllowed",
|
|
750
|
+
msg: "Vested claiming not allowed"
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
code: 6020,
|
|
754
|
+
name: "VestingCantBeClaimed",
|
|
755
|
+
msg: "Vested can't be claimed after it started"
|
|
756
|
+
}
|
|
757
|
+
],
|
|
758
|
+
types: [
|
|
759
|
+
{
|
|
760
|
+
name: "CreateLaunchpadIx",
|
|
761
|
+
type: {
|
|
762
|
+
kind: "struct",
|
|
763
|
+
fields: [
|
|
764
|
+
{
|
|
765
|
+
name: "nonce",
|
|
766
|
+
type: "u8"
|
|
767
|
+
},
|
|
768
|
+
{
|
|
769
|
+
name: "price",
|
|
770
|
+
docs: ["Price in `quote_mint` decimal value for every whole `base_mint` token"],
|
|
771
|
+
type: "u64"
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
name: "individual_depositing_cap",
|
|
775
|
+
docs: ["Individual Depositing Cap in `quote_mint` Tokens"],
|
|
776
|
+
type: "u64"
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
name: "max_depositing_cap",
|
|
780
|
+
docs: ["Max Depositing Cap in `quote_mint` Tokens"],
|
|
781
|
+
type: "u64"
|
|
782
|
+
},
|
|
783
|
+
{
|
|
784
|
+
name: "depositing_start_ts",
|
|
785
|
+
docs: ["When depositing should start"],
|
|
786
|
+
type: "u64"
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
name: "depositing_end_ts",
|
|
790
|
+
docs: ["When depositing should end"],
|
|
791
|
+
type: "u64"
|
|
792
|
+
},
|
|
793
|
+
{
|
|
794
|
+
name: "vesting_start_ts",
|
|
795
|
+
docs: ["When vesting contract start time should be"],
|
|
796
|
+
type: "u64"
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
name: "vesting_period",
|
|
800
|
+
docs: ["Vesting release period in seconds"],
|
|
801
|
+
type: "u64"
|
|
802
|
+
},
|
|
803
|
+
{
|
|
804
|
+
name: "vesting_end_ts",
|
|
805
|
+
docs: ["When vesting contract end time should be"],
|
|
806
|
+
type: "u64"
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
name: "min_price",
|
|
810
|
+
docs: ["Min price for dynamic vesting"],
|
|
811
|
+
type: "u64"
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
name: "max_price",
|
|
815
|
+
docs: ["Max price for dynamic vesting"],
|
|
816
|
+
type: "u64"
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
name: "min_percentage",
|
|
820
|
+
docs: ["Min percentage for dynamic vesting"],
|
|
821
|
+
type: "u64"
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
name: "max_percentage",
|
|
825
|
+
docs: ["Max percentage for dynamic vesting"],
|
|
826
|
+
type: "u64"
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
name: "tick_size",
|
|
830
|
+
docs: ["Size of the tick in dynamic vesting"],
|
|
831
|
+
type: "u64"
|
|
832
|
+
},
|
|
833
|
+
{
|
|
834
|
+
name: "skip_initial",
|
|
835
|
+
docs: ["Whether to skip initial calculation of amount per period in dynamic vesting"],
|
|
836
|
+
type: "bool"
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
name: "oracle_type",
|
|
840
|
+
docs: ["Type of Oracle to use to derive Token Price"],
|
|
841
|
+
type: {
|
|
842
|
+
defined: {
|
|
843
|
+
name: "OracleType"
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
},
|
|
847
|
+
{
|
|
848
|
+
name: "is_memo_required",
|
|
849
|
+
docs: ["Whether to require memo on deposit"],
|
|
850
|
+
type: "bool"
|
|
851
|
+
}
|
|
852
|
+
]
|
|
853
|
+
}
|
|
854
|
+
},
|
|
855
|
+
{
|
|
856
|
+
name: "DepositAccount",
|
|
857
|
+
type: {
|
|
858
|
+
kind: "struct",
|
|
859
|
+
fields: [
|
|
860
|
+
{
|
|
861
|
+
name: "launchpad",
|
|
862
|
+
docs: ["Launchpad to which deposit belongs"],
|
|
863
|
+
type: "pubkey"
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
name: "owner",
|
|
867
|
+
docs: ["Deposit owner"],
|
|
868
|
+
type: "pubkey"
|
|
869
|
+
},
|
|
870
|
+
{
|
|
871
|
+
name: "amount",
|
|
872
|
+
docs: ["Amount of funds deposited in `quote_mint`"],
|
|
873
|
+
type: "u64"
|
|
874
|
+
},
|
|
875
|
+
{
|
|
876
|
+
name: "allocated_amount",
|
|
877
|
+
docs: ["Amount allocated according to amount deposited"],
|
|
878
|
+
type: "u64"
|
|
879
|
+
},
|
|
880
|
+
{
|
|
881
|
+
name: "created_ts",
|
|
882
|
+
docs: ["Time when deposit was done initially"],
|
|
883
|
+
type: "u64"
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
name: "claimed_ts",
|
|
887
|
+
docs: ["Time when `allocated_amount` was claimed"],
|
|
888
|
+
type: "u64"
|
|
889
|
+
},
|
|
890
|
+
{
|
|
891
|
+
name: "_buffer",
|
|
892
|
+
docs: ["Buffer for additional fields"],
|
|
893
|
+
type: {
|
|
894
|
+
array: ["u8", 64]
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
]
|
|
898
|
+
}
|
|
899
|
+
},
|
|
900
|
+
{
|
|
901
|
+
name: "DepositIx",
|
|
902
|
+
type: {
|
|
903
|
+
kind: "struct",
|
|
904
|
+
fields: [
|
|
905
|
+
{
|
|
906
|
+
name: "amount",
|
|
907
|
+
docs: ["Amount to deposit into the launchpad"],
|
|
908
|
+
type: "u64"
|
|
909
|
+
},
|
|
910
|
+
{
|
|
911
|
+
name: "auto_cap",
|
|
912
|
+
docs: ["Whether to allow automatically cap the amount in case amount exceeds `max_depositing_cap`"],
|
|
913
|
+
type: "bool"
|
|
914
|
+
}
|
|
915
|
+
]
|
|
916
|
+
}
|
|
917
|
+
},
|
|
918
|
+
{
|
|
919
|
+
name: "Launchpad",
|
|
920
|
+
type: {
|
|
921
|
+
kind: "struct",
|
|
922
|
+
fields: [
|
|
923
|
+
{
|
|
924
|
+
name: "bump",
|
|
925
|
+
docs: ["Bump Seed used to sign transactions"],
|
|
926
|
+
type: "u8"
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
name: "nonce",
|
|
930
|
+
docs: ["Nonce to differentiate pools for the same mint"],
|
|
931
|
+
type: "u8"
|
|
932
|
+
},
|
|
933
|
+
{
|
|
934
|
+
name: "_filler",
|
|
935
|
+
docs: ["Filler to account for alignment"],
|
|
936
|
+
type: {
|
|
937
|
+
array: ["u8", 6]
|
|
938
|
+
}
|
|
939
|
+
},
|
|
940
|
+
{
|
|
941
|
+
name: "base_mint",
|
|
942
|
+
docs: ["Mint of the Launchpad Token"],
|
|
943
|
+
type: "pubkey"
|
|
944
|
+
},
|
|
945
|
+
{
|
|
946
|
+
name: "quote_mint",
|
|
947
|
+
docs: ["Mint of the Token to exchange base mint to"],
|
|
948
|
+
type: "pubkey"
|
|
949
|
+
},
|
|
950
|
+
{
|
|
951
|
+
name: "authority",
|
|
952
|
+
docs: ["Current authority"],
|
|
953
|
+
type: "pubkey"
|
|
954
|
+
},
|
|
955
|
+
{
|
|
956
|
+
name: "receiver",
|
|
957
|
+
docs: ["Token account that should receive deposits after launchpad deposits end"],
|
|
958
|
+
type: "pubkey"
|
|
959
|
+
},
|
|
960
|
+
{
|
|
961
|
+
name: "price_oracle",
|
|
962
|
+
docs: ["Oracle account for price deriviation in vesting"],
|
|
963
|
+
type: "pubkey"
|
|
964
|
+
},
|
|
965
|
+
{
|
|
966
|
+
name: "vault",
|
|
967
|
+
docs: ["Escrow Account that stores deposited tokens"],
|
|
968
|
+
type: "pubkey"
|
|
969
|
+
},
|
|
970
|
+
{
|
|
971
|
+
name: "config",
|
|
972
|
+
docs: ["Configuration"],
|
|
973
|
+
type: {
|
|
974
|
+
defined: {
|
|
975
|
+
name: "LaunchpadConfig"
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
},
|
|
979
|
+
{
|
|
980
|
+
name: "vesting_config",
|
|
981
|
+
docs: ["Vesting Configuration"],
|
|
982
|
+
type: {
|
|
983
|
+
defined: {
|
|
984
|
+
name: "VestingConfig"
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
},
|
|
988
|
+
{
|
|
989
|
+
name: "state",
|
|
990
|
+
docs: ["Current state of the Launchpad"],
|
|
991
|
+
type: {
|
|
992
|
+
defined: {
|
|
993
|
+
name: "LaunchpadState"
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
},
|
|
997
|
+
{
|
|
998
|
+
name: "_buffer",
|
|
999
|
+
docs: ["Buffer for additional fields"],
|
|
1000
|
+
type: {
|
|
1001
|
+
array: ["u8", 64]
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
]
|
|
1005
|
+
}
|
|
1006
|
+
},
|
|
1007
|
+
{
|
|
1008
|
+
name: "LaunchpadConfig",
|
|
1009
|
+
type: {
|
|
1010
|
+
kind: "struct",
|
|
1011
|
+
fields: [
|
|
1012
|
+
{
|
|
1013
|
+
name: "price",
|
|
1014
|
+
docs: ["Price in `quote_mint` decimal value for every whole `base_mint` token"],
|
|
1015
|
+
type: "u64"
|
|
1016
|
+
},
|
|
1017
|
+
{
|
|
1018
|
+
name: "individual_depositing_cap",
|
|
1019
|
+
docs: ["Individual Depositing Cap in `quote_mint` Tokens"],
|
|
1020
|
+
type: "u64"
|
|
1021
|
+
},
|
|
1022
|
+
{
|
|
1023
|
+
name: "max_depositing_cap",
|
|
1024
|
+
docs: ["Max Depositing Cap in `quote_mint` Tokens"],
|
|
1025
|
+
type: "u64"
|
|
1026
|
+
},
|
|
1027
|
+
{
|
|
1028
|
+
name: "depositing_start_ts",
|
|
1029
|
+
docs: ["When depositing should start"],
|
|
1030
|
+
type: "u64"
|
|
1031
|
+
},
|
|
1032
|
+
{
|
|
1033
|
+
name: "depositing_end_ts",
|
|
1034
|
+
docs: ["When depositing should end"],
|
|
1035
|
+
type: "u64"
|
|
1036
|
+
},
|
|
1037
|
+
{
|
|
1038
|
+
name: "is_memo_required",
|
|
1039
|
+
docs: ["Whether to require memo on deposit"],
|
|
1040
|
+
type: "bool"
|
|
1041
|
+
}
|
|
1042
|
+
]
|
|
1043
|
+
}
|
|
1044
|
+
},
|
|
1045
|
+
{
|
|
1046
|
+
name: "LaunchpadState",
|
|
1047
|
+
type: {
|
|
1048
|
+
kind: "struct",
|
|
1049
|
+
fields: [
|
|
1050
|
+
{
|
|
1051
|
+
name: "total_deposited_amount",
|
|
1052
|
+
docs: ["Total amount of `quote_mint` tokens deposited"],
|
|
1053
|
+
type: "u64"
|
|
1054
|
+
},
|
|
1055
|
+
{
|
|
1056
|
+
name: "total_deposited_users",
|
|
1057
|
+
docs: ["Total amount of users who deposited tokens"],
|
|
1058
|
+
type: "u64"
|
|
1059
|
+
},
|
|
1060
|
+
{
|
|
1061
|
+
name: "total_claimed_users",
|
|
1062
|
+
docs: ["Number of users who have claimed `base_mint` tokens already"],
|
|
1063
|
+
type: "u64"
|
|
1064
|
+
},
|
|
1065
|
+
{
|
|
1066
|
+
name: "created_ts",
|
|
1067
|
+
docs: ["Time when Launchpad was created"],
|
|
1068
|
+
type: "u64"
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
name: "claimed_ts",
|
|
1072
|
+
docs: ["Time when deposits where claimed to authority token account"],
|
|
1073
|
+
type: "u64"
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
name: "cancelled_ts",
|
|
1077
|
+
docs: ["Time when Launchpad was cancelled, makes withdrawals possible"],
|
|
1078
|
+
type: "u64"
|
|
1079
|
+
},
|
|
1080
|
+
{
|
|
1081
|
+
name: "_buffer",
|
|
1082
|
+
docs: ["Buffer for additional fields"],
|
|
1083
|
+
type: {
|
|
1084
|
+
array: ["u8", 32]
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
]
|
|
1088
|
+
}
|
|
1089
|
+
},
|
|
1090
|
+
{
|
|
1091
|
+
name: "OracleType",
|
|
1092
|
+
type: {
|
|
1093
|
+
kind: "enum",
|
|
1094
|
+
variants: [
|
|
1095
|
+
{
|
|
1096
|
+
name: "None"
|
|
1097
|
+
},
|
|
1098
|
+
{
|
|
1099
|
+
name: "Test"
|
|
1100
|
+
},
|
|
1101
|
+
{
|
|
1102
|
+
name: "Pyth"
|
|
1103
|
+
},
|
|
1104
|
+
{
|
|
1105
|
+
name: "Switchboard"
|
|
1106
|
+
}
|
|
1107
|
+
]
|
|
1108
|
+
}
|
|
1109
|
+
},
|
|
1110
|
+
{
|
|
1111
|
+
name: "VestingConfig",
|
|
1112
|
+
type: {
|
|
1113
|
+
kind: "struct",
|
|
1114
|
+
fields: [
|
|
1115
|
+
{
|
|
1116
|
+
name: "start_ts",
|
|
1117
|
+
docs: ["When vesting contract start time should be"],
|
|
1118
|
+
type: "u64"
|
|
1119
|
+
},
|
|
1120
|
+
{
|
|
1121
|
+
name: "period",
|
|
1122
|
+
docs: ["Vesting unlock/update period in seconds"],
|
|
1123
|
+
type: "u64"
|
|
1124
|
+
},
|
|
1125
|
+
{
|
|
1126
|
+
name: "end_ts",
|
|
1127
|
+
docs: ["When vesting contract end time should be"],
|
|
1128
|
+
type: "u64"
|
|
1129
|
+
},
|
|
1130
|
+
{
|
|
1131
|
+
name: "min_price",
|
|
1132
|
+
docs: ["Min price boundary"],
|
|
1133
|
+
type: "u64"
|
|
1134
|
+
},
|
|
1135
|
+
{
|
|
1136
|
+
name: "max_price",
|
|
1137
|
+
docs: ["Max price boundary"],
|
|
1138
|
+
type: "u64"
|
|
1139
|
+
},
|
|
1140
|
+
{
|
|
1141
|
+
name: "min_percentage",
|
|
1142
|
+
docs: ["Min percentage boundary, can be 0 that equals 1 Raw Token"],
|
|
1143
|
+
type: "u64"
|
|
1144
|
+
},
|
|
1145
|
+
{
|
|
1146
|
+
name: "max_percentage",
|
|
1147
|
+
docs: ["Max percentage boundary"],
|
|
1148
|
+
type: "u64"
|
|
1149
|
+
},
|
|
1150
|
+
{
|
|
1151
|
+
name: "tick_size",
|
|
1152
|
+
docs: ["Ticket size for percentage boundaries"],
|
|
1153
|
+
type: "u64"
|
|
1154
|
+
},
|
|
1155
|
+
{
|
|
1156
|
+
name: "skip_initial",
|
|
1157
|
+
docs: ["Whether to skip initial calculation of amount per period"],
|
|
1158
|
+
type: "bool"
|
|
1159
|
+
},
|
|
1160
|
+
{
|
|
1161
|
+
name: "oracle_type",
|
|
1162
|
+
docs: ["Type of Oracle to use to derive Token Price"],
|
|
1163
|
+
type: {
|
|
1164
|
+
defined: {
|
|
1165
|
+
name: "OracleType"
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
]
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
]
|
|
1173
|
+
};
|
|
1174
|
+
var deriveLaunchpadPDA = (programId, baseMint, nonce) => {
|
|
1175
|
+
return PublicKey.findProgramAddressSync(
|
|
1176
|
+
[LAUNCHPAD_PREFIX, baseMint.toBuffer(), new BN2(nonce).toArrayLike(Buffer, "le", 1)],
|
|
1177
|
+
programId
|
|
1178
|
+
)[0];
|
|
1179
|
+
};
|
|
1180
|
+
var deriveDepositPDA = (programId, launchpad, owner) => {
|
|
1181
|
+
return PublicKey.findProgramAddressSync([DEPOSIT_PREFIX, launchpad.toBuffer(), owner.toBuffer()], programId)[0];
|
|
1182
|
+
};
|
|
1183
|
+
var deriveVaultPDA = (programId, launchpad) => {
|
|
1184
|
+
return PublicKey.findProgramAddressSync([VAULT_PREFIX, launchpad.toBuffer()], programId)[0];
|
|
1185
|
+
};
|
|
1186
|
+
|
|
1187
|
+
// solana/client.ts
|
|
1188
|
+
var SolanaLaunchpadClient = class {
|
|
1189
|
+
constructor({
|
|
1190
|
+
clusterUrl,
|
|
1191
|
+
cluster = ICluster.Mainnet,
|
|
1192
|
+
commitment = "confirmed",
|
|
1193
|
+
programIds,
|
|
1194
|
+
sendRate = 1,
|
|
1195
|
+
sendThrottler
|
|
1196
|
+
}) {
|
|
1197
|
+
this.commitment = commitment;
|
|
1198
|
+
if (!clusterUrl) {
|
|
1199
|
+
switch (cluster) {
|
|
1200
|
+
case ICluster.Mainnet:
|
|
1201
|
+
clusterUrl = clusterApiUrl("mainnet-beta");
|
|
1202
|
+
break;
|
|
1203
|
+
case ICluster.Local:
|
|
1204
|
+
clusterUrl = "http://localhost:8899";
|
|
1205
|
+
break;
|
|
1206
|
+
default:
|
|
1207
|
+
clusterUrl = clusterApiUrl(cluster);
|
|
1208
|
+
break;
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
this.connection = new Connection(clusterUrl, this.commitment);
|
|
1212
|
+
this.cluster = cluster;
|
|
1213
|
+
this.sendThrottler = sendThrottler ?? buildSendThrottler(sendRate);
|
|
1214
|
+
const launchpadIdl = {
|
|
1215
|
+
...streamflow_launchpad_default,
|
|
1216
|
+
address: programIds?.launchpad ?? PROGRAM_ID[cluster] ?? streamflow_launchpad_default.address
|
|
1217
|
+
};
|
|
1218
|
+
this.program = new Program(launchpadIdl, {
|
|
1219
|
+
connection: this.connection
|
|
1220
|
+
});
|
|
1221
|
+
this.dynamicVestingId = pk(
|
|
1222
|
+
programIds?.dynamicVesting ? programIds.dynamicVesting : constants.ALIGNED_UNLOCKS_PROGRAM_ID[cluster]
|
|
1223
|
+
);
|
|
1224
|
+
this.vestingId = pk(programIds?.vesting ? programIds.vesting : constants.PROGRAM_ID[cluster]);
|
|
1225
|
+
}
|
|
1226
|
+
getCurrentProgramId() {
|
|
1227
|
+
invariant(this.program, `Program is not found`);
|
|
1228
|
+
return this.program.programId;
|
|
1229
|
+
}
|
|
1230
|
+
getCommitment() {
|
|
1231
|
+
return typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
|
|
1232
|
+
}
|
|
1233
|
+
getLaunchpad(id) {
|
|
1234
|
+
return this.program.account.launchpad.fetch(id);
|
|
1235
|
+
}
|
|
1236
|
+
searchLaunchpads(criteria = {}) {
|
|
1237
|
+
return this.program.account.launchpad.all(getFilters(criteria, LAUNCHPAD_BYTE_OFFSETS));
|
|
1238
|
+
}
|
|
1239
|
+
getDepositAccount(id) {
|
|
1240
|
+
return this.program.account.depositAccount.fetch(id);
|
|
1241
|
+
}
|
|
1242
|
+
async createLaunchpad(data, extParams) {
|
|
1243
|
+
const { ixs, publicKey } = await this.prepareCreateLaunchpadInstructions(data, extParams);
|
|
1244
|
+
const { signature } = await this.execute(ixs, extParams);
|
|
1245
|
+
return {
|
|
1246
|
+
ixs,
|
|
1247
|
+
txId: signature,
|
|
1248
|
+
metadataId: publicKey
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1251
|
+
async prepareCreateLaunchpadInstructions({
|
|
1252
|
+
baseMint: baseMintKey,
|
|
1253
|
+
quoteMint: quoteMintKey,
|
|
1254
|
+
receiver,
|
|
1255
|
+
priceOracle,
|
|
1256
|
+
nonce,
|
|
1257
|
+
price,
|
|
1258
|
+
individualDepositingCap,
|
|
1259
|
+
maxDepositingCap,
|
|
1260
|
+
depositingStartTs,
|
|
1261
|
+
depositingEndTs,
|
|
1262
|
+
vestingStartTs,
|
|
1263
|
+
vestingEndTs,
|
|
1264
|
+
vestingPeriod,
|
|
1265
|
+
oracleType,
|
|
1266
|
+
minPrice,
|
|
1267
|
+
maxPrice,
|
|
1268
|
+
minPercentage,
|
|
1269
|
+
maxPercentage,
|
|
1270
|
+
tickSize,
|
|
1271
|
+
skipInitial,
|
|
1272
|
+
isMemoRequired,
|
|
1273
|
+
tokenProgramId = TOKEN_PROGRAM_ID
|
|
1274
|
+
}, extParams) {
|
|
1275
|
+
baseMintKey = pk(baseMintKey);
|
|
1276
|
+
quoteMintKey = pk(quoteMintKey);
|
|
1277
|
+
const authority = extParams.invoker.publicKey;
|
|
1278
|
+
invariant(authority, "Undefined creator publicKey");
|
|
1279
|
+
if (!priceOracle && oracleType && !["none", "test"].includes(oracleType)) {
|
|
1280
|
+
throw new Error("Price oracle is required for the specified oracle type");
|
|
1281
|
+
}
|
|
1282
|
+
receiver = receiver ?? getAssociatedTokenAddressSync(quoteMintKey, authority);
|
|
1283
|
+
const oracle = priceOracle ?? deriveTestOraclePDA(this.dynamicVestingId, baseMintKey, authority);
|
|
1284
|
+
const launchpadPDA = deriveLaunchpadPDA(this.program.programId, baseMintKey, nonce);
|
|
1285
|
+
const createIx = await this.program.methods.createLaunchpad({
|
|
1286
|
+
nonce,
|
|
1287
|
+
price,
|
|
1288
|
+
individualDepositingCap,
|
|
1289
|
+
maxDepositingCap,
|
|
1290
|
+
depositingStartTs: new BN2(depositingStartTs),
|
|
1291
|
+
depositingEndTs: new BN2(depositingEndTs),
|
|
1292
|
+
vestingStartTs: new BN2(vestingStartTs),
|
|
1293
|
+
vestingEndTs: new BN2(vestingEndTs),
|
|
1294
|
+
vestingPeriod: new BN2(vestingPeriod),
|
|
1295
|
+
oracleType: !!oracleType ? { [oracleType]: {} } : { none: {} },
|
|
1296
|
+
minPrice: getBN(minPrice, constants.ALIGNED_PRECISION_FACTOR_POW),
|
|
1297
|
+
maxPrice: getBN(maxPrice, constants.ALIGNED_PRECISION_FACTOR_POW),
|
|
1298
|
+
minPercentage: getBN(minPercentage, constants.ALIGNED_PRECISION_FACTOR_POW),
|
|
1299
|
+
maxPercentage: getBN(maxPercentage, constants.ALIGNED_PRECISION_FACTOR_POW),
|
|
1300
|
+
tickSize: getBN(tickSize, constants.ALIGNED_PRECISION_FACTOR_POW),
|
|
1301
|
+
skipInitial,
|
|
1302
|
+
isMemoRequired
|
|
1303
|
+
}).accounts({
|
|
1304
|
+
authority,
|
|
1305
|
+
baseMint: baseMintKey,
|
|
1306
|
+
quoteMint: quoteMintKey,
|
|
1307
|
+
receiver,
|
|
1308
|
+
priceOracle: oracle,
|
|
1309
|
+
tokenProgram: tokenProgramId
|
|
1310
|
+
}).instruction();
|
|
1311
|
+
return { ixs: [createIx], publicKey: launchpadPDA };
|
|
1312
|
+
}
|
|
1313
|
+
async fundLaunchpad(data, extParams) {
|
|
1314
|
+
const { ixs } = await this.prepareFundLaunchpadInstructions(data, extParams);
|
|
1315
|
+
const { signature } = await this.execute(ixs, extParams);
|
|
1316
|
+
return {
|
|
1317
|
+
ixs,
|
|
1318
|
+
txId: signature
|
|
1319
|
+
};
|
|
1320
|
+
}
|
|
1321
|
+
async prepareFundLaunchpadInstructions({ launchpad: launchpadKey, amount, baseMint: baseMintKey, tokenProgramId = TOKEN_PROGRAM_ID }, extParams) {
|
|
1322
|
+
const authority = extParams.invoker.publicKey;
|
|
1323
|
+
invariant(authority, "Undefined authority publicKey");
|
|
1324
|
+
if (!baseMintKey) {
|
|
1325
|
+
baseMintKey = (await this.getLaunchpad(launchpadKey)).baseMint;
|
|
1326
|
+
}
|
|
1327
|
+
const { mint } = await getMintAndProgram(this.connection, pk(baseMintKey));
|
|
1328
|
+
return {
|
|
1329
|
+
ixs: [
|
|
1330
|
+
...await checkOrCreateAtaBatch(
|
|
1331
|
+
this.connection,
|
|
1332
|
+
[pk(launchpadKey)],
|
|
1333
|
+
pk(baseMintKey),
|
|
1334
|
+
extParams.invoker,
|
|
1335
|
+
pk(tokenProgramId)
|
|
1336
|
+
),
|
|
1337
|
+
createTransferCheckedInstruction(
|
|
1338
|
+
getAssociatedTokenAddressSync(mint.address, authority, true, pk(tokenProgramId)),
|
|
1339
|
+
mint.address,
|
|
1340
|
+
getAssociatedTokenAddressSync(mint.address, pk(launchpadKey), true, pk(tokenProgramId)),
|
|
1341
|
+
authority,
|
|
1342
|
+
BigInt(amount.toString()),
|
|
1343
|
+
mint.decimals,
|
|
1344
|
+
void 0,
|
|
1345
|
+
pk(tokenProgramId)
|
|
1346
|
+
)
|
|
1347
|
+
]
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
async deposit(data, extParams) {
|
|
1351
|
+
const { ixs } = await this.prepareDepositInstructions(data, extParams);
|
|
1352
|
+
const { signature } = await this.execute(ixs, extParams);
|
|
1353
|
+
return {
|
|
1354
|
+
ixs,
|
|
1355
|
+
txId: signature
|
|
1356
|
+
};
|
|
1357
|
+
}
|
|
1358
|
+
async prepareDepositInstructions({
|
|
1359
|
+
launchpad: launchpadKey,
|
|
1360
|
+
quoteMint: quoteMintKey,
|
|
1361
|
+
amount,
|
|
1362
|
+
autoCap = false,
|
|
1363
|
+
memo,
|
|
1364
|
+
owner,
|
|
1365
|
+
tokenProgramId = TOKEN_PROGRAM_ID
|
|
1366
|
+
}, extParams) {
|
|
1367
|
+
const payer = extParams.invoker.publicKey;
|
|
1368
|
+
invariant(payer, "Undefined payer publicKey");
|
|
1369
|
+
owner = pk(owner ?? payer);
|
|
1370
|
+
if (!quoteMintKey) {
|
|
1371
|
+
quoteMintKey = (await this.getLaunchpad(launchpadKey)).quoteMint;
|
|
1372
|
+
}
|
|
1373
|
+
const depositPDA = deriveDepositPDA(this.program.programId, pk(launchpadKey), owner);
|
|
1374
|
+
const ixs = [];
|
|
1375
|
+
if (memo) {
|
|
1376
|
+
ixs.push(
|
|
1377
|
+
new TransactionInstruction({
|
|
1378
|
+
keys: [{ pubkey: payer, isSigner: true, isWritable: true }],
|
|
1379
|
+
data: Buffer.from(memo, "utf-8"),
|
|
1380
|
+
programId: new PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr")
|
|
1381
|
+
})
|
|
1382
|
+
);
|
|
1383
|
+
}
|
|
1384
|
+
ixs.push(
|
|
1385
|
+
await this.program.methods.deposit({ amount, autoCap }).accounts({
|
|
1386
|
+
payer,
|
|
1387
|
+
owner,
|
|
1388
|
+
from: getAssociatedTokenAddressSync(pk(quoteMintKey), payer, true, pk(tokenProgramId)),
|
|
1389
|
+
launchpad: launchpadKey,
|
|
1390
|
+
tokenProgram: tokenProgramId
|
|
1391
|
+
}).instruction()
|
|
1392
|
+
);
|
|
1393
|
+
return { ixs, publicKey: depositPDA };
|
|
1394
|
+
}
|
|
1395
|
+
async claimDeposits(data, extParams) {
|
|
1396
|
+
const { ixs } = await this.prepareClaimDepositsInstructions(data, extParams);
|
|
1397
|
+
const { signature } = await this.execute(ixs, extParams);
|
|
1398
|
+
return {
|
|
1399
|
+
ixs,
|
|
1400
|
+
txId: signature
|
|
1401
|
+
};
|
|
1402
|
+
}
|
|
1403
|
+
async prepareClaimDepositsInstructions({ launchpad: launchpadKey, tokenProgramId = TOKEN_PROGRAM_ID }, extParams) {
|
|
1404
|
+
const authority = extParams.invoker.publicKey;
|
|
1405
|
+
invariant(authority, "Undefined authority publicKey");
|
|
1406
|
+
return {
|
|
1407
|
+
ixs: [
|
|
1408
|
+
await this.program.methods.claimDeposits().accounts({
|
|
1409
|
+
authority,
|
|
1410
|
+
launchpad: launchpadKey,
|
|
1411
|
+
tokenProgram: tokenProgramId
|
|
1412
|
+
}).instruction()
|
|
1413
|
+
]
|
|
1414
|
+
};
|
|
1415
|
+
}
|
|
1416
|
+
async claimAllocatedVested(data, extParams) {
|
|
1417
|
+
if (!extParams.computeLimit) {
|
|
1418
|
+
extParams.computeLimit = 28e4;
|
|
1419
|
+
}
|
|
1420
|
+
const { ixs, streamKeypair } = await this.prepareClaimAllocatedVestedInstructions(data, extParams);
|
|
1421
|
+
const { signature } = await this.execute(ixs, extParams, streamKeypair);
|
|
1422
|
+
return {
|
|
1423
|
+
ixs,
|
|
1424
|
+
txId: signature
|
|
1425
|
+
};
|
|
1426
|
+
}
|
|
1427
|
+
async prepareClaimAllocatedVestedInstructions({ launchpad: launchpadKey, baseMint: baseMintKey, owner, tokenProgramId = TOKEN_PROGRAM_ID }, extParams) {
|
|
1428
|
+
const payer = extParams.invoker.publicKey;
|
|
1429
|
+
invariant(payer, "Undefined payer publicKey");
|
|
1430
|
+
owner = pk(owner ?? payer);
|
|
1431
|
+
if (!baseMintKey) {
|
|
1432
|
+
baseMintKey = (await this.getLaunchpad(launchpadKey)).baseMint;
|
|
1433
|
+
}
|
|
1434
|
+
const streamKeypair = Keypair.generate();
|
|
1435
|
+
const streamKey = streamKeypair.publicKey;
|
|
1436
|
+
const proxyMetadataKey = deriveContractPDA(this.dynamicVestingId, streamKeypair.publicKey);
|
|
1437
|
+
const proxyTokensKey = getAssociatedTokenAddressSync(pk(baseMintKey), proxyMetadataKey, true);
|
|
1438
|
+
const escrowKey = deriveEscrowPDA(this.vestingId, streamKeypair.publicKey);
|
|
1439
|
+
const depositKey = deriveDepositPDA(this.program.programId, pk(launchpadKey), owner);
|
|
1440
|
+
const ix = await this.program.methods.claimAllocatedVested().accounts({
|
|
1441
|
+
depositAccount: depositKey,
|
|
1442
|
+
payer,
|
|
1443
|
+
proxyMetadata: proxyMetadataKey,
|
|
1444
|
+
proxyTokens: proxyTokensKey,
|
|
1445
|
+
streamMetadata: streamKey,
|
|
1446
|
+
escrowTokens: escrowKey,
|
|
1447
|
+
withdrawor: constants.WITHDRAWOR_PUBLIC_KEY,
|
|
1448
|
+
feeOracle: constants.FEE_ORACLE_PUBLIC_KEY,
|
|
1449
|
+
tokenProgram: tokenProgramId
|
|
1450
|
+
}).accountsPartial({
|
|
1451
|
+
streamflowProgram: this.vestingId,
|
|
1452
|
+
proxyProgram: this.dynamicVestingId
|
|
1453
|
+
}).instruction();
|
|
1454
|
+
return { ixs: [ix], streamKeypair };
|
|
1455
|
+
}
|
|
1456
|
+
async execute(ixs, extParams, ...partialSigners) {
|
|
1457
|
+
ixs = [...prepareBaseInstructions(this.connection, extParams), ...ixs];
|
|
1458
|
+
const { tx, hash, context } = await prepareTransaction(
|
|
1459
|
+
this.connection,
|
|
1460
|
+
ixs,
|
|
1461
|
+
extParams.invoker.publicKey,
|
|
1462
|
+
this.getCommitment(),
|
|
1463
|
+
...partialSigners
|
|
1464
|
+
);
|
|
1465
|
+
try {
|
|
1466
|
+
const signature = await signAndExecuteTransaction(
|
|
1467
|
+
this.connection,
|
|
1468
|
+
extParams.invoker,
|
|
1469
|
+
tx,
|
|
1470
|
+
{
|
|
1471
|
+
hash,
|
|
1472
|
+
context,
|
|
1473
|
+
commitment: this.getCommitment()
|
|
1474
|
+
},
|
|
1475
|
+
{ sendThrottler: this.sendThrottler }
|
|
1476
|
+
);
|
|
1477
|
+
return { signature };
|
|
1478
|
+
} catch (err) {
|
|
1479
|
+
if (err instanceof Error) {
|
|
1480
|
+
const parsed = translateError(err, parseIdlErrors(this.program.idl));
|
|
1481
|
+
if (parsed) {
|
|
1482
|
+
throw new ContractError(err, parsed.name, parsed.message);
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
throw err;
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
};
|
|
1489
|
+
|
|
1490
|
+
export { SolanaLaunchpadClient, constants_exports as constants, deriveDepositPDA, deriveLaunchpadPDA, deriveVaultPDA };
|
|
1491
|
+
//# sourceMappingURL=index.js.map
|
|
1492
|
+
//# sourceMappingURL=index.js.map
|