@dhedge/trading-widget 6.0.5 → 6.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +1 -1
- package/index.js +35 -31
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { usePopperTooltip as rc } from "react-popper-tooltip";
|
|
|
9
9
|
import { createContext as me, useMemo as P, useContext as we, useReducer as _n, useCallback as f, useState as W, useEffect as N, forwardRef as oc, useRef as pe, Children as ac, isValidElement as sc, Fragment as ic } from "react";
|
|
10
10
|
import { ChevronDownIcon as Ba, ArrowDownIcon as lc, ArrowPathIcon as cc, CheckIcon as Yt } from "@heroicons/react/24/solid";
|
|
11
11
|
import { XMarkIcon as Ma, ChevronLeftIcon as dc } from "@heroicons/react/16/solid";
|
|
12
|
-
import { g as Pn, N as pc, q as uc, r as X, $ as V, a0 as Fa, L as On, z as mc, a1 as
|
|
12
|
+
import { g as Pn, N as pc, q as uc, r as X, $ as V, a0 as Fa, L as On, z as mc, a1 as K, T as wc, S as Xe, B as xo, a2 as re, s as ut, A as dt, n as pn, a3 as hc, a4 as Ht, I as gc, C as Wa, U as vc, D as Dr, d as fc, a5 as bc, i as yc, p as Rr, E as Tc, h as ar, Z as Ac, k as Sc, Y as xc, j as Cc, Q as Ua, m as sr, f as Co, O as Ec, W as Ic, a6 as za, V as Ga, H as Ha, u as Va, v as Nc, o as ja, M as qa, e as _c, a7 as He, a8 as Pc, F as Ka, R as Ya, a9 as $r, aa as Oc, G as Eo, x as kc, w as Lc, J as Dc, y as Rc, K as $c, l as Bc } from "./ondo-GwhTVXds.js";
|
|
13
13
|
import { ab as RN, ac as $N, _ as BN } from "./ondo-GwhTVXds.js";
|
|
14
14
|
import { CustomError as Qa } from "ts-custom-error";
|
|
15
15
|
import { i as Mc, a as I, q as F, H as Fc, p as kn, S as Io, T as Wc, a0 as un, t as No, k as Uc, r as zc, a9 as Gc, a8 as De, m as Hc, u as Xa, n as Vc, j as jc, x as Za, af as et, b as Ut, aA as Ze, aB as Ve, aC as Je, aD as pt, v as qc, B as Ja, $ as Ie, aE as ir, O as es, J as Kc, ar as bn, g as ts, ae as mt, a1 as xe, aF as Yc, K as Vt, aG as ns, F as rs, I as os, l as Qc, G as Xc, ak as Zc, aj as Jc, D as ed, aH as td, a2 as Pe, z as Ue, L as nd, ad as Br, s as as, aa as rd, a5 as ss, y as is, av as Rt, au as $t, w as ls, E as od, al as cs, c as ds, ac as ad, Y as sd, ai as ps, aI as us, a6 as id, aJ as ld } from "./gmx-DQ-wSifY.js";
|
|
@@ -1554,11 +1554,11 @@ var Zr = fh, bh = 9007199254740991;
|
|
|
1554
1554
|
function yh(e) {
|
|
1555
1555
|
return typeof e == "number" && e > -1 && e % 1 == 0 && e <= bh;
|
|
1556
1556
|
}
|
|
1557
|
-
var Jr = yh, Th = yt, Ah = Jr, Sh = Ct, xh = "[object Arguments]", Ch = "[object Array]", Eh = "[object Boolean]", Ih = "[object Date]", Nh = "[object Error]", _h = "[object Function]", Ph = "[object Map]", Oh = "[object Number]", kh = "[object Object]", Lh = "[object RegExp]", Dh = "[object Set]", Rh = "[object String]", $h = "[object WeakMap]", Bh = "[object ArrayBuffer]", Mh = "[object DataView]", Fh = "[object Float32Array]", Wh = "[object Float64Array]", Uh = "[object Int8Array]", zh = "[object Int16Array]", Gh = "[object Int32Array]", Hh = "[object Uint8Array]", Vh = "[object Uint8ClampedArray]", jh = "[object Uint16Array]", qh = "[object Uint32Array]",
|
|
1558
|
-
|
|
1559
|
-
|
|
1557
|
+
var Jr = yh, Th = yt, Ah = Jr, Sh = Ct, xh = "[object Arguments]", Ch = "[object Array]", Eh = "[object Boolean]", Ih = "[object Date]", Nh = "[object Error]", _h = "[object Function]", Ph = "[object Map]", Oh = "[object Number]", kh = "[object Object]", Lh = "[object RegExp]", Dh = "[object Set]", Rh = "[object String]", $h = "[object WeakMap]", Bh = "[object ArrayBuffer]", Mh = "[object DataView]", Fh = "[object Float32Array]", Wh = "[object Float64Array]", Uh = "[object Int8Array]", zh = "[object Int16Array]", Gh = "[object Int32Array]", Hh = "[object Uint8Array]", Vh = "[object Uint8ClampedArray]", jh = "[object Uint16Array]", qh = "[object Uint32Array]", Y = {};
|
|
1558
|
+
Y[Fh] = Y[Wh] = Y[Uh] = Y[zh] = Y[Gh] = Y[Hh] = Y[Vh] = Y[jh] = Y[qh] = !0;
|
|
1559
|
+
Y[xh] = Y[Ch] = Y[Bh] = Y[Eh] = Y[Mh] = Y[Ih] = Y[Nh] = Y[_h] = Y[Ph] = Y[Oh] = Y[kh] = Y[Lh] = Y[Dh] = Y[Rh] = Y[$h] = !1;
|
|
1560
1560
|
function Kh(e) {
|
|
1561
|
-
return Sh(e) && Ah(e.length) && !!
|
|
1561
|
+
return Sh(e) && Ah(e.length) && !!Y[Th(e)];
|
|
1562
1562
|
}
|
|
1563
1563
|
var Yh = Kh;
|
|
1564
1564
|
function Qh(e) {
|
|
@@ -3018,7 +3018,7 @@ const fi = /* @__PURE__ */ Bn(eT), bi = ({
|
|
|
3018
3018
|
address: e,
|
|
3019
3019
|
chainId: t
|
|
3020
3020
|
});
|
|
3021
|
-
return n ? o ||
|
|
3021
|
+
return n ? o || K(n, r) : !1;
|
|
3022
3022
|
}, iT = ({
|
|
3023
3023
|
address: e,
|
|
3024
3024
|
chainId: t
|
|
@@ -3162,7 +3162,7 @@ const fi = /* @__PURE__ */ Bn(eT), bi = ({
|
|
|
3162
3162
|
BigInt(o?.tokenPrice ?? r?.tokenPrice ?? "0")
|
|
3163
3163
|
);
|
|
3164
3164
|
}, wo = ({ address: e, chainId: t }) => {
|
|
3165
|
-
const [n] = vt(), r =
|
|
3165
|
+
const [n] = vt(), r = K(n.address, e) ? n : null, {
|
|
3166
3166
|
data: {
|
|
3167
3167
|
performanceFee: o,
|
|
3168
3168
|
streamingFee: a,
|
|
@@ -3275,7 +3275,7 @@ const fi = /* @__PURE__ */ Bn(eT), bi = ({
|
|
|
3275
3275
|
})),
|
|
3276
3276
|
query: {
|
|
3277
3277
|
select: (o) => n.some(({ amount: a, tokenAddress: i }, l) => (!!o[l]?.result || wT.some(
|
|
3278
|
-
(p) =>
|
|
3278
|
+
(p) => K(p, i)
|
|
3279
3279
|
)) && a !== "0"),
|
|
3280
3280
|
staleTime: 1 / 0
|
|
3281
3281
|
}
|
|
@@ -3353,7 +3353,7 @@ const Ai = (e, t) => hc(e) ? {
|
|
|
3353
3353
|
chainId: t,
|
|
3354
3354
|
address: n
|
|
3355
3355
|
}) => {
|
|
3356
|
-
const { data: r, isFetched: o } = he({ address: n, chainId: t }), { poolFallbackData: a } = oe(), i =
|
|
3356
|
+
const { data: r, isFetched: o } = he({ address: n, chainId: t }), { poolFallbackData: a } = oe(), i = K(a.address, n) ? a.tokenPrice ?? "0" : "0";
|
|
3357
3357
|
return Oe({
|
|
3358
3358
|
address: e ? n : void 0,
|
|
3359
3359
|
abi: Ve,
|
|
@@ -3422,7 +3422,7 @@ const Ai = (e, t) => hc(e) ? {
|
|
|
3422
3422
|
address: e,
|
|
3423
3423
|
chainId: t
|
|
3424
3424
|
}), o = Xt().find(
|
|
3425
|
-
(i) =>
|
|
3425
|
+
(i) => K(e, i.address) && i.chainId === t
|
|
3426
3426
|
), a = !!(o?.maintenance || o?.maintenanceDeposits);
|
|
3427
3427
|
return n || a;
|
|
3428
3428
|
}, IN = (e) => he(e), xT = [], tn = ({
|
|
@@ -3464,7 +3464,7 @@ const Ai = (e, t) => hc(e) ? {
|
|
|
3464
3464
|
} = y(), { account: r = I } = R(), o = Be({ symbol: t, address: e }), { data: { totalSupplyD18: a } = {} } = he({
|
|
3465
3465
|
address: e,
|
|
3466
3466
|
chainId: n
|
|
3467
|
-
}), l = gc(e) && !
|
|
3467
|
+
}), l = gc(e) && !K(r, I), {
|
|
3468
3468
|
data: { lockedVaultPointsBalance: c, unlockTaxInPercents: d, unlockTime: p } = {},
|
|
3469
3469
|
isLoading: u
|
|
3470
3470
|
} = mT({
|
|
@@ -4076,7 +4076,7 @@ const eA = () => {
|
|
|
4076
4076
|
refetchInterval: n,
|
|
4077
4077
|
disabled: r = !1
|
|
4078
4078
|
}) => {
|
|
4079
|
-
const { supportedChainId: o } = nt(), {
|
|
4079
|
+
const { supportedChainId: o } = nt(), { address: a } = y(), { data: i } = le({
|
|
4080
4080
|
contracts: [
|
|
4081
4081
|
{
|
|
4082
4082
|
address: X("factory", t ?? o),
|
|
@@ -4087,11 +4087,15 @@ const eA = () => {
|
|
|
4087
4087
|
}
|
|
4088
4088
|
],
|
|
4089
4089
|
query: {
|
|
4090
|
-
|
|
4090
|
+
// A vault's own token has no price aggregator registered on the factory,
|
|
4091
|
+
// so `getAssetPrice(poolAddress)` reverts with "Price aggregator not
|
|
4092
|
+
// found". This can happen transiently on the deposit tab, where the
|
|
4093
|
+
// receive token is the vault itself.
|
|
4094
|
+
enabled: !V(e) && !K(e, a) && !r,
|
|
4091
4095
|
refetchInterval: n
|
|
4092
4096
|
}
|
|
4093
4097
|
});
|
|
4094
|
-
return ro(
|
|
4098
|
+
return ro(i), i?.[0]?.result;
|
|
4095
4099
|
}, ue = ({
|
|
4096
4100
|
address: e,
|
|
4097
4101
|
chainId: t,
|
|
@@ -4341,7 +4345,7 @@ const rA = () => {
|
|
|
4341
4345
|
}) => {
|
|
4342
4346
|
const h = Dr(d), v = p ? Rr({ maxSlippage: d }) : [], g = i ? await l(c) : Tc;
|
|
4343
4347
|
if (!r?.some(
|
|
4344
|
-
(O) =>
|
|
4348
|
+
(O) => K(O, n)
|
|
4345
4349
|
))
|
|
4346
4350
|
return ar(
|
|
4347
4351
|
r,
|
|
@@ -4546,7 +4550,7 @@ const $i = (e, t) => {
|
|
|
4546
4550
|
} = fA(), o = qn();
|
|
4547
4551
|
return {
|
|
4548
4552
|
// EasySwapperV2::unrollAndClaim is not supported from within dHEDGE vaults. Managers should be able to use regular initWithdrawal & completeWithdrawal flow instead.
|
|
4549
|
-
isUnrollAndClaimTransaction: t?.length === 1 &&
|
|
4553
|
+
isUnrollAndClaimTransaction: t?.length === 1 && K(t[0]?.address, e.address) && !o,
|
|
4550
4554
|
isFetching: n,
|
|
4551
4555
|
isFetched: r
|
|
4552
4556
|
};
|
|
@@ -4722,7 +4726,7 @@ const $i = (e, t) => {
|
|
|
4722
4726
|
chainId: t,
|
|
4723
4727
|
args: [e],
|
|
4724
4728
|
query: { enabled: !V(e) }
|
|
4725
|
-
}), NA = (e, t) =>
|
|
4729
|
+
}), NA = (e, t) => K(e, td.address) && t === Wr.id, _A = ({
|
|
4726
4730
|
tokenAddress: e,
|
|
4727
4731
|
spenderAddress: t
|
|
4728
4732
|
}) => {
|
|
@@ -4950,7 +4954,7 @@ const $i = (e, t) => {
|
|
|
4950
4954
|
referrerAddress: void 0,
|
|
4951
4955
|
referralData: void 0
|
|
4952
4956
|
}, DA = (e, t) => {
|
|
4953
|
-
if (!e || !bd(e) || t &&
|
|
4957
|
+
if (!e || !bd(e) || t && K(e, t))
|
|
4954
4958
|
return En;
|
|
4955
4959
|
const n = yd([{ type: "address" }], [e]);
|
|
4956
4960
|
return { referrerAddress: e, referralData: n };
|
|
@@ -4975,7 +4979,7 @@ const $i = (e, t) => {
|
|
|
4975
4979
|
return n !== !1;
|
|
4976
4980
|
}, ua = (e, t) => e.length ? e.find(
|
|
4977
4981
|
({ tokenAddress: r }) => Object.values(nd[t] ?? {}).some(
|
|
4978
|
-
(o) =>
|
|
4982
|
+
(o) => K(o.address, r)
|
|
4979
4983
|
)
|
|
4980
4984
|
)?.tokenAddress ?? e[0]?.tokenAddress : null, _t = () => {
|
|
4981
4985
|
const [e] = D(), { chainId: t, address: n } = y(), r = It({
|
|
@@ -4999,7 +5003,7 @@ const $i = (e, t) => {
|
|
|
4999
5003
|
};
|
|
5000
5004
|
}
|
|
5001
5005
|
const l = a.find(
|
|
5002
|
-
({ tokenAddress: c }) =>
|
|
5006
|
+
({ tokenAddress: c }) => K(c, e.address)
|
|
5003
5007
|
);
|
|
5004
5008
|
return l ? {
|
|
5005
5009
|
depositMethod: o ? Ue.DEPOSIT_CUSTOM : Ue.DEPOSIT,
|
|
@@ -5017,7 +5021,7 @@ const $i = (e, t) => {
|
|
|
5017
5021
|
]);
|
|
5018
5022
|
}, on = () => {
|
|
5019
5023
|
const [e] = D(), { vaultDepositTokenAddress: t } = _t();
|
|
5020
|
-
return !
|
|
5024
|
+
return !K(e.address, t);
|
|
5021
5025
|
}, er = () => {
|
|
5022
5026
|
const e = uo(), [{ slippage: t }] = ee(), n = on();
|
|
5023
5027
|
return t === "auto" ? n ? e : ts : t;
|
|
@@ -5973,7 +5977,7 @@ const $S = /* @__PURE__ */ Bn(RS), sn = ({
|
|
|
5973
5977
|
}, QS = [
|
|
5974
5978
|
za,
|
|
5975
5979
|
$t.address
|
|
5976
|
-
], wa = ({ tokenAddress: e }) => QS.some((t) =>
|
|
5980
|
+
], wa = ({ tokenAddress: e }) => QS.some((t) => K(e, t)), XS = ({ tokenAddress: e }) => K(e, za), ha = ({ tokenAddress: e }) => K(e, Rt.address), ZS = (e, t) => {
|
|
5977
5981
|
if (t !== Fr.id || !e.some(XS))
|
|
5978
5982
|
return e;
|
|
5979
5983
|
const n = e.filter((c) => !wa(c)), r = e.filter(wa), [o] = r;
|
|
@@ -6001,7 +6005,7 @@ const $S = /* @__PURE__ */ Bn(RS), sn = ({
|
|
|
6001
6005
|
}, JS = (e, t) => {
|
|
6002
6006
|
if (t.length === 0)
|
|
6003
6007
|
return e;
|
|
6004
|
-
const n = ({ tokenAddress: c }) => t.some((d) =>
|
|
6008
|
+
const n = ({ tokenAddress: c }) => t.some((d) => K(c, d)), r = e.filter((c) => n(c) || ha(c));
|
|
6005
6009
|
if (!r.some(n))
|
|
6006
6010
|
return e;
|
|
6007
6011
|
const [o] = r;
|
|
@@ -6040,7 +6044,7 @@ const $S = /* @__PURE__ */ Bn(RS), sn = ({
|
|
|
6040
6044
|
[o, n, a]
|
|
6041
6045
|
), l = e ? i.length : ls, c = i.find(
|
|
6042
6046
|
({ tokenAddress: m }) => es.some(
|
|
6043
|
-
(h) =>
|
|
6047
|
+
(h) => K(m, h)
|
|
6044
6048
|
)
|
|
6045
6049
|
), d = !!c && c.amount !== "0", { firstPart: p, secondPart: u } = Ga(
|
|
6046
6050
|
i,
|
|
@@ -6430,7 +6434,7 @@ const sx = (e) => {
|
|
|
6430
6434
|
query: { enabled: !V(e) }
|
|
6431
6435
|
});
|
|
6432
6436
|
}, To = () => {
|
|
6433
|
-
const { chainId: e } = y(), [t] = M(), n = Di({ address: t.address, chainId: e }), r = at(), { data: o = [] } = ce(), a = o.filter(({ address: u }) =>
|
|
6437
|
+
const { chainId: e } = y(), [t] = M(), n = Di({ address: t.address, chainId: e }), r = at(), { data: o = [] } = ce(), a = o.filter(({ address: u }) => K(u, t.address)).reduce((u, { rawBalance: m }) => u + m, BigInt(0)), i = o.filter(({ address: u }) => !K(u, t.address)).reduce((u, { valueInUsd: m }) => u + m, 0), l = new _(i).shiftedBy(F).div(n?.toString() ?? "1").shiftedBy(t.decimals).toFixed(0, _.ROUND_DOWN), c = new _(l).times(1 - as / 100).times(1 - r / 100).toFixed(0, _.ROUND_DOWN), d = new _(
|
|
6434
6438
|
a.toString()
|
|
6435
6439
|
).plus(l).toFixed(0, _.ROUND_DOWN), p = new _(
|
|
6436
6440
|
a.toString()
|
|
@@ -6528,7 +6532,7 @@ const sx = (e) => {
|
|
|
6528
6532
|
return { isCompleteWithdrawStep: e?.length > 0, isFetching: t };
|
|
6529
6533
|
}, st = () => {
|
|
6530
6534
|
const e = uo(), { chainId: t } = y(), { account: n = I } = R(), [{ slippage: r }] = ee(), [o] = M(), { data: a = [] } = ce(), i = Zi(), l = P(
|
|
6531
|
-
() => a.filter(({ address: c }) => !
|
|
6535
|
+
() => a.filter(({ address: c }) => !K(c, o.address)).map(({ address: c, rawBalance: d }) => ({
|
|
6532
6536
|
chainId: t,
|
|
6533
6537
|
sourceAddress: c,
|
|
6534
6538
|
destinationAddress: o.address,
|
|
@@ -6561,7 +6565,7 @@ const sx = (e) => {
|
|
|
6561
6565
|
if (n.length === 0 || o || a)
|
|
6562
6566
|
return;
|
|
6563
6567
|
const i = n.reduce((l, c) => {
|
|
6564
|
-
if (
|
|
6568
|
+
if (K(c.address, e.address))
|
|
6565
6569
|
return l.plus(c.rawBalance.toString());
|
|
6566
6570
|
const d = r?.[c.address] ?? [], u = d[aA(d)]?.destinationAmount ?? "0";
|
|
6567
6571
|
return l.plus(u);
|
|
@@ -6595,7 +6599,7 @@ const sx = (e) => {
|
|
|
6595
6599
|
value: $.toString()
|
|
6596
6600
|
})
|
|
6597
6601
|
), b = t ? null : g.filter(
|
|
6598
|
-
(T) => !
|
|
6602
|
+
(T) => !K(T.address, l.address)
|
|
6599
6603
|
);
|
|
6600
6604
|
c({
|
|
6601
6605
|
isOpen: !0,
|
|
@@ -6647,7 +6651,7 @@ const sx = (e) => {
|
|
|
6647
6651
|
return e === "0" || n.isZero() ? 0 : n.dividedBy(e).minus(1).times(100).decimalPlaces(2, _.ROUND_DOWN).toNumber();
|
|
6648
6652
|
}, Zi = () => {
|
|
6649
6653
|
const [e] = M(), { data: t = [] } = ce();
|
|
6650
|
-
return t.length > 0 && t.some(({ address: n }) => !
|
|
6654
|
+
return t.length > 0 && t.some(({ address: n }) => !K(n, e.address));
|
|
6651
6655
|
}, wx = ({
|
|
6652
6656
|
handleTrade: e,
|
|
6653
6657
|
onError: t
|
|
@@ -10995,7 +10999,7 @@ const Nl = (e) => {
|
|
|
10995
10999
|
const i = a.getWithdrawAssetByVaultAddress(e.address)?.address ?? a.getWithdrawAssetByLeverageAddress(
|
|
10996
11000
|
o.tokenAddress
|
|
10997
11001
|
).address, l = t.find(
|
|
10998
|
-
({ tokenAddress: u }) =>
|
|
11002
|
+
({ tokenAddress: u }) => K(i, u)
|
|
10999
11003
|
);
|
|
11000
11004
|
if (!l)
|
|
11001
11005
|
return Tr;
|
|
@@ -11997,7 +12001,7 @@ export {
|
|
|
11997
12001
|
xo as getPoolFraction,
|
|
11998
12002
|
nP as hexToString,
|
|
11999
12003
|
Eo as isAaveLendAndBorrowAsset,
|
|
12000
|
-
|
|
12004
|
+
K as isEqualAddress,
|
|
12001
12005
|
Wb as isErrorWithMessage,
|
|
12002
12006
|
gc as isFmpAirdropVaultAddress,
|
|
12003
12007
|
On as isNativeToken,
|