@streamflow/launchpad 7.5.3-alpha.p284.d53d644 → 7.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +34 -0
- package/dist/cjs/solana/client.js +261 -0
- package/dist/cjs/solana/constants.js +20 -0
- package/dist/cjs/solana/descriptor/idl/streamflow_launchpad.json +1468 -0
- package/dist/cjs/solana/descriptor/streamflow_launchpad.js +2 -0
- package/dist/cjs/solana/lib/derive-accounts.js +22 -0
- package/dist/cjs/solana/types.js +2 -0
- package/dist/esm/index.d.ts +4 -148
- package/dist/esm/index.js +4 -1492
- package/dist/esm/solana/client.d.ts +62 -0
- package/dist/esm/solana/client.js +261 -0
- package/dist/esm/solana/constants.d.ts +12 -0
- package/dist/esm/solana/constants.js +17 -0
- package/dist/esm/solana/descriptor/idl/streamflow_launchpad.json +1391 -930
- package/dist/esm/solana/descriptor/streamflow_launchpad.d.ts +1 -3
- package/dist/esm/solana/descriptor/streamflow_launchpad.js +1 -3
- package/dist/esm/solana/lib/derive-accounts.d.ts +4 -0
- package/dist/esm/solana/lib/derive-accounts.js +13 -0
- package/dist/esm/solana/types.d.ts +61 -0
- package/dist/esm/solana/types.js +1 -0
- package/package.json +18 -38
- package/dist/cjs/index.cjs +0 -1502
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/index.d.cts +0 -148
- package/dist/cjs/solana/descriptor/streamflow_launchpad.cjs +0 -4
- package/dist/cjs/solana/descriptor/streamflow_launchpad.cjs.map +0 -1
- package/dist/cjs/solana/descriptor/streamflow_launchpad.d.cts +0 -1135
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/solana/descriptor/streamflow_launchpad.js.map +0 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Program, ProgramAccount, Address } from "@coral-xyz/anchor";
|
|
2
|
+
import { Commitment, Connection, ConnectionConfig, PublicKey, TransactionInstruction, Keypair } from "@solana/web3.js";
|
|
3
|
+
import { ICluster, ITransactionResult } from "@streamflow/common";
|
|
4
|
+
import PQueue from "p-queue";
|
|
5
|
+
import { LAUNCHPAD_BYTE_OFFSETS } from "./constants.js";
|
|
6
|
+
import { StreamflowLaunchpad } from "./descriptor/streamflow_launchpad.js";
|
|
7
|
+
import { DepositAccount, Launchpad, IInteractSolanaExt, ICreateLaunchpad, IDeposit, IClaimDeposits, IClaimAllocatedVested, IFundLaunchpad } from "./types.js";
|
|
8
|
+
interface IInitOptions {
|
|
9
|
+
clusterUrl?: string;
|
|
10
|
+
cluster?: ICluster;
|
|
11
|
+
commitment?: Commitment | ConnectionConfig;
|
|
12
|
+
programIds?: {
|
|
13
|
+
launchpad?: string;
|
|
14
|
+
vesting?: string;
|
|
15
|
+
dynamicVesting?: string;
|
|
16
|
+
};
|
|
17
|
+
sendRate?: number;
|
|
18
|
+
sendThrottler?: PQueue;
|
|
19
|
+
}
|
|
20
|
+
type CreationResult = ITransactionResult & {
|
|
21
|
+
metadataId: PublicKey;
|
|
22
|
+
};
|
|
23
|
+
export declare class SolanaLaunchpadClient {
|
|
24
|
+
connection: Connection;
|
|
25
|
+
cluster: ICluster;
|
|
26
|
+
private readonly commitment;
|
|
27
|
+
private readonly sendThrottler;
|
|
28
|
+
private readonly dynamicVestingId;
|
|
29
|
+
private readonly vestingId;
|
|
30
|
+
readonly program: Program<StreamflowLaunchpad>;
|
|
31
|
+
constructor({ clusterUrl, cluster, commitment, programIds, sendRate, sendThrottler, }: IInitOptions);
|
|
32
|
+
getCurrentProgramId(): PublicKey;
|
|
33
|
+
getCommitment(): Commitment | undefined;
|
|
34
|
+
getLaunchpad(id: Address): Promise<Launchpad>;
|
|
35
|
+
searchLaunchpads(criteria?: Partial<Pick<Launchpad, keyof typeof LAUNCHPAD_BYTE_OFFSETS>>): Promise<ProgramAccount<Launchpad>[]>;
|
|
36
|
+
getDepositAccount(id: Address): Promise<DepositAccount>;
|
|
37
|
+
createLaunchpad(data: ICreateLaunchpad, extParams: IInteractSolanaExt): Promise<CreationResult>;
|
|
38
|
+
prepareCreateLaunchpadInstructions({ baseMint: baseMintKey, quoteMint: quoteMintKey, receiver, priceOracle, nonce, price, individualDepositingCap, maxDepositingCap, depositingStartTs, depositingEndTs, vestingStartTs, vestingEndTs, vestingPeriod, oracleType, minPrice, maxPrice, minPercentage, maxPercentage, tickSize, skipInitial, isMemoRequired, tokenProgramId, }: ICreateLaunchpad, extParams: IInteractSolanaExt): Promise<{
|
|
39
|
+
ixs: TransactionInstruction[];
|
|
40
|
+
publicKey: PublicKey;
|
|
41
|
+
}>;
|
|
42
|
+
fundLaunchpad(data: IFundLaunchpad, extParams: IInteractSolanaExt): Promise<ITransactionResult>;
|
|
43
|
+
prepareFundLaunchpadInstructions({ launchpad: launchpadKey, amount, baseMint: baseMintKey, tokenProgramId }: IFundLaunchpad, extParams: IInteractSolanaExt): Promise<{
|
|
44
|
+
ixs: TransactionInstruction[];
|
|
45
|
+
}>;
|
|
46
|
+
deposit(data: IDeposit, extParams: IInteractSolanaExt): Promise<ITransactionResult>;
|
|
47
|
+
prepareDepositInstructions({ launchpad: launchpadKey, quoteMint: quoteMintKey, amount, autoCap, memo, owner, tokenProgramId, }: IDeposit, extParams: IInteractSolanaExt): Promise<{
|
|
48
|
+
ixs: TransactionInstruction[];
|
|
49
|
+
publicKey: PublicKey;
|
|
50
|
+
}>;
|
|
51
|
+
claimDeposits(data: IClaimDeposits, extParams: IInteractSolanaExt): Promise<ITransactionResult>;
|
|
52
|
+
prepareClaimDepositsInstructions({ launchpad: launchpadKey, tokenProgramId }: IClaimDeposits, extParams: IInteractSolanaExt): Promise<{
|
|
53
|
+
ixs: TransactionInstruction[];
|
|
54
|
+
}>;
|
|
55
|
+
claimAllocatedVested(data: IClaimAllocatedVested, extParams: IInteractSolanaExt): Promise<ITransactionResult>;
|
|
56
|
+
prepareClaimAllocatedVestedInstructions({ launchpad: launchpadKey, baseMint: baseMintKey, owner, tokenProgramId }: IClaimAllocatedVested, extParams: IInteractSolanaExt): Promise<{
|
|
57
|
+
ixs: TransactionInstruction[];
|
|
58
|
+
streamKeypair: Keypair;
|
|
59
|
+
}>;
|
|
60
|
+
private execute;
|
|
61
|
+
}
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { Program, parseIdlErrors, translateError, } from "@coral-xyz/anchor";
|
|
2
|
+
import { getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID, createTransferCheckedInstruction } from "@solana/spl-token";
|
|
3
|
+
import { Connection, PublicKey, TransactionInstruction, Keypair, clusterApiUrl, } from "@solana/web3.js";
|
|
4
|
+
import { ContractError, ICluster, invariant, getBN } from "@streamflow/common";
|
|
5
|
+
import { buildSendThrottler, checkOrCreateAtaBatch, getFilters, pk, getMintAndProgram, prepareTransaction, signAndExecuteTransaction, prepareBaseInstructions, } from "@streamflow/common/solana";
|
|
6
|
+
import { constants as streamConstants, deriveTestOraclePDA, deriveContractPDA, deriveEscrowPDA, } from "@streamflow/stream/solana";
|
|
7
|
+
import BN from "bn.js";
|
|
8
|
+
import { LAUNCHPAD_BYTE_OFFSETS, PROGRAM_ID } from "./constants.js";
|
|
9
|
+
import StreamflowLaunchpadIDL from "./descriptor/idl/streamflow_launchpad.json";
|
|
10
|
+
import { deriveDepositPDA, deriveLaunchpadPDA } from "./lib/derive-accounts.js";
|
|
11
|
+
export class SolanaLaunchpadClient {
|
|
12
|
+
connection;
|
|
13
|
+
cluster;
|
|
14
|
+
commitment;
|
|
15
|
+
sendThrottler;
|
|
16
|
+
dynamicVestingId;
|
|
17
|
+
vestingId;
|
|
18
|
+
program;
|
|
19
|
+
constructor({ clusterUrl, cluster = ICluster.Mainnet, commitment = "confirmed", programIds, sendRate = 1, sendThrottler, }) {
|
|
20
|
+
this.commitment = commitment;
|
|
21
|
+
if (!clusterUrl) {
|
|
22
|
+
switch (cluster) {
|
|
23
|
+
case ICluster.Mainnet:
|
|
24
|
+
clusterUrl = clusterApiUrl("mainnet-beta");
|
|
25
|
+
break;
|
|
26
|
+
case ICluster.Local:
|
|
27
|
+
clusterUrl = "http://localhost:8899";
|
|
28
|
+
break;
|
|
29
|
+
default:
|
|
30
|
+
clusterUrl = clusterApiUrl(cluster);
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
this.connection = new Connection(clusterUrl, this.commitment);
|
|
35
|
+
this.cluster = cluster;
|
|
36
|
+
this.sendThrottler = sendThrottler ?? buildSendThrottler(sendRate);
|
|
37
|
+
const launchpadIdl = {
|
|
38
|
+
...StreamflowLaunchpadIDL,
|
|
39
|
+
address: programIds?.launchpad ?? PROGRAM_ID[cluster] ?? StreamflowLaunchpadIDL.address,
|
|
40
|
+
};
|
|
41
|
+
this.program = new Program(launchpadIdl, {
|
|
42
|
+
connection: this.connection,
|
|
43
|
+
});
|
|
44
|
+
this.dynamicVestingId = pk(programIds?.dynamicVesting ? programIds.dynamicVesting : streamConstants.ALIGNED_UNLOCKS_PROGRAM_ID[cluster]);
|
|
45
|
+
this.vestingId = pk(programIds?.vesting ? programIds.vesting : streamConstants.PROGRAM_ID[cluster]);
|
|
46
|
+
}
|
|
47
|
+
getCurrentProgramId() {
|
|
48
|
+
invariant(this.program, `Program is not found`);
|
|
49
|
+
return this.program.programId;
|
|
50
|
+
}
|
|
51
|
+
getCommitment() {
|
|
52
|
+
return typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
|
|
53
|
+
}
|
|
54
|
+
getLaunchpad(id) {
|
|
55
|
+
return this.program.account.launchpad.fetch(id);
|
|
56
|
+
}
|
|
57
|
+
searchLaunchpads(criteria = {}) {
|
|
58
|
+
return this.program.account.launchpad.all(getFilters(criteria, LAUNCHPAD_BYTE_OFFSETS));
|
|
59
|
+
}
|
|
60
|
+
getDepositAccount(id) {
|
|
61
|
+
return this.program.account.depositAccount.fetch(id);
|
|
62
|
+
}
|
|
63
|
+
async createLaunchpad(data, extParams) {
|
|
64
|
+
const { ixs, publicKey } = await this.prepareCreateLaunchpadInstructions(data, extParams);
|
|
65
|
+
const { signature } = await this.execute(ixs, extParams);
|
|
66
|
+
return {
|
|
67
|
+
ixs,
|
|
68
|
+
txId: signature,
|
|
69
|
+
metadataId: publicKey,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
async prepareCreateLaunchpadInstructions({ baseMint: baseMintKey, quoteMint: quoteMintKey, receiver, priceOracle, nonce, price, individualDepositingCap, maxDepositingCap, depositingStartTs, depositingEndTs, vestingStartTs, vestingEndTs, vestingPeriod, oracleType, minPrice, maxPrice, minPercentage, maxPercentage, tickSize, skipInitial, isMemoRequired, tokenProgramId = TOKEN_PROGRAM_ID, }, extParams) {
|
|
73
|
+
baseMintKey = pk(baseMintKey);
|
|
74
|
+
quoteMintKey = pk(quoteMintKey);
|
|
75
|
+
const authority = extParams.invoker.publicKey;
|
|
76
|
+
invariant(authority, "Undefined creator publicKey");
|
|
77
|
+
if (!priceOracle && oracleType && !["none", "test"].includes(oracleType)) {
|
|
78
|
+
throw new Error("Price oracle is required for the specified oracle type");
|
|
79
|
+
}
|
|
80
|
+
receiver = receiver ?? getAssociatedTokenAddressSync(quoteMintKey, authority);
|
|
81
|
+
const oracle = priceOracle ?? deriveTestOraclePDA(this.dynamicVestingId, baseMintKey, authority);
|
|
82
|
+
const launchpadPDA = deriveLaunchpadPDA(this.program.programId, baseMintKey, nonce);
|
|
83
|
+
const createIx = await this.program.methods
|
|
84
|
+
.createLaunchpad({
|
|
85
|
+
nonce,
|
|
86
|
+
price,
|
|
87
|
+
individualDepositingCap,
|
|
88
|
+
maxDepositingCap,
|
|
89
|
+
depositingStartTs: new BN(depositingStartTs),
|
|
90
|
+
depositingEndTs: new BN(depositingEndTs),
|
|
91
|
+
vestingStartTs: new BN(vestingStartTs),
|
|
92
|
+
vestingEndTs: new BN(vestingEndTs),
|
|
93
|
+
vestingPeriod: new BN(vestingPeriod),
|
|
94
|
+
oracleType: (!!oracleType ? { [oracleType]: {} } : { none: {} }),
|
|
95
|
+
minPrice: getBN(minPrice, streamConstants.ALIGNED_PRECISION_FACTOR_POW),
|
|
96
|
+
maxPrice: getBN(maxPrice, streamConstants.ALIGNED_PRECISION_FACTOR_POW),
|
|
97
|
+
minPercentage: getBN(minPercentage, streamConstants.ALIGNED_PRECISION_FACTOR_POW),
|
|
98
|
+
maxPercentage: getBN(maxPercentage, streamConstants.ALIGNED_PRECISION_FACTOR_POW),
|
|
99
|
+
tickSize: getBN(tickSize, streamConstants.ALIGNED_PRECISION_FACTOR_POW),
|
|
100
|
+
skipInitial,
|
|
101
|
+
isMemoRequired,
|
|
102
|
+
})
|
|
103
|
+
.accounts({
|
|
104
|
+
authority,
|
|
105
|
+
baseMint: baseMintKey,
|
|
106
|
+
quoteMint: quoteMintKey,
|
|
107
|
+
receiver: receiver,
|
|
108
|
+
priceOracle: oracle,
|
|
109
|
+
tokenProgram: tokenProgramId,
|
|
110
|
+
})
|
|
111
|
+
.instruction();
|
|
112
|
+
return { ixs: [createIx], publicKey: launchpadPDA };
|
|
113
|
+
}
|
|
114
|
+
async fundLaunchpad(data, extParams) {
|
|
115
|
+
const { ixs } = await this.prepareFundLaunchpadInstructions(data, extParams);
|
|
116
|
+
const { signature } = await this.execute(ixs, extParams);
|
|
117
|
+
return {
|
|
118
|
+
ixs,
|
|
119
|
+
txId: signature,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
async prepareFundLaunchpadInstructions({ launchpad: launchpadKey, amount, baseMint: baseMintKey, tokenProgramId = TOKEN_PROGRAM_ID }, extParams) {
|
|
123
|
+
const authority = extParams.invoker.publicKey;
|
|
124
|
+
invariant(authority, "Undefined authority publicKey");
|
|
125
|
+
if (!baseMintKey) {
|
|
126
|
+
baseMintKey = (await this.getLaunchpad(launchpadKey)).baseMint;
|
|
127
|
+
}
|
|
128
|
+
const { mint } = await getMintAndProgram(this.connection, pk(baseMintKey));
|
|
129
|
+
return {
|
|
130
|
+
ixs: [
|
|
131
|
+
...(await checkOrCreateAtaBatch(this.connection, [pk(launchpadKey)], pk(baseMintKey), extParams.invoker, pk(tokenProgramId))),
|
|
132
|
+
createTransferCheckedInstruction(getAssociatedTokenAddressSync(mint.address, authority, true, pk(tokenProgramId)), mint.address, getAssociatedTokenAddressSync(mint.address, pk(launchpadKey), true, pk(tokenProgramId)), authority, BigInt(amount.toString()), mint.decimals, undefined, pk(tokenProgramId)),
|
|
133
|
+
],
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
async deposit(data, extParams) {
|
|
137
|
+
const { ixs } = await this.prepareDepositInstructions(data, extParams);
|
|
138
|
+
const { signature } = await this.execute(ixs, extParams);
|
|
139
|
+
return {
|
|
140
|
+
ixs,
|
|
141
|
+
txId: signature,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
async prepareDepositInstructions({ launchpad: launchpadKey, quoteMint: quoteMintKey, amount, autoCap = false, memo, owner, tokenProgramId = TOKEN_PROGRAM_ID, }, extParams) {
|
|
145
|
+
const payer = extParams.invoker.publicKey;
|
|
146
|
+
invariant(payer, "Undefined payer publicKey");
|
|
147
|
+
owner = pk(owner ?? payer);
|
|
148
|
+
if (!quoteMintKey) {
|
|
149
|
+
quoteMintKey = (await this.getLaunchpad(launchpadKey)).quoteMint;
|
|
150
|
+
}
|
|
151
|
+
const depositPDA = deriveDepositPDA(this.program.programId, pk(launchpadKey), owner);
|
|
152
|
+
const ixs = [];
|
|
153
|
+
if (memo) {
|
|
154
|
+
ixs.push(new TransactionInstruction({
|
|
155
|
+
keys: [{ pubkey: payer, isSigner: true, isWritable: true }],
|
|
156
|
+
data: Buffer.from(memo, "utf-8"),
|
|
157
|
+
programId: new PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),
|
|
158
|
+
}));
|
|
159
|
+
}
|
|
160
|
+
ixs.push(await this.program.methods
|
|
161
|
+
.deposit({ amount, autoCap })
|
|
162
|
+
.accounts({
|
|
163
|
+
payer,
|
|
164
|
+
owner: owner,
|
|
165
|
+
from: getAssociatedTokenAddressSync(pk(quoteMintKey), payer, true, pk(tokenProgramId)),
|
|
166
|
+
launchpad: launchpadKey,
|
|
167
|
+
tokenProgram: tokenProgramId,
|
|
168
|
+
})
|
|
169
|
+
.instruction());
|
|
170
|
+
return { ixs, publicKey: depositPDA };
|
|
171
|
+
}
|
|
172
|
+
async claimDeposits(data, extParams) {
|
|
173
|
+
const { ixs } = await this.prepareClaimDepositsInstructions(data, extParams);
|
|
174
|
+
const { signature } = await this.execute(ixs, extParams);
|
|
175
|
+
return {
|
|
176
|
+
ixs,
|
|
177
|
+
txId: signature,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
async prepareClaimDepositsInstructions({ launchpad: launchpadKey, tokenProgramId = TOKEN_PROGRAM_ID }, extParams) {
|
|
181
|
+
const authority = extParams.invoker.publicKey;
|
|
182
|
+
invariant(authority, "Undefined authority publicKey");
|
|
183
|
+
return {
|
|
184
|
+
ixs: [
|
|
185
|
+
await this.program.methods
|
|
186
|
+
.claimDeposits()
|
|
187
|
+
.accounts({
|
|
188
|
+
authority,
|
|
189
|
+
launchpad: launchpadKey,
|
|
190
|
+
tokenProgram: tokenProgramId,
|
|
191
|
+
})
|
|
192
|
+
.instruction(),
|
|
193
|
+
],
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
async claimAllocatedVested(data, extParams) {
|
|
197
|
+
if (!extParams.computeLimit) {
|
|
198
|
+
extParams.computeLimit = 280_000;
|
|
199
|
+
}
|
|
200
|
+
const { ixs, streamKeypair } = await this.prepareClaimAllocatedVestedInstructions(data, extParams);
|
|
201
|
+
const { signature } = await this.execute(ixs, extParams, streamKeypair);
|
|
202
|
+
return {
|
|
203
|
+
ixs,
|
|
204
|
+
txId: signature,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
async prepareClaimAllocatedVestedInstructions({ launchpad: launchpadKey, baseMint: baseMintKey, owner, tokenProgramId = TOKEN_PROGRAM_ID }, extParams) {
|
|
208
|
+
const payer = extParams.invoker.publicKey;
|
|
209
|
+
invariant(payer, "Undefined payer publicKey");
|
|
210
|
+
owner = pk(owner ?? payer);
|
|
211
|
+
if (!baseMintKey) {
|
|
212
|
+
baseMintKey = (await this.getLaunchpad(launchpadKey)).baseMint;
|
|
213
|
+
}
|
|
214
|
+
const streamKeypair = Keypair.generate();
|
|
215
|
+
const streamKey = streamKeypair.publicKey;
|
|
216
|
+
const proxyMetadataKey = deriveContractPDA(this.dynamicVestingId, streamKeypair.publicKey);
|
|
217
|
+
const proxyTokensKey = getAssociatedTokenAddressSync(pk(baseMintKey), proxyMetadataKey, true);
|
|
218
|
+
const escrowKey = deriveEscrowPDA(this.vestingId, streamKeypair.publicKey);
|
|
219
|
+
const depositKey = deriveDepositPDA(this.program.programId, pk(launchpadKey), owner);
|
|
220
|
+
const ix = await this.program.methods
|
|
221
|
+
.claimAllocatedVested()
|
|
222
|
+
.accounts({
|
|
223
|
+
depositAccount: depositKey,
|
|
224
|
+
payer,
|
|
225
|
+
proxyMetadata: proxyMetadataKey,
|
|
226
|
+
proxyTokens: proxyTokensKey,
|
|
227
|
+
streamMetadata: streamKey,
|
|
228
|
+
escrowTokens: escrowKey,
|
|
229
|
+
withdrawor: streamConstants.WITHDRAWOR_PUBLIC_KEY,
|
|
230
|
+
feeOracle: streamConstants.FEE_ORACLE_PUBLIC_KEY,
|
|
231
|
+
tokenProgram: tokenProgramId,
|
|
232
|
+
})
|
|
233
|
+
.accountsPartial({
|
|
234
|
+
streamflowProgram: this.vestingId,
|
|
235
|
+
proxyProgram: this.dynamicVestingId,
|
|
236
|
+
})
|
|
237
|
+
.instruction();
|
|
238
|
+
return { ixs: [ix], streamKeypair };
|
|
239
|
+
}
|
|
240
|
+
async execute(ixs, extParams, ...partialSigners) {
|
|
241
|
+
ixs = [...prepareBaseInstructions(this.connection, extParams), ...ixs];
|
|
242
|
+
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey, this.getCommitment(), ...partialSigners);
|
|
243
|
+
try {
|
|
244
|
+
const signature = await signAndExecuteTransaction(this.connection, extParams.invoker, tx, {
|
|
245
|
+
hash,
|
|
246
|
+
context,
|
|
247
|
+
commitment: this.getCommitment(),
|
|
248
|
+
}, { sendThrottler: this.sendThrottler });
|
|
249
|
+
return { signature };
|
|
250
|
+
}
|
|
251
|
+
catch (err) {
|
|
252
|
+
if (err instanceof Error) {
|
|
253
|
+
const parsed = translateError(err, parseIdlErrors(this.program.idl));
|
|
254
|
+
if (parsed) {
|
|
255
|
+
throw new ContractError(err, parsed.name, parsed.message);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
throw err;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ICluster } from "@streamflow/common";
|
|
2
|
+
export declare const LAUNCHPAD_PREFIX: Buffer;
|
|
3
|
+
export declare const VAULT_PREFIX: Buffer;
|
|
4
|
+
export declare const DEPOSIT_PREFIX: Buffer;
|
|
5
|
+
export declare const ANCHOR_DISCRIMINATOR_OFFSET = 8;
|
|
6
|
+
export declare const LAUNCHPAD_BASE_MINT_OFFSET: number;
|
|
7
|
+
export declare const LAUNCHPAD_QUOTE_MINT_OFFSET: number;
|
|
8
|
+
export declare const LAUNCHPAD_BYTE_OFFSETS: {
|
|
9
|
+
readonly baseMint: number;
|
|
10
|
+
readonly quoteMint: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const PROGRAM_ID: Record<ICluster, string>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ICluster } from "@streamflow/common";
|
|
2
|
+
export const LAUNCHPAD_PREFIX = Buffer.from("launchpad", "utf-8");
|
|
3
|
+
export const VAULT_PREFIX = Buffer.from("vault", "utf-8");
|
|
4
|
+
export const DEPOSIT_PREFIX = Buffer.from("deposit", "utf-8");
|
|
5
|
+
export const ANCHOR_DISCRIMINATOR_OFFSET = 8;
|
|
6
|
+
export const LAUNCHPAD_BASE_MINT_OFFSET = ANCHOR_DISCRIMINATOR_OFFSET + 8;
|
|
7
|
+
export const LAUNCHPAD_QUOTE_MINT_OFFSET = ANCHOR_DISCRIMINATOR_OFFSET + 32;
|
|
8
|
+
export const LAUNCHPAD_BYTE_OFFSETS = {
|
|
9
|
+
baseMint: LAUNCHPAD_BASE_MINT_OFFSET,
|
|
10
|
+
quoteMint: LAUNCHPAD_QUOTE_MINT_OFFSET,
|
|
11
|
+
};
|
|
12
|
+
export const PROGRAM_ID = {
|
|
13
|
+
[ICluster.Mainnet]: "BUYfFzeTWeRW5JrPjCutbsvzjA5ERS8EnGujJjfmnJu6",
|
|
14
|
+
[ICluster.Devnet]: "BUYfFzeTWeRW5JrPjCutbsvzjA5ERS8EnGujJjfmnJu6",
|
|
15
|
+
[ICluster.Testnet]: "BUYfFzeTWeRW5JrPjCutbsvzjA5ERS8EnGujJjfmnJu6",
|
|
16
|
+
[ICluster.Local]: "BUYfFzeTWeRW5JrPjCutbsvzjA5ERS8EnGujJjfmnJu6",
|
|
17
|
+
};
|