@masterpeach/plugin-react 0.0.0-experimental-20260625203238
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/README.md +156 -0
- package/dist/ConfirmModal-BDOS4CPh.js +2852 -0
- package/dist/D3SankeyCharts-D89ah1De.js +1288 -0
- package/dist/index-B67iXHsu.js +37450 -0
- package/dist/index.d.ts +215 -0
- package/dist/index.js +4 -0
- package/dist/plugin-react.css +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,2852 @@
|
|
|
1
|
+
var Kn = Object.defineProperty;
|
|
2
|
+
var qn = (e, t, n) => t in e ? Kn(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var st = (e, t, n) => qn(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { jsxs as p, jsx as i, Fragment as Ue } from "react/jsx-runtime";
|
|
5
|
+
import { useMemo as G, useState as R, useTransition as gt, useCallback as ue, createElement as Jn, useEffect as Ae, useLayoutEffect as Zn } from "react";
|
|
6
|
+
import "react-dom";
|
|
7
|
+
import { c as Dn, C as er, $ as tr, D as nr, t as E, f as me, N as Ee, u as ht, T as vn, p as rr, a as j, r as ct, b as M, B as vt, E as ir, L as or, M as sr, U as ar, d as lt, g as wn, e as Oe, h as cr, i as lr, j as xn, k as wt, I as ut, l as mt, S as ur, m as mr, n as he, o as dr, q as bn, s as fr, v as pr, w as gr, H as hr, x as dt, y as Ce, z as Sn, A as vr, P as wr, F as xr, G as Zt, J as br, K as Sr, O as Tr, Q as Nr, R as ke, V as Ar, W as Pr, X as Ir, Y as _r, Z as Er, _ as Cr, a0 as yr, a1 as Br, a2 as Rr, a3 as Dt, a4 as Lr, a5 as en, a6 as Mr, a7 as kr, a8 as Or, a9 as Ur, aa as Fr, ab as $r, ac as Wr, ad as Hr, ae as jr, af as Vr, ag as Qr, ah as zr } from "./index-B67iXHsu.js";
|
|
8
|
+
import { formatUnits as et, erc20Abi as Tn, parseEventLogs as Xr, parseUnits as Je } from "viem";
|
|
9
|
+
import { useQuery as Yr, useQueryClient as Gr } from "@tanstack/react-query";
|
|
10
|
+
import { useConnection as tt, useReadContract as Nn, useChainId as Kr, usePublicClient as An, useWalletClient as Pn, useWriteContract as qr, useSendTransaction as Jr, useSendCallsSync as Zr } from "wagmi";
|
|
11
|
+
/**
|
|
12
|
+
* @license lucide-react v0.577.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/
|
|
17
|
+
const Dr = [
|
|
18
|
+
["path", { d: "M5 12h14", key: "1ays0h" }],
|
|
19
|
+
["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
|
|
20
|
+
], ei = Dn("arrow-right", Dr), ti = new Intl.DateTimeFormat("en-US", {
|
|
21
|
+
timeZone: "UTC",
|
|
22
|
+
month: "short",
|
|
23
|
+
day: "numeric",
|
|
24
|
+
year: "numeric",
|
|
25
|
+
hour: "2-digit",
|
|
26
|
+
minute: "2-digit",
|
|
27
|
+
hourCycle: "h23"
|
|
28
|
+
}), In = (e) => Number.isNaN(e.getTime()) ? "-" : ti.format(e), ni = (e) => {
|
|
29
|
+
const t = In(e);
|
|
30
|
+
return t === "-" ? t : `${t} (UTC)`;
|
|
31
|
+
}, ri = (e, t = Date.now()) => {
|
|
32
|
+
if (!e) return null;
|
|
33
|
+
const n = Math.max(0, Math.ceil((e * 1e3 - t) / 6e4));
|
|
34
|
+
if (n <= 0) return "expired";
|
|
35
|
+
const o = [
|
|
36
|
+
{ label: "year", minutes: 365 * 24 * 60 },
|
|
37
|
+
{ label: "month", minutes: 720 * 60 },
|
|
38
|
+
{ label: "day", minutes: 1440 },
|
|
39
|
+
{ label: "hour", minutes: 60 },
|
|
40
|
+
{ label: "min", minutes: 1 }
|
|
41
|
+
], c = o.find((d) => n >= d.minutes) ?? o.at(-1);
|
|
42
|
+
if (!c) return null;
|
|
43
|
+
const m = Math.ceil(n / c.minutes), l = m === 1 || c.label === "min" ? c.label : `${c.label}s`;
|
|
44
|
+
return `in ${m} ${l}`;
|
|
45
|
+
}, ii = (e, { includeRelative: t = !0, includeUtcSuffix: n = !0, now: o = Date.now() } = {}) => {
|
|
46
|
+
if (!e) return "-";
|
|
47
|
+
const c = n ? ni(new Date(e * 1e3)) : In(new Date(e * 1e3));
|
|
48
|
+
if (!t) return c;
|
|
49
|
+
const m = ri(e, o);
|
|
50
|
+
return m ? `${c} (${m})` : c;
|
|
51
|
+
}, oi = 25e3;
|
|
52
|
+
function qe(e) {
|
|
53
|
+
return {
|
|
54
|
+
to: e.to,
|
|
55
|
+
data: e.data,
|
|
56
|
+
value: e.value,
|
|
57
|
+
...e.gasPrice ? { gasPrice: e.gasPrice } : {},
|
|
58
|
+
...e.gasLimit ? { gas: e.gasLimit } : {}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function tn(e, t) {
|
|
62
|
+
var o, c, m, l, d, h, v, w, S, b, f;
|
|
63
|
+
if (t) return t;
|
|
64
|
+
const n = e;
|
|
65
|
+
return ((o = n == null ? void 0 : n.receipt) == null ? void 0 : o.hash) || ((c = n == null ? void 0 : n.receipt) == null ? void 0 : c.transactionHash) || (n == null ? void 0 : n.transactionHash) || (n == null ? void 0 : n.hash) || ((m = n == null ? void 0 : n.transaction) == null ? void 0 : m.hash) || ((d = (l = n == null ? void 0 : n.cause) == null ? void 0 : l.receipt) == null ? void 0 : d.hash) || ((v = (h = n == null ? void 0 : n.cause) == null ? void 0 : h.receipt) == null ? void 0 : v.transactionHash) || ((w = n == null ? void 0 : n.cause) == null ? void 0 : w.transactionHash) || ((S = n == null ? void 0 : n.cause) == null ? void 0 : S.hash) || ((f = (b = n == null ? void 0 : n.cause) == null ? void 0 : b.transaction) == null ? void 0 : f.hash);
|
|
66
|
+
}
|
|
67
|
+
function si(e) {
|
|
68
|
+
var t;
|
|
69
|
+
return ((t = e.receipts) == null ? void 0 : t.map((n) => n.transactionHash).filter((n) => !!n && n.startsWith("0x"))) ?? [];
|
|
70
|
+
}
|
|
71
|
+
function nn(e, t) {
|
|
72
|
+
if (e.status === "success")
|
|
73
|
+
return e;
|
|
74
|
+
const n = e.transactionHash || t, o = e.status === "reverted" ? "Transaction reverted on-chain." : "Transaction failed on-chain.", c = new Error(o);
|
|
75
|
+
throw c.txHash = n, c.transactionHash = n, c.receipt = e, c;
|
|
76
|
+
}
|
|
77
|
+
async function ai(e, t, n = oi) {
|
|
78
|
+
const o = e.waitForTransactionReceipt({ hash: t });
|
|
79
|
+
let c;
|
|
80
|
+
try {
|
|
81
|
+
return await Promise.race([
|
|
82
|
+
o,
|
|
83
|
+
new Promise((m, l) => {
|
|
84
|
+
c = setTimeout(async () => {
|
|
85
|
+
const [d, h] = await Promise.allSettled([
|
|
86
|
+
e.getTransactionReceipt({ hash: t }),
|
|
87
|
+
e.getTransaction({ hash: t })
|
|
88
|
+
]);
|
|
89
|
+
if (d.status === "fulfilled") {
|
|
90
|
+
m(d.value);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (h.status === "fulfilled") {
|
|
94
|
+
const w = new Error(
|
|
95
|
+
"Transaction pending - network may be busy or gas price too low. "
|
|
96
|
+
);
|
|
97
|
+
w.txHash = t, l(w);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const v = new Error("Transaction not found on-chain.");
|
|
101
|
+
v.txHash = t, l(v);
|
|
102
|
+
}, n);
|
|
103
|
+
})
|
|
104
|
+
]);
|
|
105
|
+
} finally {
|
|
106
|
+
c && clearTimeout(c);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const Me = 56, xt = "0xff0560b1bb0b666bd0df576d7d486c606081b80a", Ze = er, ci = nr, li = 0, _n = 1e4, En = 1, ui = tr, bt = 10080 * 60, mi = bt, Cn = 1440 * 60, yn = 10 * 365 * 24 * 60 * 60;
|
|
110
|
+
class St extends Error {
|
|
111
|
+
constructor(n, o) {
|
|
112
|
+
super(o.error || o.code || `Intent API request failed with status ${n}`);
|
|
113
|
+
st(this, "status");
|
|
114
|
+
st(this, "body");
|
|
115
|
+
this.name = "IntentApiError", this.status = n, this.body = o;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function Bn(e) {
|
|
119
|
+
return ((e == null ? void 0 : e.trim()) || ci).replace(/\/$/, "");
|
|
120
|
+
}
|
|
121
|
+
async function Rn(e) {
|
|
122
|
+
const t = await e.text().catch(() => ""), n = t ? (() => {
|
|
123
|
+
try {
|
|
124
|
+
return JSON.parse(t);
|
|
125
|
+
} catch {
|
|
126
|
+
return { error: t };
|
|
127
|
+
}
|
|
128
|
+
})() : {};
|
|
129
|
+
if (!e.ok)
|
|
130
|
+
throw new St(e.status, n);
|
|
131
|
+
return n;
|
|
132
|
+
}
|
|
133
|
+
function di(e) {
|
|
134
|
+
if (e instanceof St)
|
|
135
|
+
switch (e.body.code) {
|
|
136
|
+
case "insufficient_balance":
|
|
137
|
+
return "Insufficient available balance due to open orders.";
|
|
138
|
+
case "insufficient_allowance":
|
|
139
|
+
case "insufficient_permit2_token_allowance":
|
|
140
|
+
case "insufficient_permit2_allowance":
|
|
141
|
+
return "Token allowance is insufficient. Please approve again.";
|
|
142
|
+
case "invalid_signature":
|
|
143
|
+
return "Signature verification failed. Please sign the order again.";
|
|
144
|
+
case "intent_expired":
|
|
145
|
+
return "This order has expired. Please create a new order.";
|
|
146
|
+
case "invalid_time_range":
|
|
147
|
+
return "Invalid expiry time. Please choose a later expiry.";
|
|
148
|
+
case "invalid_start_time":
|
|
149
|
+
return "Invalid order start time. Please try again.";
|
|
150
|
+
case "invalid_duration":
|
|
151
|
+
return "Invalid order duration. Please choose a valid expiry.";
|
|
152
|
+
case "invalid_max_executions":
|
|
153
|
+
return "Invalid order execution setting. Please try again.";
|
|
154
|
+
case "invalid_min_fill_bps":
|
|
155
|
+
return "Invalid minimum fill setting. Please try again.";
|
|
156
|
+
case "policy_blocked":
|
|
157
|
+
return "This token is blocked by risk policy.";
|
|
158
|
+
case "balance_check_failed":
|
|
159
|
+
case "allowance_check_failed":
|
|
160
|
+
case "permit2_token_allowance_check_failed":
|
|
161
|
+
case "permit2_allowance_check_failed":
|
|
162
|
+
return "Unable to verify balance or allowance. Please try again later.";
|
|
163
|
+
case "permit2_signature_not_accepted":
|
|
164
|
+
return "Permit2 signature is not accepted. Please approve on-chain first.";
|
|
165
|
+
case "token_preflight_unavailable":
|
|
166
|
+
return "Token balance checks are temporarily unavailable. Please try again later.";
|
|
167
|
+
case "unsupported_curve_type":
|
|
168
|
+
return "Unsupported limit order price curve.";
|
|
169
|
+
case "invalid_decimal":
|
|
170
|
+
return "Invalid order amount. Please try again.";
|
|
171
|
+
case "invalid_intent":
|
|
172
|
+
return "Invalid order payload. Please check the order and try again.";
|
|
173
|
+
case "intent_not_editable":
|
|
174
|
+
case "intent_not_replaceable":
|
|
175
|
+
return "This order can no longer be edited.";
|
|
176
|
+
case "invalid_dutch_curve":
|
|
177
|
+
return "Invalid limit order price.";
|
|
178
|
+
case "intent_hash_conflict":
|
|
179
|
+
case "intent_salt_conflict":
|
|
180
|
+
return "This price update conflicts with an existing order. Please try again.";
|
|
181
|
+
case "settlement_contract_required":
|
|
182
|
+
return "Price editing is temporarily unavailable.";
|
|
183
|
+
default:
|
|
184
|
+
return e.body.error || e.body.code || e.message;
|
|
185
|
+
}
|
|
186
|
+
return e instanceof Error ? e.message : "Unknown intent error";
|
|
187
|
+
}
|
|
188
|
+
async function fi(e, t) {
|
|
189
|
+
const n = await fetch(`${Bn(t == null ? void 0 : t.baseUrl)}/intents`, {
|
|
190
|
+
method: "POST",
|
|
191
|
+
headers: { "Content-Type": "application/json" },
|
|
192
|
+
body: JSON.stringify(e),
|
|
193
|
+
signal: t == null ? void 0 : t.signal
|
|
194
|
+
});
|
|
195
|
+
return Rn(n);
|
|
196
|
+
}
|
|
197
|
+
async function pi(e, t) {
|
|
198
|
+
const n = new URLSearchParams({ owner: e.owner, token: e.token }), o = await fetch(
|
|
199
|
+
`${Bn(t == null ? void 0 : t.baseUrl)}/intents/tokens/available-balance?${n}`,
|
|
200
|
+
{
|
|
201
|
+
method: "GET",
|
|
202
|
+
signal: t == null ? void 0 : t.signal
|
|
203
|
+
}
|
|
204
|
+
);
|
|
205
|
+
return Rn(o);
|
|
206
|
+
}
|
|
207
|
+
const gi = {
|
|
208
|
+
name: "PeachIntentSettlement",
|
|
209
|
+
version: "1",
|
|
210
|
+
chainId: Me,
|
|
211
|
+
verifyingContract: xt
|
|
212
|
+
}, hi = {
|
|
213
|
+
Intent: [
|
|
214
|
+
{ name: "owner", type: "address" },
|
|
215
|
+
{ name: "sellToken", type: "address" },
|
|
216
|
+
{ name: "buyToken", type: "address" },
|
|
217
|
+
{ name: "sellAmount", type: "uint256" },
|
|
218
|
+
{ name: "startPrice", type: "uint256" },
|
|
219
|
+
{ name: "floorPrice", type: "uint256" },
|
|
220
|
+
{ name: "startTime", type: "uint256" },
|
|
221
|
+
{ name: "duration", type: "uint256" },
|
|
222
|
+
{ name: "curveType", type: "uint8" },
|
|
223
|
+
{ name: "validFrom", type: "uint256" },
|
|
224
|
+
{ name: "expiry", type: "uint256" },
|
|
225
|
+
{ name: "nonce", type: "uint256" },
|
|
226
|
+
{ name: "salt", type: "bytes32" },
|
|
227
|
+
{ name: "recipient", type: "address" },
|
|
228
|
+
{ name: "maxExecutions", type: "uint256" },
|
|
229
|
+
{ name: "minFillBps", type: "uint256" }
|
|
230
|
+
]
|
|
231
|
+
};
|
|
232
|
+
function vi() {
|
|
233
|
+
const e = new Uint8Array(32);
|
|
234
|
+
if (typeof crypto < "u" && crypto.getRandomValues)
|
|
235
|
+
crypto.getRandomValues(e);
|
|
236
|
+
else
|
|
237
|
+
for (let t = 0; t < e.length; t += 1)
|
|
238
|
+
e[t] = Math.floor(Math.random() * 256);
|
|
239
|
+
return `0x${Array.from(e).map((t) => t.toString(16).padStart(2, "0")).join("")}`;
|
|
240
|
+
}
|
|
241
|
+
function wi() {
|
|
242
|
+
return Date.now().toString();
|
|
243
|
+
}
|
|
244
|
+
function xi() {
|
|
245
|
+
return vi();
|
|
246
|
+
}
|
|
247
|
+
function bi({
|
|
248
|
+
draft: e,
|
|
249
|
+
nonce: t,
|
|
250
|
+
salt: n,
|
|
251
|
+
recipient: o = e.recipient ?? e.owner
|
|
252
|
+
}) {
|
|
253
|
+
return {
|
|
254
|
+
owner: e.owner,
|
|
255
|
+
sellToken: e.intentSellToken,
|
|
256
|
+
buyToken: e.intentBuyToken,
|
|
257
|
+
sellAmount: BigInt(e.sellAmountRaw),
|
|
258
|
+
startPrice: BigInt(e.priceRaw),
|
|
259
|
+
floorPrice: BigInt(e.priceRaw),
|
|
260
|
+
startTime: BigInt(e.startTime),
|
|
261
|
+
duration: BigInt(e.duration),
|
|
262
|
+
curveType: li,
|
|
263
|
+
validFrom: BigInt(e.validFrom),
|
|
264
|
+
expiry: BigInt(e.expiryUnixSeconds),
|
|
265
|
+
nonce: BigInt(t),
|
|
266
|
+
salt: n,
|
|
267
|
+
recipient: o,
|
|
268
|
+
maxExecutions: BigInt(En),
|
|
269
|
+
minFillBps: BigInt(_n)
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
const Si = /(\d+)\s*(days?|hours?|mins?|minutes?|months?)/gi;
|
|
273
|
+
function Ti(e = Date.now()) {
|
|
274
|
+
return Math.floor(e / 1e3);
|
|
275
|
+
}
|
|
276
|
+
function ft(e) {
|
|
277
|
+
var n;
|
|
278
|
+
let t = 0;
|
|
279
|
+
for (const o of e.matchAll(Si)) {
|
|
280
|
+
const c = Number(o[1]), m = (n = o[2]) == null ? void 0 : n.toLowerCase();
|
|
281
|
+
!Number.isFinite(c) || c <= 0 || !m || (m.startsWith("month") ? t += c * 30 * 24 * 60 * 60 : m.startsWith("day") ? t += c * 24 * 60 * 60 : m.startsWith("hour") ? t += c * 60 * 60 : t += c * 60);
|
|
282
|
+
}
|
|
283
|
+
return t;
|
|
284
|
+
}
|
|
285
|
+
function Ni(e, t = Ti()) {
|
|
286
|
+
return {
|
|
287
|
+
...e,
|
|
288
|
+
expiryUnixSeconds: t + e.expirySeconds,
|
|
289
|
+
startTime: t,
|
|
290
|
+
validFrom: t
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
function Ai(e, t) {
|
|
294
|
+
try {
|
|
295
|
+
return et(BigInt(e || "0"), t);
|
|
296
|
+
} catch {
|
|
297
|
+
return "0";
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
function Pi({
|
|
301
|
+
requestedToken: e,
|
|
302
|
+
response: t
|
|
303
|
+
}) {
|
|
304
|
+
return !e || !(t != null && t.token) || t.token.toLowerCase() !== e.toLowerCase() ? "0" : t.reserved_amount ?? "0";
|
|
305
|
+
}
|
|
306
|
+
function Ii(e, t) {
|
|
307
|
+
if (e !== void 0)
|
|
308
|
+
try {
|
|
309
|
+
const n = BigInt(t || "0"), o = e - n;
|
|
310
|
+
return o > 0n ? o : 0n;
|
|
311
|
+
} catch {
|
|
312
|
+
return e;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function at(e, t) {
|
|
316
|
+
if (!e || t === void 0) return !1;
|
|
317
|
+
try {
|
|
318
|
+
return BigInt(e) > t;
|
|
319
|
+
} catch {
|
|
320
|
+
return !1;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
function _i({
|
|
324
|
+
amount: e,
|
|
325
|
+
walletBalance: t,
|
|
326
|
+
availableBalance: n,
|
|
327
|
+
reservedAmount: o
|
|
328
|
+
}) {
|
|
329
|
+
return !at(o, 0n) || at(e, t) ? !1 : at(e, n);
|
|
330
|
+
}
|
|
331
|
+
function pt(e, t) {
|
|
332
|
+
return Ai(e, t);
|
|
333
|
+
}
|
|
334
|
+
function Ln({
|
|
335
|
+
availableAmount: e,
|
|
336
|
+
reservedAmountRaw: t,
|
|
337
|
+
decimals: n,
|
|
338
|
+
symbol: o,
|
|
339
|
+
symbolMaxLength: c = 9
|
|
340
|
+
}) {
|
|
341
|
+
return e === void 0 || t === void 0 ? null : {
|
|
342
|
+
available: me(e, 0, !0, 6),
|
|
343
|
+
inOpenOrders: me(
|
|
344
|
+
pt(t, n),
|
|
345
|
+
0,
|
|
346
|
+
!0,
|
|
347
|
+
6
|
|
348
|
+
),
|
|
349
|
+
symbol: E(o, c)
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
function Ei({
|
|
353
|
+
tokenAddress: e,
|
|
354
|
+
spenderAddress: t,
|
|
355
|
+
enabled: n = !0
|
|
356
|
+
}) {
|
|
357
|
+
const { address: o, isConnected: c } = tt(), m = Number(process.env.NEXT_PUBLIC_CHAIN_ID) || 56, l = (e == null ? void 0 : e.toLowerCase()) === Ee.toLowerCase() || !e, {
|
|
358
|
+
data: d,
|
|
359
|
+
isLoading: h,
|
|
360
|
+
isError: v,
|
|
361
|
+
error: w,
|
|
362
|
+
refetch: S
|
|
363
|
+
} = Nn({
|
|
364
|
+
address: e,
|
|
365
|
+
abi: Tn,
|
|
366
|
+
functionName: "allowance",
|
|
367
|
+
args: o && t ? [o, t] : void 0,
|
|
368
|
+
chainId: m,
|
|
369
|
+
query: {
|
|
370
|
+
enabled: n && c && !!o && !!t && !l
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
return G(
|
|
374
|
+
() => ({
|
|
375
|
+
allowance: l ? BigInt(2) ** BigInt(256) - BigInt(1) : d,
|
|
376
|
+
isLoading: h,
|
|
377
|
+
isError: v,
|
|
378
|
+
error: w,
|
|
379
|
+
refetch: S,
|
|
380
|
+
isApproved: (b) => l ? !0 : d === void 0 ? !1 : d >= b
|
|
381
|
+
}),
|
|
382
|
+
[d, h, v, w, S, l]
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
const Ci = [
|
|
386
|
+
{
|
|
387
|
+
inputs: [
|
|
388
|
+
{ internalType: "address", name: "owner", type: "address" },
|
|
389
|
+
{ internalType: "address", name: "token", type: "address" },
|
|
390
|
+
{ internalType: "address", name: "spender", type: "address" }
|
|
391
|
+
],
|
|
392
|
+
name: "allowance",
|
|
393
|
+
outputs: [
|
|
394
|
+
{ internalType: "uint160", name: "amount", type: "uint160" },
|
|
395
|
+
{ internalType: "uint48", name: "expiration", type: "uint48" },
|
|
396
|
+
{ internalType: "uint48", name: "nonce", type: "uint48" }
|
|
397
|
+
],
|
|
398
|
+
stateMutability: "view",
|
|
399
|
+
type: "function"
|
|
400
|
+
}
|
|
401
|
+
];
|
|
402
|
+
function yi({
|
|
403
|
+
tokenAddress: e,
|
|
404
|
+
spenderAddress: t,
|
|
405
|
+
enabled: n = !0
|
|
406
|
+
}) {
|
|
407
|
+
const { address: o, isConnected: c } = tt(), m = Number(process.env.NEXT_PUBLIC_CHAIN_ID) || 56, l = (e == null ? void 0 : e.toLowerCase()) === Ee.toLowerCase() || !e, { data: d, isLoading: h, isError: v, error: w, refetch: S } = Nn({
|
|
408
|
+
address: Ze,
|
|
409
|
+
abi: Ci,
|
|
410
|
+
functionName: "allowance",
|
|
411
|
+
args: o && e && t ? [o, e, t] : void 0,
|
|
412
|
+
chainId: m,
|
|
413
|
+
query: {
|
|
414
|
+
enabled: n && c && !!o && !!e && !!t && !l
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
return G(() => {
|
|
418
|
+
const b = d == null ? void 0 : d[0], f = d == null ? void 0 : d[1], s = BigInt(Math.floor(Date.now() / 1e3)), A = f !== void 0 && BigInt(f) <= s;
|
|
419
|
+
return {
|
|
420
|
+
allowance: l ? BigInt(2) ** BigInt(256) - BigInt(1) : b,
|
|
421
|
+
expiration: f,
|
|
422
|
+
nonce: d == null ? void 0 : d[2],
|
|
423
|
+
isLoading: h,
|
|
424
|
+
isError: v,
|
|
425
|
+
error: w,
|
|
426
|
+
refetch: S,
|
|
427
|
+
isApproved: (u, C) => l ? !0 : b === void 0 || f === void 0 || A || C !== void 0 && BigInt(f) < BigInt(C) ? !1 : b >= u
|
|
428
|
+
};
|
|
429
|
+
}, [d, w, v, h, l, S]);
|
|
430
|
+
}
|
|
431
|
+
function Bi({
|
|
432
|
+
owner: e,
|
|
433
|
+
token: t,
|
|
434
|
+
enabled: n = !0,
|
|
435
|
+
refetchInterval: o = !1
|
|
436
|
+
}) {
|
|
437
|
+
const { baseUrl: c } = ht(), m = e == null ? void 0 : e.toLowerCase(), l = t == null ? void 0 : t.toLowerCase(), d = (l == null ? void 0 : l.toLowerCase()) === Ee.toLowerCase();
|
|
438
|
+
return Yr({
|
|
439
|
+
queryKey: [vn, m, l, c],
|
|
440
|
+
queryFn: ({ signal: h }) => pi(
|
|
441
|
+
{
|
|
442
|
+
owner: m,
|
|
443
|
+
token: l
|
|
444
|
+
},
|
|
445
|
+
{ baseUrl: c, signal: h }
|
|
446
|
+
),
|
|
447
|
+
enabled: n && !!m && !!l && !d,
|
|
448
|
+
refetchInterval: o,
|
|
449
|
+
staleTime: 1e4
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
function Ri() {
|
|
453
|
+
const [e, t] = R(!1), [n, o] = R(""), [c, m] = R(1), [l, d] = R(!1), [h, v] = R(!1), [w, S] = R(!1), [b, f] = R(!1), [s, A] = R(!1), [u, C] = R(!1), [k, O] = R(!1), [a, _] = gt(), P = ue(() => {
|
|
454
|
+
t(!1), o(""), m(1), d(!1), v(!1), S(!1), f(!1), A(!1), C(!1), O(!1);
|
|
455
|
+
}, []);
|
|
456
|
+
return {
|
|
457
|
+
isPending: e,
|
|
458
|
+
setIsPending: t,
|
|
459
|
+
waitingCompleteTx: n,
|
|
460
|
+
setWaitingCompleteTx: o,
|
|
461
|
+
transactionStep: c,
|
|
462
|
+
setTransactionStep: m,
|
|
463
|
+
needsApproval: l,
|
|
464
|
+
setNeedsApproval: d,
|
|
465
|
+
needsTokenApproval: h,
|
|
466
|
+
setNeedsTokenApproval: v,
|
|
467
|
+
showTokenApprovalStep: w,
|
|
468
|
+
setShowTokenApprovalStep: S,
|
|
469
|
+
needsPermit2Signature: b,
|
|
470
|
+
setNeedsPermit2Signature: f,
|
|
471
|
+
isPreparing: s,
|
|
472
|
+
setIsPreparing: A,
|
|
473
|
+
slippageExceeded: u,
|
|
474
|
+
setSlippageExceeded: C,
|
|
475
|
+
showErrorDetails: k,
|
|
476
|
+
setShowErrorDetails: O,
|
|
477
|
+
isTransitioning: a,
|
|
478
|
+
startTransition: _,
|
|
479
|
+
resetExecutionState: P
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
function rn(e, t) {
|
|
483
|
+
const n = (e == null ? void 0 : e.recommendedFlow) === "token-approval" && !!e.permit2Approval && !!t.sellTokenAddress, o = (e == null ? void 0 : e.recommendedFlow) !== "batch" && !!(e != null && e.typedData) && !!t.sellTokenAddress;
|
|
484
|
+
return {
|
|
485
|
+
needsTokenApproval: n,
|
|
486
|
+
needsPermit2Signature: o,
|
|
487
|
+
showTokenApproval: !!t.sellTokenAddress && (!!t.showTokenApproval || n)
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
function on(e) {
|
|
491
|
+
return e == null ? void 0 : e.recommendedFlow;
|
|
492
|
+
}
|
|
493
|
+
function sn(e) {
|
|
494
|
+
const t = e.showTokenApproval || e.needsTokenApproval, o = Number(t) + Number(e.needsPermit2Signature) + 1;
|
|
495
|
+
return {
|
|
496
|
+
approvalStep: t ? 1 : void 0,
|
|
497
|
+
signatureStep: e.needsPermit2Signature ? t ? 2 : 1 : void 0,
|
|
498
|
+
confirmStep: o,
|
|
499
|
+
submitStep: o + 1
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
async function an(e, t, n) {
|
|
503
|
+
var o;
|
|
504
|
+
await ((o = e == null ? void 0 : e.onPreparedActions) == null ? void 0 : o.call(e, t, n));
|
|
505
|
+
}
|
|
506
|
+
async function Li({
|
|
507
|
+
aggregatorClient: e,
|
|
508
|
+
quote: t,
|
|
509
|
+
ownerAddress: n,
|
|
510
|
+
sellTokenAddress: o,
|
|
511
|
+
buyTokenAddress: c,
|
|
512
|
+
publicClient: m,
|
|
513
|
+
walletClient: l,
|
|
514
|
+
sendTransaction: d,
|
|
515
|
+
sendCallsSync: h,
|
|
516
|
+
getWalletCapabilities: v,
|
|
517
|
+
refetchAllowance: w,
|
|
518
|
+
slippageBps: S,
|
|
519
|
+
overrides: b,
|
|
520
|
+
isNativeInput: f,
|
|
521
|
+
chainId: s,
|
|
522
|
+
mevProtect: A,
|
|
523
|
+
callbacks: u
|
|
524
|
+
}) {
|
|
525
|
+
var U, te, q, fe, de, oe;
|
|
526
|
+
const C = !!(A != null && A.enabled), k = f || C ? void 0 : await (v == null ? void 0 : v()), O = {
|
|
527
|
+
slippageBps: S,
|
|
528
|
+
...b,
|
|
529
|
+
...k ? { walletCapabilities: k } : {},
|
|
530
|
+
...C ? { batchMode: "disabled" } : {}
|
|
531
|
+
};
|
|
532
|
+
let a = f ? void 0 : await e.swapWithPermit2(t, n, O);
|
|
533
|
+
const _ = f ? await e.swap(t, n, O) : void 0;
|
|
534
|
+
let P = !1, I = on(a), B = rn(a, {
|
|
535
|
+
sellTokenAddress: o,
|
|
536
|
+
showTokenApproval: P
|
|
537
|
+
});
|
|
538
|
+
P = B.showTokenApproval;
|
|
539
|
+
let T = sn(B);
|
|
540
|
+
if (await an(u, B, T), B.needsTokenApproval && (a != null && a.permit2Approval)) {
|
|
541
|
+
await ((U = u == null ? void 0 : u.onApprovalRequested) == null ? void 0 : U.call(u, a.permit2Approval, T));
|
|
542
|
+
let W;
|
|
543
|
+
try {
|
|
544
|
+
W = await d(
|
|
545
|
+
qe(a.permit2Approval)
|
|
546
|
+
), nn(
|
|
547
|
+
await m.waitForTransactionReceipt({ hash: W }),
|
|
548
|
+
W
|
|
549
|
+
), await w();
|
|
550
|
+
} finally {
|
|
551
|
+
await ((te = u == null ? void 0 : u.onApprovalSettled) == null ? void 0 : te.call(u));
|
|
552
|
+
}
|
|
553
|
+
await ((q = u == null ? void 0 : u.onApprovalConfirmed) == null ? void 0 : q.call(u, {
|
|
554
|
+
txHash: W,
|
|
555
|
+
steps: T
|
|
556
|
+
})), a = await e.swapWithPermit2(t, n, O), I = on(a), B = rn(a, {
|
|
557
|
+
sellTokenAddress: o,
|
|
558
|
+
showTokenApproval: P
|
|
559
|
+
}), P = B.showTokenApproval, T = sn(B), await an(u, B, T);
|
|
560
|
+
}
|
|
561
|
+
if (!f && I === "token-approval")
|
|
562
|
+
throw new Error("Permit2 token approval is still required after approval.");
|
|
563
|
+
if (!f && I !== "batch" && I !== "permit2-signature" && I !== "direct")
|
|
564
|
+
throw new Error("Unsupported Permit2 recommended flow.");
|
|
565
|
+
const r = I === "permit2-signature" ? a == null ? void 0 : a.typedData : void 0, ee = r ? await (async () => {
|
|
566
|
+
var x, H;
|
|
567
|
+
if (!l)
|
|
568
|
+
throw new Error("Permit2 swap requires a wallet that supports typed-data signing.");
|
|
569
|
+
const W = T.signatureStep ?? 1;
|
|
570
|
+
await ((x = u == null ? void 0 : u.onSignatureRequested) == null ? void 0 : x.call(u, W, T));
|
|
571
|
+
try {
|
|
572
|
+
return await l.signTypedData({
|
|
573
|
+
account: l.account ?? n,
|
|
574
|
+
domain: r.domain,
|
|
575
|
+
types: r.types,
|
|
576
|
+
primaryType: "PermitSingle",
|
|
577
|
+
message: r.values
|
|
578
|
+
});
|
|
579
|
+
} finally {
|
|
580
|
+
await ((H = u == null ? void 0 : u.onSignatureSettled) == null ? void 0 : H.call(u));
|
|
581
|
+
}
|
|
582
|
+
})() : "0x";
|
|
583
|
+
await ((fe = u == null ? void 0 : u.onWalletConfirmationRequested) == null ? void 0 : fe.call(u, T.confirmStep, T));
|
|
584
|
+
const N = f ? _ == null ? void 0 : _.tx : I === "batch" || a == null ? void 0 : a.buildSwapTx(ee), y = I === "batch" ? (de = a == null ? void 0 : a.batch) == null ? void 0 : de.calls : void 0;
|
|
585
|
+
if (!N && !(y != null && y.length))
|
|
586
|
+
throw new Error("Swap transaction could not be prepared.");
|
|
587
|
+
let K;
|
|
588
|
+
if (y != null && y.length) {
|
|
589
|
+
const W = await h({
|
|
590
|
+
account: n,
|
|
591
|
+
calls: y.map(({ tx: ne }) => qe(ne)),
|
|
592
|
+
throwOnFailure: !0,
|
|
593
|
+
...s ? { chainId: s } : {}
|
|
594
|
+
}), x = si(W), H = x[x.length - 1];
|
|
595
|
+
if (!H)
|
|
596
|
+
throw new Error("Wallet batch did not return a transaction hash.");
|
|
597
|
+
K = H, await w();
|
|
598
|
+
} else if (C) {
|
|
599
|
+
if (!N)
|
|
600
|
+
throw new Error("Swap transaction could not be prepared.");
|
|
601
|
+
if (!l)
|
|
602
|
+
throw new Error("MEV Protect requires a wallet that supports transaction signing.");
|
|
603
|
+
if (!(A != null && A.baseUrl))
|
|
604
|
+
throw new Error("MEV Protect is unavailable because the backend API base URL is missing.");
|
|
605
|
+
const W = qe(N), x = await l.signTransaction({
|
|
606
|
+
account: l.account ?? n,
|
|
607
|
+
to: W.to,
|
|
608
|
+
data: W.data,
|
|
609
|
+
value: W.value,
|
|
610
|
+
...W.gasPrice ? { gasPrice: W.gasPrice } : {},
|
|
611
|
+
...W.gas ? { gas: W.gas } : {},
|
|
612
|
+
...s ? { chainId: s } : {}
|
|
613
|
+
}), H = typeof x == "string" ? x : x.signedTx ?? "";
|
|
614
|
+
if (!H)
|
|
615
|
+
throw new Error("Wallet did not return a signed transaction for MEV Protect.");
|
|
616
|
+
const ne = await rr(A.baseUrl, {
|
|
617
|
+
signed_tx: H,
|
|
618
|
+
quote_id: (t == null ? void 0 : t.quoteId) || (t == null ? void 0 : t.requestId) || "",
|
|
619
|
+
quote_time: Math.floor(Date.now() / 1e3),
|
|
620
|
+
amount_in: t.amountIn.toString(),
|
|
621
|
+
amount_out: t.amountOut.toString(),
|
|
622
|
+
token_in: o || "",
|
|
623
|
+
token_out: c || "",
|
|
624
|
+
slippage_bps: S,
|
|
625
|
+
user_address: n,
|
|
626
|
+
chain_id: s ?? 0
|
|
627
|
+
});
|
|
628
|
+
if (!ne.success || !ne.tx_hashes[0])
|
|
629
|
+
throw new Error(ne.msg || "Protected execution failed");
|
|
630
|
+
K = ne.tx_hashes[0];
|
|
631
|
+
} else {
|
|
632
|
+
if (!N)
|
|
633
|
+
throw new Error("Swap transaction could not be prepared.");
|
|
634
|
+
K = await d(qe(N));
|
|
635
|
+
}
|
|
636
|
+
await ((oe = u == null ? void 0 : u.onSubmitted) == null ? void 0 : oe.call(u, {
|
|
637
|
+
txHash: K,
|
|
638
|
+
step: T.submitStep
|
|
639
|
+
}));
|
|
640
|
+
const xe = nn(
|
|
641
|
+
await ai(m, K),
|
|
642
|
+
K
|
|
643
|
+
);
|
|
644
|
+
return {
|
|
645
|
+
txHash: K,
|
|
646
|
+
receipt: xe
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
async function Mi(e, t) {
|
|
650
|
+
if (!(!(e != null && e.getProvider) || !t))
|
|
651
|
+
try {
|
|
652
|
+
const n = await e.getProvider();
|
|
653
|
+
if (!(n != null && n.request)) return;
|
|
654
|
+
const o = await n.request({
|
|
655
|
+
method: "wallet_getCapabilities",
|
|
656
|
+
params: [t]
|
|
657
|
+
});
|
|
658
|
+
return o && typeof o == "object" ? o : void 0;
|
|
659
|
+
} catch {
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
const cn = [
|
|
664
|
+
{
|
|
665
|
+
inputs: [],
|
|
666
|
+
name: "deposit",
|
|
667
|
+
outputs: [],
|
|
668
|
+
stateMutability: "payable",
|
|
669
|
+
type: "function"
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
inputs: [{ name: "wad", type: "uint256" }],
|
|
673
|
+
name: "withdraw",
|
|
674
|
+
outputs: [],
|
|
675
|
+
stateMutability: "nonpayable",
|
|
676
|
+
type: "function"
|
|
677
|
+
}
|
|
678
|
+
], ki = [
|
|
679
|
+
{
|
|
680
|
+
inputs: [
|
|
681
|
+
{ internalType: "address", name: "token", type: "address" },
|
|
682
|
+
{ internalType: "address", name: "spender", type: "address" },
|
|
683
|
+
{ internalType: "uint160", name: "amount", type: "uint160" },
|
|
684
|
+
{ internalType: "uint48", name: "expiration", type: "uint48" }
|
|
685
|
+
],
|
|
686
|
+
name: "approve",
|
|
687
|
+
outputs: [],
|
|
688
|
+
stateMutability: "nonpayable",
|
|
689
|
+
type: "function"
|
|
690
|
+
}
|
|
691
|
+
];
|
|
692
|
+
function Oi(e) {
|
|
693
|
+
const t = Math.floor(Date.now() / 1e3), n = t + bt, o = t + e.expirySeconds + Cn, c = t + yn;
|
|
694
|
+
return Math.min(Math.max(o, n), c);
|
|
695
|
+
}
|
|
696
|
+
function Ui(e) {
|
|
697
|
+
const t = e instanceof Error ? e.message : String(e);
|
|
698
|
+
return t.includes("User rejected") || t.includes("user rejected");
|
|
699
|
+
}
|
|
700
|
+
function Fi(e) {
|
|
701
|
+
return e.split(`
|
|
702
|
+
`).filter((t) => {
|
|
703
|
+
const n = t.trim();
|
|
704
|
+
return !n.startsWith("Docs:") && !n.startsWith("Version:");
|
|
705
|
+
}).join(`
|
|
706
|
+
`).trim();
|
|
707
|
+
}
|
|
708
|
+
function $i(e) {
|
|
709
|
+
const o = wn(e).join(`
|
|
710
|
+
`).toLowerCase();
|
|
711
|
+
return o.includes('contract function "deposit"') ? "BNB wrap failed. Please try again or switch RPC." : o.includes('contract function "approve"') ? "Token approval failed. Please try again or switch RPC." : o.includes("failed to fetch") || o.includes("http request failed") || o.includes("failed to fetch contract call") ? "Unable to verify the transaction with the current RPC. Please try again or switch RPC." : Fi(di(e));
|
|
712
|
+
}
|
|
713
|
+
function Wi(e, t) {
|
|
714
|
+
var S, b, f, s;
|
|
715
|
+
if (!(e instanceof St) || e.body.code !== "insufficient_balance")
|
|
716
|
+
return;
|
|
717
|
+
const n = t == null ? void 0 : t.limitIntentDraft, o = (t == null ? void 0 : t.from.decimals) ?? (n == null ? void 0 : n.sellToken.decimals) ?? 18, c = (n == null ? void 0 : n.intentSellToken.toLowerCase()) === vt.toLowerCase(), m = c ? "WBNB" : (t == null ? void 0 : t.from.symbol) ?? (n == null ? void 0 : n.sellToken.symbol) ?? "", l = e.body.reserved_sell_amount ?? ((b = (S = t == null ? void 0 : t.limitOrderDetails) == null ? void 0 : S.availableBalance) == null ? void 0 : b.reservedAmountRaw), d = e.body.available_amount ?? ((s = (f = t == null ? void 0 : t.limitOrderDetails) == null ? void 0 : f.availableBalance) == null ? void 0 : s.availableAmount) ?? "0", h = e.body.available_amount ? pt(e.body.available_amount, o) : d, v = pt(l, o);
|
|
718
|
+
return [
|
|
719
|
+
`Insufficient available balance. ${c ? "Your BNB is wrapped to WBNB and used by existing open orders." : `Your ${m} is used by existing open orders.`}`,
|
|
720
|
+
`Available: ${h} ${m}`,
|
|
721
|
+
`In Open Orders: ${v} ${m}`
|
|
722
|
+
].join(`
|
|
723
|
+
`);
|
|
724
|
+
}
|
|
725
|
+
function Hi({
|
|
726
|
+
displayData: e,
|
|
727
|
+
isTokenAllowanceApproved: t,
|
|
728
|
+
isPermit2AllowanceApproved: n,
|
|
729
|
+
refetchTokenAllowance: o,
|
|
730
|
+
refetchPermit2Allowance: c,
|
|
731
|
+
refetchBalances: m,
|
|
732
|
+
onEvent: l
|
|
733
|
+
}) {
|
|
734
|
+
const [d, h] = R(!1), [v, w] = R(1), [S, b] = R(!1), [f, s] = R(!1), [A, u] = R(!1), [C, k] = R(!1), [O, a] = R(!1), [_, P] = R(!1), [, I] = gt(), { address: B } = tt(), T = Kr(), r = An(), { data: ee } = Pn(), { mutateAsync: N } = qr(), { baseUrl: y } = ht(), K = Gr(), xe = j((x) => x.closeConfirm), U = j((x) => x.closeComplete), te = j((x) => x.clearAmounts), q = j((x) => x.openComplete), fe = ue(
|
|
735
|
+
(x) => {
|
|
736
|
+
l == null || l(x);
|
|
737
|
+
},
|
|
738
|
+
[l]
|
|
739
|
+
), de = ue(() => {
|
|
740
|
+
h(!1), w(1), b(!1), s(!1), u(!1), k(!1), a(!1), P(!1);
|
|
741
|
+
}, []), oe = ue(
|
|
742
|
+
(x) => {
|
|
743
|
+
ct(x, "limit-intent-execution");
|
|
744
|
+
const H = $i(x);
|
|
745
|
+
if (I(() => {
|
|
746
|
+
h(!1);
|
|
747
|
+
}), Ui(x)) {
|
|
748
|
+
M.error("Request rejected", { description: "User rejected the request" });
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
q({
|
|
752
|
+
result: "failed",
|
|
753
|
+
data: {
|
|
754
|
+
inputAmount: (e == null ? void 0 : e.from.amount) || "0",
|
|
755
|
+
inputSymbol: (e == null ? void 0 : e.from.symbol) || "",
|
|
756
|
+
outputAmount: (e == null ? void 0 : e.to.amount) || "0",
|
|
757
|
+
outputSymbol: (e == null ? void 0 : e.to.symbol) || "",
|
|
758
|
+
error: H,
|
|
759
|
+
errorDetails: Wi(x, e),
|
|
760
|
+
result: "failed"
|
|
761
|
+
}
|
|
762
|
+
}), M.error("Limit order failed");
|
|
763
|
+
},
|
|
764
|
+
[e, q]
|
|
765
|
+
), W = ue(async () => {
|
|
766
|
+
let x = e == null ? void 0 : e.limitIntentDraft, H = BigInt(0), ne = !1;
|
|
767
|
+
try {
|
|
768
|
+
if (!x || !e)
|
|
769
|
+
throw new Error("No limit order data available");
|
|
770
|
+
if (!B || !ee || !r)
|
|
771
|
+
throw new Error("Wallet not connected or client not ready");
|
|
772
|
+
if (T !== Me)
|
|
773
|
+
throw new Error("Please switch to BSC Mainnet");
|
|
774
|
+
const ce = x.sellToken.address.toLowerCase() === Ee.toLowerCase() && x.intentSellToken.toLowerCase() === vt.toLowerCase(), Q = BigInt(x.sellAmountRaw), J = ce, pe = !t, ae = !n, ge = !0;
|
|
775
|
+
a(J), b(pe || ae || ge), s(pe), u(ae), k(ge), w(1), h(!0);
|
|
776
|
+
let L = 1;
|
|
777
|
+
if (J) {
|
|
778
|
+
w(L), L += 1, H = Q;
|
|
779
|
+
const X = M.loading("Wrapping BNB", {
|
|
780
|
+
description: "Confirm the wrap transaction in your wallet"
|
|
781
|
+
});
|
|
782
|
+
try {
|
|
783
|
+
const Y = await N({
|
|
784
|
+
address: x.intentSellToken,
|
|
785
|
+
abi: cn,
|
|
786
|
+
functionName: "deposit",
|
|
787
|
+
chainId: Me,
|
|
788
|
+
value: H
|
|
789
|
+
});
|
|
790
|
+
await r.waitForTransactionReceipt({ hash: Y }), ne = !0, M.dismiss(X), M.success("BNB wrapped to WBNB");
|
|
791
|
+
} catch (Y) {
|
|
792
|
+
throw M.dismiss(X), Y;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
const be = pe || ae, re = L;
|
|
796
|
+
be && (L += 1);
|
|
797
|
+
const Se = L;
|
|
798
|
+
if (ge && (L += 1), pe) {
|
|
799
|
+
w(re);
|
|
800
|
+
const X = await N({
|
|
801
|
+
address: x.intentSellToken,
|
|
802
|
+
abi: Tn,
|
|
803
|
+
functionName: "approve",
|
|
804
|
+
chainId: Me,
|
|
805
|
+
args: [Ze, ir]
|
|
806
|
+
});
|
|
807
|
+
await r.waitForTransactionReceipt({ hash: X }), await o(), M.success(`${ce ? "WBNB" : x.sellToken.symbol} enabled`);
|
|
808
|
+
}
|
|
809
|
+
if (ae) {
|
|
810
|
+
w(re);
|
|
811
|
+
const X = await N({
|
|
812
|
+
address: Ze,
|
|
813
|
+
abi: ki,
|
|
814
|
+
functionName: "approve",
|
|
815
|
+
chainId: Me,
|
|
816
|
+
args: [
|
|
817
|
+
x.intentSellToken,
|
|
818
|
+
xt,
|
|
819
|
+
ui,
|
|
820
|
+
Oi(x)
|
|
821
|
+
]
|
|
822
|
+
});
|
|
823
|
+
await r.waitForTransactionReceipt({ hash: X }), await c(), M.success("Limit orders enabled");
|
|
824
|
+
}
|
|
825
|
+
w(Se), x = Ni(x);
|
|
826
|
+
const Te = wi(), ye = xi(), Pe = bi({ draft: x, nonce: Te, salt: ye }), F = await ee.signTypedData({
|
|
827
|
+
account: B,
|
|
828
|
+
domain: gi,
|
|
829
|
+
types: hi,
|
|
830
|
+
primaryType: "Intent",
|
|
831
|
+
message: Pe
|
|
832
|
+
});
|
|
833
|
+
w(L);
|
|
834
|
+
const z = await fi(
|
|
835
|
+
{
|
|
836
|
+
owner: x.owner,
|
|
837
|
+
sellToken: x.intentSellToken,
|
|
838
|
+
buyToken: x.intentBuyToken,
|
|
839
|
+
sellAmount: x.sellAmountRaw,
|
|
840
|
+
startPrice: x.priceRaw,
|
|
841
|
+
floorPrice: x.priceRaw,
|
|
842
|
+
startTime: x.startTime,
|
|
843
|
+
duration: x.duration,
|
|
844
|
+
curveType: "LINEAR",
|
|
845
|
+
validFrom: x.validFrom,
|
|
846
|
+
expiry: x.expiryUnixSeconds,
|
|
847
|
+
nonce: Te,
|
|
848
|
+
salt: ye,
|
|
849
|
+
recipient: x.recipient ?? x.owner,
|
|
850
|
+
referralCode: x.referralCode,
|
|
851
|
+
maxExecutions: En,
|
|
852
|
+
minFillBps: _n,
|
|
853
|
+
signature: F
|
|
854
|
+
},
|
|
855
|
+
{ baseUrl: y }
|
|
856
|
+
);
|
|
857
|
+
xe(), U(), h(!1), te(), m(), K.invalidateQueries({ queryKey: [or] }), K.invalidateQueries({ queryKey: [sr] }), K.invalidateQueries({ queryKey: [vn] }), K.invalidateQueries({ queryKey: [ar] }), q({
|
|
858
|
+
result: "success",
|
|
859
|
+
data: {
|
|
860
|
+
inputAmount: e.from.amount,
|
|
861
|
+
inputSymbol: e.from.symbol,
|
|
862
|
+
outputAmount: e.to.amount,
|
|
863
|
+
outputSymbol: e.to.symbol,
|
|
864
|
+
intentId: z.intent_id,
|
|
865
|
+
intentHash: z.intent_hash,
|
|
866
|
+
intentStatus: z.status,
|
|
867
|
+
expiry: z.expiry,
|
|
868
|
+
result: "success"
|
|
869
|
+
}
|
|
870
|
+
}), fe({
|
|
871
|
+
type: "limit_confirmed",
|
|
872
|
+
payload: {
|
|
873
|
+
intentId: z.intent_id,
|
|
874
|
+
intentHash: z.intent_hash,
|
|
875
|
+
status: z.status
|
|
876
|
+
}
|
|
877
|
+
}), M.success("Limit Order Placed", {
|
|
878
|
+
description: Jn(lt, {
|
|
879
|
+
from: {
|
|
880
|
+
amount: me(
|
|
881
|
+
e.from.amount || 0,
|
|
882
|
+
e.from.decimals,
|
|
883
|
+
!0
|
|
884
|
+
),
|
|
885
|
+
symbol: E(e.from.symbol, 9),
|
|
886
|
+
icon: e.from.icon
|
|
887
|
+
},
|
|
888
|
+
to: {
|
|
889
|
+
amount: me(e.to.amount || 0, e.to.decimals, !0),
|
|
890
|
+
symbol: E(e.to.symbol, 9),
|
|
891
|
+
icon: e.to.icon
|
|
892
|
+
}
|
|
893
|
+
})
|
|
894
|
+
});
|
|
895
|
+
} catch (ce) {
|
|
896
|
+
if (ne && x && H > BigInt(0)) {
|
|
897
|
+
let Q;
|
|
898
|
+
try {
|
|
899
|
+
Q = M.loading("Restoring BNB", {
|
|
900
|
+
description: "Unwrapping the BNB from this failed order"
|
|
901
|
+
});
|
|
902
|
+
const J = await N({
|
|
903
|
+
address: x.intentSellToken,
|
|
904
|
+
abi: cn,
|
|
905
|
+
functionName: "withdraw",
|
|
906
|
+
args: [H]
|
|
907
|
+
});
|
|
908
|
+
await (r == null ? void 0 : r.waitForTransactionReceipt({ hash: J })), M.dismiss(Q), M.success("BNB restored"), m();
|
|
909
|
+
} catch (J) {
|
|
910
|
+
ct(J, "limit-intent-rollback"), Q && M.dismiss(Q), console.error("Failed to unwrap BNB after limit order failure", J), M.error("Failed to restore BNB", {
|
|
911
|
+
description: "The order failed, but the wrapped WBNB remains in your wallet."
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
oe(ce);
|
|
916
|
+
}
|
|
917
|
+
}, [
|
|
918
|
+
B,
|
|
919
|
+
y,
|
|
920
|
+
te,
|
|
921
|
+
U,
|
|
922
|
+
xe,
|
|
923
|
+
T,
|
|
924
|
+
e,
|
|
925
|
+
fe,
|
|
926
|
+
oe,
|
|
927
|
+
q,
|
|
928
|
+
r,
|
|
929
|
+
K,
|
|
930
|
+
c,
|
|
931
|
+
o,
|
|
932
|
+
m,
|
|
933
|
+
ee,
|
|
934
|
+
N,
|
|
935
|
+
n,
|
|
936
|
+
t
|
|
937
|
+
]);
|
|
938
|
+
return {
|
|
939
|
+
isPending: d,
|
|
940
|
+
transactionStep: v,
|
|
941
|
+
needsApproval: S,
|
|
942
|
+
needsTokenApproval: f,
|
|
943
|
+
needsPermit2Approval: A,
|
|
944
|
+
needsPermit2Signature: C,
|
|
945
|
+
needsWrap: O,
|
|
946
|
+
showErrorDetails: _,
|
|
947
|
+
setShowErrorDetails: P,
|
|
948
|
+
executeLimitIntent: W,
|
|
949
|
+
resetExecutionState: de,
|
|
950
|
+
chainId: Me
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
function nt({
|
|
954
|
+
title: e,
|
|
955
|
+
presentation: t = "dialog",
|
|
956
|
+
onBack: n
|
|
957
|
+
}) {
|
|
958
|
+
return t === "embedded" && n ? /* @__PURE__ */ p("div", { className: "relative flex h-8 shrink-0 items-center justify-center", children: [
|
|
959
|
+
/* @__PURE__ */ p(
|
|
960
|
+
Oe,
|
|
961
|
+
{
|
|
962
|
+
type: "button",
|
|
963
|
+
variant: "ghost",
|
|
964
|
+
size: "sm",
|
|
965
|
+
className: "absolute left-0 z-10 gap-1 text-muted-foreground hover:text-foreground",
|
|
966
|
+
onClick: n,
|
|
967
|
+
children: [
|
|
968
|
+
/* @__PURE__ */ i(cr, { className: "size-4" }),
|
|
969
|
+
/* @__PURE__ */ i("span", { children: "Back" })
|
|
970
|
+
]
|
|
971
|
+
}
|
|
972
|
+
),
|
|
973
|
+
/* @__PURE__ */ i("h2", { className: "text-sm font-medium leading-none text-foreground", children: e })
|
|
974
|
+
] }) : /* @__PURE__ */ i(lr, { children: /* @__PURE__ */ i(xn, { children: e }) });
|
|
975
|
+
}
|
|
976
|
+
const ln = 9, ji = `Transaction was not confirmed.
|
|
977
|
+
This may be due to network congestion or low gas fees.`, Vi = "Something went wrong", Qi = "Transaction was not processed. Please try again.", zi = "; use swapETH instead.";
|
|
978
|
+
function Xi(e) {
|
|
979
|
+
return typeof e != "string" ? "" : e.split(`
|
|
980
|
+
`).filter((t) => {
|
|
981
|
+
const n = t.trim();
|
|
982
|
+
return !n.startsWith("Docs:") && !n.startsWith("Version:");
|
|
983
|
+
}).join(`
|
|
984
|
+
`).replaceAll(zi, "").trim();
|
|
985
|
+
}
|
|
986
|
+
function un({
|
|
987
|
+
completeResult: e,
|
|
988
|
+
completeData: t,
|
|
989
|
+
showErrorDetails: n,
|
|
990
|
+
onToggleErrorDetails: o,
|
|
991
|
+
onClose: c,
|
|
992
|
+
explorerBaseUrl: m,
|
|
993
|
+
presentation: l = "dialog",
|
|
994
|
+
onBack: d,
|
|
995
|
+
flow: h = "swap"
|
|
996
|
+
}) {
|
|
997
|
+
var A, u;
|
|
998
|
+
const v = h === "limit" || !!(t != null && t.intentId), w = Xi(t == null ? void 0 : t.error), S = Vi, b = ((A = t == null ? void 0 : t.sellToken) == null ? void 0 : A.decimals) ?? 0, f = ((u = t == null ? void 0 : t.buyToken) == null ? void 0 : u.decimals) ?? 0, s = v ? (t == null ? void 0 : t.errorDetails) || w || ji : w || Qi;
|
|
999
|
+
return /* @__PURE__ */ p(Ue, { children: [
|
|
1000
|
+
/* @__PURE__ */ i(
|
|
1001
|
+
nt,
|
|
1002
|
+
{
|
|
1003
|
+
title: v ? "Limit Order" : "Swap",
|
|
1004
|
+
presentation: l,
|
|
1005
|
+
onBack: d
|
|
1006
|
+
}
|
|
1007
|
+
),
|
|
1008
|
+
/* @__PURE__ */ p("div", { className: "flex flex-col justify-center items-center", children: [
|
|
1009
|
+
/* @__PURE__ */ i(
|
|
1010
|
+
wt,
|
|
1011
|
+
{
|
|
1012
|
+
src: e === "success" ? ut.succeeded : ut.warning,
|
|
1013
|
+
alt: e || "result",
|
|
1014
|
+
className: "w-[128px] h-[128px]"
|
|
1015
|
+
}
|
|
1016
|
+
),
|
|
1017
|
+
/* @__PURE__ */ i("p", { className: "text-sm mb-2 capitalize font-medium", children: e === "success" ? "Success" : "Oops!" }),
|
|
1018
|
+
e === "success" ? /* @__PURE__ */ p("p", { className: "text-muted-foreground text-xs", children: [
|
|
1019
|
+
v ? "Placed order to sell " : "Traded ",
|
|
1020
|
+
/* @__PURE__ */ i("span", { className: "text-foreground", children: me((t == null ? void 0 : t.inputAmount) || "0", b, !0) }),
|
|
1021
|
+
" ",
|
|
1022
|
+
E((t == null ? void 0 : t.inputSymbol) || "", ln),
|
|
1023
|
+
" for",
|
|
1024
|
+
" ",
|
|
1025
|
+
/* @__PURE__ */ i("span", { className: "text-foreground", children: me((t == null ? void 0 : t.outputAmount) || "0", f, !0) }),
|
|
1026
|
+
" ",
|
|
1027
|
+
E((t == null ? void 0 : t.outputSymbol) || "", ln)
|
|
1028
|
+
] }) : /* @__PURE__ */ p("div", { className: "flex flex-col items-center w-full", children: [
|
|
1029
|
+
/* @__PURE__ */ i("p", { className: "text-muted-foreground text-xs text-center", children: S }),
|
|
1030
|
+
/* @__PURE__ */ p("div", { className: "mt-4 w-full flex flex-col items-center", children: [
|
|
1031
|
+
/* @__PURE__ */ i(
|
|
1032
|
+
"button",
|
|
1033
|
+
{
|
|
1034
|
+
onClick: o,
|
|
1035
|
+
className: "text-primary text-xs flex items-center justify-center gap-1 hover:underline mb-2 h-auto py-0 bg-transparent border-none cursor-pointer",
|
|
1036
|
+
children: n ? "Show less" : "Details"
|
|
1037
|
+
}
|
|
1038
|
+
),
|
|
1039
|
+
n ? /* @__PURE__ */ i("div", { className: "w-full max-h-[160px] overflow-auto rounded-lg border border-border/50 bg-input p-3 text-left font-mono text-[10px] text-muted-foreground whitespace-pre-wrap break-all", children: s }) : null
|
|
1040
|
+
] })
|
|
1041
|
+
] }),
|
|
1042
|
+
/* @__PURE__ */ i(Oe, { className: "rounded-full w-[220px] mt-4 font-medium", onClick: c, children: e === "success" ? "Close" : "Dismiss" }),
|
|
1043
|
+
e === "success" && (t != null && t.txHash) ? /* @__PURE__ */ p(
|
|
1044
|
+
"a",
|
|
1045
|
+
{
|
|
1046
|
+
className: "mt-3 text-primary text-xs flex items-center gap-1 group",
|
|
1047
|
+
href: mr(t == null ? void 0 : t.txHash, m),
|
|
1048
|
+
target: "_blank",
|
|
1049
|
+
rel: "noopener noreferrer",
|
|
1050
|
+
children: [
|
|
1051
|
+
"View on BscScan",
|
|
1052
|
+
/* @__PURE__ */ i(
|
|
1053
|
+
mt,
|
|
1054
|
+
{
|
|
1055
|
+
icon: ur,
|
|
1056
|
+
size: 12,
|
|
1057
|
+
className: "text-muted-foreground group-hover:text-primary transition-colors"
|
|
1058
|
+
}
|
|
1059
|
+
)
|
|
1060
|
+
]
|
|
1061
|
+
}
|
|
1062
|
+
) : null
|
|
1063
|
+
] })
|
|
1064
|
+
] });
|
|
1065
|
+
}
|
|
1066
|
+
function mn({
|
|
1067
|
+
displayData: e,
|
|
1068
|
+
transactionStep: t,
|
|
1069
|
+
needsApproval: n,
|
|
1070
|
+
needsTokenApproval: o,
|
|
1071
|
+
needsPermit2Approval: c,
|
|
1072
|
+
showTokenApprovalStep: m,
|
|
1073
|
+
needsPermit2Signature: l = !1,
|
|
1074
|
+
isPreparing: d = !1,
|
|
1075
|
+
needsWrap: h = !1,
|
|
1076
|
+
waitingCompleteTx: v,
|
|
1077
|
+
getTransactionUrl: w = (s) => fr(s),
|
|
1078
|
+
presentation: S = "dialog",
|
|
1079
|
+
onBack: b,
|
|
1080
|
+
flow: f = "swap"
|
|
1081
|
+
}) {
|
|
1082
|
+
const s = f === "limit", u = m ?? ((o ?? n) || (c ?? !1)) ? {
|
|
1083
|
+
id: "approve",
|
|
1084
|
+
label: "Approve in Wallet"
|
|
1085
|
+
} : null, C = l ? { id: "signature", label: "Sign Message" } : null, k = s ? [
|
|
1086
|
+
...h ? [{ id: "wrap", label: "Wrap BNB to WBNB" }] : [],
|
|
1087
|
+
...u ? [u] : [],
|
|
1088
|
+
...C ? [C] : [],
|
|
1089
|
+
{ id: "confirm", label: "Place Limit Order" }
|
|
1090
|
+
] : [
|
|
1091
|
+
...h ? [{ id: "wrap", label: "Wrap BNB" }] : [],
|
|
1092
|
+
...u ? [u] : [],
|
|
1093
|
+
...C ? [C] : [],
|
|
1094
|
+
{
|
|
1095
|
+
id: "confirm",
|
|
1096
|
+
label: "Confirm Transaction"
|
|
1097
|
+
},
|
|
1098
|
+
{ id: "submit", label: "Transaction Pending" }
|
|
1099
|
+
], O = !!v, a = s || O ? t : Math.min(t, k.length - 1), _ = k.map((I, B) => {
|
|
1100
|
+
const T = B + 1, r = s && B === k.length - 1;
|
|
1101
|
+
return {
|
|
1102
|
+
...I,
|
|
1103
|
+
stepNum: T,
|
|
1104
|
+
status: s ? a > T && !r ? "completed" : a >= T ? "active" : "pending" : a > T ? "completed" : a === T ? "active" : "pending"
|
|
1105
|
+
};
|
|
1106
|
+
}), P = s ? _ : _.filter((I) => I.id !== "submit" || O);
|
|
1107
|
+
return /* @__PURE__ */ p(Ue, { children: [
|
|
1108
|
+
/* @__PURE__ */ i(
|
|
1109
|
+
nt,
|
|
1110
|
+
{
|
|
1111
|
+
title: s ? "Limit Order" : "Swap",
|
|
1112
|
+
presentation: S,
|
|
1113
|
+
onBack: b
|
|
1114
|
+
}
|
|
1115
|
+
),
|
|
1116
|
+
/* @__PURE__ */ p("div", { className: "flex flex-col gap-6 items-center py-4", children: [
|
|
1117
|
+
/* @__PURE__ */ i("div", { className: "relative w-32 h-32", children: /* @__PURE__ */ i("img", { src: ut.loading, alt: "Pending", className: "h-full w-full object-contain" }) }),
|
|
1118
|
+
/* @__PURE__ */ i("div", { className: "w-full rounded-lg bg-input px-4 py-2 text-center", children: /* @__PURE__ */ p("p", { className: "text-muted-foreground text-xs leading-none", children: [
|
|
1119
|
+
s ? "Placing order to sell " : "Traded ",
|
|
1120
|
+
/* @__PURE__ */ p("span", { className: "text-foreground font-medium", children: [
|
|
1121
|
+
me(e.from.amount || "0", e.from.decimals, !0),
|
|
1122
|
+
" ",
|
|
1123
|
+
E(e.from.symbol, 9)
|
|
1124
|
+
] }),
|
|
1125
|
+
" ",
|
|
1126
|
+
"for ",
|
|
1127
|
+
/* @__PURE__ */ p("span", { className: "text-foreground font-medium", children: [
|
|
1128
|
+
me(e.to.amount || "0", e.to.decimals, !0),
|
|
1129
|
+
" ",
|
|
1130
|
+
E(e.to.symbol, 9)
|
|
1131
|
+
] })
|
|
1132
|
+
] }) }),
|
|
1133
|
+
/* @__PURE__ */ p("div", { className: "w-full space-y-4 pt-2", children: [
|
|
1134
|
+
/* @__PURE__ */ p("div", { className: "flex items-center gap-2", children: [
|
|
1135
|
+
/* @__PURE__ */ i("div", { className: "h-px flex-1 bg-border" }),
|
|
1136
|
+
/* @__PURE__ */ i("span", { className: "text-xs tracking-wider text-muted-foreground", children: "Continue in your wallet" }),
|
|
1137
|
+
/* @__PURE__ */ i("div", { className: "h-px flex-1 bg-border" })
|
|
1138
|
+
] }),
|
|
1139
|
+
d ? /* @__PURE__ */ i(Yi, {}) : /* @__PURE__ */ i("div", { className: "space-y-4 px-2", children: P.map((I, B) => {
|
|
1140
|
+
var T;
|
|
1141
|
+
return /* @__PURE__ */ p(
|
|
1142
|
+
"div",
|
|
1143
|
+
{
|
|
1144
|
+
className: "grid grid-cols-[1rem_minmax(0,1fr)_auto] gap-x-1 group relative animate-in fade-in slide-in-from-top-1 duration-300 motion-reduce:animate-none",
|
|
1145
|
+
children: [
|
|
1146
|
+
/* @__PURE__ */ p("div", { className: "relative flex w-4 self-stretch justify-center", children: [
|
|
1147
|
+
/* @__PURE__ */ i("div", { className: "flex h-4 w-4 items-center justify-center", children: /* @__PURE__ */ i(
|
|
1148
|
+
"div",
|
|
1149
|
+
{
|
|
1150
|
+
className: he(
|
|
1151
|
+
"h-1 w-1 rounded-full",
|
|
1152
|
+
I.status === "pending" ? "bg-muted" : "bg-muted-foreground"
|
|
1153
|
+
)
|
|
1154
|
+
}
|
|
1155
|
+
) }),
|
|
1156
|
+
B < P.length - 1 ? /* @__PURE__ */ i(
|
|
1157
|
+
Gi,
|
|
1158
|
+
{
|
|
1159
|
+
isFlowing: ((T = P[B + 1]) == null ? void 0 : T.status) === "active"
|
|
1160
|
+
}
|
|
1161
|
+
) : null
|
|
1162
|
+
] }),
|
|
1163
|
+
/* @__PURE__ */ i("div", { className: "flex min-w-0 flex-col gap-0.5", children: /* @__PURE__ */ i(
|
|
1164
|
+
"span",
|
|
1165
|
+
{
|
|
1166
|
+
className: he(
|
|
1167
|
+
"text-xs",
|
|
1168
|
+
I.status === "pending" ? "text-muted-foreground" : "text-foreground"
|
|
1169
|
+
),
|
|
1170
|
+
children: I.label
|
|
1171
|
+
}
|
|
1172
|
+
) }),
|
|
1173
|
+
/* @__PURE__ */ i("div", { className: "flex items-center gap-2 self-start", children: I.status === "completed" ? /* @__PURE__ */ i(dr, { checked: !0, className: "w-4 h-4 rounded-full" }) : I.status === "active" ? /* @__PURE__ */ p("div", { className: "flex items-center gap-2 justify-end", children: [
|
|
1174
|
+
v && I.id === "submit" ? /* @__PURE__ */ i(
|
|
1175
|
+
"a",
|
|
1176
|
+
{
|
|
1177
|
+
href: w(v),
|
|
1178
|
+
target: "_blank",
|
|
1179
|
+
rel: "noopener noreferrer",
|
|
1180
|
+
className: "cursor-pointer text-xs text-muted-foreground hover:text-primary hover:underline",
|
|
1181
|
+
children: E(v, 10)
|
|
1182
|
+
}
|
|
1183
|
+
) : null,
|
|
1184
|
+
/* @__PURE__ */ i(bn, { className: "text-primary size-4" })
|
|
1185
|
+
] }) : null })
|
|
1186
|
+
]
|
|
1187
|
+
},
|
|
1188
|
+
I.id
|
|
1189
|
+
);
|
|
1190
|
+
}) })
|
|
1191
|
+
] })
|
|
1192
|
+
] })
|
|
1193
|
+
] });
|
|
1194
|
+
}
|
|
1195
|
+
function Yi() {
|
|
1196
|
+
return /* @__PURE__ */ i("div", { className: "px-2", "aria-hidden": "true", children: /* @__PURE__ */ p("div", { className: "grid grid-cols-[1rem_minmax(0,1fr)_auto] gap-x-1", children: [
|
|
1197
|
+
/* @__PURE__ */ i("div", { className: "flex h-4 w-4 items-center justify-center", children: /* @__PURE__ */ i("div", { className: "h-1 w-1 rounded-full bg-muted" }) }),
|
|
1198
|
+
/* @__PURE__ */ i("div", { className: "flex h-4 items-center", children: /* @__PURE__ */ i(pr, { className: "h-2.5 w-40 max-w-[60%] rounded-full bg-muted/60" }) })
|
|
1199
|
+
] }) });
|
|
1200
|
+
}
|
|
1201
|
+
function Gi({ isFlowing: e }) {
|
|
1202
|
+
return /* @__PURE__ */ i(
|
|
1203
|
+
"div",
|
|
1204
|
+
{
|
|
1205
|
+
"aria-hidden": "true",
|
|
1206
|
+
className: he(
|
|
1207
|
+
"absolute left-1/2 top-4 -bottom-4 w-1 -translate-x-1/2 bg-repeat-y transition-colors duration-300",
|
|
1208
|
+
e ? "text-muted-foreground/70" : "text-muted-foreground/30"
|
|
1209
|
+
),
|
|
1210
|
+
style: {
|
|
1211
|
+
backgroundImage: "radial-gradient(circle, currentColor 1.5px, transparent 1.6px)",
|
|
1212
|
+
backgroundPosition: "center top",
|
|
1213
|
+
backgroundSize: "4px 8px"
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
);
|
|
1217
|
+
}
|
|
1218
|
+
function Mn({
|
|
1219
|
+
alternateValue: e,
|
|
1220
|
+
ariaLabel: t = "Switch value direction",
|
|
1221
|
+
className: n,
|
|
1222
|
+
defaultIsAlternate: o = !1,
|
|
1223
|
+
iconClassName: c,
|
|
1224
|
+
isAlternate: m,
|
|
1225
|
+
onAlternateChange: l,
|
|
1226
|
+
value: d,
|
|
1227
|
+
valueClassName: h
|
|
1228
|
+
}) {
|
|
1229
|
+
const [v, w] = R(o), S = m ?? v, b = S && e ? e : d, f = () => {
|
|
1230
|
+
const s = !S;
|
|
1231
|
+
m == null && w(s), l == null || l(s);
|
|
1232
|
+
};
|
|
1233
|
+
return /* @__PURE__ */ p(
|
|
1234
|
+
"button",
|
|
1235
|
+
{
|
|
1236
|
+
type: "button",
|
|
1237
|
+
"data-order-card-interactive": "true",
|
|
1238
|
+
className: he(
|
|
1239
|
+
"group cursor-pointer inline-flex min-w-0 items-center justify-end gap-1 text-right transition-colors hover:text-primary",
|
|
1240
|
+
n
|
|
1241
|
+
),
|
|
1242
|
+
onClick: f,
|
|
1243
|
+
"aria-label": t,
|
|
1244
|
+
children: [
|
|
1245
|
+
/* @__PURE__ */ i("span", { className: he("min-w-0 truncate", h), children: b || "-" }),
|
|
1246
|
+
/* @__PURE__ */ i(
|
|
1247
|
+
gr,
|
|
1248
|
+
{
|
|
1249
|
+
className: he(
|
|
1250
|
+
"size-4 shrink-0 rotate-90 text-muted-foreground transition-colors group-hover:text-primary",
|
|
1251
|
+
c
|
|
1252
|
+
)
|
|
1253
|
+
}
|
|
1254
|
+
)
|
|
1255
|
+
]
|
|
1256
|
+
}
|
|
1257
|
+
);
|
|
1258
|
+
}
|
|
1259
|
+
const Ki = 1e-6;
|
|
1260
|
+
function qi(e) {
|
|
1261
|
+
return e.trim().replace(/^\$/, "").replaceAll(",", "");
|
|
1262
|
+
}
|
|
1263
|
+
function Ji(e, t) {
|
|
1264
|
+
return t.toLowerCase().includes("e") ? e.toFixed(20).replace(/0+$/, "") : t;
|
|
1265
|
+
}
|
|
1266
|
+
function Zi(e) {
|
|
1267
|
+
const t = qi(e);
|
|
1268
|
+
if (!t || t === "-" || t === "—") return "$—";
|
|
1269
|
+
const n = Number(t);
|
|
1270
|
+
if (!Number.isFinite(n) || n < 0) return "$—";
|
|
1271
|
+
if (n === 0) return "$0.00";
|
|
1272
|
+
if (n < Ki) return "<$0.000001";
|
|
1273
|
+
if (n < 0.01) {
|
|
1274
|
+
const o = Ji(n, t), [, c = ""] = o.split("."), m = c.search(/[1-9]/);
|
|
1275
|
+
return m === -1 ? "$0.00" : `$0.${c.slice(0, m + 1)}`;
|
|
1276
|
+
}
|
|
1277
|
+
return `$${new Intl.NumberFormat("en-US", {
|
|
1278
|
+
minimumFractionDigits: 2,
|
|
1279
|
+
maximumFractionDigits: 2
|
|
1280
|
+
}).format(n)}`;
|
|
1281
|
+
}
|
|
1282
|
+
function dn({
|
|
1283
|
+
symbol: e,
|
|
1284
|
+
amount: t,
|
|
1285
|
+
usdValue: n,
|
|
1286
|
+
icon: o,
|
|
1287
|
+
decimals: c,
|
|
1288
|
+
className: m
|
|
1289
|
+
}) {
|
|
1290
|
+
const l = Number(t), [, d = ""] = t.split("."), h = d.startsWith("00000"), v = l > 0 && l < 1e-6 || h ? c : 6, w = dt(t, {
|
|
1291
|
+
maximumFractionDigits: v,
|
|
1292
|
+
roundingMode: "truncate",
|
|
1293
|
+
avoidSmallNumberShorthand: !0
|
|
1294
|
+
}), S = Zi(n);
|
|
1295
|
+
return /* @__PURE__ */ p(
|
|
1296
|
+
"div",
|
|
1297
|
+
{
|
|
1298
|
+
className: he(
|
|
1299
|
+
"flex items-center justify-between rounded-lg bg-input px-4 py-3 text-foreground",
|
|
1300
|
+
m
|
|
1301
|
+
),
|
|
1302
|
+
children: [
|
|
1303
|
+
/* @__PURE__ */ p("div", { className: "font-medium", children: [
|
|
1304
|
+
/* @__PURE__ */ p("div", { className: "text-xl", children: [
|
|
1305
|
+
/* @__PURE__ */ i("span", { children: w }),
|
|
1306
|
+
" ",
|
|
1307
|
+
/* @__PURE__ */ i("span", { className: "text-base", children: e })
|
|
1308
|
+
] }),
|
|
1309
|
+
/* @__PURE__ */ i("div", { className: "text-xs text-muted-foreground", children: S })
|
|
1310
|
+
] }),
|
|
1311
|
+
/* @__PURE__ */ i(
|
|
1312
|
+
wt,
|
|
1313
|
+
{
|
|
1314
|
+
fallbackText: e,
|
|
1315
|
+
src: o,
|
|
1316
|
+
alt: e,
|
|
1317
|
+
className: "w-6 h-6 rounded-full object-cover"
|
|
1318
|
+
}
|
|
1319
|
+
)
|
|
1320
|
+
]
|
|
1321
|
+
}
|
|
1322
|
+
);
|
|
1323
|
+
}
|
|
1324
|
+
function le({
|
|
1325
|
+
label: e,
|
|
1326
|
+
value: t,
|
|
1327
|
+
labelTooltip: n
|
|
1328
|
+
}) {
|
|
1329
|
+
return /* @__PURE__ */ p("div", { className: "flex items-center justify-between text-foreground", children: [
|
|
1330
|
+
/* @__PURE__ */ p("div", { className: "flex items-center gap-1 font-medium", children: [
|
|
1331
|
+
/* @__PURE__ */ i("span", { className: "text-muted-foreground", children: e }),
|
|
1332
|
+
n ? /* @__PURE__ */ i(hr, { iconSize: 16, children: n }) : null
|
|
1333
|
+
] }),
|
|
1334
|
+
/* @__PURE__ */ i("span", { className: "font-medium", children: t })
|
|
1335
|
+
] });
|
|
1336
|
+
}
|
|
1337
|
+
const V = 9, Di = "BNB will be automatically wrapped to WBNB before placing the order.";
|
|
1338
|
+
function De(e) {
|
|
1339
|
+
if (typeof e != "string" || !e) return "--";
|
|
1340
|
+
try {
|
|
1341
|
+
return Ce(e).eq(0) ? "0" : me(e, 0, !0, 6);
|
|
1342
|
+
} catch {
|
|
1343
|
+
return e;
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
function eo(e, t) {
|
|
1347
|
+
return t ? e === t ? E(t, V) : e.endsWith(` ${t}`) ? `${e.slice(0, -t.length)}${E(t, V)}` : e : e;
|
|
1348
|
+
}
|
|
1349
|
+
function fn({ label: e, token: t }) {
|
|
1350
|
+
return /* @__PURE__ */ p("div", { className: "min-w-0 flex-1 rounded-lg bg-input px-4 py-3 text-foreground", children: [
|
|
1351
|
+
/* @__PURE__ */ i("div", { className: "text-xs font-medium text-muted-foreground", children: e }),
|
|
1352
|
+
/* @__PURE__ */ p("div", { className: "mt-2 flex min-w-0 items-center gap-2", children: [
|
|
1353
|
+
/* @__PURE__ */ i(
|
|
1354
|
+
wt,
|
|
1355
|
+
{
|
|
1356
|
+
fallbackText: t.symbol,
|
|
1357
|
+
src: t.icon,
|
|
1358
|
+
alt: t.symbol,
|
|
1359
|
+
className: "h-4 w-4 shrink-0 rounded-full object-cover"
|
|
1360
|
+
}
|
|
1361
|
+
),
|
|
1362
|
+
/* @__PURE__ */ i("span", { className: "truncate text-sm font-medium", children: E(t.symbol, V) })
|
|
1363
|
+
] })
|
|
1364
|
+
] });
|
|
1365
|
+
}
|
|
1366
|
+
function pn({
|
|
1367
|
+
action: e,
|
|
1368
|
+
price: t,
|
|
1369
|
+
quoteToken: n,
|
|
1370
|
+
subjectToken: o
|
|
1371
|
+
}) {
|
|
1372
|
+
return `${e} ${E(o, V)} ≤ ${t} ${E(
|
|
1373
|
+
n,
|
|
1374
|
+
V
|
|
1375
|
+
)}`;
|
|
1376
|
+
}
|
|
1377
|
+
function to({
|
|
1378
|
+
displayData: e,
|
|
1379
|
+
dcaOrderDetails: t,
|
|
1380
|
+
presentation: n = "dialog",
|
|
1381
|
+
onBack: o,
|
|
1382
|
+
priceUpdated: c,
|
|
1383
|
+
isPending: m,
|
|
1384
|
+
isAvailableBalanceLoading: l = !1,
|
|
1385
|
+
hasAvailableBalanceError: d = !1,
|
|
1386
|
+
onConfirm: h
|
|
1387
|
+
}) {
|
|
1388
|
+
var k, O;
|
|
1389
|
+
const [v, w] = R(
|
|
1390
|
+
"current"
|
|
1391
|
+
), S = (a) => {
|
|
1392
|
+
if (!t.triggerPriceValue)
|
|
1393
|
+
return {
|
|
1394
|
+
condition: t.triggerCondition,
|
|
1395
|
+
price: t.triggerPrice
|
|
1396
|
+
};
|
|
1397
|
+
try {
|
|
1398
|
+
const _ = Ce(t.triggerPriceValue);
|
|
1399
|
+
return _.lte(0) ? {
|
|
1400
|
+
condition: t.triggerCondition,
|
|
1401
|
+
price: t.triggerPrice
|
|
1402
|
+
} : pn(a === "current" ? {
|
|
1403
|
+
action: t.triggerConditionType === "buy_lte" ? "Buy" : "Sell",
|
|
1404
|
+
subjectToken: t.triggerBaseToken,
|
|
1405
|
+
price: De(t.triggerPriceValue),
|
|
1406
|
+
quoteToken: t.triggerQuoteToken
|
|
1407
|
+
} : {
|
|
1408
|
+
action: t.triggerConditionType === "buy_lte" ? "Sell" : "Buy",
|
|
1409
|
+
subjectToken: t.triggerQuoteToken,
|
|
1410
|
+
price: De(Ce(1).div(_).toString()),
|
|
1411
|
+
quoteToken: t.triggerBaseToken
|
|
1412
|
+
});
|
|
1413
|
+
} catch {
|
|
1414
|
+
return {
|
|
1415
|
+
condition: t.triggerCondition,
|
|
1416
|
+
price: t.triggerPrice
|
|
1417
|
+
};
|
|
1418
|
+
}
|
|
1419
|
+
}, b = (a) => typeof a == "string" ? a : a.price && a.price !== "-" ? `${a.condition} ${a.price}` : a.condition, f = b(
|
|
1420
|
+
S("current")
|
|
1421
|
+
), s = b(
|
|
1422
|
+
S("inverse")
|
|
1423
|
+
), A = t.startDateUtc === "Start now", u = Ln({
|
|
1424
|
+
availableAmount: (k = t.availableBalance) == null ? void 0 : k.availableAmount,
|
|
1425
|
+
reservedAmountRaw: (O = t.availableBalance) == null ? void 0 : O.reservedAmountRaw,
|
|
1426
|
+
decimals: e.from.decimals,
|
|
1427
|
+
symbol: e.from.symbol,
|
|
1428
|
+
symbolMaxLength: V
|
|
1429
|
+
}), C = l ? "Checking Available Balance" : d ? "Insufficient Available Balance" : "Place DCA Order";
|
|
1430
|
+
return /* @__PURE__ */ p(Ue, { children: [
|
|
1431
|
+
/* @__PURE__ */ i(nt, { title: "Review your order", presentation: n, onBack: o }),
|
|
1432
|
+
/* @__PURE__ */ p("div", { className: "flex items-center gap-3", children: [
|
|
1433
|
+
/* @__PURE__ */ i(fn, { label: "Sell", token: e.from }),
|
|
1434
|
+
/* @__PURE__ */ i(ei, { strokeWidth: 2.5, className: "size-4 shrink-0 text-muted-foreground" }),
|
|
1435
|
+
/* @__PURE__ */ i(fn, { label: "Buy", token: e.to })
|
|
1436
|
+
] }),
|
|
1437
|
+
/* @__PURE__ */ p("div", { className: "space-y-2 text-xs", children: [
|
|
1438
|
+
/* @__PURE__ */ i(le, { label: "Sell total", value: t.sellTotal }),
|
|
1439
|
+
/* @__PURE__ */ i(le, { label: "Sell per order", value: t.sellPerOrder }),
|
|
1440
|
+
/* @__PURE__ */ i(
|
|
1441
|
+
le,
|
|
1442
|
+
{
|
|
1443
|
+
label: "Price protection",
|
|
1444
|
+
value: /* @__PURE__ */ i(
|
|
1445
|
+
Mn,
|
|
1446
|
+
{
|
|
1447
|
+
ariaLabel: "Switch DCA price protection direction",
|
|
1448
|
+
className: "text-foreground font-medium",
|
|
1449
|
+
isAlternate: v === "inverse",
|
|
1450
|
+
onAlternateChange: (a) => w(a ? "inverse" : "current"),
|
|
1451
|
+
value: f,
|
|
1452
|
+
alternateValue: s
|
|
1453
|
+
}
|
|
1454
|
+
)
|
|
1455
|
+
}
|
|
1456
|
+
),
|
|
1457
|
+
/* @__PURE__ */ i(
|
|
1458
|
+
le,
|
|
1459
|
+
{
|
|
1460
|
+
label: "Invest every",
|
|
1461
|
+
value: `${t.intervalValue} ${t.intervalUnit}`
|
|
1462
|
+
}
|
|
1463
|
+
),
|
|
1464
|
+
A ? null : /* @__PURE__ */ i(le, { label: "Start time (UTC)", value: t.startDateUtc }),
|
|
1465
|
+
/* @__PURE__ */ i(le, { label: "Est. end date", value: t.endDateUtc }),
|
|
1466
|
+
t.recipient ? /* @__PURE__ */ i(le, { label: "Recipient", value: E(t.recipient, 12) }) : null,
|
|
1467
|
+
/* @__PURE__ */ i(le, { label: "Platform fee", value: t.platformFee })
|
|
1468
|
+
] }),
|
|
1469
|
+
/* @__PURE__ */ p("div", { className: "rounded-lg border border-border p-3 text-xs leading-5 text-muted-foreground", children: [
|
|
1470
|
+
/* @__PURE__ */ i("p", { children: "This is an intent-based DCA order. Execution is not guaranteed." }),
|
|
1471
|
+
/* @__PURE__ */ p("ul", { className: "mt-1 list-disc pl-4", children: [
|
|
1472
|
+
/* @__PURE__ */ i("li", { children: "Funds are not reserved and will be checked at each execution." }),
|
|
1473
|
+
/* @__PURE__ */ i("li", { children: "Each order executes independently based on your price conditions." }),
|
|
1474
|
+
/* @__PURE__ */ i("li", { children: "Execution depends on market conditions, liquidity, and network costs." })
|
|
1475
|
+
] })
|
|
1476
|
+
] }),
|
|
1477
|
+
d ? /* @__PURE__ */ p("div", { className: "rounded-lg bg-red/10 p-3 text-xs leading-5 text-red", children: [
|
|
1478
|
+
/* @__PURE__ */ i("p", { children: "Insufficient available balance due to open orders." }),
|
|
1479
|
+
u ? /* @__PURE__ */ p("p", { className: "mt-1", children: [
|
|
1480
|
+
"Available: ",
|
|
1481
|
+
u.available,
|
|
1482
|
+
" ",
|
|
1483
|
+
u.symbol,
|
|
1484
|
+
", In Open Orders: ",
|
|
1485
|
+
u.inOpenOrders,
|
|
1486
|
+
" ",
|
|
1487
|
+
u.symbol,
|
|
1488
|
+
"."
|
|
1489
|
+
] }) : null
|
|
1490
|
+
] }) : null,
|
|
1491
|
+
/* @__PURE__ */ i(Sn, { children: /* @__PURE__ */ i(
|
|
1492
|
+
Oe,
|
|
1493
|
+
{
|
|
1494
|
+
className: "min-w-55 max-w-full rounded-full px-6 font-medium text-sm",
|
|
1495
|
+
disabled: c || m || l || d,
|
|
1496
|
+
onClick: h,
|
|
1497
|
+
children: C
|
|
1498
|
+
}
|
|
1499
|
+
) })
|
|
1500
|
+
] });
|
|
1501
|
+
}
|
|
1502
|
+
const Le = 3650 * 24 * 60, no = [
|
|
1503
|
+
"5 Minutes",
|
|
1504
|
+
"10 Minutes",
|
|
1505
|
+
"30 Minutes",
|
|
1506
|
+
"1 Hour",
|
|
1507
|
+
"1 Day",
|
|
1508
|
+
"3 Days",
|
|
1509
|
+
"7 Days",
|
|
1510
|
+
"1 Month",
|
|
1511
|
+
"3 Month"
|
|
1512
|
+
];
|
|
1513
|
+
function ro(e) {
|
|
1514
|
+
let t = "0", n = "0", o = "0";
|
|
1515
|
+
if (no.includes(e))
|
|
1516
|
+
e.includes("Minute") ? o = e.split(" ")[0] || "0" : e.includes("Hour") ? n = e.split(" ")[0] || "0" : e.includes("Day") ? t = e.split(" ")[0] || "0" : e === "1 Month" ? t = "30" : e === "3 Month" && (t = "90");
|
|
1517
|
+
else {
|
|
1518
|
+
const c = e.match(/(\d+)\s*Days?/i), m = e.match(/(\d+)\s*Hours?/i), l = e.match(/(\d+)\s*(Min|Minutes?)/i);
|
|
1519
|
+
t = c ? c[1] ?? "0" : "0", n = m ? m[1] ?? "0" : "0", o = l ? l[1] ?? "0" : "0";
|
|
1520
|
+
}
|
|
1521
|
+
return { d: t, h: n, m: o };
|
|
1522
|
+
}
|
|
1523
|
+
function io({
|
|
1524
|
+
currentExpiry: e,
|
|
1525
|
+
onSelectExpiry: t,
|
|
1526
|
+
compareExpiry: n = e,
|
|
1527
|
+
onClose: o,
|
|
1528
|
+
open: c = !0,
|
|
1529
|
+
className: m
|
|
1530
|
+
}) {
|
|
1531
|
+
const [l, d] = R("0"), [h, v] = R("0"), [w, S] = R("0");
|
|
1532
|
+
Ae(() => {
|
|
1533
|
+
if (!c) return;
|
|
1534
|
+
const { d: a, h: _, m: P } = ro(e);
|
|
1535
|
+
d(a), v(_), S(P);
|
|
1536
|
+
}, [c, e]);
|
|
1537
|
+
const f = (() => {
|
|
1538
|
+
const a = [];
|
|
1539
|
+
return l !== "0" && a.push(`${l} Day${l === "1" ? "" : "s"}`), h !== "0" && a.push(`${h} Hour${h === "1" ? "" : "s"}`), w !== "0" && a.push(`${w} Min`), a.length === 0 ? "0 Min" : a.join(" ");
|
|
1540
|
+
})(), s = ft(f), A = ft(n), u = s > 0 && f !== "" && f !== "0 Min" && s !== A, C = () => {
|
|
1541
|
+
t(f), o == null || o();
|
|
1542
|
+
}, k = (a, _) => {
|
|
1543
|
+
let P = _.replace(/[^\d]/g, "");
|
|
1544
|
+
P.length > 1 && (P = P.replace(/^0+/, "")), P || (P = "0");
|
|
1545
|
+
const I = a === "d" ? Number.parseInt(P) : Number.parseInt(l), B = a === "h" ? Number.parseInt(P) : Number.parseInt(h), T = a === "m" ? Number.parseInt(P) : Number.parseInt(w);
|
|
1546
|
+
if (a === "d") {
|
|
1547
|
+
const r = B * 60 + T;
|
|
1548
|
+
I * 1440 + r > Le && (P = Math.floor((Le - r) / 1440).toString()), d(P);
|
|
1549
|
+
} else if (a === "h") {
|
|
1550
|
+
const r = I * 1440 + T;
|
|
1551
|
+
B * 60 + r > Le && (P = Math.floor((Le - r) / 60).toString()), v(P);
|
|
1552
|
+
} else if (a === "m") {
|
|
1553
|
+
const r = I * 1440 + B * 60;
|
|
1554
|
+
T + r > Le && (P = (Le - r).toString()), S(P);
|
|
1555
|
+
}
|
|
1556
|
+
}, O = [
|
|
1557
|
+
{ label: "Days", value: l, type: "d" },
|
|
1558
|
+
{ label: "Hours", value: h, type: "h" },
|
|
1559
|
+
{ label: "Min", value: w, type: "m" }
|
|
1560
|
+
];
|
|
1561
|
+
return /* @__PURE__ */ p("div", { className: he("space-y-4", m), children: [
|
|
1562
|
+
/* @__PURE__ */ i("h4", { className: "text-sm font-medium mb-3 text-center text-foreground", children: "Set Expiration Time" }),
|
|
1563
|
+
/* @__PURE__ */ i("div", { className: "flex gap-2", children: O.map((a) => /* @__PURE__ */ p(
|
|
1564
|
+
"div",
|
|
1565
|
+
{
|
|
1566
|
+
className: "flex items-center gap-2 bg-input rounded-md px-2 flex-1 border border-transparent focus-within:border-primary",
|
|
1567
|
+
children: [
|
|
1568
|
+
/* @__PURE__ */ i(
|
|
1569
|
+
vr,
|
|
1570
|
+
{
|
|
1571
|
+
type: "text",
|
|
1572
|
+
value: a.value,
|
|
1573
|
+
onChange: (_) => k(a.type, _.target.value),
|
|
1574
|
+
className: "bg-transparent dark:bg-transparent border-none rounded-none shadow-none p-0 h-[30px] w-full focus-visible:ring-0 text-right pr-2 font-medium",
|
|
1575
|
+
placeholder: ""
|
|
1576
|
+
}
|
|
1577
|
+
),
|
|
1578
|
+
/* @__PURE__ */ i(
|
|
1579
|
+
"span",
|
|
1580
|
+
{
|
|
1581
|
+
className: he(
|
|
1582
|
+
"text-xs text-muted-foreground font-medium",
|
|
1583
|
+
a.label === "Min" && "text-nowrap shrink-0"
|
|
1584
|
+
),
|
|
1585
|
+
children: a.label
|
|
1586
|
+
}
|
|
1587
|
+
)
|
|
1588
|
+
]
|
|
1589
|
+
},
|
|
1590
|
+
a.label
|
|
1591
|
+
)) }),
|
|
1592
|
+
/* @__PURE__ */ i("div", { className: "flex justify-center", children: /* @__PURE__ */ i(
|
|
1593
|
+
Oe,
|
|
1594
|
+
{
|
|
1595
|
+
onClick: C,
|
|
1596
|
+
disabled: !u,
|
|
1597
|
+
className: "w-[50%] rounded-full h-9 text-sm font-medium text-secondary-foreground bg-primary hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed",
|
|
1598
|
+
children: "Save and Close"
|
|
1599
|
+
}
|
|
1600
|
+
) })
|
|
1601
|
+
] });
|
|
1602
|
+
}
|
|
1603
|
+
function oo({
|
|
1604
|
+
displayData: e,
|
|
1605
|
+
limitOrderDetails: t,
|
|
1606
|
+
needsWrap: n,
|
|
1607
|
+
hasAvailableBalanceError: o,
|
|
1608
|
+
onLimitExpiryChange: c
|
|
1609
|
+
}) {
|
|
1610
|
+
var k, O;
|
|
1611
|
+
const [m, l] = R("sell"), [d, h] = R(Date.now()), [v, w] = R(!1), S = !!c, b = t.marketWarning, f = G(() => {
|
|
1612
|
+
const a = t.availableBalance;
|
|
1613
|
+
return Ln({
|
|
1614
|
+
availableAmount: a == null ? void 0 : a.availableAmount,
|
|
1615
|
+
reservedAmountRaw: a == null ? void 0 : a.reservedAmountRaw,
|
|
1616
|
+
decimals: e.from.decimals,
|
|
1617
|
+
symbol: e.from.symbol,
|
|
1618
|
+
symbolMaxLength: V
|
|
1619
|
+
});
|
|
1620
|
+
}, [e.from.decimals, e.from.symbol, t.availableBalance]), s = G(() => {
|
|
1621
|
+
var P, I, B;
|
|
1622
|
+
const a = (P = e.limitIntentDraft) == null ? void 0 : P.expirySeconds, _ = a !== void 0 ? Math.floor(d / 1e3) + a : (I = e.limitIntentDraft) == null ? void 0 : I.expiryUnixSeconds;
|
|
1623
|
+
return _ ? ii(_, { now: d, includeUtcSuffix: !1 }) : ((B = t.expiry) == null ? void 0 : B.replace(" (UTC)", "")) ?? null;
|
|
1624
|
+
}, [
|
|
1625
|
+
(k = e.limitIntentDraft) == null ? void 0 : k.expirySeconds,
|
|
1626
|
+
(O = e.limitIntentDraft) == null ? void 0 : O.expiryUnixSeconds,
|
|
1627
|
+
t.expiry,
|
|
1628
|
+
d
|
|
1629
|
+
]), A = (() => {
|
|
1630
|
+
if (typeof e.rate != "string") return null;
|
|
1631
|
+
try {
|
|
1632
|
+
if (Ce(e.rate).lte(0)) return null;
|
|
1633
|
+
const a = {
|
|
1634
|
+
left: E(t.sellToken, V),
|
|
1635
|
+
right: E(t.buyToken, V),
|
|
1636
|
+
value: e.rate
|
|
1637
|
+
}, _ = {
|
|
1638
|
+
left: E(t.buyToken, V),
|
|
1639
|
+
right: E(t.sellToken, V),
|
|
1640
|
+
value: Ce(1).div(e.rate).toString()
|
|
1641
|
+
};
|
|
1642
|
+
return {
|
|
1643
|
+
sell: `1 ${a.left} = ${De(a.value)} ${a.right}`,
|
|
1644
|
+
buy: `1 ${_.left} = ${De(_.value)} ${_.right}`
|
|
1645
|
+
};
|
|
1646
|
+
} catch {
|
|
1647
|
+
return null;
|
|
1648
|
+
}
|
|
1649
|
+
})(), u = /* @__PURE__ */ p("span", { className: "inline-flex items-center gap-1", children: [
|
|
1650
|
+
/* @__PURE__ */ i("span", { children: "Expires at" }),
|
|
1651
|
+
/* @__PURE__ */ i("span", { children: "(UTC)" })
|
|
1652
|
+
] }), C = (a) => {
|
|
1653
|
+
const _ = ft(a);
|
|
1654
|
+
_ > 0 && (h(Date.now()), c == null || c(a, _));
|
|
1655
|
+
};
|
|
1656
|
+
return Ae(() => {
|
|
1657
|
+
const a = window.setInterval(() => {
|
|
1658
|
+
h(Date.now());
|
|
1659
|
+
}, 6e4);
|
|
1660
|
+
return () => window.clearInterval(a);
|
|
1661
|
+
}, []), /* @__PURE__ */ p(Ue, { children: [
|
|
1662
|
+
/* @__PURE__ */ p("div", { className: "flex w-full items-center justify-between text-foreground", children: [
|
|
1663
|
+
/* @__PURE__ */ i("span", { className: "font-medium text-muted-foreground", children: "Rate (Limit Price) " }),
|
|
1664
|
+
/* @__PURE__ */ i(
|
|
1665
|
+
Mn,
|
|
1666
|
+
{
|
|
1667
|
+
ariaLabel: "Switch limit price direction",
|
|
1668
|
+
className: "font-medium text-foreground",
|
|
1669
|
+
isAlternate: m === "buy",
|
|
1670
|
+
onAlternateChange: (a) => l(a ? "buy" : "sell"),
|
|
1671
|
+
value: A == null ? void 0 : A.sell,
|
|
1672
|
+
alternateValue: A == null ? void 0 : A.buy
|
|
1673
|
+
}
|
|
1674
|
+
)
|
|
1675
|
+
] }),
|
|
1676
|
+
s ? S ? /* @__PURE__ */ p(wr, { open: v, onOpenChange: w, children: [
|
|
1677
|
+
/* @__PURE__ */ i(xr, { asChild: !0, children: /* @__PURE__ */ p(
|
|
1678
|
+
"button",
|
|
1679
|
+
{
|
|
1680
|
+
type: "button",
|
|
1681
|
+
className: "group flex w-full cursor-pointer items-center justify-between text-foreground transition-colors hover:text-primary",
|
|
1682
|
+
children: [
|
|
1683
|
+
/* @__PURE__ */ i("span", { className: "font-medium text-muted-foreground", children: u }),
|
|
1684
|
+
/* @__PURE__ */ p("span", { className: "inline-flex items-center gap-1 text-right font-medium", children: [
|
|
1685
|
+
s,
|
|
1686
|
+
/* @__PURE__ */ i(Zt, { className: "size-3.5 text-muted-foreground transition-colors group-hover:text-primary" })
|
|
1687
|
+
] })
|
|
1688
|
+
]
|
|
1689
|
+
}
|
|
1690
|
+
) }),
|
|
1691
|
+
/* @__PURE__ */ i(
|
|
1692
|
+
br,
|
|
1693
|
+
{
|
|
1694
|
+
align: "end",
|
|
1695
|
+
sideOffset: 12,
|
|
1696
|
+
className: "z-600 w-[calc(100vw-32px)] max-w-80 border-border bg-card p-4 shadow-xl data-[state=closed]:animate-none data-[state=open]:animate-none",
|
|
1697
|
+
onOpenAutoFocus: (a) => a.preventDefault(),
|
|
1698
|
+
children: /* @__PURE__ */ i(
|
|
1699
|
+
io,
|
|
1700
|
+
{
|
|
1701
|
+
currentExpiry: t.expiry,
|
|
1702
|
+
onClose: () => w(!1),
|
|
1703
|
+
onSelectExpiry: C,
|
|
1704
|
+
open: v
|
|
1705
|
+
}
|
|
1706
|
+
)
|
|
1707
|
+
}
|
|
1708
|
+
)
|
|
1709
|
+
] }) : /* @__PURE__ */ i(
|
|
1710
|
+
le,
|
|
1711
|
+
{
|
|
1712
|
+
label: u,
|
|
1713
|
+
value: /* @__PURE__ */ i("span", { className: "text-right", children: s })
|
|
1714
|
+
}
|
|
1715
|
+
) : null,
|
|
1716
|
+
/* @__PURE__ */ p("div", { className: "mt-5 rounded-lg border border-border p-3 text-xs leading-5 text-muted-foreground", children: [
|
|
1717
|
+
/* @__PURE__ */ i("p", { children: "This is an intent-based order. Execution is not guaranteed." }),
|
|
1718
|
+
/* @__PURE__ */ p("ul", { className: "mt-1 list-disc pl-4", children: [
|
|
1719
|
+
/* @__PURE__ */ i("li", { children: "Existing open orders may reserve part of your balance" }),
|
|
1720
|
+
/* @__PURE__ */ i("li", { children: "Requires sufficient balance at execution time" }),
|
|
1721
|
+
/* @__PURE__ */ i("li", { children: "Execution depends on market conditions, liquidity, and network costs." })
|
|
1722
|
+
] })
|
|
1723
|
+
] }),
|
|
1724
|
+
n ? /* @__PURE__ */ i("div", { className: "rounded-lg bg-warning/10 p-3 text-xs leading-5 text-warning", children: Di }) : null,
|
|
1725
|
+
o ? /* @__PURE__ */ p("div", { className: "rounded-lg bg-red/10 p-3 text-xs leading-5 text-red", children: [
|
|
1726
|
+
/* @__PURE__ */ i("p", { children: "Insufficient available balance due to open orders." }),
|
|
1727
|
+
f ? /* @__PURE__ */ p("p", { className: "mt-1", children: [
|
|
1728
|
+
"Available: ",
|
|
1729
|
+
f.available,
|
|
1730
|
+
" ",
|
|
1731
|
+
f.symbol,
|
|
1732
|
+
", In Open Orders:",
|
|
1733
|
+
" ",
|
|
1734
|
+
f.inOpenOrders,
|
|
1735
|
+
" ",
|
|
1736
|
+
f.symbol,
|
|
1737
|
+
"."
|
|
1738
|
+
] }) : null
|
|
1739
|
+
] }) : null,
|
|
1740
|
+
b != null && b.isBlocked ? /* @__PURE__ */ p("div", { className: "rounded-lg bg-red/10 p-3 text-xs leading-5 text-red", children: [
|
|
1741
|
+
/* @__PURE__ */ p("p", { children: [
|
|
1742
|
+
"This limit price is worse than the market price by",
|
|
1743
|
+
" ",
|
|
1744
|
+
b.displayPriceDiffPercent,
|
|
1745
|
+
"% and cannot be placed."
|
|
1746
|
+
] }),
|
|
1747
|
+
/* @__PURE__ */ p("p", { className: "mt-1 text-muted-foreground", children: [
|
|
1748
|
+
b.isReversed ? `Sell ${b.displaySellAmount} ${E(
|
|
1749
|
+
b.sellTokenSymbol,
|
|
1750
|
+
V
|
|
1751
|
+
)}` : `Buy ${E(
|
|
1752
|
+
b.buyTokenSymbol,
|
|
1753
|
+
V
|
|
1754
|
+
)} with ${b.displaySellAmount} ${E(
|
|
1755
|
+
b.sellTokenSymbol,
|
|
1756
|
+
V
|
|
1757
|
+
)}`,
|
|
1758
|
+
" ",
|
|
1759
|
+
"when price goes ",
|
|
1760
|
+
b.marketPriceDirectionText,
|
|
1761
|
+
" ",
|
|
1762
|
+
b.displayLimitRate,
|
|
1763
|
+
" ",
|
|
1764
|
+
E(b.limitRateQuoteToken, V),
|
|
1765
|
+
"."
|
|
1766
|
+
] }),
|
|
1767
|
+
/* @__PURE__ */ p(
|
|
1768
|
+
"a",
|
|
1769
|
+
{
|
|
1770
|
+
href: b.swapHref,
|
|
1771
|
+
className: "mt-1 inline-flex items-center text-muted-foreground underline underline-offset-2 transition-colors hover:text-primary",
|
|
1772
|
+
children: [
|
|
1773
|
+
"Execute this trade via Swap",
|
|
1774
|
+
/* @__PURE__ */ i(Zt, { className: "size-3" })
|
|
1775
|
+
]
|
|
1776
|
+
}
|
|
1777
|
+
)
|
|
1778
|
+
] }) : null
|
|
1779
|
+
] });
|
|
1780
|
+
}
|
|
1781
|
+
const so = "Slippage tolerance exceeded";
|
|
1782
|
+
function ao({
|
|
1783
|
+
displayData: e,
|
|
1784
|
+
sellToken: t,
|
|
1785
|
+
buyToken: n,
|
|
1786
|
+
priceDifference: o,
|
|
1787
|
+
usdPriceMap: c,
|
|
1788
|
+
slippageExceeded: m
|
|
1789
|
+
}) {
|
|
1790
|
+
var v, w, S, b;
|
|
1791
|
+
const l = j((f) => f.customFee), d = Sr(l), h = Tr(e.slippage);
|
|
1792
|
+
return /* @__PURE__ */ p(Ue, { children: [
|
|
1793
|
+
/* @__PURE__ */ i(
|
|
1794
|
+
le,
|
|
1795
|
+
{
|
|
1796
|
+
label: "Slippage Tolerance",
|
|
1797
|
+
value: /* @__PURE__ */ i("span", { className: h, children: e.slippage })
|
|
1798
|
+
}
|
|
1799
|
+
),
|
|
1800
|
+
m ? /* @__PURE__ */ i(
|
|
1801
|
+
le,
|
|
1802
|
+
{
|
|
1803
|
+
label: "Slippage",
|
|
1804
|
+
value: /* @__PURE__ */ i("span", { className: "text-red", children: so })
|
|
1805
|
+
}
|
|
1806
|
+
) : null,
|
|
1807
|
+
/* @__PURE__ */ i(
|
|
1808
|
+
le,
|
|
1809
|
+
{
|
|
1810
|
+
label: "Minimum Received",
|
|
1811
|
+
value: eo(e.minimumReceived, n.symbol),
|
|
1812
|
+
labelTooltip: "You will receive at least this amount, or your transaction will revert."
|
|
1813
|
+
}
|
|
1814
|
+
),
|
|
1815
|
+
/* @__PURE__ */ i(
|
|
1816
|
+
Nr,
|
|
1817
|
+
{
|
|
1818
|
+
priceDifference: o,
|
|
1819
|
+
hasTooltip: !0,
|
|
1820
|
+
sellTokenSymbol: t.symbol,
|
|
1821
|
+
buyTokenSymbol: n.symbol,
|
|
1822
|
+
sellTokenPrice: (v = ke(c, t.address)) == null ? void 0 : v.value,
|
|
1823
|
+
buyTokenPrice: (w = ke(c, n.address)) == null ? void 0 : w.value,
|
|
1824
|
+
sellTokenMarket: (S = ke(c, t.address)) == null ? void 0 : S.market,
|
|
1825
|
+
buyTokenMarket: (b = ke(c, n.address)) == null ? void 0 : b.market
|
|
1826
|
+
}
|
|
1827
|
+
),
|
|
1828
|
+
d ? /* @__PURE__ */ i(
|
|
1829
|
+
le,
|
|
1830
|
+
{
|
|
1831
|
+
label: "Custom Fee",
|
|
1832
|
+
value: d,
|
|
1833
|
+
labelTooltip: Ar
|
|
1834
|
+
}
|
|
1835
|
+
) : null
|
|
1836
|
+
] });
|
|
1837
|
+
}
|
|
1838
|
+
function gn({
|
|
1839
|
+
displayData: e,
|
|
1840
|
+
sellToken: t,
|
|
1841
|
+
buyToken: n,
|
|
1842
|
+
quoteLoading: o,
|
|
1843
|
+
isPricesLoading: c,
|
|
1844
|
+
quote: m,
|
|
1845
|
+
priceDifference: l,
|
|
1846
|
+
usdPriceMap: d,
|
|
1847
|
+
priceUpdated: h,
|
|
1848
|
+
slippageExceeded: v,
|
|
1849
|
+
highPriceDifference: w,
|
|
1850
|
+
marketPriceInfo: S,
|
|
1851
|
+
onAcceptPriceUpdate: b,
|
|
1852
|
+
onConfirm: f,
|
|
1853
|
+
isPending: s,
|
|
1854
|
+
isApproved: A,
|
|
1855
|
+
intent: u,
|
|
1856
|
+
presentation: C = "dialog",
|
|
1857
|
+
onBack: k,
|
|
1858
|
+
actionLabel: O = "Swap",
|
|
1859
|
+
needsWrap: a = !1,
|
|
1860
|
+
isApprovalLoading: _ = !1,
|
|
1861
|
+
isAvailableBalanceLoading: P = !1,
|
|
1862
|
+
hasAvailableBalanceError: I = !1,
|
|
1863
|
+
onLimitExpiryChange: B
|
|
1864
|
+
}) {
|
|
1865
|
+
const T = u === "limit" ? e.limitOrderDetails : void 0, r = u === "dca" ? e.dcaOrderDetails : void 0, ee = T == null ? void 0 : T.marketWarning, N = !T && _;
|
|
1866
|
+
if (r)
|
|
1867
|
+
return /* @__PURE__ */ i(
|
|
1868
|
+
to,
|
|
1869
|
+
{
|
|
1870
|
+
displayData: e,
|
|
1871
|
+
dcaOrderDetails: r,
|
|
1872
|
+
presentation: C,
|
|
1873
|
+
onBack: k,
|
|
1874
|
+
priceUpdated: h,
|
|
1875
|
+
isPending: s,
|
|
1876
|
+
isAvailableBalanceLoading: P,
|
|
1877
|
+
hasAvailableBalanceError: I,
|
|
1878
|
+
onConfirm: f
|
|
1879
|
+
}
|
|
1880
|
+
);
|
|
1881
|
+
const y = T ? a ? "Wrap BNB & Place Limit Order" : P ? "Checking Available Balance" : I ? "Insufficient Available Balance" : _ ? "Checking Allowance" : A ? "Place Limit Order" : "Approve and Place Limit Order" : w ? `${O} Anyway` : A ? `Confirm ${O}` : `Approve and Confirm ${O}`;
|
|
1882
|
+
return /* @__PURE__ */ p(Ue, { children: [
|
|
1883
|
+
/* @__PURE__ */ i(nt, { title: "Review your order", presentation: C, onBack: k }),
|
|
1884
|
+
/* @__PURE__ */ p("div", { children: [
|
|
1885
|
+
/* @__PURE__ */ i(
|
|
1886
|
+
dn,
|
|
1887
|
+
{
|
|
1888
|
+
...e.from,
|
|
1889
|
+
symbol: E(e.from.symbol, V)
|
|
1890
|
+
}
|
|
1891
|
+
),
|
|
1892
|
+
/* @__PURE__ */ i("div", { className: "flex justify-center", children: /* @__PURE__ */ i("div", { className: "flex h-7 w-7 items-center justify-center rounded-full border-4 border-card bg-card -mt-3 -mb-2", children: /* @__PURE__ */ i(mt, { icon: Pr, size: 14, className: "text-muted-foreground" }) }) }),
|
|
1893
|
+
/* @__PURE__ */ i(
|
|
1894
|
+
dn,
|
|
1895
|
+
{
|
|
1896
|
+
...e.to,
|
|
1897
|
+
symbol: E(e.to.symbol, V)
|
|
1898
|
+
}
|
|
1899
|
+
)
|
|
1900
|
+
] }),
|
|
1901
|
+
T ? null : /* @__PURE__ */ i(
|
|
1902
|
+
Ir,
|
|
1903
|
+
{
|
|
1904
|
+
sellToken: t,
|
|
1905
|
+
buyToken: n,
|
|
1906
|
+
rate: e.from.amount && e.to.amount ? Ce(e.to.amount).div(Ce(e.from.amount)).toString() : null,
|
|
1907
|
+
className: "rounded-lg bg-input px-4 py-2"
|
|
1908
|
+
}
|
|
1909
|
+
),
|
|
1910
|
+
/* @__PURE__ */ i("div", { className: "space-y-2 text-xs", children: T ? /* @__PURE__ */ i(
|
|
1911
|
+
oo,
|
|
1912
|
+
{
|
|
1913
|
+
displayData: e,
|
|
1914
|
+
limitOrderDetails: T,
|
|
1915
|
+
needsWrap: a,
|
|
1916
|
+
hasAvailableBalanceError: I,
|
|
1917
|
+
onLimitExpiryChange: B
|
|
1918
|
+
}
|
|
1919
|
+
) : /* @__PURE__ */ i(
|
|
1920
|
+
ao,
|
|
1921
|
+
{
|
|
1922
|
+
displayData: e,
|
|
1923
|
+
sellToken: t,
|
|
1924
|
+
buyToken: n,
|
|
1925
|
+
priceDifference: l,
|
|
1926
|
+
usdPriceMap: d,
|
|
1927
|
+
slippageExceeded: v
|
|
1928
|
+
}
|
|
1929
|
+
) }),
|
|
1930
|
+
h ? /* @__PURE__ */ p("div", { className: "flex items-center border border-border gap-2 rounded-lg pl-4 pr-2 py-2 text-xs", children: [
|
|
1931
|
+
/* @__PURE__ */ i("span", { children: "Price Updated" }),
|
|
1932
|
+
/* @__PURE__ */ i(
|
|
1933
|
+
Oe,
|
|
1934
|
+
{
|
|
1935
|
+
className: "ml-auto h-8 px-7 font-medium rounded-full",
|
|
1936
|
+
onClick: b,
|
|
1937
|
+
children: "Accept"
|
|
1938
|
+
}
|
|
1939
|
+
)
|
|
1940
|
+
] }) : null,
|
|
1941
|
+
w ? /* @__PURE__ */ p("div", { className: "bg-red/10 rounded-lg p-2", children: [
|
|
1942
|
+
/* @__PURE__ */ p("div", { className: "flex gap-2 items-center", children: [
|
|
1943
|
+
/* @__PURE__ */ i(mt, { icon: _r, size: 16, className: "text-red" }),
|
|
1944
|
+
/* @__PURE__ */ i("span", { className: "text-xs leading-5 text-red", children: "High price difference" })
|
|
1945
|
+
] }),
|
|
1946
|
+
/* @__PURE__ */ p("div", { className: "text-xs leading-5 text-muted-foreground", children: [
|
|
1947
|
+
/* @__PURE__ */ i("p", { children: "The exchange rate of this order deviates from the market price by a large percentage." }),
|
|
1948
|
+
/* @__PURE__ */ p("p", { children: [
|
|
1949
|
+
"Current market price: 1 ",
|
|
1950
|
+
E(t.symbol, V),
|
|
1951
|
+
" =",
|
|
1952
|
+
" ",
|
|
1953
|
+
dt(S.marketPrice.toString(), { maximumFractionDigits: 6 }),
|
|
1954
|
+
" ",
|
|
1955
|
+
E(n.symbol, V)
|
|
1956
|
+
] }),
|
|
1957
|
+
/* @__PURE__ */ p("p", { children: [
|
|
1958
|
+
"Your order price: 1 ",
|
|
1959
|
+
E(t.symbol, V),
|
|
1960
|
+
" =",
|
|
1961
|
+
" ",
|
|
1962
|
+
dt(S.expectedPrice.toString(), { maximumFractionDigits: 6 }),
|
|
1963
|
+
" ",
|
|
1964
|
+
E(n.symbol, V)
|
|
1965
|
+
] }),
|
|
1966
|
+
/* @__PURE__ */ i("p", { children: "This may result in unfavorable exchange rates." })
|
|
1967
|
+
] })
|
|
1968
|
+
] }) : null,
|
|
1969
|
+
/* @__PURE__ */ i(Sn, { children: /* @__PURE__ */ i(
|
|
1970
|
+
Oe,
|
|
1971
|
+
{
|
|
1972
|
+
className: "min-w-55 max-w-full rounded-full px-6 font-medium text-sm",
|
|
1973
|
+
disabled: h || s || N || !!(ee != null && ee.isBlocked) || !!(T && (I || P || _ && !a)),
|
|
1974
|
+
"aria-label": N ? "Checking approval" : void 0,
|
|
1975
|
+
onClick: f,
|
|
1976
|
+
children: N ? /* @__PURE__ */ i(bn, { className: "size-4" }) : y
|
|
1977
|
+
}
|
|
1978
|
+
) })
|
|
1979
|
+
] });
|
|
1980
|
+
}
|
|
1981
|
+
function co({
|
|
1982
|
+
sellToken: e,
|
|
1983
|
+
buyToken: t,
|
|
1984
|
+
displayData: n,
|
|
1985
|
+
quoteToUse: o,
|
|
1986
|
+
refetchAllowance: c,
|
|
1987
|
+
refetchBalances: m,
|
|
1988
|
+
refreshSwapOrders: l,
|
|
1989
|
+
onEvent: d,
|
|
1990
|
+
transactionExplorerBaseUrl: h,
|
|
1991
|
+
showTransactionResultToasts: v = !0,
|
|
1992
|
+
chainId: w
|
|
1993
|
+
}) {
|
|
1994
|
+
var Pe;
|
|
1995
|
+
const {
|
|
1996
|
+
isPending: S,
|
|
1997
|
+
setIsPending: b,
|
|
1998
|
+
waitingCompleteTx: f,
|
|
1999
|
+
setWaitingCompleteTx: s,
|
|
2000
|
+
transactionStep: A,
|
|
2001
|
+
setTransactionStep: u,
|
|
2002
|
+
needsApproval: C,
|
|
2003
|
+
setNeedsApproval: k,
|
|
2004
|
+
needsTokenApproval: O,
|
|
2005
|
+
setNeedsTokenApproval: a,
|
|
2006
|
+
showTokenApprovalStep: _,
|
|
2007
|
+
setShowTokenApprovalStep: P,
|
|
2008
|
+
needsPermit2Signature: I,
|
|
2009
|
+
setNeedsPermit2Signature: B,
|
|
2010
|
+
isPreparing: T,
|
|
2011
|
+
setIsPreparing: r,
|
|
2012
|
+
slippageExceeded: ee,
|
|
2013
|
+
setSlippageExceeded: N,
|
|
2014
|
+
showErrorDetails: y,
|
|
2015
|
+
setShowErrorDetails: K,
|
|
2016
|
+
isTransitioning: xe,
|
|
2017
|
+
startTransition: U,
|
|
2018
|
+
resetExecutionState: te
|
|
2019
|
+
} = Ri(), { address: q, connector: fe } = tt(), de = An(), { data: oe } = Pn(), { mutateAsync: W } = Jr(), { mutateAsync: x } = Zr(), { aggregatorPeachClient: H, baseUrl: ne } = ht(), { overrides: ce } = Er() || {}, Q = j((F) => F.closeConfirm), J = j((F) => F.closeComplete), pe = j((F) => F.clearAmounts), ae = j((F) => F.openComplete), ge = j((F) => F.slippage), L = j((F) => F.MEVProtectEnabled), be = ((Pe = e == null ? void 0 : e.address) == null ? void 0 : Pe.toLowerCase()) === Ee.toLowerCase(), re = ue(
|
|
2020
|
+
(F) => {
|
|
2021
|
+
d == null || d(F);
|
|
2022
|
+
},
|
|
2023
|
+
[d]
|
|
2024
|
+
), Se = ue(() => {
|
|
2025
|
+
te();
|
|
2026
|
+
}, [te]), Te = ue(
|
|
2027
|
+
(F, z) => {
|
|
2028
|
+
ct(F, "swap-execution"), console.error("Transaction failed", F), U(() => {
|
|
2029
|
+
b(!1), r(!1);
|
|
2030
|
+
});
|
|
2031
|
+
const X = wn(F)[0] || "Unknown error", Y = X.includes("User rejected the request") || X.includes("user rejected action"), Ie = Y ? "User rejected the request" : "";
|
|
2032
|
+
if (Cr(F)) {
|
|
2033
|
+
U(() => {
|
|
2034
|
+
N(!0);
|
|
2035
|
+
}), Q(), J(), M.error("Slippage tolerance exceeded"), re({
|
|
2036
|
+
type: "swap_failed",
|
|
2037
|
+
payload: {
|
|
2038
|
+
message: "Slippage tolerance exceeded",
|
|
2039
|
+
txHash: z
|
|
2040
|
+
}
|
|
2041
|
+
});
|
|
2042
|
+
return;
|
|
2043
|
+
}
|
|
2044
|
+
const we = !Y;
|
|
2045
|
+
we ? (ae({
|
|
2046
|
+
result: "failed",
|
|
2047
|
+
data: {
|
|
2048
|
+
inputAmount: (n == null ? void 0 : n.from.amount) || "0",
|
|
2049
|
+
inputSymbol: (n == null ? void 0 : n.from.symbol) || "",
|
|
2050
|
+
outputAmount: (n == null ? void 0 : n.to.amount) || "0",
|
|
2051
|
+
outputSymbol: (n == null ? void 0 : n.to.symbol) || "",
|
|
2052
|
+
txHash: tn(F, z),
|
|
2053
|
+
error: X
|
|
2054
|
+
}
|
|
2055
|
+
}), re({
|
|
2056
|
+
type: "swap_failed",
|
|
2057
|
+
payload: {
|
|
2058
|
+
message: X,
|
|
2059
|
+
txHash: z
|
|
2060
|
+
}
|
|
2061
|
+
})) : (Q(), J(), U(() => {
|
|
2062
|
+
N(!1), K(!1);
|
|
2063
|
+
}), re({
|
|
2064
|
+
type: "swap_failed",
|
|
2065
|
+
payload: {
|
|
2066
|
+
message: X,
|
|
2067
|
+
txHash: z
|
|
2068
|
+
}
|
|
2069
|
+
})), (v || !we) && M.error("Transaction failed", { description: Ie });
|
|
2070
|
+
},
|
|
2071
|
+
[
|
|
2072
|
+
J,
|
|
2073
|
+
Q,
|
|
2074
|
+
n,
|
|
2075
|
+
re,
|
|
2076
|
+
ae,
|
|
2077
|
+
v
|
|
2078
|
+
]
|
|
2079
|
+
), ye = ue(async () => {
|
|
2080
|
+
U(() => {
|
|
2081
|
+
N(!1);
|
|
2082
|
+
});
|
|
2083
|
+
const F = /* @__PURE__ */ i(
|
|
2084
|
+
lt,
|
|
2085
|
+
{
|
|
2086
|
+
from: {
|
|
2087
|
+
amount: me(
|
|
2088
|
+
(n == null ? void 0 : n.from.amount) || 0,
|
|
2089
|
+
(n == null ? void 0 : n.from.decimals) || 0,
|
|
2090
|
+
!0
|
|
2091
|
+
),
|
|
2092
|
+
symbol: E((n == null ? void 0 : n.from.symbol) || "", 9),
|
|
2093
|
+
icon: n == null ? void 0 : n.from.icon
|
|
2094
|
+
},
|
|
2095
|
+
to: {
|
|
2096
|
+
amount: me(
|
|
2097
|
+
(n == null ? void 0 : n.to.amount) || 0,
|
|
2098
|
+
(n == null ? void 0 : n.to.decimals) || 0,
|
|
2099
|
+
!0
|
|
2100
|
+
),
|
|
2101
|
+
symbol: E((n == null ? void 0 : n.to.symbol) || "", 9),
|
|
2102
|
+
icon: n == null ? void 0 : n.to.icon
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
);
|
|
2106
|
+
try {
|
|
2107
|
+
if (!q || !H || !de)
|
|
2108
|
+
throw new Error("Wallet not connected or client not ready");
|
|
2109
|
+
if (!o) throw new Error("No quote available");
|
|
2110
|
+
yr(o);
|
|
2111
|
+
const z = (o == null ? void 0 : o.srcNative) === !0 || be;
|
|
2112
|
+
r(!0), k(!1), a(!1), P(!1), B(!1), u(1), b(!0), s("");
|
|
2113
|
+
let X, Y;
|
|
2114
|
+
const Ie = (n == null ? void 0 : n.executionSlippageBps) ?? Br(ge);
|
|
2115
|
+
let we;
|
|
2116
|
+
try {
|
|
2117
|
+
const { receipt: Z } = await Li({
|
|
2118
|
+
aggregatorClient: H,
|
|
2119
|
+
quote: o,
|
|
2120
|
+
ownerAddress: q,
|
|
2121
|
+
sellTokenAddress: e == null ? void 0 : e.address,
|
|
2122
|
+
buyTokenAddress: t == null ? void 0 : t.address,
|
|
2123
|
+
publicClient: de,
|
|
2124
|
+
walletClient: oe,
|
|
2125
|
+
sendTransaction: W,
|
|
2126
|
+
sendCallsSync: x,
|
|
2127
|
+
getWalletCapabilities: () => Mi(fe, q),
|
|
2128
|
+
refetchAllowance: c,
|
|
2129
|
+
slippageBps: Ie,
|
|
2130
|
+
overrides: ce,
|
|
2131
|
+
isNativeInput: z,
|
|
2132
|
+
chainId: w,
|
|
2133
|
+
mevProtect: {
|
|
2134
|
+
enabled: L,
|
|
2135
|
+
baseUrl: ne
|
|
2136
|
+
},
|
|
2137
|
+
callbacks: {
|
|
2138
|
+
onPreparedActions: ($, se) => {
|
|
2139
|
+
const rt = $.needsTokenApproval || $.needsPermit2Signature;
|
|
2140
|
+
k(rt), a($.needsTokenApproval), P($.showTokenApproval), B($.needsPermit2Signature), r(!1), u(
|
|
2141
|
+
$.needsTokenApproval ? se.approvalStep ?? se.confirmStep : $.needsPermit2Signature ? se.signatureStep ?? se.confirmStep : se.confirmStep
|
|
2142
|
+
);
|
|
2143
|
+
},
|
|
2144
|
+
onApprovalRequested: () => {
|
|
2145
|
+
e && (Y = M.loading(`Approving ${E(e.symbol, 9)} to Permit2`, {
|
|
2146
|
+
description: "Confirm the Permit2 approval in your wallet"
|
|
2147
|
+
}), re({
|
|
2148
|
+
type: "approval_requested",
|
|
2149
|
+
payload: {
|
|
2150
|
+
tokenAddress: e.address,
|
|
2151
|
+
symbol: e.symbol
|
|
2152
|
+
}
|
|
2153
|
+
}));
|
|
2154
|
+
},
|
|
2155
|
+
onApprovalSettled: () => {
|
|
2156
|
+
M.dismiss(Y);
|
|
2157
|
+
},
|
|
2158
|
+
onApprovalConfirmed: ({ txHash: $ }) => {
|
|
2159
|
+
e && (M.success(`${E(e.symbol, 9)} approved for Permit2`), re({
|
|
2160
|
+
type: "approval_confirmed",
|
|
2161
|
+
payload: {
|
|
2162
|
+
tokenAddress: e.address,
|
|
2163
|
+
symbol: e.symbol,
|
|
2164
|
+
txHash: $
|
|
2165
|
+
}
|
|
2166
|
+
}));
|
|
2167
|
+
},
|
|
2168
|
+
onSignatureRequested: ($) => {
|
|
2169
|
+
u($), Y = M.loading("Pending Wallet Signature", {
|
|
2170
|
+
description: /* @__PURE__ */ p("div", { children: [
|
|
2171
|
+
"Sign in wallet to proceed",
|
|
2172
|
+
/* @__PURE__ */ i(
|
|
2173
|
+
"button",
|
|
2174
|
+
{
|
|
2175
|
+
className: "absolute right-4 top-4 hover:text-foreground cursor-pointer",
|
|
2176
|
+
onClick: () => M.dismiss(Y),
|
|
2177
|
+
children: /* @__PURE__ */ i(Dt, { className: "size-4" })
|
|
2178
|
+
}
|
|
2179
|
+
)
|
|
2180
|
+
] })
|
|
2181
|
+
});
|
|
2182
|
+
},
|
|
2183
|
+
onSignatureSettled: () => {
|
|
2184
|
+
M.dismiss(Y);
|
|
2185
|
+
},
|
|
2186
|
+
onWalletConfirmationRequested: ($) => {
|
|
2187
|
+
u($), Y = M.loading("Pending Wallet Confirmation", {
|
|
2188
|
+
description: /* @__PURE__ */ p("div", { children: [
|
|
2189
|
+
"Confirm Transaction in Wallet",
|
|
2190
|
+
/* @__PURE__ */ i(
|
|
2191
|
+
"button",
|
|
2192
|
+
{
|
|
2193
|
+
className: "absolute right-4 top-4 hover:text-foreground cursor-pointer",
|
|
2194
|
+
onClick: () => M.dismiss(Y),
|
|
2195
|
+
children: /* @__PURE__ */ i(Dt, { className: "size-4" })
|
|
2196
|
+
}
|
|
2197
|
+
)
|
|
2198
|
+
] })
|
|
2199
|
+
});
|
|
2200
|
+
},
|
|
2201
|
+
onSubmitted: ({ txHash: $, step: se }) => {
|
|
2202
|
+
we = $, s($), u(se), M.dismiss(Y), re({
|
|
2203
|
+
type: "swap_submitted",
|
|
2204
|
+
payload: { txHash: $ }
|
|
2205
|
+
}), X = Rr(
|
|
2206
|
+
we,
|
|
2207
|
+
F,
|
|
2208
|
+
h
|
|
2209
|
+
);
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
});
|
|
2213
|
+
X && M.dismiss(X), Q(), b(!1), pe(), m(), l();
|
|
2214
|
+
let Fe = (n == null ? void 0 : n.to.amount) || "0";
|
|
2215
|
+
if (Z && t && q)
|
|
2216
|
+
try {
|
|
2217
|
+
const $ = Xr({
|
|
2218
|
+
abi: [
|
|
2219
|
+
{
|
|
2220
|
+
anonymous: !1,
|
|
2221
|
+
inputs: [
|
|
2222
|
+
{ indexed: !0, name: "sender", type: "address" },
|
|
2223
|
+
{ indexed: !0, name: "quoteId", type: "bytes32" },
|
|
2224
|
+
{ indexed: !0, name: "fromToken", type: "address" },
|
|
2225
|
+
{ indexed: !1, name: "targetToken", type: "address" },
|
|
2226
|
+
{ indexed: !1, name: "amountIn", type: "uint256" },
|
|
2227
|
+
{ indexed: !1, name: "amountOut", type: "uint256" },
|
|
2228
|
+
{ indexed: !1, name: "expectAmountOut", type: "uint256" },
|
|
2229
|
+
{ indexed: !1, name: "amountOutLimit", type: "uint256" }
|
|
2230
|
+
],
|
|
2231
|
+
name: "ConfirmedSwapEvent",
|
|
2232
|
+
type: "event"
|
|
2233
|
+
}
|
|
2234
|
+
],
|
|
2235
|
+
eventName: "ConfirmedSwapEvent",
|
|
2236
|
+
logs: Z.logs
|
|
2237
|
+
});
|
|
2238
|
+
if ($.length > 0) {
|
|
2239
|
+
const se = $[$.length - 1];
|
|
2240
|
+
se != null && se.args.amountOut && (Fe = et(se.args.amountOut, t.decimals));
|
|
2241
|
+
}
|
|
2242
|
+
} catch ($) {
|
|
2243
|
+
console.error("Failed to parse actual output amount", $);
|
|
2244
|
+
}
|
|
2245
|
+
if (ae({
|
|
2246
|
+
result: "success",
|
|
2247
|
+
data: {
|
|
2248
|
+
inputAmount: (n == null ? void 0 : n.from.amount) || "0",
|
|
2249
|
+
inputSymbol: (n == null ? void 0 : n.from.symbol) || "",
|
|
2250
|
+
outputAmount: Fe,
|
|
2251
|
+
outputSymbol: (n == null ? void 0 : n.to.symbol) || "",
|
|
2252
|
+
sellToken: e ?? void 0,
|
|
2253
|
+
buyToken: t ?? void 0,
|
|
2254
|
+
txHash: Z == null ? void 0 : Z.transactionHash
|
|
2255
|
+
}
|
|
2256
|
+
}), Z != null && Z.transactionHash) {
|
|
2257
|
+
const $ = /* @__PURE__ */ i(
|
|
2258
|
+
lt,
|
|
2259
|
+
{
|
|
2260
|
+
from: {
|
|
2261
|
+
amount: me(
|
|
2262
|
+
(n == null ? void 0 : n.from.amount) || 0,
|
|
2263
|
+
(n == null ? void 0 : n.from.decimals) || 0,
|
|
2264
|
+
!0
|
|
2265
|
+
),
|
|
2266
|
+
symbol: E((n == null ? void 0 : n.from.symbol) || "", 9),
|
|
2267
|
+
icon: n == null ? void 0 : n.from.icon
|
|
2268
|
+
},
|
|
2269
|
+
to: {
|
|
2270
|
+
amount: me(Fe, (t == null ? void 0 : t.decimals) || 0, !0),
|
|
2271
|
+
symbol: E((n == null ? void 0 : n.to.symbol) || "", 9),
|
|
2272
|
+
icon: n == null ? void 0 : n.to.icon
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
);
|
|
2276
|
+
v && Lr(
|
|
2277
|
+
Z.transactionHash,
|
|
2278
|
+
$,
|
|
2279
|
+
void 0,
|
|
2280
|
+
h
|
|
2281
|
+
), re({
|
|
2282
|
+
type: "swap_confirmed",
|
|
2283
|
+
payload: { txHash: Z.transactionHash }
|
|
2284
|
+
});
|
|
2285
|
+
}
|
|
2286
|
+
} catch (Z) {
|
|
2287
|
+
throw M.dismiss(Y), X && M.dismiss(X), Z.txHash = tn(Z, we), Z;
|
|
2288
|
+
}
|
|
2289
|
+
} catch (z) {
|
|
2290
|
+
Te(z, z.txHash);
|
|
2291
|
+
}
|
|
2292
|
+
}, [
|
|
2293
|
+
H,
|
|
2294
|
+
pe,
|
|
2295
|
+
Q,
|
|
2296
|
+
n,
|
|
2297
|
+
re,
|
|
2298
|
+
Te,
|
|
2299
|
+
ae,
|
|
2300
|
+
ce,
|
|
2301
|
+
q,
|
|
2302
|
+
de,
|
|
2303
|
+
o,
|
|
2304
|
+
c,
|
|
2305
|
+
m,
|
|
2306
|
+
l,
|
|
2307
|
+
w,
|
|
2308
|
+
e,
|
|
2309
|
+
t,
|
|
2310
|
+
fe,
|
|
2311
|
+
x,
|
|
2312
|
+
W,
|
|
2313
|
+
ge,
|
|
2314
|
+
L,
|
|
2315
|
+
be,
|
|
2316
|
+
h,
|
|
2317
|
+
v,
|
|
2318
|
+
oe
|
|
2319
|
+
]);
|
|
2320
|
+
return {
|
|
2321
|
+
isPending: S,
|
|
2322
|
+
waitingCompleteTx: f,
|
|
2323
|
+
transactionStep: A,
|
|
2324
|
+
needsApproval: C,
|
|
2325
|
+
needsTokenApproval: O,
|
|
2326
|
+
showTokenApprovalStep: _,
|
|
2327
|
+
needsPermit2Signature: I,
|
|
2328
|
+
isPreparing: T,
|
|
2329
|
+
slippageExceeded: ee,
|
|
2330
|
+
showErrorDetails: y,
|
|
2331
|
+
setShowErrorDetails: K,
|
|
2332
|
+
setSlippageExceeded: N,
|
|
2333
|
+
setIsPending: b,
|
|
2334
|
+
executeSwap: ye,
|
|
2335
|
+
resetExecutionState: Se,
|
|
2336
|
+
isTransitioning: xe
|
|
2337
|
+
};
|
|
2338
|
+
}
|
|
2339
|
+
function hn(e, t, n, o, c, m) {
|
|
2340
|
+
const l = en(t.amountOut, c.decimals), d = m(l, c) ?? "-", h = Mr(e.from.amount, l, o.symbol, c.symbol), v = kr(e.slippage.replace("%", "").toLowerCase()), w = Or(t.amountOut, v / 100), S = en(w, c.decimals, 9, !0) + " " + E(c.symbol, 9);
|
|
2341
|
+
return {
|
|
2342
|
+
...e,
|
|
2343
|
+
to: {
|
|
2344
|
+
...e.to,
|
|
2345
|
+
amount: et(Je(t.amountOut, 0), c.decimals),
|
|
2346
|
+
usdValue: `$${d}`
|
|
2347
|
+
},
|
|
2348
|
+
rate: h,
|
|
2349
|
+
minimumReceived: S,
|
|
2350
|
+
rawQuote: n ?? e.rawQuote
|
|
2351
|
+
};
|
|
2352
|
+
}
|
|
2353
|
+
function wo({
|
|
2354
|
+
chainId: e = Number(process.env.NEXT_PUBLIC_CHAIN_ID) || 56,
|
|
2355
|
+
onEvent: t,
|
|
2356
|
+
onDialogViewChange: n,
|
|
2357
|
+
transactionExplorerBaseUrl: o,
|
|
2358
|
+
dialogContentClassName: c,
|
|
2359
|
+
presentation: m = "dialog",
|
|
2360
|
+
actionLabel: l = "Swap",
|
|
2361
|
+
showTransactionResultToasts: d = !0
|
|
2362
|
+
} = {}) {
|
|
2363
|
+
var jt, Vt, Qt, zt, Xt, Yt, Gt, Kt, qt;
|
|
2364
|
+
const [h, v] = R(!1), [w, S] = R(!1), [, b] = gt(), f = j((g) => g.confirmOpen), s = j((g) => g.confirmIntent), A = j((g) => g.confirmData), u = j((g) => g.closeConfirm), C = j((g) => g.completeOpen), k = j((g) => g.completeData), O = j((g) => g.completeResult), a = j((g) => g.closeComplete), _ = j((g) => g.setExternalQuote), P = j((g) => g.setBuyAmount), { refetchBalances: I, refreshSwapOrders: B } = Ur({
|
|
2365
|
+
disableAutoBuyAmount: !0,
|
|
2366
|
+
disableQuote: !0
|
|
2367
|
+
}), T = s === "swap" || s === "quickSwap", [r, ee] = R(A);
|
|
2368
|
+
Ae(() => {
|
|
2369
|
+
A && ee(A);
|
|
2370
|
+
}, [A]);
|
|
2371
|
+
const N = G(() => r ? {
|
|
2372
|
+
address: r.from.address,
|
|
2373
|
+
decimals: r.from.decimals,
|
|
2374
|
+
symbol: r.from.symbol,
|
|
2375
|
+
chainId: e,
|
|
2376
|
+
name: r.from.symbol,
|
|
2377
|
+
logoURI: r.from.icon
|
|
2378
|
+
} : null, [
|
|
2379
|
+
e,
|
|
2380
|
+
r == null ? void 0 : r.from.address,
|
|
2381
|
+
r == null ? void 0 : r.from.decimals,
|
|
2382
|
+
r == null ? void 0 : r.from.icon,
|
|
2383
|
+
r == null ? void 0 : r.from.symbol
|
|
2384
|
+
]), y = G(() => r ? {
|
|
2385
|
+
address: r.to.address,
|
|
2386
|
+
decimals: r.to.decimals,
|
|
2387
|
+
symbol: r.to.symbol,
|
|
2388
|
+
chainId: e,
|
|
2389
|
+
name: r.to.symbol,
|
|
2390
|
+
logoURI: r.to.icon
|
|
2391
|
+
} : null, [
|
|
2392
|
+
e,
|
|
2393
|
+
r == null ? void 0 : r.to.address,
|
|
2394
|
+
r == null ? void 0 : r.to.decimals,
|
|
2395
|
+
r == null ? void 0 : r.to.icon,
|
|
2396
|
+
r == null ? void 0 : r.to.symbol
|
|
2397
|
+
]), [K, xe] = R(!1), {
|
|
2398
|
+
quote: U,
|
|
2399
|
+
rawQuote: te,
|
|
2400
|
+
loading: q,
|
|
2401
|
+
clearQuote: fe
|
|
2402
|
+
} = Fr({
|
|
2403
|
+
sellToken: N,
|
|
2404
|
+
buyToken: y,
|
|
2405
|
+
sellAmount: (r == null ? void 0 : r.from.amount) ?? "0",
|
|
2406
|
+
enabled: f && s === "swap" && !!r && !r.skipReview && !K,
|
|
2407
|
+
refreshInterval: 5e3
|
|
2408
|
+
}), { calculateUsdValue: de, usdPriceMap: oe, isPricesLoading: W } = $r(N, y), { estimatedGasFee: x, estimatedGasFeeUsd: H } = Wr(U == null ? void 0 : U.gas, oe), ne = Bi({
|
|
2409
|
+
owner: ((jt = r == null ? void 0 : r.limitIntentDraft) == null ? void 0 : jt.owner) ?? ((Vt = r == null ? void 0 : r.dcaOrderDetails) == null ? void 0 : Vt.owner),
|
|
2410
|
+
token: r == null ? void 0 : r.from.address,
|
|
2411
|
+
enabled: f && (s === "limit" || s === "dca")
|
|
2412
|
+
}), ce = Hr({
|
|
2413
|
+
tokenAddress: (r == null ? void 0 : r.from.address) ?? Ee,
|
|
2414
|
+
enabled: f && (s === "limit" || s === "dca") && !!(r != null && r.from.address)
|
|
2415
|
+
}), Q = G(
|
|
2416
|
+
() => Pi({
|
|
2417
|
+
requestedToken: r == null ? void 0 : r.from.address,
|
|
2418
|
+
response: ne.data
|
|
2419
|
+
}),
|
|
2420
|
+
[r == null ? void 0 : r.from.address, ne.data]
|
|
2421
|
+
), J = G(
|
|
2422
|
+
() => Ii(ce.data.value, Q),
|
|
2423
|
+
[Q, ce.data.value]
|
|
2424
|
+
), pe = G(() => {
|
|
2425
|
+
if (J !== void 0)
|
|
2426
|
+
return et(J, (r == null ? void 0 : r.from.decimals) ?? 18);
|
|
2427
|
+
}, [r == null ? void 0 : r.from.decimals, J]), ae = G(
|
|
2428
|
+
() => {
|
|
2429
|
+
var g, D;
|
|
2430
|
+
return (s === "limit" || s === "dca") && _i({
|
|
2431
|
+
amount: ((g = r == null ? void 0 : r.limitIntentDraft) == null ? void 0 : g.sellAmountRaw) ?? ((D = r == null ? void 0 : r.dcaOrderDetails) == null ? void 0 : D.sellTotalRaw),
|
|
2432
|
+
walletBalance: ce.data.value,
|
|
2433
|
+
availableBalance: J,
|
|
2434
|
+
reservedAmount: Q
|
|
2435
|
+
});
|
|
2436
|
+
},
|
|
2437
|
+
[
|
|
2438
|
+
s,
|
|
2439
|
+
(Qt = r == null ? void 0 : r.dcaOrderDetails) == null ? void 0 : Qt.sellTotalRaw,
|
|
2440
|
+
(zt = r == null ? void 0 : r.limitIntentDraft) == null ? void 0 : zt.sellAmountRaw,
|
|
2441
|
+
J,
|
|
2442
|
+
Q,
|
|
2443
|
+
ce.data.value
|
|
2444
|
+
]
|
|
2445
|
+
), ge = (s === "limit" || s === "dca") && f && (ne.isLoading && !ne.data || ce.isLoading), L = G(() => {
|
|
2446
|
+
var D, ie;
|
|
2447
|
+
if (!r) return null;
|
|
2448
|
+
const g = s === "quickSwap" || !U || !te || !y || !N ? r : hn(
|
|
2449
|
+
r,
|
|
2450
|
+
U,
|
|
2451
|
+
te,
|
|
2452
|
+
N,
|
|
2453
|
+
y,
|
|
2454
|
+
de
|
|
2455
|
+
);
|
|
2456
|
+
return s === "limit" && g.limitOrderDetails ? {
|
|
2457
|
+
...g,
|
|
2458
|
+
limitOrderDetails: {
|
|
2459
|
+
...g.limitOrderDetails,
|
|
2460
|
+
availableBalance: {
|
|
2461
|
+
availableAmount: pe ?? ((D = g.limitOrderDetails.availableBalance) == null ? void 0 : D.availableAmount) ?? "0",
|
|
2462
|
+
reservedAmountRaw: Q
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
} : s === "dca" && g.dcaOrderDetails ? {
|
|
2466
|
+
...g,
|
|
2467
|
+
dcaOrderDetails: {
|
|
2468
|
+
...g.dcaOrderDetails,
|
|
2469
|
+
availableBalance: {
|
|
2470
|
+
availableAmount: pe ?? ((ie = g.dcaOrderDetails.availableBalance) == null ? void 0 : ie.availableAmount) ?? "0",
|
|
2471
|
+
reservedAmountRaw: Q
|
|
2472
|
+
}
|
|
2473
|
+
}
|
|
2474
|
+
} : g;
|
|
2475
|
+
}, [
|
|
2476
|
+
y,
|
|
2477
|
+
de,
|
|
2478
|
+
s,
|
|
2479
|
+
r,
|
|
2480
|
+
pe,
|
|
2481
|
+
Q,
|
|
2482
|
+
te,
|
|
2483
|
+
U,
|
|
2484
|
+
N
|
|
2485
|
+
]), be = G(() => {
|
|
2486
|
+
if (!(r != null && r.from.amount) || !N) return BigInt(0);
|
|
2487
|
+
try {
|
|
2488
|
+
return Je(r.from.amount, N.decimals);
|
|
2489
|
+
} catch {
|
|
2490
|
+
return BigInt(0);
|
|
2491
|
+
}
|
|
2492
|
+
}, [r == null ? void 0 : r.from.amount, N]), re = G(
|
|
2493
|
+
() => s === "quickSwap" || r != null && r.skipReview ? r == null ? void 0 : r.rawQuote : te ?? (r == null ? void 0 : r.rawQuote),
|
|
2494
|
+
[s, r == null ? void 0 : r.rawQuote, r == null ? void 0 : r.skipReview, te]
|
|
2495
|
+
), Se = G(() => {
|
|
2496
|
+
if (T)
|
|
2497
|
+
return jr(L ?? r, re);
|
|
2498
|
+
}, [r, T, re, L]), Te = G(() => {
|
|
2499
|
+
var Jt;
|
|
2500
|
+
if (T)
|
|
2501
|
+
return Math.floor(Date.now() / 1e3) + mi;
|
|
2502
|
+
const g = (Jt = r == null ? void 0 : r.limitIntentDraft) == null ? void 0 : Jt.expirySeconds;
|
|
2503
|
+
if (s !== "limit" || g === void 0) return;
|
|
2504
|
+
const D = Math.floor(Date.now() / 1e3), ie = D + bt, Ge = D + g + Cn, Ke = D + yn;
|
|
2505
|
+
return Math.min(Math.max(Ge, ie), Ke);
|
|
2506
|
+
}, [s, (Xt = r == null ? void 0 : r.limitIntentDraft) == null ? void 0 : Xt.expirySeconds, T]), {
|
|
2507
|
+
isApproved: ye,
|
|
2508
|
+
isLoading: Pe,
|
|
2509
|
+
refetch: F
|
|
2510
|
+
} = Ei({
|
|
2511
|
+
tokenAddress: s === "limit" ? (Yt = r == null ? void 0 : r.limitIntentDraft) == null ? void 0 : Yt.intentSellToken : N == null ? void 0 : N.address,
|
|
2512
|
+
spenderAddress: s === "limit" || s === "swap" || s === "quickSwap" ? Ze : (Kt = (Gt = L ?? r) == null ? void 0 : Gt.rawQuote) == null ? void 0 : Kt.routerAddress,
|
|
2513
|
+
enabled: f && s !== "dca" && !!r
|
|
2514
|
+
}), {
|
|
2515
|
+
isApproved: z,
|
|
2516
|
+
isLoading: X,
|
|
2517
|
+
refetch: Y
|
|
2518
|
+
} = yi({
|
|
2519
|
+
tokenAddress: s === "limit" ? (qt = r == null ? void 0 : r.limitIntentDraft) == null ? void 0 : qt.intentSellToken : N == null ? void 0 : N.address,
|
|
2520
|
+
spenderAddress: s === "limit" ? xt : Se,
|
|
2521
|
+
enabled: f && (s === "limit" && !!(r != null && r.limitIntentDraft) || (s === "swap" || s === "quickSwap") && !!r && !!Se)
|
|
2522
|
+
}), Ie = ye(be), we = s === "limit" || T ? Te === void 0 ? z(be) : z(be, Te) : !0, Z = s === "dca" ? !0 : T ? Ie : Ie && we, Fe = ue(async () => {
|
|
2523
|
+
const g = await F();
|
|
2524
|
+
return T && Se && await Y(), g;
|
|
2525
|
+
}, [T, F, Y, Se]), {
|
|
2526
|
+
isPending: $,
|
|
2527
|
+
waitingCompleteTx: se,
|
|
2528
|
+
transactionStep: rt,
|
|
2529
|
+
needsApproval: kn,
|
|
2530
|
+
needsTokenApproval: On,
|
|
2531
|
+
showTokenApprovalStep: Un,
|
|
2532
|
+
needsPermit2Signature: Fn,
|
|
2533
|
+
isPreparing: $n,
|
|
2534
|
+
slippageExceeded: Tt,
|
|
2535
|
+
showErrorDetails: He,
|
|
2536
|
+
setShowErrorDetails: je,
|
|
2537
|
+
setSlippageExceeded: Nt,
|
|
2538
|
+
executeSwap: $e,
|
|
2539
|
+
resetExecutionState: Ve
|
|
2540
|
+
} = co({
|
|
2541
|
+
sellToken: N,
|
|
2542
|
+
buyToken: y,
|
|
2543
|
+
displayData: L ?? r,
|
|
2544
|
+
quoteToUse: re,
|
|
2545
|
+
refetchAllowance: Fe,
|
|
2546
|
+
refetchBalances: I,
|
|
2547
|
+
refreshSwapOrders: B,
|
|
2548
|
+
chainId: e,
|
|
2549
|
+
onEvent: t,
|
|
2550
|
+
transactionExplorerBaseUrl: o,
|
|
2551
|
+
showTransactionResultToasts: d
|
|
2552
|
+
}), {
|
|
2553
|
+
isPending: Wn,
|
|
2554
|
+
transactionStep: Hn,
|
|
2555
|
+
needsApproval: jn,
|
|
2556
|
+
needsTokenApproval: Vn,
|
|
2557
|
+
needsPermit2Approval: Qn,
|
|
2558
|
+
needsPermit2Signature: zn,
|
|
2559
|
+
needsWrap: Xn,
|
|
2560
|
+
showErrorDetails: Qe,
|
|
2561
|
+
setShowErrorDetails: ze,
|
|
2562
|
+
executeLimitIntent: Yn,
|
|
2563
|
+
resetExecutionState: Xe
|
|
2564
|
+
} = Hi({
|
|
2565
|
+
displayData: L ?? r,
|
|
2566
|
+
isTokenAllowanceApproved: Ie,
|
|
2567
|
+
isPermit2AllowanceApproved: we,
|
|
2568
|
+
refetchTokenAllowance: F,
|
|
2569
|
+
refetchPermit2Allowance: Y,
|
|
2570
|
+
refetchBalances: I,
|
|
2571
|
+
onEvent: t
|
|
2572
|
+
}), ve = s === "dca" ? !1 : s === "limit" ? Wn : $, Be = s === "limit" ? Hn : rt, At = s === "dca" ? !1 : s === "limit" ? jn : kn, Pt = s === "limit" ? Vn : On, It = s === "limit" ? Qn : void 0, _t = s === "limit" ? void 0 : Un, Et = s === "limit" ? zn : Fn, Ct = s === "limit" ? !1 : $n, yt = s === "limit" ? Xn : !1, Bt = s === "limit" ? Pe || X : T ? Pe : !1, Rt = G(() => {
|
|
2573
|
+
const g = r == null ? void 0 : r.limitIntentDraft;
|
|
2574
|
+
return s !== "limit" || !g ? !1 : g.sellToken.address.toLowerCase() === Ee.toLowerCase() && g.intentSellToken.toLowerCase() === vt.toLowerCase();
|
|
2575
|
+
}, [s, r == null ? void 0 : r.limitIntentDraft]);
|
|
2576
|
+
Ae(() => {
|
|
2577
|
+
xe(ve);
|
|
2578
|
+
}, [ve]), Ae(() => {
|
|
2579
|
+
C && (je(!1), ze(!1));
|
|
2580
|
+
}, [C, je, ze]), Ae(() => {
|
|
2581
|
+
!f && !C && (Nt(!1), v(!1), S(!1), Ve(), Xe(), ee(null), fe());
|
|
2582
|
+
}, [
|
|
2583
|
+
fe,
|
|
2584
|
+
C,
|
|
2585
|
+
f,
|
|
2586
|
+
Ve,
|
|
2587
|
+
Xe,
|
|
2588
|
+
Nt
|
|
2589
|
+
]), Ae(() => {
|
|
2590
|
+
f && s === "quickSwap" && !h && (r != null && r.rawQuote) && r === A && !ve && Be === 1 && (v(!0), $e());
|
|
2591
|
+
}, [
|
|
2592
|
+
A,
|
|
2593
|
+
s,
|
|
2594
|
+
f,
|
|
2595
|
+
r,
|
|
2596
|
+
$e,
|
|
2597
|
+
h,
|
|
2598
|
+
ve,
|
|
2599
|
+
Be
|
|
2600
|
+
]), Ae(() => {
|
|
2601
|
+
f && s === "swap" && (r != null && r.skipReview) && !w && (r != null && r.rawQuote) && r === A && !ve && Be === 1 && (S(!0), $e());
|
|
2602
|
+
}, [
|
|
2603
|
+
ve,
|
|
2604
|
+
Be,
|
|
2605
|
+
A,
|
|
2606
|
+
s,
|
|
2607
|
+
f,
|
|
2608
|
+
r,
|
|
2609
|
+
$e,
|
|
2610
|
+
w
|
|
2611
|
+
]);
|
|
2612
|
+
const Lt = G(() => {
|
|
2613
|
+
if (s === "quickSwap" || !r || !U || !y) return !1;
|
|
2614
|
+
try {
|
|
2615
|
+
return Je(U.amountOut, 0) !== Je(r.to.amount, y.decimals);
|
|
2616
|
+
} catch {
|
|
2617
|
+
return !1;
|
|
2618
|
+
}
|
|
2619
|
+
}, [y, s, r, U]), _e = G(() => {
|
|
2620
|
+
var Ge, Ke;
|
|
2621
|
+
const g = L;
|
|
2622
|
+
if (!g || !N || !y) return { marketPrice: 0, expectedPrice: 0 };
|
|
2623
|
+
const D = (Ge = ke(oe, N.address)) == null ? void 0 : Ge.value, ie = (Ke = ke(oe, y.address)) == null ? void 0 : Ke.value;
|
|
2624
|
+
return !D || !ie ? { marketPrice: 0, expectedPrice: 0 } : {
|
|
2625
|
+
marketPrice: D / ie,
|
|
2626
|
+
expectedPrice: Number(g.to.amount) / Number(g.from.amount)
|
|
2627
|
+
};
|
|
2628
|
+
}, [y, L, N, oe]), We = G(() => _e.marketPrice === 0 ? null : (_e.expectedPrice - _e.marketPrice) / _e.marketPrice * 100, [_e]), Mt = G(() => q || !U ? !1 : We !== null && We < -5, [We, U, q]), kt = o ?? Vr(e), Ot = ue(
|
|
2629
|
+
(g) => `${kt.replace(/\/$/, "")}/tx/${g}`,
|
|
2630
|
+
[kt]
|
|
2631
|
+
), Ut = ue(() => {
|
|
2632
|
+
u(), a(), Ve(), Xe();
|
|
2633
|
+
}, [a, u, Ve, Xe]), Gn = s === "swap" && !!(r != null && r.skipReview), Ye = f || C || ve, Ne = C ? "complete" : ve || Gn ? "pending" : "confirm";
|
|
2634
|
+
Zn(() => {
|
|
2635
|
+
if (!Ye) {
|
|
2636
|
+
n == null || n(null);
|
|
2637
|
+
return;
|
|
2638
|
+
}
|
|
2639
|
+
n == null || n(Ne);
|
|
2640
|
+
}, [Ne, Ye, n]);
|
|
2641
|
+
const Ft = ue((g, D) => {
|
|
2642
|
+
ee((ie) => !(ie != null && ie.limitIntentDraft) || !ie.limitOrderDetails ? ie : {
|
|
2643
|
+
...ie,
|
|
2644
|
+
limitIntentDraft: {
|
|
2645
|
+
...ie.limitIntentDraft,
|
|
2646
|
+
expirySeconds: D
|
|
2647
|
+
},
|
|
2648
|
+
limitOrderDetails: {
|
|
2649
|
+
...ie.limitOrderDetails,
|
|
2650
|
+
expiry: g
|
|
2651
|
+
}
|
|
2652
|
+
});
|
|
2653
|
+
}, []);
|
|
2654
|
+
if (!Ye) return null;
|
|
2655
|
+
const it = m === "embedded", Re = it ? "embedded" : "dialog", ot = it ? Ut : void 0, $t = s === "limit" ? "Place Order" : s === "dca" ? "DCA Order" : l, Wt = () => {
|
|
2656
|
+
var g, D;
|
|
2657
|
+
switch (s) {
|
|
2658
|
+
case "swap":
|
|
2659
|
+
$e();
|
|
2660
|
+
break;
|
|
2661
|
+
case "limit":
|
|
2662
|
+
if ((D = (g = L == null ? void 0 : L.limitOrderDetails) == null ? void 0 : g.marketWarning) != null && D.isBlocked || ge || ae) return;
|
|
2663
|
+
Yn();
|
|
2664
|
+
break;
|
|
2665
|
+
case "dca":
|
|
2666
|
+
if (ge || ae) return;
|
|
2667
|
+
M.info("DCA order submission is not available yet");
|
|
2668
|
+
break;
|
|
2669
|
+
}
|
|
2670
|
+
}, Ht = () => {
|
|
2671
|
+
if (r && U && y && N && te) {
|
|
2672
|
+
const g = hn(
|
|
2673
|
+
r,
|
|
2674
|
+
U,
|
|
2675
|
+
te,
|
|
2676
|
+
N,
|
|
2677
|
+
y,
|
|
2678
|
+
de
|
|
2679
|
+
);
|
|
2680
|
+
ee(g), P(g.to.amount), _(U);
|
|
2681
|
+
}
|
|
2682
|
+
};
|
|
2683
|
+
return it ? /* @__PURE__ */ i(
|
|
2684
|
+
"div",
|
|
2685
|
+
{
|
|
2686
|
+
className: he(
|
|
2687
|
+
"pointer-events-auto absolute inset-0 z-50 flex max-h-full min-h-0 flex-col overflow-hidden rounded-[inherit] bg-card text-foreground shadow-lg",
|
|
2688
|
+
c
|
|
2689
|
+
),
|
|
2690
|
+
role: "dialog",
|
|
2691
|
+
"aria-modal": "true",
|
|
2692
|
+
children: /* @__PURE__ */ p("div", { className: "confirm-modal-scroll-area flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto overflow-x-hidden p-0 outline-none", children: [
|
|
2693
|
+
Ne === "complete" && /* @__PURE__ */ i(
|
|
2694
|
+
un,
|
|
2695
|
+
{
|
|
2696
|
+
completeResult: O,
|
|
2697
|
+
completeData: k,
|
|
2698
|
+
showErrorDetails: s === "limit" ? Qe : He,
|
|
2699
|
+
onToggleErrorDetails: () => {
|
|
2700
|
+
s === "limit" ? ze(!Qe) : je(!He);
|
|
2701
|
+
},
|
|
2702
|
+
explorerBaseUrl: o,
|
|
2703
|
+
presentation: Re,
|
|
2704
|
+
onBack: ot,
|
|
2705
|
+
flow: s === "limit" ? "limit" : "swap",
|
|
2706
|
+
onClose: () => {
|
|
2707
|
+
a(), u();
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
),
|
|
2711
|
+
Ne === "pending" && L && /* @__PURE__ */ i(
|
|
2712
|
+
mn,
|
|
2713
|
+
{
|
|
2714
|
+
displayData: L,
|
|
2715
|
+
waitingCompleteTx: se,
|
|
2716
|
+
transactionStep: Be,
|
|
2717
|
+
needsApproval: At,
|
|
2718
|
+
needsTokenApproval: Pt,
|
|
2719
|
+
needsPermit2Approval: It,
|
|
2720
|
+
showTokenApprovalStep: _t,
|
|
2721
|
+
needsPermit2Signature: Et,
|
|
2722
|
+
isPreparing: Ct,
|
|
2723
|
+
needsWrap: yt,
|
|
2724
|
+
getTransactionUrl: Ot,
|
|
2725
|
+
presentation: Re,
|
|
2726
|
+
onBack: ot,
|
|
2727
|
+
flow: s === "limit" ? "limit" : "swap"
|
|
2728
|
+
}
|
|
2729
|
+
),
|
|
2730
|
+
Ne === "confirm" && L && N && y && /* @__PURE__ */ i(
|
|
2731
|
+
gn,
|
|
2732
|
+
{
|
|
2733
|
+
displayData: L,
|
|
2734
|
+
sellToken: N,
|
|
2735
|
+
buyToken: y,
|
|
2736
|
+
quoteLoading: q,
|
|
2737
|
+
isPricesLoading: W,
|
|
2738
|
+
quote: U,
|
|
2739
|
+
estimatedGasFee: x,
|
|
2740
|
+
estimatedGasFeeUsd: H,
|
|
2741
|
+
priceDifference: We,
|
|
2742
|
+
usdPriceMap: oe,
|
|
2743
|
+
priceUpdated: Lt,
|
|
2744
|
+
slippageExceeded: Tt,
|
|
2745
|
+
highPriceDifference: Mt,
|
|
2746
|
+
marketPriceInfo: _e,
|
|
2747
|
+
onAcceptPriceUpdate: Ht,
|
|
2748
|
+
onConfirm: Wt,
|
|
2749
|
+
isPending: ve,
|
|
2750
|
+
isApproved: Z,
|
|
2751
|
+
intent: s,
|
|
2752
|
+
presentation: Re,
|
|
2753
|
+
onBack: ot,
|
|
2754
|
+
actionLabel: $t,
|
|
2755
|
+
needsWrap: Rt,
|
|
2756
|
+
isApprovalLoading: Bt,
|
|
2757
|
+
isAvailableBalanceLoading: ge,
|
|
2758
|
+
hasAvailableBalanceError: ae,
|
|
2759
|
+
onLimitExpiryChange: Ft
|
|
2760
|
+
}
|
|
2761
|
+
)
|
|
2762
|
+
] })
|
|
2763
|
+
}
|
|
2764
|
+
) : /* @__PURE__ */ i(
|
|
2765
|
+
Qr,
|
|
2766
|
+
{
|
|
2767
|
+
open: Ye,
|
|
2768
|
+
onOpenChange: (g) => {
|
|
2769
|
+
g || Ut();
|
|
2770
|
+
},
|
|
2771
|
+
children: /* @__PURE__ */ p(
|
|
2772
|
+
zr,
|
|
2773
|
+
{
|
|
2774
|
+
className: he("md:max-w-114 border-border bg-card text-foreground", c),
|
|
2775
|
+
onOpenAutoFocus: (g) => g.preventDefault(),
|
|
2776
|
+
children: [
|
|
2777
|
+
/* @__PURE__ */ i(xn, { className: "sr-only" }),
|
|
2778
|
+
Ne === "complete" && /* @__PURE__ */ i(
|
|
2779
|
+
un,
|
|
2780
|
+
{
|
|
2781
|
+
completeResult: O,
|
|
2782
|
+
completeData: k,
|
|
2783
|
+
showErrorDetails: s === "limit" ? Qe : He,
|
|
2784
|
+
onToggleErrorDetails: () => {
|
|
2785
|
+
s === "limit" ? ze(!Qe) : je(!He);
|
|
2786
|
+
},
|
|
2787
|
+
explorerBaseUrl: o,
|
|
2788
|
+
presentation: Re,
|
|
2789
|
+
flow: s === "limit" ? "limit" : "swap",
|
|
2790
|
+
onClose: () => {
|
|
2791
|
+
a(), u();
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
),
|
|
2795
|
+
Ne === "pending" && L && /* @__PURE__ */ i(
|
|
2796
|
+
mn,
|
|
2797
|
+
{
|
|
2798
|
+
displayData: L,
|
|
2799
|
+
waitingCompleteTx: se,
|
|
2800
|
+
transactionStep: Be,
|
|
2801
|
+
needsApproval: At,
|
|
2802
|
+
needsTokenApproval: Pt,
|
|
2803
|
+
needsPermit2Approval: It,
|
|
2804
|
+
showTokenApprovalStep: _t,
|
|
2805
|
+
needsPermit2Signature: Et,
|
|
2806
|
+
isPreparing: Ct,
|
|
2807
|
+
needsWrap: yt,
|
|
2808
|
+
getTransactionUrl: Ot,
|
|
2809
|
+
presentation: Re,
|
|
2810
|
+
flow: s === "limit" ? "limit" : "swap"
|
|
2811
|
+
}
|
|
2812
|
+
),
|
|
2813
|
+
Ne === "confirm" && L && N && y && /* @__PURE__ */ i(
|
|
2814
|
+
gn,
|
|
2815
|
+
{
|
|
2816
|
+
displayData: L,
|
|
2817
|
+
sellToken: N,
|
|
2818
|
+
buyToken: y,
|
|
2819
|
+
quoteLoading: q,
|
|
2820
|
+
isPricesLoading: W,
|
|
2821
|
+
quote: U,
|
|
2822
|
+
estimatedGasFee: x,
|
|
2823
|
+
estimatedGasFeeUsd: H,
|
|
2824
|
+
priceDifference: We,
|
|
2825
|
+
usdPriceMap: oe,
|
|
2826
|
+
priceUpdated: Lt,
|
|
2827
|
+
slippageExceeded: Tt,
|
|
2828
|
+
highPriceDifference: Mt,
|
|
2829
|
+
marketPriceInfo: _e,
|
|
2830
|
+
onAcceptPriceUpdate: Ht,
|
|
2831
|
+
onConfirm: Wt,
|
|
2832
|
+
isPending: ve,
|
|
2833
|
+
isApproved: Z,
|
|
2834
|
+
intent: s,
|
|
2835
|
+
presentation: Re,
|
|
2836
|
+
actionLabel: $t,
|
|
2837
|
+
needsWrap: Rt,
|
|
2838
|
+
isApprovalLoading: Bt,
|
|
2839
|
+
isAvailableBalanceLoading: ge,
|
|
2840
|
+
hasAvailableBalanceError: ae,
|
|
2841
|
+
onLimitExpiryChange: Ft
|
|
2842
|
+
}
|
|
2843
|
+
)
|
|
2844
|
+
]
|
|
2845
|
+
}
|
|
2846
|
+
)
|
|
2847
|
+
}
|
|
2848
|
+
);
|
|
2849
|
+
}
|
|
2850
|
+
export {
|
|
2851
|
+
wo as default
|
|
2852
|
+
};
|