@forgedevv/core 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +227 -4
- package/README.md +4 -3
- package/dist/addresses.d.ts +73 -7
- package/dist/addresses.js +96 -5
- package/dist/claims.d.ts +43 -6
- package/dist/claims.js +75 -16
- package/dist/config.d.ts +48 -37
- package/dist/config.js +282 -52
- package/dist/constants.d.ts +16 -0
- package/dist/constants.js +20 -0
- package/dist/index.d.ts +9 -5
- package/dist/index.js +15 -4
- package/dist/jupiter-referral.d.ts +334 -0
- package/dist/jupiter-referral.js +666 -0
- package/dist/launch-metadata.d.ts +5 -1
- package/dist/launch-metadata.js +2 -0
- package/dist/meteora-referral.d.ts +119 -0
- package/dist/meteora-referral.js +188 -0
- package/dist/payments.d.ts +17 -0
- package/dist/payments.js +20 -2
- package/dist/pool.d.ts +108 -17
- package/dist/pool.js +237 -60
- package/dist/position-claims.d.ts +215 -0
- package/dist/position-claims.js +457 -0
- package/dist/priority-fee.d.ts +202 -0
- package/dist/priority-fee.js +322 -0
- package/dist/reads.d.ts +20 -0
- package/dist/reads.js +39 -2
- package/dist/settings.d.ts +73 -0
- package/dist/settings.js +119 -0
- package/dist/swap.d.ts +95 -23
- package/dist/swap.js +144 -30
- package/dist/tx.d.ts +2 -0
- package/dist/tx.js +4 -2
- package/dist/validate.d.ts +14 -1
- package/dist/validate.js +86 -6
- package/package.json +3 -2
package/dist/pool.d.ts
CHANGED
|
@@ -33,12 +33,28 @@
|
|
|
33
33
|
*
|
|
34
34
|
* `buildUserCoinLaunchTx` is the same launch for a coin created by a user on the client's
|
|
35
35
|
* launchpad config: the user is pool creator, rent payer, fee payer and buyer, the mint is the
|
|
36
|
-
* only other signer.
|
|
36
|
+
* only other signer. Its first buy pays the FORGE platform fee (0.3%, rounded up) like any swap
|
|
37
|
+
* built by core: one SOL transfer to `FORGE_PLATFORM_FEE_WALLET`, the last instruction.
|
|
38
|
+
*
|
|
39
|
+
* Both builders compare the on-chain config with what core builds for it, field by field
|
|
40
|
+
* (`onchainConfigMismatches` in config.ts), before building anything.
|
|
41
|
+
*
|
|
42
|
+
* Priority fee (`priority` setting, priority-fee.ts): the price is read from the recent fees of
|
|
43
|
+
* the launch's writable accounts and bounded by the setting. The compute budget instructions come
|
|
44
|
+
* right after the nonce advance: `setComputeUnitLimit` then `setComputeUnitPrice`. The launchpad
|
|
45
|
+
* coin launch is tight (`LAUNCH_METADATA_BUDGET_BYTES`): when both do not fit in 1,232 bytes, the
|
|
46
|
+
* price goes alone (4 bytes more than the limit it replaces; the fee is then bounded for
|
|
47
|
+
* `MAX_TRANSACTION_COMPUTE_UNITS`, the most the runtime can apply without a limit), and when even
|
|
48
|
+
* that does not fit, the launch keeps its shape without a price (`priorityFeePlacement`
|
|
49
|
+
* `omitted_for_size`): the metadata budget accepted at `/v1/configs` never shrinks. That launch
|
|
50
|
+
* uses a durable nonce, so it stays valid until it lands. The user coin launch always fits both.
|
|
37
51
|
*/
|
|
38
52
|
import { type PoolConfig, type SwapQuoteConfig } from '@meteora-ag/dynamic-bonding-curve-sdk';
|
|
39
53
|
import { PublicKey, Transaction, type Connection } from '@solana/web3.js';
|
|
40
|
-
import type { OwnerTransactionSummary } from '@forge/shared';
|
|
41
|
-
import type
|
|
54
|
+
import type { LaunchpadSpec, OwnerTransactionSummary } from '@forge/shared';
|
|
55
|
+
import { type AddressEnv } from './addresses.js';
|
|
56
|
+
import { type OnchainConfigExpectation } from './config.js';
|
|
57
|
+
import { type PriorityFeeQuote, type PriorityFeeSetting } from './priority-fee.js';
|
|
42
58
|
export { LAUNCH_METADATA_BUDGET_BYTES, LaunchCoinError, MAX_FIRST_BUY_LAMPORTS, METADATA_LIMITS, assertFirstBuyLamports, assertLaunchMetadata, assertSpecLaunchable, launchMetadataBytes, type LaunchCoinErrorCode, } from './launch-metadata.js';
|
|
43
59
|
/**
|
|
44
60
|
* Compute unit limit of the launch transaction: 190,840 CU measured on devnet with the durable
|
|
@@ -96,6 +112,12 @@ export interface BuildLaunchCoinTxParams {
|
|
|
96
112
|
slippageBps?: number;
|
|
97
113
|
/** Durable nonce: the transaction then stays valid until the nonce advances. */
|
|
98
114
|
durableNonce?: DurableNonceParam;
|
|
115
|
+
/**
|
|
116
|
+
* The launchpad spec the coin config was built from. When given, the on-chain config must be
|
|
117
|
+
* exactly `buildLaunchpadCoinConfig(spec)` (`assertLaunchCoinConfig`); without it, its trading
|
|
118
|
+
* fee and anti-sniper flag are only bounded. Recommended.
|
|
119
|
+
*/
|
|
120
|
+
spec?: LaunchpadSpec;
|
|
99
121
|
/**
|
|
100
122
|
* Who pays the pool, mint, metadata and vault accounts and the pool creation fee (default
|
|
101
123
|
* `owner`; `creator` only on a config whose pool creation fee is 0).
|
|
@@ -115,7 +137,19 @@ export interface BuildLaunchCoinTxParams {
|
|
|
115
137
|
computeUnitLimit?: number;
|
|
116
138
|
/** Priority fee, micro-lamports per compute unit (default 0). */
|
|
117
139
|
computeUnitPriceMicroLamports?: number;
|
|
140
|
+
/**
|
|
141
|
+
* Priority fee read from the cluster and bounded by this setting (`{}` = the defaults, at most
|
|
142
|
+
* 0.0005 SOL), see the top of this file for its placement. Not with
|
|
143
|
+
* `computeUnitPriceMicroLamports`.
|
|
144
|
+
*/
|
|
145
|
+
priority?: PriorityFeeSetting;
|
|
118
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Where the priority fee went: with the unit limit (`limit_and_price`, also the shape without a
|
|
149
|
+
* priority fee), alone because both did not fit (`price_only`), or left out because even the
|
|
150
|
+
* price alone did not fit (`omitted_for_size`).
|
|
151
|
+
*/
|
|
152
|
+
export type PriorityFeePlacement = 'limit_and_price' | 'price_only' | 'omitted_for_size';
|
|
119
153
|
/** Lamport amounts, as bigint. */
|
|
120
154
|
export interface LaunchCoinCosts {
|
|
121
155
|
/** SOL swapped into the pool by the first buy. */
|
|
@@ -137,6 +171,11 @@ export interface LaunchCoinCosts {
|
|
|
137
171
|
ownerTemporaryLamports: bigint;
|
|
138
172
|
/** Signature fees + priority fee (paid by the owner, the fee payer). */
|
|
139
173
|
networkFeeLamports: bigint;
|
|
174
|
+
/**
|
|
175
|
+
* FORGE platform fee on the first buy (`PLATFORM_FEE_BPS` of it, rounded up), paid by the owner
|
|
176
|
+
* to `FORGE_PLATFORM_FEE_WALLET`. Only set by `buildUserCoinLaunchTx`.
|
|
177
|
+
*/
|
|
178
|
+
platformFeeLamports?: bigint;
|
|
140
179
|
/** `cluster` = `getFeeForMessage`; `estimate` = signatures x 5000 + priority fee. */
|
|
141
180
|
networkFeeSource: 'cluster' | 'estimate';
|
|
142
181
|
/** Everything the owner's balance decreases by. */
|
|
@@ -179,8 +218,15 @@ export interface LaunchCoinSummary {
|
|
|
179
218
|
recentBlockhash: string;
|
|
180
219
|
/** Null with a durable nonce (it does not expire with block height). */
|
|
181
220
|
lastValidBlockHeight: number | null;
|
|
221
|
+
/**
|
|
222
|
+
* Compute unit limit requested; the transaction sets it unless `priorityFeePlacement` is
|
|
223
|
+
* `price_only` (the runtime default then applies, bounded by `MAX_TRANSACTION_COMPUTE_UNITS`).
|
|
224
|
+
*/
|
|
182
225
|
computeUnitLimit: number;
|
|
183
226
|
computeUnitPriceMicroLamports: number;
|
|
227
|
+
/** The priority fee (price, fee, cap; `fixed` without a `priority` setting). */
|
|
228
|
+
priorityFee: PriorityFeeQuote;
|
|
229
|
+
priorityFeePlacement: PriorityFeePlacement;
|
|
184
230
|
/** Signers on the signer side (creator, mint, nonce authority if distinct), then the owner. */
|
|
185
231
|
signerSideSigners: PublicKey[];
|
|
186
232
|
ownerSigner: PublicKey;
|
|
@@ -193,13 +239,21 @@ export interface LaunchCoinTx {
|
|
|
193
239
|
}
|
|
194
240
|
/**
|
|
195
241
|
* Checks that an on-chain config is the launchpad coin config of `owner` and that it is safe to
|
|
196
|
-
* launch the coin on it
|
|
197
|
-
*
|
|
198
|
-
*
|
|
242
|
+
* launch the coin on it. Besides the essential checks (SOL quote, SPL token, first swap at the
|
|
243
|
+
* minimum fee, fee scheduler, DAMM v2 at exactly 10 SOL), EVERY field is compared with what core
|
|
244
|
+
* builds for a launchpad coin config (`onchainConfigMismatches`): fee claimer and leftover
|
|
245
|
+
* receiver = owner, FORGE creator share, the 75 / 25 permanently locked liquidity, no pool
|
|
246
|
+
* creation fee, immutable metadata, the exact fee schedule, no migration fee, no locked vesting,
|
|
247
|
+
* FORGE's supply and curve, timestamp activation.
|
|
248
|
+
*
|
|
249
|
+
* With `spec` (the spec the config was built from), the reference is exactly
|
|
250
|
+
* `buildLaunchpadCoinConfig(spec)`; without it, the trading fee and the anti-sniper flag are read
|
|
251
|
+
* from the config and only have to be values a FORGE spec can hold (linear schedule, whole fee of
|
|
252
|
+
* 50..200 bps). Pass the spec whenever it is known.
|
|
199
253
|
*
|
|
200
254
|
* @throws LaunchCoinError `CONFIG_MISMATCH` listing every mismatch.
|
|
201
255
|
*/
|
|
202
|
-
export declare function assertLaunchCoinConfig(config: PoolConfig, owner: PublicKey): void;
|
|
256
|
+
export declare function assertLaunchCoinConfig(config: PoolConfig, owner: PublicKey, spec?: LaunchpadSpec): void;
|
|
203
257
|
/** The quote inputs of a pool config, for a pool that does not exist yet. */
|
|
204
258
|
export declare function quoteConfigFromPoolConfig(config: PoolConfig): SwapQuoteConfig;
|
|
205
259
|
/**
|
|
@@ -229,13 +283,34 @@ export interface BuildUserCoinLaunchTxParams {
|
|
|
229
283
|
/** Slippage on the first buy (default 100 bps, at most 1000). */
|
|
230
284
|
slippageBps?: number;
|
|
231
285
|
/**
|
|
232
|
-
*
|
|
233
|
-
*
|
|
286
|
+
* Environment to read `FORGE_PLATFORM_FEE_WALLET` from (defaults to `process.env`; a browser
|
|
287
|
+
* passes its public copy explicitly). Read only when a platform fee is charged.
|
|
234
288
|
*/
|
|
235
289
|
env?: AddressEnv;
|
|
290
|
+
/**
|
|
291
|
+
* Charge the FORGE platform fee on the first buy (default `true`): `PLATFORM_FEE_BPS` (30 bps)
|
|
292
|
+
* of `firstBuyLamports`, rounded up to the lamport (`platformFeeLamports`), as ONE SystemProgram
|
|
293
|
+
* transfer from the wallet to `FORGE_PLATFORM_FEE_WALLET`, the last instruction. Nothing is
|
|
294
|
+
* added when there is no first buy. `false` only for tools that must reproduce a launch without
|
|
295
|
+
* it.
|
|
296
|
+
*/
|
|
297
|
+
chargePlatformFee?: boolean;
|
|
298
|
+
/**
|
|
299
|
+
* What the on-chain launchpad config must be, compared field by field
|
|
300
|
+
* (`assertUserCoinConfig`): the owner wallet (fee claimer and leftover receiver), the pool
|
|
301
|
+
* creation fee, or the full spec. Without it, every fixed FORGE setting is still compared and
|
|
302
|
+
* the spec fields only have to be within the client bounds.
|
|
303
|
+
*/
|
|
304
|
+
expectedConfig?: OnchainConfigExpectation;
|
|
236
305
|
computeUnitLimit?: number;
|
|
237
306
|
/** Priority fee, micro-lamports per compute unit (default 0). */
|
|
238
307
|
computeUnitPriceMicroLamports?: number;
|
|
308
|
+
/**
|
|
309
|
+
* Priority fee read from the cluster and bounded by this setting (`{}` = the defaults, at most
|
|
310
|
+
* 0.0005 SOL): `setComputeUnitLimit` then `setComputeUnitPrice`, first. Not with
|
|
311
|
+
* `computeUnitPriceMicroLamports`.
|
|
312
|
+
*/
|
|
313
|
+
priority?: PriorityFeeSetting;
|
|
239
314
|
}
|
|
240
315
|
export interface UserCoinLaunchSummary {
|
|
241
316
|
config: PublicKey;
|
|
@@ -252,16 +327,24 @@ export interface UserCoinLaunchSummary {
|
|
|
252
327
|
expectedTokensOut: bigint;
|
|
253
328
|
minimumTokensOut: bigint;
|
|
254
329
|
slippageBps: number;
|
|
330
|
+
/** FORGE platform fee transferred by the wallet (0 without a first buy or when not charged). */
|
|
331
|
+
platformFeeLamports: bigint;
|
|
332
|
+
/** Recipient of the platform fee transfer, or null when there is none. */
|
|
333
|
+
platformFeeWallet: PublicKey | null;
|
|
255
334
|
/**
|
|
256
335
|
* Same figures as `LaunchCoinCosts`, read the same way: the `owner*` fields are the wallet's
|
|
257
|
-
* (it pays everything, including the pool accounts
|
|
258
|
-
* `creatorTotalLamports` is 0 because no separate creator wallet pays anything.
|
|
336
|
+
* (it pays everything, including the pool accounts, the pool creation fee and the platform
|
|
337
|
+
* fee); `creatorTotalLamports` is 0 because no separate creator wallet pays anything.
|
|
259
338
|
*/
|
|
260
339
|
costs: LaunchCoinCosts;
|
|
261
340
|
recentBlockhash: string;
|
|
262
341
|
lastValidBlockHeight: number;
|
|
263
342
|
computeUnitLimit: number;
|
|
264
343
|
computeUnitPriceMicroLamports: number;
|
|
344
|
+
/** The priority fee (price, fee, cap; `fixed` without a `priority` setting). */
|
|
345
|
+
priorityFee: PriorityFeeQuote;
|
|
346
|
+
/** `limit_and_price`, or `omitted_for_size` if a priced launch would not fit (it always does). */
|
|
347
|
+
priorityFeePlacement: PriorityFeePlacement;
|
|
265
348
|
/** Required signers in message order: the wallet (fee payer) then the mint. */
|
|
266
349
|
signers: PublicKey[];
|
|
267
350
|
txBytes: number;
|
|
@@ -272,20 +355,28 @@ export interface UserCoinLaunchTx {
|
|
|
272
355
|
summary: UserCoinLaunchSummary;
|
|
273
356
|
}
|
|
274
357
|
/**
|
|
275
|
-
* Checks that an on-chain config
|
|
276
|
-
* quote, SPL token program for both tokens, `enableFirstSwapWithMinFee
|
|
277
|
-
*
|
|
358
|
+
* Checks that an on-chain config is a FORGE launchpad config a user coin can be launched on:
|
|
359
|
+
* the essential checks (SOL quote, SPL token program for both tokens, `enableFirstSwapWithMinFee`,
|
|
360
|
+
* fee scheduler, DAMM v2 at exactly 10 SOL), then EVERY field compared with what core builds for
|
|
361
|
+
* a launchpad config (`onchainConfigMismatches`): liquidity split following the creator share,
|
|
362
|
+
* immutable metadata, the exact fee schedule, no migration fee, no locked vesting, FORGE's supply
|
|
363
|
+
* and curve, timestamp activation. `expected` pins the owner wallet (fee claimer and leftover
|
|
364
|
+
* receiver), the pool creation fee, or the whole spec; without it the spec fields only have to be
|
|
365
|
+
* within the client bounds and the leftover receiver must be the fee claimer.
|
|
278
366
|
*
|
|
279
367
|
* @throws LaunchCoinError `CONFIG_MISMATCH` listing every mismatch.
|
|
280
368
|
*/
|
|
281
|
-
export declare function assertUserCoinConfig(config: PoolConfig): void;
|
|
369
|
+
export declare function assertUserCoinConfig(config: PoolConfig, expected?: OnchainConfigExpectation): void;
|
|
282
370
|
/**
|
|
283
371
|
* Builds the launch transaction of a coin created by a user on the client's launchpad config:
|
|
284
372
|
* pool creation + the user's first buy at the minimum fee (no referral), with a compute unit limit
|
|
285
373
|
* (and a priority fee when given) and a recent blockhash. The user is pool creator, rent payer,
|
|
286
|
-
* fee payer and buyer; the mint is the only other signer. Rent is read from the cluster.
|
|
374
|
+
* fee payer and buyer; the mint is the only other signer. Rent is read from the cluster. With a
|
|
375
|
+
* first buy, the last instruction transfers the platform fee (`platformFeeLamports(firstBuy)`) to
|
|
376
|
+
* `FORGE_PLATFORM_FEE_WALLET` (see `chargePlatformFee`).
|
|
287
377
|
*
|
|
288
|
-
* @throws LaunchCoinError (typed `code`
|
|
378
|
+
* @throws LaunchCoinError (typed `code`; `PLATFORM_FEE_WALLET_NOT_READY` when the fee wallet is
|
|
379
|
+
* not rent-exempt), or ForgeAddressError when `FORGE_PLATFORM_FEE_WALLET` is missing.
|
|
289
380
|
*/
|
|
290
381
|
export declare function buildUserCoinLaunchTx(params: BuildUserCoinLaunchTxParams): Promise<UserCoinLaunchTx>;
|
|
291
382
|
/**
|