@aegis-engine/core 0.1.2 → 0.1.3
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/dist/aegis-core.js +525 -514
- package/package.json +1 -1
package/dist/aegis-core.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { getAddress as b, encodeAbiParameters as J, keccak256 as
|
|
5
|
-
import { mainnet as
|
|
6
|
-
const N = 1,
|
|
1
|
+
var no = Object.defineProperty;
|
|
2
|
+
var oo = (e, t, n) => t in e ? no(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var U = (e, t, n) => oo(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { getAddress as b, encodeAbiParameters as J, keccak256 as Bt, encodeFunctionData as Ve, createWalletClient as _e, custom as we, erc20Abi as qe, http as ro, createPublicClient as io, fallback as co, isAddress as ao } from "viem";
|
|
5
|
+
import { mainnet as so } from "viem/chains";
|
|
6
|
+
const N = 1, uo = b("0x00581261a1200956ea05d1810fF28ffd66D8E254"), ol = b("0x8f29BD5c8429730fA4C46e6295c4e679eDEdd0cC"), rl = 8388608, lo = 50, jt = b(
|
|
7
7
|
"0x8ea2C7de60ef1Cd4dcE64ea2DDDe2f99F0127eFC"
|
|
8
|
-
),
|
|
8
|
+
), po = [
|
|
9
9
|
"https://eth.drpc.org",
|
|
10
10
|
"https://ethereum-rpc.publicnode.com",
|
|
11
11
|
"https://cloudflare-eth.com"
|
|
12
|
-
],
|
|
12
|
+
], fo = "https://aegis.markets/graphql/meta", Lt = 50, Gt = jt;
|
|
13
13
|
function Y(e) {
|
|
14
14
|
return e ? b(e) : void 0;
|
|
15
15
|
}
|
|
@@ -27,7 +27,7 @@ function q(e) {
|
|
|
27
27
|
universalRouterV2_1_1: Y(e.universalRouterV2_1_1)
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
const
|
|
30
|
+
const Wt = {
|
|
31
31
|
1: q({
|
|
32
32
|
poolManager: "0x000000000004444c5dc75cB358380D2e3dE08A90",
|
|
33
33
|
positionDescriptor: "0xd1428ba554f4c8450b763a0b2040a4935c63f06c",
|
|
@@ -88,33 +88,33 @@ const Gt = {
|
|
|
88
88
|
universalRouterV2_1_1: "0x8b844f885672f333bc0042cb669255f93a4c1e6b",
|
|
89
89
|
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3"
|
|
90
90
|
})
|
|
91
|
-
}, Je =
|
|
92
|
-
function
|
|
91
|
+
}, Je = Wt[N], mo = Je.permit2, ho = Je.quoter;
|
|
92
|
+
function Kt(e, t) {
|
|
93
93
|
var n;
|
|
94
94
|
return ((n = t.explorerTxUrl) == null ? void 0 : n.call(t, e)) ?? "#";
|
|
95
95
|
}
|
|
96
|
-
const
|
|
96
|
+
const _o = {
|
|
97
97
|
chainId: N,
|
|
98
|
-
chain:
|
|
98
|
+
chain: so,
|
|
99
99
|
name: "Ethereum",
|
|
100
|
-
router:
|
|
101
|
-
permit2:
|
|
102
|
-
quoter:
|
|
100
|
+
router: uo,
|
|
101
|
+
permit2: mo,
|
|
102
|
+
quoter: ho,
|
|
103
103
|
v4Contracts: Je,
|
|
104
|
-
rpcUrls:
|
|
104
|
+
rpcUrls: po,
|
|
105
105
|
explorerTxUrl: (e) => `https://etherscan.io/tx/${e}`,
|
|
106
106
|
poolExplorerUrl: (e) => `https://app.uniswap.org/explore/pools/ethereum/${e}`,
|
|
107
|
-
metadataEndpoint:
|
|
107
|
+
metadataEndpoint: fo,
|
|
108
108
|
fee: {
|
|
109
|
-
bps:
|
|
110
|
-
recipient:
|
|
109
|
+
bps: lo,
|
|
110
|
+
recipient: jt
|
|
111
111
|
}
|
|
112
112
|
}, He = {
|
|
113
|
-
[N]:
|
|
113
|
+
[N]: _o
|
|
114
114
|
};
|
|
115
|
-
function
|
|
115
|
+
function wo(e, t) {
|
|
116
116
|
var o, r;
|
|
117
|
-
const n =
|
|
117
|
+
const n = Wt[e.chainId];
|
|
118
118
|
return {
|
|
119
119
|
...n,
|
|
120
120
|
...t == null ? void 0 : t.v4Contracts,
|
|
@@ -123,9 +123,9 @@ function ho(e, t) {
|
|
|
123
123
|
quoter: ((r = e.v4Contracts) == null ? void 0 : r.quoter) ?? e.quoter ?? (t == null ? void 0 : t.quoter) ?? (n == null ? void 0 : n.quoter)
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function yo(e, t) {
|
|
127
127
|
var r;
|
|
128
|
-
const n =
|
|
128
|
+
const n = wo(e, t);
|
|
129
129
|
if (!t && (!e.chain || !e.router || !((r = e.rpcUrls) != null && r.length)))
|
|
130
130
|
throw new Error(
|
|
131
131
|
`Missing viem chain, Aegis router, or RPC URLs for chain ${e.chainId}.`
|
|
@@ -154,7 +154,7 @@ function il(e) {
|
|
|
154
154
|
for (const [n, o] of Object.entries(e)) {
|
|
155
155
|
if (!o) continue;
|
|
156
156
|
const r = o.chainId ?? Number(n);
|
|
157
|
-
t[r] =
|
|
157
|
+
t[r] = yo(
|
|
158
158
|
{ ...o, chainId: r },
|
|
159
159
|
t[r]
|
|
160
160
|
);
|
|
@@ -238,31 +238,31 @@ const ee = {
|
|
|
238
238
|
symbol: "stETH",
|
|
239
239
|
decimals: 18
|
|
240
240
|
}
|
|
241
|
-
},
|
|
241
|
+
}, vo = {
|
|
242
242
|
USDC: ee.USDC,
|
|
243
243
|
ETH: Xe.ETH,
|
|
244
244
|
WATER: ee.WATER,
|
|
245
245
|
WOOD: ee.WOOD,
|
|
246
246
|
GRASS: ee.GRASS,
|
|
247
247
|
STONE: ee.STONE
|
|
248
|
-
},
|
|
248
|
+
}, bo = Object.values(
|
|
249
249
|
Xe
|
|
250
|
-
),
|
|
251
|
-
|
|
250
|
+
), go = Object.values(
|
|
251
|
+
vo
|
|
252
252
|
), cl = {
|
|
253
|
-
default:
|
|
254
|
-
wolfgame:
|
|
253
|
+
default: bo,
|
|
254
|
+
wolfgame: go
|
|
255
255
|
}, al = Xe;
|
|
256
256
|
function Ue(e) {
|
|
257
257
|
return (e == null ? void 0 : e.toLowerCase()) ?? "";
|
|
258
258
|
}
|
|
259
|
-
function
|
|
259
|
+
function D(e, t) {
|
|
260
260
|
return e.toLowerCase() === t.toLowerCase();
|
|
261
261
|
}
|
|
262
|
-
function
|
|
263
|
-
return e === null || t === null ? e === t :
|
|
262
|
+
function Eo(e, t) {
|
|
263
|
+
return e === null || t === null ? e === t : D(e, t);
|
|
264
264
|
}
|
|
265
|
-
function
|
|
265
|
+
function Vt(e, t) {
|
|
266
266
|
return e.toLowerCase() === t.toLowerCase();
|
|
267
267
|
}
|
|
268
268
|
const Qe = [
|
|
@@ -319,7 +319,7 @@ const Qe = [
|
|
|
319
319
|
],
|
|
320
320
|
outputs: []
|
|
321
321
|
}
|
|
322
|
-
],
|
|
322
|
+
], qt = [
|
|
323
323
|
{
|
|
324
324
|
type: "function",
|
|
325
325
|
name: "approve",
|
|
@@ -410,13 +410,13 @@ const Qe = [
|
|
|
410
410
|
{ name: "gasEstimate", type: "uint256" }
|
|
411
411
|
]
|
|
412
412
|
}
|
|
413
|
-
],
|
|
413
|
+
], Jt = 0n, ko = 2n ** 128n - 1n, re = {
|
|
414
414
|
SWAP_EXACT_IN_SINGLE: 6,
|
|
415
415
|
SWAP_EXACT_OUT_SINGLE: 8,
|
|
416
416
|
SETTLE: 11,
|
|
417
417
|
TAKE: 14,
|
|
418
418
|
TAKE_PORTION: 16
|
|
419
|
-
},
|
|
419
|
+
}, Ht = {
|
|
420
420
|
name: "poolKey",
|
|
421
421
|
type: "tuple",
|
|
422
422
|
components: [
|
|
@@ -426,75 +426,75 @@ const Qe = [
|
|
|
426
426
|
{ name: "tickSpacing", type: "int24" },
|
|
427
427
|
{ name: "hooks", type: "address" }
|
|
428
428
|
]
|
|
429
|
-
},
|
|
429
|
+
}, So = [
|
|
430
430
|
{
|
|
431
431
|
name: "params",
|
|
432
432
|
type: "tuple",
|
|
433
433
|
components: [
|
|
434
|
-
|
|
434
|
+
Ht,
|
|
435
435
|
{ name: "zeroForOne", type: "bool" },
|
|
436
436
|
{ name: "amountIn", type: "uint128" },
|
|
437
437
|
{ name: "amountOutMinimum", type: "uint128" },
|
|
438
438
|
{ name: "hookData", type: "bytes" }
|
|
439
439
|
]
|
|
440
440
|
}
|
|
441
|
-
],
|
|
441
|
+
], Io = [
|
|
442
442
|
{
|
|
443
443
|
name: "params",
|
|
444
444
|
type: "tuple",
|
|
445
445
|
components: [
|
|
446
|
-
|
|
446
|
+
Ht,
|
|
447
447
|
{ name: "zeroForOne", type: "bool" },
|
|
448
448
|
{ name: "amountOut", type: "uint128" },
|
|
449
449
|
{ name: "amountInMaximum", type: "uint128" },
|
|
450
450
|
{ name: "hookData", type: "bytes" }
|
|
451
451
|
]
|
|
452
452
|
}
|
|
453
|
-
],
|
|
453
|
+
], Ao = [
|
|
454
454
|
{ name: "currency", type: "address" },
|
|
455
455
|
{ name: "amount", type: "uint256" },
|
|
456
456
|
{ name: "payerIsUser", type: "bool" }
|
|
457
|
-
],
|
|
457
|
+
], Xt = [
|
|
458
458
|
{ name: "currency", type: "address" },
|
|
459
459
|
{ name: "recipient", type: "address" },
|
|
460
460
|
{ name: "amount", type: "uint256" }
|
|
461
|
-
],
|
|
461
|
+
], zo = [
|
|
462
462
|
{ name: "currency", type: "address" },
|
|
463
463
|
{ name: "recipient", type: "address" },
|
|
464
464
|
{ name: "bips", type: "uint256" }
|
|
465
465
|
];
|
|
466
|
-
function
|
|
466
|
+
function To(e) {
|
|
467
467
|
return `0x${e.map((t) => t.toString(16).padStart(2, "0")).join("")}`;
|
|
468
468
|
}
|
|
469
|
-
function
|
|
469
|
+
function $o(e, t) {
|
|
470
470
|
return {
|
|
471
471
|
requiresV4Unlock: !0,
|
|
472
|
-
actions:
|
|
472
|
+
actions: To(e),
|
|
473
473
|
params: t
|
|
474
474
|
};
|
|
475
475
|
}
|
|
476
|
-
function
|
|
476
|
+
function Oo(e, t) {
|
|
477
477
|
return Ve({
|
|
478
478
|
abi: Qe,
|
|
479
479
|
functionName: "execute",
|
|
480
480
|
args: [e, t]
|
|
481
481
|
});
|
|
482
482
|
}
|
|
483
|
-
function
|
|
483
|
+
function Co(e) {
|
|
484
484
|
return Ve({
|
|
485
485
|
abi: Qe,
|
|
486
486
|
functionName: "permitBatch",
|
|
487
487
|
args: [e.owner, e.permitBatch, e.signature]
|
|
488
488
|
});
|
|
489
489
|
}
|
|
490
|
-
function
|
|
490
|
+
function Po(e) {
|
|
491
491
|
return Ve({
|
|
492
492
|
abi: Qe,
|
|
493
493
|
functionName: "multicall",
|
|
494
494
|
args: [e]
|
|
495
495
|
});
|
|
496
496
|
}
|
|
497
|
-
function
|
|
497
|
+
function xo(e) {
|
|
498
498
|
if (!e) return !1;
|
|
499
499
|
if ("bips" in e) {
|
|
500
500
|
if (!Number.isInteger(e.bips) || e.bips < 0 || e.bips > 1e4)
|
|
@@ -503,24 +503,24 @@ function Co(e) {
|
|
|
503
503
|
}
|
|
504
504
|
return e.amount > 0n;
|
|
505
505
|
}
|
|
506
|
-
function
|
|
506
|
+
function Zo(e, t) {
|
|
507
507
|
return "bips" in e ? {
|
|
508
508
|
action: re.TAKE_PORTION,
|
|
509
|
-
params: J(
|
|
509
|
+
params: J(zo, [t, e.recipient, BigInt(e.bips)])
|
|
510
510
|
} : {
|
|
511
511
|
action: re.TAKE,
|
|
512
|
-
params: J(
|
|
512
|
+
params: J(Xt, [t, e.recipient, e.amount])
|
|
513
513
|
};
|
|
514
514
|
}
|
|
515
515
|
function pe(e, t = "Amount") {
|
|
516
|
-
if (e < 0n || e >
|
|
516
|
+
if (e < 0n || e > ko)
|
|
517
517
|
throw new Error(`${t} is too large for a single V4 swap.`);
|
|
518
518
|
}
|
|
519
|
-
function
|
|
520
|
-
return t ?
|
|
519
|
+
function No(e, t) {
|
|
520
|
+
return t ? Po([Co(t), e]) : e;
|
|
521
521
|
}
|
|
522
|
-
function
|
|
523
|
-
return
|
|
522
|
+
function Qt(e) {
|
|
523
|
+
return Bt(
|
|
524
524
|
J(
|
|
525
525
|
[
|
|
526
526
|
{ name: "currency0", type: "address" },
|
|
@@ -539,8 +539,8 @@ function Xt(e) {
|
|
|
539
539
|
)
|
|
540
540
|
);
|
|
541
541
|
}
|
|
542
|
-
function
|
|
543
|
-
const t = e.zeroForOne ? e.poolKey.currency0 : e.poolKey.currency1, n = e.zeroForOne ? e.poolKey.currency1 : e.poolKey.currency0, o =
|
|
542
|
+
function Yt(e) {
|
|
543
|
+
const t = e.zeroForOne ? e.poolKey.currency0 : e.poolKey.currency1, n = e.zeroForOne ? e.poolKey.currency1 : e.poolKey.currency0, o = xo(e.fee) ? e.fee : null, r = o ? Zo(o, n) : null, i = $o(
|
|
544
544
|
[
|
|
545
545
|
e.swapAction,
|
|
546
546
|
re.SETTLE,
|
|
@@ -549,20 +549,20 @@ function Qt(e) {
|
|
|
549
549
|
],
|
|
550
550
|
[
|
|
551
551
|
e.encodedSwapParams,
|
|
552
|
-
J(
|
|
552
|
+
J(Ao, [t, e.settleAmount, !0]),
|
|
553
553
|
...r ? [r.params] : [],
|
|
554
|
-
J(
|
|
554
|
+
J(Xt, [n, e.recipient, Jt])
|
|
555
555
|
]
|
|
556
556
|
);
|
|
557
557
|
return {
|
|
558
|
-
calldata:
|
|
558
|
+
calldata: No(Oo([i], e.deadline), e.permit),
|
|
559
559
|
value: 0n
|
|
560
560
|
};
|
|
561
561
|
}
|
|
562
|
-
function
|
|
563
|
-
return pe(e.amountIn, "Swap input amount"), pe(e.amountOutMinimum, "Swap minimum output"),
|
|
562
|
+
function Ro(e) {
|
|
563
|
+
return pe(e.amountIn, "Swap input amount"), pe(e.amountOutMinimum, "Swap minimum output"), Yt({
|
|
564
564
|
swapAction: re.SWAP_EXACT_IN_SINGLE,
|
|
565
|
-
encodedSwapParams: J(
|
|
565
|
+
encodedSwapParams: J(So, [
|
|
566
566
|
{
|
|
567
567
|
poolKey: e.poolKey,
|
|
568
568
|
zeroForOne: e.zeroForOne,
|
|
@@ -580,10 +580,10 @@ function Zo(e) {
|
|
|
580
580
|
fee: e.fee
|
|
581
581
|
});
|
|
582
582
|
}
|
|
583
|
-
function
|
|
584
|
-
return pe(e.amountOut, "Swap output amount"), pe(e.amountInMaximum, "Swap maximum input"),
|
|
583
|
+
function Do(e) {
|
|
584
|
+
return pe(e.amountOut, "Swap output amount"), pe(e.amountInMaximum, "Swap maximum input"), Yt({
|
|
585
585
|
swapAction: re.SWAP_EXACT_OUT_SINGLE,
|
|
586
|
-
encodedSwapParams: J(
|
|
586
|
+
encodedSwapParams: J(Io, [
|
|
587
587
|
{
|
|
588
588
|
poolKey: e.poolKey,
|
|
589
589
|
zeroForOne: e.zeroForOne,
|
|
@@ -594,7 +594,7 @@ function No(e) {
|
|
|
594
594
|
]),
|
|
595
595
|
poolKey: e.poolKey,
|
|
596
596
|
zeroForOne: e.zeroForOne,
|
|
597
|
-
settleAmount:
|
|
597
|
+
settleAmount: Jt,
|
|
598
598
|
recipient: e.recipient,
|
|
599
599
|
deadline: e.deadline,
|
|
600
600
|
permit: e.permit,
|
|
@@ -607,7 +607,7 @@ function st(e) {
|
|
|
607
607
|
address: b(e.address)
|
|
608
608
|
};
|
|
609
609
|
}
|
|
610
|
-
function
|
|
610
|
+
function Mo(e) {
|
|
611
611
|
const t = b(e.currency0), n = b(e.currency1);
|
|
612
612
|
if (t.toLowerCase() >= n.toLowerCase())
|
|
613
613
|
throw new Error(
|
|
@@ -621,13 +621,13 @@ function Ro(e) {
|
|
|
621
621
|
hooks: b(e.hooks)
|
|
622
622
|
};
|
|
623
623
|
}
|
|
624
|
-
function
|
|
624
|
+
function Uo(e, t = He) {
|
|
625
625
|
const n = st(e.token), o = st(e.counterToken), r = e.chainId ?? n.chainId ?? o.chainId ?? N, i = t[r];
|
|
626
626
|
if (!i) throw new Error(`No Aegis swap chain config found for chain ${r}.`);
|
|
627
627
|
if (n.chainId !== r || o.chainId !== r)
|
|
628
628
|
throw new Error(`Pool token chain ids must match chain ${r}.`);
|
|
629
|
-
const c =
|
|
630
|
-
if (e.poolId && !
|
|
629
|
+
const c = Mo(e.poolKey), a = Qt(c);
|
|
630
|
+
if (e.poolId && !Vt(e.poolId, a))
|
|
631
631
|
throw new Error("Configured pool id does not match the pool key.");
|
|
632
632
|
return {
|
|
633
633
|
id: e.id,
|
|
@@ -646,28 +646,28 @@ function Do(e, t = He) {
|
|
|
646
646
|
function sl(e, t = He) {
|
|
647
647
|
return e != null && e.length ? Object.fromEntries(
|
|
648
648
|
e.map((n) => {
|
|
649
|
-
const o =
|
|
649
|
+
const o = Uo(n, t);
|
|
650
650
|
return [o.id, o];
|
|
651
651
|
})
|
|
652
652
|
) : {};
|
|
653
653
|
}
|
|
654
|
-
function
|
|
654
|
+
function en(e) {
|
|
655
655
|
if (!Number.isFinite(e) || e < 0 || e > 2e3)
|
|
656
656
|
throw new Error("Slippage must be between 0% and 20%.");
|
|
657
657
|
}
|
|
658
|
-
function
|
|
659
|
-
return
|
|
658
|
+
function Fo(e, t) {
|
|
659
|
+
return en(t), e * BigInt(1e4 - Math.round(t)) / 10000n;
|
|
660
660
|
}
|
|
661
|
-
function
|
|
662
|
-
return
|
|
661
|
+
function Bo(e, t) {
|
|
662
|
+
return en(t), (e * BigInt(1e4 + Math.round(t)) + 9999n) / 10000n;
|
|
663
663
|
}
|
|
664
|
-
function
|
|
664
|
+
function jo(e, t) {
|
|
665
665
|
return t <= 0 ? 0n : e * BigInt(t) / 10000n;
|
|
666
666
|
}
|
|
667
|
-
function
|
|
667
|
+
function Lo(e, t) {
|
|
668
668
|
return t <= 0 ? e : (e * 10000n + BigInt(1e4 - t - 1)) / BigInt(1e4 - t);
|
|
669
669
|
}
|
|
670
|
-
function
|
|
670
|
+
function Go(e, t) {
|
|
671
671
|
if (t <= 0) return e;
|
|
672
672
|
const n = BigInt(1e4 - t);
|
|
673
673
|
return (e * 10000n + n - 1n) / n;
|
|
@@ -675,20 +675,20 @@ function jo(e, t) {
|
|
|
675
675
|
function ve(e) {
|
|
676
676
|
return pe(e), e;
|
|
677
677
|
}
|
|
678
|
-
function
|
|
679
|
-
if (
|
|
680
|
-
if (
|
|
678
|
+
function Wo(e, t) {
|
|
679
|
+
if (D(t.address, e.currency0)) return !0;
|
|
680
|
+
if (D(t.address, e.currency1)) return !1;
|
|
681
681
|
throw new Error("Input token is not part of this pool.");
|
|
682
682
|
}
|
|
683
|
-
function
|
|
684
|
-
const o =
|
|
685
|
-
if (!
|
|
683
|
+
function Ko(e, t, n) {
|
|
684
|
+
const o = Qt(e.poolKey);
|
|
685
|
+
if (!Vt(o, e.poolId))
|
|
686
686
|
throw new Error("Configured pool id does not match the pool key.");
|
|
687
|
-
const r =
|
|
688
|
-
if (!r || !i ||
|
|
687
|
+
const r = D(t.address, e.poolKey.currency0) || D(t.address, e.poolKey.currency1), i = D(n.address, e.poolKey.currency0) || D(n.address, e.poolKey.currency1);
|
|
688
|
+
if (!r || !i || D(t.address, n.address))
|
|
689
689
|
throw new Error("Selected tokens do not match this direct pool.");
|
|
690
690
|
}
|
|
691
|
-
function
|
|
691
|
+
function Vo(e, t) {
|
|
692
692
|
if (Array.isArray(e)) {
|
|
693
693
|
const r = e[0], i = e[1];
|
|
694
694
|
if (typeof r == "bigint" && typeof i == "bigint")
|
|
@@ -700,15 +700,15 @@ function Wo(e, t) {
|
|
|
700
700
|
return { amount: o, gasEstimate: n.gasEstimate };
|
|
701
701
|
throw new Error("Unexpected V4 Quoter response.");
|
|
702
702
|
}
|
|
703
|
-
async function
|
|
703
|
+
async function qo(e) {
|
|
704
704
|
var m, f, _, y;
|
|
705
705
|
if ((m = e.signal) != null && m.aborted) throw new DOMException("Quote request aborted", "AbortError");
|
|
706
706
|
if (e.amount <= 0n) throw new Error("Enter an amount to swap.");
|
|
707
|
-
ve(e.amount),
|
|
708
|
-
const t = e.market.poolKey, n =
|
|
707
|
+
ve(e.amount), Ko(e.market, e.tokenIn, e.tokenOut);
|
|
708
|
+
const t = e.market.poolKey, n = Wo(t, e.tokenIn), o = ((f = e.fee) == null ? void 0 : f.bps) ?? 0;
|
|
709
709
|
if (!Number.isInteger(o) || o < 0 || o >= 1e4)
|
|
710
710
|
throw new Error("Fee must be an integer between 0 and 9999 bps.");
|
|
711
|
-
const r = e.mode === "exactOut" ? ve(
|
|
711
|
+
const r = e.mode === "exactOut" ? ve(Lo(e.amount, o)) : e.amount, i = e.mode === "exactOut" ? await e.publicClient.simulateContract({
|
|
712
712
|
address: e.market.quoter,
|
|
713
713
|
abi: at,
|
|
714
714
|
functionName: "quoteExactOutputSingle",
|
|
@@ -722,10 +722,10 @@ async function Ko(e) {
|
|
|
722
722
|
account: e.account
|
|
723
723
|
});
|
|
724
724
|
if ((_ = e.signal) != null && _.aborted) throw new DOMException("Quote request aborted", "AbortError");
|
|
725
|
-
const c =
|
|
725
|
+
const c = Vo(
|
|
726
726
|
i.result,
|
|
727
727
|
e.mode === "exactOut" ? "amountIn" : "amountOut"
|
|
728
|
-
), a = e.mode === "exactOut" ? c.amount : e.amount, s = e.mode === "exactOut" ? r : c.amount, u = e.mode === "exactOut" ? s - e.amount :
|
|
728
|
+
), a = e.mode === "exactOut" ? c.amount : e.amount, s = e.mode === "exactOut" ? r : c.amount, u = e.mode === "exactOut" ? s - e.amount : jo(s, o), l = s - u, p = e.mode === "exactOut" ? l : Fo(l, e.slippageBps);
|
|
729
729
|
return {
|
|
730
730
|
mode: e.mode,
|
|
731
731
|
poolKey: t,
|
|
@@ -733,8 +733,8 @@ async function Ko(e) {
|
|
|
733
733
|
amountIn: a,
|
|
734
734
|
amountOut: l,
|
|
735
735
|
grossAmountOut: s,
|
|
736
|
-
amountOutMinimum: e.mode === "exactOut" ? s : ve(
|
|
737
|
-
amountInMaximum: e.mode === "exactOut" ? ve(
|
|
736
|
+
amountOutMinimum: e.mode === "exactOut" ? s : ve(Go(p, o)),
|
|
737
|
+
amountInMaximum: e.mode === "exactOut" ? ve(Bo(a, e.slippageBps)) : a,
|
|
738
738
|
userAmountOutMinimum: p,
|
|
739
739
|
feeAmount: u,
|
|
740
740
|
feeBps: o,
|
|
@@ -742,14 +742,14 @@ async function Ko(e) {
|
|
|
742
742
|
gasEstimate: c.gasEstimate
|
|
743
743
|
};
|
|
744
744
|
}
|
|
745
|
-
function
|
|
746
|
-
return e.mode === t.mode && e.zeroForOne === t.zeroForOne &&
|
|
745
|
+
function tn(e, t) {
|
|
746
|
+
return e.mode === t.mode && e.zeroForOne === t.zeroForOne && D(e.poolKey.currency0, t.poolKey.currency0) && D(e.poolKey.currency1, t.poolKey.currency1) && e.poolKey.fee === t.poolKey.fee && e.poolKey.tickSpacing === t.poolKey.tickSpacing && D(e.poolKey.hooks, t.poolKey.hooks) && e.feeBps === t.feeBps && Eo(e.feeRecipient, t.feeRecipient);
|
|
747
747
|
}
|
|
748
748
|
function ul(e, t) {
|
|
749
|
-
return
|
|
749
|
+
return tn(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;
|
|
750
750
|
}
|
|
751
|
-
function
|
|
752
|
-
return !e || !
|
|
751
|
+
function Jo(e, t) {
|
|
752
|
+
return !e || !tn(e, t) ? { quote: t, priceMovedBeyondTolerance: !1 } : t.mode === "exactIn" ? t.amountOut < e.userAmountOutMinimum ? { quote: t, priceMovedBeyondTolerance: !0 } : {
|
|
753
753
|
quote: {
|
|
754
754
|
...t,
|
|
755
755
|
amountOutMinimum: t.amountOutMinimum > e.amountOutMinimum ? t.amountOutMinimum : e.amountOutMinimum,
|
|
@@ -764,28 +764,28 @@ function Vo(e, t) {
|
|
|
764
764
|
priceMovedBeyondTolerance: !1
|
|
765
765
|
};
|
|
766
766
|
}
|
|
767
|
-
function
|
|
767
|
+
function Ho(e) {
|
|
768
768
|
return e.mode === "exactOut" ? e.amountInMaximum : e.amountIn;
|
|
769
769
|
}
|
|
770
|
-
function
|
|
770
|
+
function Xo(e) {
|
|
771
771
|
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;
|
|
772
772
|
}
|
|
773
|
-
function
|
|
773
|
+
function nn(e) {
|
|
774
774
|
for (let n = e; n && typeof n == "object"; n = n.cause)
|
|
775
775
|
if (n.code === 4001) return !0;
|
|
776
776
|
const t = e instanceof Error ? e.message.toLowerCase() : "";
|
|
777
777
|
return t.includes("user rejected") || t.includes("user denied") || t.includes("rejected the request") || t.includes("request rejected");
|
|
778
778
|
}
|
|
779
|
-
const
|
|
780
|
-
function
|
|
781
|
-
if (
|
|
782
|
-
return
|
|
779
|
+
const Qo = "Request rejected.";
|
|
780
|
+
function Yo(e, t) {
|
|
781
|
+
if (nn(e))
|
|
782
|
+
return Qo;
|
|
783
783
|
const n = e instanceof Error ? e.message : "";
|
|
784
784
|
if (!n) return t;
|
|
785
785
|
const o = n.toLowerCase();
|
|
786
786
|
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." : o.includes("token not found") ? "Token is not supported by KyberSwap." : o.includes("kyberswap api error") ? "KyberSwap could not build this route. Try again." : t;
|
|
787
787
|
}
|
|
788
|
-
class
|
|
788
|
+
class on extends Error {
|
|
789
789
|
constructor({
|
|
790
790
|
status: n,
|
|
791
791
|
statusText: o,
|
|
@@ -794,14 +794,14 @@ class nn extends Error {
|
|
|
794
794
|
body: c
|
|
795
795
|
}) {
|
|
796
796
|
super(i);
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
797
|
+
U(this, "status");
|
|
798
|
+
U(this, "statusText");
|
|
799
|
+
U(this, "code");
|
|
800
|
+
U(this, "body");
|
|
801
801
|
this.name = "KyberSwapApiError", this.status = n, this.statusText = o, this.code = r, this.body = c;
|
|
802
802
|
}
|
|
803
803
|
}
|
|
804
|
-
const
|
|
804
|
+
const rn = "https://aggregator-api.kyberswap.com", Fe = "Aegis", er = {
|
|
805
805
|
1: "ethereum",
|
|
806
806
|
10: "optimism",
|
|
807
807
|
56: "bsc",
|
|
@@ -822,13 +822,13 @@ const on = "https://aggregator-api.kyberswap.com", Fe = "Aegis", Qo = {
|
|
|
822
822
|
59144: "linea",
|
|
823
823
|
80094: "berachain"
|
|
824
824
|
};
|
|
825
|
-
function
|
|
826
|
-
const t =
|
|
825
|
+
function cn(e) {
|
|
826
|
+
const t = er[e];
|
|
827
827
|
if (!t)
|
|
828
828
|
throw new Error(`KyberSwap does not support chain ${e}.`);
|
|
829
829
|
return t;
|
|
830
830
|
}
|
|
831
|
-
async function
|
|
831
|
+
async function an(e) {
|
|
832
832
|
const t = e.clone();
|
|
833
833
|
let n, o, r;
|
|
834
834
|
try {
|
|
@@ -842,7 +842,7 @@ async function cn(e) {
|
|
|
842
842
|
}
|
|
843
843
|
}
|
|
844
844
|
const i = r ? `: ${r.slice(0, 300)}` : "", c = o !== void 0 ? ` ${o}` : "", a = e.statusText || "Request failed";
|
|
845
|
-
return new
|
|
845
|
+
return new on({
|
|
846
846
|
status: e.status,
|
|
847
847
|
statusText: a,
|
|
848
848
|
code: o,
|
|
@@ -850,10 +850,10 @@ async function cn(e) {
|
|
|
850
850
|
body: n
|
|
851
851
|
});
|
|
852
852
|
}
|
|
853
|
-
function
|
|
854
|
-
return e instanceof
|
|
853
|
+
function sn(e) {
|
|
854
|
+
return e instanceof on && (e.status === 429 || e.status >= 500);
|
|
855
855
|
}
|
|
856
|
-
function
|
|
856
|
+
function tr(e) {
|
|
857
857
|
if (!(e != null && e.routeSummary) || !(e != null && e.routerAddress))
|
|
858
858
|
throw new Error("Invalid response from KyberSwap API");
|
|
859
859
|
return {
|
|
@@ -864,7 +864,7 @@ function Yo(e) {
|
|
|
864
864
|
routeSummary: e.routeSummary
|
|
865
865
|
};
|
|
866
866
|
}
|
|
867
|
-
function
|
|
867
|
+
function nr(e) {
|
|
868
868
|
if (!(e != null && e.data) || !(e != null && e.routerAddress))
|
|
869
869
|
throw new Error("Invalid encoded route from KyberSwap API");
|
|
870
870
|
return {
|
|
@@ -873,7 +873,7 @@ function er(e) {
|
|
|
873
873
|
routerAddress: b(e.routerAddress)
|
|
874
874
|
};
|
|
875
875
|
}
|
|
876
|
-
async function
|
|
876
|
+
async function or({
|
|
877
877
|
tokenIn: e,
|
|
878
878
|
tokenOut: t,
|
|
879
879
|
amountIn: n,
|
|
@@ -890,7 +890,7 @@ async function tr({
|
|
|
890
890
|
});
|
|
891
891
|
r && a.set("origin", r), i && (a.set("feeAmount", i.feeAmount), a.set("chargeFeeBy", i.chargeFeeBy), a.set("isInBps", String(i.isInBps)), a.set("feeReceiver", i.feeReceiver));
|
|
892
892
|
const s = await fetch(
|
|
893
|
-
`${
|
|
893
|
+
`${rn}/${cn(o)}/api/v1/routes?${a}`,
|
|
894
894
|
{
|
|
895
895
|
method: "GET",
|
|
896
896
|
headers: {
|
|
@@ -900,11 +900,11 @@ async function tr({
|
|
|
900
900
|
signal: c
|
|
901
901
|
}
|
|
902
902
|
);
|
|
903
|
-
if (!s.ok) throw await
|
|
903
|
+
if (!s.ok) throw await an(s);
|
|
904
904
|
const u = await s.json();
|
|
905
|
-
return
|
|
905
|
+
return tr(u.data);
|
|
906
906
|
}
|
|
907
|
-
async function
|
|
907
|
+
async function rr({
|
|
908
908
|
routeSummary: e,
|
|
909
909
|
sender: t,
|
|
910
910
|
recipient: n,
|
|
@@ -913,7 +913,7 @@ async function nr({
|
|
|
913
913
|
signal: i
|
|
914
914
|
}) {
|
|
915
915
|
const c = await fetch(
|
|
916
|
-
`${
|
|
916
|
+
`${rn}/${cn(r)}/api/v1/route/build`,
|
|
917
917
|
{
|
|
918
918
|
method: "POST",
|
|
919
919
|
headers: {
|
|
@@ -934,33 +934,33 @@ async function nr({
|
|
|
934
934
|
signal: i
|
|
935
935
|
}
|
|
936
936
|
);
|
|
937
|
-
if (!c.ok) throw await
|
|
937
|
+
if (!c.ok) throw await an(c);
|
|
938
938
|
const a = await c.json();
|
|
939
|
-
return
|
|
939
|
+
return nr(a.data);
|
|
940
940
|
}
|
|
941
|
-
const
|
|
941
|
+
const ir = 2, cr = "Route temporarily unavailable. Refresh the quote and try again.";
|
|
942
942
|
function ll(e, t) {
|
|
943
|
-
return
|
|
943
|
+
return sn(e) ? cr : Yo(e, t);
|
|
944
944
|
}
|
|
945
|
-
function
|
|
945
|
+
function ar(e, t) {
|
|
946
946
|
if (!Number.isFinite(t) || t < 0 || t > 2e3)
|
|
947
947
|
throw new Error("Slippage must be between 0% and 20%.");
|
|
948
948
|
return e * BigInt(1e4 - Math.round(t)) / 10000n;
|
|
949
949
|
}
|
|
950
|
-
function
|
|
950
|
+
function sr(e, t) {
|
|
951
951
|
if (t <= 0) return 0n;
|
|
952
952
|
const n = BigInt(1e4 - t);
|
|
953
953
|
return (e * 10000n + n - 1n) / n - e;
|
|
954
954
|
}
|
|
955
|
-
function
|
|
955
|
+
function ur(e) {
|
|
956
956
|
return e !== N ? null : {
|
|
957
|
-
feeAmount: String(
|
|
957
|
+
feeAmount: String(Lt),
|
|
958
958
|
chargeFeeBy: "currency_out",
|
|
959
959
|
isInBps: !0,
|
|
960
|
-
feeReceiver:
|
|
960
|
+
feeReceiver: Gt
|
|
961
961
|
};
|
|
962
962
|
}
|
|
963
|
-
function
|
|
963
|
+
function lr(e) {
|
|
964
964
|
const t = e.routeSummary.gasEstimate ?? e.routeSummary.gas ?? "0";
|
|
965
965
|
try {
|
|
966
966
|
return BigInt(t);
|
|
@@ -968,12 +968,12 @@ function sr(e) {
|
|
|
968
968
|
return 0n;
|
|
969
969
|
}
|
|
970
970
|
}
|
|
971
|
-
function
|
|
971
|
+
function dr(e) {
|
|
972
972
|
var t;
|
|
973
973
|
return ((t = e.routeSummary.route) == null ? void 0 : t.flat()) ?? [];
|
|
974
974
|
}
|
|
975
|
-
function
|
|
976
|
-
const o =
|
|
975
|
+
function pr(e, t, n) {
|
|
976
|
+
const o = dr(e);
|
|
977
977
|
return o.length ? o.map((r) => ({
|
|
978
978
|
dex: r.exchange || r.poolType || "Unknown",
|
|
979
979
|
inputToken: t,
|
|
@@ -993,10 +993,10 @@ async function ut(e, t, n, o, r = "exactIn", i, c, a) {
|
|
|
993
993
|
throw new Error("Input and output tokens must be on the same chain.");
|
|
994
994
|
if (n <= 0n)
|
|
995
995
|
throw new Error("Enter an amount to swap.");
|
|
996
|
-
const s =
|
|
996
|
+
const s = ur(e.chainId), u = i ? ir : 1;
|
|
997
997
|
let l;
|
|
998
998
|
for (let p = 0; p < u; p += 1) {
|
|
999
|
-
const m = await
|
|
999
|
+
const m = await or({
|
|
1000
1000
|
tokenIn: e.address,
|
|
1001
1001
|
tokenOut: t.address,
|
|
1002
1002
|
amountIn: n.toString(),
|
|
@@ -1004,10 +1004,10 @@ async function ut(e, t, n, o, r = "exactIn", i, c, a) {
|
|
|
1004
1004
|
origin: i,
|
|
1005
1005
|
fee: s,
|
|
1006
1006
|
signal: c
|
|
1007
|
-
}), f = BigInt(m.routeSummary.amountOut), _ = s ?
|
|
1007
|
+
}), f = BigInt(m.routeSummary.amountOut), _ = s ? Lt : 0, y = sr(f, _), k = ar(f, o);
|
|
1008
1008
|
let w = null;
|
|
1009
1009
|
try {
|
|
1010
|
-
w = i ? await
|
|
1010
|
+
w = i ? await rr({
|
|
1011
1011
|
routeSummary: m.routeSummary,
|
|
1012
1012
|
sender: i,
|
|
1013
1013
|
recipient: i,
|
|
@@ -1016,7 +1016,7 @@ async function ut(e, t, n, o, r = "exactIn", i, c, a) {
|
|
|
1016
1016
|
signal: c
|
|
1017
1017
|
}) : null;
|
|
1018
1018
|
} catch (T) {
|
|
1019
|
-
if (l = T, i && p < u - 1 &&
|
|
1019
|
+
if (l = T, i && p < u - 1 && sn(T))
|
|
1020
1020
|
continue;
|
|
1021
1021
|
throw T;
|
|
1022
1022
|
}
|
|
@@ -1025,22 +1025,22 @@ async function ut(e, t, n, o, r = "exactIn", i, c, a) {
|
|
|
1025
1025
|
outputToken: t,
|
|
1026
1026
|
amountIn: n,
|
|
1027
1027
|
amountOut: f,
|
|
1028
|
-
gasEstimate: w != null && w.gas ? BigInt(w.gas) :
|
|
1029
|
-
hops:
|
|
1028
|
+
gasEstimate: w != null && w.gas ? BigInt(w.gas) : lr(m),
|
|
1029
|
+
hops: pr(m, e, t),
|
|
1030
1030
|
routerAddress: (w == null ? void 0 : w.routerAddress) ?? m.routerAddress,
|
|
1031
1031
|
calldata: (w == null ? void 0 : w.data) ?? null,
|
|
1032
1032
|
transactionValue: w != null && w.transactionValue ? BigInt(w.transactionValue) : 0n,
|
|
1033
1033
|
priceImpact: m.routeSummary.priceImpact ?? 0,
|
|
1034
1034
|
feeAmount: y,
|
|
1035
1035
|
feeBps: _,
|
|
1036
|
-
feeRecipient: s ?
|
|
1036
|
+
feeRecipient: s ? Gt : null,
|
|
1037
1037
|
userAmountOutMinimum: k,
|
|
1038
1038
|
amountOutMinimum: k
|
|
1039
1039
|
};
|
|
1040
1040
|
}
|
|
1041
1041
|
throw l instanceof Error ? l : new Error("Swap route could not be encoded. Try again.");
|
|
1042
1042
|
}
|
|
1043
|
-
const Se = 2n ** 160n - 1n,
|
|
1043
|
+
const Se = 2n ** 160n - 1n, un = 2n ** 256n - 1n, ln = 600, fr = 1800, dn = 1800, mr = ln, hr = 2 ** 48 - 1, _r = {
|
|
1044
1044
|
PermitBatch: [
|
|
1045
1045
|
{ name: "details", type: "PermitDetails[]" },
|
|
1046
1046
|
{ name: "spender", type: "address" },
|
|
@@ -1053,8 +1053,8 @@ const Se = 2n ** 160n - 1n, sn = 2n ** 256n - 1n, un = 600, dr = 1800, ln = 1800
|
|
|
1053
1053
|
{ name: "nonce", type: "uint48" }
|
|
1054
1054
|
]
|
|
1055
1055
|
};
|
|
1056
|
-
async function
|
|
1057
|
-
const t = e.amount ??
|
|
1056
|
+
async function lt(e) {
|
|
1057
|
+
const t = e.amount ?? un, n = _e({
|
|
1058
1058
|
account: e.account,
|
|
1059
1059
|
chain: e.chain,
|
|
1060
1060
|
transport: we(e.provider)
|
|
@@ -1079,8 +1079,8 @@ function Ie(e) {
|
|
|
1079
1079
|
args: [e.owner, e.spender]
|
|
1080
1080
|
});
|
|
1081
1081
|
}
|
|
1082
|
-
async function
|
|
1083
|
-
const t = e.amount ??
|
|
1082
|
+
async function dt(e) {
|
|
1083
|
+
const t = e.amount ?? un, o = await _e({
|
|
1084
1084
|
account: e.account,
|
|
1085
1085
|
chain: e.chain,
|
|
1086
1086
|
transport: we(e.provider)
|
|
@@ -1095,14 +1095,14 @@ async function lt(e) {
|
|
|
1095
1095
|
if ((await e.publicClient.waitForTransactionReceipt({ hash: o })).status === "reverted") throw new Error("Token approval reverted.");
|
|
1096
1096
|
return o;
|
|
1097
1097
|
}
|
|
1098
|
-
async function
|
|
1099
|
-
const t = e.amount && e.amount < Se ? e.amount : Se, n = e.expiration ??
|
|
1098
|
+
async function wr(e) {
|
|
1099
|
+
const t = e.amount && e.amount < Se ? e.amount : Se, n = e.expiration ?? hr, o = _e({
|
|
1100
1100
|
account: e.account,
|
|
1101
1101
|
chain: e.chain,
|
|
1102
1102
|
transport: we(e.provider)
|
|
1103
1103
|
}), { request: r } = await e.publicClient.simulateContract({
|
|
1104
1104
|
address: e.permit2,
|
|
1105
|
-
abi:
|
|
1105
|
+
abi: qt,
|
|
1106
1106
|
functionName: "approve",
|
|
1107
1107
|
args: [e.token, e.router, t, n],
|
|
1108
1108
|
account: e.account
|
|
@@ -1113,29 +1113,29 @@ async function _r(e) {
|
|
|
1113
1113
|
if ((await e.publicClient.waitForTransactionReceipt({ hash: i })).status === "reverted") throw new Error("Permit2 approval reverted.");
|
|
1114
1114
|
return i;
|
|
1115
1115
|
}
|
|
1116
|
-
function
|
|
1116
|
+
function pn(e) {
|
|
1117
1117
|
return e.publicClient.readContract({
|
|
1118
1118
|
address: e.permit2,
|
|
1119
|
-
abi:
|
|
1119
|
+
abi: qt,
|
|
1120
1120
|
functionName: "allowance",
|
|
1121
1121
|
args: [e.account, e.token, e.router]
|
|
1122
1122
|
});
|
|
1123
1123
|
}
|
|
1124
|
-
async function
|
|
1125
|
-
const [t, n, o] = await (e.allowanceRead ??
|
|
1126
|
-
if (t >= e.amount && Number(n) > r +
|
|
1124
|
+
async function yr(e) {
|
|
1125
|
+
const [t, n, o] = await (e.allowanceRead ?? pn(e)), r = Math.floor(Date.now() / 1e3);
|
|
1126
|
+
if (t >= e.amount && Number(n) > r + mr)
|
|
1127
1127
|
return null;
|
|
1128
1128
|
const i = {
|
|
1129
1129
|
details: [
|
|
1130
1130
|
{
|
|
1131
1131
|
token: e.token,
|
|
1132
1132
|
amount: e.sizing === "max" || e.amount > Se ? Se : e.amount,
|
|
1133
|
-
expiration: r +
|
|
1133
|
+
expiration: r + dn,
|
|
1134
1134
|
nonce: Number(o)
|
|
1135
1135
|
}
|
|
1136
1136
|
],
|
|
1137
1137
|
spender: e.router,
|
|
1138
|
-
sigDeadline: BigInt(r +
|
|
1138
|
+
sigDeadline: BigInt(r + fr)
|
|
1139
1139
|
}, a = await _e({
|
|
1140
1140
|
account: e.account,
|
|
1141
1141
|
chain: e.chain,
|
|
@@ -1147,7 +1147,7 @@ async function wr(e) {
|
|
|
1147
1147
|
chainId: e.chainId,
|
|
1148
1148
|
verifyingContract: e.permit2
|
|
1149
1149
|
},
|
|
1150
|
-
types:
|
|
1150
|
+
types: _r,
|
|
1151
1151
|
primaryType: "PermitBatch",
|
|
1152
1152
|
message: i
|
|
1153
1153
|
});
|
|
@@ -1157,29 +1157,29 @@ async function wr(e) {
|
|
|
1157
1157
|
signature: a
|
|
1158
1158
|
};
|
|
1159
1159
|
}
|
|
1160
|
-
const
|
|
1161
|
-
function
|
|
1160
|
+
const vr = "https://ichi-images.s3.us-east-1.amazonaws.com/tokens", Ne = /* @__PURE__ */ new Map();
|
|
1161
|
+
function pt(e, t, n) {
|
|
1162
1162
|
return `${e}|evm_${t}_${n.toLowerCase()}`;
|
|
1163
1163
|
}
|
|
1164
|
-
function
|
|
1164
|
+
function br(e, t) {
|
|
1165
1165
|
return `evm_${e}_${t.toLowerCase()}`;
|
|
1166
1166
|
}
|
|
1167
|
-
function
|
|
1167
|
+
function gr(e) {
|
|
1168
1168
|
const t = e == null ? void 0 : e.trim();
|
|
1169
1169
|
if (!t) return null;
|
|
1170
1170
|
const n = t.split("-"), r = (n.length > 1 ? n[n.length - 1] : t).trim().toLowerCase();
|
|
1171
1171
|
return !r || !/^[a-z0-9]+$/.test(r) ? null : r;
|
|
1172
1172
|
}
|
|
1173
|
-
function
|
|
1174
|
-
const t =
|
|
1175
|
-
return t ? `${
|
|
1173
|
+
function Er(e) {
|
|
1174
|
+
const t = gr(e);
|
|
1175
|
+
return t ? `${vr}/logo_256_${t}.svg` : null;
|
|
1176
1176
|
}
|
|
1177
1177
|
function dl(e, t) {
|
|
1178
1178
|
var n, o;
|
|
1179
|
-
return ((n = e.iconUrl) != null && n.trim() ? e.iconUrl : null) ?? ((o = t[Ue(e.address)]) == null ? void 0 : o.iconURL) ??
|
|
1179
|
+
return ((n = e.iconUrl) != null && n.trim() ? e.iconUrl : null) ?? ((o = t[Ue(e.address)]) == null ? void 0 : o.iconURL) ?? Er(e.symbol);
|
|
1180
1180
|
}
|
|
1181
|
-
function
|
|
1182
|
-
return `query AegisSwapWidgetTokenMetadata { ${t.map((o, r) => `t${r}: getGlobalToken(id: ${JSON.stringify(
|
|
1181
|
+
function kr(e, t) {
|
|
1182
|
+
return `query AegisSwapWidgetTokenMetadata { ${t.map((o, r) => `t${r}: getGlobalToken(id: ${JSON.stringify(br(e, o))}) { chainId address symbol displayName fullName decimals iconURL }`).join(" ")} }`;
|
|
1183
1183
|
}
|
|
1184
1184
|
async function pl(e) {
|
|
1185
1185
|
var a, s;
|
|
@@ -1191,7 +1191,7 @@ async function pl(e) {
|
|
|
1191
1191
|
})
|
|
1192
1192
|
).values()
|
|
1193
1193
|
], o = /* @__PURE__ */ new Map(), r = n.filter((u) => {
|
|
1194
|
-
const l =
|
|
1194
|
+
const l = pt(t, e.chainId, u);
|
|
1195
1195
|
if (!Ne.has(l)) return !0;
|
|
1196
1196
|
const p = Ne.get(l);
|
|
1197
1197
|
return p && o.set(Ue(u), p), !1;
|
|
@@ -1201,7 +1201,7 @@ async function pl(e) {
|
|
|
1201
1201
|
method: "POST",
|
|
1202
1202
|
headers: { "Content-Type": "application/json" },
|
|
1203
1203
|
body: JSON.stringify({
|
|
1204
|
-
query:
|
|
1204
|
+
query: kr(e.chainId, r)
|
|
1205
1205
|
}),
|
|
1206
1206
|
signal: e.signal
|
|
1207
1207
|
});
|
|
@@ -1213,29 +1213,29 @@ async function pl(e) {
|
|
|
1213
1213
|
return r.forEach((u, l) => {
|
|
1214
1214
|
var m;
|
|
1215
1215
|
const p = ((m = c.data) == null ? void 0 : m[`t${l}`]) ?? null;
|
|
1216
|
-
Ne.set(
|
|
1216
|
+
Ne.set(pt(t, e.chainId, u), p), p && o.set(Ue(u), p);
|
|
1217
1217
|
}), o;
|
|
1218
1218
|
}
|
|
1219
|
-
function
|
|
1219
|
+
function Sr() {
|
|
1220
1220
|
return typeof window > "u" ? null : window.ethereum ?? null;
|
|
1221
1221
|
}
|
|
1222
1222
|
function $e(e) {
|
|
1223
|
-
return typeof e != "string" || !
|
|
1223
|
+
return typeof e != "string" || !ao(e) ? null : b(e);
|
|
1224
1224
|
}
|
|
1225
|
-
function
|
|
1225
|
+
function Ir(e) {
|
|
1226
1226
|
return !!(e && typeof e == "object" && typeof e.request == "function");
|
|
1227
1227
|
}
|
|
1228
|
-
function
|
|
1229
|
-
return
|
|
1228
|
+
function Ar(e) {
|
|
1229
|
+
return Ir(e) ? { provider: e, account: null } : !e || typeof e != "object" ? { provider: null, account: null } : {
|
|
1230
1230
|
provider: e.provider ?? null,
|
|
1231
1231
|
account: $e(e.account)
|
|
1232
1232
|
};
|
|
1233
1233
|
}
|
|
1234
|
-
async function
|
|
1234
|
+
async function zr(e) {
|
|
1235
1235
|
const t = await e.request({ method: "eth_accounts" });
|
|
1236
1236
|
return $e(t == null ? void 0 : t[0]);
|
|
1237
1237
|
}
|
|
1238
|
-
async function
|
|
1238
|
+
async function Tr(e) {
|
|
1239
1239
|
const t = await e.request({ method: "eth_requestAccounts" });
|
|
1240
1240
|
return $e(t == null ? void 0 : t[0]);
|
|
1241
1241
|
}
|
|
@@ -1245,28 +1245,28 @@ async function Be(e) {
|
|
|
1245
1245
|
const n = Number.parseInt(t, 16);
|
|
1246
1246
|
return Number.isSafeInteger(n) ? n : null;
|
|
1247
1247
|
}
|
|
1248
|
-
function
|
|
1248
|
+
function $r(e) {
|
|
1249
1249
|
return `0x${e.toString(16)}`;
|
|
1250
1250
|
}
|
|
1251
|
-
function
|
|
1251
|
+
function Or(e) {
|
|
1252
1252
|
const t = e, n = [t.message, t.shortMessage, t.details].filter((o) => typeof o == "string").join(" ").toLowerCase();
|
|
1253
1253
|
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");
|
|
1254
1254
|
}
|
|
1255
|
-
function
|
|
1255
|
+
function Cr(e) {
|
|
1256
1256
|
return typeof e == "number" ? { chainId: e } : e;
|
|
1257
1257
|
}
|
|
1258
|
-
function
|
|
1258
|
+
function Pr(e) {
|
|
1259
1259
|
var t, n;
|
|
1260
1260
|
return (t = e.rpcUrls) != null && t.length ? e.rpcUrls : ((n = e.chain) == null ? void 0 : n.rpcUrls.default.http) ?? [];
|
|
1261
1261
|
}
|
|
1262
|
-
function
|
|
1262
|
+
function xr(e) {
|
|
1263
1263
|
var n, o;
|
|
1264
1264
|
const t = (o = (n = e.chain) == null ? void 0 : n.blockExplorers) == null ? void 0 : o.default.url;
|
|
1265
1265
|
return t ? [t] : [];
|
|
1266
1266
|
}
|
|
1267
|
-
async function
|
|
1267
|
+
async function Zr(e, t) {
|
|
1268
1268
|
var i, c;
|
|
1269
|
-
const n =
|
|
1269
|
+
const n = Cr(t), o = $r(n.chainId), r = {
|
|
1270
1270
|
method: "wallet_switchEthereumChain",
|
|
1271
1271
|
params: [{ chainId: o }]
|
|
1272
1272
|
};
|
|
@@ -1274,10 +1274,10 @@ async function xr(e, t) {
|
|
|
1274
1274
|
await e.request(r);
|
|
1275
1275
|
return;
|
|
1276
1276
|
} catch (a) {
|
|
1277
|
-
if (
|
|
1278
|
-
const s =
|
|
1277
|
+
if (!Or(a)) throw a;
|
|
1278
|
+
const s = Pr(n);
|
|
1279
1279
|
if (s.length === 0) throw a;
|
|
1280
|
-
const u =
|
|
1280
|
+
const u = xr(n);
|
|
1281
1281
|
await e.request({
|
|
1282
1282
|
method: "wallet_addEthereumChain",
|
|
1283
1283
|
params: [
|
|
@@ -1302,16 +1302,16 @@ async function xr(e, t) {
|
|
|
1302
1302
|
}
|
|
1303
1303
|
function fl(e, t) {
|
|
1304
1304
|
const n = t.map(
|
|
1305
|
-
(o) =>
|
|
1305
|
+
(o) => ro(o, {
|
|
1306
1306
|
batch: !0,
|
|
1307
1307
|
retryCount: 2,
|
|
1308
1308
|
retryDelay: 150,
|
|
1309
1309
|
timeout: 1e4
|
|
1310
1310
|
})
|
|
1311
1311
|
);
|
|
1312
|
-
return
|
|
1312
|
+
return io({
|
|
1313
1313
|
chain: e,
|
|
1314
|
-
transport: n.length === 1 ? n[0] :
|
|
1314
|
+
transport: n.length === 1 ? n[0] : co(n)
|
|
1315
1315
|
});
|
|
1316
1316
|
}
|
|
1317
1317
|
function ml(e, t) {
|
|
@@ -1330,7 +1330,14 @@ function ml(e, t) {
|
|
|
1330
1330
|
(i = n.removeListener) == null || i.call(n, "accountsChanged", o), (c = n.removeListener) == null || c.call(n, "chainChanged", r);
|
|
1331
1331
|
};
|
|
1332
1332
|
}
|
|
1333
|
-
function
|
|
1333
|
+
async function fn(e, t) {
|
|
1334
|
+
try {
|
|
1335
|
+
return await e.estimateGas(t) * 12n / 10n;
|
|
1336
|
+
} catch {
|
|
1337
|
+
return;
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
function Nr(e) {
|
|
1334
1341
|
const t = e.gasUsed ?? 0n, n = e.effectiveGasPrice ?? 0n;
|
|
1335
1342
|
return {
|
|
1336
1343
|
transactionHash: e.transactionHash,
|
|
@@ -1340,7 +1347,7 @@ function Zr(e) {
|
|
|
1340
1347
|
feeWei: t * n
|
|
1341
1348
|
};
|
|
1342
1349
|
}
|
|
1343
|
-
async function
|
|
1350
|
+
async function mn(e) {
|
|
1344
1351
|
var i, c;
|
|
1345
1352
|
const n = await _e({
|
|
1346
1353
|
account: e.wallet.account,
|
|
@@ -1368,9 +1375,9 @@ async function pn(e) {
|
|
|
1368
1375
|
});
|
|
1369
1376
|
if (o === "cancelled") throw new Error("Swap was cancelled in the wallet.");
|
|
1370
1377
|
if (r.status === "reverted") throw new Error("Swap reverted on-chain.");
|
|
1371
|
-
return { receipt: r, summary:
|
|
1378
|
+
return { receipt: r, summary: Nr(r) };
|
|
1372
1379
|
}
|
|
1373
|
-
async function
|
|
1380
|
+
async function Rr({
|
|
1374
1381
|
wallet: e,
|
|
1375
1382
|
publicClient: t,
|
|
1376
1383
|
activeChain: n,
|
|
@@ -1383,7 +1390,7 @@ async function Nr({
|
|
|
1383
1390
|
setTxHash: u,
|
|
1384
1391
|
onSubmitted: l
|
|
1385
1392
|
}) {
|
|
1386
|
-
const p = BigInt(Math.floor(Date.now() / 1e3) +
|
|
1393
|
+
const p = BigInt(Math.floor(Date.now() / 1e3) + ln), m = Xo(c), f = c.mode === "exactOut" ? Do({
|
|
1387
1394
|
poolKey: c.poolKey,
|
|
1388
1395
|
zeroForOne: c.zeroForOne,
|
|
1389
1396
|
amountOut: c.grossAmountOut,
|
|
@@ -1392,7 +1399,7 @@ async function Nr({
|
|
|
1392
1399
|
deadline: p,
|
|
1393
1400
|
permit: a,
|
|
1394
1401
|
fee: m
|
|
1395
|
-
}) :
|
|
1402
|
+
}) : Ro({
|
|
1396
1403
|
poolKey: c.poolKey,
|
|
1397
1404
|
zeroForOne: c.zeroForOne,
|
|
1398
1405
|
amountIn: c.amountIn,
|
|
@@ -1403,7 +1410,7 @@ async function Nr({
|
|
|
1403
1410
|
fee: m
|
|
1404
1411
|
});
|
|
1405
1412
|
s("submitting");
|
|
1406
|
-
const _ = await t
|
|
1413
|
+
const _ = await fn(t, {
|
|
1407
1414
|
account: e.account,
|
|
1408
1415
|
to: o.router,
|
|
1409
1416
|
data: f.calldata,
|
|
@@ -1416,21 +1423,21 @@ async function Nr({
|
|
|
1416
1423
|
amountOut: c.amountOut,
|
|
1417
1424
|
feeAmount: c.feeAmount,
|
|
1418
1425
|
feeBps: c.feeBps
|
|
1419
|
-
}, { receipt: k, summary: w } = await
|
|
1426
|
+
}, { receipt: k, summary: w } = await mn({
|
|
1420
1427
|
wallet: e,
|
|
1421
1428
|
publicClient: t,
|
|
1422
1429
|
chain: n.chain,
|
|
1423
1430
|
to: o.router,
|
|
1424
1431
|
data: f.calldata,
|
|
1425
1432
|
value: f.value,
|
|
1426
|
-
gas: _
|
|
1433
|
+
gas: _,
|
|
1427
1434
|
swapDetails: y,
|
|
1428
1435
|
onHash: u,
|
|
1429
1436
|
onSubmitted: l
|
|
1430
1437
|
});
|
|
1431
1438
|
return { receipt: k, summary: w, swapDetails: y };
|
|
1432
1439
|
}
|
|
1433
|
-
async function
|
|
1440
|
+
async function Dr({
|
|
1434
1441
|
wallet: e,
|
|
1435
1442
|
publicClient: t,
|
|
1436
1443
|
activeChain: n,
|
|
@@ -1442,8 +1449,9 @@ async function Rr({
|
|
|
1442
1449
|
allowanceRead: s,
|
|
1443
1450
|
setStatus: u
|
|
1444
1451
|
}) {
|
|
1452
|
+
await s;
|
|
1445
1453
|
try {
|
|
1446
|
-
return await
|
|
1454
|
+
return await yr({
|
|
1447
1455
|
provider: e.provider,
|
|
1448
1456
|
publicClient: t,
|
|
1449
1457
|
account: e.account,
|
|
@@ -1457,8 +1465,8 @@ async function Rr({
|
|
|
1457
1465
|
allowanceRead: s
|
|
1458
1466
|
});
|
|
1459
1467
|
} catch (l) {
|
|
1460
|
-
if (
|
|
1461
|
-
return u("approving"), await
|
|
1468
|
+
if (nn(l)) throw l;
|
|
1469
|
+
return u("approving"), await wr({
|
|
1462
1470
|
provider: e.provider,
|
|
1463
1471
|
publicClient: t,
|
|
1464
1472
|
account: e.account,
|
|
@@ -1468,7 +1476,7 @@ async function Rr({
|
|
|
1468
1476
|
router: r,
|
|
1469
1477
|
// undefined -> MAX_UINT160, mirroring the 'max' permit sizing above.
|
|
1470
1478
|
amount: a === "max" ? void 0 : c,
|
|
1471
|
-
expiration: Math.floor(Date.now() / 1e3) +
|
|
1479
|
+
expiration: Math.floor(Date.now() / 1e3) + dn
|
|
1472
1480
|
}), null;
|
|
1473
1481
|
}
|
|
1474
1482
|
}
|
|
@@ -1487,55 +1495,55 @@ async function _l(e, t, n, o) {
|
|
|
1487
1495
|
}
|
|
1488
1496
|
throw r ?? new Error("retryOnError was called with attempts < 1.");
|
|
1489
1497
|
}
|
|
1490
|
-
async function
|
|
1498
|
+
async function hn(e, t, n, o) {
|
|
1491
1499
|
let r = await e();
|
|
1492
1500
|
for (let i = 1; i < n && !t(r); i += 1)
|
|
1493
1501
|
await new Promise((c) => setTimeout(c, o)), r = await e();
|
|
1494
1502
|
return r;
|
|
1495
1503
|
}
|
|
1496
|
-
async function
|
|
1497
|
-
const n = await
|
|
1504
|
+
async function _n(e, t) {
|
|
1505
|
+
const n = await hn(e, (o) => o >= t, 5, 300);
|
|
1498
1506
|
if (n < t)
|
|
1499
1507
|
throw new Error("Approval confirmed, but allowance is still below this quote. Try again.");
|
|
1500
1508
|
return n;
|
|
1501
1509
|
}
|
|
1502
|
-
async function
|
|
1503
|
-
return await
|
|
1510
|
+
async function Mr(e, t, n = 12, o = 250) {
|
|
1511
|
+
return await hn(
|
|
1504
1512
|
() => Be(e),
|
|
1505
1513
|
(i) => i === t,
|
|
1506
1514
|
n,
|
|
1507
1515
|
o
|
|
1508
1516
|
) === t;
|
|
1509
1517
|
}
|
|
1510
|
-
async function
|
|
1518
|
+
async function wn(e) {
|
|
1511
1519
|
var r, i;
|
|
1512
1520
|
const t = await Be(e.provider);
|
|
1513
1521
|
if ((r = e.onChainId) == null || r.call(e, t), t === e.chain.chainId) return;
|
|
1514
|
-
await
|
|
1515
|
-
const n = await
|
|
1522
|
+
await Zr(e.provider, e.chain);
|
|
1523
|
+
const n = await Mr(e.provider, e.chain.chainId), o = n ? e.chain.chainId : await Be(e.provider);
|
|
1516
1524
|
if ((i = e.onChainId) == null || i.call(e, o), !n)
|
|
1517
1525
|
throw new Error("Network switch did not complete. Switch to the correct network and try again.");
|
|
1518
1526
|
}
|
|
1519
1527
|
async function wl(e = {}) {
|
|
1520
1528
|
var o;
|
|
1521
|
-
let t = e.provider ?? await ((o = e.getProvider) == null ? void 0 : o.call(e)) ??
|
|
1529
|
+
let t = e.provider ?? await ((o = e.getProvider) == null ? void 0 : o.call(e)) ?? Sr(), n = $e(e.account);
|
|
1522
1530
|
if ((!t || !n) && e.connectWallet) {
|
|
1523
|
-
const r =
|
|
1531
|
+
const r = Ar(await e.connectWallet());
|
|
1524
1532
|
t = r.provider ?? t, n = n ?? r.account;
|
|
1525
1533
|
}
|
|
1526
1534
|
if (!t) throw new Error("No wallet provider found.");
|
|
1527
|
-
if (n || (n = e.requestAccount === !1 ? await
|
|
1535
|
+
if (n || (n = e.requestAccount === !1 ? await zr(t) : await Tr(t)), !n) throw new Error("Wallet connection was not completed.");
|
|
1528
1536
|
return { provider: t, account: n };
|
|
1529
1537
|
}
|
|
1530
|
-
class
|
|
1538
|
+
class Ur extends Error {
|
|
1531
1539
|
constructor(n) {
|
|
1532
1540
|
super("Price moved beyond your slippage tolerance. Review the updated quote and try again.");
|
|
1533
|
-
|
|
1541
|
+
U(this, "quote");
|
|
1534
1542
|
this.name = "DirectPoolSwapPriceMovedError", this.quote = n;
|
|
1535
1543
|
}
|
|
1536
1544
|
}
|
|
1537
|
-
function
|
|
1538
|
-
return
|
|
1545
|
+
function Fr(e) {
|
|
1546
|
+
return qo({
|
|
1539
1547
|
publicClient: e.publicClient,
|
|
1540
1548
|
account: e.account,
|
|
1541
1549
|
market: e.market,
|
|
@@ -1548,7 +1556,7 @@ function Ur(e) {
|
|
|
1548
1556
|
signal: e.signal
|
|
1549
1557
|
});
|
|
1550
1558
|
}
|
|
1551
|
-
async function
|
|
1559
|
+
async function Br(e) {
|
|
1552
1560
|
var r;
|
|
1553
1561
|
const t = () => Ie({
|
|
1554
1562
|
publicClient: e.publicClient,
|
|
@@ -1558,8 +1566,16 @@ async function Fr(e) {
|
|
|
1558
1566
|
});
|
|
1559
1567
|
let n = await t();
|
|
1560
1568
|
if (n >= e.amount) return { approvalHash: null, allowance: n };
|
|
1561
|
-
(r = e.onStatus) == null || r.call(e, "approving")
|
|
1562
|
-
|
|
1569
|
+
(r = e.onStatus) == null || r.call(e, "approving"), n > 0n && await lt({
|
|
1570
|
+
provider: e.wallet.provider,
|
|
1571
|
+
publicClient: e.publicClient,
|
|
1572
|
+
account: e.wallet.account,
|
|
1573
|
+
chain: e.activeChain.chain,
|
|
1574
|
+
token: e.token.address,
|
|
1575
|
+
permit2: e.permit2,
|
|
1576
|
+
amount: 0n
|
|
1577
|
+
});
|
|
1578
|
+
const o = await lt({
|
|
1563
1579
|
provider: e.wallet.provider,
|
|
1564
1580
|
publicClient: e.publicClient,
|
|
1565
1581
|
account: e.wallet.account,
|
|
@@ -1568,11 +1584,11 @@ async function Fr(e) {
|
|
|
1568
1584
|
permit2: e.permit2,
|
|
1569
1585
|
amount: e.approvalMode === "exact" ? e.amount : void 0
|
|
1570
1586
|
});
|
|
1571
|
-
return n = await
|
|
1587
|
+
return n = await _n(t, e.amount), { approvalHash: o, allowance: n };
|
|
1572
1588
|
}
|
|
1573
1589
|
async function yl(e) {
|
|
1574
1590
|
var l, p, m;
|
|
1575
|
-
await
|
|
1591
|
+
await wn({
|
|
1576
1592
|
provider: e.wallet.provider,
|
|
1577
1593
|
chain: e.activeChain,
|
|
1578
1594
|
onChainId: e.onWalletChainId
|
|
@@ -1582,7 +1598,7 @@ async function yl(e) {
|
|
|
1582
1598
|
token: e.inputToken.address,
|
|
1583
1599
|
owner: e.wallet.account,
|
|
1584
1600
|
spender: e.market.permit2
|
|
1585
|
-
}).catch(() => null), n =
|
|
1601
|
+
}).catch(() => null), n = pn({
|
|
1586
1602
|
publicClient: e.publicClient,
|
|
1587
1603
|
permit2: e.market.permit2,
|
|
1588
1604
|
account: e.wallet.account,
|
|
@@ -1591,7 +1607,7 @@ async function yl(e) {
|
|
|
1591
1607
|
});
|
|
1592
1608
|
n.catch(() => {
|
|
1593
1609
|
});
|
|
1594
|
-
const o = await
|
|
1610
|
+
const o = await Fr({
|
|
1595
1611
|
publicClient: e.publicClient,
|
|
1596
1612
|
account: e.wallet.account,
|
|
1597
1613
|
activeChain: e.activeChain,
|
|
@@ -1602,10 +1618,10 @@ async function yl(e) {
|
|
|
1602
1618
|
amount: e.amount,
|
|
1603
1619
|
slippageBps: e.slippageBps,
|
|
1604
1620
|
signal: e.signal
|
|
1605
|
-
}), r =
|
|
1621
|
+
}), r = Jo(e.displayedQuote ?? null, o);
|
|
1606
1622
|
if (r.priceMovedBeyondTolerance)
|
|
1607
|
-
throw (l = e.onStatus) == null || l.call(e, "idle"), new
|
|
1608
|
-
const i = r.quote, c =
|
|
1623
|
+
throw (l = e.onStatus) == null || l.call(e, "idle"), new Ur(o);
|
|
1624
|
+
const i = r.quote, c = Ho(i);
|
|
1609
1625
|
if (c <= 0n) throw new Error("Quote returned an empty amount. Try again.");
|
|
1610
1626
|
let a = await t ?? await Ie({
|
|
1611
1627
|
publicClient: e.publicClient,
|
|
@@ -1613,7 +1629,7 @@ async function yl(e) {
|
|
|
1613
1629
|
owner: e.wallet.account,
|
|
1614
1630
|
spender: e.market.permit2
|
|
1615
1631
|
});
|
|
1616
|
-
if (a < c && (a = (await
|
|
1632
|
+
if (a < c && (a = (await Br({
|
|
1617
1633
|
wallet: e.wallet,
|
|
1618
1634
|
publicClient: e.publicClient,
|
|
1619
1635
|
activeChain: e.activeChain,
|
|
@@ -1625,7 +1641,7 @@ async function yl(e) {
|
|
|
1625
1641
|
})).allowance), a < c)
|
|
1626
1642
|
throw new Error(`Approve ${e.inputToken.symbol} before swapping.`);
|
|
1627
1643
|
(p = e.onStatus) == null || p.call(e, "signing");
|
|
1628
|
-
const s = await
|
|
1644
|
+
const s = await Dr({
|
|
1629
1645
|
wallet: e.wallet,
|
|
1630
1646
|
publicClient: e.publicClient,
|
|
1631
1647
|
activeChain: e.activeChain,
|
|
@@ -1639,7 +1655,7 @@ async function yl(e) {
|
|
|
1639
1655
|
var _;
|
|
1640
1656
|
return (_ = e.onStatus) == null ? void 0 : _.call(e, f);
|
|
1641
1657
|
}
|
|
1642
|
-
}), u = await
|
|
1658
|
+
}), u = await Rr({
|
|
1643
1659
|
wallet: e.wallet,
|
|
1644
1660
|
publicClient: e.publicClient,
|
|
1645
1661
|
activeChain: e.activeChain,
|
|
@@ -1660,33 +1676,26 @@ async function yl(e) {
|
|
|
1660
1676
|
});
|
|
1661
1677
|
return (m = e.onStatus) == null || m.call(e, "success"), {
|
|
1662
1678
|
hash: u.receipt.transactionHash,
|
|
1663
|
-
explorerUrl:
|
|
1679
|
+
explorerUrl: Kt(u.receipt.transactionHash, e.activeChain),
|
|
1664
1680
|
quote: i,
|
|
1665
1681
|
receiptSummary: u.summary,
|
|
1666
1682
|
swap: u.swapDetails
|
|
1667
1683
|
};
|
|
1668
1684
|
}
|
|
1669
|
-
async function Br(e, t) {
|
|
1670
|
-
try {
|
|
1671
|
-
return await e.estimateGas(t) * 12n / 10n;
|
|
1672
|
-
} catch {
|
|
1673
|
-
return;
|
|
1674
|
-
}
|
|
1675
|
-
}
|
|
1676
1685
|
const jr = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
1677
|
-
function
|
|
1686
|
+
function yn(e) {
|
|
1678
1687
|
return e.address.toLowerCase() === jr.toLowerCase();
|
|
1679
1688
|
}
|
|
1680
1689
|
class Lr extends Error {
|
|
1681
1690
|
constructor(n) {
|
|
1682
1691
|
super("Price moved beyond your slippage tolerance. Review the updated quote and try again.");
|
|
1683
|
-
|
|
1692
|
+
U(this, "quote");
|
|
1684
1693
|
this.name = "KyberSwapPriceMovedError", this.quote = n;
|
|
1685
1694
|
}
|
|
1686
1695
|
}
|
|
1687
1696
|
async function Gr(e) {
|
|
1688
1697
|
var r;
|
|
1689
|
-
if (
|
|
1698
|
+
if (yn(e.inputToken)) return { approvalHashes: [], allowance: e.amount };
|
|
1690
1699
|
const t = () => Ie({
|
|
1691
1700
|
publicClient: e.publicClient,
|
|
1692
1701
|
token: e.inputToken.address,
|
|
@@ -1698,7 +1707,7 @@ async function Gr(e) {
|
|
|
1698
1707
|
(r = e.onStatus) == null || r.call(e, "approving");
|
|
1699
1708
|
const o = [];
|
|
1700
1709
|
return n > 0n && o.push(
|
|
1701
|
-
await
|
|
1710
|
+
await dt({
|
|
1702
1711
|
provider: e.wallet.provider,
|
|
1703
1712
|
publicClient: e.publicClient,
|
|
1704
1713
|
account: e.wallet.account,
|
|
@@ -1708,7 +1717,7 @@ async function Gr(e) {
|
|
|
1708
1717
|
amount: 0n
|
|
1709
1718
|
})
|
|
1710
1719
|
), o.push(
|
|
1711
|
-
await
|
|
1720
|
+
await dt({
|
|
1712
1721
|
provider: e.wallet.provider,
|
|
1713
1722
|
publicClient: e.publicClient,
|
|
1714
1723
|
account: e.wallet.account,
|
|
@@ -1717,7 +1726,7 @@ async function Gr(e) {
|
|
|
1717
1726
|
spender: e.spender,
|
|
1718
1727
|
amount: e.approvalMode === "max" ? void 0 : e.amount
|
|
1719
1728
|
})
|
|
1720
|
-
), n = await
|
|
1729
|
+
), n = await _n(t, e.amount), { approvalHashes: o, allowance: n };
|
|
1721
1730
|
}
|
|
1722
1731
|
function Wr(e) {
|
|
1723
1732
|
return {
|
|
@@ -1732,7 +1741,7 @@ function Wr(e) {
|
|
|
1732
1741
|
}
|
|
1733
1742
|
async function vl(e) {
|
|
1734
1743
|
var s, u, l;
|
|
1735
|
-
await
|
|
1744
|
+
await wn({
|
|
1736
1745
|
provider: e.wallet.provider,
|
|
1737
1746
|
chain: e.activeChain,
|
|
1738
1747
|
onChainId: e.onWalletChainId
|
|
@@ -1765,15 +1774,17 @@ async function vl(e) {
|
|
|
1765
1774
|
e.wallet.account,
|
|
1766
1775
|
e.signal
|
|
1767
1776
|
);
|
|
1777
|
+
if (!D(n.routerAddress, t.routerAddress))
|
|
1778
|
+
throw new Error("Swap route changed unexpectedly. Refresh the quote and try again.");
|
|
1768
1779
|
if (e.displayedQuote && n.amountOut < e.displayedQuote.userAmountOutMinimum)
|
|
1769
1780
|
throw (u = e.onStatus) == null || u.call(e, "idle"), new Lr(n);
|
|
1770
1781
|
if (!n.calldata) throw new Error("Swap route could not be encoded. Try again.");
|
|
1771
|
-
const o = n.transactionValue || (
|
|
1782
|
+
const o = n.transactionValue || (yn(e.inputToken) ? n.amountIn : 0n), r = await fn(e.publicClient, {
|
|
1772
1783
|
account: e.wallet.account,
|
|
1773
1784
|
to: n.routerAddress,
|
|
1774
1785
|
data: n.calldata,
|
|
1775
1786
|
value: o
|
|
1776
|
-
}), i = Wr(n), { receipt: c, summary: a } = await
|
|
1787
|
+
}), i = Wr(n), { receipt: c, summary: a } = await mn({
|
|
1777
1788
|
wallet: e.wallet,
|
|
1778
1789
|
publicClient: e.publicClient,
|
|
1779
1790
|
chain: e.activeChain.chain,
|
|
@@ -1787,7 +1798,7 @@ async function vl(e) {
|
|
|
1787
1798
|
});
|
|
1788
1799
|
return (l = e.onStatus) == null || l.call(e, "success"), {
|
|
1789
1800
|
hash: c.transactionHash,
|
|
1790
|
-
explorerUrl:
|
|
1801
|
+
explorerUrl: Kt(c.transactionHash, e.activeChain),
|
|
1791
1802
|
quote: n,
|
|
1792
1803
|
receiptSummary: a,
|
|
1793
1804
|
swap: i
|
|
@@ -1899,7 +1910,7 @@ function gl({
|
|
|
1899
1910
|
activeWidthPct: 100
|
|
1900
1911
|
};
|
|
1901
1912
|
}
|
|
1902
|
-
var
|
|
1913
|
+
var ft;
|
|
1903
1914
|
function d(e, t, n) {
|
|
1904
1915
|
function o(a, s) {
|
|
1905
1916
|
if (a._zod || Object.defineProperty(a, "_zod", {
|
|
@@ -1942,17 +1953,17 @@ class oe extends Error {
|
|
|
1942
1953
|
super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
|
|
1943
1954
|
}
|
|
1944
1955
|
}
|
|
1945
|
-
class
|
|
1956
|
+
class vn extends Error {
|
|
1946
1957
|
constructor(t) {
|
|
1947
1958
|
super(`Encountered unidirectional transform during encode: ${t}`), this.name = "ZodEncodeError";
|
|
1948
1959
|
}
|
|
1949
1960
|
}
|
|
1950
|
-
(
|
|
1961
|
+
(ft = globalThis).__zod_globalConfig ?? (ft.__zod_globalConfig = {});
|
|
1951
1962
|
const Ye = globalThis.__zod_globalConfig;
|
|
1952
1963
|
function G(e) {
|
|
1953
1964
|
return Ye;
|
|
1954
1965
|
}
|
|
1955
|
-
function
|
|
1966
|
+
function bn(e) {
|
|
1956
1967
|
const t = Object.values(e).filter((o) => typeof o == "number");
|
|
1957
1968
|
return Object.entries(e).filter(([o, r]) => t.indexOf(+o) === -1).map(([o, r]) => r);
|
|
1958
1969
|
}
|
|
@@ -1980,13 +1991,13 @@ function qr(e, t) {
|
|
|
1980
1991
|
const n = e / t, o = Math.round(n), r = Number.EPSILON * Math.max(Math.abs(n), 1);
|
|
1981
1992
|
return Math.abs(n - o) < r ? 0 : n - o;
|
|
1982
1993
|
}
|
|
1983
|
-
const
|
|
1994
|
+
const mt = /* @__PURE__ */ Symbol("evaluating");
|
|
1984
1995
|
function v(e, t, n) {
|
|
1985
1996
|
let o;
|
|
1986
1997
|
Object.defineProperty(e, t, {
|
|
1987
1998
|
get() {
|
|
1988
|
-
if (o !==
|
|
1989
|
-
return o === void 0 && (o =
|
|
1999
|
+
if (o !== mt)
|
|
2000
|
+
return o === void 0 && (o = mt, o = n()), o;
|
|
1990
2001
|
},
|
|
1991
2002
|
set(r) {
|
|
1992
2003
|
Object.defineProperty(e, t, {
|
|
@@ -2013,13 +2024,13 @@ function K(...e) {
|
|
|
2013
2024
|
}
|
|
2014
2025
|
return Object.defineProperties({}, t);
|
|
2015
2026
|
}
|
|
2016
|
-
function
|
|
2027
|
+
function ht(e) {
|
|
2017
2028
|
return JSON.stringify(e);
|
|
2018
2029
|
}
|
|
2019
2030
|
function Jr(e) {
|
|
2020
2031
|
return e.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
2021
2032
|
}
|
|
2022
|
-
const
|
|
2033
|
+
const gn = "captureStackTrace" in Error ? Error.captureStackTrace : (...e) => {
|
|
2023
2034
|
};
|
|
2024
2035
|
function fe(e) {
|
|
2025
2036
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
@@ -2044,7 +2055,7 @@ function ie(e) {
|
|
|
2044
2055
|
const n = t.prototype;
|
|
2045
2056
|
return !(fe(n) === !1 || Object.prototype.hasOwnProperty.call(n, "isPrototypeOf") === !1);
|
|
2046
2057
|
}
|
|
2047
|
-
function
|
|
2058
|
+
function En(e) {
|
|
2048
2059
|
return ie(e) ? { ...e } : Array.isArray(e) ? [...e] : e instanceof Map ? new Map(e) : e instanceof Set ? new Set(e) : e;
|
|
2049
2060
|
}
|
|
2050
2061
|
const Xr = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
|
|
@@ -2255,7 +2266,7 @@ function me(...e) {
|
|
|
2255
2266
|
inst: o
|
|
2256
2267
|
} : { ...t };
|
|
2257
2268
|
}
|
|
2258
|
-
const
|
|
2269
|
+
const kn = (e, t) => {
|
|
2259
2270
|
e.name = "$ZodError", Object.defineProperty(e, "_zod", {
|
|
2260
2271
|
value: e._zod,
|
|
2261
2272
|
enumerable: !1
|
|
@@ -2266,7 +2277,7 @@ const gn = (e, t) => {
|
|
|
2266
2277
|
value: () => e.message,
|
|
2267
2278
|
enumerable: !1
|
|
2268
2279
|
});
|
|
2269
|
-
},
|
|
2280
|
+
}, Sn = d("$ZodError", kn), In = d("$ZodError", kn, { Parent: Error });
|
|
2270
2281
|
function si(e, t = (n) => n.message) {
|
|
2271
2282
|
const n = {}, o = [];
|
|
2272
2283
|
for (const r of e.issues)
|
|
@@ -2303,7 +2314,7 @@ const ot = (e) => (t, n, o, r) => {
|
|
|
2303
2314
|
throw new oe();
|
|
2304
2315
|
if (c.issues.length) {
|
|
2305
2316
|
const a = new ((r == null ? void 0 : r.Err) ?? e)(c.issues.map((s) => W(s, i, G())));
|
|
2306
|
-
throw
|
|
2317
|
+
throw gn(a, r == null ? void 0 : r.callee), a;
|
|
2307
2318
|
}
|
|
2308
2319
|
return c.value;
|
|
2309
2320
|
}, rt = (e) => async (t, n, o, r) => {
|
|
@@ -2311,7 +2322,7 @@ const ot = (e) => (t, n, o, r) => {
|
|
|
2311
2322
|
let c = t._zod.run({ value: n, issues: [] }, i);
|
|
2312
2323
|
if (c instanceof Promise && (c = await c), c.issues.length) {
|
|
2313
2324
|
const a = new ((r == null ? void 0 : r.Err) ?? e)(c.issues.map((s) => W(s, i, G())));
|
|
2314
|
-
throw
|
|
2325
|
+
throw gn(a, r == null ? void 0 : r.callee), a;
|
|
2315
2326
|
}
|
|
2316
2327
|
return c.value;
|
|
2317
2328
|
}, Ce = (e) => (t, n, o) => {
|
|
@@ -2320,16 +2331,16 @@ const ot = (e) => (t, n, o, r) => {
|
|
|
2320
2331
|
throw new oe();
|
|
2321
2332
|
return i.issues.length ? {
|
|
2322
2333
|
success: !1,
|
|
2323
|
-
error: new (e ??
|
|
2334
|
+
error: new (e ?? Sn)(i.issues.map((c) => W(c, r, G())))
|
|
2324
2335
|
} : { success: !0, data: i.value };
|
|
2325
|
-
}, li = /* @__PURE__ */ Ce(
|
|
2336
|
+
}, li = /* @__PURE__ */ Ce(In), Pe = (e) => async (t, n, o) => {
|
|
2326
2337
|
const r = o ? { ...o, async: !0 } : { async: !0 };
|
|
2327
2338
|
let i = t._zod.run({ value: n, issues: [] }, r);
|
|
2328
2339
|
return i instanceof Promise && (i = await i), i.issues.length ? {
|
|
2329
2340
|
success: !1,
|
|
2330
2341
|
error: new e(i.issues.map((c) => W(c, r, G())))
|
|
2331
2342
|
} : { success: !0, data: i.value };
|
|
2332
|
-
}, di = /* @__PURE__ */ Pe(
|
|
2343
|
+
}, di = /* @__PURE__ */ Pe(In), pi = (e) => (t, n, o) => {
|
|
2333
2344
|
const r = o ? { ...o, direction: "backward" } : { direction: "backward" };
|
|
2334
2345
|
return ot(e)(t, n, r);
|
|
2335
2346
|
}, fi = (e) => (t, n, o) => ot(e)(t, n, o), mi = (e) => async (t, n, o) => {
|
|
@@ -2341,37 +2352,37 @@ const ot = (e) => (t, n, o, r) => {
|
|
|
2341
2352
|
}, wi = (e) => (t, n, o) => Ce(e)(t, n, o), yi = (e) => async (t, n, o) => {
|
|
2342
2353
|
const r = o ? { ...o, direction: "backward" } : { direction: "backward" };
|
|
2343
2354
|
return Pe(e)(t, n, r);
|
|
2344
|
-
}, vi = (e) => async (t, n, o) => Pe(e)(t, n, o), bi = /^[cC][0-9a-z]{6,}$/, gi = /^[0-9a-z]+$/, Ei = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/, ki = /^[0-9a-vA-V]{20}$/, Si = /^[A-Za-z0-9]{27}$/, Ii = /^[a-zA-Z0-9_-]{21}$/, Ai = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/, zi = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,
|
|
2355
|
+
}, vi = (e) => async (t, n, o) => Pe(e)(t, n, o), bi = /^[cC][0-9a-z]{6,}$/, gi = /^[0-9a-z]+$/, Ei = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/, ki = /^[0-9a-vA-V]{20}$/, Si = /^[A-Za-z0-9]{27}$/, Ii = /^[a-zA-Z0-9_-]{21}$/, Ai = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/, zi = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/, _t = (e) => e ? new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`) : /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/, Ti = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/, $i = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
2345
2356
|
function Oi() {
|
|
2346
2357
|
return new RegExp($i, "u");
|
|
2347
2358
|
}
|
|
2348
|
-
const Ci = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, Pi = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/, xi = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/, Zi = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, Ni = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,
|
|
2349
|
-
function
|
|
2359
|
+
const Ci = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, Pi = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/, xi = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/, Zi = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, Ni = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/, An = /^[A-Za-z0-9_-]*$/, Ri = /^https?$/, Di = /^\+[1-9]\d{6,14}$/, zn = "(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))", Mi = /* @__PURE__ */ new RegExp(`^${zn}$`);
|
|
2360
|
+
function Tn(e) {
|
|
2350
2361
|
const t = "(?:[01]\\d|2[0-3]):[0-5]\\d";
|
|
2351
2362
|
return typeof e.precision == "number" ? e.precision === -1 ? `${t}` : e.precision === 0 ? `${t}:[0-5]\\d` : `${t}:[0-5]\\d\\.\\d{${e.precision}}` : `${t}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
2352
2363
|
}
|
|
2353
2364
|
function Ui(e) {
|
|
2354
|
-
return new RegExp(`^${
|
|
2365
|
+
return new RegExp(`^${Tn(e)}$`);
|
|
2355
2366
|
}
|
|
2356
2367
|
function Fi(e) {
|
|
2357
|
-
const t =
|
|
2368
|
+
const t = Tn({ precision: e.precision }), n = ["Z"];
|
|
2358
2369
|
e.local && n.push(""), e.offset && n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");
|
|
2359
2370
|
const o = `${t}(?:${n.join("|")})`;
|
|
2360
|
-
return new RegExp(`^${
|
|
2371
|
+
return new RegExp(`^${zn}T(?:${o})$`);
|
|
2361
2372
|
}
|
|
2362
2373
|
const Bi = (e) => {
|
|
2363
2374
|
const t = e ? `[\\s\\S]{${(e == null ? void 0 : e.minimum) ?? 0},${(e == null ? void 0 : e.maximum) ?? ""}}` : "[\\s\\S]*";
|
|
2364
2375
|
return new RegExp(`^${t}$`);
|
|
2365
|
-
}, ji = /^-?\d+$/,
|
|
2376
|
+
}, ji = /^-?\d+$/, $n = /^-?\d+(?:\.\d+)?$/, Li = /^(?:true|false)$/i, Gi = /^[^A-Z]*$/, Wi = /^[^a-z]*$/, M = /* @__PURE__ */ d("$ZodCheck", (e, t) => {
|
|
2366
2377
|
var n;
|
|
2367
2378
|
e._zod ?? (e._zod = {}), e._zod.def = t, (n = e._zod).onattach ?? (n.onattach = []);
|
|
2368
|
-
}),
|
|
2379
|
+
}), On = {
|
|
2369
2380
|
number: "number",
|
|
2370
2381
|
bigint: "bigint",
|
|
2371
2382
|
object: "date"
|
|
2372
|
-
},
|
|
2373
|
-
|
|
2374
|
-
const n =
|
|
2383
|
+
}, Cn = /* @__PURE__ */ d("$ZodCheckLessThan", (e, t) => {
|
|
2384
|
+
M.init(e, t);
|
|
2385
|
+
const n = On[typeof t.value];
|
|
2375
2386
|
e._zod.onattach.push((o) => {
|
|
2376
2387
|
const r = o._zod.bag, i = (t.inclusive ? r.maximum : r.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
2377
2388
|
t.value < i && (t.inclusive ? r.maximum = t.value : r.exclusiveMaximum = t.value);
|
|
@@ -2386,9 +2397,9 @@ const Bi = (e) => {
|
|
|
2386
2397
|
continue: !t.abort
|
|
2387
2398
|
});
|
|
2388
2399
|
};
|
|
2389
|
-
}),
|
|
2390
|
-
|
|
2391
|
-
const n =
|
|
2400
|
+
}), Pn = /* @__PURE__ */ d("$ZodCheckGreaterThan", (e, t) => {
|
|
2401
|
+
M.init(e, t);
|
|
2402
|
+
const n = On[typeof t.value];
|
|
2392
2403
|
e._zod.onattach.push((o) => {
|
|
2393
2404
|
const r = o._zod.bag, i = (t.inclusive ? r.minimum : r.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
2394
2405
|
t.value > i && (t.inclusive ? r.minimum = t.value : r.exclusiveMinimum = t.value);
|
|
@@ -2404,7 +2415,7 @@ const Bi = (e) => {
|
|
|
2404
2415
|
});
|
|
2405
2416
|
};
|
|
2406
2417
|
}), Ki = /* @__PURE__ */ d("$ZodCheckMultipleOf", (e, t) => {
|
|
2407
|
-
|
|
2418
|
+
M.init(e, t), e._zod.onattach.push((n) => {
|
|
2408
2419
|
var o;
|
|
2409
2420
|
(o = n._zod.bag).multipleOf ?? (o.multipleOf = t.value);
|
|
2410
2421
|
}), e._zod.check = (n) => {
|
|
@@ -2421,7 +2432,7 @@ const Bi = (e) => {
|
|
|
2421
2432
|
};
|
|
2422
2433
|
}), Vi = /* @__PURE__ */ d("$ZodCheckNumberFormat", (e, t) => {
|
|
2423
2434
|
var c;
|
|
2424
|
-
|
|
2435
|
+
M.init(e, t), t.format = t.format || "float64";
|
|
2425
2436
|
const n = (c = t.format) == null ? void 0 : c.includes("int"), o = n ? "int" : "number", [r, i] = Yr[t.format];
|
|
2426
2437
|
e._zod.onattach.push((a) => {
|
|
2427
2438
|
const s = a._zod.bag;
|
|
@@ -2483,7 +2494,7 @@ const Bi = (e) => {
|
|
|
2483
2494
|
};
|
|
2484
2495
|
}), qi = /* @__PURE__ */ d("$ZodCheckMaxLength", (e, t) => {
|
|
2485
2496
|
var n;
|
|
2486
|
-
|
|
2497
|
+
M.init(e, t), (n = e._zod.def).when ?? (n.when = (o) => {
|
|
2487
2498
|
const r = o.value;
|
|
2488
2499
|
return !et(r) && r.length !== void 0;
|
|
2489
2500
|
}), e._zod.onattach.push((o) => {
|
|
@@ -2506,7 +2517,7 @@ const Bi = (e) => {
|
|
|
2506
2517
|
};
|
|
2507
2518
|
}), Ji = /* @__PURE__ */ d("$ZodCheckMinLength", (e, t) => {
|
|
2508
2519
|
var n;
|
|
2509
|
-
|
|
2520
|
+
M.init(e, t), (n = e._zod.def).when ?? (n.when = (o) => {
|
|
2510
2521
|
const r = o.value;
|
|
2511
2522
|
return !et(r) && r.length !== void 0;
|
|
2512
2523
|
}), e._zod.onattach.push((o) => {
|
|
@@ -2529,7 +2540,7 @@ const Bi = (e) => {
|
|
|
2529
2540
|
};
|
|
2530
2541
|
}), Hi = /* @__PURE__ */ d("$ZodCheckLengthEquals", (e, t) => {
|
|
2531
2542
|
var n;
|
|
2532
|
-
|
|
2543
|
+
M.init(e, t), (n = e._zod.def).when ?? (n.when = (o) => {
|
|
2533
2544
|
const r = o.value;
|
|
2534
2545
|
return !et(r) && r.length !== void 0;
|
|
2535
2546
|
}), e._zod.onattach.push((o) => {
|
|
@@ -2552,7 +2563,7 @@ const Bi = (e) => {
|
|
|
2552
2563
|
};
|
|
2553
2564
|
}), xe = /* @__PURE__ */ d("$ZodCheckStringFormat", (e, t) => {
|
|
2554
2565
|
var n, o;
|
|
2555
|
-
|
|
2566
|
+
M.init(e, t), e._zod.onattach.push((r) => {
|
|
2556
2567
|
const i = r._zod.bag;
|
|
2557
2568
|
i.format = t.format, t.pattern && (i.patterns ?? (i.patterns = /* @__PURE__ */ new Set()), i.patterns.add(t.pattern));
|
|
2558
2569
|
}), t.pattern ? (n = e._zod).check ?? (n.check = (r) => {
|
|
@@ -2584,7 +2595,7 @@ const Bi = (e) => {
|
|
|
2584
2595
|
}), Yi = /* @__PURE__ */ d("$ZodCheckUpperCase", (e, t) => {
|
|
2585
2596
|
t.pattern ?? (t.pattern = Wi), xe.init(e, t);
|
|
2586
2597
|
}), ec = /* @__PURE__ */ d("$ZodCheckIncludes", (e, t) => {
|
|
2587
|
-
|
|
2598
|
+
M.init(e, t);
|
|
2588
2599
|
const n = ce(t.includes), o = new RegExp(typeof t.position == "number" ? `^.{${t.position}}${n}` : n);
|
|
2589
2600
|
t.pattern = o, e._zod.onattach.push((r) => {
|
|
2590
2601
|
const i = r._zod.bag;
|
|
@@ -2601,7 +2612,7 @@ const Bi = (e) => {
|
|
|
2601
2612
|
});
|
|
2602
2613
|
};
|
|
2603
2614
|
}), tc = /* @__PURE__ */ d("$ZodCheckStartsWith", (e, t) => {
|
|
2604
|
-
|
|
2615
|
+
M.init(e, t);
|
|
2605
2616
|
const n = new RegExp(`^${ce(t.prefix)}.*`);
|
|
2606
2617
|
t.pattern ?? (t.pattern = n), e._zod.onattach.push((o) => {
|
|
2607
2618
|
const r = o._zod.bag;
|
|
@@ -2618,7 +2629,7 @@ const Bi = (e) => {
|
|
|
2618
2629
|
});
|
|
2619
2630
|
};
|
|
2620
2631
|
}), nc = /* @__PURE__ */ d("$ZodCheckEndsWith", (e, t) => {
|
|
2621
|
-
|
|
2632
|
+
M.init(e, t);
|
|
2622
2633
|
const n = new RegExp(`.*${ce(t.suffix)}$`);
|
|
2623
2634
|
t.pattern ?? (t.pattern = n), e._zod.onattach.push((o) => {
|
|
2624
2635
|
const r = o._zod.bag;
|
|
@@ -2635,7 +2646,7 @@ const Bi = (e) => {
|
|
|
2635
2646
|
});
|
|
2636
2647
|
};
|
|
2637
2648
|
}), oc = /* @__PURE__ */ d("$ZodCheckOverwrite", (e, t) => {
|
|
2638
|
-
|
|
2649
|
+
M.init(e, t), e._zod.check = (n) => {
|
|
2639
2650
|
n.value = t.tx(n.value);
|
|
2640
2651
|
};
|
|
2641
2652
|
});
|
|
@@ -2778,9 +2789,9 @@ const ic = {
|
|
|
2778
2789
|
}[t.version];
|
|
2779
2790
|
if (o === void 0)
|
|
2780
2791
|
throw new Error(`Invalid UUID version: "${t.version}"`);
|
|
2781
|
-
t.pattern ?? (t.pattern =
|
|
2792
|
+
t.pattern ?? (t.pattern = _t(o));
|
|
2782
2793
|
} else
|
|
2783
|
-
t.pattern ?? (t.pattern =
|
|
2794
|
+
t.pattern ?? (t.pattern = _t());
|
|
2784
2795
|
E.init(e, t);
|
|
2785
2796
|
}), sc = /* @__PURE__ */ d("$ZodEmail", (e, t) => {
|
|
2786
2797
|
t.pattern ?? (t.pattern = Ti), E.init(e, t);
|
|
@@ -2895,7 +2906,7 @@ const ic = {
|
|
|
2895
2906
|
}
|
|
2896
2907
|
};
|
|
2897
2908
|
});
|
|
2898
|
-
function
|
|
2909
|
+
function xn(e) {
|
|
2899
2910
|
if (e === "")
|
|
2900
2911
|
return !0;
|
|
2901
2912
|
if (/\s/.test(e) || e.length % 4 !== 0)
|
|
@@ -2908,7 +2919,7 @@ function Cn(e) {
|
|
|
2908
2919
|
}
|
|
2909
2920
|
const Ic = /* @__PURE__ */ d("$ZodBase64", (e, t) => {
|
|
2910
2921
|
t.pattern ?? (t.pattern = Ni), E.init(e, t), e._zod.bag.contentEncoding = "base64", e._zod.check = (n) => {
|
|
2911
|
-
|
|
2922
|
+
xn(n.value) || n.issues.push({
|
|
2912
2923
|
code: "invalid_format",
|
|
2913
2924
|
format: "base64",
|
|
2914
2925
|
input: n.value,
|
|
@@ -2918,13 +2929,13 @@ const Ic = /* @__PURE__ */ d("$ZodBase64", (e, t) => {
|
|
|
2918
2929
|
};
|
|
2919
2930
|
});
|
|
2920
2931
|
function Ac(e) {
|
|
2921
|
-
if (!
|
|
2932
|
+
if (!An.test(e))
|
|
2922
2933
|
return !1;
|
|
2923
2934
|
const t = e.replace(/[-_]/g, (o) => o === "-" ? "+" : "/"), n = t.padEnd(Math.ceil(t.length / 4) * 4, "=");
|
|
2924
|
-
return
|
|
2935
|
+
return xn(n);
|
|
2925
2936
|
}
|
|
2926
2937
|
const zc = /* @__PURE__ */ d("$ZodBase64URL", (e, t) => {
|
|
2927
|
-
t.pattern ?? (t.pattern =
|
|
2938
|
+
t.pattern ?? (t.pattern = An), E.init(e, t), e._zod.bag.contentEncoding = "base64url", e._zod.check = (n) => {
|
|
2928
2939
|
Ac(n.value) || n.issues.push({
|
|
2929
2940
|
code: "invalid_format",
|
|
2930
2941
|
format: "base64url",
|
|
@@ -2960,8 +2971,8 @@ const Oc = /* @__PURE__ */ d("$ZodJWT", (e, t) => {
|
|
|
2960
2971
|
continue: !t.abort
|
|
2961
2972
|
});
|
|
2962
2973
|
};
|
|
2963
|
-
}),
|
|
2964
|
-
S.init(e, t), e._zod.pattern = e._zod.bag.pattern ??
|
|
2974
|
+
}), Zn = /* @__PURE__ */ d("$ZodNumber", (e, t) => {
|
|
2975
|
+
S.init(e, t), e._zod.pattern = e._zod.bag.pattern ?? $n, e._zod.parse = (n, o) => {
|
|
2965
2976
|
if (t.coerce)
|
|
2966
2977
|
try {
|
|
2967
2978
|
n.value = Number(n.value);
|
|
@@ -2980,7 +2991,7 @@ const Oc = /* @__PURE__ */ d("$ZodJWT", (e, t) => {
|
|
|
2980
2991
|
}), n;
|
|
2981
2992
|
};
|
|
2982
2993
|
}), Cc = /* @__PURE__ */ d("$ZodNumberFormat", (e, t) => {
|
|
2983
|
-
Vi.init(e, t),
|
|
2994
|
+
Vi.init(e, t), Zn.init(e, t);
|
|
2984
2995
|
}), Pc = /* @__PURE__ */ d("$ZodBoolean", (e, t) => {
|
|
2985
2996
|
S.init(e, t), e._zod.pattern = Li, e._zod.parse = (n, o) => {
|
|
2986
2997
|
if (t.coerce)
|
|
@@ -3006,7 +3017,7 @@ const Oc = /* @__PURE__ */ d("$ZodJWT", (e, t) => {
|
|
|
3006
3017
|
inst: e
|
|
3007
3018
|
}), n);
|
|
3008
3019
|
});
|
|
3009
|
-
function
|
|
3020
|
+
function wt(e, t, n) {
|
|
3010
3021
|
e.issues.length && t.issues.push(...ne(n, e.issues)), t.value[n] = e.value;
|
|
3011
3022
|
}
|
|
3012
3023
|
const Nc = /* @__PURE__ */ d("$ZodArray", (e, t) => {
|
|
@@ -3026,7 +3037,7 @@ const Nc = /* @__PURE__ */ d("$ZodArray", (e, t) => {
|
|
|
3026
3037
|
value: a,
|
|
3027
3038
|
issues: []
|
|
3028
3039
|
}, o);
|
|
3029
|
-
s instanceof Promise ? i.push(s.then((u) =>
|
|
3040
|
+
s instanceof Promise ? i.push(s.then((u) => wt(u, n, c))) : wt(s, n, c);
|
|
3030
3041
|
}
|
|
3031
3042
|
return i.length ? Promise.all(i).then(() => n) : n;
|
|
3032
3043
|
};
|
|
@@ -3049,7 +3060,7 @@ function Ae(e, t, n, o, r, i) {
|
|
|
3049
3060
|
}
|
|
3050
3061
|
e.value === void 0 ? c && (t.value[n] = void 0) : t.value[n] = e.value;
|
|
3051
3062
|
}
|
|
3052
|
-
function
|
|
3063
|
+
function Nn(e) {
|
|
3053
3064
|
var o, r, i, c;
|
|
3054
3065
|
const t = Object.keys(e.shape);
|
|
3055
3066
|
for (const a of t)
|
|
@@ -3064,7 +3075,7 @@ function xn(e) {
|
|
|
3064
3075
|
optionalKeys: new Set(n)
|
|
3065
3076
|
};
|
|
3066
3077
|
}
|
|
3067
|
-
function
|
|
3078
|
+
function Rn(e, t, n, o, r, i) {
|
|
3068
3079
|
const c = [], a = r.keySet, s = r.catchall._zod, u = s.def.type, l = s.optin === "optional", p = s.optout === "optional";
|
|
3069
3080
|
for (const m in t) {
|
|
3070
3081
|
if (m === "__proto__" || a.has(m))
|
|
@@ -3097,7 +3108,7 @@ const Rc = /* @__PURE__ */ d("$ZodObject", (e, t) => {
|
|
|
3097
3108
|
}
|
|
3098
3109
|
});
|
|
3099
3110
|
}
|
|
3100
|
-
const o = Oe(() =>
|
|
3111
|
+
const o = Oe(() => Nn(t));
|
|
3101
3112
|
v(e._zod, "propValues", () => {
|
|
3102
3113
|
const a = t.shape, s = {};
|
|
3103
3114
|
for (const u in a) {
|
|
@@ -3128,14 +3139,14 @@ const Rc = /* @__PURE__ */ d("$ZodObject", (e, t) => {
|
|
|
3128
3139
|
const f = p[m], _ = f._zod.optin === "optional", y = f._zod.optout === "optional", k = f._zod.run({ value: u[m], issues: [] }, s);
|
|
3129
3140
|
k instanceof Promise ? l.push(k.then((w) => Ae(w, a, m, u, _, y))) : Ae(k, a, m, u, _, y);
|
|
3130
3141
|
}
|
|
3131
|
-
return i ?
|
|
3142
|
+
return i ? Rn(l, u, a, s, o.value, e) : l.length ? Promise.all(l).then(() => a) : a;
|
|
3132
3143
|
};
|
|
3133
3144
|
}), Dc = /* @__PURE__ */ d("$ZodObjectJIT", (e, t) => {
|
|
3134
3145
|
Rc.init(e, t);
|
|
3135
|
-
const n = e._zod.parse, o = Oe(() =>
|
|
3146
|
+
const n = e._zod.parse, o = Oe(() => Nn(t)), r = (m) => {
|
|
3136
3147
|
var le, R;
|
|
3137
3148
|
const f = new rc(["shape", "payload", "ctx"]), _ = o.value, y = (j) => {
|
|
3138
|
-
const z =
|
|
3149
|
+
const z = ht(j);
|
|
3139
3150
|
return `shape[${z}]._zod.run({ value: input[${z}], issues: [] }, ctx)`;
|
|
3140
3151
|
};
|
|
3141
3152
|
f.write("const input = payload.value;");
|
|
@@ -3145,8 +3156,8 @@ const Rc = /* @__PURE__ */ d("$ZodObject", (e, t) => {
|
|
|
3145
3156
|
k[j] = `key_${w++}`;
|
|
3146
3157
|
f.write("const newResult = {};");
|
|
3147
3158
|
for (const j of _.keys) {
|
|
3148
|
-
const z = k[j], P =
|
|
3149
|
-
f.write(`const ${z} = ${y(j)};`), ct &&
|
|
3159
|
+
const z = k[j], P = ht(j), Q = m[j], ct = ((le = Q == null ? void 0 : Q._zod) == null ? void 0 : le.optin) === "optional", to = ((R = Q == null ? void 0 : Q._zod) == null ? void 0 : R.optout) === "optional";
|
|
3160
|
+
f.write(`const ${z} = ${y(j)};`), ct && to ? f.write(`
|
|
3150
3161
|
if (${z}.issues.length) {
|
|
3151
3162
|
if (${P} in input) {
|
|
3152
3163
|
payload.issues = payload.issues.concat(${z}.issues.map(iss => ({
|
|
@@ -3217,7 +3228,7 @@ const Rc = /* @__PURE__ */ d("$ZodObject", (e, t) => {
|
|
|
3217
3228
|
e._zod.parse = (m, f) => {
|
|
3218
3229
|
p ?? (p = o.value);
|
|
3219
3230
|
const _ = m.value;
|
|
3220
|
-
return c(_) ? a && u && (f == null ? void 0 : f.async) === !1 && f.jitless !== !0 ? (i || (i = r(t.shape)), m = i(m, f), l ?
|
|
3231
|
+
return c(_) ? a && u && (f == null ? void 0 : f.async) === !1 && f.jitless !== !0 ? (i || (i = r(t.shape)), m = i(m, f), l ? Rn([], _, m, f, p, e) : m) : n(m, f) : (m.issues.push({
|
|
3221
3232
|
expected: "object",
|
|
3222
3233
|
code: "invalid_type",
|
|
3223
3234
|
input: _,
|
|
@@ -3225,7 +3236,7 @@ const Rc = /* @__PURE__ */ d("$ZodObject", (e, t) => {
|
|
|
3225
3236
|
}), m);
|
|
3226
3237
|
};
|
|
3227
3238
|
});
|
|
3228
|
-
function
|
|
3239
|
+
function yt(e, t, n, o) {
|
|
3229
3240
|
for (const i of e)
|
|
3230
3241
|
if (i.issues.length === 0)
|
|
3231
3242
|
return t.value = i.value, t;
|
|
@@ -3237,7 +3248,7 @@ function wt(e, t, n, o) {
|
|
|
3237
3248
|
errors: e.map((i) => i.issues.map((c) => W(c, o, G())))
|
|
3238
3249
|
}), t);
|
|
3239
3250
|
}
|
|
3240
|
-
const
|
|
3251
|
+
const Dn = /* @__PURE__ */ d("$ZodUnion", (e, t) => {
|
|
3241
3252
|
S.init(e, t), v(e._zod, "optin", () => t.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0), v(e._zod, "optout", () => t.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0), v(e._zod, "values", () => {
|
|
3242
3253
|
if (t.options.every((o) => o._zod.values))
|
|
3243
3254
|
return new Set(t.options.flatMap((o) => Array.from(o._zod.values)));
|
|
@@ -3266,10 +3277,10 @@ const Nn = /* @__PURE__ */ d("$ZodUnion", (e, t) => {
|
|
|
3266
3277
|
c.push(s);
|
|
3267
3278
|
}
|
|
3268
3279
|
}
|
|
3269
|
-
return i ? Promise.all(c).then((a) =>
|
|
3280
|
+
return i ? Promise.all(c).then((a) => yt(a, o, e, r)) : yt(c, o, e, r);
|
|
3270
3281
|
};
|
|
3271
3282
|
}), Mc = /* @__PURE__ */ d("$ZodDiscriminatedUnion", (e, t) => {
|
|
3272
|
-
t.inclusive = !1,
|
|
3283
|
+
t.inclusive = !1, Dn.init(e, t);
|
|
3273
3284
|
const n = e._zod.parse;
|
|
3274
3285
|
v(e._zod, "propValues", () => {
|
|
3275
3286
|
const r = {};
|
|
@@ -3324,7 +3335,7 @@ const Nn = /* @__PURE__ */ d("$ZodUnion", (e, t) => {
|
|
|
3324
3335
|
}), Uc = /* @__PURE__ */ d("$ZodIntersection", (e, t) => {
|
|
3325
3336
|
S.init(e, t), e._zod.parse = (n, o) => {
|
|
3326
3337
|
const r = n.value, i = t.left._zod.run({ value: r, issues: [] }, o), c = t.right._zod.run({ value: r, issues: [] }, o);
|
|
3327
|
-
return i instanceof Promise || c instanceof Promise ? Promise.all([i, c]).then(([s, u]) =>
|
|
3338
|
+
return i instanceof Promise || c instanceof Promise ? Promise.all([i, c]).then(([s, u]) => vt(n, s, u)) : vt(n, i, c);
|
|
3328
3339
|
};
|
|
3329
3340
|
});
|
|
3330
3341
|
function Le(e, t) {
|
|
@@ -3362,7 +3373,7 @@ function Le(e, t) {
|
|
|
3362
3373
|
}
|
|
3363
3374
|
return { valid: !1, mergeErrorPath: [] };
|
|
3364
3375
|
}
|
|
3365
|
-
function
|
|
3376
|
+
function vt(e, t, n) {
|
|
3366
3377
|
const o = /* @__PURE__ */ new Map();
|
|
3367
3378
|
let r;
|
|
3368
3379
|
for (const a of t.issues)
|
|
@@ -3439,7 +3450,7 @@ const Fc = /* @__PURE__ */ d("$ZodRecord", (e, t) => {
|
|
|
3439
3450
|
let s = t.keyType._zod.run({ value: a, issues: [] }, o);
|
|
3440
3451
|
if (s instanceof Promise)
|
|
3441
3452
|
throw new Error("Async schemas not supported in object keys currently");
|
|
3442
|
-
if (typeof a == "string" &&
|
|
3453
|
+
if (typeof a == "string" && $n.test(a) && s.issues.length) {
|
|
3443
3454
|
const p = t.keyType._zod.run({ value: Number(a), issues: [] }, o);
|
|
3444
3455
|
if (p instanceof Promise)
|
|
3445
3456
|
throw new Error("Async schemas not supported in object keys currently");
|
|
@@ -3466,7 +3477,7 @@ const Fc = /* @__PURE__ */ d("$ZodRecord", (e, t) => {
|
|
|
3466
3477
|
};
|
|
3467
3478
|
}), Bc = /* @__PURE__ */ d("$ZodEnum", (e, t) => {
|
|
3468
3479
|
S.init(e, t);
|
|
3469
|
-
const n =
|
|
3480
|
+
const n = bn(t.entries), o = new Set(n);
|
|
3470
3481
|
e._zod.values = o, e._zod.pattern = new RegExp(`^(${n.filter((r) => Xr.has(typeof r)).map((r) => typeof r == "string" ? ce(r) : r.toString()).join("|")})$`), e._zod.parse = (r, i) => {
|
|
3471
3482
|
const c = r.value;
|
|
3472
3483
|
return o.has(c) || r.issues.push({
|
|
@@ -3492,7 +3503,7 @@ const Fc = /* @__PURE__ */ d("$ZodRecord", (e, t) => {
|
|
|
3492
3503
|
}), Lc = /* @__PURE__ */ d("$ZodTransform", (e, t) => {
|
|
3493
3504
|
S.init(e, t), e._zod.optin = "optional", e._zod.parse = (n, o) => {
|
|
3494
3505
|
if (o.direction === "backward")
|
|
3495
|
-
throw new
|
|
3506
|
+
throw new vn(e.constructor.name);
|
|
3496
3507
|
const r = t.transform(n.value, n);
|
|
3497
3508
|
if (o.async)
|
|
3498
3509
|
return (r instanceof Promise ? r : Promise.resolve(r)).then((c) => (n.value = c, n.fallback = !0, n));
|
|
@@ -3501,22 +3512,22 @@ const Fc = /* @__PURE__ */ d("$ZodRecord", (e, t) => {
|
|
|
3501
3512
|
return n.value = r, n.fallback = !0, n;
|
|
3502
3513
|
};
|
|
3503
3514
|
});
|
|
3504
|
-
function
|
|
3515
|
+
function bt(e, t) {
|
|
3505
3516
|
return t === void 0 && (e.issues.length || e.fallback) ? { issues: [], value: void 0 } : e;
|
|
3506
3517
|
}
|
|
3507
|
-
const
|
|
3518
|
+
const Mn = /* @__PURE__ */ d("$ZodOptional", (e, t) => {
|
|
3508
3519
|
S.init(e, t), e._zod.optin = "optional", e._zod.optout = "optional", v(e._zod, "values", () => t.innerType._zod.values ? /* @__PURE__ */ new Set([...t.innerType._zod.values, void 0]) : void 0), v(e._zod, "pattern", () => {
|
|
3509
3520
|
const n = t.innerType._zod.pattern;
|
|
3510
3521
|
return n ? new RegExp(`^(${tt(n.source)})?$`) : void 0;
|
|
3511
3522
|
}), e._zod.parse = (n, o) => {
|
|
3512
3523
|
if (t.innerType._zod.optin === "optional") {
|
|
3513
3524
|
const r = n.value, i = t.innerType._zod.run(n, o);
|
|
3514
|
-
return i instanceof Promise ? i.then((c) =>
|
|
3525
|
+
return i instanceof Promise ? i.then((c) => bt(c, r)) : bt(i, r);
|
|
3515
3526
|
}
|
|
3516
3527
|
return n.value === void 0 ? n : t.innerType._zod.run(n, o);
|
|
3517
3528
|
};
|
|
3518
3529
|
}), Gc = /* @__PURE__ */ d("$ZodExactOptional", (e, t) => {
|
|
3519
|
-
|
|
3530
|
+
Mn.init(e, t), v(e._zod, "values", () => t.innerType._zod.values), v(e._zod, "pattern", () => t.innerType._zod.pattern), e._zod.parse = (n, o) => t.innerType._zod.run(n, o);
|
|
3520
3531
|
}), Wc = /* @__PURE__ */ d("$ZodNullable", (e, t) => {
|
|
3521
3532
|
S.init(e, t), v(e._zod, "optin", () => t.innerType._zod.optin), v(e._zod, "optout", () => t.innerType._zod.optout), v(e._zod, "pattern", () => {
|
|
3522
3533
|
const n = t.innerType._zod.pattern;
|
|
@@ -3529,10 +3540,10 @@ const Rn = /* @__PURE__ */ d("$ZodOptional", (e, t) => {
|
|
|
3529
3540
|
if (n.value === void 0)
|
|
3530
3541
|
return n.value = t.defaultValue, n;
|
|
3531
3542
|
const r = t.innerType._zod.run(n, o);
|
|
3532
|
-
return r instanceof Promise ? r.then((i) =>
|
|
3543
|
+
return r instanceof Promise ? r.then((i) => gt(i, t)) : gt(r, t);
|
|
3533
3544
|
};
|
|
3534
3545
|
});
|
|
3535
|
-
function
|
|
3546
|
+
function gt(e, t) {
|
|
3536
3547
|
return e.value === void 0 && (e.value = t.defaultValue), e;
|
|
3537
3548
|
}
|
|
3538
3549
|
const Vc = /* @__PURE__ */ d("$ZodPrefault", (e, t) => {
|
|
@@ -3543,10 +3554,10 @@ const Vc = /* @__PURE__ */ d("$ZodPrefault", (e, t) => {
|
|
|
3543
3554
|
return n ? new Set([...n].filter((o) => o !== void 0)) : void 0;
|
|
3544
3555
|
}), e._zod.parse = (n, o) => {
|
|
3545
3556
|
const r = t.innerType._zod.run(n, o);
|
|
3546
|
-
return r instanceof Promise ? r.then((i) =>
|
|
3557
|
+
return r instanceof Promise ? r.then((i) => Et(i, e)) : Et(r, e);
|
|
3547
3558
|
};
|
|
3548
3559
|
});
|
|
3549
|
-
function
|
|
3560
|
+
function Et(e, t) {
|
|
3550
3561
|
return !e.issues.length && e.value === void 0 && e.issues.push({
|
|
3551
3562
|
code: "invalid_type",
|
|
3552
3563
|
expected: "nonoptional",
|
|
@@ -3597,21 +3608,21 @@ const Xc = /* @__PURE__ */ d("$ZodReadonly", (e, t) => {
|
|
|
3597
3608
|
if (o.direction === "backward")
|
|
3598
3609
|
return t.innerType._zod.run(n, o);
|
|
3599
3610
|
const r = t.innerType._zod.run(n, o);
|
|
3600
|
-
return r instanceof Promise ? r.then(
|
|
3611
|
+
return r instanceof Promise ? r.then(kt) : kt(r);
|
|
3601
3612
|
};
|
|
3602
3613
|
});
|
|
3603
|
-
function
|
|
3614
|
+
function kt(e) {
|
|
3604
3615
|
return e.value = Object.freeze(e.value), e;
|
|
3605
3616
|
}
|
|
3606
3617
|
const Qc = /* @__PURE__ */ d("$ZodCustom", (e, t) => {
|
|
3607
|
-
|
|
3618
|
+
M.init(e, t), S.init(e, t), e._zod.parse = (n, o) => n, e._zod.check = (n) => {
|
|
3608
3619
|
const o = n.value, r = t.fn(o);
|
|
3609
3620
|
if (r instanceof Promise)
|
|
3610
|
-
return r.then((i) =>
|
|
3611
|
-
|
|
3621
|
+
return r.then((i) => St(i, n, o, e));
|
|
3622
|
+
St(r, n, o, e);
|
|
3612
3623
|
};
|
|
3613
3624
|
});
|
|
3614
|
-
function
|
|
3625
|
+
function St(e, t, n, o) {
|
|
3615
3626
|
if (!e) {
|
|
3616
3627
|
const r = {
|
|
3617
3628
|
code: "custom",
|
|
@@ -3626,7 +3637,7 @@ function kt(e, t, n, o) {
|
|
|
3626
3637
|
o._zod.def.params && (r.params = o._zod.def.params), t.issues.push(me(r));
|
|
3627
3638
|
}
|
|
3628
3639
|
}
|
|
3629
|
-
var
|
|
3640
|
+
var It;
|
|
3630
3641
|
class Yc {
|
|
3631
3642
|
constructor() {
|
|
3632
3643
|
this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map();
|
|
@@ -3659,7 +3670,7 @@ class Yc {
|
|
|
3659
3670
|
function ea() {
|
|
3660
3671
|
return new Yc();
|
|
3661
3672
|
}
|
|
3662
|
-
(
|
|
3673
|
+
(It = globalThis).__zod_globalRegistry ?? (It.__zod_globalRegistry = ea());
|
|
3663
3674
|
const de = globalThis.__zod_globalRegistry;
|
|
3664
3675
|
// @__NO_SIDE_EFFECTS__
|
|
3665
3676
|
function ta(e, t) {
|
|
@@ -3679,7 +3690,7 @@ function na(e, t) {
|
|
|
3679
3690
|
});
|
|
3680
3691
|
}
|
|
3681
3692
|
// @__NO_SIDE_EFFECTS__
|
|
3682
|
-
function
|
|
3693
|
+
function At(e, t) {
|
|
3683
3694
|
return new e({
|
|
3684
3695
|
type: "string",
|
|
3685
3696
|
format: "guid",
|
|
@@ -3970,8 +3981,8 @@ function Ca(e, t) {
|
|
|
3970
3981
|
});
|
|
3971
3982
|
}
|
|
3972
3983
|
// @__NO_SIDE_EFFECTS__
|
|
3973
|
-
function
|
|
3974
|
-
return new
|
|
3984
|
+
function zt(e, t) {
|
|
3985
|
+
return new Cn({
|
|
3975
3986
|
check: "less_than",
|
|
3976
3987
|
...h(t),
|
|
3977
3988
|
value: e,
|
|
@@ -3980,7 +3991,7 @@ function At(e, t) {
|
|
|
3980
3991
|
}
|
|
3981
3992
|
// @__NO_SIDE_EFFECTS__
|
|
3982
3993
|
function Re(e, t) {
|
|
3983
|
-
return new
|
|
3994
|
+
return new Cn({
|
|
3984
3995
|
check: "less_than",
|
|
3985
3996
|
...h(t),
|
|
3986
3997
|
value: e,
|
|
@@ -3988,8 +3999,8 @@ function Re(e, t) {
|
|
|
3988
3999
|
});
|
|
3989
4000
|
}
|
|
3990
4001
|
// @__NO_SIDE_EFFECTS__
|
|
3991
|
-
function
|
|
3992
|
-
return new
|
|
4002
|
+
function Tt(e, t) {
|
|
4003
|
+
return new Pn({
|
|
3993
4004
|
check: "greater_than",
|
|
3994
4005
|
...h(t),
|
|
3995
4006
|
value: e,
|
|
@@ -3998,7 +4009,7 @@ function zt(e, t) {
|
|
|
3998
4009
|
}
|
|
3999
4010
|
// @__NO_SIDE_EFFECTS__
|
|
4000
4011
|
function De(e, t) {
|
|
4001
|
-
return new
|
|
4012
|
+
return new Pn({
|
|
4002
4013
|
check: "greater_than",
|
|
4003
4014
|
...h(t),
|
|
4004
4015
|
value: e,
|
|
@@ -4006,7 +4017,7 @@ function De(e, t) {
|
|
|
4006
4017
|
});
|
|
4007
4018
|
}
|
|
4008
4019
|
// @__NO_SIDE_EFFECTS__
|
|
4009
|
-
function
|
|
4020
|
+
function $t(e, t) {
|
|
4010
4021
|
return new Ki({
|
|
4011
4022
|
check: "multiple_of",
|
|
4012
4023
|
...h(t),
|
|
@@ -4014,7 +4025,7 @@ function Tt(e, t) {
|
|
|
4014
4025
|
});
|
|
4015
4026
|
}
|
|
4016
4027
|
// @__NO_SIDE_EFFECTS__
|
|
4017
|
-
function
|
|
4028
|
+
function Un(e, t) {
|
|
4018
4029
|
return new qi({
|
|
4019
4030
|
check: "max_length",
|
|
4020
4031
|
...h(t),
|
|
@@ -4030,7 +4041,7 @@ function ze(e, t) {
|
|
|
4030
4041
|
});
|
|
4031
4042
|
}
|
|
4032
4043
|
// @__NO_SIDE_EFFECTS__
|
|
4033
|
-
function
|
|
4044
|
+
function Fn(e, t) {
|
|
4034
4045
|
return new Hi({
|
|
4035
4046
|
check: "length_equals",
|
|
4036
4047
|
...h(t),
|
|
@@ -4150,13 +4161,13 @@ function Wa(e, t) {
|
|
|
4150
4161
|
}
|
|
4151
4162
|
// @__NO_SIDE_EFFECTS__
|
|
4152
4163
|
function Ka(e, t) {
|
|
4153
|
-
const n = new
|
|
4164
|
+
const n = new M({
|
|
4154
4165
|
check: "custom",
|
|
4155
4166
|
...h(t)
|
|
4156
4167
|
});
|
|
4157
4168
|
return n._zod.check = e, n;
|
|
4158
4169
|
}
|
|
4159
|
-
function
|
|
4170
|
+
function Bn(e) {
|
|
4160
4171
|
let t = (e == null ? void 0 : e.target) ?? "draft-2020-12";
|
|
4161
4172
|
return t === "draft-4" && (t = "draft-04"), t === "draft-7" && (t = "draft-07"), {
|
|
4162
4173
|
processors: e.processors ?? {},
|
|
@@ -4204,7 +4215,7 @@ function $(e, t, n = { path: [], schemaPath: [] }) {
|
|
|
4204
4215
|
const s = t.metadataRegistry.get(e);
|
|
4205
4216
|
return s && Object.assign(c.schema, s), t.io === "input" && Z(e) && (delete c.schema.examples, delete c.schema.default), t.io === "input" && "_prefault" in c.schema && ((o = c.schema).default ?? (o.default = c.schema._prefault)), delete c.schema._prefault, t.seen.get(e).schema;
|
|
4206
4217
|
}
|
|
4207
|
-
function
|
|
4218
|
+
function jn(e, t) {
|
|
4208
4219
|
var c, a, s, u;
|
|
4209
4220
|
const n = e.seen.get(t);
|
|
4210
4221
|
if (!n)
|
|
@@ -4278,7 +4289,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4278
4289
|
}
|
|
4279
4290
|
}
|
|
4280
4291
|
}
|
|
4281
|
-
function
|
|
4292
|
+
function Ln(e, t) {
|
|
4282
4293
|
var a, s, u, l;
|
|
4283
4294
|
const n = e.seen.get(t);
|
|
4284
4295
|
if (!n)
|
|
@@ -4390,11 +4401,11 @@ function Z(e, t) {
|
|
|
4390
4401
|
return !1;
|
|
4391
4402
|
}
|
|
4392
4403
|
const Va = (e, t = {}) => (n) => {
|
|
4393
|
-
const o =
|
|
4394
|
-
return $(e, o),
|
|
4404
|
+
const o = Bn({ ...n, processors: t });
|
|
4405
|
+
return $(e, o), jn(o, e), Ln(o, e);
|
|
4395
4406
|
}, Te = (e, t, n = {}) => (o) => {
|
|
4396
|
-
const { libraryOptions: r, target: i } = o ?? {}, c =
|
|
4397
|
-
return $(e, c),
|
|
4407
|
+
const { libraryOptions: r, target: i } = o ?? {}, c = Bn({ ...r ?? {}, target: i, io: t, processors: n });
|
|
4408
|
+
return $(e, c), jn(c, e), Ln(c, e);
|
|
4398
4409
|
}, qa = {
|
|
4399
4410
|
guid: "uuid",
|
|
4400
4411
|
url: "uri",
|
|
@@ -4426,7 +4437,7 @@ const Va = (e, t = {}) => (n) => {
|
|
|
4426
4437
|
n.not = {};
|
|
4427
4438
|
}, Ya = (e, t, n, o) => {
|
|
4428
4439
|
}, es = (e, t, n, o) => {
|
|
4429
|
-
const r = e._zod.def, i =
|
|
4440
|
+
const r = e._zod.def, i = bn(r.entries);
|
|
4430
4441
|
i.every((c) => typeof c == "number") && (n.type = "number"), i.every((c) => typeof c == "string") && (n.type = "string"), n.enum = i;
|
|
4431
4442
|
}, ts = (e, t, n, o) => {
|
|
4432
4443
|
const r = e._zod.def, i = [];
|
|
@@ -4558,7 +4569,7 @@ const Va = (e, t = {}) => (n) => {
|
|
|
4558
4569
|
$(r.innerType, t, o);
|
|
4559
4570
|
const i = t.seen.get(e);
|
|
4560
4571
|
i.ref = r.innerType, n.readOnly = !0;
|
|
4561
|
-
},
|
|
4572
|
+
}, Gn = (e, t, n, o) => {
|
|
4562
4573
|
const r = e._zod.def;
|
|
4563
4574
|
$(r.innerType, t, o);
|
|
4564
4575
|
const i = t.seen.get(e);
|
|
@@ -4566,7 +4577,7 @@ const Va = (e, t = {}) => (n) => {
|
|
|
4566
4577
|
}, _s = /* @__PURE__ */ d("ZodISODateTime", (e, t) => {
|
|
4567
4578
|
wc.init(e, t), A.init(e, t);
|
|
4568
4579
|
});
|
|
4569
|
-
function
|
|
4580
|
+
function Wn(e) {
|
|
4570
4581
|
return /* @__PURE__ */ ka(_s, e);
|
|
4571
4582
|
}
|
|
4572
4583
|
const ws = /* @__PURE__ */ d("ZodISODate", (e, t) => {
|
|
@@ -4588,7 +4599,7 @@ function Es(e) {
|
|
|
4588
4599
|
return /* @__PURE__ */ Aa(gs, e);
|
|
4589
4600
|
}
|
|
4590
4601
|
const ks = (e, t) => {
|
|
4591
|
-
|
|
4602
|
+
Sn.init(e, t), e.name = "ZodError", Object.defineProperties(e, {
|
|
4592
4603
|
format: {
|
|
4593
4604
|
value: (n) => ui(e, n)
|
|
4594
4605
|
// enumerable: false,
|
|
@@ -4618,11 +4629,11 @@ const ks = (e, t) => {
|
|
|
4618
4629
|
});
|
|
4619
4630
|
}, B = /* @__PURE__ */ d("ZodError", ks, {
|
|
4620
4631
|
Parent: Error
|
|
4621
|
-
}), Ss = /* @__PURE__ */ ot(B), Is = /* @__PURE__ */ rt(B), As = /* @__PURE__ */ Ce(B), zs = /* @__PURE__ */ Pe(B), Ts = /* @__PURE__ */ pi(B), $s = /* @__PURE__ */ fi(B), Os = /* @__PURE__ */ mi(B), Cs = /* @__PURE__ */ hi(B), Ps = /* @__PURE__ */ _i(B), xs = /* @__PURE__ */ wi(B), Zs = /* @__PURE__ */ yi(B), Ns = /* @__PURE__ */ vi(B),
|
|
4632
|
+
}), Ss = /* @__PURE__ */ ot(B), Is = /* @__PURE__ */ rt(B), As = /* @__PURE__ */ Ce(B), zs = /* @__PURE__ */ Pe(B), Ts = /* @__PURE__ */ pi(B), $s = /* @__PURE__ */ fi(B), Os = /* @__PURE__ */ mi(B), Cs = /* @__PURE__ */ hi(B), Ps = /* @__PURE__ */ _i(B), xs = /* @__PURE__ */ wi(B), Zs = /* @__PURE__ */ yi(B), Ns = /* @__PURE__ */ vi(B), Ot = /* @__PURE__ */ new WeakMap();
|
|
4622
4633
|
function ye(e, t, n) {
|
|
4623
4634
|
const o = Object.getPrototypeOf(e);
|
|
4624
|
-
let r =
|
|
4625
|
-
if (r || (r = /* @__PURE__ */ new Set(),
|
|
4635
|
+
let r = Ot.get(o);
|
|
4636
|
+
if (r || (r = /* @__PURE__ */ new Set(), Ot.set(o, r)), !r.has(t)) {
|
|
4626
4637
|
r.add(t);
|
|
4627
4638
|
for (const i in n) {
|
|
4628
4639
|
const c = n[i];
|
|
@@ -4687,16 +4698,16 @@ const I = /* @__PURE__ */ d("ZodType", (e, t) => (S.init(e, t), Object.assign(e[
|
|
|
4687
4698
|
return this.check(/* @__PURE__ */ se(n));
|
|
4688
4699
|
},
|
|
4689
4700
|
optional() {
|
|
4690
|
-
return
|
|
4701
|
+
return Rt(this);
|
|
4691
4702
|
},
|
|
4692
4703
|
exactOptional() {
|
|
4693
4704
|
return hu(this);
|
|
4694
4705
|
},
|
|
4695
4706
|
nullable() {
|
|
4696
|
-
return
|
|
4707
|
+
return Dt(this);
|
|
4697
4708
|
},
|
|
4698
4709
|
nullish() {
|
|
4699
|
-
return
|
|
4710
|
+
return Rt(Dt(this));
|
|
4700
4711
|
},
|
|
4701
4712
|
nonoptional(n) {
|
|
4702
4713
|
return gu(this, n);
|
|
@@ -4711,7 +4722,7 @@ const I = /* @__PURE__ */ d("ZodType", (e, t) => (S.init(e, t), Object.assign(e[
|
|
|
4711
4722
|
return lu(this, n);
|
|
4712
4723
|
},
|
|
4713
4724
|
transform(n) {
|
|
4714
|
-
return
|
|
4725
|
+
return Mt(this, fu(n));
|
|
4715
4726
|
},
|
|
4716
4727
|
default(n) {
|
|
4717
4728
|
return yu(this, n);
|
|
@@ -4723,7 +4734,7 @@ const I = /* @__PURE__ */ d("ZodType", (e, t) => (S.init(e, t), Object.assign(e[
|
|
|
4723
4734
|
return ku(this, n);
|
|
4724
4735
|
},
|
|
4725
4736
|
pipe(n) {
|
|
4726
|
-
return
|
|
4737
|
+
return Mt(this, n);
|
|
4727
4738
|
},
|
|
4728
4739
|
readonly() {
|
|
4729
4740
|
return Au(this);
|
|
@@ -4753,7 +4764,7 @@ const I = /* @__PURE__ */ d("ZodType", (e, t) => (S.init(e, t), Object.assign(e[
|
|
|
4753
4764
|
return (n = de.get(e)) == null ? void 0 : n.description;
|
|
4754
4765
|
},
|
|
4755
4766
|
configurable: !0
|
|
4756
|
-
}), e)),
|
|
4767
|
+
}), e)), Kn = /* @__PURE__ */ d("_ZodString", (e, t) => {
|
|
4757
4768
|
it.init(e, t), I.init(e, t), e._zod.processJSONSchema = (o, r, i) => Ja(e, o, r);
|
|
4758
4769
|
const n = e._zod.bag;
|
|
4759
4770
|
e.format = n.format ?? null, e.minLength = n.minimum ?? null, e.maxLength = n.maximum ?? null, ye(e, "_ZodString", {
|
|
@@ -4773,10 +4784,10 @@ const I = /* @__PURE__ */ d("ZodType", (e, t) => (S.init(e, t), Object.assign(e[
|
|
|
4773
4784
|
return this.check(/* @__PURE__ */ ze(...o));
|
|
4774
4785
|
},
|
|
4775
4786
|
max(...o) {
|
|
4776
|
-
return this.check(/* @__PURE__ */
|
|
4787
|
+
return this.check(/* @__PURE__ */ Un(...o));
|
|
4777
4788
|
},
|
|
4778
4789
|
length(...o) {
|
|
4779
|
-
return this.check(/* @__PURE__ */
|
|
4790
|
+
return this.check(/* @__PURE__ */ Fn(...o));
|
|
4780
4791
|
},
|
|
4781
4792
|
nonempty(...o) {
|
|
4782
4793
|
return this.check(/* @__PURE__ */ ze(1, ...o));
|
|
@@ -4804,16 +4815,16 @@ const I = /* @__PURE__ */ d("ZodType", (e, t) => (S.init(e, t), Object.assign(e[
|
|
|
4804
4815
|
}
|
|
4805
4816
|
});
|
|
4806
4817
|
}), Rs = /* @__PURE__ */ d("ZodString", (e, t) => {
|
|
4807
|
-
it.init(e, t),
|
|
4818
|
+
it.init(e, t), Kn.init(e, t), e.email = (n) => e.check(/* @__PURE__ */ na(Ds, n)), e.url = (n) => e.check(/* @__PURE__ */ aa(Ms, n)), e.jwt = (n) => e.check(/* @__PURE__ */ Ea(Ys, n)), e.emoji = (n) => e.check(/* @__PURE__ */ sa(Us, n)), e.guid = (n) => e.check(/* @__PURE__ */ At(Ct, n)), e.uuid = (n) => e.check(/* @__PURE__ */ oa(ke, n)), e.uuidv4 = (n) => e.check(/* @__PURE__ */ ra(ke, n)), e.uuidv6 = (n) => e.check(/* @__PURE__ */ ia(ke, n)), e.uuidv7 = (n) => e.check(/* @__PURE__ */ ca(ke, n)), e.nanoid = (n) => e.check(/* @__PURE__ */ ua(Fs, n)), e.guid = (n) => e.check(/* @__PURE__ */ At(Ct, n)), e.cuid = (n) => e.check(/* @__PURE__ */ la(Bs, n)), e.cuid2 = (n) => e.check(/* @__PURE__ */ da(js, n)), e.ulid = (n) => e.check(/* @__PURE__ */ pa(Ls, n)), e.base64 = (n) => e.check(/* @__PURE__ */ va(Hs, n)), e.base64url = (n) => e.check(/* @__PURE__ */ ba(Xs, n)), e.xid = (n) => e.check(/* @__PURE__ */ fa(Gs, n)), e.ksuid = (n) => e.check(/* @__PURE__ */ ma(Ws, n)), e.ipv4 = (n) => e.check(/* @__PURE__ */ ha(Ks, n)), e.ipv6 = (n) => e.check(/* @__PURE__ */ _a(Vs, n)), e.cidrv4 = (n) => e.check(/* @__PURE__ */ wa(qs, n)), e.cidrv6 = (n) => e.check(/* @__PURE__ */ ya(Js, n)), e.e164 = (n) => e.check(/* @__PURE__ */ ga(Qs, n)), e.datetime = (n) => e.check(Wn(n)), e.date = (n) => e.check(ys(n)), e.time = (n) => e.check(bs(n)), e.duration = (n) => e.check(Es(n));
|
|
4808
4819
|
});
|
|
4809
4820
|
function g(e) {
|
|
4810
4821
|
return /* @__PURE__ */ ta(Rs, e);
|
|
4811
4822
|
}
|
|
4812
4823
|
const A = /* @__PURE__ */ d("ZodStringFormat", (e, t) => {
|
|
4813
|
-
E.init(e, t),
|
|
4824
|
+
E.init(e, t), Kn.init(e, t);
|
|
4814
4825
|
}), Ds = /* @__PURE__ */ d("ZodEmail", (e, t) => {
|
|
4815
4826
|
sc.init(e, t), A.init(e, t);
|
|
4816
|
-
}),
|
|
4827
|
+
}), Ct = /* @__PURE__ */ d("ZodGUID", (e, t) => {
|
|
4817
4828
|
cc.init(e, t), A.init(e, t);
|
|
4818
4829
|
}), ke = /* @__PURE__ */ d("ZodUUID", (e, t) => {
|
|
4819
4830
|
ac.init(e, t), A.init(e, t);
|
|
@@ -4849,10 +4860,10 @@ const A = /* @__PURE__ */ d("ZodStringFormat", (e, t) => {
|
|
|
4849
4860
|
Tc.init(e, t), A.init(e, t);
|
|
4850
4861
|
}), Ys = /* @__PURE__ */ d("ZodJWT", (e, t) => {
|
|
4851
4862
|
Oc.init(e, t), A.init(e, t);
|
|
4852
|
-
}),
|
|
4853
|
-
|
|
4863
|
+
}), Vn = /* @__PURE__ */ d("ZodNumber", (e, t) => {
|
|
4864
|
+
Zn.init(e, t), I.init(e, t), e._zod.processJSONSchema = (o, r, i) => Ha(e, o, r), ye(e, "ZodNumber", {
|
|
4854
4865
|
gt(o, r) {
|
|
4855
|
-
return this.check(/* @__PURE__ */
|
|
4866
|
+
return this.check(/* @__PURE__ */ Tt(o, r));
|
|
4856
4867
|
},
|
|
4857
4868
|
gte(o, r) {
|
|
4858
4869
|
return this.check(/* @__PURE__ */ De(o, r));
|
|
@@ -4861,7 +4872,7 @@ const A = /* @__PURE__ */ d("ZodStringFormat", (e, t) => {
|
|
|
4861
4872
|
return this.check(/* @__PURE__ */ De(o, r));
|
|
4862
4873
|
},
|
|
4863
4874
|
lt(o, r) {
|
|
4864
|
-
return this.check(/* @__PURE__ */
|
|
4875
|
+
return this.check(/* @__PURE__ */ zt(o, r));
|
|
4865
4876
|
},
|
|
4866
4877
|
lte(o, r) {
|
|
4867
4878
|
return this.check(/* @__PURE__ */ Re(o, r));
|
|
@@ -4870,28 +4881,28 @@ const A = /* @__PURE__ */ d("ZodStringFormat", (e, t) => {
|
|
|
4870
4881
|
return this.check(/* @__PURE__ */ Re(o, r));
|
|
4871
4882
|
},
|
|
4872
4883
|
int(o) {
|
|
4873
|
-
return this.check(
|
|
4884
|
+
return this.check(Pt(o));
|
|
4874
4885
|
},
|
|
4875
4886
|
safe(o) {
|
|
4876
|
-
return this.check(
|
|
4887
|
+
return this.check(Pt(o));
|
|
4877
4888
|
},
|
|
4878
4889
|
positive(o) {
|
|
4879
|
-
return this.check(/* @__PURE__ */
|
|
4890
|
+
return this.check(/* @__PURE__ */ Tt(0, o));
|
|
4880
4891
|
},
|
|
4881
4892
|
nonnegative(o) {
|
|
4882
4893
|
return this.check(/* @__PURE__ */ De(0, o));
|
|
4883
4894
|
},
|
|
4884
4895
|
negative(o) {
|
|
4885
|
-
return this.check(/* @__PURE__ */
|
|
4896
|
+
return this.check(/* @__PURE__ */ zt(0, o));
|
|
4886
4897
|
},
|
|
4887
4898
|
nonpositive(o) {
|
|
4888
4899
|
return this.check(/* @__PURE__ */ Re(0, o));
|
|
4889
4900
|
},
|
|
4890
4901
|
multipleOf(o, r) {
|
|
4891
|
-
return this.check(/* @__PURE__ */
|
|
4902
|
+
return this.check(/* @__PURE__ */ $t(o, r));
|
|
4892
4903
|
},
|
|
4893
4904
|
step(o, r) {
|
|
4894
|
-
return this.check(/* @__PURE__ */
|
|
4905
|
+
return this.check(/* @__PURE__ */ $t(o, r));
|
|
4895
4906
|
},
|
|
4896
4907
|
finite() {
|
|
4897
4908
|
return this;
|
|
@@ -4901,12 +4912,12 @@ const A = /* @__PURE__ */ d("ZodStringFormat", (e, t) => {
|
|
|
4901
4912
|
e.minValue = Math.max(n.minimum ?? Number.NEGATIVE_INFINITY, n.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null, e.maxValue = Math.min(n.maximum ?? Number.POSITIVE_INFINITY, n.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null, e.isInt = (n.format ?? "").includes("int") || Number.isSafeInteger(n.multipleOf ?? 0.5), e.isFinite = !0, e.format = n.format ?? null;
|
|
4902
4913
|
});
|
|
4903
4914
|
function x(e) {
|
|
4904
|
-
return /* @__PURE__ */ za(
|
|
4915
|
+
return /* @__PURE__ */ za(Vn, e);
|
|
4905
4916
|
}
|
|
4906
4917
|
const eu = /* @__PURE__ */ d("ZodNumberFormat", (e, t) => {
|
|
4907
|
-
Cc.init(e, t),
|
|
4918
|
+
Cc.init(e, t), Vn.init(e, t);
|
|
4908
4919
|
});
|
|
4909
|
-
function
|
|
4920
|
+
function Pt(e) {
|
|
4910
4921
|
return /* @__PURE__ */ Ta(eu, e);
|
|
4911
4922
|
}
|
|
4912
4923
|
const tu = /* @__PURE__ */ d("ZodBoolean", (e, t) => {
|
|
@@ -4918,7 +4929,7 @@ function he(e) {
|
|
|
4918
4929
|
const nu = /* @__PURE__ */ d("ZodUnknown", (e, t) => {
|
|
4919
4930
|
xc.init(e, t), I.init(e, t), e._zod.processJSONSchema = (n, o, r) => Ya();
|
|
4920
4931
|
});
|
|
4921
|
-
function
|
|
4932
|
+
function xt() {
|
|
4922
4933
|
return /* @__PURE__ */ Oa(nu);
|
|
4923
4934
|
}
|
|
4924
4935
|
const ou = /* @__PURE__ */ d("ZodNever", (e, t) => {
|
|
@@ -4936,10 +4947,10 @@ const ru = /* @__PURE__ */ d("ZodArray", (e, t) => {
|
|
|
4936
4947
|
return this.check(/* @__PURE__ */ ze(1, n));
|
|
4937
4948
|
},
|
|
4938
4949
|
max(n, o) {
|
|
4939
|
-
return this.check(/* @__PURE__ */
|
|
4950
|
+
return this.check(/* @__PURE__ */ Un(n, o));
|
|
4940
4951
|
},
|
|
4941
4952
|
length(n, o) {
|
|
4942
|
-
return this.check(/* @__PURE__ */
|
|
4953
|
+
return this.check(/* @__PURE__ */ Fn(n, o));
|
|
4943
4954
|
},
|
|
4944
4955
|
unwrap() {
|
|
4945
4956
|
return this.element;
|
|
@@ -4958,10 +4969,10 @@ const iu = /* @__PURE__ */ d("ZodObject", (e, t) => {
|
|
|
4958
4969
|
return this.clone({ ...this._zod.def, catchall: n });
|
|
4959
4970
|
},
|
|
4960
4971
|
passthrough() {
|
|
4961
|
-
return this.clone({ ...this._zod.def, catchall:
|
|
4972
|
+
return this.clone({ ...this._zod.def, catchall: xt() });
|
|
4962
4973
|
},
|
|
4963
4974
|
loose() {
|
|
4964
|
-
return this.clone({ ...this._zod.def, catchall:
|
|
4975
|
+
return this.clone({ ...this._zod.def, catchall: xt() });
|
|
4965
4976
|
},
|
|
4966
4977
|
strict() {
|
|
4967
4978
|
return this.clone({ ...this._zod.def, catchall: Ge() });
|
|
@@ -4985,10 +4996,10 @@ const iu = /* @__PURE__ */ d("ZodObject", (e, t) => {
|
|
|
4985
4996
|
return ti(this, n);
|
|
4986
4997
|
},
|
|
4987
4998
|
partial(...n) {
|
|
4988
|
-
return ii(
|
|
4999
|
+
return ii(Jn, this, n[0]);
|
|
4989
5000
|
},
|
|
4990
5001
|
required(...n) {
|
|
4991
|
-
return ci(
|
|
5002
|
+
return ci(Hn, this, n[0]);
|
|
4992
5003
|
}
|
|
4993
5004
|
});
|
|
4994
5005
|
});
|
|
@@ -5000,18 +5011,18 @@ function O(e, t) {
|
|
|
5000
5011
|
};
|
|
5001
5012
|
return new iu(n);
|
|
5002
5013
|
}
|
|
5003
|
-
const
|
|
5004
|
-
|
|
5014
|
+
const qn = /* @__PURE__ */ d("ZodUnion", (e, t) => {
|
|
5015
|
+
Dn.init(e, t), I.init(e, t), e._zod.processJSONSchema = (n, o, r) => cs(e, n, o, r), e.options = t.options;
|
|
5005
5016
|
});
|
|
5006
5017
|
function cu(e, t) {
|
|
5007
|
-
return new
|
|
5018
|
+
return new qn({
|
|
5008
5019
|
type: "union",
|
|
5009
5020
|
options: e,
|
|
5010
5021
|
...h(t)
|
|
5011
5022
|
});
|
|
5012
5023
|
}
|
|
5013
5024
|
const au = /* @__PURE__ */ d("ZodDiscriminatedUnion", (e, t) => {
|
|
5014
|
-
|
|
5025
|
+
qn.init(e, t), Mc.init(e, t);
|
|
5015
5026
|
});
|
|
5016
5027
|
function su(e, t, n) {
|
|
5017
5028
|
return new au({
|
|
@@ -5031,16 +5042,16 @@ function lu(e, t) {
|
|
|
5031
5042
|
right: t
|
|
5032
5043
|
});
|
|
5033
5044
|
}
|
|
5034
|
-
const
|
|
5045
|
+
const Zt = /* @__PURE__ */ d("ZodRecord", (e, t) => {
|
|
5035
5046
|
Fc.init(e, t), I.init(e, t), e._zod.processJSONSchema = (n, o, r) => ss(e, n, o, r), e.keyType = t.keyType, e.valueType = t.valueType;
|
|
5036
5047
|
});
|
|
5037
5048
|
function We(e, t, n) {
|
|
5038
|
-
return !t || !t._zod ? new
|
|
5049
|
+
return !t || !t._zod ? new Zt({
|
|
5039
5050
|
type: "record",
|
|
5040
5051
|
keyType: g(),
|
|
5041
5052
|
valueType: e,
|
|
5042
5053
|
...h(t)
|
|
5043
|
-
}) : new
|
|
5054
|
+
}) : new Zt({
|
|
5044
5055
|
type: "record",
|
|
5045
5056
|
keyType: e,
|
|
5046
5057
|
valueType: t,
|
|
@@ -5095,7 +5106,7 @@ const du = /* @__PURE__ */ d("ZodLiteral", (e, t) => {
|
|
|
5095
5106
|
}
|
|
5096
5107
|
});
|
|
5097
5108
|
});
|
|
5098
|
-
function
|
|
5109
|
+
function Nt(e, t) {
|
|
5099
5110
|
return new du({
|
|
5100
5111
|
type: "literal",
|
|
5101
5112
|
values: Array.isArray(e) ? e : [e],
|
|
@@ -5105,7 +5116,7 @@ function Zt(e, t) {
|
|
|
5105
5116
|
const pu = /* @__PURE__ */ d("ZodTransform", (e, t) => {
|
|
5106
5117
|
Lc.init(e, t), I.init(e, t), e._zod.processJSONSchema = (n, o, r) => os(e, n), e._zod.parse = (n, o) => {
|
|
5107
5118
|
if (o.direction === "backward")
|
|
5108
|
-
throw new
|
|
5119
|
+
throw new vn(e.constructor.name);
|
|
5109
5120
|
n.addIssue = (i) => {
|
|
5110
5121
|
if (typeof i == "string")
|
|
5111
5122
|
n.issues.push(me(i, n.value, t));
|
|
@@ -5124,17 +5135,17 @@ function fu(e) {
|
|
|
5124
5135
|
transform: e
|
|
5125
5136
|
});
|
|
5126
5137
|
}
|
|
5127
|
-
const
|
|
5128
|
-
|
|
5138
|
+
const Jn = /* @__PURE__ */ d("ZodOptional", (e, t) => {
|
|
5139
|
+
Mn.init(e, t), I.init(e, t), e._zod.processJSONSchema = (n, o, r) => Gn(e, n, o, r), e.unwrap = () => e._zod.def.innerType;
|
|
5129
5140
|
});
|
|
5130
|
-
function
|
|
5131
|
-
return new
|
|
5141
|
+
function Rt(e) {
|
|
5142
|
+
return new Jn({
|
|
5132
5143
|
type: "optional",
|
|
5133
5144
|
innerType: e
|
|
5134
5145
|
});
|
|
5135
5146
|
}
|
|
5136
5147
|
const mu = /* @__PURE__ */ d("ZodExactOptional", (e, t) => {
|
|
5137
|
-
Gc.init(e, t), I.init(e, t), e._zod.processJSONSchema = (n, o, r) =>
|
|
5148
|
+
Gc.init(e, t), I.init(e, t), e._zod.processJSONSchema = (n, o, r) => Gn(e, n, o, r), e.unwrap = () => e._zod.def.innerType;
|
|
5138
5149
|
});
|
|
5139
5150
|
function hu(e) {
|
|
5140
5151
|
return new mu({
|
|
@@ -5145,7 +5156,7 @@ function hu(e) {
|
|
|
5145
5156
|
const _u = /* @__PURE__ */ d("ZodNullable", (e, t) => {
|
|
5146
5157
|
Wc.init(e, t), I.init(e, t), e._zod.processJSONSchema = (n, o, r) => us(e, n, o, r), e.unwrap = () => e._zod.def.innerType;
|
|
5147
5158
|
});
|
|
5148
|
-
function
|
|
5159
|
+
function Dt(e) {
|
|
5149
5160
|
return new _u({
|
|
5150
5161
|
type: "nullable",
|
|
5151
5162
|
innerType: e
|
|
@@ -5159,7 +5170,7 @@ function yu(e, t) {
|
|
|
5159
5170
|
type: "default",
|
|
5160
5171
|
innerType: e,
|
|
5161
5172
|
get defaultValue() {
|
|
5162
|
-
return typeof t == "function" ? t() :
|
|
5173
|
+
return typeof t == "function" ? t() : En(t);
|
|
5163
5174
|
}
|
|
5164
5175
|
});
|
|
5165
5176
|
}
|
|
@@ -5171,15 +5182,15 @@ function bu(e, t) {
|
|
|
5171
5182
|
type: "prefault",
|
|
5172
5183
|
innerType: e,
|
|
5173
5184
|
get defaultValue() {
|
|
5174
|
-
return typeof t == "function" ? t() :
|
|
5185
|
+
return typeof t == "function" ? t() : En(t);
|
|
5175
5186
|
}
|
|
5176
5187
|
});
|
|
5177
5188
|
}
|
|
5178
|
-
const
|
|
5189
|
+
const Hn = /* @__PURE__ */ d("ZodNonOptional", (e, t) => {
|
|
5179
5190
|
qc.init(e, t), I.init(e, t), e._zod.processJSONSchema = (n, o, r) => ls(e, n, o, r), e.unwrap = () => e._zod.def.innerType;
|
|
5180
5191
|
});
|
|
5181
5192
|
function gu(e, t) {
|
|
5182
|
-
return new
|
|
5193
|
+
return new Hn({
|
|
5183
5194
|
type: "nonoptional",
|
|
5184
5195
|
innerType: e,
|
|
5185
5196
|
...h(t)
|
|
@@ -5198,7 +5209,7 @@ function ku(e, t) {
|
|
|
5198
5209
|
const Su = /* @__PURE__ */ d("ZodPipe", (e, t) => {
|
|
5199
5210
|
Hc.init(e, t), I.init(e, t), e._zod.processJSONSchema = (n, o, r) => ms(e, n, o, r), e.in = t.in, e.out = t.out;
|
|
5200
5211
|
});
|
|
5201
|
-
function
|
|
5212
|
+
function Mt(e, t) {
|
|
5202
5213
|
return new Su({
|
|
5203
5214
|
type: "pipe",
|
|
5204
5215
|
in: e,
|
|
@@ -5224,7 +5235,7 @@ function Tu(e, t = {}) {
|
|
|
5224
5235
|
function $u(e, t) {
|
|
5225
5236
|
return /* @__PURE__ */ Wa(e, t);
|
|
5226
5237
|
}
|
|
5227
|
-
const Ou = /^0x[0-9a-fA-F]{40}$/, Cu = /^0x[0-9a-fA-F]*$/, Pu = /^\d+$/, C = g().regex(Ou, "Expected a 0x-prefixed 20-byte hex address").transform((e) => e), H = g().regex(Cu, "Expected 0x-prefixed hex data").transform((e) => e), F = g().regex(Pu, "Expected a base-10 unsigned integer string"),
|
|
5238
|
+
const Ou = /^0x[0-9a-fA-F]{40}$/, Cu = /^0x[0-9a-fA-F]*$/, Pu = /^\d+$/, C = g().regex(Ou, "Expected a 0x-prefixed 20-byte hex address").transform((e) => e), H = g().regex(Cu, "Expected 0x-prefixed hex data").transform((e) => e), F = g().regex(Pu, "Expected a base-10 unsigned integer string"), Xn = Wn({ offset: !0 }), Ze = ue(["aegis-direct-v4", "kyber"]), El = ue(["exactIn", "exactOut"]), xu = ue(["enabled", "disabled"]), Zu = ue(["pending", "success", "reverted", "not_found"]), Nu = O({
|
|
5228
5239
|
chainId: x().int(),
|
|
5229
5240
|
slug: g(),
|
|
5230
5241
|
name: g()
|
|
@@ -5238,7 +5249,7 @@ const Ou = /^0x[0-9a-fA-F]{40}$/, Cu = /^0x[0-9a-fA-F]*$/, Pu = /^\d+$/, C = g()
|
|
|
5238
5249
|
), Mu = O({
|
|
5239
5250
|
routers: L(C),
|
|
5240
5251
|
spenders: L(C)
|
|
5241
|
-
}),
|
|
5252
|
+
}), Qn = O({
|
|
5242
5253
|
outputFeeBps: x(),
|
|
5243
5254
|
recipient: C
|
|
5244
5255
|
}), Uu = O({
|
|
@@ -5248,7 +5259,7 @@ const Ou = /^0x[0-9a-fA-F]{40}$/, Cu = /^0x[0-9a-fA-F]*$/, Pu = /^\d+$/, C = g()
|
|
|
5248
5259
|
quote: Ru,
|
|
5249
5260
|
contracts: We(g(), Du),
|
|
5250
5261
|
allowlists: We(g(), Mu),
|
|
5251
|
-
fee:
|
|
5262
|
+
fee: Qn
|
|
5252
5263
|
}), Fu = O({
|
|
5253
5264
|
id: g(),
|
|
5254
5265
|
chainId: x().int(),
|
|
@@ -5282,7 +5293,7 @@ const Ou = /^0x[0-9a-fA-F]{40}$/, Cu = /^0x[0-9a-fA-F]*$/, Pu = /^\d+$/, C = g()
|
|
|
5282
5293
|
poolKey: ju,
|
|
5283
5294
|
metrics: Bu.optional(),
|
|
5284
5295
|
warnings: L(g())
|
|
5285
|
-
}),
|
|
5296
|
+
}), Ut = {
|
|
5286
5297
|
chainId: x().int(),
|
|
5287
5298
|
provider: Ze,
|
|
5288
5299
|
marketId: g().optional(),
|
|
@@ -5292,14 +5303,14 @@ const Ou = /^0x[0-9a-fA-F]{40}$/, Cu = /^0x[0-9a-fA-F]*$/, Pu = /^\d+$/, C = g()
|
|
|
5292
5303
|
account: C.nullable().optional()
|
|
5293
5304
|
}, kl = su("mode", [
|
|
5294
5305
|
O({
|
|
5295
|
-
...
|
|
5296
|
-
mode:
|
|
5306
|
+
...Ut,
|
|
5307
|
+
mode: Nt("exactIn"),
|
|
5297
5308
|
amountIn: F,
|
|
5298
5309
|
amountOut: Ge().optional()
|
|
5299
5310
|
}),
|
|
5300
5311
|
O({
|
|
5301
|
-
...
|
|
5302
|
-
mode:
|
|
5312
|
+
...Ut,
|
|
5313
|
+
mode: Nt("exactOut"),
|
|
5303
5314
|
amountOut: F,
|
|
5304
5315
|
amountIn: Ge().optional()
|
|
5305
5316
|
})
|
|
@@ -5311,7 +5322,7 @@ const Ou = /^0x[0-9a-fA-F]{40}$/, Cu = /^0x[0-9a-fA-F]*$/, Pu = /^\d+$/, C = g()
|
|
|
5311
5322
|
quoteId: g(),
|
|
5312
5323
|
quoteHash: H,
|
|
5313
5324
|
routeHash: H,
|
|
5314
|
-
expiresAt:
|
|
5325
|
+
expiresAt: Xn,
|
|
5315
5326
|
quoteBlockNumber: F,
|
|
5316
5327
|
provider: Ze,
|
|
5317
5328
|
marketId: g().optional(),
|
|
@@ -5320,7 +5331,7 @@ const Ou = /^0x[0-9a-fA-F]{40}$/, Cu = /^0x[0-9a-fA-F]*$/, Pu = /^\d+$/, C = g()
|
|
|
5320
5331
|
minAmountOut: F,
|
|
5321
5332
|
gasEstimate: F.nullable().optional(),
|
|
5322
5333
|
approval: Gu,
|
|
5323
|
-
fee:
|
|
5334
|
+
fee: Qn,
|
|
5324
5335
|
warnings: L(g())
|
|
5325
5336
|
}), Sl = O({
|
|
5326
5337
|
quoteId: g(),
|
|
@@ -5337,7 +5348,7 @@ const Ou = /^0x[0-9a-fA-F]{40}$/, Cu = /^0x[0-9a-fA-F]*$/, Pu = /^\d+$/, C = g()
|
|
|
5337
5348
|
quoteId: g(),
|
|
5338
5349
|
routeHash: H,
|
|
5339
5350
|
expectedCalldataHash: H,
|
|
5340
|
-
expiresAt:
|
|
5351
|
+
expiresAt: Xn,
|
|
5341
5352
|
tx: Ku,
|
|
5342
5353
|
allowance: O({
|
|
5343
5354
|
spender: C,
|
|
@@ -5357,8 +5368,8 @@ const Ou = /^0x[0-9a-fA-F]{40}$/, Cu = /^0x[0-9a-fA-F]*$/, Pu = /^\d+$/, C = g()
|
|
|
5357
5368
|
explorerUrl: g().nullable().optional()
|
|
5358
5369
|
}), Ju = O({
|
|
5359
5370
|
ok: he()
|
|
5360
|
-
}),
|
|
5361
|
-
class
|
|
5371
|
+
}), Ft = L(Fu), Hu = L(Lu);
|
|
5372
|
+
class Yn extends Error {
|
|
5362
5373
|
constructor({
|
|
5363
5374
|
status: n,
|
|
5364
5375
|
statusText: o,
|
|
@@ -5366,23 +5377,23 @@ class Xn extends Error {
|
|
|
5366
5377
|
}) {
|
|
5367
5378
|
const i = r && typeof r == "object" && "message" in r ? `: ${String(r.message)}` : "";
|
|
5368
5379
|
super(`Aegis backend API error ${n}${i || `: ${o || "Request failed"}`}`);
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5380
|
+
U(this, "status");
|
|
5381
|
+
U(this, "statusText");
|
|
5382
|
+
U(this, "body");
|
|
5372
5383
|
this.name = "AegisBackendApiError", this.status = n, this.statusText = o, this.body = r;
|
|
5373
5384
|
}
|
|
5374
5385
|
}
|
|
5375
|
-
class
|
|
5386
|
+
class eo extends Error {
|
|
5376
5387
|
constructor({ endpoint: n, issues: o }) {
|
|
5377
5388
|
const r = o[0], i = r ? `: ${r.path.length > 0 ? r.path.join(".") : "(root)"} ${r.message}` : "";
|
|
5378
5389
|
super(`Aegis backend response violated the V1 contract at ${n}${i}`);
|
|
5379
|
-
|
|
5380
|
-
|
|
5390
|
+
U(this, "endpoint");
|
|
5391
|
+
U(this, "issues");
|
|
5381
5392
|
this.name = "AegisBackendContractError", this.endpoint = n, this.issues = o;
|
|
5382
5393
|
}
|
|
5383
5394
|
}
|
|
5384
5395
|
function Il(e) {
|
|
5385
|
-
return e instanceof
|
|
5396
|
+
return e instanceof Yn ? e.status === 429 || e.status >= 500 : e instanceof eo ? !1 : e instanceof TypeError ? !0 : e instanceof Error && (e.name === "AbortError" || e.name === "TimeoutError");
|
|
5386
5397
|
}
|
|
5387
5398
|
function Xu(e) {
|
|
5388
5399
|
const t = e.trim();
|
|
@@ -5435,7 +5446,7 @@ function Al(e) {
|
|
|
5435
5446
|
try {
|
|
5436
5447
|
const _ = await n(`${t}${c}`, f), y = await Qu(_);
|
|
5437
5448
|
if (!_.ok)
|
|
5438
|
-
throw new
|
|
5449
|
+
throw new Yn({
|
|
5439
5450
|
status: _.status,
|
|
5440
5451
|
statusText: _.statusText,
|
|
5441
5452
|
body: y
|
|
@@ -5443,7 +5454,7 @@ function Al(e) {
|
|
|
5443
5454
|
if (!o) return y;
|
|
5444
5455
|
const k = a.safeParse(y);
|
|
5445
5456
|
if (!k.success)
|
|
5446
|
-
throw new
|
|
5457
|
+
throw new eo({
|
|
5447
5458
|
endpoint: c,
|
|
5448
5459
|
issues: k.error.issues
|
|
5449
5460
|
});
|
|
@@ -5458,7 +5469,7 @@ function Al(e) {
|
|
|
5458
5469
|
tokens: ({ chainId: i }, c) => r(
|
|
5459
5470
|
"GET",
|
|
5460
5471
|
Me("/v1/tokens", { chainId: i }),
|
|
5461
|
-
|
|
5472
|
+
Ft,
|
|
5462
5473
|
void 0,
|
|
5463
5474
|
c
|
|
5464
5475
|
),
|
|
@@ -5468,7 +5479,7 @@ function Al(e) {
|
|
|
5468
5479
|
chainId: i,
|
|
5469
5480
|
addresses: c.join(",")
|
|
5470
5481
|
}),
|
|
5471
|
-
|
|
5482
|
+
Ft,
|
|
5472
5483
|
void 0,
|
|
5473
5484
|
a
|
|
5474
5485
|
),
|
|
@@ -5493,7 +5504,7 @@ function Al(e) {
|
|
|
5493
5504
|
class ae extends Error {
|
|
5494
5505
|
constructor(n, o) {
|
|
5495
5506
|
super(o);
|
|
5496
|
-
|
|
5507
|
+
U(this, "code");
|
|
5497
5508
|
this.name = "AegisContractGuardError", this.code = n;
|
|
5498
5509
|
}
|
|
5499
5510
|
}
|
|
@@ -5511,21 +5522,21 @@ function zl(e, t = Date.now()) {
|
|
|
5511
5522
|
);
|
|
5512
5523
|
}
|
|
5513
5524
|
function Tl(e, t) {
|
|
5514
|
-
if (!t.some((n) =>
|
|
5525
|
+
if (!t.some((n) => D(n, e)))
|
|
5515
5526
|
throw new ae(
|
|
5516
5527
|
"ROUTER_NOT_ALLOWLISTED",
|
|
5517
5528
|
`Transaction target ${e} is not an allowlisted router.`
|
|
5518
5529
|
);
|
|
5519
5530
|
}
|
|
5520
5531
|
function $l(e, t) {
|
|
5521
|
-
if (!t.some((n) =>
|
|
5532
|
+
if (!t.some((n) => D(n, e)))
|
|
5522
5533
|
throw new ae(
|
|
5523
5534
|
"SPENDER_NOT_ALLOWLISTED",
|
|
5524
5535
|
`Approval spender ${e} is not an allowlisted spender.`
|
|
5525
5536
|
);
|
|
5526
5537
|
}
|
|
5527
5538
|
function Ol(e, t) {
|
|
5528
|
-
const n =
|
|
5539
|
+
const n = Bt(e);
|
|
5529
5540
|
if (n.toLowerCase() !== t.toLowerCase())
|
|
5530
5541
|
throw new ae(
|
|
5531
5542
|
"CALLDATA_HASH_MISMATCH",
|
|
@@ -5543,47 +5554,47 @@ export {
|
|
|
5543
5554
|
rl as AEGIS_DYNAMIC_FEE_FLAG,
|
|
5544
5555
|
He as AEGIS_SWAP_CHAINS,
|
|
5545
5556
|
N as AEGIS_SWAP_CHAIN_ID,
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5557
|
+
lo as AEGIS_SWAP_DEFAULT_FEE_BPS,
|
|
5558
|
+
jt as AEGIS_SWAP_DEFAULT_FEE_RECIPIENT,
|
|
5559
|
+
fo as AEGIS_SWAP_DEFAULT_METADATA_ENDPOINT,
|
|
5560
|
+
po as AEGIS_SWAP_DEFAULT_RPC_URLS,
|
|
5550
5561
|
ol as AEGIS_SWAP_HOOK,
|
|
5551
|
-
|
|
5562
|
+
_o as AEGIS_SWAP_MAINNET_CHAIN,
|
|
5552
5563
|
Je as AEGIS_SWAP_MAINNET_UNISWAP_V4_CONTRACTS,
|
|
5553
|
-
|
|
5554
|
-
|
|
5564
|
+
mo as AEGIS_SWAP_PERMIT2,
|
|
5565
|
+
uo as AEGIS_SWAP_ROUTER,
|
|
5555
5566
|
ee as AEGIS_SWAP_TOKENS,
|
|
5556
|
-
|
|
5567
|
+
ho as AEGIS_SWAP_V4_QUOTER,
|
|
5557
5568
|
al as AGGREGATED_SWAP_CURATED_TOKENS,
|
|
5558
5569
|
Xe as AGGREGATED_SWAP_DEFAULT_TOKENS,
|
|
5559
|
-
|
|
5570
|
+
bo as AGGREGATED_SWAP_DEFAULT_TOKEN_LIST,
|
|
5560
5571
|
cl as AGGREGATED_SWAP_TOKEN_PRESETS,
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5572
|
+
vo as AGGREGATED_SWAP_WOLFGAME_TOKENS,
|
|
5573
|
+
go as AGGREGATED_SWAP_WOLFGAME_TOKEN_LIST,
|
|
5574
|
+
Yn as AegisBackendApiError,
|
|
5575
|
+
eo as AegisBackendContractError,
|
|
5565
5576
|
ae as AegisContractGuardError,
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5577
|
+
dn as DEFAULT_PERMIT_EXPIRATION_SECONDS,
|
|
5578
|
+
Ur as DirectPoolSwapPriceMovedError,
|
|
5579
|
+
on as KyberSwapApiError,
|
|
5569
5580
|
Lr as KyberSwapPriceMovedError,
|
|
5570
|
-
|
|
5581
|
+
ko as MAX_UINT128,
|
|
5571
5582
|
Se as MAX_UINT160,
|
|
5572
|
-
|
|
5583
|
+
un as MAX_UINT256,
|
|
5573
5584
|
jr as NATIVE_TOKEN_ADDRESS,
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5585
|
+
hr as PERMIT2_FAR_FUTURE_EXPIRATION,
|
|
5586
|
+
ln as SWAP_TX_DEADLINE_SECONDS,
|
|
5587
|
+
Wt as UNISWAP_V4_CONTRACTS_BY_CHAIN,
|
|
5577
5588
|
Mu as aegisBackendAddressAllowlistSchema,
|
|
5578
5589
|
C as aegisBackendAddressSchema,
|
|
5579
5590
|
Nu as aegisBackendChainSchema,
|
|
5580
5591
|
Uu as aegisBackendConfigSchema,
|
|
5581
5592
|
Du as aegisBackendContractRegistrySchema,
|
|
5582
5593
|
F as aegisBackendDecimalStringSchema,
|
|
5583
|
-
|
|
5594
|
+
Qn as aegisBackendFeeConfigSchema,
|
|
5584
5595
|
Ju as aegisBackendHealthResponseSchema,
|
|
5585
5596
|
H as aegisBackendHexSchema,
|
|
5586
|
-
|
|
5597
|
+
Xn as aegisBackendIsoDateTimeSchema,
|
|
5587
5598
|
Bu as aegisBackendMarketMetricsSchema,
|
|
5588
5599
|
Lu as aegisBackendMarketSchema,
|
|
5589
5600
|
xu as aegisBackendMarketStatusSchema,
|
|
@@ -5597,72 +5608,72 @@ export {
|
|
|
5597
5608
|
kl as aegisBackendSwapQuoteRequestSchema,
|
|
5598
5609
|
Wu as aegisBackendSwapQuoteResponseSchema,
|
|
5599
5610
|
Fu as aegisBackendTokenSchema,
|
|
5600
|
-
|
|
5611
|
+
Ft as aegisBackendTokensResponseSchema,
|
|
5601
5612
|
qu as aegisBackendTxStatusResponseSchema,
|
|
5602
5613
|
Zu as aegisBackendTxStatusSchema,
|
|
5603
5614
|
Ku as aegisBackendUnsignedSwapTxSchema,
|
|
5604
5615
|
ju as aegisPoolKeySchema,
|
|
5605
5616
|
ll as aggregatedSwapErrorMessage,
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5617
|
+
Br as approveDirectPoolSwapInput,
|
|
5618
|
+
dt as approveErc20Spender,
|
|
5619
|
+
lt as approveErc20ToPermit2,
|
|
5609
5620
|
Gr as approveKyberSwapInput,
|
|
5610
|
-
|
|
5621
|
+
wr as approvePermit2ToRouter,
|
|
5611
5622
|
Ol as assertCalldataHash,
|
|
5612
5623
|
Cl as assertChainMatches,
|
|
5613
5624
|
zl as assertQuoteFresh,
|
|
5614
5625
|
Tl as assertRouterAllowlisted,
|
|
5615
5626
|
$l as assertSpenderAllowlisted,
|
|
5616
5627
|
pe as assertUint128,
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5628
|
+
Ro as buildExactInSwapTransaction,
|
|
5629
|
+
Do as buildExactOutSwapTransaction,
|
|
5630
|
+
rr as buildKyberSwapRoute,
|
|
5631
|
+
yr as buildSignedPermitBatch,
|
|
5632
|
+
Qt as computePoolId,
|
|
5622
5633
|
Al as createAegisBackendApiClient,
|
|
5623
|
-
|
|
5634
|
+
yo as createAegisSwapChainConfig,
|
|
5624
5635
|
il as createAegisSwapChains,
|
|
5625
5636
|
sl as createAegisSwapMarketsFromPools,
|
|
5626
|
-
|
|
5637
|
+
Uo as createAegisSwapPoolMarket,
|
|
5627
5638
|
q as createAegisSwapUniswapV4Contracts,
|
|
5628
5639
|
fl as createSwapPublicClient,
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5640
|
+
wn as ensureWalletChain,
|
|
5641
|
+
Yo as errorMessage,
|
|
5642
|
+
fn as estimateSwapGasWithBuffer,
|
|
5632
5643
|
yl as executeDirectPoolSwap,
|
|
5633
5644
|
vl as executeKyberSwap,
|
|
5634
5645
|
ut as fetchAggregatedSwapQuote,
|
|
5635
|
-
|
|
5646
|
+
Fr as fetchDirectPoolSwapQuote,
|
|
5636
5647
|
pl as fetchGlobalTokenMetadata,
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5648
|
+
or as fetchKyberSwapRoute,
|
|
5649
|
+
Kt as getExplorerUrl,
|
|
5650
|
+
Er as getIchiIconGuess,
|
|
5651
|
+
Sr as getInjectedProvider,
|
|
5652
|
+
zr as getProviderAccount,
|
|
5642
5653
|
Be as getProviderChainId,
|
|
5643
|
-
|
|
5654
|
+
Wo as getZeroForOne,
|
|
5644
5655
|
bl as isBusy,
|
|
5645
5656
|
hl as isDocumentVisible,
|
|
5646
|
-
|
|
5647
|
-
|
|
5657
|
+
Ir as isEip1193Provider,
|
|
5658
|
+
yn as isNativeToken,
|
|
5648
5659
|
Il as isRetryableAegisBackendApiError,
|
|
5649
|
-
|
|
5650
|
-
|
|
5660
|
+
sn as isRetryableKyberSwapError,
|
|
5661
|
+
nn as isUserRejectedError,
|
|
5651
5662
|
$e as normalizeAccount,
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5663
|
+
Ar as normalizeWalletConnection,
|
|
5664
|
+
Xo as outputFeeForQuote,
|
|
5665
|
+
hn as pollUntil,
|
|
5666
|
+
Ho as quoteSpendAmount,
|
|
5656
5667
|
Ie as readErc20Allowance,
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5668
|
+
pn as readPermit2RouterAllowance,
|
|
5669
|
+
Jo as reconcileSubmitQuote,
|
|
5670
|
+
Tr as requestProviderAccount,
|
|
5660
5671
|
dl as resolveTokenIconUrl,
|
|
5661
5672
|
wl as resolveWalletSession,
|
|
5662
5673
|
_l as retryOnError,
|
|
5663
5674
|
ul as sameQuote,
|
|
5664
5675
|
ml as subscribeProvider,
|
|
5665
|
-
|
|
5676
|
+
Zr as switchProviderChain,
|
|
5666
5677
|
gl as transactionProgressView,
|
|
5667
|
-
|
|
5678
|
+
Mr as waitForProviderChain
|
|
5668
5679
|
};
|