@dhedge/trading-widget 6.3.3 → 6.3.6
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/{contract-error-log-CbE2J5kb.js → contract-error-log-C72hcInG.js} +356 -349
- package/contract-error-log-xoZ1OAil.cjs +1 -0
- package/core-kit/hooks/trading/withdraw-v2/init-step/use-init-withdraw-simulation-withdraw-data.d.ts +4 -1
- package/core-kit/utils/number.d.ts +1 -0
- package/core-kit/utils/ondo.d.ts +2 -0
- package/index.cjs +1 -1
- package/index.js +3791 -3755
- package/limit-orders/common/utils.d.ts +0 -1
- package/package.json +1 -1
- package/utils.cjs +1 -1
- package/utils.js +73 -70
- package/contract-error-log-CNIRNvc6.cjs +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { hyperEvm as
|
|
2
|
-
import { aq as
|
|
1
|
+
import { hyperEvm as H, mainnet as I, polygon as at, optimism as rt, base as ot, arbitrum as it } from "wagmi/chains";
|
|
2
|
+
import { aq as ct, ao as ut, ap as dt, a as N, q as R, ar as pt, as as lt, a5 as mt, ak as yt, a3 as gt, b as At, ae as Et, Z as k, aj as ht, at as V, e as ft, d as St, M as Tt, R as wt, P as _t, au as bt, av as Dt, Q as It, N as Nt, ah as _, _ as Rt, W as Ot, X as Ct, U as xt, aw as q, ax as Bt, ay as Lt, az as Mt, aA as Pt, aB as Ut, ad as $t } from "./gmx-Cyz_GmV5.js";
|
|
3
3
|
import d from "bignumber.js";
|
|
4
|
-
import { zeroHash as
|
|
5
|
-
const
|
|
4
|
+
import { zeroHash as vt, bytesToHex as Ft, pad as Yt, stringToHex as O, encodeAbiParameters as T, encodeFunctionData as A, maxUint256 as w, erc20Abi as K } from "viem";
|
|
5
|
+
const B = "application/json";
|
|
6
6
|
class j extends Error {
|
|
7
|
-
constructor(e,
|
|
8
|
-
super(`HTTP ${e}${
|
|
7
|
+
constructor(e, s, n) {
|
|
8
|
+
super(`HTTP ${e}${n ? `: ${n}` : ""}`), this.name = "FetchRequestError", this.status = e, this.statusText = s, this.body = n;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
const
|
|
11
|
+
const Xe = (t) => {
|
|
12
12
|
if (!(t instanceof j) || !t.body)
|
|
13
13
|
return null;
|
|
14
14
|
try {
|
|
@@ -16,43 +16,43 @@ const Ke = (t) => {
|
|
|
16
16
|
} catch {
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
19
|
-
},
|
|
20
|
-
const
|
|
21
|
-
if (!
|
|
22
|
-
return
|
|
23
|
-
const a =
|
|
24
|
-
return `${r}${r.includes("?") ? "&" : "?"}${
|
|
19
|
+
}, Gt = (t) => typeof t == "string" || t instanceof FormData || t instanceof URLSearchParams || t instanceof Blob || t instanceof ArrayBuffer || ArrayBuffer.isView(t), Wt = (t, e) => {
|
|
20
|
+
const s = String(t), n = e ? new URLSearchParams(e).toString() : "";
|
|
21
|
+
if (!n)
|
|
22
|
+
return s;
|
|
23
|
+
const a = s.indexOf("#"), r = a === -1 ? s : s.slice(0, a), o = a === -1 ? "" : s.slice(a);
|
|
24
|
+
return `${r}${r.includes("?") ? "&" : "?"}${n}${o}`;
|
|
25
25
|
}, Ht = (t, e) => {
|
|
26
|
-
const
|
|
27
|
-
e?.aborted &&
|
|
28
|
-
const a = setTimeout(
|
|
29
|
-
return e?.addEventListener("abort",
|
|
30
|
-
signal:
|
|
26
|
+
const s = new AbortController(), n = () => s.abort();
|
|
27
|
+
e?.aborted && n();
|
|
28
|
+
const a = setTimeout(n, t);
|
|
29
|
+
return e?.addEventListener("abort", n), {
|
|
30
|
+
signal: s.signal,
|
|
31
31
|
cleanup: () => {
|
|
32
|
-
clearTimeout(a), e?.removeEventListener("abort",
|
|
32
|
+
clearTimeout(a), e?.removeEventListener("abort", n);
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
},
|
|
36
|
-
if (
|
|
35
|
+
}, kt = async (t, e, s) => {
|
|
36
|
+
if (s === void 0)
|
|
37
37
|
return await t[e]();
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
throw new Error(`Response too large: ${
|
|
38
|
+
const n = Number(t.headers.get("content-length"));
|
|
39
|
+
if (n > s)
|
|
40
|
+
throw new Error(`Response too large: ${n} bytes`);
|
|
41
41
|
if (e === "blob" || e === "arrayBuffer") {
|
|
42
42
|
const r = await t[e](), o = r instanceof Blob ? r.size : r.byteLength;
|
|
43
|
-
if (o >
|
|
43
|
+
if (o > s)
|
|
44
44
|
throw new Error(`Response too large: ${o} bytes`);
|
|
45
45
|
return r;
|
|
46
46
|
}
|
|
47
47
|
const a = await t.text();
|
|
48
|
-
if (a.length >
|
|
48
|
+
if (a.length > s)
|
|
49
49
|
throw new Error(`Response too large: ${a.length} chars`);
|
|
50
50
|
return e === "json" ? JSON.parse(a) : a;
|
|
51
|
-
},
|
|
51
|
+
}, Vt = async ({
|
|
52
52
|
url: t,
|
|
53
53
|
headers: e,
|
|
54
|
-
method:
|
|
55
|
-
body:
|
|
54
|
+
method: s,
|
|
55
|
+
body: n,
|
|
56
56
|
params: a,
|
|
57
57
|
signal: r,
|
|
58
58
|
readMethod: o = "json",
|
|
@@ -60,24 +60,24 @@ const Ke = (t) => {
|
|
|
60
60
|
timeoutMs: i,
|
|
61
61
|
maxResponseBytes: u
|
|
62
62
|
}) => {
|
|
63
|
-
const l =
|
|
64
|
-
o === "json" && !m.has("Accept") && m.set("Accept",
|
|
63
|
+
const l = n !== void 0 && s !== "GET", g = l && !Gt(n), m = new Headers(e);
|
|
64
|
+
o === "json" && !m.has("Accept") && m.set("Accept", B), g && !m.has("Content-Type") && m.set("Content-Type", B);
|
|
65
65
|
const f = i ? Ht(i, r) : void 0, nt = {
|
|
66
|
-
method:
|
|
66
|
+
method: s,
|
|
67
67
|
headers: m,
|
|
68
68
|
signal: f?.signal ?? r,
|
|
69
69
|
...c && { cache: c },
|
|
70
|
-
...l && { body: g ? JSON.stringify(
|
|
70
|
+
...l && { body: g ? JSON.stringify(n) : n }
|
|
71
71
|
};
|
|
72
72
|
try {
|
|
73
|
-
const E = await fetch(
|
|
73
|
+
const E = await fetch(Wt(t, a), nt);
|
|
74
74
|
if (!E.ok)
|
|
75
75
|
throw new j(E.status, E.statusText, await E.text().catch(() => ""));
|
|
76
|
-
return await
|
|
76
|
+
return await kt(E, o, u);
|
|
77
77
|
} finally {
|
|
78
78
|
f?.cleanup();
|
|
79
79
|
}
|
|
80
|
-
},
|
|
80
|
+
}, ze = typeof window < "u", Qe = [
|
|
81
81
|
{
|
|
82
82
|
inputs: [
|
|
83
83
|
{ internalType: "address", name: "_pool", type: "address" },
|
|
@@ -128,7 +128,7 @@ const Ke = (t) => {
|
|
|
128
128
|
{ name: "amountOutMinimum", type: "uint256" }
|
|
129
129
|
]
|
|
130
130
|
}
|
|
131
|
-
],
|
|
131
|
+
], Kt = [
|
|
132
132
|
{ name: "asset", type: "address" },
|
|
133
133
|
{ name: "amount", type: "uint256" },
|
|
134
134
|
{ name: "assetType", type: "uint16" },
|
|
@@ -139,7 +139,7 @@ const Ke = (t) => {
|
|
|
139
139
|
{ name: "tokenId", type: "uint256" },
|
|
140
140
|
{ name: "debtKey", type: "uint248" },
|
|
141
141
|
{ name: "shares", type: "uint256" }
|
|
142
|
-
],
|
|
142
|
+
], Ze = [
|
|
143
143
|
{
|
|
144
144
|
inputs: [
|
|
145
145
|
{ internalType: "address", name: "_pool", type: "address" },
|
|
@@ -150,7 +150,7 @@ const Ke = (t) => {
|
|
|
150
150
|
{
|
|
151
151
|
name: "assetData",
|
|
152
152
|
type: "tuple[]",
|
|
153
|
-
components:
|
|
153
|
+
components: Kt
|
|
154
154
|
}
|
|
155
155
|
],
|
|
156
156
|
stateMutability: "nonpayable",
|
|
@@ -205,7 +205,7 @@ const Ke = (t) => {
|
|
|
205
205
|
stateMutability: "nonpayable",
|
|
206
206
|
type: "function"
|
|
207
207
|
}
|
|
208
|
-
],
|
|
208
|
+
], jt = [
|
|
209
209
|
{
|
|
210
210
|
inputs: [
|
|
211
211
|
{ name: "tokenIn", type: "address" },
|
|
@@ -234,7 +234,7 @@ const Ke = (t) => {
|
|
|
234
234
|
stateMutability: "nonpayable",
|
|
235
235
|
type: "function"
|
|
236
236
|
}
|
|
237
|
-
],
|
|
237
|
+
], Xt = [
|
|
238
238
|
{
|
|
239
239
|
type: "tuple",
|
|
240
240
|
components: [
|
|
@@ -288,62 +288,62 @@ const Ke = (t) => {
|
|
|
288
288
|
...t.selectorErrors,
|
|
289
289
|
...D.selectorErrors
|
|
290
290
|
}
|
|
291
|
-
}),
|
|
291
|
+
}), zt = [
|
|
292
292
|
"https://cdn.jsdelivr.net/gh/dhedge/V2-Public@master/readmes/errorCodes/registry.json",
|
|
293
293
|
"https://raw.githubusercontent.com/dhedge/V2-Public/master/readmes/errorCodes/registry.json"
|
|
294
|
-
],
|
|
294
|
+
], Qt = 1, Zt = 1e4, Jt = 2e6, te = 2e3, ee = 500, se = 120, ne = 300, ae = 4, re = /^dh\d{1,3}$/i, z = /[\u0000-\u001f\u007f]/, oe = /https?:\/\/|[<>`]/i, ie = (t) => t.length <= se && !z.test(t) && (re.test(t) || t.length >= ae), h = (t) => typeof t == "string" && t.length > 0 && t.length <= ne && !z.test(t) && !oe.test(t);
|
|
295
295
|
let Q = D, b = null;
|
|
296
|
-
const Z = () => Q,
|
|
296
|
+
const Z = () => Q, ce = (t) => {
|
|
297
297
|
Q = X(t);
|
|
298
|
-
},
|
|
298
|
+
}, ue = (t) => {
|
|
299
299
|
const e = t;
|
|
300
|
-
if (e?.schemaVersion !==
|
|
300
|
+
if (e?.schemaVersion !== Qt)
|
|
301
301
|
throw new Error(
|
|
302
302
|
`Unsupported error registry schemaVersion: ${String(e?.schemaVersion)}`
|
|
303
303
|
);
|
|
304
|
-
const n = {};
|
|
305
|
-
for (const [a, r] of Object.entries(e.stringErrors ?? {}))
|
|
306
|
-
r?.curated === !0 && oe(a) && h(r.description) && h(r.action) && (n[a] = { title: r.description, hint: r.action });
|
|
307
304
|
const s = {};
|
|
305
|
+
for (const [a, r] of Object.entries(e.stringErrors ?? {}))
|
|
306
|
+
r?.curated === !0 && ie(a) && h(r.description) && h(r.action) && (s[a] = { title: r.description, hint: r.action });
|
|
307
|
+
const n = {};
|
|
308
308
|
for (const [a, r] of Object.entries(e.selectorErrors ?? {}))
|
|
309
|
-
r?.curated === !0 && /^0x[0-9a-f]{8}$/.test(a) && h(r.signature) && h(r.description) && h(r.action) && (
|
|
309
|
+
r?.curated === !0 && /^0x[0-9a-f]{8}$/.test(a) && h(r.signature) && h(r.description) && h(r.action) && (n[a] = {
|
|
310
310
|
signature: r.signature,
|
|
311
311
|
title: r.description,
|
|
312
312
|
hint: r.action
|
|
313
313
|
});
|
|
314
|
-
if (!Object.keys(
|
|
314
|
+
if (!Object.keys(s).length)
|
|
315
315
|
throw new Error("Error registry contained no curated string errors");
|
|
316
|
-
if (Object.keys(
|
|
316
|
+
if (Object.keys(s).length > te || Object.keys(n).length > ee)
|
|
317
317
|
throw new Error("Error registry exceeded expected entry counts");
|
|
318
|
-
return { stringErrors:
|
|
319
|
-
},
|
|
320
|
-
timeoutMs: t =
|
|
318
|
+
return { stringErrors: s, selectorErrors: n };
|
|
319
|
+
}, de = async ({
|
|
320
|
+
timeoutMs: t = Zt
|
|
321
321
|
} = {}) => {
|
|
322
322
|
const e = [];
|
|
323
|
-
for (const
|
|
323
|
+
for (const s of zt)
|
|
324
324
|
try {
|
|
325
|
-
const
|
|
326
|
-
url:
|
|
325
|
+
const n = await Vt({
|
|
326
|
+
url: s,
|
|
327
327
|
method: "GET",
|
|
328
328
|
timeoutMs: t,
|
|
329
|
-
maxResponseBytes:
|
|
329
|
+
maxResponseBytes: Jt
|
|
330
330
|
});
|
|
331
|
-
return X(
|
|
332
|
-
} catch (
|
|
331
|
+
return X(ue(n));
|
|
332
|
+
} catch (n) {
|
|
333
333
|
e.push(
|
|
334
|
-
`${
|
|
334
|
+
`${s}: ${n instanceof Error ? n.message : String(n)}`
|
|
335
335
|
);
|
|
336
336
|
}
|
|
337
337
|
throw new Error(`All error registry sources failed: ${e.join("; ")}`);
|
|
338
|
-
},
|
|
338
|
+
}, Je = () => (b ?? (b = de().then(ce).catch(() => {
|
|
339
339
|
b = null;
|
|
340
|
-
})), b),
|
|
341
|
-
function
|
|
342
|
-
return
|
|
340
|
+
})), b), pe = () => typeof window < "u";
|
|
341
|
+
function le() {
|
|
342
|
+
return pe() && typeof window.ethereum < "u";
|
|
343
343
|
}
|
|
344
|
-
async function
|
|
344
|
+
async function ts(t) {
|
|
345
345
|
try {
|
|
346
|
-
if (
|
|
346
|
+
if (le())
|
|
347
347
|
return window.ethereum.request({
|
|
348
348
|
method: "wallet_watchAsset",
|
|
349
349
|
params: {
|
|
@@ -356,7 +356,7 @@ async function Ze(t) {
|
|
|
356
356
|
}
|
|
357
357
|
return !1;
|
|
358
358
|
}
|
|
359
|
-
const p = (t, e) => t?.toLowerCase() === e?.toLowerCase(),
|
|
359
|
+
const p = (t, e) => t?.toLowerCase() === e?.toLowerCase(), es = (t) => p(t, ct), S = (t) => {
|
|
360
360
|
if (!t) throw new Error("Cannot prefix an empty hex value");
|
|
361
361
|
return t.startsWith("0x") ? t : `0x${t}`;
|
|
362
362
|
}, y = (t, e) => {
|
|
@@ -365,40 +365,44 @@ const p = (t, e) => t?.toLowerCase() === e?.toLowerCase(), Je = (t) => p(t, it),
|
|
|
365
365
|
} catch {
|
|
366
366
|
throw new Error(`Cannot convert "${e}" value "${t}" to bigint`);
|
|
367
367
|
}
|
|
368
|
-
},
|
|
368
|
+
}, L = (t) => t ? Yt(S(t), { size: 32 }) : vt, me = (t) => {
|
|
369
369
|
if (!t) throw new Error("Cannot decode an empty base64 string");
|
|
370
|
-
return
|
|
371
|
-
},
|
|
370
|
+
return Ft(Uint8Array.from(atob(t), (e) => e.charCodeAt(0)));
|
|
371
|
+
}, ye = (t, e) => dt[e]?.[t] ?? N, ss = (t) => ut[t], ns = (t) => t && `${t.substring(0, 6)}...${t.substring(
|
|
372
372
|
t.length - 4,
|
|
373
373
|
t.length
|
|
374
|
-
)}`,
|
|
374
|
+
)}`, as = ({
|
|
375
375
|
address: t,
|
|
376
376
|
chainId: e
|
|
377
377
|
}) => {
|
|
378
|
-
const
|
|
378
|
+
const s = ye(
|
|
379
379
|
"aaveLendingPoolV3",
|
|
380
380
|
e
|
|
381
381
|
);
|
|
382
|
-
return p(t,
|
|
383
|
-
},
|
|
382
|
+
return p(t, s);
|
|
383
|
+
}, ge = ({
|
|
384
384
|
sourceAddress: t,
|
|
385
385
|
amount: e
|
|
386
|
-
}) => `${t}_${e}`,
|
|
387
|
-
const
|
|
388
|
-
return { firstPart:
|
|
389
|
-
},
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
386
|
+
}) => `${t}_${e}`, rs = (t, e) => {
|
|
387
|
+
const s = t.slice(0, e), n = t.slice(e);
|
|
388
|
+
return { firstPart: s, secondPart: n };
|
|
389
|
+
}, Ae = (t, e) => t / e * 100, os = (t) => t < 1 ? 4 : t < 10 ? 3 : 2, is = (t, e = R) => new d(t.toString()).shiftedBy(e).toFixed(0), cs = (t) => {
|
|
390
|
+
const e = t?.trim();
|
|
391
|
+
return e ? !isNaN(Number(e)) && Number(e) > 0 : !1;
|
|
392
|
+
}, us = (t, e, s, n) => new d(e).dividedBy(s).multipliedBy(t).shiftedBy(-(n || R)).toNumber(), ds = (t) => {
|
|
393
|
+
const e = new d(t || "0").shiftedBy(R);
|
|
394
|
+
return e.isFinite() ? BigInt(e.toFixed(0, d.ROUND_DOWN)) : BigInt(0);
|
|
395
|
+
}, J = (t) => {
|
|
396
|
+
const e = new d(0.01), s = new d(t), n = !s.isZero() && s.lt(e) ? e : s;
|
|
397
|
+
return BigInt(n.multipliedBy(100).toFixed(0));
|
|
398
|
+
}, ps = ({
|
|
395
399
|
chainId: t,
|
|
396
400
|
slippage: e
|
|
397
|
-
}) => t ===
|
|
401
|
+
}) => t === H.id ? BigInt(0) : J(e), ls = ({
|
|
398
402
|
vaultAddress: t,
|
|
399
403
|
swapData: e,
|
|
400
|
-
sendTokenAddress:
|
|
401
|
-
sendTokenAmount:
|
|
404
|
+
sendTokenAddress: s,
|
|
405
|
+
sendTokenAmount: n,
|
|
402
406
|
vaultDepositTokenAddress: a,
|
|
403
407
|
minVaultTokensReceivedAmount: r,
|
|
404
408
|
routerKey: o = "ONE_INCH",
|
|
@@ -406,18 +410,18 @@ const p = (t, e) => t?.toLowerCase() === e?.toLowerCase(), Je = (t) => p(t, it),
|
|
|
406
410
|
swapSlippage: i
|
|
407
411
|
}) => {
|
|
408
412
|
const u = new d(c).multipliedBy(1 - i / 100).toFixed(0), l = [O(o, { size: 32 }), e];
|
|
409
|
-
return [t, [[
|
|
410
|
-
},
|
|
413
|
+
return [t, [[s, n, l], [a, u]], r];
|
|
414
|
+
}, ms = ({
|
|
411
415
|
receiveAssetAddress: t,
|
|
412
416
|
assets: e,
|
|
413
|
-
swapData:
|
|
414
|
-
slippage:
|
|
417
|
+
swapData: s,
|
|
418
|
+
slippage: n
|
|
415
419
|
}) => {
|
|
416
420
|
const a = {
|
|
417
421
|
srcData: [],
|
|
418
422
|
destAmount: new d("0")
|
|
419
423
|
}, { srcData: r, destAmount: o } = e?.reduce((c, i) => {
|
|
420
|
-
const u =
|
|
424
|
+
const u = s?.[i.address];
|
|
421
425
|
if (!u)
|
|
422
426
|
return c;
|
|
423
427
|
const l = [
|
|
@@ -433,24 +437,24 @@ const p = (t, e) => t?.toLowerCase() === e?.toLowerCase(), Je = (t) => p(t, it),
|
|
|
433
437
|
r,
|
|
434
438
|
[
|
|
435
439
|
t,
|
|
436
|
-
o.times(1 -
|
|
440
|
+
o.times(1 - n / 100).toFixed(0, d.ROUND_DOWN)
|
|
437
441
|
]
|
|
438
442
|
];
|
|
439
|
-
},
|
|
443
|
+
}, Ee = ({
|
|
440
444
|
assetAddress: t,
|
|
441
445
|
swapQuotes: e,
|
|
442
|
-
swapParams:
|
|
443
|
-
slippageToleranceForContractTransaction:
|
|
446
|
+
swapParams: s,
|
|
447
|
+
slippageToleranceForContractTransaction: n,
|
|
444
448
|
routerKey: a
|
|
445
449
|
}) => {
|
|
446
|
-
if (!
|
|
450
|
+
if (!s)
|
|
447
451
|
return {
|
|
448
452
|
supportedAsset: t,
|
|
449
453
|
withdrawData: "",
|
|
450
454
|
slippageTolerance: BigInt(0)
|
|
451
455
|
};
|
|
452
|
-
const { srcData: r, dstData: o } =
|
|
453
|
-
const m = e?.[
|
|
456
|
+
const { srcData: r, dstData: o } = s, c = r.map(({ asset: l, amount: g }) => {
|
|
457
|
+
const m = e?.[ge({
|
|
454
458
|
sourceAddress: l,
|
|
455
459
|
amount: g.toString()
|
|
456
460
|
})]?.find((f) => f.routerKey === a);
|
|
@@ -463,48 +467,48 @@ const p = (t, e) => t?.toLowerCase() === e?.toLowerCase(), Je = (t) => p(t, it),
|
|
|
463
467
|
}
|
|
464
468
|
};
|
|
465
469
|
}), i = T(
|
|
466
|
-
|
|
470
|
+
pt,
|
|
467
471
|
[c]
|
|
468
|
-
), u = T(
|
|
472
|
+
), u = T(lt, [
|
|
469
473
|
{
|
|
470
474
|
encodedSrcData: i,
|
|
471
475
|
dstData: {
|
|
472
476
|
dstAddress: o.asset,
|
|
473
477
|
dstAmount: o.amount
|
|
474
478
|
},
|
|
475
|
-
slippage:
|
|
479
|
+
slippage: n
|
|
476
480
|
}
|
|
477
481
|
]);
|
|
478
482
|
return {
|
|
479
483
|
supportedAsset: t,
|
|
480
484
|
withdrawData: u,
|
|
481
|
-
slippageTolerance:
|
|
485
|
+
slippageTolerance: n
|
|
482
486
|
};
|
|
483
|
-
},
|
|
487
|
+
}, ys = ({
|
|
484
488
|
chainId: t,
|
|
485
489
|
txHash: e,
|
|
486
|
-
error:
|
|
490
|
+
error: s
|
|
487
491
|
}) => {
|
|
488
|
-
if (t !== I.id || !e || !
|
|
492
|
+
if (t !== I.id || !e || !s)
|
|
489
493
|
return !1;
|
|
490
|
-
const
|
|
491
|
-
return /\bNo Result\b/i.test(
|
|
492
|
-
},
|
|
494
|
+
const n = s instanceof Error ? s.message : String(s);
|
|
495
|
+
return /\bNo Result\b/i.test(n);
|
|
496
|
+
}, gs = ({
|
|
493
497
|
chainId: t,
|
|
494
498
|
action: e,
|
|
495
|
-
isRabbyWallet:
|
|
496
|
-
}) => e === "update_ondo_prices" && t === I.id &&
|
|
499
|
+
isRabbyWallet: s
|
|
500
|
+
}) => e === "update_ondo_prices" && t === I.id && s ? mt : t ? yt[t] ?? 0 : 0, As = (t, e) => At[e]?.nativeTokenSymbol === t, Es = ({
|
|
497
501
|
nativeTokenBalance: t,
|
|
498
502
|
tokenDecimals: e,
|
|
499
|
-
gasPrice:
|
|
503
|
+
gasPrice: s
|
|
500
504
|
}) => {
|
|
501
|
-
const
|
|
502
|
-
|
|
505
|
+
const n = new d(s).multipliedBy(gt).shiftedBy(-e), a = new d(t).minus(
|
|
506
|
+
n
|
|
503
507
|
);
|
|
504
508
|
return a.gt("0") ? a : new d("0");
|
|
505
|
-
},
|
|
509
|
+
}, hs = (t) => Et.includes(t), fs = (t) => {
|
|
506
510
|
const e = Object.values(t).reduce(
|
|
507
|
-
(
|
|
511
|
+
(s, { type: n }) => (s[n] = s[n] + 1, s),
|
|
508
512
|
{ string: 0, number: 0 }
|
|
509
513
|
);
|
|
510
514
|
if (e.string > 10)
|
|
@@ -512,198 +516,198 @@ const p = (t, e) => t?.toLowerCase() === e?.toLowerCase(), Je = (t) => p(t, it),
|
|
|
512
516
|
if (e.number > 40)
|
|
513
517
|
throw new Error("logger params must contain up to 40 numeric values");
|
|
514
518
|
return !0;
|
|
515
|
-
},
|
|
519
|
+
}, he = (t, e = 150) => t.length > e ? t.substring(0, e) : t, tt = () => ({
|
|
516
520
|
...Z().stringErrors,
|
|
517
|
-
...
|
|
518
|
-
}),
|
|
521
|
+
...ht
|
|
522
|
+
}), fe = () => [
|
|
519
523
|
...Object.keys(tt()),
|
|
520
524
|
...Object.keys(k)
|
|
521
|
-
],
|
|
522
|
-
const
|
|
523
|
-
return [...e ??
|
|
524
|
-
},
|
|
525
|
-
const { selectorErrors: e } = Z(),
|
|
526
|
-
if (
|
|
527
|
-
return { title:
|
|
525
|
+
], Se = /^dh\d+$/i, Te = (t, e) => Se.test(e) ? new RegExp(`\\b${e}\\b`, "i").test(t) : t.includes(e.toLowerCase()), M = (t, e) => {
|
|
526
|
+
const s = t.toLowerCase();
|
|
527
|
+
return [...e ?? fe()].sort((n, a) => a.length - n.length).find((n) => Te(s, n));
|
|
528
|
+
}, P = (t) => tt()[t] ?? k[t], we = /\b0x[0-9a-f]{8}\b/i, _e = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), be = (t) => {
|
|
529
|
+
const { selectorErrors: e } = Z(), s = t.match(we)?.[0]?.toLowerCase(), n = s ? e[s] : void 0;
|
|
530
|
+
if (n)
|
|
531
|
+
return { title: n.title, hint: n.hint };
|
|
528
532
|
const a = Object.values(e).find(
|
|
529
533
|
(r) => new RegExp(
|
|
530
|
-
`\\b${
|
|
534
|
+
`\\b${_e(r.signature.split("(")[0] ?? "")}\\b`
|
|
531
535
|
).test(t)
|
|
532
536
|
);
|
|
533
537
|
return a ? { title: a.title, hint: a.hint } : void 0;
|
|
534
|
-
},
|
|
538
|
+
}, Ss = ({
|
|
535
539
|
errorMessage: t,
|
|
536
540
|
abiErrors: e
|
|
537
541
|
}) => {
|
|
538
542
|
if (!t || t.includes("User rejected"))
|
|
539
543
|
return null;
|
|
540
|
-
const
|
|
541
|
-
if (
|
|
542
|
-
const o =
|
|
544
|
+
const s = e.find((o) => t.includes(o));
|
|
545
|
+
if (s) {
|
|
546
|
+
const o = M(s);
|
|
543
547
|
if (o)
|
|
544
|
-
return
|
|
548
|
+
return P(o);
|
|
545
549
|
}
|
|
546
|
-
const
|
|
547
|
-
if (
|
|
548
|
-
return
|
|
549
|
-
const a =
|
|
550
|
+
const n = M(t);
|
|
551
|
+
if (n)
|
|
552
|
+
return P(n);
|
|
553
|
+
const a = be(t);
|
|
550
554
|
if (a)
|
|
551
555
|
return a;
|
|
552
|
-
const [r] = t.split(
|
|
556
|
+
const [r] = t.split(s ? "." : "Contract").map((o) => o.trim());
|
|
553
557
|
return {
|
|
554
558
|
title: "Transaction failed",
|
|
555
|
-
hint: `${
|
|
559
|
+
hint: `${he(r ?? "")} ${s ? `: ${s}` : ""}`
|
|
556
560
|
};
|
|
557
|
-
},
|
|
561
|
+
}, Ts = (t) => typeof t == "number" && Number.isFinite(t), ws = (t) => typeof t == "bigint" && t !== BigInt(0), De = (t, e = V) => new d(t).shiftedBy(-e).toNumber(), Ie = (t) => !isNaN(parseFloat(t)) && !isNaN(t), Ne = ({
|
|
558
562
|
value: t,
|
|
559
563
|
minimumFractionDigits: e = 2,
|
|
560
|
-
maximumFractionDigits:
|
|
561
|
-
compact:
|
|
564
|
+
maximumFractionDigits: s = 2,
|
|
565
|
+
compact: n = !1,
|
|
562
566
|
normalize: a = !1
|
|
563
567
|
}) => new Intl.NumberFormat("en-US", {
|
|
564
568
|
style: "currency",
|
|
565
569
|
currency: "USD",
|
|
566
|
-
notation:
|
|
570
|
+
notation: n ? "compact" : void 0,
|
|
567
571
|
minimumFractionDigits: e,
|
|
568
|
-
maximumFractionDigits:
|
|
569
|
-
}).format(a ?
|
|
572
|
+
maximumFractionDigits: s
|
|
573
|
+
}).format(a ? De(t) : Number(t)), U = (t) => Ie(t) ? new d(t).toFixed() : "", $ = ["₀", "₁", "₂", "₃", "₄", "₅", "₆", "₇", "₈", "₉"], Re = ({
|
|
570
574
|
value: t,
|
|
571
575
|
decimals: e = 4
|
|
572
576
|
}) => {
|
|
573
|
-
const
|
|
574
|
-
if (
|
|
575
|
-
return
|
|
576
|
-
const a = (/e/i.test(t.toString()) ? parseFloat(t.toString()).toFixed(
|
|
577
|
+
const s = new d(t);
|
|
578
|
+
if (s.isGreaterThan(1) || s.isZero())
|
|
579
|
+
return U(s.toFixed(e));
|
|
580
|
+
const a = (/e/i.test(t.toString()) ? parseFloat(t.toString()).toFixed(V) : t.toString()).match(/^0\.(0+)(\d+)$/);
|
|
577
581
|
if (a) {
|
|
578
582
|
const [, r, o] = a;
|
|
579
|
-
if (r.length >= e && r.length <
|
|
580
|
-
return `0.0${
|
|
583
|
+
if (r.length >= e && r.length < $.length)
|
|
584
|
+
return `0.0${$[r.length]}${o.slice(0, 3)}`;
|
|
581
585
|
}
|
|
582
|
-
return
|
|
583
|
-
},
|
|
584
|
-
const
|
|
585
|
-
return
|
|
586
|
-
},
|
|
586
|
+
return U(s.toFixed(e));
|
|
587
|
+
}, Oe = (t, e = 0) => `${t.toLocaleString("en-US", { maximumFractionDigits: e })}%`, _s = (t) => t.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), bs = (t, e, s = 0) => {
|
|
588
|
+
const n = Ae(+t, e);
|
|
589
|
+
return Oe(n, s);
|
|
590
|
+
}, Ds = ({
|
|
587
591
|
currency: t,
|
|
588
592
|
value: e
|
|
589
|
-
}) => t === "USD" ?
|
|
593
|
+
}) => t === "USD" ? Ne({ value: e }) : `${ft[t]} ${Re({
|
|
590
594
|
value: e,
|
|
591
|
-
decimals:
|
|
592
|
-
})}`,
|
|
595
|
+
decimals: St[t]
|
|
596
|
+
})}`, Ce = (t, e) => new d(
|
|
593
597
|
new d(t).toFixed(e, d.ROUND_DOWN)
|
|
594
|
-
).toString(),
|
|
598
|
+
).toString(), xe = (t, e = 3, s = 2) => {
|
|
595
599
|
if (t.length <= 5)
|
|
596
600
|
return t;
|
|
597
|
-
const
|
|
598
|
-
return t.length <= e +
|
|
599
|
-
},
|
|
601
|
+
const n = "...";
|
|
602
|
+
return t.length <= e + s + n.length ? t : `${t.slice(0, e)}${n}${t.slice(-s)}`;
|
|
603
|
+
}, Is = ({
|
|
600
604
|
balance: t,
|
|
601
605
|
symbol: e,
|
|
602
|
-
precision:
|
|
603
|
-
truncateSymbol:
|
|
604
|
-
}) => `${
|
|
606
|
+
precision: s,
|
|
607
|
+
truncateSymbol: n
|
|
608
|
+
}) => `${Ce(t, s)} ${n ? xe(e) : e}`, Ns = (t) => {
|
|
605
609
|
if (!t)
|
|
606
610
|
return;
|
|
607
611
|
const e = t.match(/0x[a-fA-F0-9]{64}/);
|
|
608
612
|
if (!e)
|
|
609
613
|
return;
|
|
610
|
-
const
|
|
611
|
-
return `${
|
|
612
|
-
},
|
|
614
|
+
const s = e[0];
|
|
615
|
+
return `${s.slice(0, 4)}...${s.slice(-3)}`;
|
|
616
|
+
}, Rs = (t) => p(bt, t) || p(Dt, t), Os = (t) => Nt.some(
|
|
613
617
|
(e) => p(e, t)
|
|
614
|
-
),
|
|
618
|
+
), Cs = (t) => Tt[t.toLowerCase()] ?? {
|
|
615
619
|
symbol: "",
|
|
616
620
|
decimals: 18,
|
|
617
|
-
address:
|
|
618
|
-
},
|
|
621
|
+
address: N
|
|
622
|
+
}, xs = (t) => p(t, It) ? wt : _t, Be = (t) => `eth_${t}`, Bs = ({
|
|
619
623
|
action: t,
|
|
620
624
|
log: e,
|
|
621
|
-
symbol:
|
|
622
|
-
vaultAddress:
|
|
625
|
+
symbol: s,
|
|
626
|
+
vaultAddress: n,
|
|
623
627
|
chainId: a
|
|
624
628
|
}) => {
|
|
625
629
|
const r = {
|
|
626
|
-
[_.SYMBOL.NAME]:
|
|
630
|
+
[_.SYMBOL.NAME]: s,
|
|
627
631
|
[_.CHAIN_ID.NAME]: a,
|
|
628
|
-
[_.ADDRESS.NAME]:
|
|
632
|
+
[_.ADDRESS.NAME]: Be(n)
|
|
629
633
|
};
|
|
630
634
|
Rt[t].forEach((o) => {
|
|
631
635
|
e?.(o, r);
|
|
632
636
|
});
|
|
633
|
-
},
|
|
637
|
+
}, Ls = (t) => xt.some((e) => p(e, t)), Ms = (t) => Ot[t.toLowerCase()] ?? {
|
|
634
638
|
symbol: "",
|
|
635
639
|
decimals: 18,
|
|
636
|
-
address:
|
|
637
|
-
},
|
|
638
|
-
|
|
639
|
-
const
|
|
640
|
-
if (p(t,
|
|
640
|
+
address: N
|
|
641
|
+
}, Ps = (t) => Ct[t.toLowerCase()], Le = "0x3333333333333333333333333333333333333333";
|
|
642
|
+
it.id + "", Ut.address, ot.id + "", Pt.address, rt.id + "", Mt.address, at.id + "", Lt.address, I.id + "", Bt.address, H.id + "", q.address;
|
|
643
|
+
const Me = "0x2222222222222222222222222222222222222222", v = BigInt("0x2000000000000000000000000000000000000000"), Pe = 10000n, Ue = (t) => p(t, Le), $e = (t) => {
|
|
644
|
+
if (p(t, Me))
|
|
641
645
|
return !0;
|
|
642
646
|
try {
|
|
643
647
|
const e = BigInt(t);
|
|
644
|
-
return e >=
|
|
648
|
+
return e >= v && e < v + Pe;
|
|
645
649
|
} catch {
|
|
646
650
|
return !1;
|
|
647
651
|
}
|
|
648
|
-
},
|
|
649
|
-
const
|
|
650
|
-
|
|
652
|
+
}, Us = (t) => Ue(t) || $e(t), $s = () => q, vs = /* @__PURE__ */ new Map(), et = (t, e) => !e || e.size === 0 ? t : t.map((s) => {
|
|
653
|
+
const n = e.get(
|
|
654
|
+
s.supportedAsset.toLowerCase()
|
|
651
655
|
);
|
|
652
|
-
return
|
|
653
|
-
...
|
|
654
|
-
withdrawData:
|
|
655
|
-
slippageTolerance:
|
|
656
|
-
} :
|
|
657
|
-
}),
|
|
656
|
+
return n ? {
|
|
657
|
+
...s,
|
|
658
|
+
withdrawData: n.withdrawData,
|
|
659
|
+
slippageTolerance: n.slippageTolerance
|
|
660
|
+
} : s;
|
|
661
|
+
}), ve = (t) => {
|
|
658
662
|
const e = t.find(
|
|
659
|
-
({ swapQuotes:
|
|
663
|
+
({ swapQuotes: s }) => s
|
|
660
664
|
);
|
|
661
665
|
return e?.swapQuotes ? Object.values(e.swapQuotes)[0]?.map(
|
|
662
|
-
({ routerKey:
|
|
666
|
+
({ routerKey: s }) => s
|
|
663
667
|
) ?? [] : [];
|
|
664
|
-
},
|
|
665
|
-
supportedAsset:
|
|
668
|
+
}, Fe = (t, e, s) => t.map(({ asset: n, swapParams: a, swapQuotes: r }) => !a || !r ? {
|
|
669
|
+
supportedAsset: n,
|
|
666
670
|
withdrawData: "",
|
|
667
|
-
slippageTolerance:
|
|
668
|
-
} :
|
|
669
|
-
assetAddress:
|
|
671
|
+
slippageTolerance: s
|
|
672
|
+
} : Ee({
|
|
673
|
+
assetAddress: n,
|
|
670
674
|
swapQuotes: r,
|
|
671
675
|
swapParams: a,
|
|
672
|
-
slippageToleranceForContractTransaction:
|
|
676
|
+
slippageToleranceForContractTransaction: s,
|
|
673
677
|
routerKey: e
|
|
674
|
-
})),
|
|
678
|
+
})), Ye = async (t, e, s, n, a, r) => {
|
|
675
679
|
for (const o of t) {
|
|
676
680
|
const c = et(
|
|
677
|
-
|
|
681
|
+
Fe(
|
|
678
682
|
e,
|
|
679
683
|
o,
|
|
680
|
-
|
|
684
|
+
s
|
|
681
685
|
),
|
|
682
686
|
r
|
|
683
|
-
), { error: i } = await
|
|
687
|
+
), { error: i } = await n(...a, c);
|
|
684
688
|
if (!i)
|
|
685
689
|
return c;
|
|
686
690
|
}
|
|
687
691
|
return null;
|
|
688
|
-
},
|
|
689
|
-
const
|
|
692
|
+
}, Fs = (t, e, s) => {
|
|
693
|
+
const n = (t ?? []).map((a) => ({
|
|
690
694
|
supportedAsset: a,
|
|
691
695
|
withdrawData: "",
|
|
692
696
|
slippageTolerance: e
|
|
693
697
|
}));
|
|
694
|
-
return et(
|
|
695
|
-
},
|
|
698
|
+
return et(n, s);
|
|
699
|
+
}, Ys = async (t, e, s, n, a) => {
|
|
696
700
|
for (const r of t) {
|
|
697
701
|
const o = J(r);
|
|
698
702
|
try {
|
|
699
|
-
const c = await e(r), i =
|
|
703
|
+
const c = await e(r), i = ve(
|
|
700
704
|
c
|
|
701
|
-
), u = await
|
|
705
|
+
), u = await Ye(
|
|
702
706
|
i,
|
|
703
707
|
c,
|
|
704
708
|
o,
|
|
705
|
-
n,
|
|
706
709
|
s,
|
|
710
|
+
n,
|
|
707
711
|
a
|
|
708
712
|
);
|
|
709
713
|
if (u)
|
|
@@ -718,9 +722,9 @@ const Le = "0x2222222222222222222222222222222222222222", $ = BigInt("0x200000000
|
|
|
718
722
|
}
|
|
719
723
|
}
|
|
720
724
|
return null;
|
|
721
|
-
},
|
|
722
|
-
fetchAaveSwapParams:
|
|
723
|
-
fetchAaveSwapQuotes:
|
|
725
|
+
}, Gs = async (t, e, {
|
|
726
|
+
fetchAaveSwapParams: s,
|
|
727
|
+
fetchAaveSwapQuotes: n,
|
|
724
728
|
withdrawAmountD18: a,
|
|
725
729
|
slippage: r
|
|
726
730
|
}) => Promise.all(
|
|
@@ -728,12 +732,12 @@ const Le = "0x2222222222222222222222222222222222222222", $ = BigInt("0x200000000
|
|
|
728
732
|
if (!p(o, e))
|
|
729
733
|
return { asset: o };
|
|
730
734
|
try {
|
|
731
|
-
const i = await
|
|
735
|
+
const i = await s({
|
|
732
736
|
withdrawAmountD18: a,
|
|
733
737
|
slippage: r
|
|
734
738
|
});
|
|
735
739
|
if (i?.srcData.length) {
|
|
736
|
-
const u = await
|
|
740
|
+
const u = await n({
|
|
737
741
|
swapParams: i,
|
|
738
742
|
slippage: r
|
|
739
743
|
});
|
|
@@ -744,15 +748,15 @@ const Le = "0x2222222222222222222222222222222222222222", $ = BigInt("0x200000000
|
|
|
744
748
|
return console.error(i), { asset: o };
|
|
745
749
|
}
|
|
746
750
|
})
|
|
747
|
-
),
|
|
751
|
+
), F = (t) => Math.round(t * 100) / 100, Ws = ({
|
|
748
752
|
maxSlippage: t,
|
|
749
|
-
candidates: e =
|
|
753
|
+
candidates: e = $t
|
|
750
754
|
}) => {
|
|
751
755
|
if (!Number.isFinite(t) || t <= 0)
|
|
752
756
|
return [];
|
|
753
|
-
const
|
|
754
|
-
return a.add(
|
|
755
|
-
},
|
|
757
|
+
const s = F(Math.min(t, 100)), n = e.filter((r) => r > 0 && r <= s).map(F), a = new Set(n);
|
|
758
|
+
return a.add(s), a.add(t), Array.from(a).sort((r, o) => r - o);
|
|
759
|
+
}, x = 1000000000000000000n, Ge = 1000000n, Y = 10000n, G = 100n, Hs = (t) => ({
|
|
756
760
|
quotes: t.quotes.map(
|
|
757
761
|
(e) => ({
|
|
758
762
|
chainId: y(e.chainId, "chainId"),
|
|
@@ -767,53 +771,53 @@ const Le = "0x2222222222222222222222222222222222222222", $ = BigInt("0x200000000
|
|
|
767
771
|
})
|
|
768
772
|
),
|
|
769
773
|
signatures: t.signatures.map(S)
|
|
770
|
-
}),
|
|
771
|
-
const
|
|
774
|
+
}), st = (t, e) => t * e / x, We = x, ks = (t, e) => !!e && st(t, e) < We, He = (t, e, s) => {
|
|
775
|
+
const n = BigInt(Math.max(0, Math.round(s * 100))), a = n > G ? G : n, r = Y - a, c = st(t, e) * r * Ge, i = Y * x;
|
|
772
776
|
return (c + i - 1n) / i;
|
|
773
|
-
},
|
|
777
|
+
}, ke = (t, e) => ({
|
|
774
778
|
chainId: e,
|
|
775
779
|
attestationId: y(t.attestationId, "attestationId"),
|
|
776
|
-
userId:
|
|
780
|
+
userId: L(t.userId),
|
|
777
781
|
asset: t.assetAddress,
|
|
778
782
|
price: y(t.price, "price"),
|
|
779
783
|
quantity: y(t.tokenAmount, "tokenAmount"),
|
|
780
784
|
expiration: y(t.expiration, "expiration"),
|
|
781
785
|
side: Number(t.side),
|
|
782
|
-
additionalData:
|
|
783
|
-
}),
|
|
786
|
+
additionalData: L(t.additionalData)
|
|
787
|
+
}), Vs = ({
|
|
784
788
|
attestation: t,
|
|
785
789
|
chainId: e,
|
|
786
|
-
slippagePercent:
|
|
790
|
+
slippagePercent: s
|
|
787
791
|
}) => {
|
|
788
|
-
const
|
|
792
|
+
const n = ke(t, e);
|
|
789
793
|
return T(qt, [
|
|
790
794
|
{
|
|
791
|
-
attestationSignature:
|
|
792
|
-
quote:
|
|
793
|
-
amountOutMinimum:
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
795
|
+
attestationSignature: me(t.signature),
|
|
796
|
+
quote: n,
|
|
797
|
+
amountOutMinimum: He(
|
|
798
|
+
n.quantity,
|
|
799
|
+
n.price,
|
|
800
|
+
s
|
|
797
801
|
)
|
|
798
802
|
}
|
|
799
803
|
]);
|
|
800
|
-
},
|
|
801
|
-
(
|
|
804
|
+
}, qs = (t) => [...t.reduce(
|
|
805
|
+
(s, n) => s.has(n.accountId) ? s : s.set(n.accountId, n),
|
|
802
806
|
/* @__PURE__ */ new Map()
|
|
803
|
-
).values()].map(({ accountId:
|
|
804
|
-
accountId:
|
|
805
|
-
marketId:
|
|
807
|
+
).values()].map(({ accountId: s, marketId: n }) => ({
|
|
808
|
+
accountId: s,
|
|
809
|
+
marketId: n,
|
|
806
810
|
collaterals: t.filter(
|
|
807
|
-
(a) => a.accountId ===
|
|
811
|
+
(a) => a.accountId === s && !a.isDebt
|
|
808
812
|
),
|
|
809
813
|
debt: t.find(
|
|
810
|
-
(a) => a.accountId ===
|
|
814
|
+
(a) => a.accountId === s && a.isDebt
|
|
811
815
|
)
|
|
812
|
-
})),
|
|
816
|
+
})), Ks = ({
|
|
813
817
|
collateral: t,
|
|
814
818
|
dytmOffice: e,
|
|
815
|
-
processor:
|
|
816
|
-
gmToken:
|
|
819
|
+
processor: s,
|
|
820
|
+
gmToken: n,
|
|
817
821
|
ondoGMSwap: a,
|
|
818
822
|
usdc: r,
|
|
819
823
|
gmAmount: o,
|
|
@@ -832,7 +836,7 @@ const Le = "0x2222222222222222222222222222222222222222", $ = BigInt("0x200000000
|
|
|
832
836
|
{
|
|
833
837
|
account: t.accountId,
|
|
834
838
|
tokenId: t.tokenId,
|
|
835
|
-
receiver:
|
|
839
|
+
receiver: s,
|
|
836
840
|
assets: 0n,
|
|
837
841
|
shares: w,
|
|
838
842
|
extraData: "0x"
|
|
@@ -842,7 +846,7 @@ const Le = "0x2222222222222222222222222222222222222222", $ = BigInt("0x200000000
|
|
|
842
846
|
},
|
|
843
847
|
{
|
|
844
848
|
// 2 · approve the GM token to Ondo's swap contract
|
|
845
|
-
to:
|
|
849
|
+
to: n,
|
|
846
850
|
data: A({
|
|
847
851
|
abi: K,
|
|
848
852
|
functionName: "approve",
|
|
@@ -853,15 +857,15 @@ const Le = "0x2222222222222222222222222222222222222222", $ = BigInt("0x200000000
|
|
|
853
857
|
// 3 · redeem GM -> USDC with the signed attestation
|
|
854
858
|
to: a,
|
|
855
859
|
data: A({
|
|
856
|
-
abi:
|
|
860
|
+
abi: jt,
|
|
857
861
|
functionName: "swapExactInWithAttestation",
|
|
858
|
-
args: [
|
|
862
|
+
args: [n, o, r, c, i, u]
|
|
859
863
|
})
|
|
860
864
|
}
|
|
861
|
-
],
|
|
865
|
+
], js = ({
|
|
862
866
|
collateral: t,
|
|
863
867
|
dytmOffice: e,
|
|
864
|
-
processor:
|
|
868
|
+
processor: s
|
|
865
869
|
}) => ({
|
|
866
870
|
to: e,
|
|
867
871
|
data: A({
|
|
@@ -871,31 +875,31 @@ const Le = "0x2222222222222222222222222222222222222222", $ = BigInt("0x200000000
|
|
|
871
875
|
{
|
|
872
876
|
account: t.accountId,
|
|
873
877
|
tokenId: t.tokenId,
|
|
874
|
-
receiver:
|
|
878
|
+
receiver: s,
|
|
875
879
|
assets: 0n,
|
|
876
880
|
shares: w,
|
|
877
881
|
extraData: "0x"
|
|
878
882
|
}
|
|
879
883
|
]
|
|
880
884
|
})
|
|
881
|
-
}),
|
|
885
|
+
}), Xs = ({
|
|
882
886
|
accountId: t,
|
|
883
887
|
debtKey: e,
|
|
884
|
-
dytmOffice:
|
|
885
|
-
usdc:
|
|
888
|
+
dytmOffice: s,
|
|
889
|
+
usdc: n
|
|
886
890
|
}) => [
|
|
887
891
|
{
|
|
888
892
|
// approve USDC to the DYTM Office for the repay
|
|
889
|
-
to:
|
|
893
|
+
to: n,
|
|
890
894
|
data: A({
|
|
891
895
|
abi: K,
|
|
892
896
|
functionName: "approve",
|
|
893
|
-
args: [
|
|
897
|
+
args: [s, w]
|
|
894
898
|
})
|
|
895
899
|
},
|
|
896
900
|
{
|
|
897
901
|
// repay the slice's whole USDC debt
|
|
898
|
-
to:
|
|
902
|
+
to: s,
|
|
899
903
|
data: A({
|
|
900
904
|
abi: C,
|
|
901
905
|
functionName: "repay",
|
|
@@ -913,104 +917,107 @@ const Le = "0x2222222222222222222222222222222222222222", $ = BigInt("0x200000000
|
|
|
913
917
|
]
|
|
914
918
|
})
|
|
915
919
|
}
|
|
916
|
-
],
|
|
920
|
+
], zs = ({
|
|
917
921
|
actions: t,
|
|
918
922
|
outputAsset: e,
|
|
919
|
-
minOutputAmount:
|
|
920
|
-
}) => T(
|
|
921
|
-
{ actions: t, outputAsset: e, minOutputAmount:
|
|
922
|
-
]),
|
|
923
|
+
minOutputAmount: s
|
|
924
|
+
}) => T(Xt, [
|
|
925
|
+
{ actions: t, outputAsset: e, minOutputAmount: s }
|
|
926
|
+
]), W = /* @__PURE__ */ new Set(), Qs = (t) => {
|
|
923
927
|
const e = t?.message;
|
|
924
|
-
!e ||
|
|
928
|
+
!e || W.has(e) || (W.add(e), console.warn(e));
|
|
925
929
|
};
|
|
926
930
|
export {
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
931
|
+
As as $,
|
|
932
|
+
ss as A,
|
|
933
|
+
ye as B,
|
|
930
934
|
Z as C,
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
935
|
+
os as D,
|
|
936
|
+
vs as E,
|
|
937
|
+
M as F,
|
|
938
|
+
Cs as G,
|
|
939
|
+
xs as H,
|
|
940
|
+
Ms as I,
|
|
941
|
+
Ps as J,
|
|
942
|
+
$s as K,
|
|
943
|
+
Es as L,
|
|
944
|
+
We as M,
|
|
945
|
+
Ae as N,
|
|
946
|
+
us as O,
|
|
947
|
+
gs as P,
|
|
948
|
+
J as Q,
|
|
949
|
+
Ns as R,
|
|
950
|
+
qs as S,
|
|
947
951
|
D as T,
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
952
|
+
as as U,
|
|
953
|
+
Os as V,
|
|
954
|
+
Rs as W,
|
|
955
|
+
Ls as X,
|
|
956
|
+
Us as Y,
|
|
953
957
|
Ue as Z,
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
958
|
+
$e as _,
|
|
959
|
+
ce as a,
|
|
960
|
+
cs as a0,
|
|
961
|
+
hs as a1,
|
|
962
|
+
ks as a2,
|
|
963
|
+
Qs as a3,
|
|
964
|
+
Bs as a4,
|
|
965
|
+
ke as a5,
|
|
966
|
+
Hs as a6,
|
|
967
|
+
et as a7,
|
|
968
|
+
ds as a8,
|
|
969
|
+
Ss as a9,
|
|
970
|
+
_s as aA,
|
|
971
|
+
U as aB,
|
|
972
|
+
is as aa,
|
|
973
|
+
ns as ab,
|
|
974
|
+
ys as ac,
|
|
975
|
+
rs as ad,
|
|
976
|
+
y as ae,
|
|
977
|
+
L as af,
|
|
978
|
+
Be as ag,
|
|
979
|
+
xe as ah,
|
|
980
|
+
Ye as ai,
|
|
981
|
+
Ys as aj,
|
|
982
|
+
fs as ak,
|
|
983
|
+
Vt as al,
|
|
984
|
+
Xe as am,
|
|
985
|
+
es as an,
|
|
986
|
+
Ts as ao,
|
|
987
|
+
p as ap,
|
|
988
|
+
Ne as aq,
|
|
989
|
+
ws as ar,
|
|
990
|
+
De as as,
|
|
991
|
+
Ze as at,
|
|
992
|
+
Qe as au,
|
|
993
|
+
Le as av,
|
|
994
|
+
Re as aw,
|
|
995
|
+
ts as ax,
|
|
996
|
+
Oe as ay,
|
|
997
|
+
Ie as az,
|
|
998
|
+
me as b,
|
|
999
|
+
Ee as c,
|
|
1000
|
+
Fe as d,
|
|
1001
|
+
Ks as e,
|
|
1002
|
+
js as f,
|
|
1003
|
+
Xs as g,
|
|
1004
|
+
ge as h,
|
|
1005
|
+
ms as i,
|
|
1006
|
+
ls as j,
|
|
1007
|
+
ze as k,
|
|
1008
|
+
He as l,
|
|
1009
|
+
Fs as m,
|
|
1010
|
+
Vs as n,
|
|
1011
|
+
zs as o,
|
|
1012
|
+
Gs as p,
|
|
1013
|
+
Je as q,
|
|
1007
1014
|
S as r,
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1015
|
+
ve as s,
|
|
1016
|
+
de as t,
|
|
1017
|
+
Ce as u,
|
|
1018
|
+
Ds as v,
|
|
1019
|
+
bs as w,
|
|
1020
|
+
Is as x,
|
|
1021
|
+
Ws as y,
|
|
1022
|
+
ps as z
|
|
1016
1023
|
};
|