aegis-swap-widget 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +193 -0
- package/dist/abis.d.ts +188 -0
- package/dist/abis.d.ts.map +1 -0
- package/dist/aegis-swap-widget.js +1422 -0
- package/dist/config.d.ts +78 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/encoding.d.ts +47 -0
- package/dist/encoding.d.ts.map +1 -0
- package/dist/format.d.ts +8 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/metadata.d.ts +18 -0
- package/dist/metadata.d.ts.map +1 -0
- package/dist/permit.d.ts +25 -0
- package/dist/permit.d.ts.map +1 -0
- package/dist/quote.d.ts +26 -0
- package/dist/quote.d.ts.map +1 -0
- package/dist/styles.css +1 -0
- package/dist/wallet.d.ts +23 -0
- package/dist/wallet.d.ts.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1,1422 @@
|
|
|
1
|
+
import { jsxs as y, jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as O, useState as g, useCallback as le, useEffect as W } from "react";
|
|
3
|
+
import { keccak256 as en, encodeAbiParameters as G, encodeFunctionData as Le, getAddress as m, parseUnits as tn, formatUnits as yt, createWalletClient as We, custom as $e, erc20Abi as Ge, isAddress as nn, http as an, createPublicClient as on, fallback as rn } from "viem";
|
|
4
|
+
import { mainnet as cn } from "viem/chains";
|
|
5
|
+
const qe = [
|
|
6
|
+
{
|
|
7
|
+
type: "function",
|
|
8
|
+
name: "execute",
|
|
9
|
+
stateMutability: "payable",
|
|
10
|
+
inputs: [
|
|
11
|
+
{
|
|
12
|
+
name: "batches",
|
|
13
|
+
type: "tuple[]",
|
|
14
|
+
components: [
|
|
15
|
+
{ name: "requiresV4Unlock", type: "bool" },
|
|
16
|
+
{ name: "actions", type: "bytes" },
|
|
17
|
+
{ name: "params", type: "bytes[]" }
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
{ name: "deadline", type: "uint256" }
|
|
21
|
+
],
|
|
22
|
+
outputs: []
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
type: "function",
|
|
26
|
+
name: "multicall",
|
|
27
|
+
stateMutability: "payable",
|
|
28
|
+
inputs: [{ name: "data", type: "bytes[]" }],
|
|
29
|
+
outputs: [{ name: "results", type: "bytes[]" }]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: "function",
|
|
33
|
+
name: "permitBatch",
|
|
34
|
+
stateMutability: "payable",
|
|
35
|
+
inputs: [
|
|
36
|
+
{ name: "owner", type: "address" },
|
|
37
|
+
{
|
|
38
|
+
name: "permitBatch",
|
|
39
|
+
type: "tuple",
|
|
40
|
+
components: [
|
|
41
|
+
{
|
|
42
|
+
name: "details",
|
|
43
|
+
type: "tuple[]",
|
|
44
|
+
components: [
|
|
45
|
+
{ name: "token", type: "address" },
|
|
46
|
+
{ name: "amount", type: "uint160" },
|
|
47
|
+
{ name: "expiration", type: "uint48" },
|
|
48
|
+
{ name: "nonce", type: "uint48" }
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{ name: "spender", type: "address" },
|
|
52
|
+
{ name: "sigDeadline", type: "uint256" }
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
{ name: "signature", type: "bytes" }
|
|
56
|
+
],
|
|
57
|
+
outputs: []
|
|
58
|
+
}
|
|
59
|
+
], sn = [
|
|
60
|
+
{
|
|
61
|
+
type: "function",
|
|
62
|
+
name: "allowance",
|
|
63
|
+
stateMutability: "view",
|
|
64
|
+
inputs: [
|
|
65
|
+
{ name: "owner", type: "address" },
|
|
66
|
+
{ name: "token", type: "address" },
|
|
67
|
+
{ name: "spender", type: "address" }
|
|
68
|
+
],
|
|
69
|
+
outputs: [
|
|
70
|
+
{ name: "amount", type: "uint160" },
|
|
71
|
+
{ name: "expiration", type: "uint48" },
|
|
72
|
+
{ name: "nonce", type: "uint48" }
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
], it = [
|
|
76
|
+
{
|
|
77
|
+
type: "function",
|
|
78
|
+
name: "quoteExactInputSingle",
|
|
79
|
+
stateMutability: "nonpayable",
|
|
80
|
+
inputs: [
|
|
81
|
+
{
|
|
82
|
+
name: "params",
|
|
83
|
+
type: "tuple",
|
|
84
|
+
components: [
|
|
85
|
+
{
|
|
86
|
+
name: "poolKey",
|
|
87
|
+
type: "tuple",
|
|
88
|
+
components: [
|
|
89
|
+
{ name: "currency0", type: "address" },
|
|
90
|
+
{ name: "currency1", type: "address" },
|
|
91
|
+
{ name: "fee", type: "uint24" },
|
|
92
|
+
{ name: "tickSpacing", type: "int24" },
|
|
93
|
+
{ name: "hooks", type: "address" }
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
{ name: "zeroForOne", type: "bool" },
|
|
97
|
+
{ name: "exactAmount", type: "uint128" },
|
|
98
|
+
{ name: "hookData", type: "bytes" }
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
],
|
|
102
|
+
outputs: [
|
|
103
|
+
{ name: "amountOut", type: "uint256" },
|
|
104
|
+
{ name: "gasEstimate", type: "uint256" }
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
type: "function",
|
|
109
|
+
name: "quoteExactOutputSingle",
|
|
110
|
+
stateMutability: "nonpayable",
|
|
111
|
+
inputs: [
|
|
112
|
+
{
|
|
113
|
+
name: "params",
|
|
114
|
+
type: "tuple",
|
|
115
|
+
components: [
|
|
116
|
+
{
|
|
117
|
+
name: "poolKey",
|
|
118
|
+
type: "tuple",
|
|
119
|
+
components: [
|
|
120
|
+
{ name: "currency0", type: "address" },
|
|
121
|
+
{ name: "currency1", type: "address" },
|
|
122
|
+
{ name: "fee", type: "uint24" },
|
|
123
|
+
{ name: "tickSpacing", type: "int24" },
|
|
124
|
+
{ name: "hooks", type: "address" }
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
{ name: "zeroForOne", type: "bool" },
|
|
128
|
+
{ name: "exactAmount", type: "uint128" },
|
|
129
|
+
{ name: "hookData", type: "bytes" }
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
outputs: [
|
|
134
|
+
{ name: "amountIn", type: "uint256" },
|
|
135
|
+
{ name: "gasEstimate", type: "uint256" }
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
], Fe = 0n, J = {
|
|
139
|
+
SWAP_EXACT_IN_SINGLE: 6,
|
|
140
|
+
SWAP_EXACT_OUT_SINGLE: 8,
|
|
141
|
+
SETTLE: 11,
|
|
142
|
+
TAKE: 14
|
|
143
|
+
}, wt = {
|
|
144
|
+
name: "poolKey",
|
|
145
|
+
type: "tuple",
|
|
146
|
+
components: [
|
|
147
|
+
{ name: "currency0", type: "address" },
|
|
148
|
+
{ name: "currency1", type: "address" },
|
|
149
|
+
{ name: "fee", type: "uint24" },
|
|
150
|
+
{ name: "tickSpacing", type: "int24" },
|
|
151
|
+
{ name: "hooks", type: "address" }
|
|
152
|
+
]
|
|
153
|
+
}, un = [
|
|
154
|
+
{
|
|
155
|
+
name: "params",
|
|
156
|
+
type: "tuple",
|
|
157
|
+
components: [
|
|
158
|
+
wt,
|
|
159
|
+
{ name: "zeroForOne", type: "bool" },
|
|
160
|
+
{ name: "amountIn", type: "uint128" },
|
|
161
|
+
{ name: "amountOutMinimum", type: "uint128" },
|
|
162
|
+
{ name: "hookData", type: "bytes" }
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
], ln = [
|
|
166
|
+
{
|
|
167
|
+
name: "params",
|
|
168
|
+
type: "tuple",
|
|
169
|
+
components: [
|
|
170
|
+
wt,
|
|
171
|
+
{ name: "zeroForOne", type: "bool" },
|
|
172
|
+
{ name: "amountOut", type: "uint128" },
|
|
173
|
+
{ name: "amountInMaximum", type: "uint128" },
|
|
174
|
+
{ name: "hookData", type: "bytes" }
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
], gt = [
|
|
178
|
+
{ name: "currency", type: "address" },
|
|
179
|
+
{ name: "amount", type: "uint256" },
|
|
180
|
+
{ name: "payerIsUser", type: "bool" }
|
|
181
|
+
], _t = [
|
|
182
|
+
{ name: "currency", type: "address" },
|
|
183
|
+
{ name: "recipient", type: "address" },
|
|
184
|
+
{ name: "amount", type: "uint256" }
|
|
185
|
+
];
|
|
186
|
+
function dn(e) {
|
|
187
|
+
return `0x${e.map((t) => t.toString(16).padStart(2, "0")).join("")}`;
|
|
188
|
+
}
|
|
189
|
+
function bt(e, t) {
|
|
190
|
+
return {
|
|
191
|
+
requiresV4Unlock: !0,
|
|
192
|
+
actions: dn(e),
|
|
193
|
+
params: t
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function It(e, t) {
|
|
197
|
+
return Le({
|
|
198
|
+
abi: qe,
|
|
199
|
+
functionName: "execute",
|
|
200
|
+
args: [e, t]
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
function pn(e) {
|
|
204
|
+
return Le({
|
|
205
|
+
abi: qe,
|
|
206
|
+
functionName: "permitBatch",
|
|
207
|
+
args: [e.owner, e.permitBatch, e.signature]
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
function mn(e) {
|
|
211
|
+
return Le({
|
|
212
|
+
abi: qe,
|
|
213
|
+
functionName: "multicall",
|
|
214
|
+
args: [e]
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
function Et(e, t) {
|
|
218
|
+
return t ? mn([pn(t), e]) : e;
|
|
219
|
+
}
|
|
220
|
+
function At(e) {
|
|
221
|
+
return en(
|
|
222
|
+
G(
|
|
223
|
+
[
|
|
224
|
+
{ name: "currency0", type: "address" },
|
|
225
|
+
{ name: "currency1", type: "address" },
|
|
226
|
+
{ name: "fee", type: "uint24" },
|
|
227
|
+
{ name: "tickSpacing", type: "int24" },
|
|
228
|
+
{ name: "hooks", type: "address" }
|
|
229
|
+
],
|
|
230
|
+
[
|
|
231
|
+
e.currency0,
|
|
232
|
+
e.currency1,
|
|
233
|
+
e.fee,
|
|
234
|
+
e.tickSpacing,
|
|
235
|
+
e.hooks
|
|
236
|
+
]
|
|
237
|
+
)
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
function fn(e) {
|
|
241
|
+
const t = e.zeroForOne ? e.poolKey.currency0 : e.poolKey.currency1, n = e.zeroForOne ? e.poolKey.currency1 : e.poolKey.currency0, o = bt(
|
|
242
|
+
[J.SWAP_EXACT_IN_SINGLE, J.SETTLE, J.TAKE],
|
|
243
|
+
[
|
|
244
|
+
G(un, [
|
|
245
|
+
{
|
|
246
|
+
poolKey: e.poolKey,
|
|
247
|
+
zeroForOne: e.zeroForOne,
|
|
248
|
+
amountIn: e.amountIn,
|
|
249
|
+
amountOutMinimum: e.amountOutMinimum,
|
|
250
|
+
hookData: "0x"
|
|
251
|
+
}
|
|
252
|
+
]),
|
|
253
|
+
G(gt, [t, e.amountIn, !0]),
|
|
254
|
+
G(_t, [n, e.recipient, Fe])
|
|
255
|
+
]
|
|
256
|
+
);
|
|
257
|
+
return {
|
|
258
|
+
calldata: Et(It([o], e.deadline), e.permit),
|
|
259
|
+
value: 0n
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
function hn(e) {
|
|
263
|
+
const t = e.zeroForOne ? e.poolKey.currency0 : e.poolKey.currency1, n = e.zeroForOne ? e.poolKey.currency1 : e.poolKey.currency0, o = bt(
|
|
264
|
+
[J.SWAP_EXACT_OUT_SINGLE, J.SETTLE, J.TAKE],
|
|
265
|
+
[
|
|
266
|
+
G(ln, [
|
|
267
|
+
{
|
|
268
|
+
poolKey: e.poolKey,
|
|
269
|
+
zeroForOne: e.zeroForOne,
|
|
270
|
+
amountOut: e.amountOut,
|
|
271
|
+
amountInMaximum: e.amountInMaximum,
|
|
272
|
+
hookData: "0x"
|
|
273
|
+
}
|
|
274
|
+
]),
|
|
275
|
+
G(gt, [t, Fe, !0]),
|
|
276
|
+
G(_t, [n, e.recipient, Fe])
|
|
277
|
+
]
|
|
278
|
+
);
|
|
279
|
+
return {
|
|
280
|
+
calldata: Et(It([o], e.deadline), e.permit),
|
|
281
|
+
value: 0n
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
const k = 1, St = m("0x00581261a1200956ea05d1810fF28ffd66D8E254"), Ct = m("0x000000000022D473030F116dDEE9F6B43aC78BA3"), Tt = m("0x52f0e24d1c21c8a0cb1e5a5dd6198556bd9e1203"), yn = m("0x8f29BD5c8429730fA4C46e6295c4e679eDEdd0cC"), wn = 8388608, gn = [
|
|
285
|
+
"https://eth.drpc.org",
|
|
286
|
+
"https://ethereum-rpc.publicnode.com",
|
|
287
|
+
"https://cloudflare-eth.com"
|
|
288
|
+
], _n = "https://aegis.markets/graphql/meta", bn = {
|
|
289
|
+
chainId: k,
|
|
290
|
+
chain: cn,
|
|
291
|
+
name: "Ethereum",
|
|
292
|
+
router: St,
|
|
293
|
+
permit2: Ct,
|
|
294
|
+
quoter: Tt,
|
|
295
|
+
rpcUrls: gn,
|
|
296
|
+
explorerTxUrl: (e) => `https://etherscan.io/tx/${e}`,
|
|
297
|
+
metadataEndpoint: _n
|
|
298
|
+
}, Ae = {
|
|
299
|
+
[k]: bn
|
|
300
|
+
}, _ = {
|
|
301
|
+
USDC: {
|
|
302
|
+
chainId: k,
|
|
303
|
+
address: m("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),
|
|
304
|
+
name: "USD Coin",
|
|
305
|
+
symbol: "USDC",
|
|
306
|
+
decimals: 6
|
|
307
|
+
},
|
|
308
|
+
WATER: {
|
|
309
|
+
chainId: k,
|
|
310
|
+
address: m("0x828B22c9ea1c20B551EeFC6198174C4bb7a8CBF6"),
|
|
311
|
+
name: "WATER",
|
|
312
|
+
symbol: "WATER",
|
|
313
|
+
decimals: 18
|
|
314
|
+
},
|
|
315
|
+
WOOD: {
|
|
316
|
+
chainId: k,
|
|
317
|
+
address: m("0x670AfdD7226e73d3CC55B5cd83933E46aF22DECd"),
|
|
318
|
+
name: "WOOD",
|
|
319
|
+
symbol: "WOOD",
|
|
320
|
+
decimals: 18
|
|
321
|
+
},
|
|
322
|
+
GRASS: {
|
|
323
|
+
chainId: k,
|
|
324
|
+
address: m("0xF06Ad052b0d8D511D0B6f00100b8e402639209EF"),
|
|
325
|
+
name: "GRASS",
|
|
326
|
+
symbol: "GRASS",
|
|
327
|
+
decimals: 18
|
|
328
|
+
},
|
|
329
|
+
STONE: {
|
|
330
|
+
chainId: k,
|
|
331
|
+
address: m("0xCabcc33D9Ff7e24F413d939773D232C0d50dCc7f"),
|
|
332
|
+
name: "STONE",
|
|
333
|
+
symbol: "STONE",
|
|
334
|
+
decimals: 18
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
function Ie(e, t, n, o, r) {
|
|
338
|
+
return {
|
|
339
|
+
chainId: k,
|
|
340
|
+
symbol: e,
|
|
341
|
+
poolId: t,
|
|
342
|
+
poolKey: {
|
|
343
|
+
currency0: n,
|
|
344
|
+
currency1: o,
|
|
345
|
+
fee: wn,
|
|
346
|
+
tickSpacing: r,
|
|
347
|
+
hooks: yn
|
|
348
|
+
},
|
|
349
|
+
token: _[e],
|
|
350
|
+
counterToken: _.USDC,
|
|
351
|
+
router: St,
|
|
352
|
+
permit2: Ct,
|
|
353
|
+
quoter: Tt,
|
|
354
|
+
label: `${_.USDC.symbol} / ${e}`
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
const xt = {
|
|
358
|
+
WATER: Ie(
|
|
359
|
+
"WATER",
|
|
360
|
+
"0x01409fc6f1bf49e20bf05df5d4dcb96ed3977ea717bc4a135e9deacd92ebc0af",
|
|
361
|
+
_.WATER.address,
|
|
362
|
+
_.USDC.address,
|
|
363
|
+
60
|
|
364
|
+
),
|
|
365
|
+
WOOD: Ie(
|
|
366
|
+
"WOOD",
|
|
367
|
+
"0x0f8a98e3fdb7ea4438a3f7342f040cbc9d1eced1b90a876d38f3453100243356",
|
|
368
|
+
_.WOOD.address,
|
|
369
|
+
_.USDC.address,
|
|
370
|
+
60
|
|
371
|
+
),
|
|
372
|
+
GRASS: Ie(
|
|
373
|
+
"GRASS",
|
|
374
|
+
"0xc516dba7bd70aa2dcb986bb1c27208ea29ecd097fa0ce636611e88e54ae4444d",
|
|
375
|
+
_.USDC.address,
|
|
376
|
+
_.GRASS.address,
|
|
377
|
+
30
|
|
378
|
+
),
|
|
379
|
+
STONE: Ie(
|
|
380
|
+
"STONE",
|
|
381
|
+
"0x3fa06e44e4bee9539887681eab6b608b646784e2027ea6292198cde0690aff54",
|
|
382
|
+
_.USDC.address,
|
|
383
|
+
_.STONE.address,
|
|
384
|
+
60
|
|
385
|
+
)
|
|
386
|
+
}, In = [
|
|
387
|
+
"WATER",
|
|
388
|
+
"WOOD",
|
|
389
|
+
"GRASS",
|
|
390
|
+
"STONE"
|
|
391
|
+
];
|
|
392
|
+
function ct(e) {
|
|
393
|
+
return {
|
|
394
|
+
...e,
|
|
395
|
+
address: m(e.address)
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
function En(e) {
|
|
399
|
+
return {
|
|
400
|
+
currency0: m(e.currency0),
|
|
401
|
+
currency1: m(e.currency1),
|
|
402
|
+
fee: e.fee,
|
|
403
|
+
tickSpacing: e.tickSpacing,
|
|
404
|
+
hooks: m(e.hooks)
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
function An(e) {
|
|
408
|
+
return "poolKey" in e;
|
|
409
|
+
}
|
|
410
|
+
function Sn(e, t) {
|
|
411
|
+
var n;
|
|
412
|
+
if (!t && (!e.chain || !e.router || !e.permit2 || !e.quoter || !((n = e.rpcUrls) != null && n.length)))
|
|
413
|
+
throw new Error(
|
|
414
|
+
`Missing viem chain, router, Permit2, Quoter, or RPC URLs for chain ${e.chainId}.`
|
|
415
|
+
);
|
|
416
|
+
return {
|
|
417
|
+
chainId: e.chainId,
|
|
418
|
+
chain: e.chain ?? t.chain,
|
|
419
|
+
name: e.name ?? (t == null ? void 0 : t.name) ?? `Chain ${e.chainId}`,
|
|
420
|
+
router: m(e.router ?? t.router),
|
|
421
|
+
permit2: m(e.permit2 ?? t.permit2),
|
|
422
|
+
quoter: m(e.quoter ?? t.quoter),
|
|
423
|
+
rpcUrls: e.rpcUrls ?? t.rpcUrls,
|
|
424
|
+
explorerTxUrl: e.explorerTxUrl ?? (t == null ? void 0 : t.explorerTxUrl),
|
|
425
|
+
poolExplorerUrl: e.poolExplorerUrl ?? (t == null ? void 0 : t.poolExplorerUrl),
|
|
426
|
+
metadataEndpoint: e.metadataEndpoint ?? (t == null ? void 0 : t.metadataEndpoint)
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
function Cn(e) {
|
|
430
|
+
const t = { ...Ae };
|
|
431
|
+
if (!e) return t;
|
|
432
|
+
for (const [n, o] of Object.entries(e)) {
|
|
433
|
+
if (!o) continue;
|
|
434
|
+
const r = o.chainId ?? Number(n);
|
|
435
|
+
t[r] = Sn(
|
|
436
|
+
{ ...o, chainId: r },
|
|
437
|
+
t[r]
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
return t;
|
|
441
|
+
}
|
|
442
|
+
function Tn(e, t, n = Ae) {
|
|
443
|
+
const o = xt[e], r = An(t) ? t : { poolKey: t }, s = r.chainId ?? (o == null ? void 0 : o.chainId) ?? k, u = n[s];
|
|
444
|
+
if (!u) throw new Error(`No Aegis swap chain config found for chain ${s}.`);
|
|
445
|
+
const I = En(r.poolKey), C = ct(r.token ?? o.token), w = ct(r.counterToken ?? o.counterToken);
|
|
446
|
+
return {
|
|
447
|
+
chainId: s,
|
|
448
|
+
symbol: e,
|
|
449
|
+
poolId: r.poolId ?? At(I),
|
|
450
|
+
poolKey: I,
|
|
451
|
+
token: C,
|
|
452
|
+
counterToken: w,
|
|
453
|
+
router: m(r.router ?? u.router),
|
|
454
|
+
permit2: m(r.permit2 ?? u.permit2),
|
|
455
|
+
quoter: m(r.quoter ?? u.quoter),
|
|
456
|
+
label: r.label ?? `${w.symbol} / ${C.symbol}`
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
function xn(e, t = Ae) {
|
|
460
|
+
return e ? Object.fromEntries(
|
|
461
|
+
Object.entries(e).map(([n, o]) => [
|
|
462
|
+
n,
|
|
463
|
+
Tn(n, o, t)
|
|
464
|
+
])
|
|
465
|
+
) : {};
|
|
466
|
+
}
|
|
467
|
+
function Re(e) {
|
|
468
|
+
const t = e.replace(/[^\d.]/g, ""), [n = "", ...o] = t.split("."), r = o.length > 0 ? `${n}.${o.join("")}` : n;
|
|
469
|
+
return r === "." ? "0." : r;
|
|
470
|
+
}
|
|
471
|
+
function On(e) {
|
|
472
|
+
const t = Re(e);
|
|
473
|
+
if (!t) return "";
|
|
474
|
+
const n = Number(t);
|
|
475
|
+
return Number.isFinite(n) && n > 20 ? "20" : t;
|
|
476
|
+
}
|
|
477
|
+
function st(e, t) {
|
|
478
|
+
const n = e.trim();
|
|
479
|
+
if (!n || n === ".") return null;
|
|
480
|
+
try {
|
|
481
|
+
return tn(n, t);
|
|
482
|
+
} catch {
|
|
483
|
+
return null;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
function ut(e) {
|
|
487
|
+
const t = e.trim();
|
|
488
|
+
if (!t) return null;
|
|
489
|
+
const n = Number(t);
|
|
490
|
+
return !Number.isFinite(n) || n < 0 || n > 20 ? null : Math.round(n * 100);
|
|
491
|
+
}
|
|
492
|
+
function lt(e, t, n = 6) {
|
|
493
|
+
if (e == null) return "--";
|
|
494
|
+
const o = yt(e, t), [r, s = ""] = o.split(".");
|
|
495
|
+
if (!s || n <= 0) return r;
|
|
496
|
+
const u = s.slice(0, n).replace(/0+$/, "");
|
|
497
|
+
return u ? `${r}.${u}` : r;
|
|
498
|
+
}
|
|
499
|
+
function De(e, t) {
|
|
500
|
+
return e == null ? "" : yt(e, t).replace(/\.?0+$/, "");
|
|
501
|
+
}
|
|
502
|
+
const kn = "https://ichi-images.s3.us-east-1.amazonaws.com/tokens", Me = /* @__PURE__ */ new Map();
|
|
503
|
+
function dt(e, t, n) {
|
|
504
|
+
return `${e}|evm_${t}_${n.toLowerCase()}`;
|
|
505
|
+
}
|
|
506
|
+
function Nn(e, t) {
|
|
507
|
+
return `evm_${e}_${t.toLowerCase()}`;
|
|
508
|
+
}
|
|
509
|
+
function vn(e) {
|
|
510
|
+
const t = e == null ? void 0 : e.trim();
|
|
511
|
+
if (!t) return null;
|
|
512
|
+
const n = t.split("-"), r = (n.length > 1 ? n[n.length - 1] : t).trim().toLowerCase();
|
|
513
|
+
return !r || !/^[a-z0-9]+$/.test(r) ? null : r;
|
|
514
|
+
}
|
|
515
|
+
function Pn(e) {
|
|
516
|
+
const t = vn(e);
|
|
517
|
+
return t ? `${kn}/logo_256_${t}.svg` : null;
|
|
518
|
+
}
|
|
519
|
+
function Dn(e, t) {
|
|
520
|
+
return `query AegisSwapWidgetTokenMetadata { ${t.map((o, r) => `t${r}: getGlobalToken(id: ${JSON.stringify(Nn(e, o))}) { chainId address symbol displayName fullName decimals iconURL }`).join(" ")} }`;
|
|
521
|
+
}
|
|
522
|
+
async function Mn(e) {
|
|
523
|
+
var I, C;
|
|
524
|
+
const t = e.endpoint.trim(), n = Array.from(
|
|
525
|
+
new Set(
|
|
526
|
+
e.addresses.map((w) => m(w).toLowerCase())
|
|
527
|
+
)
|
|
528
|
+
).map((w) => m(w)), o = /* @__PURE__ */ new Map(), r = n.filter((w) => {
|
|
529
|
+
const v = dt(t, e.chainId, w);
|
|
530
|
+
if (!Me.has(v)) return !0;
|
|
531
|
+
const P = Me.get(v);
|
|
532
|
+
return P && o.set(w.toLowerCase(), P), !1;
|
|
533
|
+
});
|
|
534
|
+
if (!r.length || typeof fetch != "function") return o;
|
|
535
|
+
const s = await fetch(t, {
|
|
536
|
+
method: "POST",
|
|
537
|
+
headers: { "Content-Type": "application/json" },
|
|
538
|
+
body: JSON.stringify({
|
|
539
|
+
query: Dn(e.chainId, r)
|
|
540
|
+
}),
|
|
541
|
+
signal: e.signal
|
|
542
|
+
});
|
|
543
|
+
if (!s.ok)
|
|
544
|
+
throw new Error(`Token metadata request failed with HTTP ${s.status}.`);
|
|
545
|
+
const u = await s.json();
|
|
546
|
+
if ((I = u.errors) != null && I.length)
|
|
547
|
+
throw new Error(((C = u.errors[0]) == null ? void 0 : C.message) ?? "Token metadata request failed.");
|
|
548
|
+
return r.forEach((w, v) => {
|
|
549
|
+
var pe;
|
|
550
|
+
const P = ((pe = u.data) == null ? void 0 : pe[`t${v}`]) ?? null;
|
|
551
|
+
Me.set(dt(t, e.chainId, w), P), P && o.set(w.toLowerCase(), P);
|
|
552
|
+
}), o;
|
|
553
|
+
}
|
|
554
|
+
const pt = 2n ** 160n - 1n, Un = 2n ** 256n - 1n, Bn = 1800, Fn = 1800, Rn = 60, Ln = {
|
|
555
|
+
PermitBatch: [
|
|
556
|
+
{ name: "details", type: "PermitDetails[]" },
|
|
557
|
+
{ name: "spender", type: "address" },
|
|
558
|
+
{ name: "sigDeadline", type: "uint256" }
|
|
559
|
+
],
|
|
560
|
+
PermitDetails: [
|
|
561
|
+
{ name: "token", type: "address" },
|
|
562
|
+
{ name: "amount", type: "uint160" },
|
|
563
|
+
{ name: "expiration", type: "uint48" },
|
|
564
|
+
{ name: "nonce", type: "uint48" }
|
|
565
|
+
]
|
|
566
|
+
};
|
|
567
|
+
async function Wn(e) {
|
|
568
|
+
const n = await We({
|
|
569
|
+
account: e.account,
|
|
570
|
+
chain: e.chain,
|
|
571
|
+
transport: $e(e.provider)
|
|
572
|
+
}).writeContract({
|
|
573
|
+
address: e.token,
|
|
574
|
+
abi: Ge,
|
|
575
|
+
functionName: "approve",
|
|
576
|
+
args: [e.permit2, Un]
|
|
577
|
+
});
|
|
578
|
+
if ((await e.publicClient.waitForTransactionReceipt({ hash: n })).status === "reverted") throw new Error("Token approval reverted.");
|
|
579
|
+
return n;
|
|
580
|
+
}
|
|
581
|
+
async function $n(e) {
|
|
582
|
+
const [t, n, o] = await e.publicClient.readContract({
|
|
583
|
+
address: e.permit2,
|
|
584
|
+
abi: sn,
|
|
585
|
+
functionName: "allowance",
|
|
586
|
+
args: [e.account, e.token, e.router]
|
|
587
|
+
}), r = Math.floor(Date.now() / 1e3);
|
|
588
|
+
if (t >= e.amount && Number(n) > r + Rn)
|
|
589
|
+
return null;
|
|
590
|
+
const s = {
|
|
591
|
+
details: [
|
|
592
|
+
{
|
|
593
|
+
token: e.token,
|
|
594
|
+
amount: e.amount > pt ? pt : e.amount,
|
|
595
|
+
expiration: r + Fn,
|
|
596
|
+
nonce: Number(o)
|
|
597
|
+
}
|
|
598
|
+
],
|
|
599
|
+
spender: e.router,
|
|
600
|
+
sigDeadline: BigInt(r + Bn)
|
|
601
|
+
}, I = await We({
|
|
602
|
+
account: e.account,
|
|
603
|
+
chain: e.chain,
|
|
604
|
+
transport: $e(e.provider)
|
|
605
|
+
}).signTypedData({
|
|
606
|
+
account: e.account,
|
|
607
|
+
domain: {
|
|
608
|
+
name: "Permit2",
|
|
609
|
+
chainId: e.chainId,
|
|
610
|
+
verifyingContract: e.permit2
|
|
611
|
+
},
|
|
612
|
+
types: Ln,
|
|
613
|
+
primaryType: "PermitBatch",
|
|
614
|
+
message: s
|
|
615
|
+
});
|
|
616
|
+
return {
|
|
617
|
+
owner: e.account,
|
|
618
|
+
permitBatch: s,
|
|
619
|
+
signature: I
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
const Gn = 2n ** 128n - 1n;
|
|
623
|
+
function $(e, t) {
|
|
624
|
+
return e.toLowerCase() === t.toLowerCase();
|
|
625
|
+
}
|
|
626
|
+
function Ot(e) {
|
|
627
|
+
if (!Number.isFinite(e) || e < 0 || e > 2e3)
|
|
628
|
+
throw new Error("Slippage must be between 0% and 20%.");
|
|
629
|
+
}
|
|
630
|
+
function qn(e, t) {
|
|
631
|
+
return Ot(t), e * BigInt(1e4 - Math.round(t)) / 10000n;
|
|
632
|
+
}
|
|
633
|
+
function Kn(e, t) {
|
|
634
|
+
return Ot(t), (e * BigInt(1e4 + Math.round(t)) + 9999n) / 10000n;
|
|
635
|
+
}
|
|
636
|
+
function zn(e, t) {
|
|
637
|
+
if ($(t.address, e.currency0)) return !0;
|
|
638
|
+
if ($(t.address, e.currency1)) return !1;
|
|
639
|
+
throw new Error("Input token is not part of this pool.");
|
|
640
|
+
}
|
|
641
|
+
function jn(e, t, n) {
|
|
642
|
+
if (At(e.poolKey).toLowerCase() !== e.poolId.toLowerCase())
|
|
643
|
+
throw new Error("Configured pool id does not match the pool key.");
|
|
644
|
+
const r = $(t.address, e.poolKey.currency0) || $(t.address, e.poolKey.currency1), s = $(n.address, e.poolKey.currency0) || $(n.address, e.poolKey.currency1);
|
|
645
|
+
if (!r || !s || $(t.address, n.address))
|
|
646
|
+
throw new Error("Selected tokens do not match this direct pool.");
|
|
647
|
+
}
|
|
648
|
+
function Qn(e, t) {
|
|
649
|
+
if (Array.isArray(e))
|
|
650
|
+
return { amount: e[0], gasEstimate: e[1] };
|
|
651
|
+
const n = e, o = n[t];
|
|
652
|
+
if (typeof o == "bigint" && typeof n.gasEstimate == "bigint")
|
|
653
|
+
return { amount: o, gasEstimate: n.gasEstimate };
|
|
654
|
+
throw new Error("Unexpected V4 Quoter response.");
|
|
655
|
+
}
|
|
656
|
+
async function Vn(e) {
|
|
657
|
+
var I, C;
|
|
658
|
+
if ((I = e.signal) != null && I.aborted) throw new DOMException("Quote request aborted", "AbortError");
|
|
659
|
+
if (e.amount <= 0n) throw new Error("Enter an amount to swap.");
|
|
660
|
+
if (e.amount > Gn) throw new Error("Amount is too large for a single V4 swap.");
|
|
661
|
+
jn(e.market, e.tokenIn, e.tokenOut);
|
|
662
|
+
const t = e.market.poolKey, n = zn(t, e.tokenIn), o = e.mode === "exactOut" ? await e.publicClient.simulateContract({
|
|
663
|
+
address: e.market.quoter,
|
|
664
|
+
abi: it,
|
|
665
|
+
functionName: "quoteExactOutputSingle",
|
|
666
|
+
args: [{ poolKey: t, zeroForOne: n, exactAmount: e.amount, hookData: "0x" }],
|
|
667
|
+
account: e.account
|
|
668
|
+
}) : await e.publicClient.simulateContract({
|
|
669
|
+
address: e.market.quoter,
|
|
670
|
+
abi: it,
|
|
671
|
+
functionName: "quoteExactInputSingle",
|
|
672
|
+
args: [{ poolKey: t, zeroForOne: n, exactAmount: e.amount, hookData: "0x" }],
|
|
673
|
+
account: e.account
|
|
674
|
+
});
|
|
675
|
+
if ((C = e.signal) != null && C.aborted) throw new DOMException("Quote request aborted", "AbortError");
|
|
676
|
+
const r = Qn(
|
|
677
|
+
o.result,
|
|
678
|
+
e.mode === "exactOut" ? "amountIn" : "amountOut"
|
|
679
|
+
), s = e.mode === "exactOut" ? r.amount : e.amount, u = e.mode === "exactOut" ? e.amount : r.amount;
|
|
680
|
+
return {
|
|
681
|
+
mode: e.mode,
|
|
682
|
+
poolKey: t,
|
|
683
|
+
zeroForOne: n,
|
|
684
|
+
amountIn: s,
|
|
685
|
+
amountOut: u,
|
|
686
|
+
amountOutMinimum: e.mode === "exactOut" ? u : qn(u, e.slippageBps),
|
|
687
|
+
amountInMaximum: e.mode === "exactOut" ? Kn(s, e.slippageBps) : s,
|
|
688
|
+
gasEstimate: r.gasEstimate
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
function Ue() {
|
|
692
|
+
return typeof window > "u" ? null : window.ethereum ?? null;
|
|
693
|
+
}
|
|
694
|
+
function kt(e) {
|
|
695
|
+
return typeof e != "string" || !nn(e) ? null : m(e);
|
|
696
|
+
}
|
|
697
|
+
async function Xn(e) {
|
|
698
|
+
const t = await e.request({ method: "eth_accounts" });
|
|
699
|
+
return kt(t == null ? void 0 : t[0]);
|
|
700
|
+
}
|
|
701
|
+
async function Hn(e) {
|
|
702
|
+
const t = await e.request({ method: "eth_requestAccounts" });
|
|
703
|
+
return kt(t == null ? void 0 : t[0]);
|
|
704
|
+
}
|
|
705
|
+
async function Be(e) {
|
|
706
|
+
const t = await e.request({ method: "eth_chainId" });
|
|
707
|
+
return typeof t != "string" ? null : Number.parseInt(t, 16);
|
|
708
|
+
}
|
|
709
|
+
async function Yn(e, t) {
|
|
710
|
+
await e.request({
|
|
711
|
+
method: "wallet_switchEthereumChain",
|
|
712
|
+
params: [{ chainId: `0x${t.toString(16)}` }]
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
function Zn(e, t) {
|
|
716
|
+
const n = e;
|
|
717
|
+
if (!n.on || !n.removeListener) return () => {
|
|
718
|
+
};
|
|
719
|
+
const o = () => {
|
|
720
|
+
var s;
|
|
721
|
+
return (s = t.onAccountsChanged) == null ? void 0 : s.call(t);
|
|
722
|
+
}, r = () => {
|
|
723
|
+
var s;
|
|
724
|
+
return (s = t.onChainChanged) == null ? void 0 : s.call(t);
|
|
725
|
+
};
|
|
726
|
+
return n.on("accountsChanged", o), n.on("chainChanged", r), () => {
|
|
727
|
+
var s, u;
|
|
728
|
+
(s = n.removeListener) == null || s.call(n, "accountsChanged", o), (u = n.removeListener) == null || u.call(n, "chainChanged", r);
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
function Jn(e, t) {
|
|
732
|
+
const n = t.map(
|
|
733
|
+
(o) => an(o, {
|
|
734
|
+
batch: !0,
|
|
735
|
+
retryCount: 2,
|
|
736
|
+
retryDelay: 150,
|
|
737
|
+
timeout: 1e4
|
|
738
|
+
})
|
|
739
|
+
);
|
|
740
|
+
return on({
|
|
741
|
+
chain: e,
|
|
742
|
+
transport: n.length === 1 ? n[0] : rn(n)
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
function Ee(e, t, n) {
|
|
746
|
+
return e.readContract({
|
|
747
|
+
address: t.address,
|
|
748
|
+
abi: Ge,
|
|
749
|
+
functionName: "balanceOf",
|
|
750
|
+
args: [n]
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
function Nt(e) {
|
|
754
|
+
if (!e) return null;
|
|
755
|
+
try {
|
|
756
|
+
return m(e);
|
|
757
|
+
} catch {
|
|
758
|
+
return null;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
function ea(e) {
|
|
762
|
+
return !!(e && typeof e == "object" && typeof e.request == "function");
|
|
763
|
+
}
|
|
764
|
+
function ta(e) {
|
|
765
|
+
return ea(e) ? { provider: e, account: null } : !e || typeof e != "object" ? { provider: null, account: null } : {
|
|
766
|
+
provider: e.provider ?? null,
|
|
767
|
+
account: Nt(e.account)
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
function mt(e, t) {
|
|
771
|
+
return e instanceof Error && e.message ? e.message : t;
|
|
772
|
+
}
|
|
773
|
+
function ft(e, t) {
|
|
774
|
+
var n;
|
|
775
|
+
return ((n = t.explorerTxUrl) == null ? void 0 : n.call(t, e)) ?? "#";
|
|
776
|
+
}
|
|
777
|
+
function na(e, t) {
|
|
778
|
+
return e[t] ?? null;
|
|
779
|
+
}
|
|
780
|
+
function Z(e) {
|
|
781
|
+
return e === "approving" || e === "signing" || e === "submitting";
|
|
782
|
+
}
|
|
783
|
+
function aa(e, t) {
|
|
784
|
+
return (e ?? t) === "light" ? "light" : "dark";
|
|
785
|
+
}
|
|
786
|
+
function oa(e) {
|
|
787
|
+
return e.address.toLowerCase();
|
|
788
|
+
}
|
|
789
|
+
const ra = {
|
|
790
|
+
USDC: { primary: "#d7ecff", secondary: "#2775ca", text: "#06111f" },
|
|
791
|
+
WATER: { primary: "#87dcff", secondary: "#0f5d96", text: "#051621" },
|
|
792
|
+
WOOD: { primary: "#c79a62", secondary: "#45633d", text: "#171008" },
|
|
793
|
+
GRASS: { primary: "#76e28a", secondary: "#244f32", text: "#061508" },
|
|
794
|
+
STONE: { primary: "#d7d1c3", secondary: "#5a6366", text: "#111416" }
|
|
795
|
+
};
|
|
796
|
+
function ia(e) {
|
|
797
|
+
const t = ra[e];
|
|
798
|
+
return {
|
|
799
|
+
"--aegis-token-primary": t.primary,
|
|
800
|
+
"--aegis-token-secondary": t.secondary,
|
|
801
|
+
"--aegis-token-text": t.text
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
function ca(e, t) {
|
|
805
|
+
var n;
|
|
806
|
+
return e.iconUrl ?? ((n = t[oa(e)]) == null ? void 0 : n.iconURL) ?? Pn(e.symbol);
|
|
807
|
+
}
|
|
808
|
+
function de({
|
|
809
|
+
token: e,
|
|
810
|
+
metadataByAddress: t,
|
|
811
|
+
className: n
|
|
812
|
+
}) {
|
|
813
|
+
const o = ca(e, t), [r, s] = g(null), u = o && r !== o ? o : null;
|
|
814
|
+
return /* @__PURE__ */ c("span", { className: n, style: ia(e.symbol), "aria-hidden": "true", children: u ? /* @__PURE__ */ c(
|
|
815
|
+
"img",
|
|
816
|
+
{
|
|
817
|
+
src: u,
|
|
818
|
+
alt: "",
|
|
819
|
+
loading: "lazy",
|
|
820
|
+
decoding: "async",
|
|
821
|
+
onError: () => s(u)
|
|
822
|
+
}
|
|
823
|
+
) : e.symbol.slice(0, 1) });
|
|
824
|
+
}
|
|
825
|
+
function ht({
|
|
826
|
+
market: e,
|
|
827
|
+
metadataByAddress: t,
|
|
828
|
+
className: n
|
|
829
|
+
}) {
|
|
830
|
+
return /* @__PURE__ */ y("span", { className: n, "aria-hidden": "true", children: [
|
|
831
|
+
/* @__PURE__ */ c(
|
|
832
|
+
de,
|
|
833
|
+
{
|
|
834
|
+
token: e.counterToken,
|
|
835
|
+
metadataByAddress: t,
|
|
836
|
+
className: "aegis-swap-widget__pair-icon aegis-swap-widget__pair-icon--primary"
|
|
837
|
+
}
|
|
838
|
+
),
|
|
839
|
+
/* @__PURE__ */ c(
|
|
840
|
+
de,
|
|
841
|
+
{
|
|
842
|
+
token: e.token,
|
|
843
|
+
metadataByAddress: t,
|
|
844
|
+
className: "aegis-swap-widget__pair-icon aegis-swap-widget__pair-icon--secondary"
|
|
845
|
+
}
|
|
846
|
+
)
|
|
847
|
+
] });
|
|
848
|
+
}
|
|
849
|
+
function sa() {
|
|
850
|
+
return /* @__PURE__ */ y("svg", { viewBox: "0 0 150 151", "aria-hidden": "true", focusable: "false", children: [
|
|
851
|
+
/* @__PURE__ */ c(
|
|
852
|
+
"path",
|
|
853
|
+
{
|
|
854
|
+
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",
|
|
855
|
+
fill: "currentColor",
|
|
856
|
+
opacity: "0.92"
|
|
857
|
+
}
|
|
858
|
+
),
|
|
859
|
+
/* @__PURE__ */ c(
|
|
860
|
+
"path",
|
|
861
|
+
{
|
|
862
|
+
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",
|
|
863
|
+
fill: "currentColor",
|
|
864
|
+
opacity: "0.42"
|
|
865
|
+
}
|
|
866
|
+
)
|
|
867
|
+
] });
|
|
868
|
+
}
|
|
869
|
+
function ua() {
|
|
870
|
+
return /* @__PURE__ */ y("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
|
|
871
|
+
/* @__PURE__ */ c("path", { d: "m3 16 4 4 4-4" }),
|
|
872
|
+
/* @__PURE__ */ c("path", { d: "M7 20V4" }),
|
|
873
|
+
/* @__PURE__ */ c("path", { d: "m21 8-4-4-4 4" }),
|
|
874
|
+
/* @__PURE__ */ c("path", { d: "M17 4v16" })
|
|
875
|
+
] });
|
|
876
|
+
}
|
|
877
|
+
function la({
|
|
878
|
+
provider: e,
|
|
879
|
+
account: t,
|
|
880
|
+
getProvider: n,
|
|
881
|
+
onConnectWallet: o,
|
|
882
|
+
onSubmitted: r,
|
|
883
|
+
onSuccess: s,
|
|
884
|
+
onError: u,
|
|
885
|
+
chainId: I = k,
|
|
886
|
+
chains: C,
|
|
887
|
+
poolKeys: w,
|
|
888
|
+
targets: v,
|
|
889
|
+
markets: P,
|
|
890
|
+
defaultTarget: pe = "WATER",
|
|
891
|
+
defaultDirection: vt = "intoTarget",
|
|
892
|
+
defaultSlippagePercent: Pt = "1",
|
|
893
|
+
rpcUrls: Dt,
|
|
894
|
+
metadataEndpoint: Ke,
|
|
895
|
+
className: Mt,
|
|
896
|
+
theme: Ut,
|
|
897
|
+
themeMode: Bt,
|
|
898
|
+
accentColor: ze = "#2fbf7a",
|
|
899
|
+
accentTextColor: Se,
|
|
900
|
+
showPoolLink: Ft = !0
|
|
901
|
+
}) {
|
|
902
|
+
var rt;
|
|
903
|
+
const Rt = aa(Ut, Bt), Lt = O(() => {
|
|
904
|
+
const a = {
|
|
905
|
+
"--aegis-swap-accent": ze
|
|
906
|
+
};
|
|
907
|
+
return Se && (a["--aegis-swap-accent-text"] = Se), a;
|
|
908
|
+
}, [ze, Se]), Ce = O(() => Cn(C), [C]), l = Ce[I] ?? Ae[k], je = O(
|
|
909
|
+
() => xn(w, Ce),
|
|
910
|
+
[Ce, w]
|
|
911
|
+
), q = O(
|
|
912
|
+
() => ({ ...xt, ...je, ...P }),
|
|
913
|
+
[P, je]
|
|
914
|
+
), F = O(() => (v && v.length > 0 ? v : w ? Object.keys(w) : In).filter((i) => {
|
|
915
|
+
var p;
|
|
916
|
+
return ((p = q[i]) == null ? void 0 : p.chainId) === l.chainId;
|
|
917
|
+
}), [l.chainId, q, w, v]), Qe = Dt ?? l.rpcUrls, Te = Ke === void 0 ? l.metadataEndpoint : Ke, b = O(
|
|
918
|
+
() => Jn(l.chain, Qe),
|
|
919
|
+
[l.chain, Qe]
|
|
920
|
+
), M = Nt(t), [ee, Ve] = g(pe), [me, Wt] = g(vt), [D, K] = g("exactIn"), [fe, z] = g(""), [Xe, j] = g(""), [he, He] = g(Pt), [$t, ye] = g(M), [Ye, te] = g(null), [U, we] = g({ input: null, output: null }), [f, ne] = g(null), [Ze, xe] = g(!1), [ge, ae] = g(null), [N, T] = g("idle"), [Je, et] = g(null), [tt, oe] = g(null), [re, Gt] = g({}), [qt, Oe] = g(null), Q = le(async () => {
|
|
921
|
+
if (e) return e;
|
|
922
|
+
if (n) {
|
|
923
|
+
const a = await n();
|
|
924
|
+
if (a) return a;
|
|
925
|
+
}
|
|
926
|
+
return Ue();
|
|
927
|
+
}, [n, e]), ie = e ?? qt ?? Ue(), E = M ?? $t, _e = na(q, ee), d = (_e == null ? void 0 : _e.chainId) === l.chainId ? _e : null, V = (d == null ? void 0 : d.token) ?? _[ee], X = (d == null ? void 0 : d.counterToken) ?? _.USDC, h = me === "intoTarget" ? X : V, A = me === "intoTarget" ? V : X, H = D === "exactOut" ? Xe : fe, nt = D === "exactOut" ? A : h, ce = O(
|
|
928
|
+
() => st(H, nt.decimals),
|
|
929
|
+
[H, nt.decimals]
|
|
930
|
+
);
|
|
931
|
+
O(
|
|
932
|
+
() => st(fe, h.decimals),
|
|
933
|
+
[h.decimals, fe]
|
|
934
|
+
);
|
|
935
|
+
const B = O(() => ut(he), [he]), ke = Ye !== null && Ye !== l.chainId, Ne = H.trim().length > 0 && ce === null, R = D === "exactOut" ? f == null ? void 0 : f.amountInMaximum : f == null ? void 0 : f.amountIn, ve = R !== void 0 && U.input !== null && R > U.input, at = d ? ((rt = l.poolExplorerUrl) == null ? void 0 : rt.call(l, d.poolId, d)) ?? null : null, Kt = D === "exactOut" && f ? De(f.amountIn, h.decimals) : fe, zt = D === "exactIn" && f ? De(f.amountOut, A.decimals) : Xe, Pe = O(() => {
|
|
936
|
+
const a = /* @__PURE__ */ new Set();
|
|
937
|
+
for (const i of F) {
|
|
938
|
+
const p = q[i];
|
|
939
|
+
!p || p.chainId !== l.chainId || (a.add(p.token.address), a.add(p.counterToken.address));
|
|
940
|
+
}
|
|
941
|
+
return [...a];
|
|
942
|
+
}, [l.chainId, q, F]);
|
|
943
|
+
W(() => {
|
|
944
|
+
ye(M);
|
|
945
|
+
}, [M]), W(() => {
|
|
946
|
+
let a = !1;
|
|
947
|
+
return Q().then((i) => {
|
|
948
|
+
a || Oe(i);
|
|
949
|
+
}).catch((i) => {
|
|
950
|
+
a || (console.warn("[AegisSwapWidget] Provider resolver unavailable", i), Oe(Ue()));
|
|
951
|
+
}), () => {
|
|
952
|
+
a = !0;
|
|
953
|
+
};
|
|
954
|
+
}, [Q]), W(() => {
|
|
955
|
+
if (!Te || !Pe.length) return;
|
|
956
|
+
const a = new AbortController();
|
|
957
|
+
return Mn({
|
|
958
|
+
endpoint: Te,
|
|
959
|
+
chainId: l.chainId,
|
|
960
|
+
addresses: Pe,
|
|
961
|
+
signal: a.signal
|
|
962
|
+
}).then((i) => {
|
|
963
|
+
a.signal.aborted || i.size === 0 || Gt((p) => {
|
|
964
|
+
let x = !1;
|
|
965
|
+
const S = { ...p };
|
|
966
|
+
return i.forEach((se, L) => {
|
|
967
|
+
var be;
|
|
968
|
+
((be = S[L]) == null ? void 0 : be.iconURL) !== se.iconURL && (S[L] = se, x = !0);
|
|
969
|
+
}), x ? S : p;
|
|
970
|
+
});
|
|
971
|
+
}).catch((i) => {
|
|
972
|
+
a.signal.aborted || console.warn("[AegisSwapWidget] Token metadata icons unavailable", i);
|
|
973
|
+
}), () => a.abort();
|
|
974
|
+
}, [l.chainId, Pe, Te]), W(() => {
|
|
975
|
+
F.length > 0 && !F.includes(ee) && (Ve(F[0]), K("exactIn"), z(""), j(""), ne(null), ae(null), T("idle"));
|
|
976
|
+
}, [ee, F]), W(() => {
|
|
977
|
+
if (!ie) return;
|
|
978
|
+
let a = !1;
|
|
979
|
+
const i = async () => {
|
|
980
|
+
try {
|
|
981
|
+
const [x, S] = await Promise.all([
|
|
982
|
+
M ? Promise.resolve(M) : Xn(ie),
|
|
983
|
+
Be(ie)
|
|
984
|
+
]);
|
|
985
|
+
if (a) return;
|
|
986
|
+
ye(x), te(S);
|
|
987
|
+
} catch {
|
|
988
|
+
a || (M || ye(null), te(null));
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
i();
|
|
992
|
+
const p = Zn(ie, {
|
|
993
|
+
onAccountsChanged: i,
|
|
994
|
+
onChainChanged: i
|
|
995
|
+
});
|
|
996
|
+
return () => {
|
|
997
|
+
a = !0, p();
|
|
998
|
+
};
|
|
999
|
+
}, [M, ie]), W(() => {
|
|
1000
|
+
let a = !1;
|
|
1001
|
+
async function i() {
|
|
1002
|
+
if (!E) {
|
|
1003
|
+
we({ input: null, output: null });
|
|
1004
|
+
return;
|
|
1005
|
+
}
|
|
1006
|
+
try {
|
|
1007
|
+
const [x, S] = await Promise.all([
|
|
1008
|
+
Ee(b, h, E),
|
|
1009
|
+
Ee(b, A, E)
|
|
1010
|
+
]);
|
|
1011
|
+
a || we({ input: x, output: S });
|
|
1012
|
+
} catch {
|
|
1013
|
+
a || we({ input: null, output: null });
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
i();
|
|
1017
|
+
const p = window.setInterval(i, 5e3);
|
|
1018
|
+
return () => {
|
|
1019
|
+
a = !0, window.clearInterval(p);
|
|
1020
|
+
};
|
|
1021
|
+
}, [h, A, E, b]), W(() => {
|
|
1022
|
+
const a = new AbortController();
|
|
1023
|
+
if (ne(null), ae(null), !E || !d || !ce || ce <= 0n || B === null)
|
|
1024
|
+
return xe(!1), () => a.abort();
|
|
1025
|
+
xe(!0);
|
|
1026
|
+
const i = window.setTimeout(() => {
|
|
1027
|
+
Vn({
|
|
1028
|
+
publicClient: b,
|
|
1029
|
+
account: E,
|
|
1030
|
+
market: d,
|
|
1031
|
+
tokenIn: h,
|
|
1032
|
+
tokenOut: A,
|
|
1033
|
+
mode: D,
|
|
1034
|
+
amount: ce,
|
|
1035
|
+
slippageBps: B,
|
|
1036
|
+
signal: a.signal
|
|
1037
|
+
}).then((p) => {
|
|
1038
|
+
a.signal.aborted || (ne(p), ae(null));
|
|
1039
|
+
}).catch((p) => {
|
|
1040
|
+
a.signal.aborted || ae(mt(p, "Quote unavailable."));
|
|
1041
|
+
}).finally(() => {
|
|
1042
|
+
a.signal.aborted || xe(!1);
|
|
1043
|
+
});
|
|
1044
|
+
}, 250);
|
|
1045
|
+
return () => {
|
|
1046
|
+
window.clearTimeout(i), a.abort();
|
|
1047
|
+
};
|
|
1048
|
+
}, [
|
|
1049
|
+
ce,
|
|
1050
|
+
h,
|
|
1051
|
+
d,
|
|
1052
|
+
A,
|
|
1053
|
+
E,
|
|
1054
|
+
b,
|
|
1055
|
+
D,
|
|
1056
|
+
B
|
|
1057
|
+
]);
|
|
1058
|
+
const ot = le(async () => {
|
|
1059
|
+
oe(null);
|
|
1060
|
+
const a = ta(
|
|
1061
|
+
o ? await o() : void 0
|
|
1062
|
+
), i = a.provider ?? await Q();
|
|
1063
|
+
if (!i)
|
|
1064
|
+
return oe("No wallet provider found."), null;
|
|
1065
|
+
Oe(i);
|
|
1066
|
+
const p = a.account ?? await Hn(i), x = await Be(i);
|
|
1067
|
+
return ye(p), te(x), { provider: i, account: p };
|
|
1068
|
+
}, [Q, o]), jt = le(() => {
|
|
1069
|
+
U.input !== null && (K("exactIn"), z(De(U.input, h.decimals)), j(""), T("idle"));
|
|
1070
|
+
}, [U.input, h.decimals]), Qt = le(() => {
|
|
1071
|
+
Wt((a) => a === "intoTarget" ? "outOfTarget" : "intoTarget"), K("exactIn"), z(""), j(""), ne(null), ae(null), T("idle");
|
|
1072
|
+
}, []), Vt = le(async () => {
|
|
1073
|
+
oe(null), et(null);
|
|
1074
|
+
try {
|
|
1075
|
+
let a = await Q(), i = E;
|
|
1076
|
+
if (!a || !i) {
|
|
1077
|
+
const Y = await ot();
|
|
1078
|
+
a = (Y == null ? void 0 : Y.provider) ?? a, i = i ?? (Y == null ? void 0 : Y.account) ?? null;
|
|
1079
|
+
}
|
|
1080
|
+
if (!a) {
|
|
1081
|
+
oe("No wallet provider found.");
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1084
|
+
if (!i) return;
|
|
1085
|
+
const p = await Be(a);
|
|
1086
|
+
if (te(p), p !== l.chainId) {
|
|
1087
|
+
await Yn(a, l.chainId), te(l.chainId);
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
if (!d || !f || !R || R <= 0n || B === null) return;
|
|
1091
|
+
await b.readContract({
|
|
1092
|
+
address: h.address,
|
|
1093
|
+
abi: Ge,
|
|
1094
|
+
functionName: "allowance",
|
|
1095
|
+
args: [i, d.permit2]
|
|
1096
|
+
}) < R && (T("approving"), await Wn({
|
|
1097
|
+
provider: a,
|
|
1098
|
+
publicClient: b,
|
|
1099
|
+
account: i,
|
|
1100
|
+
chain: l.chain,
|
|
1101
|
+
token: h.address,
|
|
1102
|
+
permit2: d.permit2
|
|
1103
|
+
})), T("signing");
|
|
1104
|
+
const S = await $n({
|
|
1105
|
+
provider: a,
|
|
1106
|
+
publicClient: b,
|
|
1107
|
+
account: i,
|
|
1108
|
+
chainId: l.chainId,
|
|
1109
|
+
chain: l.chain,
|
|
1110
|
+
permit2: d.permit2,
|
|
1111
|
+
router: d.router,
|
|
1112
|
+
token: h.address,
|
|
1113
|
+
amount: R
|
|
1114
|
+
}), se = BigInt(Math.floor(Date.now() / 1e3) + 600), L = f.mode === "exactOut" ? hn({
|
|
1115
|
+
poolKey: f.poolKey,
|
|
1116
|
+
zeroForOne: f.zeroForOne,
|
|
1117
|
+
amountOut: f.amountOut,
|
|
1118
|
+
amountInMaximum: f.amountInMaximum,
|
|
1119
|
+
recipient: i,
|
|
1120
|
+
deadline: se,
|
|
1121
|
+
permit: S
|
|
1122
|
+
}) : fn({
|
|
1123
|
+
poolKey: f.poolKey,
|
|
1124
|
+
zeroForOne: f.zeroForOne,
|
|
1125
|
+
amountIn: f.amountIn,
|
|
1126
|
+
amountOutMinimum: f.amountOutMinimum,
|
|
1127
|
+
recipient: i,
|
|
1128
|
+
deadline: se,
|
|
1129
|
+
permit: S
|
|
1130
|
+
});
|
|
1131
|
+
T("submitting");
|
|
1132
|
+
const be = We({
|
|
1133
|
+
account: i,
|
|
1134
|
+
chain: l.chain,
|
|
1135
|
+
transport: $e(a)
|
|
1136
|
+
}), Yt = await b.estimateGas({
|
|
1137
|
+
account: i,
|
|
1138
|
+
to: d.router,
|
|
1139
|
+
data: L.calldata,
|
|
1140
|
+
value: L.value
|
|
1141
|
+
}), ue = await be.sendTransaction({
|
|
1142
|
+
to: d.router,
|
|
1143
|
+
data: L.calldata,
|
|
1144
|
+
value: L.value,
|
|
1145
|
+
gas: Yt * 12n / 10n
|
|
1146
|
+
});
|
|
1147
|
+
if (et(ue), r == null || r(ue), (await b.waitForTransactionReceipt({ hash: ue })).status === "reverted") throw new Error("Swap reverted on-chain.");
|
|
1148
|
+
T("success"), s == null || s({ hash: ue, explorerUrl: ft(ue, l) });
|
|
1149
|
+
const [Zt, Jt] = await Promise.all([
|
|
1150
|
+
Ee(b, h, i),
|
|
1151
|
+
Ee(b, A, i)
|
|
1152
|
+
]);
|
|
1153
|
+
we({ input: Zt, output: Jt });
|
|
1154
|
+
} catch (a) {
|
|
1155
|
+
const i = mt(a, "Swap failed."), p = a instanceof Error ? a : new Error(i);
|
|
1156
|
+
oe(i), T("idle"), u == null || u(p);
|
|
1157
|
+
}
|
|
1158
|
+
}, [
|
|
1159
|
+
ot,
|
|
1160
|
+
l,
|
|
1161
|
+
Q,
|
|
1162
|
+
h,
|
|
1163
|
+
d,
|
|
1164
|
+
u,
|
|
1165
|
+
r,
|
|
1166
|
+
s,
|
|
1167
|
+
A,
|
|
1168
|
+
E,
|
|
1169
|
+
b,
|
|
1170
|
+
f,
|
|
1171
|
+
B,
|
|
1172
|
+
R
|
|
1173
|
+
]), Xt = O(() => N === "approving" ? `Approving ${h.symbol}` : N === "signing" ? "Signing permit" : N === "submitting" ? "Swapping" : E ? ke ? `Switch to ${l.name}` : d ? H.trim() ? Ne ? "Invalid amount" : B === null ? "Invalid slippage" : ve ? `Insufficient ${h.symbol}` : Ze ? "Fetching quote" : ge ? "Quote unavailable" : me === "intoTarget" ? `Swap to ${V.symbol}` : `Swap to ${X.symbol}` : "Enter amount" : "Pool unavailable" : "Connect wallet", [
|
|
1174
|
+
H,
|
|
1175
|
+
l.name,
|
|
1176
|
+
Ne,
|
|
1177
|
+
X.symbol,
|
|
1178
|
+
me,
|
|
1179
|
+
h.symbol,
|
|
1180
|
+
ve,
|
|
1181
|
+
d,
|
|
1182
|
+
E,
|
|
1183
|
+
ge,
|
|
1184
|
+
Ze,
|
|
1185
|
+
B,
|
|
1186
|
+
N,
|
|
1187
|
+
V.symbol,
|
|
1188
|
+
ke
|
|
1189
|
+
]), Ht = !!(!Z(N) && d && H.trim() && !Ne && B !== null && !ve && (!E || ke || f));
|
|
1190
|
+
return /* @__PURE__ */ y(
|
|
1191
|
+
"section",
|
|
1192
|
+
{
|
|
1193
|
+
className: [
|
|
1194
|
+
"aegis-swap-widget",
|
|
1195
|
+
`aegis-swap-widget--${Rt}`,
|
|
1196
|
+
Mt ?? ""
|
|
1197
|
+
].join(" "),
|
|
1198
|
+
style: Lt,
|
|
1199
|
+
"aria-label": "Aegis direct pool swap",
|
|
1200
|
+
children: [
|
|
1201
|
+
/* @__PURE__ */ y("div", { className: "aegis-swap-widget__header", children: [
|
|
1202
|
+
/* @__PURE__ */ y("div", { className: "aegis-swap-widget__brand", children: [
|
|
1203
|
+
/* @__PURE__ */ c("span", { className: "aegis-swap-widget__logo", children: /* @__PURE__ */ c(sa, {}) }),
|
|
1204
|
+
/* @__PURE__ */ y("div", { children: [
|
|
1205
|
+
/* @__PURE__ */ c("span", { className: "aegis-swap-widget__eyebrow", children: "Direct pool router" }),
|
|
1206
|
+
/* @__PURE__ */ c("h2", { children: "Aegis Swap" })
|
|
1207
|
+
] })
|
|
1208
|
+
] }),
|
|
1209
|
+
/* @__PURE__ */ c("div", { className: "aegis-swap-widget__chain", children: l.name })
|
|
1210
|
+
] }),
|
|
1211
|
+
/* @__PURE__ */ c("div", { className: "aegis-swap-widget__targets", role: "tablist", "aria-label": "Swap token", children: F.map((a) => {
|
|
1212
|
+
const i = q[a], p = !!i, x = a === ee, S = (i == null ? void 0 : i.token) ?? _[a];
|
|
1213
|
+
return /* @__PURE__ */ y(
|
|
1214
|
+
"button",
|
|
1215
|
+
{
|
|
1216
|
+
type: "button",
|
|
1217
|
+
className: "aegis-swap-widget__target",
|
|
1218
|
+
"aria-selected": x,
|
|
1219
|
+
disabled: !p || Z(N),
|
|
1220
|
+
onClick: () => {
|
|
1221
|
+
Ve(a), K("exactIn"), z(""), j(""), ne(null), T("idle");
|
|
1222
|
+
},
|
|
1223
|
+
children: [
|
|
1224
|
+
i ? /* @__PURE__ */ c(
|
|
1225
|
+
ht,
|
|
1226
|
+
{
|
|
1227
|
+
market: i,
|
|
1228
|
+
metadataByAddress: re,
|
|
1229
|
+
className: "aegis-swap-widget__target-pair"
|
|
1230
|
+
}
|
|
1231
|
+
) : /* @__PURE__ */ c(
|
|
1232
|
+
de,
|
|
1233
|
+
{
|
|
1234
|
+
token: S,
|
|
1235
|
+
metadataByAddress: re,
|
|
1236
|
+
className: "aegis-swap-widget__target-mark"
|
|
1237
|
+
}
|
|
1238
|
+
),
|
|
1239
|
+
/* @__PURE__ */ c("span", { className: "aegis-swap-widget__target-symbol", children: a })
|
|
1240
|
+
]
|
|
1241
|
+
},
|
|
1242
|
+
a
|
|
1243
|
+
);
|
|
1244
|
+
}) }),
|
|
1245
|
+
/* @__PURE__ */ y("div", { className: "aegis-swap-widget__panel", children: [
|
|
1246
|
+
/* @__PURE__ */ y("label", { className: "aegis-swap-widget__amount-box", children: [
|
|
1247
|
+
/* @__PURE__ */ y("span", { className: "aegis-swap-widget__field-label", children: [
|
|
1248
|
+
"Sell",
|
|
1249
|
+
/* @__PURE__ */ c(
|
|
1250
|
+
"button",
|
|
1251
|
+
{
|
|
1252
|
+
type: "button",
|
|
1253
|
+
className: "aegis-swap-widget__max",
|
|
1254
|
+
disabled: U.input === null || Z(N),
|
|
1255
|
+
onClick: jt,
|
|
1256
|
+
children: "Max"
|
|
1257
|
+
}
|
|
1258
|
+
)
|
|
1259
|
+
] }),
|
|
1260
|
+
/* @__PURE__ */ y("span", { className: "aegis-swap-widget__amount-row", children: [
|
|
1261
|
+
/* @__PURE__ */ c(
|
|
1262
|
+
"input",
|
|
1263
|
+
{
|
|
1264
|
+
inputMode: "decimal",
|
|
1265
|
+
autoComplete: "off",
|
|
1266
|
+
value: Kt,
|
|
1267
|
+
onChange: (a) => {
|
|
1268
|
+
K("exactIn"), z(Re(a.target.value)), j(""), T("idle");
|
|
1269
|
+
},
|
|
1270
|
+
placeholder: "0",
|
|
1271
|
+
disabled: D === "exactOut" || Z(N)
|
|
1272
|
+
}
|
|
1273
|
+
),
|
|
1274
|
+
/* @__PURE__ */ y("span", { className: "aegis-swap-widget__token", children: [
|
|
1275
|
+
/* @__PURE__ */ c(
|
|
1276
|
+
de,
|
|
1277
|
+
{
|
|
1278
|
+
token: h,
|
|
1279
|
+
metadataByAddress: re,
|
|
1280
|
+
className: "aegis-swap-widget__token-mark"
|
|
1281
|
+
}
|
|
1282
|
+
),
|
|
1283
|
+
/* @__PURE__ */ c("span", { className: "aegis-swap-widget__token-symbol", children: h.symbol })
|
|
1284
|
+
] })
|
|
1285
|
+
] }),
|
|
1286
|
+
/* @__PURE__ */ y("span", { className: "aegis-swap-widget__meta", children: [
|
|
1287
|
+
"Balance ",
|
|
1288
|
+
lt(U.input, h.decimals),
|
|
1289
|
+
" ",
|
|
1290
|
+
h.symbol
|
|
1291
|
+
] })
|
|
1292
|
+
] }),
|
|
1293
|
+
/* @__PURE__ */ c(
|
|
1294
|
+
"button",
|
|
1295
|
+
{
|
|
1296
|
+
type: "button",
|
|
1297
|
+
className: "aegis-swap-widget__flip",
|
|
1298
|
+
onClick: Qt,
|
|
1299
|
+
disabled: !d || Z(N),
|
|
1300
|
+
"aria-label": "Switch swap direction",
|
|
1301
|
+
children: /* @__PURE__ */ c(ua, {})
|
|
1302
|
+
}
|
|
1303
|
+
),
|
|
1304
|
+
/* @__PURE__ */ y("label", { className: "aegis-swap-widget__amount-box", children: [
|
|
1305
|
+
/* @__PURE__ */ c("span", { className: "aegis-swap-widget__field-label", children: "Buy" }),
|
|
1306
|
+
/* @__PURE__ */ y("span", { className: "aegis-swap-widget__amount-row", children: [
|
|
1307
|
+
/* @__PURE__ */ c(
|
|
1308
|
+
"input",
|
|
1309
|
+
{
|
|
1310
|
+
inputMode: "decimal",
|
|
1311
|
+
autoComplete: "off",
|
|
1312
|
+
value: zt,
|
|
1313
|
+
onChange: (a) => {
|
|
1314
|
+
K("exactOut"), j(Re(a.target.value)), z(""), T("idle");
|
|
1315
|
+
},
|
|
1316
|
+
placeholder: "0",
|
|
1317
|
+
disabled: D === "exactIn" || Z(N)
|
|
1318
|
+
}
|
|
1319
|
+
),
|
|
1320
|
+
/* @__PURE__ */ y("span", { className: "aegis-swap-widget__token", children: [
|
|
1321
|
+
/* @__PURE__ */ c(
|
|
1322
|
+
de,
|
|
1323
|
+
{
|
|
1324
|
+
token: A,
|
|
1325
|
+
metadataByAddress: re,
|
|
1326
|
+
className: "aegis-swap-widget__token-mark"
|
|
1327
|
+
}
|
|
1328
|
+
),
|
|
1329
|
+
/* @__PURE__ */ c("span", { className: "aegis-swap-widget__token-symbol", children: A.symbol })
|
|
1330
|
+
] })
|
|
1331
|
+
] }),
|
|
1332
|
+
/* @__PURE__ */ y("span", { className: "aegis-swap-widget__meta", children: [
|
|
1333
|
+
"Balance ",
|
|
1334
|
+
lt(U.output, A.decimals),
|
|
1335
|
+
" ",
|
|
1336
|
+
A.symbol
|
|
1337
|
+
] })
|
|
1338
|
+
] })
|
|
1339
|
+
] }),
|
|
1340
|
+
/* @__PURE__ */ c("div", { className: "aegis-swap-widget__settings", children: /* @__PURE__ */ y("label", { children: [
|
|
1341
|
+
/* @__PURE__ */ c("span", { children: "Slippage" }),
|
|
1342
|
+
/* @__PURE__ */ y("span", { className: "aegis-swap-widget__slippage-input", children: [
|
|
1343
|
+
/* @__PURE__ */ c(
|
|
1344
|
+
"input",
|
|
1345
|
+
{
|
|
1346
|
+
value: he,
|
|
1347
|
+
inputMode: "decimal",
|
|
1348
|
+
onChange: (a) => He(On(a.target.value)),
|
|
1349
|
+
onBlur: () => {
|
|
1350
|
+
ut(he) === null && He("1");
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
),
|
|
1354
|
+
/* @__PURE__ */ c("span", { children: "%" })
|
|
1355
|
+
] })
|
|
1356
|
+
] }) }),
|
|
1357
|
+
d ? /* @__PURE__ */ c("div", { className: "aegis-swap-widget__details", children: /* @__PURE__ */ y("div", { className: "aegis-swap-widget__pool", children: [
|
|
1358
|
+
/* @__PURE__ */ y("span", { className: "aegis-swap-widget__pool-label", children: [
|
|
1359
|
+
/* @__PURE__ */ c(
|
|
1360
|
+
ht,
|
|
1361
|
+
{
|
|
1362
|
+
market: d,
|
|
1363
|
+
metadataByAddress: re,
|
|
1364
|
+
className: "aegis-swap-widget__pool-pair"
|
|
1365
|
+
}
|
|
1366
|
+
),
|
|
1367
|
+
"Direct pool"
|
|
1368
|
+
] }),
|
|
1369
|
+
Ft && at ? /* @__PURE__ */ c("a", { href: at, target: "_blank", rel: "noreferrer", children: d.label ?? `${X.symbol} / ${V.symbol}` }) : /* @__PURE__ */ c("strong", { children: d.label ?? `${X.symbol} / ${V.symbol}` })
|
|
1370
|
+
] }) }) : null,
|
|
1371
|
+
ge || tt ? /* @__PURE__ */ c("p", { className: "aegis-swap-widget__error", role: "alert", children: ge ?? tt }) : null,
|
|
1372
|
+
/* @__PURE__ */ c(
|
|
1373
|
+
"button",
|
|
1374
|
+
{
|
|
1375
|
+
type: "button",
|
|
1376
|
+
className: "aegis-swap-widget__submit",
|
|
1377
|
+
disabled: !Ht,
|
|
1378
|
+
onClick: () => {
|
|
1379
|
+
Vt();
|
|
1380
|
+
},
|
|
1381
|
+
children: Xt
|
|
1382
|
+
}
|
|
1383
|
+
),
|
|
1384
|
+
Je ? /* @__PURE__ */ c(
|
|
1385
|
+
"a",
|
|
1386
|
+
{
|
|
1387
|
+
className: "aegis-swap-widget__tx",
|
|
1388
|
+
href: ft(Je, l),
|
|
1389
|
+
target: "_blank",
|
|
1390
|
+
rel: "noreferrer",
|
|
1391
|
+
children: "View transaction"
|
|
1392
|
+
}
|
|
1393
|
+
) : null
|
|
1394
|
+
]
|
|
1395
|
+
}
|
|
1396
|
+
);
|
|
1397
|
+
}
|
|
1398
|
+
const ya = la;
|
|
1399
|
+
export {
|
|
1400
|
+
wn as AEGIS_DYNAMIC_FEE_FLAG,
|
|
1401
|
+
Ae as AEGIS_SWAP_CHAINS,
|
|
1402
|
+
k as AEGIS_SWAP_CHAIN_ID,
|
|
1403
|
+
_n as AEGIS_SWAP_DEFAULT_METADATA_ENDPOINT,
|
|
1404
|
+
gn as AEGIS_SWAP_DEFAULT_RPC_URLS,
|
|
1405
|
+
yn as AEGIS_SWAP_HOOK,
|
|
1406
|
+
bn as AEGIS_SWAP_MAINNET_CHAIN,
|
|
1407
|
+
xt as AEGIS_SWAP_MARKETS,
|
|
1408
|
+
Ct as AEGIS_SWAP_PERMIT2,
|
|
1409
|
+
St as AEGIS_SWAP_ROUTER,
|
|
1410
|
+
In as AEGIS_SWAP_TARGET_SYMBOLS,
|
|
1411
|
+
_ as AEGIS_SWAP_TOKENS,
|
|
1412
|
+
Tt as AEGIS_SWAP_V4_QUOTER,
|
|
1413
|
+
la as AegisDirectSwapWidget,
|
|
1414
|
+
ya as AegisSwapWidget,
|
|
1415
|
+
Sn as createAegisSwapChainConfig,
|
|
1416
|
+
Cn as createAegisSwapChains,
|
|
1417
|
+
Tn as createAegisSwapMarket,
|
|
1418
|
+
xn as createAegisSwapMarketsFromPoolKeys,
|
|
1419
|
+
la as default,
|
|
1420
|
+
Mn as fetchGlobalTokenMetadata,
|
|
1421
|
+
Pn as getIchiIconGuess
|
|
1422
|
+
};
|