@clawnch/clawncher-sdk 0.1.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/README.md +603 -0
- package/dist/abis.d.ts +935 -0
- package/dist/abis.d.ts.map +1 -0
- package/dist/abis.js +486 -0
- package/dist/abis.js.map +1 -0
- package/dist/addresses.d.ts +51 -0
- package/dist/addresses.d.ts.map +1 -0
- package/dist/addresses.js +80 -0
- package/dist/addresses.js.map +1 -0
- package/dist/api-deployer-types.d.ts +165 -0
- package/dist/api-deployer-types.d.ts.map +1 -0
- package/dist/api-deployer-types.js +9 -0
- package/dist/api-deployer-types.js.map +1 -0
- package/dist/api-deployer.d.ts +114 -0
- package/dist/api-deployer.d.ts.map +1 -0
- package/dist/api-deployer.js +309 -0
- package/dist/api-deployer.js.map +1 -0
- package/dist/claimer.d.ts +197 -0
- package/dist/claimer.d.ts.map +1 -0
- package/dist/claimer.js +311 -0
- package/dist/claimer.js.map +1 -0
- package/dist/deployer.d.ts +229 -0
- package/dist/deployer.d.ts.map +1 -0
- package/dist/deployer.js +305 -0
- package/dist/deployer.js.map +1 -0
- package/dist/erc8004-types.d.ts +94 -0
- package/dist/erc8004-types.d.ts.map +1 -0
- package/dist/erc8004-types.js +8 -0
- package/dist/erc8004-types.js.map +1 -0
- package/dist/errors.d.ts +62 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +75 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +204 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +358 -0
- package/dist/index.js.map +1 -0
- package/dist/liquidity-types.d.ts +198 -0
- package/dist/liquidity-types.d.ts.map +1 -0
- package/dist/liquidity-types.js +8 -0
- package/dist/liquidity-types.js.map +1 -0
- package/dist/liquidity.d.ts +111 -0
- package/dist/liquidity.d.ts.map +1 -0
- package/dist/liquidity.js +608 -0
- package/dist/liquidity.js.map +1 -0
- package/dist/molten-types.d.ts +282 -0
- package/dist/molten-types.d.ts.map +1 -0
- package/dist/molten-types.js +8 -0
- package/dist/molten-types.js.map +1 -0
- package/dist/molten.d.ts +336 -0
- package/dist/molten.d.ts.map +1 -0
- package/dist/molten.js +560 -0
- package/dist/molten.js.map +1 -0
- package/dist/portfolio.d.ts +129 -0
- package/dist/portfolio.d.ts.map +1 -0
- package/dist/portfolio.js +218 -0
- package/dist/portfolio.js.map +1 -0
- package/dist/reader.d.ts +249 -0
- package/dist/reader.d.ts.map +1 -0
- package/dist/reader.js +488 -0
- package/dist/reader.js.map +1 -0
- package/dist/swap-types.d.ts +159 -0
- package/dist/swap-types.d.ts.map +1 -0
- package/dist/swap-types.js +22 -0
- package/dist/swap-types.js.map +1 -0
- package/dist/swap.d.ts +762 -0
- package/dist/swap.d.ts.map +1 -0
- package/dist/swap.js +345 -0
- package/dist/swap.js.map +1 -0
- package/dist/token-verification-data.d.ts +4 -0
- package/dist/token-verification-data.d.ts.map +1 -0
- package/dist/token-verification-data.js +6 -0
- package/dist/token-verification-data.js.map +1 -0
- package/dist/types.d.ts +244 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/uniswap-abis.d.ts +470 -0
- package/dist/uniswap-abis.d.ts.map +1 -0
- package/dist/uniswap-abis.js +322 -0
- package/dist/uniswap-abis.js.map +1 -0
- package/dist/uniswap-addresses.d.ts +38 -0
- package/dist/uniswap-addresses.d.ts.map +1 -0
- package/dist/uniswap-addresses.js +67 -0
- package/dist/uniswap-addresses.js.map +1 -0
- package/dist/vanity.d.ts +115 -0
- package/dist/vanity.d.ts.map +1 -0
- package/dist/vanity.js +166 -0
- package/dist/vanity.js.map +1 -0
- package/dist/verify.d.ts +88 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +181 -0
- package/dist/verify.js.map +1 -0
- package/dist/watcher.d.ts +112 -0
- package/dist/watcher.d.ts.map +1 -0
- package/dist/watcher.js +132 -0
- package/dist/watcher.js.map +1 -0
- package/package.json +59 -0
package/dist/swap.d.ts
ADDED
|
@@ -0,0 +1,762 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClawnchSwapper - Token swaps via Clawnch API (0x aggregation)
|
|
3
|
+
*
|
|
4
|
+
* Server-side / agent swap execution on Base using 0x aggregation
|
|
5
|
+
* routed through the Clawnch API. No API key needed — the Clawnch
|
|
6
|
+
* server handles 0x authentication and integrator fees.
|
|
7
|
+
*
|
|
8
|
+
* Uses the AllowanceHolder path for simple approve-and-swap flow.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { ClawnchSwapper, NATIVE_TOKEN_ADDRESS } from '@clawnch/clawncher-sdk';
|
|
13
|
+
* import { createWalletClient, createPublicClient, http, parseEther } from 'viem';
|
|
14
|
+
* import { privateKeyToAccount } from 'viem/accounts';
|
|
15
|
+
* import { base } from 'viem/chains';
|
|
16
|
+
*
|
|
17
|
+
* const account = privateKeyToAccount('0x...');
|
|
18
|
+
* const wallet = createWalletClient({ account, chain: base, transport: http() });
|
|
19
|
+
* const publicClient = createPublicClient({ chain: base, transport: http() });
|
|
20
|
+
*
|
|
21
|
+
* const swapper = new ClawnchSwapper({ wallet, publicClient });
|
|
22
|
+
*
|
|
23
|
+
* // Swap 0.01 ETH for a token
|
|
24
|
+
* const result = await swapper.swap({
|
|
25
|
+
* sellToken: NATIVE_TOKEN_ADDRESS,
|
|
26
|
+
* buyToken: '0x...', // token address
|
|
27
|
+
* sellAmount: parseEther('0.01'),
|
|
28
|
+
* });
|
|
29
|
+
* console.log('Received:', result.buyAmount);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
import { type Address, type Hex, type Hash } from 'viem';
|
|
33
|
+
import type { SwapperConfig, SwapParams, SwapPriceResult, SwapQuoteResult, SwapResult } from './swap-types.js';
|
|
34
|
+
export type { SwapperConfig, SwapParams, SwapPriceResult, SwapQuoteResult, SwapResult, } from './swap-types.js';
|
|
35
|
+
export { NATIVE_TOKEN_ADDRESS, ZEROX_API_BASE, BASE_CHAIN_ID, BASE_SEPOLIA_CHAIN_ID, BASE_WETH, BASE_SEPOLIA_WETH, } from './swap-types.js';
|
|
36
|
+
export declare class ClawnchSwapper {
|
|
37
|
+
private readonly wallet;
|
|
38
|
+
private readonly publicClient;
|
|
39
|
+
private readonly network;
|
|
40
|
+
private readonly apiBaseUrl;
|
|
41
|
+
private readonly chainId;
|
|
42
|
+
constructor(config: SwapperConfig);
|
|
43
|
+
/**
|
|
44
|
+
* Get the taker address (wallet account)
|
|
45
|
+
*/
|
|
46
|
+
getTakerAddress(): Address;
|
|
47
|
+
/**
|
|
48
|
+
* Get the chain object for the configured network
|
|
49
|
+
*/
|
|
50
|
+
getChain(): {
|
|
51
|
+
blockExplorers: {
|
|
52
|
+
readonly default: {
|
|
53
|
+
readonly name: "Basescan";
|
|
54
|
+
readonly url: "https://basescan.org";
|
|
55
|
+
readonly apiUrl: "https://api.basescan.org/api";
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
blockTime: 2000;
|
|
59
|
+
contracts: {
|
|
60
|
+
readonly disputeGameFactory: {
|
|
61
|
+
readonly 1: {
|
|
62
|
+
readonly address: "0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e";
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
readonly l2OutputOracle: {
|
|
66
|
+
readonly 1: {
|
|
67
|
+
readonly address: "0x56315b90c40730925ec5485cf004d835058518A0";
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
readonly multicall3: {
|
|
71
|
+
readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
|
|
72
|
+
readonly blockCreated: 5022;
|
|
73
|
+
};
|
|
74
|
+
readonly portal: {
|
|
75
|
+
readonly 1: {
|
|
76
|
+
readonly address: "0x49048044D57e1C92A77f79988d21Fa8fAF74E97e";
|
|
77
|
+
readonly blockCreated: 17482143;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
readonly l1StandardBridge: {
|
|
81
|
+
readonly 1: {
|
|
82
|
+
readonly address: "0x3154Cf16ccdb4C6d922629664174b904d80F2C35";
|
|
83
|
+
readonly blockCreated: 17482143;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
readonly gasPriceOracle: {
|
|
87
|
+
readonly address: "0x420000000000000000000000000000000000000F";
|
|
88
|
+
};
|
|
89
|
+
readonly l1Block: {
|
|
90
|
+
readonly address: "0x4200000000000000000000000000000000000015";
|
|
91
|
+
};
|
|
92
|
+
readonly l2CrossDomainMessenger: {
|
|
93
|
+
readonly address: "0x4200000000000000000000000000000000000007";
|
|
94
|
+
};
|
|
95
|
+
readonly l2Erc721Bridge: {
|
|
96
|
+
readonly address: "0x4200000000000000000000000000000000000014";
|
|
97
|
+
};
|
|
98
|
+
readonly l2StandardBridge: {
|
|
99
|
+
readonly address: "0x4200000000000000000000000000000000000010";
|
|
100
|
+
};
|
|
101
|
+
readonly l2ToL1MessagePasser: {
|
|
102
|
+
readonly address: "0x4200000000000000000000000000000000000016";
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
ensTlds?: readonly string[] | undefined;
|
|
106
|
+
id: 8453;
|
|
107
|
+
name: "Base";
|
|
108
|
+
nativeCurrency: {
|
|
109
|
+
readonly name: "Ether";
|
|
110
|
+
readonly symbol: "ETH";
|
|
111
|
+
readonly decimals: 18;
|
|
112
|
+
};
|
|
113
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
114
|
+
rpcUrls: {
|
|
115
|
+
readonly default: {
|
|
116
|
+
readonly http: readonly ["https://mainnet.base.org"];
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
sourceId: 1;
|
|
120
|
+
testnet?: boolean | undefined | undefined;
|
|
121
|
+
custom?: Record<string, unknown> | undefined;
|
|
122
|
+
extendSchema?: Record<string, unknown> | undefined;
|
|
123
|
+
fees?: import("viem").ChainFees<undefined> | undefined;
|
|
124
|
+
formatters: {
|
|
125
|
+
readonly block: {
|
|
126
|
+
exclude: [] | undefined;
|
|
127
|
+
format: (args: import("viem/chains").OpStackRpcBlock, action?: string | undefined) => {
|
|
128
|
+
baseFeePerGas: bigint | null;
|
|
129
|
+
blobGasUsed: bigint;
|
|
130
|
+
difficulty: bigint;
|
|
131
|
+
excessBlobGas: bigint;
|
|
132
|
+
extraData: import("viem").Hex;
|
|
133
|
+
gasLimit: bigint;
|
|
134
|
+
gasUsed: bigint;
|
|
135
|
+
hash: `0x${string}` | null;
|
|
136
|
+
logsBloom: `0x${string}` | null;
|
|
137
|
+
miner: import("abitype").Address;
|
|
138
|
+
mixHash: import("viem").Hash;
|
|
139
|
+
nonce: `0x${string}` | null;
|
|
140
|
+
number: bigint | null;
|
|
141
|
+
parentBeaconBlockRoot?: `0x${string}` | undefined;
|
|
142
|
+
parentHash: import("viem").Hash;
|
|
143
|
+
receiptsRoot: import("viem").Hex;
|
|
144
|
+
sealFields: import("viem").Hex[];
|
|
145
|
+
sha3Uncles: import("viem").Hash;
|
|
146
|
+
size: bigint;
|
|
147
|
+
stateRoot: import("viem").Hash;
|
|
148
|
+
timestamp: bigint;
|
|
149
|
+
totalDifficulty: bigint | null;
|
|
150
|
+
transactions: `0x${string}`[] | import("viem/chains").OpStackTransaction<boolean>[];
|
|
151
|
+
transactionsRoot: import("viem").Hash;
|
|
152
|
+
uncles: import("viem").Hash[];
|
|
153
|
+
withdrawals?: import("viem").Withdrawal[] | undefined | undefined;
|
|
154
|
+
withdrawalsRoot?: `0x${string}` | undefined;
|
|
155
|
+
} & {};
|
|
156
|
+
type: "block";
|
|
157
|
+
};
|
|
158
|
+
readonly transaction: {
|
|
159
|
+
exclude: [] | undefined;
|
|
160
|
+
format: (args: import("viem/chains").OpStackRpcTransaction, action?: string | undefined) => ({
|
|
161
|
+
blockHash: `0x${string}` | null;
|
|
162
|
+
blockNumber: bigint | null;
|
|
163
|
+
from: import("abitype").Address;
|
|
164
|
+
gas: bigint;
|
|
165
|
+
hash: import("viem").Hash;
|
|
166
|
+
input: import("viem").Hex;
|
|
167
|
+
nonce: number;
|
|
168
|
+
r: import("viem").Hex;
|
|
169
|
+
s: import("viem").Hex;
|
|
170
|
+
to: import("abitype").Address | null;
|
|
171
|
+
transactionIndex: number | null;
|
|
172
|
+
typeHex: import("viem").Hex | null;
|
|
173
|
+
v: bigint;
|
|
174
|
+
value: bigint;
|
|
175
|
+
yParity: number;
|
|
176
|
+
gasPrice?: undefined | undefined;
|
|
177
|
+
maxFeePerBlobGas?: undefined | undefined;
|
|
178
|
+
maxFeePerGas: bigint;
|
|
179
|
+
maxPriorityFeePerGas: bigint;
|
|
180
|
+
isSystemTx?: boolean;
|
|
181
|
+
mint?: bigint | undefined | undefined;
|
|
182
|
+
sourceHash: import("viem").Hex;
|
|
183
|
+
type: "deposit";
|
|
184
|
+
} | {
|
|
185
|
+
r: import("viem").Hex;
|
|
186
|
+
s: import("viem").Hex;
|
|
187
|
+
v: bigint;
|
|
188
|
+
to: import("abitype").Address | null;
|
|
189
|
+
from: import("abitype").Address;
|
|
190
|
+
gas: bigint;
|
|
191
|
+
nonce: number;
|
|
192
|
+
value: bigint;
|
|
193
|
+
blockHash: `0x${string}` | null;
|
|
194
|
+
blockNumber: bigint | null;
|
|
195
|
+
hash: import("viem").Hash;
|
|
196
|
+
input: import("viem").Hex;
|
|
197
|
+
transactionIndex: number | null;
|
|
198
|
+
typeHex: import("viem").Hex | null;
|
|
199
|
+
accessList?: undefined | undefined;
|
|
200
|
+
authorizationList?: undefined | undefined;
|
|
201
|
+
blobVersionedHashes?: undefined | undefined;
|
|
202
|
+
chainId?: number | undefined;
|
|
203
|
+
yParity?: undefined | undefined;
|
|
204
|
+
type: "legacy";
|
|
205
|
+
gasPrice: bigint;
|
|
206
|
+
maxFeePerBlobGas?: undefined | undefined;
|
|
207
|
+
maxFeePerGas?: undefined | undefined;
|
|
208
|
+
maxPriorityFeePerGas?: undefined | undefined;
|
|
209
|
+
isSystemTx?: undefined | undefined;
|
|
210
|
+
mint?: undefined | undefined;
|
|
211
|
+
sourceHash?: undefined | undefined;
|
|
212
|
+
} | {
|
|
213
|
+
blockHash: `0x${string}` | null;
|
|
214
|
+
blockNumber: bigint | null;
|
|
215
|
+
from: import("abitype").Address;
|
|
216
|
+
gas: bigint;
|
|
217
|
+
hash: import("viem").Hash;
|
|
218
|
+
input: import("viem").Hex;
|
|
219
|
+
nonce: number;
|
|
220
|
+
r: import("viem").Hex;
|
|
221
|
+
s: import("viem").Hex;
|
|
222
|
+
to: import("abitype").Address | null;
|
|
223
|
+
transactionIndex: number | null;
|
|
224
|
+
typeHex: import("viem").Hex | null;
|
|
225
|
+
v: bigint;
|
|
226
|
+
value: bigint;
|
|
227
|
+
yParity: number;
|
|
228
|
+
accessList: import("viem").AccessList;
|
|
229
|
+
authorizationList?: undefined | undefined;
|
|
230
|
+
blobVersionedHashes?: undefined | undefined;
|
|
231
|
+
chainId: number;
|
|
232
|
+
type: "eip2930";
|
|
233
|
+
gasPrice: bigint;
|
|
234
|
+
maxFeePerBlobGas?: undefined | undefined;
|
|
235
|
+
maxFeePerGas?: undefined | undefined;
|
|
236
|
+
maxPriorityFeePerGas?: undefined | undefined;
|
|
237
|
+
isSystemTx?: undefined | undefined;
|
|
238
|
+
mint?: undefined | undefined;
|
|
239
|
+
sourceHash?: undefined | undefined;
|
|
240
|
+
} | {
|
|
241
|
+
blockHash: `0x${string}` | null;
|
|
242
|
+
blockNumber: bigint | null;
|
|
243
|
+
from: import("abitype").Address;
|
|
244
|
+
gas: bigint;
|
|
245
|
+
hash: import("viem").Hash;
|
|
246
|
+
input: import("viem").Hex;
|
|
247
|
+
nonce: number;
|
|
248
|
+
r: import("viem").Hex;
|
|
249
|
+
s: import("viem").Hex;
|
|
250
|
+
to: import("abitype").Address | null;
|
|
251
|
+
transactionIndex: number | null;
|
|
252
|
+
typeHex: import("viem").Hex | null;
|
|
253
|
+
v: bigint;
|
|
254
|
+
value: bigint;
|
|
255
|
+
yParity: number;
|
|
256
|
+
accessList: import("viem").AccessList;
|
|
257
|
+
authorizationList?: undefined | undefined;
|
|
258
|
+
blobVersionedHashes?: undefined | undefined;
|
|
259
|
+
chainId: number;
|
|
260
|
+
type: "eip1559";
|
|
261
|
+
gasPrice?: undefined | undefined;
|
|
262
|
+
maxFeePerBlobGas?: undefined | undefined;
|
|
263
|
+
maxFeePerGas: bigint;
|
|
264
|
+
maxPriorityFeePerGas: bigint;
|
|
265
|
+
isSystemTx?: undefined | undefined;
|
|
266
|
+
mint?: undefined | undefined;
|
|
267
|
+
sourceHash?: undefined | undefined;
|
|
268
|
+
} | {
|
|
269
|
+
blockHash: `0x${string}` | null;
|
|
270
|
+
blockNumber: bigint | null;
|
|
271
|
+
from: import("abitype").Address;
|
|
272
|
+
gas: bigint;
|
|
273
|
+
hash: import("viem").Hash;
|
|
274
|
+
input: import("viem").Hex;
|
|
275
|
+
nonce: number;
|
|
276
|
+
r: import("viem").Hex;
|
|
277
|
+
s: import("viem").Hex;
|
|
278
|
+
to: import("abitype").Address | null;
|
|
279
|
+
transactionIndex: number | null;
|
|
280
|
+
typeHex: import("viem").Hex | null;
|
|
281
|
+
v: bigint;
|
|
282
|
+
value: bigint;
|
|
283
|
+
yParity: number;
|
|
284
|
+
accessList: import("viem").AccessList;
|
|
285
|
+
authorizationList?: undefined | undefined;
|
|
286
|
+
blobVersionedHashes: readonly import("viem").Hex[];
|
|
287
|
+
chainId: number;
|
|
288
|
+
type: "eip4844";
|
|
289
|
+
gasPrice?: undefined | undefined;
|
|
290
|
+
maxFeePerBlobGas: bigint;
|
|
291
|
+
maxFeePerGas: bigint;
|
|
292
|
+
maxPriorityFeePerGas: bigint;
|
|
293
|
+
isSystemTx?: undefined | undefined;
|
|
294
|
+
mint?: undefined | undefined;
|
|
295
|
+
sourceHash?: undefined | undefined;
|
|
296
|
+
} | {
|
|
297
|
+
blockHash: `0x${string}` | null;
|
|
298
|
+
blockNumber: bigint | null;
|
|
299
|
+
from: import("abitype").Address;
|
|
300
|
+
gas: bigint;
|
|
301
|
+
hash: import("viem").Hash;
|
|
302
|
+
input: import("viem").Hex;
|
|
303
|
+
nonce: number;
|
|
304
|
+
r: import("viem").Hex;
|
|
305
|
+
s: import("viem").Hex;
|
|
306
|
+
to: import("abitype").Address | null;
|
|
307
|
+
transactionIndex: number | null;
|
|
308
|
+
typeHex: import("viem").Hex | null;
|
|
309
|
+
v: bigint;
|
|
310
|
+
value: bigint;
|
|
311
|
+
yParity: number;
|
|
312
|
+
accessList: import("viem").AccessList;
|
|
313
|
+
authorizationList: import("viem").SignedAuthorizationList;
|
|
314
|
+
blobVersionedHashes?: undefined | undefined;
|
|
315
|
+
chainId: number;
|
|
316
|
+
type: "eip7702";
|
|
317
|
+
gasPrice?: undefined | undefined;
|
|
318
|
+
maxFeePerBlobGas?: undefined | undefined;
|
|
319
|
+
maxFeePerGas: bigint;
|
|
320
|
+
maxPriorityFeePerGas: bigint;
|
|
321
|
+
isSystemTx?: undefined | undefined;
|
|
322
|
+
mint?: undefined | undefined;
|
|
323
|
+
sourceHash?: undefined | undefined;
|
|
324
|
+
}) & {};
|
|
325
|
+
type: "transaction";
|
|
326
|
+
};
|
|
327
|
+
readonly transactionReceipt: {
|
|
328
|
+
exclude: [] | undefined;
|
|
329
|
+
format: (args: import("viem/chains").OpStackRpcTransactionReceipt, action?: string | undefined) => {
|
|
330
|
+
blobGasPrice?: bigint | undefined;
|
|
331
|
+
blobGasUsed?: bigint | undefined;
|
|
332
|
+
blockHash: import("viem").Hash;
|
|
333
|
+
blockNumber: bigint;
|
|
334
|
+
contractAddress: import("abitype").Address | null | undefined;
|
|
335
|
+
cumulativeGasUsed: bigint;
|
|
336
|
+
effectiveGasPrice: bigint;
|
|
337
|
+
from: import("abitype").Address;
|
|
338
|
+
gasUsed: bigint;
|
|
339
|
+
logs: import("viem").Log<bigint, number, false>[];
|
|
340
|
+
logsBloom: import("viem").Hex;
|
|
341
|
+
root?: `0x${string}` | undefined;
|
|
342
|
+
status: "success" | "reverted";
|
|
343
|
+
to: import("abitype").Address | null;
|
|
344
|
+
transactionHash: import("viem").Hash;
|
|
345
|
+
transactionIndex: number;
|
|
346
|
+
type: import("viem").TransactionType;
|
|
347
|
+
l1GasPrice: bigint | null;
|
|
348
|
+
l1GasUsed: bigint | null;
|
|
349
|
+
l1Fee: bigint | null;
|
|
350
|
+
l1FeeScalar: number | null;
|
|
351
|
+
} & {};
|
|
352
|
+
type: "transactionReceipt";
|
|
353
|
+
};
|
|
354
|
+
};
|
|
355
|
+
prepareTransactionRequest?: ((args: import("viem").PrepareTransactionRequestParameters, options: {
|
|
356
|
+
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
357
|
+
}) => Promise<import("viem").PrepareTransactionRequestParameters>) | [fn: ((args: import("viem").PrepareTransactionRequestParameters, options: {
|
|
358
|
+
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
359
|
+
}) => Promise<import("viem").PrepareTransactionRequestParameters>) | undefined, options: {
|
|
360
|
+
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
361
|
+
}] | undefined;
|
|
362
|
+
serializers: {
|
|
363
|
+
readonly transaction: typeof import("viem/chains").serializeTransactionOpStack;
|
|
364
|
+
};
|
|
365
|
+
verifyHash?: ((client: import("viem").Client, parameters: import("viem").VerifyHashActionParameters) => Promise<import("viem").VerifyHashActionReturnType>) | undefined;
|
|
366
|
+
} | {
|
|
367
|
+
blockExplorers: {
|
|
368
|
+
readonly default: {
|
|
369
|
+
readonly name: "Basescan";
|
|
370
|
+
readonly url: "https://sepolia.basescan.org";
|
|
371
|
+
readonly apiUrl: "https://api-sepolia.basescan.org/api";
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
blockTime: 2000;
|
|
375
|
+
contracts: {
|
|
376
|
+
readonly disputeGameFactory: {
|
|
377
|
+
readonly 11155111: {
|
|
378
|
+
readonly address: "0xd6E6dBf4F7EA0ac412fD8b65ED297e64BB7a06E1";
|
|
379
|
+
};
|
|
380
|
+
};
|
|
381
|
+
readonly l2OutputOracle: {
|
|
382
|
+
readonly 11155111: {
|
|
383
|
+
readonly address: "0x84457ca9D0163FbC4bbfe4Dfbb20ba46e48DF254";
|
|
384
|
+
};
|
|
385
|
+
};
|
|
386
|
+
readonly portal: {
|
|
387
|
+
readonly 11155111: {
|
|
388
|
+
readonly address: "0x49f53e41452c74589e85ca1677426ba426459e85";
|
|
389
|
+
readonly blockCreated: 4446677;
|
|
390
|
+
};
|
|
391
|
+
};
|
|
392
|
+
readonly l1StandardBridge: {
|
|
393
|
+
readonly 11155111: {
|
|
394
|
+
readonly address: "0xfd0Bf71F60660E2f608ed56e1659C450eB113120";
|
|
395
|
+
readonly blockCreated: 4446677;
|
|
396
|
+
};
|
|
397
|
+
};
|
|
398
|
+
readonly multicall3: {
|
|
399
|
+
readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
|
|
400
|
+
readonly blockCreated: 1059647;
|
|
401
|
+
};
|
|
402
|
+
readonly gasPriceOracle: {
|
|
403
|
+
readonly address: "0x420000000000000000000000000000000000000F";
|
|
404
|
+
};
|
|
405
|
+
readonly l1Block: {
|
|
406
|
+
readonly address: "0x4200000000000000000000000000000000000015";
|
|
407
|
+
};
|
|
408
|
+
readonly l2CrossDomainMessenger: {
|
|
409
|
+
readonly address: "0x4200000000000000000000000000000000000007";
|
|
410
|
+
};
|
|
411
|
+
readonly l2Erc721Bridge: {
|
|
412
|
+
readonly address: "0x4200000000000000000000000000000000000014";
|
|
413
|
+
};
|
|
414
|
+
readonly l2StandardBridge: {
|
|
415
|
+
readonly address: "0x4200000000000000000000000000000000000010";
|
|
416
|
+
};
|
|
417
|
+
readonly l2ToL1MessagePasser: {
|
|
418
|
+
readonly address: "0x4200000000000000000000000000000000000016";
|
|
419
|
+
};
|
|
420
|
+
};
|
|
421
|
+
ensTlds?: readonly string[] | undefined;
|
|
422
|
+
id: 84532;
|
|
423
|
+
name: "Base Sepolia";
|
|
424
|
+
nativeCurrency: {
|
|
425
|
+
readonly name: "Sepolia Ether";
|
|
426
|
+
readonly symbol: "ETH";
|
|
427
|
+
readonly decimals: 18;
|
|
428
|
+
};
|
|
429
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
430
|
+
rpcUrls: {
|
|
431
|
+
readonly default: {
|
|
432
|
+
readonly http: readonly ["https://sepolia.base.org"];
|
|
433
|
+
};
|
|
434
|
+
};
|
|
435
|
+
sourceId: 11155111;
|
|
436
|
+
testnet: true;
|
|
437
|
+
custom?: Record<string, unknown> | undefined;
|
|
438
|
+
extendSchema?: Record<string, unknown> | undefined;
|
|
439
|
+
fees?: import("viem").ChainFees<undefined> | undefined;
|
|
440
|
+
formatters: {
|
|
441
|
+
readonly block: {
|
|
442
|
+
exclude: [] | undefined;
|
|
443
|
+
format: (args: import("viem/chains").OpStackRpcBlock, action?: string | undefined) => {
|
|
444
|
+
baseFeePerGas: bigint | null;
|
|
445
|
+
blobGasUsed: bigint;
|
|
446
|
+
difficulty: bigint;
|
|
447
|
+
excessBlobGas: bigint;
|
|
448
|
+
extraData: import("viem").Hex;
|
|
449
|
+
gasLimit: bigint;
|
|
450
|
+
gasUsed: bigint;
|
|
451
|
+
hash: `0x${string}` | null;
|
|
452
|
+
logsBloom: `0x${string}` | null;
|
|
453
|
+
miner: import("abitype").Address;
|
|
454
|
+
mixHash: import("viem").Hash;
|
|
455
|
+
nonce: `0x${string}` | null;
|
|
456
|
+
number: bigint | null;
|
|
457
|
+
parentBeaconBlockRoot?: `0x${string}` | undefined;
|
|
458
|
+
parentHash: import("viem").Hash;
|
|
459
|
+
receiptsRoot: import("viem").Hex;
|
|
460
|
+
sealFields: import("viem").Hex[];
|
|
461
|
+
sha3Uncles: import("viem").Hash;
|
|
462
|
+
size: bigint;
|
|
463
|
+
stateRoot: import("viem").Hash;
|
|
464
|
+
timestamp: bigint;
|
|
465
|
+
totalDifficulty: bigint | null;
|
|
466
|
+
transactions: `0x${string}`[] | import("viem/chains").OpStackTransaction<boolean>[];
|
|
467
|
+
transactionsRoot: import("viem").Hash;
|
|
468
|
+
uncles: import("viem").Hash[];
|
|
469
|
+
withdrawals?: import("viem").Withdrawal[] | undefined | undefined;
|
|
470
|
+
withdrawalsRoot?: `0x${string}` | undefined;
|
|
471
|
+
} & {};
|
|
472
|
+
type: "block";
|
|
473
|
+
};
|
|
474
|
+
readonly transaction: {
|
|
475
|
+
exclude: [] | undefined;
|
|
476
|
+
format: (args: import("viem/chains").OpStackRpcTransaction, action?: string | undefined) => ({
|
|
477
|
+
blockHash: `0x${string}` | null;
|
|
478
|
+
blockNumber: bigint | null;
|
|
479
|
+
from: import("abitype").Address;
|
|
480
|
+
gas: bigint;
|
|
481
|
+
hash: import("viem").Hash;
|
|
482
|
+
input: import("viem").Hex;
|
|
483
|
+
nonce: number;
|
|
484
|
+
r: import("viem").Hex;
|
|
485
|
+
s: import("viem").Hex;
|
|
486
|
+
to: import("abitype").Address | null;
|
|
487
|
+
transactionIndex: number | null;
|
|
488
|
+
typeHex: import("viem").Hex | null;
|
|
489
|
+
v: bigint;
|
|
490
|
+
value: bigint;
|
|
491
|
+
yParity: number;
|
|
492
|
+
gasPrice?: undefined | undefined;
|
|
493
|
+
maxFeePerBlobGas?: undefined | undefined;
|
|
494
|
+
maxFeePerGas: bigint;
|
|
495
|
+
maxPriorityFeePerGas: bigint;
|
|
496
|
+
isSystemTx?: boolean;
|
|
497
|
+
mint?: bigint | undefined | undefined;
|
|
498
|
+
sourceHash: import("viem").Hex;
|
|
499
|
+
type: "deposit";
|
|
500
|
+
} | {
|
|
501
|
+
r: import("viem").Hex;
|
|
502
|
+
s: import("viem").Hex;
|
|
503
|
+
v: bigint;
|
|
504
|
+
to: import("abitype").Address | null;
|
|
505
|
+
from: import("abitype").Address;
|
|
506
|
+
gas: bigint;
|
|
507
|
+
nonce: number;
|
|
508
|
+
value: bigint;
|
|
509
|
+
blockHash: `0x${string}` | null;
|
|
510
|
+
blockNumber: bigint | null;
|
|
511
|
+
hash: import("viem").Hash;
|
|
512
|
+
input: import("viem").Hex;
|
|
513
|
+
transactionIndex: number | null;
|
|
514
|
+
typeHex: import("viem").Hex | null;
|
|
515
|
+
accessList?: undefined | undefined;
|
|
516
|
+
authorizationList?: undefined | undefined;
|
|
517
|
+
blobVersionedHashes?: undefined | undefined;
|
|
518
|
+
chainId?: number | undefined;
|
|
519
|
+
yParity?: undefined | undefined;
|
|
520
|
+
type: "legacy";
|
|
521
|
+
gasPrice: bigint;
|
|
522
|
+
maxFeePerBlobGas?: undefined | undefined;
|
|
523
|
+
maxFeePerGas?: undefined | undefined;
|
|
524
|
+
maxPriorityFeePerGas?: undefined | undefined;
|
|
525
|
+
isSystemTx?: undefined | undefined;
|
|
526
|
+
mint?: undefined | undefined;
|
|
527
|
+
sourceHash?: undefined | undefined;
|
|
528
|
+
} | {
|
|
529
|
+
blockHash: `0x${string}` | null;
|
|
530
|
+
blockNumber: bigint | null;
|
|
531
|
+
from: import("abitype").Address;
|
|
532
|
+
gas: bigint;
|
|
533
|
+
hash: import("viem").Hash;
|
|
534
|
+
input: import("viem").Hex;
|
|
535
|
+
nonce: number;
|
|
536
|
+
r: import("viem").Hex;
|
|
537
|
+
s: import("viem").Hex;
|
|
538
|
+
to: import("abitype").Address | null;
|
|
539
|
+
transactionIndex: number | null;
|
|
540
|
+
typeHex: import("viem").Hex | null;
|
|
541
|
+
v: bigint;
|
|
542
|
+
value: bigint;
|
|
543
|
+
yParity: number;
|
|
544
|
+
accessList: import("viem").AccessList;
|
|
545
|
+
authorizationList?: undefined | undefined;
|
|
546
|
+
blobVersionedHashes?: undefined | undefined;
|
|
547
|
+
chainId: number;
|
|
548
|
+
type: "eip2930";
|
|
549
|
+
gasPrice: bigint;
|
|
550
|
+
maxFeePerBlobGas?: undefined | undefined;
|
|
551
|
+
maxFeePerGas?: undefined | undefined;
|
|
552
|
+
maxPriorityFeePerGas?: undefined | undefined;
|
|
553
|
+
isSystemTx?: undefined | undefined;
|
|
554
|
+
mint?: undefined | undefined;
|
|
555
|
+
sourceHash?: undefined | undefined;
|
|
556
|
+
} | {
|
|
557
|
+
blockHash: `0x${string}` | null;
|
|
558
|
+
blockNumber: bigint | null;
|
|
559
|
+
from: import("abitype").Address;
|
|
560
|
+
gas: bigint;
|
|
561
|
+
hash: import("viem").Hash;
|
|
562
|
+
input: import("viem").Hex;
|
|
563
|
+
nonce: number;
|
|
564
|
+
r: import("viem").Hex;
|
|
565
|
+
s: import("viem").Hex;
|
|
566
|
+
to: import("abitype").Address | null;
|
|
567
|
+
transactionIndex: number | null;
|
|
568
|
+
typeHex: import("viem").Hex | null;
|
|
569
|
+
v: bigint;
|
|
570
|
+
value: bigint;
|
|
571
|
+
yParity: number;
|
|
572
|
+
accessList: import("viem").AccessList;
|
|
573
|
+
authorizationList?: undefined | undefined;
|
|
574
|
+
blobVersionedHashes?: undefined | undefined;
|
|
575
|
+
chainId: number;
|
|
576
|
+
type: "eip1559";
|
|
577
|
+
gasPrice?: undefined | undefined;
|
|
578
|
+
maxFeePerBlobGas?: undefined | undefined;
|
|
579
|
+
maxFeePerGas: bigint;
|
|
580
|
+
maxPriorityFeePerGas: bigint;
|
|
581
|
+
isSystemTx?: undefined | undefined;
|
|
582
|
+
mint?: undefined | undefined;
|
|
583
|
+
sourceHash?: undefined | undefined;
|
|
584
|
+
} | {
|
|
585
|
+
blockHash: `0x${string}` | null;
|
|
586
|
+
blockNumber: bigint | null;
|
|
587
|
+
from: import("abitype").Address;
|
|
588
|
+
gas: bigint;
|
|
589
|
+
hash: import("viem").Hash;
|
|
590
|
+
input: import("viem").Hex;
|
|
591
|
+
nonce: number;
|
|
592
|
+
r: import("viem").Hex;
|
|
593
|
+
s: import("viem").Hex;
|
|
594
|
+
to: import("abitype").Address | null;
|
|
595
|
+
transactionIndex: number | null;
|
|
596
|
+
typeHex: import("viem").Hex | null;
|
|
597
|
+
v: bigint;
|
|
598
|
+
value: bigint;
|
|
599
|
+
yParity: number;
|
|
600
|
+
accessList: import("viem").AccessList;
|
|
601
|
+
authorizationList?: undefined | undefined;
|
|
602
|
+
blobVersionedHashes: readonly import("viem").Hex[];
|
|
603
|
+
chainId: number;
|
|
604
|
+
type: "eip4844";
|
|
605
|
+
gasPrice?: undefined | undefined;
|
|
606
|
+
maxFeePerBlobGas: bigint;
|
|
607
|
+
maxFeePerGas: bigint;
|
|
608
|
+
maxPriorityFeePerGas: bigint;
|
|
609
|
+
isSystemTx?: undefined | undefined;
|
|
610
|
+
mint?: undefined | undefined;
|
|
611
|
+
sourceHash?: undefined | undefined;
|
|
612
|
+
} | {
|
|
613
|
+
blockHash: `0x${string}` | null;
|
|
614
|
+
blockNumber: bigint | null;
|
|
615
|
+
from: import("abitype").Address;
|
|
616
|
+
gas: bigint;
|
|
617
|
+
hash: import("viem").Hash;
|
|
618
|
+
input: import("viem").Hex;
|
|
619
|
+
nonce: number;
|
|
620
|
+
r: import("viem").Hex;
|
|
621
|
+
s: import("viem").Hex;
|
|
622
|
+
to: import("abitype").Address | null;
|
|
623
|
+
transactionIndex: number | null;
|
|
624
|
+
typeHex: import("viem").Hex | null;
|
|
625
|
+
v: bigint;
|
|
626
|
+
value: bigint;
|
|
627
|
+
yParity: number;
|
|
628
|
+
accessList: import("viem").AccessList;
|
|
629
|
+
authorizationList: import("viem").SignedAuthorizationList;
|
|
630
|
+
blobVersionedHashes?: undefined | undefined;
|
|
631
|
+
chainId: number;
|
|
632
|
+
type: "eip7702";
|
|
633
|
+
gasPrice?: undefined | undefined;
|
|
634
|
+
maxFeePerBlobGas?: undefined | undefined;
|
|
635
|
+
maxFeePerGas: bigint;
|
|
636
|
+
maxPriorityFeePerGas: bigint;
|
|
637
|
+
isSystemTx?: undefined | undefined;
|
|
638
|
+
mint?: undefined | undefined;
|
|
639
|
+
sourceHash?: undefined | undefined;
|
|
640
|
+
}) & {};
|
|
641
|
+
type: "transaction";
|
|
642
|
+
};
|
|
643
|
+
readonly transactionReceipt: {
|
|
644
|
+
exclude: [] | undefined;
|
|
645
|
+
format: (args: import("viem/chains").OpStackRpcTransactionReceipt, action?: string | undefined) => {
|
|
646
|
+
blobGasPrice?: bigint | undefined;
|
|
647
|
+
blobGasUsed?: bigint | undefined;
|
|
648
|
+
blockHash: import("viem").Hash;
|
|
649
|
+
blockNumber: bigint;
|
|
650
|
+
contractAddress: import("abitype").Address | null | undefined;
|
|
651
|
+
cumulativeGasUsed: bigint;
|
|
652
|
+
effectiveGasPrice: bigint;
|
|
653
|
+
from: import("abitype").Address;
|
|
654
|
+
gasUsed: bigint;
|
|
655
|
+
logs: import("viem").Log<bigint, number, false>[];
|
|
656
|
+
logsBloom: import("viem").Hex;
|
|
657
|
+
root?: `0x${string}` | undefined;
|
|
658
|
+
status: "success" | "reverted";
|
|
659
|
+
to: import("abitype").Address | null;
|
|
660
|
+
transactionHash: import("viem").Hash;
|
|
661
|
+
transactionIndex: number;
|
|
662
|
+
type: import("viem").TransactionType;
|
|
663
|
+
l1GasPrice: bigint | null;
|
|
664
|
+
l1GasUsed: bigint | null;
|
|
665
|
+
l1Fee: bigint | null;
|
|
666
|
+
l1FeeScalar: number | null;
|
|
667
|
+
} & {};
|
|
668
|
+
type: "transactionReceipt";
|
|
669
|
+
};
|
|
670
|
+
};
|
|
671
|
+
prepareTransactionRequest?: ((args: import("viem").PrepareTransactionRequestParameters, options: {
|
|
672
|
+
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
673
|
+
}) => Promise<import("viem").PrepareTransactionRequestParameters>) | [fn: ((args: import("viem").PrepareTransactionRequestParameters, options: {
|
|
674
|
+
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
675
|
+
}) => Promise<import("viem").PrepareTransactionRequestParameters>) | undefined, options: {
|
|
676
|
+
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
677
|
+
}] | undefined;
|
|
678
|
+
serializers: {
|
|
679
|
+
readonly transaction: typeof import("viem/chains").serializeTransactionOpStack;
|
|
680
|
+
};
|
|
681
|
+
verifyHash?: ((client: import("viem").Client, parameters: import("viem").VerifyHashActionParameters) => Promise<import("viem").VerifyHashActionReturnType>) | undefined;
|
|
682
|
+
readonly network: "base-sepolia";
|
|
683
|
+
};
|
|
684
|
+
/**
|
|
685
|
+
* Make a request to the Clawnch swap API proxy
|
|
686
|
+
*
|
|
687
|
+
* The Clawnch server proxies 0x Swap API requests, adding our API key
|
|
688
|
+
* and integrator fee configuration server-side. Users never need a 0x key.
|
|
689
|
+
*
|
|
690
|
+
* Paths are relative to the API base, e.g. '/price?...' becomes
|
|
691
|
+
* 'https://clawn.ch/api/swap/price?...'
|
|
692
|
+
*/
|
|
693
|
+
private apiRequest;
|
|
694
|
+
/**
|
|
695
|
+
* Build query params from SwapParams
|
|
696
|
+
*/
|
|
697
|
+
private buildSwapQuery;
|
|
698
|
+
/**
|
|
699
|
+
* Parse the raw 0x API price/quote response into our typed result
|
|
700
|
+
*/
|
|
701
|
+
private parsePriceResponse;
|
|
702
|
+
/**
|
|
703
|
+
* Parse a quote response (includes transaction data)
|
|
704
|
+
*/
|
|
705
|
+
private parseQuoteResponse;
|
|
706
|
+
/**
|
|
707
|
+
* Get an indicative price for a swap (no commitment, no taker required)
|
|
708
|
+
*
|
|
709
|
+
* Use this for price discovery / display before the user commits.
|
|
710
|
+
* Does NOT reserve liquidity with market makers.
|
|
711
|
+
*/
|
|
712
|
+
getPrice(params: SwapParams): Promise<SwapPriceResult>;
|
|
713
|
+
/**
|
|
714
|
+
* Get a firm quote for a swap (market makers commit assets)
|
|
715
|
+
*
|
|
716
|
+
* Requires a taker address. Returns transaction data ready to submit.
|
|
717
|
+
* Only call this when ready to execute — market makers reserve liquidity.
|
|
718
|
+
*/
|
|
719
|
+
getQuote(params: SwapParams): Promise<SwapQuoteResult>;
|
|
720
|
+
/**
|
|
721
|
+
* Check current ERC20 allowance for a given spender
|
|
722
|
+
*/
|
|
723
|
+
getAllowance(token: Address, owner: Address, spender: Address): Promise<bigint>;
|
|
724
|
+
/**
|
|
725
|
+
* Approve an ERC20 token for a spender (e.g. AllowanceHolder)
|
|
726
|
+
*
|
|
727
|
+
* @param token - ERC20 token address
|
|
728
|
+
* @param spender - Contract to approve (usually the allowanceTarget from quote)
|
|
729
|
+
* @param amount - Amount to approve (default: max uint256)
|
|
730
|
+
* @returns Transaction hash of the approval
|
|
731
|
+
*/
|
|
732
|
+
approveToken(token: Address, spender: Address, amount?: bigint): Promise<Hash>;
|
|
733
|
+
/**
|
|
734
|
+
* Execute a full swap: quote -> approve if needed -> send transaction
|
|
735
|
+
*
|
|
736
|
+
* This is the primary method for agents. It handles the entire flow:
|
|
737
|
+
* 1. Gets a firm quote from 0x
|
|
738
|
+
* 2. Checks and sets token allowance if needed (ERC20 only)
|
|
739
|
+
* 3. Sends the swap transaction
|
|
740
|
+
* 4. Waits for confirmation
|
|
741
|
+
*
|
|
742
|
+
* @returns SwapResult with transaction details and amounts
|
|
743
|
+
*/
|
|
744
|
+
swap(params: SwapParams): Promise<SwapResult>;
|
|
745
|
+
/**
|
|
746
|
+
* Get token balance for an address
|
|
747
|
+
*/
|
|
748
|
+
getBalance(token: Address, owner?: Address): Promise<bigint>;
|
|
749
|
+
/**
|
|
750
|
+
* Get token decimals
|
|
751
|
+
*/
|
|
752
|
+
getDecimals(token: Address): Promise<number>;
|
|
753
|
+
/**
|
|
754
|
+
* Get token symbol
|
|
755
|
+
*/
|
|
756
|
+
getSymbol(token: Address): Promise<string>;
|
|
757
|
+
/**
|
|
758
|
+
* Format a token amount to human-readable string
|
|
759
|
+
*/
|
|
760
|
+
formatAmount(token: Address, amount: bigint): Promise<string>;
|
|
761
|
+
}
|
|
762
|
+
//# sourceMappingURL=swap.d.ts.map
|