@streamflow/launchpad 7.1.0-alpha.1

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 ADDED
@@ -0,0 +1,175 @@
1
+ # Streamflow Launchpad
2
+
3
+ ## JS SDk to interact with the Launchpad Protocol
4
+
5
+ This package exposes several instruction needed by both Launchpad creator and depositors:
6
+ - `create new Launchpad`;
7
+ - `fund launchpad`;
8
+ - `deposit into launchpad`;
9
+ - `claim deposited tokens`;
10
+ - `claim allocated tokens`;
11
+
12
+ Each Launchpad consist of multiple configuration options:
13
+ - **Base Mint** - mint that users will be buying - Launchpad should be funded with enough tokens prior to users claiming their allocations;
14
+ - **Quote Mint** - mint that users will deposit and in which price of the **Base Mint** will be denominated - Launchpad authority will be able to claim deposited tokens after depositting period ends;
15
+ - **Price** - price of the 1 **Base Mint** in **Quote Mint** tokens;
16
+ - **Periods** - there are Depositing period and Vesting period needed to be configured;
17
+ - **Vesting Configuration** - dynamic vesting will be used, so Launchpad creator should provide various configuration options for it;
18
+
19
+ ## API Reference
20
+
21
+ API Documentation available here: [docs site →](https://streamflow-finance.github.io/js-sdk/)
22
+
23
+ ## Installation
24
+
25
+ Install the sdk with npm
26
+
27
+ ```npm
28
+ npm install @streamflow/launchpad
29
+ ```
30
+ ```yarn
31
+ yarn install @streamflow/launchpad
32
+ ```
33
+ ```pnpm
34
+ pnpm add @streamflow/launchpad
35
+ ```
36
+
37
+ ## Usage/Examples
38
+
39
+ ### Initiate the client
40
+ ```typescript
41
+ const client = new SolanaLaunchpadClient({
42
+ clusterUrl: "https://api.mainnet-beta.solana.com",
43
+ cluster: ICluster.Mainnet
44
+ });
45
+ ```
46
+
47
+ > [!WARNING]
48
+ > All operations expect ATAs to be created at the moment of execution and don't add these instructions.
49
+ > - Claim Deposits - Receiver token account that will be used to claim deposited tokens;
50
+ > - Claim Allocation - Token account for the `Base Mint` should be created prior to Depositor claiming their allocation;
51
+
52
+
53
+ ### Read operations
54
+
55
+ ```typescript
56
+
57
+ await client.searchLaunchpad({ baseMint, quoteMint }) // both mint parameters are optional.
58
+
59
+ await client.getLaunchpad(id) // fetch specific Launchpad by its ID.
60
+
61
+ await client.getDepositAccount(id) // fetch specific Deposit Account by its ID.
62
+ ```
63
+
64
+ ### Create new Launchpad
65
+ import { getBN } from "@streamflow/common";
66
+
67
+ ```typescript
68
+ const { txId: createSig, metadataId } = await client.createLaunchpad({
69
+ baseMint, // Mint that users will be buying
70
+ quoteMint, // Mint that users will deposit
71
+ receiver, // [optional] Token account that should receive deposits once deposit period is ended
72
+ priceOracle, // [optional] Price Oracle address that will be used in dynamic vesting
73
+ nonce: 1, // Nonce value, Launchpad PDA will be derived from nonce + baseMint
74
+ price: getBN(0.15, QUOTE_MINT_DECIMALS), // Price per 1 `baseMint` whole token denominated in `quoteMint` tokens
75
+ individualDepositingCap: getBN(1_000, QUOTE_MINT_DECIMALS), // Max Cap per User of `quoteMint` tokens to deposit
76
+ maxDepositingCap: getBN(1_000_000, QUOTE_MINT_DECIMALS), // Max global Cap of `quoteMint` tokens to deposit
77
+ depositingStartTs, // Timestamp when depositing should start
78
+ depositingEndTs, // Timestamp when depositing should end
79
+ vestingStartTs, // Timestamp when vesting should start
80
+ vestingEndTs, // Timestamp when vesting should end initially
81
+ vestingPeriod, // Period in seconds of vesting and dynamic vesting unlock updates, should be at least 30
82
+ oracleType: "test", // [optional] Type the Price Oracle, should be aligned with the provided `priceOracle`
83
+ minPrice: 0.05, // Min Price for dynamic vesting
84
+ maxPrice: 1, // Max Price for dynamic vesting
85
+ minPercentage: 1, // Min Percentage for dynamic vesting - will be used if current price <= `minPrice`
86
+ maxPercentage: 1000, // Max Percentage for dynamic vesting - will be used if current price >= `maxPrice`
87
+ tickSize: 1, // Tick size for percentages in dynamic vesting - will be used in case minPrice < current price < maxPrice
88
+ skipInitial: false, // Whether to skip initial unlock amount update when dynamic vesting is initiated
89
+ isMemoRequired: false, // Whether to require special Memo instruction on deposit
90
+ tokenProgramId: TOKEN_PROGRAM_ID // [optional] SPL Token Program to use
91
+ },
92
+ { invoker: authority }
93
+ );
94
+ ```
95
+
96
+ ### Deposit tokens
97
+
98
+ ```typescript
99
+ const { txId: depositSig } = await client.deposit(
100
+ {
101
+ launchpad: metadataId, // Id of the Launchpad to deposit tokens into
102
+ quoteMint, // [optional] Mint Id, if not provided it will be fetched from the Laucnhpad
103
+ amount: getBN(100.15, QUOTE_MINT_DECIMALS), // Amount of `quoteMint` tokens to deposit,
104
+ autoCap: true, // [opional] Whether to automatically cap deposited tokens in case user deposited more than `maxDepositingCap`
105
+ memo: "I don't reside in a sanctioned country.", // [optional] Text for memo instruction
106
+ owner: user1.publicKey, // [optional] Deposit owner in case it differs from the invoker
107
+ tokenProgramId: TOKEN_PROGRAM_ID // [optional] SPL Token Program to use
108
+ },
109
+ { invoker: user1 }
110
+ );
111
+ ```
112
+
113
+ User can deposit tokens however many times they want if both individual and max Depositing caps are respected.
114
+
115
+ > [!Warning]
116
+ > It's not possible to withdraw deposited tokens currently.
117
+
118
+ ### Fund Launchpad
119
+
120
+ ```typescript
121
+ const { txId: fundLaunchpadSig } = await client.fundLaunchpad(
122
+ {
123
+ launchpad: metadataId, // Id of the Launchpad to fund
124
+ baseMint, // [optional] Mint Id, if not provided it will be fetched from the Laucnhpad
125
+ amount: getBN(6_666_666, BASE_MINT_DECIMALS), // Amount of base tokens to funds Laucnhpad by
126
+ tokenProgramId: TOKEN_PROGRAM_ID // [optional] SPL Token Program to use
127
+ },
128
+ { invoker: authority }
129
+ );
130
+ ```
131
+
132
+ > [!Note]
133
+ > Client just uses spl transfer instruction, so technically anyone can fund a Launchpad.
134
+
135
+ ### Claim deposited tokens
136
+
137
+ ```typescript
138
+ const { txId: claimDepositsSig } = await client.claimDeposits(
139
+ {
140
+ launchpad: metadataId, // Id of the Launchpad to claim deposited tokens from
141
+ quoteMint, // [optional] Mint Id, if not provided it will be fetched from the Laucnhpad
142
+ tokenProgramId: TOKEN_PROGRAM_ID // [optional] SPL Token Program to use
143
+ },
144
+ { invoker: authority }
145
+ );
146
+ ```
147
+
148
+ > [!Warning]
149
+ > Claiming of Deposited tokens is possible only after Deposit period has ended.
150
+
151
+ ### Claim token allocation
152
+
153
+ ```typescript
154
+ const { txId: claimAllocatedSig } = await client.claimAllocatedVested(
155
+ {
156
+ launchpad: metadataId, // Id of the Launchpad to claimed allocation from
157
+ baseMint, // [optional] Mint Id, if not provided it will be fetched from the Laucnhpad
158
+ owner: user1.publicKey, // [optional] Deposit owner in case it differs from the invoker
159
+ tokenProgramId: TOKEN_PROGRAM_ID // [optional] SPL Token Program to use
160
+ },
161
+ { invoker: user1 }
162
+ );
163
+ ```
164
+
165
+ > [!Note]
166
+ > Anyone can call this action on behalf of the Deposit after Deposit period has ended.
167
+ >
168
+ > This action will essentially create a Streamflow Dynamic vesting contract where:
169
+ > - total depostted amount will be equal to the Depositor token allocation;
170
+ > - initial vesting start and end time will be set according to the vesting configuration
171
+ > - in case `skipInitial` was not disabled, vesting schedule may differ depending on current price of the token;
172
+
173
+
174
+ > [!Warning]
175
+ > This action should be done prior to Vesting Start Time - as dynamic vesting will be used and dynamic vesting can not have any cliff amount.
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.constants = exports.SolanaLaunchpadClient = void 0;
30
+ var client_js_1 = require("./solana/client.js");
31
+ Object.defineProperty(exports, "SolanaLaunchpadClient", { enumerable: true, get: function () { return client_js_1.SolanaLaunchpadClient; } });
32
+ __exportStar(require("./solana/types.js"), exports);
33
+ __exportStar(require("./solana/lib/derive-accounts.js"), exports);
34
+ exports.constants = __importStar(require("./solana/constants.js"));
@@ -0,0 +1,261 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SolanaLaunchpadClient = void 0;
7
+ const anchor_1 = require("@coral-xyz/anchor");
8
+ const spl_token_1 = require("@solana/spl-token");
9
+ const web3_js_1 = require("@solana/web3.js");
10
+ const common_1 = require("@streamflow/common");
11
+ const solana_1 = require("@streamflow/common/solana");
12
+ const solana_2 = require("@streamflow/stream/solana");
13
+ const bn_js_1 = __importDefault(require("bn.js"));
14
+ const constants_js_1 = require("./constants.js");
15
+ const streamflow_launchpad_json_1 = __importDefault(require("./descriptor/idl/streamflow_launchpad.json"));
16
+ const derive_accounts_js_1 = require("./lib/derive-accounts.js");
17
+ class SolanaLaunchpadClient {
18
+ constructor({ clusterUrl, cluster = common_1.ICluster.Mainnet, commitment = "confirmed", programIds, sendRate = 1, sendThrottler, }) {
19
+ this.commitment = commitment;
20
+ if (!clusterUrl) {
21
+ switch (cluster) {
22
+ case common_1.ICluster.Mainnet:
23
+ clusterUrl = (0, web3_js_1.clusterApiUrl)("mainnet-beta");
24
+ break;
25
+ case common_1.ICluster.Local:
26
+ clusterUrl = "http://localhost:8899";
27
+ break;
28
+ default:
29
+ clusterUrl = (0, web3_js_1.clusterApiUrl)(cluster);
30
+ break;
31
+ }
32
+ }
33
+ this.connection = new web3_js_1.Connection(clusterUrl, this.commitment);
34
+ this.cluster = cluster;
35
+ this.sendThrottler = sendThrottler ?? (0, solana_1.buildSendThrottler)(sendRate);
36
+ const launchpadIdl = {
37
+ ...streamflow_launchpad_json_1.default,
38
+ address: programIds?.launchpad ?? constants_js_1.PROGRAM_ID[cluster] ?? streamflow_launchpad_json_1.default.address,
39
+ };
40
+ this.program = new anchor_1.Program(launchpadIdl, {
41
+ connection: this.connection,
42
+ });
43
+ this.dynamicVestingId = (0, solana_1.pk)(programIds?.dynamicVesting ? programIds.dynamicVesting : solana_2.constants.ALIGNED_UNLOCKS_PROGRAM_ID[cluster]);
44
+ this.vestingId = (0, solana_1.pk)(programIds?.vesting ? programIds.vesting : solana_2.constants.PROGRAM_ID[cluster]);
45
+ }
46
+ getCurrentProgramId() {
47
+ (0, common_1.invariant)(this.program, `Program is not found`);
48
+ return this.program.programId;
49
+ }
50
+ getCommitment() {
51
+ return typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
52
+ }
53
+ getLaunchpad(id) {
54
+ return this.program.account.launchpad.fetch(id);
55
+ }
56
+ searchLaunchpads(criteria = {}) {
57
+ return this.program.account.launchpad.all((0, solana_1.getFilters)(criteria, constants_js_1.LAUNCHPAD_BYTE_OFFSETS));
58
+ }
59
+ getDepositAccount(id) {
60
+ return this.program.account.depositAccount.fetch(id);
61
+ }
62
+ async createLaunchpad(data, extParams) {
63
+ const { ixs, publicKey } = await this.prepareCreateLaunchpadInstructions(data, extParams);
64
+ const { signature } = await this.execute(ixs, extParams);
65
+ return {
66
+ ixs,
67
+ txId: signature,
68
+ metadataId: publicKey,
69
+ };
70
+ }
71
+ 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 = spl_token_1.TOKEN_PROGRAM_ID, }, extParams) {
72
+ baseMintKey = (0, solana_1.pk)(baseMintKey);
73
+ quoteMintKey = (0, solana_1.pk)(quoteMintKey);
74
+ const authority = extParams.invoker.publicKey;
75
+ (0, common_1.invariant)(authority, "Undefined creator publicKey");
76
+ if (!priceOracle && oracleType && !["none", "test"].includes(oracleType)) {
77
+ throw new Error("Price oracle is required for the specified oracle type");
78
+ }
79
+ receiver = receiver ?? (0, spl_token_1.getAssociatedTokenAddressSync)(quoteMintKey, authority);
80
+ const oracle = priceOracle ?? (0, solana_2.deriveTestOraclePDA)(this.dynamicVestingId, baseMintKey, authority);
81
+ const launchpadPDA = (0, derive_accounts_js_1.deriveLaunchpadPDA)(this.program.programId, baseMintKey, nonce);
82
+ const createIx = await this.program.methods
83
+ .createLaunchpad({
84
+ nonce,
85
+ price,
86
+ individualDepositingCap,
87
+ maxDepositingCap,
88
+ depositingStartTs: new bn_js_1.default(depositingStartTs),
89
+ depositingEndTs: new bn_js_1.default(depositingEndTs),
90
+ vestingStartTs: new bn_js_1.default(vestingStartTs),
91
+ vestingEndTs: new bn_js_1.default(vestingEndTs),
92
+ vestingPeriod: new bn_js_1.default(vestingPeriod),
93
+ oracleType: (!!oracleType ? { [oracleType]: {} } : { none: {} }),
94
+ minPrice: (0, common_1.getBN)(minPrice, solana_2.constants.ALIGNED_PRECISION_FACTOR_POW),
95
+ maxPrice: (0, common_1.getBN)(maxPrice, solana_2.constants.ALIGNED_PRECISION_FACTOR_POW),
96
+ minPercentage: (0, common_1.getBN)(minPercentage, solana_2.constants.ALIGNED_PRECISION_FACTOR_POW),
97
+ maxPercentage: (0, common_1.getBN)(maxPercentage, solana_2.constants.ALIGNED_PRECISION_FACTOR_POW),
98
+ tickSize: (0, common_1.getBN)(tickSize, solana_2.constants.ALIGNED_PRECISION_FACTOR_POW),
99
+ skipInitial,
100
+ isMemoRequired,
101
+ })
102
+ .accounts({
103
+ authority,
104
+ baseMint: baseMintKey,
105
+ quoteMint: quoteMintKey,
106
+ receiver: receiver,
107
+ priceOracle: oracle,
108
+ tokenProgram: tokenProgramId,
109
+ })
110
+ .instruction();
111
+ return { ixs: [createIx], publicKey: launchpadPDA };
112
+ }
113
+ async fundLaunchpad(data, extParams) {
114
+ const { ixs } = await this.prepareFundLaunchpadInstructions(data, extParams);
115
+ const { signature } = await this.execute(ixs, extParams);
116
+ return {
117
+ ixs,
118
+ txId: signature,
119
+ };
120
+ }
121
+ async prepareFundLaunchpadInstructions({ launchpad: launchpadKey, amount, baseMint: baseMintKey, tokenProgramId = spl_token_1.TOKEN_PROGRAM_ID }, extParams) {
122
+ const authority = extParams.invoker.publicKey;
123
+ (0, common_1.invariant)(authority, "Undefined authority publicKey");
124
+ if (!baseMintKey) {
125
+ baseMintKey = (await this.getLaunchpad(launchpadKey)).baseMint;
126
+ }
127
+ const { mint } = await (0, solana_1.getMintAndProgram)(this.connection, (0, solana_1.pk)(baseMintKey));
128
+ return {
129
+ ixs: [
130
+ ...(await (0, solana_1.checkOrCreateAtaBatch)(this.connection, [(0, solana_1.pk)(launchpadKey)], (0, solana_1.pk)(baseMintKey), extParams.invoker, (0, solana_1.pk)(tokenProgramId))),
131
+ (0, spl_token_1.createTransferCheckedInstruction)((0, spl_token_1.getAssociatedTokenAddressSync)(mint.address, authority, true, (0, solana_1.pk)(tokenProgramId)), mint.address, (0, spl_token_1.getAssociatedTokenAddressSync)(mint.address, (0, solana_1.pk)(launchpadKey), true, (0, solana_1.pk)(tokenProgramId)), authority, BigInt(amount.toString()), mint.decimals, undefined, (0, solana_1.pk)(tokenProgramId)),
132
+ ],
133
+ };
134
+ }
135
+ async deposit(data, extParams) {
136
+ const { ixs } = await this.prepareDepositInstructions(data, extParams);
137
+ const { signature } = await this.execute(ixs, extParams);
138
+ return {
139
+ ixs,
140
+ txId: signature,
141
+ };
142
+ }
143
+ async prepareDepositInstructions({ launchpad: launchpadKey, quoteMint: quoteMintKey, amount, autoCap = false, memo, owner, tokenProgramId = spl_token_1.TOKEN_PROGRAM_ID, }, extParams) {
144
+ const payer = extParams.invoker.publicKey;
145
+ (0, common_1.invariant)(payer, "Undefined payer publicKey");
146
+ owner = (0, solana_1.pk)(owner ?? payer);
147
+ if (!quoteMintKey) {
148
+ quoteMintKey = (await this.getLaunchpad(launchpadKey)).quoteMint;
149
+ }
150
+ const depositPDA = (0, derive_accounts_js_1.deriveDepositPDA)(this.program.programId, (0, solana_1.pk)(launchpadKey), owner);
151
+ const ixs = [];
152
+ if (memo) {
153
+ ixs.push(new web3_js_1.TransactionInstruction({
154
+ keys: [{ pubkey: payer, isSigner: true, isWritable: true }],
155
+ data: Buffer.from(memo, "utf-8"),
156
+ programId: new web3_js_1.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),
157
+ }));
158
+ }
159
+ ixs.push(await this.program.methods
160
+ .deposit({ amount, autoCap })
161
+ .accounts({
162
+ payer,
163
+ owner: owner,
164
+ from: (0, spl_token_1.getAssociatedTokenAddressSync)((0, solana_1.pk)(quoteMintKey), payer, true, (0, solana_1.pk)(tokenProgramId)),
165
+ launchpad: launchpadKey,
166
+ tokenProgram: tokenProgramId,
167
+ })
168
+ .instruction());
169
+ return { ixs, publicKey: depositPDA };
170
+ }
171
+ async claimDeposits(data, extParams) {
172
+ const { ixs } = await this.prepareClaimDepositsInstructions(data, extParams);
173
+ const { signature } = await this.execute(ixs, extParams);
174
+ return {
175
+ ixs,
176
+ txId: signature,
177
+ };
178
+ }
179
+ async prepareClaimDepositsInstructions({ launchpad: launchpadKey, tokenProgramId = spl_token_1.TOKEN_PROGRAM_ID }, extParams) {
180
+ const authority = extParams.invoker.publicKey;
181
+ (0, common_1.invariant)(authority, "Undefined authority publicKey");
182
+ return {
183
+ ixs: [
184
+ await this.program.methods
185
+ .claimDeposits()
186
+ .accounts({
187
+ authority,
188
+ launchpad: launchpadKey,
189
+ tokenProgram: tokenProgramId,
190
+ })
191
+ .instruction(),
192
+ ],
193
+ };
194
+ }
195
+ async claimAllocatedVested(data, extParams) {
196
+ if (!extParams.computeLimit) {
197
+ extParams.computeLimit = 280000;
198
+ }
199
+ const { ixs, streamKeypair } = await this.prepareClaimAllocatedVestedInstructions(data, extParams);
200
+ const { signature } = await this.execute(ixs, extParams, streamKeypair);
201
+ return {
202
+ ixs,
203
+ txId: signature,
204
+ };
205
+ }
206
+ async prepareClaimAllocatedVestedInstructions({ launchpad: launchpadKey, baseMint: baseMintKey, owner, tokenProgramId = spl_token_1.TOKEN_PROGRAM_ID }, extParams) {
207
+ const payer = extParams.invoker.publicKey;
208
+ (0, common_1.invariant)(payer, "Undefined payer publicKey");
209
+ owner = (0, solana_1.pk)(owner ?? payer);
210
+ if (!baseMintKey) {
211
+ baseMintKey = (await this.getLaunchpad(launchpadKey)).baseMint;
212
+ }
213
+ const streamKeypair = web3_js_1.Keypair.generate();
214
+ const streamKey = streamKeypair.publicKey;
215
+ const proxyMetadataKey = (0, solana_2.deriveContractPDA)(this.dynamicVestingId, streamKeypair.publicKey);
216
+ const proxyTokensKey = (0, spl_token_1.getAssociatedTokenAddressSync)((0, solana_1.pk)(baseMintKey), proxyMetadataKey, true);
217
+ const escrowKey = (0, solana_2.deriveEscrowPDA)(this.vestingId, streamKeypair.publicKey);
218
+ const depositKey = (0, derive_accounts_js_1.deriveDepositPDA)(this.program.programId, (0, solana_1.pk)(launchpadKey), owner);
219
+ const ix = await this.program.methods
220
+ .claimAllocatedVested()
221
+ .accounts({
222
+ depositAccount: depositKey,
223
+ payer,
224
+ proxyMetadata: proxyMetadataKey,
225
+ proxyTokens: proxyTokensKey,
226
+ streamMetadata: streamKey,
227
+ escrowTokens: escrowKey,
228
+ withdrawor: solana_2.constants.WITHDRAWOR_PUBLIC_KEY,
229
+ feeOracle: solana_2.constants.FEE_ORACLE_PUBLIC_KEY,
230
+ tokenProgram: tokenProgramId,
231
+ })
232
+ .accountsPartial({
233
+ streamflowProgram: this.vestingId,
234
+ proxyProgram: this.dynamicVestingId,
235
+ })
236
+ .instruction();
237
+ return { ixs: [ix], streamKeypair };
238
+ }
239
+ async execute(ixs, extParams, ...partialSigners) {
240
+ ixs = [...(0, solana_1.prepareBaseInstructions)(this.connection, extParams), ...ixs];
241
+ const { tx, hash, context } = await (0, solana_1.prepareTransaction)(this.connection, ixs, extParams.invoker.publicKey, this.getCommitment(), ...partialSigners);
242
+ try {
243
+ const signature = await (0, solana_1.signAndExecuteTransaction)(this.connection, extParams.invoker, tx, {
244
+ hash,
245
+ context,
246
+ commitment: this.getCommitment(),
247
+ }, { sendThrottler: this.sendThrottler });
248
+ return { signature };
249
+ }
250
+ catch (err) {
251
+ if (err instanceof Error) {
252
+ const parsed = (0, anchor_1.translateError)(err, (0, anchor_1.parseIdlErrors)(this.program.idl));
253
+ if (parsed) {
254
+ throw new common_1.ContractError(err, parsed.name, parsed.message);
255
+ }
256
+ }
257
+ throw err;
258
+ }
259
+ }
260
+ }
261
+ exports.SolanaLaunchpadClient = SolanaLaunchpadClient;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PROGRAM_ID = exports.LAUNCHPAD_BYTE_OFFSETS = exports.LAUNCHPAD_QUOTE_MINT_OFFSET = exports.LAUNCHPAD_BASE_MINT_OFFSET = exports.ANCHOR_DISCRIMINATOR_OFFSET = exports.DEPOSIT_PREFIX = exports.VAULT_PREFIX = exports.LAUNCHPAD_PREFIX = void 0;
4
+ const common_1 = require("@streamflow/common");
5
+ exports.LAUNCHPAD_PREFIX = Buffer.from("launchpad", "utf-8");
6
+ exports.VAULT_PREFIX = Buffer.from("vault", "utf-8");
7
+ exports.DEPOSIT_PREFIX = Buffer.from("deposit", "utf-8");
8
+ exports.ANCHOR_DISCRIMINATOR_OFFSET = 8;
9
+ exports.LAUNCHPAD_BASE_MINT_OFFSET = exports.ANCHOR_DISCRIMINATOR_OFFSET + 8;
10
+ exports.LAUNCHPAD_QUOTE_MINT_OFFSET = exports.ANCHOR_DISCRIMINATOR_OFFSET + 32;
11
+ exports.LAUNCHPAD_BYTE_OFFSETS = {
12
+ baseMint: exports.LAUNCHPAD_BASE_MINT_OFFSET,
13
+ quoteMint: exports.LAUNCHPAD_QUOTE_MINT_OFFSET,
14
+ };
15
+ exports.PROGRAM_ID = {
16
+ [common_1.ICluster.Mainnet]: "BUYfFzeTWeRW5JrPjCutbsvzjA5ERS8EnGujJjfmnJu6",
17
+ [common_1.ICluster.Devnet]: "BUYfFzeTWeRW5JrPjCutbsvzjA5ERS8EnGujJjfmnJu6",
18
+ [common_1.ICluster.Testnet]: "BUYfFzeTWeRW5JrPjCutbsvzjA5ERS8EnGujJjfmnJu6",
19
+ [common_1.ICluster.Local]: "BUYfFzeTWeRW5JrPjCutbsvzjA5ERS8EnGujJjfmnJu6",
20
+ };