@dhedge/trading-widget 6.0.1 → 6.0.3

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
1
  import d from "bignumber.js";
2
- import { al as P, aj as U, ak as F, a as D, p as _, am as W, an as $, a2 as v, b as V, a8 as Y, ae as G, ad as H, Y as K, ao as C, e as q, d as k, L as Z, Q as z, O as Q, ap as j, aq as X, P as J, M as tt, ab as S, Z as et, V as st, W as nt, T as at, ar as L, as as rt, at as ot, au as it, av as ct, aw as dt, a7 as ut } from "./gmx-Cu3Ax-nZ.js";
3
- import { stringToHex as f, encodeAbiParameters as y, bytesToHex as lt, zeroHash as mt, pad as pt } from "viem";
4
- import { hyperEvm as At, mainnet as gt, polygon as Tt, optimism as St, base as yt, arbitrum as Dt } from "wagmi/chains";
5
- const Zt = typeof window < "u", zt = [
2
+ import { am as x, ak as U, al as F, a as D, q as y, an as W, ao as $, a3 as v, b as G, a9 as V, af as Y, ae as H, Z as q, ap as L, e as K, d as k, M as Z, R as z, P as Q, aq as X, ar as j, Q as J, N as tt, ac as S, _ as et, W as st, X as at, U as nt, as as B, at as rt, au as ot, av as it, aw as ct, ax as dt, o as ut, a8 as lt } from "./gmx-C9vHHvqC.js";
3
+ import { stringToHex as f, encodeAbiParameters as _, bytesToHex as mt, zeroHash as pt, pad as At } from "viem";
4
+ import { hyperEvm as Tt, mainnet as gt, polygon as St, optimism as _t, base as Dt, arbitrum as yt } from "wagmi/chains";
5
+ const zt = typeof window < "u", Qt = [
6
6
  {
7
7
  inputs: [
8
8
  { internalType: "address", name: "_pool", type: "address" },
@@ -16,7 +16,7 @@ const Zt = typeof window < "u", zt = [
16
16
  stateMutability: "nonpayable",
17
17
  type: "function"
18
18
  }
19
- ], _t = [
19
+ ], ft = [
20
20
  {
21
21
  type: "tuple",
22
22
  components: [
@@ -39,13 +39,13 @@ const Zt = typeof window < "u", zt = [
39
39
  { name: "amountOutMinimum", type: "uint256" }
40
40
  ]
41
41
  }
42
- ], ft = () => typeof window < "u";
43
- function Et() {
44
- return ft() && typeof window.ethereum < "u";
42
+ ], Et = () => typeof window < "u";
43
+ function It() {
44
+ return Et() && typeof window.ethereum < "u";
45
45
  }
46
- async function Qt(t) {
46
+ async function Xt(t) {
47
47
  try {
48
- if (Et())
48
+ if (It())
49
49
  return window.ethereum.request({
50
50
  method: "wallet_watchAsset",
51
51
  params: {
@@ -58,10 +58,10 @@ async function Qt(t) {
58
58
  }
59
59
  return !1;
60
60
  }
61
- const m = (t, e) => t?.toLowerCase() === e?.toLowerCase(), jt = (t) => m(t, P), ht = (t, e) => F[e]?.[t] ?? D, Xt = (t) => U[t], Jt = (t) => t && `${t.substring(0, 6)}...${t.substring(
61
+ const m = (t, e) => t?.toLowerCase() === e?.toLowerCase(), jt = (t) => m(t, x), ht = (t, e) => F[e]?.[t] ?? D, Jt = (t) => U[t], te = (t) => t && `${t.substring(0, 6)}...${t.substring(
62
62
  t.length - 4,
63
63
  t.length
64
- )}`, te = ({
64
+ )}`, ee = ({
65
65
  address: t,
66
66
  chainId: e
67
67
  }) => {
@@ -73,34 +73,34 @@ const m = (t, e) => t?.toLowerCase() === e?.toLowerCase(), jt = (t) => m(t, P),
73
73
  }, wt = ({
74
74
  sourceAddress: t,
75
75
  amount: e
76
- }) => `${t}_${e}`, ee = (t, e) => {
77
- const s = t.slice(0, e), n = t.slice(e);
78
- return { firstPart: s, secondPart: n };
79
- }, It = (t, e) => t / e * 100, se = (t) => t < 1 ? 4 : t < 10 ? 3 : 2, ne = (t, e = _) => new d(t.toString()).shiftedBy(e).toFixed(0), ae = (t, e, s, n) => new d(e).dividedBy(s).multipliedBy(t).shiftedBy(-(n || _)).toNumber(), re = (t) => BigInt(
80
- new d(t || "0").shiftedBy(_).toFixed(0, d.ROUND_DOWN)
81
- ), Nt = (t) => {
82
- const e = new d(0.01), s = new d(t), n = !s.isZero() && s.lt(e) ? e : s;
83
- return BigInt(n.multipliedBy(100).toFixed(0));
84
- }, oe = ({
76
+ }) => `${t}_${e}`, se = (t, e) => {
77
+ const s = t.slice(0, e), a = t.slice(e);
78
+ return { firstPart: s, secondPart: a };
79
+ }, Nt = (t, e) => t / e * 100, ae = (t) => t < 1 ? 4 : t < 10 ? 3 : 2, ne = (t, e = y) => new d(t.toString()).shiftedBy(e).toFixed(0), re = (t, e, s, a) => new d(e).dividedBy(s).multipliedBy(t).shiftedBy(-(a || y)).toNumber(), oe = (t) => BigInt(
80
+ new d(t || "0").shiftedBy(y).toFixed(0, d.ROUND_DOWN)
81
+ ), Ot = (t) => {
82
+ const e = new d(0.01), s = new d(t), a = !s.isZero() && s.lt(e) ? e : s;
83
+ return BigInt(a.multipliedBy(100).toFixed(0));
84
+ }, ie = ({
85
85
  vaultAddress: t,
86
86
  swapData: e,
87
87
  sendTokenAddress: s,
88
- sendTokenAmount: n,
89
- vaultDepositTokenAddress: a,
88
+ sendTokenAmount: a,
89
+ vaultDepositTokenAddress: n,
90
90
  minVaultTokensReceivedAmount: r,
91
91
  routerKey: o = "ONE_INCH",
92
92
  swapDestinationAmount: c,
93
93
  swapSlippage: i
94
94
  }) => {
95
95
  const u = new d(c).multipliedBy(1 - i / 100).toFixed(0), p = [f(o, { size: 32 }), e];
96
- return [t, [[s, n, p], [a, u]], r];
97
- }, ie = ({
96
+ return [t, [[s, a, p], [n, u]], r];
97
+ }, ce = ({
98
98
  receiveAssetAddress: t,
99
99
  assets: e,
100
100
  swapData: s,
101
- slippage: n
101
+ slippage: a
102
102
  }) => {
103
- const a = {
103
+ const n = {
104
104
  srcData: [],
105
105
  destAmount: new d("0")
106
106
  }, { srcData: r, destAmount: o } = e?.reduce((c, i) => {
@@ -115,20 +115,20 @@ const m = (t, e) => t?.toLowerCase() === e?.toLowerCase(), jt = (t) => m(t, P),
115
115
  srcData: [...c.srcData, A],
116
116
  destAmount: c.destAmount.plus(u.destinationAmount)
117
117
  };
118
- }, a) ?? a;
118
+ }, n) ?? n;
119
119
  return [
120
120
  r,
121
121
  [
122
122
  t,
123
- o.times(1 - n / 100).toFixed(0, d.ROUND_DOWN)
123
+ o.times(1 - a / 100).toFixed(0, d.ROUND_DOWN)
124
124
  ]
125
125
  ];
126
- }, Ot = ({
126
+ }, bt = ({
127
127
  assetAddress: t,
128
128
  swapQuotes: e,
129
129
  swapParams: s,
130
- slippageToleranceForContractTransaction: n,
131
- routerKey: a
130
+ slippageToleranceForContractTransaction: a,
131
+ routerKey: n
132
132
  }) => {
133
133
  if (!s)
134
134
  return {
@@ -137,48 +137,48 @@ const m = (t, e) => t?.toLowerCase() === e?.toLowerCase(), jt = (t) => m(t, P),
137
137
  slippageTolerance: BigInt(0)
138
138
  };
139
139
  const { srcData: r, dstData: o } = s, c = r.map(({ asset: p, amount: A }) => {
140
- const T = e?.[wt({
140
+ const g = e?.[wt({
141
141
  sourceAddress: p,
142
142
  amount: A.toString()
143
- })]?.find((x) => x.routerKey === a);
143
+ })]?.find((P) => P.routerKey === n);
144
144
  return {
145
145
  asset: p,
146
146
  amount: A,
147
147
  swapData: {
148
- routerKey: f(T?.routerKey ?? "", { size: 32 }),
149
- txData: T?.rawTransaction.data ?? "0x"
148
+ routerKey: f(g?.routerKey ?? "", { size: 32 }),
149
+ txData: g?.rawTransaction.data ?? "0x"
150
150
  }
151
151
  };
152
- }), i = y(
152
+ }), i = _(
153
153
  W,
154
154
  [c]
155
- ), u = y($, [
155
+ ), u = _($, [
156
156
  {
157
157
  encodedSrcData: i,
158
158
  dstData: {
159
159
  dstAddress: o.asset,
160
160
  dstAmount: o.amount
161
161
  },
162
- slippage: n
162
+ slippage: a
163
163
  }
164
164
  ]);
165
165
  return {
166
166
  supportedAsset: t,
167
167
  withdrawData: u,
168
- slippageTolerance: n
168
+ slippageTolerance: a
169
169
  };
170
- }, ce = (t, e) => V[e]?.nativeTokenSymbol === t, de = ({
170
+ }, de = (t, e) => G[e]?.nativeTokenSymbol === t, ue = ({
171
171
  nativeTokenBalance: t,
172
172
  tokenDecimals: e,
173
173
  gasPrice: s
174
174
  }) => {
175
- const n = new d(s).multipliedBy(v).shiftedBy(-e), a = new d(t).minus(
176
- n
175
+ const a = new d(s).multipliedBy(v).shiftedBy(-e), n = new d(t).minus(
176
+ a
177
177
  );
178
- return a.gt("0") ? a : new d("0");
179
- }, ue = (t) => Y.includes(t), le = (t) => {
178
+ return n.gt("0") ? n : new d("0");
179
+ }, le = (t) => V.includes(t), me = (t) => {
180
180
  const e = Object.values(t).reduce(
181
- (s, { type: n }) => (s[n] = s[n] + 1, s),
181
+ (s, { type: a }) => (s[a] = s[a] + 1, s),
182
182
  { string: 0, number: 0 }
183
183
  );
184
184
  if (e.string > 10)
@@ -186,10 +186,10 @@ const m = (t, e) => t?.toLowerCase() === e?.toLowerCase(), jt = (t) => m(t, P),
186
186
  if (e.number > 40)
187
187
  throw new Error("logger params must contain up to 40 numeric values");
188
188
  return !0;
189
- }, bt = (t, e = 150) => t.length > e ? t.substring(0, e) : t, E = (t, e = G) => {
189
+ }, Rt = (t, e = 150) => t.length > e ? t.substring(0, e) : t, E = (t, e = Y) => {
190
190
  const s = t.toLowerCase();
191
- return e.sort((n, a) => a.length - n.length).find((n) => s.includes(n.toLowerCase()));
192
- }, h = (t) => H[t] ?? K[t], me = ({
191
+ return e.sort((a, n) => n.length - a.length).find((a) => s.includes(a.toLowerCase()));
192
+ }, I = (t) => H[t] ?? q[t], pe = ({
193
193
  errorMessage: t,
194
194
  abiErrors: e
195
195
  }) => {
@@ -197,63 +197,63 @@ const m = (t, e) => t?.toLowerCase() === e?.toLowerCase(), jt = (t) => m(t, P),
197
197
  return null;
198
198
  const s = e.find((r) => t.includes(r));
199
199
  if (s && E(s))
200
- return h(s);
201
- const n = E(t);
202
- if (n)
203
- return h(n);
204
- const [a] = t.split(s ? "." : "Contract").map((r) => r.trim());
200
+ return I(s);
201
+ const a = E(t);
202
+ if (a)
203
+ return I(a);
204
+ const [n] = t.split(s ? "." : "Contract").map((r) => r.trim());
205
205
  return {
206
206
  title: "Transaction failed",
207
- hint: `${bt(a ?? "")} ${s ? `: ${s}` : ""}`
207
+ hint: `${Rt(n ?? "")} ${s ? `: ${s}` : ""}`
208
208
  };
209
- }, pe = (t) => typeof t == "number" && Number.isFinite(t), Ae = (t) => typeof t == "bigint" && t !== BigInt(0), Rt = (t, e = C) => new d(t).shiftedBy(-e).toNumber(), Bt = (t) => !isNaN(parseFloat(t)) && !isNaN(t), Ct = ({
209
+ }, Ae = (t) => typeof t == "number" && Number.isFinite(t), Te = (t) => typeof t == "bigint" && t !== BigInt(0), Ct = (t, e = L) => new d(t).shiftedBy(-e).toNumber(), Lt = (t) => !isNaN(parseFloat(t)) && !isNaN(t), Bt = ({
210
210
  value: t,
211
211
  minimumFractionDigits: e = 2,
212
212
  maximumFractionDigits: s = 2,
213
- compact: n = !1,
214
- normalize: a = !1
213
+ compact: a = !1,
214
+ normalize: n = !1
215
215
  }) => new Intl.NumberFormat("en-US", {
216
216
  style: "currency",
217
217
  currency: "USD",
218
- notation: n ? "compact" : void 0,
218
+ notation: a ? "compact" : void 0,
219
219
  minimumFractionDigits: e,
220
220
  maximumFractionDigits: s
221
- }).format(a ? Rt(t) : Number(t)), w = (t) => Bt(t) ? new d(t).toFixed() : "", I = ["₀", "₁", "₂", "₃", "₄", "₅", "₆", "₇", "₈", "₉"], Lt = ({
221
+ }).format(n ? Ct(t) : Number(t)), h = (t) => Lt(t) ? new d(t).toFixed() : "", w = ["₀", "₁", "₂", "₃", "₄", "₅", "₆", "₇", "₈", "₉"], Mt = ({
222
222
  value: t,
223
223
  decimals: e = 4
224
224
  }) => {
225
225
  const s = new d(t);
226
226
  if (s.isGreaterThan(1) || s.isZero())
227
- return w(s.toFixed(e));
228
- const a = (/e/i.test(t.toString()) ? parseFloat(t.toString()).toFixed(C) : t.toString()).match(/^0\.(0+)(\d+)$/);
229
- if (a) {
230
- const [, r, o] = a;
231
- if (r.length >= e && r.length < I.length)
232
- return `0.0${I[r.length]}${o.slice(0, 3)}`;
227
+ return h(s.toFixed(e));
228
+ const n = (/e/i.test(t.toString()) ? parseFloat(t.toString()).toFixed(L) : t.toString()).match(/^0\.(0+)(\d+)$/);
229
+ if (n) {
230
+ const [, r, o] = n;
231
+ if (r.length >= e && r.length < w.length)
232
+ return `0.0${w[r.length]}${o.slice(0, 3)}`;
233
233
  }
234
- return w(s.toFixed(e));
235
- }, Mt = (t, e = 0) => `${t.toLocaleString("en-US", { maximumFractionDigits: e })}%`, ge = (t) => t.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), Te = (t, e, s = 0) => {
236
- const n = It(+t, e);
237
- return Mt(n, s);
238
- }, Se = ({
234
+ return h(s.toFixed(e));
235
+ }, Pt = (t, e = 0) => `${t.toLocaleString("en-US", { maximumFractionDigits: e })}%`, ge = (t) => t.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), Se = (t, e, s = 0) => {
236
+ const a = Nt(+t, e);
237
+ return Pt(a, s);
238
+ }, _e = ({
239
239
  currency: t,
240
240
  value: e
241
- }) => t === "USD" ? Ct({ value: e }) : `${q[t]} ${Lt({
241
+ }) => t === "USD" ? Bt({ value: e }) : `${K[t]} ${Mt({
242
242
  value: e,
243
243
  decimals: k[t]
244
244
  })}`, xt = (t, e) => new d(
245
245
  new d(t).toFixed(e, d.ROUND_DOWN)
246
- ).toString(), Pt = (t, e = 3, s = 2) => {
246
+ ).toString(), Ut = (t, e = 3, s = 2) => {
247
247
  if (t.length <= 5)
248
248
  return t;
249
- const n = "...";
250
- return t.length <= e + s + n.length ? t : `${t.slice(0, e)}${n}${t.slice(-s)}`;
251
- }, ye = ({
249
+ const a = "...";
250
+ return t.length <= e + s + a.length ? t : `${t.slice(0, e)}${a}${t.slice(-s)}`;
251
+ }, De = ({
252
252
  balance: t,
253
253
  symbol: e,
254
254
  precision: s,
255
- truncateSymbol: n
256
- }) => `${xt(t, s)} ${n ? Pt(e) : e}`, De = (t) => {
255
+ truncateSymbol: a
256
+ }) => `${xt(t, s)} ${a ? Ut(e) : e}`, ye = (t) => {
257
257
  if (!t)
258
258
  return;
259
259
  const e = t.match(/0x[a-fA-F0-9]{64}/);
@@ -261,89 +261,94 @@ const m = (t, e) => t?.toLowerCase() === e?.toLowerCase(), jt = (t) => m(t, P),
261
261
  return;
262
262
  const s = e[0];
263
263
  return `${s.slice(0, 4)}...${s.slice(-3)}`;
264
- }, _e = (t) => m(j, t) || m(X, t), fe = (t) => tt.some(
264
+ }, fe = (t) => m(X, t) || m(j, t), Ee = (t) => tt.some(
265
265
  (e) => m(e, t)
266
- ), Ee = (t) => Z[t.toLowerCase()] ?? {
266
+ ), Ie = (t) => Z[t.toLowerCase()] ?? {
267
267
  symbol: "",
268
268
  decimals: 18,
269
269
  address: D
270
- }, he = (t) => m(t, J) ? z : Q, Ut = (t) => `eth_${t}`, we = ({
270
+ }, he = (t) => m(t, J) ? z : Q, Ft = (t) => `eth_${t}`, we = ({
271
271
  action: t,
272
272
  log: e,
273
273
  symbol: s,
274
- vaultAddress: n,
275
- chainId: a
274
+ vaultAddress: a,
275
+ chainId: n
276
276
  }) => {
277
277
  const r = {
278
278
  [S.SYMBOL.NAME]: s,
279
- [S.CHAIN_ID.NAME]: a,
280
- [S.ADDRESS.NAME]: Ut(n)
279
+ [S.CHAIN_ID.NAME]: n,
280
+ [S.ADDRESS.NAME]: Ft(a)
281
281
  };
282
282
  et[t].forEach((o) => {
283
283
  e?.(o, r);
284
284
  });
285
- }, Ie = (t) => at.some((e) => m(e, t)), Ne = (t) => st[t.toLowerCase()] ?? {
285
+ }, Ne = (t) => nt.some((e) => m(e, t)), Oe = (t) => st[t.toLowerCase()] ?? {
286
286
  symbol: "",
287
287
  decimals: 18,
288
288
  address: D
289
- }, Oe = (t) => nt[t.toLowerCase()], Ft = "0x3333333333333333333333333333333333333333";
290
- Dt.id + "", dt.address, yt.id + "", ct.address, St.id + "", it.address, Tt.id + "", ot.address, gt.id + "", rt.address, At.id + "", L.address;
291
- const be = (t) => m(t, Ft), Re = () => L, Be = /* @__PURE__ */ new Map(), M = (t, e) => !e || e.size === 0 ? t : t.map((s) => {
292
- const n = e.get(
289
+ }, be = (t) => at[t.toLowerCase()], Wt = "0x3333333333333333333333333333333333333333";
290
+ yt.id + "", dt.address, Dt.id + "", ct.address, _t.id + "", it.address, St.id + "", ot.address, gt.id + "", rt.address, Tt.id + "", B.address;
291
+ const Re = (t) => m(t, Wt), Ce = () => B, Le = /* @__PURE__ */ new Map(), M = (t, e) => !e || e.size === 0 ? t : t.map((s) => {
292
+ const a = e.get(
293
293
  s.supportedAsset.toLowerCase()
294
294
  );
295
- return n ? { ...s, withdrawData: n } : s;
296
- }), Wt = (t) => {
295
+ return a ? {
296
+ ...s,
297
+ withdrawData: a,
298
+ // Ondo assets require a hardcoded increased slippage
299
+ slippageTolerance: ut
300
+ } : s;
301
+ }), $t = (t) => {
297
302
  const e = t.find(
298
303
  ({ swapQuotes: s }) => s
299
304
  );
300
305
  return e?.swapQuotes ? Object.values(e.swapQuotes)[0]?.map(
301
306
  ({ routerKey: s }) => s
302
307
  ) ?? [] : [];
303
- }, $t = (t, e, s) => t.map(({ asset: n, swapParams: a, swapQuotes: r }) => !a || !r ? {
304
- supportedAsset: n,
308
+ }, vt = (t, e, s) => t.map(({ asset: a, swapParams: n, swapQuotes: r }) => !n || !r ? {
309
+ supportedAsset: a,
305
310
  withdrawData: "",
306
311
  slippageTolerance: s
307
- } : Ot({
308
- assetAddress: n,
312
+ } : bt({
313
+ assetAddress: a,
309
314
  swapQuotes: r,
310
- swapParams: a,
315
+ swapParams: n,
311
316
  slippageToleranceForContractTransaction: s,
312
317
  routerKey: e
313
- })), vt = async (t, e, s, n, a, r) => {
318
+ })), Gt = async (t, e, s, a, n, r) => {
314
319
  for (const o of t) {
315
320
  const c = M(
316
- $t(
321
+ vt(
317
322
  e,
318
323
  o,
319
324
  s
320
325
  ),
321
326
  r
322
- ), { error: i } = await n(...a, c);
327
+ ), { error: i } = await a(...n, c);
323
328
  if (!i)
324
329
  return c;
325
330
  }
326
331
  return null;
327
- }, Ce = (t, e, s) => {
328
- const n = (t ?? []).map((a) => ({
329
- supportedAsset: a,
332
+ }, Be = (t, e, s) => {
333
+ const a = (t ?? []).map((n) => ({
334
+ supportedAsset: n,
330
335
  withdrawData: "",
331
336
  slippageTolerance: e
332
337
  }));
333
- return M(n, s);
334
- }, Le = async (t, e, s, n, a) => {
338
+ return M(a, s);
339
+ }, Me = async (t, e, s, a, n) => {
335
340
  for (const r of t) {
336
- const o = Nt(r);
341
+ const o = Ot(r);
337
342
  try {
338
- const c = await e(r), i = Wt(
343
+ const c = await e(r), i = $t(
339
344
  c
340
- ), u = await vt(
345
+ ), u = await Gt(
341
346
  i,
342
347
  c,
343
348
  o,
344
349
  s,
345
- n,
346
- a
350
+ a,
351
+ n
347
352
  );
348
353
  if (u)
349
354
  return console.debug(
@@ -357,10 +362,10 @@ const be = (t) => m(t, Ft), Re = () => L, Be = /* @__PURE__ */ new Map(), M = (t
357
362
  }
358
363
  }
359
364
  return null;
360
- }, Me = async (t, e, {
365
+ }, Pe = async (t, e, {
361
366
  fetchAaveSwapParams: s,
362
- fetchAaveSwapQuotes: n,
363
- withdrawAmountD18: a,
367
+ fetchAaveSwapQuotes: a,
368
+ withdrawAmountD18: n,
364
369
  slippage: r
365
370
  }) => Promise.all(
366
371
  (t ?? []).map(async (o) => {
@@ -368,11 +373,11 @@ const be = (t) => m(t, Ft), Re = () => L, Be = /* @__PURE__ */ new Map(), M = (t
368
373
  return { asset: o };
369
374
  try {
370
375
  const i = await s({
371
- withdrawAmountD18: a,
376
+ withdrawAmountD18: n,
372
377
  slippage: r
373
378
  });
374
379
  if (i?.srcData.length) {
375
- const u = await n({
380
+ const u = await a({
376
381
  swapParams: i,
377
382
  slippage: r
378
383
  });
@@ -385,13 +390,13 @@ const be = (t) => m(t, Ft), Re = () => L, Be = /* @__PURE__ */ new Map(), M = (t
385
390
  })
386
391
  ), N = (t) => Math.round(t * 100) / 100, xe = ({
387
392
  maxSlippage: t,
388
- candidates: e = ut
393
+ candidates: e = lt
389
394
  }) => {
390
395
  if (!Number.isFinite(t) || t <= 0)
391
396
  return [];
392
- const s = N(Math.min(t, 100)), n = e.filter((r) => r > 0 && r <= s).map(N), a = new Set(n);
393
- return a.add(s), a.add(t), Array.from(a).sort((r, o) => r - o);
394
- }, O = 1000000000000000000n, Vt = 1000000n, b = 10000n, R = 100n, g = (t) => {
397
+ const s = N(Math.min(t, 100)), a = e.filter((r) => r > 0 && r <= s).map(N), n = new Set(a);
398
+ return n.add(s), n.add(t), Array.from(n).sort((r, o) => r - o);
399
+ }, O = 1000000000000000000n, Vt = 1000000n, b = 10000n, R = 100n, T = (t) => {
395
400
  if (!t) throw new Error("Ondo: empty hex value");
396
401
  return t.startsWith("0x") ? t : `0x${t}`;
397
402
  }, l = (t, e) => {
@@ -402,50 +407,50 @@ const be = (t) => m(t, Ft), Re = () => L, Be = /* @__PURE__ */ new Map(), M = (t
402
407
  `Ondo: cannot convert "${e}" value "${t}" to bigint`
403
408
  );
404
409
  }
405
- }, B = (t) => t ? pt(g(t), { size: 32 }) : mt, Yt = (t) => {
410
+ }, C = (t) => t ? At(T(t), { size: 32 }) : pt, Yt = (t) => {
406
411
  if (!t) throw new Error("Ondo: empty signature");
407
- return lt(Uint8Array.from(atob(t), (e) => e.charCodeAt(0)));
408
- }, Pe = (t) => ({
412
+ return mt(Uint8Array.from(atob(t), (e) => e.charCodeAt(0)));
413
+ }, Ue = (t) => ({
409
414
  quotes: t.quotes.map(
410
415
  (e) => ({
411
416
  chainId: l(e.chainId, "chainId"),
412
417
  attestationId: l(e.attestationId, "attestationId"),
413
- userId: g(e.userId),
418
+ userId: T(e.userId),
414
419
  asset: e.asset,
415
420
  price: l(e.price, "price"),
416
421
  quantity: l(e.quantity, "quantity"),
417
422
  expiration: l(e.expiration, "expiration"),
418
423
  side: Number(e.side),
419
- additionalData: g(e.additionalData)
424
+ additionalData: T(e.additionalData)
420
425
  })
421
426
  ),
422
- signatures: t.signatures.map(g)
423
- }), Gt = (t, e, s) => {
424
- const n = BigInt(Math.max(0, Math.round(s * 100))), a = n > R ? R : n, r = b - a, c = t * e / O * r * Vt, i = b * O;
427
+ signatures: t.signatures.map(T)
428
+ }), Ht = (t, e, s) => {
429
+ const a = BigInt(Math.max(0, Math.round(s * 100))), n = a > R ? R : a, r = b - n, c = t * e / O * r * Vt, i = b * O;
425
430
  return (c + i - 1n) / i;
426
- }, Ue = ({
431
+ }, Fe = ({
427
432
  attestation: t,
428
433
  chainId: e,
429
434
  slippagePercent: s
430
435
  }) => {
431
- const n = l(t.tokenAmount, "tokenAmount"), a = l(t.price, "price");
432
- return y(_t, [
436
+ const a = l(t.tokenAmount, "tokenAmount"), n = l(t.price, "price");
437
+ return _(ft, [
433
438
  {
434
439
  attestationSignature: Yt(t.signature),
435
440
  quote: {
436
441
  chainId: e,
437
442
  attestationId: l(t.attestationId, "attestationId"),
438
- userId: B(t.userId),
443
+ userId: C(t.userId),
439
444
  asset: t.assetAddress,
440
- price: a,
441
- quantity: n,
445
+ price: n,
446
+ quantity: a,
442
447
  expiration: l(t.expiration, "expiration"),
443
448
  side: Number(t.side),
444
- additionalData: B(t.additionalData)
449
+ additionalData: C(t.additionalData)
445
450
  },
446
- amountOutMinimum: Gt(
447
- n,
451
+ amountOutMinimum: Ht(
448
452
  a,
453
+ n,
449
454
  s
450
455
  )
451
456
  }
@@ -453,68 +458,68 @@ const be = (t) => m(t, Ft), Re = () => L, Be = /* @__PURE__ */ new Map(), M = (t
453
458
  };
454
459
  export {
455
460
  m as $,
456
- It as A,
457
- ae as B,
458
- Nt as C,
459
- De as D,
460
- Be as E,
461
- te as F,
462
- fe as G,
463
- _e as H,
464
- Ie as I,
465
- be as J,
466
- ce as K,
467
- ue as L,
461
+ Nt as A,
462
+ re as B,
463
+ Ot as C,
464
+ ye as D,
465
+ Le as E,
466
+ ee as F,
467
+ Ee as G,
468
+ fe as H,
469
+ Ne as I,
470
+ Re as J,
471
+ de as K,
472
+ le as L,
468
473
  we as M,
469
- Pe as N,
474
+ Ue as N,
470
475
  M as O,
471
- re as P,
472
- me as Q,
476
+ oe as P,
477
+ pe as Q,
473
478
  ne as R,
474
- Jt as S,
475
- ee as T,
476
- Ut as U,
477
- Pt as V,
478
- vt as W,
479
- Le as X,
480
- le as Y,
479
+ te as S,
480
+ se as T,
481
+ Ft as U,
482
+ Ut as V,
483
+ Gt as W,
484
+ Me as X,
485
+ me as Y,
481
486
  jt as Z,
482
- pe as _,
483
- Ot as a,
484
- Ct as a0,
485
- Ae as a1,
486
- Rt as a2,
487
- zt as a3,
488
- Ft as a4,
489
- Lt as a5,
490
- Qt as a6,
491
- Mt as a7,
492
- Bt as a8,
487
+ Ae as _,
488
+ bt as a,
489
+ Bt as a0,
490
+ Te as a1,
491
+ Ct as a2,
492
+ Qt as a3,
493
+ Wt as a4,
494
+ Mt as a5,
495
+ Xt as a6,
496
+ Pt as a7,
497
+ Lt as a8,
493
498
  ge as a9,
494
- w as aa,
499
+ h as aa,
495
500
  Yt as b,
496
- $t as c,
501
+ vt as c,
497
502
  wt as d,
498
- ie as e,
499
- oe as f,
500
- Zt as g,
501
- Ce as h,
502
- Ue as i,
503
- Me as j,
504
- Wt as k,
503
+ ce as e,
504
+ ie as f,
505
+ zt as g,
506
+ Be as h,
507
+ Fe as i,
508
+ Pe as j,
509
+ $t as k,
505
510
  xt as l,
506
- Se as m,
507
- Te as n,
508
- ye as o,
511
+ _e as m,
512
+ Se as n,
513
+ De as o,
509
514
  xe as p,
510
- Xt as q,
515
+ Jt as q,
511
516
  ht as r,
512
- se as s,
517
+ ae as s,
513
518
  E as t,
514
- Ee as u,
519
+ Ie as u,
515
520
  he as v,
516
- Ne as w,
517
- Oe as x,
518
- Re as y,
519
- de as z
521
+ Oe as w,
522
+ be as x,
523
+ Ce as y,
524
+ ue as z
520
525
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhedge/trading-widget",
3
- "version": "6.0.1",
3
+ "version": "6.0.3",
4
4
  "dependencies": {
5
5
  "@headlessui/react": "^2.1.2",
6
6
  "@heroicons/react": "^2.1.5",