@dhedge/trading-widget 6.0.0 → 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.
- package/const.cjs +1 -1
- package/const.js +64 -63
- package/core-kit/const/trading.d.ts +1 -0
- package/{gmx-Cu3Ax-nZ.js → gmx-C9vHHvqC.js} +125 -124
- package/{gmx-DwT1ybQ5.cjs → gmx-DVJxXc_8.cjs} +1 -1
- package/index.cjs +1 -1
- package/index.js +310 -302
- package/ondo-BnkOJgHw.cjs +1 -0
- package/{ondo-v5VUY6Q9.js → ondo-Cl97ID2o.js} +193 -188
- package/package.json +1 -1
- package/trading-widget/providers/component-provider/component-provider.d.ts +3 -0
- package/trading-widget/providers/component-provider/component-provider.hooks.d.ts +3 -0
- package/trading-widget/providers/component-provider/component-provider.types.d.ts +3 -0
- package/utils.cjs +1 -1
- package/utils.js +1 -1
- package/ondo-RW9qMjVL.cjs +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import d from "bignumber.js";
|
|
2
|
-
import {
|
|
3
|
-
import { stringToHex as f, encodeAbiParameters as
|
|
4
|
-
import { hyperEvm as
|
|
5
|
-
const
|
|
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
|
-
],
|
|
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
|
-
],
|
|
43
|
-
function
|
|
44
|
-
return
|
|
42
|
+
], Et = () => typeof window < "u";
|
|
43
|
+
function It() {
|
|
44
|
+
return Et() && typeof window.ethereum < "u";
|
|
45
45
|
}
|
|
46
|
-
async function
|
|
46
|
+
async function Xt(t) {
|
|
47
47
|
try {
|
|
48
|
-
if (
|
|
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,
|
|
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
|
-
)}`,
|
|
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}`,
|
|
77
|
-
const s = t.slice(0, e),
|
|
78
|
-
return { firstPart: s, secondPart:
|
|
79
|
-
},
|
|
80
|
-
new d(t || "0").shiftedBy(
|
|
81
|
-
),
|
|
82
|
-
const e = new d(0.01), s = new d(t),
|
|
83
|
-
return BigInt(
|
|
84
|
-
},
|
|
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:
|
|
89
|
-
vaultDepositTokenAddress:
|
|
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,
|
|
97
|
-
},
|
|
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:
|
|
101
|
+
slippage: a
|
|
102
102
|
}) => {
|
|
103
|
-
const
|
|
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
|
-
},
|
|
118
|
+
}, n) ?? n;
|
|
119
119
|
return [
|
|
120
120
|
r,
|
|
121
121
|
[
|
|
122
122
|
t,
|
|
123
|
-
o.times(1 -
|
|
123
|
+
o.times(1 - a / 100).toFixed(0, d.ROUND_DOWN)
|
|
124
124
|
]
|
|
125
125
|
];
|
|
126
|
-
},
|
|
126
|
+
}, bt = ({
|
|
127
127
|
assetAddress: t,
|
|
128
128
|
swapQuotes: e,
|
|
129
129
|
swapParams: s,
|
|
130
|
-
slippageToleranceForContractTransaction:
|
|
131
|
-
routerKey:
|
|
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
|
|
140
|
+
const g = e?.[wt({
|
|
141
141
|
sourceAddress: p,
|
|
142
142
|
amount: A.toString()
|
|
143
|
-
})]?.find((
|
|
143
|
+
})]?.find((P) => P.routerKey === n);
|
|
144
144
|
return {
|
|
145
145
|
asset: p,
|
|
146
146
|
amount: A,
|
|
147
147
|
swapData: {
|
|
148
|
-
routerKey: f(
|
|
149
|
-
txData:
|
|
148
|
+
routerKey: f(g?.routerKey ?? "", { size: 32 }),
|
|
149
|
+
txData: g?.rawTransaction.data ?? "0x"
|
|
150
150
|
}
|
|
151
151
|
};
|
|
152
|
-
}), i =
|
|
152
|
+
}), i = _(
|
|
153
153
|
W,
|
|
154
154
|
[c]
|
|
155
|
-
), u =
|
|
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:
|
|
162
|
+
slippage: a
|
|
163
163
|
}
|
|
164
164
|
]);
|
|
165
165
|
return {
|
|
166
166
|
supportedAsset: t,
|
|
167
167
|
withdrawData: u,
|
|
168
|
-
slippageTolerance:
|
|
168
|
+
slippageTolerance: a
|
|
169
169
|
};
|
|
170
|
-
},
|
|
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
|
|
176
|
-
|
|
175
|
+
const a = new d(s).multipliedBy(v).shiftedBy(-e), n = new d(t).minus(
|
|
176
|
+
a
|
|
177
177
|
);
|
|
178
|
-
return
|
|
179
|
-
},
|
|
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:
|
|
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
|
-
},
|
|
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((
|
|
192
|
-
},
|
|
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
|
|
201
|
-
const
|
|
202
|
-
if (
|
|
203
|
-
return
|
|
204
|
-
const [
|
|
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: `${
|
|
207
|
+
hint: `${Rt(n ?? "")} ${s ? `: ${s}` : ""}`
|
|
208
208
|
};
|
|
209
|
-
},
|
|
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:
|
|
214
|
-
normalize:
|
|
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:
|
|
218
|
+
notation: a ? "compact" : void 0,
|
|
219
219
|
minimumFractionDigits: e,
|
|
220
220
|
maximumFractionDigits: s
|
|
221
|
-
}).format(
|
|
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
|
|
228
|
-
const
|
|
229
|
-
if (
|
|
230
|
-
const [, r, o] =
|
|
231
|
-
if (r.length >= e && r.length <
|
|
232
|
-
return `0.0${
|
|
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
|
|
235
|
-
},
|
|
236
|
-
const
|
|
237
|
-
return
|
|
238
|
-
},
|
|
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" ?
|
|
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(),
|
|
246
|
+
).toString(), Ut = (t, e = 3, s = 2) => {
|
|
247
247
|
if (t.length <= 5)
|
|
248
248
|
return t;
|
|
249
|
-
const
|
|
250
|
-
return t.length <= e + s +
|
|
251
|
-
},
|
|
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:
|
|
256
|
-
}) => `${xt(t, s)} ${
|
|
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
|
-
},
|
|
264
|
+
}, fe = (t) => m(X, t) || m(j, t), Ee = (t) => tt.some(
|
|
265
265
|
(e) => m(e, t)
|
|
266
|
-
),
|
|
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,
|
|
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:
|
|
275
|
-
chainId:
|
|
274
|
+
vaultAddress: a,
|
|
275
|
+
chainId: n
|
|
276
276
|
}) => {
|
|
277
277
|
const r = {
|
|
278
278
|
[S.SYMBOL.NAME]: s,
|
|
279
|
-
[S.CHAIN_ID.NAME]:
|
|
280
|
-
[S.ADDRESS.NAME]:
|
|
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
|
-
},
|
|
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
|
-
},
|
|
290
|
-
|
|
291
|
-
const
|
|
292
|
-
const
|
|
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
|
|
296
|
-
|
|
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
|
-
},
|
|
304
|
-
supportedAsset:
|
|
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
|
-
} :
|
|
308
|
-
assetAddress:
|
|
312
|
+
} : bt({
|
|
313
|
+
assetAddress: a,
|
|
309
314
|
swapQuotes: r,
|
|
310
|
-
swapParams:
|
|
315
|
+
swapParams: n,
|
|
311
316
|
slippageToleranceForContractTransaction: s,
|
|
312
317
|
routerKey: e
|
|
313
|
-
})),
|
|
318
|
+
})), Gt = async (t, e, s, a, n, r) => {
|
|
314
319
|
for (const o of t) {
|
|
315
320
|
const c = M(
|
|
316
|
-
|
|
321
|
+
vt(
|
|
317
322
|
e,
|
|
318
323
|
o,
|
|
319
324
|
s
|
|
320
325
|
),
|
|
321
326
|
r
|
|
322
|
-
), { error: i } = await
|
|
327
|
+
), { error: i } = await a(...n, c);
|
|
323
328
|
if (!i)
|
|
324
329
|
return c;
|
|
325
330
|
}
|
|
326
331
|
return null;
|
|
327
|
-
},
|
|
328
|
-
const
|
|
329
|
-
supportedAsset:
|
|
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(
|
|
334
|
-
},
|
|
338
|
+
return M(a, s);
|
|
339
|
+
}, Me = async (t, e, s, a, n) => {
|
|
335
340
|
for (const r of t) {
|
|
336
|
-
const o =
|
|
341
|
+
const o = Ot(r);
|
|
337
342
|
try {
|
|
338
|
-
const c = await e(r), i =
|
|
343
|
+
const c = await e(r), i = $t(
|
|
339
344
|
c
|
|
340
|
-
), u = await
|
|
345
|
+
), u = await Gt(
|
|
341
346
|
i,
|
|
342
347
|
c,
|
|
343
348
|
o,
|
|
344
349
|
s,
|
|
345
|
-
|
|
346
|
-
|
|
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
|
-
},
|
|
365
|
+
}, Pe = async (t, e, {
|
|
361
366
|
fetchAaveSwapParams: s,
|
|
362
|
-
fetchAaveSwapQuotes:
|
|
363
|
-
withdrawAmountD18:
|
|
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:
|
|
376
|
+
withdrawAmountD18: n,
|
|
372
377
|
slippage: r
|
|
373
378
|
});
|
|
374
379
|
if (i?.srcData.length) {
|
|
375
|
-
const u = await
|
|
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 =
|
|
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)),
|
|
393
|
-
return
|
|
394
|
-
}, O = 1000000000000000000n, Vt = 1000000n, b = 10000n, R = 100n,
|
|
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
|
-
},
|
|
410
|
+
}, C = (t) => t ? At(T(t), { size: 32 }) : pt, Yt = (t) => {
|
|
406
411
|
if (!t) throw new Error("Ondo: empty signature");
|
|
407
|
-
return
|
|
408
|
-
},
|
|
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:
|
|
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:
|
|
424
|
+
additionalData: T(e.additionalData)
|
|
420
425
|
})
|
|
421
426
|
),
|
|
422
|
-
signatures: t.signatures.map(
|
|
423
|
-
}),
|
|
424
|
-
const
|
|
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
|
-
},
|
|
431
|
+
}, Fe = ({
|
|
427
432
|
attestation: t,
|
|
428
433
|
chainId: e,
|
|
429
434
|
slippagePercent: s
|
|
430
435
|
}) => {
|
|
431
|
-
const
|
|
432
|
-
return
|
|
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:
|
|
443
|
+
userId: C(t.userId),
|
|
439
444
|
asset: t.assetAddress,
|
|
440
|
-
price:
|
|
441
|
-
quantity:
|
|
445
|
+
price: n,
|
|
446
|
+
quantity: a,
|
|
442
447
|
expiration: l(t.expiration, "expiration"),
|
|
443
448
|
side: Number(t.side),
|
|
444
|
-
additionalData:
|
|
449
|
+
additionalData: C(t.additionalData)
|
|
445
450
|
},
|
|
446
|
-
amountOutMinimum:
|
|
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
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
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
|
-
|
|
474
|
+
Ue as N,
|
|
470
475
|
M as O,
|
|
471
|
-
|
|
472
|
-
|
|
476
|
+
oe as P,
|
|
477
|
+
pe as Q,
|
|
473
478
|
ne as R,
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
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
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
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
|
-
|
|
499
|
+
h as aa,
|
|
495
500
|
Yt as b,
|
|
496
|
-
|
|
501
|
+
vt as c,
|
|
497
502
|
wt as d,
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
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
|
-
|
|
507
|
-
|
|
508
|
-
|
|
511
|
+
_e as m,
|
|
512
|
+
Se as n,
|
|
513
|
+
De as o,
|
|
509
514
|
xe as p,
|
|
510
|
-
|
|
515
|
+
Jt as q,
|
|
511
516
|
ht as r,
|
|
512
|
-
|
|
517
|
+
ae as s,
|
|
513
518
|
E as t,
|
|
514
|
-
|
|
519
|
+
Ie as u,
|
|
515
520
|
he as v,
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
521
|
+
Oe as w,
|
|
522
|
+
be as x,
|
|
523
|
+
Ce as y,
|
|
524
|
+
ue as z
|
|
520
525
|
};
|