@masterpeach/launchpad-sdk 0.0.0-experimental-20260818121657
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 +262 -0
- package/README.zh-CN.md +242 -0
- package/dist/abi/index.cjs +2786 -0
- package/dist/abi/index.cjs.map +1 -0
- package/dist/abi/index.d.cts +2121 -0
- package/dist/abi/index.d.ts +2121 -0
- package/dist/abi/index.js +19 -0
- package/dist/abi/index.js.map +1 -0
- package/dist/chunk-PGZCTPUB.js +127 -0
- package/dist/chunk-PGZCTPUB.js.map +1 -0
- package/dist/chunk-SH2Y5F5L.js +2754 -0
- package/dist/chunk-SH2Y5F5L.js.map +1 -0
- package/dist/core.cjs +163 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +48 -0
- package/dist/core.d.ts +48 -0
- package/dist/core.js +27 -0
- package/dist/core.js.map +1 -0
- package/dist/index.cjs +4420 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1273 -0
- package/dist/index.d.ts +1273 -0
- package/dist/index.js +1840 -0
- package/dist/index.js.map +1 -0
- package/dist/transaction-BiLcoXyx.d.cts +13 -0
- package/dist/transaction-BiLcoXyx.d.ts +13 -0
- package/package.json +81 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1273 @@
|
|
|
1
|
+
import { Address, Hex, PublicClient, BlockTag, WalletClient, TransactionReceipt, Hash } from 'viem';
|
|
2
|
+
import { S as SdkTransactionResult } from './transaction-BiLcoXyx.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Addresses of a single, version-scoped Launchpad deployment. Every field is scoped to one
|
|
6
|
+
* `chainId + portal`; a Portal redeployment is a new deployment, never an in-place upgrade.
|
|
7
|
+
* The bonding curve, migrator, and future DEX router are distinct modules and must not be
|
|
8
|
+
* conflated into a single "router" slot.
|
|
9
|
+
*/
|
|
10
|
+
interface LaunchpadContracts {
|
|
11
|
+
readonly portal: Address;
|
|
12
|
+
readonly tokenFactory: Address;
|
|
13
|
+
readonly curve: Address;
|
|
14
|
+
readonly migrator: Address;
|
|
15
|
+
readonly liquidityLocker: Address;
|
|
16
|
+
readonly quoteToken: Address;
|
|
17
|
+
readonly v3Factory?: Address;
|
|
18
|
+
readonly positionManager?: Address;
|
|
19
|
+
/** Only configured once a graduated-execution router adapter has been audited. */
|
|
20
|
+
readonly dexRouter?: Address;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A Launchpad protocol deployment traceable to an exact contract revision. The runtime code hash
|
|
24
|
+
* and commits let {@link verifyLaunchpadDeployment} prove the registered addresses match on-chain
|
|
25
|
+
* state before any read or write is trusted.
|
|
26
|
+
*/
|
|
27
|
+
interface LaunchpadDeployment {
|
|
28
|
+
readonly chainId: number;
|
|
29
|
+
readonly contractVersion: string;
|
|
30
|
+
readonly contracts: LaunchpadContracts;
|
|
31
|
+
readonly deploymentBlock: bigint;
|
|
32
|
+
readonly artifactCommit: string;
|
|
33
|
+
readonly sourceCommit: string;
|
|
34
|
+
readonly portalRuntimeCodeHash: Hex;
|
|
35
|
+
}
|
|
36
|
+
type LaunchpadDeploymentRegistry = Readonly<Record<number, LaunchpadDeployment>>;
|
|
37
|
+
/**
|
|
38
|
+
* Raised when supplied deployment material fails structural validation. Mirrors the plain-`Error`
|
|
39
|
+
* shape of `InvalidLendingDomainError` and `InvalidLaunchpadChainConfigError`; chain resolution
|
|
40
|
+
* reuses the shared `UnsupportedChainError` instead.
|
|
41
|
+
*/
|
|
42
|
+
declare class InvalidLaunchpadDeploymentError extends Error {
|
|
43
|
+
readonly field: string;
|
|
44
|
+
constructor(field: string, message: string);
|
|
45
|
+
}
|
|
46
|
+
/** Validates, normalizes, and deep-freezes a caller-supplied Launchpad deployment. */
|
|
47
|
+
declare function defineLaunchpadDeployment(input: LaunchpadDeployment): Readonly<LaunchpadDeployment>;
|
|
48
|
+
/**
|
|
49
|
+
* Validates and freezes a chainId-keyed deployment registry, rejecting any entry whose key does
|
|
50
|
+
* not match its own `chainId`.
|
|
51
|
+
*/
|
|
52
|
+
declare function defineLaunchpadDeploymentRegistry(input: Readonly<Record<number, LaunchpadDeployment>>): LaunchpadDeploymentRegistry;
|
|
53
|
+
/**
|
|
54
|
+
* Built-in registry of production Launchpad deployments. It stays empty until a deployment has
|
|
55
|
+
* passed RPC bytecode and binding verification; testnet material is exported separately as an
|
|
56
|
+
* explicitly named development configuration.
|
|
57
|
+
*/
|
|
58
|
+
declare const launchpadDeploymentRegistry: LaunchpadDeploymentRegistry;
|
|
59
|
+
/** Resolves a verified deployment or throws {@link UnsupportedChainError}. */
|
|
60
|
+
declare function resolveLaunchpadDeployment(registry: LaunchpadDeploymentRegistry, chainId: number): Readonly<LaunchpadDeployment>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Block selector threaded through every read so a page can pin token state, quotes, balances, and
|
|
64
|
+
* allowances to one block instead of stitching together values from different heights.
|
|
65
|
+
*/
|
|
66
|
+
interface LaunchpadReadOptions {
|
|
67
|
+
readonly blockNumber?: bigint;
|
|
68
|
+
readonly blockTag?: BlockTag;
|
|
69
|
+
}
|
|
70
|
+
/** Public-client scope for a single verified deployment. */
|
|
71
|
+
interface LaunchpadActionContext {
|
|
72
|
+
readonly publicClient: PublicClient;
|
|
73
|
+
readonly deployment: LaunchpadDeployment;
|
|
74
|
+
}
|
|
75
|
+
/** Adds the signer required for write paths. Chain agreement is re-checked at call time. */
|
|
76
|
+
interface LaunchpadWriteActionContext extends LaunchpadActionContext {
|
|
77
|
+
readonly walletClient: WalletClient;
|
|
78
|
+
}
|
|
79
|
+
/** Chain-scoped ERC-20 asset reference. */
|
|
80
|
+
interface LaunchpadAssetRef {
|
|
81
|
+
readonly address: Address;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Stable lifecycle phase. Maps `Portal.TokenState.status` (`INVALID=0`, `TRADING=1`,
|
|
86
|
+
* `MIGRATING=2`, `DEX=3`) onto names that do not leak the raw enum ordering to consumers.
|
|
87
|
+
*/
|
|
88
|
+
type LaunchpadPhase = "invalid" | "bonding" | "migrating" | "graduated";
|
|
89
|
+
/**
|
|
90
|
+
* Token-level pause state. `Portal.setTokenPause` uses `0=active`, `1=buy paused (sell allowed)`,
|
|
91
|
+
* `2=all curve trades paused`.
|
|
92
|
+
*/
|
|
93
|
+
type LaunchpadPauseMode = "active" | "buyPaused" | "tradingPaused";
|
|
94
|
+
/** Chain-scoped token state with every amount expressed as `bigint`. */
|
|
95
|
+
interface LaunchpadTokenState {
|
|
96
|
+
readonly id: LaunchpadTokenId;
|
|
97
|
+
readonly phase: LaunchpadPhase;
|
|
98
|
+
readonly tokenVersion: number;
|
|
99
|
+
readonly curveId: number;
|
|
100
|
+
readonly migratorId: number;
|
|
101
|
+
readonly quoteReserve: bigint;
|
|
102
|
+
readonly circulatingSupply: bigint;
|
|
103
|
+
readonly creator: Address;
|
|
104
|
+
/** Absent while the token is `invalid`, or whenever the Portal reports the zero address. */
|
|
105
|
+
readonly dexPool?: Address;
|
|
106
|
+
readonly launchBlock: bigint;
|
|
107
|
+
readonly protectionBlocks: number;
|
|
108
|
+
readonly pauseMode: LaunchpadPauseMode;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Result of `Portal.quoteBuy`. `quoteSpent` may be less than the requested input when the buy
|
|
112
|
+
* reaches the graduation threshold, so approvals and UI must follow `quoteSpent`, not user input.
|
|
113
|
+
*/
|
|
114
|
+
interface BuyQuote {
|
|
115
|
+
readonly tokenOut: bigint;
|
|
116
|
+
readonly quoteSpent: bigint;
|
|
117
|
+
readonly fee: bigint;
|
|
118
|
+
readonly reachesGraduation: boolean;
|
|
119
|
+
}
|
|
120
|
+
/** Result of `Portal.quoteSell`. `quoteOut` is already net of the trade fee. */
|
|
121
|
+
interface SellQuote {
|
|
122
|
+
readonly quoteOut: bigint;
|
|
123
|
+
readonly fee: bigint;
|
|
124
|
+
}
|
|
125
|
+
/** Slippage tolerance in basis points. Validated against a hard 10% ceiling. */
|
|
126
|
+
interface Slippage {
|
|
127
|
+
readonly bps: number;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Bonding-curve reference price. This is always the curve formula's output, never an executable
|
|
131
|
+
* quote, and it does not become a live V3 pool price after graduation — hence the explicit
|
|
132
|
+
* `source` and the `phase` observed at read time.
|
|
133
|
+
*/
|
|
134
|
+
interface LaunchpadPrice {
|
|
135
|
+
readonly valueWad: bigint;
|
|
136
|
+
readonly source: "bondingCurveReference";
|
|
137
|
+
readonly phase: LaunchpadPhase;
|
|
138
|
+
}
|
|
139
|
+
/** Why a curve trade is currently rejected, or `undefined` when trading is available. */
|
|
140
|
+
type LaunchpadTradeBlockedReason = "invalidToken" | "protocolPaused" | "buyPaused" | "tradingPaused" | "launchBlock" | "migrating" | "graduated";
|
|
141
|
+
/**
|
|
142
|
+
* Everything a UI needs to render trade availability without re-deriving protection rules:
|
|
143
|
+
* the current phase, pause state, the fee that applies at `blockNumber`, and the next block at
|
|
144
|
+
* which trading becomes possible.
|
|
145
|
+
*/
|
|
146
|
+
interface LaunchpadTradeAvailability {
|
|
147
|
+
readonly phase: LaunchpadPhase;
|
|
148
|
+
readonly protocolPaused: boolean;
|
|
149
|
+
readonly pauseMode: LaunchpadPauseMode;
|
|
150
|
+
readonly canBuy: boolean;
|
|
151
|
+
readonly canSell: boolean;
|
|
152
|
+
readonly feeBps: number;
|
|
153
|
+
readonly blockNumber: bigint;
|
|
154
|
+
/** Present while inside the launch-block trading ban. */
|
|
155
|
+
readonly nextTradableBlock?: bigint;
|
|
156
|
+
readonly blockedReason?: LaunchpadTradeBlockedReason;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* A graduated token's V3 liquidity position, permanently held by the Locker.
|
|
160
|
+
*
|
|
161
|
+
* `tokenId` is the Uniswap V3 position NFT id, not a token address. `token0`/`token1` follow V3's
|
|
162
|
+
* address ordering, so which one is the launched token depends on how it sorts against the quote
|
|
163
|
+
* token — never assume a fixed slot.
|
|
164
|
+
*/
|
|
165
|
+
interface LaunchpadLockedPosition {
|
|
166
|
+
readonly tokenId: bigint;
|
|
167
|
+
readonly token0: Address;
|
|
168
|
+
readonly token1: Address;
|
|
169
|
+
readonly creator: Address;
|
|
170
|
+
/** Platform share of collected fees, in basis points. The remainder credits the creator. */
|
|
171
|
+
readonly platformFeeBps: number;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* A previewed CREATE2 token address.
|
|
175
|
+
*
|
|
176
|
+
* Valid only while `creatorNonce` is still the creator's current nonce — it increments on every
|
|
177
|
+
* successful creation, so launching any token invalidates an earlier prediction.
|
|
178
|
+
*/
|
|
179
|
+
interface PredictedLaunchpadToken {
|
|
180
|
+
readonly address: Address;
|
|
181
|
+
readonly creator: Address;
|
|
182
|
+
/** Portal nonce this prediction is bound to. */
|
|
183
|
+
readonly creatorNonce: bigint;
|
|
184
|
+
readonly userSalt: Hex;
|
|
185
|
+
/** The derived factory salt, exposed for verification against the chain. */
|
|
186
|
+
readonly salt: Hex;
|
|
187
|
+
}
|
|
188
|
+
/** On-chain name, symbol, and decimals for a token, read together at one block. */
|
|
189
|
+
interface LaunchpadErc20Metadata {
|
|
190
|
+
readonly address: Address;
|
|
191
|
+
readonly name: string;
|
|
192
|
+
readonly symbol: string;
|
|
193
|
+
readonly decimals: number;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** Canonical identifier for a Launchpad token. Addresses alone are not cross-chain identifiers. */
|
|
197
|
+
interface LaunchpadTokenId {
|
|
198
|
+
readonly chainId: number;
|
|
199
|
+
readonly address: Address;
|
|
200
|
+
}
|
|
201
|
+
type LaunchpadCapability = "create" | "bondingTrade" | "graduatedTrade" | "antiFarmer" | "earlySellTax" | "rewards" | "referral";
|
|
202
|
+
interface LaunchpadQuoteTokenConfig {
|
|
203
|
+
readonly address: Address;
|
|
204
|
+
readonly decimals: number;
|
|
205
|
+
readonly symbol: string;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Per-chain network and product metadata for the ABI-neutral adapter client. `deployment` is the
|
|
209
|
+
* same verified {@link LaunchpadDeployment} the typed `LaunchpadPortalClient` uses — there is no
|
|
210
|
+
* separate, looser address shape here. This keeps the bonding curve, migrator, and any future DEX
|
|
211
|
+
* router as distinct, named module slots instead of collapsing them into one ambiguous "router".
|
|
212
|
+
*/
|
|
213
|
+
interface LaunchpadChainConfig {
|
|
214
|
+
readonly slug: string;
|
|
215
|
+
readonly chainId: number;
|
|
216
|
+
readonly family: "evm";
|
|
217
|
+
readonly nativeCurrency: {
|
|
218
|
+
readonly symbol: string;
|
|
219
|
+
readonly decimals: number;
|
|
220
|
+
};
|
|
221
|
+
readonly rpcUrls: readonly string[];
|
|
222
|
+
readonly explorerUrl: string;
|
|
223
|
+
readonly apiBaseUrl: string;
|
|
224
|
+
readonly realtimeUrl: string;
|
|
225
|
+
readonly deployment: LaunchpadDeployment;
|
|
226
|
+
readonly quoteTokens: readonly LaunchpadQuoteTokenConfig[];
|
|
227
|
+
readonly capabilities: Readonly<Record<LaunchpadCapability, boolean>>;
|
|
228
|
+
readonly confirmations: number;
|
|
229
|
+
}
|
|
230
|
+
type LaunchpadChainRegistry = Readonly<Record<number, LaunchpadChainConfig>>;
|
|
231
|
+
/**
|
|
232
|
+
* ABI-neutral request passed to a contract adapter. The operation and argument shape become typed
|
|
233
|
+
* only after the Launchpad contracts are delivered and their public interface is frozen.
|
|
234
|
+
*/
|
|
235
|
+
interface LaunchpadReadRequest {
|
|
236
|
+
readonly operation: string;
|
|
237
|
+
readonly args?: unknown;
|
|
238
|
+
}
|
|
239
|
+
interface LaunchpadWriteRequest extends LaunchpadReadRequest {
|
|
240
|
+
readonly requiredCapability: LaunchpadCapability;
|
|
241
|
+
}
|
|
242
|
+
interface LaunchpadReadContext {
|
|
243
|
+
readonly chain: LaunchpadChainConfig;
|
|
244
|
+
readonly publicClient: PublicClient;
|
|
245
|
+
}
|
|
246
|
+
interface LaunchpadWriteContext extends LaunchpadReadContext {
|
|
247
|
+
readonly walletClient: WalletClient;
|
|
248
|
+
}
|
|
249
|
+
/** Adapter boundary for generated ABI bindings and protocol-specific actions. */
|
|
250
|
+
interface LaunchpadContractAdapter {
|
|
251
|
+
read<Result>(context: LaunchpadReadContext, request: LaunchpadReadRequest): Promise<Result>;
|
|
252
|
+
write<Result>(context: LaunchpadWriteContext, request: LaunchpadWriteRequest): Promise<Result>;
|
|
253
|
+
}
|
|
254
|
+
type LaunchpadAdapterRegistry = Readonly<Record<number, LaunchpadContractAdapter>>;
|
|
255
|
+
interface LaunchpadClientConfig {
|
|
256
|
+
readonly publicClient: PublicClient;
|
|
257
|
+
readonly walletClient?: WalletClient;
|
|
258
|
+
readonly chains: LaunchpadChainRegistry;
|
|
259
|
+
readonly adapters?: LaunchpadAdapterRegistry;
|
|
260
|
+
}
|
|
261
|
+
interface LaunchpadClient {
|
|
262
|
+
readonly publicClient: PublicClient;
|
|
263
|
+
readonly walletClient?: WalletClient;
|
|
264
|
+
getChain(chainId?: number): LaunchpadChainConfig;
|
|
265
|
+
getAdapter(chainId?: number): LaunchpadContractAdapter;
|
|
266
|
+
read<Result>(request: LaunchpadReadRequest, chainId?: number): Promise<Result>;
|
|
267
|
+
write<Result>(request: LaunchpadWriteRequest, chainId?: number): Promise<Result>;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** Allowance status for one asset/spender pair, resolved at a single block. */
|
|
271
|
+
interface LaunchpadApprovalStatus {
|
|
272
|
+
readonly asset: Address;
|
|
273
|
+
readonly owner: Address;
|
|
274
|
+
readonly spender: Address;
|
|
275
|
+
readonly allowance: bigint;
|
|
276
|
+
readonly requiredAmount: bigint;
|
|
277
|
+
readonly sufficient: boolean;
|
|
278
|
+
/** Exactly the shortfall, so a caller can approve the precise amount still needed. */
|
|
279
|
+
readonly missingAmount: bigint;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Resolves whether an exact-amount approval is still required.
|
|
283
|
+
*
|
|
284
|
+
* The spender for both buy and sell is always the Portal — never a pool and never a future DEX
|
|
285
|
+
* router. For a buy, `requiredAmount` should be the quote's `quoteSpent` rather than the user's
|
|
286
|
+
* typed input, because a graduating buy spends less than requested.
|
|
287
|
+
*/
|
|
288
|
+
declare function getLaunchpadApprovalStatus(context: LaunchpadActionContext, input: {
|
|
289
|
+
readonly asset: Address;
|
|
290
|
+
readonly owner: Address;
|
|
291
|
+
readonly requiredAmount: bigint;
|
|
292
|
+
readonly spender?: Address;
|
|
293
|
+
}, options?: LaunchpadReadOptions): Promise<LaunchpadApprovalStatus>;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* `ICurve.State` as the Portal builds it in `_curveState`. Every field is read from the deployed
|
|
297
|
+
* Portal's constants rather than hardcoded, so a redeployment with different curve parameters
|
|
298
|
+
* cannot silently produce wrong quotes.
|
|
299
|
+
*/
|
|
300
|
+
interface LaunchpadCurveState {
|
|
301
|
+
readonly totalSupply: bigint;
|
|
302
|
+
readonly circulatingSupply: bigint;
|
|
303
|
+
readonly quoteReserve: bigint;
|
|
304
|
+
readonly virtualTokenReserve: bigint;
|
|
305
|
+
readonly virtualQuoteReserve: bigint;
|
|
306
|
+
readonly k: bigint;
|
|
307
|
+
}
|
|
308
|
+
/** Portal curve constants, read once per deployment. */
|
|
309
|
+
interface LaunchpadCurveConstants {
|
|
310
|
+
readonly totalSupply: bigint;
|
|
311
|
+
readonly dexSupplyThreshold: bigint;
|
|
312
|
+
readonly virtualTokenReserve: bigint;
|
|
313
|
+
readonly virtualQuoteReserve: bigint;
|
|
314
|
+
readonly curveK: bigint;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Builds the curve state the Portal would pass at token creation: nothing circulating and no
|
|
318
|
+
* quote reserve yet. Identical to `Portal._curveState()` for a freshly created token.
|
|
319
|
+
*/
|
|
320
|
+
declare function initialCurveState(constants: LaunchpadCurveConstants): LaunchpadCurveState;
|
|
321
|
+
/**
|
|
322
|
+
* Fee applied to a creator's atomic first buy. `Portal._createToken` calls
|
|
323
|
+
* `_buy(..., creatorFirstBuy = true)`, which pins the fee to `TRADE_FEE_BPS` and bypasses the
|
|
324
|
+
* anti-sniper ladder entirely — the creator is never charged the launch-block rate.
|
|
325
|
+
*/
|
|
326
|
+
declare function creatorFirstBuyFee(quoteIn: bigint): bigint;
|
|
327
|
+
/**
|
|
328
|
+
* Assembles a creator first-buy quote from the curve's own outputs.
|
|
329
|
+
*
|
|
330
|
+
* This mirrors `Portal._quoteBuy(state, quoteIn, creatorFirstBuy = true)` exactly. The two curve
|
|
331
|
+
* results must come from `eth_call`s against the deployed `ConstantProductCurve` — the SDK never
|
|
332
|
+
* reimplements the bonding-curve math in JavaScript. Only the flat fee and the `mulDivUp`
|
|
333
|
+
* gross-up run locally, and both are exact in `bigint`.
|
|
334
|
+
*
|
|
335
|
+
* @param quoteIn Total quote the creator commits, fee inclusive.
|
|
336
|
+
* @param tokenOutFromCurve `curve.quoteBuy(initialState, quoteIn - fee)`.
|
|
337
|
+
* @param netRequiredForThreshold `curve.quoteBuyExactOut(initialState, dexSupplyThreshold)`,
|
|
338
|
+
* required only when the first buy alone would reach graduation.
|
|
339
|
+
*/
|
|
340
|
+
declare function toCreatorFirstBuyQuote(constants: LaunchpadCurveConstants, quoteIn: bigint, tokenOutFromCurve: bigint, netRequiredForThreshold?: bigint): BuyQuote;
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Scale factor baked into `Portal.priceWad`.
|
|
344
|
+
*
|
|
345
|
+
* The Portal computes `CURVE_K * 1e30 / effectiveBase²`, and `CURVE_K` is
|
|
346
|
+
* `VIRTUAL_QUOTE_RESERVE * (TOTAL_SUPPLY + VIRTUAL_TOKEN_RESERVE)` — a product of one amount in the
|
|
347
|
+
* quote's smallest unit and one in the token's. The quoted price is therefore
|
|
348
|
+
* `(quote smallest unit / token smallest unit) * 1e30`, independent of either token's decimals.
|
|
349
|
+
* Ratios against it need no decimals conversion, which is why nothing here takes one.
|
|
350
|
+
*/
|
|
351
|
+
declare const PRICE_WAD_SCALE: bigint;
|
|
352
|
+
/**
|
|
353
|
+
* Price impact in basis points: how far the average execution price sits from the spot price.
|
|
354
|
+
*
|
|
355
|
+
* Positive means the trade executed worse than spot (a buy pushing up the curve), negative means
|
|
356
|
+
* better (a sell pushing down). Callers rendering a single figure usually want the magnitude.
|
|
357
|
+
*
|
|
358
|
+
* Both prices are expressed as quote-per-token, so the {@link PRICE_WAD_SCALE} cancels and no
|
|
359
|
+
* decimals are involved.
|
|
360
|
+
*
|
|
361
|
+
* @param spotPriceWad `Portal.priceWad` observed at the same block as the quote.
|
|
362
|
+
* @param quoteAmount Quote that actually moves along the curve, fee excluded.
|
|
363
|
+
* @param tokenAmount Token that moves in the same trade.
|
|
364
|
+
*/
|
|
365
|
+
declare function priceImpactBps(spotPriceWad: bigint, quoteAmount: bigint, tokenAmount: bigint): number;
|
|
366
|
+
/**
|
|
367
|
+
* Price impact of a buy, with the protocol fee removed.
|
|
368
|
+
*
|
|
369
|
+
* `quoteSpent` is fee-inclusive but only `quoteSpent - fee` reaches the curve, so charging the fee
|
|
370
|
+
* to price impact would overstate it — the fee is a separate, flat cost a UI shows on its own line.
|
|
371
|
+
*/
|
|
372
|
+
declare function buyPriceImpactBps(spotPriceWad: bigint, quote: BuyQuote): number;
|
|
373
|
+
/**
|
|
374
|
+
* Price impact of a sell, with the protocol fee added back.
|
|
375
|
+
*
|
|
376
|
+
* `quoteOut` is already net of the fee, so the gross amount the curve produced is `quoteOut + fee`.
|
|
377
|
+
* The result is negative: a sell moves the price down.
|
|
378
|
+
*/
|
|
379
|
+
declare function sellPriceImpactBps(spotPriceWad: bigint, quote: SellQuote, tokenIn: bigint): number;
|
|
380
|
+
/**
|
|
381
|
+
* Converts `Portal.priceWad` into quote-per-whole-token, scaled to 1e18 for display.
|
|
382
|
+
*
|
|
383
|
+
* `priceWad` is a ratio of smallest units, so rendering it directly is only correct for one
|
|
384
|
+
* specific decimals pairing — with a 6-decimal quote and an 18-decimal token it happens to equal
|
|
385
|
+
* this result, which is why `formatUnits(priceWad, 18)` appears to work. Against an 18-decimal
|
|
386
|
+
* quote such as BNB or ETH that shortcut is off by twelve orders of magnitude, so the conversion
|
|
387
|
+
* is made explicit here rather than left to a coincidence.
|
|
388
|
+
*/
|
|
389
|
+
declare function priceWadPerWholeToken(priceWad: bigint, quoteDecimals: number, tokenDecimals?: number): bigint;
|
|
390
|
+
/**
|
|
391
|
+
* Fully diluted market capitalisation, in the quote token's smallest unit.
|
|
392
|
+
*
|
|
393
|
+
* Uses `totalSupply` rather than circulating supply: the whole supply is minted at creation, with
|
|
394
|
+
* the un-sold remainder held by the Portal for the curve and the eventual V3 position.
|
|
395
|
+
*/
|
|
396
|
+
declare function marketCapQuote(priceWad: bigint, totalSupply: bigint): bigint;
|
|
397
|
+
/**
|
|
398
|
+
* Reproduces `Portal._priceWad` for an arbitrary circulating supply.
|
|
399
|
+
*
|
|
400
|
+
* Lets a caller price a point the curve has not reached yet — the graduation price, or a series
|
|
401
|
+
* for a curve chart — without a round trip per point.
|
|
402
|
+
*/
|
|
403
|
+
declare function curvePriceWadAt(circulatingSupply: bigint, constants: LaunchpadCurveConstants): bigint;
|
|
404
|
+
/**
|
|
405
|
+
* Market cap the token will have when it graduates, in the quote's smallest unit.
|
|
406
|
+
*
|
|
407
|
+
* This is the figure behind a "migrates at X" label. It is derived from the deployment's own curve
|
|
408
|
+
* constants rather than hard-coded, so it stays correct if a deployment is configured differently
|
|
409
|
+
* — and it is denominated in the quote token, not USD. Converting to USD needs an external price
|
|
410
|
+
* for the quote, which is the application's concern, not the SDK's.
|
|
411
|
+
*/
|
|
412
|
+
declare function graduationMarketCapQuote(constants: LaunchpadCurveConstants): bigint;
|
|
413
|
+
/** Graduation progress of a bonding token, derived from supply rather than reserve. */
|
|
414
|
+
interface LaunchpadGraduationProgress {
|
|
415
|
+
/** Token still purchasable on the curve before graduation, in the token's smallest unit. */
|
|
416
|
+
readonly tokensRemaining: bigint;
|
|
417
|
+
/** Progress toward the threshold, 0–10000. */
|
|
418
|
+
readonly progressBps: number;
|
|
419
|
+
/** True once the curve allocation is exhausted and the token is at or past graduation. */
|
|
420
|
+
readonly reachedThreshold: boolean;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Progress toward graduation, measured in supply.
|
|
424
|
+
*
|
|
425
|
+
* Supply is the condition the Portal actually tests (`tokenOut >= dexSupplyThreshold -
|
|
426
|
+
* circulatingSupply`), so this needs no hard-coded quote target and stays exact. A UI that
|
|
427
|
+
* displays "X / Y quote raised" can still show `quoteReserve` beside it, but the percentage
|
|
428
|
+
* belongs to supply.
|
|
429
|
+
*
|
|
430
|
+
* Already-graduated tokens report 100%: their reserve is moved into the V3 position at migration
|
|
431
|
+
* and reads back as zero, which would otherwise render as 0%.
|
|
432
|
+
*/
|
|
433
|
+
declare function graduationProgress(circulatingSupply: bigint, constants: LaunchpadCurveConstants): LaunchpadGraduationProgress;
|
|
434
|
+
/** Fee a plain (non-creator) trade pays at the standard rate, in the quote's smallest unit. */
|
|
435
|
+
declare function tradeFee(quoteAmount: bigint): bigint;
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Reads the Portal's curve constants.
|
|
439
|
+
*
|
|
440
|
+
* These are `immutable`/`constant` on a given Portal, so a caller may read them once per
|
|
441
|
+
* deployment and reuse the result. They are read from the contract rather than hardcoded so a
|
|
442
|
+
* redeployment with different curve parameters cannot silently produce wrong quotes.
|
|
443
|
+
*/
|
|
444
|
+
declare function getLaunchpadCurveConstants(context: LaunchpadActionContext, options?: LaunchpadReadOptions): Promise<LaunchpadCurveConstants>;
|
|
445
|
+
/**
|
|
446
|
+
* Quotes the creator's atomic first buy, so `prepareCreateToken` can be given a non-zero
|
|
447
|
+
* `minInitialTokenOut` instead of the unsafe `0`.
|
|
448
|
+
*
|
|
449
|
+
* The Portal exposes no public creator-first-buy view: `_quoteBuy(..., creatorFirstBuy = true)` is
|
|
450
|
+
* internal, and simulating `createTokenV2` only returns the new token address. However the
|
|
451
|
+
* registered `ConstantProductCurve` is a deployed, stateless `pure` contract, so this reproduces
|
|
452
|
+
* the Portal's own arithmetic by calling that contract with the state a freshly created token
|
|
453
|
+
* would have. The bonding-curve math therefore runs as real Solidity, never as a JavaScript
|
|
454
|
+
* re-implementation; only the flat 1% fee and the `mulDivUp` gross-up happen locally, both exact
|
|
455
|
+
* in `bigint`.
|
|
456
|
+
*
|
|
457
|
+
* Pass `constants` to skip re-reading the Portal's immutable curve parameters on every quote.
|
|
458
|
+
*/
|
|
459
|
+
declare function quoteCreatorFirstBuy(context: LaunchpadActionContext, quoteIn: bigint, options?: LaunchpadReadOptions & {
|
|
460
|
+
readonly constants?: LaunchpadCurveConstants;
|
|
461
|
+
}): Promise<BuyQuote>;
|
|
462
|
+
/**
|
|
463
|
+
* Everything a token screen needs to render curve progress, resolved at one block.
|
|
464
|
+
*
|
|
465
|
+
* `apps/web` derived this from a hard-coded quote target and separate unpinned reads. Here the
|
|
466
|
+
* threshold comes from the deployment's own constants and every figure shares a block, so the
|
|
467
|
+
* headline market cap can never disagree with the progress bar beside it.
|
|
468
|
+
*/
|
|
469
|
+
interface LaunchpadCurveProgress extends LaunchpadGraduationProgress {
|
|
470
|
+
readonly blockNumber: bigint;
|
|
471
|
+
readonly phase: LaunchpadPhase;
|
|
472
|
+
readonly circulatingSupply: bigint;
|
|
473
|
+
/** Quote raised on the curve. Reads back as zero once migrated — the reserve moved into V3. */
|
|
474
|
+
readonly quoteReserve: bigint;
|
|
475
|
+
readonly priceWad: bigint;
|
|
476
|
+
/** Fully diluted market cap in the quote token's smallest unit. */
|
|
477
|
+
readonly marketCapQuote: bigint;
|
|
478
|
+
/**
|
|
479
|
+
* Market cap this token graduates at, in the quote's smallest unit.
|
|
480
|
+
*
|
|
481
|
+
* Derived from the deployment's curve constants, never hard-coded, and denominated in the quote
|
|
482
|
+
* token — a USD figure needs an external quote price, which the application owns.
|
|
483
|
+
*/
|
|
484
|
+
readonly graduationMarketCapQuote: bigint;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Reads curve progress for one token: tokens remaining, percentage, and market cap.
|
|
488
|
+
*
|
|
489
|
+
* Constants are immutable per deployment, so a caller holding them may pass them in to save a
|
|
490
|
+
* round trip; otherwise they are read alongside everything else.
|
|
491
|
+
*/
|
|
492
|
+
declare function getLaunchpadCurveProgress(context: LaunchpadActionContext, token: Address, options?: LaunchpadReadOptions & {
|
|
493
|
+
readonly constants?: LaunchpadCurveConstants;
|
|
494
|
+
}): Promise<LaunchpadCurveProgress>;
|
|
495
|
+
|
|
496
|
+
/** Raised when a read is attempted with an input the Portal would reject outright. */
|
|
497
|
+
declare class InvalidLaunchpadReadInputError extends Error {
|
|
498
|
+
readonly field: string;
|
|
499
|
+
constructor(field: string, message: string);
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Raised when a composite read that must observe one block is asked to use a tag with no stable
|
|
503
|
+
* height. `pending` names a block that does not exist yet, so nothing can be pinned to it.
|
|
504
|
+
*/
|
|
505
|
+
declare class UnpinnableBlockTagError extends Error {
|
|
506
|
+
readonly blockTag: string;
|
|
507
|
+
constructor(blockTag: string);
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Resolves a concrete height that every part of a composite read can be pinned to.
|
|
511
|
+
*
|
|
512
|
+
* Reads that combine several calls must not each resolve `latest` independently: the chain head can
|
|
513
|
+
* advance between them, silently mixing one block's state with another block's height or pause
|
|
514
|
+
* flag. This collapses the caller's intent to a single number up front, so `latest`, `safe`,
|
|
515
|
+
* `finalized`, and an explicit height all carry the same "one observed block" guarantee.
|
|
516
|
+
*
|
|
517
|
+
* Exported so callers composing their own multi-read views get the same guarantee instead of
|
|
518
|
+
* resolving `latest` per call.
|
|
519
|
+
*/
|
|
520
|
+
declare function resolvePinnedBlockNumber(context: LaunchpadActionContext, options?: LaunchpadReadOptions): Promise<bigint>;
|
|
521
|
+
/** Reads the Portal's token state and converts it to the stable domain shape. */
|
|
522
|
+
declare function getLaunchpadTokenState(context: LaunchpadActionContext, token: Address, options?: LaunchpadReadOptions): Promise<LaunchpadTokenState>;
|
|
523
|
+
/** Reads the raw, untrusted metadata string. Parsing is the caller's choice. */
|
|
524
|
+
declare function getLaunchpadTokenMetadata(context: LaunchpadActionContext, token: Address, options?: LaunchpadReadOptions): Promise<string>;
|
|
525
|
+
/**
|
|
526
|
+
* Reads the bonding-curve reference price, tagged with its source and the phase observed at the
|
|
527
|
+
* same block. This is never an executable quote and must not be used to derive a `minOut`; after
|
|
528
|
+
* graduation it remains a curve value and does not track the V3 pool.
|
|
529
|
+
*
|
|
530
|
+
* The price and the phase are pinned to one resolved height, so a `graduated` phase can never be
|
|
531
|
+
* reported alongside a price read from an earlier block (or the reverse).
|
|
532
|
+
*/
|
|
533
|
+
declare function getLaunchpadPrice(context: LaunchpadActionContext, token: Address, options?: LaunchpadReadOptions): Promise<LaunchpadPrice>;
|
|
534
|
+
/** Quotes a curve buy. `quoteSpent` may be below `quoteIn` when the buy reaches graduation. */
|
|
535
|
+
declare function quoteLaunchpadBuy(context: LaunchpadActionContext, token: Address, quoteIn: bigint, options?: LaunchpadReadOptions): Promise<BuyQuote>;
|
|
536
|
+
/** Quotes a curve sell. `quoteOut` is already net of the trade fee. */
|
|
537
|
+
declare function quoteLaunchpadSell(context: LaunchpadActionContext, token: Address, tokenIn: bigint, options?: LaunchpadReadOptions): Promise<SellQuote>;
|
|
538
|
+
/**
|
|
539
|
+
* Combines token state, the global pause flag, and the block height into a single availability
|
|
540
|
+
* view, so a UI renders the fee, reason, and next tradable block without duplicating rules.
|
|
541
|
+
*
|
|
542
|
+
* The height is resolved **first**, then the state and pause flag are both pinned to it. Resolving
|
|
543
|
+
* them concurrently against `latest` would let the chain head advance mid-read and compute the
|
|
544
|
+
* protection-fee ladder for one block from another block's state — reporting the wrong fee and,
|
|
545
|
+
* inside the launch window, wrongly showing a banned token as tradable.
|
|
546
|
+
*/
|
|
547
|
+
declare function getLaunchpadTradeAvailability(context: LaunchpadActionContext, token: Address, options?: LaunchpadReadOptions): Promise<LaunchpadTradeAvailability>;
|
|
548
|
+
/** Reads an ERC-20 balance at the given block. */
|
|
549
|
+
declare function getErc20Balance(context: LaunchpadActionContext, asset: Address, account: Address, options?: LaunchpadReadOptions): Promise<bigint>;
|
|
550
|
+
/**
|
|
551
|
+
* Reads a token's name, symbol, and decimals together at one block.
|
|
552
|
+
*
|
|
553
|
+
* The frontend integration guide lists these as required for any token screen, and reading them
|
|
554
|
+
* as one pinned batch keeps a header from pairing one token's symbol with another's decimals
|
|
555
|
+
* mid-render. Decimals matter most: formatting an amount with the wrong scale misstates it by
|
|
556
|
+
* orders of magnitude.
|
|
557
|
+
*/
|
|
558
|
+
declare function getErc20Metadata(context: LaunchpadActionContext, asset: Address, options?: LaunchpadReadOptions): Promise<LaunchpadErc20Metadata>;
|
|
559
|
+
/** Reads an ERC-20 allowance at the given block. */
|
|
560
|
+
declare function getErc20Allowance(context: LaunchpadActionContext, asset: Address, owner: Address, spender: Address, options?: LaunchpadReadOptions): Promise<bigint>;
|
|
561
|
+
/**
|
|
562
|
+
* Reads a caller's claimable Locker reward for one asset. The Locker only ever exposes the
|
|
563
|
+
* caller's own balance, so `account` is a lookup key, not an authorization bypass.
|
|
564
|
+
*/
|
|
565
|
+
declare function getClaimableLaunchpadReward(context: LaunchpadActionContext, account: Address, asset: Address, options?: LaunchpadReadOptions): Promise<bigint>;
|
|
566
|
+
/**
|
|
567
|
+
* Reads a locked V3 position by its LP NFT id, or `undefined` when nothing is registered.
|
|
568
|
+
*
|
|
569
|
+
* `tokenId` is the Uniswap V3 position NFT id minted during migration — not a token address. The
|
|
570
|
+
* Locker stores only `tokenId -> position`, with no reverse index, and this SDK does not scan logs
|
|
571
|
+
* to build one: `DATA_INDEXING_SPEC.md` assigns `PositionLocked`/`PositionMinted` to the indexing
|
|
572
|
+
* service and forbids browsers from scanning `eth_getLogs` from the deployment block. Callers
|
|
573
|
+
* therefore obtain `tokenId` from that service (or from the migration receipt) and pass it in.
|
|
574
|
+
*/
|
|
575
|
+
declare function getLockedLaunchpadPosition(context: LaunchpadActionContext, tokenId: bigint, options?: LaunchpadReadOptions): Promise<LaunchpadLockedPosition | undefined>;
|
|
576
|
+
/**
|
|
577
|
+
* Predicts the CREATE2 address a token would receive if `creator` launched it right now.
|
|
578
|
+
*
|
|
579
|
+
* The Portal does not use `userSalt` directly — it derives the factory salt from the creator, an
|
|
580
|
+
* auto-incrementing per-creator nonce, and `userSalt`:
|
|
581
|
+
*
|
|
582
|
+
* ```solidity
|
|
583
|
+
* salt = keccak256(abi.encode(msg.sender, creatorNonces[msg.sender]++, params.userSalt));
|
|
584
|
+
* ```
|
|
585
|
+
*
|
|
586
|
+
* Reproducing that by hand is easy to get subtly wrong, so it lives here. The returned
|
|
587
|
+
* `creatorNonce` is part of the result rather than an internal detail: because the nonce increments
|
|
588
|
+
* on every successful creation, a prediction is only valid until this creator launches their next
|
|
589
|
+
* token. A UI offering to "reserve" an address must either create before that happens or re-check.
|
|
590
|
+
*
|
|
591
|
+
* This is a preview, not a reservation — nothing on-chain holds the address. Always take the real
|
|
592
|
+
* address from the `TokenCreated` event in the receipt.
|
|
593
|
+
*/
|
|
594
|
+
declare function predictLaunchpadTokenAddress(context: LaunchpadActionContext, input: {
|
|
595
|
+
readonly creator: Address;
|
|
596
|
+
readonly name: string;
|
|
597
|
+
readonly symbol: string;
|
|
598
|
+
readonly userSalt: Hex;
|
|
599
|
+
}, options?: LaunchpadReadOptions): Promise<PredictedLaunchpadToken>;
|
|
600
|
+
|
|
601
|
+
interface LaunchpadTokenCreatedEvent {
|
|
602
|
+
readonly token: Address;
|
|
603
|
+
readonly creator: Address;
|
|
604
|
+
readonly name: string;
|
|
605
|
+
readonly symbol: string;
|
|
606
|
+
readonly metadata: string;
|
|
607
|
+
readonly curveId: number;
|
|
608
|
+
readonly migratorId: number;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Direction-normalized trade event.
|
|
612
|
+
*
|
|
613
|
+
* The on-chain `quoteAmount` is asymmetric — the Portal emits the **net** quote on a buy and the
|
|
614
|
+
* **gross** quote on a sell — so the raw value alone cannot be summed into volume. `raw` is
|
|
615
|
+
* preserved for auditability while the derived deltas state, unambiguously, what the trader paid
|
|
616
|
+
* or received and how the curve reserve moved.
|
|
617
|
+
*/
|
|
618
|
+
interface LaunchpadTradeEvent {
|
|
619
|
+
readonly token: Address;
|
|
620
|
+
readonly trader: Address;
|
|
621
|
+
readonly side: "buy" | "sell";
|
|
622
|
+
readonly tokenAmount: bigint;
|
|
623
|
+
readonly quoteAmountRaw: bigint;
|
|
624
|
+
readonly fee: bigint;
|
|
625
|
+
/** Signed change in the trader's quote balance: buy is negative, sell positive. */
|
|
626
|
+
readonly traderQuoteDelta: bigint;
|
|
627
|
+
/** Signed change in the curve's quote reserve. */
|
|
628
|
+
readonly reserveQuoteDelta: bigint;
|
|
629
|
+
}
|
|
630
|
+
interface LaunchpadMigrationStartedEvent {
|
|
631
|
+
readonly token: Address;
|
|
632
|
+
readonly tokenAmount: bigint;
|
|
633
|
+
readonly quoteAmount: bigint;
|
|
634
|
+
}
|
|
635
|
+
interface LaunchpadMigrationCompletedEvent {
|
|
636
|
+
readonly token: Address;
|
|
637
|
+
readonly pool: Address;
|
|
638
|
+
readonly liquidity: bigint;
|
|
639
|
+
readonly lpRecipient: Address;
|
|
640
|
+
}
|
|
641
|
+
interface LaunchpadRewardsClaimedEvent {
|
|
642
|
+
readonly account: Address;
|
|
643
|
+
readonly asset: Address;
|
|
644
|
+
readonly recipient: Address;
|
|
645
|
+
readonly amount: bigint;
|
|
646
|
+
}
|
|
647
|
+
/** Everything the SDK could decode from one receipt, scoped to a single deployment. */
|
|
648
|
+
interface LaunchpadReceiptEvents {
|
|
649
|
+
readonly tokenCreated: readonly LaunchpadTokenCreatedEvent[];
|
|
650
|
+
readonly trades: readonly LaunchpadTradeEvent[];
|
|
651
|
+
readonly migrationStarted: readonly LaunchpadMigrationStartedEvent[];
|
|
652
|
+
readonly migrationCompleted: readonly LaunchpadMigrationCompletedEvent[];
|
|
653
|
+
readonly rewardsClaimed: readonly LaunchpadRewardsClaimedEvent[];
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Decodes the Launchpad events in a receipt.
|
|
657
|
+
*
|
|
658
|
+
* Logs are filtered by emitting address against the deployment, so a transaction that also touches
|
|
659
|
+
* unrelated contracts — or a look-alike contract emitting the same topic — cannot inject events
|
|
660
|
+
* that appear to come from this Portal.
|
|
661
|
+
*/
|
|
662
|
+
declare function parseLaunchpadReceiptEvents(deployment: LaunchpadDeployment, receipt: TransactionReceipt): LaunchpadReceiptEvents;
|
|
663
|
+
/**
|
|
664
|
+
* Resolves the created token address from a receipt. The `TokenCreated` event is the only
|
|
665
|
+
* authority — `TokenFactory.predictAddress` is a preview, never a success signal.
|
|
666
|
+
*/
|
|
667
|
+
declare function createdTokenAddress(deployment: LaunchpadDeployment, receipt: TransactionReceipt): Address | undefined;
|
|
668
|
+
|
|
669
|
+
/** Confirmed transaction plus the Launchpad events decoded from its receipt. */
|
|
670
|
+
interface LaunchpadTransactionResult extends SdkTransactionResult {
|
|
671
|
+
readonly events: LaunchpadReceiptEvents;
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Waits for a transaction and decodes its Launchpad events.
|
|
675
|
+
*
|
|
676
|
+
* A reverted receipt is reported as `status: "reverted"` rather than thrown, so a caller can tell
|
|
677
|
+
* "the chain rejected this" apart from "the request never landed". Events are still parsed, which
|
|
678
|
+
* is empty for a revert.
|
|
679
|
+
*/
|
|
680
|
+
declare function waitForLaunchpadTransaction(context: LaunchpadActionContext, hash: Hash, options?: {
|
|
681
|
+
readonly confirmations?: number;
|
|
682
|
+
}): Promise<LaunchpadTransactionResult>;
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Compile-time brand. It exists only in the type system, so application code cannot construct a
|
|
686
|
+
* `PreparedLaunchpadTransaction` by writing an object literal — every value must come from one of
|
|
687
|
+
* this module's `prepare*` functions. Runtime provenance is enforced separately (see
|
|
688
|
+
* `assertPreparedProvenance` and the typed client's registry).
|
|
689
|
+
*/
|
|
690
|
+
declare const preparedLaunchpadTransactionBrand: unique symbol;
|
|
691
|
+
/**
|
|
692
|
+
* The wallet and deployment context a prepared transaction was simulated under.
|
|
693
|
+
*
|
|
694
|
+
* Carried on the prepared value so the broadcast step can prove the wallet has not switched chain
|
|
695
|
+
* or account, and that the request belongs to the deployment now in use.
|
|
696
|
+
*/
|
|
697
|
+
interface PreparedLaunchpadTransactionContext {
|
|
698
|
+
readonly chainId: number;
|
|
699
|
+
readonly account: Address;
|
|
700
|
+
readonly portal: Address;
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* A simulated, ready-to-broadcast transaction plus the preview the simulation was based on.
|
|
704
|
+
* Holding these together stops a caller from submitting one intent while showing another.
|
|
705
|
+
*/
|
|
706
|
+
interface PreparedLaunchpadTransaction<Preview> {
|
|
707
|
+
readonly [preparedLaunchpadTransactionBrand]: true;
|
|
708
|
+
/** Frozen inspection copy; `send` uses a separate canonical snapshot retained by the SDK. */
|
|
709
|
+
readonly request: Readonly<Record<string, unknown>>;
|
|
710
|
+
readonly preview: Preview;
|
|
711
|
+
readonly context: PreparedLaunchpadTransactionContext;
|
|
712
|
+
}
|
|
713
|
+
interface CreateTokenPreview {
|
|
714
|
+
/** The full creator first-buy quote, or `undefined` when no first buy is made. */
|
|
715
|
+
readonly firstBuy?: BuyQuote;
|
|
716
|
+
readonly initialQuoteIn: bigint;
|
|
717
|
+
readonly minInitialTokenOut: bigint;
|
|
718
|
+
readonly protectionBlocks: number;
|
|
719
|
+
readonly deadline: bigint;
|
|
720
|
+
}
|
|
721
|
+
interface MigrationPreview {
|
|
722
|
+
readonly token: Address;
|
|
723
|
+
}
|
|
724
|
+
interface ClaimPreview {
|
|
725
|
+
readonly asset: Address;
|
|
726
|
+
readonly recipient: Address;
|
|
727
|
+
readonly amount: bigint;
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Outcome of collecting a locked V3 position's fees, simulated before broadcast.
|
|
731
|
+
*
|
|
732
|
+
* `amount0`/`amount1` are the gross amounts the Locker pulls from the position manager; the
|
|
733
|
+
* creator's share is what lands in `pendingRewards` after `platformFeeBps` is taken.
|
|
734
|
+
*/
|
|
735
|
+
interface CollectFeesPreview {
|
|
736
|
+
readonly tokenId: bigint;
|
|
737
|
+
readonly token0: Address;
|
|
738
|
+
readonly token1: Address;
|
|
739
|
+
readonly creator: Address;
|
|
740
|
+
readonly platformFeeBps: number;
|
|
741
|
+
readonly amount0: bigint;
|
|
742
|
+
readonly amount1: bigint;
|
|
743
|
+
}
|
|
744
|
+
interface ApprovalPreview {
|
|
745
|
+
readonly asset: Address;
|
|
746
|
+
readonly spender: Address;
|
|
747
|
+
readonly amount: bigint;
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* Prepares an ERC-20 approval for an exact amount.
|
|
751
|
+
*
|
|
752
|
+
* The SDK never widens this to an unlimited allowance on the caller's behalf; a UI wanting
|
|
753
|
+
* `maxUint256` must pass it explicitly and show its own risk confirmation.
|
|
754
|
+
*/
|
|
755
|
+
declare function prepareApproveErc20(context: LaunchpadWriteActionContext, input: {
|
|
756
|
+
readonly asset: Address;
|
|
757
|
+
readonly amount: bigint;
|
|
758
|
+
readonly spender?: Address;
|
|
759
|
+
}): Promise<PreparedLaunchpadTransaction<ApprovalPreview>>;
|
|
760
|
+
/**
|
|
761
|
+
* Prepares a bonding-curve buy: refreshes the quote, derives a non-zero `minTokenOut` from the
|
|
762
|
+
* caller's slippage, verifies the allowance covers `quoteSpent`, then simulates.
|
|
763
|
+
*/
|
|
764
|
+
declare function prepareLaunchpadBuy(context: LaunchpadWriteActionContext, input: {
|
|
765
|
+
readonly token: Address;
|
|
766
|
+
readonly quoteIn: bigint;
|
|
767
|
+
readonly slippage: Slippage;
|
|
768
|
+
readonly deadline: bigint;
|
|
769
|
+
}): Promise<PreparedLaunchpadTransaction<BuyQuote>>;
|
|
770
|
+
/** Prepares a bonding-curve sell with a non-zero `minQuoteOut` and a Portal-scoped allowance. */
|
|
771
|
+
declare function prepareLaunchpadSell(context: LaunchpadWriteActionContext, input: {
|
|
772
|
+
readonly token: Address;
|
|
773
|
+
readonly tokenIn: bigint;
|
|
774
|
+
readonly slippage: Slippage;
|
|
775
|
+
readonly deadline: bigint;
|
|
776
|
+
}): Promise<PreparedLaunchpadTransaction<SellQuote>>;
|
|
777
|
+
/** Input for {@link prepareCreateToken}. */
|
|
778
|
+
interface CreateTokenInput {
|
|
779
|
+
readonly name: string;
|
|
780
|
+
readonly symbol: string;
|
|
781
|
+
readonly metadata: string;
|
|
782
|
+
readonly userSalt: Hex;
|
|
783
|
+
/** Quote committed to the creator's atomic first buy. Zero means no first buy. */
|
|
784
|
+
readonly initialQuoteIn: bigint;
|
|
785
|
+
readonly deadline: bigint;
|
|
786
|
+
readonly protectionBlocks: number;
|
|
787
|
+
/**
|
|
788
|
+
* Slippage tolerance used to derive `minInitialTokenOut` from the creator first-buy quote.
|
|
789
|
+
* Required when `initialQuoteIn > 0`, unless `minInitialTokenOut` is supplied instead.
|
|
790
|
+
*/
|
|
791
|
+
readonly slippage?: Slippage;
|
|
792
|
+
/**
|
|
793
|
+
* Advanced escape hatch: an explicit minimum that overrides the slippage-derived value.
|
|
794
|
+
*
|
|
795
|
+
* Kept only for callers who compute the minimum themselves against their own quote. It must be
|
|
796
|
+
* positive whenever a first buy is made and must not exceed the SDK's own fresh quote (which
|
|
797
|
+
* would revert on-chain). It is never a way to opt out of slippage protection: passing `0` with
|
|
798
|
+
* a first buy is rejected, so there is no unsafe default path.
|
|
799
|
+
*/
|
|
800
|
+
readonly minInitialTokenOut?: bigint;
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* Prepares token creation, deriving a safe non-zero `minInitialTokenOut` for the creator's atomic
|
|
804
|
+
* first buy.
|
|
805
|
+
*
|
|
806
|
+
* When `initialQuoteIn > 0` the SDK prices the first buy itself via the deployed curve
|
|
807
|
+
* ({@link quoteCreatorFirstBuy}) and applies the caller's slippage, so a caller never has to invent
|
|
808
|
+
* a minimum. Two contract details drive the rest:
|
|
809
|
+
*
|
|
810
|
+
* - The allowance is checked against `quote.quoteSpent`, not `initialQuoteIn`. A first buy large
|
|
811
|
+
* enough to graduate is truncated at the threshold and the Portal transfers only `quoteSpent`, so
|
|
812
|
+
* requiring the full input would demand an allowance the transaction never uses.
|
|
813
|
+
* - The simulation still passes the caller's raw `initialQuoteIn`, because the Portal performs that
|
|
814
|
+
* truncation itself; passing `quoteSpent` would change the intent.
|
|
815
|
+
*
|
|
816
|
+
* When `initialQuoteIn` is zero, `minInitialTokenOut` must also be zero — the Portal rejects any
|
|
817
|
+
* other combination.
|
|
818
|
+
*/
|
|
819
|
+
declare function prepareCreateToken(context: LaunchpadWriteActionContext, input: CreateTokenInput): Promise<PreparedLaunchpadTransaction<CreateTokenPreview>>;
|
|
820
|
+
/** Prepares the permissionless migration. Only valid while the token is `migrating`. */
|
|
821
|
+
declare function prepareLaunchpadMigration(context: LaunchpadWriteActionContext, token: Address): Promise<PreparedLaunchpadTransaction<MigrationPreview>>;
|
|
822
|
+
/**
|
|
823
|
+
* Prepares a fee collection for a locked V3 position.
|
|
824
|
+
*
|
|
825
|
+
* This is the step that funds a claim: it pulls the position's accrued V3 fees into the Locker and
|
|
826
|
+
* credits the creator's share to `pendingRewards`. Until it runs there is nothing to claim, so a
|
|
827
|
+
* rewards UI that only exposes `prepareClaimReward` can never pay anyone out.
|
|
828
|
+
*
|
|
829
|
+
* Permissionless by design — the Locker credits `positions[tokenId].creator`, never the caller, so
|
|
830
|
+
* anyone may trigger collection and it is deliberately *not* behind the `rewards` capability.
|
|
831
|
+
* Gating it would let a disabled capability strand fees that belong to creators.
|
|
832
|
+
*
|
|
833
|
+
* `tokenId` is the Uniswap V3 position NFT id, obtained from the indexing service or the migration
|
|
834
|
+
* receipt; see {@link getLockedLaunchpadPosition} for why the SDK cannot resolve it from a token
|
|
835
|
+
* address.
|
|
836
|
+
*/
|
|
837
|
+
declare function prepareCollectLaunchpadFees(context: LaunchpadWriteActionContext, tokenId: bigint): Promise<PreparedLaunchpadTransaction<CollectFeesPreview>>;
|
|
838
|
+
/**
|
|
839
|
+
* Prepares a Locker reward claim.
|
|
840
|
+
*
|
|
841
|
+
* The Locker only ever pays out `pendingRewards[msg.sender]`, so a claim can never drain another
|
|
842
|
+
* account. Callers must gate this behind the deployment's `rewards` capability, which is off by
|
|
843
|
+
* default until the product confirms the claim surface.
|
|
844
|
+
*
|
|
845
|
+
* A claim only pays out what {@link prepareCollectLaunchpadFees} has already credited.
|
|
846
|
+
*/
|
|
847
|
+
declare function prepareClaimLaunchpadReward(context: LaunchpadWriteActionContext, input: {
|
|
848
|
+
readonly asset: Address;
|
|
849
|
+
readonly recipient?: Address;
|
|
850
|
+
}): Promise<PreparedLaunchpadTransaction<ClaimPreview>>;
|
|
851
|
+
/**
|
|
852
|
+
* Broadcasts an already-simulated transaction. Never simulates or mutates the request here.
|
|
853
|
+
*
|
|
854
|
+
* The module-private canonical-request registry also protects this standalone action: structural
|
|
855
|
+
* copies and hand-built values have no canonical simulation request and are rejected.
|
|
856
|
+
*/
|
|
857
|
+
declare function sendPreparedLaunchpadTransaction(context: LaunchpadWriteActionContext, prepared: PreparedLaunchpadTransaction<unknown>): Promise<Hash>;
|
|
858
|
+
|
|
859
|
+
declare class InvalidLaunchpadChainConfigError extends Error {
|
|
860
|
+
readonly field: string;
|
|
861
|
+
constructor(field: string, message: string);
|
|
862
|
+
}
|
|
863
|
+
/** Validates, normalizes, and freezes a caller-supplied chain configuration. */
|
|
864
|
+
declare function defineLaunchpadChain(input: LaunchpadChainConfig): Readonly<LaunchpadChainConfig>;
|
|
865
|
+
/** Normalizes an EVM token address while preserving its chain-scoped identity. */
|
|
866
|
+
declare function defineLaunchpadTokenId(input: LaunchpadTokenId): Readonly<LaunchpadTokenId>;
|
|
867
|
+
|
|
868
|
+
/** Creates a chain-scoped, ABI-neutral Launchpad client around caller-provided adapters. */
|
|
869
|
+
declare function createLaunchpadClient(config: LaunchpadClientConfig): LaunchpadClient;
|
|
870
|
+
declare class UnsupportedLaunchpadCapabilityError extends Error {
|
|
871
|
+
readonly chainId: number;
|
|
872
|
+
readonly capability: LaunchpadWriteRequest["requiredCapability"];
|
|
873
|
+
constructor(chainId: number, capability: LaunchpadWriteRequest["requiredCapability"]);
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
/** Raw `Portal.getTokenState` tuple. Consumers must never index this positionally. */
|
|
877
|
+
interface RawLaunchpadTokenState {
|
|
878
|
+
readonly status: number;
|
|
879
|
+
readonly tokenVersion: number;
|
|
880
|
+
readonly curveId: number;
|
|
881
|
+
readonly migratorId: number;
|
|
882
|
+
readonly quoteReserve: bigint;
|
|
883
|
+
readonly circulatingSupply: bigint;
|
|
884
|
+
readonly creator: Address;
|
|
885
|
+
readonly dexPool: Address;
|
|
886
|
+
readonly launchBlock: bigint;
|
|
887
|
+
readonly protectionBlocks: number;
|
|
888
|
+
readonly pauseMode: number;
|
|
889
|
+
}
|
|
890
|
+
declare class InvalidLaunchpadStateError extends Error {
|
|
891
|
+
readonly field: string;
|
|
892
|
+
constructor(field: string, message: string);
|
|
893
|
+
}
|
|
894
|
+
/** Maps `Portal.Status` to a stable phase name. */
|
|
895
|
+
declare function toLaunchpadPhase(status: number): LaunchpadPhase;
|
|
896
|
+
/** Maps `Portal.TokenState.pauseMode` to a stable pause name. */
|
|
897
|
+
declare function toLaunchpadPauseMode(pauseMode: number): LaunchpadPauseMode;
|
|
898
|
+
/**
|
|
899
|
+
* Converts the raw Portal state tuple into the stable domain shape.
|
|
900
|
+
*
|
|
901
|
+
* `dexPool` is omitted rather than reported as the zero address, so a caller can never mistake an
|
|
902
|
+
* unprepared pool for a tradable one. The pool is only meaningful once the token has graduated;
|
|
903
|
+
* it is populated at creation time for the migrator, so it is suppressed while `invalid`.
|
|
904
|
+
*/
|
|
905
|
+
declare function toLaunchpadTokenState(id: LaunchpadTokenId, raw: RawLaunchpadTokenState): LaunchpadTokenState;
|
|
906
|
+
|
|
907
|
+
/** Arc Testnet chain id. Testnet-only; never treated as a production default. */
|
|
908
|
+
declare const arcTestnetChainId = 5042002;
|
|
909
|
+
/**
|
|
910
|
+
* Explicitly named Arc Testnet V2 development deployment (deployed 2026-08-13).
|
|
911
|
+
*
|
|
912
|
+
* This is a development configuration, not a production default: it is deliberately excluded from
|
|
913
|
+
* `launchpadDeploymentRegistry`, and consumers must opt in by name. Addresses, the Portal runtime
|
|
914
|
+
* code hash, and the deployment block were read from Arc Testnet and cross-checked against the
|
|
915
|
+
* contract repository's deployment record at the pinned revision. Callers should still run
|
|
916
|
+
* `verifyLaunchpadDeployment` before trusting it.
|
|
917
|
+
*/
|
|
918
|
+
declare const arcTestnetLaunchpadDeployment: Readonly<LaunchpadDeployment>;
|
|
919
|
+
|
|
920
|
+
/** Base class for every stable Launchpad failure, so callers can branch on one instanceof. */
|
|
921
|
+
declare class LaunchpadError extends Error {
|
|
922
|
+
constructor(message: string, options?: {
|
|
923
|
+
cause?: unknown;
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
/** The token is not in a phase that permits the attempted operation. */
|
|
927
|
+
declare class LaunchpadPhaseUnavailableError extends LaunchpadError {
|
|
928
|
+
readonly phase?: LaunchpadPhase;
|
|
929
|
+
constructor(phase?: LaunchpadPhase, options?: {
|
|
930
|
+
cause?: unknown;
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
/** Trading is paused, either protocol-wide or for this token. */
|
|
934
|
+
declare class LaunchpadTradingPausedError extends LaunchpadError {
|
|
935
|
+
readonly scope: "protocol" | "token";
|
|
936
|
+
readonly mode?: LaunchpadPauseMode;
|
|
937
|
+
constructor(scope: "protocol" | "token", mode?: LaunchpadPauseMode, options?: {
|
|
938
|
+
cause?: unknown;
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
/** The launch block forbids trading; retry from `nextEligibleBlock`. */
|
|
942
|
+
declare class LaunchpadProtectionError extends LaunchpadError {
|
|
943
|
+
readonly nextEligibleBlock?: bigint;
|
|
944
|
+
constructor(nextEligibleBlock?: bigint, options?: {
|
|
945
|
+
cause?: unknown;
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
/** The quote moved past the caller's tolerance; re-quote before retrying. */
|
|
949
|
+
declare class LaunchpadSlippageError extends LaunchpadError {
|
|
950
|
+
constructor(options?: {
|
|
951
|
+
cause?: unknown;
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
/** The deadline elapsed. The transaction must be rebuilt, never replayed. */
|
|
955
|
+
declare class LaunchpadDeadlineExpiredError extends LaunchpadError {
|
|
956
|
+
constructor(options?: {
|
|
957
|
+
cause?: unknown;
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
/** An ERC-20 approval is required before the operation can succeed. */
|
|
961
|
+
declare class LaunchpadApprovalRequiredError extends LaunchpadError {
|
|
962
|
+
readonly asset: Address;
|
|
963
|
+
readonly spender: Address;
|
|
964
|
+
readonly requiredAmount: bigint;
|
|
965
|
+
constructor(asset: Address, spender: Address, requiredAmount: bigint);
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* The account cannot cover the amount a transfer would move.
|
|
969
|
+
*
|
|
970
|
+
* Checked alongside the allowance during `prepare*`, because the Portal moves funds through
|
|
971
|
+
* `SafeTransferLib`, which collapses every underlying failure into an opaque `TransferFailed()`.
|
|
972
|
+
* Without this check an insufficient balance surfaces as an unmapped revert that gives the caller
|
|
973
|
+
* no way to tell "top up" apart from a genuine contract fault.
|
|
974
|
+
*/
|
|
975
|
+
declare class LaunchpadInsufficientBalanceError extends LaunchpadError {
|
|
976
|
+
readonly asset: Address;
|
|
977
|
+
readonly account: Address;
|
|
978
|
+
readonly requiredAmount: bigint;
|
|
979
|
+
readonly balance: bigint;
|
|
980
|
+
constructor(asset: Address, account: Address, requiredAmount: bigint, balance: bigint);
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* The wallet switched accounts between preparing and broadcasting.
|
|
984
|
+
*
|
|
985
|
+
* The simulated request is bound to the account it was prepared for — allowances, balances, and the
|
|
986
|
+
* `from` address were all resolved against it — so it must not be sent from a different account.
|
|
987
|
+
*/
|
|
988
|
+
declare class PreparedAccountMismatchError extends LaunchpadError {
|
|
989
|
+
readonly expectedAccount: Address;
|
|
990
|
+
readonly actualAccount: Address;
|
|
991
|
+
constructor(expectedAccount: Address, actualAccount: Address);
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* The value passed to a send call did not originate from this SDK's prepare pipeline, or belongs to
|
|
995
|
+
* a different deployment. Broadcasting it would skip simulation and the safety checks around it.
|
|
996
|
+
*/
|
|
997
|
+
declare class ForgedPreparedTransactionError extends LaunchpadError {
|
|
998
|
+
constructor(message: string);
|
|
999
|
+
}
|
|
1000
|
+
/** A write was attempted on a client constructed without a Wallet Client. */
|
|
1001
|
+
declare class MissingWalletClientError extends LaunchpadError {
|
|
1002
|
+
constructor();
|
|
1003
|
+
}
|
|
1004
|
+
/** There is no claimable balance for this account and asset; the Locker would revert. */
|
|
1005
|
+
declare class LaunchpadNothingToClaimError extends LaunchpadError {
|
|
1006
|
+
readonly asset: Address;
|
|
1007
|
+
readonly account: Address;
|
|
1008
|
+
constructor(asset: Address, account: Address);
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* No locked position is registered under the given LP NFT id.
|
|
1012
|
+
*
|
|
1013
|
+
* Usually means the id came from the wrong source: it is a Uniswap V3 position NFT id, not a token
|
|
1014
|
+
* address, and only ids minted by this deployment's migrator are registered here.
|
|
1015
|
+
*/
|
|
1016
|
+
declare class LaunchpadUnknownPositionError extends LaunchpadError {
|
|
1017
|
+
readonly tokenId: bigint;
|
|
1018
|
+
constructor(tokenId: bigint);
|
|
1019
|
+
}
|
|
1020
|
+
/**
|
|
1021
|
+
* The official V3 pool rejects liquidity operations before graduation.
|
|
1022
|
+
*
|
|
1023
|
+
* `LaunchToken` keeps its official pool locked until the Portal migrates it, so an attempt to seed
|
|
1024
|
+
* or trade that pool early reverts here rather than silently competing with the bonding curve.
|
|
1025
|
+
*/
|
|
1026
|
+
declare class LaunchpadOfficialPoolLockedError extends LaunchpadError {
|
|
1027
|
+
constructor(options?: {
|
|
1028
|
+
cause?: unknown;
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
/** The wallet is connected to a different chain than the requested deployment. */
|
|
1032
|
+
declare class WrongWalletChainError extends LaunchpadError {
|
|
1033
|
+
readonly expectedChainId: number;
|
|
1034
|
+
readonly actualChainId?: number;
|
|
1035
|
+
constructor(expectedChainId: number, actualChainId?: number);
|
|
1036
|
+
}
|
|
1037
|
+
/** Extracts the reverted custom-error name from a viem error chain, if present. */
|
|
1038
|
+
declare function revertErrorName(error: unknown): string | undefined;
|
|
1039
|
+
/**
|
|
1040
|
+
* Maps a contract failure onto a stable SDK error using the decoded custom-error name, never the
|
|
1041
|
+
* message text. Unrecognized failures fall back to the shared core error codes, preserving the
|
|
1042
|
+
* original cause and request metadata.
|
|
1043
|
+
*/
|
|
1044
|
+
declare function toLaunchpadError(error: unknown): Error;
|
|
1045
|
+
|
|
1046
|
+
/** Regular curve trade fee once the protection window has elapsed (`Portal.TRADE_FEE_BPS`). */
|
|
1047
|
+
declare const TRADE_FEE_BPS = 100;
|
|
1048
|
+
/** `Portal.BPS`. A fee of exactly this value means trading is disabled, not a 100% fee. */
|
|
1049
|
+
declare const BPS = 10000;
|
|
1050
|
+
/** `Portal.MAX_PROTECTION_BLOCKS`. Creators may choose fewer, so never assume this value. */
|
|
1051
|
+
declare const MAX_PROTECTION_BLOCKS = 6;
|
|
1052
|
+
/**
|
|
1053
|
+
* Reproduces `Portal._tradeFeeBps(state)` for a given block.
|
|
1054
|
+
*
|
|
1055
|
+
* Returns `BPS` (10000) only for the launch block itself, which the Portal rejects with
|
|
1056
|
+
* `LaunchBlockTradingDisabled`. Use {@link isLaunchBlockTradingDisabled} rather than comparing
|
|
1057
|
+
* the returned fee to 10000 at call sites.
|
|
1058
|
+
*/
|
|
1059
|
+
declare function tradeFeeBpsAt(launchBlock: bigint, protectionBlocks: number, blockNumber: bigint): number;
|
|
1060
|
+
/** True when the Portal would revert with `LaunchBlockTradingDisabled` at this block. */
|
|
1061
|
+
declare function isLaunchBlockTradingDisabled(launchBlock: bigint, protectionBlocks: number, blockNumber: bigint): boolean;
|
|
1062
|
+
/**
|
|
1063
|
+
* First block at which curve trading is permitted. With `protectionBlocks === 0` the ladder is
|
|
1064
|
+
* skipped entirely and the launch block itself is tradable.
|
|
1065
|
+
*/
|
|
1066
|
+
declare function firstTradableBlock(launchBlock: bigint, protectionBlocks: number): bigint;
|
|
1067
|
+
/**
|
|
1068
|
+
* Derives trade availability from already-read state, so a UI can render the fee, the reason
|
|
1069
|
+
* trading is blocked, and the next tradable block without duplicating protection rules.
|
|
1070
|
+
*/
|
|
1071
|
+
declare function toLaunchpadTradeAvailability(state: LaunchpadTokenState, blockNumber: bigint, protocolPaused: boolean): LaunchpadTradeAvailability;
|
|
1072
|
+
|
|
1073
|
+
/** Hard ceiling on caller-supplied slippage. Anything above this is rejected outright. */
|
|
1074
|
+
declare const MAX_SLIPPAGE_BPS = 1000;
|
|
1075
|
+
/** Default deadline horizon: ten minutes from the reference chain time. */
|
|
1076
|
+
declare const DEFAULT_DEADLINE_SECONDS = 600n;
|
|
1077
|
+
declare class InvalidSlippageError extends Error {
|
|
1078
|
+
readonly bps: number;
|
|
1079
|
+
constructor(bps: number, message: string);
|
|
1080
|
+
}
|
|
1081
|
+
declare class InvalidDeadlineError extends Error {
|
|
1082
|
+
constructor(message: string);
|
|
1083
|
+
}
|
|
1084
|
+
/** Validates a slippage tolerance against the 0..10% range. */
|
|
1085
|
+
declare function assertSlippage(slippage: Slippage): number;
|
|
1086
|
+
/**
|
|
1087
|
+
* Applies slippage to a quoted output, rounding **down** so the on-chain minimum is never more
|
|
1088
|
+
* optimistic than the quote. Rejects a zero expected output, because a zero `minOut` would
|
|
1089
|
+
* disable the contract's own slippage guard.
|
|
1090
|
+
*/
|
|
1091
|
+
declare function applySlippageToMinimumOut(expectedOut: bigint, slippage: Slippage): bigint;
|
|
1092
|
+
/**
|
|
1093
|
+
* Builds a transaction deadline from a reference chain timestamp. The reference must come from a
|
|
1094
|
+
* block, not the client clock, because the Portal compares against `block.timestamp`.
|
|
1095
|
+
*/
|
|
1096
|
+
declare function toDeadline(referenceTimestamp: bigint, seconds?: bigint): bigint;
|
|
1097
|
+
/** Rounds up `x * y / denominator`, mirroring `Portal._mulDivUp`. */
|
|
1098
|
+
declare function mulDivUp(x: bigint, y: bigint, denominator: bigint): bigint;
|
|
1099
|
+
|
|
1100
|
+
/**
|
|
1101
|
+
* Parsed view of `CreateParams.metadata`. Every field is optional because the on-chain value is an
|
|
1102
|
+
* opaque, untrusted string that any creator can set to anything.
|
|
1103
|
+
*
|
|
1104
|
+
* The SDK deliberately does not validate URL schemes, fetch images, sanitize HTML, or moderate
|
|
1105
|
+
* content — that belongs to the application and its metadata service. `raw` is always preserved so
|
|
1106
|
+
* callers can apply their own policy.
|
|
1107
|
+
*/
|
|
1108
|
+
interface LaunchpadMetadata {
|
|
1109
|
+
readonly raw: string;
|
|
1110
|
+
/** True only when `raw` parsed as a JSON object. */
|
|
1111
|
+
readonly valid: boolean;
|
|
1112
|
+
readonly description?: string;
|
|
1113
|
+
readonly image?: string;
|
|
1114
|
+
readonly website?: string;
|
|
1115
|
+
/** Any other top-level keys, preserved without interpretation. */
|
|
1116
|
+
readonly extra: Readonly<Record<string, unknown>>;
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Parses token metadata without ever throwing. Invalid JSON, JSON primitives, arrays, `null`, and
|
|
1120
|
+
* unexpected field types all degrade to `valid: false` (or a missing field) rather than an error,
|
|
1121
|
+
* so a single malformed token can never break a list render.
|
|
1122
|
+
*/
|
|
1123
|
+
declare function parseLaunchpadMetadata(raw: string): LaunchpadMetadata;
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* Typed client configuration.
|
|
1127
|
+
*
|
|
1128
|
+
* The client is configured from a single {@link LaunchpadChainConfig}, which already carries the
|
|
1129
|
+
* verified {@link LaunchpadDeployment} plus the product `capabilities`. Taking one object avoids the
|
|
1130
|
+
* drift that two parallel sources (a deployment here, capabilities elsewhere) would allow, and it
|
|
1131
|
+
* makes the capability gate impossible to omit.
|
|
1132
|
+
*/
|
|
1133
|
+
interface LaunchpadPortalClientConfig {
|
|
1134
|
+
readonly publicClient: PublicClient;
|
|
1135
|
+
readonly walletClient?: WalletClient;
|
|
1136
|
+
readonly chain: LaunchpadChainConfig;
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* Strongly typed client bound to one verified deployment.
|
|
1140
|
+
*
|
|
1141
|
+
* This is the primary business API. The ABI-neutral `adapter.read/write` client remains available
|
|
1142
|
+
* for versions this SDK does not yet cover and for test adapters, but production call sites should
|
|
1143
|
+
* use these methods.
|
|
1144
|
+
*
|
|
1145
|
+
* Write paths are gated by the chain's declared capabilities, so a product that has not enabled
|
|
1146
|
+
* rewards (the default) cannot prepare a claim even by mistake. Reads are never gated: a page must
|
|
1147
|
+
* be able to render state without a signer and regardless of which writes are enabled.
|
|
1148
|
+
*/
|
|
1149
|
+
interface LaunchpadPortalClient {
|
|
1150
|
+
readonly chain: LaunchpadChainConfig;
|
|
1151
|
+
readonly deployment: LaunchpadDeployment;
|
|
1152
|
+
readonly publicClient: PublicClient;
|
|
1153
|
+
readonly walletClient?: WalletClient;
|
|
1154
|
+
getTokenState(token: Address, options?: LaunchpadReadOptions): Promise<LaunchpadTokenState>;
|
|
1155
|
+
getTokenMetadata(token: Address, options?: LaunchpadReadOptions): Promise<string>;
|
|
1156
|
+
getPrice(token: Address, options?: LaunchpadReadOptions): Promise<LaunchpadPrice>;
|
|
1157
|
+
quoteBuy(token: Address, quoteIn: bigint, options?: LaunchpadReadOptions): Promise<BuyQuote>;
|
|
1158
|
+
quoteSell(token: Address, tokenIn: bigint, options?: LaunchpadReadOptions): Promise<SellQuote>;
|
|
1159
|
+
/** Curve constants for this deployment; immutable, so callers may cache the result. */
|
|
1160
|
+
getCurveConstants(options?: LaunchpadReadOptions): Promise<LaunchpadCurveConstants>;
|
|
1161
|
+
/**
|
|
1162
|
+
* Prices a creator's atomic first buy. `prepareCreateToken` calls this internally, so a caller
|
|
1163
|
+
* only needs it to preview a first buy before committing to one.
|
|
1164
|
+
*/
|
|
1165
|
+
quoteCreatorFirstBuy(quoteIn: bigint, options?: LaunchpadReadOptions & {
|
|
1166
|
+
readonly constants?: LaunchpadCurveConstants;
|
|
1167
|
+
}): Promise<BuyQuote>;
|
|
1168
|
+
getTradeAvailability(token: Address, options?: LaunchpadReadOptions): Promise<LaunchpadTradeAvailability>;
|
|
1169
|
+
getBalance(asset: Address, account: Address, options?: LaunchpadReadOptions): Promise<bigint>;
|
|
1170
|
+
getAllowance(asset: Address, owner: Address, spender: Address, options?: LaunchpadReadOptions): Promise<bigint>;
|
|
1171
|
+
getApprovalStatus(input: {
|
|
1172
|
+
readonly asset: Address;
|
|
1173
|
+
readonly owner: Address;
|
|
1174
|
+
readonly requiredAmount: bigint;
|
|
1175
|
+
readonly spender?: Address;
|
|
1176
|
+
}, options?: LaunchpadReadOptions): Promise<LaunchpadApprovalStatus>;
|
|
1177
|
+
getClaimableReward(account: Address, asset: Address, options?: LaunchpadReadOptions): Promise<bigint>;
|
|
1178
|
+
/** Token name, symbol, and decimals, read together at one block. */
|
|
1179
|
+
getErc20Metadata(asset: Address, options?: LaunchpadReadOptions): Promise<LaunchpadErc20Metadata>;
|
|
1180
|
+
/**
|
|
1181
|
+
* Looks up a locked V3 position by its LP NFT id, or `undefined` when unregistered.
|
|
1182
|
+
*
|
|
1183
|
+
* The id comes from the indexing service or a migration receipt — the Locker keeps no reverse
|
|
1184
|
+
* index from token address to `tokenId`.
|
|
1185
|
+
*/
|
|
1186
|
+
getLockedPosition(tokenId: bigint, options?: LaunchpadReadOptions): Promise<LaunchpadLockedPosition | undefined>;
|
|
1187
|
+
/**
|
|
1188
|
+
* Curve progress for a token screen: tokens remaining, percentage, and market cap, all pinned to
|
|
1189
|
+
* one block. Pass `constants` to reuse an already-read copy.
|
|
1190
|
+
*/
|
|
1191
|
+
getCurveProgress(token: Address, options?: LaunchpadReadOptions & {
|
|
1192
|
+
readonly constants?: LaunchpadCurveConstants;
|
|
1193
|
+
}): Promise<LaunchpadCurveProgress>;
|
|
1194
|
+
/**
|
|
1195
|
+
* Previews the CREATE2 address a token would get if this creator launched it now.
|
|
1196
|
+
*
|
|
1197
|
+
* A preview, not a reservation: the Portal mixes an auto-incrementing per-creator nonce into the
|
|
1198
|
+
* salt, so the prediction stops holding once this creator launches anything. Take the real
|
|
1199
|
+
* address from the receipt's `TokenCreated` event.
|
|
1200
|
+
*/
|
|
1201
|
+
predictTokenAddress(input: {
|
|
1202
|
+
readonly creator: Address;
|
|
1203
|
+
readonly name: string;
|
|
1204
|
+
readonly symbol: string;
|
|
1205
|
+
readonly userSalt: Hex;
|
|
1206
|
+
}, options?: LaunchpadReadOptions): Promise<PredictedLaunchpadToken>;
|
|
1207
|
+
/** ERC-20 approval. Ungated: a plain token approval is not a Launchpad protocol write. */
|
|
1208
|
+
prepareApprove(input: {
|
|
1209
|
+
readonly asset: Address;
|
|
1210
|
+
readonly amount: bigint;
|
|
1211
|
+
readonly spender?: Address;
|
|
1212
|
+
}): Promise<PreparedLaunchpadTransaction<ApprovalPreview>>;
|
|
1213
|
+
/** Requires the `create` capability. */
|
|
1214
|
+
prepareCreateToken(input: CreateTokenInput): Promise<PreparedLaunchpadTransaction<CreateTokenPreview>>;
|
|
1215
|
+
/** Requires the `bondingTrade` capability. */
|
|
1216
|
+
prepareBuy(input: {
|
|
1217
|
+
readonly token: Address;
|
|
1218
|
+
readonly quoteIn: bigint;
|
|
1219
|
+
readonly slippage: Slippage;
|
|
1220
|
+
readonly deadline: bigint;
|
|
1221
|
+
}): Promise<PreparedLaunchpadTransaction<BuyQuote>>;
|
|
1222
|
+
/** Requires the `bondingTrade` capability. */
|
|
1223
|
+
prepareSell(input: {
|
|
1224
|
+
readonly token: Address;
|
|
1225
|
+
readonly tokenIn: bigint;
|
|
1226
|
+
readonly slippage: Slippage;
|
|
1227
|
+
readonly deadline: bigint;
|
|
1228
|
+
}): Promise<PreparedLaunchpadTransaction<SellQuote>>;
|
|
1229
|
+
/**
|
|
1230
|
+
* Migration is permissionless on-chain and completes a token that has already graduated, so it is
|
|
1231
|
+
* deliberately **not** gated by a product capability — disabling it would leave graduated tokens
|
|
1232
|
+
* stranded even though anyone can call `migrate`.
|
|
1233
|
+
*/
|
|
1234
|
+
prepareMigration(token: Address): Promise<PreparedLaunchpadTransaction<MigrationPreview>>;
|
|
1235
|
+
/**
|
|
1236
|
+
* Collects a locked position's V3 fees into the Locker, crediting the creator's share.
|
|
1237
|
+
*
|
|
1238
|
+
* Permissionless like migration, and likewise **not** gated by `rewards`: the Locker always
|
|
1239
|
+
* credits `positions[tokenId].creator` rather than the caller, and gating it would strand fees
|
|
1240
|
+
* that belong to creators whenever the capability is off. It is the step that makes
|
|
1241
|
+
* `prepareClaimReward` able to pay out anything at all.
|
|
1242
|
+
*/
|
|
1243
|
+
prepareCollectFees(tokenId: bigint): Promise<PreparedLaunchpadTransaction<CollectFeesPreview>>;
|
|
1244
|
+
/** Requires the `rewards` capability, which defaults to off. */
|
|
1245
|
+
prepareClaimReward(input: {
|
|
1246
|
+
readonly asset: Address;
|
|
1247
|
+
readonly recipient?: Address;
|
|
1248
|
+
}): Promise<PreparedLaunchpadTransaction<ClaimPreview>>;
|
|
1249
|
+
send(prepared: PreparedLaunchpadTransaction<unknown>): Promise<Hash>;
|
|
1250
|
+
wait(hash: Hash, options?: {
|
|
1251
|
+
readonly confirmations?: number;
|
|
1252
|
+
}): Promise<LaunchpadTransactionResult>;
|
|
1253
|
+
}
|
|
1254
|
+
/** Creates a typed client for one verified Launchpad deployment. */
|
|
1255
|
+
declare function createLaunchpadPortalClient(config: LaunchpadPortalClientConfig): LaunchpadPortalClient;
|
|
1256
|
+
|
|
1257
|
+
/** Raised when on-chain state contradicts a registered deployment. */
|
|
1258
|
+
declare class LaunchpadDeploymentVerificationError extends Error {
|
|
1259
|
+
readonly field: string;
|
|
1260
|
+
readonly expected: string;
|
|
1261
|
+
readonly actual: string;
|
|
1262
|
+
constructor(field: string, expected: string, actual: string);
|
|
1263
|
+
}
|
|
1264
|
+
/**
|
|
1265
|
+
* Verifies that a registered {@link LaunchpadDeployment} matches live chain state before it is
|
|
1266
|
+
* trusted: the connected chain id, the Portal runtime bytecode hash, the Portal's core bindings
|
|
1267
|
+
* and default module registrations, and the Migrator/Locker cross-bindings. Throws
|
|
1268
|
+
* {@link LaunchpadDeploymentVerificationError} on the first mismatch. This performs read-only
|
|
1269
|
+
* calls; it never writes or broadcasts.
|
|
1270
|
+
*/
|
|
1271
|
+
declare function verifyLaunchpadDeployment(publicClient: PublicClient, deployment: LaunchpadDeployment): Promise<void>;
|
|
1272
|
+
|
|
1273
|
+
export { type ApprovalPreview, BPS, type BuyQuote, type ClaimPreview, type CollectFeesPreview, type CreateTokenInput, type CreateTokenPreview, DEFAULT_DEADLINE_SECONDS, ForgedPreparedTransactionError, InvalidDeadlineError, InvalidLaunchpadChainConfigError, InvalidLaunchpadDeploymentError, InvalidLaunchpadReadInputError, InvalidLaunchpadStateError, InvalidSlippageError, type LaunchpadActionContext, type LaunchpadAdapterRegistry, LaunchpadApprovalRequiredError, type LaunchpadApprovalStatus, type LaunchpadAssetRef, type LaunchpadCapability, type LaunchpadChainConfig, type LaunchpadChainRegistry, type LaunchpadClient, type LaunchpadClientConfig, type LaunchpadContractAdapter, type LaunchpadContracts, type LaunchpadCurveConstants, type LaunchpadCurveProgress, type LaunchpadCurveState, LaunchpadDeadlineExpiredError, type LaunchpadDeployment, type LaunchpadDeploymentRegistry, LaunchpadDeploymentVerificationError, type LaunchpadErc20Metadata, LaunchpadError, type LaunchpadGraduationProgress, LaunchpadInsufficientBalanceError, type LaunchpadLockedPosition, type LaunchpadMetadata, type LaunchpadMigrationCompletedEvent, type LaunchpadMigrationStartedEvent, LaunchpadNothingToClaimError, LaunchpadOfficialPoolLockedError, type LaunchpadPauseMode, type LaunchpadPhase, LaunchpadPhaseUnavailableError, type LaunchpadPortalClient, type LaunchpadPortalClientConfig, type LaunchpadPrice, LaunchpadProtectionError, type LaunchpadQuoteTokenConfig, type LaunchpadReadContext, type LaunchpadReadOptions, type LaunchpadReadRequest, type LaunchpadReceiptEvents, type LaunchpadRewardsClaimedEvent, LaunchpadSlippageError, type LaunchpadTokenCreatedEvent, type LaunchpadTokenId, type LaunchpadTokenState, type LaunchpadTradeAvailability, type LaunchpadTradeBlockedReason, type LaunchpadTradeEvent, LaunchpadTradingPausedError, type LaunchpadTransactionResult, LaunchpadUnknownPositionError, type LaunchpadWriteActionContext, type LaunchpadWriteContext, type LaunchpadWriteRequest, MAX_PROTECTION_BLOCKS, MAX_SLIPPAGE_BPS, type MigrationPreview, MissingWalletClientError, PRICE_WAD_SCALE, type PredictedLaunchpadToken, PreparedAccountMismatchError, type PreparedLaunchpadTransaction, type PreparedLaunchpadTransactionContext, type RawLaunchpadTokenState, type SellQuote, type Slippage, TRADE_FEE_BPS, UnpinnableBlockTagError, UnsupportedLaunchpadCapabilityError, WrongWalletChainError, applySlippageToMinimumOut, arcTestnetChainId, arcTestnetLaunchpadDeployment, assertSlippage, buyPriceImpactBps, createLaunchpadClient, createLaunchpadPortalClient, createdTokenAddress, creatorFirstBuyFee, curvePriceWadAt, defineLaunchpadChain, defineLaunchpadDeployment, defineLaunchpadDeploymentRegistry, defineLaunchpadTokenId, firstTradableBlock, getClaimableLaunchpadReward, getErc20Allowance, getErc20Balance, getErc20Metadata, getLaunchpadApprovalStatus, getLaunchpadCurveConstants, getLaunchpadCurveProgress, getLaunchpadPrice, getLaunchpadTokenMetadata, getLaunchpadTokenState, getLaunchpadTradeAvailability, getLockedLaunchpadPosition, graduationMarketCapQuote, graduationProgress, initialCurveState, isLaunchBlockTradingDisabled, launchpadDeploymentRegistry, marketCapQuote, mulDivUp, parseLaunchpadMetadata, parseLaunchpadReceiptEvents, predictLaunchpadTokenAddress, prepareApproveErc20, prepareClaimLaunchpadReward, prepareCollectLaunchpadFees, prepareCreateToken, prepareLaunchpadBuy, prepareLaunchpadMigration, prepareLaunchpadSell, priceImpactBps, priceWadPerWholeToken, quoteCreatorFirstBuy, quoteLaunchpadBuy, quoteLaunchpadSell, resolveLaunchpadDeployment, resolvePinnedBlockNumber, revertErrorName, sellPriceImpactBps, sendPreparedLaunchpadTransaction, toCreatorFirstBuyQuote, toDeadline, toLaunchpadError, toLaunchpadPauseMode, toLaunchpadPhase, toLaunchpadTokenState, toLaunchpadTradeAvailability, tradeFee, tradeFeeBpsAt, verifyLaunchpadDeployment, waitForLaunchpadTransaction };
|