aegis-swap-widget 0.3.2 → 0.3.4

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +114 -43
  3. package/dist/abis.d.ts +0 -73
  4. package/dist/aegis-swap-widget.js +3468 -2344
  5. package/dist/config/chains.d.ts +11 -0
  6. package/dist/config/constants.d.ts +8 -0
  7. package/dist/config/contracts.d.ts +6 -0
  8. package/dist/config/createMarket.d.ts +3 -0
  9. package/dist/config/index.d.ts +7 -0
  10. package/dist/config/markets.d.ts +3 -0
  11. package/dist/config/tokens.d.ts +11 -0
  12. package/dist/{config.d.ts → config/types.d.ts} +5 -26
  13. package/dist/core.d.ts +3 -15
  14. package/dist/core.js +4 -64
  15. package/dist/encoding.d.ts +0 -29
  16. package/dist/hooks/useSubmitSwap.d.ts +11 -29
  17. package/dist/hooks/useSwapQuote.d.ts +3 -2
  18. package/dist/index.d.ts +3 -1
  19. package/dist/markets-LIeOtFf_.js +229 -0
  20. package/dist/permit.d.ts +1 -47
  21. package/dist/quote/aggregatedSwapQuote.d.ts +5 -0
  22. package/dist/services/kyberSwap.d.ts +84 -0
  23. package/dist/styles.css +1 -1
  24. package/dist/types/aggregatedSwap.d.ts +29 -0
  25. package/dist/widget/AegisAggregatedSwapWidget.d.ts +3 -0
  26. package/dist/widget/AmountField.d.ts +5 -1
  27. package/dist/widget/SwapWidgetShell.d.ts +51 -0
  28. package/dist/widget/TokenSelector.d.ts +13 -0
  29. package/dist/widget/types.d.ts +23 -2
  30. package/dist/widget/useAggregatedSwapController.d.ts +74 -0
  31. package/dist/widget/useRailAutoReset.d.ts +11 -0
  32. package/dist/widget/useStatusSurface.d.ts +32 -0
  33. package/dist/widget/useSwapController.d.ts +13 -14
  34. package/dist/widget/useWidgetStyle.d.ts +13 -0
  35. package/dist/widget/viewState.d.ts +21 -1
  36. package/package.json +23 -21
  37. package/dist/polling-BI4pZg8Z.js +0 -1252
  38. package/dist/swap/authorizePermit.d.ts +0 -30
  39. package/dist/swap/executeSwapTransaction.d.ts +0 -39
  40. package/dist/swap/types.d.ts +0 -7
@@ -1,1252 +0,0 @@
1
- import { keccak256 as ee, encodeAbiParameters as h, encodeFunctionData as P, getAddress as u, createWalletClient as D, custom as M, erc20Abi as te, http as ne, createPublicClient as oe, fallback as ae, isAddress as re } from "viem";
2
- import { mainnet as ie } from "viem/chains";
3
- function T(e) {
4
- return (e == null ? void 0 : e.toLowerCase()) ?? "";
5
- }
6
- function d(e, t) {
7
- return e.toLowerCase() === t.toLowerCase();
8
- }
9
- function ce(e, t) {
10
- return e === null || t === null ? e === t : d(e, t);
11
- }
12
- function K(e, t) {
13
- return e.toLowerCase() === t.toLowerCase();
14
- }
15
- const v = [
16
- {
17
- type: "function",
18
- name: "execute",
19
- stateMutability: "payable",
20
- inputs: [
21
- {
22
- name: "batches",
23
- type: "tuple[]",
24
- components: [
25
- { name: "requiresV4Unlock", type: "bool" },
26
- { name: "actions", type: "bytes" },
27
- { name: "params", type: "bytes[]" }
28
- ]
29
- },
30
- { name: "deadline", type: "uint256" }
31
- ],
32
- outputs: []
33
- },
34
- {
35
- type: "function",
36
- name: "multicall",
37
- stateMutability: "payable",
38
- inputs: [{ name: "data", type: "bytes[]" }],
39
- outputs: [{ name: "results", type: "bytes[]" }]
40
- },
41
- {
42
- type: "function",
43
- name: "permitBatch",
44
- stateMutability: "payable",
45
- inputs: [
46
- { name: "owner", type: "address" },
47
- {
48
- name: "permitBatch",
49
- type: "tuple",
50
- components: [
51
- {
52
- name: "details",
53
- type: "tuple[]",
54
- components: [
55
- { name: "token", type: "address" },
56
- { name: "amount", type: "uint160" },
57
- { name: "expiration", type: "uint48" },
58
- { name: "nonce", type: "uint48" }
59
- ]
60
- },
61
- { name: "spender", type: "address" },
62
- { name: "sigDeadline", type: "uint256" }
63
- ]
64
- },
65
- { name: "signature", type: "bytes" }
66
- ],
67
- outputs: []
68
- }
69
- ], L = [
70
- {
71
- type: "function",
72
- name: "approve",
73
- stateMutability: "nonpayable",
74
- inputs: [
75
- { name: "token", type: "address" },
76
- { name: "spender", type: "address" },
77
- { name: "amount", type: "uint160" },
78
- { name: "expiration", type: "uint48" }
79
- ],
80
- outputs: []
81
- },
82
- {
83
- type: "function",
84
- name: "allowance",
85
- stateMutability: "view",
86
- inputs: [
87
- { name: "owner", type: "address" },
88
- { name: "token", type: "address" },
89
- { name: "spender", type: "address" }
90
- ],
91
- outputs: [
92
- { name: "amount", type: "uint160" },
93
- { name: "expiration", type: "uint48" },
94
- { name: "nonce", type: "uint48" }
95
- ]
96
- }
97
- ], B = [
98
- {
99
- type: "function",
100
- name: "quoteExactInputSingle",
101
- stateMutability: "nonpayable",
102
- inputs: [
103
- {
104
- name: "params",
105
- type: "tuple",
106
- components: [
107
- {
108
- name: "poolKey",
109
- type: "tuple",
110
- components: [
111
- { name: "currency0", type: "address" },
112
- { name: "currency1", type: "address" },
113
- { name: "fee", type: "uint24" },
114
- { name: "tickSpacing", type: "int24" },
115
- { name: "hooks", type: "address" }
116
- ]
117
- },
118
- { name: "zeroForOne", type: "bool" },
119
- { name: "exactAmount", type: "uint128" },
120
- { name: "hookData", type: "bytes" }
121
- ]
122
- }
123
- ],
124
- outputs: [
125
- { name: "amountOut", type: "uint256" },
126
- { name: "gasEstimate", type: "uint256" }
127
- ]
128
- },
129
- {
130
- type: "function",
131
- name: "quoteExactOutputSingle",
132
- stateMutability: "nonpayable",
133
- inputs: [
134
- {
135
- name: "params",
136
- type: "tuple",
137
- components: [
138
- {
139
- name: "poolKey",
140
- type: "tuple",
141
- components: [
142
- { name: "currency0", type: "address" },
143
- { name: "currency1", type: "address" },
144
- { name: "fee", type: "uint24" },
145
- { name: "tickSpacing", type: "int24" },
146
- { name: "hooks", type: "address" }
147
- ]
148
- },
149
- { name: "zeroForOne", type: "bool" },
150
- { name: "exactAmount", type: "uint128" },
151
- { name: "hookData", type: "bytes" }
152
- ]
153
- }
154
- ],
155
- outputs: [
156
- { name: "amountIn", type: "uint256" },
157
- { name: "gasEstimate", type: "uint256" }
158
- ]
159
- }
160
- ], $ = 0n, ue = 2n ** 128n - 1n, w = {
161
- SWAP_EXACT_IN_SINGLE: 6,
162
- SWAP_EXACT_OUT_SINGLE: 8,
163
- SETTLE: 11,
164
- TAKE: 14,
165
- TAKE_PORTION: 16
166
- }, G = {
167
- name: "poolKey",
168
- type: "tuple",
169
- components: [
170
- { name: "currency0", type: "address" },
171
- { name: "currency1", type: "address" },
172
- { name: "fee", type: "uint24" },
173
- { name: "tickSpacing", type: "int24" },
174
- { name: "hooks", type: "address" }
175
- ]
176
- }, se = [
177
- {
178
- name: "params",
179
- type: "tuple",
180
- components: [
181
- G,
182
- { name: "zeroForOne", type: "bool" },
183
- { name: "amountIn", type: "uint128" },
184
- { name: "amountOutMinimum", type: "uint128" },
185
- { name: "hookData", type: "bytes" }
186
- ]
187
- }
188
- ], me = [
189
- {
190
- name: "params",
191
- type: "tuple",
192
- components: [
193
- G,
194
- { name: "zeroForOne", type: "bool" },
195
- { name: "amountOut", type: "uint128" },
196
- { name: "amountInMaximum", type: "uint128" },
197
- { name: "hookData", type: "bytes" }
198
- ]
199
- }
200
- ], pe = [
201
- { name: "currency", type: "address" },
202
- { name: "amount", type: "uint256" },
203
- { name: "payerIsUser", type: "bool" }
204
- ], V = [
205
- { name: "currency", type: "address" },
206
- { name: "recipient", type: "address" },
207
- { name: "amount", type: "uint256" }
208
- ], de = [
209
- { name: "currency", type: "address" },
210
- { name: "recipient", type: "address" },
211
- { name: "bips", type: "uint256" }
212
- ];
213
- function le(e) {
214
- return `0x${e.map((t) => t.toString(16).padStart(2, "0")).join("")}`;
215
- }
216
- function fe(e, t) {
217
- return {
218
- requiresV4Unlock: !0,
219
- actions: le(e),
220
- params: t
221
- };
222
- }
223
- function ye(e, t) {
224
- return P({
225
- abi: v,
226
- functionName: "execute",
227
- args: [e, t]
228
- });
229
- }
230
- function Ee(e) {
231
- return P({
232
- abi: v,
233
- functionName: "permitBatch",
234
- args: [e.owner, e.permitBatch, e.signature]
235
- });
236
- }
237
- function he(e) {
238
- return P({
239
- abi: v,
240
- functionName: "multicall",
241
- args: [e]
242
- });
243
- }
244
- function Ae(e) {
245
- if (!e) return !1;
246
- if ("bips" in e) {
247
- if (!Number.isInteger(e.bips) || e.bips < 0 || e.bips > 1e4)
248
- throw new Error("Fee portion must be an integer between 0 and 10000 bips.");
249
- return e.bips > 0;
250
- }
251
- return e.amount > 0n;
252
- }
253
- function we(e, t) {
254
- return "bips" in e ? {
255
- action: w.TAKE_PORTION,
256
- params: h(de, [t, e.recipient, BigInt(e.bips)])
257
- } : {
258
- action: w.TAKE,
259
- params: h(V, [t, e.recipient, e.amount])
260
- };
261
- }
262
- function S(e, t = "Amount") {
263
- if (e < 0n || e > ue)
264
- throw new Error(`${t} is too large for a single V4 swap.`);
265
- }
266
- function be(e, t) {
267
- return t ? he([Ee(t), e]) : e;
268
- }
269
- function z(e) {
270
- return ee(
271
- h(
272
- [
273
- { name: "currency0", type: "address" },
274
- { name: "currency1", type: "address" },
275
- { name: "fee", type: "uint24" },
276
- { name: "tickSpacing", type: "int24" },
277
- { name: "hooks", type: "address" }
278
- ],
279
- [
280
- e.currency0,
281
- e.currency1,
282
- e.fee,
283
- e.tickSpacing,
284
- e.hooks
285
- ]
286
- )
287
- );
288
- }
289
- function j(e) {
290
- const t = e.zeroForOne ? e.poolKey.currency0 : e.poolKey.currency1, n = e.zeroForOne ? e.poolKey.currency1 : e.poolKey.currency0, o = Ae(e.fee) ? e.fee : null, a = o ? we(o, n) : null, i = fe(
291
- [
292
- e.swapAction,
293
- w.SETTLE,
294
- ...a ? [a.action] : [],
295
- w.TAKE
296
- ],
297
- [
298
- e.encodedSwapParams,
299
- h(pe, [t, e.settleAmount, !0]),
300
- ...a ? [a.params] : [],
301
- h(V, [n, e.recipient, $])
302
- ]
303
- );
304
- return {
305
- calldata: be(ye([i], e.deadline), e.permit),
306
- value: 0n
307
- };
308
- }
309
- function yt(e) {
310
- return S(e.amountIn, "Swap input amount"), S(e.amountOutMinimum, "Swap minimum output"), j({
311
- swapAction: w.SWAP_EXACT_IN_SINGLE,
312
- encodedSwapParams: h(se, [
313
- {
314
- poolKey: e.poolKey,
315
- zeroForOne: e.zeroForOne,
316
- amountIn: e.amountIn,
317
- amountOutMinimum: e.amountOutMinimum,
318
- hookData: "0x"
319
- }
320
- ]),
321
- poolKey: e.poolKey,
322
- zeroForOne: e.zeroForOne,
323
- settleAmount: e.amountIn,
324
- recipient: e.recipient,
325
- deadline: e.deadline,
326
- permit: e.permit,
327
- fee: e.fee
328
- });
329
- }
330
- function Et(e) {
331
- return S(e.amountOut, "Swap output amount"), S(e.amountInMaximum, "Swap maximum input"), j({
332
- swapAction: w.SWAP_EXACT_OUT_SINGLE,
333
- encodedSwapParams: h(me, [
334
- {
335
- poolKey: e.poolKey,
336
- zeroForOne: e.zeroForOne,
337
- amountOut: e.amountOut,
338
- amountInMaximum: e.amountInMaximum,
339
- hookData: "0x"
340
- }
341
- ]),
342
- poolKey: e.poolKey,
343
- zeroForOne: e.zeroForOne,
344
- settleAmount: $,
345
- recipient: e.recipient,
346
- deadline: e.deadline,
347
- permit: e.permit,
348
- fee: e.fee
349
- });
350
- }
351
- function ht(e, t) {
352
- var n;
353
- return ((n = t.explorerTxUrl) == null ? void 0 : n.call(t, e)) ?? "#";
354
- }
355
- const f = 1, Q = u("0x00581261a1200956ea05d1810fF28ffd66D8E254"), Se = u("0x8f29BD5c8429730fA4C46e6295c4e679eDEdd0cC"), Ie = 8388608, _e = 50, Ce = u(
356
- "0x8ea2C7de60ef1Cd4dcE64ea2DDDe2f99F0127eFC"
357
- );
358
- function A(e) {
359
- return e ? u(e) : void 0;
360
- }
361
- function E(e) {
362
- if (!e.permit2 || !e.quoter)
363
- throw new Error("Missing Permit2 or V4 Quoter contract address.");
364
- return {
365
- permit2: u(e.permit2),
366
- quoter: u(e.quoter),
367
- poolManager: A(e.poolManager),
368
- positionDescriptor: A(e.positionDescriptor),
369
- positionManager: A(e.positionManager),
370
- stateView: A(e.stateView),
371
- universalRouter: A(e.universalRouter),
372
- universalRouterV2_1_1: A(e.universalRouterV2_1_1)
373
- };
374
- }
375
- const X = {
376
- 1: E({
377
- poolManager: "0x000000000004444c5dc75cB358380D2e3dE08A90",
378
- positionDescriptor: "0xd1428ba554f4c8450b763a0b2040a4935c63f06c",
379
- positionManager: "0xbd216513d74c8cf14cf4747e6aaa6420ff64ee9e",
380
- quoter: "0x52f0e24d1c21c8a0cb1e5a5dd6198556bd9e1203",
381
- stateView: "0x7ffe42c4a5deea5b0fec41c94c136cf115597227",
382
- universalRouter: "0x66a9893cc07d91d95644aedd05d03f95e1dba8af",
383
- universalRouterV2_1_1: "0x4c82d1fbfe28c977cbb58d8c7ff8fcf9f70a2cca",
384
- permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3"
385
- }),
386
- 10: E({
387
- poolManager: "0x9a13f98cb987694c9f086b1f5eb990eea8264ec3",
388
- positionDescriptor: "0xedd81496169c46df161b8513a52ffecaaaa66743",
389
- positionManager: "0x3c3ea4b57a46241e54610e5f022e5c45859a1017",
390
- quoter: "0x1f3131a13296fb91c90870043742c3cdbff1a8d7",
391
- stateView: "0xc18a3169788f4f75a170290584eca6395c75ecdb",
392
- universalRouter: "0x851116d9223fabed8e56c0e6b8ad0c31d98b3507",
393
- universalRouterV2_1_1: "0x8b844f885672f333bc0042cb669255f93a4c1e6b",
394
- permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3"
395
- }),
396
- 130: E({
397
- poolManager: "0x1f98400000000000000000000000000000000004",
398
- positionDescriptor: "0x9fb28449a191cd8c03a1b7abfb0f5996ecf7f722",
399
- positionManager: "0x4529a01c7a0410167c5740c487a8de60232617bf",
400
- quoter: "0x333e3c607b141b18ff6de9f258db6e77fe7491e0",
401
- stateView: "0x86e8631a016f9068c3f085faf484ee3f5fdee8f2",
402
- universalRouter: "0xef740bf23acae26f6492b10de645d6b98dc8eaf3",
403
- universalRouterV2_1_1: "0xfdf682f51fe81aa4898f0ae2163d8a55c127fbc7",
404
- permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3"
405
- }),
406
- 137: E({
407
- poolManager: "0x67366782805870060151383f4bbff9dab53e5cd6",
408
- positionDescriptor: "0x0892771f0c1b78ad6013d6e5536007e1c16e6794",
409
- positionManager: "0x1ec2ebf4f37e7363fdfe3551602425af0b3ceef9",
410
- quoter: "0xb3d5c3dfc3a7aebff71895a7191796bffc2c81b9",
411
- stateView: "0x5ea1bd7974c8a611cbab0bdcafcb1d9cc9b3ba5a",
412
- universalRouter: "0x1095692a6237d83c6a72f3f5efedb9a670c49223",
413
- universalRouterV2_1_1: "0x8b844f885672f333bc0042cb669255f93a4c1e6b",
414
- permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3"
415
- }),
416
- 8453: E({
417
- poolManager: "0x498581ff718922c3f8e6a244956af099b2652b2b",
418
- positionDescriptor: "0x25d093633990dc94bedeed76c8f3cdaa75f3e7d5",
419
- positionManager: "0x7c5f5a4bbd8fd63184577525326123b519429bdc",
420
- quoter: "0x0d5e0f971ed27fbff6c2837bf31316121532048d",
421
- stateView: "0xa3c0c9b65bad0b08107aa264b0f3db444b867a71",
422
- universalRouter: "0x6ff5693b99212da76ad316178a184ab56d299b43",
423
- universalRouterV2_1_1: "0xfdf682f51fe81aa4898f0ae2163d8a55c127fbc7",
424
- permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3"
425
- }),
426
- 42161: E({
427
- poolManager: "0x360e68faccca8ca495c1b759fd9eee466db9fb32",
428
- positionDescriptor: "0xe2023f3fa515cf070e07fd9d51c1d236e07843f4",
429
- positionManager: "0xd88f38f930b7952f2db2432cb002e7abbf3dd869",
430
- quoter: "0x3972c00f7ed4885e145823eb7c655375d275a1c5",
431
- stateView: "0x76fd297e2d437cd7f76d50f01afe6160f86e9990",
432
- universalRouter: "0xa51afafe0263b40edaef0df8781ea9aa03e381a3",
433
- universalRouterV2_1_1: "0x8b844f885672f333bc0042cb669255f93a4c1e6b",
434
- permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3"
435
- })
436
- }, U = X[f], H = U.permit2, Y = U.quoter, xe = [
437
- "https://eth.drpc.org",
438
- "https://ethereum-rpc.publicnode.com",
439
- "https://cloudflare-eth.com"
440
- ], Oe = "https://aegis.markets/graphql/meta", Te = {
441
- chainId: f,
442
- chain: ie,
443
- name: "Ethereum",
444
- router: Q,
445
- permit2: H,
446
- quoter: Y,
447
- v4Contracts: U,
448
- rpcUrls: xe,
449
- explorerTxUrl: (e) => `https://etherscan.io/tx/${e}`,
450
- poolExplorerUrl: (e) => `https://app.uniswap.org/explore/pools/ethereum/${e}`,
451
- metadataEndpoint: Oe,
452
- fee: {
453
- bps: _e,
454
- recipient: Ce
455
- }
456
- }, R = {
457
- [f]: Te
458
- }, l = {
459
- USDC: {
460
- chainId: f,
461
- address: u("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),
462
- name: "USD Coin",
463
- symbol: "USDC",
464
- decimals: 6
465
- },
466
- WATER: {
467
- chainId: f,
468
- address: u("0x828B22c9ea1c20B551EeFC6198174C4bb7a8CBF6"),
469
- name: "WATER",
470
- symbol: "WATER",
471
- decimals: 18
472
- },
473
- WOOD: {
474
- chainId: f,
475
- address: u("0x670AfdD7226e73d3CC55B5cd83933E46aF22DECd"),
476
- name: "WOOD",
477
- symbol: "WOOD",
478
- decimals: 18
479
- },
480
- GRASS: {
481
- chainId: f,
482
- address: u("0xF06Ad052b0d8D511D0B6f00100b8e402639209EF"),
483
- name: "GRASS",
484
- symbol: "GRASS",
485
- decimals: 18
486
- },
487
- STONE: {
488
- chainId: f,
489
- address: u("0xCabcc33D9Ff7e24F413d939773D232C0d50dCc7f"),
490
- name: "STONE",
491
- symbol: "STONE",
492
- decimals: 18,
493
- // STONE's ichi asset is logo_256_stone_2.svg, not the symbol-derived
494
- // logo_256_stone.svg that getIchiIconGuess('STONE') produces. Pin it so the
495
- // mark stays correct even when the metadata service is unreachable.
496
- iconUrl: "https://ichi-images.s3.us-east-1.amazonaws.com/tokens/logo_256_stone_2.svg"
497
- }
498
- };
499
- function x(e, t, n, o, a, i) {
500
- return {
501
- id: e,
502
- chainId: f,
503
- symbol: t,
504
- poolId: n,
505
- poolKey: {
506
- currency0: o,
507
- currency1: a,
508
- fee: Ie,
509
- tickSpacing: i,
510
- hooks: Se
511
- },
512
- token: l[t],
513
- counterToken: l.USDC,
514
- router: Q,
515
- permit2: H,
516
- quoter: Y,
517
- label: `${l.USDC.symbol} / ${t}`
518
- };
519
- }
520
- const Pe = x(
521
- "WATER_USDC",
522
- "WATER",
523
- "0x01409fc6f1bf49e20bf05df5d4dcb96ed3977ea717bc4a135e9deacd92ebc0af",
524
- l.WATER.address,
525
- l.USDC.address,
526
- 60
527
- ), De = x(
528
- "WOOD_USDC",
529
- "WOOD",
530
- "0x0f8a98e3fdb7ea4438a3f7342f040cbc9d1eced1b90a876d38f3453100243356",
531
- l.WOOD.address,
532
- l.USDC.address,
533
- 60
534
- ), Me = x(
535
- "GRASS_USDC",
536
- "GRASS",
537
- "0xd0194ad1f57730361b93ecf8da86e18590bd5e1f64e4a35f3a5b5bd666e48ae1",
538
- l.USDC.address,
539
- l.GRASS.address,
540
- 60
541
- ), ve = x(
542
- "STONE_USDC",
543
- "STONE",
544
- "0x3fa06e44e4bee9539887681eab6b608b646784e2027ea6292198cde0690aff54",
545
- l.USDC.address,
546
- l.STONE.address,
547
- 60
548
- ), At = {
549
- WATER_USDC: Pe,
550
- WOOD_USDC: De,
551
- GRASS_USDC: Me,
552
- STONE_USDC: ve
553
- }, wt = [
554
- "WATER_USDC",
555
- "WOOD_USDC",
556
- "GRASS_USDC",
557
- "STONE_USDC"
558
- ];
559
- function W(e) {
560
- return {
561
- ...e,
562
- address: u(e.address)
563
- };
564
- }
565
- function Ue(e) {
566
- const t = u(e.currency0), n = u(e.currency1);
567
- if (t.toLowerCase() >= n.toLowerCase())
568
- throw new Error(
569
- "Invalid pool key: currency0 must sort below currency1 (Uniswap v4 canonical ordering)."
570
- );
571
- return {
572
- currency0: t,
573
- currency1: n,
574
- fee: e.fee,
575
- tickSpacing: e.tickSpacing,
576
- hooks: u(e.hooks)
577
- };
578
- }
579
- function Re(e, t) {
580
- var o, a;
581
- const n = X[e.chainId];
582
- return {
583
- ...n,
584
- ...t == null ? void 0 : t.v4Contracts,
585
- ...e.v4Contracts,
586
- permit2: ((o = e.v4Contracts) == null ? void 0 : o.permit2) ?? e.permit2 ?? (t == null ? void 0 : t.permit2) ?? (n == null ? void 0 : n.permit2),
587
- quoter: ((a = e.v4Contracts) == null ? void 0 : a.quoter) ?? e.quoter ?? (t == null ? void 0 : t.quoter) ?? (n == null ? void 0 : n.quoter)
588
- };
589
- }
590
- function ke(e, t) {
591
- var a;
592
- const n = Re(e, t);
593
- if (!t && (!e.chain || !e.router || !((a = e.rpcUrls) != null && a.length)))
594
- throw new Error(
595
- `Missing viem chain, Aegis router, or RPC URLs for chain ${e.chainId}.`
596
- );
597
- const o = E(n);
598
- return {
599
- chainId: e.chainId,
600
- chain: e.chain ?? t.chain,
601
- name: e.name ?? (t == null ? void 0 : t.name) ?? `Chain ${e.chainId}`,
602
- router: u(e.router ?? t.router),
603
- permit2: o.permit2,
604
- quoter: o.quoter,
605
- v4Contracts: o,
606
- rpcUrls: e.rpcUrls ?? t.rpcUrls,
607
- explorerTxUrl: e.explorerTxUrl ?? (t == null ? void 0 : t.explorerTxUrl),
608
- poolExplorerUrl: e.poolExplorerUrl ?? (t == null ? void 0 : t.poolExplorerUrl),
609
- metadataEndpoint: e.metadataEndpoint ?? (t == null ? void 0 : t.metadataEndpoint),
610
- // Fee stays internal: it is never read from host input, only inherited from
611
- // the bundled base chain config (e.g. mainnet keeps its 50 bps fee).
612
- fee: t == null ? void 0 : t.fee
613
- };
614
- }
615
- function bt(e) {
616
- const t = { ...R };
617
- if (!e) return t;
618
- for (const [n, o] of Object.entries(e)) {
619
- if (!o) continue;
620
- const a = o.chainId ?? Number(n);
621
- t[a] = ke(
622
- { ...o, chainId: a },
623
- t[a]
624
- );
625
- }
626
- return t;
627
- }
628
- function ge(e, t = R) {
629
- const n = W(e.token), o = W(e.counterToken), a = e.chainId ?? n.chainId ?? o.chainId ?? f, i = t[a];
630
- if (!i) throw new Error(`No Aegis swap chain config found for chain ${a}.`);
631
- if (n.chainId !== a || o.chainId !== a)
632
- throw new Error(`Pool token chain ids must match chain ${a}.`);
633
- const c = Ue(e.poolKey), r = z(c);
634
- if (e.poolId && !K(e.poolId, r))
635
- throw new Error("Configured pool id does not match the pool key.");
636
- return {
637
- id: e.id,
638
- chainId: a,
639
- symbol: e.symbol ?? n.symbol,
640
- poolId: e.poolId ?? r,
641
- poolKey: c,
642
- token: n,
643
- counterToken: o,
644
- router: u(e.router ?? i.router),
645
- permit2: u(e.permit2 ?? i.permit2),
646
- quoter: u(e.quoter ?? i.quoter),
647
- label: e.label ?? `${o.symbol} / ${n.symbol}`
648
- };
649
- }
650
- function St(e, t = R) {
651
- return e != null && e.length ? Object.fromEntries(
652
- e.map((n) => {
653
- const o = ge(n, t);
654
- return [o.id, o];
655
- })
656
- ) : {};
657
- }
658
- function J(e) {
659
- if (!Number.isFinite(e) || e < 0 || e > 2e3)
660
- throw new Error("Slippage must be between 0% and 20%.");
661
- }
662
- function Ne(e, t) {
663
- return J(t), e * BigInt(1e4 - Math.round(t)) / 10000n;
664
- }
665
- function Fe(e, t) {
666
- return J(t), (e * BigInt(1e4 + Math.round(t)) + 9999n) / 10000n;
667
- }
668
- function Be(e, t) {
669
- return t <= 0 ? 0n : e * BigInt(t) / 10000n;
670
- }
671
- function We(e, t) {
672
- return t <= 0 ? e : (e * 10000n + BigInt(1e4 - t - 1)) / BigInt(1e4 - t);
673
- }
674
- function qe(e, t) {
675
- if (t <= 0) return e;
676
- const n = BigInt(1e4 - t);
677
- return (e * 10000n + n - 1n) / n;
678
- }
679
- function I(e) {
680
- return S(e), e;
681
- }
682
- function Ke(e, t) {
683
- if (d(t.address, e.currency0)) return !0;
684
- if (d(t.address, e.currency1)) return !1;
685
- throw new Error("Input token is not part of this pool.");
686
- }
687
- function Le(e, t, n) {
688
- const o = z(e.poolKey);
689
- if (!K(o, e.poolId))
690
- throw new Error("Configured pool id does not match the pool key.");
691
- const a = d(t.address, e.poolKey.currency0) || d(t.address, e.poolKey.currency1), i = d(n.address, e.poolKey.currency0) || d(n.address, e.poolKey.currency1);
692
- if (!a || !i || d(t.address, n.address))
693
- throw new Error("Selected tokens do not match this direct pool.");
694
- }
695
- function $e(e, t) {
696
- if (Array.isArray(e)) {
697
- const a = e[0], i = e[1];
698
- if (typeof a == "bigint" && typeof i == "bigint")
699
- return { amount: a, gasEstimate: i };
700
- throw new Error("Unexpected V4 Quoter response.");
701
- }
702
- const n = e, o = n[t];
703
- if (typeof o == "bigint" && typeof n.gasEstimate == "bigint")
704
- return { amount: o, gasEstimate: n.gasEstimate };
705
- throw new Error("Unexpected V4 Quoter response.");
706
- }
707
- async function It(e) {
708
- var b, g, N, F;
709
- if ((b = e.signal) != null && b.aborted) throw new DOMException("Quote request aborted", "AbortError");
710
- if (e.amount <= 0n) throw new Error("Enter an amount to swap.");
711
- I(e.amount), Le(e.market, e.tokenIn, e.tokenOut);
712
- const t = e.market.poolKey, n = Ke(t, e.tokenIn), o = ((g = e.fee) == null ? void 0 : g.bps) ?? 0;
713
- if (!Number.isInteger(o) || o < 0 || o >= 1e4)
714
- throw new Error("Fee must be an integer between 0 and 9999 bps.");
715
- const a = e.mode === "exactOut" ? I(We(e.amount, o)) : e.amount, i = e.mode === "exactOut" ? await e.publicClient.simulateContract({
716
- address: e.market.quoter,
717
- abi: B,
718
- functionName: "quoteExactOutputSingle",
719
- args: [{ poolKey: t, zeroForOne: n, exactAmount: a, hookData: "0x" }],
720
- account: e.account
721
- }) : await e.publicClient.simulateContract({
722
- address: e.market.quoter,
723
- abi: B,
724
- functionName: "quoteExactInputSingle",
725
- args: [{ poolKey: t, zeroForOne: n, exactAmount: e.amount, hookData: "0x" }],
726
- account: e.account
727
- });
728
- if ((N = e.signal) != null && N.aborted) throw new DOMException("Quote request aborted", "AbortError");
729
- const c = $e(
730
- i.result,
731
- e.mode === "exactOut" ? "amountIn" : "amountOut"
732
- ), r = e.mode === "exactOut" ? c.amount : e.amount, s = e.mode === "exactOut" ? a : c.amount, m = e.mode === "exactOut" ? s - e.amount : Be(s, o), p = s - m, y = e.mode === "exactOut" ? p : Ne(p, e.slippageBps);
733
- return {
734
- mode: e.mode,
735
- poolKey: t,
736
- zeroForOne: n,
737
- amountIn: r,
738
- amountOut: p,
739
- grossAmountOut: s,
740
- amountOutMinimum: e.mode === "exactOut" ? s : I(qe(y, o)),
741
- amountInMaximum: e.mode === "exactOut" ? I(Fe(r, e.slippageBps)) : r,
742
- userAmountOutMinimum: y,
743
- feeAmount: m,
744
- feeBps: o,
745
- feeRecipient: o > 0 ? ((F = e.fee) == null ? void 0 : F.recipient) ?? null : null,
746
- gasEstimate: c.gasEstimate
747
- };
748
- }
749
- function Z(e, t) {
750
- return e.mode === t.mode && e.zeroForOne === t.zeroForOne && d(e.poolKey.currency0, t.poolKey.currency0) && d(e.poolKey.currency1, t.poolKey.currency1) && e.poolKey.fee === t.poolKey.fee && e.poolKey.tickSpacing === t.poolKey.tickSpacing && d(e.poolKey.hooks, t.poolKey.hooks) && e.feeBps === t.feeBps && ce(e.feeRecipient, t.feeRecipient);
751
- }
752
- function _t(e, t) {
753
- return Z(e, t) && e.amountIn === t.amountIn && e.amountOut === t.amountOut && e.grossAmountOut === t.grossAmountOut && e.amountOutMinimum === t.amountOutMinimum && e.amountInMaximum === t.amountInMaximum && e.userAmountOutMinimum === t.userAmountOutMinimum && e.feeAmount === t.feeAmount;
754
- }
755
- function Ct(e, t) {
756
- return !e || !Z(e, t) ? { quote: t, priceMovedBeyondTolerance: !1 } : t.mode === "exactIn" ? t.amountOut < e.userAmountOutMinimum ? { quote: t, priceMovedBeyondTolerance: !0 } : {
757
- quote: {
758
- ...t,
759
- amountOutMinimum: t.amountOutMinimum > e.amountOutMinimum ? t.amountOutMinimum : e.amountOutMinimum,
760
- userAmountOutMinimum: t.userAmountOutMinimum > e.userAmountOutMinimum ? t.userAmountOutMinimum : e.userAmountOutMinimum
761
- },
762
- priceMovedBeyondTolerance: !1
763
- } : t.amountIn > e.amountInMaximum ? { quote: t, priceMovedBeyondTolerance: !0 } : {
764
- quote: {
765
- ...t,
766
- amountInMaximum: t.amountInMaximum < e.amountInMaximum ? t.amountInMaximum : e.amountInMaximum
767
- },
768
- priceMovedBeyondTolerance: !1
769
- };
770
- }
771
- function xt(e) {
772
- return e.mode === "exactOut" ? e.amountInMaximum : e.amountIn;
773
- }
774
- function Ot(e) {
775
- return e.feeRecipient ? e.mode === "exactIn" ? e.feeBps > 0 ? { recipient: e.feeRecipient, bips: e.feeBps } : null : e.feeAmount > 0n ? { recipient: e.feeRecipient, amount: e.feeAmount } : null : null;
776
- }
777
- const C = 2n ** 160n - 1n, Ge = 2n ** 256n - 1n, Ve = 600, ze = 1800, je = 1800, Qe = Ve, Xe = 2 ** 48 - 1, He = {
778
- PermitBatch: [
779
- { name: "details", type: "PermitDetails[]" },
780
- { name: "spender", type: "address" },
781
- { name: "sigDeadline", type: "uint256" }
782
- ],
783
- PermitDetails: [
784
- { name: "token", type: "address" },
785
- { name: "amount", type: "uint160" },
786
- { name: "expiration", type: "uint48" },
787
- { name: "nonce", type: "uint48" }
788
- ]
789
- };
790
- async function Tt(e) {
791
- const t = e.amount ?? Ge, n = D({
792
- account: e.account,
793
- chain: e.chain,
794
- transport: M(e.provider)
795
- }), { request: o } = await e.publicClient.simulateContract({
796
- address: e.token,
797
- abi: te,
798
- functionName: "approve",
799
- args: [e.permit2, t],
800
- account: e.account
801
- }), a = await n.writeContract({
802
- ...o,
803
- chain: e.chain
804
- });
805
- if ((await e.publicClient.waitForTransactionReceipt({ hash: a })).status === "reverted") throw new Error("Token approval reverted.");
806
- return a;
807
- }
808
- async function Pt(e) {
809
- const t = e.amount && e.amount < C ? e.amount : C, n = e.expiration ?? Xe, o = D({
810
- account: e.account,
811
- chain: e.chain,
812
- transport: M(e.provider)
813
- }), { request: a } = await e.publicClient.simulateContract({
814
- address: e.permit2,
815
- abi: L,
816
- functionName: "approve",
817
- args: [e.token, e.router, t, n],
818
- account: e.account
819
- }), i = await o.writeContract({
820
- ...a,
821
- chain: e.chain
822
- });
823
- if ((await e.publicClient.waitForTransactionReceipt({ hash: i })).status === "reverted") throw new Error("Permit2 approval reverted.");
824
- return i;
825
- }
826
- function Ye(e) {
827
- return e.publicClient.readContract({
828
- address: e.permit2,
829
- abi: L,
830
- functionName: "allowance",
831
- args: [e.account, e.token, e.router]
832
- });
833
- }
834
- async function Dt(e) {
835
- const [t, n, o] = await (e.allowanceRead ?? Ye(e)), a = Math.floor(Date.now() / 1e3);
836
- if (t >= e.amount && Number(n) > a + Qe)
837
- return null;
838
- const i = {
839
- details: [
840
- {
841
- token: e.token,
842
- amount: e.sizing === "max" || e.amount > C ? C : e.amount,
843
- expiration: a + je,
844
- nonce: Number(o)
845
- }
846
- ],
847
- spender: e.router,
848
- sigDeadline: BigInt(a + ze)
849
- }, r = await D({
850
- account: e.account,
851
- chain: e.chain,
852
- transport: M(e.provider)
853
- }).signTypedData({
854
- account: e.account,
855
- domain: {
856
- name: "Permit2",
857
- chainId: e.chainId,
858
- verifyingContract: e.permit2
859
- },
860
- types: He,
861
- primaryType: "PermitBatch",
862
- message: i
863
- });
864
- return {
865
- owner: e.account,
866
- permitBatch: i,
867
- signature: r
868
- };
869
- }
870
- const Je = "https://ichi-images.s3.us-east-1.amazonaws.com/tokens", O = /* @__PURE__ */ new Map();
871
- function q(e, t, n) {
872
- return `${e}|evm_${t}_${n.toLowerCase()}`;
873
- }
874
- function Ze(e, t) {
875
- return `evm_${e}_${t.toLowerCase()}`;
876
- }
877
- function et(e) {
878
- const t = e == null ? void 0 : e.trim();
879
- if (!t) return null;
880
- const n = t.split("-"), a = (n.length > 1 ? n[n.length - 1] : t).trim().toLowerCase();
881
- return !a || !/^[a-z0-9]+$/.test(a) ? null : a;
882
- }
883
- function tt(e) {
884
- const t = et(e);
885
- return t ? `${Je}/logo_256_${t}.svg` : null;
886
- }
887
- function Mt(e, t) {
888
- var n, o;
889
- return ((n = e.iconUrl) != null && n.trim() ? e.iconUrl : null) ?? ((o = t[T(e.address)]) == null ? void 0 : o.iconURL) ?? tt(e.symbol);
890
- }
891
- function nt(e, t) {
892
- return `query AegisSwapWidgetTokenMetadata { ${t.map((o, a) => `t${a}: getGlobalToken(id: ${JSON.stringify(Ze(e, o))}) { chainId address symbol displayName fullName decimals iconURL }`).join(" ")} }`;
893
- }
894
- async function vt(e) {
895
- var r, s;
896
- const t = e.endpoint.trim(), n = [
897
- ...new Map(
898
- e.addresses.map((m) => {
899
- const p = u(m);
900
- return [p.toLowerCase(), p];
901
- })
902
- ).values()
903
- ], o = /* @__PURE__ */ new Map(), a = n.filter((m) => {
904
- const p = q(t, e.chainId, m);
905
- if (!O.has(p)) return !0;
906
- const y = O.get(p);
907
- return y && o.set(T(m), y), !1;
908
- });
909
- if (!a.length || typeof fetch != "function") return o;
910
- const i = await fetch(t, {
911
- method: "POST",
912
- headers: { "Content-Type": "application/json" },
913
- body: JSON.stringify({
914
- query: nt(e.chainId, a)
915
- }),
916
- signal: e.signal
917
- });
918
- if (!i.ok)
919
- throw new Error(`Token metadata request failed with HTTP ${i.status}.`);
920
- const c = await i.json();
921
- if ((r = c.errors) != null && r.length)
922
- throw new Error(((s = c.errors[0]) == null ? void 0 : s.message) ?? "Token metadata request failed.");
923
- return a.forEach((m, p) => {
924
- var b;
925
- const y = ((b = c.data) == null ? void 0 : b[`t${p}`]) ?? null;
926
- O.set(q(t, e.chainId, m), y), y && o.set(T(m), y);
927
- }), o;
928
- }
929
- function Ut() {
930
- return typeof window > "u" ? null : window.ethereum ?? null;
931
- }
932
- function k(e) {
933
- return typeof e != "string" || !re(e) ? null : u(e);
934
- }
935
- function ot(e) {
936
- return !!(e && typeof e == "object" && typeof e.request == "function");
937
- }
938
- function Rt(e) {
939
- return ot(e) ? { provider: e, account: null } : !e || typeof e != "object" ? { provider: null, account: null } : {
940
- provider: e.provider ?? null,
941
- account: k(e.account)
942
- };
943
- }
944
- async function kt(e) {
945
- const t = await e.request({ method: "eth_accounts" });
946
- return k(t == null ? void 0 : t[0]);
947
- }
948
- async function gt(e) {
949
- const t = await e.request({ method: "eth_requestAccounts" });
950
- return k(t == null ? void 0 : t[0]);
951
- }
952
- async function Nt(e) {
953
- const t = await e.request({ method: "eth_chainId" });
954
- if (typeof t != "string" || !/^0x[0-9a-f]+$/i.test(t)) return null;
955
- const n = Number.parseInt(t, 16);
956
- return Number.isSafeInteger(n) ? n : null;
957
- }
958
- function at(e) {
959
- return `0x${e.toString(16)}`;
960
- }
961
- function rt(e) {
962
- const t = e, n = [t.message, t.shortMessage, t.details].filter((o) => typeof o == "string").join(" ").toLowerCase();
963
- return t.code === 4902 || n.includes("unrecognized chain") || n.includes("unknown chain") || n.includes("chain has not been added") || n.includes("not added to wallet");
964
- }
965
- function it(e) {
966
- return typeof e == "number" ? { chainId: e } : e;
967
- }
968
- function ct(e) {
969
- var t, n;
970
- return (t = e.rpcUrls) != null && t.length ? e.rpcUrls : ((n = e.chain) == null ? void 0 : n.rpcUrls.default.http) ?? [];
971
- }
972
- function ut(e) {
973
- var n, o;
974
- const t = (o = (n = e.chain) == null ? void 0 : n.blockExplorers) == null ? void 0 : o.default.url;
975
- return t ? [t] : [];
976
- }
977
- async function Ft(e, t) {
978
- var i, c;
979
- const n = it(t), o = at(n.chainId), a = {
980
- method: "wallet_switchEthereumChain",
981
- params: [{ chainId: o }]
982
- };
983
- try {
984
- await e.request(a);
985
- return;
986
- } catch (r) {
987
- if (!rt(r)) throw r;
988
- const s = ct(n);
989
- if (s.length === 0) throw r;
990
- const m = ut(n);
991
- await e.request({
992
- method: "wallet_addEthereumChain",
993
- params: [
994
- {
995
- chainId: o,
996
- chainName: n.name ?? ((i = n.chain) == null ? void 0 : i.name) ?? `Chain ${n.chainId}`,
997
- nativeCurrency: ((c = n.chain) == null ? void 0 : c.nativeCurrency) ?? {
998
- name: "Ether",
999
- symbol: "ETH",
1000
- decimals: 18
1001
- },
1002
- rpcUrls: s,
1003
- ...m.length ? { blockExplorerUrls: m } : {}
1004
- }
1005
- ]
1006
- });
1007
- }
1008
- await e.request({
1009
- method: "wallet_switchEthereumChain",
1010
- params: [{ chainId: o }]
1011
- });
1012
- }
1013
- function Bt(e, t) {
1014
- const n = t.map(
1015
- (o) => ne(o, {
1016
- batch: !0,
1017
- retryCount: 2,
1018
- retryDelay: 150,
1019
- timeout: 1e4
1020
- })
1021
- );
1022
- return oe({
1023
- chain: e,
1024
- transport: n.length === 1 ? n[0] : ae(n)
1025
- });
1026
- }
1027
- function Wt(e, t) {
1028
- const n = e;
1029
- if (!n.on || !n.removeListener) return () => {
1030
- };
1031
- const o = () => {
1032
- var i;
1033
- return (i = t.onAccountsChanged) == null ? void 0 : i.call(t);
1034
- }, a = () => {
1035
- var i;
1036
- return (i = t.onChainChanged) == null ? void 0 : i.call(t);
1037
- };
1038
- return n.on("accountsChanged", o), n.on("chainChanged", a), () => {
1039
- var i, c;
1040
- (i = n.removeListener) == null || i.call(n, "accountsChanged", o), (c = n.removeListener) == null || c.call(n, "chainChanged", a);
1041
- };
1042
- }
1043
- function st(e) {
1044
- for (let n = e; n && typeof n == "object"; n = n.cause)
1045
- if (n.code === 4001) return !0;
1046
- const t = e instanceof Error ? e.message.toLowerCase() : "";
1047
- return t.includes("user rejected") || t.includes("user denied") || t.includes("rejected the request") || t.includes("request rejected");
1048
- }
1049
- const mt = "Request rejected.";
1050
- function qt(e, t) {
1051
- if (st(e))
1052
- return mt;
1053
- const n = e instanceof Error ? e.message : "";
1054
- if (!n) return t;
1055
- const o = n.toLowerCase();
1056
- return o.includes("wallet_switchethereumchain") || o.includes("wallet_addethereumchain") ? "Network switch failed." : o.includes("insufficient funds") ? "Insufficient funds for gas." : o.includes("execution reverted") || o.includes("swap reverted") ? "Swap reverted on-chain." : t;
1057
- }
1058
- function Kt(e) {
1059
- return e === "approving" || e === "signing" || e === "submitting";
1060
- }
1061
- const pt = {
1062
- total: 0,
1063
- completed: 0,
1064
- active: null
1065
- };
1066
- function _({ total: e, completed: t }) {
1067
- return e <= 0 ? 0 : t / e * 100;
1068
- }
1069
- function dt({
1070
- status: e,
1071
- txHash: t,
1072
- approvalRequired: n,
1073
- approvalDone: o,
1074
- authorizationRequired: a
1075
- }) {
1076
- const i = n || o, c = a, r = e === "idle" && !o ? 0 : 1 + (i ? 1 : 0) + (c ? 1 : 0);
1077
- if (r === 0) return pt;
1078
- if (e === "success") return { total: r, completed: r, active: null };
1079
- if (e === "idle")
1080
- return {
1081
- total: r,
1082
- completed: o && i ? 1 : 0,
1083
- active: null
1084
- };
1085
- if (e === "approving") {
1086
- if (o && c) {
1087
- const p = i ? 1 : 0;
1088
- return { total: r, completed: p, active: p + 1 };
1089
- }
1090
- return {
1091
- total: r,
1092
- completed: 0,
1093
- active: i || c ? 1 : null
1094
- };
1095
- }
1096
- const s = i ? 1 : 0;
1097
- if (e === "signing")
1098
- return {
1099
- total: r,
1100
- completed: s,
1101
- active: c ? s + 1 : null
1102
- };
1103
- const m = r - 1;
1104
- return {
1105
- total: r,
1106
- completed: t ? r : m,
1107
- active: t ? null : r
1108
- };
1109
- }
1110
- function Lt({
1111
- status: e,
1112
- inputSymbol: t,
1113
- txHash: n,
1114
- actionError: o,
1115
- approvalRequired: a,
1116
- approvalDone: i,
1117
- authorizationRequired: c
1118
- }) {
1119
- const r = dt({
1120
- status: e,
1121
- txHash: n,
1122
- approvalRequired: a,
1123
- approvalDone: i,
1124
- authorizationRequired: c
1125
- });
1126
- return o ? {
1127
- state: "error",
1128
- label: o,
1129
- walletPrompts: r,
1130
- completePct: 100,
1131
- activeWidthPct: 0
1132
- } : e === "success" ? {
1133
- state: "success",
1134
- label: "Swap confirmed",
1135
- walletPrompts: r,
1136
- completePct: 100,
1137
- activeWidthPct: 0
1138
- } : e === "idle" ? i ? {
1139
- state: "pending",
1140
- label: `ERC20 approval complete · ready to swap · ${r.completed} of ${r.total} prompts done`,
1141
- walletPrompts: r,
1142
- completePct: _(r),
1143
- activeWidthPct: 0
1144
- } : null : e === "approving" ? {
1145
- state: "pending",
1146
- label: i && c ? `Approving Permit2 router · wallet prompt ${r.active ?? 1} of ${r.total}` : `Approving ${t} for Permit2 · wallet prompt ${r.active ?? 1} of ${r.total}`,
1147
- walletPrompts: r,
1148
- completePct: _(r),
1149
- activeWidthPct: 100
1150
- } : a || i ? {
1151
- state: e === "submitting" && n ? "mining" : "pending",
1152
- label: e === "signing" ? `ERC20 approval complete · sign Permit2 permit · wallet prompt ${r.active ?? 2} of ${r.total}` : n ? `Confirming swap · ${r.completed} of ${r.total} wallet prompts complete` : `Approve complete · submitting swap · wallet prompt ${r.active ?? r.total} of ${r.total}`,
1153
- walletPrompts: r,
1154
- completePct: _(r),
1155
- activeWidthPct: 100
1156
- } : {
1157
- state: e === "submitting" && n ? "mining" : "pending",
1158
- label: e === "signing" ? c ? `Signing Permit2 spending permit · wallet prompt ${r.active ?? 1} of ${r.total}` : "Preparing swap" : n ? `Confirming swap on-chain · ${r.completed} of ${r.total} wallet prompts complete` : `Submitting swap · wallet prompt ${r.active ?? r.total} of ${r.total}`,
1159
- walletPrompts: r,
1160
- completePct: _(r),
1161
- activeWidthPct: 100
1162
- };
1163
- }
1164
- function $t() {
1165
- return typeof document > "u" ? !0 : document.visibilityState !== "hidden";
1166
- }
1167
- async function Gt(e, t, n, o) {
1168
- let a;
1169
- for (let i = 0; i < t; i += 1) {
1170
- i > 0 && await new Promise((c) => setTimeout(c, n));
1171
- try {
1172
- return await e();
1173
- } catch (c) {
1174
- if (a = c, o != null && o()) break;
1175
- }
1176
- }
1177
- throw a ?? new Error("retryOnError was called with attempts < 1.");
1178
- }
1179
- async function Vt(e, t, n, o) {
1180
- let a = await e();
1181
- for (let i = 1; i < n && !t(a); i += 1)
1182
- await new Promise((c) => setTimeout(c, o)), a = await e();
1183
- return a;
1184
- }
1185
- export {
1186
- xt as $,
1187
- Ie as A,
1188
- St as B,
1189
- ge as C,
1190
- je as D,
1191
- E,
1192
- Bt as F,
1193
- qt as G,
1194
- It as H,
1195
- vt as I,
1196
- ht as J,
1197
- tt as K,
1198
- Ut as L,
1199
- ue as M,
1200
- kt as N,
1201
- Nt as O,
1202
- Xe as P,
1203
- Ke as Q,
1204
- Kt as R,
1205
- Ve as S,
1206
- $t as T,
1207
- X as U,
1208
- ot as V,
1209
- st as W,
1210
- k as X,
1211
- Rt as Y,
1212
- Ot as Z,
1213
- Vt as _,
1214
- R as a,
1215
- Ye as a0,
1216
- Ct as a1,
1217
- gt as a2,
1218
- Mt as a3,
1219
- Gt as a4,
1220
- _t as a5,
1221
- Wt as a6,
1222
- Ft as a7,
1223
- Lt as a8,
1224
- mt as a9,
1225
- T as aa,
1226
- d as ab,
1227
- f as b,
1228
- _e as c,
1229
- Ce as d,
1230
- Oe as e,
1231
- wt as f,
1232
- xe as g,
1233
- Se as h,
1234
- Te as i,
1235
- U as j,
1236
- At as k,
1237
- H as l,
1238
- Q as m,
1239
- l as n,
1240
- Y as o,
1241
- C as p,
1242
- Ge as q,
1243
- Tt as r,
1244
- Pt as s,
1245
- S as t,
1246
- yt as u,
1247
- Et as v,
1248
- Dt as w,
1249
- z as x,
1250
- ke as y,
1251
- bt as z
1252
- };