@dhedge/trading-widget 6.0.3 → 6.0.4

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.
@@ -0,0 +1,540 @@
1
+ import { mainnet as D, hyperEvm as U, polygon as F, optimism as W, base as $, arbitrum as v } from "wagmi/chains";
2
+ import { ao as Y, am as G, an as V, a as y, q as E, ap as H, aq as q, a4 as K, ai as k, a3 as z, b as Z, ab as Q, ah as X, ag as j, Z as J, ar as B, e as tt, d as et, M as st, R as at, P as nt, as as ot, at as rt, Q as it, N as ct, ae as _, _ as ut, W as dt, X as lt, U as At, au as M, av as mt, aw as pt, ax as Tt, ay as gt, az as _t, o as St, aa as Dt } from "./gmx-CzVsBV3W.js";
3
+ import u from "bignumber.js";
4
+ import { stringToHex as f, encodeAbiParameters as S, bytesToHex as yt, zeroHash as Et, pad as ft } from "viem";
5
+ const Xt = typeof window < "u", jt = [
6
+ {
7
+ inputs: [
8
+ { internalType: "address", name: "_pool", type: "address" },
9
+ { internalType: "address", name: "_asset", type: "address" },
10
+ { internalType: "uint256", name: "_poolTokenAmount", type: "uint256" }
11
+ ],
12
+ name: "previewGmTokenAmount",
13
+ outputs: [
14
+ { internalType: "uint256", name: "gmTokenAmount", type: "uint256" }
15
+ ],
16
+ stateMutability: "nonpayable",
17
+ type: "function"
18
+ }
19
+ ], Nt = [
20
+ {
21
+ type: "tuple",
22
+ components: [
23
+ { name: "attestationSignature", type: "bytes" },
24
+ {
25
+ name: "quote",
26
+ type: "tuple",
27
+ components: [
28
+ { name: "chainId", type: "uint256" },
29
+ { name: "attestationId", type: "uint256" },
30
+ { name: "userId", type: "bytes32" },
31
+ { name: "asset", type: "address" },
32
+ { name: "price", type: "uint256" },
33
+ { name: "quantity", type: "uint256" },
34
+ { name: "expiration", type: "uint256" },
35
+ { name: "side", type: "uint8" },
36
+ { name: "additionalData", type: "bytes32" }
37
+ ]
38
+ },
39
+ { name: "amountOutMinimum", type: "uint256" }
40
+ ]
41
+ }
42
+ ], wt = () => typeof window < "u";
43
+ function It() {
44
+ return wt() && typeof window.ethereum < "u";
45
+ }
46
+ async function Jt(t) {
47
+ try {
48
+ if (It())
49
+ return window.ethereum.request({
50
+ method: "wallet_watchAsset",
51
+ params: {
52
+ type: "ERC20",
53
+ options: t
54
+ }
55
+ });
56
+ } catch {
57
+ return !1;
58
+ }
59
+ return !1;
60
+ }
61
+ const A = (t, e) => t?.toLowerCase() === e?.toLowerCase(), te = (t) => A(t, Y), ht = (t, e) => V[e]?.[t] ?? y, ee = (t) => G[t], se = (t) => t && `${t.substring(0, 6)}...${t.substring(
62
+ t.length - 4,
63
+ t.length
64
+ )}`, ae = ({
65
+ address: t,
66
+ chainId: e
67
+ }) => {
68
+ const s = ht(
69
+ "aaveLendingPoolV3",
70
+ e
71
+ );
72
+ return A(t, s);
73
+ }, Ot = ({
74
+ sourceAddress: t,
75
+ amount: e
76
+ }) => `${t}_${e}`, ne = (t, e) => {
77
+ const s = t.slice(0, e), a = t.slice(e);
78
+ return { firstPart: s, secondPart: a };
79
+ }, bt = (t, e) => t / e * 100, oe = (t) => t < 1 ? 4 : t < 10 ? 3 : 2, re = (t, e = E) => new u(t.toString()).shiftedBy(e).toFixed(0), ie = (t, e, s, a) => new u(e).dividedBy(s).multipliedBy(t).shiftedBy(-(a || E)).toNumber(), ce = (t) => BigInt(
80
+ new u(t || "0").shiftedBy(E).toFixed(0, u.ROUND_DOWN)
81
+ ), Rt = (t) => {
82
+ const e = new u(0.01), s = new u(t), a = !s.isZero() && s.lt(e) ? e : s;
83
+ return BigInt(a.multipliedBy(100).toFixed(0));
84
+ }, ue = ({
85
+ vaultAddress: t,
86
+ swapData: e,
87
+ sendTokenAddress: s,
88
+ sendTokenAmount: a,
89
+ vaultDepositTokenAddress: n,
90
+ minVaultTokensReceivedAmount: o,
91
+ routerKey: r = "ONE_INCH",
92
+ swapDestinationAmount: c,
93
+ swapSlippage: i
94
+ }) => {
95
+ const d = new u(c).multipliedBy(1 - i / 100).toFixed(0), m = [f(r, { size: 32 }), e];
96
+ return [t, [[s, a, m], [n, d]], o];
97
+ }, de = ({
98
+ receiveAssetAddress: t,
99
+ assets: e,
100
+ swapData: s,
101
+ slippage: a
102
+ }) => {
103
+ const n = {
104
+ srcData: [],
105
+ destAmount: new u("0")
106
+ }, { srcData: o, destAmount: r } = e?.reduce((c, i) => {
107
+ const d = s?.[i.address];
108
+ if (!d)
109
+ return c;
110
+ const m = [
111
+ f(d.routerKey, { size: 32 }),
112
+ d.rawTransaction.data
113
+ ], p = [i.address, i.rawBalance, m];
114
+ return {
115
+ srcData: [...c.srcData, p],
116
+ destAmount: c.destAmount.plus(d.destinationAmount)
117
+ };
118
+ }, n) ?? n;
119
+ return [
120
+ o,
121
+ [
122
+ t,
123
+ r.times(1 - a / 100).toFixed(0, u.ROUND_DOWN)
124
+ ]
125
+ ];
126
+ }, Lt = ({
127
+ assetAddress: t,
128
+ swapQuotes: e,
129
+ swapParams: s,
130
+ slippageToleranceForContractTransaction: a,
131
+ routerKey: n
132
+ }) => {
133
+ if (!s)
134
+ return {
135
+ supportedAsset: t,
136
+ withdrawData: "",
137
+ slippageTolerance: BigInt(0)
138
+ };
139
+ const { srcData: o, dstData: r } = s, c = o.map(({ asset: m, amount: p }) => {
140
+ const g = e?.[Ot({
141
+ sourceAddress: m,
142
+ amount: p.toString()
143
+ })]?.find((x) => x.routerKey === n);
144
+ return {
145
+ asset: m,
146
+ amount: p,
147
+ swapData: {
148
+ routerKey: f(g?.routerKey ?? "", { size: 32 }),
149
+ txData: g?.rawTransaction.data ?? "0x"
150
+ }
151
+ };
152
+ }), i = S(
153
+ H,
154
+ [c]
155
+ ), d = S(q, [
156
+ {
157
+ encodedSrcData: i,
158
+ dstData: {
159
+ dstAddress: r.asset,
160
+ dstAmount: r.amount
161
+ },
162
+ slippage: a
163
+ }
164
+ ]);
165
+ return {
166
+ supportedAsset: t,
167
+ withdrawData: d,
168
+ slippageTolerance: a
169
+ };
170
+ }, le = ({
171
+ chainId: t,
172
+ txHash: e,
173
+ error: s
174
+ }) => {
175
+ if (t !== D.id || !e || !s)
176
+ return !1;
177
+ const a = s instanceof Error ? s.message : String(s);
178
+ return /\bNo Result\b/i.test(a);
179
+ }, Ae = ({
180
+ chainId: t,
181
+ action: e,
182
+ isRabbyWallet: s
183
+ }) => e === "update_ondo_prices" && t === D.id && s ? K : t ? k[t] ?? 0 : 0, me = (t, e) => Z[e]?.nativeTokenSymbol === t, pe = ({
184
+ nativeTokenBalance: t,
185
+ tokenDecimals: e,
186
+ gasPrice: s
187
+ }) => {
188
+ const a = new u(s).multipliedBy(z).shiftedBy(-e), n = new u(t).minus(
189
+ a
190
+ );
191
+ return n.gt("0") ? n : new u("0");
192
+ }, Te = (t) => Q.includes(t), ge = (t) => {
193
+ const e = Object.values(t).reduce(
194
+ (s, { type: a }) => (s[a] = s[a] + 1, s),
195
+ { string: 0, number: 0 }
196
+ );
197
+ if (e.string > 10)
198
+ throw new Error("logger params must contain up to 10 string values");
199
+ if (e.number > 40)
200
+ throw new Error("logger params must contain up to 40 numeric values");
201
+ return !0;
202
+ }, Ct = (t, e = 150) => t.length > e ? t.substring(0, e) : t, N = (t, e = X) => {
203
+ const s = t.toLowerCase();
204
+ return e.sort((a, n) => n.length - a.length).find((a) => s.includes(a.toLowerCase()));
205
+ }, w = (t) => j[t] ?? J[t], _e = ({
206
+ errorMessage: t,
207
+ abiErrors: e
208
+ }) => {
209
+ if (!t || t.includes("User rejected"))
210
+ return null;
211
+ const s = e.find((o) => t.includes(o));
212
+ if (s && N(s))
213
+ return w(s);
214
+ const a = N(t);
215
+ if (a)
216
+ return w(a);
217
+ const [n] = t.split(s ? "." : "Contract").map((o) => o.trim());
218
+ return {
219
+ title: "Transaction failed",
220
+ hint: `${Ct(n ?? "")} ${s ? `: ${s}` : ""}`
221
+ };
222
+ }, Se = (t) => typeof t == "number" && Number.isFinite(t), De = (t) => typeof t == "bigint" && t !== BigInt(0), Bt = (t, e = B) => new u(t).shiftedBy(-e).toNumber(), Mt = (t) => !isNaN(parseFloat(t)) && !isNaN(t), Pt = ({
223
+ value: t,
224
+ minimumFractionDigits: e = 2,
225
+ maximumFractionDigits: s = 2,
226
+ compact: a = !1,
227
+ normalize: n = !1
228
+ }) => new Intl.NumberFormat("en-US", {
229
+ style: "currency",
230
+ currency: "USD",
231
+ notation: a ? "compact" : void 0,
232
+ minimumFractionDigits: e,
233
+ maximumFractionDigits: s
234
+ }).format(n ? Bt(t) : Number(t)), I = (t) => Mt(t) ? new u(t).toFixed() : "", h = ["₀", "₁", "₂", "₃", "₄", "₅", "₆", "₇", "₈", "₉"], xt = ({
235
+ value: t,
236
+ decimals: e = 4
237
+ }) => {
238
+ const s = new u(t);
239
+ if (s.isGreaterThan(1) || s.isZero())
240
+ return I(s.toFixed(e));
241
+ const n = (/e/i.test(t.toString()) ? parseFloat(t.toString()).toFixed(B) : t.toString()).match(/^0\.(0+)(\d+)$/);
242
+ if (n) {
243
+ const [, o, r] = n;
244
+ if (o.length >= e && o.length < h.length)
245
+ return `0.0${h[o.length]}${r.slice(0, 3)}`;
246
+ }
247
+ return I(s.toFixed(e));
248
+ }, Ut = (t, e = 0) => `${t.toLocaleString("en-US", { maximumFractionDigits: e })}%`, ye = (t) => t.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), Ee = (t, e, s = 0) => {
249
+ const a = bt(+t, e);
250
+ return Ut(a, s);
251
+ }, fe = ({
252
+ currency: t,
253
+ value: e
254
+ }) => t === "USD" ? Pt({ value: e }) : `${tt[t]} ${xt({
255
+ value: e,
256
+ decimals: et[t]
257
+ })}`, Ft = (t, e) => new u(
258
+ new u(t).toFixed(e, u.ROUND_DOWN)
259
+ ).toString(), Wt = (t, e = 3, s = 2) => {
260
+ if (t.length <= 5)
261
+ return t;
262
+ const a = "...";
263
+ return t.length <= e + s + a.length ? t : `${t.slice(0, e)}${a}${t.slice(-s)}`;
264
+ }, Ne = ({
265
+ balance: t,
266
+ symbol: e,
267
+ precision: s,
268
+ truncateSymbol: a
269
+ }) => `${Ft(t, s)} ${a ? Wt(e) : e}`, we = (t) => {
270
+ if (!t)
271
+ return;
272
+ const e = t.match(/0x[a-fA-F0-9]{64}/);
273
+ if (!e)
274
+ return;
275
+ const s = e[0];
276
+ return `${s.slice(0, 4)}...${s.slice(-3)}`;
277
+ }, Ie = (t) => A(ot, t) || A(rt, t), he = (t) => ct.some(
278
+ (e) => A(e, t)
279
+ ), Oe = (t) => st[t.toLowerCase()] ?? {
280
+ symbol: "",
281
+ decimals: 18,
282
+ address: y
283
+ }, be = (t) => A(t, it) ? at : nt, $t = (t) => `eth_${t}`, Re = ({
284
+ action: t,
285
+ log: e,
286
+ symbol: s,
287
+ vaultAddress: a,
288
+ chainId: n
289
+ }) => {
290
+ const o = {
291
+ [_.SYMBOL.NAME]: s,
292
+ [_.CHAIN_ID.NAME]: n,
293
+ [_.ADDRESS.NAME]: $t(a)
294
+ };
295
+ ut[t].forEach((r) => {
296
+ e?.(r, o);
297
+ });
298
+ }, Le = (t) => At.some((e) => A(e, t)), Ce = (t) => dt[t.toLowerCase()] ?? {
299
+ symbol: "",
300
+ decimals: 18,
301
+ address: y
302
+ }, Be = (t) => lt[t.toLowerCase()], vt = "0x3333333333333333333333333333333333333333";
303
+ v.id + "", _t.address, $.id + "", gt.address, W.id + "", Tt.address, F.id + "", pt.address, D.id + "", mt.address, U.id + "", M.address;
304
+ const Me = (t) => A(t, vt), Pe = () => M, xe = /* @__PURE__ */ new Map(), P = (t, e) => !e || e.size === 0 ? t : t.map((s) => {
305
+ const a = e.get(
306
+ s.supportedAsset.toLowerCase()
307
+ );
308
+ return a ? {
309
+ ...s,
310
+ withdrawData: a,
311
+ // Ondo assets require a hardcoded increased slippage
312
+ slippageTolerance: St
313
+ } : s;
314
+ }), Yt = (t) => {
315
+ const e = t.find(
316
+ ({ swapQuotes: s }) => s
317
+ );
318
+ return e?.swapQuotes ? Object.values(e.swapQuotes)[0]?.map(
319
+ ({ routerKey: s }) => s
320
+ ) ?? [] : [];
321
+ }, Gt = (t, e, s) => t.map(({ asset: a, swapParams: n, swapQuotes: o }) => !n || !o ? {
322
+ supportedAsset: a,
323
+ withdrawData: "",
324
+ slippageTolerance: s
325
+ } : Lt({
326
+ assetAddress: a,
327
+ swapQuotes: o,
328
+ swapParams: n,
329
+ slippageToleranceForContractTransaction: s,
330
+ routerKey: e
331
+ })), Vt = async (t, e, s, a, n, o) => {
332
+ for (const r of t) {
333
+ const c = P(
334
+ Gt(
335
+ e,
336
+ r,
337
+ s
338
+ ),
339
+ o
340
+ ), { error: i } = await a(...n, c);
341
+ if (!i)
342
+ return c;
343
+ }
344
+ return null;
345
+ }, Ue = (t, e, s) => {
346
+ const a = (t ?? []).map((n) => ({
347
+ supportedAsset: n,
348
+ withdrawData: "",
349
+ slippageTolerance: e
350
+ }));
351
+ return P(a, s);
352
+ }, Fe = async (t, e, s, a, n) => {
353
+ for (const o of t) {
354
+ const r = Rt(o);
355
+ try {
356
+ const c = await e(o), i = Yt(
357
+ c
358
+ ), d = await Vt(
359
+ i,
360
+ c,
361
+ r,
362
+ s,
363
+ a,
364
+ n
365
+ );
366
+ if (d)
367
+ return console.debug(
368
+ `[Init Withdraw] Auto slippage simulation succeeded: slippage=${o}%`
369
+ ), console.debug("[Init Withdraw] Complex asset data:", d), d;
370
+ } catch (c) {
371
+ console.error(
372
+ `[Init Withdraw] Failed to fetch quotes for slippage=${o}%:`,
373
+ c
374
+ );
375
+ }
376
+ }
377
+ return null;
378
+ }, We = async (t, e, {
379
+ fetchAaveSwapParams: s,
380
+ fetchAaveSwapQuotes: a,
381
+ withdrawAmountD18: n,
382
+ slippage: o
383
+ }) => Promise.all(
384
+ (t ?? []).map(async (r) => {
385
+ if (!A(r, e))
386
+ return { asset: r };
387
+ try {
388
+ const i = await s({
389
+ withdrawAmountD18: n,
390
+ slippage: o
391
+ });
392
+ if (i?.srcData.length) {
393
+ const d = await a({
394
+ swapParams: i,
395
+ slippage: o
396
+ });
397
+ return { asset: r, swapParams: i, swapQuotes: d };
398
+ }
399
+ return { asset: r };
400
+ } catch (i) {
401
+ return console.error(i), { asset: r };
402
+ }
403
+ })
404
+ ), O = (t) => Math.round(t * 100) / 100, $e = ({
405
+ maxSlippage: t,
406
+ candidates: e = Dt
407
+ }) => {
408
+ if (!Number.isFinite(t) || t <= 0)
409
+ return [];
410
+ const s = O(Math.min(t, 100)), a = e.filter((o) => o > 0 && o <= s).map(O), n = new Set(a);
411
+ return n.add(s), n.add(t), Array.from(n).sort((o, r) => o - r);
412
+ }, b = 1000000000000000000n, Ht = 1000000n, R = 10000n, L = 100n, T = (t) => {
413
+ if (!t) throw new Error("Ondo: empty hex value");
414
+ return t.startsWith("0x") ? t : `0x${t}`;
415
+ }, l = (t, e) => {
416
+ try {
417
+ return BigInt(t);
418
+ } catch {
419
+ throw new Error(
420
+ `Ondo: cannot convert "${e}" value "${t}" to bigint`
421
+ );
422
+ }
423
+ }, C = (t) => t ? ft(T(t), { size: 32 }) : Et, qt = (t) => {
424
+ if (!t) throw new Error("Ondo: empty signature");
425
+ return yt(Uint8Array.from(atob(t), (e) => e.charCodeAt(0)));
426
+ }, ve = (t) => ({
427
+ quotes: t.quotes.map(
428
+ (e) => ({
429
+ chainId: l(e.chainId, "chainId"),
430
+ attestationId: l(e.attestationId, "attestationId"),
431
+ userId: T(e.userId),
432
+ asset: e.asset,
433
+ price: l(e.price, "price"),
434
+ quantity: l(e.quantity, "quantity"),
435
+ expiration: l(e.expiration, "expiration"),
436
+ side: Number(e.side),
437
+ additionalData: T(e.additionalData)
438
+ })
439
+ ),
440
+ signatures: t.signatures.map(T)
441
+ }), Kt = (t, e, s) => {
442
+ const a = BigInt(Math.max(0, Math.round(s * 100))), n = a > L ? L : a, o = R - n, c = t * e / b * o * Ht, i = R * b;
443
+ return (c + i - 1n) / i;
444
+ }, Ye = ({
445
+ attestation: t,
446
+ chainId: e,
447
+ slippagePercent: s
448
+ }) => {
449
+ const a = l(t.tokenAmount, "tokenAmount"), n = l(t.price, "price");
450
+ return S(Nt, [
451
+ {
452
+ attestationSignature: qt(t.signature),
453
+ quote: {
454
+ chainId: e,
455
+ attestationId: l(t.attestationId, "attestationId"),
456
+ userId: C(t.userId),
457
+ asset: t.assetAddress,
458
+ price: n,
459
+ quantity: a,
460
+ expiration: l(t.expiration, "expiration"),
461
+ side: Number(t.side),
462
+ additionalData: C(t.additionalData)
463
+ },
464
+ amountOutMinimum: Kt(
465
+ a,
466
+ n,
467
+ s
468
+ )
469
+ }
470
+ ]);
471
+ };
472
+ export {
473
+ te as $,
474
+ bt as A,
475
+ ie as B,
476
+ Ae as C,
477
+ Rt as D,
478
+ xe as E,
479
+ we as F,
480
+ ae as G,
481
+ he as H,
482
+ Ie as I,
483
+ Le as J,
484
+ Me as K,
485
+ me as L,
486
+ Te as M,
487
+ Re as N,
488
+ ve as O,
489
+ P,
490
+ ce as Q,
491
+ _e as R,
492
+ re as S,
493
+ se as T,
494
+ le as U,
495
+ ne as V,
496
+ $t as W,
497
+ Wt as X,
498
+ Vt as Y,
499
+ Fe as Z,
500
+ ge as _,
501
+ Lt as a,
502
+ Se as a0,
503
+ A as a1,
504
+ Pt as a2,
505
+ De as a3,
506
+ Bt as a4,
507
+ jt as a5,
508
+ vt as a6,
509
+ xt as a7,
510
+ Jt as a8,
511
+ Ut as a9,
512
+ Mt as aa,
513
+ ye as ab,
514
+ I as ac,
515
+ qt as b,
516
+ Gt as c,
517
+ Ot as d,
518
+ de as e,
519
+ ue as f,
520
+ Xt as g,
521
+ Ue as h,
522
+ Ye as i,
523
+ We as j,
524
+ Yt as k,
525
+ Ft as l,
526
+ fe as m,
527
+ Ee as n,
528
+ Ne as o,
529
+ $e as p,
530
+ ee as q,
531
+ ht as r,
532
+ oe as s,
533
+ N as t,
534
+ Oe as u,
535
+ be as v,
536
+ Ce as w,
537
+ Be as x,
538
+ Pe as y,
539
+ pe as z
540
+ };
@@ -0,0 +1 @@
1
+ "use strict";const T=require("wagmi/chains"),r=require("./gmx-DT_j1_Y4.cjs"),u=require("bignumber.js"),p=require("viem"),Q=typeof window<"u",z=[{inputs:[{internalType:"address",name:"_pool",type:"address"},{internalType:"address",name:"_asset",type:"address"},{internalType:"uint256",name:"_poolTokenAmount",type:"uint256"}],name:"previewGmTokenAmount",outputs:[{internalType:"uint256",name:"gmTokenAmount",type:"uint256"}],stateMutability:"nonpayable",type:"function"}],j=[{type:"tuple",components:[{name:"attestationSignature",type:"bytes"},{name:"quote",type:"tuple",components:[{name:"chainId",type:"uint256"},{name:"attestationId",type:"uint256"},{name:"userId",type:"bytes32"},{name:"asset",type:"address"},{name:"price",type:"uint256"},{name:"quantity",type:"uint256"},{name:"expiration",type:"uint256"},{name:"side",type:"uint8"},{name:"additionalData",type:"bytes32"}]},{name:"amountOutMinimum",type:"uint256"}]}],X=()=>typeof window<"u";function J(){return X()&&typeof window.ethereum<"u"}async function tt(t){try{if(J())return window.ethereum.request({method:"wallet_watchAsset",params:{type:"ERC20",options:t}})}catch{return!1}return!1}const A=(t,e)=>t?.toLowerCase()===e?.toLowerCase(),et=t=>A(t,r.AddressZero$1),O=(t,e)=>r.contractsAddressesMap[e]?.[t]??r.AddressZero,nt=t=>r.contractsAbisMap[t],st=t=>t&&`${t.substring(0,6)}...${t.substring(t.length-4,t.length)}`,rt=({address:t,chainId:e})=>{const n=O("aaveLendingPoolV3",e);return A(t,n)},L=({sourceAddress:t,amount:e})=>`${t}_${e}`,ot=(t,e)=>{const n=t.slice(0,e),s=t.slice(e);return{firstPart:n,secondPart:s}},B=(t,e)=>t/e*100,at=t=>t<1?4:t<10?3:2,it=(t,e=r.DEFAULT_PRECISION)=>new u(t.toString()).shiftedBy(e).toFixed(0),ct=(t,e,n,s)=>new u(e).dividedBy(n).multipliedBy(t).shiftedBy(-(s||r.DEFAULT_PRECISION)).toNumber(),dt=t=>BigInt(new u(t||"0").shiftedBy(r.DEFAULT_PRECISION).toFixed(0,u.ROUND_DOWN)),P=t=>{const e=new u(.01),n=new u(t),s=!n.isZero()&&n.lt(e)?e:n;return BigInt(s.multipliedBy(100).toFixed(0))},ut=({vaultAddress:t,swapData:e,sendTokenAddress:n,sendTokenAmount:s,vaultDepositTokenAddress:o,minVaultTokensReceivedAmount:a,routerKey:i="ONE_INCH",swapDestinationAmount:d,swapSlippage:c})=>{const l=new u(d).multipliedBy(1-c/100).toFixed(0),g=[p.stringToHex(i,{size:32}),e];return[t,[[n,s,g],[o,l]],a]},lt=({receiveAssetAddress:t,assets:e,swapData:n,slippage:s})=>{const o={srcData:[],destAmount:new u("0")},{srcData:a,destAmount:i}=e?.reduce((d,c)=>{const l=n?.[c.address];if(!l)return d;const g=[p.stringToHex(l.routerKey,{size:32}),l.rawTransaction.data],S=[c.address,c.rawBalance,g];return{srcData:[...d.srcData,S],destAmount:d.destAmount.plus(l.destinationAmount)}},o)??o;return[a,[t,i.times(1-s/100).toFixed(0,u.ROUND_DOWN)]]},M=({assetAddress:t,swapQuotes:e,swapParams:n,slippageToleranceForContractTransaction:s,routerKey:o})=>{if(!n)return{supportedAsset:t,withdrawData:"",slippageTolerance:BigInt(0)};const{srcData:a,dstData:i}=n,d=a.map(({asset:g,amount:S})=>{const D=e?.[L({sourceAddress:g,amount:S.toString()})]?.find(Z=>Z.routerKey===o);return{asset:g,amount:S,swapData:{routerKey:p.stringToHex(D?.routerKey??"",{size:32}),txData:D?.rawTransaction.data??"0x"}}}),c=p.encodeAbiParameters(r.ComplexWithdrawalAssetSrcDataAbiItem,[d]),l=p.encodeAbiParameters(r.ComplexWithdrawalDataAbiItem,[{encodedSrcData:c,dstData:{dstAddress:i.asset,dstAmount:i.amount},slippage:s}]);return{supportedAsset:t,withdrawData:l,slippageTolerance:s}},At=({chainId:t,txHash:e,error:n})=>{if(t!==T.mainnet.id||!e||!n)return!1;const s=n instanceof Error?n.message:String(n);return/\bNo Result\b/i.test(s)},mt=({chainId:t,action:e,isRabbyWallet:n})=>e==="update_ondo_prices"&&t===T.mainnet.id&&n?r.ONDO_PRICES_RABBY_SETTLE_DELAY:t?r.TRANSACTION_SETTLE_DELAY[t]??0:0,pt=(t,e)=>r.CHAIN_NATIVE_TOKENS[e]?.nativeTokenSymbol===t,Tt=({nativeTokenBalance:t,tokenDecimals:e,gasPrice:n})=>{const s=new u(n).multipliedBy(r.NATIVE_TOKEN_DEPOSIT_GAS_LIMIT).shiftedBy(-e),o=new u(t).minus(s);return o.gt("0")?o:new u("0")},gt=t=>r.STABLE_TOKEN_SYMBOLS.includes(t),St=t=>{const e=Object.values(t).reduce((n,{type:s})=>(n[s]=n[s]+1,n),{string:0,number:0});if(e.string>10)throw new Error("logger params must contain up to 10 string values");if(e.number>40)throw new Error("logger params must contain up to 40 numeric values");return!0},yt=(t,e=150)=>t.length>e?t.substring(0,e):t,_=(t,e=r.TRANSACTION_ERROR_KEYS)=>{const n=t.toLowerCase();return e.sort((s,o)=>o.length-s.length).find(s=>n.includes(s.toLowerCase()))},N=t=>r.TRANSACTION_ERRORS[t]??r.LIMIT_ORDER_TRANSACTION_ERRORS[t],Dt=({errorMessage:t,abiErrors:e})=>{if(!t||t.includes("User rejected"))return null;const n=e.find(a=>t.includes(a));if(n&&_(n))return N(n);const s=_(t);if(s)return N(s);const[o]=t.split(n?".":"Contract").map(a=>a.trim());return{title:"Transaction failed",hint:`${yt(o??"")} ${n?`: ${n}`:""}`}},_t=t=>typeof t=="number"&&Number.isFinite(t),Et=t=>typeof t=="bigint"&&t!==BigInt(0),x=(t,e=r.DEFAULT_PRECISION$1)=>new u(t).shiftedBy(-e).toNumber(),F=t=>!isNaN(parseFloat(t))&&!isNaN(t),U=({value:t,minimumFractionDigits:e=2,maximumFractionDigits:n=2,compact:s=!1,normalize:o=!1})=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",notation:s?"compact":void 0,minimumFractionDigits:e,maximumFractionDigits:n}).format(o?x(t):Number(t)),E=t=>F(t)?new u(t).toFixed():"",f=["₀","₁","₂","₃","₄","₅","₆","₇","₈","₉"],v=({value:t,decimals:e=4})=>{const n=new u(t);if(n.isGreaterThan(1)||n.isZero())return E(n.toFixed(e));const o=(/e/i.test(t.toString())?parseFloat(t.toString()).toFixed(r.DEFAULT_PRECISION$1):t.toString()).match(/^0\.(0+)(\d+)$/);if(o){const[,a,i]=o;if(a.length>=e&&a.length<f.length)return`0.0${f[a.length]}${i.slice(0,3)}`}return E(n.toFixed(e))},W=(t,e=0)=>`${t.toLocaleString("en-US",{maximumFractionDigits:e})}%`,It=t=>t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","),Nt=(t,e,n=0)=>{const s=B(+t,e);return W(s,n)},ft=({currency:t,value:e})=>t==="USD"?U({value:e}):`${r.CURRENCY_SYMBOL_MAP[t]} ${v({value:e,decimals:r.CURRENCY_DECIMALS_MAP[t]})}`,G=(t,e)=>new u(new u(t).toFixed(e,u.ROUND_DOWN)).toString(),$=(t,e=3,n=2)=>{if(t.length<=5)return t;const s="...";return t.length<=e+n+s.length?t:`${t.slice(0,e)}${s}${t.slice(-n)}`},ht=({balance:t,symbol:e,precision:n,truncateSymbol:s})=>`${G(t,n)} ${s?$(e):e}`,wt=t=>{if(!t)return;const e=t.match(/0x[a-fA-F0-9]{64}/);if(!e)return;const n=e[0];return`${n.slice(0,4)}...${n.slice(-3)}`},Rt=t=>A(r.FLATMONEY_EARLY_DEPOSITOR_VAULT_ADDRESS_BASE,t)||A(r.FLATMONEY_DHT_STAKING_VAULT_ADDRESS_BASE,t),bt=t=>r.FLAT_MONEY_LEVERAGED_ASSET_ADDRESSES.some(e=>A(e,t)),Ct=t=>r.FLAT_MONEY_COLLATERAL_MAP[t.toLowerCase()]??{symbol:"",decimals:18,address:r.AddressZero},Ot=t=>A(t,r.FLAT_MONEY_V1_UNIT_ADDRESS)?r.FLAT_MONEY_V1_UNIT_LINK:r.FLAT_MONEY_UNIT_LINK,H=t=>`eth_${t}`,Lt=({action:t,log:e,symbol:n,vaultAddress:s,chainId:o})=>{const a={[r.TRADING_LOG_EVENT_PARAM.SYMBOL.NAME]:n,[r.TRADING_LOG_EVENT_PARAM.CHAIN_ID.NAME]:o,[r.TRADING_LOG_EVENT_PARAM.ADDRESS.NAME]:H(s)};r.LOG_EVENT_BY_TRANSACTION_ACTION_MAP[t].forEach(i=>{e?.(i,a)})},Bt=t=>r.GMX_MARKET_ASSETS.some(e=>A(e,t)),Pt=t=>r.GMX_WITHDRAW_ASSET_MAP[t.toLowerCase()]??{symbol:"",decimals:18,address:r.AddressZero},Mt=t=>r.GMX_WITHDRAW_ASSET_MAP_BY_VAULT_ADDRESS[t.toLowerCase()],V="0x3333333333333333333333333333333333333333";T.arbitrum.id+"",r.USDC_ARBITRUM.address,T.base.id+"",r.USDC_BASE.address,T.optimism.id+"",r.USDC_OPTIMISM.address,T.polygon.id+"",r.USDC_POLYGON.address,T.mainnet.id+"",r.USDC_MAINNET.address,T.hyperEvm.id+"",r.USDC_HYPEREVM.address;const xt=t=>A(t,V),Ft=()=>r.USDC_HYPEREVM,Ut=new Map,I=(t,e)=>!e||e.size===0?t:t.map(n=>{const s=e.get(n.supportedAsset.toLowerCase());return s?{...n,withdrawData:s,slippageTolerance:r.DEFAULT_ONDO_WITHDRAWAL_CONTRACT_SLIPPAGE}:n}),Y=t=>{const e=t.find(({swapQuotes:n})=>n);return e?.swapQuotes?Object.values(e.swapQuotes)[0]?.map(({routerKey:n})=>n)??[]:[]},q=(t,e,n)=>t.map(({asset:s,swapParams:o,swapQuotes:a})=>!o||!a?{supportedAsset:s,withdrawData:"",slippageTolerance:n}:M({assetAddress:s,swapQuotes:a,swapParams:o,slippageToleranceForContractTransaction:n,routerKey:e})),K=async(t,e,n,s,o,a)=>{for(const i of t){const d=I(q(e,i,n),a),{error:c}=await s(...o,d);if(!c)return d}return null},vt=(t,e,n)=>{const s=(t??[]).map(o=>({supportedAsset:o,withdrawData:"",slippageTolerance:e}));return I(s,n)},Wt=async(t,e,n,s,o)=>{for(const a of t){const i=P(a);try{const d=await e(a),c=Y(d),l=await K(c,d,i,n,s,o);if(l)return console.debug(`[Init Withdraw] Auto slippage simulation succeeded: slippage=${a}%`),console.debug("[Init Withdraw] Complex asset data:",l),l}catch(d){console.error(`[Init Withdraw] Failed to fetch quotes for slippage=${a}%:`,d)}}return null},Gt=async(t,e,{fetchAaveSwapParams:n,fetchAaveSwapQuotes:s,withdrawAmountD18:o,slippage:a})=>Promise.all((t??[]).map(async i=>{if(!A(i,e))return{asset:i};try{const c=await n({withdrawAmountD18:o,slippage:a});if(c?.srcData.length){const l=await s({swapParams:c,slippage:a});return{asset:i,swapParams:c,swapQuotes:l}}return{asset:i}}catch(c){return console.error(c),{asset:i}}})),h=t=>Math.round(t*100)/100,$t=({maxSlippage:t,candidates:e=r.SLIPPAGE_AUTO_SIMULATION_CANDIDATES})=>{if(!Number.isFinite(t)||t<=0)return[];const n=h(Math.min(t,100)),s=e.filter(a=>a>0&&a<=n).map(h),o=new Set(s);return o.add(n),o.add(t),Array.from(o).sort((a,i)=>a-i)},w=1000000000000000000n,Ht=1000000n,R=10000n,b=100n,y=t=>{if(!t)throw new Error("Ondo: empty hex value");return t.startsWith("0x")?t:`0x${t}`},m=(t,e)=>{try{return BigInt(t)}catch{throw new Error(`Ondo: cannot convert "${e}" value "${t}" to bigint`)}},C=t=>t?p.pad(y(t),{size:32}):p.zeroHash,k=t=>{if(!t)throw new Error("Ondo: empty signature");return p.bytesToHex(Uint8Array.from(atob(t),e=>e.charCodeAt(0)))},Vt=t=>({quotes:t.quotes.map(e=>({chainId:m(e.chainId,"chainId"),attestationId:m(e.attestationId,"attestationId"),userId:y(e.userId),asset:e.asset,price:m(e.price,"price"),quantity:m(e.quantity,"quantity"),expiration:m(e.expiration,"expiration"),side:Number(e.side),additionalData:y(e.additionalData)})),signatures:t.signatures.map(y)}),Yt=(t,e,n)=>{const s=BigInt(Math.max(0,Math.round(n*100))),o=s>b?b:s,a=R-o,d=t*e/w*a*Ht,c=R*w;return(d+c-1n)/c},qt=({attestation:t,chainId:e,slippagePercent:n})=>{const s=m(t.tokenAmount,"tokenAmount"),o=m(t.price,"price");return p.encodeAbiParameters(j,[{attestationSignature:k(t.signature),quote:{chainId:e,attestationId:m(t.attestationId,"attestationId"),userId:C(t.userId),asset:t.assetAddress,price:o,quantity:s,expiration:m(t.expiration,"expiration"),side:Number(t.side),additionalData:C(t.additionalData)},amountOutMinimum:Yt(s,o,n)}])};exports.EMPTY_PER_ASSET_WITHDRAW_DATA=Ut;exports.HYPERLIQUID_PERPS_ACCOUNT_ADDRESS=V;exports.OndoGMTokenAssetGuardAbi=z;exports.addTokenToWallet=tt;exports.base64SignatureToHex=k;exports.buildAaveWithdrawAssetTransactionData=M;exports.buildComplexAssetDataForRouter=q;exports.buildSwapQuoteKeyForAave=L;exports.buildSwapWithdrawTransactionData=lt;exports.buildZapDepositTransactionArguments=ut;exports.clientSide=Q;exports.commify=It;exports.createDefaultComplexAssetData=vt;exports.encodeOndoWithdrawData=qt;exports.enrichAssetsWithSwapQuotes=Gt;exports.extractAvailableRouterKeys=Y;exports.formatBalance=G;exports.formatByCurrency=ft;exports.formatNumberToLimitedDecimals=v;exports.formatNumeratorToPercentage=Nt;exports.formatPercentage=W;exports.formatToUsd=U;exports.formatTokenBalance=ht;exports.getAutoSlippageSimulationCandidates=$t;exports.getContractAbiById=nt;exports.getContractAddressById=O;exports.getConventionalTokenPriceDecimals=at;exports.getErrorKey=_;exports.getFlatMoneyCollateralByLeverageAddress=Ct;exports.getFlatMoneyLinkByUnitAddress=Ot;exports.getGmxWithdrawAssetByLeverageAddress=Pt;exports.getGmxWithdrawAssetByVaultAddress=Mt;exports.getHyperliquidWithdrawAsset=Ft;exports.getNativeTokenInvestableBalance=Tt;exports.getPercent=B;exports.getPoolFraction=ct;exports.getSettleDelay=mt;exports.getSlippageToleranceForContractTransaction=P;exports.getTxHashShort=wt;exports.isAaveLendAndBorrowAsset=rt;exports.isEqualAddress=A;exports.isFlatMoneyLeveragedAsset=bt;exports.isFmpAirdropVaultAddress=Rt;exports.isGmxLeveragedAsset=Bt;exports.isHyperliquidPerpsAsset=xt;exports.isNativeToken=pt;exports.isNumberType=_t;exports.isNumeric=F;exports.isStableSymbol=gt;exports.isZeroAddress=et;exports.logTransactionByActionType=Lt;exports.mapOndoApiResponseToUpdatePricesArgs=Vt;exports.nonZeroBigInt=Et;exports.normalizeNumber=x;exports.overlayWithdrawData=I;exports.parseAmountToD18=dt;exports.parseContractErrorMessage=Dt;exports.removeInsignificantTrailingZeros=E;exports.shiftBy=it;exports.shortenAddress=st;exports.shouldSwallowMainnetPollError=At;exports.sliceByIndex=ot;exports.transformAddressForAnalytics=H;exports.truncateString=$;exports.tryEstimateWithRouters=K;exports.tryEstimateWithSlippageValues=Wt;exports.validateLoggerEventParams=St;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhedge/trading-widget",
3
- "version": "6.0.3",
3
+ "version": "6.0.4",
4
4
  "dependencies": {
5
5
  "@headlessui/react": "^2.1.2",
6
6
  "@heroicons/react": "^2.1.5",
package/utils.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./ondo-BnkOJgHw.cjs"),t=require("viem");exports.EMPTY_PER_ASSET_WITHDRAW_DATA=e.EMPTY_PER_ASSET_WITHDRAW_DATA;exports.base64SignatureToHex=e.base64SignatureToHex;exports.buildAaveWithdrawAssetTransactionData=e.buildAaveWithdrawAssetTransactionData;exports.buildComplexAssetDataForRouter=e.buildComplexAssetDataForRouter;exports.buildSwapQuoteKeyForAave=e.buildSwapQuoteKeyForAave;exports.buildSwapWithdrawTransactionData=e.buildSwapWithdrawTransactionData;exports.buildZapDepositTransactionArguments=e.buildZapDepositTransactionArguments;exports.clientSide=e.clientSide;exports.createDefaultComplexAssetData=e.createDefaultComplexAssetData;exports.encodeOndoWithdrawData=e.encodeOndoWithdrawData;exports.enrichAssetsWithSwapQuotes=e.enrichAssetsWithSwapQuotes;exports.extractAvailableRouterKeys=e.extractAvailableRouterKeys;exports.formatBalance=e.formatBalance;exports.formatByCurrency=e.formatByCurrency;exports.formatNumeratorToPercentage=e.formatNumeratorToPercentage;exports.formatTokenBalance=e.formatTokenBalance;exports.getAutoSlippageSimulationCandidates=e.getAutoSlippageSimulationCandidates;exports.getContractAbiById=e.getContractAbiById;exports.getContractAddressById=e.getContractAddressById;exports.getConventionalTokenPriceDecimals=e.getConventionalTokenPriceDecimals;exports.getErrorKey=e.getErrorKey;exports.getFlatMoneyCollateralByLeverageAddress=e.getFlatMoneyCollateralByLeverageAddress;exports.getFlatMoneyLinkByUnitAddress=e.getFlatMoneyLinkByUnitAddress;exports.getGmxWithdrawAssetByLeverageAddress=e.getGmxWithdrawAssetByLeverageAddress;exports.getGmxWithdrawAssetByVaultAddress=e.getGmxWithdrawAssetByVaultAddress;exports.getHyperliquidWithdrawAsset=e.getHyperliquidWithdrawAsset;exports.getNativeTokenInvestableBalance=e.getNativeTokenInvestableBalance;exports.getPercent=e.getPercent;exports.getPoolFraction=e.getPoolFraction;exports.getSlippageToleranceForContractTransaction=e.getSlippageToleranceForContractTransaction;exports.getTxHashShort=e.getTxHashShort;exports.isAaveLendAndBorrowAsset=e.isAaveLendAndBorrowAsset;exports.isFlatMoneyLeveragedAsset=e.isFlatMoneyLeveragedAsset;exports.isFmpAirdropVaultAddress=e.isFmpAirdropVaultAddress;exports.isGmxLeveragedAsset=e.isGmxLeveragedAsset;exports.isHyperliquidPerpsAsset=e.isHyperliquidPerpsAsset;exports.isNativeToken=e.isNativeToken;exports.isStableSymbol=e.isStableSymbol;exports.logTransactionByActionType=e.logTransactionByActionType;exports.mapOndoApiResponseToUpdatePricesArgs=e.mapOndoApiResponseToUpdatePricesArgs;exports.overlayWithdrawData=e.overlayWithdrawData;exports.parseAmountToD18=e.parseAmountToD18;exports.parseContractErrorMessage=e.parseContractErrorMessage;exports.shiftBy=e.shiftBy;exports.shortenAddress=e.shortenAddress;exports.sliceByIndex=e.sliceByIndex;exports.transformAddressForAnalytics=e.transformAddressForAnalytics;exports.truncateString=e.truncateString;exports.tryEstimateWithRouters=e.tryEstimateWithRouters;exports.tryEstimateWithSlippageValues=e.tryEstimateWithSlippageValues;exports.validateLoggerEventParams=e.validateLoggerEventParams;Object.defineProperty(exports,"decodeErrorResult",{enumerable:!0,get:()=>t.decodeErrorResult});Object.defineProperty(exports,"encodeFunctionData",{enumerable:!0,get:()=>t.encodeFunctionData});Object.defineProperty(exports,"formatEther",{enumerable:!0,get:()=>t.formatEther});Object.defineProperty(exports,"formatUnits",{enumerable:!0,get:()=>t.formatUnits});Object.defineProperty(exports,"hexToString",{enumerable:!0,get:()=>t.hexToString});Object.defineProperty(exports,"trim",{enumerable:!0,get:()=>t.trim});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./ondo-CANFUt4H.cjs"),t=require("viem");exports.EMPTY_PER_ASSET_WITHDRAW_DATA=e.EMPTY_PER_ASSET_WITHDRAW_DATA;exports.base64SignatureToHex=e.base64SignatureToHex;exports.buildAaveWithdrawAssetTransactionData=e.buildAaveWithdrawAssetTransactionData;exports.buildComplexAssetDataForRouter=e.buildComplexAssetDataForRouter;exports.buildSwapQuoteKeyForAave=e.buildSwapQuoteKeyForAave;exports.buildSwapWithdrawTransactionData=e.buildSwapWithdrawTransactionData;exports.buildZapDepositTransactionArguments=e.buildZapDepositTransactionArguments;exports.clientSide=e.clientSide;exports.createDefaultComplexAssetData=e.createDefaultComplexAssetData;exports.encodeOndoWithdrawData=e.encodeOndoWithdrawData;exports.enrichAssetsWithSwapQuotes=e.enrichAssetsWithSwapQuotes;exports.extractAvailableRouterKeys=e.extractAvailableRouterKeys;exports.formatBalance=e.formatBalance;exports.formatByCurrency=e.formatByCurrency;exports.formatNumeratorToPercentage=e.formatNumeratorToPercentage;exports.formatTokenBalance=e.formatTokenBalance;exports.getAutoSlippageSimulationCandidates=e.getAutoSlippageSimulationCandidates;exports.getContractAbiById=e.getContractAbiById;exports.getContractAddressById=e.getContractAddressById;exports.getConventionalTokenPriceDecimals=e.getConventionalTokenPriceDecimals;exports.getErrorKey=e.getErrorKey;exports.getFlatMoneyCollateralByLeverageAddress=e.getFlatMoneyCollateralByLeverageAddress;exports.getFlatMoneyLinkByUnitAddress=e.getFlatMoneyLinkByUnitAddress;exports.getGmxWithdrawAssetByLeverageAddress=e.getGmxWithdrawAssetByLeverageAddress;exports.getGmxWithdrawAssetByVaultAddress=e.getGmxWithdrawAssetByVaultAddress;exports.getHyperliquidWithdrawAsset=e.getHyperliquidWithdrawAsset;exports.getNativeTokenInvestableBalance=e.getNativeTokenInvestableBalance;exports.getPercent=e.getPercent;exports.getPoolFraction=e.getPoolFraction;exports.getSettleDelay=e.getSettleDelay;exports.getSlippageToleranceForContractTransaction=e.getSlippageToleranceForContractTransaction;exports.getTxHashShort=e.getTxHashShort;exports.isAaveLendAndBorrowAsset=e.isAaveLendAndBorrowAsset;exports.isFlatMoneyLeveragedAsset=e.isFlatMoneyLeveragedAsset;exports.isFmpAirdropVaultAddress=e.isFmpAirdropVaultAddress;exports.isGmxLeveragedAsset=e.isGmxLeveragedAsset;exports.isHyperliquidPerpsAsset=e.isHyperliquidPerpsAsset;exports.isNativeToken=e.isNativeToken;exports.isStableSymbol=e.isStableSymbol;exports.logTransactionByActionType=e.logTransactionByActionType;exports.mapOndoApiResponseToUpdatePricesArgs=e.mapOndoApiResponseToUpdatePricesArgs;exports.overlayWithdrawData=e.overlayWithdrawData;exports.parseAmountToD18=e.parseAmountToD18;exports.parseContractErrorMessage=e.parseContractErrorMessage;exports.shiftBy=e.shiftBy;exports.shortenAddress=e.shortenAddress;exports.shouldSwallowMainnetPollError=e.shouldSwallowMainnetPollError;exports.sliceByIndex=e.sliceByIndex;exports.transformAddressForAnalytics=e.transformAddressForAnalytics;exports.truncateString=e.truncateString;exports.tryEstimateWithRouters=e.tryEstimateWithRouters;exports.tryEstimateWithSlippageValues=e.tryEstimateWithSlippageValues;exports.validateLoggerEventParams=e.validateLoggerEventParams;Object.defineProperty(exports,"decodeErrorResult",{enumerable:!0,get:()=>t.decodeErrorResult});Object.defineProperty(exports,"encodeFunctionData",{enumerable:!0,get:()=>t.encodeFunctionData});Object.defineProperty(exports,"formatEther",{enumerable:!0,get:()=>t.formatEther});Object.defineProperty(exports,"formatUnits",{enumerable:!0,get:()=>t.formatUnits});Object.defineProperty(exports,"hexToString",{enumerable:!0,get:()=>t.hexToString});Object.defineProperty(exports,"trim",{enumerable:!0,get:()=>t.trim});
package/utils.js CHANGED
@@ -1,5 +1,5 @@
1
- import { E as s, b as t, a as r, c as o, d as i, e as n, f as d, g as l, h as A, i as c, j as g, k as p, l as m, m as u, n as y, o as T, p as h, q as S, r as v, s as B, t as D, u as x, v as W, w as b, x as f, y as w, z as C, A as E, B as F, C as P, D as L, F as R, G as k, H, I, J as M, K as G, L as K, M as N, N as U, O as V, P as _, Q as q, R as O, S as Q, T as Y, U as j, V as z, W as J, X, Y as Z } from "./ondo-Cl97ID2o.js";
2
- import { decodeErrorResult as aa, encodeFunctionData as ea, formatEther as sa, formatUnits as ta, hexToString as ra, trim as oa } from "viem";
1
+ import { E as s, b as t, a as r, c as o, d as i, e as n, f as d, g as l, h as A, i as g, j as c, k as p, l as u, m, n as y, o as T, p as h, q as S, r as v, s as B, t as D, u as w, v as x, w as W, x as b, y as f, z as E, A as C, B as F, C as P, D as L, F as R, G as M, H as k, I as H, J as I, K as _, L as G, M as K, N, O as U, P as V, Q as q, R as O, S as Q, T as Y, U as Z, V as j, W as z, X as J, Y as X, Z as $, _ as aa } from "./ondo-BVTXZqmD.js";
2
+ import { decodeErrorResult as sa, encodeFunctionData as ta, formatEther as ra, formatUnits as oa, hexToString as ia, trim as na } from "viem";
3
3
  export {
4
4
  s as EMPTY_PER_ASSET_WITHDRAW_DATA,
5
5
  t as base64SignatureToHex,
@@ -10,52 +10,54 @@ export {
10
10
  d as buildZapDepositTransactionArguments,
11
11
  l as clientSide,
12
12
  A as createDefaultComplexAssetData,
13
- aa as decodeErrorResult,
14
- ea as encodeFunctionData,
15
- c as encodeOndoWithdrawData,
16
- g as enrichAssetsWithSwapQuotes,
13
+ sa as decodeErrorResult,
14
+ ta as encodeFunctionData,
15
+ g as encodeOndoWithdrawData,
16
+ c as enrichAssetsWithSwapQuotes,
17
17
  p as extractAvailableRouterKeys,
18
- m as formatBalance,
19
- u as formatByCurrency,
20
- sa as formatEther,
18
+ u as formatBalance,
19
+ m as formatByCurrency,
20
+ ra as formatEther,
21
21
  y as formatNumeratorToPercentage,
22
22
  T as formatTokenBalance,
23
- ta as formatUnits,
23
+ oa as formatUnits,
24
24
  h as getAutoSlippageSimulationCandidates,
25
25
  S as getContractAbiById,
26
26
  v as getContractAddressById,
27
27
  B as getConventionalTokenPriceDecimals,
28
28
  D as getErrorKey,
29
- x as getFlatMoneyCollateralByLeverageAddress,
30
- W as getFlatMoneyLinkByUnitAddress,
31
- b as getGmxWithdrawAssetByLeverageAddress,
32
- f as getGmxWithdrawAssetByVaultAddress,
33
- w as getHyperliquidWithdrawAsset,
34
- C as getNativeTokenInvestableBalance,
35
- E as getPercent,
29
+ w as getFlatMoneyCollateralByLeverageAddress,
30
+ x as getFlatMoneyLinkByUnitAddress,
31
+ W as getGmxWithdrawAssetByLeverageAddress,
32
+ b as getGmxWithdrawAssetByVaultAddress,
33
+ f as getHyperliquidWithdrawAsset,
34
+ E as getNativeTokenInvestableBalance,
35
+ C as getPercent,
36
36
  F as getPoolFraction,
37
- P as getSlippageToleranceForContractTransaction,
38
- L as getTxHashShort,
39
- ra as hexToString,
40
- R as isAaveLendAndBorrowAsset,
37
+ P as getSettleDelay,
38
+ L as getSlippageToleranceForContractTransaction,
39
+ R as getTxHashShort,
40
+ ia as hexToString,
41
+ M as isAaveLendAndBorrowAsset,
41
42
  k as isFlatMoneyLeveragedAsset,
42
43
  H as isFmpAirdropVaultAddress,
43
44
  I as isGmxLeveragedAsset,
44
- M as isHyperliquidPerpsAsset,
45
+ _ as isHyperliquidPerpsAsset,
45
46
  G as isNativeToken,
46
47
  K as isStableSymbol,
47
48
  N as logTransactionByActionType,
48
49
  U as mapOndoApiResponseToUpdatePricesArgs,
49
50
  V as overlayWithdrawData,
50
- _ as parseAmountToD18,
51
- q as parseContractErrorMessage,
52
- O as shiftBy,
53
- Q as shortenAddress,
54
- Y as sliceByIndex,
55
- j as transformAddressForAnalytics,
56
- oa as trim,
57
- z as truncateString,
58
- J as tryEstimateWithRouters,
59
- X as tryEstimateWithSlippageValues,
60
- Z as validateLoggerEventParams
51
+ q as parseAmountToD18,
52
+ O as parseContractErrorMessage,
53
+ Q as shiftBy,
54
+ Y as shortenAddress,
55
+ Z as shouldSwallowMainnetPollError,
56
+ j as sliceByIndex,
57
+ z as transformAddressForAnalytics,
58
+ na as trim,
59
+ J as truncateString,
60
+ X as tryEstimateWithRouters,
61
+ $ as tryEstimateWithSlippageValues,
62
+ aa as validateLoggerEventParams
61
63
  };