@dhedge/trading-widget 6.2.2 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
- import { hyperEvm as F, mainnet as w, polygon as Z, optimism as J, base as tt, arbitrum as et } from "wagmi/chains";
2
- import { aq as st, ao as nt, ap as at, a as b, q as D, ar as rt, as as ot, a5 as it, ak as ct, a3 as ut, b as dt, ae as pt, Z as v, aj as lt, at as Y, e as mt, d as yt, M as At, R as gt, P as Et, au as ht, av as ft, Q as Tt, N as _t, ah as T, _ as St, W as wt, X as bt, U as Dt, aw as G, ax as Rt, ay as It, az as Nt, aA as Ot, aB as Ct, ad as Mt } from "./gmx-Cyz_GmV5.js";
1
+ import { hyperEvm as Y, mainnet as b, polygon as J, optimism as tt, base as et, arbitrum as st } from "wagmi/chains";
2
+ import { aq as nt, ao as at, ap as rt, a as D, q as I, ar as ot, as as it, a5 as ct, ak as ut, a3 as dt, b as pt, ae as lt, Z as W, aj as mt, at as G, e as yt, d as At, M as gt, R as Et, P as ht, au as St, av as ft, Q as Tt, N as _t, ah as f, _ as wt, W as bt, X as Dt, U as It, aw as H, ax as Rt, ay as Nt, az as Ot, aA as Ct, aB as Mt, ad as xt } from "./gmx-Cyz_GmV5.js";
3
3
  import u from "bignumber.js";
4
- import { zeroHash as xt, bytesToHex as Lt, pad as Bt, stringToHex as R, encodeAbiParameters as h, encodeFunctionData as g, erc20Abi as W, maxUint256 as I } from "viem";
5
- const xe = typeof window < "u", Le = [
4
+ import { zeroHash as Lt, bytesToHex as Bt, pad as Pt, stringToHex as R, encodeAbiParameters as h, encodeFunctionData as y, erc20Abi as k, maxUint256 as _ } from "viem";
5
+ const $e = typeof window < "u", ve = [
6
6
  {
7
7
  inputs: [
8
8
  { internalType: "address", name: "_pool", type: "address" },
@@ -30,7 +30,7 @@ const xe = typeof window < "u", Le = [
30
30
  stateMutability: "view",
31
31
  type: "function"
32
32
  }
33
- ], Pt = [
33
+ ], Ut = [
34
34
  {
35
35
  type: "tuple",
36
36
  components: [
@@ -53,7 +53,7 @@ const xe = typeof window < "u", Le = [
53
53
  { name: "amountOutMinimum", type: "uint256" }
54
54
  ]
55
55
  }
56
- ], Ut = [
56
+ ], $t = [
57
57
  { name: "asset", type: "address" },
58
58
  { name: "amount", type: "uint256" },
59
59
  { name: "assetType", type: "uint16" },
@@ -64,7 +64,7 @@ const xe = typeof window < "u", Le = [
64
64
  { name: "tokenId", type: "uint256" },
65
65
  { name: "debtKey", type: "uint248" },
66
66
  { name: "shares", type: "uint256" }
67
- ], Be = [
67
+ ], Fe = [
68
68
  {
69
69
  inputs: [
70
70
  { internalType: "address", name: "_pool", type: "address" },
@@ -75,7 +75,7 @@ const xe = typeof window < "u", Le = [
75
75
  {
76
76
  name: "assetData",
77
77
  type: "tuple[]",
78
- components: Ut
78
+ components: $t
79
79
  }
80
80
  ],
81
81
  stateMutability: "nonpayable",
@@ -88,7 +88,7 @@ const xe = typeof window < "u", Le = [
88
88
  stateMutability: "view",
89
89
  type: "function"
90
90
  }
91
- ], k = [
91
+ ], N = [
92
92
  {
93
93
  inputs: [
94
94
  {
@@ -130,7 +130,7 @@ const xe = typeof window < "u", Le = [
130
130
  stateMutability: "nonpayable",
131
131
  type: "function"
132
132
  }
133
- ], $t = [
133
+ ], vt = [
134
134
  {
135
135
  inputs: [
136
136
  { name: "tokenIn", type: "address" },
@@ -175,7 +175,7 @@ const xe = typeof window < "u", Le = [
175
175
  { name: "minOutputAmount", type: "uint256" }
176
176
  ]
177
177
  }
178
- ], S = {
178
+ ], w = {
179
179
  stringErrors: {
180
180
  // Ondo tokenized assets trade only during market hours; the full message
181
181
  // includes a dynamic reopen time (e.g. "QUBTon is currently closed for
@@ -204,48 +204,48 @@ const xe = typeof window < "u", Le = [
204
204
  hint: "Increase slippage tolerance and try again."
205
205
  }
206
206
  }
207
- }, H = (t) => ({
207
+ }, V = (t) => ({
208
208
  stringErrors: {
209
209
  ...t.stringErrors,
210
- ...S.stringErrors
210
+ ...w.stringErrors
211
211
  },
212
212
  selectorErrors: {
213
213
  ...t.selectorErrors,
214
- ...S.selectorErrors
214
+ ...w.selectorErrors
215
215
  }
216
- }), vt = [
216
+ }), Yt = [
217
217
  "https://cdn.jsdelivr.net/gh/dhedge/V2-Public@master/readmes/errorCodes/registry.json",
218
218
  "https://raw.githubusercontent.com/dhedge/V2-Public/master/readmes/errorCodes/registry.json"
219
- ], Yt = 1, Gt = 1e4, N = 2e6, Wt = 2e3, kt = 500, Ht = 120, Vt = 300, Kt = 4, qt = /^dh\d{1,3}$/i, V = /[\u0000-\u001f\u007f]/, jt = /https?:\/\/|[<>`]/i, Xt = (t) => t.length <= Ht && !V.test(t) && (qt.test(t) || t.length >= Kt), A = (t) => typeof t == "string" && t.length > 0 && t.length <= Vt && !V.test(t) && !jt.test(t);
220
- let K = S, _ = null;
221
- const q = () => K, zt = (t) => {
222
- K = H(t);
223
- }, Qt = (t) => {
219
+ ], Wt = 1, Gt = 1e4, O = 2e6, Ht = 2e3, kt = 500, Vt = 120, Kt = 300, qt = 4, jt = /^dh\d{1,3}$/i, K = /[\u0000-\u001f\u007f]/, Xt = /https?:\/\/|[<>`]/i, zt = (t) => t.length <= Vt && !K.test(t) && (jt.test(t) || t.length >= qt), g = (t) => typeof t == "string" && t.length > 0 && t.length <= Kt && !K.test(t) && !Xt.test(t);
220
+ let q = w, T = null;
221
+ const j = () => q, Qt = (t) => {
222
+ q = V(t);
223
+ }, Zt = (t) => {
224
224
  const e = t;
225
- if (e?.schemaVersion !== Yt)
225
+ if (e?.schemaVersion !== Wt)
226
226
  throw new Error(
227
227
  `Unsupported error registry schemaVersion: ${String(e?.schemaVersion)}`
228
228
  );
229
229
  const s = {};
230
230
  for (const [r, a] of Object.entries(e.stringErrors ?? {}))
231
- a?.curated === !0 && Xt(r) && A(a.description) && A(a.action) && (s[r] = { title: a.description, hint: a.action });
231
+ a?.curated === !0 && zt(r) && g(a.description) && g(a.action) && (s[r] = { title: a.description, hint: a.action });
232
232
  const n = {};
233
233
  for (const [r, a] of Object.entries(e.selectorErrors ?? {}))
234
- a?.curated === !0 && /^0x[0-9a-f]{8}$/.test(r) && A(a.signature) && A(a.description) && A(a.action) && (n[r] = {
234
+ a?.curated === !0 && /^0x[0-9a-f]{8}$/.test(r) && g(a.signature) && g(a.description) && g(a.action) && (n[r] = {
235
235
  signature: a.signature,
236
236
  title: a.description,
237
237
  hint: a.action
238
238
  });
239
239
  if (!Object.keys(s).length)
240
240
  throw new Error("Error registry contained no curated string errors");
241
- if (Object.keys(s).length > Wt || Object.keys(n).length > kt)
241
+ if (Object.keys(s).length > Ht || Object.keys(n).length > kt)
242
242
  throw new Error("Error registry exceeded expected entry counts");
243
243
  return { stringErrors: s, selectorErrors: n };
244
- }, Zt = async ({
244
+ }, Jt = async ({
245
245
  timeoutMs: t = Gt
246
246
  } = {}) => {
247
247
  const e = [];
248
- for (const s of vt) {
248
+ for (const s of Yt) {
249
249
  const n = new AbortController(), r = setTimeout(() => n.abort(), t);
250
250
  try {
251
251
  const a = await fetch(s, {
@@ -254,12 +254,12 @@ const q = () => K, zt = (t) => {
254
254
  });
255
255
  if (!a.ok) throw new Error(`HTTP ${a.status}`);
256
256
  const o = Number(a.headers.get("content-length"));
257
- if (o > N)
257
+ if (o > O)
258
258
  throw new Error(`Response too large: ${o} bytes`);
259
259
  const i = await a.text();
260
- if (i.length > N)
260
+ if (i.length > O)
261
261
  throw new Error(`Response too large: ${i.length} chars`);
262
- return H(Qt(JSON.parse(i)));
262
+ return V(Zt(JSON.parse(i)));
263
263
  } catch (a) {
264
264
  e.push(
265
265
  `${s}: ${a instanceof Error ? a.message : String(a)}`
@@ -269,15 +269,15 @@ const q = () => K, zt = (t) => {
269
269
  }
270
270
  }
271
271
  throw new Error(`All error registry sources failed: ${e.join("; ")}`);
272
- }, Pe = () => (_ ?? (_ = Zt().then(zt).catch(() => {
273
- _ = null;
274
- })), _), Jt = () => typeof window < "u";
275
- function te() {
276
- return Jt() && typeof window.ethereum < "u";
272
+ }, Ye = () => (T ?? (T = Jt().then(Qt).catch(() => {
273
+ T = null;
274
+ })), T), te = () => typeof window < "u";
275
+ function ee() {
276
+ return te() && typeof window.ethereum < "u";
277
277
  }
278
- async function Ue(t) {
278
+ async function We(t) {
279
279
  try {
280
- if (te())
280
+ if (ee())
281
281
  return window.ethereum.request({
282
282
  method: "wallet_watchAsset",
283
283
  params: {
@@ -290,45 +290,45 @@ async function Ue(t) {
290
290
  }
291
291
  return !1;
292
292
  }
293
- const l = (t, e) => t?.toLowerCase() === e?.toLowerCase(), $e = (t) => l(t, st), E = (t) => {
293
+ const p = (t, e) => t?.toLowerCase() === e?.toLowerCase(), Ge = (t) => p(t, nt), E = (t) => {
294
294
  if (!t) throw new Error("Cannot prefix an empty hex value");
295
295
  return t.startsWith("0x") ? t : `0x${t}`;
296
- }, p = (t, e) => {
296
+ }, l = (t, e) => {
297
297
  try {
298
298
  return BigInt(t);
299
299
  } catch {
300
300
  throw new Error(`Cannot convert "${e}" value "${t}" to bigint`);
301
301
  }
302
- }, O = (t) => t ? Bt(E(t), { size: 32 }) : xt, ee = (t) => {
302
+ }, C = (t) => t ? Pt(E(t), { size: 32 }) : Lt, se = (t) => {
303
303
  if (!t) throw new Error("Cannot decode an empty base64 string");
304
- return Lt(Uint8Array.from(atob(t), (e) => e.charCodeAt(0)));
305
- }, se = (t, e) => at[e]?.[t] ?? b, Fe = (t) => nt[t], ve = (t) => t && `${t.substring(0, 6)}...${t.substring(
304
+ return Bt(Uint8Array.from(atob(t), (e) => e.charCodeAt(0)));
305
+ }, ne = (t, e) => rt[e]?.[t] ?? D, He = (t) => at[t], ke = (t) => t && `${t.substring(0, 6)}...${t.substring(
306
306
  t.length - 4,
307
307
  t.length
308
- )}`, Ye = ({
308
+ )}`, Ve = ({
309
309
  address: t,
310
310
  chainId: e
311
311
  }) => {
312
- const s = se(
312
+ const s = ne(
313
313
  "aaveLendingPoolV3",
314
314
  e
315
315
  );
316
- return l(t, s);
317
- }, ne = ({
316
+ return p(t, s);
317
+ }, ae = ({
318
318
  sourceAddress: t,
319
319
  amount: e
320
- }) => `${t}_${e}`, Ge = (t, e) => {
320
+ }) => `${t}_${e}`, Ke = (t, e) => {
321
321
  const s = t.slice(0, e), n = t.slice(e);
322
322
  return { firstPart: s, secondPart: n };
323
- }, ae = (t, e) => t / e * 100, We = (t) => t < 1 ? 4 : t < 10 ? 3 : 2, ke = (t, e = D) => new u(t.toString()).shiftedBy(e).toFixed(0), He = (t, e, s, n) => new u(e).dividedBy(s).multipliedBy(t).shiftedBy(-(n || D)).toNumber(), Ve = (t) => BigInt(
324
- new u(t || "0").shiftedBy(D).toFixed(0, u.ROUND_DOWN)
325
- ), j = (t) => {
323
+ }, re = (t, e) => t / e * 100, qe = (t) => t < 1 ? 4 : t < 10 ? 3 : 2, je = (t, e = I) => new u(t.toString()).shiftedBy(e).toFixed(0), Xe = (t, e, s, n) => new u(e).dividedBy(s).multipliedBy(t).shiftedBy(-(n || I)).toNumber(), ze = (t) => BigInt(
324
+ new u(t || "0").shiftedBy(I).toFixed(0, u.ROUND_DOWN)
325
+ ), X = (t) => {
326
326
  const e = new u(0.01), s = new u(t), n = !s.isZero() && s.lt(e) ? e : s;
327
327
  return BigInt(n.multipliedBy(100).toFixed(0));
328
- }, Ke = ({
328
+ }, Qe = ({
329
329
  chainId: t,
330
330
  slippage: e
331
- }) => t === F.id ? BigInt(0) : j(e), qe = ({
331
+ }) => t === Y.id ? BigInt(0) : X(e), Ze = ({
332
332
  vaultAddress: t,
333
333
  swapData: e,
334
334
  sendTokenAddress: s,
@@ -341,7 +341,7 @@ const l = (t, e) => t?.toLowerCase() === e?.toLowerCase(), $e = (t) => l(t, st),
341
341
  }) => {
342
342
  const d = new u(i).multipliedBy(1 - c / 100).toFixed(0), m = [R(o, { size: 32 }), e];
343
343
  return [t, [[s, n, m], [r, d]], a];
344
- }, je = ({
344
+ }, Je = ({
345
345
  receiveAssetAddress: t,
346
346
  assets: e,
347
347
  swapData: s,
@@ -357,9 +357,9 @@ const l = (t, e) => t?.toLowerCase() === e?.toLowerCase(), $e = (t) => l(t, st),
357
357
  const m = [
358
358
  R(d.routerKey, { size: 32 }),
359
359
  d.rawTransaction.data
360
- ], y = [c.address, c.rawBalance, m];
360
+ ], A = [c.address, c.rawBalance, m];
361
361
  return {
362
- srcData: [...i.srcData, y],
362
+ srcData: [...i.srcData, A],
363
363
  destAmount: i.destAmount.plus(d.destinationAmount)
364
364
  };
365
365
  }, r) ?? r;
@@ -370,7 +370,7 @@ const l = (t, e) => t?.toLowerCase() === e?.toLowerCase(), $e = (t) => l(t, st),
370
370
  o.times(1 - n / 100).toFixed(0, u.ROUND_DOWN)
371
371
  ]
372
372
  ];
373
- }, re = ({
373
+ }, oe = ({
374
374
  assetAddress: t,
375
375
  swapQuotes: e,
376
376
  swapParams: s,
@@ -383,23 +383,23 @@ const l = (t, e) => t?.toLowerCase() === e?.toLowerCase(), $e = (t) => l(t, st),
383
383
  withdrawData: "",
384
384
  slippageTolerance: BigInt(0)
385
385
  };
386
- const { srcData: a, dstData: o } = s, i = a.map(({ asset: m, amount: y }) => {
387
- const f = e?.[ne({
386
+ const { srcData: a, dstData: o } = s, i = a.map(({ asset: m, amount: A }) => {
387
+ const S = e?.[ae({
388
388
  sourceAddress: m,
389
- amount: y.toString()
390
- })]?.find((Q) => Q.routerKey === r);
389
+ amount: A.toString()
390
+ })]?.find((Z) => Z.routerKey === r);
391
391
  return {
392
392
  asset: m,
393
- amount: y,
393
+ amount: A,
394
394
  swapData: {
395
- routerKey: R(f?.routerKey ?? "", { size: 32 }),
396
- txData: f?.rawTransaction.data ?? "0x"
395
+ routerKey: R(S?.routerKey ?? "", { size: 32 }),
396
+ txData: S?.rawTransaction.data ?? "0x"
397
397
  }
398
398
  };
399
399
  }), c = h(
400
- rt,
400
+ ot,
401
401
  [i]
402
- ), d = h(ot, [
402
+ ), d = h(it, [
403
403
  {
404
404
  encodedSrcData: c,
405
405
  dstData: {
@@ -414,29 +414,29 @@ const l = (t, e) => t?.toLowerCase() === e?.toLowerCase(), $e = (t) => l(t, st),
414
414
  withdrawData: d,
415
415
  slippageTolerance: n
416
416
  };
417
- }, Xe = ({
417
+ }, ts = ({
418
418
  chainId: t,
419
419
  txHash: e,
420
420
  error: s
421
421
  }) => {
422
- if (t !== w.id || !e || !s)
422
+ if (t !== b.id || !e || !s)
423
423
  return !1;
424
424
  const n = s instanceof Error ? s.message : String(s);
425
425
  return /\bNo Result\b/i.test(n);
426
- }, ze = ({
426
+ }, es = ({
427
427
  chainId: t,
428
428
  action: e,
429
429
  isRabbyWallet: s
430
- }) => e === "update_ondo_prices" && t === w.id && s ? it : t ? ct[t] ?? 0 : 0, Qe = (t, e) => dt[e]?.nativeTokenSymbol === t, Ze = ({
430
+ }) => e === "update_ondo_prices" && t === b.id && s ? ct : t ? ut[t] ?? 0 : 0, ss = (t, e) => pt[e]?.nativeTokenSymbol === t, ns = ({
431
431
  nativeTokenBalance: t,
432
432
  tokenDecimals: e,
433
433
  gasPrice: s
434
434
  }) => {
435
- const n = new u(s).multipliedBy(ut).shiftedBy(-e), r = new u(t).minus(
435
+ const n = new u(s).multipliedBy(dt).shiftedBy(-e), r = new u(t).minus(
436
436
  n
437
437
  );
438
438
  return r.gt("0") ? r : new u("0");
439
- }, Je = (t) => pt.includes(t), ts = (t) => {
439
+ }, as = (t) => lt.includes(t), rs = (t) => {
440
440
  const e = Object.values(t).reduce(
441
441
  (s, { type: n }) => (s[n] = s[n] + 1, s),
442
442
  { string: 0, number: 0 }
@@ -446,26 +446,26 @@ const l = (t, e) => t?.toLowerCase() === e?.toLowerCase(), $e = (t) => l(t, st),
446
446
  if (e.number > 40)
447
447
  throw new Error("logger params must contain up to 40 numeric values");
448
448
  return !0;
449
- }, oe = (t, e = 150) => t.length > e ? t.substring(0, e) : t, X = () => ({
450
- ...q().stringErrors,
451
- ...lt
452
- }), ie = () => [
453
- ...Object.keys(X()),
454
- ...Object.keys(v)
455
- ], ce = /^dh\d+$/i, ue = (t, e) => ce.test(e) ? new RegExp(`\\b${e}\\b`, "i").test(t) : t.includes(e.toLowerCase()), C = (t, e) => {
449
+ }, ie = (t, e = 150) => t.length > e ? t.substring(0, e) : t, z = () => ({
450
+ ...j().stringErrors,
451
+ ...mt
452
+ }), ce = () => [
453
+ ...Object.keys(z()),
454
+ ...Object.keys(W)
455
+ ], ue = /^dh\d+$/i, de = (t, e) => ue.test(e) ? new RegExp(`\\b${e}\\b`, "i").test(t) : t.includes(e.toLowerCase()), M = (t, e) => {
456
456
  const s = t.toLowerCase();
457
- return [...e ?? ie()].sort((n, r) => r.length - n.length).find((n) => ue(s, n));
458
- }, M = (t) => X()[t] ?? v[t], de = /\b0x[0-9a-f]{8}\b/i, pe = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), le = (t) => {
459
- const { selectorErrors: e } = q(), s = t.match(de)?.[0]?.toLowerCase(), n = s ? e[s] : void 0;
457
+ return [...e ?? ce()].sort((n, r) => r.length - n.length).find((n) => de(s, n));
458
+ }, x = (t) => z()[t] ?? W[t], pe = /\b0x[0-9a-f]{8}\b/i, le = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), me = (t) => {
459
+ const { selectorErrors: e } = j(), s = t.match(pe)?.[0]?.toLowerCase(), n = s ? e[s] : void 0;
460
460
  if (n)
461
461
  return { title: n.title, hint: n.hint };
462
462
  const r = Object.values(e).find(
463
463
  (a) => new RegExp(
464
- `\\b${pe(a.signature.split("(")[0] ?? "")}\\b`
464
+ `\\b${le(a.signature.split("(")[0] ?? "")}\\b`
465
465
  ).test(t)
466
466
  );
467
467
  return r ? { title: r.title, hint: r.hint } : void 0;
468
- }, es = ({
468
+ }, os = ({
469
469
  errorMessage: t,
470
470
  abiErrors: e
471
471
  }) => {
@@ -473,22 +473,22 @@ const l = (t, e) => t?.toLowerCase() === e?.toLowerCase(), $e = (t) => l(t, st),
473
473
  return null;
474
474
  const s = e.find((o) => t.includes(o));
475
475
  if (s) {
476
- const o = C(s);
476
+ const o = M(s);
477
477
  if (o)
478
- return M(o);
478
+ return x(o);
479
479
  }
480
- const n = C(t);
480
+ const n = M(t);
481
481
  if (n)
482
- return M(n);
483
- const r = le(t);
482
+ return x(n);
483
+ const r = me(t);
484
484
  if (r)
485
485
  return r;
486
486
  const [a] = t.split(s ? "." : "Contract").map((o) => o.trim());
487
487
  return {
488
488
  title: "Transaction failed",
489
- hint: `${oe(a ?? "")} ${s ? `: ${s}` : ""}`
489
+ hint: `${ie(a ?? "")} ${s ? `: ${s}` : ""}`
490
490
  };
491
- }, ss = (t) => typeof t == "number" && Number.isFinite(t), ns = (t) => typeof t == "bigint" && t !== BigInt(0), me = (t, e = Y) => new u(t).shiftedBy(-e).toNumber(), ye = (t) => !isNaN(parseFloat(t)) && !isNaN(t), Ae = ({
491
+ }, is = (t) => typeof t == "number" && Number.isFinite(t), cs = (t) => typeof t == "bigint" && t !== BigInt(0), ye = (t, e = G) => new u(t).shiftedBy(-e).toNumber(), Ae = (t) => !isNaN(parseFloat(t)) && !isNaN(t), ge = ({
492
492
  value: t,
493
493
  minimumFractionDigits: e = 2,
494
494
  maximumFractionDigits: s = 2,
@@ -500,42 +500,42 @@ const l = (t, e) => t?.toLowerCase() === e?.toLowerCase(), $e = (t) => l(t, st),
500
500
  notation: n ? "compact" : void 0,
501
501
  minimumFractionDigits: e,
502
502
  maximumFractionDigits: s
503
- }).format(r ? me(t) : Number(t)), x = (t) => ye(t) ? new u(t).toFixed() : "", L = ["₀", "₁", "₂", "₃", "₄", "₅", "₆", "₇", "₈", "₉"], ge = ({
503
+ }).format(r ? ye(t) : Number(t)), L = (t) => Ae(t) ? new u(t).toFixed() : "", B = ["₀", "₁", "₂", "₃", "₄", "₅", "₆", "₇", "₈", "₉"], Ee = ({
504
504
  value: t,
505
505
  decimals: e = 4
506
506
  }) => {
507
507
  const s = new u(t);
508
508
  if (s.isGreaterThan(1) || s.isZero())
509
- return x(s.toFixed(e));
510
- const r = (/e/i.test(t.toString()) ? parseFloat(t.toString()).toFixed(Y) : t.toString()).match(/^0\.(0+)(\d+)$/);
509
+ return L(s.toFixed(e));
510
+ const r = (/e/i.test(t.toString()) ? parseFloat(t.toString()).toFixed(G) : t.toString()).match(/^0\.(0+)(\d+)$/);
511
511
  if (r) {
512
512
  const [, a, o] = r;
513
- if (a.length >= e && a.length < L.length)
514
- return `0.0${L[a.length]}${o.slice(0, 3)}`;
513
+ if (a.length >= e && a.length < B.length)
514
+ return `0.0${B[a.length]}${o.slice(0, 3)}`;
515
515
  }
516
- return x(s.toFixed(e));
517
- }, Ee = (t, e = 0) => `${t.toLocaleString("en-US", { maximumFractionDigits: e })}%`, as = (t) => t.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), rs = (t, e, s = 0) => {
518
- const n = ae(+t, e);
519
- return Ee(n, s);
520
- }, os = ({
516
+ return L(s.toFixed(e));
517
+ }, he = (t, e = 0) => `${t.toLocaleString("en-US", { maximumFractionDigits: e })}%`, us = (t) => t.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), ds = (t, e, s = 0) => {
518
+ const n = re(+t, e);
519
+ return he(n, s);
520
+ }, ps = ({
521
521
  currency: t,
522
522
  value: e
523
- }) => t === "USD" ? Ae({ value: e }) : `${mt[t]} ${ge({
523
+ }) => t === "USD" ? ge({ value: e }) : `${yt[t]} ${Ee({
524
524
  value: e,
525
- decimals: yt[t]
526
- })}`, he = (t, e) => new u(
525
+ decimals: At[t]
526
+ })}`, Se = (t, e) => new u(
527
527
  new u(t).toFixed(e, u.ROUND_DOWN)
528
528
  ).toString(), fe = (t, e = 3, s = 2) => {
529
529
  if (t.length <= 5)
530
530
  return t;
531
531
  const n = "...";
532
532
  return t.length <= e + s + n.length ? t : `${t.slice(0, e)}${n}${t.slice(-s)}`;
533
- }, is = ({
533
+ }, ls = ({
534
534
  balance: t,
535
535
  symbol: e,
536
536
  precision: s,
537
537
  truncateSymbol: n
538
- }) => `${he(t, s)} ${n ? fe(e) : e}`, cs = (t) => {
538
+ }) => `${Se(t, s)} ${n ? fe(e) : e}`, ms = (t) => {
539
539
  if (!t)
540
540
  return;
541
541
  const e = t.match(/0x[a-fA-F0-9]{64}/);
@@ -543,13 +543,13 @@ const l = (t, e) => t?.toLowerCase() === e?.toLowerCase(), $e = (t) => l(t, st),
543
543
  return;
544
544
  const s = e[0];
545
545
  return `${s.slice(0, 4)}...${s.slice(-3)}`;
546
- }, us = (t) => l(ht, t) || l(ft, t), ds = (t) => _t.some(
547
- (e) => l(e, t)
548
- ), ps = (t) => At[t.toLowerCase()] ?? {
546
+ }, ys = (t) => p(St, t) || p(ft, t), As = (t) => _t.some(
547
+ (e) => p(e, t)
548
+ ), gs = (t) => gt[t.toLowerCase()] ?? {
549
549
  symbol: "",
550
550
  decimals: 18,
551
- address: b
552
- }, ls = (t) => l(t, Tt) ? gt : Et, Te = (t) => `eth_${t}`, ms = ({
551
+ address: D
552
+ }, Es = (t) => p(t, Tt) ? Et : ht, Te = (t) => `eth_${t}`, hs = ({
553
553
  action: t,
554
554
  log: e,
555
555
  symbol: s,
@@ -557,20 +557,29 @@ const l = (t, e) => t?.toLowerCase() === e?.toLowerCase(), $e = (t) => l(t, st),
557
557
  chainId: r
558
558
  }) => {
559
559
  const a = {
560
- [T.SYMBOL.NAME]: s,
561
- [T.CHAIN_ID.NAME]: r,
562
- [T.ADDRESS.NAME]: Te(n)
560
+ [f.SYMBOL.NAME]: s,
561
+ [f.CHAIN_ID.NAME]: r,
562
+ [f.ADDRESS.NAME]: Te(n)
563
563
  };
564
- St[t].forEach((o) => {
564
+ wt[t].forEach((o) => {
565
565
  e?.(o, a);
566
566
  });
567
- }, ys = (t) => Dt.some((e) => l(e, t)), As = (t) => wt[t.toLowerCase()] ?? {
567
+ }, Ss = (t) => It.some((e) => p(e, t)), fs = (t) => bt[t.toLowerCase()] ?? {
568
568
  symbol: "",
569
569
  decimals: 18,
570
- address: b
571
- }, gs = (t) => bt[t.toLowerCase()], _e = "0x3333333333333333333333333333333333333333";
572
- et.id + "", Ct.address, tt.id + "", Ot.address, J.id + "", Nt.address, Z.id + "", It.address, w.id + "", Rt.address, F.id + "", G.address;
573
- const Es = (t) => l(t, _e), hs = () => G, fs = /* @__PURE__ */ new Map(), z = (t, e) => !e || e.size === 0 ? t : t.map((s) => {
570
+ address: D
571
+ }, Ts = (t) => Dt[t.toLowerCase()], _e = "0x3333333333333333333333333333333333333333";
572
+ st.id + "", Mt.address, et.id + "", Ct.address, tt.id + "", Ot.address, J.id + "", Nt.address, b.id + "", Rt.address, Y.id + "", H.address;
573
+ const we = "0x2222222222222222222222222222222222222222", P = BigInt("0x2000000000000000000000000000000000000000"), be = 10000n, De = (t) => p(t, _e), Ie = (t) => {
574
+ if (p(t, we))
575
+ return !0;
576
+ try {
577
+ const e = BigInt(t);
578
+ return e >= P && e < P + be;
579
+ } catch {
580
+ return !1;
581
+ }
582
+ }, _s = (t) => De(t) || Ie(t), ws = () => H, bs = /* @__PURE__ */ new Map(), Q = (t, e) => !e || e.size === 0 ? t : t.map((s) => {
574
583
  const n = e.get(
575
584
  s.supportedAsset.toLowerCase()
576
585
  );
@@ -579,27 +588,27 @@ const Es = (t) => l(t, _e), hs = () => G, fs = /* @__PURE__ */ new Map(), z = (t
579
588
  withdrawData: n.withdrawData,
580
589
  slippageTolerance: n.slippageTolerance
581
590
  } : s;
582
- }), Se = (t) => {
591
+ }), Re = (t) => {
583
592
  const e = t.find(
584
593
  ({ swapQuotes: s }) => s
585
594
  );
586
595
  return e?.swapQuotes ? Object.values(e.swapQuotes)[0]?.map(
587
596
  ({ routerKey: s }) => s
588
597
  ) ?? [] : [];
589
- }, we = (t, e, s) => t.map(({ asset: n, swapParams: r, swapQuotes: a }) => !r || !a ? {
598
+ }, Ne = (t, e, s) => t.map(({ asset: n, swapParams: r, swapQuotes: a }) => !r || !a ? {
590
599
  supportedAsset: n,
591
600
  withdrawData: "",
592
601
  slippageTolerance: s
593
- } : re({
602
+ } : oe({
594
603
  assetAddress: n,
595
604
  swapQuotes: a,
596
605
  swapParams: r,
597
606
  slippageToleranceForContractTransaction: s,
598
607
  routerKey: e
599
- })), be = async (t, e, s, n, r, a) => {
608
+ })), Oe = async (t, e, s, n, r, a) => {
600
609
  for (const o of t) {
601
- const i = z(
602
- we(
610
+ const i = Q(
611
+ Ne(
603
612
  e,
604
613
  o,
605
614
  s
@@ -610,20 +619,20 @@ const Es = (t) => l(t, _e), hs = () => G, fs = /* @__PURE__ */ new Map(), z = (t
610
619
  return i;
611
620
  }
612
621
  return null;
613
- }, Ts = (t, e, s) => {
622
+ }, Ds = (t, e, s) => {
614
623
  const n = (t ?? []).map((r) => ({
615
624
  supportedAsset: r,
616
625
  withdrawData: "",
617
626
  slippageTolerance: e
618
627
  }));
619
- return z(n, s);
620
- }, _s = async (t, e, s, n, r) => {
628
+ return Q(n, s);
629
+ }, Is = async (t, e, s, n, r) => {
621
630
  for (const a of t) {
622
- const o = j(a);
631
+ const o = X(a);
623
632
  try {
624
- const i = await e(a), c = Se(
633
+ const i = await e(a), c = Re(
625
634
  i
626
- ), d = await be(
635
+ ), d = await Oe(
627
636
  c,
628
637
  i,
629
638
  o,
@@ -643,14 +652,14 @@ const Es = (t) => l(t, _e), hs = () => G, fs = /* @__PURE__ */ new Map(), z = (t
643
652
  }
644
653
  }
645
654
  return null;
646
- }, Ss = async (t, e, {
655
+ }, Rs = async (t, e, {
647
656
  fetchAaveSwapParams: s,
648
657
  fetchAaveSwapQuotes: n,
649
658
  withdrawAmountD18: r,
650
659
  slippage: a
651
660
  }) => Promise.all(
652
661
  (t ?? []).map(async (o) => {
653
- if (!l(o, e))
662
+ if (!p(o, e))
654
663
  return { asset: o };
655
664
  try {
656
665
  const c = await s({
@@ -669,60 +678,60 @@ const Es = (t) => l(t, _e), hs = () => G, fs = /* @__PURE__ */ new Map(), z = (t
669
678
  return console.error(c), { asset: o };
670
679
  }
671
680
  })
672
- ), B = (t) => Math.round(t * 100) / 100, ws = ({
681
+ ), U = (t) => Math.round(t * 100) / 100, Ns = ({
673
682
  maxSlippage: t,
674
- candidates: e = Mt
683
+ candidates: e = xt
675
684
  }) => {
676
685
  if (!Number.isFinite(t) || t <= 0)
677
686
  return [];
678
- const s = B(Math.min(t, 100)), n = e.filter((a) => a > 0 && a <= s).map(B), r = new Set(n);
687
+ const s = U(Math.min(t, 100)), n = e.filter((a) => a > 0 && a <= s).map(U), r = new Set(n);
679
688
  return r.add(s), r.add(t), Array.from(r).sort((a, o) => a - o);
680
- }, P = 1000000000000000000n, De = 1000000n, U = 10000n, $ = 100n, bs = (t) => ({
689
+ }, $ = 1000000000000000000n, Ce = 1000000n, v = 10000n, F = 100n, Os = (t) => ({
681
690
  quotes: t.quotes.map(
682
691
  (e) => ({
683
- chainId: p(e.chainId, "chainId"),
684
- attestationId: p(e.attestationId, "attestationId"),
692
+ chainId: l(e.chainId, "chainId"),
693
+ attestationId: l(e.attestationId, "attestationId"),
685
694
  userId: E(e.userId),
686
695
  asset: e.asset,
687
- price: p(e.price, "price"),
688
- quantity: p(e.quantity, "quantity"),
689
- expiration: p(e.expiration, "expiration"),
696
+ price: l(e.price, "price"),
697
+ quantity: l(e.quantity, "quantity"),
698
+ expiration: l(e.expiration, "expiration"),
690
699
  side: Number(e.side),
691
700
  additionalData: E(e.additionalData)
692
701
  })
693
702
  ),
694
703
  signatures: t.signatures.map(E)
695
- }), Re = (t, e, s) => {
696
- const n = BigInt(Math.max(0, Math.round(s * 100))), r = n > $ ? $ : n, a = U - r, i = t * e / P * a * De, c = U * P;
704
+ }), Me = (t, e, s) => {
705
+ const n = BigInt(Math.max(0, Math.round(s * 100))), r = n > F ? F : n, a = v - r, i = t * e / $ * a * Ce, c = v * $;
697
706
  return (i + c - 1n) / c;
698
- }, Ie = (t, e) => ({
707
+ }, xe = (t, e) => ({
699
708
  chainId: e,
700
- attestationId: p(t.attestationId, "attestationId"),
701
- userId: O(t.userId),
709
+ attestationId: l(t.attestationId, "attestationId"),
710
+ userId: C(t.userId),
702
711
  asset: t.assetAddress,
703
- price: p(t.price, "price"),
704
- quantity: p(t.tokenAmount, "tokenAmount"),
705
- expiration: p(t.expiration, "expiration"),
712
+ price: l(t.price, "price"),
713
+ quantity: l(t.tokenAmount, "tokenAmount"),
714
+ expiration: l(t.expiration, "expiration"),
706
715
  side: Number(t.side),
707
- additionalData: O(t.additionalData)
708
- }), Ds = ({
716
+ additionalData: C(t.additionalData)
717
+ }), Cs = ({
709
718
  attestation: t,
710
719
  chainId: e,
711
720
  slippagePercent: s
712
721
  }) => {
713
- const n = Ie(t, e);
714
- return h(Pt, [
722
+ const n = xe(t, e);
723
+ return h(Ut, [
715
724
  {
716
- attestationSignature: ee(t.signature),
725
+ attestationSignature: se(t.signature),
717
726
  quote: n,
718
- amountOutMinimum: Re(
727
+ amountOutMinimum: Me(
719
728
  n.quantity,
720
729
  n.price,
721
730
  s
722
731
  )
723
732
  }
724
733
  ]);
725
- }, Rs = (t) => [...t.reduce(
734
+ }, Ms = (t) => [...t.reduce(
726
735
  (s, n) => s.has(n.accountId) ? s : s.set(n.accountId, n),
727
736
  /* @__PURE__ */ new Map()
728
737
  ).values()].map(({ accountId: s, marketId: n }) => ({
@@ -734,7 +743,7 @@ const Es = (t) => l(t, _e), hs = () => G, fs = /* @__PURE__ */ new Map(), z = (t
734
743
  debt: t.find(
735
744
  (r) => r.accountId === s && r.isDebt
736
745
  )
737
- })), Is = ({
746
+ })), xs = ({
738
747
  collateral: t,
739
748
  dytmOffice: e,
740
749
  processor: s,
@@ -749,8 +758,8 @@ const Es = (t) => l(t, _e), hs = () => G, fs = /* @__PURE__ */ new Map(), z = (t
749
758
  {
750
759
  // 1 · pull GM collateral out of the split account -> processor
751
760
  to: e,
752
- data: g({
753
- abi: k,
761
+ data: y({
762
+ abi: N,
754
763
  functionName: "withdraw",
755
764
  args: [
756
765
  {
@@ -767,8 +776,8 @@ const Es = (t) => l(t, _e), hs = () => G, fs = /* @__PURE__ */ new Map(), z = (t
767
776
  {
768
777
  // 2 · approve the GM token to Ondo's swap contract
769
778
  to: n,
770
- data: g({
771
- abi: W,
779
+ data: y({
780
+ abi: k,
772
781
  functionName: "approve",
773
782
  args: [r, o]
774
783
  })
@@ -776,13 +785,33 @@ const Es = (t) => l(t, _e), hs = () => G, fs = /* @__PURE__ */ new Map(), z = (t
776
785
  {
777
786
  // 3 · redeem GM -> USDC with the signed attestation
778
787
  to: r,
779
- data: g({
780
- abi: $t,
788
+ data: y({
789
+ abi: vt,
781
790
  functionName: "swapExactInWithAttestation",
782
791
  args: [n, o, a, i, c, d]
783
792
  })
784
793
  }
785
- ], Ns = ({
794
+ ], Ls = ({
795
+ collateral: t,
796
+ dytmOffice: e,
797
+ processor: s
798
+ }) => ({
799
+ to: e,
800
+ data: y({
801
+ abi: N,
802
+ functionName: "withdraw",
803
+ args: [
804
+ {
805
+ account: t.accountId,
806
+ tokenId: t.tokenId,
807
+ receiver: s,
808
+ assets: 0n,
809
+ shares: _,
810
+ extraData: "0x"
811
+ }
812
+ ]
813
+ })
814
+ }), Bs = ({
786
815
  accountId: t,
787
816
  debtKey: e,
788
817
  dytmOffice: s,
@@ -791,17 +820,17 @@ const Es = (t) => l(t, _e), hs = () => G, fs = /* @__PURE__ */ new Map(), z = (t
791
820
  {
792
821
  // approve USDC to the DYTM Office for the repay
793
822
  to: n,
794
- data: g({
795
- abi: W,
823
+ data: y({
824
+ abi: k,
796
825
  functionName: "approve",
797
- args: [s, I]
826
+ args: [s, _]
798
827
  })
799
828
  },
800
829
  {
801
830
  // repay the slice's whole USDC debt
802
831
  to: s,
803
- data: g({
804
- abi: k,
832
+ data: y({
833
+ abi: N,
805
834
  functionName: "repay",
806
835
  args: [
807
836
  {
@@ -809,7 +838,7 @@ const Es = (t) => l(t, _e), hs = () => G, fs = /* @__PURE__ */ new Map(), z = (t
809
838
  key: e,
810
839
  withCollateralType: 0,
811
840
  // DytmParamStructs.TokenType.NONE
812
- assets: I,
841
+ assets: _,
813
842
  // repay all
814
843
  shares: 0n,
815
844
  extraData: "0x"
@@ -817,7 +846,7 @@ const Es = (t) => l(t, _e), hs = () => G, fs = /* @__PURE__ */ new Map(), z = (t
817
846
  ]
818
847
  })
819
848
  }
820
- ], Os = ({
849
+ ], Ps = ({
821
850
  actions: t,
822
851
  outputAsset: e,
823
852
  minOutputAmount: s
@@ -825,87 +854,90 @@ const Es = (t) => l(t, _e), hs = () => G, fs = /* @__PURE__ */ new Map(), z = (t
825
854
  { actions: t, outputAsset: e, minOutputAmount: s }
826
855
  ]);
827
856
  export {
828
- bs as $,
829
- se as A,
830
- q as B,
831
- We as C,
832
- C as D,
833
- fs as E,
834
- ps as F,
835
- ls as G,
836
- As as H,
837
- gs as I,
838
- hs as J,
839
- Ze as K,
840
- ae as L,
841
- He as M,
842
- ze as N,
843
- j as O,
844
- cs as P,
845
- Rs as Q,
846
- Ye as R,
847
- ds as S,
848
- S as T,
849
- us as U,
857
+ as as $,
858
+ He as A,
859
+ ne as B,
860
+ j as C,
861
+ qe as D,
862
+ bs as E,
863
+ M as F,
864
+ gs as G,
865
+ Es as H,
866
+ fs as I,
867
+ Ts as J,
868
+ ws as K,
869
+ ns as L,
870
+ re as M,
871
+ Xe as N,
872
+ es as O,
873
+ X as P,
874
+ ms as Q,
875
+ Ms as R,
876
+ Ve as S,
877
+ w as T,
878
+ As as U,
850
879
  ys as V,
851
- Es as W,
852
- Qe as X,
853
- Je as Y,
854
- ms as Z,
855
- Ie as _,
856
- zt as a,
857
- z as a0,
858
- Ve as a1,
859
- es as a2,
860
- ke as a3,
861
- ve as a4,
862
- Xe as a5,
863
- Ge as a6,
864
- p as a7,
865
- O as a8,
866
- Te as a9,
867
- fe as aa,
868
- be as ab,
869
- _s as ac,
870
- ts as ad,
871
- $e as ae,
872
- ss as af,
873
- l as ag,
874
- Ae as ah,
875
- ns as ai,
876
- me as aj,
877
- Be as ak,
878
- Le as al,
879
- _e as am,
880
- ge as an,
881
- Ue as ao,
882
- Ee as ap,
883
- ye as aq,
884
- as as ar,
885
- x as as,
886
- ee as b,
887
- re as c,
888
- we as d,
889
- Is as e,
890
- Ns as f,
891
- ne as g,
892
- je as h,
893
- qe as i,
894
- xe as j,
895
- Re as k,
896
- Ts as l,
880
+ Ss as W,
881
+ _s as X,
882
+ De as Y,
883
+ Ie as Z,
884
+ ss as _,
885
+ Qt as a,
886
+ hs as a0,
887
+ xe as a1,
888
+ Os as a2,
889
+ Q as a3,
890
+ ze as a4,
891
+ os as a5,
892
+ je as a6,
893
+ ke as a7,
894
+ ts as a8,
895
+ Ke as a9,
896
+ l as aa,
897
+ C as ab,
898
+ Te as ac,
899
+ fe as ad,
900
+ Oe as ae,
901
+ Is as af,
902
+ rs as ag,
903
+ Ge as ah,
904
+ is as ai,
905
+ p as aj,
906
+ ge as ak,
907
+ cs as al,
908
+ ye as am,
909
+ Fe as an,
910
+ ve as ao,
911
+ _e as ap,
912
+ Ee as aq,
913
+ We as ar,
914
+ he as as,
915
+ Ae as at,
916
+ us as au,
917
+ L as av,
918
+ se as b,
919
+ oe as c,
920
+ Ne as d,
921
+ xs as e,
922
+ Ls as f,
923
+ Bs as g,
924
+ ae as h,
925
+ Je as i,
926
+ Ze as j,
927
+ $e as k,
928
+ Me as l,
897
929
  Ds as m,
898
- Os as n,
899
- Ss as o,
900
- Pe as p,
901
- E as q,
902
- Se as r,
903
- Zt as s,
904
- he as t,
905
- os as u,
906
- rs as v,
907
- is as w,
908
- ws as x,
909
- Ke as y,
910
- Fe as z
930
+ Cs as n,
931
+ Ps as o,
932
+ Rs as p,
933
+ Ye as q,
934
+ E as r,
935
+ Re as s,
936
+ Jt as t,
937
+ Se as u,
938
+ ps as v,
939
+ ds as w,
940
+ ls as x,
941
+ Ns as y,
942
+ Qe as z
911
943
  };