@fazedotfun/sdk 0.5.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/LICENSE +21 -0
- package/README.md +231 -0
- package/dist/chain.d.mts +142 -0
- package/dist/chain.mjs +1 -0
- package/dist/index-DiWbmSpu.d.mts +834 -0
- package/dist/public.d.mts +560 -0
- package/dist/public.mjs +1 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Varpa Labs Ltd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# @fazedotfun/sdk
|
|
2
|
+
|
|
3
|
+
Official EVM client SDK for the Faze platform.
|
|
4
|
+
|
|
5
|
+
Coins live on a bonding curve until they graduate into a Uniswap v4 pool whose liquidity position is burned. Every
|
|
6
|
+
transaction is signed and broadcast by **your** wallet or **your** key - the platform is non-custodial and never holds
|
|
7
|
+
one.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install @fazedotfun/sdk
|
|
13
|
+
# only if you sign or build transactions yourself (see "Trade with a key")
|
|
14
|
+
npm install viem
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Read
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { createClient } from '@fazedotfun/sdk';
|
|
21
|
+
|
|
22
|
+
const client = createClient({ baseUrl: 'https://<your-api-origin>/api/v1' });
|
|
23
|
+
|
|
24
|
+
const { coins } = await client.listCoins({ sort: 'trending' });
|
|
25
|
+
const { launch, metrics } = await client.getCoinSummary(coins[0].mint);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Reads are anonymous. What is available:
|
|
29
|
+
|
|
30
|
+
- **Coins** - `listCoins`, `getCoinSummary`, `getLaunch`, `listLaunches`, `getCoinMetrics`, `getCoinHolders`,
|
|
31
|
+
`getCoinTraders`, `getCoinTrades`, `getCoinBurns`, `getCandles`, `getActivity`, `getCoinSentiment`, `getPoolFee`,
|
|
32
|
+
`getNativeUsdRates`.
|
|
33
|
+
- **Wallets** - `getWalletHoldings`, `getWalletPnl`, `getWalletTrades`, `getWalletTradingStats`, `getWalletPnlCurve`,
|
|
34
|
+
`getCreatorStats`, `getProfile`, `checkHandle`.
|
|
35
|
+
- **World** - `getWorldProps`, `getWorldPlayers`, `searchWorldPlayers`, `getBazaar`, `getRing`, `getPlacements`,
|
|
36
|
+
`getAdBoards`, `getAdPulse`.
|
|
37
|
+
|
|
38
|
+
Anything that identifies a caller - `getWatchlist`, `watchCoin`, `setCoinSentiment`, `getMyProfile`, `updateProfile`,
|
|
39
|
+
`walletModeration` - needs a session and a linked wallet.
|
|
40
|
+
|
|
41
|
+
Balances, quotes, transaction building and receipts are **not** here: those are chain reads, and they belong to the RPC
|
|
42
|
+
you choose rather than to ours. `/chain` below covers all of them.
|
|
43
|
+
|
|
44
|
+
### A coin's quote asset
|
|
45
|
+
|
|
46
|
+
Every coin raises and trades in ONE quote asset for its whole life: the chain's native gas token by default, or an
|
|
47
|
+
ERC-20 the platform has approved for that deployment (a tokenized stock, a stablecoin). `getLaunchConfig().quoteAssets`
|
|
48
|
+
lists the approved ones - address, symbol, `decimals`, the on-chain target band - and a launch record carries the coin's
|
|
49
|
+
choice as `providerMeta.quoteToken` (null = native) with `quoteDecimals` beside it. **Every amount on that coin is in
|
|
50
|
+
its quote's base units**: wei of the gas token on a native-quoted coin, the ERC-20's own decimals otherwise.
|
|
51
|
+
|
|
52
|
+
## Link a wallet
|
|
53
|
+
|
|
54
|
+
A session is a cookie the API mints; a wallet is bound to it by signing a single-use challenge. Do this once, before any
|
|
55
|
+
launch, watchlist write, or server-built trade.
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
const { termsVersion } = await client.getLaunchConfig();
|
|
59
|
+
|
|
60
|
+
const { message } = await client.walletChallenge();
|
|
61
|
+
const signature = await wallet.signMessage({ message }); // EIP-191 personal_sign
|
|
62
|
+
await client.walletLink({ publicKey: address, signature, acceptedTermsVersion: termsVersion });
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`acceptedTermsVersion` records which terms the user agreed to, so it comes from the deployment rather than from you -
|
|
66
|
+
`getLaunchConfig().termsVersion` is the value it expects, and a link that names a different one is refused. Read it
|
|
67
|
+
rather than hardcoding it: it changes when the terms do, and the 403 that a stale one earns carries the current version,
|
|
68
|
+
so a client can self-heal without re-reading the config.
|
|
69
|
+
|
|
70
|
+
The challenge is single-use: a second `walletLink` against the same message is a 409, so retry from `walletChallenge`,
|
|
71
|
+
not from the signature.
|
|
72
|
+
|
|
73
|
+
Server-side consumers have no cookie jar; pass the session through `createClient({ headers })`.
|
|
74
|
+
|
|
75
|
+
## Trade with a key
|
|
76
|
+
|
|
77
|
+
The shortest path from a private key to a confirmed trade. It picks the venue off the coin's lifecycle, quotes for your
|
|
78
|
+
own address, builds against **your** RPC, broadcasts the built requests in order (waiting for each receipt, because a
|
|
79
|
+
swap sent before its approve reverts), and serializes its own sends so one key's nonce sequence stays single-threaded.
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
import { createClient } from '@fazedotfun/sdk';
|
|
83
|
+
import { createTrader } from '@fazedotfun/sdk/chain';
|
|
84
|
+
|
|
85
|
+
const client = createClient({ baseUrl: 'https://<your-api-origin>/api/v1' });
|
|
86
|
+
const trader = createTrader({
|
|
87
|
+
client,
|
|
88
|
+
privateKey: process.env.PRIVATE_KEY as `0x${string}`,
|
|
89
|
+
rpcUrl: 'https://your-own-rpc.example',
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const quote = await trader.quote({ mint, side: 'buy', amountIn: 10_000_000_000_000_000n });
|
|
93
|
+
|
|
94
|
+
const result = await trader.trade({ mint, side: 'buy', amountIn: 10_000_000_000_000_000n, slippageBps: 100 });
|
|
95
|
+
result.status; // 'confirmed' | 'reverted' - a revert is what the receipt said, not a client error
|
|
96
|
+
result.hashes; // every hash broadcast, in order; the last is the swap
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`amountIn` is base units: the coin's quote on a buy (wei of the gas token, or the quote asset's own decimals on a
|
|
100
|
+
stock-paired coin), coin units on a sell (`trader.coinBalance(mint)` reads the position, `trader.nativeBalance()` the
|
|
101
|
+
gas). On a stock-paired coin the wallet must hold the QUOTE asset for a buy, and the trader prepends the approve legs it
|
|
102
|
+
needs - the quote on such a buy, the coin on a sell. No session is needed - the chain does not care who asks - so the
|
|
103
|
+
only API reads are the deployment's contract addresses and the coin's own row. If you gate access yourself,
|
|
104
|
+
`client.walletModeration()` is the platform's own standing check.
|
|
105
|
+
|
|
106
|
+
Quotes are per wallet on a fresh coin: while a coin's sniper-tax window is open (up to 30 seconds from launch), a buy
|
|
107
|
+
from a wallet the launch did not exempt pays a 99% fee decaying to the base fee, so the trader always quotes for its own
|
|
108
|
+
key. A quote for an anonymous address is the worst case, never yours.
|
|
109
|
+
|
|
110
|
+
The key never leaves your process: it signs locally and only the signed transaction reaches the RPC.
|
|
111
|
+
|
|
112
|
+
## Build transactions, sign elsewhere
|
|
113
|
+
|
|
114
|
+
If the key lives somewhere this process cannot reach - a browser wallet, a remote signer, an HSM - take the builders
|
|
115
|
+
instead. Same code, same math; broadcasting is yours.
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
import { createPublicClient, http } from 'viem';
|
|
119
|
+
import { buildCurveTrade, curveConfigFrom } from '@fazedotfun/sdk/chain';
|
|
120
|
+
|
|
121
|
+
const { curveContracts } = await client.getLaunchConfig();
|
|
122
|
+
if (!curveContracts) throw new Error('this deployment builds server-side');
|
|
123
|
+
|
|
124
|
+
const coin = await client.getLaunch(mint);
|
|
125
|
+
const built = await buildCurveTrade(
|
|
126
|
+
createPublicClient({ transport: http('https://your-own-rpc.example') }),
|
|
127
|
+
curveConfigFrom(curveContracts),
|
|
128
|
+
{
|
|
129
|
+
mint: coin.mint,
|
|
130
|
+
curveAddress: coin.providerMeta.curveAddress,
|
|
131
|
+
curveKind: coin.providerMeta.curveKind,
|
|
132
|
+
hookAddress: coin.providerMeta.hookAddress,
|
|
133
|
+
quoteToken: coin.providerMeta.quoteToken,
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
venue: 'curve',
|
|
137
|
+
side: 'buy',
|
|
138
|
+
amountIn: 10_000_000_000_000_000n,
|
|
139
|
+
slippageBps: 100,
|
|
140
|
+
owner,
|
|
141
|
+
buyer: owner,
|
|
142
|
+
nowMs: Date.now(),
|
|
143
|
+
},
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
for (const request of built.txRequests) {
|
|
147
|
+
const hash = await wallet.sendTransaction(request);
|
|
148
|
+
await waitForReceipt(hash); // ordered: a swap sent before its approve is mined will revert
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
`venue` is `'curve'` while the coin is on its bonding curve and `'dex'` once it has graduated -
|
|
153
|
+
`getLaunch(mint).lifecycleState` tells you which. An `abandoned` coin (its curve filled but it never graduated, and
|
|
154
|
+
after a week stuck the platform reopened it sell-only) still trades on the curve for a `sell`; a `buy` is refused before
|
|
155
|
+
anything is signed. Take the contract addresses from `getLaunchConfig().curveContracts` rather than hardcoding them: a
|
|
156
|
+
deployment can move a contract, and a stale address builds a perfectly valid transaction aimed at the wrong one. Pass
|
|
157
|
+
the coin's `quoteToken` stamp through: it decides which asset the approve legs cover and which side of the graduated
|
|
158
|
+
pool the coin sits on.
|
|
159
|
+
|
|
160
|
+
## Launch a coin
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
import { readFile } from 'node:fs/promises';
|
|
164
|
+
|
|
165
|
+
const upload = await client.uploadAndAwaitReady(await readFile('logo.png'), 'image/png');
|
|
166
|
+
const built = await client.buildLaunch({
|
|
167
|
+
name: 'My Coin',
|
|
168
|
+
ticker: 'MINE',
|
|
169
|
+
imageKey: upload.key,
|
|
170
|
+
compoundCommitBps: 2000, // 20% of your creator fee share compounds into locked liquidity
|
|
171
|
+
burnShareBps: 3000, // 30% buys and burns the coin; the remaining 50% is yours
|
|
172
|
+
/* ... */
|
|
173
|
+
});
|
|
174
|
+
const hashes: `0x${string}`[] = [];
|
|
175
|
+
for (const request of built.txRequests) {
|
|
176
|
+
const hash = await wallet.sendTransaction(request);
|
|
177
|
+
await waitForReceipt(hash); // ordered: each later request assumes the earlier one is mined
|
|
178
|
+
hashes.push(hash);
|
|
179
|
+
}
|
|
180
|
+
await client.confirmLaunch(built.launch.mint, { signature: hashes[0] });
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
The launch is the one transaction the platform still builds, because it is the one a client cannot build for itself:
|
|
184
|
+
`built.launch.mint` is the coin's address, predicted before the transaction is sent, so you can reference the coin
|
|
185
|
+
immediately. `imageKey` is a content hash from the upload, not a URL. `confirmLaunch` records the hash of the launch
|
|
186
|
+
transaction itself (the first request on a native raise; an ERC-20 dev buy puts an approve ahead of it); the platform's
|
|
187
|
+
own verifier is what flips the coin live once the transaction lands - read the receipt itself off your own RPC
|
|
188
|
+
(`trader.chainClient` is one, already pointed at your endpoint).
|
|
189
|
+
|
|
190
|
+
The optional fields are the launch's economics, validated against the deployment's config before anything is built:
|
|
191
|
+
`quoteToken` (an address from `quoteAssets`; omitted = native), `bondingTargetWei` (the raise, in that quote's base
|
|
192
|
+
units - `getLaunchConfig().raiseLadder` is the five-stop dollar ladder the form offers, the third stop its default), the
|
|
193
|
+
pool fee and window dials from the served menus, the creator pie below, and up to 30 `sniperExempt` wallets that pay the
|
|
194
|
+
base fee inside the coin's sniper-tax window (the launcher is exempt without being listed). A dev buy in an ERC-20 quote
|
|
195
|
+
adds an approve ahead of the launch transaction, so broadcast `txRequests` in order rather than assuming one.
|
|
196
|
+
|
|
197
|
+
**The creator pie.** The creator's share of every fee (70% at the default platform split) reads as 100%, and the launch
|
|
198
|
+
cuts it three ways: `compoundCommitBps` auto-compounds a slice into locked pool liquidity (1000-5000 in 1000 steps),
|
|
199
|
+
`burnShareBps` routes a slice to a buy-and-burn contract that market-buys the coin and sends it to the dead address
|
|
200
|
+
(1000-10000 in 1000 steps; 10000 with no compound commit burns everything), and the remainder pays the creator seat.
|
|
201
|
+
Together they may not exceed 10000; an off-menu or over-pie ask is refused before anything is built. A burn is chosen at
|
|
202
|
+
launch only, and it makes the launch THREE transactions: the launch, the burn contract deployed on the coin's predicted
|
|
203
|
+
pool, and the routing of the creator leg to it. Through the sale the burn is pending: the routing is the creator's own
|
|
204
|
+
dial, and the curve pays the leg to the contract from the first trade only while the deployment's
|
|
205
|
+
`curveCreatorFeesEnabled` (`getLaunchConfig()`) is on - off, as it ships, the curve legs settle to the treasury and
|
|
206
|
+
nothing reaches the contract before graduation. At graduation the contract becomes the coin's creator seat (when the
|
|
207
|
+
hook names a pass factory), which no code path can hand back from then on. Either share can only be raised afterwards,
|
|
208
|
+
never lowered, and a raise only ever spends the creator's own remainder.
|
|
209
|
+
|
|
210
|
+
The bytes must be a real, decodable image: the platform re-encodes every upload rather than serving what you sent, so a
|
|
211
|
+
placeholder string or a hand-written header is rejected at decode, not at validation. For a smoke test, this is a valid
|
|
212
|
+
1x1 PNG:
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
const onePixelPng = Buffer.from(
|
|
216
|
+
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==',
|
|
217
|
+
'base64',
|
|
218
|
+
);
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Errors
|
|
222
|
+
|
|
223
|
+
Every method throws `ApiError` (carrying `status`, the API's stable `apiError` identifier, and on a schema-validation
|
|
224
|
+
400 a `details` array of `{field, reason}` naming exactly which field was refused) or `RateLimitError` (carrying
|
|
225
|
+
`retryAfterMs`). Branch on `apiError`; render `reason`. Responses are validated at the boundary, so a drifting API fails
|
|
226
|
+
at the edge rather than deep in your own code.
|
|
227
|
+
|
|
228
|
+
## License
|
|
229
|
+
|
|
230
|
+
MIT - see [LICENSE](./LICENSE). It covers this client package. It is not a grant over the Faze platform, its name,
|
|
231
|
+
or the services this client talks to.
|
package/dist/chain.d.mts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { $ as TradeSide, Dt as CurveRelease, M as EvmTxRequest, Ot as EvmCurveProtocolAddresses, Q as TradeQuote, R as LaunchLifecycleState, j as CurveContracts, z as LaunchProviderMeta } from "./index-DiWbmSpu.mjs";
|
|
2
|
+
import { PublicClient } from "viem";
|
|
3
|
+
export declare class ProtocolError extends Error {
|
|
4
|
+
constructor(message: string, options?: ErrorOptions);
|
|
5
|
+
}
|
|
6
|
+
interface CurveConfig {
|
|
7
|
+
chainId: number;
|
|
8
|
+
addresses: EvmCurveProtocolAddresses;
|
|
9
|
+
}
|
|
10
|
+
interface CurveCoinRef {
|
|
11
|
+
mint: string;
|
|
12
|
+
curveAddress: string | null;
|
|
13
|
+
stampedCurveAddress?: string | null | undefined;
|
|
14
|
+
curveKind?: 'v3' | 'v4' | undefined;
|
|
15
|
+
curveRelease?: CurveRelease | undefined;
|
|
16
|
+
hookAddress?: string | null | undefined;
|
|
17
|
+
quoteToken?: string | null | undefined;
|
|
18
|
+
}
|
|
19
|
+
export declare function coinBondingCurve(ref: CurveCoinRef, config: CurveConfig): string;
|
|
20
|
+
export declare function coinCurveRelease(ref: CurveCoinRef, config: CurveConfig): CurveRelease;
|
|
21
|
+
interface CurveCoinState {
|
|
22
|
+
creator: string;
|
|
23
|
+
feeBps: number;
|
|
24
|
+
migrationFeeBps: number;
|
|
25
|
+
complete: boolean;
|
|
26
|
+
graduated: boolean;
|
|
27
|
+
active: boolean;
|
|
28
|
+
ethOffset: bigint;
|
|
29
|
+
ethReserve: bigint;
|
|
30
|
+
tokenReserve: bigint;
|
|
31
|
+
bondingTarget: bigint;
|
|
32
|
+
quoteToken?: string | undefined;
|
|
33
|
+
sniperTaxWindow?: number | undefined;
|
|
34
|
+
openedAt?: bigint | undefined;
|
|
35
|
+
abandoned?: boolean | undefined;
|
|
36
|
+
completedAt?: bigint | undefined;
|
|
37
|
+
}
|
|
38
|
+
export declare function readCurveCoinState(client: PublicClient, config: CurveConfig, ref: CurveCoinRef): Promise<CurveCoinState>;
|
|
39
|
+
export declare function applySlippageFloor(expectedOut: bigint, slippageBps: number): bigint;
|
|
40
|
+
interface TradeInput {
|
|
41
|
+
venue: 'curve' | 'dex';
|
|
42
|
+
side: TradeSide;
|
|
43
|
+
amountIn: bigint;
|
|
44
|
+
slippageBps: number;
|
|
45
|
+
buyer?: string | undefined;
|
|
46
|
+
}
|
|
47
|
+
interface TradeBuildInput extends TradeInput {
|
|
48
|
+
owner: string;
|
|
49
|
+
nowMs: number;
|
|
50
|
+
}
|
|
51
|
+
interface BuiltTrade {
|
|
52
|
+
txRequests: EvmTxRequest[];
|
|
53
|
+
quote: TradeQuote;
|
|
54
|
+
}
|
|
55
|
+
export declare function quoteCurveTrade(client: PublicClient, config: CurveConfig, ref: CurveCoinRef, input: TradeInput): Promise<TradeQuote>;
|
|
56
|
+
export declare function buildCurveTrade(client: PublicClient, config: CurveConfig, ref: CurveCoinRef, input: TradeBuildInput): Promise<BuiltTrade>;
|
|
57
|
+
/**
|
|
58
|
+
* Turn the contract set the API serves (`getLaunchConfig().curveContracts`) into the config the builders take.
|
|
59
|
+
*
|
|
60
|
+
* Always go through this rather than assembling a config by hand: a deployment's effective addresses are its own, and
|
|
61
|
+
* the fields easiest to get wrong are the `legacy*` pair - they are deliberately distinct from the active curve and
|
|
62
|
+
* hook, because two contract releases run side by side and a coin launched on the older one still lives there. Fold
|
|
63
|
+
* them together and you will build a perfectly valid transaction against a curve that does not hold the coin, or
|
|
64
|
+
* quote against a hook the coin's pool does not carry.
|
|
65
|
+
*/
|
|
66
|
+
export declare function curveConfigFrom(contracts: CurveContracts): CurveConfig;
|
|
67
|
+
/** The API reads a trader needs. A `PlatformClient` satisfies this structurally - pass one straight in. */
|
|
68
|
+
interface TraderApi {
|
|
69
|
+
getLaunchConfig(): Promise<{
|
|
70
|
+
curveContracts?: CurveContracts | null | undefined;
|
|
71
|
+
}>;
|
|
72
|
+
getLaunch(mint: string): Promise<{
|
|
73
|
+
mint: string;
|
|
74
|
+
lifecycleState: LaunchLifecycleState;
|
|
75
|
+
providerMeta: LaunchProviderMeta;
|
|
76
|
+
}>;
|
|
77
|
+
}
|
|
78
|
+
interface TraderOptions {
|
|
79
|
+
/** The API client - `createClient({ baseUrl })` from the package root. */
|
|
80
|
+
client: TraderApi;
|
|
81
|
+
/**
|
|
82
|
+
* The trading wallet's private key, 0x-prefixed.
|
|
83
|
+
*
|
|
84
|
+
* It never leaves this process: it signs locally and only the signed transaction reaches the RPC. Load it from
|
|
85
|
+
* your own secret store - a key in source or in a browser bundle is a key that is already spent.
|
|
86
|
+
*/
|
|
87
|
+
privateKey: `0x${string}`;
|
|
88
|
+
/**
|
|
89
|
+
* The JSON-RPC endpoint for every chain read, broadcast and receipt poll.
|
|
90
|
+
*
|
|
91
|
+
* Yours to choose, and worth choosing deliberately: a trading loop's receipt polls dwarf everything else it does,
|
|
92
|
+
* and a chain's public endpoint will rate-limit a real one.
|
|
93
|
+
*/
|
|
94
|
+
rpcUrl: string;
|
|
95
|
+
/** Default slippage tolerance when a trade does not name one. Defaults to 100 (1%). */
|
|
96
|
+
slippageBps?: number;
|
|
97
|
+
/** How long to wait for a transaction's receipt before giving up on it. Defaults to 120s - generous on purpose,
|
|
98
|
+
* because a congested block is not a failure. */
|
|
99
|
+
confirmTimeoutMs?: number;
|
|
100
|
+
/** Receipt poll interval. Defaults to 1s. */
|
|
101
|
+
confirmPollMs?: number;
|
|
102
|
+
}
|
|
103
|
+
interface TradeRequest {
|
|
104
|
+
mint: string;
|
|
105
|
+
side: TradeSide;
|
|
106
|
+
/** buy: native base units (wei) to spend. sell: base units of the COIN to sell. */
|
|
107
|
+
amountIn: bigint;
|
|
108
|
+
/** Overrides the trader's default for this trade. */
|
|
109
|
+
slippageBps?: number;
|
|
110
|
+
}
|
|
111
|
+
interface TradeResult {
|
|
112
|
+
/** The quote the transaction was built against - `minimumOut` is what the chain enforced. */
|
|
113
|
+
quote: TradeQuote;
|
|
114
|
+
/** Which venue filled it: the bonding curve, or the graduated pool. */
|
|
115
|
+
venue: 'curve' | 'dex';
|
|
116
|
+
/** Every hash broadcast, IN ORDER. The last is the swap; a sell may be preceded by approvals. */
|
|
117
|
+
hashes: `0x${string}`[];
|
|
118
|
+
/**
|
|
119
|
+
* The final transaction's on-chain verdict. `reverted` is a real answer, not an error: the transaction landed and
|
|
120
|
+
* failed, the gas is spent, and only the receipt could have told you - no indexed read can, because a reverted
|
|
121
|
+
* transaction emits no logs.
|
|
122
|
+
*/
|
|
123
|
+
status: 'confirmed' | 'reverted';
|
|
124
|
+
}
|
|
125
|
+
/** A wallet bound to one key and one endpoint. Create one per key: a trader serializes its own sends, which is what
|
|
126
|
+
* keeps a single nonce sequence single-threaded. */
|
|
127
|
+
interface Trader {
|
|
128
|
+
/** The wallet address derived from the key - the `from` of every transaction and the swap recipient. */
|
|
129
|
+
readonly address: `0x${string}`;
|
|
130
|
+
/** Price a trade without signing anything. Safe to poll. */
|
|
131
|
+
quote(request: TradeRequest): Promise<TradeQuote>;
|
|
132
|
+
/** Price, build, sign, broadcast and confirm one trade. */
|
|
133
|
+
trade(request: TradeRequest): Promise<TradeResult>;
|
|
134
|
+
/** This wallet's native gas balance, base units. */
|
|
135
|
+
nativeBalance(): Promise<bigint>;
|
|
136
|
+
/** This wallet's balance of one coin, base units. */
|
|
137
|
+
coinBalance(mint: string): Promise<bigint>;
|
|
138
|
+
/** The read client, if you want to make your own chain calls on the same endpoint. */
|
|
139
|
+
readonly chainClient: PublicClient;
|
|
140
|
+
}
|
|
141
|
+
export declare function createTrader(options: TraderOptions): Trader;
|
|
142
|
+
export type { BuiltTrade, CurveCoinRef, CurveCoinState, CurveConfig, TradeBuildInput, TradeInput, TradeRequest, TradeResult, Trader, TraderApi, TraderOptions };
|
package/dist/chain.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createPublicClient as e,createWalletClient as t,defineChain as n,encodeAbiParameters as r,encodeFunctionData as i,encodePacked as a,erc20Abi as o,http as s,keccak256 as c,parseAbi as l,zeroAddress as u}from"viem";import{privateKeyToAccount as d}from"viem/accounts";function f(e){return{chainId:e.chainId,addresses:{bondingCurveV4:e.bondingCurveV4,v4Quoter:e.v4Quoter,stateView:e.stateView,universalRouter:e.universalRouter,permit2:e.permit2,positionManager:e.positionManager??null,launchpadHook:e.launchpadHook,legacyBondingCurveV4:e.legacyBondingCurveV4,legacyLaunchpadHook:e.legacyLaunchpadHook,activeCurveRelease:e.activeCurveRelease,liquidityMigratorV4:null,legacyLiquidityMigratorV4:null,uniswapV4PoolManager:null}}}const p={totalSupply:10n**27n,sellableSupply:8n*10n**26n,reserveSupply:2n*10n**26n,tokenOffset:8n*10n**26n/4n,graduatedFeeTierBps:1e4},m={totalSupply:p.totalSupply,sellableSupply:p.sellableSupply,reserveSupply:p.reserveSupply,tokenOffset:p.tokenOffset},h={totalSupply:p.totalSupply,sellableSupply:777777778n*10n**18n,reserveSupply:p.totalSupply-777777778n*10n**18n,tokenOffset:311111111n*10n**18n};function g(e){return e===`9.0`?h:m}const _={poolFeeBps:[30,50,100,150,200,250],sellWindowFeeBps:[500,1e3,1500,2e3],sellWindowDecayS:[300,900,1800,2700,3600,7200],buyWindowFeeBps:[500,1e3,1500,2e3],buyWindowDecayS:[60,300,600,900,1800],earlyBuyFeeBps:[0,1250,2500],poolFeeBps:[30,50,100,150,200,250,300,400,500],compoundCommitBps:[1250,2500,3750,5e3],buyWindowDecayS:[15,30,45,60,90,150,300,600,900,1800]};_.sellWindowFeeBps,_.sellWindowDecayS,_.buyWindowFeeBps,_.buyWindowDecayS;var v=class extends Error{constructor(e,t){super(e,t),this.name=`ProtocolError`}};function y(e){let t=e.quoteToken;return t==null||/^0x0{40}$/i.test(t)?null:t}function b(e){let t=e.addresses.bondingCurveV4;if(t===null)throw new v(`This chain has no launch stack deployed yet - launching is unavailable here.`);return t}function x(e){if(e.curveKind===`v3`)throw new v(`This coin launched on the retired v3 stack and can no longer be traded here.`)}function S(e,t){return e.curveAddress??e.stampedCurveAddress??b(t)}function C(e,t){if(e.curveRelease!==void 0)return e.curveRelease;let n=S(e,t).toLowerCase(),r=t.addresses.legacyBondingCurveV4;if(r!==null&&n===r.toLowerCase())return t.addresses.legacyCurveRelease??`2.0`;let i=t.addresses.bondingCurveV4;return i!==null&&n===i.toLowerCase()?t.addresses.activeCurveRelease:`2.0`}const ee=new Set([`4.0`,`5.0`,`6.0`,`7.0`,`7.1`,`8.0`,`9.0`]);function w(e,t){let n=C(e,t);if(!ee.has(n))throw new v(`This coin launched on decommissioned release ${n} and cannot be served right now.`);return n}function te(e,t){if(e.hookAddress!==void 0&&e.hookAddress!==null)return e.hookAddress;let n=t.addresses.legacyBondingCurveV4;return n!==null&&S(e,t).toLowerCase()===n.toLowerCase()?t.addresses.legacyLaunchpadHook??t.addresses.launchpadHook:t.addresses.launchpadHook}const T=l([`struct TokenMetadata { string name; string symbol; string tokenURI; string logo; string description; }`,`function predictToken(address launcher, TokenMetadata meta, bytes32 salt) view returns (address)`,`function feeBps() view returns (uint16)`,`function migrationFeeBps() view returns (uint16)`,`function launchFee() view returns (uint256)`,`function launchesPaused() view returns (bool)`,`function buy(address token, uint256 minTokensOut) payable returns (uint256)`,`function sell(address token, uint256 tokensIn, uint256 minEthOut) returns (uint256)`,`function quoteSell(address token, uint256 tokensIn) view returns (uint256 ethOut, uint256 ethGross, uint256 fee)`,`function graduate(address token) returns (uint256)`,`error UnknownCoin()`,`error CurveComplete()`,`error CurveNotActive()`,`error CurveNotComplete()`,`error AlreadyGraduated()`,`error AmountTooSmall()`,`error SlippageExceeded()`,`error MigratorUnset()`,`error LaunchesPaused()`,`error LaunchFeeNotPaid()`,`error LaunchFeeTooHigh()`,`error TargetTooSmall()`,`error TargetTooLarge()`,`error EthTransferFailed()`]),E=l([`struct TokenMetadata { string name; string symbol; string tokenURI; string logo; string description; }`,`struct Coin { address creator; address devBuyer; address migrator; uint16 feeBps; uint16 migrationFeeBps; bool complete; bool graduated; bool active; uint16 poolFeeBps; uint16 launchFeeBps; uint32 launchFeeDecay; bool compounding; uint16 earlyBuyFeeBps; uint64 activatedAt; uint256 ethOffset; uint256 ethReserve; uint256 tokenReserve; uint256 bondingTarget; uint256 soldHighWater; uint256 accrued; uint256 earlyBuyAccrued; }`,`struct BuyQuote { uint256 tokensOut; uint256 ethUsed; uint256 tradeFee; uint256 earlyBuyFee; uint16 earlyBuyRateBps; bool completes; }`,`struct LaunchParams { TokenMetadata meta; bytes32 salt; uint256 bondingTarget; bool awaitDevBuy; uint256 devBuyMinTokens; uint16 poolFeeBps; uint16 windowFeeBps; uint32 windowDecay; uint16 earlyBuyFeeBps; bool compounding; address devBuyer; }`,`function launch(LaunchParams params) payable returns (address)`,`function getCoin(address token) view returns (Coin coin)`,`function quoteBuy(address token, uint256 ethGross) view returns (BuyQuote quote)`,`function maxLaunchWindowFeeBps() view returns (uint16)`,`function launchWindowEnabled() view returns (bool)`,`function lowerEarlyBuyFee(address token, uint16 earlyBuyFeeBps)`,`function pendingFees(address token) view returns (uint256 creatorAmount, uint256 treasuryAmount)`,`function collect(address token) returns (uint256 creatorAmount, uint256 treasuryAmount)`,`error EarlyBuyFeeOffMenu()`,`error PoolTermsRejected()`,`error InvalidDevBuyer()`]),D=l([`struct TokenMetadata { string name; string symbol; string tokenURI; string logo; string description; }`,`struct Coin { address creator; address devBuyer; address migrator; uint16 feeBps; uint16 migrationFeeBps; bool complete; bool graduated; bool active; uint16 poolFeeBps; uint16 launchSellFeeBps; uint32 launchSellFeeDecay; uint16 launchBuyFeeBps; uint32 launchBuyFeeDecay; bool compounding; uint16 earlyBuyFeeBps; uint64 activatedAt; uint256 ethOffset; uint256 ethReserve; uint256 tokenReserve; uint256 bondingTarget; uint256 soldHighWater; uint256 accrued; uint256 earlyBuyAccrued; }`,`struct BuyQuote { uint256 tokensOut; uint256 ethUsed; uint256 tradeFee; uint256 earlyBuyFee; uint16 earlyBuyRateBps; bool completes; }`,`struct LaunchParams { TokenMetadata meta; bytes32 salt; uint256 bondingTarget; bool awaitDevBuy; uint256 devBuyMinTokens; uint16 poolFeeBps; uint16 sellWindowFeeBps; uint32 sellWindowDecay; uint16 earlyBuyFeeBps; bool compounding; address devBuyer; uint16 buyWindowFeeBps; uint32 buyWindowDecay; }`,`function launch(LaunchParams params) payable returns (address)`,`function getCoin(address token) view returns (Coin coin)`,`function quoteBuy(address token, uint256 ethGross) view returns (BuyQuote quote)`,`function lowerEarlyBuyFee(address token, uint16 earlyBuyFeeBps)`,`function maxSellWindowFeeBps() view returns (uint16)`,`function maxBuyWindowFeeBps() view returns (uint16)`,`function sellWindowEnabled() view returns (bool)`,`function buyWindowEnabled() view returns (bool)`,`function pendingFees(address token) view returns (uint256 creatorAmount, uint256 treasuryAmount)`,`function collect(address token) returns (uint256 creatorAmount, uint256 treasuryAmount)`,`error EarlyBuyFeeOffMenu()`,`error PoolTermsRejected()`,`error InvalidDevBuyer()`,`error SellWindowDisabled()`,`error BuyWindowDisabled()`]),O=l([`struct TokenMetadata { string name; string symbol; string tokenURI; string logo; string description; }`,`struct Coin { address creator; address devBuyer; address migrator; uint16 feeBps; uint16 migrationFeeBps; bool complete; bool graduated; bool active; uint16 poolFeeBps; uint16 launchSellFeeBps; uint32 launchSellFeeDecay; uint16 launchBuyFeeBps; uint32 launchBuyFeeDecay; uint16 compoundCommitBps; uint16 earlyBuyFeeBps; uint64 activatedAt; uint256 ethOffset; uint256 ethReserve; uint256 tokenReserve; uint256 bondingTarget; uint256 soldHighWater; uint256 accrued; uint256 earlyBuyAccrued; }`,`struct BuyQuote { uint256 tokensOut; uint256 ethUsed; uint256 tradeFee; uint256 earlyBuyFee; uint16 earlyBuyRateBps; bool completes; }`,`struct LaunchParams { TokenMetadata meta; bytes32 salt; uint256 bondingTarget; bool awaitDevBuy; uint256 devBuyMinTokens; uint16 poolFeeBps; uint16 sellWindowFeeBps; uint32 sellWindowDecay; uint16 earlyBuyFeeBps; bool compounding; address devBuyer; uint16 buyWindowFeeBps; uint32 buyWindowDecay; uint16 compoundCommitBps; }`,`function launch(LaunchParams params) payable returns (address)`,`function getCoin(address token) view returns (Coin coin)`,`function quoteBuy(address token, uint256 ethGross) view returns (BuyQuote quote)`,`function lowerEarlyBuyFee(address token, uint16 earlyBuyFeeBps)`,`function maxSellWindowFeeBps() view returns (uint16)`,`function maxBuyWindowFeeBps() view returns (uint16)`,`function sellWindowEnabled() view returns (bool)`,`function buyWindowEnabled() view returns (bool)`,`function pendingFees(address token) view returns (uint256 creatorAmount, uint256 treasuryAmount)`,`function collect(address token) returns (uint256 creatorAmount, uint256 treasuryAmount)`,`error EarlyBuyFeeOffMenu()`,`error PoolTermsRejected()`,`error InvalidDevBuyer()`,`error SellWindowDisabled()`,`error BuyWindowDisabled()`]),k=l([`struct TokenMetadata { string name; string symbol; string tokenURI; string logo; string description; }`,`struct Coin { address creator; address devBuyer; address migrator; uint16 feeBps; uint16 migrationFeeBps; bool complete; bool graduated; bool active; bool creatorCurveFees; uint16 poolFeeBps; uint16 launchSellFeeBps; uint32 launchSellFeeDecay; uint16 launchBuyFeeBps; uint32 launchBuyFeeDecay; uint16 compoundCommitBps; uint16 earlyBuyFeeBps; uint64 activatedAt; uint256 ethOffset; uint256 ethReserve; uint256 tokenReserve; uint256 bondingTarget; uint256 soldHighWater; uint256 accrued; uint256 earlyBuyAccrued; }`,`struct BuyQuote { uint256 tokensOut; uint256 ethUsed; uint256 tradeFee; uint256 earlyBuyFee; uint16 earlyBuyRateBps; bool completes; }`,`struct LaunchParams { TokenMetadata meta; bytes32 salt; uint256 bondingTarget; bool awaitDevBuy; uint256 devBuyMinTokens; uint16 poolFeeBps; uint16 sellWindowFeeBps; uint32 sellWindowDecay; uint16 earlyBuyFeeBps; bool compounding; address devBuyer; uint16 buyWindowFeeBps; uint32 buyWindowDecay; uint16 compoundCommitBps; }`,`function launch(LaunchParams params) payable returns (address)`,`function getCoin(address token) view returns (Coin coin)`,`function quoteBuy(address token, uint256 ethGross) view returns (BuyQuote quote)`,`function lowerEarlyBuyFee(address token, uint16 earlyBuyFeeBps)`,`function maxSellWindowFeeBps() view returns (uint16)`,`function maxBuyWindowFeeBps() view returns (uint16)`,`function sellWindowEnabled() view returns (bool)`,`function buyWindowEnabled() view returns (bool)`,`function earlyBuyEnabled() view returns (bool)`,`function creatorCurveFeesEnabled() view returns (bool)`,`function pendingFees(address token) view returns (uint256 creatorAmount, uint256 treasuryAmount)`,`function collect(address token) returns (uint256 creatorAmount, uint256 treasuryAmount)`,`error EarlyBuyFeeOffMenu()`,`error EarlyBuyDisabled()`,`error PoolTermsRejected()`,`error InvalidDevBuyer()`,`error SellWindowDisabled()`,`error BuyWindowDisabled()`]),A=l(`struct TokenMetadata { string name; string symbol; string tokenURI; string logo; string description; }.struct Coin { address creator; address devBuyer; address migrator; address quoteToken; uint16 feeBps; uint16 migrationFeeBps; bool complete; bool graduated; bool active; bool abandoned; bool creatorCurveFees; uint16 poolFeeBps; uint16 launchSellFeeBps; uint32 launchSellFeeDecay; uint16 launchBuyFeeBps; uint32 launchBuyFeeDecay; uint16 compoundCommitBps; uint32 sniperTaxWindow; uint64 openedAt; uint64 completedAt; uint256 ethOffset; uint256 ethReserve; uint256 tokenReserve; uint256 bondingTarget; uint256 accrued; }.struct BuyQuote { uint256 tokensOut; uint256 ethUsed; uint256 tradeFee; bool completes; }.struct LaunchParams { TokenMetadata meta; bytes32 salt; uint256 bondingTarget; bool awaitDevBuy; uint256 devBuyMinTokens; address quoteToken; uint256 devBuyQuoteIn; uint16 poolFeeBps; uint16 sellWindowFeeBps; uint32 sellWindowDecay; bool compounding; address devBuyer; uint16 buyWindowFeeBps; uint32 buyWindowDecay; uint16 compoundCommitBps; address[] sniperExempt; }.function launch(LaunchParams params) payable returns (address).function getCoin(address token) view returns (Coin coin).function quoteBuyFor(address token, address buyer, uint256 ethGross) view returns (BuyQuote quote).function quoteSell(address token, uint256 tokensIn) view returns (uint256 ethOut, uint256 ethGross, uint256 fee).function buy(address token, uint256 quoteIn, uint256 minTokensOut) payable returns (uint256 tokensOut).function sell(address token, uint256 tokensIn, uint256 minEthOut) returns (uint256 ethOut).function quoteAssets(address quote) view returns (bool approved, uint8 decimals, uint256 minTarget, uint256 maxTarget).function approveQuote(address quote, uint8 decimals, uint256 minTarget, uint256 maxTarget).function revokeQuote(address quote).function setQuoteBand(address quote, uint256 minTarget, uint256 maxTarget).function maxSellWindowFeeBps() view returns (uint16).function maxBuyWindowFeeBps() view returns (uint16).function sellWindowEnabled() view returns (bool).function buyWindowEnabled() view returns (bool).function creatorCurveFeesEnabled() view returns (bool).function curveCreatorShareBps() view returns (uint16).function pendingFees(address token) view returns (uint256 creatorAmount, uint256 treasuryAmount).function collect(address token) returns (uint256 creatorAmount, uint256 treasuryAmount).function owed(address quote, address recipient) view returns (uint256).function totalOwed(address quote) view returns (uint256).function withdrawOwed(address quote) returns (uint256 amount).function payOut(address quote, address to) returns (uint256 amount).function payoutRecipient(address token) view returns (address).function setPayoutRecipient(address token, address recipient).function pendingCreators(address token) view returns (address).function proposeCreator(address token, address proposed).function acceptCreator(address token).function passFactory() view returns (address).function setPassFactory(address factory).function commitSeat(address token, address clone).event PassFactorySet(address indexed factory).function sniperTaxWindow() view returns (uint32).function setSniperTaxWindow(uint32 sniperTaxWindow).function accruedQuoteFees(address quote) view returns (uint256).function ABANDON_DELAY() view returns (uint256).function abandon(address token).function graduate(address token) returns (uint256 liquidity).function operators(address operator) view returns (bool).function sniperExempt(address token, address wallet) view returns (bool).function SNIPER_TAX_BPS() view returns (uint16).function MAX_SNIPER_TAX_WINDOW() view returns (uint32).function MAX_SNIPER_EXEMPTIONS() view returns (uint256).error UnknownCoin().error CurveComplete().error CurveNotActive().error AmountTooSmall().error SlippageExceeded().error PoolTermsRejected().error InvalidDevBuyer().error SellWindowDisabled().error BuyWindowDisabled().error QuoteNotApproved().error QuoteInvalid().error QuoteDecimalsMismatch(uint8 expected, uint8 actual).error NativeValueMismatch().error UnexpectedNativeValue().error NotPassFactory().error CoinNotActive().error TargetTooSmall().error TargetTooLarge().error TooManyExemptions().error SniperWindowTooLong()`.split(`.`));l([`function description() view returns (string)`,`function logo() view returns (string)`]);const ne=l([`struct PoolKey { address currency0; address currency1; uint24 fee; int24 tickSpacing; address hooks; }`,`struct QuoteExactSingleParams { PoolKey poolKey; bool zeroForOne; uint128 exactAmount; bytes hookData; }`,`function quoteExactInputSingle(QuoteExactSingleParams params) returns (uint256 amountOut, uint256 gasEstimate)`]),j=l([`function execute(bytes commands, bytes[] inputs, uint256 deadline) payable`]),M=l([`function allowance(address owner, address token, address spender) view returns (uint160 amount, uint48 expiration, uint48 nonce)`,`function approve(address token, address spender, uint160 amount, uint48 expiration)`]),re=l([`function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)`]);l([`function creatorShareBps() view returns (uint16)`,`function compoundCreatorShareBps() view returns (uint16)`,`function compoundShareBps() view returns (uint16)`,`function mandatoryCompounding() view returns (bool)`,`function settleThresholdWei() view returns (uint256)`,`function defaultFeeBps() view returns (uint16)`,`function currentSellFeeBps(bytes32 poolId) view returns (uint16)`,`function pendingFees(bytes32 poolId) view returns (uint256 creatorAmount, uint256 compoundAmount, uint256 treasuryAmount)`,`function collect(bytes32 poolId) returns (uint256 creatorAmount, uint256 compoundAmount, uint256 treasuryAmount)`,`function pools(bytes32 poolId) view returns (address creator, uint16 feeBps, uint16 launchFeeBps, uint32 launchFeeDecay, uint64 graduatedAt, address asset, int24 tickSpacing, bool compounding, uint256 accrued, uint256 compoundPot)`,`function pendingCreators(bytes32 poolId) view returns (address)`,`function proposeCreator(bytes32 poolId, address proposed)`,`function acceptCreator(bytes32 poolId)`,`function lowerFee(bytes32 poolId, uint16 feeBps)`]),l([`function creatorShareBps() view returns (uint16)`,`function compoundCreatorShareBps() view returns (uint16)`,`function compoundShareBps() view returns (uint16)`,`function mandatoryCompounding() view returns (bool)`,`function settleThresholdWei() view returns (uint256)`,`function defaultFeeBps() view returns (uint16)`,`function graduationSurchargeEnabled() view returns (bool)`,`function GRADUATION_SURCHARGE_BPS() view returns (uint16)`,`function currentSellFeeBps(bytes32 poolId) view returns (uint16)`,`function currentBuyFeeBps(bytes32 poolId) view returns (uint16)`,`function quoteFees(bytes32 poolId) view returns (uint16 buyFeeBps, uint16 sellFeeBps, uint64 buyWindowEndsAt, uint64 sellWindowEndsAt)`,`function pendingFees(bytes32 poolId) view returns (uint256 creatorAmount, uint256 compoundAmount, uint256 treasuryAmount)`,`function collect(bytes32 poolId) returns (uint256 creatorAmount, uint256 compoundAmount, uint256 treasuryAmount)`,`function pools(bytes32 poolId) view returns (address creator, uint16 feeBps, uint16 launchSellFeeBps, uint32 launchSellFeeDecay, uint16 launchBuyFeeBps, uint32 launchBuyFeeDecay, uint64 graduatedAt, uint64 graduationBlock, address asset, int24 tickSpacing, bool compounding, uint256 accrued, uint256 compoundPot)`,`function pendingCreators(bytes32 poolId) view returns (address)`,`function proposeCreator(bytes32 poolId, address proposed)`,`function acceptCreator(bytes32 poolId)`,`function cancelBuyWindow(bytes32 poolId)`,`function cancelSellWindow(bytes32 poolId)`,`function enableCompounding(bytes32 poolId)`,`function lowerFee(bytes32 poolId, uint16 feeBps)`,`error NoWindow()`,`error AlreadyCompounding()`,`error Unauthorized()`]),l([`event BuyWindowCancelled(bytes32 indexed poolId)`,`event SellWindowCancelled(bytes32 indexed poolId)`,`event CompoundingEnabled(bytes32 indexed poolId)`]),l(`function creatorShareBps() view returns (uint16).function mandatoryCommitBps() view returns (uint16).function compoundingPaused() view returns (bool).function compoundCommitBps(bytes32 poolId) view returns (uint16).function isAllowedCompoundCommit(uint16 commitBps) view returns (bool).function settleThresholdWei() view returns (uint256).function defaultFeeBps() view returns (uint16).function graduationSurchargeEnabled() view returns (bool).function GRADUATION_SURCHARGE_BPS() view returns (uint16).function currentSellFeeBps(bytes32 poolId) view returns (uint16).function currentBuyFeeBps(bytes32 poolId) view returns (uint16).function quoteFees(bytes32 poolId) view returns (uint16 buyFeeBps, uint16 sellFeeBps, uint64 buyWindowEndsAt, uint64 sellWindowEndsAt).function pendingFees(bytes32 poolId) view returns (uint256 creatorAmount, uint256 compoundAmount, uint256 treasuryAmount).function collect(bytes32 poolId) returns (uint256 creatorAmount, uint256 compoundAmount, uint256 treasuryAmount).function pools(bytes32 poolId) view returns (address creator, uint16 feeBps, uint16 launchSellFeeBps, uint32 launchSellFeeDecay, uint16 launchBuyFeeBps, uint32 launchBuyFeeDecay, uint64 graduatedAt, uint64 graduationBlock, address asset, int24 tickSpacing, bool compounding, uint256 accrued, uint256 compoundPot).function pendingCreators(bytes32 poolId) view returns (address).function proposeCreator(bytes32 poolId, address proposed).function acceptCreator(bytes32 poolId).function cancelBuyWindow(bytes32 poolId).function cancelSellWindow(bytes32 poolId).function raiseCompoundCommit(bytes32 poolId, uint16 commitBps).function lowerFee(bytes32 poolId, uint16 feeBps).error NoWindow().error CommitOffMenu().error CommitNotRaised().error Unauthorized()`.split(`.`)),l([`event BuyWindowCancelled(bytes32 indexed poolId)`,`event SellWindowCancelled(bytes32 indexed poolId)`,`event CompoundCommitRaised(bytes32 indexed poolId, uint16 fromBps, uint16 toBps)`]),l(`function creatorShareBps() view returns (uint16).function mandatoryCommitBps() view returns (uint16).function compoundingPaused() view returns (bool).function compoundCommitBps(bytes32 poolId) view returns (uint16).function isAllowedCompoundCommit(uint16 commitBps) view returns (bool).function isAllowedPoolFeeBps(uint16 feeBps) view returns (bool).function settleThresholdWei() view returns (uint256).function quoteSettleThreshold(address quote) view returns (uint256).function setQuoteSettleThreshold(address quote, uint256 threshold).function settleThresholdFor(address quote) view returns (uint256).function defaultFeeBps() view returns (uint16).function graduationSurchargeEnabled() view returns (bool).function GRADUATION_SURCHARGE_BPS() view returns (uint16).function currentSellFeeBps(bytes32 poolId) view returns (uint16).function currentBuyFeeBps(bytes32 poolId) view returns (uint16).function quoteFees(bytes32 poolId) view returns (uint16 buyFeeBps, uint16 sellFeeBps, uint64 buyWindowEndsAt, uint64 sellWindowEndsAt).function pendingFees(bytes32 poolId) view returns (uint256 creatorAmount, uint256 compoundAmount, uint256 treasuryAmount).function collect(bytes32 poolId) returns (uint256 creatorAmount, uint256 compoundAmount, uint256 treasuryAmount).function pools(bytes32 poolId) view returns (address creator, uint16 feeBps, uint16 launchSellFeeBps, uint32 launchSellFeeDecay, uint16 launchBuyFeeBps, uint32 launchBuyFeeDecay, uint64 graduatedAt, uint64 graduationBlock, address asset, int24 tickSpacing, bool compounding, uint256 accrued, uint256 compoundPot).function poolQuote(bytes32 poolId) view returns (address).function pendingCreators(bytes32 poolId) view returns (address).function proposeCreator(bytes32 poolId, address proposed).function acceptCreator(bytes32 poolId).function payoutRecipient(bytes32 poolId) view returns (address).function setPayoutRecipient(bytes32 poolId, address recipient).function owed(address quote, address recipient) view returns (uint256).function withdrawOwed(address quote) returns (uint256 amount).function payOut(address quote, address to) returns (uint256 amount).function cancelBuyWindow(bytes32 poolId).function cancelSellWindow(bytes32 poolId).function raiseCompoundCommit(bytes32 poolId, uint16 commitBps).function lowerFee(bytes32 poolId, uint16 feeBps).function setPassFactory(address factory).function passFactory() view returns (address).function creatorRecoveries(bytes32 poolId) view returns (address creator, uint64 eta).function CREATOR_RECOVERY_DELAY() view returns (uint64).function CREATOR_RECOVERY_WINDOW() view returns (uint64).function proposeCreatorRecovery(bytes32 poolId, address creator).function executeCreatorRecovery(bytes32 poolId).function cancelCreatorRecovery(bytes32 poolId).function allowedMigrators(address migrator) view returns (bool).function collectMany(bytes32[] poolIds).function operators(address operator) view returns (bool).error NoWindow().error CommitOffMenu().error CommitNotRaised().error Unauthorized()`.split(`.`)),l([`event BuyWindowCancelled(bytes32 indexed poolId)`,`event SellWindowCancelled(bytes32 indexed poolId)`,`event CompoundCommitRaised(bytes32 indexed poolId, uint16 fromBps, uint16 toBps)`,`event PayoutRecipientSet(bytes32 indexed poolId, address indexed creator, address indexed recipient)`,`event SeatCommitted(bytes32 indexed poolId, address indexed creator, address indexed clone)`,`event PassFactorySet(address indexed factory)`]),l(`function deployBurner(address hook, bytes32 poolId) returns (address).function deploySplitter(address hook, bytes32 poolId, uint16 burnShareBps) returns (address).function deployBurnerForCoin(address curve, address token) returns (address).function deploySplitterForCoin(address curve, address token, uint16 burnShareBps) returns (address).function burnerFor(bytes32 poolId) view returns (address).function splitterFor(bytes32 poolId) view returns (address).function predictBurner(bytes32 poolId) view returns (address).function predictSplitter(bytes32 poolId) view returns (address).function isFactoryClone(address candidate) view returns (bool).function isFactoryBurner(address candidate) view returns (bool).function isFactorySplitter(address candidate) view returns (bool).function allowedCurves(address curve) view returns (bool).function allowedHooks(address hook) view returns (bool).function quoteBoundsSet(address quote) view returns (bool).function setCurveAllowed(address curve, bool allowed).function distributorRegistry() view returns (address).function setDistributorRegistry(address registry).function distributorFor(bytes32 poolId) view returns (address distributor).function BURN_SHARE_MIN_BPS() view returns (uint16).function BURN_SHARE_MAX_BPS() view returns (uint16).error CurveNotAllowed().error CoinNotOnCurve().error HookNotAllowed().error AllocationExceedsPie().error NotPoolCreator().error BurnShareOutOfBounds().error SplitterExists().error BurnerExists().error QuoteBoundsUnset().event BurnerDeployed(bytes32 indexed poolId, address indexed burner, address indexed creatorAdmin, address hook).event SplitterDeployed(bytes32 indexed poolId, address indexed splitter, address indexed creatorAdmin, uint16 burnShareBps).event CurveAllowed(address indexed curve, bool allowed).event DistributorRegistrySet(address indexed registry)`.split(`.`)),l(`function claimSeat().function burnShareBps() view returns (uint16).function allocation() view returns (uint16 compoundBps, uint16 burnBps, uint16 holderBps, uint16 creatorBps).function holderShareBps() view returns (uint16).function raiseHolderShare(uint16 newShareBps).function heldHolders() view returns (uint256).function totalToHolders() view returns (uint256).function BURN_SHARE_MIN_BPS() view returns (uint16).event HolderShareRaised(uint16 fromBps, uint16 toBps).event HoldersFlushed(address indexed distributor, uint256 toHolders, uint256 heldHolders).error ShareBelowFloor().error DistributionNotLive().function curve() view returns (address).function pullOwedFromCurve() returns (uint256).function fuel() view returns (uint256).function balance() view returns (uint256).function totalEthBurned() view returns (uint256).function totalTokensBurned() view returns (uint256).function checkpoint().function burn() returns (uint256).function flush().function pullOwed() returns (uint256).function checkpointAt() view returns (uint64).function lastBurnAt() view returns (uint64).function burnThresholdWei() view returns (uint256).function maxBurnPerCallWei() view returns (uint256).function burnCooldownSec() view returns (uint64).function bountyBps() view returns (uint16).function slippageBandBps() view returns (uint16).function setBurnConfig(uint256 thresholdWei, uint256 maxPerCallWei, uint64 cooldownSec, uint16 bountyBps, uint16 bandBps).function raiseBurnShare(uint16 newShareBps).function raiseCompoundCommit(uint16 commitBps).function creatorAdmin() view returns (address).function pendingCreatorAdmin() view returns (address).function recoveryProposedAdmin() view returns (address).function recoveryEta() view returns (uint64).function ADMIN_RECOVERY_DELAY_SEC() view returns (uint64).function ADMIN_RECOVERY_WINDOW_SEC() view returns (uint64).function proposeAdminRecovery(address newAdmin).function executeAdminRecovery().function cancelAdminRecovery().error NotRecoveryAuthority().error NoRecoveryPending().error RecoveryNotReady().error RecoveryExpired().function moneyBounds() view returns ((uint256 thresholdMinWei, uint256 thresholdMaxWei, uint256 clipMinWei, uint256 clipMaxWei, uint256 defaultThresholdWei, uint256 defaultClipWei)).function COOLDOWN_MAX_SEC() view returns (uint64).function BOUNTY_MAX_BPS() view returns (uint16).function BAND_MIN_BPS() view returns (uint16).function BAND_MAX_BPS() view returns (uint16).function CHECKPOINT_MIN_AGE_SEC() view returns (uint64).function CHECKPOINT_MAX_AGE_SEC() view returns (uint64).function CHECKPOINT_COOLDOWN_SEC() view returns (uint64)`.split(`.`)),l([`function sweepStranded(address quote) returns (uint256 amount)`,`function positionTokenIds(bytes32 poolId) view returns (uint256)`,`error NothingToSweep()`,`error EthTransferFailed()`]),l([`event Bought(address indexed token, address indexed buyer, uint256 ethGross, uint256 fee, uint256 tokensOut, uint256 ethReserve, uint256 tokenReserve)`,`event Sold(address indexed token, address indexed seller, uint256 tokensIn, uint256 fee, uint256 ethOut, uint256 ethReserve, uint256 tokenReserve)`]);async function N(e,t,n){x(n);let r=w(n,t),i=S(n,t);return r===`9.0`?e.readContract({address:i,abi:A,functionName:`getCoin`,args:[n.mint]}):r===`8.0`?e.readContract({address:i,abi:k,functionName:`getCoin`,args:[n.mint]}):r===`7.0`||r===`7.1`?e.readContract({address:i,abi:O,functionName:`getCoin`,args:[n.mint]}):r===`4.0`?e.readContract({address:i,abi:E,functionName:`getCoin`,args:[n.mint]}):e.readContract({address:i,abi:D,functionName:`getCoin`,args:[n.mint]})}const P=1e4;function ie(e){return!Number.isFinite(e)||e<0?0:e>P?P:Math.trunc(e)}function F(e,t){let n=ie(t);return e*BigInt(P-n)/BigInt(P)}function I(e,t,n=null){let r=n??`0x0000000000000000000000000000000000000000`,[i,a]=BigInt(r)<BigInt(e)?[r,e]:[e,r];return{currency0:i,currency1:a,fee:0,tickSpacing:200,hooks:t}}function L(e,t){return e.currency0.toLowerCase()!==t.toLowerCase()}const ae=[{type:`tuple`,components:[{name:`currency0`,type:`address`},{name:`currency1`,type:`address`},{name:`fee`,type:`uint24`},{name:`tickSpacing`,type:`int24`},{name:`hooks`,type:`address`}]}];function oe(e){return c(r(ae,[e]))}const se=[{type:`tuple`,components:[{name:`poolKey`,type:`tuple`,components:[{name:`currency0`,type:`address`},{name:`currency1`,type:`address`},{name:`fee`,type:`uint24`},{name:`tickSpacing`,type:`int24`},{name:`hooks`,type:`address`}]},{name:`zeroForOne`,type:`bool`},{name:`amountIn`,type:`uint128`},{name:`amountOutMinimum`,type:`uint128`},{name:`hookData`,type:`bytes`}]}];function R(e){let{universalRouter:t,permit2:n,v4Quoter:r,stateView:i}=e.addresses;if(t===null||n===null||r===null)throw new v(`This chain has no v4 graduated trade path deployed yet - trading is unavailable here.`);return{universalRouter:t,permit2:n,v4Quoter:r,stateView:i}}function z(e,t){let n=te(e,t);if(n===null)throw new v(`This chain has no v4 launch hook deployed yet - trading is unavailable here.`);return I(e.mint,n,y(e))}function B(e,t,n){let r=L(t,e.mint),i=n===`buy`,a=r?t.currency0:t.currency1;return{zeroForOne:i===r,currencyIn:i?a:e.mint,currencyOut:i?e.mint:a,isQuoteFirst:r}}async function V(e,t,n,r){let{v4Quoter:i}=R(t),a=z(n,t),o;try{let{result:t}=await e.simulateContract({address:i,abi:ne,functionName:`quoteExactInputSingle`,args:[{poolKey:a,zeroForOne:B(n,a,r.side).zeroForOne,exactAmount:r.amountIn,hookData:`0x`}]});o=t[0]}catch(e){throw new v(`Could not quote this trade.`,{cause:e})}if(o<=0n)throw new v(`This trade quotes to zero output - try a larger amount.`);return o}async function H(e,t,n){try{let{stateView:r}=R(t);if(r===null)return null;let i=z(n,t),[a]=await e.readContract({address:r,abi:re,functionName:`getSlot0`,args:[oe(i)]}),o=Number(a)/2**96,s=o*o;return s<=0?null:L(i,n.mint)?1/s:s}catch{return null}}function U(e){let t=a([`uint8`,`uint8`,`uint8`],[6,12,15]),n=r(se,[{poolKey:e.poolKey,zeroForOne:e.zeroForOne,amountIn:e.amountIn,amountOutMinimum:e.minimumOut,hookData:`0x`}]),o=r([{type:`address`},{type:`uint256`}],[e.currencyIn,e.amountIn]),s=r([{type:`address`},{type:`uint256`}],[e.currencyOut,e.minimumOut]),c=r([{type:`bytes`},{type:`bytes[]`}],[t,[n,o,s]]);return i({abi:j,functionName:`execute`,args:[`0x10`,[c],e.deadlineSeconds]})}async function W(e,t,n,r,a,s,c){let{universalRouter:l,permit2:u}=R(t),[d,f]=await Promise.all([e.readContract({address:n,abi:o,functionName:`allowance`,args:[r,u]}),e.readContract({address:u,abi:M,functionName:`allowance`,args:[r,n,l]})]),p=[];d<a&&p.push({from:r,to:n,data:i({abi:o,functionName:`approve`,args:[u,a]}),value:`0`,chainId:t.chainId,gas:null});let[m,h]=f,g=BigInt(Math.floor(c/1e3));return(m<a||BigInt(h)<=g)&&p.push({from:r,to:u,data:i({abi:M,functionName:`approve`,args:[n,l,a,Number(s)]}),value:`0`,chainId:t.chainId,gas:null}),p}function G(e,t,n,r,i,a,o){return W(e,t,n.mint,r,i,a,o)}function ce(e,t,n,r,i,a,o){let s=y(n);return s===null?Promise.resolve([]):W(e,t,s,r,i,a,o)}function le(e,t,n,r,i,a){let{universalRouter:o}=R(e),s=z(t,e),{zeroForOne:c,currencyIn:l,currencyOut:u}=B(t,s,r.side),d=r.side===`buy`&&y(t)===null;return{from:n,to:o,data:U({poolKey:s,zeroForOne:c,currencyIn:l,currencyOut:u,amountIn:r.amountIn,minimumOut:i,deadlineSeconds:a}),value:d?r.amountIn.toString():`0`,chainId:e.chainId,gas:null}}function K(e){return e instanceof Error?`${e.message} ${K(e.cause)}`:typeof e==`string`?e:``}function ue(e){let t=K(e);return t.includes(`CurveComplete`)?new v(`This curve is complete - trading is frozen until the coin graduates.`):t.includes(`UnknownCoin`)?new v(`This coin has not landed on the curve yet.`):t.includes(`AmountTooSmall`)?new v(`This trade is too small to quote - try a larger amount.`):new v(`Could not quote this trade.`,{cause:e})}function de(e){return e===`4.0`?E:e===`8.0`?k:e===`7.0`||e===`7.1`?O:D}async function fe(e,t,n,r){let i=await e.readContract({address:t,abi:A,functionName:`quoteBuyFor`,args:[n,r.buyer??u,r.amountIn]});return{expectedOut:i.tokensOut,amountUsed:i.ethUsed,willCompleteCurve:i.completes}}async function pe(e,t,n,r){x(n);let i=w(n,t),a=S(n,t),o=n.mint;try{if(r.side===`buy`){if(i===`9.0`)return await fe(e,a,o,r);let t=await e.readContract({address:a,abi:de(i),functionName:`quoteBuy`,args:[o,r.amountIn]});return{expectedOut:t.tokensOut,amountUsed:t.ethUsed,willCompleteCurve:t.completes}}let[t]=await e.readContract({address:a,abi:T,functionName:`quoteSell`,args:[o,r.amountIn]});return{expectedOut:t,amountUsed:r.amountIn,willCompleteCurve:!1}}catch(e){throw ue(e)}}async function q(e,t,n,r){return r.venue===`curve`?pe(e,t,n,r):(x(n),{expectedOut:await V(e,t,n,r),amountUsed:r.amountIn,willCompleteCurve:!1})}async function J(e,t,n,r){try{if(r===`dex`)return await H(e,t,n);let i=await N(e,t,n),{tokenOffset:a}=g(C(n,t)),o=Number(a+i.tokenReserve);return o>0?Number(i.ethOffset+i.ethReserve)/o:null}catch{return null}}function me(e,t,n){if(n===null||n<=0)return null;let r=Number(t.expectedOut);return r<=0?null:e.side===`buy`?(Number(t.amountUsed)/r/n-1)*1e4:(1-r/Number(e.amountIn)/n)*1e4}function Y(e,t,n){return{venue:e.venue,side:e.side,amountIn:e.amountIn.toString(),expectedOut:t.expectedOut.toString(),minimumOut:F(t.expectedOut,e.slippageBps).toString(),amountUsed:t.amountUsed.toString(),completesCurve:t.willCompleteCurve,slippageBps:e.slippageBps,priceImpactBps:me(e,t,n)}}async function X(e,t,n,r){let[i,a]=await Promise.all([q(e,t,n,r),J(e,t,n,r.venue)]);return Y(r,i,a)}function he(e,t,n,r,a=`8.0`){return i(e===`buy`?a===`9.0`?{abi:A,functionName:`buy`,args:[t,n,r]}:{abi:T,functionName:`buy`,args:[t,r]}:{abi:T,functionName:`sell`,args:[t,n,r]})}function Z(e,t){return i({abi:o,functionName:`approve`,args:[e,t]})}async function ge(e,t,n,r,i,a){return await e.readContract({address:n,abi:o,functionName:`allowance`,args:[r,i]})>=a?null:{from:r,to:n,data:Z(i,a),value:`0`,chainId:t.chainId,gas:null}}async function Q(e,t,n,r){if(r.venue===`dex`)return _e(e,t,n,r);let i=r.owner,a=n.mint;x(n);let o=w(n,t),s=S(n,t),c=y(n),l=r.side===`sell`?a:c,[u,d,f]=await Promise.all([q(e,t,n,{...r,buyer:r.owner}),J(e,t,n,r.venue),l===null?Promise.resolve(null):ge(e,t,l,i,s,r.amountIn)]),p=Y(r,u,d),m=f===null?[]:[f];return m.push({from:i,to:s,data:he(r.side,a,r.amountIn,BigInt(p.minimumOut),o),value:r.side===`buy`&&c===null?r.amountIn.toString():`0`,chainId:t.chainId,gas:null}),{txRequests:m,quote:p}}async function _e(e,t,n,r){x(n);let i=r.owner,a=BigInt(Math.floor(r.nowMs/1e3)+1200),[o,s,c]=await Promise.all([V(e,t,n,r),H(e,t,n),r.side===`sell`?G(e,t,n,i,r.amountIn,a,r.nowMs):ce(e,t,n,i,r.amountIn,a,r.nowMs)]),l=Y(r,{expectedOut:o,amountUsed:r.amountIn,willCompleteCurve:!1},s),u=BigInt(l.minimumOut);return{txRequests:[...c,le(t,n,i,r,u,a)],quote:l}}function ve(){}function $(e){return n({id:e,name:`eip155-${String(e)}`,nativeCurrency:{name:`Native currency`,symbol:`NATIVE`,decimals:18},rpcUrls:{default:{http:[]}}})}const ye=[{type:`function`,name:`balanceOf`,stateMutability:`view`,inputs:[{name:`account`,type:`address`}],outputs:[{name:``,type:`uint256`}]}],be=new Set([`curve-trading`,`dormant`,`awaiting-dev-buy`,`abandoned`]);function xe(e){return e.lifecycleState===`graduated`?e.providerMeta.graduatedPoolAddress===null?null:`dex`:be.has(e.lifecycleState)?e.providerMeta.curveAddress===null?null:`curve`:null}function Se(n){let r=d(n.privateKey),i=n.slippageBps??100,a=n.confirmTimeoutMs??12e4,o=n.confirmPollMs??1e3,c=s(n.rpcUrl,{batch:!0,timeout:15e3,retryCount:1}),l=e({transport:c});async function u(){let e=(await n.client.getLaunchConfig()).curveContracts;if(e==null)throw Error(`This deployment does not serve its contract set (getLaunchConfig().curveContracts is null), so trades cannot be built. It is too old for client-side trading, or its launch surface is disabled.`);return f(e)}let p=null;async function m(){p??=u();try{return await p}catch(e){throw p=null,e}}let h=new Map;function g(e){let n=h.get(e);if(n!==void 0)return n;let i=t({account:r,chain:$(e),transport:c});return h.set(e,i),i}async function _(e,t){let[r,i]=await Promise.all([m(),n.client.getLaunch(e)]),a=xe(i);if(a===null)throw Error(`Coin ${e} is not tradable right now (lifecycle state ${i.lifecycleState}).`);if(i.lifecycleState===`abandoned`&&t===`buy`)throw Error(`Coin ${e} was abandoned - it filled its curve but never graduated, and was reopened sell-only. It accepts sells back into the raise and nothing else.`);let o=i.providerMeta;return{config:r,venue:a,ref:{mint:i.mint,curveAddress:o.curveAddress,...o.curveKind!==void 0&&{curveKind:o.curveKind},...o.curveRelease!==void 0&&{curveRelease:o.curveRelease},...o.hookAddress!==void 0&&{hookAddress:o.hookAddress},...o.quoteToken!==void 0&&{quoteToken:o.quoteToken}}}}async function v(e){let t=$(e.chainId),n=await g(e.chainId).sendTransaction({account:r,chain:t,to:e.to,data:e.data,value:BigInt(e.value),...e.gas!==null&&{gas:BigInt(e.gas)}});return{hash:n,status:(await l.waitForTransactionReceipt({hash:n,timeout:a,pollingInterval:o})).status===`success`?`confirmed`:`reverted`}}let y=Promise.resolve();async function b(e){let t=y,n=ve;y=new Promise(e=>{n=e}),await t;try{return await e()}finally{n()}}return{address:r.address,chainClient:l,async quote(e){let{config:t,venue:n,ref:a}=await _(e.mint,e.side);return X(l,t,a,{venue:n,side:e.side,amountIn:e.amountIn,slippageBps:e.slippageBps??i,buyer:r.address})},async trade(e){return b(async()=>{let{config:t,venue:n,ref:a}=await _(e.mint,e.side),o=await Q(l,t,a,{venue:n,side:e.side,amountIn:e.amountIn,slippageBps:e.slippageBps??i,owner:r.address,nowMs:Date.now()}),s=[];for(let e of o.txRequests){let t=await v(e);if(s.push(t.hash),t.status===`reverted`)return{quote:o.quote,venue:n,hashes:s,status:`reverted`}}return{quote:o.quote,venue:n,hashes:s,status:`confirmed`}})},async nativeBalance(){return l.getBalance({address:r.address})},async coinBalance(e){return l.readContract({address:e,abi:ye,functionName:`balanceOf`,args:[r.address]})}}}export{v as ProtocolError,F as applySlippageFloor,Q as buildCurveTrade,S as coinBondingCurve,C as coinCurveRelease,Se as createTrader,f as curveConfigFrom,X as quoteCurveTrade,N as readCurveCoinState};
|