@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/claims.js
CHANGED
|
@@ -25,13 +25,21 @@
|
|
|
25
25
|
* exactly that amount of SOL to the receiver.
|
|
26
26
|
* So the payer's balance only decreases by the network fee and the one-time rent below, and the
|
|
27
27
|
* claimer's balance does not change at all when the claimer is not the payer (read-only signer).
|
|
28
|
-
* A claimer WSOL account that already holds WSOL
|
|
29
|
-
*
|
|
28
|
+
* A claimer WSOL account that already holds WSOL (anyone can send some to it) goes with the
|
|
29
|
+
* close: to the receiver when the receiver pays (accepted and counted in the summary as
|
|
30
|
+
* received, `existingWsolLamports`), back to the claimer when it pays its own claim (accepted).
|
|
31
|
+
* It is refused when the close would hand it to a payer that is neither (`claimer_wsol_not_empty`).
|
|
30
32
|
*
|
|
31
33
|
* Base side (the coin): the program needs a base token account even when there is nothing to
|
|
32
34
|
* claim (FORGE configs collect fees in SOL only). It is the receiver's associated account, created
|
|
33
35
|
* idempotently by the payer: the first claim of each pool costs the payer that account's rent
|
|
34
36
|
* (~0.00204 SOL), which stays in an account owned by the receiver (recoverable by closing it).
|
|
37
|
+
*
|
|
38
|
+
* Priority fee (`ClaimOptions.priority`, priority-fee.ts): two compute budget instructions come
|
|
39
|
+
* first, `setComputeUnitLimit` (`CLAIM_COMPUTE_UNITS`, or `POOL_CREATION_FEE_CLAIM_COMPUTE_UNITS`)
|
|
40
|
+
* then `setComputeUnitPrice`, priced from the recent fees of the claim's writable accounts and
|
|
41
|
+
* bounded by the setting; the costs (network fee, worthwhile check) count it. Without the option
|
|
42
|
+
* the claims carry no compute budget instruction, as before.
|
|
35
43
|
*/
|
|
36
44
|
import { ACCOUNT_SIZE, NATIVE_MINT, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, createAssociatedTokenAccountIdempotentInstruction, createCloseAccountInstruction, createTransferInstruction, getAssociatedTokenAddressSync, unpackAccount, } from '@solana/spl-token';
|
|
37
45
|
import { PublicKey, SystemProgram, Transaction, } from '@solana/web3.js';
|
|
@@ -39,9 +47,18 @@ import { CreatorService, DYNAMIC_BONDING_CURVE_PROGRAM_ID, PartnerService, Token
|
|
|
39
47
|
import BN from 'bn.js';
|
|
40
48
|
import { getMultisigVault } from './addresses.js';
|
|
41
49
|
import { SOL_QUOTE_MINT } from './constants.js';
|
|
50
|
+
import { estimatePriorityFee, priorityFeeInstructions, resolvePriorityFeePolicy, writableAccountsOf, } from './priority-fee.js';
|
|
42
51
|
import { READ_COMMITMENT, feeMetrics, getDbcPoolState, poolCreationFeeStatus, retryRpc, } from './reads.js';
|
|
43
|
-
/** Base fee per signature (lamports);
|
|
52
|
+
/** Base fee per signature (lamports); a priority fee comes on top with `ClaimOptions.priority`. */
|
|
44
53
|
export const CLAIM_LAMPORTS_PER_SIGNATURE = 5000n;
|
|
54
|
+
/**
|
|
55
|
+
* Compute unit limit of a trading fee claim with a priority fee: two idempotent token account
|
|
56
|
+
* creations (about 25,000 CU each when they create), the DBC claim (two token transfers and its
|
|
57
|
+
* event), a token self-transfer, a close and a SOL transfer, about 100,000 CU at most: 2x margin.
|
|
58
|
+
*/
|
|
59
|
+
export const CLAIM_COMPUTE_UNITS = 200_000;
|
|
60
|
+
/** Compute unit limit of a pool creation fee claim (one DBC instruction moving lamports). */
|
|
61
|
+
export const POOL_CREATION_FEE_CLAIM_COMPUTE_UNITS = 100_000;
|
|
45
62
|
// Pool creation fee helpers live in reads.ts (CoinOfConfig uses them); re-exported here.
|
|
46
63
|
export { PARTNER_POOL_CREATION_FEE_CLAIMED_BIT, partnerPoolCreationFeeShare } from './reads.js';
|
|
47
64
|
export class ClaimError extends Error {
|
|
@@ -52,6 +69,23 @@ export class ClaimError extends Error {
|
|
|
52
69
|
this.code = code;
|
|
53
70
|
}
|
|
54
71
|
}
|
|
72
|
+
/** Checks `options.priority` before any network call. @throws RangeError. */
|
|
73
|
+
export function assertClaimPriority(options) {
|
|
74
|
+
if (options.priority !== undefined)
|
|
75
|
+
resolvePriorityFeePolicy(options.priority);
|
|
76
|
+
}
|
|
77
|
+
/** The priced compute budget of a claim, or nothing without `priority`. */
|
|
78
|
+
export async function claimPriorityFee(connection, instructions, computeUnitLimit, priority) {
|
|
79
|
+
if (priority === undefined)
|
|
80
|
+
return { quote: null, instructions: [] };
|
|
81
|
+
const quote = await estimatePriorityFee({
|
|
82
|
+
connection,
|
|
83
|
+
writableAccounts: writableAccountsOf(instructions),
|
|
84
|
+
computeUnitLimit,
|
|
85
|
+
setting: priority,
|
|
86
|
+
});
|
|
87
|
+
return { quote, instructions: priorityFeeInstructions(quote) };
|
|
88
|
+
}
|
|
55
89
|
// ---------------------------------------------------------------------------------------------
|
|
56
90
|
// Pure helpers
|
|
57
91
|
// ---------------------------------------------------------------------------------------------
|
|
@@ -66,12 +100,15 @@ export function minimumWorthwhileClaimLamports(costs, minNetLamports = 0n) {
|
|
|
66
100
|
export function isClaimWorthwhile(summary, minNetLamports = 0n) {
|
|
67
101
|
return summary.receiverQuoteLamports > 0n && summary.netLamports > minNetLamports;
|
|
68
102
|
}
|
|
69
|
-
|
|
103
|
+
/** @throws ClaimError `unsupported_quote_mint` unless the pool is quoted in SOL. */
|
|
104
|
+
export function assertSolQuotedPool(state) {
|
|
70
105
|
if (!state.config.quoteMint.equals(SOL_QUOTE_MINT)) {
|
|
71
106
|
throw new ClaimError('unsupported_quote_mint', `Pool ${state.address.toBase58()} is not quoted in SOL: FORGE pools are SOL-quoted only`);
|
|
72
107
|
}
|
|
73
108
|
}
|
|
74
|
-
|
|
109
|
+
const assertSolQuote = assertSolQuotedPool;
|
|
110
|
+
/** @throws ClaimError `invalid_receiver` for anything but a usable wallet address. */
|
|
111
|
+
export function assertClaimReceiver(receiver) {
|
|
75
112
|
if (!(receiver instanceof PublicKey)) {
|
|
76
113
|
throw new ClaimError('invalid_receiver', 'Claim receiver must be a PublicKey');
|
|
77
114
|
}
|
|
@@ -79,6 +116,7 @@ function assertReceiver(receiver) {
|
|
|
79
116
|
throw new ClaimError('invalid_receiver', 'Claim receiver is not a valid wallet');
|
|
80
117
|
}
|
|
81
118
|
}
|
|
119
|
+
const assertReceiver = assertClaimReceiver;
|
|
82
120
|
function isEmpty(amounts) {
|
|
83
121
|
return amounts.base === 0n && amounts.quote === 0n;
|
|
84
122
|
}
|
|
@@ -111,7 +149,14 @@ async function buildTradingClaim(connection, input, options) {
|
|
|
111
149
|
transaction: null,
|
|
112
150
|
lastValidBlockHeight: null,
|
|
113
151
|
skipReason: 'nothing_to_claim',
|
|
114
|
-
summary: {
|
|
152
|
+
summary: {
|
|
153
|
+
...baseSummary,
|
|
154
|
+
receiverQuoteLamports: 0n,
|
|
155
|
+
existingWsolLamports: 0n,
|
|
156
|
+
costs: ZERO_COSTS,
|
|
157
|
+
netLamports: 0n,
|
|
158
|
+
priorityFee: null,
|
|
159
|
+
},
|
|
115
160
|
};
|
|
116
161
|
}
|
|
117
162
|
const baseMint = state.virtualPool.poolState.baseMint;
|
|
@@ -136,9 +181,11 @@ async function buildTradingClaim(connection, input, options) {
|
|
|
136
181
|
retryRpc(() => connection.getMinimumBalanceForRentExemption(ACCOUNT_SIZE, commitment), options.retry),
|
|
137
182
|
]);
|
|
138
183
|
const [receiverBaseInfo, claimerWsolInfo, receiverInfo] = infos;
|
|
139
|
-
// The temporary WSOL account is closed to the payer
|
|
140
|
-
//
|
|
141
|
-
|
|
184
|
+
// The temporary WSOL account is closed to the payer. WSOL it already holds (anyone can send
|
|
185
|
+
// some, 1 lamport is enough) goes with the close: fine when the payer is the receiver (it is
|
|
186
|
+
// received) or the claimer itself (its own); refused when it would reach a third-party payer.
|
|
187
|
+
let existingWsolLamports = 0n;
|
|
188
|
+
if (claimerWsolInfo && claimerWsolInfo.owner.equals(TOKEN_PROGRAM_ID)) {
|
|
142
189
|
let amount;
|
|
143
190
|
try {
|
|
144
191
|
amount = unpackAccount(claimerWsol, claimerWsolInfo, TOKEN_PROGRAM_ID).amount;
|
|
@@ -147,9 +194,11 @@ async function buildTradingClaim(connection, input, options) {
|
|
|
147
194
|
// Not a token account (e.g. lamports sent to the address): the idempotent creation takes it.
|
|
148
195
|
amount = 0n;
|
|
149
196
|
}
|
|
150
|
-
if (amount > 0n) {
|
|
197
|
+
if (amount > 0n && !claimer.equals(payer) && !receiver.equals(payer)) {
|
|
151
198
|
throw new ClaimError('claimer_wsol_not_empty', `The claimer's WSOL account ${claimerWsol.toBase58()} holds ${amount} lamports of WSOL: unwrap it before claiming with another payer`);
|
|
152
199
|
}
|
|
200
|
+
if (receiver.equals(payer))
|
|
201
|
+
existingWsolLamports = amount;
|
|
153
202
|
}
|
|
154
203
|
if (exact && quote > 0n) {
|
|
155
204
|
const size = receiverInfo?.data.length ?? 0;
|
|
@@ -173,12 +222,13 @@ async function buildTradingClaim(connection, input, options) {
|
|
|
173
222
|
if (exact && quote > 0n) {
|
|
174
223
|
instructions.push(SystemProgram.transfer({ fromPubkey: payer, toPubkey: receiver, lamports: quote }));
|
|
175
224
|
}
|
|
225
|
+
const priority = await claimPriorityFee(connection, instructions, CLAIM_COMPUTE_UNITS, options.priority);
|
|
176
226
|
const { blockhash, lastValidBlockHeight } = await retryRpc(() => connection.getLatestBlockhash(commitment), options.retry);
|
|
177
227
|
const transaction = new Transaction({ feePayer: payer, blockhash, lastValidBlockHeight });
|
|
178
|
-
transaction.add(...instructions);
|
|
228
|
+
transaction.add(...priority.instructions, ...instructions);
|
|
179
229
|
// 4. Costs and net.
|
|
180
230
|
const signatures = BigInt(transaction.compileMessage().header.numRequiredSignatures);
|
|
181
|
-
const networkFeeLamports = signatures * CLAIM_LAMPORTS_PER_SIGNATURE;
|
|
231
|
+
const networkFeeLamports = signatures * CLAIM_LAMPORTS_PER_SIGNATURE + (priority.quote?.priorityFeeLamports ?? 0n);
|
|
182
232
|
const receiverTokenAccountRentLamports = receiverBaseInfo ? 0n : BigInt(tokenAccountRent);
|
|
183
233
|
const temporaryLamports = claimerWsolInfo ? 0n : BigInt(tokenAccountRent);
|
|
184
234
|
const payerTotalLamports = networkFeeLamports + receiverTokenAccountRentLamports;
|
|
@@ -189,11 +239,14 @@ async function buildTradingClaim(connection, input, options) {
|
|
|
189
239
|
payerTotalLamports,
|
|
190
240
|
payerRequiredBalanceLamports: payerTotalLamports + temporaryLamports,
|
|
191
241
|
};
|
|
242
|
+
const receiverQuoteLamports = quote + existingWsolLamports;
|
|
192
243
|
const summary = {
|
|
193
244
|
...baseSummary,
|
|
194
|
-
receiverQuoteLamports
|
|
245
|
+
receiverQuoteLamports,
|
|
246
|
+
existingWsolLamports,
|
|
195
247
|
costs,
|
|
196
|
-
netLamports:
|
|
248
|
+
netLamports: receiverQuoteLamports - payerTotalLamports,
|
|
249
|
+
priorityFee: priority.quote,
|
|
197
250
|
};
|
|
198
251
|
if (options.minNetLamports !== undefined && !isClaimWorthwhile(summary, options.minNetLamports)) {
|
|
199
252
|
return { transaction: null, lastValidBlockHeight: null, skipReason: 'not_worthwhile', summary };
|
|
@@ -209,6 +262,7 @@ async function buildTradingClaim(connection, input, options) {
|
|
|
209
262
|
export async function buildCreatorClaimTx(connection, params, options = {}) {
|
|
210
263
|
const commitment = options.commitment ?? READ_COMMITMENT;
|
|
211
264
|
assertReceiver(params.receiver);
|
|
265
|
+
assertClaimPriority(options);
|
|
212
266
|
if (params.expectedReceiver && !params.expectedReceiver.equals(params.receiver)) {
|
|
213
267
|
throw new ClaimError('receiver_mismatch', `Creator fees of pool ${params.pool.toBase58()} must go to ${params.expectedReceiver.toBase58()}, not ${params.receiver.toBase58()}`);
|
|
214
268
|
}
|
|
@@ -260,6 +314,7 @@ export async function buildPartnerClaimTx(connection, params, options = {}) {
|
|
|
260
314
|
const commitment = options.commitment ?? READ_COMMITMENT;
|
|
261
315
|
const receiver = params.receiver ?? params.feeClaimer;
|
|
262
316
|
assertReceiver(receiver);
|
|
317
|
+
assertClaimPriority(options);
|
|
263
318
|
const state = await getDbcPoolState(connection, params.pool, {
|
|
264
319
|
commitment,
|
|
265
320
|
retry: options.retry,
|
|
@@ -299,6 +354,7 @@ export async function buildPartnerPoolCreationFeeClaimTx(connection, params, opt
|
|
|
299
354
|
const commitment = options.commitment ?? READ_COMMITMENT;
|
|
300
355
|
const receiver = params.receiver ?? params.feeClaimer;
|
|
301
356
|
assertReceiver(receiver);
|
|
357
|
+
assertClaimPriority(options);
|
|
302
358
|
const state = await getDbcPoolState(connection, params.pool, {
|
|
303
359
|
commitment,
|
|
304
360
|
retry: options.retry,
|
|
@@ -323,6 +379,7 @@ export async function buildPartnerPoolCreationFeeClaimTx(connection, params, opt
|
|
|
323
379
|
claimableLamports: 0n,
|
|
324
380
|
networkFeeLamports: 0n,
|
|
325
381
|
netLamports: 0n,
|
|
382
|
+
priorityFee: null,
|
|
326
383
|
};
|
|
327
384
|
if (partnerShareLamports === 0n || alreadyClaimed) {
|
|
328
385
|
return {
|
|
@@ -348,11 +405,12 @@ export async function buildPartnerPoolCreationFeeClaimTx(connection, params, opt
|
|
|
348
405
|
!claimIx.keys.some((k) => k.isWritable && k.pubkey.equals(receiver))) {
|
|
349
406
|
throw new ClaimError('unexpected_sdk_instructions', 'The SDK pool creation fee claim does not have the expected instruction');
|
|
350
407
|
}
|
|
408
|
+
const priority = await claimPriorityFee(connection, [claimIx], POOL_CREATION_FEE_CLAIM_COMPUTE_UNITS, options.priority);
|
|
351
409
|
const { blockhash, lastValidBlockHeight } = await retryRpc(() => connection.getLatestBlockhash(commitment), options.retry);
|
|
352
410
|
const transaction = new Transaction({ feePayer: payer, blockhash, lastValidBlockHeight });
|
|
353
|
-
transaction.add(claimIx);
|
|
411
|
+
transaction.add(...priority.instructions, claimIx);
|
|
354
412
|
const signatures = BigInt(transaction.compileMessage().header.numRequiredSignatures);
|
|
355
|
-
const networkFeeLamports = signatures * CLAIM_LAMPORTS_PER_SIGNATURE;
|
|
413
|
+
const networkFeeLamports = signatures * CLAIM_LAMPORTS_PER_SIGNATURE + (priority.quote?.priorityFeeLamports ?? 0n);
|
|
356
414
|
return {
|
|
357
415
|
transaction,
|
|
358
416
|
lastValidBlockHeight,
|
|
@@ -362,6 +420,7 @@ export async function buildPartnerPoolCreationFeeClaimTx(connection, params, opt
|
|
|
362
420
|
claimableLamports: partnerShareLamports,
|
|
363
421
|
networkFeeLamports,
|
|
364
422
|
netLamports: partnerShareLamports - networkFeeLamports,
|
|
423
|
+
priorityFee: priority.quote,
|
|
365
424
|
},
|
|
366
425
|
};
|
|
367
426
|
}
|
package/dist/config.d.ts
CHANGED
|
@@ -25,41 +25,11 @@
|
|
|
25
25
|
* `buildLaunchpadConfig` / `buildLaunchpadCoinConfig` are pure and deterministic. Every result
|
|
26
26
|
* passes `validate.ts` before it is returned; otherwise a `ValidationError` is thrown.
|
|
27
27
|
*/
|
|
28
|
-
import {
|
|
28
|
+
import { type BuildCurveParams, type ConfigParameters, type PoolConfig, type SwapQuoteConfig } from '@meteora-ag/dynamic-bonding-curve-sdk';
|
|
29
29
|
import { PublicKey, Transaction, type Connection } from '@solana/web3.js';
|
|
30
30
|
import { LaunchpadSpec } from '@forge/shared';
|
|
31
|
-
|
|
32
|
-
export
|
|
33
|
-
readonly tokenType: TokenType.SPLToken;
|
|
34
|
-
readonly tokenBaseDecimal: TokenDecimal.SIX;
|
|
35
|
-
readonly tokenQuoteDecimal: 9;
|
|
36
|
-
readonly tokenAuthorityOption: TokenAuthorityOption.Immutable;
|
|
37
|
-
readonly totalTokenSupply: 1000000000;
|
|
38
|
-
readonly leftover: 0;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Anti-sniper fee schedule (`spec.antiSniper`): the fee starts at `startingFeeBps` and decreases
|
|
42
|
-
* linearly, in `numberOfPeriod` equal steps over `totalDurationSeconds`, to `spec.tradingFeeBps`.
|
|
43
|
-
* Within the validate.ts bounds (starting fee <= 9900 bps, duration <= 300 s).
|
|
44
|
-
*/
|
|
45
|
-
export declare const ANTI_SNIPER_FEE_SCHEDULE: {
|
|
46
|
-
readonly baseFeeMode: BaseFeeMode.FeeSchedulerLinear;
|
|
47
|
-
readonly startingFeeBps: 9900;
|
|
48
|
-
readonly numberOfPeriod: 10;
|
|
49
|
-
readonly totalDurationSeconds: 60;
|
|
50
|
-
};
|
|
51
|
-
/** Migration: DAMM v2, migrated pool fee 0.25%, no migration fee, 20% of the supply migrated. */
|
|
52
|
-
export declare const FORGE_MIGRATION_SETTINGS: {
|
|
53
|
-
readonly migrationOption: MigrationOption.MET_DAMM_V2;
|
|
54
|
-
readonly migrationFeeOption: MigrationFeeOption.FixedBps25;
|
|
55
|
-
readonly migrationFee: {
|
|
56
|
-
readonly feePercentage: 0;
|
|
57
|
-
readonly creatorFeePercentage: 0;
|
|
58
|
-
};
|
|
59
|
-
readonly percentageSupplyOnMigration: 20;
|
|
60
|
-
};
|
|
61
|
-
/** Fee scheduler periods are counted in seconds. */
|
|
62
|
-
export declare const FORGE_ACTIVATION_TYPE = ActivationType.Timestamp;
|
|
31
|
+
import { type PriorityFeeQuote, type PriorityFeeSetting } from './priority-fee.js';
|
|
32
|
+
export { ANTI_SNIPER_FEE_SCHEDULE, FORGE_ACTIVATION_TYPE, FORGE_MIGRATION_SETTINGS, FORGE_TOKEN_SETTINGS, FORGE_TOKEN_SUPPLY_RAW, forgeBaseFee, forgeFeeSchedulerParam, forgeReferenceCurve, type ForgeReferenceCurve, } from './settings.js';
|
|
63
33
|
/**
|
|
64
34
|
* Pool creation fee of the launchpad coin config: none. The only pool ever created on it is the
|
|
65
35
|
* client's own coin, paid by the client: a fee would only move the client's SOL to its own fee
|
|
@@ -69,9 +39,14 @@ export declare const FORGE_ACTIVATION_TYPE = ActivationType.Timestamp;
|
|
|
69
39
|
*/
|
|
70
40
|
export declare const LAUNCHPAD_COIN_POOL_CREATION_FEE_SOL = 0;
|
|
71
41
|
/** Pool creation fee of a config kind, in SOL. */
|
|
72
|
-
export declare function poolCreationFeeSolFor(spec: LaunchpadSpec, kind: ConfigKind): number;
|
|
42
|
+
export declare function poolCreationFeeSolFor(spec: Pick<LaunchpadSpec, 'poolCreationFeeSol'>, kind: ConfigKind): number;
|
|
73
43
|
/** Which of the two configs. */
|
|
74
44
|
export type ConfigKind = 'launchpad' | 'launchpadCoin';
|
|
45
|
+
/**
|
|
46
|
+
* The spec fields a config depends on, besides the owner wallet (a full `LaunchpadSpec` fits).
|
|
47
|
+
* Everything else in a FORGE config is a fixed setting (settings.ts).
|
|
48
|
+
*/
|
|
49
|
+
export type ConfigSpecFields = Pick<LaunchpadSpec, 'tradingFeeBps' | 'antiSniper' | 'coinCreatorSharePct' | 'poolCreationFeeSol'>;
|
|
75
50
|
/**
|
|
76
51
|
* What `createConfig` needs besides the config keypair and the payer: the SDK
|
|
77
52
|
* `ConfigParameters` plus the accounts that decide where the money goes.
|
|
@@ -92,9 +67,9 @@ export type LaunchpadConfigParams = ConfigParameters & {
|
|
|
92
67
|
*/
|
|
93
68
|
export declare function parseLaunchpadSpec(spec: unknown): LaunchpadSpec;
|
|
94
69
|
/** Creator share of the trading fees for each config kind. */
|
|
95
|
-
export declare function creatorTradingFeePercentageFor(spec: LaunchpadSpec, kind: ConfigKind): number;
|
|
96
|
-
/** The `buildCurve` input for a spec and a config kind (pure). */
|
|
97
|
-
export declare function curveParamsFor(spec:
|
|
70
|
+
export declare function creatorTradingFeePercentageFor(spec: Pick<LaunchpadSpec, 'coinCreatorSharePct'>, kind: ConfigKind): number;
|
|
71
|
+
/** The `buildCurve` input for a spec (or just its config fields) and a config kind (pure). */
|
|
72
|
+
export declare function curveParamsFor(spec: ConfigSpecFields, kind: ConfigKind): BuildCurveParams;
|
|
98
73
|
export interface ConfigParamsOptions {
|
|
99
74
|
/**
|
|
100
75
|
* Metadata URI the launchpad coin will be launched with, when known (the signer knows it from
|
|
@@ -115,6 +90,35 @@ export declare function buildConfigParams(spec: LaunchpadSpec, kind: ConfigKind,
|
|
|
115
90
|
export declare function buildLaunchpadConfig(spec: LaunchpadSpec): LaunchpadConfigParams;
|
|
116
91
|
/** Launchpad coin config: the launchpad's own coin, FORGE is the creator (25%). */
|
|
117
92
|
export declare function buildLaunchpadCoinConfig(spec: LaunchpadSpec): LaunchpadConfigParams;
|
|
93
|
+
/** What an on-chain config is expected to be, besides its kind. */
|
|
94
|
+
export interface OnchainConfigExpectation {
|
|
95
|
+
/**
|
|
96
|
+
* The spec the config was built from. Every field is then compared with
|
|
97
|
+
* `buildConfigParams(spec, kind)`, exactly what `buildCreateConfigTx` sent.
|
|
98
|
+
*/
|
|
99
|
+
spec?: LaunchpadSpec;
|
|
100
|
+
/** Fee claimer and leftover receiver (`spec.ownerWallet` when a spec is given). */
|
|
101
|
+
owner?: PublicKey;
|
|
102
|
+
/** Pool creation fee in lamports (launchpad config; the coin config never has one). */
|
|
103
|
+
poolCreationFeeLamports?: bigint;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Compares a config read from the chain with the parameters core builds for it, field by field:
|
|
107
|
+
* accounts, token, base fee (cliff, periods, period, reduction, mode), dynamic fee, creator share,
|
|
108
|
+
* pool creation fee, first swap at the minimum fee, activation, liquidity split and vesting,
|
|
109
|
+
* migration (option, fee option, threshold, migration fee percentages, migrated pool fee), locked
|
|
110
|
+
* vesting, token supply, start price and curve. The values the program derives from these
|
|
111
|
+
* (`swapBaseAmount`, `migrationBaseThreshold`, `migrationSqrtPrice`) are not compared.
|
|
112
|
+
*
|
|
113
|
+
* With `expected.spec`, the reference is `buildConfigParams(spec, kind)`. Without it, the spec
|
|
114
|
+
* fields are read from the config itself (`inferSpecFields`: they must be values a FORGE spec can
|
|
115
|
+
* hold) and every other field must be FORGE's fixed setting; the fee claimer and leftover receiver
|
|
116
|
+
* must be `expected.owner` (or, without it, the same key).
|
|
117
|
+
*
|
|
118
|
+
* @returns every mismatch, as readable messages (on-chain values are public); empty when the config
|
|
119
|
+
* is exactly a FORGE config of this kind.
|
|
120
|
+
*/
|
|
121
|
+
export declare function onchainConfigMismatches(config: PoolConfig, kind: ConfigKind, expected?: OnchainConfigExpectation): string[];
|
|
118
122
|
export interface FirstBuyQuote {
|
|
119
123
|
/** Raw base units (6 decimals) delivered by the first buy. */
|
|
120
124
|
tokensOut: bigint;
|
|
@@ -167,6 +171,11 @@ export interface BuildCreateConfigTxParams {
|
|
|
167
171
|
payer: PublicKey;
|
|
168
172
|
/** Priority fee, in micro-lamports per compute unit (default 0). */
|
|
169
173
|
computeUnitPriceMicroLamports?: number;
|
|
174
|
+
/**
|
|
175
|
+
* Priority fee read from the cluster for the payer and the config account, bounded by this
|
|
176
|
+
* setting (priority-fee.ts). Not with `computeUnitPriceMicroLamports`.
|
|
177
|
+
*/
|
|
178
|
+
priority?: PriorityFeeSetting;
|
|
170
179
|
/** Blockhash to use; fetched from the cluster when absent. */
|
|
171
180
|
recentBlockhash?: {
|
|
172
181
|
blockhash: string;
|
|
@@ -184,6 +193,8 @@ export interface CreateConfigTx {
|
|
|
184
193
|
lastValidBlockHeight: number;
|
|
185
194
|
/** Who must sign: the payer (fee payer) and the config keypair. */
|
|
186
195
|
signers: PublicKey[];
|
|
196
|
+
/** The priority fee (price, fee, cap; `fixed` without a `priority` setting). */
|
|
197
|
+
priorityFee: PriorityFeeQuote;
|
|
187
198
|
}
|
|
188
199
|
/**
|
|
189
200
|
* Unsigned transaction creating one of the two configs (`createConfig`). The parameters are
|