@orbs-network/spot-react 2.1.17 → 2.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,82 +1,88 @@
1
1
  "use client";
2
- var xe = Object.defineProperty;
3
- var Fe = (e, t, n) => t in e ? xe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
4
- var oe = (e, t, n) => Fe(e, typeof t != "symbol" ? t + "" : t, n);
5
- import { OrderStatus as J, Module as X, createClient as Ue, analytics as De, calculateOrderForm as Ge, isNativeAddress as Q, eqIgnoreCase as Pe, toAmountRaw as k, toAmountUI as ne, isTxRejected as ve, getOrderLimitPriceRate as Me, getTriggerPriceRate as Be, getOrderExecutionRate as we, getOrderFillDelayMillis as _e, getTwapConfig as qe, invertPriceInput as fe, setUIVersion as We } from "@orbs-network/spot-ui";
6
- import { DISCLAIMER_URL as ur, InputErrors as lr, Module as mr, ORBS_LOGO as gr, ORBS_SLTP_FAQ_URL as Pr, ORBS_TWAP_FAQ_URL as fr, ORBS_WEBSITE_URL as hr, OrderFilter as Er, OrderStatus as Ir, OrderType as Sr, Partners as Or, TimeUnit as pr, calculateOrderForm as Ar, createClient as vr, eqIgnoreCase as wr, getOrderExecutionRate as Cr, getOrderFillDelayMillis as yr, getOrderLimitPriceRate as Rr, getTriggerPriceRate as Tr, getTwapConfig as Nr, invertPriceInput as Lr, isNativeAddress as xr, isTxRejected as Fr, toAmountRaw as Ur, toAmountUI as Dr } from "@orbs-network/spot-ui";
7
- import { jsx as U, jsxs as ue, Fragment as Ke } from "react/jsx-runtime";
8
- import { createContext as le, useContext as me, useState as Ve, useCallback as v, useMemo as R, useEffect as ie, Component as He, useRef as je } from "react";
9
- import { useStore as Je } from "zustand";
10
- import { createStore as ze } from "zustand/vanilla";
11
- const $e = "2.1.17", Qe = {
12
- version: $e
13
- }, Ce = le(null), Ye = ({
2
+ var Re = Object.defineProperty;
3
+ var Le = (e, t, n) => t in e ? Re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
4
+ var te = (e, t, n) => Le(e, typeof t != "symbol" ? t + "" : t, n);
5
+ import { OrderStatus as V, Module as j, createClient as xe, analytics as Fe, calculateOrder as Ne, isNativeAddress as $, eqIgnoreCase as ue, toAmountRaw as Y, toAmountUI as ee, isTxRejected as Ee, getOrderLimitPriceRate as Ue, getTriggerPriceRate as De, getOrderExecutionRate as Se, getOrderFillDelayMillis as Me, getTwapConfig as Ge, invertPriceInput as le, watchOrder as Be, executeOrder as _e, setUIVersion as He } from "@orbs-network/spot-ui";
6
+ import { DISCLAIMER_URL as sr, InputErrors as ar, Module as cr, ORBS_LOGO as dr, ORBS_SLTP_FAQ_URL as ur, ORBS_TWAP_FAQ_URL as lr, ORBS_WEBSITE_URL as mr, OrderFilter as gr, OrderSettlementError as fr, OrderStatus as hr, OrderType as Pr, Partners as Er, QuoteError as Sr, SWAP_CAPABILITIES as Or, SpotError as Ir, TimeUnit as vr, analytics as wr, calculateOrder as pr, calculateOrderForm as Ar, createClient as yr, eqIgnoreCase as Cr, executeOrder as Tr, getMinimumOutputAmount as Rr, getOrderExecutionRate as Lr, getOrderFillDelayMillis as xr, getOrderLimitPriceRate as Fr, getOrders as Nr, getQuote as Ur, getTriggerPriceRate as Dr, getTwapConfig as Mr, invertPriceInput as Gr, isNativeAddress as Br, isQuoteFresh as _r, isSwapSupported as Hr, isTxRejected as qr, setUIVersion as Kr, submitSwap as Wr, toAmountRaw as Vr, toAmountUI as jr, waitForOrder as Jr, watchOrder as Qr } from "@orbs-network/spot-ui";
7
+ import { jsx as N, jsxs as oe, Fragment as qe } from "react/jsx-runtime";
8
+ import { createContext as se, useContext as ae, useState as Ke, useCallback as y, useMemo as C, useEffect as b, Component as We, useRef as Oe } from "react";
9
+ import { useStore as Ve } from "zustand";
10
+ import { createStore as je } from "zustand/vanilla";
11
+ const Je = "2.1.18", Qe = {
12
+ version: Je
13
+ }, Ie = se(null), ze = ({
14
14
  children: e,
15
15
  value: t
16
- }) => /* @__PURE__ */ U(Ce.Provider, { value: t, children: e }), x = () => {
17
- const e = me(Ce);
16
+ }) => /* @__PURE__ */ N(Ie.Provider, { value: t, children: e }), R = () => {
17
+ const e = ae(Ie);
18
18
  if (e === null)
19
19
  throw new Error("useSpotTrading must be used within SpotProvider");
20
20
  return e;
21
21
  };
22
- var q = /* @__PURE__ */ ((e) => (e[e.LOADING = 1] = "LOADING", e[e.SUCCESS = 2] = "SUCCESS", e[e.FAILED = 3] = "FAILED", e))(q || {}), d = /* @__PURE__ */ ((e) => (e.IDLE = "idle", e.PREPARING = "preparing", e.WRAPPING = "wrapping", e.APPROVING = "approving", e.SIGNING = "signing", e.SUBMITTING = "submitting", e.SUCCESS = "success", e.FAILED = "failed", e.REJECTED = "rejected", e))(d || {}), ee = /* @__PURE__ */ ((e) => (e.TRIGGER_MARKET_PRICE = "triggerMarketPriceDisclaimer", e.MARKET_PRICE = "marketOrderDisclaimer", e.LIMIT_PRICE = "limitOrderDisclaimer", e))(ee || {}), z = /* @__PURE__ */ ((e) => (e.WRAP = "wrap", e.APPROVE = "approve", e.CREATE = "create", e))(z || {});
23
- const Xe = /* @__PURE__ */ new Set([
24
- d.PREPARING,
25
- d.WRAPPING,
26
- d.APPROVING,
27
- d.SIGNING,
28
- d.SUBMITTING
29
- ]), Ze = {
30
- [d.IDLE]: /* @__PURE__ */ new Set(),
31
- [d.PREPARING]: /* @__PURE__ */ new Set([
32
- d.PREPARING,
33
- d.WRAPPING,
34
- d.APPROVING,
35
- d.SIGNING,
36
- d.FAILED,
37
- d.REJECTED
22
+ var _ = /* @__PURE__ */ ((e) => (e[e.LOADING = 1] = "LOADING", e[e.SUCCESS = 2] = "SUCCESS", e[e.FAILED = 3] = "FAILED", e))(_ || {}), u = /* @__PURE__ */ ((e) => (e.IDLE = "idle", e.PREPARING = "preparing", e.WRAPPING = "wrapping", e.APPROVING = "approving", e.SIGNING = "signing", e.SUBMITTING = "submitting", e.SETTLING = "settling", e.SUCCESS = "success", e.FAILED = "failed", e.REJECTED = "rejected", e))(u || {}), X = /* @__PURE__ */ ((e) => (e.TRIGGER_MARKET_PRICE = "triggerMarketPriceDisclaimer", e.MARKET_PRICE = "marketOrderDisclaimer", e.LIMIT_PRICE = "limitOrderDisclaimer", e))(X || {}), Q = /* @__PURE__ */ ((e) => (e.WRAP = "wrap", e.APPROVE = "approve", e.CREATE = "create", e))(Q || {});
23
+ const $e = /* @__PURE__ */ new Set([
24
+ u.PREPARING,
25
+ u.WRAPPING,
26
+ u.APPROVING,
27
+ u.SIGNING,
28
+ u.SUBMITTING,
29
+ u.SETTLING
30
+ ]), be = {
31
+ [u.IDLE]: /* @__PURE__ */ new Set(),
32
+ [u.PREPARING]: /* @__PURE__ */ new Set([
33
+ u.PREPARING,
34
+ u.WRAPPING,
35
+ u.APPROVING,
36
+ u.SIGNING,
37
+ u.FAILED,
38
+ u.REJECTED
38
39
  ]),
39
- [d.WRAPPING]: /* @__PURE__ */ new Set([
40
- d.WRAPPING,
41
- d.APPROVING,
42
- d.SIGNING,
43
- d.FAILED,
44
- d.REJECTED
40
+ [u.WRAPPING]: /* @__PURE__ */ new Set([
41
+ u.WRAPPING,
42
+ u.APPROVING,
43
+ u.SIGNING,
44
+ u.FAILED,
45
+ u.REJECTED
45
46
  ]),
46
- [d.APPROVING]: /* @__PURE__ */ new Set([
47
- d.APPROVING,
48
- d.SIGNING,
49
- d.FAILED,
50
- d.REJECTED
47
+ [u.APPROVING]: /* @__PURE__ */ new Set([
48
+ u.APPROVING,
49
+ u.SIGNING,
50
+ u.FAILED,
51
+ u.REJECTED
51
52
  ]),
52
- [d.SIGNING]: /* @__PURE__ */ new Set([
53
- d.SIGNING,
54
- d.SUBMITTING,
55
- d.FAILED,
56
- d.REJECTED
53
+ [u.SIGNING]: /* @__PURE__ */ new Set([
54
+ u.SIGNING,
55
+ u.SUBMITTING,
56
+ u.FAILED,
57
+ u.REJECTED
57
58
  ]),
58
- [d.SUBMITTING]: /* @__PURE__ */ new Set([
59
- d.SUCCESS,
60
- d.FAILED,
61
- d.REJECTED
59
+ [u.SUBMITTING]: /* @__PURE__ */ new Set([
60
+ u.SETTLING,
61
+ u.SUCCESS,
62
+ u.FAILED,
63
+ u.REJECTED
62
64
  ]),
63
- [d.SUCCESS]: /* @__PURE__ */ new Set(),
64
- [d.FAILED]: /* @__PURE__ */ new Set(),
65
- [d.REJECTED]: /* @__PURE__ */ new Set()
66
- }, te = (e) => ({
67
- phase: d.IDLE,
65
+ [u.SETTLING]: /* @__PURE__ */ new Set([
66
+ u.SUCCESS,
67
+ u.FAILED
68
+ ]),
69
+ [u.SUCCESS]: /* @__PURE__ */ new Set(),
70
+ [u.FAILED]: /* @__PURE__ */ new Set(),
71
+ [u.REJECTED]: /* @__PURE__ */ new Set()
72
+ }, Z = (e) => ({
73
+ phase: u.IDLE,
68
74
  completedWrap: e
69
- }), $ = (e) => Xe.has(e), be = (e) => e === d.IDLE || e === d.FAILED || e === d.REJECTED, ke = (e, t) => Ze[e].has(t), et = (e) => {
70
- if ($(e)) return q.LOADING;
71
- if (e === d.SUCCESS) return q.SUCCESS;
72
- if (e === d.FAILED || e === d.REJECTED)
73
- return q.FAILED;
74
- }, tt = (e) => {
75
- if (e === d.WRAPPING) return z.WRAP;
76
- if (e === d.APPROVING) return z.APPROVE;
77
- if (e === d.SIGNING || e === d.SUBMITTING)
78
- return z.CREATE;
79
- }, ge = (e) => {
75
+ }), z = (e) => $e.has(e), ve = (e) => e === u.IDLE || e === u.FAILED || e === u.REJECTED, Ye = (e, t) => be[e].has(t), Xe = (e) => {
76
+ if (z(e)) return _.LOADING;
77
+ if (e === u.SUCCESS) return _.SUCCESS;
78
+ if (e === u.FAILED || e === u.REJECTED)
79
+ return _.FAILED;
80
+ }, Ze = (e) => {
81
+ if (e === u.WRAPPING) return Q.WRAP;
82
+ if (e === u.APPROVING) return Q.APPROVE;
83
+ if (e === u.SIGNING || e === u.SUBMITTING)
84
+ return Q.CREATE;
85
+ }, ce = (e) => {
80
86
  if (e instanceof Error) return e.message;
81
87
  if (typeof e == "string") return e;
82
88
  if (typeof e == "object" && e !== null) {
@@ -84,17 +90,17 @@ const Xe = /* @__PURE__ */ new Set([
84
90
  if (typeof t == "string") return t;
85
91
  }
86
92
  return "Unknown error";
87
- }, rt = (e) => {
93
+ }, ke = (e) => {
88
94
  if (typeof e != "object" || e === null) return 0;
89
95
  const t = Reflect.get(e, "code");
90
96
  return typeof t == "number" && Number.isFinite(t) ? t : typeof t == "string" && /^-?\d+$/.test(t) ? Number(t) : 0;
91
- }, re = (e) => e instanceof Error ? e : new Error(ge(e)), se = (e) => {
92
- const t = ge(e), n = t.match(/,\s*code\s*:\s*(-?\d+)/i);
97
+ }, k = (e) => e instanceof Error ? e : new Error(ce(e)), re = (e) => {
98
+ const t = ce(e), n = t.match(/,\s*code\s*:\s*(-?\d+)/i);
93
99
  return {
94
100
  message: t.replace(/^error\s*:/i, "").replace(/,\s*code\s*:\s*-?\d+/i, "").trim() || "Unknown error",
95
- code: rt(e) || (n ? Number(n[1]) : 0)
101
+ code: ke(e) || (n ? Number(n[1]) : 0)
96
102
  };
97
- }, I = (e) => {
103
+ }, w = (e) => {
98
104
  if (e)
99
105
  try {
100
106
  const t = e();
@@ -102,7 +108,7 @@ const Xe = /* @__PURE__ */ new Set([
102
108
  });
103
109
  } catch {
104
110
  }
105
- }, nt = ({
111
+ }, et = ({
106
112
  execution: e,
107
113
  account: t,
108
114
  chainId: n,
@@ -110,16 +116,16 @@ const Xe = /* @__PURE__ */ new Set([
110
116
  inputAmountRaw: i
111
117
  }) => {
112
118
  const o = e.completedWrap;
113
- if ((o == null ? void 0 : o.account.toLowerCase()) === t.toLowerCase() && o.chainId === n && o.inputTokenAddress.toLowerCase() === r.toLowerCase() && it(o.inputAmountRaw, i))
119
+ if ((o == null ? void 0 : o.account.toLowerCase()) === t.toLowerCase() && o.chainId === n && o.inputTokenAddress.toLowerCase() === r.toLowerCase() && tt(o.inputAmountRaw, i))
114
120
  return o;
115
- }, it = (e, t) => {
121
+ }, tt = (e, t) => {
116
122
  try {
117
123
  return BigInt(e) >= BigInt(t);
118
124
  } catch {
119
125
  return !1;
120
126
  }
121
- }, ot = 2e4, he = /* @__PURE__ */ new WeakMap(), Ee = (e) => {
122
- const t = he.get(e);
127
+ }, rt = 2e4, me = /* @__PURE__ */ new WeakMap(), ge = (e) => {
128
+ const t = me.get(e);
123
129
  if (t) return t;
124
130
  const n = {
125
131
  all: [...e].sort((r, i) => i.createdAt - r.createdAt),
@@ -130,26 +136,26 @@ const Xe = /* @__PURE__ */ new Set([
130
136
  };
131
137
  for (const r of n.all)
132
138
  switch (r.status) {
133
- case J.Open:
139
+ case V.Open:
134
140
  n.open.push(r);
135
141
  break;
136
- case J.Completed:
142
+ case V.Completed:
137
143
  n.completed.push(r);
138
144
  break;
139
- case J.Cancelled:
145
+ case V.Cancelled:
140
146
  n.cancelled.push(r);
141
147
  break;
142
- case J.Expired:
148
+ case V.Expired:
143
149
  n.expired.push(r);
144
150
  break;
145
151
  }
146
- return he.set(e, n), n;
147
- }, st = (e, t) => {
152
+ return me.set(e, n), n;
153
+ }, nt = (e, t) => {
148
154
  const n = new Set(e.map((i) => i.historyKey)), r = (t == null ? void 0 : t.filter(
149
155
  (i) => i.version === 1 && !n.has(i.historyKey)
150
156
  )) ?? [];
151
157
  return [...e, ...r];
152
- }, at = (e, t, n) => {
158
+ }, we = (e, t, n) => {
153
159
  if (!e) return;
154
160
  const r = new Map(
155
161
  t.map((o) => [o.historyKey, o])
@@ -157,39 +163,39 @@ const Xe = /* @__PURE__ */ new Set([
157
163
  for (const o of e) {
158
164
  if (o.version !== 2) continue;
159
165
  const s = r.get(o.historyKey);
160
- !s || s.progress === o.progress || (i.push(s), s.status === J.Completed && I(() => {
166
+ !s || s.progress === o.progress && s.status === o.status || (i.push(s), s.status === V.Completed && o.status !== V.Completed && w(() => {
161
167
  var a;
162
168
  return (a = n == null ? void 0 : n.onOrderFilled) == null ? void 0 : a.call(n, s);
163
169
  }));
164
170
  }
165
- i.length > 0 && I(() => {
171
+ i.length > 0 && w(() => {
166
172
  var o;
167
173
  return (o = n == null ? void 0 : n.onOrdersProgressUpdate) == null ? void 0 : o.call(n, i);
168
174
  });
169
- }, Ie = (e) => {
175
+ }, fe = (e) => {
170
176
  if (e === null || typeof e != "object") return !1;
171
177
  const t = Object.getPrototypeOf(e);
172
178
  return t === Object.prototype || t === null;
173
- }, ae = (e, t) => {
179
+ }, ne = (e, t) => {
174
180
  if (Object.is(e, t)) return e;
175
181
  if (Array.isArray(e) && Array.isArray(t)) {
176
182
  const n = t.map(
177
- (i, o) => ae(e[o], i)
183
+ (i, o) => ne(e[o], i)
178
184
  );
179
185
  return e.length === n.length && n.every((i, o) => i === e[o]) ? e : n;
180
186
  }
181
- if (Ie(e) && Ie(t)) {
187
+ if (fe(e) && fe(t)) {
182
188
  const n = Object.keys(e), r = Object.keys(t), i = {};
183
189
  let o = n.length === r.length;
184
190
  for (const s of r) {
185
191
  Object.prototype.hasOwnProperty.call(e, s) || (o = !1);
186
- const a = ae(e[s], t[s]);
192
+ const a = ne(e[s], t[s]);
187
193
  i[s] = a, a !== e[s] && (o = !1);
188
194
  }
189
195
  return o ? e : i;
190
196
  }
191
197
  return t;
192
- }, ct = (e, t) => e ? ae(e, t) : t, dt = async ({
198
+ }, pe = (e, t) => e ? ne(e, t) : t, it = async ({
193
199
  client: e,
194
200
  account: t,
195
201
  signal: n,
@@ -204,11 +210,11 @@ const Xe = /* @__PURE__ */ new Set([
204
210
  legacyOrders: r && !o
205
211
  });
206
212
  if (n.aborted) throw n.reason;
207
- return at(i, a.orders, s), {
208
- orders: r && !a.legacyLoaded ? st(a.orders, i) : a.orders,
213
+ return we(i, a.orders, s), {
214
+ orders: r && !a.legacyLoaded ? nt(a.orders, i) : a.orders,
209
215
  legacyLoaded: o || a.legacyLoaded
210
216
  };
211
- }, ce = (e) => ({
217
+ }, ie = (e) => ({
212
218
  tradeCount: e.tradeCount,
213
219
  tradeInterval: e.tradeInterval,
214
220
  orderDuration: e.orderDuration,
@@ -218,86 +224,86 @@ const Xe = /* @__PURE__ */ new Set([
218
224
  limitPricePercent: e.limitPricePercent,
219
225
  isMarketOrder: e.isMarketOrder,
220
226
  isPriceInverted: void 0
221
- }), ut = (e) => ({
222
- ...ce(e),
227
+ }), ot = (e) => ({
228
+ ...ie(e),
223
229
  cancelOrders: {},
224
- currentExecution: te()
225
- }), Se = { isFetching: !1 }, Oe = { isFetching: !1 }, lt = (e) => new Promise((t) => setTimeout(t, e)), mt = (e) => {
226
- let t = 0, n, r, i = 0, o, s, a, c = !1, h = 0, p = 0, u, g, E;
227
- return ze((m, S) => {
228
- const y = async () => {
230
+ currentExecution: Z()
231
+ }), he = { isFetching: !1 }, Pe = { isFetching: !1 }, st = (e) => new Promise((t) => setTimeout(t, e)), at = (e) => {
232
+ let t = 0, n, r, i = 0, o, s, a, c = !1, E = 0, O = 0, d, m, g;
233
+ return je((h, S) => {
234
+ const T = async () => {
229
235
  if (!n || !r) return;
230
236
  if (o) return o;
231
- const l = ++i, P = r;
232
- m((f) => ({
237
+ const f = ++i, P = r;
238
+ h((x) => ({
233
239
  client: {
234
240
  key: n,
235
- data: f.client.data,
241
+ data: x.client.data,
236
242
  error: void 0,
237
243
  isFetching: !0
238
244
  }
239
245
  }));
240
- const O = (async () => {
241
- let f;
242
- for (let B = 0; B < 3; B++) {
243
- if (l !== i) return;
246
+ const I = (async () => {
247
+ let x;
248
+ for (let v = 0; v < 3; v++) {
249
+ if (f !== i) return;
244
250
  try {
245
- const w = await P();
246
- return l !== i ? void 0 : (m({
247
- client: { key: n, data: w, isFetching: !1 }
248
- }), w);
249
- } catch (w) {
250
- if (f = w instanceof Error ? w : new Error(String(w)), l !== i) return;
251
- B < 2 && await lt(2 ** B * 1e3);
251
+ const p = await P();
252
+ return f !== i ? void 0 : (h({
253
+ client: { key: n, data: p, isFetching: !1 }
254
+ }), p);
255
+ } catch (p) {
256
+ if (x = p instanceof Error ? p : new Error(String(p)), f !== i) return;
257
+ v < 2 && await st(2 ** v * 1e3);
252
258
  }
253
259
  }
254
- l === i && m({
255
- client: { key: n, error: f, isFetching: !1 }
260
+ f === i && h({
261
+ client: { key: n, error: x, isFetching: !1 }
256
262
  });
257
263
  })();
258
- return o = O, O.finally(() => {
259
- o === O && (o = void 0);
260
- }), O;
261
- }, T = async (l = !1, P = !1) => {
262
- if (!l && h === 0 || !s || !a)
264
+ return o = I, I.finally(() => {
265
+ o === I && (o = void 0);
266
+ }), I;
267
+ }, L = async (f = !1, P = !1) => {
268
+ if (!f && E === 0 || !s || !a)
263
269
  return S().orders.data;
264
- if (u) {
265
- if (!P) return u;
266
- const C = s;
267
- return await u, s !== C ? void 0 : T(l, P);
270
+ if (d) {
271
+ if (!P) return d;
272
+ const l = s;
273
+ return await d, s !== l ? void 0 : L(f, P);
268
274
  }
269
- const O = ++p, f = a, B = S().orders.data, w = new AbortController();
270
- g = w, m((C) => ({
275
+ const I = ++O, x = a, v = S().orders.data, p = new AbortController();
276
+ m = p, h((l) => ({
271
277
  orders: {
272
278
  key: s,
273
- data: C.orders.data,
279
+ data: l.orders.data,
274
280
  error: void 0,
275
281
  isFetching: !0
276
282
  }
277
283
  }));
278
- const F = f(
279
- B,
284
+ const F = x(
285
+ v,
280
286
  P ? !1 : c,
281
- w.signal
282
- ).then(({ orders: C, legacyLoaded: D }) => {
283
- if (O !== p) return;
287
+ p.signal
288
+ ).then(({ orders: l, legacyLoaded: D }) => {
289
+ if (I !== O) return;
284
290
  c = D;
285
- const G = ct(
291
+ const G = pe(
286
292
  S().orders.data,
287
- C
293
+ l
288
294
  );
289
- return m({
295
+ return h({
290
296
  orders: {
291
297
  key: s,
292
298
  data: G,
293
299
  isFetching: !1
294
300
  }
295
301
  }), G;
296
- }).catch((C) => {
297
- if (O !== p || w.signal.aborted)
302
+ }).catch((l) => {
303
+ if (I !== O || p.signal.aborted)
298
304
  return;
299
- const D = C instanceof Error ? C : new Error(String(C));
300
- m((G) => ({
305
+ const D = l instanceof Error ? l : new Error(String(l));
306
+ h((G) => ({
301
307
  orders: {
302
308
  key: s,
303
309
  data: G.orders.data,
@@ -306,132 +312,132 @@ const Xe = /* @__PURE__ */ new Set([
306
312
  }
307
313
  }));
308
314
  });
309
- return u = F, F.finally(() => {
310
- u === F && (u = void 0), g === w && (g = void 0);
315
+ return d = F, F.finally(() => {
316
+ d === F && (d = void 0), m === p && (m = void 0);
311
317
  }), F;
312
- }, L = () => {
313
- T();
318
+ }, q = () => {
319
+ L();
314
320
  }, K = () => {
315
- E && (clearInterval(E), E = void 0), typeof window < "u" && window.removeEventListener("focus", L), g == null || g.abort(), g = void 0, u = void 0, p++, m((l) => ({
316
- orders: { ...l.orders, isFetching: !1 }
321
+ g && (clearInterval(g), g = void 0), typeof window < "u" && window.removeEventListener("focus", q), m == null || m.abort(), m = void 0, d = void 0, O++, h((f) => ({
322
+ orders: { ...f.orders, isFetching: !1 }
317
323
  }));
318
- }, M = () => {
319
- !s || !a || E || (T(!0), E = setInterval(() => {
320
- T();
321
- }, ot), typeof window < "u" && window.addEventListener("focus", L));
324
+ }, U = () => {
325
+ !s || !a || g || (L(!0), g = setInterval(() => {
326
+ L();
327
+ }, rt), typeof window < "u" && window.addEventListener("focus", q));
322
328
  };
323
329
  return {
324
- client: Se,
325
- orders: Oe,
326
- state: ut(e),
327
- configureClient: (l, P) => {
328
- if (n === l) {
330
+ client: he,
331
+ orders: Pe,
332
+ state: ot(e),
333
+ configureClient: (f, P) => {
334
+ if (n === f) {
329
335
  r = P;
330
336
  return;
331
337
  }
332
- n = l, r = P, i++, o = void 0, m({
333
- client: l ? { key: l, isFetching: !1 } : Se
334
- }), l && P && y();
338
+ n = f, r = P, i++, o = void 0, h({
339
+ client: f ? { key: f, isFetching: !1 } : he
340
+ }), f && P && T();
335
341
  },
336
- refetchClient: y,
337
- configureOrders: (l, P) => {
338
- if (s === l) {
342
+ refetchClient: T,
343
+ configureOrders: (f, P) => {
344
+ if (s === f) {
339
345
  a = P;
340
346
  return;
341
347
  }
342
- K(), s = l, a = P, c = !1, m({
343
- orders: l ? { key: l, isFetching: !1 } : Oe
344
- }), h > 0 && M();
348
+ K(), s = f, a = P, c = !1, h({
349
+ orders: f ? { key: f, isFetching: !1 } : Pe
350
+ }), E > 0 && U();
345
351
  },
346
- registerOrdersConsumer: () => (h++, h === 1 && M(), () => {
347
- h = Math.max(0, h - 1), h === 0 && K();
352
+ registerOrdersConsumer: () => (E++, E === 1 && U(), () => {
353
+ E = Math.max(0, E - 1), E === 0 && K();
348
354
  }),
349
- refetchOrders: T,
350
- addOrder: (l) => {
351
- m((P) => {
352
- const O = P.orders.data;
353
- return O != null && O.some(
354
- (f) => f.historyKey === l.historyKey
355
+ refetchOrders: L,
356
+ addOrder: (f) => {
357
+ h((P) => {
358
+ const I = P.orders.data;
359
+ return I != null && I.some(
360
+ (x) => x.historyKey === f.historyKey
355
361
  ) ? P : {
356
362
  orders: {
357
363
  ...P.orders,
358
- data: [l, ...O ?? []]
364
+ data: [f, ...I ?? []]
359
365
  }
360
366
  };
361
367
  });
362
368
  },
363
- setCancelOrder: (l, P) => {
364
- m((O) => ({
369
+ setCancelOrder: (f, P) => {
370
+ h((I) => ({
365
371
  state: {
366
- ...O.state,
367
- cancelOrders: { ...O.state.cancelOrders, [l]: P }
372
+ ...I.state,
373
+ cancelOrders: { ...I.state.cancelOrders, [f]: P }
368
374
  }
369
375
  }));
370
376
  },
371
- clearCancelOrder: (l) => {
372
- m((P) => {
373
- if (!(l in P.state.cancelOrders)) return P;
374
- const O = { ...P.state.cancelOrders };
375
- return delete O[l], { state: { ...P.state, cancelOrders: O } };
377
+ clearCancelOrder: (f) => {
378
+ h((P) => {
379
+ if (!(f in P.state.cancelOrders)) return P;
380
+ const I = { ...P.state.cancelOrders };
381
+ return delete I[f], { state: { ...P.state, cancelOrders: I } };
376
382
  });
377
383
  },
378
- updateState: (l) => m((P) => ({ state: { ...P.state, ...l } })),
379
- beginExecution: (l) => {
384
+ updateState: (f) => h((P) => ({ state: { ...P.state, ...f } })),
385
+ beginExecution: (f) => {
380
386
  let P;
381
- return m((O) => be(O.state.currentExecution.phase) ? (P = {
382
- ...l,
387
+ return h((I) => ve(I.state.currentExecution.phase) ? (P = {
388
+ ...f,
383
389
  executionId: ++t,
384
- phase: d.PREPARING
390
+ phase: u.PREPARING
385
391
  }, {
386
392
  state: {
387
- ...O.state,
393
+ ...I.state,
388
394
  currentExecution: P
389
395
  }
390
- }) : O), P;
396
+ }) : I), P;
391
397
  },
392
- replaceExecution: (l, P) => {
393
- let O = !1;
394
- return m((f) => {
395
- const B = f.state.currentExecution;
396
- return B.executionId !== l || P.executionId !== l || !ke(B.phase, P.phase) ? f : (O = !0, {
397
- state: { ...f.state, currentExecution: P }
398
+ replaceExecution: (f, P) => {
399
+ let I = !1;
400
+ return h((x) => {
401
+ const v = x.state.currentExecution;
402
+ return v.executionId !== f || P.executionId !== f || !Ye(v.phase, P.phase) ? x : (I = !0, {
403
+ state: { ...x.state, currentExecution: P }
398
404
  });
399
- }), O;
405
+ }), I;
400
406
  },
401
407
  returnToOrderForm: () => {
402
- const l = S().state.currentExecution;
403
- return $(l.phase) || l.phase === d.SUCCESS ? !1 : (m((P) => ({
408
+ const f = S().state.currentExecution;
409
+ return z(f.phase) || f.phase === u.SUCCESS ? !1 : (h((P) => ({
404
410
  state: {
405
411
  ...P.state,
406
- currentExecution: te(l.completedWrap)
412
+ currentExecution: Z(f.completedWrap)
407
413
  }
408
414
  })), !0);
409
415
  },
410
- syncFormDefaults: (l) => $(S().state.currentExecution.phase) ? !1 : (m((P) => ({
416
+ syncFormDefaults: (f) => z(S().state.currentExecution.phase) ? !1 : (h((P) => ({
411
417
  state: {
412
418
  ...P.state,
413
- ...ce(l),
414
- currentExecution: te()
419
+ ...ie(f),
420
+ currentExecution: Z()
415
421
  }
416
422
  })), !0),
417
- startNewOrder: (l) => {
423
+ startNewOrder: (f) => {
418
424
  const { state: P } = S();
419
- return $(P.currentExecution.phase) ? !1 : (m((O) => ({
425
+ return z(P.currentExecution.phase) ? !1 : (h((I) => ({
420
426
  state: {
421
- ...O.state,
422
- ...ce(l),
427
+ ...I.state,
428
+ ...ie(f),
423
429
  isMarketOrder: P.isMarketOrder,
424
- currentExecution: te()
430
+ currentExecution: Z()
425
431
  }
426
432
  })), !0);
427
433
  }
428
434
  };
429
435
  });
430
- }, ye = (e) => {
436
+ }, Ae = (e) => {
431
437
  var n;
432
438
  const t = (n = e.overrides) == null ? void 0 : n.state;
433
439
  return {
434
- isMarketOrder: e.module === X.LIMIT ? !1 : t == null ? void 0 : t.isMarketOrder,
440
+ isMarketOrder: e.module === j.LIMIT || e.module === j.SWAP ? !1 : t == null ? void 0 : t.isMarketOrder,
435
441
  tradeCount: t == null ? void 0 : t.tradeCount,
436
442
  tradeInterval: t == null ? void 0 : t.tradeInterval,
437
443
  orderDuration: t == null ? void 0 : t.orderDuration,
@@ -440,34 +446,34 @@ const Xe = /* @__PURE__ */ new Set([
440
446
  triggerPricePercent: t == null ? void 0 : t.triggerPricePercent,
441
447
  limitPricePercent: t == null ? void 0 : t.limitPricePercent
442
448
  };
443
- }, Re = le(null), gt = ({
449
+ }, ye = se(null), ct = ({
444
450
  children: e,
445
451
  initialState: t
446
452
  }) => {
447
- const [n] = Ve(() => mt(t));
448
- return /* @__PURE__ */ U(Re.Provider, { value: n, children: e });
449
- }, V = () => {
450
- const e = me(Re);
453
+ const [n] = Ke(() => at(t));
454
+ return /* @__PURE__ */ N(ye.Provider, { value: n, children: e });
455
+ }, W = () => {
456
+ const e = ae(ye);
451
457
  if (e === null)
452
458
  throw new Error("useSpotStore must be used within SpotProvider");
453
459
  return e;
454
460
  }, A = (e) => {
455
- const t = V();
456
- return Je(t, e);
457
- }, Pt = { isFetching: !1 }, ft = () => {
458
- const { partner: e, chainId: t, hasChainId: n } = x(), r = V(), i = !!(t && n), o = i ? `${e}:${t}` : void 0, s = v(() => t ? Ue(e, t) : Promise.reject(
461
+ const t = W();
462
+ return Ve(t, e);
463
+ }, dt = { isFetching: !1 }, ut = () => {
464
+ const { partner: e, chainId: t, hasChainId: n } = R(), r = W(), i = !!(t && n), o = i ? `${e}:${t}` : void 0, s = y(() => t ? xe(e, t) : Promise.reject(
459
465
  new Error("Spot is unavailable on the connected chain")
460
466
  ), [t, e]);
461
- ie(() => {
467
+ b(() => {
462
468
  r.getState().configureClient(o, i ? s : void 0);
463
469
  }, [i, o, s, r]);
464
- }, Y = () => {
465
- const { partner: e, chainId: t, hasChainId: n } = x(), r = V(), i = A((h) => h.client), o = !!(t && n), s = o ? `${e}:${t}` : void 0, a = i.key === s ? i : Pt, c = v(() => {
470
+ }, J = () => {
471
+ const { partner: e, chainId: t, hasChainId: n } = R(), r = W(), i = A((E) => E.client), o = !!(t && n), s = o ? `${e}:${t}` : void 0, a = i.key === s ? i : dt, c = y(() => {
466
472
  if (!o || !s) return Promise.resolve(void 0);
467
- const h = r.getState();
468
- return h.client.key !== s ? Promise.resolve(void 0) : h.refetchClient();
473
+ const E = r.getState();
474
+ return E.client.key !== s ? Promise.resolve(void 0) : E.refetchClient();
469
475
  }, [o, s, r]);
470
- return R(
476
+ return C(
471
477
  () => ({
472
478
  data: a.data,
473
479
  error: a.error,
@@ -477,56 +483,58 @@ const Xe = /* @__PURE__ */ new Set([
477
483
  }),
478
484
  [a, o, c]
479
485
  );
480
- }, ht = { isFetching: !1 }, Te = (e, t, n) => e && t ? JSON.stringify([
486
+ }, lt = { isFetching: !1 }, de = (e, t, n) => e && t ? JSON.stringify([
481
487
  e,
482
488
  t.exchangeAddress,
483
489
  t.partner,
484
490
  t.chainId,
485
491
  n
486
- ]) : void 0, Et = () => {
487
- const { account: e, supportLegacyOrders: t, callbacks: n } = x(), { data: r } = Y(), i = V(), o = Te(e, r, t), s = !!o, a = v(
488
- async (c, h, p) => !e || !r ? { orders: [], legacyLoaded: !1 } : dt({
492
+ ]) : void 0, mt = () => {
493
+ const { account: e, supportLegacyOrders: t, callbacks: n } = R(), { data: r } = J(), i = W(), o = de(e, r, t), s = !!o, a = y(
494
+ async (c, E, O) => !e || !r ? { orders: [], legacyLoaded: !1 } : it({
489
495
  client: r,
490
496
  account: e,
491
- signal: p,
497
+ signal: O,
492
498
  supportLegacyOrders: t,
493
499
  previousOrders: c,
494
- legacyLoaded: h,
500
+ legacyLoaded: E,
495
501
  callbacks: n
496
502
  }),
497
503
  [e, n, r, t]
498
504
  );
499
- ie(() => {
505
+ b(() => {
500
506
  i.getState().configureOrders(o, s ? a : void 0);
501
507
  }, [s, o, a, i]);
502
- }, Ne = () => {
503
- const { account: e, supportLegacyOrders: t } = x(), { data: n } = Y(), r = V(), i = Te(e, n, t), o = !!i, s = v((a = !1) => !o || !i || r.getState().orders.key !== i ? Promise.resolve(void 0) : r.getState().refetchOrders(!0, a), [o, i, r]);
508
+ }, Ce = () => {
509
+ const { account: e, supportLegacyOrders: t } = R(), { data: n } = J(), r = W(), i = de(e, n, t), o = !!i, s = y((a = !1) => !o || !i || r.getState().orders.key !== i ? Promise.resolve(void 0) : r.getState().refetchOrders(!0, a), [o, i, r]);
504
510
  return { enabled: o, key: i, refetch: s };
505
- }, It = () => {
506
- const e = V();
507
- return v(
508
- (t) => e.getState().addOrder(t),
509
- [e]
511
+ }, gt = () => {
512
+ const e = W(), { account: t, supportLegacyOrders: n } = R(), { data: r } = J(), i = de(t, r, n);
513
+ return y(
514
+ (o) => {
515
+ !i || e.getState().orders.key !== i || e.getState().addOrder(o);
516
+ },
517
+ [i, e]
510
518
  );
511
- }, St = () => {
512
- const e = V();
513
- return v(
519
+ }, ft = () => {
520
+ const e = W();
521
+ return y(
514
522
  () => e.getState().refetchOrders(),
515
523
  [e]
516
524
  );
517
- }, zt = () => {
525
+ }, Wt = () => {
518
526
  const e = A((c) => c.orders), t = A(
519
527
  (c) => c.registerOrdersConsumer
520
- ), { enabled: n, key: r, refetch: i } = Ne(), o = e.key === r ? e : ht;
521
- ie(() => t(), [t]);
522
- const s = R(
523
- () => o.data === void 0 ? void 0 : Ee(o.data),
528
+ ), { enabled: n, key: r, refetch: i } = Ce(), o = e.key === r ? e : lt;
529
+ b(() => t(), [t]);
530
+ const s = C(
531
+ () => o.data === void 0 ? void 0 : ge(o.data),
524
532
  [o.data]
525
- ), a = v(async () => {
533
+ ), a = y(async () => {
526
534
  const c = await i();
527
- return c === void 0 ? void 0 : Ee(c);
535
+ return c === void 0 ? void 0 : ge(c);
528
536
  }, [i]);
529
- return R(
537
+ return C(
530
538
  () => ({
531
539
  data: s,
532
540
  error: o.error,
@@ -537,13 +545,13 @@ const Xe = /* @__PURE__ */ new Set([
537
545
  }),
538
546
  [o, s, n, a]
539
547
  );
540
- }, Ot = ({ children: e }) => (ft(), Et(), e), pt = ({
548
+ }, ht = ({ children: e }) => (ut(), mt(), e), Pt = ({
541
549
  error: e,
542
550
  retry: t,
543
551
  isRetrying: n
544
- }) => /* @__PURE__ */ ue("div", { className: "spot-client-error-fallback", role: "alert", children: [
545
- /* @__PURE__ */ U("p", { children: e.message || "Unable to load Spot configuration." }),
546
- /* @__PURE__ */ U(
552
+ }) => /* @__PURE__ */ oe("div", { className: "spot-client-error-fallback", role: "alert", children: [
553
+ /* @__PURE__ */ N("p", { children: e.message || "Unable to load Spot configuration." }),
554
+ /* @__PURE__ */ N(
547
555
  "button",
548
556
  {
549
557
  type: "button",
@@ -553,16 +561,16 @@ const Xe = /* @__PURE__ */ new Set([
553
561
  children: n ? "Retrying…" : "Retry"
554
562
  }
555
563
  )
556
- ] }), At = ({
564
+ ] }), Et = ({
557
565
  children: e,
558
- fallback: t = pt
566
+ fallback: t = Pt
559
567
  }) => {
560
- const { hasChainId: n } = x(), { data: r, error: i, isFetching: o, refetch: s } = Y(), a = v(async () => {
568
+ const { hasChainId: n } = R(), { data: r, error: i, isFetching: o, refetch: s } = J(), a = y(async () => {
561
569
  await s();
562
570
  }, [s]);
563
- return /* @__PURE__ */ ue(Ke, { children: [
571
+ return /* @__PURE__ */ oe(qe, { children: [
564
572
  e,
565
- !r && i && n ? /* @__PURE__ */ U(
573
+ !r && i && n ? /* @__PURE__ */ N(
566
574
  t,
567
575
  {
568
576
  error: i,
@@ -571,26 +579,26 @@ const Xe = /* @__PURE__ */ new Set([
571
579
  }
572
580
  ) : null
573
581
  ] });
574
- }, vt = ({
582
+ }, St = ({
575
583
  resetErrorBoundary: e
576
- }) => /* @__PURE__ */ ue("div", { className: "twap-error-fallback", role: "alert", children: [
577
- /* @__PURE__ */ U("p", { children: "Something went wrong" }),
578
- /* @__PURE__ */ U("button", { type: "button", onClick: e, children: "Retry" })
579
- ] }), wt = ({
584
+ }) => /* @__PURE__ */ oe("div", { className: "twap-error-fallback", role: "alert", children: [
585
+ /* @__PURE__ */ N("p", { children: "Something went wrong" }),
586
+ /* @__PURE__ */ N("button", { type: "button", onClick: e, children: "Retry" })
587
+ ] }), Ot = ({
580
588
  children: e,
581
- fallback: t = vt
589
+ fallback: t = St
582
590
  }) => {
583
- const n = V(), r = v((i) => {
591
+ const n = W(), r = y((i) => {
584
592
  var s;
585
- (((s = n.getState().client.data) == null ? void 0 : s.analytics) ?? De).onCrash(i);
593
+ (((s = n.getState().client.data) == null ? void 0 : s.analytics) ?? Fe).onCrash(i);
586
594
  }, [n]);
587
- return /* @__PURE__ */ U(Ct, { fallback: t, reportCrash: r, children: e });
595
+ return /* @__PURE__ */ N(It, { fallback: t, reportCrash: r, children: e });
588
596
  };
589
- class Ct extends He {
597
+ class It extends We {
590
598
  constructor() {
591
599
  super(...arguments);
592
- oe(this, "state", {});
593
- oe(this, "resetErrorBoundary", () => {
600
+ te(this, "state", {});
601
+ te(this, "resetErrorBoundary", () => {
594
602
  this.setState({ error: void 0 });
595
603
  });
596
604
  }
@@ -604,7 +612,7 @@ class Ct extends He {
604
612
  const { error: n } = this.state;
605
613
  if (n) {
606
614
  const r = this.props.fallback;
607
- return /* @__PURE__ */ U(
615
+ return /* @__PURE__ */ N(
608
616
  r,
609
617
  {
610
618
  error: n,
@@ -615,109 +623,112 @@ class Ct extends He {
615
623
  return this.props.children;
616
624
  }
617
625
  }
618
- const yt = ({
626
+ const vt = ({
619
627
  children: e,
620
628
  defaults: t,
621
629
  scopeKey: n
622
630
  }) => {
623
- const r = V(), i = A(
631
+ const r = W(), i = A(
624
632
  (s) => s.state.currentExecution.phase
625
- ), o = je(n);
626
- return ie(() => {
627
- o.current === n || $(i) || r.getState().syncFormDefaults(t) && (o.current = n);
633
+ ), o = Oe(n);
634
+ return b(() => {
635
+ o.current === n || z(i) || r.getState().syncFormDefaults(t) && (o.current = n);
628
636
  }, [t, i, n, r]), e;
629
- }, Le = le(null), Rt = ({ children: e }) => {
637
+ }, Te = se(null), wt = ({ children: e }) => {
630
638
  const {
631
639
  inputToken: t,
632
640
  outputToken: n,
633
641
  inputAmountUi: r,
634
642
  quotedOutputAmountRaw: i,
635
- inputTokenUsdPrice: o,
636
- outputTokenUsdPrice: s,
637
- minTradeSizeUsd: a,
638
- inputBalanceRaw: c,
639
- displayFeePercent: h,
640
- priceProtectionPercent: p,
641
- module: u
642
- } = x(), g = A((f) => f.state.tradeCount), E = A((f) => f.state.tradeInterval), m = A((f) => f.state.orderDuration), S = A(
643
- (f) => f.state.limitPriceUi
644
- ), y = A(
645
- (f) => f.state.triggerPriceUi
646
- ), T = A(
647
- (f) => f.state.limitPricePercent
643
+ minimumOutputAmountRaw: o,
644
+ inputTokenUsdPrice: s,
645
+ outputTokenUsdPrice: a,
646
+ minTradeSizeUsd: c,
647
+ inputBalanceRaw: E,
648
+ displayFeePercent: O,
649
+ priceProtectionPercent: d,
650
+ module: m
651
+ } = R(), g = A((v) => v.state.tradeCount), h = A((v) => v.state.tradeInterval), S = A((v) => v.state.orderDuration), T = A(
652
+ (v) => v.state.limitPriceUi
648
653
  ), L = A(
649
- (f) => f.state.triggerPricePercent
654
+ (v) => v.state.triggerPriceUi
655
+ ), q = A(
656
+ (v) => v.state.limitPricePercent
650
657
  ), K = A(
651
- (f) => f.state.isPriceInverted
652
- ), M = A((f) => f.state.isMarketOrder), l = A((f) => {
653
- const B = f.state.currentExecution;
654
- return B.phase !== d.IDLE ? B.form : void 0;
655
- }), P = R(
658
+ (v) => v.state.triggerPricePercent
659
+ ), U = A(
660
+ (v) => v.state.isPriceInverted
661
+ ), f = A((v) => v.state.isMarketOrder), P = A((v) => {
662
+ const p = v.state.currentExecution;
663
+ return p.phase !== u.IDLE ? p.form : void 0;
664
+ }), I = C(
656
665
  () => ({
657
- module: u,
666
+ module: m,
658
667
  inputTokenDecimals: (t == null ? void 0 : t.decimals) ?? 0,
659
668
  outputTokenDecimals: (n == null ? void 0 : n.decimals) ?? 0,
660
669
  quotedOutputAmountRaw: i,
661
- inputTokenUsdPrice: o,
662
- outputTokenUsdPrice: s,
663
- minTradeSizeUsd: a,
664
- priceProtectionPercent: p,
665
- displayFeePercent: h,
666
- inputBalanceRaw: c,
670
+ minimumOutputAmountRaw: o,
671
+ inputTokenUsdPrice: s,
672
+ outputTokenUsdPrice: a,
673
+ minTradeSizeUsd: c,
674
+ priceProtectionPercent: d,
675
+ displayFeePercent: O,
676
+ inputBalanceRaw: E,
667
677
  userInput: {
668
678
  inputAmountUi: r,
669
- isMarketOrder: !!M,
679
+ isMarketOrder: !!f,
670
680
  tradeCount: g,
671
- tradeInterval: E,
672
- orderDuration: m,
673
- limitPriceUi: S,
674
- limitPricePercent: T,
675
- triggerPriceUi: y,
676
- triggerPricePercent: L,
677
- isPriceInverted: K
681
+ tradeInterval: h,
682
+ orderDuration: S,
683
+ limitPriceUi: T,
684
+ limitPricePercent: q,
685
+ triggerPriceUi: L,
686
+ triggerPricePercent: K,
687
+ isPriceInverted: U
678
688
  }
679
689
  }),
680
690
  [
691
+ o,
681
692
  n == null ? void 0 : n.decimals,
682
- s,
683
- h,
684
- i,
685
693
  a,
686
- u,
687
- p,
694
+ O,
695
+ i,
688
696
  c,
697
+ m,
698
+ d,
699
+ E,
689
700
  t == null ? void 0 : t.decimals,
690
- o,
701
+ s,
702
+ U,
703
+ f,
704
+ q,
691
705
  K,
692
- M,
693
- T,
694
- L,
695
706
  g,
696
- m,
697
- E,
698
707
  S,
708
+ h,
709
+ T,
699
710
  r,
700
- y
711
+ L
701
712
  ]
702
- ), O = R(() => {
703
- if (l) return l;
704
- const f = Ge(P);
705
- return t && n ? f : {
706
- ...f,
713
+ ), x = C(() => {
714
+ if (P) return P;
715
+ const v = Ne(I);
716
+ return t && n ? v : {
717
+ ...v,
707
718
  isReady: !1,
708
719
  canSubmit: !1
709
720
  };
710
- }, [l, t, n, P]);
711
- return /* @__PURE__ */ U(Le.Provider, { value: O, children: e });
712
- }, W = () => {
713
- const e = me(Le);
721
+ }, [P, t, n, I]);
722
+ return /* @__PURE__ */ N(Te.Provider, { value: x, children: e });
723
+ }, H = () => {
724
+ const e = ae(Te);
714
725
  if (!e)
715
726
  throw new Error("useOrderForm must be used within OrderFormProvider");
716
727
  return e;
717
- }, Tt = (e) => {
718
- var p, u, g, E, m, S, y, T, L, K, M, l;
719
- const t = Number.isSafeInteger(e.chainId) && Number(e.chainId) > 0, n = (p = e.wrappedNativeToken) == null ? void 0 : p.address, r = !!(n && (Q((u = e.inputToken) == null ? void 0 : u.address) && Pe(((g = e.outputToken) == null ? void 0 : g.address) || "", n) || Pe(((E = e.inputToken) == null ? void 0 : E.address) || "", n) && Q((m = e.outputToken) == null ? void 0 : m.address))), i = r ? k(e.inputAmountUi, (S = e.outputToken) == null ? void 0 : S.decimals) : e.marketQuote.isLoading ? void 0 : e.marketQuote.quotedOutputAmountRaw, o = r ? !1 : e.marketQuote.isLoading, s = r ? !1 : e.marketQuote.noLiquidity, a = R(
720
- () => ye({
728
+ }, pt = (e) => {
729
+ var O, d, m, g, h, S, T, L, q, K, U, f;
730
+ const t = Number.isSafeInteger(e.chainId) && Number(e.chainId) > 0, n = (O = e.wrappedNativeToken) == null ? void 0 : O.address, r = !!(n && ($((d = e.inputToken) == null ? void 0 : d.address) && ue(((m = e.outputToken) == null ? void 0 : m.address) || "", n) || ue(((g = e.inputToken) == null ? void 0 : g.address) || "", n) && $((h = e.outputToken) == null ? void 0 : h.address))), i = r ? Y(e.inputAmountUi, (S = e.outputToken) == null ? void 0 : S.decimals) : e.marketQuote.isLoading ? void 0 : e.marketQuote.quotedOutputAmountRaw, o = r ? !1 : e.marketQuote.isLoading, s = r ? !1 : e.marketQuote.noLiquidity, a = C(
731
+ () => Ae({
721
732
  module: e.module,
722
733
  overrides: e.overrides
723
734
  }),
@@ -726,20 +737,21 @@ const yt = ({
726
737
  e.partner,
727
738
  e.chainId,
728
739
  e.module,
729
- (y = e.inputToken) == null ? void 0 : y.address,
730
- (T = e.inputToken) == null ? void 0 : T.decimals,
731
- (L = e.outputToken) == null ? void 0 : L.address,
740
+ (T = e.inputToken) == null ? void 0 : T.address,
741
+ (L = e.inputToken) == null ? void 0 : L.decimals,
742
+ (q = e.outputToken) == null ? void 0 : q.address,
732
743
  (K = e.outputToken) == null ? void 0 : K.decimals,
733
- (M = e.wrappedNativeToken) == null ? void 0 : M.address,
734
- (l = e.wrappedNativeToken) == null ? void 0 : l.decimals,
744
+ (U = e.wrappedNativeToken) == null ? void 0 : U.address,
745
+ (f = e.wrappedNativeToken) == null ? void 0 : f.decimals,
735
746
  a
736
- ]), h = R(
747
+ ]), E = C(
737
748
  () => ({
738
749
  inputAmountUi: e.inputAmountUi,
739
750
  minTradeSizeUsd: e.minTradeSizeUsd,
740
751
  account: e.account,
741
752
  walletInteractions: e.walletInteractions,
742
753
  quotedOutputAmountRaw: i,
754
+ minimumOutputAmountRaw: e.marketQuote.isLoading ? void 0 : e.marketQuote.minimumOutputAmountRaw,
743
755
  marketPriceLoading: o,
744
756
  noLiquidity: s,
745
757
  priceProtectionPercent: e.priceProtectionPercent,
@@ -759,6 +771,8 @@ const yt = ({
759
771
  overrides: e.overrides
760
772
  }),
761
773
  [
774
+ e.marketQuote.isLoading,
775
+ e.marketQuote.minimumOutputAmountRaw,
762
776
  e.account,
763
777
  e.callbacks,
764
778
  e.chainId,
@@ -783,29 +797,29 @@ const yt = ({
783
797
  i
784
798
  ]
785
799
  );
786
- return { initialState: a, formScopeKey: c, trading: h };
787
- }, $t = (e) => {
788
- const { initialState: t, formScopeKey: n, trading: r } = Tt(e);
789
- return /* @__PURE__ */ U(Ye, { value: r, children: /* @__PURE__ */ U(gt, { initialState: t, children: /* @__PURE__ */ U(wt, { fallback: e.errorFallback, children: /* @__PURE__ */ U(Ot, { children: /* @__PURE__ */ U(
790
- yt,
800
+ return { initialState: a, formScopeKey: c, trading: E };
801
+ }, Vt = (e) => {
802
+ const { initialState: t, formScopeKey: n, trading: r } = pt(e);
803
+ return /* @__PURE__ */ N(ze, { value: r, children: /* @__PURE__ */ N(ct, { initialState: t, children: /* @__PURE__ */ N(Ot, { fallback: e.errorFallback, children: /* @__PURE__ */ N(ht, { children: /* @__PURE__ */ N(
804
+ vt,
791
805
  {
792
806
  defaults: t,
793
807
  scopeKey: n,
794
- children: /* @__PURE__ */ U(At, { fallback: e.clientErrorFallback, children: /* @__PURE__ */ U(Rt, { children: e.children }) })
808
+ children: /* @__PURE__ */ N(Et, { fallback: e.clientErrorFallback, children: /* @__PURE__ */ N(wt, { children: e.children }) })
795
809
  }
796
810
  ) }) }) }) });
797
- }, Qt = (e, t) => R(() => ne(t, e), [e, t]), Nt = 60, Lt = () => {
798
- const { refetch: e } = Ne();
799
- return v(
811
+ }, jt = (e, t) => C(() => ee(t, e), [e, t]), At = 60, yt = () => {
812
+ const { refetch: e } = Ce();
813
+ return y(
800
814
  async (t, n = !1) => {
801
- for (let r = 0; r < Nt; r++) {
815
+ for (let r = 0; r < At; r++) {
802
816
  const i = await e(n);
803
817
  if (!i)
804
818
  throw new Error("orders not found");
805
819
  const o = i.find(
806
820
  (s) => s.historyKey === t
807
821
  );
808
- if ((o == null ? void 0 : o.status) === J.Cancelled)
822
+ if ((o == null ? void 0 : o.status) === V.Cancelled)
809
823
  return;
810
824
  await new Promise((s) => setTimeout(s, 1e3));
811
825
  }
@@ -815,52 +829,52 @@ const yt = ({
815
829
  },
816
830
  [e]
817
831
  );
818
- }, xt = (e) => ({
832
+ }, Ct = (e) => ({
819
833
  ...e,
820
- status: J.Cancelled
821
- }), Yt = (e) => {
822
- const { account: t, walletInteractions: n, callbacks: r } = x(), { data: i } = Y(), o = Lt(), s = A((u) => u.state.cancelOrders[(e == null ? void 0 : e.historyKey) ?? ""]), a = A((u) => u.setCancelOrder), c = A((u) => u.clearCancelOrder), h = v(async () => {
823
- const u = e == null ? void 0 : e.historyKey;
834
+ status: V.Cancelled
835
+ }), Jt = (e) => {
836
+ const { account: t, walletInteractions: n, callbacks: r } = R(), { data: i } = J(), o = yt(), s = A((d) => d.state.cancelOrders[(e == null ? void 0 : e.historyKey) ?? ""]), a = A((d) => d.setCancelOrder), c = A((d) => d.clearCancelOrder), E = y(async () => {
837
+ const d = e == null ? void 0 : e.historyKey;
824
838
  try {
825
839
  if (!t) throw new Error("missing account");
826
840
  if (!e) throw new Error("order is required");
827
841
  if (!i) throw new Error("Spot client is unavailable");
828
- const g = e.historyKey;
829
- a(g, { status: q.LOADING }), I(() => {
830
- var y;
831
- return (y = r == null ? void 0 : r.onCancelOrderRequest) == null ? void 0 : y.call(r, e);
832
- }), I(
842
+ const m = e.historyKey;
843
+ a(m, { status: _.LOADING }), w(() => {
844
+ var T;
845
+ return (T = r == null ? void 0 : r.onCancelOrderRequest) == null ? void 0 : T.call(r, e);
846
+ }), w(
833
847
  () => i.analytics.onCancelOrderRequest(
834
848
  [e.version === 1 ? e.id.toString() : e.hash],
835
849
  e.version
836
850
  )
837
851
  );
838
- const E = i.getCancelOrderRequest(e), m = await n.cancelOrder(E);
839
- if (!m) throw new Error("failed to cancel order");
840
- I(() => i.analytics.onCancelOrderSuccess(m)), a(g, {
841
- status: q.LOADING,
842
- txHash: m
843
- }), await o(g, e.version === 1);
844
- const S = xt(e);
845
- return a(g, {
846
- status: q.SUCCESS,
847
- txHash: m
848
- }), I(
852
+ const g = i.getCancelOrderRequest(e), h = await n.cancelOrder(g);
853
+ if (!h) throw new Error("failed to cancel order");
854
+ w(() => i.analytics.onCancelOrderSuccess(h)), a(m, {
855
+ status: _.LOADING,
856
+ txHash: h
857
+ }), await o(m, e.version === 1);
858
+ const S = Ct(e);
859
+ return a(m, {
860
+ status: _.SUCCESS,
861
+ txHash: h
862
+ }), w(
849
863
  () => {
850
- var y;
851
- return (y = r == null ? void 0 : r.onCancelOrderSuccess) == null ? void 0 : y.call(r, {
864
+ var T;
865
+ return (T = r == null ? void 0 : r.onCancelOrderSuccess) == null ? void 0 : T.call(r, {
852
866
  order: S,
853
- txHash: m
867
+ txHash: h
854
868
  });
855
869
  }
856
- ), m;
857
- } catch (g) {
858
- ve(g) ? u && c(u) : (u && a(u, {
859
- status: q.FAILED,
860
- error: ge(g)
861
- }), I(() => i == null ? void 0 : i.analytics.onCancelOrderError(g))), I(() => {
862
- var E;
863
- return (E = r == null ? void 0 : r.onCancelOrderFailed) == null ? void 0 : E.call(r, re(g));
870
+ ), h;
871
+ } catch (m) {
872
+ Ee(m) ? d && c(d) : (d && a(d, {
873
+ status: _.FAILED,
874
+ error: ce(m)
875
+ }), w(() => i == null ? void 0 : i.analytics.onCancelOrderError(m))), w(() => {
876
+ var g;
877
+ return (g = r == null ? void 0 : r.onCancelOrderFailed) == null ? void 0 : g.call(r, k(m));
864
878
  });
865
879
  }
866
880
  }, [
@@ -872,46 +886,46 @@ const yt = ({
872
886
  o,
873
887
  a,
874
888
  n
875
- ]), p = R(() => {
876
- const u = s;
889
+ ]), O = C(() => {
890
+ const d = s;
877
891
  return {
878
- isLoading: (u == null ? void 0 : u.status) === q.LOADING,
892
+ isLoading: (d == null ? void 0 : d.status) === _.LOADING,
879
893
  disabled: !!(e && !i),
880
- isSuccess: (u == null ? void 0 : u.status) === q.SUCCESS,
881
- isError: (u == null ? void 0 : u.status) === q.FAILED,
882
- error: u == null ? void 0 : u.error,
883
- txHash: u == null ? void 0 : u.txHash
894
+ isSuccess: (d == null ? void 0 : d.status) === _.SUCCESS,
895
+ isError: (d == null ? void 0 : d.status) === _.FAILED,
896
+ error: d == null ? void 0 : d.error,
897
+ txHash: d == null ? void 0 : d.txHash
884
898
  };
885
899
  }, [s, e, i]);
886
- return R(() => ({ cancelOrder: h, ...p }), [h, p]);
887
- }, Xt = () => {
888
- const { module: e, values: t } = W();
889
- if (t.isMarketOrder && e === X.STOP_LOSS)
890
- return ee.TRIGGER_MARKET_PRICE;
891
- if (e === X.LIMIT || e === X.TWAP)
892
- return t.isMarketOrder ? ee.MARKET_PRICE : ee.LIMIT_PRICE;
893
- }, Zt = () => {
894
- const { callbacks: e } = x(), t = A((a) => a.updateState), { schedule: n } = W(), { duration: r } = n, i = v(
900
+ return C(() => ({ cancelOrder: E, ...O }), [E, O]);
901
+ }, Qt = () => {
902
+ const { module: e, values: t } = H();
903
+ if (t.isMarketOrder && e === j.STOP_LOSS)
904
+ return X.TRIGGER_MARKET_PRICE;
905
+ if (e === j.LIMIT || e === j.TWAP)
906
+ return t.isMarketOrder ? X.MARKET_PRICE : X.LIMIT_PRICE;
907
+ }, zt = () => {
908
+ const { callbacks: e } = R(), t = A((a) => a.updateState), { schedule: n } = H(), { duration: r } = n, i = y(
895
909
  (a) => {
896
- t({ orderDuration: a }), I(() => {
910
+ t({ orderDuration: a }), w(() => {
897
911
  var c;
898
912
  return (c = e == null ? void 0 : e.onOrderDurationChange) == null ? void 0 : c.call(e, a);
899
913
  });
900
914
  },
901
915
  [e, t]
902
- ), o = v(
916
+ ), o = y(
903
917
  (a) => {
904
918
  const c = Number(a);
905
919
  Number.isFinite(c) && i({ unit: r.unit, value: c });
906
920
  },
907
921
  [r.unit, i]
908
- ), s = v(
922
+ ), s = y(
909
923
  (a) => {
910
924
  i({ unit: a, value: r.value });
911
925
  },
912
926
  [r.value, i]
913
927
  );
914
- return R(
928
+ return C(
915
929
  () => ({
916
930
  duration: r,
917
931
  onChange: i,
@@ -922,26 +936,26 @@ const yt = ({
922
936
  }),
923
937
  [r, i, o, s, n]
924
938
  );
925
- }, bt = () => {
926
- const { callbacks: e } = x(), t = A((a) => a.updateState), { schedule: n } = W(), { fillDelay: r } = n, i = v(
939
+ }, $t = () => {
940
+ const { callbacks: e } = R(), t = A((a) => a.updateState), { schedule: n } = H(), { fillDelay: r } = n, i = y(
927
941
  (a) => {
928
- t({ tradeInterval: a }), I(() => {
942
+ t({ tradeInterval: a }), w(() => {
929
943
  var c;
930
944
  return (c = e == null ? void 0 : e.onTradeIntervalChange) == null ? void 0 : c.call(e, a);
931
945
  });
932
946
  },
933
947
  [e, t]
934
- ), o = v(
948
+ ), o = y(
935
949
  (a) => {
936
950
  const c = Number(a);
937
951
  Number.isFinite(c) && i({ unit: r.unit, value: c });
938
952
  },
939
953
  [r.unit, i]
940
- ), s = v(
954
+ ), s = y(
941
955
  (a) => i({ unit: a, value: r.value }),
942
956
  [r.value, i]
943
957
  );
944
- return R(
958
+ return C(
945
959
  () => ({
946
960
  onInputChange: o,
947
961
  onUnitSelect: s,
@@ -952,55 +966,55 @@ const yt = ({
952
966
  }),
953
967
  [r, i, o, s, n]
954
968
  );
955
- }, _ = (e, t) => ({
969
+ }, B = (e, t) => ({
956
970
  raw: e || "",
957
- ui: ne(e, t)
958
- }), Ft = (e, t, n) => R(() => !e || !t || !n ? [] : e.map((r) => ({
971
+ ui: ee(e, t)
972
+ }), Tt = (e, t, n) => C(() => !e || !t || !n ? [] : e.map((r) => ({
959
973
  rawFill: r,
960
974
  inputToken: t,
961
975
  outputToken: n,
962
- inputAmount: _(r.inAmount, t.decimals),
963
- outputAmount: _(r.outAmount, n.decimals),
976
+ inputAmount: B(r.inAmount, t.decimals),
977
+ outputAmount: B(r.outAmount, n.decimals),
964
978
  timestamp: r.timestamp,
965
979
  txHash: r.txHash,
966
- executionRate: we(
980
+ executionRate: Se(
967
981
  r.inAmount,
968
982
  r.outAmount,
969
983
  t.decimals,
970
984
  n.decimals
971
985
  )
972
- })), [e, t, n]), kt = (e, t, n) => {
973
- const { chainId: r, partner: i } = x(), o = R(() => {
986
+ })), [e, t, n]), bt = (e, t, n) => {
987
+ const { chainId: r, partner: i } = R(), o = C(() => {
974
988
  if (!(!t || !n || !e || e.isMarketPrice))
975
- return Me(
989
+ return Ue(
976
990
  e,
977
991
  t.decimals,
978
992
  n.decimals
979
993
  );
980
- }, [t, e, n]), s = R(() => {
994
+ }, [t, e, n]), s = C(() => {
981
995
  if (!(!t || !n || !e))
982
- return Be(
996
+ return De(
983
997
  e,
984
998
  t.decimals,
985
999
  n.decimals
986
1000
  );
987
- }, [t, e, n]), a = R(() => {
1001
+ }, [t, e, n]), a = C(() => {
988
1002
  if (!(!t || !n || !e))
989
- return we(
1003
+ return Se(
990
1004
  e.srcAmountFilled,
991
1005
  e.dstAmountFilled,
992
1006
  t.decimals,
993
1007
  n.decimals
994
1008
  );
995
- }, [t, e, n]), c = R(() => e ? _e(
1009
+ }, [t, e, n]), c = C(() => e ? Me(
996
1010
  e,
997
- r ? qe(i, r) : void 0
998
- ) : 0, [e, i, r]), h = Ft(e == null ? void 0 : e.fills, t, n);
999
- return R(() => {
1011
+ r ? Ge(i, r) : void 0
1012
+ ) : 0, [e, i, r]), E = Tt(e == null ? void 0 : e.fills, t, n);
1013
+ return C(() => {
1000
1014
  if (e != null && e.id)
1001
1015
  return {
1002
1016
  original: e,
1003
- fills: h,
1017
+ fills: E,
1004
1018
  inputToken: t,
1005
1019
  outputToken: n,
1006
1020
  orderType: e.type,
@@ -1009,46 +1023,46 @@ const yt = ({
1009
1023
  totalTrades: e.totalTradesAmount || 0,
1010
1024
  tradeInterval: c,
1011
1025
  recipient: e.maker || "",
1012
- inputAmount: _(e.srcAmount, t == null ? void 0 : t.decimals),
1013
- limitPrice: _(
1014
- k(o, n == null ? void 0 : n.decimals),
1026
+ inputAmount: B(e.srcAmount, t == null ? void 0 : t.decimals),
1027
+ limitPrice: B(
1028
+ Y(o, n == null ? void 0 : n.decimals),
1015
1029
  n == null ? void 0 : n.decimals
1016
1030
  ),
1017
- inputAmountPerTrade: _(
1031
+ inputAmountPerTrade: B(
1018
1032
  e.srcAmountPerTrade,
1019
1033
  t == null ? void 0 : t.decimals
1020
1034
  ),
1021
- minOutputAmountPerTrade: _(
1035
+ minOutputAmountPerTrade: B(
1022
1036
  e.dstMinAmountPerTrade,
1023
1037
  n == null ? void 0 : n.decimals
1024
1038
  ),
1025
- minOutputAmount: _(
1039
+ minOutputAmount: B(
1026
1040
  e.dstMinAmountTotal,
1027
1041
  n == null ? void 0 : n.decimals
1028
1042
  ),
1029
- triggerPrice: _(
1030
- k(s, n == null ? void 0 : n.decimals),
1043
+ triggerPrice: B(
1044
+ Y(s, n == null ? void 0 : n.decimals),
1031
1045
  n == null ? void 0 : n.decimals
1032
1046
  ),
1033
1047
  id: e.id,
1034
- inputAmountFilled: _(
1048
+ inputAmountFilled: B(
1035
1049
  e.srcAmountFilled,
1036
1050
  t == null ? void 0 : t.decimals
1037
1051
  ),
1038
- outputAmountFilled: _(
1052
+ outputAmountFilled: B(
1039
1053
  e.dstAmountFilled,
1040
1054
  n == null ? void 0 : n.decimals
1041
1055
  ),
1042
1056
  progress: e.progress,
1043
- executionPrice: _(
1044
- k(a, n == null ? void 0 : n.decimals),
1057
+ executionPrice: B(
1058
+ Y(a, n == null ? void 0 : n.decimals),
1045
1059
  n == null ? void 0 : n.decimals
1046
1060
  ),
1047
1061
  version: e.version
1048
1062
  };
1049
1063
  }, [
1050
1064
  e,
1051
- h,
1065
+ E,
1052
1066
  t,
1053
1067
  n,
1054
1068
  c,
@@ -1056,96 +1070,96 @@ const yt = ({
1056
1070
  s,
1057
1071
  a
1058
1072
  ]);
1059
- }, er = () => {
1060
- const { marketPriceLoading: e } = x(), t = W().errors.primary;
1073
+ }, Yt = () => {
1074
+ const { marketPriceLoading: e } = R(), t = H().errors.primary;
1061
1075
  return e ? void 0 : t;
1062
- }, tr = () => {
1063
- const { marketPriceLoading: e, inputToken: t, outputToken: n, callbacks: r } = x(), { limitPrice: i, values: o, module: s, isInverted: a } = W(), c = A((m) => m.updateState), h = v(
1064
- (m) => {
1065
- c({ limitPriceUi: m, limitPricePercent: null }), I(() => {
1076
+ }, Xt = () => {
1077
+ const { marketPriceLoading: e, inputToken: t, outputToken: n, callbacks: r } = R(), { limitPrice: i, values: o, module: s, isInverted: a } = H(), c = A((h) => h.updateState), E = y(
1078
+ (h) => {
1079
+ c({ limitPriceUi: h, limitPricePercent: null }), w(() => {
1066
1080
  var S;
1067
- return (S = r == null ? void 0 : r.onLimitPriceChange) == null ? void 0 : S.call(r, m || "");
1068
- }), I(() => {
1081
+ return (S = r == null ? void 0 : r.onLimitPriceChange) == null ? void 0 : S.call(r, h || "");
1082
+ }), w(() => {
1069
1083
  var S;
1070
1084
  return (S = r == null ? void 0 : r.onLimitPricePercentChange) == null ? void 0 : S.call(r, "");
1071
1085
  });
1072
1086
  },
1073
1087
  [r, c]
1074
- ), p = v(
1075
- (m) => {
1088
+ ), O = y(
1089
+ (h) => {
1076
1090
  c({
1077
1091
  limitPriceUi: void 0,
1078
- limitPricePercent: m
1079
- }), I(() => {
1092
+ limitPricePercent: h
1093
+ }), w(() => {
1080
1094
  var S;
1081
1095
  return (S = r == null ? void 0 : r.onLimitPriceChange) == null ? void 0 : S.call(r, "");
1082
- }), I(() => {
1096
+ }), w(() => {
1083
1097
  var S;
1084
- return (S = r == null ? void 0 : r.onLimitPricePercentChange) == null ? void 0 : S.call(r, m || "");
1098
+ return (S = r == null ? void 0 : r.onLimitPricePercentChange) == null ? void 0 : S.call(r, h || "");
1085
1099
  });
1086
1100
  },
1087
1101
  [r, c]
1088
- ), u = v(() => {
1102
+ ), d = y(() => {
1089
1103
  c({
1090
1104
  limitPriceUi: void 0,
1091
1105
  limitPricePercent: void 0
1092
1106
  });
1093
- }, [c]), g = !o.isMarketOrder, E = v(() => {
1107
+ }, [c]), m = !o.isMarketOrder, g = y(() => {
1094
1108
  c({
1095
1109
  isMarketOrder: !o.isMarketOrder,
1096
1110
  ...o.isMarketOrder ? {} : { isPriceInverted: !1 },
1097
- ...!o.isMarketOrder && s === X.STOP_LOSS ? { limitPricePercent: void 0 } : {}
1111
+ ...!o.isMarketOrder && s === j.STOP_LOSS ? { limitPricePercent: void 0 } : {}
1098
1112
  });
1099
1113
  }, [s, c, o.isMarketOrder]);
1100
- return R(
1114
+ return C(
1101
1115
  () => ({
1102
1116
  price: i.display,
1103
1117
  canonicalPriceRaw: i.raw,
1104
1118
  error: i.error,
1105
- onInputChange: h,
1106
- onPercentageChange: p,
1107
- onReset: u,
1119
+ onInputChange: E,
1120
+ onPercentageChange: O,
1121
+ onReset: d,
1108
1122
  inputToken: t,
1109
1123
  outputToken: n,
1110
1124
  displayInputToken: a ? n : t,
1111
1125
  displayOutputToken: a ? t : n,
1112
1126
  percentage: i.percentage,
1113
1127
  isLoading: !!e,
1114
- isEnabled: g,
1115
- toggle: E,
1128
+ isEnabled: m,
1129
+ toggle: g,
1116
1130
  isTypedValue: i.isTypedValue
1117
1131
  }),
1118
1132
  [
1119
1133
  t,
1120
1134
  a,
1121
- g,
1135
+ m,
1122
1136
  i,
1123
1137
  e,
1124
- h,
1125
- p,
1126
- u,
1138
+ E,
1139
+ O,
1140
+ d,
1127
1141
  n,
1128
- E
1142
+ g
1129
1143
  ]
1130
1144
  );
1131
- }, rr = () => {
1132
- const { marketPriceLoading: e } = x(), { outputAmount: t } = W();
1133
- return R(
1145
+ }, Zt = () => {
1146
+ const { marketPriceLoading: e } = R(), { outputAmount: t } = H();
1147
+ return C(
1134
1148
  () => ({
1135
1149
  amount: t,
1136
1150
  isLoading: !!e
1137
1151
  }),
1138
1152
  [e, t]
1139
1153
  );
1140
- }, nr = () => {
1141
- const { inputToken: e, outputToken: t } = x(), n = A((c) => c.updateState), { isInverted: r, values: i } = W(), o = A((c) => c.state.triggerPriceUi), s = A((c) => c.state.limitPriceUi), a = v(() => {
1154
+ }, kt = () => {
1155
+ const { inputToken: e, outputToken: t } = R(), n = A((c) => c.updateState), { isInverted: r, values: i } = H(), o = A((c) => c.state.triggerPriceUi), s = A((c) => c.state.limitPriceUi), a = y(() => {
1142
1156
  n({
1143
1157
  isPriceInverted: !r,
1144
- ...o !== void 0 ? { triggerPriceUi: fe(o) } : {},
1145
- ...s !== void 0 ? { limitPriceUi: fe(s) } : {}
1158
+ ...o !== void 0 ? { triggerPriceUi: le(o) } : {},
1159
+ ...s !== void 0 ? { limitPriceUi: le(s) } : {}
1146
1160
  });
1147
1161
  }, [n, r, o, s]);
1148
- return R(
1162
+ return C(
1149
1163
  () => ({
1150
1164
  onInvert: a,
1151
1165
  isInverted: r,
@@ -1157,37 +1171,49 @@ const yt = ({
1157
1171
  }),
1158
1172
  [e, r, a, t, i.isMarketOrder]
1159
1173
  );
1160
- }, pe = 3, Ut = 3e3, Dt = (e) => new Promise((t) => setTimeout(t, e)), de = (e, t) => {
1174
+ }, Rt = async ({ store: e, callbacks: t, order: n, executionId: r, signal: i }) => {
1175
+ const o = new AbortController(), s = () => {
1176
+ (i.aborted || e.getState().state.currentExecution.executionId !== r) && o.abort();
1177
+ };
1178
+ i.addEventListener("abort", s, { once: !0 });
1179
+ const a = e.subscribe(s);
1180
+ s();
1181
+ try {
1182
+ let c = n;
1183
+ for await (const E of Be({ order: n, signal: o.signal }))
1184
+ o.signal.aborted || (w(() => {
1185
+ const O = e.getState().orders.data ?? [n], d = O.find((m) => m.historyKey === n.historyKey);
1186
+ e.setState((m) => ({ orders: {
1187
+ ...m.orders,
1188
+ data: pe(m.orders.data, d ? O.map((g) => g.historyKey === n.historyKey ? E : g) : [E, ...O])
1189
+ } })), we([d ?? n], [E], t);
1190
+ }), c = E);
1191
+ return c;
1192
+ } finally {
1193
+ a(), i.removeEventListener("abort", s), o.abort();
1194
+ }
1195
+ }, Lt = (e) => new Promise((t) => setTimeout(t, e)), xt = (e, t) => {
1161
1196
  if (!/^\d+$/.test(e))
1162
1197
  throw new Error(
1163
1198
  `${t} must be a non-negative integer base-unit amount`
1164
1199
  );
1165
1200
  return BigInt(e);
1166
- }, Ae = async ({
1167
- client: e,
1168
- walletInteractions: t,
1169
- tokenAddress: n,
1170
- inputAmountRaw: r
1171
- }) => {
1172
- const i = await t.getAllowance({
1173
- tokenAddress: n,
1174
- spenderAddress: e.spenderAddress
1175
- });
1176
- return de(i || "0", "Allowance") >= de(r, "Input amount");
1177
- }, Gt = (e) => {
1201
+ }, Ft = (e) => {
1178
1202
  if (!e.client) throw new Error("Spot client is unavailable");
1179
- if (!e.hasChainId || !e.chainId)
1203
+ if (!e.chainId || !Number.isSafeInteger(e.chainId) || e.chainId <= 0)
1180
1204
  throw new Error("Spot is unavailable on the connected chain");
1181
1205
  if (!e.account) throw new Error("missing account");
1182
1206
  if (!e.inputToken) throw new Error("missing inputToken");
1183
1207
  if (!e.outputToken) throw new Error("missing outputToken");
1184
- const t = Q(e.inputToken.address) ? e.wrappedNativeToken : e.inputToken;
1185
- if (!t || Q(t.address))
1208
+ const t = $(e.inputToken.address) ? e.wrappedNativeToken : e.inputToken;
1209
+ if (!t || $(t.address))
1186
1210
  throw new Error("missing wrappedNativeToken for native input");
1187
1211
  if (!e.form.canSubmit)
1188
1212
  throw new Error("Order form is not submittable");
1213
+ if (e.form.module === j.SWAP && !e.waitForOrderFill)
1214
+ throw new Error("Swap settlement tracking is unavailable");
1189
1215
  const n = e.form.inputAmount.raw;
1190
- return de(n, "Input amount"), {
1216
+ return xt(n, "Input amount"), {
1191
1217
  account: e.account,
1192
1218
  chainId: e.chainId,
1193
1219
  inputToken: e.inputToken,
@@ -1196,7 +1222,7 @@ const yt = ({
1196
1222
  client: e.client,
1197
1223
  inputAmountRaw: n
1198
1224
  };
1199
- }, Mt = ({
1225
+ }, Nt = ({
1200
1226
  analytics: e,
1201
1227
  account: t,
1202
1228
  chainId: n,
@@ -1205,7 +1231,7 @@ const yt = ({
1205
1231
  preparedOrder: o
1206
1232
  }) => {
1207
1233
  const { form: s, values: a } = o;
1208
- I(
1234
+ w(
1209
1235
  () => e.onRequestOrder({
1210
1236
  account: t,
1211
1237
  chainId: n,
@@ -1223,7 +1249,7 @@ const yt = ({
1223
1249
  chunksAmount: a.totalTrades
1224
1250
  })
1225
1251
  );
1226
- }, Bt = async (e) => {
1252
+ }, Ut = async (e) => {
1227
1253
  const {
1228
1254
  form: t,
1229
1255
  walletInteractions: n,
@@ -1233,13 +1259,13 @@ const yt = ({
1233
1259
  getCurrentExecution: s,
1234
1260
  beginExecution: a,
1235
1261
  replaceExecution: c,
1236
- wait: h = Dt
1262
+ wait: E = Lt
1237
1263
  } = e;
1238
- let p;
1264
+ let O;
1239
1265
  try {
1240
- p = Gt(e);
1241
- } catch (w) {
1242
- const F = re(w), C = se(w), D = a({
1266
+ O = Ft(e);
1267
+ } catch (p) {
1268
+ const F = k(p), l = re(p), D = a({
1243
1269
  form: t,
1244
1270
  inputToken: e.inputToken,
1245
1271
  outputToken: e.outputToken,
@@ -1247,256 +1273,207 @@ const yt = ({
1247
1273
  });
1248
1274
  throw D && c(D.executionId, {
1249
1275
  ...D,
1250
- phase: d.FAILED,
1276
+ phase: u.FAILED,
1251
1277
  error: F,
1252
- parsedError: C
1253
- }), I(
1278
+ parsedError: l
1279
+ }), w(
1254
1280
  () => {
1255
1281
  var G;
1256
- return (G = r == null ? void 0 : r.onSubmitOrderFailed) == null ? void 0 : G.call(r, C);
1282
+ return (G = r == null ? void 0 : r.onSubmitOrderFailed) == null ? void 0 : G.call(r, l);
1257
1283
  }
1258
1284
  ), F;
1259
1285
  }
1260
1286
  const {
1261
- account: u,
1262
- chainId: g,
1263
- inputToken: E,
1264
- orderInputToken: m,
1287
+ account: d,
1288
+ chainId: m,
1289
+ inputToken: g,
1290
+ orderInputToken: h,
1265
1291
  outputToken: S,
1266
- client: y,
1267
- inputAmountRaw: T
1268
- } = p, { analytics: L } = y, K = s(), M = nt({
1292
+ client: T,
1293
+ inputAmountRaw: L
1294
+ } = O, { analytics: q } = T, K = s(), U = et({
1269
1295
  execution: K,
1270
- account: u,
1271
- chainId: g,
1272
- inputTokenAddress: E.address,
1273
- inputAmountRaw: T
1274
- }), l = a({
1296
+ account: d,
1297
+ chainId: m,
1298
+ inputTokenAddress: g.address,
1299
+ inputAmountRaw: L
1300
+ }), f = a({
1275
1301
  form: t,
1276
- inputToken: E,
1302
+ inputToken: g,
1277
1303
  outputToken: S,
1278
- chainId: g,
1279
- completedWrap: M,
1280
- wrapTxHash: M == null ? void 0 : M.txHash
1304
+ chainId: m,
1305
+ completedWrap: U,
1306
+ wrapTxHash: U == null ? void 0 : U.txHash
1281
1307
  });
1282
- if (!l) return;
1283
- const P = l.executionId;
1284
- let O = l;
1285
- const f = (w, F = {}) => {
1286
- const C = {
1287
- ...O,
1308
+ if (!f) return;
1309
+ const P = f.executionId;
1310
+ let I = f;
1311
+ const x = (p, F = {}) => {
1312
+ const l = {
1313
+ ...I,
1288
1314
  ...F,
1289
1315
  executionId: P,
1290
- phase: w
1316
+ phase: p
1291
1317
  };
1292
- if (!c(P, C))
1318
+ if (!c(P, l))
1293
1319
  throw new Error("Execution is no longer current");
1294
- O = C;
1295
- }, B = (w, F = {}) => {
1296
- const C = {
1297
- ...O,
1320
+ I = l;
1321
+ }, v = (p, F = {}) => {
1322
+ const l = {
1323
+ ...I,
1298
1324
  ...F,
1299
1325
  executionId: P,
1300
- phase: w
1326
+ phase: p
1301
1327
  };
1302
- return c(P, C) ? (O = C, !0) : !1;
1328
+ return c(P, l) ? (I = l, !0) : !1;
1303
1329
  };
1304
1330
  try {
1305
- const w = Q(E.address) && !M, F = !await Ae({
1306
- client: y,
1331
+ const { order: p } = await _e({
1332
+ client: T,
1333
+ account: d,
1334
+ inputTokenAddress: h.address,
1335
+ inputAmountRaw: L,
1336
+ nativeInput: $(g.address),
1337
+ completedWrapTxHash: U == null ? void 0 : U.txHash,
1307
1338
  walletInteractions: n,
1308
- tokenAddress: m.address,
1309
- inputAmountRaw: T
1310
- }), C = [];
1311
- w && C.push(z.WRAP), F && C.push(z.APPROVE), C.push(z.CREATE);
1312
- let D = 0;
1313
- if (f(d.PREPARING, {
1314
- pendingSteps: C,
1315
- totalSteps: C.length,
1316
- stepIndex: D,
1317
- hasApproval: !F
1318
- }), w) {
1319
- f(d.WRAPPING), I(() => L.onWrapRequest()), I(r == null ? void 0 : r.onWrapRequest);
1320
- const N = await n.wrapNativeToken(
1321
- T
1322
- );
1323
- if (!N) throw new Error("failed to wrap input token");
1324
- const j = {
1325
- account: u,
1326
- chainId: g,
1327
- inputTokenAddress: E.address,
1328
- inputAmountRaw: T,
1329
- txHash: N
1330
- };
1331
- D++, f(d.WRAPPING, {
1332
- wrapTxHash: N,
1333
- completedWrap: j,
1334
- stepIndex: D
1335
- }), I(() => L.onWrapSuccess(N)), I(
1336
- () => {
1337
- var H;
1338
- return (H = r == null ? void 0 : r.onWrapSuccess) == null ? void 0 : H.call(r, {
1339
- txHash: N,
1340
- amount: ne(T, m.decimals)
1341
- });
1342
- }
1343
- );
1344
- }
1345
- if (F) {
1346
- f(d.APPROVING), I(() => L.onApproveRequest()), I(r == null ? void 0 : r.onApproveRequest);
1347
- const N = await n.approveToken({
1348
- tokenAddress: m.address,
1349
- amount: T,
1350
- spenderAddress: y.spenderAddress
1351
- });
1352
- if (!N) throw new Error("failed to approve token");
1353
- f(d.APPROVING, { approveTxHash: N });
1354
- let j = !1;
1355
- for (let H = 0; H < pe && (j = await Ae({
1356
- client: y,
1357
- walletInteractions: n,
1358
- tokenAddress: m.address,
1359
- inputAmountRaw: T
1360
- }), !j); H++)
1361
- H < pe - 1 && await h(Ut);
1362
- if (!j)
1363
- throw new Error(
1364
- `Insufficient ${m.symbol} allowance to perform the swap. Please approve the token first.`
1365
- );
1366
- D++, f(d.APPROVING, {
1367
- hasApproval: !0,
1368
- stepIndex: D
1369
- }), I(() => L.onApproveSuccess(N)), I(
1370
- () => {
1371
- var H;
1372
- return (H = r == null ? void 0 : r.onApproveSuccess) == null ? void 0 : H.call(r, {
1373
- txHash: N,
1374
- token: m,
1375
- amount: ne(T, m.decimals)
1376
- });
1377
- }
1378
- );
1379
- }
1380
- f(d.SIGNING);
1381
- const G = y.prepareOrder({
1382
- form: t,
1383
- inputTokenAddress: m.address,
1384
- outputTokenAddress: S.address,
1385
- swapperAddress: u
1386
- });
1387
- f(d.SIGNING, { preparedOrder: G }), Mt({
1388
- analytics: L,
1389
- account: u,
1390
- chainId: g,
1391
- inputToken: E,
1392
- outputToken: S,
1393
- preparedOrder: G
1394
- }), I(() => L.onSignOrderRequest(G.order)), I(r == null ? void 0 : r.onSignOrderRequest);
1395
- let Z;
1396
- try {
1397
- Z = await n.signOrder(
1398
- G.signingRequest
1399
- ), I(() => L.onSignOrderSuccess(Z)), I(() => {
1400
- var N;
1401
- return (N = r == null ? void 0 : r.onSignOrderSuccess) == null ? void 0 : N.call(r, Z);
1402
- });
1403
- } catch (N) {
1404
- throw I(() => L.onSignOrderError(N)), I(() => {
1405
- var j;
1406
- return (j = r == null ? void 0 : r.onSignOrderError) == null ? void 0 : j.call(r, re(N));
1407
- }), N;
1339
+ wait: E,
1340
+ signal: e.signal,
1341
+ prepareOrder: () => T.prepareOrder({
1342
+ form: t,
1343
+ inputTokenAddress: h.address,
1344
+ outputTokenAddress: S.address,
1345
+ swapperAddress: d
1346
+ }),
1347
+ validateContext: () => {
1348
+ if (s().executionId !== P) throw new Error("Execution is no longer current");
1349
+ },
1350
+ onUpdate: (l) => {
1351
+ const D = l.steps.map((M) => ({ wrap: Q.WRAP, approve: Q.APPROVE, create: Q.CREATE })[M]), G = l.phase;
1352
+ x(G, {
1353
+ pendingSteps: D,
1354
+ totalSteps: D.length,
1355
+ stepIndex: l.stepIndex,
1356
+ hasApproval: l.hasApproval,
1357
+ wrapTxHash: l.wrapTxHash,
1358
+ approveTxHash: l.approvalTxHash,
1359
+ ...l.preparedOrder ? { preparedOrder: l.preparedOrder } : {},
1360
+ ...l.phase === "wrapping" && l.event === "success" && l.wrapTxHash ? {
1361
+ completedWrap: { account: d, chainId: m, inputTokenAddress: g.address, inputAmountRaw: L, txHash: l.wrapTxHash }
1362
+ } : {}
1363
+ }), l.phase === "wrapping" && (l.event === "request" && w(r == null ? void 0 : r.onWrapRequest), l.event === "success" && l.wrapTxHash && w(() => {
1364
+ var M;
1365
+ return (M = r == null ? void 0 : r.onWrapSuccess) == null ? void 0 : M.call(r, { txHash: l.wrapTxHash, amount: ee(L, h.decimals) });
1366
+ })), l.phase === "approving" && (l.event === "request" && w(r == null ? void 0 : r.onApproveRequest), l.event === "success" && l.approvalTxHash && w(() => {
1367
+ var M;
1368
+ return (M = r == null ? void 0 : r.onApproveSuccess) == null ? void 0 : M.call(r, { txHash: l.approvalTxHash, token: h, amount: ee(L, h.decimals) });
1369
+ })), l.phase === "signing" && (l.event === "prepared" && l.preparedOrder && (Nt({ analytics: q, account: d, chainId: m, inputToken: g, outputToken: S, preparedOrder: l.preparedOrder }), w(r == null ? void 0 : r.onSignOrderRequest)), l.event === "success" && l.signature && w(() => {
1370
+ var M;
1371
+ return (M = r == null ? void 0 : r.onSignOrderSuccess) == null ? void 0 : M.call(r, l.signature);
1372
+ }), l.event === "error" && w(() => {
1373
+ var M;
1374
+ return (M = r == null ? void 0 : r.onSignOrderError) == null ? void 0 : M.call(r, k(l.error));
1375
+ }));
1376
+ }
1377
+ }), F = t.module === j.SWAP;
1378
+ if (x(F ? u.SETTLING : u.SUCCESS, {
1379
+ orderId: p.id.toString()
1380
+ }), w(() => i(p)), F || w(() => o()), w(() => {
1381
+ var l;
1382
+ return (l = r == null ? void 0 : r.onOrderCreated) == null ? void 0 : l.call(r, p);
1383
+ }), F) {
1384
+ const l = await e.waitForOrderFill(p, P);
1385
+ return x(u.SUCCESS), l;
1408
1386
  }
1409
- f(d.SUBMITTING);
1410
- const b = await y.submitOrder(G.order, Z);
1411
- return f(d.SUCCESS, {
1412
- orderId: b.id.toString()
1413
- }), I(() => i(b)), I(() => o()), I(() => {
1414
- var N;
1415
- return (N = r == null ? void 0 : r.onOrderCreated) == null ? void 0 : N.call(r, b);
1416
- }), b;
1417
- } catch (w) {
1418
- const F = O.phase, C = re(w), D = ve(w);
1419
- throw B(
1420
- D ? d.REJECTED : d.FAILED,
1387
+ return p;
1388
+ } catch (p) {
1389
+ const F = I.phase, l = k(p), D = Ee(p);
1390
+ throw v(
1391
+ D ? u.REJECTED : u.FAILED,
1421
1392
  {
1422
- error: C,
1423
- parsedError: se(w)
1393
+ error: l,
1394
+ parsedError: re(p)
1424
1395
  }
1425
- ), F === d.WRAPPING ? I(() => L.onWrapError(w)) : F === d.APPROVING && I(() => L.onApproveError(w)), I(D ? r == null ? void 0 : r.onSubmitOrderRejected : () => {
1396
+ ), D ? w(r == null ? void 0 : r.onSubmitOrderRejected) : F !== u.SETTLING && w(() => {
1426
1397
  var G;
1427
- return (G = r == null ? void 0 : r.onSubmitOrderFailed) == null ? void 0 : G.call(r, se(w));
1428
- }), C;
1398
+ return (G = r == null ? void 0 : r.onSubmitOrderFailed) == null ? void 0 : G.call(r, re(p));
1399
+ }), l;
1429
1400
  }
1430
- }, _t = () => {
1431
- const { data: e } = Y(), {
1401
+ }, Dt = () => {
1402
+ const { data: e } = J(), {
1432
1403
  inputToken: t,
1433
1404
  outputToken: n,
1434
1405
  wrappedNativeToken: r,
1435
1406
  chainId: i,
1436
- hasChainId: o,
1437
- callbacks: s,
1438
- account: a,
1439
- walletInteractions: c
1440
- } = x(), h = It(), p = St(), u = W(), g = V();
1441
- return v(() => {
1442
- Bt({
1443
- account: a,
1407
+ callbacks: o,
1408
+ account: s,
1409
+ walletInteractions: a
1410
+ } = R(), c = gt(), E = ft(), O = H(), d = W(), m = Oe(void 0);
1411
+ return b(() => () => {
1412
+ var g;
1413
+ return (g = m.current) == null ? void 0 : g.abort();
1414
+ }, [s, i, e]), y(() => {
1415
+ if (!ve(d.getState().state.currentExecution.phase)) return;
1416
+ const g = new AbortController();
1417
+ m.current = g, Ut({
1418
+ signal: g.signal,
1419
+ account: s,
1444
1420
  chainId: i,
1445
- hasChainId: o,
1446
1421
  inputToken: t,
1447
1422
  outputToken: n,
1448
1423
  wrappedNativeToken: r,
1449
- form: u,
1424
+ form: O,
1450
1425
  client: e,
1451
- walletInteractions: c,
1452
- callbacks: s,
1453
- addNewOrder: h,
1454
- refetchActiveOrders: p,
1455
- getCurrentExecution: () => g.getState().state.currentExecution,
1456
- beginExecution: g.getState().beginExecution,
1457
- replaceExecution: g.getState().replaceExecution
1426
+ walletInteractions: a,
1427
+ callbacks: o,
1428
+ addNewOrder: c,
1429
+ refetchActiveOrders: E,
1430
+ waitForOrderFill: (h, S) => Rt({ store: d, callbacks: o, order: h, executionId: S, signal: g.signal }),
1431
+ getCurrentExecution: () => d.getState().state.currentExecution,
1432
+ beginExecution: d.getState().beginExecution,
1433
+ replaceExecution: d.getState().replaceExecution
1458
1434
  }).catch(() => {
1435
+ }).finally(() => {
1436
+ m.current === g && (m.current = void 0);
1459
1437
  });
1460
1438
  }, [
1461
- a,
1462
- h,
1463
1439
  s,
1440
+ c,
1441
+ o,
1464
1442
  i,
1465
1443
  e,
1466
- u,
1444
+ O,
1467
1445
  t,
1468
- o,
1469
1446
  n,
1470
1447
  r,
1471
- p,
1472
- g,
1473
- c
1448
+ E,
1449
+ d,
1450
+ a
1474
1451
  ]);
1475
- }, qt = () => {
1452
+ }, Mt = () => {
1476
1453
  const e = A((n) => n.state.currentExecution), t = A(
1477
1454
  (n) => n.returnToOrderForm
1478
1455
  );
1479
- return R(
1456
+ return C(
1480
1457
  () => ({ ...e, returnToOrderForm: t }),
1481
1458
  [e, t]
1482
1459
  );
1483
- }, ir = () => {
1484
- const e = qt(), {
1460
+ }, er = () => {
1461
+ const e = Mt(), {
1485
1462
  inputToken: t,
1486
1463
  outputToken: n,
1487
1464
  chainId: r,
1488
1465
  hasChainId: i,
1489
1466
  module: o,
1490
1467
  overrides: s
1491
- } = x(), { data: a, isLoading: c } = Y(), h = _t(), p = A((y) => y.startNewOrder), u = v(() => h(), [h]), g = v(
1492
- () => p(ye({ module: o, overrides: s })),
1493
- [o, s, p]
1494
- ), E = et(e.phase), m = tt(e.phase), S = $(e.phase);
1495
- return R(() => ({
1468
+ } = R(), { data: a, isLoading: c } = J(), E = Dt(), O = A((T) => T.startNewOrder), d = y(() => E(), [E]), m = y(
1469
+ () => O(Ae({ module: o, overrides: s })),
1470
+ [o, s, O]
1471
+ ), g = Xe(e.phase), h = Ze(e.phase), S = z(e.phase);
1472
+ return C(() => ({
1496
1473
  phase: e.phase,
1497
- status: E,
1474
+ status: g,
1498
1475
  error: e.parsedError,
1499
- currentStep: m,
1476
+ currentStep: h,
1500
1477
  currentStepIndex: e.stepIndex,
1501
1478
  approvalTxHash: e.approveTxHash,
1502
1479
  wrapTxHash: e.wrapTxHash,
@@ -1505,30 +1482,30 @@ const yt = ({
1505
1482
  inputToken: e.inputToken ?? t,
1506
1483
  outputToken: e.outputToken ?? n,
1507
1484
  chainId: e.chainId ?? r,
1508
- submitOrder: u,
1509
- startNewOrder: g,
1485
+ submitOrder: d,
1486
+ startNewOrder: m,
1510
1487
  returnToOrderForm: e.returnToOrderForm,
1511
1488
  isExecuting: S,
1512
- isSuccess: e.phase === d.SUCCESS,
1513
- isFailed: e.phase === d.FAILED,
1514
- isRejected: e.phase === d.REJECTED,
1515
- isPreparingOrder: e.phase === d.PREPARING || i && c && !a,
1489
+ isSuccess: e.phase === u.SUCCESS,
1490
+ isFailed: e.phase === u.FAILED,
1491
+ isRejected: e.phase === u.REJECTED,
1492
+ isPreparingOrder: e.phase === u.PREPARING || i && c && !a,
1516
1493
  canDismiss: !S
1517
1494
  }), [
1518
1495
  a,
1519
- m,
1496
+ h,
1520
1497
  t,
1521
1498
  n,
1522
1499
  r,
1523
1500
  c,
1524
1501
  S,
1525
1502
  i,
1503
+ m,
1504
+ d,
1526
1505
  g,
1527
- u,
1528
- E,
1529
1506
  e
1530
1507
  ]);
1531
- }, or = () => {
1508
+ }, tr = () => {
1532
1509
  const {
1533
1510
  inputToken: e,
1534
1511
  outputToken: t,
@@ -1538,24 +1515,24 @@ const yt = ({
1538
1515
  inputAmountUi: o,
1539
1516
  marketPriceLoading: s,
1540
1517
  hasChainId: a
1541
- } = x(), c = W(), { data: h, isLoading: p } = Y(), u = A(
1542
- (T) => T.state.currentExecution.phase
1543
- ), g = $(u), E = !!(e && Q(e.address) && (!n || Q(n.address))), m = s || !c.isReady || r === void 0, S = g || a && p && !h || !!(e && t && o && m), y = !!(!c.canSubmit || g || !a || !h || i || S || !e || !t || E);
1544
- return R(() => ({
1545
- disabled: y,
1518
+ } = R(), c = H(), { data: E, isLoading: O } = J(), d = A(
1519
+ (L) => L.state.currentExecution.phase
1520
+ ), m = z(d), g = !!(e && $(e.address) && (!n || $(n.address))), h = s || !c.isReady && !c.errors.primary || r === void 0, S = m || a && O && !E || !!(e && t && o && h), T = !!(!c.canSubmit || m || !a || !E || i || S || !e || !t || g);
1521
+ return C(() => ({
1522
+ disabled: T,
1546
1523
  loading: S
1547
- }), [y, S]);
1548
- }, sr = () => {
1549
- const { inputToken: e, outputToken: t, callbacks: n } = x(), r = A((s) => s.updateState), { trades: i } = W(), o = v(
1524
+ }), [T, S]);
1525
+ }, rr = () => {
1526
+ const { inputToken: e, outputToken: t, callbacks: n } = R(), r = A((s) => s.updateState), { trades: i } = H(), o = y(
1550
1527
  (s) => {
1551
- r({ tradeCount: s }), I(() => {
1528
+ r({ tradeCount: s }), w(() => {
1552
1529
  var a;
1553
1530
  return (a = n == null ? void 0 : n.onTradeCountChange) == null ? void 0 : a.call(n, s);
1554
1531
  });
1555
1532
  },
1556
1533
  [n, r]
1557
1534
  );
1558
- return R(
1535
+ return C(
1559
1536
  () => ({
1560
1537
  totalTrades: i.totalTrades,
1561
1538
  maxTrades: i.maxTrades,
@@ -1569,48 +1546,48 @@ const yt = ({
1569
1546
  }),
1570
1547
  [e, o, t, i]
1571
1548
  );
1572
- }, ar = () => {
1573
- const { marketPriceLoading: e, inputToken: t, outputToken: n, callbacks: r } = x(), { marketPrice: i, trades: o, triggerPrice: s, isInverted: a } = W(), c = A((g) => g.updateState), h = v(
1574
- (g) => {
1575
- c({ triggerPriceUi: g, triggerPricePercent: null }), I(() => {
1576
- var E;
1577
- return (E = r == null ? void 0 : r.onTriggerPriceChange) == null ? void 0 : E.call(r, g || "");
1578
- }), I(() => {
1579
- var E;
1580
- return (E = r == null ? void 0 : r.onTriggerPricePercentChange) == null ? void 0 : E.call(r, "");
1549
+ }, nr = () => {
1550
+ const { marketPriceLoading: e, inputToken: t, outputToken: n, callbacks: r } = R(), { marketPrice: i, trades: o, triggerPrice: s, isInverted: a } = H(), c = A((m) => m.updateState), E = y(
1551
+ (m) => {
1552
+ c({ triggerPriceUi: m, triggerPricePercent: null }), w(() => {
1553
+ var g;
1554
+ return (g = r == null ? void 0 : r.onTriggerPriceChange) == null ? void 0 : g.call(r, m || "");
1555
+ }), w(() => {
1556
+ var g;
1557
+ return (g = r == null ? void 0 : r.onTriggerPricePercentChange) == null ? void 0 : g.call(r, "");
1581
1558
  });
1582
1559
  },
1583
1560
  [r, c]
1584
- ), p = v(
1585
- (g) => {
1561
+ ), O = y(
1562
+ (m) => {
1586
1563
  c({
1587
1564
  triggerPriceUi: void 0,
1588
- triggerPricePercent: g
1589
- }), I(() => {
1590
- var E;
1591
- return (E = r == null ? void 0 : r.onTriggerPriceChange) == null ? void 0 : E.call(r, "");
1592
- }), I(() => {
1593
- var E;
1594
- return (E = r == null ? void 0 : r.onTriggerPricePercentChange) == null ? void 0 : E.call(r, g || "");
1565
+ triggerPricePercent: m
1566
+ }), w(() => {
1567
+ var g;
1568
+ return (g = r == null ? void 0 : r.onTriggerPriceChange) == null ? void 0 : g.call(r, "");
1569
+ }), w(() => {
1570
+ var g;
1571
+ return (g = r == null ? void 0 : r.onTriggerPricePercentChange) == null ? void 0 : g.call(r, m || "");
1595
1572
  });
1596
1573
  },
1597
1574
  [r, c]
1598
- ), u = v(() => {
1575
+ ), d = y(() => {
1599
1576
  c({
1600
1577
  triggerPricePercent: void 0,
1601
1578
  triggerPriceUi: void 0
1602
1579
  });
1603
1580
  }, [c]);
1604
- return R(
1581
+ return C(
1605
1582
  () => ({
1606
1583
  price: s.display,
1607
1584
  canonicalPriceRaw: s.raw,
1608
1585
  outputAmountPerTrade: o.triggerOutputAmountPerTrade,
1609
1586
  error: s.error,
1610
- onInputChange: h,
1611
- onPercentageChange: p,
1587
+ onInputChange: E,
1588
+ onPercentageChange: O,
1612
1589
  percentage: s.percentage,
1613
- onReset: u,
1590
+ onReset: d,
1614
1591
  inputToken: t,
1615
1592
  outputToken: n,
1616
1593
  displayInputToken: a ? n : t,
@@ -1623,62 +1600,78 @@ const yt = ({
1623
1600
  a,
1624
1601
  i.raw,
1625
1602
  e,
1626
- h,
1627
- p,
1628
- u,
1603
+ E,
1604
+ O,
1605
+ d,
1629
1606
  n,
1630
1607
  o.triggerOutputAmountPerTrade,
1631
1608
  s
1632
1609
  ]
1633
1610
  );
1634
1611
  };
1635
- We(Qe.version);
1612
+ He(Qe.version);
1636
1613
  export {
1637
- ur as DISCLAIMER_URL,
1638
- ee as Disclaimer,
1639
- d as ExecutionPhase,
1640
- q as ExecutionStatus,
1641
- lr as InputErrors,
1642
- mr as Module,
1643
- gr as ORBS_LOGO,
1644
- Pr as ORBS_SLTP_FAQ_URL,
1645
- fr as ORBS_TWAP_FAQ_URL,
1646
- hr as ORBS_WEBSITE_URL,
1647
- Er as OrderFilter,
1648
- Ir as OrderStatus,
1649
- Sr as OrderType,
1650
- Or as Partners,
1651
- $t as SpotProvider,
1652
- z as Steps,
1653
- pr as TimeUnit,
1614
+ sr as DISCLAIMER_URL,
1615
+ X as Disclaimer,
1616
+ u as ExecutionPhase,
1617
+ _ as ExecutionStatus,
1618
+ ar as InputErrors,
1619
+ cr as Module,
1620
+ dr as ORBS_LOGO,
1621
+ ur as ORBS_SLTP_FAQ_URL,
1622
+ lr as ORBS_TWAP_FAQ_URL,
1623
+ mr as ORBS_WEBSITE_URL,
1624
+ gr as OrderFilter,
1625
+ fr as OrderSettlementError,
1626
+ hr as OrderStatus,
1627
+ Pr as OrderType,
1628
+ Er as Partners,
1629
+ Sr as QuoteError,
1630
+ Or as SWAP_CAPABILITIES,
1631
+ Ir as SpotError,
1632
+ Vt as SpotProvider,
1633
+ Q as Steps,
1634
+ vr as TimeUnit,
1635
+ wr as analytics,
1636
+ pr as calculateOrder,
1654
1637
  Ar as calculateOrderForm,
1655
- vr as createClient,
1656
- wr as eqIgnoreCase,
1657
- Cr as getOrderExecutionRate,
1658
- yr as getOrderFillDelayMillis,
1659
- Rr as getOrderLimitPriceRate,
1660
- Tr as getTriggerPriceRate,
1661
- Nr as getTwapConfig,
1662
- Lr as invertPriceInput,
1663
- xr as isNativeAddress,
1664
- Fr as isTxRejected,
1665
- Ur as toAmountRaw,
1666
- Dr as toAmountUI,
1667
- Qt as useAmountUi,
1668
- Yt as useCancelOrder,
1669
- Y as useClient,
1670
- Xt as useDisclaimer,
1671
- Zt as useDuration,
1672
- ir as useExecution,
1673
- bt as useFillDelay,
1674
- kt as useHistoryOrder,
1675
- er as useInputErrors,
1676
- tr as useLimitPrice,
1677
- W as useOrderForm,
1678
- zt as useOrders,
1679
- rr as useOutputAmount,
1680
- nr as usePriceDisplay,
1681
- or as useSubmitButton,
1682
- sr as useTrades,
1683
- ar as useTriggerPrice
1638
+ yr as createClient,
1639
+ Cr as eqIgnoreCase,
1640
+ Tr as executeOrder,
1641
+ Rr as getMinimumOutputAmount,
1642
+ Lr as getOrderExecutionRate,
1643
+ xr as getOrderFillDelayMillis,
1644
+ Fr as getOrderLimitPriceRate,
1645
+ Nr as getOrders,
1646
+ Ur as getQuote,
1647
+ Dr as getTriggerPriceRate,
1648
+ Mr as getTwapConfig,
1649
+ Gr as invertPriceInput,
1650
+ Br as isNativeAddress,
1651
+ _r as isQuoteFresh,
1652
+ Hr as isSwapSupported,
1653
+ qr as isTxRejected,
1654
+ Kr as setUIVersion,
1655
+ Wr as submitSwap,
1656
+ Vr as toAmountRaw,
1657
+ jr as toAmountUI,
1658
+ jt as useAmountUi,
1659
+ Jt as useCancelOrder,
1660
+ J as useClient,
1661
+ Qt as useDisclaimer,
1662
+ zt as useDuration,
1663
+ er as useExecution,
1664
+ $t as useFillDelay,
1665
+ bt as useHistoryOrder,
1666
+ Yt as useInputErrors,
1667
+ Xt as useLimitPrice,
1668
+ H as useOrderForm,
1669
+ Wt as useOrders,
1670
+ Zt as useOutputAmount,
1671
+ kt as usePriceDisplay,
1672
+ tr as useSubmitButton,
1673
+ rr as useTrades,
1674
+ nr as useTriggerPrice,
1675
+ Jr as waitForOrder,
1676
+ Qr as watchOrder
1684
1677
  };