aegis-swap-widget 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +82 -0
- package/LICENSE +21 -0
- package/README.md +101 -24
- package/dist/abis.d.ts +18 -1
- package/dist/address.d.ts +5 -0
- package/dist/aegis-swap-widget.js +2423 -1014
- package/dist/color.d.ts +2 -0
- package/dist/components/icons.d.ts +23 -0
- package/dist/config.d.ts +3 -2
- package/dist/encoding.d.ts +5 -1
- package/dist/errors.d.ts +2 -0
- package/dist/format.d.ts +3 -3
- package/dist/hooks/useResolvedTheme.d.ts +3 -0
- package/dist/hooks/useScrollAnchor.d.ts +12 -0
- package/dist/hooks/useStableValue.d.ts +2 -0
- package/dist/hooks/useSubmitSwap.d.ts +66 -0
- package/dist/hooks/useSwapQuote.d.ts +30 -0
- package/dist/hooks/useTokenAllowance.d.ts +24 -0
- package/dist/hooks/useTokenBalances.d.ts +15 -0
- package/dist/hooks/useTokenIconMetadata.d.ts +7 -0
- package/dist/hooks/useWalletConnection.d.ts +18 -0
- package/dist/index.d.ts +6 -42
- package/dist/metadata.d.ts +0 -1
- package/dist/permit.d.ts +24 -1
- package/dist/polling.d.ts +2 -0
- package/dist/quote.d.ts +30 -2
- package/dist/styles.css +1 -1
- package/dist/transactionProgress.d.ts +18 -0
- package/dist/wallet.d.ts +19 -8
- package/dist/widget/AegisDirectSwapWidget.d.ts +4 -0
- package/dist/widget/AmountField.d.ts +17 -0
- package/dist/widget/ExecutionDetails.d.ts +29 -0
- package/dist/widget/NetworkSelector.d.ts +3 -0
- package/dist/widget/PoolSelector.d.ts +13 -0
- package/dist/widget/types.d.ts +66 -0
- package/dist/widget/viewState.d.ts +54 -0
- package/package.json +40 -8
- package/dist/abis.d.ts.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/encoding.d.ts.map +0 -1
- package/dist/format.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/metadata.d.ts.map +0 -1
- package/dist/permit.d.ts.map +0 -1
- package/dist/quote.d.ts.map +0 -1
- package/dist/wallet.d.ts.map +0 -1
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import {
|
|
3
|
-
import { keccak256 as
|
|
4
|
-
import { mainnet as
|
|
5
|
-
|
|
1
|
+
import { jsxs as h, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { memo as En, useState as A, useEffect as Y, useRef as te, useLayoutEffect as Po, useCallback as P, useMemo as H, useId as ke } from "react";
|
|
3
|
+
import { keccak256 as Do, encodeAbiParameters as be, encodeFunctionData as Ct, getAddress as F, parseUnits as Ro, formatUnits as Nt, createWalletClient as at, custom as rt, erc20Abi as Tt, http as Bo, createPublicClient as Uo, fallback as ko, isAddress as Fo, WaitForTransactionReceiptTimeoutError as an } from "viem";
|
|
4
|
+
import { mainnet as Lo } from "viem/chains";
|
|
5
|
+
function de(e) {
|
|
6
|
+
return (e == null ? void 0 : e.toLowerCase()) ?? "";
|
|
7
|
+
}
|
|
8
|
+
function G(e, t) {
|
|
9
|
+
return e.toLowerCase() === t.toLowerCase();
|
|
10
|
+
}
|
|
11
|
+
function qo(e, t) {
|
|
12
|
+
return e === null || t === null ? e === t : G(e, t);
|
|
13
|
+
}
|
|
14
|
+
function Sn(e, t) {
|
|
15
|
+
return e.toLowerCase() === t.toLowerCase();
|
|
16
|
+
}
|
|
17
|
+
const Ot = [
|
|
6
18
|
{
|
|
7
19
|
type: "function",
|
|
8
20
|
name: "execute",
|
|
@@ -56,7 +68,19 @@ const et = [
|
|
|
56
68
|
],
|
|
57
69
|
outputs: []
|
|
58
70
|
}
|
|
59
|
-
],
|
|
71
|
+
], xn = [
|
|
72
|
+
{
|
|
73
|
+
type: "function",
|
|
74
|
+
name: "approve",
|
|
75
|
+
stateMutability: "nonpayable",
|
|
76
|
+
inputs: [
|
|
77
|
+
{ name: "token", type: "address" },
|
|
78
|
+
{ name: "spender", type: "address" },
|
|
79
|
+
{ name: "amount", type: "uint160" },
|
|
80
|
+
{ name: "expiration", type: "uint48" }
|
|
81
|
+
],
|
|
82
|
+
outputs: []
|
|
83
|
+
},
|
|
60
84
|
{
|
|
61
85
|
type: "function",
|
|
62
86
|
name: "allowance",
|
|
@@ -72,7 +96,7 @@ const et = [
|
|
|
72
96
|
{ name: "nonce", type: "uint48" }
|
|
73
97
|
]
|
|
74
98
|
}
|
|
75
|
-
],
|
|
99
|
+
], rn = [
|
|
76
100
|
{
|
|
77
101
|
type: "function",
|
|
78
102
|
name: "quoteExactInputSingle",
|
|
@@ -135,12 +159,13 @@ const et = [
|
|
|
135
159
|
{ name: "gasEstimate", type: "uint256" }
|
|
136
160
|
]
|
|
137
161
|
}
|
|
138
|
-
],
|
|
162
|
+
], Cn = 0n, Wo = 2n ** 128n - 1n, Se = {
|
|
139
163
|
SWAP_EXACT_IN_SINGLE: 6,
|
|
140
164
|
SWAP_EXACT_OUT_SINGLE: 8,
|
|
141
165
|
SETTLE: 11,
|
|
142
|
-
TAKE: 14
|
|
143
|
-
|
|
166
|
+
TAKE: 14,
|
|
167
|
+
TAKE_PORTION: 16
|
|
168
|
+
}, Nn = {
|
|
144
169
|
name: "poolKey",
|
|
145
170
|
type: "tuple",
|
|
146
171
|
components: [
|
|
@@ -150,79 +175,102 @@ const et = [
|
|
|
150
175
|
{ name: "tickSpacing", type: "int24" },
|
|
151
176
|
{ name: "hooks", type: "address" }
|
|
152
177
|
]
|
|
153
|
-
},
|
|
178
|
+
}, $o = [
|
|
154
179
|
{
|
|
155
180
|
name: "params",
|
|
156
181
|
type: "tuple",
|
|
157
182
|
components: [
|
|
158
|
-
|
|
183
|
+
Nn,
|
|
159
184
|
{ name: "zeroForOne", type: "bool" },
|
|
160
185
|
{ name: "amountIn", type: "uint128" },
|
|
161
186
|
{ name: "amountOutMinimum", type: "uint128" },
|
|
162
187
|
{ name: "hookData", type: "bytes" }
|
|
163
188
|
]
|
|
164
189
|
}
|
|
165
|
-
],
|
|
190
|
+
], Ko = [
|
|
166
191
|
{
|
|
167
192
|
name: "params",
|
|
168
193
|
type: "tuple",
|
|
169
194
|
components: [
|
|
170
|
-
|
|
195
|
+
Nn,
|
|
171
196
|
{ name: "zeroForOne", type: "bool" },
|
|
172
197
|
{ name: "amountOut", type: "uint128" },
|
|
173
198
|
{ name: "amountInMaximum", type: "uint128" },
|
|
174
199
|
{ name: "hookData", type: "bytes" }
|
|
175
200
|
]
|
|
176
201
|
}
|
|
177
|
-
],
|
|
202
|
+
], zo = [
|
|
178
203
|
{ name: "currency", type: "address" },
|
|
179
204
|
{ name: "amount", type: "uint256" },
|
|
180
205
|
{ name: "payerIsUser", type: "bool" }
|
|
181
|
-
],
|
|
206
|
+
], Tn = [
|
|
182
207
|
{ name: "currency", type: "address" },
|
|
183
208
|
{ name: "recipient", type: "address" },
|
|
184
209
|
{ name: "amount", type: "uint256" }
|
|
210
|
+
], Go = [
|
|
211
|
+
{ name: "currency", type: "address" },
|
|
212
|
+
{ name: "recipient", type: "address" },
|
|
213
|
+
{ name: "bips", type: "uint256" }
|
|
185
214
|
];
|
|
186
|
-
function
|
|
215
|
+
function Vo(e) {
|
|
187
216
|
return `0x${e.map((t) => t.toString(16).padStart(2, "0")).join("")}`;
|
|
188
217
|
}
|
|
189
|
-
function
|
|
218
|
+
function jo(e, t) {
|
|
190
219
|
return {
|
|
191
220
|
requiresV4Unlock: !0,
|
|
192
|
-
actions:
|
|
221
|
+
actions: Vo(e),
|
|
193
222
|
params: t
|
|
194
223
|
};
|
|
195
224
|
}
|
|
196
|
-
function
|
|
197
|
-
return
|
|
198
|
-
abi:
|
|
225
|
+
function Qo(e, t) {
|
|
226
|
+
return Ct({
|
|
227
|
+
abi: Ot,
|
|
199
228
|
functionName: "execute",
|
|
200
229
|
args: [e, t]
|
|
201
230
|
});
|
|
202
231
|
}
|
|
203
|
-
function
|
|
204
|
-
return
|
|
205
|
-
abi:
|
|
232
|
+
function Ho(e) {
|
|
233
|
+
return Ct({
|
|
234
|
+
abi: Ot,
|
|
206
235
|
functionName: "permitBatch",
|
|
207
236
|
args: [e.owner, e.permitBatch, e.signature]
|
|
208
237
|
});
|
|
209
238
|
}
|
|
210
|
-
function
|
|
211
|
-
return
|
|
212
|
-
abi:
|
|
239
|
+
function Xo(e) {
|
|
240
|
+
return Ct({
|
|
241
|
+
abi: Ot,
|
|
213
242
|
functionName: "multicall",
|
|
214
243
|
args: [e]
|
|
215
244
|
});
|
|
216
245
|
}
|
|
217
|
-
function
|
|
218
|
-
|
|
246
|
+
function Yo(e) {
|
|
247
|
+
if (!e) return !1;
|
|
248
|
+
if ("bips" in e) {
|
|
249
|
+
if (!Number.isInteger(e.bips) || e.bips < 0 || e.bips > 1e4)
|
|
250
|
+
throw new Error("Fee portion must be an integer between 0 and 10000 bips.");
|
|
251
|
+
return e.bips > 0;
|
|
252
|
+
}
|
|
253
|
+
return e.amount > 0n;
|
|
254
|
+
}
|
|
255
|
+
function Zo(e, t) {
|
|
256
|
+
return "bips" in e ? {
|
|
257
|
+
action: Se.TAKE_PORTION,
|
|
258
|
+
params: be(Go, [t, e.recipient, BigInt(e.bips)])
|
|
259
|
+
} : {
|
|
260
|
+
action: Se.TAKE,
|
|
261
|
+
params: be(Tn, [t, e.recipient, e.amount])
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
function qe(e, t = "Amount") {
|
|
265
|
+
if (e < 0n || e > Wo)
|
|
266
|
+
throw new Error(`${t} is too large for a single V4 swap.`);
|
|
219
267
|
}
|
|
220
|
-
function
|
|
221
|
-
return t ?
|
|
268
|
+
function Jo(e, t) {
|
|
269
|
+
return t ? Xo([Ho(t), e]) : e;
|
|
222
270
|
}
|
|
223
|
-
function
|
|
224
|
-
return
|
|
225
|
-
|
|
271
|
+
function On(e) {
|
|
272
|
+
return Do(
|
|
273
|
+
be(
|
|
226
274
|
[
|
|
227
275
|
{ name: "currency0", type: "address" },
|
|
228
276
|
{ name: "currency1", type: "address" },
|
|
@@ -240,84 +288,94 @@ function Ft(e) {
|
|
|
240
288
|
)
|
|
241
289
|
);
|
|
242
290
|
}
|
|
243
|
-
function
|
|
244
|
-
const t = e.zeroForOne ? e.poolKey.currency0 : e.poolKey.currency1, n = e.zeroForOne ? e.poolKey.currency1 : e.poolKey.currency0,
|
|
291
|
+
function Mn(e) {
|
|
292
|
+
const t = e.zeroForOne ? e.poolKey.currency0 : e.poolKey.currency1, n = e.zeroForOne ? e.poolKey.currency1 : e.poolKey.currency0, o = Yo(e.fee) ? e.fee : null, a = o ? Zo(o, n) : null, r = jo(
|
|
245
293
|
[
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
...a ? [
|
|
249
|
-
|
|
294
|
+
e.swapAction,
|
|
295
|
+
Se.SETTLE,
|
|
296
|
+
...a ? [a.action] : [],
|
|
297
|
+
Se.TAKE
|
|
250
298
|
],
|
|
251
299
|
[
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
amountIn: e.amountIn,
|
|
257
|
-
amountOutMinimum: e.amountOutMinimum,
|
|
258
|
-
hookData: "0x"
|
|
259
|
-
}
|
|
260
|
-
]),
|
|
261
|
-
R(Mt, [t, e.amountIn, !0]),
|
|
262
|
-
...a ? [R(ve, [n, a.recipient, a.amount])] : [],
|
|
263
|
-
R(ve, [n, e.recipient, je])
|
|
300
|
+
e.encodedSwapParams,
|
|
301
|
+
be(zo, [t, e.settleAmount, !0]),
|
|
302
|
+
...a ? [a.params] : [],
|
|
303
|
+
be(Tn, [n, e.recipient, Cn])
|
|
264
304
|
]
|
|
265
305
|
);
|
|
266
306
|
return {
|
|
267
|
-
calldata:
|
|
307
|
+
calldata: Jo(Qo([r], e.deadline), e.permit),
|
|
268
308
|
value: 0n
|
|
269
309
|
};
|
|
270
310
|
}
|
|
271
|
-
function
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
)
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
311
|
+
function ea(e) {
|
|
312
|
+
return qe(e.amountIn, "Swap input amount"), qe(e.amountOutMinimum, "Swap minimum output"), Mn({
|
|
313
|
+
swapAction: Se.SWAP_EXACT_IN_SINGLE,
|
|
314
|
+
encodedSwapParams: be($o, [
|
|
315
|
+
{
|
|
316
|
+
poolKey: e.poolKey,
|
|
317
|
+
zeroForOne: e.zeroForOne,
|
|
318
|
+
amountIn: e.amountIn,
|
|
319
|
+
amountOutMinimum: e.amountOutMinimum,
|
|
320
|
+
hookData: "0x"
|
|
321
|
+
}
|
|
322
|
+
]),
|
|
323
|
+
poolKey: e.poolKey,
|
|
324
|
+
zeroForOne: e.zeroForOne,
|
|
325
|
+
settleAmount: e.amountIn,
|
|
326
|
+
recipient: e.recipient,
|
|
327
|
+
deadline: e.deadline,
|
|
328
|
+
permit: e.permit,
|
|
329
|
+
fee: e.fee
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
function ta(e) {
|
|
333
|
+
return qe(e.amountOut, "Swap output amount"), qe(e.amountInMaximum, "Swap maximum input"), Mn({
|
|
334
|
+
swapAction: Se.SWAP_EXACT_OUT_SINGLE,
|
|
335
|
+
encodedSwapParams: be(Ko, [
|
|
336
|
+
{
|
|
337
|
+
poolKey: e.poolKey,
|
|
338
|
+
zeroForOne: e.zeroForOne,
|
|
339
|
+
amountOut: e.amountOut,
|
|
340
|
+
amountInMaximum: e.amountInMaximum,
|
|
341
|
+
hookData: "0x"
|
|
342
|
+
}
|
|
343
|
+
]),
|
|
344
|
+
poolKey: e.poolKey,
|
|
345
|
+
zeroForOne: e.zeroForOne,
|
|
346
|
+
settleAmount: Cn,
|
|
347
|
+
recipient: e.recipient,
|
|
348
|
+
deadline: e.deadline,
|
|
349
|
+
permit: e.permit,
|
|
350
|
+
fee: e.fee
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
function Pn(e, t) {
|
|
354
|
+
var n;
|
|
355
|
+
return ((n = t.explorerTxUrl) == null ? void 0 : n.call(t, e)) ?? "#";
|
|
298
356
|
}
|
|
299
|
-
const
|
|
357
|
+
const ee = 1, Dn = F("0x00581261a1200956ea05d1810fF28ffd66D8E254"), na = F("0x8f29BD5c8429730fA4C46e6295c4e679eDEdd0cC"), oa = 8388608, aa = 50, ra = F(
|
|
300
358
|
"0x8ea2C7de60ef1Cd4dcE64ea2DDDe2f99F0127eFC"
|
|
301
359
|
);
|
|
302
|
-
function
|
|
303
|
-
return e ?
|
|
360
|
+
function Ae(e) {
|
|
361
|
+
return e ? F(e) : void 0;
|
|
304
362
|
}
|
|
305
|
-
function
|
|
363
|
+
function ye(e) {
|
|
306
364
|
if (!e.permit2 || !e.quoter)
|
|
307
365
|
throw new Error("Missing Permit2 or V4 Quoter contract address.");
|
|
308
366
|
return {
|
|
309
|
-
permit2:
|
|
310
|
-
quoter:
|
|
311
|
-
poolManager:
|
|
312
|
-
positionDescriptor:
|
|
313
|
-
positionManager:
|
|
314
|
-
stateView:
|
|
315
|
-
universalRouter:
|
|
316
|
-
universalRouterV2_1_1:
|
|
367
|
+
permit2: F(e.permit2),
|
|
368
|
+
quoter: F(e.quoter),
|
|
369
|
+
poolManager: Ae(e.poolManager),
|
|
370
|
+
positionDescriptor: Ae(e.positionDescriptor),
|
|
371
|
+
positionManager: Ae(e.positionManager),
|
|
372
|
+
stateView: Ae(e.stateView),
|
|
373
|
+
universalRouter: Ae(e.universalRouter),
|
|
374
|
+
universalRouterV2_1_1: Ae(e.universalRouterV2_1_1)
|
|
317
375
|
};
|
|
318
376
|
}
|
|
319
|
-
const
|
|
320
|
-
1:
|
|
377
|
+
const Rn = {
|
|
378
|
+
1: ye({
|
|
321
379
|
poolManager: "0x000000000004444c5dc75cB358380D2e3dE08A90",
|
|
322
380
|
positionDescriptor: "0xd1428ba554f4c8450b763a0b2040a4935c63f06c",
|
|
323
381
|
positionManager: "0xbd216513d74c8cf14cf4747e6aaa6420ff64ee9e",
|
|
@@ -327,7 +385,7 @@ const Wt = {
|
|
|
327
385
|
universalRouterV2_1_1: "0x4c82d1fbfe28c977cbb58d8c7ff8fcf9f70a2cca",
|
|
328
386
|
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3"
|
|
329
387
|
}),
|
|
330
|
-
10:
|
|
388
|
+
10: ye({
|
|
331
389
|
poolManager: "0x9a13f98cb987694c9f086b1f5eb990eea8264ec3",
|
|
332
390
|
positionDescriptor: "0xedd81496169c46df161b8513a52ffecaaaa66743",
|
|
333
391
|
positionManager: "0x3c3ea4b57a46241e54610e5f022e5c45859a1017",
|
|
@@ -337,7 +395,7 @@ const Wt = {
|
|
|
337
395
|
universalRouterV2_1_1: "0x8b844f885672f333bc0042cb669255f93a4c1e6b",
|
|
338
396
|
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3"
|
|
339
397
|
}),
|
|
340
|
-
130:
|
|
398
|
+
130: ye({
|
|
341
399
|
poolManager: "0x1f98400000000000000000000000000000000004",
|
|
342
400
|
positionDescriptor: "0x9fb28449a191cd8c03a1b7abfb0f5996ecf7f722",
|
|
343
401
|
positionManager: "0x4529a01c7a0410167c5740c487a8de60232617bf",
|
|
@@ -347,7 +405,7 @@ const Wt = {
|
|
|
347
405
|
universalRouterV2_1_1: "0xfdf682f51fe81aa4898f0ae2163d8a55c127fbc7",
|
|
348
406
|
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3"
|
|
349
407
|
}),
|
|
350
|
-
137:
|
|
408
|
+
137: ye({
|
|
351
409
|
poolManager: "0x67366782805870060151383f4bbff9dab53e5cd6",
|
|
352
410
|
positionDescriptor: "0x0892771f0c1b78ad6013d6e5536007e1c16e6794",
|
|
353
411
|
positionManager: "0x1ec2ebf4f37e7363fdfe3551602425af0b3ceef9",
|
|
@@ -357,7 +415,7 @@ const Wt = {
|
|
|
357
415
|
universalRouterV2_1_1: "0x8b844f885672f333bc0042cb669255f93a4c1e6b",
|
|
358
416
|
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3"
|
|
359
417
|
}),
|
|
360
|
-
8453:
|
|
418
|
+
8453: ye({
|
|
361
419
|
poolManager: "0x498581ff718922c3f8e6a244956af099b2652b2b",
|
|
362
420
|
positionDescriptor: "0x25d093633990dc94bedeed76c8f3cdaa75f3e7d5",
|
|
363
421
|
positionManager: "0x7c5f5a4bbd8fd63184577525326123b519429bdc",
|
|
@@ -367,7 +425,7 @@ const Wt = {
|
|
|
367
425
|
universalRouterV2_1_1: "0xfdf682f51fe81aa4898f0ae2163d8a55c127fbc7",
|
|
368
426
|
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3"
|
|
369
427
|
}),
|
|
370
|
-
42161:
|
|
428
|
+
42161: ye({
|
|
371
429
|
poolManager: "0x360e68faccca8ca495c1b759fd9eee466db9fb32",
|
|
372
430
|
positionDescriptor: "0xe2023f3fa515cf070e07fd9d51c1d236e07843f4",
|
|
373
431
|
positionManager: "0xd88f38f930b7952f2db2432cb002e7abbf3dd869",
|
|
@@ -377,295 +435,622 @@ const Wt = {
|
|
|
377
435
|
universalRouterV2_1_1: "0x8b844f885672f333bc0042cb669255f93a4c1e6b",
|
|
378
436
|
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3"
|
|
379
437
|
})
|
|
380
|
-
},
|
|
438
|
+
}, Mt = Rn[ee], Bn = Mt.permit2, Un = Mt.quoter, ia = [
|
|
381
439
|
"https://eth.drpc.org",
|
|
382
440
|
"https://ethereum-rpc.publicnode.com",
|
|
383
441
|
"https://cloudflare-eth.com"
|
|
384
|
-
],
|
|
385
|
-
chainId:
|
|
386
|
-
chain:
|
|
442
|
+
], ca = "https://aegis.markets/graphql/meta", sa = {
|
|
443
|
+
chainId: ee,
|
|
444
|
+
chain: Lo,
|
|
387
445
|
name: "Ethereum",
|
|
388
|
-
router:
|
|
389
|
-
permit2:
|
|
390
|
-
quoter:
|
|
391
|
-
v4Contracts:
|
|
392
|
-
rpcUrls:
|
|
446
|
+
router: Dn,
|
|
447
|
+
permit2: Bn,
|
|
448
|
+
quoter: Un,
|
|
449
|
+
v4Contracts: Mt,
|
|
450
|
+
rpcUrls: ia,
|
|
393
451
|
explorerTxUrl: (e) => `https://etherscan.io/tx/${e}`,
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
452
|
+
poolExplorerUrl: (e) => `https://app.uniswap.org/explore/pools/ethereum/${e}`,
|
|
453
|
+
metadataEndpoint: ca,
|
|
454
|
+
fee: {
|
|
455
|
+
bps: aa,
|
|
456
|
+
recipient: ra
|
|
457
|
+
}
|
|
458
|
+
}, it = {
|
|
459
|
+
[ee]: sa
|
|
460
|
+
}, X = {
|
|
398
461
|
USDC: {
|
|
399
|
-
chainId:
|
|
400
|
-
address:
|
|
462
|
+
chainId: ee,
|
|
463
|
+
address: F("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),
|
|
401
464
|
name: "USD Coin",
|
|
402
465
|
symbol: "USDC",
|
|
403
466
|
decimals: 6
|
|
404
467
|
},
|
|
405
468
|
WATER: {
|
|
406
|
-
chainId:
|
|
407
|
-
address:
|
|
469
|
+
chainId: ee,
|
|
470
|
+
address: F("0x828B22c9ea1c20B551EeFC6198174C4bb7a8CBF6"),
|
|
408
471
|
name: "WATER",
|
|
409
472
|
symbol: "WATER",
|
|
410
473
|
decimals: 18
|
|
411
474
|
},
|
|
412
475
|
WOOD: {
|
|
413
|
-
chainId:
|
|
414
|
-
address:
|
|
476
|
+
chainId: ee,
|
|
477
|
+
address: F("0x670AfdD7226e73d3CC55B5cd83933E46aF22DECd"),
|
|
415
478
|
name: "WOOD",
|
|
416
479
|
symbol: "WOOD",
|
|
417
480
|
decimals: 18
|
|
418
481
|
},
|
|
419
482
|
GRASS: {
|
|
420
|
-
chainId:
|
|
421
|
-
address:
|
|
483
|
+
chainId: ee,
|
|
484
|
+
address: F("0xF06Ad052b0d8D511D0B6f00100b8e402639209EF"),
|
|
422
485
|
name: "GRASS",
|
|
423
486
|
symbol: "GRASS",
|
|
424
487
|
decimals: 18
|
|
425
488
|
},
|
|
426
489
|
STONE: {
|
|
427
|
-
chainId:
|
|
428
|
-
address:
|
|
490
|
+
chainId: ee,
|
|
491
|
+
address: F("0xCabcc33D9Ff7e24F413d939773D232C0d50dCc7f"),
|
|
429
492
|
name: "STONE",
|
|
430
493
|
symbol: "STONE",
|
|
431
494
|
decimals: 18
|
|
432
495
|
}
|
|
433
496
|
};
|
|
434
|
-
function
|
|
497
|
+
function ct(e, t, n, o, a, r) {
|
|
435
498
|
return {
|
|
436
499
|
id: e,
|
|
437
|
-
chainId:
|
|
500
|
+
chainId: ee,
|
|
438
501
|
symbol: t,
|
|
439
502
|
poolId: n,
|
|
440
503
|
poolKey: {
|
|
441
|
-
currency0:
|
|
442
|
-
currency1:
|
|
443
|
-
fee:
|
|
444
|
-
tickSpacing:
|
|
445
|
-
hooks:
|
|
504
|
+
currency0: o,
|
|
505
|
+
currency1: a,
|
|
506
|
+
fee: oa,
|
|
507
|
+
tickSpacing: r,
|
|
508
|
+
hooks: na
|
|
446
509
|
},
|
|
447
|
-
token:
|
|
448
|
-
counterToken:
|
|
449
|
-
router:
|
|
450
|
-
permit2:
|
|
451
|
-
quoter:
|
|
452
|
-
label: `${
|
|
510
|
+
token: X[t],
|
|
511
|
+
counterToken: X.USDC,
|
|
512
|
+
router: Dn,
|
|
513
|
+
permit2: Bn,
|
|
514
|
+
quoter: Un,
|
|
515
|
+
label: `${X.USDC.symbol} / ${t}`
|
|
453
516
|
};
|
|
454
517
|
}
|
|
455
|
-
const
|
|
518
|
+
const ua = ct(
|
|
456
519
|
"WATER_USDC",
|
|
457
520
|
"WATER",
|
|
458
521
|
"0x01409fc6f1bf49e20bf05df5d4dcb96ed3977ea717bc4a135e9deacd92ebc0af",
|
|
459
|
-
|
|
460
|
-
|
|
522
|
+
X.WATER.address,
|
|
523
|
+
X.USDC.address,
|
|
461
524
|
60
|
|
462
|
-
),
|
|
525
|
+
), la = ct(
|
|
463
526
|
"WOOD_USDC",
|
|
464
527
|
"WOOD",
|
|
465
528
|
"0x0f8a98e3fdb7ea4438a3f7342f040cbc9d1eced1b90a876d38f3453100243356",
|
|
466
|
-
|
|
467
|
-
|
|
529
|
+
X.WOOD.address,
|
|
530
|
+
X.USDC.address,
|
|
468
531
|
60
|
|
469
|
-
),
|
|
532
|
+
), da = ct(
|
|
470
533
|
"GRASS_USDC",
|
|
471
534
|
"GRASS",
|
|
472
|
-
"
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
),
|
|
535
|
+
"0xd0194ad1f57730361b93ecf8da86e18590bd5e1f64e4a35f3a5b5bd666e48ae1",
|
|
536
|
+
X.USDC.address,
|
|
537
|
+
X.GRASS.address,
|
|
538
|
+
60
|
|
539
|
+
), pa = ct(
|
|
477
540
|
"STONE_USDC",
|
|
478
541
|
"STONE",
|
|
479
542
|
"0x3fa06e44e4bee9539887681eab6b608b646784e2027ea6292198cde0690aff54",
|
|
480
|
-
|
|
481
|
-
|
|
543
|
+
X.USDC.address,
|
|
544
|
+
X.STONE.address,
|
|
482
545
|
60
|
|
483
|
-
),
|
|
484
|
-
WATER_USDC:
|
|
485
|
-
WOOD_USDC:
|
|
486
|
-
GRASS_USDC:
|
|
487
|
-
STONE_USDC:
|
|
488
|
-
},
|
|
546
|
+
), ma = {
|
|
547
|
+
WATER_USDC: ua,
|
|
548
|
+
WOOD_USDC: la,
|
|
549
|
+
GRASS_USDC: da,
|
|
550
|
+
STONE_USDC: pa
|
|
551
|
+
}, cn = [
|
|
489
552
|
"WATER_USDC",
|
|
490
553
|
"WOOD_USDC",
|
|
491
554
|
"GRASS_USDC",
|
|
492
555
|
"STONE_USDC"
|
|
493
556
|
];
|
|
494
|
-
function
|
|
557
|
+
function sn(e) {
|
|
495
558
|
return {
|
|
496
559
|
...e,
|
|
497
|
-
address:
|
|
560
|
+
address: F(e.address)
|
|
498
561
|
};
|
|
499
562
|
}
|
|
500
|
-
function
|
|
563
|
+
function fa(e) {
|
|
564
|
+
const t = F(e.currency0), n = F(e.currency1);
|
|
565
|
+
if (t.toLowerCase() >= n.toLowerCase())
|
|
566
|
+
throw new Error(
|
|
567
|
+
"Invalid pool key: currency0 must sort below currency1 (Uniswap v4 canonical ordering)."
|
|
568
|
+
);
|
|
501
569
|
return {
|
|
502
|
-
currency0:
|
|
503
|
-
currency1:
|
|
570
|
+
currency0: t,
|
|
571
|
+
currency1: n,
|
|
504
572
|
fee: e.fee,
|
|
505
573
|
tickSpacing: e.tickSpacing,
|
|
506
|
-
hooks:
|
|
574
|
+
hooks: F(e.hooks)
|
|
507
575
|
};
|
|
508
576
|
}
|
|
509
|
-
function
|
|
510
|
-
var
|
|
511
|
-
const n =
|
|
577
|
+
function ha(e, t) {
|
|
578
|
+
var o, a;
|
|
579
|
+
const n = Rn[e.chainId];
|
|
512
580
|
return {
|
|
513
581
|
...n,
|
|
514
582
|
...t == null ? void 0 : t.v4Contracts,
|
|
515
583
|
...e.v4Contracts,
|
|
516
|
-
permit2: ((
|
|
517
|
-
quoter: ((
|
|
584
|
+
permit2: ((o = e.v4Contracts) == null ? void 0 : o.permit2) ?? e.permit2 ?? (t == null ? void 0 : t.permit2) ?? (n == null ? void 0 : n.permit2),
|
|
585
|
+
quoter: ((a = e.v4Contracts) == null ? void 0 : a.quoter) ?? e.quoter ?? (t == null ? void 0 : t.quoter) ?? (n == null ? void 0 : n.quoter)
|
|
518
586
|
};
|
|
519
587
|
}
|
|
520
|
-
function
|
|
521
|
-
var
|
|
522
|
-
const n =
|
|
523
|
-
if (!t && (!e.chain || !e.router || !((
|
|
588
|
+
function wa(e, t) {
|
|
589
|
+
var a;
|
|
590
|
+
const n = ha(e, t);
|
|
591
|
+
if (!t && (!e.chain || !e.router || !((a = e.rpcUrls) != null && a.length)))
|
|
524
592
|
throw new Error(
|
|
525
593
|
`Missing viem chain, Aegis router, or RPC URLs for chain ${e.chainId}.`
|
|
526
594
|
);
|
|
527
|
-
const
|
|
595
|
+
const o = ye(n);
|
|
528
596
|
return {
|
|
529
597
|
chainId: e.chainId,
|
|
530
598
|
chain: e.chain ?? t.chain,
|
|
531
599
|
name: e.name ?? (t == null ? void 0 : t.name) ?? `Chain ${e.chainId}`,
|
|
532
|
-
router:
|
|
533
|
-
permit2:
|
|
534
|
-
quoter:
|
|
535
|
-
v4Contracts:
|
|
600
|
+
router: F(e.router ?? t.router),
|
|
601
|
+
permit2: o.permit2,
|
|
602
|
+
quoter: o.quoter,
|
|
603
|
+
v4Contracts: o,
|
|
536
604
|
rpcUrls: e.rpcUrls ?? t.rpcUrls,
|
|
537
605
|
explorerTxUrl: e.explorerTxUrl ?? (t == null ? void 0 : t.explorerTxUrl),
|
|
538
606
|
poolExplorerUrl: e.poolExplorerUrl ?? (t == null ? void 0 : t.poolExplorerUrl),
|
|
539
|
-
metadataEndpoint: e.metadataEndpoint ?? (t == null ? void 0 : t.metadataEndpoint)
|
|
607
|
+
metadataEndpoint: e.metadataEndpoint ?? (t == null ? void 0 : t.metadataEndpoint),
|
|
608
|
+
// Fee stays internal: it is never read from host input, only inherited from
|
|
609
|
+
// the bundled base chain config (e.g. mainnet keeps its 50 bps fee).
|
|
610
|
+
fee: t == null ? void 0 : t.fee
|
|
540
611
|
};
|
|
541
612
|
}
|
|
542
|
-
function
|
|
543
|
-
const t = { ...
|
|
613
|
+
function ga(e) {
|
|
614
|
+
const t = { ...it };
|
|
544
615
|
if (!e) return t;
|
|
545
|
-
for (const [n,
|
|
546
|
-
if (!
|
|
547
|
-
const
|
|
548
|
-
t[
|
|
549
|
-
{ ...
|
|
550
|
-
t[
|
|
616
|
+
for (const [n, o] of Object.entries(e)) {
|
|
617
|
+
if (!o) continue;
|
|
618
|
+
const a = o.chainId ?? Number(n);
|
|
619
|
+
t[a] = wa(
|
|
620
|
+
{ ...o, chainId: a },
|
|
621
|
+
t[a]
|
|
551
622
|
);
|
|
552
623
|
}
|
|
553
624
|
return t;
|
|
554
625
|
}
|
|
555
|
-
function
|
|
556
|
-
const n =
|
|
557
|
-
if (!
|
|
558
|
-
|
|
626
|
+
function ya(e, t = it) {
|
|
627
|
+
const n = sn(e.token), o = sn(e.counterToken), a = e.chainId ?? n.chainId ?? o.chainId ?? ee, r = t[a];
|
|
628
|
+
if (!r) throw new Error(`No Aegis swap chain config found for chain ${a}.`);
|
|
629
|
+
if (n.chainId !== a || o.chainId !== a)
|
|
630
|
+
throw new Error(`Pool token chain ids must match chain ${a}.`);
|
|
631
|
+
const c = fa(e.poolKey), s = On(c);
|
|
632
|
+
if (e.poolId && !Sn(e.poolId, s))
|
|
633
|
+
throw new Error("Configured pool id does not match the pool key.");
|
|
559
634
|
return {
|
|
560
635
|
id: e.id,
|
|
561
|
-
chainId:
|
|
636
|
+
chainId: a,
|
|
562
637
|
symbol: e.symbol ?? n.symbol,
|
|
563
|
-
poolId: e.poolId ??
|
|
564
|
-
poolKey:
|
|
638
|
+
poolId: e.poolId ?? s,
|
|
639
|
+
poolKey: c,
|
|
565
640
|
token: n,
|
|
566
|
-
counterToken:
|
|
567
|
-
router:
|
|
568
|
-
permit2:
|
|
569
|
-
quoter:
|
|
570
|
-
label: e.label ?? `${
|
|
641
|
+
counterToken: o,
|
|
642
|
+
router: F(e.router ?? r.router),
|
|
643
|
+
permit2: F(e.permit2 ?? r.permit2),
|
|
644
|
+
quoter: F(e.quoter ?? r.quoter),
|
|
645
|
+
label: e.label ?? `${o.symbol} / ${n.symbol}`
|
|
571
646
|
};
|
|
572
647
|
}
|
|
573
|
-
function
|
|
648
|
+
function ba(e, t = it) {
|
|
574
649
|
return e != null && e.length ? Object.fromEntries(
|
|
575
650
|
e.map((n) => {
|
|
576
|
-
const
|
|
577
|
-
return [
|
|
651
|
+
const o = ya(n, t);
|
|
652
|
+
return [o.id, o];
|
|
578
653
|
})
|
|
579
654
|
) : {};
|
|
580
655
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
return
|
|
656
|
+
const un = "#06120c", ln = "#f4f8f5";
|
|
657
|
+
function ve(e) {
|
|
658
|
+
return Math.min(255, Math.max(0, Math.round(e)));
|
|
659
|
+
}
|
|
660
|
+
function dn(e) {
|
|
661
|
+
const t = e.replace(/^#/, "");
|
|
662
|
+
if (!/^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$/.test(t)) return null;
|
|
663
|
+
const n = t.length === 3 ? t.split("").map((o) => o + o).join("") : t;
|
|
664
|
+
return {
|
|
665
|
+
r: Number.parseInt(n.slice(0, 2), 16),
|
|
666
|
+
g: Number.parseInt(n.slice(2, 4), 16),
|
|
667
|
+
b: Number.parseInt(n.slice(4, 6), 16)
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
function _a(e) {
|
|
671
|
+
return e.endsWith("%") ? Number.parseFloat(e) * 255 / 100 : Number.parseFloat(e);
|
|
672
|
+
}
|
|
673
|
+
function pn(e) {
|
|
674
|
+
const t = e.match(/^rgba?\(\s*([\d.]+%?)\s*[,\s]\s*([\d.]+%?)\s*[,\s]\s*([\d.]+%?)/i);
|
|
675
|
+
if (!t) return null;
|
|
676
|
+
const [n, o, a] = [t[1], t[2], t[3]].map(_a);
|
|
677
|
+
return [n, o, a].some((r) => Number.isNaN(r)) ? null : { r: ve(n), g: ve(o), b: ve(a) };
|
|
678
|
+
}
|
|
679
|
+
function Ia(e, t, n) {
|
|
680
|
+
const o = t / 100, a = n / 100, r = (1 - Math.abs(2 * a - 1)) * o, c = (e % 360 + 360) % 360 / 60, s = r * (1 - Math.abs(c % 2 - 1)), l = a - r / 2, [u, d, m] = c < 1 ? [r, s, 0] : c < 2 ? [s, r, 0] : c < 3 ? [0, r, s] : c < 4 ? [0, s, r] : c < 5 ? [s, 0, r] : [r, 0, s];
|
|
681
|
+
return {
|
|
682
|
+
r: ve((u + l) * 255),
|
|
683
|
+
g: ve((d + l) * 255),
|
|
684
|
+
b: ve((m + l) * 255)
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
function Aa(e) {
|
|
688
|
+
const t = e.match(/^hsla?\(\s*([\d.]+)(?:deg)?\s*[,\s]\s*([\d.]+)%\s*[,\s]\s*([\d.]+)%/i);
|
|
689
|
+
if (!t) return null;
|
|
690
|
+
const [n, o, a] = [t[1], t[2], t[3]].map(Number.parseFloat);
|
|
691
|
+
return [n, o, a].some((r) => Number.isNaN(r)) ? null : Ia(n, o, a);
|
|
692
|
+
}
|
|
693
|
+
function va(e) {
|
|
694
|
+
if (typeof document > "u") return null;
|
|
695
|
+
const t = document.createElement("canvas").getContext("2d");
|
|
696
|
+
if (!t) return null;
|
|
697
|
+
t.fillStyle = "#000", t.fillStyle = e;
|
|
698
|
+
const n = t.fillStyle;
|
|
699
|
+
t.fillStyle = "#fff", t.fillStyle = e;
|
|
700
|
+
const o = t.fillStyle;
|
|
701
|
+
return n === o ? n : null;
|
|
702
|
+
}
|
|
703
|
+
function Ea(e) {
|
|
704
|
+
const t = e.trim(), n = dn(t) ?? pn(t) ?? Aa(t);
|
|
705
|
+
if (n) return n;
|
|
706
|
+
const o = va(t);
|
|
707
|
+
return o ? dn(o) ?? pn(o) : null;
|
|
708
|
+
}
|
|
709
|
+
function _t(e) {
|
|
710
|
+
const t = e / 255;
|
|
711
|
+
return t <= 0.03928 ? t / 12.92 : ((t + 0.055) / 1.055) ** 2.4;
|
|
712
|
+
}
|
|
713
|
+
function It(e) {
|
|
714
|
+
const t = Ea(e);
|
|
715
|
+
return t ? 0.2126 * _t(t.r) + 0.7152 * _t(t.g) + 0.0722 * _t(t.b) : null;
|
|
716
|
+
}
|
|
717
|
+
function mn(e, t) {
|
|
718
|
+
return (Math.max(e, t) + 0.05) / (Math.min(e, t) + 0.05);
|
|
719
|
+
}
|
|
720
|
+
function Sa(e) {
|
|
721
|
+
const t = It(e);
|
|
722
|
+
if (t === null) return null;
|
|
723
|
+
const n = It(un) ?? 0, o = It(ln) ?? 1;
|
|
724
|
+
return mn(t, n) >= mn(t, o) ? un : ln;
|
|
725
|
+
}
|
|
726
|
+
const xa = "https://ichi-images.s3.us-east-1.amazonaws.com/tokens", At = /* @__PURE__ */ new Map();
|
|
727
|
+
function fn(e, t, n) {
|
|
728
|
+
return `${e}|evm_${t}_${n.toLowerCase()}`;
|
|
729
|
+
}
|
|
730
|
+
function Ca(e, t) {
|
|
731
|
+
return `evm_${e}_${t.toLowerCase()}`;
|
|
732
|
+
}
|
|
733
|
+
function Na(e) {
|
|
734
|
+
const t = e == null ? void 0 : e.trim();
|
|
735
|
+
if (!t) return null;
|
|
736
|
+
const n = t.split("-"), a = (n.length > 1 ? n[n.length - 1] : t).trim().toLowerCase();
|
|
737
|
+
return !a || !/^[a-z0-9]+$/.test(a) ? null : a;
|
|
738
|
+
}
|
|
739
|
+
function Ta(e) {
|
|
740
|
+
const t = Na(e);
|
|
741
|
+
return t ? `${xa}/logo_256_${t}.svg` : null;
|
|
742
|
+
}
|
|
743
|
+
function Oa(e, t) {
|
|
744
|
+
return `query AegisSwapWidgetTokenMetadata { ${t.map((o, a) => `t${a}: getGlobalToken(id: ${JSON.stringify(Ca(e, o))}) { chainId address symbol displayName fullName decimals iconURL }`).join(" ")} }`;
|
|
745
|
+
}
|
|
746
|
+
async function Ma(e) {
|
|
747
|
+
var s, l;
|
|
748
|
+
const t = e.endpoint.trim(), n = [
|
|
749
|
+
...new Map(
|
|
750
|
+
e.addresses.map((u) => {
|
|
751
|
+
const d = F(u);
|
|
752
|
+
return [d.toLowerCase(), d];
|
|
753
|
+
})
|
|
754
|
+
).values()
|
|
755
|
+
], o = /* @__PURE__ */ new Map(), a = n.filter((u) => {
|
|
756
|
+
const d = fn(t, e.chainId, u);
|
|
757
|
+
if (!At.has(d)) return !0;
|
|
758
|
+
const m = At.get(d);
|
|
759
|
+
return m && o.set(de(u), m), !1;
|
|
760
|
+
});
|
|
761
|
+
if (!a.length || typeof fetch != "function") return o;
|
|
762
|
+
const r = await fetch(t, {
|
|
763
|
+
method: "POST",
|
|
764
|
+
headers: { "Content-Type": "application/json" },
|
|
765
|
+
body: JSON.stringify({
|
|
766
|
+
query: Oa(e.chainId, a)
|
|
767
|
+
}),
|
|
768
|
+
signal: e.signal
|
|
769
|
+
});
|
|
770
|
+
if (!r.ok)
|
|
771
|
+
throw new Error(`Token metadata request failed with HTTP ${r.status}.`);
|
|
772
|
+
const c = await r.json();
|
|
773
|
+
if ((s = c.errors) != null && s.length)
|
|
774
|
+
throw new Error(((l = c.errors[0]) == null ? void 0 : l.message) ?? "Token metadata request failed.");
|
|
775
|
+
return a.forEach((u, d) => {
|
|
776
|
+
var f;
|
|
777
|
+
const m = ((f = c.data) == null ? void 0 : f[`t${d}`]) ?? null;
|
|
778
|
+
At.set(fn(t, e.chainId, u), m), m && o.set(de(u), m);
|
|
779
|
+
}), o;
|
|
780
|
+
}
|
|
781
|
+
const Pa = {
|
|
782
|
+
USDC: { primary: "#d7ecff", secondary: "#2775ca", text: "#06111f" },
|
|
783
|
+
WATER: { primary: "#87dcff", secondary: "#0f5d96", text: "#051621" },
|
|
784
|
+
WOOD: { primary: "#c79a62", secondary: "#45633d", text: "#171008" },
|
|
785
|
+
GRASS: { primary: "#76e28a", secondary: "#244f32", text: "#061508" },
|
|
786
|
+
STONE: { primary: "#d7d1c3", secondary: "#5a6366", text: "#111416" }
|
|
787
|
+
};
|
|
788
|
+
function Da(e) {
|
|
789
|
+
const t = Pa[e] ?? {
|
|
790
|
+
primary: "#eef3f0",
|
|
791
|
+
secondary: "#75827c",
|
|
792
|
+
text: "#111815"
|
|
793
|
+
};
|
|
794
|
+
return {
|
|
795
|
+
"--aegis-token-primary": t.primary,
|
|
796
|
+
"--aegis-token-secondary": t.secondary,
|
|
797
|
+
"--aegis-token-text": t.text
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
function Ra(e, t) {
|
|
801
|
+
var n;
|
|
802
|
+
return e.iconUrl ?? ((n = t[de(e.address)]) == null ? void 0 : n.iconURL) ?? Ta(e.symbol);
|
|
803
|
+
}
|
|
804
|
+
const Et = En(function({
|
|
805
|
+
token: t,
|
|
806
|
+
metadataByAddress: n,
|
|
807
|
+
className: o
|
|
808
|
+
}) {
|
|
809
|
+
const a = Ra(t, n), [r, c] = A(null), s = a && r !== a ? a : null;
|
|
810
|
+
return /* @__PURE__ */ i("span", { className: o, style: Da(t.symbol), "aria-hidden": "true", children: s ? /* @__PURE__ */ i(
|
|
811
|
+
"img",
|
|
812
|
+
{
|
|
813
|
+
src: s,
|
|
814
|
+
alt: "",
|
|
815
|
+
loading: "lazy",
|
|
816
|
+
decoding: "async",
|
|
817
|
+
onError: () => c(s)
|
|
818
|
+
}
|
|
819
|
+
) : t.symbol.slice(0, 1) });
|
|
820
|
+
}), kn = En(function({
|
|
821
|
+
market: t,
|
|
822
|
+
metadataByAddress: n,
|
|
823
|
+
className: o
|
|
824
|
+
}) {
|
|
825
|
+
return /* @__PURE__ */ h("span", { className: o, "aria-hidden": "true", children: [
|
|
826
|
+
/* @__PURE__ */ i(
|
|
827
|
+
Et,
|
|
828
|
+
{
|
|
829
|
+
token: t.counterToken,
|
|
830
|
+
metadataByAddress: n,
|
|
831
|
+
className: "aegis-swap-widget__pair-icon"
|
|
832
|
+
}
|
|
833
|
+
),
|
|
834
|
+
/* @__PURE__ */ i(
|
|
835
|
+
Et,
|
|
836
|
+
{
|
|
837
|
+
token: t.token,
|
|
838
|
+
metadataByAddress: n,
|
|
839
|
+
className: "aegis-swap-widget__pair-icon aegis-swap-widget__pair-icon--secondary"
|
|
840
|
+
}
|
|
841
|
+
)
|
|
842
|
+
] });
|
|
843
|
+
});
|
|
844
|
+
function hn() {
|
|
845
|
+
return /* @__PURE__ */ h("svg", { viewBox: "0 0 150 151", "aria-hidden": "true", focusable: "false", children: [
|
|
846
|
+
/* @__PURE__ */ i(
|
|
847
|
+
"path",
|
|
848
|
+
{
|
|
849
|
+
d: "M64.7727 0.691736C28.1896 5.67985 0 37.048 0 75.0003C0 112.952 28.1896 144.321 64.7727 149.309C68.264 148.833 71.6788 148.116 75 147.177C106.48 138.274 129.545 109.141 129.545 74.8109C129.545 51.4969 113.281 31.9817 91.4795 26.993C87.8685 26.1667 84.1035 26.1664 80.4924 26.9925C78.6184 27.4212 76.7854 27.9573 75 28.5939C93.9861 35.3633 107.576 53.5001 107.576 74.8109C107.576 96.1216 93.9861 114.258 75 121.028C73.2146 121.664 71.3816 122.2 69.5076 122.629C65.8965 123.455 62.1318 123.454 58.5199 122.632C36.7188 117.667 20.4545 98.314 20.4545 75.0003C20.4545 40.67 43.5204 11.727 75 2.82341C78.3212 1.88407 81.736 1.16777 85.2273 0.691735C81.8833 0.235781 78.4691 0.000244141 75 0.000244141C71.5309 0.000244141 68.1167 0.235782 64.7727 0.691736Z",
|
|
850
|
+
fill: "currentColor",
|
|
851
|
+
opacity: "0.92"
|
|
852
|
+
}
|
|
853
|
+
),
|
|
854
|
+
/* @__PURE__ */ i(
|
|
855
|
+
"path",
|
|
856
|
+
{
|
|
857
|
+
d: "M85.2273 149.374C121.81 144.386 150 113.018 150 75.0659C150 37.1137 121.81 5.74551 85.2273 0.757401C81.736 1.23343 78.3212 1.94972 75 2.88907C43.5204 11.7926 20.4545 40.925 20.4545 75.2553C20.4545 98.5693 36.7191 118.084 58.5205 123.073C62.1315 123.899 65.8965 123.9 69.5076 123.074C71.3816 122.645 73.2146 122.109 75 121.472C56.0139 114.703 42.4242 96.5661 42.4242 75.2553C42.4242 53.9445 56.0139 35.8078 75 29.0383C76.7854 28.4017 78.6184 27.8657 80.4924 27.437C84.1035 26.6108 87.8682 26.612 91.4801 27.4345C113.281 32.3988 129.545 51.7522 129.545 75.0659C129.545 109.396 106.48 138.339 75 147.243C71.6788 148.182 68.264 148.898 64.7727 149.374C68.1167 149.83 71.5309 150.066 75 150.066C78.4691 150.066 81.8833 149.83 85.2273 149.374Z",
|
|
858
|
+
fill: "currentColor",
|
|
859
|
+
opacity: "0.42"
|
|
860
|
+
}
|
|
861
|
+
)
|
|
862
|
+
] });
|
|
863
|
+
}
|
|
864
|
+
function wn({ className: e }) {
|
|
865
|
+
return /* @__PURE__ */ h(
|
|
866
|
+
"svg",
|
|
867
|
+
{
|
|
868
|
+
className: e,
|
|
869
|
+
viewBox: "0 0 1920 1920",
|
|
870
|
+
"aria-hidden": "true",
|
|
871
|
+
focusable: "false",
|
|
872
|
+
fill: "currentColor",
|
|
873
|
+
children: [
|
|
874
|
+
/* @__PURE__ */ i("path", { d: "m959.8 730.9-539.8 245.4 539.8 319.1 539.9-319.1z", opacity: "0.6" }),
|
|
875
|
+
/* @__PURE__ */ i("path", { d: "m420.2 976.3 539.8 319.1v-564.5-650.3z", opacity: "0.45" }),
|
|
876
|
+
/* @__PURE__ */ i("path", { d: "m960 80.6v650.3 564.5l539.8-319.1z", opacity: "0.8" }),
|
|
877
|
+
/* @__PURE__ */ i("path", { d: "m420 1078.7 539.8 760.7v-441.8z", opacity: "0.45" }),
|
|
878
|
+
/* @__PURE__ */ i("path", { d: "m959.8 1397.6v441.8l540.2-760.7z", opacity: "0.8" })
|
|
879
|
+
]
|
|
880
|
+
}
|
|
881
|
+
);
|
|
882
|
+
}
|
|
883
|
+
function Ba() {
|
|
884
|
+
return /* @__PURE__ */ h("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
|
|
885
|
+
/* @__PURE__ */ i("path", { d: "m3 16 4 4 4-4" }),
|
|
886
|
+
/* @__PURE__ */ i("path", { d: "M7 20V4" }),
|
|
887
|
+
/* @__PURE__ */ i("path", { d: "m21 8-4-4-4 4" }),
|
|
888
|
+
/* @__PURE__ */ i("path", { d: "M17 4v16" })
|
|
889
|
+
] });
|
|
890
|
+
}
|
|
891
|
+
function Fn() {
|
|
892
|
+
return /* @__PURE__ */ h("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
|
|
893
|
+
/* @__PURE__ */ i("path", { d: "M14 5h5v5" }),
|
|
894
|
+
/* @__PURE__ */ i("path", { d: "m13 11 6-6" }),
|
|
895
|
+
/* @__PURE__ */ i("path", { d: "M19 14v4.5A1.5 1.5 0 0 1 17.5 20h-12A1.5 1.5 0 0 1 4 18.5v-12A1.5 1.5 0 0 1 5.5 5H10" })
|
|
896
|
+
] });
|
|
897
|
+
}
|
|
898
|
+
function Ua() {
|
|
899
|
+
return /* @__PURE__ */ h("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
|
|
900
|
+
/* @__PURE__ */ i("rect", { x: "8", y: "8", width: "12", height: "12", rx: "2" }),
|
|
901
|
+
/* @__PURE__ */ i("path", { d: "M4 14V6a2 2 0 0 1 2-2h8" })
|
|
902
|
+
] });
|
|
903
|
+
}
|
|
904
|
+
function Ln() {
|
|
905
|
+
return /* @__PURE__ */ i("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ i("path", { d: "M20 6 9 17l-5-5" }) });
|
|
906
|
+
}
|
|
907
|
+
function qn() {
|
|
908
|
+
return /* @__PURE__ */ i("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ i("path", { d: "m6 9 6 6 6-6" }) });
|
|
909
|
+
}
|
|
910
|
+
function ka() {
|
|
911
|
+
return /* @__PURE__ */ h("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
|
|
912
|
+
/* @__PURE__ */ i("path", { d: "M5 7h5" }),
|
|
913
|
+
/* @__PURE__ */ i("path", { d: "M14 7h5" }),
|
|
914
|
+
/* @__PURE__ */ i("path", { d: "M5 17h9" }),
|
|
915
|
+
/* @__PURE__ */ i("path", { d: "M18 17h1" }),
|
|
916
|
+
/* @__PURE__ */ i("circle", { cx: "12", cy: "7", r: "2" }),
|
|
917
|
+
/* @__PURE__ */ i("circle", { cx: "16", cy: "17", r: "2" })
|
|
918
|
+
] });
|
|
919
|
+
}
|
|
920
|
+
function Fe(e) {
|
|
921
|
+
const o = ((e.match(/,/g) ?? []).length === 1 && !e.includes(".") ? e.replace(",", ".") : e).replace(/[^\d.]/g, ""), [a = "", ...r] = o.split("."), c = r.length > 0 ? `${a}.${r.join("")}` : a;
|
|
922
|
+
return c === "." ? "0." : c;
|
|
584
923
|
}
|
|
585
|
-
function
|
|
586
|
-
const t =
|
|
924
|
+
function gn(e) {
|
|
925
|
+
const t = Fe(e);
|
|
587
926
|
if (!t) return "";
|
|
588
927
|
const n = Number(t);
|
|
589
928
|
return Number.isFinite(n) && n > 20 ? "20" : t;
|
|
590
929
|
}
|
|
591
|
-
function
|
|
930
|
+
function Fa(e, t) {
|
|
592
931
|
const n = e.trim();
|
|
593
932
|
if (!n || n === ".") return null;
|
|
594
933
|
try {
|
|
595
|
-
return
|
|
934
|
+
return Ro(n, t);
|
|
596
935
|
} catch {
|
|
597
936
|
return null;
|
|
598
937
|
}
|
|
599
938
|
}
|
|
600
|
-
function
|
|
939
|
+
function yn(e) {
|
|
601
940
|
const t = e.trim();
|
|
602
941
|
if (!t) return null;
|
|
603
942
|
const n = Number(t);
|
|
604
943
|
return !Number.isFinite(n) || n < 0 || n > 20 ? null : Math.round(n * 100);
|
|
605
944
|
}
|
|
606
|
-
function
|
|
607
|
-
if (e
|
|
608
|
-
const
|
|
609
|
-
if (
|
|
610
|
-
const
|
|
611
|
-
return
|
|
945
|
+
function Wn(e, t, n = "half-up") {
|
|
946
|
+
if (e === 0n || t <= 0) return e;
|
|
947
|
+
const o = e < 0n ? -1n : 1n, a = e < 0n ? -e : e, c = a.toString().length - t;
|
|
948
|
+
if (c <= 0) return e;
|
|
949
|
+
const s = 10n ** BigInt(c);
|
|
950
|
+
return (n === "floor" ? a / s * s : (a + s / 2n) / s * s) * o;
|
|
612
951
|
}
|
|
613
|
-
function
|
|
614
|
-
return e
|
|
952
|
+
function Pt(e) {
|
|
953
|
+
return e.includes(".") ? e.replace(/\.?0+$/, "") : e;
|
|
615
954
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
return `${e}|evm_${t}_${n.toLowerCase()}`;
|
|
955
|
+
function Le(e, t, n = 4) {
|
|
956
|
+
return e == null ? "--" : Pt(Nt(Wn(e, n), t));
|
|
619
957
|
}
|
|
620
|
-
function
|
|
621
|
-
return
|
|
958
|
+
function La(e, t, n = 4) {
|
|
959
|
+
return e == null ? "--" : Pt(
|
|
960
|
+
Nt(Wn(e, n, "floor"), t)
|
|
961
|
+
);
|
|
622
962
|
}
|
|
623
|
-
function
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
return
|
|
963
|
+
function bn(e, t) {
|
|
964
|
+
return e == null ? "" : Le(e, t);
|
|
965
|
+
}
|
|
966
|
+
function qa(e, t) {
|
|
967
|
+
return e == null ? "" : Pt(Nt(e, t));
|
|
968
|
+
}
|
|
969
|
+
const $n = "(prefers-color-scheme: light)";
|
|
970
|
+
function Wa() {
|
|
971
|
+
return typeof window > "u" || !window.matchMedia ? "dark" : window.matchMedia($n).matches ? "light" : "dark";
|
|
972
|
+
}
|
|
973
|
+
function $a(e) {
|
|
974
|
+
const t = e === "auto", [n, o] = A(Wa);
|
|
975
|
+
return Y(() => {
|
|
976
|
+
if (!t || typeof window > "u" || !window.matchMedia) return;
|
|
977
|
+
const a = window.matchMedia($n), r = () => o(a.matches ? "light" : "dark");
|
|
978
|
+
return r(), a.addEventListener("change", r), () => a.removeEventListener("change", r);
|
|
979
|
+
}, [t]), e === "light" ? "light" : e === "dark" ? "dark" : t ? n : "dark";
|
|
980
|
+
}
|
|
981
|
+
const Ka = typeof window > "u" ? Y : Po;
|
|
982
|
+
function za(e) {
|
|
983
|
+
if (typeof window > "u") return e;
|
|
984
|
+
let t = e.parentElement;
|
|
985
|
+
for (; t; ) {
|
|
986
|
+
const n = window.getComputedStyle(t), o = `${n.overflowY} ${n.overflow}`;
|
|
987
|
+
if (/(auto|scroll|overlay)/.test(o) && t.scrollHeight > t.clientHeight)
|
|
988
|
+
return t;
|
|
989
|
+
t = t.parentElement;
|
|
990
|
+
}
|
|
991
|
+
return window;
|
|
628
992
|
}
|
|
629
|
-
function
|
|
630
|
-
|
|
631
|
-
|
|
993
|
+
function Ga(e, t) {
|
|
994
|
+
if (typeof window < "u" && e === window) {
|
|
995
|
+
window.scrollBy(0, t);
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
const n = e;
|
|
999
|
+
n.scrollTop += t;
|
|
632
1000
|
}
|
|
633
|
-
function
|
|
634
|
-
|
|
1001
|
+
function Va(e) {
|
|
1002
|
+
const t = te(null), n = te(null), o = te(null), a = () => {
|
|
1003
|
+
const r = t.current;
|
|
1004
|
+
n.current = (r == null ? void 0 : r.getBoundingClientRect().top) ?? null, o.current = r ? za(r) : null;
|
|
1005
|
+
};
|
|
1006
|
+
return Ka(() => {
|
|
1007
|
+
const r = n.current, c = t.current;
|
|
1008
|
+
if (r === null || !c) return;
|
|
1009
|
+
n.current = null;
|
|
1010
|
+
const s = o.current ?? window;
|
|
1011
|
+
o.current = null;
|
|
1012
|
+
const u = c.getBoundingClientRect().top - r;
|
|
1013
|
+
Math.abs(u) > 0.5 && Ga(s, u);
|
|
1014
|
+
}, [e]), { toggleRef: t, captureAnchor: a };
|
|
1015
|
+
}
|
|
1016
|
+
function ja(e, t) {
|
|
1017
|
+
return St(e, t, /* @__PURE__ */ new WeakSet());
|
|
1018
|
+
}
|
|
1019
|
+
function St(e, t, n) {
|
|
1020
|
+
if (e === t) return !0;
|
|
1021
|
+
if (typeof e != typeof t || typeof e != "object" || e === null || t === null || n.has(e)) return !1;
|
|
1022
|
+
n.add(e);
|
|
1023
|
+
try {
|
|
1024
|
+
if (Array.isArray(e))
|
|
1025
|
+
return !Array.isArray(t) || e.length !== t.length ? !1 : e.every((c, s) => St(c, t[s], n));
|
|
1026
|
+
if (Array.isArray(t)) return !1;
|
|
1027
|
+
const o = e, a = t, r = Object.keys(o);
|
|
1028
|
+
return r.length !== Object.keys(a).length ? !1 : r.every(
|
|
1029
|
+
(c) => Object.prototype.hasOwnProperty.call(a, c) && St(o[c], a[c], n)
|
|
1030
|
+
);
|
|
1031
|
+
} finally {
|
|
1032
|
+
n.delete(e);
|
|
1033
|
+
}
|
|
635
1034
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
const
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
signal: e.signal
|
|
656
|
-
});
|
|
657
|
-
if (!s.ok)
|
|
658
|
-
throw new Error(`Token metadata request failed with HTTP ${s.status}.`);
|
|
659
|
-
const p = await s.json();
|
|
660
|
-
if ((N = p.errors) != null && N.length)
|
|
661
|
-
throw new Error(((v = p.errors[0]) == null ? void 0 : v.message) ?? "Token metadata request failed.");
|
|
662
|
-
return i.forEach((m, D) => {
|
|
663
|
-
var B;
|
|
664
|
-
const A = ((B = p.data) == null ? void 0 : B[`t${D}`]) ?? null;
|
|
665
|
-
Ve.set(xt(t, e.chainId, m), A), A && a.set(m.toLowerCase(), A);
|
|
666
|
-
}), a;
|
|
667
|
-
}
|
|
668
|
-
const Tt = 2n ** 160n - 1n, Jn = 2n ** 256n - 1n, ea = 1800, ta = 1800, na = 60, aa = {
|
|
1035
|
+
function ge(e) {
|
|
1036
|
+
const t = te(e);
|
|
1037
|
+
return ja(t.current, e) || (t.current = e), t.current;
|
|
1038
|
+
}
|
|
1039
|
+
function Kn(e) {
|
|
1040
|
+
for (let n = e; n && typeof n == "object"; n = n.cause)
|
|
1041
|
+
if (n.code === 4001) return !0;
|
|
1042
|
+
const t = e instanceof Error ? e.message.toLowerCase() : "";
|
|
1043
|
+
return t.includes("user rejected") || t.includes("user denied") || t.includes("rejected the request") || t.includes("request rejected");
|
|
1044
|
+
}
|
|
1045
|
+
function Ee(e, t) {
|
|
1046
|
+
if (Kn(e))
|
|
1047
|
+
return "Request rejected.";
|
|
1048
|
+
const n = e instanceof Error ? e.message : "";
|
|
1049
|
+
if (!n) return t;
|
|
1050
|
+
const o = n.toLowerCase();
|
|
1051
|
+
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;
|
|
1052
|
+
}
|
|
1053
|
+
const nt = 2n ** 160n - 1n, Qa = 2n ** 256n - 1n, Dt = 600, Ha = 1800, zn = 1800, Xa = Dt, Ya = 2 ** 48 - 1, Za = {
|
|
669
1054
|
PermitBatch: [
|
|
670
1055
|
{ name: "details", type: "PermitDetails[]" },
|
|
671
1056
|
{ name: "spender", type: "address" },
|
|
@@ -678,44 +1063,69 @@ const Tt = 2n ** 160n - 1n, Jn = 2n ** 256n - 1n, ea = 1800, ta = 1800, na = 60,
|
|
|
678
1063
|
{ name: "nonce", type: "uint48" }
|
|
679
1064
|
]
|
|
680
1065
|
};
|
|
681
|
-
async function
|
|
682
|
-
const n =
|
|
1066
|
+
async function Ja(e) {
|
|
1067
|
+
const t = e.amount ?? Qa, n = at({
|
|
683
1068
|
account: e.account,
|
|
684
1069
|
chain: e.chain,
|
|
685
|
-
transport:
|
|
686
|
-
}).
|
|
1070
|
+
transport: rt(e.provider)
|
|
1071
|
+
}), { request: o } = await e.publicClient.simulateContract({
|
|
687
1072
|
address: e.token,
|
|
688
|
-
abi:
|
|
1073
|
+
abi: Tt,
|
|
1074
|
+
functionName: "approve",
|
|
1075
|
+
args: [e.permit2, t],
|
|
1076
|
+
account: e.account
|
|
1077
|
+
}), a = await n.writeContract({
|
|
1078
|
+
...o,
|
|
1079
|
+
chain: e.chain
|
|
1080
|
+
});
|
|
1081
|
+
if ((await e.publicClient.waitForTransactionReceipt({ hash: a })).status === "reverted") throw new Error("Token approval reverted.");
|
|
1082
|
+
return a;
|
|
1083
|
+
}
|
|
1084
|
+
async function er(e) {
|
|
1085
|
+
const t = e.amount && e.amount < nt ? e.amount : nt, n = e.expiration ?? Ya, o = at({
|
|
1086
|
+
account: e.account,
|
|
1087
|
+
chain: e.chain,
|
|
1088
|
+
transport: rt(e.provider)
|
|
1089
|
+
}), { request: a } = await e.publicClient.simulateContract({
|
|
1090
|
+
address: e.permit2,
|
|
1091
|
+
abi: xn,
|
|
689
1092
|
functionName: "approve",
|
|
690
|
-
args: [e.
|
|
1093
|
+
args: [e.token, e.router, t, n],
|
|
1094
|
+
account: e.account
|
|
1095
|
+
}), r = await o.writeContract({
|
|
1096
|
+
...a,
|
|
1097
|
+
chain: e.chain
|
|
691
1098
|
});
|
|
692
|
-
if ((await e.publicClient.waitForTransactionReceipt({ hash:
|
|
693
|
-
return
|
|
1099
|
+
if ((await e.publicClient.waitForTransactionReceipt({ hash: r })).status === "reverted") throw new Error("Permit2 approval reverted.");
|
|
1100
|
+
return r;
|
|
694
1101
|
}
|
|
695
|
-
|
|
696
|
-
|
|
1102
|
+
function Rt(e) {
|
|
1103
|
+
return e.publicClient.readContract({
|
|
697
1104
|
address: e.permit2,
|
|
698
|
-
abi:
|
|
1105
|
+
abi: xn,
|
|
699
1106
|
functionName: "allowance",
|
|
700
1107
|
args: [e.account, e.token, e.router]
|
|
701
|
-
})
|
|
702
|
-
|
|
1108
|
+
});
|
|
1109
|
+
}
|
|
1110
|
+
async function tr(e) {
|
|
1111
|
+
const [t, n, o] = await (e.allowanceRead ?? Rt(e)), a = Math.floor(Date.now() / 1e3);
|
|
1112
|
+
if (t >= e.amount && Number(n) > a + Xa)
|
|
703
1113
|
return null;
|
|
704
|
-
const
|
|
1114
|
+
const r = {
|
|
705
1115
|
details: [
|
|
706
1116
|
{
|
|
707
1117
|
token: e.token,
|
|
708
|
-
amount: e.amount >
|
|
709
|
-
expiration:
|
|
710
|
-
nonce: Number(
|
|
1118
|
+
amount: e.amount > nt ? nt : e.amount,
|
|
1119
|
+
expiration: a + zn,
|
|
1120
|
+
nonce: Number(o)
|
|
711
1121
|
}
|
|
712
1122
|
],
|
|
713
1123
|
spender: e.router,
|
|
714
|
-
sigDeadline: BigInt(
|
|
715
|
-
},
|
|
1124
|
+
sigDeadline: BigInt(a + Ha)
|
|
1125
|
+
}, s = await at({
|
|
716
1126
|
account: e.account,
|
|
717
1127
|
chain: e.chain,
|
|
718
|
-
transport:
|
|
1128
|
+
transport: rt(e.provider)
|
|
719
1129
|
}).signTypedData({
|
|
720
1130
|
account: e.account,
|
|
721
1131
|
domain: {
|
|
@@ -723,869 +1133,1868 @@ async function ra(e) {
|
|
|
723
1133
|
chainId: e.chainId,
|
|
724
1134
|
verifyingContract: e.permit2
|
|
725
1135
|
},
|
|
726
|
-
types:
|
|
1136
|
+
types: Za,
|
|
727
1137
|
primaryType: "PermitBatch",
|
|
728
|
-
message:
|
|
1138
|
+
message: r
|
|
729
1139
|
});
|
|
730
1140
|
return {
|
|
731
1141
|
owner: e.account,
|
|
732
|
-
permitBatch:
|
|
733
|
-
signature:
|
|
1142
|
+
permitBatch: r,
|
|
1143
|
+
signature: s
|
|
734
1144
|
};
|
|
735
1145
|
}
|
|
736
|
-
|
|
737
|
-
function H(e, t) {
|
|
738
|
-
return e.toLowerCase() === t.toLowerCase();
|
|
739
|
-
}
|
|
740
|
-
function Kt(e) {
|
|
1146
|
+
function Gn(e) {
|
|
741
1147
|
if (!Number.isFinite(e) || e < 0 || e > 2e3)
|
|
742
1148
|
throw new Error("Slippage must be between 0% and 20%.");
|
|
743
1149
|
}
|
|
744
|
-
function
|
|
745
|
-
return
|
|
1150
|
+
function nr(e, t) {
|
|
1151
|
+
return Gn(t), e * BigInt(1e4 - Math.round(t)) / 10000n;
|
|
746
1152
|
}
|
|
747
|
-
function
|
|
748
|
-
return
|
|
1153
|
+
function or(e, t) {
|
|
1154
|
+
return Gn(t), (e * BigInt(1e4 + Math.round(t)) + 9999n) / 10000n;
|
|
749
1155
|
}
|
|
750
|
-
function
|
|
1156
|
+
function ar(e, t) {
|
|
751
1157
|
return t <= 0 ? 0n : e * BigInt(t) / 10000n;
|
|
752
1158
|
}
|
|
753
|
-
function
|
|
1159
|
+
function rr(e, t) {
|
|
754
1160
|
return t <= 0 ? e : (e * 10000n + BigInt(1e4 - t - 1)) / BigInt(1e4 - t);
|
|
755
1161
|
}
|
|
756
|
-
function
|
|
757
|
-
if (
|
|
758
|
-
|
|
1162
|
+
function ir(e, t) {
|
|
1163
|
+
if (t <= 0) return e;
|
|
1164
|
+
const n = BigInt(1e4 - t);
|
|
1165
|
+
return (e * 10000n + n - 1n) / n;
|
|
1166
|
+
}
|
|
1167
|
+
function et(e) {
|
|
1168
|
+
return qe(e), e;
|
|
1169
|
+
}
|
|
1170
|
+
function cr(e, t) {
|
|
1171
|
+
if (G(t.address, e.currency0)) return !0;
|
|
1172
|
+
if (G(t.address, e.currency1)) return !1;
|
|
759
1173
|
throw new Error("Input token is not part of this pool.");
|
|
760
1174
|
}
|
|
761
|
-
function
|
|
762
|
-
|
|
1175
|
+
function sr(e, t, n) {
|
|
1176
|
+
const o = On(e.poolKey);
|
|
1177
|
+
if (!Sn(o, e.poolId))
|
|
763
1178
|
throw new Error("Configured pool id does not match the pool key.");
|
|
764
|
-
const
|
|
765
|
-
if (!
|
|
1179
|
+
const a = G(t.address, e.poolKey.currency0) || G(t.address, e.poolKey.currency1), r = G(n.address, e.poolKey.currency0) || G(n.address, e.poolKey.currency1);
|
|
1180
|
+
if (!a || !r || G(t.address, n.address))
|
|
766
1181
|
throw new Error("Selected tokens do not match this direct pool.");
|
|
767
1182
|
}
|
|
768
|
-
function
|
|
769
|
-
if (Array.isArray(e))
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
1183
|
+
function ur(e, t) {
|
|
1184
|
+
if (Array.isArray(e)) {
|
|
1185
|
+
const a = e[0], r = e[1];
|
|
1186
|
+
if (typeof a == "bigint" && typeof r == "bigint")
|
|
1187
|
+
return { amount: a, gasEstimate: r };
|
|
1188
|
+
throw new Error("Unexpected V4 Quoter response.");
|
|
1189
|
+
}
|
|
1190
|
+
const n = e, o = n[t];
|
|
1191
|
+
if (typeof o == "bigint" && typeof n.gasEstimate == "bigint")
|
|
1192
|
+
return { amount: o, gasEstimate: n.gasEstimate };
|
|
774
1193
|
throw new Error("Unexpected V4 Quoter response.");
|
|
775
1194
|
}
|
|
776
|
-
async function
|
|
777
|
-
var
|
|
778
|
-
if ((
|
|
1195
|
+
async function Vn(e) {
|
|
1196
|
+
var f, v, p, w;
|
|
1197
|
+
if ((f = e.signal) != null && f.aborted) throw new DOMException("Quote request aborted", "AbortError");
|
|
779
1198
|
if (e.amount <= 0n) throw new Error("Enter an amount to swap.");
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
if (!Number.isInteger(a) || a < 0 || a >= 1e4)
|
|
1199
|
+
et(e.amount), sr(e.market, e.tokenIn, e.tokenOut);
|
|
1200
|
+
const t = e.market.poolKey, n = cr(t, e.tokenIn), o = ((v = e.fee) == null ? void 0 : v.bps) ?? 0;
|
|
1201
|
+
if (!Number.isInteger(o) || o < 0 || o >= 1e4)
|
|
784
1202
|
throw new Error("Fee must be an integer between 0 and 9999 bps.");
|
|
785
|
-
const
|
|
1203
|
+
const a = e.mode === "exactOut" ? et(rr(e.amount, o)) : e.amount, r = e.mode === "exactOut" ? await e.publicClient.simulateContract({
|
|
786
1204
|
address: e.market.quoter,
|
|
787
|
-
abi:
|
|
1205
|
+
abi: rn,
|
|
788
1206
|
functionName: "quoteExactOutputSingle",
|
|
789
|
-
args: [{ poolKey: t, zeroForOne: n, exactAmount:
|
|
1207
|
+
args: [{ poolKey: t, zeroForOne: n, exactAmount: a, hookData: "0x" }],
|
|
790
1208
|
account: e.account
|
|
791
1209
|
}) : await e.publicClient.simulateContract({
|
|
792
1210
|
address: e.market.quoter,
|
|
793
|
-
abi:
|
|
1211
|
+
abi: rn,
|
|
794
1212
|
functionName: "quoteExactInputSingle",
|
|
795
1213
|
args: [{ poolKey: t, zeroForOne: n, exactAmount: e.amount, hookData: "0x" }],
|
|
796
1214
|
account: e.account
|
|
797
1215
|
});
|
|
798
|
-
if ((
|
|
799
|
-
const
|
|
800
|
-
|
|
1216
|
+
if ((p = e.signal) != null && p.aborted) throw new DOMException("Quote request aborted", "AbortError");
|
|
1217
|
+
const c = ur(
|
|
1218
|
+
r.result,
|
|
801
1219
|
e.mode === "exactOut" ? "amountIn" : "amountOut"
|
|
802
|
-
),
|
|
1220
|
+
), s = e.mode === "exactOut" ? c.amount : e.amount, l = e.mode === "exactOut" ? a : c.amount, u = e.mode === "exactOut" ? l - e.amount : ar(l, o), d = l - u, m = e.mode === "exactOut" ? d : nr(d, e.slippageBps);
|
|
803
1221
|
return {
|
|
804
1222
|
mode: e.mode,
|
|
805
1223
|
poolKey: t,
|
|
806
1224
|
zeroForOne: n,
|
|
807
|
-
amountIn:
|
|
808
|
-
amountOut:
|
|
809
|
-
grossAmountOut:
|
|
810
|
-
amountOutMinimum: e.mode === "exactOut" ?
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
feeAmount:
|
|
814
|
-
|
|
815
|
-
|
|
1225
|
+
amountIn: s,
|
|
1226
|
+
amountOut: d,
|
|
1227
|
+
grossAmountOut: l,
|
|
1228
|
+
amountOutMinimum: e.mode === "exactOut" ? l : et(ir(m, o)),
|
|
1229
|
+
amountInMaximum: e.mode === "exactOut" ? et(or(s, e.slippageBps)) : s,
|
|
1230
|
+
userAmountOutMinimum: m,
|
|
1231
|
+
feeAmount: u,
|
|
1232
|
+
feeBps: o,
|
|
1233
|
+
feeRecipient: o > 0 ? ((w = e.fee) == null ? void 0 : w.recipient) ?? null : null,
|
|
1234
|
+
gasEstimate: c.gasEstimate
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
function jn(e, t) {
|
|
1238
|
+
return e.mode === t.mode && e.zeroForOne === t.zeroForOne && G(e.poolKey.currency0, t.poolKey.currency0) && G(e.poolKey.currency1, t.poolKey.currency1) && e.poolKey.fee === t.poolKey.fee && e.poolKey.tickSpacing === t.poolKey.tickSpacing && G(e.poolKey.hooks, t.poolKey.hooks) && e.feeBps === t.feeBps && qo(e.feeRecipient, t.feeRecipient);
|
|
1239
|
+
}
|
|
1240
|
+
function lr(e, t) {
|
|
1241
|
+
return jn(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;
|
|
1242
|
+
}
|
|
1243
|
+
function dr(e, t) {
|
|
1244
|
+
return !e || !jn(e, t) ? { quote: t, priceMovedBeyondTolerance: !1 } : t.mode === "exactIn" ? t.amountOut < e.userAmountOutMinimum ? { quote: t, priceMovedBeyondTolerance: !0 } : {
|
|
1245
|
+
quote: {
|
|
1246
|
+
...t,
|
|
1247
|
+
amountOutMinimum: t.amountOutMinimum > e.amountOutMinimum ? t.amountOutMinimum : e.amountOutMinimum,
|
|
1248
|
+
userAmountOutMinimum: t.userAmountOutMinimum > e.userAmountOutMinimum ? t.userAmountOutMinimum : e.userAmountOutMinimum
|
|
1249
|
+
},
|
|
1250
|
+
priceMovedBeyondTolerance: !1
|
|
1251
|
+
} : t.amountIn > e.amountInMaximum ? { quote: t, priceMovedBeyondTolerance: !0 } : {
|
|
1252
|
+
quote: {
|
|
1253
|
+
...t,
|
|
1254
|
+
amountInMaximum: t.amountInMaximum < e.amountInMaximum ? t.amountInMaximum : e.amountInMaximum
|
|
1255
|
+
},
|
|
1256
|
+
priceMovedBeyondTolerance: !1
|
|
1257
|
+
};
|
|
1258
|
+
}
|
|
1259
|
+
function xt(e) {
|
|
1260
|
+
return e.mode === "exactOut" ? e.amountInMaximum : e.amountIn;
|
|
1261
|
+
}
|
|
1262
|
+
function pr(e) {
|
|
1263
|
+
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;
|
|
1264
|
+
}
|
|
1265
|
+
function ot() {
|
|
1266
|
+
return typeof document > "u" ? !0 : document.visibilityState !== "hidden";
|
|
1267
|
+
}
|
|
1268
|
+
async function Qn(e, t, n, o) {
|
|
1269
|
+
let a = await e();
|
|
1270
|
+
for (let r = 1; r < n && !t(a); r += 1)
|
|
1271
|
+
await new Promise((c) => setTimeout(c, o)), a = await e();
|
|
1272
|
+
return a;
|
|
1273
|
+
}
|
|
1274
|
+
function mr(e) {
|
|
1275
|
+
return e === "approving" || e === "signing" || e === "submitting";
|
|
1276
|
+
}
|
|
1277
|
+
function fr({
|
|
1278
|
+
status: e,
|
|
1279
|
+
inputSymbol: t,
|
|
1280
|
+
txHash: n,
|
|
1281
|
+
actionError: o,
|
|
1282
|
+
approvalRequired: a,
|
|
1283
|
+
approvalDone: r
|
|
1284
|
+
}) {
|
|
1285
|
+
return o ? {
|
|
1286
|
+
state: "error",
|
|
1287
|
+
label: o,
|
|
1288
|
+
completePct: 100,
|
|
1289
|
+
activeWidthPct: 0
|
|
1290
|
+
} : e === "success" ? {
|
|
1291
|
+
state: "success",
|
|
1292
|
+
label: "Swap confirmed",
|
|
1293
|
+
completePct: 100,
|
|
1294
|
+
activeWidthPct: 0
|
|
1295
|
+
} : e === "idle" ? r ? {
|
|
1296
|
+
state: "pending",
|
|
1297
|
+
label: "ERC20 approval complete · ready to swap · 1 of 2 done",
|
|
1298
|
+
completePct: 50,
|
|
1299
|
+
activeWidthPct: 0
|
|
1300
|
+
} : null : e === "approving" ? {
|
|
1301
|
+
state: "pending",
|
|
1302
|
+
label: `Approving ${t} for Permit2 · step 1 of 2`,
|
|
1303
|
+
completePct: 0,
|
|
1304
|
+
activeWidthPct: 50
|
|
1305
|
+
} : a || r ? {
|
|
1306
|
+
state: e === "submitting" && n ? "mining" : "pending",
|
|
1307
|
+
label: e === "signing" ? "ERC20 approval complete · sign Permit2 permit · step 2 of 2" : n ? "Approve complete · confirming swap · step 2 of 2" : "Approve complete · submitting swap · step 2 of 2",
|
|
1308
|
+
completePct: 50,
|
|
1309
|
+
activeWidthPct: 50
|
|
1310
|
+
} : {
|
|
1311
|
+
state: e === "submitting" && n ? "mining" : "pending",
|
|
1312
|
+
label: e === "signing" ? "Signing Permit2 spending permit" : n ? "Confirming swap on-chain" : "Submitting swap",
|
|
1313
|
+
completePct: 0,
|
|
1314
|
+
activeWidthPct: 100
|
|
816
1315
|
};
|
|
817
1316
|
}
|
|
818
|
-
function
|
|
1317
|
+
function vt() {
|
|
819
1318
|
return typeof window > "u" ? null : window.ethereum ?? null;
|
|
820
1319
|
}
|
|
821
|
-
function
|
|
822
|
-
return typeof e != "string" || !
|
|
1320
|
+
function st(e) {
|
|
1321
|
+
return typeof e != "string" || !Fo(e) ? null : F(e);
|
|
1322
|
+
}
|
|
1323
|
+
function hr(e) {
|
|
1324
|
+
return !!(e && typeof e == "object" && typeof e.request == "function");
|
|
1325
|
+
}
|
|
1326
|
+
function wr(e) {
|
|
1327
|
+
return hr(e) ? { provider: e, account: null } : !e || typeof e != "object" ? { provider: null, account: null } : {
|
|
1328
|
+
provider: e.provider ?? null,
|
|
1329
|
+
account: st(e.account)
|
|
1330
|
+
};
|
|
823
1331
|
}
|
|
824
|
-
async function
|
|
1332
|
+
async function gr(e) {
|
|
825
1333
|
const t = await e.request({ method: "eth_accounts" });
|
|
826
|
-
return
|
|
1334
|
+
return st(t == null ? void 0 : t[0]);
|
|
827
1335
|
}
|
|
828
|
-
async function
|
|
1336
|
+
async function yr(e) {
|
|
829
1337
|
const t = await e.request({ method: "eth_requestAccounts" });
|
|
830
|
-
return
|
|
1338
|
+
return st(t == null ? void 0 : t[0]);
|
|
831
1339
|
}
|
|
832
|
-
async function
|
|
1340
|
+
async function We(e) {
|
|
833
1341
|
const t = await e.request({ method: "eth_chainId" });
|
|
834
|
-
|
|
1342
|
+
if (typeof t != "string" || !/^0x[0-9a-f]+$/i.test(t)) return null;
|
|
1343
|
+
const n = Number.parseInt(t, 16);
|
|
1344
|
+
return Number.isSafeInteger(n) ? n : null;
|
|
1345
|
+
}
|
|
1346
|
+
function br(e) {
|
|
1347
|
+
return `0x${e.toString(16)}`;
|
|
835
1348
|
}
|
|
836
|
-
|
|
1349
|
+
function _r(e) {
|
|
1350
|
+
const t = e, n = [t.message, t.shortMessage, t.details].filter((o) => typeof o == "string").join(" ").toLowerCase();
|
|
1351
|
+
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");
|
|
1352
|
+
}
|
|
1353
|
+
function Ir(e) {
|
|
1354
|
+
return typeof e == "number" ? { chainId: e } : e;
|
|
1355
|
+
}
|
|
1356
|
+
function Ar(e) {
|
|
1357
|
+
var t, n;
|
|
1358
|
+
return (t = e.rpcUrls) != null && t.length ? e.rpcUrls : ((n = e.chain) == null ? void 0 : n.rpcUrls.default.http) ?? [];
|
|
1359
|
+
}
|
|
1360
|
+
function vr(e) {
|
|
1361
|
+
var n, o;
|
|
1362
|
+
const t = (o = (n = e.chain) == null ? void 0 : n.blockExplorers) == null ? void 0 : o.default.url;
|
|
1363
|
+
return t ? [t] : [];
|
|
1364
|
+
}
|
|
1365
|
+
async function Er(e, t) {
|
|
1366
|
+
var r, c;
|
|
1367
|
+
const n = Ir(t), o = br(n.chainId), a = {
|
|
1368
|
+
method: "wallet_switchEthereumChain",
|
|
1369
|
+
params: [{ chainId: o }]
|
|
1370
|
+
};
|
|
1371
|
+
try {
|
|
1372
|
+
await e.request(a);
|
|
1373
|
+
return;
|
|
1374
|
+
} catch (s) {
|
|
1375
|
+
if (!_r(s)) throw s;
|
|
1376
|
+
const l = Ar(n);
|
|
1377
|
+
if (l.length === 0) throw s;
|
|
1378
|
+
const u = vr(n);
|
|
1379
|
+
await e.request({
|
|
1380
|
+
method: "wallet_addEthereumChain",
|
|
1381
|
+
params: [
|
|
1382
|
+
{
|
|
1383
|
+
chainId: o,
|
|
1384
|
+
chainName: n.name ?? ((r = n.chain) == null ? void 0 : r.name) ?? `Chain ${n.chainId}`,
|
|
1385
|
+
nativeCurrency: ((c = n.chain) == null ? void 0 : c.nativeCurrency) ?? {
|
|
1386
|
+
name: "Ether",
|
|
1387
|
+
symbol: "ETH",
|
|
1388
|
+
decimals: 18
|
|
1389
|
+
},
|
|
1390
|
+
rpcUrls: l,
|
|
1391
|
+
...u.length ? { blockExplorerUrls: u } : {}
|
|
1392
|
+
}
|
|
1393
|
+
]
|
|
1394
|
+
});
|
|
1395
|
+
}
|
|
837
1396
|
await e.request({
|
|
838
1397
|
method: "wallet_switchEthereumChain",
|
|
839
|
-
params: [{ chainId:
|
|
1398
|
+
params: [{ chainId: o }]
|
|
840
1399
|
});
|
|
841
1400
|
}
|
|
842
|
-
function
|
|
843
|
-
const n = e;
|
|
844
|
-
if (!n.on || !n.removeListener) return () => {
|
|
845
|
-
};
|
|
846
|
-
const a = () => {
|
|
847
|
-
var s;
|
|
848
|
-
return (s = t.onAccountsChanged) == null ? void 0 : s.call(t);
|
|
849
|
-
}, i = () => {
|
|
850
|
-
var s;
|
|
851
|
-
return (s = t.onChainChanged) == null ? void 0 : s.call(t);
|
|
852
|
-
};
|
|
853
|
-
return n.on("accountsChanged", a), n.on("chainChanged", i), () => {
|
|
854
|
-
var s, p;
|
|
855
|
-
(s = n.removeListener) == null || s.call(n, "accountsChanged", a), (p = n.removeListener) == null || p.call(n, "chainChanged", i);
|
|
856
|
-
};
|
|
857
|
-
}
|
|
858
|
-
const _a = 250, ga = 5e3;
|
|
859
|
-
function Ea(e, t) {
|
|
1401
|
+
function Sr(e, t) {
|
|
860
1402
|
const n = t.map(
|
|
861
|
-
(
|
|
1403
|
+
(o) => Bo(o, {
|
|
862
1404
|
batch: !0,
|
|
863
1405
|
retryCount: 2,
|
|
864
1406
|
retryDelay: 150,
|
|
865
1407
|
timeout: 1e4
|
|
866
1408
|
})
|
|
867
1409
|
);
|
|
868
|
-
return
|
|
1410
|
+
return Uo({
|
|
869
1411
|
chain: e,
|
|
870
|
-
transport: n.length === 1 ? n[0] :
|
|
871
|
-
});
|
|
872
|
-
}
|
|
873
|
-
function Te(e, t, n) {
|
|
874
|
-
return e.readContract({
|
|
875
|
-
address: t.address,
|
|
876
|
-
abi: Je,
|
|
877
|
-
functionName: "balanceOf",
|
|
878
|
-
args: [n]
|
|
1412
|
+
transport: n.length === 1 ? n[0] : ko(n)
|
|
879
1413
|
});
|
|
880
1414
|
}
|
|
881
|
-
function
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
return h(e);
|
|
885
|
-
} catch {
|
|
886
|
-
return null;
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
function Aa(e) {
|
|
890
|
-
return !!(e && typeof e == "object" && typeof e.request == "function");
|
|
891
|
-
}
|
|
892
|
-
function Ia(e) {
|
|
893
|
-
return Aa(e) ? { provider: e, account: null } : !e || typeof e != "object" ? { provider: null, account: null } : {
|
|
894
|
-
provider: e.provider ?? null,
|
|
895
|
-
account: Vt(e.account)
|
|
1415
|
+
function xr(e, t) {
|
|
1416
|
+
const n = e;
|
|
1417
|
+
if (!n.on || !n.removeListener) return () => {
|
|
896
1418
|
};
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
}
|
|
908
|
-
function Sa(e, t) {
|
|
909
|
-
return e[t] ?? null;
|
|
910
|
-
}
|
|
911
|
-
function ie(e) {
|
|
912
|
-
return e === "approving" || e === "signing" || e === "submitting";
|
|
913
|
-
}
|
|
914
|
-
function Ca(e) {
|
|
915
|
-
return e === "light" ? "light" : "dark";
|
|
916
|
-
}
|
|
917
|
-
function xa(e) {
|
|
918
|
-
return e !== C ? null : {
|
|
919
|
-
bps: Nn,
|
|
920
|
-
recipient: Dn
|
|
1419
|
+
const o = () => {
|
|
1420
|
+
var r;
|
|
1421
|
+
return (r = t.onAccountsChanged) == null ? void 0 : r.call(t);
|
|
1422
|
+
}, a = () => {
|
|
1423
|
+
var r;
|
|
1424
|
+
return (r = t.onChainChanged) == null ? void 0 : r.call(t);
|
|
1425
|
+
};
|
|
1426
|
+
return n.on("accountsChanged", o), n.on("chainChanged", a), () => {
|
|
1427
|
+
var r, c;
|
|
1428
|
+
(r = n.removeListener) == null || r.call(n, "accountsChanged", o), (c = n.removeListener) == null || c.call(n, "chainChanged", a);
|
|
921
1429
|
};
|
|
922
1430
|
}
|
|
923
|
-
function
|
|
924
|
-
return
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
1431
|
+
async function Cr(e, t) {
|
|
1432
|
+
return await Qn(
|
|
1433
|
+
() => We(e),
|
|
1434
|
+
(o) => o === t,
|
|
1435
|
+
12,
|
|
1436
|
+
250
|
|
1437
|
+
) === t;
|
|
1438
|
+
}
|
|
1439
|
+
function Nr(e, t) {
|
|
1440
|
+
return Qn(e, (n) => n >= t, 5, 300);
|
|
1441
|
+
}
|
|
1442
|
+
function Tr({
|
|
1443
|
+
publicClient: e,
|
|
1444
|
+
activeChain: t,
|
|
1445
|
+
market: n,
|
|
1446
|
+
inputToken: o,
|
|
1447
|
+
outputToken: a,
|
|
1448
|
+
quoteMode: r,
|
|
1449
|
+
activeAmount: c,
|
|
1450
|
+
slippageBps: s,
|
|
1451
|
+
feeConfig: l,
|
|
1452
|
+
quote: u,
|
|
1453
|
+
setQuote: d,
|
|
1454
|
+
owner: m,
|
|
1455
|
+
getActiveProvider: f,
|
|
1456
|
+
connectWallet: v,
|
|
1457
|
+
setWalletChainId: p,
|
|
1458
|
+
readAllowance: w,
|
|
1459
|
+
commitAllowance: b,
|
|
1460
|
+
approvalMode: E,
|
|
1461
|
+
refreshBalances: U,
|
|
1462
|
+
onSubmitted: L,
|
|
1463
|
+
onSuccess: q,
|
|
1464
|
+
onError: N
|
|
1465
|
+
}) {
|
|
1466
|
+
const [_, I] = A("idle"), [V, D] = A(null), [z, T] = A(null), [j, S] = A({
|
|
1467
|
+
required: !1,
|
|
1468
|
+
done: !1
|
|
1469
|
+
}), R = P(() => {
|
|
1470
|
+
I("idle"), D(null), T(null), S({ required: !1, done: !1 });
|
|
1471
|
+
}, []), Z = P(async () => {
|
|
1472
|
+
let g = await f(), x = m;
|
|
1473
|
+
if (!g || !x) {
|
|
1474
|
+
const M = await v();
|
|
1475
|
+
g = (M == null ? void 0 : M.provider) ?? g, x = x ?? (M == null ? void 0 : M.account) ?? null;
|
|
1476
|
+
}
|
|
1477
|
+
if (!g)
|
|
1478
|
+
return T("No wallet provider found."), null;
|
|
1479
|
+
if (!x)
|
|
1480
|
+
return T("Wallet connection was not completed."), null;
|
|
1481
|
+
const W = await We(g);
|
|
1482
|
+
if (p(W), W !== t.chainId) {
|
|
1483
|
+
await Er(g, t);
|
|
1484
|
+
const M = await Cr(g, t.chainId);
|
|
1485
|
+
if (p(M ? t.chainId : await We(g)), !M)
|
|
1486
|
+
return T("Network switch did not complete. Switch to the correct network and try again."), null;
|
|
1487
|
+
}
|
|
1488
|
+
return { provider: g, account: x };
|
|
1489
|
+
}, [t, v, f, m, p]), re = P(
|
|
1490
|
+
async (g, x) => {
|
|
1491
|
+
if (!n || s === null || !c || c <= 0n) {
|
|
1492
|
+
T("Enter a valid amount and slippage, then try again."), I("idle");
|
|
1493
|
+
return;
|
|
1494
|
+
}
|
|
1495
|
+
const W = x !== void 0 ? Promise.resolve(x) : w(g.account, n).catch(() => null), M = Rt({
|
|
1496
|
+
publicClient: e,
|
|
1497
|
+
permit2: n.permit2,
|
|
1498
|
+
account: g.account,
|
|
1499
|
+
token: o.address,
|
|
1500
|
+
router: n.router
|
|
1501
|
+
});
|
|
1502
|
+
M.catch(() => {
|
|
1503
|
+
});
|
|
1504
|
+
let O;
|
|
1505
|
+
try {
|
|
1506
|
+
const C = await Vn({
|
|
1507
|
+
publicClient: e,
|
|
1508
|
+
account: g.account,
|
|
1509
|
+
market: n,
|
|
1510
|
+
tokenIn: o,
|
|
1511
|
+
tokenOut: a,
|
|
1512
|
+
mode: r,
|
|
1513
|
+
amount: c,
|
|
1514
|
+
slippageBps: s,
|
|
1515
|
+
fee: l
|
|
1516
|
+
}), Te = dr(u, C);
|
|
1517
|
+
if (Te.priceMovedBeyondTolerance) {
|
|
1518
|
+
d(C), T(
|
|
1519
|
+
"Price moved beyond your slippage tolerance. Review the updated quote and try again."
|
|
1520
|
+
), I("idle");
|
|
1521
|
+
return;
|
|
1522
|
+
}
|
|
1523
|
+
O = Te.quote;
|
|
1524
|
+
} catch (C) {
|
|
1525
|
+
T(Ee(C, "Quote unavailable. Try again.")), I("idle");
|
|
1526
|
+
return;
|
|
1527
|
+
}
|
|
1528
|
+
d(O);
|
|
1529
|
+
const ne = xt(O);
|
|
1530
|
+
if (ne <= 0n) {
|
|
1531
|
+
T("Quote returned an empty amount. Try again."), I("idle");
|
|
1532
|
+
return;
|
|
1533
|
+
}
|
|
1534
|
+
const $e = await W ?? await w(g.account, n);
|
|
1535
|
+
if (b(g.account, n, $e), $e < ne) {
|
|
1536
|
+
S({ required: !0, done: !1 }), T(`Approve ${o.symbol} before swapping.`), I("idle");
|
|
1537
|
+
return;
|
|
1538
|
+
}
|
|
1539
|
+
I("signing");
|
|
1540
|
+
let oe;
|
|
1541
|
+
try {
|
|
1542
|
+
oe = await tr({
|
|
1543
|
+
provider: g.provider,
|
|
1544
|
+
publicClient: e,
|
|
1545
|
+
account: g.account,
|
|
1546
|
+
chainId: t.chainId,
|
|
1547
|
+
chain: t.chain,
|
|
1548
|
+
permit2: n.permit2,
|
|
1549
|
+
router: n.router,
|
|
1550
|
+
token: o.address,
|
|
1551
|
+
amount: ne,
|
|
1552
|
+
allowanceRead: M
|
|
1553
|
+
});
|
|
1554
|
+
} catch (C) {
|
|
1555
|
+
if (Kn(C)) throw C;
|
|
1556
|
+
I("approving"), await er({
|
|
1557
|
+
provider: g.provider,
|
|
1558
|
+
publicClient: e,
|
|
1559
|
+
account: g.account,
|
|
1560
|
+
chain: t.chain,
|
|
1561
|
+
token: o.address,
|
|
1562
|
+
permit2: n.permit2,
|
|
1563
|
+
router: n.router,
|
|
1564
|
+
amount: ne,
|
|
1565
|
+
expiration: Math.floor(Date.now() / 1e3) + zn
|
|
1566
|
+
}), oe = null;
|
|
1567
|
+
}
|
|
1568
|
+
const Ce = BigInt(Math.floor(Date.now() / 1e3) + Dt), Ke = pr(O), pe = O.mode === "exactOut" ? ta({
|
|
1569
|
+
poolKey: O.poolKey,
|
|
1570
|
+
zeroForOne: O.zeroForOne,
|
|
1571
|
+
amountOut: O.grossAmountOut,
|
|
1572
|
+
amountInMaximum: O.amountInMaximum,
|
|
1573
|
+
recipient: g.account,
|
|
1574
|
+
deadline: Ce,
|
|
1575
|
+
permit: oe,
|
|
1576
|
+
fee: Ke
|
|
1577
|
+
}) : ea({
|
|
1578
|
+
poolKey: O.poolKey,
|
|
1579
|
+
zeroForOne: O.zeroForOne,
|
|
1580
|
+
amountIn: O.amountIn,
|
|
1581
|
+
amountOutMinimum: O.amountOutMinimum,
|
|
1582
|
+
recipient: g.account,
|
|
1583
|
+
deadline: Ce,
|
|
1584
|
+
permit: oe,
|
|
1585
|
+
fee: Ke
|
|
1586
|
+
});
|
|
1587
|
+
I("submitting");
|
|
1588
|
+
const B = at({
|
|
1589
|
+
account: g.account,
|
|
1590
|
+
chain: t.chain,
|
|
1591
|
+
transport: rt(g.provider)
|
|
1592
|
+
}), ze = await e.estimateGas({
|
|
1593
|
+
account: g.account,
|
|
1594
|
+
to: n.router,
|
|
1595
|
+
data: pe.calldata,
|
|
1596
|
+
value: pe.value
|
|
1597
|
+
}), K = await B.sendTransaction({
|
|
1598
|
+
to: n.router,
|
|
1599
|
+
data: pe.calldata,
|
|
1600
|
+
value: pe.value,
|
|
1601
|
+
gas: ze * 12n / 10n
|
|
1602
|
+
}), Ne = {
|
|
1603
|
+
mode: O.mode,
|
|
1604
|
+
inputSymbol: o.symbol,
|
|
1605
|
+
outputSymbol: a.symbol,
|
|
1606
|
+
amountIn: O.amountIn,
|
|
1607
|
+
amountOut: O.amountOut,
|
|
1608
|
+
feeAmount: O.feeAmount,
|
|
1609
|
+
feeBps: O.feeBps
|
|
1610
|
+
};
|
|
1611
|
+
D(K);
|
|
1612
|
+
try {
|
|
1613
|
+
L == null || L(K, Ne);
|
|
1614
|
+
} catch (C) {
|
|
1615
|
+
console.warn("[AegisSwapWidget] onSubmitted callback failed", C);
|
|
1616
|
+
}
|
|
1617
|
+
let ue = null;
|
|
1618
|
+
const me = await e.waitForTransactionReceipt({
|
|
1619
|
+
hash: K,
|
|
1620
|
+
onReplaced: (C) => {
|
|
1621
|
+
ue = C.reason, D(C.transaction.hash);
|
|
1622
|
+
}
|
|
1623
|
+
});
|
|
1624
|
+
if (ue === "cancelled") throw new Error("Swap was cancelled in the wallet.");
|
|
1625
|
+
if (me.status === "reverted") throw new Error("Swap reverted on-chain.");
|
|
1626
|
+
I("success");
|
|
1627
|
+
try {
|
|
1628
|
+
q == null || q({
|
|
1629
|
+
hash: me.transactionHash,
|
|
1630
|
+
explorerUrl: Pn(me.transactionHash, t),
|
|
1631
|
+
swap: Ne
|
|
1632
|
+
}), await U(g.account);
|
|
1633
|
+
} catch (C) {
|
|
1634
|
+
console.warn("[AegisSwapWidget] Post-success refresh failed", C);
|
|
1635
|
+
}
|
|
1636
|
+
},
|
|
1637
|
+
[
|
|
1638
|
+
c,
|
|
1639
|
+
t,
|
|
1640
|
+
b,
|
|
1641
|
+
l,
|
|
1642
|
+
o,
|
|
1643
|
+
n,
|
|
1644
|
+
L,
|
|
1645
|
+
q,
|
|
1646
|
+
a,
|
|
1647
|
+
e,
|
|
1648
|
+
u,
|
|
1649
|
+
r,
|
|
1650
|
+
w,
|
|
1651
|
+
U,
|
|
1652
|
+
d,
|
|
1653
|
+
s
|
|
1654
|
+
]
|
|
1655
|
+
), xe = P(async () => {
|
|
1656
|
+
T(null), D(null);
|
|
1657
|
+
try {
|
|
1658
|
+
const g = await Z();
|
|
1659
|
+
if (!g) return;
|
|
1660
|
+
await re(g);
|
|
1661
|
+
} catch (g) {
|
|
1662
|
+
if (g instanceof an) {
|
|
1663
|
+
T("Transaction is still pending. Check its status via the transaction link."), I("idle");
|
|
1664
|
+
return;
|
|
1665
|
+
}
|
|
1666
|
+
const x = Ee(g, "Swap failed."), W = g instanceof Error ? g : new Error(x);
|
|
1667
|
+
T(x), I("idle"), N == null || N(W);
|
|
1668
|
+
}
|
|
1669
|
+
}, [Z, N, re]), he = P(async () => {
|
|
1670
|
+
T(null), D(null), S({ required: !0, done: !1 });
|
|
1671
|
+
let g = !1;
|
|
1672
|
+
try {
|
|
1673
|
+
const x = await Z();
|
|
1674
|
+
if (!x) return;
|
|
1675
|
+
if (!n || !u || c === null || c <= 0n) {
|
|
1676
|
+
T("Enter a valid amount before approving.");
|
|
1677
|
+
return;
|
|
1678
|
+
}
|
|
1679
|
+
const W = xt(u);
|
|
1680
|
+
if (W <= 0n) {
|
|
1681
|
+
T("Enter a valid amount before approving.");
|
|
1682
|
+
return;
|
|
1683
|
+
}
|
|
1684
|
+
let M = await w(x.account, n);
|
|
1685
|
+
if (b(x.account, n, M), M < W && (I("approving"), await Ja({
|
|
1686
|
+
provider: x.provider,
|
|
1687
|
+
publicClient: e,
|
|
1688
|
+
account: x.account,
|
|
1689
|
+
chain: t.chain,
|
|
1690
|
+
token: o.address,
|
|
1691
|
+
permit2: n.permit2,
|
|
1692
|
+
amount: E === "exact" ? W : void 0
|
|
1693
|
+
}), M = await Nr(
|
|
1694
|
+
() => w(x.account, n),
|
|
1695
|
+
W
|
|
1696
|
+
), b(x.account, n, M), M < W)) {
|
|
1697
|
+
T("Approval confirmed, but allowance is still below this quote. Try again."), I("idle");
|
|
1698
|
+
return;
|
|
1699
|
+
}
|
|
1700
|
+
S({ required: !0, done: !0 }), g = !0, await re(x, M);
|
|
1701
|
+
} catch (x) {
|
|
1702
|
+
if (x instanceof an) {
|
|
1703
|
+
T(
|
|
1704
|
+
g ? "Transaction is still pending. Check its status via the transaction link." : "Approval is still pending. Wait for it to confirm, then try again."
|
|
1705
|
+
), I("idle");
|
|
1706
|
+
return;
|
|
1707
|
+
}
|
|
1708
|
+
const W = Ee(x, g ? "Swap failed." : "Approval failed."), M = x instanceof Error ? x : new Error(W);
|
|
1709
|
+
T(W), I("idle"), N == null || N(M);
|
|
1710
|
+
}
|
|
1711
|
+
}, [
|
|
1712
|
+
c,
|
|
1713
|
+
t.chain,
|
|
1714
|
+
E,
|
|
1715
|
+
b,
|
|
1716
|
+
Z,
|
|
1717
|
+
o.address,
|
|
1718
|
+
n,
|
|
1719
|
+
N,
|
|
1720
|
+
re,
|
|
1721
|
+
e,
|
|
1722
|
+
u,
|
|
1723
|
+
w
|
|
1724
|
+
]);
|
|
939
1725
|
return {
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
1726
|
+
submit: xe,
|
|
1727
|
+
approveInputToken: he,
|
|
1728
|
+
reset: R,
|
|
1729
|
+
status: _,
|
|
1730
|
+
busy: mr(_),
|
|
1731
|
+
txHash: V,
|
|
1732
|
+
actionError: z,
|
|
1733
|
+
approvalProgress: j
|
|
943
1734
|
};
|
|
944
1735
|
}
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
1736
|
+
const Or = 250, Mr = 5e3;
|
|
1737
|
+
function Pr({
|
|
1738
|
+
owner: e,
|
|
1739
|
+
market: t,
|
|
1740
|
+
inputToken: n,
|
|
1741
|
+
outputToken: o,
|
|
1742
|
+
quoteMode: a,
|
|
1743
|
+
activeAmount: r,
|
|
1744
|
+
slippageBps: c,
|
|
1745
|
+
feeConfig: s
|
|
953
1746
|
}) {
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
"
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
1747
|
+
return [
|
|
1748
|
+
de(e),
|
|
1749
|
+
(t == null ? void 0 : t.chainId) ?? "",
|
|
1750
|
+
(t == null ? void 0 : t.poolId.toLowerCase()) ?? "",
|
|
1751
|
+
de(n.address),
|
|
1752
|
+
de(o.address),
|
|
1753
|
+
a,
|
|
1754
|
+
(r == null ? void 0 : r.toString()) ?? "",
|
|
1755
|
+
c ?? "",
|
|
1756
|
+
(s == null ? void 0 : s.bps) ?? "",
|
|
1757
|
+
de(s == null ? void 0 : s.recipient)
|
|
1758
|
+
].join("|");
|
|
1759
|
+
}
|
|
1760
|
+
function Dr({
|
|
1761
|
+
publicClient: e,
|
|
1762
|
+
owner: t,
|
|
1763
|
+
market: n,
|
|
1764
|
+
inputToken: o,
|
|
1765
|
+
outputToken: a,
|
|
1766
|
+
quoteMode: r,
|
|
1767
|
+
activeAmount: c,
|
|
1768
|
+
slippageBps: s,
|
|
1769
|
+
feeConfig: l,
|
|
1770
|
+
onQuote: u,
|
|
1771
|
+
pausedRef: d
|
|
970
1772
|
}) {
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1773
|
+
const [m, f] = A(null), [v, p] = A(!1), [w, b] = A(null), E = H(
|
|
1774
|
+
() => Pr({
|
|
1775
|
+
owner: t,
|
|
1776
|
+
market: n,
|
|
1777
|
+
inputToken: o,
|
|
1778
|
+
outputToken: a,
|
|
1779
|
+
quoteMode: r,
|
|
1780
|
+
activeAmount: c,
|
|
1781
|
+
slippageBps: s,
|
|
1782
|
+
feeConfig: l
|
|
1783
|
+
}),
|
|
1784
|
+
[c, l, o, n, a, t, r, s]
|
|
1785
|
+
), U = (m == null ? void 0 : m.key) === E ? m.quote : null, L = P(
|
|
1786
|
+
(_) => {
|
|
1787
|
+
f(_ ? { key: E, quote: _ } : null);
|
|
1788
|
+
},
|
|
1789
|
+
[E]
|
|
1790
|
+
), q = te(u);
|
|
1791
|
+
q.current = u;
|
|
1792
|
+
const N = P(() => {
|
|
1793
|
+
f(null), b(null);
|
|
1794
|
+
}, []);
|
|
1795
|
+
return Y(() => {
|
|
1796
|
+
const _ = new AbortController();
|
|
1797
|
+
let I = !1, V = !1, D;
|
|
1798
|
+
f(null), b(null);
|
|
1799
|
+
const z = t, T = n, j = c, S = s;
|
|
1800
|
+
if (!z || !T || !j || j <= 0n || S === null)
|
|
1801
|
+
return p(!1), () => _.abort();
|
|
1802
|
+
const R = z, Z = T, re = j, xe = S;
|
|
1803
|
+
async function he(W) {
|
|
1804
|
+
var M;
|
|
1805
|
+
if (!(V || _.signal.aborted)) {
|
|
1806
|
+
V = !0, W && p(!0);
|
|
1807
|
+
try {
|
|
1808
|
+
const O = await Vn({
|
|
1809
|
+
publicClient: e,
|
|
1810
|
+
account: R,
|
|
1811
|
+
market: Z,
|
|
1812
|
+
tokenIn: o,
|
|
1813
|
+
tokenOut: a,
|
|
1814
|
+
mode: r,
|
|
1815
|
+
amount: re,
|
|
1816
|
+
slippageBps: xe,
|
|
1817
|
+
fee: l,
|
|
1818
|
+
signal: _.signal
|
|
1819
|
+
});
|
|
1820
|
+
if (I || _.signal.aborted) return;
|
|
1821
|
+
f(
|
|
1822
|
+
(ne) => ne && ne.key === E && lr(ne.quote, O) ? ne : { key: E, quote: O }
|
|
1823
|
+
), b(null), (M = q.current) == null || M.call(q, O);
|
|
1824
|
+
} catch (O) {
|
|
1825
|
+
if (I || _.signal.aborted) return;
|
|
1826
|
+
b(Ee(O, "Quote unavailable."));
|
|
1827
|
+
} finally {
|
|
1828
|
+
V = !1, !I && !_.signal.aborted && p(!1);
|
|
1829
|
+
}
|
|
986
1830
|
}
|
|
987
|
-
|
|
988
|
-
|
|
1831
|
+
}
|
|
1832
|
+
const g = window.setTimeout(() => {
|
|
1833
|
+
he(!0), D = window.setInterval(() => {
|
|
1834
|
+
!(d != null && d.current) && ot() && he(!1);
|
|
1835
|
+
}, Mr);
|
|
1836
|
+
}, Or), x = () => {
|
|
1837
|
+
!(d != null && d.current) && ot() && he(!1);
|
|
1838
|
+
};
|
|
1839
|
+
return document.addEventListener("visibilitychange", x), () => {
|
|
1840
|
+
I = !0, window.clearTimeout(g), D !== void 0 && window.clearInterval(D), document.removeEventListener("visibilitychange", x), _.abort();
|
|
1841
|
+
};
|
|
1842
|
+
}, [
|
|
1843
|
+
c,
|
|
1844
|
+
l,
|
|
1845
|
+
o,
|
|
1846
|
+
n,
|
|
1847
|
+
a,
|
|
1848
|
+
t,
|
|
1849
|
+
e,
|
|
1850
|
+
r,
|
|
1851
|
+
E,
|
|
1852
|
+
s
|
|
1853
|
+
]), { quote: U, quoteLoading: v, quoteError: w, setQuote: L, clearQuote: N };
|
|
1854
|
+
}
|
|
1855
|
+
function _n(e, t, n, o) {
|
|
1856
|
+
return !e || !t || !G(e.owner, t) || !G(e.token, n) || !G(e.spender, o) ? null : e;
|
|
1857
|
+
}
|
|
1858
|
+
function Rr(e, t) {
|
|
1859
|
+
if (!e || t === void 0 || t <= 0n) return !1;
|
|
1860
|
+
const n = Math.floor(Date.now() / 1e3);
|
|
1861
|
+
return e.amount >= t && e.expiration > n + Dt;
|
|
1862
|
+
}
|
|
1863
|
+
function Br({
|
|
1864
|
+
publicClient: e,
|
|
1865
|
+
owner: t,
|
|
1866
|
+
market: n,
|
|
1867
|
+
inputToken: o,
|
|
1868
|
+
spendAmount: a
|
|
1869
|
+
}) {
|
|
1870
|
+
var j;
|
|
1871
|
+
const [r, c] = A(null), [s, l] = A(null), [u, d] = A(!1), [m, f] = A(!1), [v, p] = A(null), [w, b] = A(null), E = P(
|
|
1872
|
+
async (S, R) => e.readContract({
|
|
1873
|
+
address: o.address,
|
|
1874
|
+
abi: Tt,
|
|
1875
|
+
functionName: "allowance",
|
|
1876
|
+
args: [S, R.permit2]
|
|
1877
|
+
}),
|
|
1878
|
+
[o.address, e]
|
|
1879
|
+
), U = P(
|
|
1880
|
+
(S, R, Z) => {
|
|
1881
|
+
c({
|
|
1882
|
+
owner: S,
|
|
1883
|
+
token: o.address,
|
|
1884
|
+
spender: R.permit2,
|
|
1885
|
+
amount: Z
|
|
1886
|
+
}), p(null);
|
|
1887
|
+
},
|
|
1888
|
+
[o.address]
|
|
1889
|
+
), L = P(
|
|
1890
|
+
async (S, R) => {
|
|
1891
|
+
const [Z, re] = await Rt({
|
|
1892
|
+
publicClient: e,
|
|
1893
|
+
permit2: R.permit2,
|
|
1894
|
+
account: S,
|
|
1895
|
+
token: o.address,
|
|
1896
|
+
router: R.router
|
|
1897
|
+
});
|
|
1898
|
+
return {
|
|
1899
|
+
owner: S,
|
|
1900
|
+
token: o.address,
|
|
1901
|
+
spender: R.router,
|
|
1902
|
+
amount: Z,
|
|
1903
|
+
expiration: Number(re)
|
|
1904
|
+
};
|
|
1905
|
+
},
|
|
1906
|
+
[o.address, e]
|
|
1907
|
+
), q = a !== void 0 && a > 0n ? a : null, N = q !== null;
|
|
1908
|
+
Y(() => {
|
|
1909
|
+
let S = !1;
|
|
1910
|
+
return p(null), !t || !n || !N ? (c(null), d(!1), () => {
|
|
1911
|
+
S = !0;
|
|
1912
|
+
}) : (d(!0), E(t, n).then((R) => {
|
|
1913
|
+
S || U(t, n, R);
|
|
1914
|
+
}).catch((R) => {
|
|
1915
|
+
S || (c(null), p(Ee(R, "Approval check unavailable.")));
|
|
1916
|
+
}).finally(() => {
|
|
1917
|
+
S || d(!1);
|
|
1918
|
+
}), () => {
|
|
1919
|
+
S = !0;
|
|
1920
|
+
});
|
|
1921
|
+
}, [U, N, n, t, E]), Y(() => {
|
|
1922
|
+
let S = !1;
|
|
1923
|
+
return b(null), !t || !n || !N ? (l(null), f(!1), () => {
|
|
1924
|
+
S = !0;
|
|
1925
|
+
}) : (f(!0), L(t, n).then((R) => {
|
|
1926
|
+
S || l(R);
|
|
1927
|
+
}).catch((R) => {
|
|
1928
|
+
S || (l(null), b(
|
|
1929
|
+
Ee(R, "Authorization check unavailable.")
|
|
1930
|
+
));
|
|
1931
|
+
}).finally(() => {
|
|
1932
|
+
S || f(!1);
|
|
1933
|
+
}), () => {
|
|
1934
|
+
S = !0;
|
|
1935
|
+
});
|
|
1936
|
+
}, [N, n, t, L]);
|
|
1937
|
+
const _ = n ? ((j = _n(r, t, o.address, n.permit2)) == null ? void 0 : j.amount) ?? null : null, I = n ? _n(s, t, o.address, n.router) : null, V = !!(t && n && N && !v && (u || _ === null)), D = !!(t && n && q !== null && _ !== null && _ < q), z = !!(t && n && N && !D && !w && (m || I === null)), T = !!(t && n && N && !D && (w || I !== null && !Rr(I, a)));
|
|
1938
|
+
return {
|
|
1939
|
+
allowanceAmount: _,
|
|
1940
|
+
allowanceError: v,
|
|
1941
|
+
approvalCheckPending: V,
|
|
1942
|
+
approvalRequired: D,
|
|
1943
|
+
authorizationCheckPending: z,
|
|
1944
|
+
authorizationRequired: T,
|
|
1945
|
+
readAllowance: E,
|
|
1946
|
+
commitAllowance: U
|
|
1947
|
+
};
|
|
989
1948
|
}
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
1949
|
+
const Ur = 5e3, kr = { input: null, output: null };
|
|
1950
|
+
function tt(e, t, n) {
|
|
1951
|
+
return [e ?? "", de(t), de(n.address)].join("|");
|
|
1952
|
+
}
|
|
1953
|
+
function Fr(e, t, n, o, a) {
|
|
1954
|
+
return e[t] === n && e[o] === a ? e : { ...e, [t]: n, [o]: a };
|
|
1955
|
+
}
|
|
1956
|
+
function In(e, t, n) {
|
|
1957
|
+
return e.readContract({
|
|
1958
|
+
address: t.address,
|
|
1959
|
+
abi: Tt,
|
|
1960
|
+
functionName: "balanceOf",
|
|
1961
|
+
args: [n]
|
|
1962
|
+
});
|
|
1963
|
+
}
|
|
1964
|
+
function Lr({
|
|
1965
|
+
publicClient: e,
|
|
1966
|
+
owner: t,
|
|
1967
|
+
inputToken: n,
|
|
1968
|
+
outputToken: o
|
|
1969
|
+
}) {
|
|
1970
|
+
var m;
|
|
1971
|
+
const [a, r] = A({}), c = te(0), s = (m = e.chain) == null ? void 0 : m.id, l = H(
|
|
1972
|
+
() => t ? {
|
|
1973
|
+
input: a[tt(s, t, n)] ?? null,
|
|
1974
|
+
output: a[tt(s, t, o)] ?? null
|
|
1975
|
+
} : kr,
|
|
1976
|
+
[a, s, n, o, t]
|
|
1977
|
+
), u = P(
|
|
1978
|
+
async (f, v) => {
|
|
1979
|
+
const p = ++c.current, w = tt(s, f, n), b = tt(s, f, o);
|
|
1980
|
+
try {
|
|
1981
|
+
const [E, U] = await Promise.all([
|
|
1982
|
+
In(e, n, f),
|
|
1983
|
+
In(e, o, f)
|
|
1984
|
+
]);
|
|
1985
|
+
p === c.current && !(v != null && v()) && r((L) => Fr(L, w, E, b, U));
|
|
1986
|
+
} catch {
|
|
998
1987
|
}
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1988
|
+
},
|
|
1989
|
+
[s, n, o, e]
|
|
1990
|
+
), d = P(
|
|
1991
|
+
(f) => u(f),
|
|
1992
|
+
[u]
|
|
1993
|
+
);
|
|
1994
|
+
return Y(() => {
|
|
1995
|
+
let f = !1;
|
|
1996
|
+
if (!t)
|
|
1997
|
+
return c.current += 1, r({}), () => {
|
|
1998
|
+
f = !0;
|
|
1999
|
+
};
|
|
2000
|
+
const v = t;
|
|
2001
|
+
let p = !1;
|
|
2002
|
+
async function w() {
|
|
2003
|
+
if (!p) {
|
|
2004
|
+
p = !0;
|
|
2005
|
+
try {
|
|
2006
|
+
await u(v, () => f);
|
|
2007
|
+
} finally {
|
|
2008
|
+
p = !1;
|
|
2009
|
+
}
|
|
1006
2010
|
}
|
|
1007
|
-
|
|
1008
|
-
|
|
2011
|
+
}
|
|
2012
|
+
w();
|
|
2013
|
+
const b = window.setInterval(() => {
|
|
2014
|
+
ot() && w();
|
|
2015
|
+
}, Ur), E = () => {
|
|
2016
|
+
ot() && w();
|
|
2017
|
+
};
|
|
2018
|
+
return document.addEventListener("visibilitychange", E), () => {
|
|
2019
|
+
f = !0, window.clearInterval(b), document.removeEventListener("visibilitychange", E);
|
|
2020
|
+
};
|
|
2021
|
+
}, [u, t]), { balances: l, refreshBalances: d };
|
|
1009
2022
|
}
|
|
1010
|
-
function
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
2023
|
+
function qr({
|
|
2024
|
+
endpoint: e,
|
|
2025
|
+
chainId: t,
|
|
2026
|
+
addresses: n
|
|
2027
|
+
}) {
|
|
2028
|
+
const [o, a] = A({});
|
|
2029
|
+
return Y(() => {
|
|
2030
|
+
if (!e || !n.length) return;
|
|
2031
|
+
const r = new AbortController();
|
|
2032
|
+
return Ma({
|
|
2033
|
+
endpoint: e,
|
|
2034
|
+
chainId: t,
|
|
2035
|
+
addresses: n,
|
|
2036
|
+
signal: r.signal
|
|
2037
|
+
}).then((c) => {
|
|
2038
|
+
r.signal.aborted || c.size === 0 || a((s) => {
|
|
2039
|
+
let l = !1;
|
|
2040
|
+
const u = { ...s };
|
|
2041
|
+
return c.forEach((d, m) => {
|
|
2042
|
+
var f;
|
|
2043
|
+
((f = u[m]) == null ? void 0 : f.iconURL) !== d.iconURL && (u[m] = d, l = !0);
|
|
2044
|
+
}), l ? u : s;
|
|
2045
|
+
});
|
|
2046
|
+
}).catch((c) => {
|
|
2047
|
+
r.signal.aborted || console.warn("[AegisSwapWidget] Token metadata icons unavailable", c);
|
|
2048
|
+
}), () => r.abort();
|
|
2049
|
+
}, [n, t, e]), o;
|
|
1017
2050
|
}
|
|
1018
|
-
function
|
|
2051
|
+
function Wr({
|
|
1019
2052
|
provider: e,
|
|
1020
|
-
|
|
2053
|
+
controlledAccount: t,
|
|
1021
2054
|
getProvider: n,
|
|
1022
|
-
onConnectWallet:
|
|
1023
|
-
onSubmitted: i,
|
|
1024
|
-
onSuccess: s,
|
|
1025
|
-
onError: p,
|
|
1026
|
-
chainId: N = C,
|
|
1027
|
-
chains: v,
|
|
1028
|
-
pools: m,
|
|
1029
|
-
defaultPoolId: D,
|
|
1030
|
-
targets: A,
|
|
1031
|
-
markets: B,
|
|
1032
|
-
defaultDirection: he = "intoTarget",
|
|
1033
|
-
defaultSlippagePercent: ye = "1",
|
|
1034
|
-
rpcUrls: we,
|
|
1035
|
-
metadataEndpoint: nt,
|
|
1036
|
-
className: zt,
|
|
1037
|
-
theme: Qt,
|
|
1038
|
-
accentColor: at = "#2fbf7a",
|
|
1039
|
-
accentTextColor: De,
|
|
1040
|
-
showPoolLink: jt = !0
|
|
2055
|
+
onConnectWallet: o
|
|
1041
2056
|
}) {
|
|
1042
|
-
|
|
1043
|
-
const Ht = Ca(Qt), Xt = T(() => {
|
|
1044
|
-
const o = {
|
|
1045
|
-
"--aegis-swap-accent": at
|
|
1046
|
-
};
|
|
1047
|
-
return De && (o["--aegis-swap-accent-text"] = De), o;
|
|
1048
|
-
}, [at, De]), ke = T(() => Kn(v), [v]), u = ke[N] ?? Oe[C], ot = T(() => xa(u.chainId), [u.chainId]), rt = T(
|
|
1049
|
-
() => Vn(m, ke),
|
|
1050
|
-
[ke, m]
|
|
1051
|
-
), X = T(
|
|
1052
|
-
() => ({
|
|
1053
|
-
...m != null && m.length ? {} : qn,
|
|
1054
|
-
...rt,
|
|
1055
|
-
...B
|
|
1056
|
-
}),
|
|
1057
|
-
[rt, B, m]
|
|
1058
|
-
), G = T(() => (A && A.length > 0 ? A : m != null && m.length ? m.map((r) => r.id) : Et).filter((r) => {
|
|
1059
|
-
var l;
|
|
1060
|
-
return ((l = X[r]) == null ? void 0 : l.chainId) === u.chainId;
|
|
1061
|
-
}), [u.chainId, X, m, A]), it = we ?? u.rpcUrls, Me = nt === void 0 ? u.metadataEndpoint : nt, I = T(
|
|
1062
|
-
() => Ea(u.chain, it),
|
|
1063
|
-
[u.chain, it]
|
|
1064
|
-
), F = Vt(t), [ce, ct] = b(
|
|
1065
|
-
D ?? Et[0]
|
|
1066
|
-
), [be, Yt] = b(he), [K, Y] = b("exactIn"), [_e, Z] = b(""), [st, J] = b(""), [ge, ut] = b(ye), [Zt, Ee] = b(F), [lt, se] = b(null), [q, Ae] = b({ input: null, output: null }), [f, ee] = b(null), [dt, Ue] = b(!1), [Ie, ue] = b(null), [k, O] = b("idle"), [pt, mt] = b(null), [ft, le] = b(null), [de, Jt] = b({}), [en, Pe] = b(null), te = me(async () => {
|
|
2057
|
+
const [a, r] = A(null), [c, s] = A(null), [l, u] = A(null), d = P(async () => {
|
|
1067
2058
|
if (e) return e;
|
|
1068
2059
|
if (n) {
|
|
1069
|
-
const
|
|
1070
|
-
if (
|
|
2060
|
+
const p = await n();
|
|
2061
|
+
if (p) return p;
|
|
1071
2062
|
}
|
|
1072
|
-
return
|
|
1073
|
-
}, [n, e]),
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
() =>
|
|
1079
|
-
|
|
1080
|
-
);
|
|
1081
|
-
const $ = T(() => St(ge), [ge]), Ce = lt !== null && lt !== u.chainId, Be = oe.trim().length > 0 && Re === null, V = K === "exactOut" ? f == null ? void 0 : f.amountInMaximum : f == null ? void 0 : f.amountIn, Fe = V !== void 0 && q.input !== null && V > q.input, yt = d ? ((bt = u.poolExplorerUrl) == null ? void 0 : bt.call(u, d.poolId, d)) ?? null : null, nn = K === "exactOut" && f ? $e(f.amountIn, y.decimals) : _e, an = K === "exactIn" && f ? $e(f.amountOut, x.decimals) : st, qe = T(() => {
|
|
1082
|
-
const o = /* @__PURE__ */ new Set();
|
|
1083
|
-
for (const r of G) {
|
|
1084
|
-
const l = X[r];
|
|
1085
|
-
!l || l.chainId !== u.chainId || (o.add(l.token.address), o.add(l.counterToken.address));
|
|
1086
|
-
}
|
|
1087
|
-
return [...o];
|
|
1088
|
-
}, [u.chainId, X, G]);
|
|
1089
|
-
Q(() => {
|
|
1090
|
-
Ee(F);
|
|
1091
|
-
}, [F]), Q(() => {
|
|
1092
|
-
let o = !1;
|
|
1093
|
-
return te().then((r) => {
|
|
1094
|
-
o || Pe(r);
|
|
1095
|
-
}).catch((r) => {
|
|
1096
|
-
o || (console.warn("[AegisSwapWidget] Provider resolver unavailable", r), Pe(ze()));
|
|
2063
|
+
return vt();
|
|
2064
|
+
}, [n, e]), m = e ?? l ?? vt(), f = t ?? a;
|
|
2065
|
+
Y(() => {
|
|
2066
|
+
let p = !1;
|
|
2067
|
+
return d().then((w) => {
|
|
2068
|
+
p || u(w);
|
|
2069
|
+
}).catch((w) => {
|
|
2070
|
+
p || (console.warn("[AegisSwapWidget] Provider resolver unavailable", w), u(vt()));
|
|
1097
2071
|
}), () => {
|
|
1098
|
-
|
|
2072
|
+
p = !0;
|
|
1099
2073
|
};
|
|
1100
|
-
}, [
|
|
1101
|
-
if (!
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
endpoint: Me,
|
|
1105
|
-
chainId: u.chainId,
|
|
1106
|
-
addresses: qe,
|
|
1107
|
-
signal: o.signal
|
|
1108
|
-
}).then((r) => {
|
|
1109
|
-
o.signal.aborted || r.size === 0 || Jt((l) => {
|
|
1110
|
-
let E = !1;
|
|
1111
|
-
const _ = { ...l };
|
|
1112
|
-
return r.forEach((M, P) => {
|
|
1113
|
-
var U;
|
|
1114
|
-
((U = _[P]) == null ? void 0 : U.iconURL) !== M.iconURL && (_[P] = M, E = !0);
|
|
1115
|
-
}), E ? _ : l;
|
|
1116
|
-
});
|
|
1117
|
-
}).catch((r) => {
|
|
1118
|
-
o.signal.aborted || console.warn("[AegisSwapWidget] Token metadata icons unavailable", r);
|
|
1119
|
-
}), () => o.abort();
|
|
1120
|
-
}, [u.chainId, qe, Me]), Q(() => {
|
|
1121
|
-
G.length > 0 && !G.includes(ce) && (ct(G[0]), Y("exactIn"), Z(""), J(""), ee(null), ue(null), O("idle"));
|
|
1122
|
-
}, [G, ce]), Q(() => {
|
|
1123
|
-
if (!pe) return;
|
|
1124
|
-
let o = !1;
|
|
1125
|
-
const r = async () => {
|
|
2074
|
+
}, [d]), Y(() => {
|
|
2075
|
+
if (!m) return;
|
|
2076
|
+
let p = !1;
|
|
2077
|
+
const w = async () => {
|
|
1126
2078
|
try {
|
|
1127
|
-
const [E,
|
|
1128
|
-
|
|
1129
|
-
|
|
2079
|
+
const [E, U] = await Promise.all([
|
|
2080
|
+
t ? Promise.resolve(t) : gr(m),
|
|
2081
|
+
We(m)
|
|
1130
2082
|
]);
|
|
1131
|
-
if (
|
|
1132
|
-
|
|
2083
|
+
if (p) return;
|
|
2084
|
+
r(E), s(U);
|
|
1133
2085
|
} catch {
|
|
1134
|
-
|
|
2086
|
+
p || (t || r(null), s(null));
|
|
1135
2087
|
}
|
|
1136
2088
|
};
|
|
1137
|
-
|
|
1138
|
-
const
|
|
1139
|
-
onAccountsChanged:
|
|
1140
|
-
onChainChanged:
|
|
2089
|
+
w();
|
|
2090
|
+
const b = xr(m, {
|
|
2091
|
+
onAccountsChanged: w,
|
|
2092
|
+
onChainChanged: w
|
|
1141
2093
|
});
|
|
1142
2094
|
return () => {
|
|
1143
|
-
|
|
2095
|
+
p = !0, b();
|
|
1144
2096
|
};
|
|
1145
|
-
}, [
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
2097
|
+
}, [t, m]);
|
|
2098
|
+
const v = P(async () => {
|
|
2099
|
+
const p = wr(
|
|
2100
|
+
o ? await o() : void 0
|
|
2101
|
+
), w = p.provider ?? await d();
|
|
2102
|
+
if (!w) return null;
|
|
2103
|
+
u(w);
|
|
2104
|
+
const b = p.account ?? await yr(w), E = await We(w);
|
|
2105
|
+
return r(b), s(E), { provider: w, account: b };
|
|
2106
|
+
}, [d, o]);
|
|
2107
|
+
return { owner: f, walletChainId: c, setWalletChainId: s, getActiveProvider: d, connectWallet: v };
|
|
2108
|
+
}
|
|
2109
|
+
function $r(e) {
|
|
2110
|
+
return e === "sell" || e === "outOfTarget" ? "sell" : "buy";
|
|
2111
|
+
}
|
|
2112
|
+
function Kr(e) {
|
|
2113
|
+
return `${e.slice(0, 6)}...${e.slice(-4)}`;
|
|
2114
|
+
}
|
|
2115
|
+
function zr({
|
|
2116
|
+
busy: e,
|
|
2117
|
+
status: t,
|
|
2118
|
+
hasMarket: n,
|
|
2119
|
+
hasAvailablePools: o,
|
|
2120
|
+
ownerConnected: a,
|
|
2121
|
+
wrongChain: r,
|
|
2122
|
+
activeChainName: c,
|
|
2123
|
+
activeInput: s,
|
|
2124
|
+
amountInvalid: l,
|
|
2125
|
+
slippageValid: u,
|
|
2126
|
+
insufficientBalance: d,
|
|
2127
|
+
hasQuote: m,
|
|
2128
|
+
quoteLoading: f,
|
|
2129
|
+
quoteUnavailable: v,
|
|
2130
|
+
allowanceError: p,
|
|
2131
|
+
approvalCheckPending: w,
|
|
2132
|
+
approvalRequired: b,
|
|
2133
|
+
authorizationCheckPending: E,
|
|
2134
|
+
authorizationRequired: U,
|
|
2135
|
+
inputSymbol: L,
|
|
2136
|
+
targetSymbol: q,
|
|
2137
|
+
counterSymbol: N,
|
|
2138
|
+
direction: _
|
|
2139
|
+
}) {
|
|
2140
|
+
const I = !a, V = a && r, D = !!(a && !r && s.trim() && !l && u && !d && m && !p), z = !!(D && b), T = !!(D && !w && !b && !E && U), j = !!(D && !w && !b && !E && !U), S = !!(!e && n && (I || V || z || T || j)), R = t === "approving" ? `Approving ${L}` : t === "signing" ? "Signing permit" : t === "submitting" ? "Swapping" : t === "success" ? "Swapped" : n ? I ? "Connect wallet" : V ? `Switch to ${c}` : s.trim() ? l ? "Invalid amount" : u ? d ? `Insufficient ${L}` : f ? "Fetching quote" : v ? "Quote unavailable" : p ? "Approval unavailable" : w ? "Checking approval" : b ? `Approve ${L} & swap` : E ? "Checking authorization" : U ? _ === "buy" ? `Approve & swap to ${q}` : `Approve & swap to ${N}` : _ === "buy" ? `Swap to ${q}` : `Swap to ${N}` : "Invalid slippage" : "Enter amount" : o ? "Pool unavailable" : "No pools available";
|
|
2141
|
+
return {
|
|
2142
|
+
canConnectWallet: I,
|
|
2143
|
+
canSwitchChain: V,
|
|
2144
|
+
validEntry: D,
|
|
2145
|
+
canApprove: z,
|
|
2146
|
+
canAuthorize: T,
|
|
2147
|
+
canSwap: j,
|
|
2148
|
+
canSubmit: S,
|
|
2149
|
+
primaryAction: b ? "approve" : "swap",
|
|
2150
|
+
ctaLabel: R
|
|
2151
|
+
};
|
|
2152
|
+
}
|
|
2153
|
+
function Gr({
|
|
2154
|
+
quote: e,
|
|
2155
|
+
inputSymbol: t,
|
|
2156
|
+
inputDecimals: n,
|
|
2157
|
+
outputSymbol: o,
|
|
2158
|
+
outputDecimals: a
|
|
2159
|
+
}) {
|
|
2160
|
+
if (!e) return [];
|
|
2161
|
+
const r = [], c = e.amountIn > 0n ? e.amountOut * 10n ** BigInt(n) / e.amountIn : null;
|
|
2162
|
+
return c !== null && r.push({
|
|
2163
|
+
label: "Rate",
|
|
2164
|
+
value: `1 ${t} = ${Le(c, a)} ${o}`
|
|
2165
|
+
}), e.mode === "exactOut" ? r.push({
|
|
2166
|
+
label: "Max sold",
|
|
2167
|
+
value: `${Le(e.amountInMaximum, n)} ${t}`
|
|
2168
|
+
}) : r.push({
|
|
2169
|
+
label: "Min received",
|
|
2170
|
+
value: `${Le(e.userAmountOutMinimum, a)} ${o}`
|
|
2171
|
+
}), r;
|
|
2172
|
+
}
|
|
2173
|
+
const Vr = 150;
|
|
2174
|
+
function An({ activeChainName: e }) {
|
|
2175
|
+
const [t, n] = A(!1), [o, a] = A(!1), r = te(null), c = te(null), s = te(), l = ke(), u = P((m = !1) => {
|
|
2176
|
+
var f;
|
|
2177
|
+
n(!1), a(!0), window.clearTimeout(s.current), s.current = window.setTimeout(() => a(!1), Vr), m && ((f = c.current) == null || f.focus());
|
|
2178
|
+
}, []), d = P(() => {
|
|
2179
|
+
window.clearTimeout(s.current), a(!1), n(!0);
|
|
2180
|
+
}, []);
|
|
2181
|
+
return Y(() => () => window.clearTimeout(s.current), []), Y(() => {
|
|
2182
|
+
if (!t) return;
|
|
2183
|
+
const m = (v) => {
|
|
2184
|
+
var p;
|
|
2185
|
+
(p = r.current) != null && p.contains(v.target) || u();
|
|
2186
|
+
}, f = (v) => {
|
|
2187
|
+
v.key === "Escape" && (v.stopPropagation(), u(!0));
|
|
2188
|
+
};
|
|
2189
|
+
return document.addEventListener("pointerdown", m), document.addEventListener("keydown", f), () => {
|
|
2190
|
+
document.removeEventListener("pointerdown", m), document.removeEventListener("keydown", f);
|
|
2191
|
+
};
|
|
2192
|
+
}, [t, u]), /* @__PURE__ */ h("div", { className: "aegis-swap-widget__network", ref: r, children: [
|
|
2193
|
+
/* @__PURE__ */ h(
|
|
2194
|
+
"button",
|
|
2195
|
+
{
|
|
2196
|
+
type: "button",
|
|
2197
|
+
ref: c,
|
|
2198
|
+
className: "aegis-swap-widget__chain",
|
|
2199
|
+
"aria-haspopup": "listbox",
|
|
2200
|
+
"aria-expanded": t,
|
|
2201
|
+
"aria-controls": l,
|
|
2202
|
+
"aria-label": `Network: ${e}. Change network`,
|
|
2203
|
+
"data-open": t || void 0,
|
|
2204
|
+
onClick: () => t ? u() : d(),
|
|
2205
|
+
children: [
|
|
2206
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__chain-mark", "aria-hidden": "true", children: /* @__PURE__ */ i(wn, { className: "aegis-swap-widget__chain-logo" }) }),
|
|
2207
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__chain-caret", "aria-hidden": "true", children: /* @__PURE__ */ i(qn, {}) })
|
|
2208
|
+
]
|
|
1151
2209
|
}
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
2210
|
+
),
|
|
2211
|
+
/* @__PURE__ */ h(
|
|
2212
|
+
"div",
|
|
2213
|
+
{
|
|
2214
|
+
className: `aegis-swap-widget__network-menu${t ? " is-open" : ""}${o ? " is-closing" : ""}`,
|
|
2215
|
+
"aria-hidden": !t,
|
|
2216
|
+
children: [
|
|
2217
|
+
/* @__PURE__ */ i(
|
|
2218
|
+
"div",
|
|
2219
|
+
{
|
|
2220
|
+
role: "listbox",
|
|
2221
|
+
id: l,
|
|
2222
|
+
"aria-label": "Network",
|
|
2223
|
+
className: "aegis-swap-widget__network-list",
|
|
2224
|
+
children: /* @__PURE__ */ h(
|
|
2225
|
+
"button",
|
|
2226
|
+
{
|
|
2227
|
+
type: "button",
|
|
2228
|
+
role: "option",
|
|
2229
|
+
"aria-selected": !0,
|
|
2230
|
+
tabIndex: t ? 0 : -1,
|
|
2231
|
+
className: "aegis-swap-widget__network-option",
|
|
2232
|
+
onClick: () => u(!0),
|
|
2233
|
+
children: [
|
|
2234
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__network-mark", "aria-hidden": "true", children: /* @__PURE__ */ i(wn, { className: "aegis-swap-widget__chain-logo" }) }),
|
|
2235
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__network-name", children: e }),
|
|
2236
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__network-check", "aria-hidden": "true", children: /* @__PURE__ */ i(Ln, {}) })
|
|
2237
|
+
]
|
|
2238
|
+
}
|
|
2239
|
+
)
|
|
2240
|
+
}
|
|
2241
|
+
),
|
|
2242
|
+
/* @__PURE__ */ i("p", { className: "aegis-swap-widget__network-soon", children: "More networks coming soon" })
|
|
2243
|
+
]
|
|
1160
2244
|
}
|
|
2245
|
+
)
|
|
2246
|
+
] });
|
|
2247
|
+
}
|
|
2248
|
+
function jr({
|
|
2249
|
+
poolIds: e,
|
|
2250
|
+
activePoolId: t,
|
|
2251
|
+
marketMap: n,
|
|
2252
|
+
metadataByAddress: o,
|
|
2253
|
+
busy: a,
|
|
2254
|
+
onSelectPool: r,
|
|
2255
|
+
onKeyDown: c,
|
|
2256
|
+
buttonRefs: s
|
|
2257
|
+
}) {
|
|
2258
|
+
return /* @__PURE__ */ i(
|
|
2259
|
+
"div",
|
|
2260
|
+
{
|
|
2261
|
+
className: "aegis-swap-widget__targets",
|
|
2262
|
+
role: "radiogroup",
|
|
2263
|
+
"aria-label": "Swap pool",
|
|
2264
|
+
onKeyDown: c,
|
|
2265
|
+
children: e.map((l) => {
|
|
2266
|
+
const u = n[l], d = l === t;
|
|
2267
|
+
return /* @__PURE__ */ h(
|
|
2268
|
+
"button",
|
|
2269
|
+
{
|
|
2270
|
+
type: "button",
|
|
2271
|
+
role: "radio",
|
|
2272
|
+
ref: (m) => {
|
|
2273
|
+
s.current.set(l, m);
|
|
2274
|
+
},
|
|
2275
|
+
className: "aegis-swap-widget__target",
|
|
2276
|
+
"aria-checked": d,
|
|
2277
|
+
tabIndex: d ? 0 : -1,
|
|
2278
|
+
disabled: a,
|
|
2279
|
+
onClick: () => r(l),
|
|
2280
|
+
children: [
|
|
2281
|
+
/* @__PURE__ */ i(
|
|
2282
|
+
kn,
|
|
2283
|
+
{
|
|
2284
|
+
market: u,
|
|
2285
|
+
metadataByAddress: o,
|
|
2286
|
+
className: "aegis-swap-widget__target-pair"
|
|
2287
|
+
}
|
|
2288
|
+
),
|
|
2289
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__target-symbol", children: u.symbol ?? l })
|
|
2290
|
+
]
|
|
2291
|
+
},
|
|
2292
|
+
l
|
|
2293
|
+
);
|
|
2294
|
+
})
|
|
1161
2295
|
}
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
2296
|
+
);
|
|
2297
|
+
}
|
|
2298
|
+
function vn({
|
|
2299
|
+
inputId: e,
|
|
2300
|
+
label: t,
|
|
2301
|
+
token: n,
|
|
2302
|
+
value: o,
|
|
2303
|
+
balance: a,
|
|
2304
|
+
invalid: r,
|
|
2305
|
+
busy: c,
|
|
2306
|
+
metadataByAddress: s,
|
|
2307
|
+
onChange: l,
|
|
2308
|
+
quickActions: u
|
|
2309
|
+
}) {
|
|
2310
|
+
return /* @__PURE__ */ h("div", { className: "aegis-swap-widget__amount-box", children: [
|
|
2311
|
+
/* @__PURE__ */ h("span", { className: "aegis-swap-widget__field-label", children: [
|
|
2312
|
+
/* @__PURE__ */ i("label", { htmlFor: e, children: t }),
|
|
2313
|
+
u ? /* @__PURE__ */ h("span", { className: "aegis-swap-widget__quick", children: [
|
|
2314
|
+
/* @__PURE__ */ i(
|
|
2315
|
+
"button",
|
|
2316
|
+
{
|
|
2317
|
+
type: "button",
|
|
2318
|
+
className: "aegis-swap-widget__half",
|
|
2319
|
+
"aria-label": `Use half ${n.symbol} balance`,
|
|
2320
|
+
disabled: a === null || c,
|
|
2321
|
+
onClick: u.onHalf,
|
|
2322
|
+
children: "50%"
|
|
2323
|
+
}
|
|
2324
|
+
),
|
|
2325
|
+
/* @__PURE__ */ i(
|
|
2326
|
+
"button",
|
|
2327
|
+
{
|
|
2328
|
+
type: "button",
|
|
2329
|
+
className: "aegis-swap-widget__max",
|
|
2330
|
+
"aria-label": `Use max ${n.symbol} balance`,
|
|
2331
|
+
disabled: a === null || c,
|
|
2332
|
+
onClick: u.onMax,
|
|
2333
|
+
children: "Max"
|
|
2334
|
+
}
|
|
2335
|
+
)
|
|
2336
|
+
] }) : null
|
|
2337
|
+
] }),
|
|
2338
|
+
/* @__PURE__ */ h("span", { className: "aegis-swap-widget__amount-row", children: [
|
|
2339
|
+
/* @__PURE__ */ i(
|
|
2340
|
+
"input",
|
|
2341
|
+
{
|
|
2342
|
+
id: e,
|
|
2343
|
+
inputMode: "decimal",
|
|
2344
|
+
autoComplete: "off",
|
|
2345
|
+
value: o,
|
|
2346
|
+
"aria-invalid": r ? !0 : void 0,
|
|
2347
|
+
onChange: (d) => l(d.target.value),
|
|
2348
|
+
placeholder: "0",
|
|
2349
|
+
disabled: c
|
|
1198
2350
|
}
|
|
2351
|
+
),
|
|
2352
|
+
/* @__PURE__ */ h("span", { className: "aegis-swap-widget__token", children: [
|
|
2353
|
+
/* @__PURE__ */ i(
|
|
2354
|
+
Et,
|
|
2355
|
+
{
|
|
2356
|
+
token: n,
|
|
2357
|
+
metadataByAddress: s,
|
|
2358
|
+
className: "aegis-swap-widget__token-mark"
|
|
2359
|
+
}
|
|
2360
|
+
),
|
|
2361
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__token-symbol", children: n.symbol })
|
|
2362
|
+
] })
|
|
2363
|
+
] }),
|
|
2364
|
+
/* @__PURE__ */ h("span", { className: "aegis-swap-widget__meta", children: [
|
|
2365
|
+
"Balance ",
|
|
2366
|
+
La(a, n.decimals),
|
|
2367
|
+
" ",
|
|
2368
|
+
n.symbol
|
|
2369
|
+
] })
|
|
2370
|
+
] });
|
|
2371
|
+
}
|
|
2372
|
+
function Qr({
|
|
2373
|
+
open: e,
|
|
2374
|
+
toggleRef: t,
|
|
2375
|
+
panelId: n,
|
|
2376
|
+
onToggle: o,
|
|
2377
|
+
rows: a,
|
|
2378
|
+
slippageInputId: r,
|
|
2379
|
+
slippageValue: c,
|
|
2380
|
+
slippageInvalid: s,
|
|
2381
|
+
onSlippageChange: l,
|
|
2382
|
+
onSlippageBlur: u,
|
|
2383
|
+
showApprovalControl: d,
|
|
2384
|
+
approvalMode: m,
|
|
2385
|
+
onApprovalModeChange: f,
|
|
2386
|
+
busy: v,
|
|
2387
|
+
market: p,
|
|
2388
|
+
metadataByAddress: w,
|
|
2389
|
+
counterToken: b,
|
|
2390
|
+
targetToken: E,
|
|
2391
|
+
showPoolLink: U,
|
|
2392
|
+
poolUrl: L,
|
|
2393
|
+
onCopyPoolId: q,
|
|
2394
|
+
poolCopied: N
|
|
2395
|
+
}) {
|
|
2396
|
+
return /* @__PURE__ */ h("div", { className: "aegis-swap-widget__execution", "data-open": e ? !0 : void 0, children: [
|
|
2397
|
+
/* @__PURE__ */ h(
|
|
2398
|
+
"button",
|
|
2399
|
+
{
|
|
2400
|
+
ref: t,
|
|
2401
|
+
type: "button",
|
|
2402
|
+
className: "aegis-swap-widget__execution-toggle",
|
|
2403
|
+
"aria-expanded": e,
|
|
2404
|
+
"aria-controls": n,
|
|
2405
|
+
"aria-label": e ? "Collapse trade details" : "Expand trade details",
|
|
2406
|
+
onClick: o,
|
|
2407
|
+
children: [
|
|
2408
|
+
/* @__PURE__ */ h("span", { className: "aegis-swap-widget__execution-toggle-label", children: [
|
|
2409
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__execution-toggle-icon", children: /* @__PURE__ */ i(ka, {}) }),
|
|
2410
|
+
/* @__PURE__ */ i("span", { children: "Trade details" })
|
|
2411
|
+
] }),
|
|
2412
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__execution-chevron", children: /* @__PURE__ */ i(qn, {}) })
|
|
2413
|
+
]
|
|
1199
2414
|
}
|
|
2415
|
+
),
|
|
2416
|
+
/* @__PURE__ */ i("div", { id: n, className: "aegis-swap-widget__execution-panel", children: /* @__PURE__ */ h("div", { className: "aegis-swap-widget__execution-panel-inner", children: [
|
|
2417
|
+
a.length > 0 ? /* @__PURE__ */ i("div", { className: "aegis-swap-widget__quote-summary", children: a.map((_) => /* @__PURE__ */ h("div", { className: "aegis-swap-widget__detail-row", children: [
|
|
2418
|
+
/* @__PURE__ */ i("span", { children: _.label }),
|
|
2419
|
+
/* @__PURE__ */ i("strong", { children: _.value })
|
|
2420
|
+
] }, _.label)) }) : null,
|
|
2421
|
+
/* @__PURE__ */ i("div", { className: "aegis-swap-widget__settings", children: /* @__PURE__ */ h("label", { htmlFor: r, children: [
|
|
2422
|
+
/* @__PURE__ */ i("span", { children: "Slippage" }),
|
|
2423
|
+
/* @__PURE__ */ h("span", { className: "aegis-swap-widget__slippage-input", children: [
|
|
2424
|
+
/* @__PURE__ */ i(
|
|
2425
|
+
"input",
|
|
2426
|
+
{
|
|
2427
|
+
id: r,
|
|
2428
|
+
value: c,
|
|
2429
|
+
inputMode: "decimal",
|
|
2430
|
+
"aria-invalid": s ? !0 : void 0,
|
|
2431
|
+
onChange: (_) => l(_.target.value),
|
|
2432
|
+
onBlur: u
|
|
2433
|
+
}
|
|
2434
|
+
),
|
|
2435
|
+
/* @__PURE__ */ i("span", { children: "%" })
|
|
2436
|
+
] })
|
|
2437
|
+
] }) }),
|
|
2438
|
+
d ? /* @__PURE__ */ h("div", { className: "aegis-swap-widget__approval-mode", children: [
|
|
2439
|
+
/* @__PURE__ */ i("span", { children: "Approval" }),
|
|
2440
|
+
/* @__PURE__ */ h(
|
|
2441
|
+
"span",
|
|
2442
|
+
{
|
|
2443
|
+
className: "aegis-swap-widget__approval-options",
|
|
2444
|
+
role: "group",
|
|
2445
|
+
"aria-label": "Approval amount",
|
|
2446
|
+
children: [
|
|
2447
|
+
/* @__PURE__ */ i(
|
|
2448
|
+
"button",
|
|
2449
|
+
{
|
|
2450
|
+
type: "button",
|
|
2451
|
+
"data-active": m === "exact" ? !0 : void 0,
|
|
2452
|
+
disabled: v,
|
|
2453
|
+
onClick: () => f("exact"),
|
|
2454
|
+
children: "Exact"
|
|
2455
|
+
}
|
|
2456
|
+
),
|
|
2457
|
+
/* @__PURE__ */ i(
|
|
2458
|
+
"button",
|
|
2459
|
+
{
|
|
2460
|
+
type: "button",
|
|
2461
|
+
"data-active": m === "max" ? !0 : void 0,
|
|
2462
|
+
disabled: v,
|
|
2463
|
+
onClick: () => f("max"),
|
|
2464
|
+
children: "Max"
|
|
2465
|
+
}
|
|
2466
|
+
)
|
|
2467
|
+
]
|
|
2468
|
+
}
|
|
2469
|
+
)
|
|
2470
|
+
] }) : null,
|
|
2471
|
+
p ? /* @__PURE__ */ i("div", { className: "aegis-swap-widget__details", children: /* @__PURE__ */ h("div", { className: "aegis-swap-widget__pool", children: [
|
|
2472
|
+
/* @__PURE__ */ h("span", { className: "aegis-swap-widget__pool-label", children: [
|
|
2473
|
+
/* @__PURE__ */ i(
|
|
2474
|
+
kn,
|
|
2475
|
+
{
|
|
2476
|
+
market: p,
|
|
2477
|
+
metadataByAddress: w,
|
|
2478
|
+
className: "aegis-swap-widget__pool-pair"
|
|
2479
|
+
}
|
|
2480
|
+
),
|
|
2481
|
+
"Route"
|
|
2482
|
+
] }),
|
|
2483
|
+
/* @__PURE__ */ h(
|
|
2484
|
+
"span",
|
|
2485
|
+
{
|
|
2486
|
+
className: "aegis-swap-widget__route-chip",
|
|
2487
|
+
"aria-label": `Uniswap v4 pool ${p.poolId}`,
|
|
2488
|
+
title: `${p.label ?? `${b.symbol} / ${E.symbol}`}: ${p.poolId}`,
|
|
2489
|
+
children: [
|
|
2490
|
+
/* @__PURE__ */ h("span", { className: "aegis-swap-widget__route-protocol", children: [
|
|
2491
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__route-version", children: "v4" }),
|
|
2492
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__route-kind", children: "Pool" })
|
|
2493
|
+
] }),
|
|
2494
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__route-id", children: Kr(p.poolId) }),
|
|
2495
|
+
/* @__PURE__ */ h("span", { className: "aegis-swap-widget__route-actions", children: [
|
|
2496
|
+
U && L ? /* @__PURE__ */ i(
|
|
2497
|
+
"a",
|
|
2498
|
+
{
|
|
2499
|
+
className: "aegis-swap-widget__route-action",
|
|
2500
|
+
href: L,
|
|
2501
|
+
target: "_blank",
|
|
2502
|
+
rel: "noreferrer",
|
|
2503
|
+
"aria-label": "Open pool",
|
|
2504
|
+
children: /* @__PURE__ */ i(Fn, {})
|
|
2505
|
+
}
|
|
2506
|
+
) : null,
|
|
2507
|
+
/* @__PURE__ */ h(
|
|
2508
|
+
"button",
|
|
2509
|
+
{
|
|
2510
|
+
type: "button",
|
|
2511
|
+
className: "aegis-swap-widget__route-action",
|
|
2512
|
+
"data-copied": N || void 0,
|
|
2513
|
+
onClick: q,
|
|
2514
|
+
"aria-label": N ? "Pool id copied" : "Copy pool id",
|
|
2515
|
+
children: [
|
|
2516
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__copy-icon", "data-icon": "copy", "aria-hidden": "true", children: /* @__PURE__ */ i(Ua, {}) }),
|
|
2517
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__copy-icon", "data-icon": "check", "aria-hidden": "true", children: /* @__PURE__ */ i(Ln, {}) })
|
|
2518
|
+
]
|
|
2519
|
+
}
|
|
2520
|
+
)
|
|
2521
|
+
] })
|
|
2522
|
+
]
|
|
2523
|
+
}
|
|
2524
|
+
)
|
|
2525
|
+
] }) }) : null
|
|
2526
|
+
] }) })
|
|
2527
|
+
] });
|
|
2528
|
+
}
|
|
2529
|
+
function Hr({
|
|
2530
|
+
provider: e,
|
|
2531
|
+
account: t,
|
|
2532
|
+
getProvider: n,
|
|
2533
|
+
onConnectWallet: o,
|
|
2534
|
+
onSubmitted: a,
|
|
2535
|
+
onSuccess: r,
|
|
2536
|
+
onError: c,
|
|
2537
|
+
onQuote: s,
|
|
2538
|
+
chainId: l = ee,
|
|
2539
|
+
chains: u,
|
|
2540
|
+
pools: d,
|
|
2541
|
+
defaultPoolId: m,
|
|
2542
|
+
poolIds: f,
|
|
2543
|
+
targets: v,
|
|
2544
|
+
markets: p,
|
|
2545
|
+
defaultDirection: w,
|
|
2546
|
+
defaultSlippagePercent: b = 1,
|
|
2547
|
+
rpcUrls: E,
|
|
2548
|
+
metadataEndpoint: U,
|
|
2549
|
+
className: L,
|
|
2550
|
+
style: q,
|
|
2551
|
+
title: N = "",
|
|
2552
|
+
subtitle: _ = "",
|
|
2553
|
+
ariaLabel: I = "Aegis direct pool swap",
|
|
2554
|
+
theme: V,
|
|
2555
|
+
accentColor: D,
|
|
2556
|
+
accentTextColor: z,
|
|
2557
|
+
showPoolLink: T = !0,
|
|
2558
|
+
defaultApprovalMode: j = "exact",
|
|
2559
|
+
showApprovalModeControl: S = !0,
|
|
2560
|
+
showExecutionDetails: R = !0,
|
|
2561
|
+
defaultExecutionDetailsOpen: Z = !1
|
|
2562
|
+
}) {
|
|
2563
|
+
var tn;
|
|
2564
|
+
const re = $a(V), xe = ke(), he = ke(), g = ke(), x = ke(), W = ge(u), M = ge(d), O = ge(p), ne = ge(f), $e = ge(v), oe = ge(E), Ce = ge(q), Ke = H(() => {
|
|
2565
|
+
const y = { ...Ce };
|
|
2566
|
+
if (D) {
|
|
2567
|
+
y["--aegis-swap-accent"] = D;
|
|
2568
|
+
const $ = z ?? Sa(D);
|
|
2569
|
+
$ && (y["--aegis-swap-accent-text"] = $);
|
|
2570
|
+
} else z && (y["--aegis-swap-accent-text"] = z);
|
|
2571
|
+
return y;
|
|
2572
|
+
}, [D, z, Ce]), pe = H(() => ga(W), [W]), B = pe[l] ?? it[ee], ze = B.fee ?? null, K = H(
|
|
2573
|
+
() => M ?? (O ? Object.values(O) : void 0),
|
|
2574
|
+
[O, M]
|
|
2575
|
+
), Ne = H(
|
|
2576
|
+
() => ba(K, pe),
|
|
2577
|
+
[pe, K]
|
|
2578
|
+
), ue = H(
|
|
2579
|
+
() => ({
|
|
2580
|
+
...K != null && K.length ? {} : ma,
|
|
2581
|
+
...Ne
|
|
2582
|
+
}),
|
|
2583
|
+
[Ne, K]
|
|
2584
|
+
), me = ne ?? $e, C = H(() => (me && me.length > 0 ? me : K != null && K.length ? K.map(($) => $.id) : cn).filter(($) => {
|
|
2585
|
+
var ae;
|
|
2586
|
+
return ((ae = ue[$]) == null ? void 0 : ae.chainId) === B.chainId;
|
|
2587
|
+
}), [B.chainId, K, ue, me]), Te = H(() => Array.isArray(oe) ? oe : (oe == null ? void 0 : oe[B.chainId]) ?? B.rpcUrls, [B, oe]), Hn = U === void 0 ? B.metadataEndpoint : U, Xn = Te.join(","), Ge = H(
|
|
2588
|
+
() => Sr(B.chain, Te),
|
|
2589
|
+
[B.chainId, Xn]
|
|
2590
|
+
// not activeChain.chain/resolvedRpcUrls identity
|
|
2591
|
+
), Yn = st(t), [Bt, Zn] = A(
|
|
2592
|
+
m ?? cn[0]
|
|
2593
|
+
), [ut, Jn] = A(
|
|
2594
|
+
() => $r(w)
|
|
2595
|
+
), [fe, Oe] = A("exactIn"), [Ut, Me] = A(""), [kt, Pe] = A(""), Ft = gn(String(b)) || "1", [De, Lt] = A(Ft), [eo, lt] = A(null), [qt, to] = A(j), [Wt, no] = A(Z), $t = te(/* @__PURE__ */ new Map()), dt = te(void 0), { toggleRef: oo, captureAnchor: ao } = Va(Wt);
|
|
2596
|
+
Y(() => () => window.clearTimeout(dt.current), []);
|
|
2597
|
+
const { owner: Re, walletChainId: Kt, setWalletChainId: ro, getActiveProvider: io, connectWallet: co } = Wr({ provider: e, controlledAccount: Yn, getProvider: n, onConnectWallet: o }), _e = C.includes(Bt) ? Bt : C[0], k = _e ? ue[_e] ?? null : null, Ve = (k == null ? void 0 : k.token) ?? X.WATER, je = (k == null ? void 0 : k.counterToken) ?? X.USDC, Q = ut === "buy" ? je : Ve, ie = ut === "buy" ? Ve : je, Qe = fe === "exactOut" ? kt : Ut, zt = fe === "exactOut" ? ie : Q, pt = H(
|
|
2598
|
+
() => Fa(Qe, zt.decimals),
|
|
2599
|
+
[Qe, zt.decimals]
|
|
2600
|
+
), He = H(() => yn(De), [De]), { balances: le, refreshBalances: so } = Lr({
|
|
2601
|
+
publicClient: Ge,
|
|
2602
|
+
owner: Re,
|
|
2603
|
+
inputToken: Q,
|
|
2604
|
+
outputToken: ie
|
|
2605
|
+
}), Gt = te(!1), { quote: J, quoteLoading: uo, quoteError: mt, setQuote: lo, clearQuote: Xe } = Dr({
|
|
2606
|
+
publicClient: Ge,
|
|
2607
|
+
owner: Re,
|
|
2608
|
+
market: k,
|
|
2609
|
+
inputToken: Q,
|
|
2610
|
+
outputToken: ie,
|
|
2611
|
+
quoteMode: fe,
|
|
2612
|
+
activeAmount: pt,
|
|
2613
|
+
slippageBps: He,
|
|
2614
|
+
feeConfig: ze,
|
|
2615
|
+
onQuote: s,
|
|
2616
|
+
pausedRef: Gt
|
|
2617
|
+
}), Ie = J ? xt(J) : void 0, {
|
|
2618
|
+
allowanceAmount: Vt,
|
|
2619
|
+
allowanceError: ft,
|
|
2620
|
+
approvalCheckPending: po,
|
|
2621
|
+
approvalRequired: mo,
|
|
2622
|
+
authorizationCheckPending: fo,
|
|
2623
|
+
authorizationRequired: ho,
|
|
2624
|
+
readAllowance: wo,
|
|
2625
|
+
commitAllowance: go
|
|
2626
|
+
} = Br({ publicClient: Ge, owner: Re, market: k, inputToken: Q, spendAmount: Ie }), {
|
|
2627
|
+
submit: jt,
|
|
2628
|
+
approveInputToken: Qt,
|
|
2629
|
+
reset: ce,
|
|
2630
|
+
status: Be,
|
|
2631
|
+
busy: we,
|
|
2632
|
+
txHash: Ye,
|
|
2633
|
+
actionError: ht,
|
|
2634
|
+
approvalProgress: Ht
|
|
2635
|
+
} = Tr({
|
|
2636
|
+
publicClient: Ge,
|
|
2637
|
+
activeChain: B,
|
|
2638
|
+
market: k,
|
|
2639
|
+
inputToken: Q,
|
|
2640
|
+
outputToken: ie,
|
|
2641
|
+
quoteMode: fe,
|
|
2642
|
+
activeAmount: pt,
|
|
2643
|
+
slippageBps: He,
|
|
2644
|
+
feeConfig: ze,
|
|
2645
|
+
quote: J,
|
|
2646
|
+
setQuote: lo,
|
|
2647
|
+
owner: Re,
|
|
2648
|
+
getActiveProvider: io,
|
|
2649
|
+
connectWallet: co,
|
|
2650
|
+
setWalletChainId: ro,
|
|
2651
|
+
readAllowance: wo,
|
|
2652
|
+
commitAllowance: go,
|
|
2653
|
+
approvalMode: qt,
|
|
2654
|
+
refreshBalances: so,
|
|
2655
|
+
onSubmitted: a,
|
|
2656
|
+
onSuccess: r,
|
|
2657
|
+
onError: c
|
|
2658
|
+
});
|
|
2659
|
+
Gt.current = we, Y(() => {
|
|
2660
|
+
if (Be !== "success") return;
|
|
2661
|
+
const y = window.setTimeout(() => ce(), 3e3);
|
|
2662
|
+
return () => window.clearTimeout(y);
|
|
2663
|
+
}, [Be, ce]);
|
|
2664
|
+
const yo = H(() => {
|
|
2665
|
+
const y = /* @__PURE__ */ new Set();
|
|
2666
|
+
for (const $ of C) {
|
|
2667
|
+
const ae = ue[$];
|
|
2668
|
+
y.add(ae.token.address), y.add(ae.counterToken.address);
|
|
1200
2669
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
d,
|
|
1214
|
-
x,
|
|
1215
|
-
S,
|
|
1216
|
-
I,
|
|
1217
|
-
K,
|
|
1218
|
-
$
|
|
1219
|
-
]);
|
|
1220
|
-
const wt = me(async () => {
|
|
1221
|
-
le(null);
|
|
1222
|
-
const o = Ia(
|
|
1223
|
-
a ? await a() : void 0
|
|
1224
|
-
), r = o.provider ?? await te();
|
|
1225
|
-
if (!r)
|
|
1226
|
-
return le("No wallet provider found."), null;
|
|
1227
|
-
Pe(r);
|
|
1228
|
-
const l = o.account ?? await ya(r), E = await Qe(r);
|
|
1229
|
-
return Ee(l), se(E), { provider: r, account: l };
|
|
1230
|
-
}, [te, a]), on = me(() => {
|
|
1231
|
-
q.input !== null && (Y("exactIn"), Z($e(q.input, y.decimals)), J(""), O("idle"));
|
|
1232
|
-
}, [q.input, y.decimals]), rn = me(() => {
|
|
1233
|
-
Yt((o) => o === "intoTarget" ? "outOfTarget" : "intoTarget"), Y("exactIn"), Z(""), J(""), ee(null), ue(null), O("idle");
|
|
1234
|
-
}, []), cn = me(async () => {
|
|
1235
|
-
le(null), mt(null);
|
|
1236
|
-
try {
|
|
1237
|
-
let o = await te(), r = S;
|
|
1238
|
-
if (!o || !r) {
|
|
1239
|
-
const W = await wt();
|
|
1240
|
-
o = (W == null ? void 0 : W.provider) ?? o, r = r ?? (W == null ? void 0 : W.account) ?? null;
|
|
1241
|
-
}
|
|
1242
|
-
if (!o) {
|
|
1243
|
-
le("No wallet provider found.");
|
|
1244
|
-
return;
|
|
2670
|
+
return [...y];
|
|
2671
|
+
}, [ue, C]), Ze = qr({
|
|
2672
|
+
endpoint: Hn,
|
|
2673
|
+
chainId: B.chainId,
|
|
2674
|
+
addresses: yo
|
|
2675
|
+
}), bo = Kt !== null && Kt !== B.chainId, wt = Qe.trim().length > 0 && pt === null, Xt = C.length > 0, _o = Ie !== void 0 && le.input !== null && Ie > le.input, Io = k ? ((tn = B.poolExplorerUrl) == null ? void 0 : tn.call(B, k.poolId, k)) ?? null : null, Ao = !!(k && eo === k.poolId), Ue = fe === "exactOut" && J ? bn(J.amountIn, Q.decimals) : Ut, gt = fe === "exactIn" && J ? bn(J.amountOut, ie.decimals) : kt, vo = P(async () => {
|
|
2676
|
+
var y;
|
|
2677
|
+
if (!(!k || !((y = navigator.clipboard) != null && y.writeText)))
|
|
2678
|
+
try {
|
|
2679
|
+
await navigator.clipboard.writeText(k.poolId), lt(k.poolId), window.clearTimeout(dt.current), dt.current = window.setTimeout(() => lt(null), 1e3);
|
|
2680
|
+
} catch {
|
|
2681
|
+
lt(null);
|
|
1245
2682
|
}
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
2683
|
+
}, [k]), Je = P(
|
|
2684
|
+
(y) => {
|
|
2685
|
+
y !== null && (Oe("exactIn"), Me(qa(y, Q.decimals)), Pe(""), ce());
|
|
2686
|
+
},
|
|
2687
|
+
[Q.decimals, ce]
|
|
2688
|
+
), Eo = P(
|
|
2689
|
+
() => Je(le.input === null ? null : le.input / 2n),
|
|
2690
|
+
[le.input, Je]
|
|
2691
|
+
), So = P(
|
|
2692
|
+
() => Je(le.input),
|
|
2693
|
+
[le.input, Je]
|
|
2694
|
+
), xo = P(() => {
|
|
2695
|
+
const y = Fe(gt || Ue);
|
|
2696
|
+
Jn(($) => $ === "buy" ? "sell" : "buy"), Oe("exactIn"), Me(y), Pe(""), Xe(), ce();
|
|
2697
|
+
}, [gt, Xe, ce, Ue]), yt = P(
|
|
2698
|
+
(y) => {
|
|
2699
|
+
const $ = Fe(Ue);
|
|
2700
|
+
Zn(y), Oe("exactIn"), Me($), Pe(""), Xe(), ce();
|
|
2701
|
+
},
|
|
2702
|
+
[Xe, ce, Ue]
|
|
2703
|
+
), Co = P(
|
|
2704
|
+
(y) => {
|
|
2705
|
+
var on;
|
|
2706
|
+
if (C.length === 0 || !_e) return;
|
|
2707
|
+
const $ = Math.max(C.indexOf(_e), 0);
|
|
2708
|
+
let ae;
|
|
2709
|
+
switch (y.key) {
|
|
2710
|
+
case "ArrowRight":
|
|
2711
|
+
case "ArrowDown":
|
|
2712
|
+
ae = ($ + 1) % C.length;
|
|
2713
|
+
break;
|
|
2714
|
+
case "ArrowLeft":
|
|
2715
|
+
case "ArrowUp":
|
|
2716
|
+
ae = ($ - 1 + C.length) % C.length;
|
|
2717
|
+
break;
|
|
2718
|
+
case "Home":
|
|
2719
|
+
ae = 0;
|
|
2720
|
+
break;
|
|
2721
|
+
case "End":
|
|
2722
|
+
ae = C.length - 1;
|
|
2723
|
+
break;
|
|
2724
|
+
default:
|
|
2725
|
+
return;
|
|
1251
2726
|
}
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
const [xe, Ge] = await Promise.all([
|
|
1314
|
-
Te(I, y, r),
|
|
1315
|
-
Te(I, x, r)
|
|
1316
|
-
]);
|
|
1317
|
-
Ae({ input: xe, output: Ge });
|
|
1318
|
-
} catch (o) {
|
|
1319
|
-
const r = vt(o, "Swap failed."), l = o instanceof Error ? o : new Error(r);
|
|
1320
|
-
le(r), O("idle"), p == null || p(l);
|
|
2727
|
+
y.preventDefault();
|
|
2728
|
+
const nn = C[ae];
|
|
2729
|
+
yt(nn), (on = $t.current.get(nn)) == null || on.focus();
|
|
2730
|
+
},
|
|
2731
|
+
[_e, C, yt]
|
|
2732
|
+
), Yt = P(
|
|
2733
|
+
(y, $) => {
|
|
2734
|
+
y === "exactIn" ? (Oe("exactIn"), Me(Fe($)), Pe("")) : (Oe("exactOut"), Pe(Fe($)), Me("")), ce();
|
|
2735
|
+
},
|
|
2736
|
+
[ce]
|
|
2737
|
+
), { canSubmit: Zt, primaryAction: bt, ctaLabel: No } = zr({
|
|
2738
|
+
busy: we,
|
|
2739
|
+
status: Be,
|
|
2740
|
+
hasMarket: !!k,
|
|
2741
|
+
hasAvailablePools: Xt,
|
|
2742
|
+
ownerConnected: !!Re,
|
|
2743
|
+
wrongChain: bo,
|
|
2744
|
+
activeChainName: B.name,
|
|
2745
|
+
activeInput: Qe,
|
|
2746
|
+
amountInvalid: wt,
|
|
2747
|
+
slippageValid: He !== null,
|
|
2748
|
+
insufficientBalance: _o,
|
|
2749
|
+
hasQuote: !!J,
|
|
2750
|
+
quoteLoading: uo,
|
|
2751
|
+
quoteUnavailable: !!(mt && !J),
|
|
2752
|
+
allowanceError: !!ft,
|
|
2753
|
+
approvalCheckPending: po,
|
|
2754
|
+
approvalRequired: mo,
|
|
2755
|
+
authorizationCheckPending: fo,
|
|
2756
|
+
authorizationRequired: ho,
|
|
2757
|
+
inputSymbol: Q.symbol,
|
|
2758
|
+
targetSymbol: Ve.symbol,
|
|
2759
|
+
counterSymbol: je.symbol,
|
|
2760
|
+
direction: ut
|
|
2761
|
+
}), To = !!(Ht.done && Ie !== void 0 && Ie > 0n && Vt !== null && Vt >= Ie), se = fr({
|
|
2762
|
+
status: Be,
|
|
2763
|
+
inputSymbol: Q.symbol,
|
|
2764
|
+
txHash: Ye,
|
|
2765
|
+
actionError: ht,
|
|
2766
|
+
// transactionProgressView already treats status === 'approving' as step 1.
|
|
2767
|
+
approvalRequired: Ht.required,
|
|
2768
|
+
approvalDone: To
|
|
2769
|
+
}), Oo = P(() => {
|
|
2770
|
+
bt === "approve" ? Qt() : jt();
|
|
2771
|
+
}, [Qt, bt, jt]), Mo = Gr({
|
|
2772
|
+
quote: J,
|
|
2773
|
+
inputSymbol: Q.symbol,
|
|
2774
|
+
inputDecimals: Q.decimals,
|
|
2775
|
+
outputSymbol: ie.symbol,
|
|
2776
|
+
outputDecimals: ie.decimals
|
|
2777
|
+
}), Jt = !!(N || _), en = /* @__PURE__ */ i(
|
|
2778
|
+
jr,
|
|
2779
|
+
{
|
|
2780
|
+
poolIds: C,
|
|
2781
|
+
activePoolId: _e,
|
|
2782
|
+
marketMap: ue,
|
|
2783
|
+
metadataByAddress: Ze,
|
|
2784
|
+
busy: we,
|
|
2785
|
+
onSelectPool: yt,
|
|
2786
|
+
onKeyDown: Co,
|
|
2787
|
+
buttonRefs: $t
|
|
1321
2788
|
}
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
u,
|
|
1325
|
-
te,
|
|
1326
|
-
y,
|
|
1327
|
-
d,
|
|
1328
|
-
p,
|
|
1329
|
-
i,
|
|
1330
|
-
s,
|
|
1331
|
-
x,
|
|
1332
|
-
S,
|
|
1333
|
-
I,
|
|
1334
|
-
f,
|
|
1335
|
-
$,
|
|
1336
|
-
V
|
|
1337
|
-
]), sn = T(() => k === "approving" ? `Approving ${y.symbol}` : k === "signing" ? "Signing permit" : k === "submitting" ? "Swapping" : S ? Ce ? `Switch to ${u.name}` : d ? oe.trim() ? Be ? "Invalid amount" : $ === null ? "Invalid slippage" : Fe ? `Insufficient ${y.symbol}` : dt ? "Fetching quote" : Ie ? "Quote unavailable" : be === "intoTarget" ? `Swap to ${ne.symbol}` : `Swap to ${ae.symbol}` : "Enter amount" : "Pool unavailable" : "Connect wallet", [
|
|
1338
|
-
oe,
|
|
1339
|
-
u.name,
|
|
1340
|
-
Be,
|
|
1341
|
-
ae.symbol,
|
|
1342
|
-
be,
|
|
1343
|
-
y.symbol,
|
|
1344
|
-
Fe,
|
|
1345
|
-
d,
|
|
1346
|
-
S,
|
|
1347
|
-
Ie,
|
|
1348
|
-
dt,
|
|
1349
|
-
$,
|
|
1350
|
-
k,
|
|
1351
|
-
ne.symbol,
|
|
1352
|
-
Ce
|
|
1353
|
-
]), un = !S, ln = !!(S && Ce), dn = !!(S && !Ce && oe.trim() && !Be && $ !== null && !Fe && f), pn = !!(!ie(k) && d && (un || ln || dn));
|
|
1354
|
-
return /* @__PURE__ */ w(
|
|
2789
|
+
);
|
|
2790
|
+
return /* @__PURE__ */ h(
|
|
1355
2791
|
"section",
|
|
1356
2792
|
{
|
|
1357
2793
|
className: [
|
|
1358
2794
|
"aegis-swap-widget",
|
|
1359
|
-
`aegis-swap-widget--${
|
|
1360
|
-
|
|
2795
|
+
`aegis-swap-widget--${re}`,
|
|
2796
|
+
L ?? ""
|
|
1361
2797
|
].join(" "),
|
|
1362
|
-
|
|
1363
|
-
|
|
2798
|
+
"data-progress-state": se == null ? void 0 : se.state,
|
|
2799
|
+
style: Ke,
|
|
2800
|
+
"aria-label": I,
|
|
1364
2801
|
children: [
|
|
1365
|
-
/* @__PURE__ */
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
2802
|
+
se ? /* @__PURE__ */ h(
|
|
2803
|
+
"span",
|
|
2804
|
+
{
|
|
2805
|
+
className: "aegis-swap-widget__progress-rail",
|
|
2806
|
+
"data-state": se.state,
|
|
2807
|
+
title: `${se.label} · ${se.state}`,
|
|
2808
|
+
style: {
|
|
2809
|
+
"--aegis-swap-progress-complete": `${se.completePct}%`,
|
|
2810
|
+
"--aegis-swap-progress-active-width": `${se.activeWidthPct}%`
|
|
2811
|
+
},
|
|
2812
|
+
"aria-hidden": "true",
|
|
2813
|
+
children: [
|
|
2814
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__progress-complete" }),
|
|
2815
|
+
se.activeWidthPct > 0 ? /* @__PURE__ */ i("span", { className: "aegis-swap-widget__progress-active" }) : null
|
|
2816
|
+
]
|
|
2817
|
+
}
|
|
2818
|
+
) : null,
|
|
2819
|
+
Jt ? /* @__PURE__ */ h("div", { className: "aegis-swap-widget__header", children: [
|
|
2820
|
+
/* @__PURE__ */ h("div", { className: "aegis-swap-widget__brand", children: [
|
|
2821
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__logo", children: /* @__PURE__ */ i(hn, {}) }),
|
|
2822
|
+
/* @__PURE__ */ h("div", { children: [
|
|
2823
|
+
_ ? /* @__PURE__ */ i("span", { className: "aegis-swap-widget__eyebrow", children: _ }) : null,
|
|
2824
|
+
N ? /* @__PURE__ */ i("h2", { children: N }) : null
|
|
1371
2825
|
] })
|
|
1372
2826
|
] }),
|
|
1373
|
-
/* @__PURE__ */
|
|
2827
|
+
/* @__PURE__ */ i(An, { activeChainName: B.name })
|
|
2828
|
+
] }) : null,
|
|
2829
|
+
Jt ? en : /* @__PURE__ */ h("div", { className: "aegis-swap-widget__topbar", children: [
|
|
2830
|
+
en,
|
|
2831
|
+
/* @__PURE__ */ i(An, { activeChainName: B.name })
|
|
1374
2832
|
] }),
|
|
1375
|
-
/* @__PURE__ */
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
children: [
|
|
1388
|
-
|
|
1389
|
-
|
|
2833
|
+
Xt ? null : /* @__PURE__ */ h("p", { className: "aegis-swap-widget__empty", role: "status", children: [
|
|
2834
|
+
"No pools are configured for ",
|
|
2835
|
+
B.name,
|
|
2836
|
+
"."
|
|
2837
|
+
] }),
|
|
2838
|
+
/* @__PURE__ */ h(
|
|
2839
|
+
"form",
|
|
2840
|
+
{
|
|
2841
|
+
onSubmit: (y) => {
|
|
2842
|
+
y.preventDefault(), Zt && Oo();
|
|
2843
|
+
},
|
|
2844
|
+
children: [
|
|
2845
|
+
/* @__PURE__ */ h("div", { className: "aegis-swap-widget__panel", children: [
|
|
2846
|
+
/* @__PURE__ */ i(
|
|
2847
|
+
vn,
|
|
1390
2848
|
{
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
2849
|
+
inputId: xe,
|
|
2850
|
+
label: "Sell",
|
|
2851
|
+
token: Q,
|
|
2852
|
+
value: Ue,
|
|
2853
|
+
balance: le.input,
|
|
2854
|
+
invalid: fe === "exactIn" && wt,
|
|
2855
|
+
busy: we,
|
|
2856
|
+
metadataByAddress: Ze,
|
|
2857
|
+
onChange: (y) => Yt("exactIn", y),
|
|
2858
|
+
quickActions: { onHalf: Eo, onMax: So }
|
|
1394
2859
|
}
|
|
1395
|
-
)
|
|
1396
|
-
|
|
2860
|
+
),
|
|
2861
|
+
/* @__PURE__ */ i(
|
|
2862
|
+
"button",
|
|
1397
2863
|
{
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
2864
|
+
type: "button",
|
|
2865
|
+
className: "aegis-swap-widget__flip",
|
|
2866
|
+
onClick: xo,
|
|
2867
|
+
disabled: !k || we,
|
|
2868
|
+
"aria-label": "Switch swap direction",
|
|
2869
|
+
children: /* @__PURE__ */ i(Ba, {})
|
|
1401
2870
|
}
|
|
1402
2871
|
),
|
|
1403
|
-
/* @__PURE__ */
|
|
1404
|
-
|
|
1405
|
-
},
|
|
1406
|
-
o
|
|
1407
|
-
);
|
|
1408
|
-
}) }),
|
|
1409
|
-
/* @__PURE__ */ w("div", { className: "aegis-swap-widget__panel", children: [
|
|
1410
|
-
/* @__PURE__ */ w("label", { className: "aegis-swap-widget__amount-box", children: [
|
|
1411
|
-
/* @__PURE__ */ w("span", { className: "aegis-swap-widget__field-label", children: [
|
|
1412
|
-
"Sell",
|
|
1413
|
-
/* @__PURE__ */ c(
|
|
1414
|
-
"button",
|
|
1415
|
-
{
|
|
1416
|
-
type: "button",
|
|
1417
|
-
className: "aegis-swap-widget__max",
|
|
1418
|
-
disabled: q.input === null || ie(k),
|
|
1419
|
-
onClick: on,
|
|
1420
|
-
children: "Max"
|
|
1421
|
-
}
|
|
1422
|
-
)
|
|
1423
|
-
] }),
|
|
1424
|
-
/* @__PURE__ */ w("span", { className: "aegis-swap-widget__amount-row", children: [
|
|
1425
|
-
/* @__PURE__ */ c(
|
|
1426
|
-
"input",
|
|
1427
|
-
{
|
|
1428
|
-
inputMode: "decimal",
|
|
1429
|
-
autoComplete: "off",
|
|
1430
|
-
value: nn,
|
|
1431
|
-
onChange: (o) => {
|
|
1432
|
-
Y("exactIn"), Z(He(o.target.value)), J(""), O("idle");
|
|
1433
|
-
},
|
|
1434
|
-
placeholder: "0",
|
|
1435
|
-
disabled: ie(k)
|
|
1436
|
-
}
|
|
1437
|
-
),
|
|
1438
|
-
/* @__PURE__ */ w("span", { className: "aegis-swap-widget__token", children: [
|
|
1439
|
-
/* @__PURE__ */ c(
|
|
1440
|
-
fe,
|
|
2872
|
+
/* @__PURE__ */ i(
|
|
2873
|
+
vn,
|
|
1441
2874
|
{
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
2875
|
+
inputId: he,
|
|
2876
|
+
label: "Buy",
|
|
2877
|
+
token: ie,
|
|
2878
|
+
value: gt,
|
|
2879
|
+
balance: le.output,
|
|
2880
|
+
invalid: fe === "exactOut" && wt,
|
|
2881
|
+
busy: we,
|
|
2882
|
+
metadataByAddress: Ze,
|
|
2883
|
+
onChange: (y) => Yt("exactOut", y)
|
|
1445
2884
|
}
|
|
1446
|
-
)
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
/* @__PURE__ */ w("span", { className: "aegis-swap-widget__meta", children: [
|
|
1451
|
-
"Balance ",
|
|
1452
|
-
Ct(q.input, y.decimals),
|
|
1453
|
-
" ",
|
|
1454
|
-
y.symbol
|
|
1455
|
-
] })
|
|
1456
|
-
] }),
|
|
1457
|
-
/* @__PURE__ */ c(
|
|
1458
|
-
"button",
|
|
1459
|
-
{
|
|
1460
|
-
type: "button",
|
|
1461
|
-
className: "aegis-swap-widget__flip",
|
|
1462
|
-
onClick: rn,
|
|
1463
|
-
disabled: !d || ie(k),
|
|
1464
|
-
"aria-label": "Switch swap direction",
|
|
1465
|
-
children: /* @__PURE__ */ c(ka, {})
|
|
1466
|
-
}
|
|
1467
|
-
),
|
|
1468
|
-
/* @__PURE__ */ w("label", { className: "aegis-swap-widget__amount-box", children: [
|
|
1469
|
-
/* @__PURE__ */ c("span", { className: "aegis-swap-widget__field-label", children: "Buy" }),
|
|
1470
|
-
/* @__PURE__ */ w("span", { className: "aegis-swap-widget__amount-row", children: [
|
|
1471
|
-
/* @__PURE__ */ c(
|
|
1472
|
-
"input",
|
|
2885
|
+
)
|
|
2886
|
+
] }),
|
|
2887
|
+
R ? /* @__PURE__ */ i(
|
|
2888
|
+
Qr,
|
|
1473
2889
|
{
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
2890
|
+
open: Wt,
|
|
2891
|
+
toggleRef: oo,
|
|
2892
|
+
panelId: x,
|
|
2893
|
+
onToggle: () => {
|
|
2894
|
+
ao(), no((y) => !y);
|
|
2895
|
+
},
|
|
2896
|
+
rows: Mo,
|
|
2897
|
+
slippageInputId: g,
|
|
2898
|
+
slippageValue: De,
|
|
2899
|
+
slippageInvalid: !!(De.trim() && He === null),
|
|
2900
|
+
onSlippageChange: (y) => Lt(gn(y)),
|
|
2901
|
+
onSlippageBlur: () => {
|
|
2902
|
+
yn(De) === null && Lt(Ft);
|
|
1479
2903
|
},
|
|
1480
|
-
|
|
1481
|
-
|
|
2904
|
+
showApprovalControl: S,
|
|
2905
|
+
approvalMode: qt,
|
|
2906
|
+
onApprovalModeChange: to,
|
|
2907
|
+
busy: we,
|
|
2908
|
+
market: k,
|
|
2909
|
+
metadataByAddress: Ze,
|
|
2910
|
+
counterToken: je,
|
|
2911
|
+
targetToken: Ve,
|
|
2912
|
+
showPoolLink: T,
|
|
2913
|
+
poolUrl: Io,
|
|
2914
|
+
onCopyPoolId: vo,
|
|
2915
|
+
poolCopied: Ao
|
|
1482
2916
|
}
|
|
1483
|
-
),
|
|
1484
|
-
/* @__PURE__ */
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
/* @__PURE__ */ c("span", { className: "aegis-swap-widget__token-symbol", children: x.symbol })
|
|
1494
|
-
] })
|
|
1495
|
-
] }),
|
|
1496
|
-
/* @__PURE__ */ w("span", { className: "aegis-swap-widget__meta", children: [
|
|
1497
|
-
"Balance ",
|
|
1498
|
-
Ct(q.output, x.decimals),
|
|
1499
|
-
" ",
|
|
1500
|
-
x.symbol
|
|
1501
|
-
] })
|
|
1502
|
-
] })
|
|
1503
|
-
] }),
|
|
1504
|
-
/* @__PURE__ */ c("div", { className: "aegis-swap-widget__settings", children: /* @__PURE__ */ w("label", { children: [
|
|
1505
|
-
/* @__PURE__ */ c("span", { children: "Slippage" }),
|
|
1506
|
-
/* @__PURE__ */ w("span", { className: "aegis-swap-widget__slippage-input", children: [
|
|
1507
|
-
/* @__PURE__ */ c(
|
|
1508
|
-
"input",
|
|
1509
|
-
{
|
|
1510
|
-
value: ge,
|
|
1511
|
-
inputMode: "decimal",
|
|
1512
|
-
onChange: (o) => ut(zn(o.target.value)),
|
|
1513
|
-
onBlur: () => {
|
|
1514
|
-
St(ge) === null && ut("1");
|
|
2917
|
+
) : null,
|
|
2918
|
+
mt || ht || ft ? /* @__PURE__ */ i("p", { className: "aegis-swap-widget__error", role: "alert", children: mt ?? ht ?? ft }) : null,
|
|
2919
|
+
/* @__PURE__ */ i(
|
|
2920
|
+
"button",
|
|
2921
|
+
{
|
|
2922
|
+
type: "submit",
|
|
2923
|
+
className: "aegis-swap-widget__submit",
|
|
2924
|
+
disabled: !Zt,
|
|
2925
|
+
"data-action": bt,
|
|
2926
|
+
children: No
|
|
1515
2927
|
}
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
/* @__PURE__ */ c("span", { children: "%" })
|
|
1519
|
-
] })
|
|
1520
|
-
] }) }),
|
|
1521
|
-
d ? /* @__PURE__ */ c("div", { className: "aegis-swap-widget__details", children: /* @__PURE__ */ w("div", { className: "aegis-swap-widget__pool", children: [
|
|
1522
|
-
/* @__PURE__ */ w("span", { className: "aegis-swap-widget__pool-label", children: [
|
|
1523
|
-
/* @__PURE__ */ c(
|
|
1524
|
-
Nt,
|
|
1525
|
-
{
|
|
1526
|
-
market: d,
|
|
1527
|
-
metadataByAddress: de,
|
|
1528
|
-
className: "aegis-swap-widget__pool-pair"
|
|
1529
|
-
}
|
|
1530
|
-
),
|
|
1531
|
-
"Direct pool"
|
|
1532
|
-
] }),
|
|
1533
|
-
jt && yt ? /* @__PURE__ */ c("a", { href: yt, target: "_blank", rel: "noreferrer", children: d.label ?? `${ae.symbol} / ${ne.symbol}` }) : /* @__PURE__ */ c("strong", { children: d.label ?? `${ae.symbol} / ${ne.symbol}` })
|
|
1534
|
-
] }) }) : null,
|
|
1535
|
-
Ie || ft ? /* @__PURE__ */ c("p", { className: "aegis-swap-widget__error", role: "alert", children: Ie ?? ft }) : null,
|
|
1536
|
-
/* @__PURE__ */ c(
|
|
1537
|
-
"button",
|
|
1538
|
-
{
|
|
1539
|
-
type: "button",
|
|
1540
|
-
className: "aegis-swap-widget__submit",
|
|
1541
|
-
disabled: !pn,
|
|
1542
|
-
onClick: () => {
|
|
1543
|
-
cn();
|
|
1544
|
-
},
|
|
1545
|
-
children: sn
|
|
2928
|
+
)
|
|
2929
|
+
]
|
|
1546
2930
|
}
|
|
1547
2931
|
),
|
|
1548
|
-
|
|
2932
|
+
Be === "success" && Ye && J ? /* @__PURE__ */ h("p", { className: "aegis-swap-widget__success", role: "status", children: [
|
|
2933
|
+
"Swap complete — received ~",
|
|
2934
|
+
Le(J.amountOut, ie.decimals),
|
|
2935
|
+
" ",
|
|
2936
|
+
ie.symbol
|
|
2937
|
+
] }) : null,
|
|
2938
|
+
Ye ? /* @__PURE__ */ h(
|
|
1549
2939
|
"a",
|
|
1550
2940
|
{
|
|
1551
2941
|
className: "aegis-swap-widget__tx",
|
|
1552
|
-
href:
|
|
2942
|
+
href: Pn(Ye, B),
|
|
1553
2943
|
target: "_blank",
|
|
1554
2944
|
rel: "noreferrer",
|
|
1555
|
-
children:
|
|
2945
|
+
children: [
|
|
2946
|
+
"View transaction",
|
|
2947
|
+
/* @__PURE__ */ i(Fn, {})
|
|
2948
|
+
]
|
|
1556
2949
|
}
|
|
1557
|
-
) : null
|
|
2950
|
+
) : null,
|
|
2951
|
+
/* @__PURE__ */ h("p", { className: "aegis-swap-widget__powered", children: [
|
|
2952
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__powered-prefix", children: "Powered by" }),
|
|
2953
|
+
/* @__PURE__ */ h(
|
|
2954
|
+
"a",
|
|
2955
|
+
{
|
|
2956
|
+
className: "aegis-swap-widget__powered-link",
|
|
2957
|
+
href: "https://aegis.markets/",
|
|
2958
|
+
target: "_blank",
|
|
2959
|
+
rel: "noreferrer",
|
|
2960
|
+
children: [
|
|
2961
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__powered-mark", children: /* @__PURE__ */ i(hn, {}) }),
|
|
2962
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__powered-brand", children: "AEGIS" })
|
|
2963
|
+
]
|
|
2964
|
+
}
|
|
2965
|
+
)
|
|
2966
|
+
] })
|
|
1558
2967
|
]
|
|
1559
2968
|
}
|
|
1560
2969
|
);
|
|
1561
2970
|
}
|
|
1562
|
-
const
|
|
2971
|
+
const ei = Hr;
|
|
1563
2972
|
export {
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
2973
|
+
oa as AEGIS_DYNAMIC_FEE_FLAG,
|
|
2974
|
+
it as AEGIS_SWAP_CHAINS,
|
|
2975
|
+
ee as AEGIS_SWAP_CHAIN_ID,
|
|
2976
|
+
aa as AEGIS_SWAP_DEFAULT_FEE_BPS,
|
|
2977
|
+
ra as AEGIS_SWAP_DEFAULT_FEE_RECIPIENT,
|
|
2978
|
+
ca as AEGIS_SWAP_DEFAULT_METADATA_ENDPOINT,
|
|
2979
|
+
cn as AEGIS_SWAP_DEFAULT_POOL_IDS,
|
|
2980
|
+
ia as AEGIS_SWAP_DEFAULT_RPC_URLS,
|
|
2981
|
+
na as AEGIS_SWAP_HOOK,
|
|
2982
|
+
sa as AEGIS_SWAP_MAINNET_CHAIN,
|
|
2983
|
+
Mt as AEGIS_SWAP_MAINNET_UNISWAP_V4_CONTRACTS,
|
|
2984
|
+
ma as AEGIS_SWAP_MARKETS,
|
|
2985
|
+
Bn as AEGIS_SWAP_PERMIT2,
|
|
2986
|
+
Dn as AEGIS_SWAP_ROUTER,
|
|
2987
|
+
X as AEGIS_SWAP_TOKENS,
|
|
2988
|
+
Un as AEGIS_SWAP_V4_QUOTER,
|
|
2989
|
+
Hr as AegisDirectSwapWidget,
|
|
2990
|
+
ei as AegisSwapWidget,
|
|
2991
|
+
Rn as UNISWAP_V4_CONTRACTS_BY_CHAIN,
|
|
2992
|
+
wa as createAegisSwapChainConfig,
|
|
2993
|
+
ga as createAegisSwapChains,
|
|
2994
|
+
ba as createAegisSwapMarketsFromPools,
|
|
2995
|
+
ya as createAegisSwapPoolMarket,
|
|
2996
|
+
ye as createAegisSwapUniswapV4Contracts,
|
|
2997
|
+
Hr as default,
|
|
2998
|
+
Ma as fetchGlobalTokenMetadata,
|
|
2999
|
+
Ta as getIchiIconGuess
|
|
1591
3000
|
};
|