@dhedge/trading-widget 6.2.0-canary.1 → 6.2.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 { mainnet as S, hyperEvm as j, polygon as X, optimism as z, base as Q, arbitrum as Z } from "wagmi/chains";
2
- import { aq as J, ao as tt, ap as et, a as w, q as D, ar as nt, as as st, a5 as at, ak as rt, a3 as ot, b as it, ae as ct, Z as F, aj as ut, at as $, e as dt, d as pt, M as mt, R as lt, P as yt, au as At, av as Et, Q as gt, N as ht, ah as _, _ as ft, W as _t, X as Tt, U as St, aw as v, ax as wt, ay as Dt, az as bt, aA as It, aB as Nt, ad as Rt } from "./gmx-Cyz_GmV5.js";
1
+ import { mainnet as w, hyperEvm as z, polygon as Q, optimism as Z, base as J, arbitrum as tt } from "wagmi/chains";
2
+ import { aq as et, ao as nt, ap as st, a as b, q as D, ar as at, as as rt, a5 as ot, ak as it, a3 as ct, b as ut, ae as dt, Z as F, aj as pt, at as v, e as lt, d as mt, M as yt, R as At, P as gt, au as Et, av as ht, Q as ft, N as Tt, ah as T, _ as _t, W as St, X as wt, U as bt, aw as Y, ax as Dt, ay as Rt, az as It, aA as Nt, aB as Ot, ad as Ct } from "./gmx-Cyz_GmV5.js";
3
3
  import u from "bignumber.js";
4
- import { zeroHash as Ot, bytesToHex as Ct, pad as Mt, stringToHex as b, encodeAbiParameters as h, encodeFunctionData as E, erc20Abi as G, maxUint256 as I } from "viem";
5
- const Ce = typeof window < "u", Me = [
4
+ import { zeroHash as Mt, bytesToHex as xt, pad as Lt, stringToHex as R, encodeAbiParameters as h, encodeFunctionData as g, erc20Abi as G, maxUint256 as I } from "viem";
5
+ const xe = typeof window < "u", Le = [
6
6
  {
7
7
  inputs: [
8
8
  { internalType: "address", name: "_pool", type: "address" },
@@ -30,7 +30,7 @@ const Ce = typeof window < "u", Me = [
30
30
  stateMutability: "view",
31
31
  type: "function"
32
32
  }
33
- ], Lt = [
33
+ ], Bt = [
34
34
  {
35
35
  type: "tuple",
36
36
  components: [
@@ -53,7 +53,7 @@ const Ce = typeof window < "u", Me = [
53
53
  { name: "amountOutMinimum", type: "uint256" }
54
54
  ]
55
55
  }
56
- ], Bt = [
56
+ ], Pt = [
57
57
  { name: "asset", type: "address" },
58
58
  { name: "amount", type: "uint256" },
59
59
  { name: "assetType", type: "uint16" },
@@ -64,7 +64,7 @@ const Ce = typeof window < "u", Me = [
64
64
  { name: "tokenId", type: "uint256" },
65
65
  { name: "debtKey", type: "uint248" },
66
66
  { name: "shares", type: "uint256" }
67
- ], Le = [
67
+ ], Be = [
68
68
  {
69
69
  inputs: [
70
70
  { internalType: "address", name: "_pool", type: "address" },
@@ -75,7 +75,7 @@ const Ce = typeof window < "u", Me = [
75
75
  {
76
76
  name: "assetData",
77
77
  type: "tuple[]",
78
- components: Bt
78
+ components: Pt
79
79
  }
80
80
  ],
81
81
  stateMutability: "nonpayable",
@@ -88,7 +88,7 @@ const Ce = typeof window < "u", Me = [
88
88
  stateMutability: "view",
89
89
  type: "function"
90
90
  }
91
- ], Y = [
91
+ ], W = [
92
92
  {
93
93
  inputs: [
94
94
  {
@@ -130,7 +130,7 @@ const Ce = typeof window < "u", Me = [
130
130
  stateMutability: "nonpayable",
131
131
  type: "function"
132
132
  }
133
- ], xt = [
133
+ ], Ut = [
134
134
  {
135
135
  inputs: [
136
136
  { name: "tokenIn", type: "address" },
@@ -159,7 +159,7 @@ const Ce = typeof window < "u", Me = [
159
159
  stateMutability: "nonpayable",
160
160
  type: "function"
161
161
  }
162
- ], Pt = [
162
+ ], $t = [
163
163
  {
164
164
  type: "tuple",
165
165
  components: [
@@ -175,25 +175,60 @@ const Ce = typeof window < "u", Me = [
175
175
  { name: "minOutputAmount", type: "uint256" }
176
176
  ]
177
177
  }
178
- ], Ut = [
178
+ ], S = {
179
+ stringErrors: {
180
+ // Ondo tokenized assets trade only during market hours; the full message
181
+ // includes a dynamic reopen time (e.g. "QUBTon is currently closed for
182
+ // trading. It will be open in 29 minutes."), so there is no fixed literal
183
+ // the registry could key on.
184
+ "currently closed for trading": {
185
+ title: "The market for this tokenized asset is closed right now",
186
+ hint: "Wait until the market reopens (the error message says when) and simply retry."
187
+ },
188
+ // Synthetix revert hit when a vault still holds deprecated synths.
189
+ "Synth exchange suspended. Operation prohibited": {
190
+ title: "Vault includes deprecated synths in portfolio",
191
+ hint: "Redeem deprecated synth to be able to withdraw."
192
+ }
193
+ },
194
+ selectorErrors: {
195
+ // EasySwapperV2 swap periphery (see core-kit/abi/easy-swapper-v2.ts).
196
+ "0x54971d46": {
197
+ signature: "SwapFailed(address,(address,uint256,(bytes32,bytes)),bytes)",
198
+ title: "The token swap failed to execute",
199
+ hint: "Your assets are still in your wallet — try again, or retry with a higher slippage tolerance."
200
+ },
201
+ "0x81a815ef": {
202
+ signature: "InsufficientAmountReceived(address,uint256,uint256)",
203
+ title: "Swap output was below the minimum received amount",
204
+ hint: "Increase slippage tolerance and try again."
205
+ }
206
+ }
207
+ }, k = (t) => ({
208
+ stringErrors: {
209
+ ...t.stringErrors,
210
+ ...S.stringErrors
211
+ },
212
+ selectorErrors: {
213
+ ...t.selectorErrors,
214
+ ...S.selectorErrors
215
+ }
216
+ }), Ft = [
179
217
  "https://cdn.jsdelivr.net/gh/dhedge/V2-Public@master/readmes/errorCodes/registry.json",
180
218
  "https://raw.githubusercontent.com/dhedge/V2-Public/master/readmes/errorCodes/registry.json"
181
- ], Ft = 1, $t = 1e4, N = 2e6, vt = 2e3, Gt = 500, Yt = 120, Wt = 300, Ht = 4, Kt = /^dh\d{1,3}$/i, W = /[\u0000-\u001f\u007f]/, Vt = /https?:\/\/|[<>`]/i, kt = (t) => t.length <= Yt && !W.test(t) && (Kt.test(t) || t.length >= Ht), A = (t) => typeof t == "string" && t.length > 0 && t.length <= Wt && !W.test(t) && !Vt.test(t), qt = {
182
- stringErrors: {},
183
- selectorErrors: {}
184
- };
185
- let H = qt, T = null;
186
- const K = () => H, jt = (t) => {
187
- H = t;
188
- }, Xt = (t) => {
219
+ ], vt = 1, Yt = 1e4, N = 2e6, Gt = 2e3, Wt = 500, kt = 120, Ht = 300, Vt = 4, Kt = /^dh\d{1,3}$/i, H = /[\u0000-\u001f\u007f]/, qt = /https?:\/\/|[<>`]/i, jt = (t) => t.length <= kt && !H.test(t) && (Kt.test(t) || t.length >= Vt), A = (t) => typeof t == "string" && t.length > 0 && t.length <= Ht && !H.test(t) && !qt.test(t);
220
+ let V = S, _ = null;
221
+ const K = () => V, Xt = (t) => {
222
+ V = k(t);
223
+ }, zt = (t) => {
189
224
  const e = t;
190
- if (e?.schemaVersion !== Ft)
225
+ if (e?.schemaVersion !== vt)
191
226
  throw new Error(
192
227
  `Unsupported error registry schemaVersion: ${String(e?.schemaVersion)}`
193
228
  );
194
229
  const n = {};
195
230
  for (const [r, a] of Object.entries(e.stringErrors ?? {}))
196
- a?.curated === !0 && kt(r) && A(a.description) && A(a.action) && (n[r] = { title: a.description, hint: a.action });
231
+ a?.curated === !0 && jt(r) && A(a.description) && A(a.action) && (n[r] = { title: a.description, hint: a.action });
197
232
  const s = {};
198
233
  for (const [r, a] of Object.entries(e.selectorErrors ?? {}))
199
234
  a?.curated === !0 && /^0x[0-9a-f]{8}$/.test(r) && A(a.signature) && A(a.description) && A(a.action) && (s[r] = {
@@ -203,14 +238,14 @@ const K = () => H, jt = (t) => {
203
238
  });
204
239
  if (!Object.keys(n).length)
205
240
  throw new Error("Error registry contained no curated string errors");
206
- if (Object.keys(n).length > vt || Object.keys(s).length > Gt)
241
+ if (Object.keys(n).length > Gt || Object.keys(s).length > Wt)
207
242
  throw new Error("Error registry exceeded expected entry counts");
208
243
  return { stringErrors: n, selectorErrors: s };
209
- }, zt = async ({
210
- timeoutMs: t = $t
244
+ }, Qt = async ({
245
+ timeoutMs: t = Yt
211
246
  } = {}) => {
212
247
  const e = [];
213
- for (const n of Ut) {
248
+ for (const n of Ft) {
214
249
  const s = new AbortController(), r = setTimeout(() => s.abort(), t);
215
250
  try {
216
251
  const a = await fetch(n, {
@@ -224,7 +259,7 @@ const K = () => H, jt = (t) => {
224
259
  const i = await a.text();
225
260
  if (i.length > N)
226
261
  throw new Error(`Response too large: ${i.length} chars`);
227
- return Xt(JSON.parse(i));
262
+ return k(zt(JSON.parse(i)));
228
263
  } catch (a) {
229
264
  e.push(
230
265
  `${n}: ${a instanceof Error ? a.message : String(a)}`
@@ -234,15 +269,15 @@ const K = () => H, jt = (t) => {
234
269
  }
235
270
  }
236
271
  throw new Error(`All error registry sources failed: ${e.join("; ")}`);
237
- }, Be = () => (T ?? (T = zt().then(jt).catch(() => {
238
- T = null;
239
- })), T), Qt = () => typeof window < "u";
240
- function Zt() {
241
- return Qt() && typeof window.ethereum < "u";
272
+ }, Pe = () => (_ ?? (_ = Qt().then(Xt).catch(() => {
273
+ _ = null;
274
+ })), _), Zt = () => typeof window < "u";
275
+ function Jt() {
276
+ return Zt() && typeof window.ethereum < "u";
242
277
  }
243
- async function xe(t) {
278
+ async function Ue(t) {
244
279
  try {
245
- if (Zt())
280
+ if (Jt())
246
281
  return window.ethereum.request({
247
282
  method: "wallet_watchAsset",
248
283
  params: {
@@ -255,7 +290,7 @@ async function xe(t) {
255
290
  }
256
291
  return !1;
257
292
  }
258
- const m = (t, e) => t?.toLowerCase() === e?.toLowerCase(), Pe = (t) => m(t, J), g = (t) => {
293
+ const l = (t, e) => t?.toLowerCase() === e?.toLowerCase(), $e = (t) => l(t, et), E = (t) => {
259
294
  if (!t) throw new Error("Cannot prefix an empty hex value");
260
295
  return t.startsWith("0x") ? t : `0x${t}`;
261
296
  }, p = (t, e) => {
@@ -264,30 +299,30 @@ const m = (t, e) => t?.toLowerCase() === e?.toLowerCase(), Pe = (t) => m(t, J),
264
299
  } catch {
265
300
  throw new Error(`Cannot convert "${e}" value "${t}" to bigint`);
266
301
  }
267
- }, R = (t) => t ? Mt(g(t), { size: 32 }) : Ot, Jt = (t) => {
302
+ }, O = (t) => t ? Lt(E(t), { size: 32 }) : Mt, te = (t) => {
268
303
  if (!t) throw new Error("Cannot decode an empty base64 string");
269
- return Ct(Uint8Array.from(atob(t), (e) => e.charCodeAt(0)));
270
- }, te = (t, e) => et[e]?.[t] ?? w, Ue = (t) => tt[t], Fe = (t) => t && `${t.substring(0, 6)}...${t.substring(
304
+ return xt(Uint8Array.from(atob(t), (e) => e.charCodeAt(0)));
305
+ }, ee = (t, e) => st[e]?.[t] ?? b, Fe = (t) => nt[t], ve = (t) => t && `${t.substring(0, 6)}...${t.substring(
271
306
  t.length - 4,
272
307
  t.length
273
- )}`, $e = ({
308
+ )}`, Ye = ({
274
309
  address: t,
275
310
  chainId: e
276
311
  }) => {
277
- const n = te(
312
+ const n = ee(
278
313
  "aaveLendingPoolV3",
279
314
  e
280
315
  );
281
- return m(t, n);
282
- }, ee = ({
316
+ return l(t, n);
317
+ }, ne = ({
283
318
  sourceAddress: t,
284
319
  amount: e
285
- }) => `${t}_${e}`, ve = (t, e) => {
320
+ }) => `${t}_${e}`, Ge = (t, e) => {
286
321
  const n = t.slice(0, e), s = t.slice(e);
287
322
  return { firstPart: n, secondPart: s };
288
- }, ne = (t, e) => t / e * 100, Ge = (t) => t < 1 ? 4 : t < 10 ? 3 : 2, Ye = (t, e = D) => new u(t.toString()).shiftedBy(e).toFixed(0), We = (t, e, n, s) => new u(e).dividedBy(n).multipliedBy(t).shiftedBy(-(s || D)).toNumber(), He = (t) => BigInt(
323
+ }, se = (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, n, s) => new u(e).dividedBy(n).multipliedBy(t).shiftedBy(-(s || D)).toNumber(), Ve = (t) => BigInt(
289
324
  new u(t || "0").shiftedBy(D).toFixed(0, u.ROUND_DOWN)
290
- ), se = (t) => {
325
+ ), ae = (t) => {
291
326
  const e = new u(0.01), n = new u(t), s = !n.isZero() && n.lt(e) ? e : n;
292
327
  return BigInt(s.multipliedBy(100).toFixed(0));
293
328
  }, Ke = ({
@@ -301,9 +336,9 @@ const m = (t, e) => t?.toLowerCase() === e?.toLowerCase(), Pe = (t) => m(t, J),
301
336
  swapDestinationAmount: i,
302
337
  swapSlippage: c
303
338
  }) => {
304
- const d = new u(i).multipliedBy(1 - c / 100).toFixed(0), l = [b(o, { size: 32 }), e];
305
- return [t, [[n, s, l], [r, d]], a];
306
- }, Ve = ({
339
+ const d = new u(i).multipliedBy(1 - c / 100).toFixed(0), m = [R(o, { size: 32 }), e];
340
+ return [t, [[n, s, m], [r, d]], a];
341
+ }, qe = ({
307
342
  receiveAssetAddress: t,
308
343
  assets: e,
309
344
  swapData: n,
@@ -316,10 +351,10 @@ const m = (t, e) => t?.toLowerCase() === e?.toLowerCase(), Pe = (t) => m(t, J),
316
351
  const d = n?.[c.address];
317
352
  if (!d)
318
353
  return i;
319
- const l = [
320
- b(d.routerKey, { size: 32 }),
354
+ const m = [
355
+ R(d.routerKey, { size: 32 }),
321
356
  d.rawTransaction.data
322
- ], y = [c.address, c.rawBalance, l];
357
+ ], y = [c.address, c.rawBalance, m];
323
358
  return {
324
359
  srcData: [...i.srcData, y],
325
360
  destAmount: i.destAmount.plus(d.destinationAmount)
@@ -332,7 +367,7 @@ const m = (t, e) => t?.toLowerCase() === e?.toLowerCase(), Pe = (t) => m(t, J),
332
367
  o.times(1 - s / 100).toFixed(0, u.ROUND_DOWN)
333
368
  ]
334
369
  ];
335
- }, ae = ({
370
+ }, re = ({
336
371
  assetAddress: t,
337
372
  swapQuotes: e,
338
373
  swapParams: n,
@@ -345,23 +380,23 @@ const m = (t, e) => t?.toLowerCase() === e?.toLowerCase(), Pe = (t) => m(t, J),
345
380
  withdrawData: "",
346
381
  slippageTolerance: BigInt(0)
347
382
  };
348
- const { srcData: a, dstData: o } = n, i = a.map(({ asset: l, amount: y }) => {
349
- const f = e?.[ee({
350
- sourceAddress: l,
383
+ const { srcData: a, dstData: o } = n, i = a.map(({ asset: m, amount: y }) => {
384
+ const f = e?.[ne({
385
+ sourceAddress: m,
351
386
  amount: y.toString()
352
- })]?.find((q) => q.routerKey === r);
387
+ })]?.find((X) => X.routerKey === r);
353
388
  return {
354
- asset: l,
389
+ asset: m,
355
390
  amount: y,
356
391
  swapData: {
357
- routerKey: b(f?.routerKey ?? "", { size: 32 }),
392
+ routerKey: R(f?.routerKey ?? "", { size: 32 }),
358
393
  txData: f?.rawTransaction.data ?? "0x"
359
394
  }
360
395
  };
361
396
  }), c = h(
362
- nt,
397
+ at,
363
398
  [i]
364
- ), d = h(st, [
399
+ ), d = h(rt, [
365
400
  {
366
401
  encodedSrcData: c,
367
402
  dstData: {
@@ -376,29 +411,29 @@ const m = (t, e) => t?.toLowerCase() === e?.toLowerCase(), Pe = (t) => m(t, J),
376
411
  withdrawData: d,
377
412
  slippageTolerance: s
378
413
  };
379
- }, ke = ({
414
+ }, je = ({
380
415
  chainId: t,
381
416
  txHash: e,
382
417
  error: n
383
418
  }) => {
384
- if (t !== S.id || !e || !n)
419
+ if (t !== w.id || !e || !n)
385
420
  return !1;
386
421
  const s = n instanceof Error ? n.message : String(n);
387
422
  return /\bNo Result\b/i.test(s);
388
- }, qe = ({
423
+ }, Xe = ({
389
424
  chainId: t,
390
425
  action: e,
391
426
  isRabbyWallet: n
392
- }) => e === "update_ondo_prices" && t === S.id && n ? at : t ? rt[t] ?? 0 : 0, je = (t, e) => it[e]?.nativeTokenSymbol === t, Xe = ({
427
+ }) => e === "update_ondo_prices" && t === w.id && n ? ot : t ? it[t] ?? 0 : 0, ze = (t, e) => ut[e]?.nativeTokenSymbol === t, Qe = ({
393
428
  nativeTokenBalance: t,
394
429
  tokenDecimals: e,
395
430
  gasPrice: n
396
431
  }) => {
397
- const s = new u(n).multipliedBy(ot).shiftedBy(-e), r = new u(t).minus(
432
+ const s = new u(n).multipliedBy(ct).shiftedBy(-e), r = new u(t).minus(
398
433
  s
399
434
  );
400
435
  return r.gt("0") ? r : new u("0");
401
- }, ze = (t) => ct.includes(t), Qe = (t) => {
436
+ }, Ze = (t) => dt.includes(t), Je = (t) => {
402
437
  const e = Object.values(t).reduce(
403
438
  (n, { type: s }) => (n[s] = n[s] + 1, n),
404
439
  { string: 0, number: 0 }
@@ -408,19 +443,26 @@ const m = (t, e) => t?.toLowerCase() === e?.toLowerCase(), Pe = (t) => m(t, J),
408
443
  if (e.number > 40)
409
444
  throw new Error("logger params must contain up to 40 numeric values");
410
445
  return !0;
411
- }, re = (t, e = 150) => t.length > e ? t.substring(0, e) : t, V = () => ({
446
+ }, oe = (t, e = 150) => t.length > e ? t.substring(0, e) : t, q = () => ({
412
447
  ...K().stringErrors,
413
- ...ut
414
- }), oe = () => [
415
- ...Object.keys(V()),
448
+ ...pt
449
+ }), ie = () => [
450
+ ...Object.keys(q()),
416
451
  ...Object.keys(F)
417
- ], ie = /^dh\d+$/i, ce = (t, e) => ie.test(e) ? new RegExp(`\\b${e}\\b`, "i").test(t) : t.includes(e.toLowerCase()), O = (t, e) => {
452
+ ], 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) => {
418
453
  const n = t.toLowerCase();
419
- return [...e ?? oe()].sort((s, r) => r.length - s.length).find((s) => ce(n, s));
420
- }, C = (t) => V()[t] ?? F[t], ue = /\b0x[0-9a-f]{8}\b/i, de = (t) => {
421
- const e = t.match(ue)?.[0]?.toLowerCase(), n = e ? K().selectorErrors[e] : void 0;
422
- return n ? { title: n.title, hint: n.hint } : void 0;
423
- }, Ze = ({
454
+ return [...e ?? ie()].sort((s, r) => r.length - s.length).find((s) => ue(n, s));
455
+ }, M = (t) => q()[t] ?? F[t], de = /\b0x[0-9a-f]{8}\b/i, pe = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), le = (t) => {
456
+ const { selectorErrors: e } = K(), n = t.match(de)?.[0]?.toLowerCase(), s = n ? e[n] : void 0;
457
+ if (s)
458
+ return { title: s.title, hint: s.hint };
459
+ const r = Object.values(e).find(
460
+ (a) => new RegExp(
461
+ `\\b${pe(a.signature.split("(")[0] ?? "")}\\b`
462
+ ).test(t)
463
+ );
464
+ return r ? { title: r.title, hint: r.hint } : void 0;
465
+ }, tn = ({
424
466
  errorMessage: t,
425
467
  abiErrors: e
426
468
  }) => {
@@ -428,22 +470,22 @@ const m = (t, e) => t?.toLowerCase() === e?.toLowerCase(), Pe = (t) => m(t, J),
428
470
  return null;
429
471
  const n = e.find((o) => t.includes(o));
430
472
  if (n) {
431
- const o = O(n);
473
+ const o = C(n);
432
474
  if (o)
433
- return C(o);
475
+ return M(o);
434
476
  }
435
- const s = O(t);
477
+ const s = C(t);
436
478
  if (s)
437
- return C(s);
438
- const r = de(t);
479
+ return M(s);
480
+ const r = le(t);
439
481
  if (r)
440
482
  return r;
441
483
  const [a] = t.split(n ? "." : "Contract").map((o) => o.trim());
442
484
  return {
443
485
  title: "Transaction failed",
444
- hint: `${re(a ?? "")} ${n ? `: ${n}` : ""}`
486
+ hint: `${oe(a ?? "")} ${n ? `: ${n}` : ""}`
445
487
  };
446
- }, Je = (t) => typeof t == "number" && Number.isFinite(t), tn = (t) => typeof t == "bigint" && t !== BigInt(0), pe = (t, e = $) => new u(t).shiftedBy(-e).toNumber(), me = (t) => !isNaN(parseFloat(t)) && !isNaN(t), le = ({
488
+ }, en = (t) => typeof t == "number" && Number.isFinite(t), nn = (t) => typeof t == "bigint" && t !== BigInt(0), me = (t, e = v) => new u(t).shiftedBy(-e).toNumber(), ye = (t) => !isNaN(parseFloat(t)) && !isNaN(t), Ae = ({
447
489
  value: t,
448
490
  minimumFractionDigits: e = 2,
449
491
  maximumFractionDigits: n = 2,
@@ -455,42 +497,42 @@ const m = (t, e) => t?.toLowerCase() === e?.toLowerCase(), Pe = (t) => m(t, J),
455
497
  notation: s ? "compact" : void 0,
456
498
  minimumFractionDigits: e,
457
499
  maximumFractionDigits: n
458
- }).format(r ? pe(t) : Number(t)), M = (t) => me(t) ? new u(t).toFixed() : "", L = ["₀", "₁", "₂", "₃", "₄", "₅", "₆", "₇", "₈", "₉"], ye = ({
500
+ }).format(r ? me(t) : Number(t)), x = (t) => ye(t) ? new u(t).toFixed() : "", L = ["₀", "₁", "₂", "₃", "₄", "₅", "₆", "₇", "₈", "₉"], ge = ({
459
501
  value: t,
460
502
  decimals: e = 4
461
503
  }) => {
462
504
  const n = new u(t);
463
505
  if (n.isGreaterThan(1) || n.isZero())
464
- return M(n.toFixed(e));
465
- const r = (/e/i.test(t.toString()) ? parseFloat(t.toString()).toFixed($) : t.toString()).match(/^0\.(0+)(\d+)$/);
506
+ return x(n.toFixed(e));
507
+ const r = (/e/i.test(t.toString()) ? parseFloat(t.toString()).toFixed(v) : t.toString()).match(/^0\.(0+)(\d+)$/);
466
508
  if (r) {
467
509
  const [, a, o] = r;
468
510
  if (a.length >= e && a.length < L.length)
469
511
  return `0.0${L[a.length]}${o.slice(0, 3)}`;
470
512
  }
471
- return M(n.toFixed(e));
472
- }, Ae = (t, e = 0) => `${t.toLocaleString("en-US", { maximumFractionDigits: e })}%`, en = (t) => t.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), nn = (t, e, n = 0) => {
473
- const s = ne(+t, e);
474
- return Ae(s, n);
475
- }, sn = ({
513
+ return x(n.toFixed(e));
514
+ }, Ee = (t, e = 0) => `${t.toLocaleString("en-US", { maximumFractionDigits: e })}%`, sn = (t) => t.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), an = (t, e, n = 0) => {
515
+ const s = se(+t, e);
516
+ return Ee(s, n);
517
+ }, rn = ({
476
518
  currency: t,
477
519
  value: e
478
- }) => t === "USD" ? le({ value: e }) : `${dt[t]} ${ye({
520
+ }) => t === "USD" ? Ae({ value: e }) : `${lt[t]} ${ge({
479
521
  value: e,
480
- decimals: pt[t]
481
- })}`, Ee = (t, e) => new u(
522
+ decimals: mt[t]
523
+ })}`, he = (t, e) => new u(
482
524
  new u(t).toFixed(e, u.ROUND_DOWN)
483
- ).toString(), ge = (t, e = 3, n = 2) => {
525
+ ).toString(), fe = (t, e = 3, n = 2) => {
484
526
  if (t.length <= 5)
485
527
  return t;
486
528
  const s = "...";
487
529
  return t.length <= e + n + s.length ? t : `${t.slice(0, e)}${s}${t.slice(-n)}`;
488
- }, an = ({
530
+ }, on = ({
489
531
  balance: t,
490
532
  symbol: e,
491
533
  precision: n,
492
534
  truncateSymbol: s
493
- }) => `${Ee(t, n)} ${s ? ge(e) : e}`, rn = (t) => {
535
+ }) => `${he(t, n)} ${s ? fe(e) : e}`, cn = (t) => {
494
536
  if (!t)
495
537
  return;
496
538
  const e = t.match(/0x[a-fA-F0-9]{64}/);
@@ -498,13 +540,13 @@ const m = (t, e) => t?.toLowerCase() === e?.toLowerCase(), Pe = (t) => m(t, J),
498
540
  return;
499
541
  const n = e[0];
500
542
  return `${n.slice(0, 4)}...${n.slice(-3)}`;
501
- }, on = (t) => m(At, t) || m(Et, t), cn = (t) => ht.some(
502
- (e) => m(e, t)
503
- ), un = (t) => mt[t.toLowerCase()] ?? {
543
+ }, un = (t) => l(Et, t) || l(ht, t), dn = (t) => Tt.some(
544
+ (e) => l(e, t)
545
+ ), pn = (t) => yt[t.toLowerCase()] ?? {
504
546
  symbol: "",
505
547
  decimals: 18,
506
- address: w
507
- }, dn = (t) => m(t, gt) ? lt : yt, he = (t) => `eth_${t}`, pn = ({
548
+ address: b
549
+ }, ln = (t) => l(t, ft) ? At : gt, Te = (t) => `eth_${t}`, mn = ({
508
550
  action: t,
509
551
  log: e,
510
552
  symbol: n,
@@ -512,20 +554,20 @@ const m = (t, e) => t?.toLowerCase() === e?.toLowerCase(), Pe = (t) => m(t, J),
512
554
  chainId: r
513
555
  }) => {
514
556
  const a = {
515
- [_.SYMBOL.NAME]: n,
516
- [_.CHAIN_ID.NAME]: r,
517
- [_.ADDRESS.NAME]: he(s)
557
+ [T.SYMBOL.NAME]: n,
558
+ [T.CHAIN_ID.NAME]: r,
559
+ [T.ADDRESS.NAME]: Te(s)
518
560
  };
519
- ft[t].forEach((o) => {
561
+ _t[t].forEach((o) => {
520
562
  e?.(o, a);
521
563
  });
522
- }, mn = (t) => St.some((e) => m(e, t)), ln = (t) => _t[t.toLowerCase()] ?? {
564
+ }, yn = (t) => bt.some((e) => l(e, t)), An = (t) => St[t.toLowerCase()] ?? {
523
565
  symbol: "",
524
566
  decimals: 18,
525
- address: w
526
- }, yn = (t) => Tt[t.toLowerCase()], fe = "0x3333333333333333333333333333333333333333";
527
- Z.id + "", Nt.address, Q.id + "", It.address, z.id + "", bt.address, X.id + "", Dt.address, S.id + "", wt.address, j.id + "", v.address;
528
- const An = (t) => m(t, fe), En = () => v, gn = /* @__PURE__ */ new Map(), k = (t, e) => !e || e.size === 0 ? t : t.map((n) => {
567
+ address: b
568
+ }, gn = (t) => wt[t.toLowerCase()], _e = "0x3333333333333333333333333333333333333333";
569
+ tt.id + "", Ot.address, J.id + "", Nt.address, Z.id + "", It.address, Q.id + "", Rt.address, w.id + "", Dt.address, z.id + "", Y.address;
570
+ const En = (t) => l(t, _e), hn = () => Y, fn = /* @__PURE__ */ new Map(), j = (t, e) => !e || e.size === 0 ? t : t.map((n) => {
529
571
  const s = e.get(
530
572
  n.supportedAsset.toLowerCase()
531
573
  );
@@ -534,27 +576,27 @@ const An = (t) => m(t, fe), En = () => v, gn = /* @__PURE__ */ new Map(), k = (t
534
576
  withdrawData: s.withdrawData,
535
577
  slippageTolerance: s.slippageTolerance
536
578
  } : n;
537
- }), _e = (t) => {
579
+ }), Se = (t) => {
538
580
  const e = t.find(
539
581
  ({ swapQuotes: n }) => n
540
582
  );
541
583
  return e?.swapQuotes ? Object.values(e.swapQuotes)[0]?.map(
542
584
  ({ routerKey: n }) => n
543
585
  ) ?? [] : [];
544
- }, Te = (t, e, n) => t.map(({ asset: s, swapParams: r, swapQuotes: a }) => !r || !a ? {
586
+ }, we = (t, e, n) => t.map(({ asset: s, swapParams: r, swapQuotes: a }) => !r || !a ? {
545
587
  supportedAsset: s,
546
588
  withdrawData: "",
547
589
  slippageTolerance: n
548
- } : ae({
590
+ } : re({
549
591
  assetAddress: s,
550
592
  swapQuotes: a,
551
593
  swapParams: r,
552
594
  slippageToleranceForContractTransaction: n,
553
595
  routerKey: e
554
- })), Se = async (t, e, n, s, r, a) => {
596
+ })), be = async (t, e, n, s, r, a) => {
555
597
  for (const o of t) {
556
- const i = k(
557
- Te(
598
+ const i = j(
599
+ we(
558
600
  e,
559
601
  o,
560
602
  n
@@ -565,20 +607,20 @@ const An = (t) => m(t, fe), En = () => v, gn = /* @__PURE__ */ new Map(), k = (t
565
607
  return i;
566
608
  }
567
609
  return null;
568
- }, hn = (t, e, n) => {
610
+ }, Tn = (t, e, n) => {
569
611
  const s = (t ?? []).map((r) => ({
570
612
  supportedAsset: r,
571
613
  withdrawData: "",
572
614
  slippageTolerance: e
573
615
  }));
574
- return k(s, n);
575
- }, fn = async (t, e, n, s, r) => {
616
+ return j(s, n);
617
+ }, _n = async (t, e, n, s, r) => {
576
618
  for (const a of t) {
577
- const o = se(a);
619
+ const o = ae(a);
578
620
  try {
579
- const i = await e(a), c = _e(
621
+ const i = await e(a), c = Se(
580
622
  i
581
- ), d = await Se(
623
+ ), d = await be(
582
624
  c,
583
625
  i,
584
626
  o,
@@ -598,14 +640,14 @@ const An = (t) => m(t, fe), En = () => v, gn = /* @__PURE__ */ new Map(), k = (t
598
640
  }
599
641
  }
600
642
  return null;
601
- }, _n = async (t, e, {
643
+ }, Sn = async (t, e, {
602
644
  fetchAaveSwapParams: n,
603
645
  fetchAaveSwapQuotes: s,
604
646
  withdrawAmountD18: r,
605
647
  slippage: a
606
648
  }) => Promise.all(
607
649
  (t ?? []).map(async (o) => {
608
- if (!m(o, e))
650
+ if (!l(o, e))
609
651
  return { asset: o };
610
652
  try {
611
653
  const c = await n({
@@ -624,60 +666,60 @@ const An = (t) => m(t, fe), En = () => v, gn = /* @__PURE__ */ new Map(), k = (t
624
666
  return console.error(c), { asset: o };
625
667
  }
626
668
  })
627
- ), B = (t) => Math.round(t * 100) / 100, Tn = ({
669
+ ), B = (t) => Math.round(t * 100) / 100, wn = ({
628
670
  maxSlippage: t,
629
- candidates: e = Rt
671
+ candidates: e = Ct
630
672
  }) => {
631
673
  if (!Number.isFinite(t) || t <= 0)
632
674
  return [];
633
675
  const n = B(Math.min(t, 100)), s = e.filter((a) => a > 0 && a <= n).map(B), r = new Set(s);
634
676
  return r.add(n), r.add(t), Array.from(r).sort((a, o) => a - o);
635
- }, x = 1000000000000000000n, we = 1000000n, P = 10000n, U = 100n, Sn = (t) => ({
677
+ }, P = 1000000000000000000n, De = 1000000n, U = 10000n, $ = 100n, bn = (t) => ({
636
678
  quotes: t.quotes.map(
637
679
  (e) => ({
638
680
  chainId: p(e.chainId, "chainId"),
639
681
  attestationId: p(e.attestationId, "attestationId"),
640
- userId: g(e.userId),
682
+ userId: E(e.userId),
641
683
  asset: e.asset,
642
684
  price: p(e.price, "price"),
643
685
  quantity: p(e.quantity, "quantity"),
644
686
  expiration: p(e.expiration, "expiration"),
645
687
  side: Number(e.side),
646
- additionalData: g(e.additionalData)
688
+ additionalData: E(e.additionalData)
647
689
  })
648
690
  ),
649
- signatures: t.signatures.map(g)
650
- }), De = (t, e, n) => {
651
- const s = BigInt(Math.max(0, Math.round(n * 100))), r = s > U ? U : s, a = P - r, i = t * e / x * a * we, c = P * x;
691
+ signatures: t.signatures.map(E)
692
+ }), Re = (t, e, n) => {
693
+ const s = BigInt(Math.max(0, Math.round(n * 100))), r = s > $ ? $ : s, a = U - r, i = t * e / P * a * De, c = U * P;
652
694
  return (i + c - 1n) / c;
653
- }, be = (t, e) => ({
695
+ }, Ie = (t, e) => ({
654
696
  chainId: e,
655
697
  attestationId: p(t.attestationId, "attestationId"),
656
- userId: R(t.userId),
698
+ userId: O(t.userId),
657
699
  asset: t.assetAddress,
658
700
  price: p(t.price, "price"),
659
701
  quantity: p(t.tokenAmount, "tokenAmount"),
660
702
  expiration: p(t.expiration, "expiration"),
661
703
  side: Number(t.side),
662
- additionalData: R(t.additionalData)
663
- }), wn = ({
704
+ additionalData: O(t.additionalData)
705
+ }), Dn = ({
664
706
  attestation: t,
665
707
  chainId: e,
666
708
  slippagePercent: n
667
709
  }) => {
668
- const s = be(t, e);
669
- return h(Lt, [
710
+ const s = Ie(t, e);
711
+ return h(Bt, [
670
712
  {
671
- attestationSignature: Jt(t.signature),
713
+ attestationSignature: te(t.signature),
672
714
  quote: s,
673
- amountOutMinimum: De(
715
+ amountOutMinimum: Re(
674
716
  s.quantity,
675
717
  s.price,
676
718
  n
677
719
  )
678
720
  }
679
721
  ]);
680
- }, Dn = (t) => [...t.reduce(
722
+ }, Rn = (t) => [...t.reduce(
681
723
  (n, s) => n.has(s.accountId) ? n : n.set(s.accountId, s),
682
724
  /* @__PURE__ */ new Map()
683
725
  ).values()].map(({ accountId: n, marketId: s }) => ({
@@ -689,7 +731,7 @@ const An = (t) => m(t, fe), En = () => v, gn = /* @__PURE__ */ new Map(), k = (t
689
731
  debt: t.find(
690
732
  (r) => r.accountId === n && r.isDebt
691
733
  )
692
- })), bn = ({
734
+ })), In = ({
693
735
  collateral: t,
694
736
  dytmOffice: e,
695
737
  processor: n,
@@ -704,8 +746,8 @@ const An = (t) => m(t, fe), En = () => v, gn = /* @__PURE__ */ new Map(), k = (t
704
746
  {
705
747
  // 1 · pull GM collateral out of the split account -> processor
706
748
  to: e,
707
- data: E({
708
- abi: Y,
749
+ data: g({
750
+ abi: W,
709
751
  functionName: "withdraw",
710
752
  args: [
711
753
  {
@@ -722,7 +764,7 @@ const An = (t) => m(t, fe), En = () => v, gn = /* @__PURE__ */ new Map(), k = (t
722
764
  {
723
765
  // 2 · approve the GM token to Ondo's swap contract
724
766
  to: s,
725
- data: E({
767
+ data: g({
726
768
  abi: G,
727
769
  functionName: "approve",
728
770
  args: [r, o]
@@ -731,13 +773,13 @@ const An = (t) => m(t, fe), En = () => v, gn = /* @__PURE__ */ new Map(), k = (t
731
773
  {
732
774
  // 3 · redeem GM -> USDC with the signed attestation
733
775
  to: r,
734
- data: E({
735
- abi: xt,
776
+ data: g({
777
+ abi: Ut,
736
778
  functionName: "swapExactInWithAttestation",
737
779
  args: [s, o, a, i, c, d]
738
780
  })
739
781
  }
740
- ], In = ({
782
+ ], Nn = ({
741
783
  accountId: t,
742
784
  debtKey: e,
743
785
  dytmOffice: n,
@@ -746,7 +788,7 @@ const An = (t) => m(t, fe), En = () => v, gn = /* @__PURE__ */ new Map(), k = (t
746
788
  {
747
789
  // approve USDC to the DYTM Office for the repay
748
790
  to: s,
749
- data: E({
791
+ data: g({
750
792
  abi: G,
751
793
  functionName: "approve",
752
794
  args: [n, I]
@@ -755,8 +797,8 @@ const An = (t) => m(t, fe), En = () => v, gn = /* @__PURE__ */ new Map(), k = (t
755
797
  {
756
798
  // repay the slice's whole USDC debt
757
799
  to: n,
758
- data: E({
759
- abi: Y,
800
+ data: g({
801
+ abi: W,
760
802
  functionName: "repay",
761
803
  args: [
762
804
  {
@@ -772,93 +814,94 @@ const An = (t) => m(t, fe), En = () => v, gn = /* @__PURE__ */ new Map(), k = (t
772
814
  ]
773
815
  })
774
816
  }
775
- ], Nn = ({
817
+ ], On = ({
776
818
  actions: t,
777
819
  outputAsset: e,
778
820
  minOutputAmount: n
779
- }) => h(Pt, [
821
+ }) => h($t, [
780
822
  { actions: t, outputAsset: e, minOutputAmount: n }
781
823
  ]);
782
824
  export {
783
- He as $,
825
+ j as $,
784
826
  K as A,
785
- Ge as B,
786
- O as C,
787
- un as D,
788
- gn as E,
789
- dn as F,
790
- ln as G,
791
- yn as H,
792
- En as I,
793
- Xe as J,
794
- ne as K,
795
- We as L,
796
- qe as M,
797
- se as N,
798
- rn as O,
799
- Dn as P,
800
- $e as Q,
801
- cn as R,
802
- on as S,
803
- mn as T,
804
- An as U,
805
- je as V,
827
+ We as B,
828
+ C,
829
+ pn as D,
830
+ fn as E,
831
+ ln as F,
832
+ An as G,
833
+ gn as H,
834
+ hn as I,
835
+ Qe as J,
836
+ se as K,
837
+ He as L,
838
+ Xe as M,
839
+ ae as N,
840
+ cn as O,
841
+ Rn as P,
842
+ Ye as Q,
843
+ dn as R,
844
+ un as S,
845
+ S as T,
846
+ yn as U,
847
+ En as V,
806
848
  ze as W,
807
- pn as X,
808
- be as Y,
809
- Sn as Z,
810
- k as _,
811
- jt as a,
812
- Ze as a0,
813
- Ye as a1,
814
- Fe as a2,
815
- ke as a3,
816
- ve as a4,
817
- p as a5,
818
- R as a6,
819
- he as a7,
820
- ge as a8,
821
- Se as a9,
822
- fn as aa,
823
- Qe as ab,
824
- Pe as ac,
825
- Je as ad,
826
- m as ae,
827
- le as af,
828
- tn as ag,
829
- pe as ah,
830
- Le as ai,
831
- Me as aj,
832
- fe as ak,
833
- ye as al,
834
- xe as am,
835
- Ae as an,
836
- me as ao,
837
- en as ap,
838
- M as aq,
839
- Jt as b,
840
- ae as c,
841
- Te as d,
842
- bn as e,
843
- In as f,
844
- ee as g,
845
- Ve as h,
849
+ Ze as X,
850
+ mn as Y,
851
+ Ie as Z,
852
+ bn as _,
853
+ Xt as a,
854
+ Ve as a0,
855
+ tn as a1,
856
+ ke as a2,
857
+ ve as a3,
858
+ je as a4,
859
+ Ge as a5,
860
+ p as a6,
861
+ O as a7,
862
+ Te as a8,
863
+ fe as a9,
864
+ be as aa,
865
+ _n as ab,
866
+ Je as ac,
867
+ $e as ad,
868
+ en as ae,
869
+ l as af,
870
+ Ae as ag,
871
+ nn as ah,
872
+ me as ai,
873
+ Be as aj,
874
+ Le as ak,
875
+ _e as al,
876
+ ge as am,
877
+ Ue as an,
878
+ Ee as ao,
879
+ ye as ap,
880
+ sn as aq,
881
+ x as ar,
882
+ te as b,
883
+ re as c,
884
+ we as d,
885
+ In as e,
886
+ Nn as f,
887
+ ne as g,
888
+ qe as h,
846
889
  Ke as i,
847
- Ce as j,
848
- De as k,
849
- hn as l,
850
- wn as m,
851
- Nn as n,
852
- _n as o,
853
- Be as p,
854
- g as q,
855
- _e as r,
856
- zt as s,
857
- Ee as t,
858
- sn as u,
859
- nn as v,
860
- an as w,
861
- Tn as x,
862
- Ue as y,
863
- te as z
890
+ xe as j,
891
+ Re as k,
892
+ Tn as l,
893
+ Dn as m,
894
+ On as n,
895
+ Sn as o,
896
+ Pe as p,
897
+ E as q,
898
+ Se as r,
899
+ Qt as s,
900
+ he as t,
901
+ rn as u,
902
+ an as v,
903
+ on as w,
904
+ wn as x,
905
+ Fe as y,
906
+ ee as z
864
907
  };