@dhedge/trading-widget 6.3.2 → 6.3.5
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/LICENSE +1 -1
- package/{contract-error-log-Ci0TIrO5.js → contract-error-log-B5cBnMzk.js} +366 -363
- package/{contract-error-log-D3UONUXl.cjs → contract-error-log-BK2h_izP.cjs} +1 -1
- package/core-kit/hooks/trading/withdraw-v2/init-step/use-init-withdraw-simulation-withdraw-data.d.ts +4 -1
- package/core-kit/utils/ondo.d.ts +2 -0
- package/index.cjs +1 -1
- package/index.js +3721 -3687
- package/package.json +1 -1
- package/utils.cjs +1 -1
- package/utils.js +69 -67
|
@@ -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 R, q as N, ar as pt, as as lt, a5 as mt, ak as yt, a3 as At, b as gt, 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 Rt, ah as _, _ as Nt, 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 g, 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", A = l && !Gt(n), m = new Headers(e);
|
|
64
|
+
o === "json" && !m.has("Accept") && m.set("Accept", B), A && !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:
|
|
70
|
+
...l && { body: A ? 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
|
-
],
|
|
295
|
-
let Q = D,
|
|
296
|
-
const Z = () => Q,
|
|
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
|
+
let Q = D, b = null;
|
|
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
|
-
},
|
|
339
|
-
|
|
340
|
-
})),
|
|
341
|
-
function
|
|
342
|
-
return
|
|
338
|
+
}, Je = () => (b ?? (b = de().then(ce).catch(() => {
|
|
339
|
+
b = null;
|
|
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,40 @@ 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] ?? R, 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
|
+
}, Ae = ({
|
|
384
384
|
sourceAddress: t,
|
|
385
385
|
amount: e
|
|
386
|
-
}) => `${t}_${e}`,
|
|
387
|
-
const
|
|
388
|
-
return { firstPart:
|
|
389
|
-
}, ge = (t, e) => t / e * 100,
|
|
386
|
+
}) => `${t}_${e}`, rs = (t, e) => {
|
|
387
|
+
const s = t.slice(0, e), n = t.slice(e);
|
|
388
|
+
return { firstPart: s, secondPart: n };
|
|
389
|
+
}, ge = (t, e) => t / e * 100, os = (t) => t < 1 ? 4 : t < 10 ? 3 : 2, is = (t, e = N) => new d(t.toString()).shiftedBy(e).toFixed(0), cs = (t, e, s, n) => new d(e).dividedBy(s).multipliedBy(t).shiftedBy(-(n || N)).toNumber(), us = (t) => BigInt(
|
|
390
390
|
new d(t || "0").shiftedBy(N).toFixed(0, d.ROUND_DOWN)
|
|
391
391
|
), J = (t) => {
|
|
392
|
-
const e = new d(0.01),
|
|
393
|
-
return BigInt(
|
|
394
|
-
},
|
|
392
|
+
const e = new d(0.01), s = new d(t), n = !s.isZero() && s.lt(e) ? e : s;
|
|
393
|
+
return BigInt(n.multipliedBy(100).toFixed(0));
|
|
394
|
+
}, ds = ({
|
|
395
395
|
chainId: t,
|
|
396
396
|
slippage: e
|
|
397
|
-
}) => t ===
|
|
397
|
+
}) => t === H.id ? BigInt(0) : J(e), ps = ({
|
|
398
398
|
vaultAddress: t,
|
|
399
399
|
swapData: e,
|
|
400
|
-
sendTokenAddress:
|
|
401
|
-
sendTokenAmount:
|
|
400
|
+
sendTokenAddress: s,
|
|
401
|
+
sendTokenAmount: n,
|
|
402
402
|
vaultDepositTokenAddress: a,
|
|
403
403
|
minVaultTokensReceivedAmount: r,
|
|
404
404
|
routerKey: o = "ONE_INCH",
|
|
@@ -406,26 +406,26 @@ const p = (t, e) => t?.toLowerCase() === e?.toLowerCase(), Je = (t) => p(t, it),
|
|
|
406
406
|
swapSlippage: i
|
|
407
407
|
}) => {
|
|
408
408
|
const u = new d(c).multipliedBy(1 - i / 100).toFixed(0), l = [O(o, { size: 32 }), e];
|
|
409
|
-
return [t, [[
|
|
410
|
-
},
|
|
409
|
+
return [t, [[s, n, l], [a, u]], r];
|
|
410
|
+
}, ls = ({
|
|
411
411
|
receiveAssetAddress: t,
|
|
412
412
|
assets: e,
|
|
413
|
-
swapData:
|
|
414
|
-
slippage:
|
|
413
|
+
swapData: s,
|
|
414
|
+
slippage: n
|
|
415
415
|
}) => {
|
|
416
416
|
const a = {
|
|
417
417
|
srcData: [],
|
|
418
418
|
destAmount: new d("0")
|
|
419
419
|
}, { srcData: r, destAmount: o } = e?.reduce((c, i) => {
|
|
420
|
-
const u =
|
|
420
|
+
const u = s?.[i.address];
|
|
421
421
|
if (!u)
|
|
422
422
|
return c;
|
|
423
423
|
const l = [
|
|
424
424
|
O(u.routerKey, { size: 32 }),
|
|
425
425
|
u.rawTransaction.data
|
|
426
|
-
],
|
|
426
|
+
], A = [i.address, i.rawBalance, l];
|
|
427
427
|
return {
|
|
428
|
-
srcData: [...c.srcData,
|
|
428
|
+
srcData: [...c.srcData, A],
|
|
429
429
|
destAmount: c.destAmount.plus(u.destinationAmount)
|
|
430
430
|
};
|
|
431
431
|
}, a) ?? a;
|
|
@@ -433,78 +433,78 @@ const p = (t, e) => t?.toLowerCase() === e?.toLowerCase(), Je = (t) => p(t, it),
|
|
|
433
433
|
r,
|
|
434
434
|
[
|
|
435
435
|
t,
|
|
436
|
-
o.times(1 -
|
|
436
|
+
o.times(1 - n / 100).toFixed(0, d.ROUND_DOWN)
|
|
437
437
|
]
|
|
438
438
|
];
|
|
439
|
-
},
|
|
439
|
+
}, Ee = ({
|
|
440
440
|
assetAddress: t,
|
|
441
441
|
swapQuotes: e,
|
|
442
|
-
swapParams:
|
|
443
|
-
slippageToleranceForContractTransaction:
|
|
442
|
+
swapParams: s,
|
|
443
|
+
slippageToleranceForContractTransaction: n,
|
|
444
444
|
routerKey: a
|
|
445
445
|
}) => {
|
|
446
|
-
if (!
|
|
446
|
+
if (!s)
|
|
447
447
|
return {
|
|
448
448
|
supportedAsset: t,
|
|
449
449
|
withdrawData: "",
|
|
450
450
|
slippageTolerance: BigInt(0)
|
|
451
451
|
};
|
|
452
|
-
const { srcData: r, dstData: o } =
|
|
453
|
-
const m = e?.[
|
|
452
|
+
const { srcData: r, dstData: o } = s, c = r.map(({ asset: l, amount: A }) => {
|
|
453
|
+
const m = e?.[Ae({
|
|
454
454
|
sourceAddress: l,
|
|
455
|
-
amount:
|
|
455
|
+
amount: A.toString()
|
|
456
456
|
})]?.find((f) => f.routerKey === a);
|
|
457
457
|
return {
|
|
458
458
|
asset: l,
|
|
459
|
-
amount:
|
|
459
|
+
amount: A,
|
|
460
460
|
swapData: {
|
|
461
461
|
routerKey: O(m?.routerKey ?? "", { size: 32 }),
|
|
462
462
|
txData: m?.rawTransaction.data ?? "0x"
|
|
463
463
|
}
|
|
464
464
|
};
|
|
465
465
|
}), i = T(
|
|
466
|
-
|
|
466
|
+
pt,
|
|
467
467
|
[c]
|
|
468
|
-
), u = T(
|
|
468
|
+
), u = T(lt, [
|
|
469
469
|
{
|
|
470
470
|
encodedSrcData: i,
|
|
471
471
|
dstData: {
|
|
472
472
|
dstAddress: o.asset,
|
|
473
473
|
dstAmount: o.amount
|
|
474
474
|
},
|
|
475
|
-
slippage:
|
|
475
|
+
slippage: n
|
|
476
476
|
}
|
|
477
477
|
]);
|
|
478
478
|
return {
|
|
479
479
|
supportedAsset: t,
|
|
480
480
|
withdrawData: u,
|
|
481
|
-
slippageTolerance:
|
|
481
|
+
slippageTolerance: n
|
|
482
482
|
};
|
|
483
|
-
},
|
|
483
|
+
}, ms = ({
|
|
484
484
|
chainId: t,
|
|
485
485
|
txHash: e,
|
|
486
|
-
error:
|
|
486
|
+
error: s
|
|
487
487
|
}) => {
|
|
488
|
-
if (t !== I.id || !e || !
|
|
488
|
+
if (t !== I.id || !e || !s)
|
|
489
489
|
return !1;
|
|
490
|
-
const
|
|
491
|
-
return /\bNo Result\b/i.test(
|
|
492
|
-
},
|
|
490
|
+
const n = s instanceof Error ? s.message : String(s);
|
|
491
|
+
return /\bNo Result\b/i.test(n);
|
|
492
|
+
}, ys = ({
|
|
493
493
|
chainId: t,
|
|
494
494
|
action: e,
|
|
495
|
-
isRabbyWallet:
|
|
496
|
-
}) => e === "update_ondo_prices" && t === I.id &&
|
|
495
|
+
isRabbyWallet: s
|
|
496
|
+
}) => e === "update_ondo_prices" && t === I.id && s ? mt : t ? yt[t] ?? 0 : 0, As = (t, e) => gt[e]?.nativeTokenSymbol === t, gs = ({
|
|
497
497
|
nativeTokenBalance: t,
|
|
498
498
|
tokenDecimals: e,
|
|
499
|
-
gasPrice:
|
|
499
|
+
gasPrice: s
|
|
500
500
|
}) => {
|
|
501
|
-
const
|
|
502
|
-
|
|
501
|
+
const n = new d(s).multipliedBy(At).shiftedBy(-e), a = new d(t).minus(
|
|
502
|
+
n
|
|
503
503
|
);
|
|
504
504
|
return a.gt("0") ? a : new d("0");
|
|
505
|
-
},
|
|
505
|
+
}, Es = (t) => Et.includes(t), hs = (t) => {
|
|
506
506
|
const e = Object.values(t).reduce(
|
|
507
|
-
(
|
|
507
|
+
(s, { type: n }) => (s[n] = s[n] + 1, s),
|
|
508
508
|
{ string: 0, number: 0 }
|
|
509
509
|
);
|
|
510
510
|
if (e.string > 10)
|
|
@@ -512,198 +512,198 @@ const p = (t, e) => t?.toLowerCase() === e?.toLowerCase(), Je = (t) => p(t, it),
|
|
|
512
512
|
if (e.number > 40)
|
|
513
513
|
throw new Error("logger params must contain up to 40 numeric values");
|
|
514
514
|
return !0;
|
|
515
|
-
},
|
|
515
|
+
}, he = (t, e = 150) => t.length > e ? t.substring(0, e) : t, tt = () => ({
|
|
516
516
|
...Z().stringErrors,
|
|
517
|
-
...
|
|
518
|
-
}),
|
|
517
|
+
...ht
|
|
518
|
+
}), fe = () => [
|
|
519
519
|
...Object.keys(tt()),
|
|
520
520
|
...Object.keys(k)
|
|
521
|
-
],
|
|
522
|
-
const
|
|
523
|
-
return [...e ??
|
|
524
|
-
},
|
|
525
|
-
const { selectorErrors: e } = Z(),
|
|
526
|
-
if (
|
|
527
|
-
return { title:
|
|
521
|
+
], 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) => {
|
|
522
|
+
const s = t.toLowerCase();
|
|
523
|
+
return [...e ?? fe()].sort((n, a) => a.length - n.length).find((n) => Te(s, n));
|
|
524
|
+
}, P = (t) => tt()[t] ?? k[t], we = /\b0x[0-9a-f]{8}\b/i, _e = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), be = (t) => {
|
|
525
|
+
const { selectorErrors: e } = Z(), s = t.match(we)?.[0]?.toLowerCase(), n = s ? e[s] : void 0;
|
|
526
|
+
if (n)
|
|
527
|
+
return { title: n.title, hint: n.hint };
|
|
528
528
|
const a = Object.values(e).find(
|
|
529
529
|
(r) => new RegExp(
|
|
530
|
-
`\\b${
|
|
530
|
+
`\\b${_e(r.signature.split("(")[0] ?? "")}\\b`
|
|
531
531
|
).test(t)
|
|
532
532
|
);
|
|
533
533
|
return a ? { title: a.title, hint: a.hint } : void 0;
|
|
534
|
-
},
|
|
534
|
+
}, fs = ({
|
|
535
535
|
errorMessage: t,
|
|
536
536
|
abiErrors: e
|
|
537
537
|
}) => {
|
|
538
538
|
if (!t || t.includes("User rejected"))
|
|
539
539
|
return null;
|
|
540
|
-
const
|
|
541
|
-
if (
|
|
542
|
-
const o =
|
|
540
|
+
const s = e.find((o) => t.includes(o));
|
|
541
|
+
if (s) {
|
|
542
|
+
const o = M(s);
|
|
543
543
|
if (o)
|
|
544
|
-
return
|
|
544
|
+
return P(o);
|
|
545
545
|
}
|
|
546
|
-
const
|
|
547
|
-
if (
|
|
548
|
-
return
|
|
549
|
-
const a =
|
|
546
|
+
const n = M(t);
|
|
547
|
+
if (n)
|
|
548
|
+
return P(n);
|
|
549
|
+
const a = be(t);
|
|
550
550
|
if (a)
|
|
551
551
|
return a;
|
|
552
|
-
const [r] = t.split(
|
|
552
|
+
const [r] = t.split(s ? "." : "Contract").map((o) => o.trim());
|
|
553
553
|
return {
|
|
554
554
|
title: "Transaction failed",
|
|
555
|
-
hint: `${
|
|
555
|
+
hint: `${he(r ?? "")} ${s ? `: ${s}` : ""}`
|
|
556
556
|
};
|
|
557
|
-
},
|
|
557
|
+
}, Ss = (t) => typeof t == "number" && Number.isFinite(t), Ts = (t) => typeof t == "bigint" && t !== BigInt(0), De = (t, e = V) => new d(t).shiftedBy(-e).toNumber(), Ie = (t) => !isNaN(parseFloat(t)) && !isNaN(t), Re = ({
|
|
558
558
|
value: t,
|
|
559
559
|
minimumFractionDigits: e = 2,
|
|
560
|
-
maximumFractionDigits:
|
|
561
|
-
compact:
|
|
560
|
+
maximumFractionDigits: s = 2,
|
|
561
|
+
compact: n = !1,
|
|
562
562
|
normalize: a = !1
|
|
563
563
|
}) => new Intl.NumberFormat("en-US", {
|
|
564
564
|
style: "currency",
|
|
565
565
|
currency: "USD",
|
|
566
|
-
notation:
|
|
566
|
+
notation: n ? "compact" : void 0,
|
|
567
567
|
minimumFractionDigits: e,
|
|
568
|
-
maximumFractionDigits:
|
|
569
|
-
}).format(a ?
|
|
568
|
+
maximumFractionDigits: s
|
|
569
|
+
}).format(a ? De(t) : Number(t)), U = (t) => Ie(t) ? new d(t).toFixed() : "", $ = ["₀", "₁", "₂", "₃", "₄", "₅", "₆", "₇", "₈", "₉"], Ne = ({
|
|
570
570
|
value: t,
|
|
571
571
|
decimals: e = 4
|
|
572
572
|
}) => {
|
|
573
|
-
const
|
|
574
|
-
if (
|
|
575
|
-
return
|
|
576
|
-
const a = (/e/i.test(t.toString()) ? parseFloat(t.toString()).toFixed(
|
|
573
|
+
const s = new d(t);
|
|
574
|
+
if (s.isGreaterThan(1) || s.isZero())
|
|
575
|
+
return U(s.toFixed(e));
|
|
576
|
+
const a = (/e/i.test(t.toString()) ? parseFloat(t.toString()).toFixed(V) : t.toString()).match(/^0\.(0+)(\d+)$/);
|
|
577
577
|
if (a) {
|
|
578
578
|
const [, r, o] = a;
|
|
579
|
-
if (r.length >= e && r.length <
|
|
580
|
-
return `0.0${
|
|
579
|
+
if (r.length >= e && r.length < $.length)
|
|
580
|
+
return `0.0${$[r.length]}${o.slice(0, 3)}`;
|
|
581
581
|
}
|
|
582
|
-
return
|
|
583
|
-
},
|
|
584
|
-
const
|
|
585
|
-
return
|
|
586
|
-
},
|
|
582
|
+
return U(s.toFixed(e));
|
|
583
|
+
}, Oe = (t, e = 0) => `${t.toLocaleString("en-US", { maximumFractionDigits: e })}%`, ws = (t) => t.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), _s = (t, e, s = 0) => {
|
|
584
|
+
const n = ge(+t, e);
|
|
585
|
+
return Oe(n, s);
|
|
586
|
+
}, bs = ({
|
|
587
587
|
currency: t,
|
|
588
588
|
value: e
|
|
589
|
-
}) => t === "USD" ?
|
|
589
|
+
}) => t === "USD" ? Re({ value: e }) : `${ft[t]} ${Ne({
|
|
590
590
|
value: e,
|
|
591
|
-
decimals:
|
|
592
|
-
})}`,
|
|
591
|
+
decimals: St[t]
|
|
592
|
+
})}`, Ce = (t, e) => new d(
|
|
593
593
|
new d(t).toFixed(e, d.ROUND_DOWN)
|
|
594
|
-
).toString(),
|
|
594
|
+
).toString(), xe = (t, e = 3, s = 2) => {
|
|
595
595
|
if (t.length <= 5)
|
|
596
596
|
return t;
|
|
597
|
-
const
|
|
598
|
-
return t.length <= e +
|
|
599
|
-
},
|
|
597
|
+
const n = "...";
|
|
598
|
+
return t.length <= e + s + n.length ? t : `${t.slice(0, e)}${n}${t.slice(-s)}`;
|
|
599
|
+
}, Ds = ({
|
|
600
600
|
balance: t,
|
|
601
601
|
symbol: e,
|
|
602
|
-
precision:
|
|
603
|
-
truncateSymbol:
|
|
604
|
-
}) => `${
|
|
602
|
+
precision: s,
|
|
603
|
+
truncateSymbol: n
|
|
604
|
+
}) => `${Ce(t, s)} ${n ? xe(e) : e}`, Is = (t) => {
|
|
605
605
|
if (!t)
|
|
606
606
|
return;
|
|
607
607
|
const e = t.match(/0x[a-fA-F0-9]{64}/);
|
|
608
608
|
if (!e)
|
|
609
609
|
return;
|
|
610
|
-
const
|
|
611
|
-
return `${
|
|
612
|
-
},
|
|
610
|
+
const s = e[0];
|
|
611
|
+
return `${s.slice(0, 4)}...${s.slice(-3)}`;
|
|
612
|
+
}, Rs = (t) => p(bt, t) || p(Dt, t), Ns = (t) => Rt.some(
|
|
613
613
|
(e) => p(e, t)
|
|
614
|
-
),
|
|
614
|
+
), Os = (t) => Tt[t.toLowerCase()] ?? {
|
|
615
615
|
symbol: "",
|
|
616
616
|
decimals: 18,
|
|
617
617
|
address: R
|
|
618
|
-
},
|
|
618
|
+
}, Cs = (t) => p(t, It) ? wt : _t, Be = (t) => `eth_${t}`, xs = ({
|
|
619
619
|
action: t,
|
|
620
620
|
log: e,
|
|
621
|
-
symbol:
|
|
622
|
-
vaultAddress:
|
|
621
|
+
symbol: s,
|
|
622
|
+
vaultAddress: n,
|
|
623
623
|
chainId: a
|
|
624
624
|
}) => {
|
|
625
625
|
const r = {
|
|
626
|
-
[
|
|
627
|
-
[
|
|
628
|
-
[
|
|
626
|
+
[_.SYMBOL.NAME]: s,
|
|
627
|
+
[_.CHAIN_ID.NAME]: a,
|
|
628
|
+
[_.ADDRESS.NAME]: Be(n)
|
|
629
629
|
};
|
|
630
|
-
|
|
630
|
+
Nt[t].forEach((o) => {
|
|
631
631
|
e?.(o, r);
|
|
632
632
|
});
|
|
633
|
-
},
|
|
633
|
+
}, Bs = (t) => xt.some((e) => p(e, t)), Ls = (t) => Ot[t.toLowerCase()] ?? {
|
|
634
634
|
symbol: "",
|
|
635
635
|
decimals: 18,
|
|
636
636
|
address: R
|
|
637
|
-
},
|
|
638
|
-
|
|
639
|
-
const
|
|
640
|
-
if (p(t,
|
|
637
|
+
}, Ms = (t) => Ct[t.toLowerCase()], Le = "0x3333333333333333333333333333333333333333";
|
|
638
|
+
it.id + "", Ut.address, ot.id + "", Pt.address, rt.id + "", Mt.address, at.id + "", Lt.address, I.id + "", Bt.address, H.id + "", q.address;
|
|
639
|
+
const Me = "0x2222222222222222222222222222222222222222", v = BigInt("0x2000000000000000000000000000000000000000"), Pe = 10000n, Ue = (t) => p(t, Le), $e = (t) => {
|
|
640
|
+
if (p(t, Me))
|
|
641
641
|
return !0;
|
|
642
642
|
try {
|
|
643
643
|
const e = BigInt(t);
|
|
644
|
-
return e >=
|
|
644
|
+
return e >= v && e < v + Pe;
|
|
645
645
|
} catch {
|
|
646
646
|
return !1;
|
|
647
647
|
}
|
|
648
|
-
},
|
|
649
|
-
const
|
|
650
|
-
|
|
648
|
+
}, Ps = (t) => Ue(t) || $e(t), Us = () => q, $s = /* @__PURE__ */ new Map(), et = (t, e) => !e || e.size === 0 ? t : t.map((s) => {
|
|
649
|
+
const n = e.get(
|
|
650
|
+
s.supportedAsset.toLowerCase()
|
|
651
651
|
);
|
|
652
|
-
return
|
|
653
|
-
...
|
|
654
|
-
withdrawData:
|
|
655
|
-
slippageTolerance:
|
|
656
|
-
} :
|
|
657
|
-
}),
|
|
652
|
+
return n ? {
|
|
653
|
+
...s,
|
|
654
|
+
withdrawData: n.withdrawData,
|
|
655
|
+
slippageTolerance: n.slippageTolerance
|
|
656
|
+
} : s;
|
|
657
|
+
}), ve = (t) => {
|
|
658
658
|
const e = t.find(
|
|
659
|
-
({ swapQuotes:
|
|
659
|
+
({ swapQuotes: s }) => s
|
|
660
660
|
);
|
|
661
661
|
return e?.swapQuotes ? Object.values(e.swapQuotes)[0]?.map(
|
|
662
|
-
({ routerKey:
|
|
662
|
+
({ routerKey: s }) => s
|
|
663
663
|
) ?? [] : [];
|
|
664
|
-
},
|
|
665
|
-
supportedAsset:
|
|
664
|
+
}, Fe = (t, e, s) => t.map(({ asset: n, swapParams: a, swapQuotes: r }) => !a || !r ? {
|
|
665
|
+
supportedAsset: n,
|
|
666
666
|
withdrawData: "",
|
|
667
|
-
slippageTolerance:
|
|
668
|
-
} :
|
|
669
|
-
assetAddress:
|
|
667
|
+
slippageTolerance: s
|
|
668
|
+
} : Ee({
|
|
669
|
+
assetAddress: n,
|
|
670
670
|
swapQuotes: r,
|
|
671
671
|
swapParams: a,
|
|
672
|
-
slippageToleranceForContractTransaction:
|
|
672
|
+
slippageToleranceForContractTransaction: s,
|
|
673
673
|
routerKey: e
|
|
674
|
-
})),
|
|
674
|
+
})), Ye = async (t, e, s, n, a, r) => {
|
|
675
675
|
for (const o of t) {
|
|
676
676
|
const c = et(
|
|
677
|
-
|
|
677
|
+
Fe(
|
|
678
678
|
e,
|
|
679
679
|
o,
|
|
680
|
-
|
|
680
|
+
s
|
|
681
681
|
),
|
|
682
682
|
r
|
|
683
|
-
), { error: i } = await
|
|
683
|
+
), { error: i } = await n(...a, c);
|
|
684
684
|
if (!i)
|
|
685
685
|
return c;
|
|
686
686
|
}
|
|
687
687
|
return null;
|
|
688
|
-
},
|
|
689
|
-
const
|
|
688
|
+
}, vs = (t, e, s) => {
|
|
689
|
+
const n = (t ?? []).map((a) => ({
|
|
690
690
|
supportedAsset: a,
|
|
691
691
|
withdrawData: "",
|
|
692
692
|
slippageTolerance: e
|
|
693
693
|
}));
|
|
694
|
-
return et(
|
|
695
|
-
},
|
|
694
|
+
return et(n, s);
|
|
695
|
+
}, Fs = async (t, e, s, n, a) => {
|
|
696
696
|
for (const r of t) {
|
|
697
697
|
const o = J(r);
|
|
698
698
|
try {
|
|
699
|
-
const c = await e(r), i =
|
|
699
|
+
const c = await e(r), i = ve(
|
|
700
700
|
c
|
|
701
|
-
), u = await
|
|
701
|
+
), u = await Ye(
|
|
702
702
|
i,
|
|
703
703
|
c,
|
|
704
704
|
o,
|
|
705
|
-
n,
|
|
706
705
|
s,
|
|
706
|
+
n,
|
|
707
707
|
a
|
|
708
708
|
);
|
|
709
709
|
if (u)
|
|
@@ -718,9 +718,9 @@ const Le = "0x2222222222222222222222222222222222222222", $ = BigInt("0x200000000
|
|
|
718
718
|
}
|
|
719
719
|
}
|
|
720
720
|
return null;
|
|
721
|
-
},
|
|
722
|
-
fetchAaveSwapParams:
|
|
723
|
-
fetchAaveSwapQuotes:
|
|
721
|
+
}, Ys = async (t, e, {
|
|
722
|
+
fetchAaveSwapParams: s,
|
|
723
|
+
fetchAaveSwapQuotes: n,
|
|
724
724
|
withdrawAmountD18: a,
|
|
725
725
|
slippage: r
|
|
726
726
|
}) => Promise.all(
|
|
@@ -728,12 +728,12 @@ const Le = "0x2222222222222222222222222222222222222222", $ = BigInt("0x200000000
|
|
|
728
728
|
if (!p(o, e))
|
|
729
729
|
return { asset: o };
|
|
730
730
|
try {
|
|
731
|
-
const i = await
|
|
731
|
+
const i = await s({
|
|
732
732
|
withdrawAmountD18: a,
|
|
733
733
|
slippage: r
|
|
734
734
|
});
|
|
735
735
|
if (i?.srcData.length) {
|
|
736
|
-
const u = await
|
|
736
|
+
const u = await n({
|
|
737
737
|
swapParams: i,
|
|
738
738
|
slippage: r
|
|
739
739
|
});
|
|
@@ -744,15 +744,15 @@ const Le = "0x2222222222222222222222222222222222222222", $ = BigInt("0x200000000
|
|
|
744
744
|
return console.error(i), { asset: o };
|
|
745
745
|
}
|
|
746
746
|
})
|
|
747
|
-
),
|
|
747
|
+
), F = (t) => Math.round(t * 100) / 100, Gs = ({
|
|
748
748
|
maxSlippage: t,
|
|
749
|
-
candidates: e =
|
|
749
|
+
candidates: e = $t
|
|
750
750
|
}) => {
|
|
751
751
|
if (!Number.isFinite(t) || t <= 0)
|
|
752
752
|
return [];
|
|
753
|
-
const
|
|
754
|
-
return a.add(
|
|
755
|
-
},
|
|
753
|
+
const s = F(Math.min(t, 100)), n = e.filter((r) => r > 0 && r <= s).map(F), a = new Set(n);
|
|
754
|
+
return a.add(s), a.add(t), Array.from(a).sort((r, o) => r - o);
|
|
755
|
+
}, x = 1000000000000000000n, Ge = 1000000n, Y = 10000n, G = 100n, Ws = (t) => ({
|
|
756
756
|
quotes: t.quotes.map(
|
|
757
757
|
(e) => ({
|
|
758
758
|
chainId: y(e.chainId, "chainId"),
|
|
@@ -767,53 +767,53 @@ const Le = "0x2222222222222222222222222222222222222222", $ = BigInt("0x200000000
|
|
|
767
767
|
})
|
|
768
768
|
),
|
|
769
769
|
signatures: t.signatures.map(S)
|
|
770
|
-
}),
|
|
771
|
-
const
|
|
770
|
+
}), st = (t, e) => t * e / x, We = x, Hs = (t, e) => !!e && st(t, e) < We, He = (t, e, s) => {
|
|
771
|
+
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
772
|
return (c + i - 1n) / i;
|
|
773
|
-
},
|
|
773
|
+
}, ke = (t, e) => ({
|
|
774
774
|
chainId: e,
|
|
775
775
|
attestationId: y(t.attestationId, "attestationId"),
|
|
776
|
-
userId:
|
|
776
|
+
userId: L(t.userId),
|
|
777
777
|
asset: t.assetAddress,
|
|
778
778
|
price: y(t.price, "price"),
|
|
779
779
|
quantity: y(t.tokenAmount, "tokenAmount"),
|
|
780
780
|
expiration: y(t.expiration, "expiration"),
|
|
781
781
|
side: Number(t.side),
|
|
782
|
-
additionalData:
|
|
783
|
-
}),
|
|
782
|
+
additionalData: L(t.additionalData)
|
|
783
|
+
}), ks = ({
|
|
784
784
|
attestation: t,
|
|
785
785
|
chainId: e,
|
|
786
|
-
slippagePercent:
|
|
786
|
+
slippagePercent: s
|
|
787
787
|
}) => {
|
|
788
|
-
const
|
|
788
|
+
const n = ke(t, e);
|
|
789
789
|
return T(qt, [
|
|
790
790
|
{
|
|
791
|
-
attestationSignature:
|
|
792
|
-
quote:
|
|
793
|
-
amountOutMinimum:
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
791
|
+
attestationSignature: me(t.signature),
|
|
792
|
+
quote: n,
|
|
793
|
+
amountOutMinimum: He(
|
|
794
|
+
n.quantity,
|
|
795
|
+
n.price,
|
|
796
|
+
s
|
|
797
797
|
)
|
|
798
798
|
}
|
|
799
799
|
]);
|
|
800
|
-
},
|
|
801
|
-
(
|
|
800
|
+
}, Vs = (t) => [...t.reduce(
|
|
801
|
+
(s, n) => s.has(n.accountId) ? s : s.set(n.accountId, n),
|
|
802
802
|
/* @__PURE__ */ new Map()
|
|
803
|
-
).values()].map(({ accountId:
|
|
804
|
-
accountId:
|
|
805
|
-
marketId:
|
|
803
|
+
).values()].map(({ accountId: s, marketId: n }) => ({
|
|
804
|
+
accountId: s,
|
|
805
|
+
marketId: n,
|
|
806
806
|
collaterals: t.filter(
|
|
807
|
-
(a) => a.accountId ===
|
|
807
|
+
(a) => a.accountId === s && !a.isDebt
|
|
808
808
|
),
|
|
809
809
|
debt: t.find(
|
|
810
|
-
(a) => a.accountId ===
|
|
810
|
+
(a) => a.accountId === s && a.isDebt
|
|
811
811
|
)
|
|
812
|
-
})),
|
|
812
|
+
})), qs = ({
|
|
813
813
|
collateral: t,
|
|
814
814
|
dytmOffice: e,
|
|
815
|
-
processor:
|
|
816
|
-
gmToken:
|
|
815
|
+
processor: s,
|
|
816
|
+
gmToken: n,
|
|
817
817
|
ondoGMSwap: a,
|
|
818
818
|
usdc: r,
|
|
819
819
|
gmAmount: o,
|
|
@@ -822,18 +822,19 @@ const Le = "0x2222222222222222222222222222222222222222", $ = BigInt("0x200000000
|
|
|
822
822
|
quote: u
|
|
823
823
|
}) => [
|
|
824
824
|
{
|
|
825
|
-
// 1 ·
|
|
825
|
+
// 1 · drain GM collateral out of the split account -> processor with the
|
|
826
|
+
// max-shares sentinel.
|
|
826
827
|
to: e,
|
|
827
|
-
data:
|
|
828
|
+
data: g({
|
|
828
829
|
abi: C,
|
|
829
830
|
functionName: "withdraw",
|
|
830
831
|
args: [
|
|
831
832
|
{
|
|
832
833
|
account: t.accountId,
|
|
833
834
|
tokenId: t.tokenId,
|
|
834
|
-
receiver:
|
|
835
|
-
assets:
|
|
836
|
-
shares:
|
|
835
|
+
receiver: s,
|
|
836
|
+
assets: 0n,
|
|
837
|
+
shares: w,
|
|
837
838
|
extraData: "0x"
|
|
838
839
|
}
|
|
839
840
|
]
|
|
@@ -841,8 +842,8 @@ const Le = "0x2222222222222222222222222222222222222222", $ = BigInt("0x200000000
|
|
|
841
842
|
},
|
|
842
843
|
{
|
|
843
844
|
// 2 · approve the GM token to Ondo's swap contract
|
|
844
|
-
to:
|
|
845
|
-
data:
|
|
845
|
+
to: n,
|
|
846
|
+
data: g({
|
|
846
847
|
abi: K,
|
|
847
848
|
functionName: "approve",
|
|
848
849
|
args: [a, o]
|
|
@@ -851,51 +852,51 @@ const Le = "0x2222222222222222222222222222222222222222", $ = BigInt("0x200000000
|
|
|
851
852
|
{
|
|
852
853
|
// 3 · redeem GM -> USDC with the signed attestation
|
|
853
854
|
to: a,
|
|
854
|
-
data:
|
|
855
|
-
abi:
|
|
855
|
+
data: g({
|
|
856
|
+
abi: jt,
|
|
856
857
|
functionName: "swapExactInWithAttestation",
|
|
857
|
-
args: [
|
|
858
|
+
args: [n, o, r, c, i, u]
|
|
858
859
|
})
|
|
859
860
|
}
|
|
860
|
-
],
|
|
861
|
+
], Ks = ({
|
|
861
862
|
collateral: t,
|
|
862
863
|
dytmOffice: e,
|
|
863
|
-
processor:
|
|
864
|
+
processor: s
|
|
864
865
|
}) => ({
|
|
865
866
|
to: e,
|
|
866
|
-
data:
|
|
867
|
+
data: g({
|
|
867
868
|
abi: C,
|
|
868
869
|
functionName: "withdraw",
|
|
869
870
|
args: [
|
|
870
871
|
{
|
|
871
872
|
account: t.accountId,
|
|
872
873
|
tokenId: t.tokenId,
|
|
873
|
-
receiver:
|
|
874
|
+
receiver: s,
|
|
874
875
|
assets: 0n,
|
|
875
|
-
shares:
|
|
876
|
+
shares: w,
|
|
876
877
|
extraData: "0x"
|
|
877
878
|
}
|
|
878
879
|
]
|
|
879
880
|
})
|
|
880
|
-
}),
|
|
881
|
+
}), js = ({
|
|
881
882
|
accountId: t,
|
|
882
883
|
debtKey: e,
|
|
883
|
-
dytmOffice:
|
|
884
|
-
usdc:
|
|
884
|
+
dytmOffice: s,
|
|
885
|
+
usdc: n
|
|
885
886
|
}) => [
|
|
886
887
|
{
|
|
887
888
|
// approve USDC to the DYTM Office for the repay
|
|
888
|
-
to:
|
|
889
|
-
data:
|
|
889
|
+
to: n,
|
|
890
|
+
data: g({
|
|
890
891
|
abi: K,
|
|
891
892
|
functionName: "approve",
|
|
892
|
-
args: [
|
|
893
|
+
args: [s, w]
|
|
893
894
|
})
|
|
894
895
|
},
|
|
895
896
|
{
|
|
896
897
|
// repay the slice's whole USDC debt
|
|
897
|
-
to:
|
|
898
|
-
data:
|
|
898
|
+
to: s,
|
|
899
|
+
data: g({
|
|
899
900
|
abi: C,
|
|
900
901
|
functionName: "repay",
|
|
901
902
|
args: [
|
|
@@ -904,7 +905,7 @@ const Le = "0x2222222222222222222222222222222222222222", $ = BigInt("0x200000000
|
|
|
904
905
|
key: e,
|
|
905
906
|
withCollateralType: 0,
|
|
906
907
|
// DytmParamStructs.TokenType.NONE
|
|
907
|
-
assets:
|
|
908
|
+
assets: w,
|
|
908
909
|
// repay all
|
|
909
910
|
shares: 0n,
|
|
910
911
|
extraData: "0x"
|
|
@@ -912,104 +913,106 @@ const Le = "0x2222222222222222222222222222222222222222", $ = BigInt("0x200000000
|
|
|
912
913
|
]
|
|
913
914
|
})
|
|
914
915
|
}
|
|
915
|
-
],
|
|
916
|
+
], Xs = ({
|
|
916
917
|
actions: t,
|
|
917
918
|
outputAsset: e,
|
|
918
|
-
minOutputAmount:
|
|
919
|
-
}) => T(
|
|
920
|
-
{ actions: t, outputAsset: e, minOutputAmount:
|
|
921
|
-
]),
|
|
919
|
+
minOutputAmount: s
|
|
920
|
+
}) => T(Xt, [
|
|
921
|
+
{ actions: t, outputAsset: e, minOutputAmount: s }
|
|
922
|
+
]), W = /* @__PURE__ */ new Set(), zs = (t) => {
|
|
922
923
|
const e = t?.message;
|
|
923
|
-
!e ||
|
|
924
|
+
!e || W.has(e) || (W.add(e), console.warn(e));
|
|
924
925
|
};
|
|
925
926
|
export {
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
927
|
+
As as $,
|
|
928
|
+
ss as A,
|
|
929
|
+
ye as B,
|
|
929
930
|
Z as C,
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
931
|
+
os as D,
|
|
932
|
+
$s as E,
|
|
933
|
+
M as F,
|
|
934
|
+
Os as G,
|
|
935
|
+
Cs as H,
|
|
936
|
+
Ls as I,
|
|
937
|
+
Ms as J,
|
|
938
|
+
Us as K,
|
|
939
|
+
gs as L,
|
|
940
|
+
We as M,
|
|
941
|
+
ge as N,
|
|
942
|
+
cs as O,
|
|
943
|
+
ys as P,
|
|
944
|
+
J as Q,
|
|
945
|
+
Is as R,
|
|
946
|
+
Vs as S,
|
|
946
947
|
D as T,
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
948
|
+
as as U,
|
|
949
|
+
Ns as V,
|
|
950
|
+
Rs as W,
|
|
951
|
+
Bs as X,
|
|
952
|
+
Ps as Y,
|
|
952
953
|
Ue as Z,
|
|
953
|
-
|
|
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
|
-
|
|
954
|
+
$e as _,
|
|
955
|
+
ce as a,
|
|
956
|
+
Es as a0,
|
|
957
|
+
Hs as a1,
|
|
958
|
+
zs as a2,
|
|
959
|
+
xs as a3,
|
|
960
|
+
ke as a4,
|
|
961
|
+
Ws as a5,
|
|
962
|
+
et as a6,
|
|
963
|
+
us as a7,
|
|
964
|
+
fs as a8,
|
|
965
|
+
is as a9,
|
|
966
|
+
U as aA,
|
|
967
|
+
ns as aa,
|
|
968
|
+
ms as ab,
|
|
969
|
+
rs as ac,
|
|
970
|
+
y as ad,
|
|
971
|
+
L as ae,
|
|
972
|
+
Be as af,
|
|
973
|
+
xe as ag,
|
|
974
|
+
Ye as ah,
|
|
975
|
+
Fs as ai,
|
|
976
|
+
hs as aj,
|
|
977
|
+
Vt as ak,
|
|
978
|
+
Xe as al,
|
|
979
|
+
es as am,
|
|
980
|
+
Ss as an,
|
|
981
|
+
p as ao,
|
|
982
|
+
Re as ap,
|
|
983
|
+
Ts as aq,
|
|
984
|
+
De as ar,
|
|
985
|
+
Ze as as,
|
|
986
|
+
Qe as at,
|
|
987
|
+
Le as au,
|
|
986
988
|
Ne as av,
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
989
|
+
ts as aw,
|
|
990
|
+
Oe as ax,
|
|
991
|
+
Ie as ay,
|
|
992
|
+
ws as az,
|
|
993
|
+
me as b,
|
|
994
|
+
Ee as c,
|
|
995
|
+
Fe as d,
|
|
996
|
+
qs as e,
|
|
997
|
+
Ks as f,
|
|
998
|
+
js as g,
|
|
999
|
+
Ae as h,
|
|
1000
|
+
ls as i,
|
|
1001
|
+
ps as j,
|
|
1002
|
+
ze as k,
|
|
1003
|
+
He as l,
|
|
1004
|
+
vs as m,
|
|
1005
|
+
ks as n,
|
|
1006
|
+
Xs as o,
|
|
1007
|
+
Ys as p,
|
|
1008
|
+
Je as q,
|
|
1006
1009
|
S as r,
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1010
|
+
ve as s,
|
|
1011
|
+
de as t,
|
|
1012
|
+
Ce as u,
|
|
1013
|
+
bs as v,
|
|
1014
|
+
_s as w,
|
|
1015
|
+
Ds as x,
|
|
1016
|
+
Gs as y,
|
|
1017
|
+
ds as z
|
|
1015
1018
|
};
|