@dhedge/trading-widget 6.1.1 → 6.2.0-canary.1

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/dytm-CWhBYz0P.js DELETED
@@ -1,784 +0,0 @@
1
- import { mainnet as f, hyperEvm as $, polygon as Y, optimism as k, base as q, arbitrum as G } from "wagmi/chains";
2
- import { ar as V, ap as K, aq as H, a as _, q as w, as as z, at as Q, a5 as Z, al as j, a3 as X, b as J, ae as tt, ak as et, aj as at, Z as nt, au as x, e as st, d as ot, M as rt, R as it, P as ut, av as ct, aw as dt, Q as pt, N as mt, ah as S, _ as lt, W as yt, X as At, U as Tt, ax as P, ay as gt, az as Dt, aA as St, aB as ft, aC as _t, ad as wt } from "./gmx-c42QlKyJ.js";
3
- import c from "bignumber.js";
4
- import { zeroHash as Et, bytesToHex as bt, pad as ht, stringToHex as E, encodeAbiParameters as g, encodeFunctionData as A, erc20Abi as U, maxUint256 as b } from "viem";
5
- const se = typeof window < "u", oe = [
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
- {
20
- inputs: [],
21
- name: "ondoGMSwap",
22
- outputs: [{ internalType: "address", name: "", type: "address" }],
23
- stateMutability: "view",
24
- type: "function"
25
- },
26
- {
27
- inputs: [],
28
- name: "usdc",
29
- outputs: [{ internalType: "address", name: "", type: "address" }],
30
- stateMutability: "view",
31
- type: "function"
32
- }
33
- ], It = [
34
- {
35
- type: "tuple",
36
- components: [
37
- { name: "attestationSignature", type: "bytes" },
38
- {
39
- name: "quote",
40
- type: "tuple",
41
- components: [
42
- { name: "chainId", type: "uint256" },
43
- { name: "attestationId", type: "uint256" },
44
- { name: "userId", type: "bytes32" },
45
- { name: "asset", type: "address" },
46
- { name: "price", type: "uint256" },
47
- { name: "quantity", type: "uint256" },
48
- { name: "expiration", type: "uint256" },
49
- { name: "side", type: "uint8" },
50
- { name: "additionalData", type: "bytes32" }
51
- ]
52
- },
53
- { name: "amountOutMinimum", type: "uint256" }
54
- ]
55
- }
56
- ], Nt = [
57
- { name: "asset", type: "address" },
58
- { name: "amount", type: "uint256" },
59
- { name: "assetType", type: "uint16" },
60
- { name: "isPool", type: "bool" },
61
- { name: "isDebt", type: "bool" },
62
- { name: "marketId", type: "uint88" },
63
- { name: "accountId", type: "uint256" },
64
- { name: "tokenId", type: "uint256" },
65
- { name: "debtKey", type: "uint248" },
66
- { name: "shares", type: "uint256" }
67
- ], re = [
68
- {
69
- inputs: [
70
- { internalType: "address", name: "_pool", type: "address" },
71
- { internalType: "uint256", name: "_poolTokenAmount", type: "uint256" }
72
- ],
73
- name: "previewWithdrawal",
74
- outputs: [
75
- {
76
- name: "assetData",
77
- type: "tuple[]",
78
- components: Nt
79
- }
80
- ],
81
- stateMutability: "nonpayable",
82
- type: "function"
83
- },
84
- {
85
- inputs: [],
86
- name: "dytmWithdrawProcessor",
87
- outputs: [{ name: "", type: "address" }],
88
- stateMutability: "view",
89
- type: "function"
90
- }
91
- ], F = [
92
- {
93
- inputs: [
94
- {
95
- name: "params",
96
- type: "tuple",
97
- components: [
98
- { name: "account", type: "uint256" },
99
- { name: "tokenId", type: "uint256" },
100
- { name: "receiver", type: "address" },
101
- { name: "assets", type: "uint256" },
102
- { name: "shares", type: "uint256" },
103
- { name: "extraData", type: "bytes" }
104
- ]
105
- }
106
- ],
107
- name: "withdraw",
108
- outputs: [{ name: "assets", type: "uint256" }],
109
- stateMutability: "nonpayable",
110
- type: "function"
111
- },
112
- {
113
- inputs: [
114
- {
115
- name: "params",
116
- type: "tuple",
117
- components: [
118
- { name: "account", type: "uint256" },
119
- { name: "key", type: "uint248" },
120
- // DytmParamStructs.TokenType enum — 0 = NONE.
121
- { name: "withCollateralType", type: "uint8" },
122
- { name: "assets", type: "uint256" },
123
- { name: "shares", type: "uint256" },
124
- { name: "extraData", type: "bytes" }
125
- ]
126
- }
127
- ],
128
- name: "repay",
129
- outputs: [{ name: "assetsRepaid", type: "uint256" }],
130
- stateMutability: "nonpayable",
131
- type: "function"
132
- }
133
- ], Ot = [
134
- {
135
- inputs: [
136
- { name: "tokenIn", type: "address" },
137
- { name: "amountIn", type: "uint256" },
138
- { name: "tokenOut", type: "address" },
139
- { name: "amountOutMinimum", type: "uint256" },
140
- { name: "attestationSignature", type: "bytes" },
141
- {
142
- name: "quote",
143
- type: "tuple",
144
- components: [
145
- { name: "chainId", type: "uint256" },
146
- { name: "attestationId", type: "uint256" },
147
- { name: "userId", type: "bytes32" },
148
- { name: "asset", type: "address" },
149
- { name: "price", type: "uint256" },
150
- { name: "quantity", type: "uint256" },
151
- { name: "expiration", type: "uint256" },
152
- { name: "side", type: "uint8" },
153
- { name: "additionalData", type: "bytes32" }
154
- ]
155
- }
156
- ],
157
- name: "swapExactInWithAttestation",
158
- outputs: [],
159
- stateMutability: "nonpayable",
160
- type: "function"
161
- }
162
- ], Rt = [
163
- {
164
- type: "tuple",
165
- components: [
166
- {
167
- name: "actions",
168
- type: "tuple[]",
169
- components: [
170
- { name: "to", type: "address" },
171
- { name: "data", type: "bytes" }
172
- ]
173
- },
174
- { name: "outputAsset", type: "address" },
175
- { name: "minOutputAmount", type: "uint256" }
176
- ]
177
- }
178
- ], Ct = () => typeof window < "u";
179
- function Mt() {
180
- return Ct() && typeof window.ethereum < "u";
181
- }
182
- async function ie(t) {
183
- try {
184
- if (Mt())
185
- return window.ethereum.request({
186
- method: "wallet_watchAsset",
187
- params: {
188
- type: "ERC20",
189
- options: t
190
- }
191
- });
192
- } catch {
193
- return !1;
194
- }
195
- return !1;
196
- }
197
- const m = (t, e) => t?.toLowerCase() === e?.toLowerCase(), ue = (t) => m(t, V), T = (t) => {
198
- if (!t) throw new Error("Cannot prefix an empty hex value");
199
- return t.startsWith("0x") ? t : `0x${t}`;
200
- }, p = (t, e) => {
201
- try {
202
- return BigInt(t);
203
- } catch {
204
- throw new Error(`Cannot convert "${e}" value "${t}" to bigint`);
205
- }
206
- }, h = (t) => t ? ht(T(t), { size: 32 }) : Et, Bt = (t) => {
207
- if (!t) throw new Error("Cannot decode an empty base64 string");
208
- return bt(Uint8Array.from(atob(t), (e) => e.charCodeAt(0)));
209
- }, Lt = (t, e) => H[e]?.[t] ?? _, ce = (t) => K[t], de = (t) => t && `${t.substring(0, 6)}...${t.substring(
210
- t.length - 4,
211
- t.length
212
- )}`, pe = ({
213
- address: t,
214
- chainId: e
215
- }) => {
216
- const a = Lt(
217
- "aaveLendingPoolV3",
218
- e
219
- );
220
- return m(t, a);
221
- }, xt = ({
222
- sourceAddress: t,
223
- amount: e
224
- }) => `${t}_${e}`, me = (t, e) => {
225
- const a = t.slice(0, e), n = t.slice(e);
226
- return { firstPart: a, secondPart: n };
227
- }, Pt = (t, e) => t / e * 100, le = (t) => t < 1 ? 4 : t < 10 ? 3 : 2, ye = (t, e = w) => new c(t.toString()).shiftedBy(e).toFixed(0), Ae = (t, e, a, n) => new c(e).dividedBy(a).multipliedBy(t).shiftedBy(-(n || w)).toNumber(), Te = (t) => BigInt(
228
- new c(t || "0").shiftedBy(w).toFixed(0, c.ROUND_DOWN)
229
- ), Ut = (t) => {
230
- const e = new c(0.01), a = new c(t), n = !a.isZero() && a.lt(e) ? e : a;
231
- return BigInt(n.multipliedBy(100).toFixed(0));
232
- }, ge = ({
233
- vaultAddress: t,
234
- swapData: e,
235
- sendTokenAddress: a,
236
- sendTokenAmount: n,
237
- vaultDepositTokenAddress: s,
238
- minVaultTokensReceivedAmount: o,
239
- routerKey: r = "ONE_INCH",
240
- swapDestinationAmount: u,
241
- swapSlippage: i
242
- }) => {
243
- const d = new c(u).multipliedBy(1 - i / 100).toFixed(0), l = [E(r, { size: 32 }), e];
244
- return [t, [[a, n, l], [s, d]], o];
245
- }, De = ({
246
- receiveAssetAddress: t,
247
- assets: e,
248
- swapData: a,
249
- slippage: n
250
- }) => {
251
- const s = {
252
- srcData: [],
253
- destAmount: new c("0")
254
- }, { srcData: o, destAmount: r } = e?.reduce((u, i) => {
255
- const d = a?.[i.address];
256
- if (!d)
257
- return u;
258
- const l = [
259
- E(d.routerKey, { size: 32 }),
260
- d.rawTransaction.data
261
- ], y = [i.address, i.rawBalance, l];
262
- return {
263
- srcData: [...u.srcData, y],
264
- destAmount: u.destAmount.plus(d.destinationAmount)
265
- };
266
- }, s) ?? s;
267
- return [
268
- o,
269
- [
270
- t,
271
- r.times(1 - n / 100).toFixed(0, c.ROUND_DOWN)
272
- ]
273
- ];
274
- }, Ft = ({
275
- assetAddress: t,
276
- swapQuotes: e,
277
- swapParams: a,
278
- slippageToleranceForContractTransaction: n,
279
- routerKey: s
280
- }) => {
281
- if (!a)
282
- return {
283
- supportedAsset: t,
284
- withdrawData: "",
285
- slippageTolerance: BigInt(0)
286
- };
287
- const { srcData: o, dstData: r } = a, u = o.map(({ asset: l, amount: y }) => {
288
- const D = e?.[xt({
289
- sourceAddress: l,
290
- amount: y.toString()
291
- })]?.find((W) => W.routerKey === s);
292
- return {
293
- asset: l,
294
- amount: y,
295
- swapData: {
296
- routerKey: E(D?.routerKey ?? "", { size: 32 }),
297
- txData: D?.rawTransaction.data ?? "0x"
298
- }
299
- };
300
- }), i = g(
301
- z,
302
- [u]
303
- ), d = g(Q, [
304
- {
305
- encodedSrcData: i,
306
- dstData: {
307
- dstAddress: r.asset,
308
- dstAmount: r.amount
309
- },
310
- slippage: n
311
- }
312
- ]);
313
- return {
314
- supportedAsset: t,
315
- withdrawData: d,
316
- slippageTolerance: n
317
- };
318
- }, Se = ({
319
- chainId: t,
320
- txHash: e,
321
- error: a
322
- }) => {
323
- if (t !== f.id || !e || !a)
324
- return !1;
325
- const n = a instanceof Error ? a.message : String(a);
326
- return /\bNo Result\b/i.test(n);
327
- }, fe = ({
328
- chainId: t,
329
- action: e,
330
- isRabbyWallet: a
331
- }) => e === "update_ondo_prices" && t === f.id && a ? Z : t ? j[t] ?? 0 : 0, _e = (t, e) => J[e]?.nativeTokenSymbol === t, we = ({
332
- nativeTokenBalance: t,
333
- tokenDecimals: e,
334
- gasPrice: a
335
- }) => {
336
- const n = new c(a).multipliedBy(X).shiftedBy(-e), s = new c(t).minus(
337
- n
338
- );
339
- return s.gt("0") ? s : new c("0");
340
- }, Ee = (t) => tt.includes(t), be = (t) => {
341
- const e = Object.values(t).reduce(
342
- (a, { type: n }) => (a[n] = a[n] + 1, a),
343
- { string: 0, number: 0 }
344
- );
345
- if (e.string > 10)
346
- throw new Error("logger params must contain up to 10 string values");
347
- if (e.number > 40)
348
- throw new Error("logger params must contain up to 40 numeric values");
349
- return !0;
350
- }, vt = (t, e = 150) => t.length > e ? t.substring(0, e) : t, I = (t, e = et) => {
351
- const a = t.toLowerCase();
352
- return e.sort((n, s) => s.length - n.length).find((n) => a.includes(n.toLowerCase()));
353
- }, N = (t) => at[t] ?? nt[t], he = ({
354
- errorMessage: t,
355
- abiErrors: e
356
- }) => {
357
- if (!t || t.includes("User rejected"))
358
- return null;
359
- const a = e.find((o) => t.includes(o));
360
- if (a && I(a))
361
- return N(a);
362
- const n = I(t);
363
- if (n)
364
- return N(n);
365
- const [s] = t.split(a ? "." : "Contract").map((o) => o.trim());
366
- return {
367
- title: "Transaction failed",
368
- hint: `${vt(s ?? "")} ${a ? `: ${a}` : ""}`
369
- };
370
- }, Ie = (t) => typeof t == "number" && Number.isFinite(t), Ne = (t) => typeof t == "bigint" && t !== BigInt(0), Wt = (t, e = x) => new c(t).shiftedBy(-e).toNumber(), $t = (t) => !isNaN(parseFloat(t)) && !isNaN(t), Yt = ({
371
- value: t,
372
- minimumFractionDigits: e = 2,
373
- maximumFractionDigits: a = 2,
374
- compact: n = !1,
375
- normalize: s = !1
376
- }) => new Intl.NumberFormat("en-US", {
377
- style: "currency",
378
- currency: "USD",
379
- notation: n ? "compact" : void 0,
380
- minimumFractionDigits: e,
381
- maximumFractionDigits: a
382
- }).format(s ? Wt(t) : Number(t)), O = (t) => $t(t) ? new c(t).toFixed() : "", R = ["₀", "₁", "₂", "₃", "₄", "₅", "₆", "₇", "₈", "₉"], kt = ({
383
- value: t,
384
- decimals: e = 4
385
- }) => {
386
- const a = new c(t);
387
- if (a.isGreaterThan(1) || a.isZero())
388
- return O(a.toFixed(e));
389
- const s = (/e/i.test(t.toString()) ? parseFloat(t.toString()).toFixed(x) : t.toString()).match(/^0\.(0+)(\d+)$/);
390
- if (s) {
391
- const [, o, r] = s;
392
- if (o.length >= e && o.length < R.length)
393
- return `0.0${R[o.length]}${r.slice(0, 3)}`;
394
- }
395
- return O(a.toFixed(e));
396
- }, qt = (t, e = 0) => `${t.toLocaleString("en-US", { maximumFractionDigits: e })}%`, Oe = (t) => t.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), Re = (t, e, a = 0) => {
397
- const n = Pt(+t, e);
398
- return qt(n, a);
399
- }, Ce = ({
400
- currency: t,
401
- value: e
402
- }) => t === "USD" ? Yt({ value: e }) : `${st[t]} ${kt({
403
- value: e,
404
- decimals: ot[t]
405
- })}`, Gt = (t, e) => new c(
406
- new c(t).toFixed(e, c.ROUND_DOWN)
407
- ).toString(), Vt = (t, e = 3, a = 2) => {
408
- if (t.length <= 5)
409
- return t;
410
- const n = "...";
411
- return t.length <= e + a + n.length ? t : `${t.slice(0, e)}${n}${t.slice(-a)}`;
412
- }, Me = ({
413
- balance: t,
414
- symbol: e,
415
- precision: a,
416
- truncateSymbol: n
417
- }) => `${Gt(t, a)} ${n ? Vt(e) : e}`, Be = (t) => {
418
- if (!t)
419
- return;
420
- const e = t.match(/0x[a-fA-F0-9]{64}/);
421
- if (!e)
422
- return;
423
- const a = e[0];
424
- return `${a.slice(0, 4)}...${a.slice(-3)}`;
425
- }, Le = (t) => m(ct, t) || m(dt, t), xe = (t) => mt.some(
426
- (e) => m(e, t)
427
- ), Pe = (t) => rt[t.toLowerCase()] ?? {
428
- symbol: "",
429
- decimals: 18,
430
- address: _
431
- }, Ue = (t) => m(t, pt) ? it : ut, Kt = (t) => `eth_${t}`, Fe = ({
432
- action: t,
433
- log: e,
434
- symbol: a,
435
- vaultAddress: n,
436
- chainId: s
437
- }) => {
438
- const o = {
439
- [S.SYMBOL.NAME]: a,
440
- [S.CHAIN_ID.NAME]: s,
441
- [S.ADDRESS.NAME]: Kt(n)
442
- };
443
- lt[t].forEach((r) => {
444
- e?.(r, o);
445
- });
446
- }, ve = (t) => Tt.some((e) => m(e, t)), We = (t) => yt[t.toLowerCase()] ?? {
447
- symbol: "",
448
- decimals: 18,
449
- address: _
450
- }, $e = (t) => At[t.toLowerCase()], Ht = "0x3333333333333333333333333333333333333333";
451
- G.id + "", _t.address, q.id + "", ft.address, k.id + "", St.address, Y.id + "", Dt.address, f.id + "", gt.address, $.id + "", P.address;
452
- const Ye = (t) => m(t, Ht), ke = () => P, qe = /* @__PURE__ */ new Map(), v = (t, e) => !e || e.size === 0 ? t : t.map((a) => {
453
- const n = e.get(
454
- a.supportedAsset.toLowerCase()
455
- );
456
- return n ? {
457
- ...a,
458
- withdrawData: n.withdrawData,
459
- slippageTolerance: n.slippageTolerance
460
- } : a;
461
- }), zt = (t) => {
462
- const e = t.find(
463
- ({ swapQuotes: a }) => a
464
- );
465
- return e?.swapQuotes ? Object.values(e.swapQuotes)[0]?.map(
466
- ({ routerKey: a }) => a
467
- ) ?? [] : [];
468
- }, Qt = (t, e, a) => t.map(({ asset: n, swapParams: s, swapQuotes: o }) => !s || !o ? {
469
- supportedAsset: n,
470
- withdrawData: "",
471
- slippageTolerance: a
472
- } : Ft({
473
- assetAddress: n,
474
- swapQuotes: o,
475
- swapParams: s,
476
- slippageToleranceForContractTransaction: a,
477
- routerKey: e
478
- })), Zt = async (t, e, a, n, s, o) => {
479
- for (const r of t) {
480
- const u = v(
481
- Qt(
482
- e,
483
- r,
484
- a
485
- ),
486
- o
487
- ), { error: i } = await n(...s, u);
488
- if (!i)
489
- return u;
490
- }
491
- return null;
492
- }, Ge = (t, e, a) => {
493
- const n = (t ?? []).map((s) => ({
494
- supportedAsset: s,
495
- withdrawData: "",
496
- slippageTolerance: e
497
- }));
498
- return v(n, a);
499
- }, Ve = async (t, e, a, n, s) => {
500
- for (const o of t) {
501
- const r = Ut(o);
502
- try {
503
- const u = await e(o), i = zt(
504
- u
505
- ), d = await Zt(
506
- i,
507
- u,
508
- r,
509
- a,
510
- n,
511
- s
512
- );
513
- if (d)
514
- return console.debug(
515
- `[Init Withdraw] Auto slippage simulation succeeded: slippage=${o}%`
516
- ), console.debug("[Init Withdraw] Complex asset data:", d), d;
517
- } catch (u) {
518
- console.error(
519
- `[Init Withdraw] Failed to fetch quotes for slippage=${o}%:`,
520
- u
521
- );
522
- }
523
- }
524
- return null;
525
- }, Ke = async (t, e, {
526
- fetchAaveSwapParams: a,
527
- fetchAaveSwapQuotes: n,
528
- withdrawAmountD18: s,
529
- slippage: o
530
- }) => Promise.all(
531
- (t ?? []).map(async (r) => {
532
- if (!m(r, e))
533
- return { asset: r };
534
- try {
535
- const i = await a({
536
- withdrawAmountD18: s,
537
- slippage: o
538
- });
539
- if (i?.srcData.length) {
540
- const d = await n({
541
- swapParams: i,
542
- slippage: o
543
- });
544
- return { asset: r, swapParams: i, swapQuotes: d };
545
- }
546
- return { asset: r };
547
- } catch (i) {
548
- return console.error(i), { asset: r };
549
- }
550
- })
551
- ), C = (t) => Math.round(t * 100) / 100, He = ({
552
- maxSlippage: t,
553
- candidates: e = wt
554
- }) => {
555
- if (!Number.isFinite(t) || t <= 0)
556
- return [];
557
- const a = C(Math.min(t, 100)), n = e.filter((o) => o > 0 && o <= a).map(C), s = new Set(n);
558
- return s.add(a), s.add(t), Array.from(s).sort((o, r) => o - r);
559
- }, M = 1000000000000000000n, jt = 1000000n, B = 10000n, L = 100n, ze = (t) => ({
560
- quotes: t.quotes.map(
561
- (e) => ({
562
- chainId: p(e.chainId, "chainId"),
563
- attestationId: p(e.attestationId, "attestationId"),
564
- userId: T(e.userId),
565
- asset: e.asset,
566
- price: p(e.price, "price"),
567
- quantity: p(e.quantity, "quantity"),
568
- expiration: p(e.expiration, "expiration"),
569
- side: Number(e.side),
570
- additionalData: T(e.additionalData)
571
- })
572
- ),
573
- signatures: t.signatures.map(T)
574
- }), Xt = (t, e, a) => {
575
- const n = BigInt(Math.max(0, Math.round(a * 100))), s = n > L ? L : n, o = B - s, u = t * e / M * o * jt, i = B * M;
576
- return (u + i - 1n) / i;
577
- }, Jt = (t, e) => ({
578
- chainId: e,
579
- attestationId: p(t.attestationId, "attestationId"),
580
- userId: h(t.userId),
581
- asset: t.assetAddress,
582
- price: p(t.price, "price"),
583
- quantity: p(t.tokenAmount, "tokenAmount"),
584
- expiration: p(t.expiration, "expiration"),
585
- side: Number(t.side),
586
- additionalData: h(t.additionalData)
587
- }), Qe = ({
588
- attestation: t,
589
- chainId: e,
590
- slippagePercent: a
591
- }) => {
592
- const n = Jt(t, e);
593
- return g(It, [
594
- {
595
- attestationSignature: Bt(t.signature),
596
- quote: n,
597
- amountOutMinimum: Xt(
598
- n.quantity,
599
- n.price,
600
- a
601
- )
602
- }
603
- ]);
604
- }, Ze = (t) => [...t.reduce(
605
- (a, n) => a.has(n.accountId) ? a : a.set(n.accountId, n),
606
- /* @__PURE__ */ new Map()
607
- ).values()].map(({ accountId: a, marketId: n }) => ({
608
- accountId: a,
609
- marketId: n,
610
- collaterals: t.filter(
611
- (s) => s.accountId === a && !s.isDebt
612
- ),
613
- debt: t.find(
614
- (s) => s.accountId === a && s.isDebt
615
- )
616
- })), je = ({
617
- collateral: t,
618
- dytmOffice: e,
619
- processor: a,
620
- gmToken: n,
621
- ondoGMSwap: s,
622
- usdc: o,
623
- gmAmount: r,
624
- amountOutMinimum: u,
625
- signature: i,
626
- quote: d
627
- }) => [
628
- {
629
- // 1 · pull GM collateral out of the split account -> processor
630
- to: e,
631
- data: A({
632
- abi: F,
633
- functionName: "withdraw",
634
- args: [
635
- {
636
- account: t.accountId,
637
- tokenId: t.tokenId,
638
- receiver: a,
639
- assets: r,
640
- shares: 0n,
641
- extraData: "0x"
642
- }
643
- ]
644
- })
645
- },
646
- {
647
- // 2 · approve the GM token to Ondo's swap contract
648
- to: n,
649
- data: A({
650
- abi: U,
651
- functionName: "approve",
652
- args: [s, r]
653
- })
654
- },
655
- {
656
- // 3 · redeem GM -> USDC with the signed attestation
657
- to: s,
658
- data: A({
659
- abi: Ot,
660
- functionName: "swapExactInWithAttestation",
661
- args: [n, r, o, u, i, d]
662
- })
663
- }
664
- ], Xe = ({
665
- accountId: t,
666
- debtKey: e,
667
- dytmOffice: a,
668
- usdc: n
669
- }) => [
670
- {
671
- // approve USDC to the DYTM Office for the repay
672
- to: n,
673
- data: A({
674
- abi: U,
675
- functionName: "approve",
676
- args: [a, b]
677
- })
678
- },
679
- {
680
- // repay the slice's whole USDC debt
681
- to: a,
682
- data: A({
683
- abi: F,
684
- functionName: "repay",
685
- args: [
686
- {
687
- account: t,
688
- key: e,
689
- withCollateralType: 0,
690
- // DytmParamStructs.TokenType.NONE
691
- assets: b,
692
- // repay all
693
- shares: 0n,
694
- extraData: "0x"
695
- }
696
- ]
697
- })
698
- }
699
- ], Je = ({
700
- actions: t,
701
- outputAsset: e,
702
- minOutputAmount: a
703
- }) => g(Rt, [
704
- { actions: t, outputAsset: e, minOutputAmount: a }
705
- ]);
706
- export {
707
- Se as $,
708
- Ue as A,
709
- We as B,
710
- $e as C,
711
- ke as D,
712
- qe as E,
713
- we as F,
714
- Pt as G,
715
- Ae as H,
716
- fe as I,
717
- Ut as J,
718
- Be as K,
719
- Ze as L,
720
- pe as M,
721
- xe as N,
722
- Le as O,
723
- ve as P,
724
- Ye as Q,
725
- _e as R,
726
- Ee as S,
727
- Fe as T,
728
- Jt as U,
729
- ze as V,
730
- v as W,
731
- Te as X,
732
- he as Y,
733
- ye as Z,
734
- de as _,
735
- Ft as a,
736
- me as a0,
737
- p as a1,
738
- h as a2,
739
- Kt as a3,
740
- Vt as a4,
741
- Zt as a5,
742
- Ve as a6,
743
- be as a7,
744
- ue as a8,
745
- Ie as a9,
746
- m as aa,
747
- Yt as ab,
748
- Ne as ac,
749
- Wt as ad,
750
- re as ae,
751
- oe as af,
752
- Ht as ag,
753
- kt as ah,
754
- ie as ai,
755
- qt as aj,
756
- $t as ak,
757
- Oe as al,
758
- O as am,
759
- Bt as b,
760
- Qt as c,
761
- je as d,
762
- Xe as e,
763
- xt as f,
764
- De as g,
765
- ge as h,
766
- se as i,
767
- Xt as j,
768
- Ge as k,
769
- Qe as l,
770
- Je as m,
771
- Ke as n,
772
- T as o,
773
- zt as p,
774
- Gt as q,
775
- Ce as r,
776
- Re as s,
777
- Me as t,
778
- He as u,
779
- ce as v,
780
- Lt as w,
781
- le as x,
782
- I as y,
783
- Pe as z
784
- };