@velora-dex/widget 0.7.0 → 0.7.2

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.
Files changed (80) hide show
  1. package/dist/components/ui/tooltip.js +1 -1
  2. package/dist/components/ui/tooltip.js.map +1 -1
  3. package/dist/components/widget/AppHeader/AppHeader.d.ts.map +1 -1
  4. package/dist/components/widget/AppHeader/AppHeader.js +45 -41
  5. package/dist/components/widget/AppHeader/AppHeader.js.map +1 -1
  6. package/dist/components/widget/AppHeader/TradeModeSwitcher.d.ts +3 -1
  7. package/dist/components/widget/AppHeader/TradeModeSwitcher.d.ts.map +1 -1
  8. package/dist/components/widget/AppHeader/TradeModeSwitcher.js +69 -34
  9. package/dist/components/widget/AppHeader/TradeModeSwitcher.js.map +1 -1
  10. package/dist/components/widget/SwapRate/SwapRate.d.ts +2 -1
  11. package/dist/components/widget/SwapRate/SwapRate.d.ts.map +1 -1
  12. package/dist/components/widget/SwapRate/SwapRate.js +25 -37
  13. package/dist/components/widget/SwapRate/SwapRate.js.map +1 -1
  14. package/dist/components/widget/SwapRate/SwapRateWithTooltip.d.ts +3 -0
  15. package/dist/components/widget/SwapRate/SwapRateWithTooltip.d.ts.map +1 -0
  16. package/dist/components/widget/SwapRate/SwapRateWithTooltip.js +42 -0
  17. package/dist/components/widget/SwapRate/SwapRateWithTooltip.js.map +1 -0
  18. package/dist/components/widget/SwapRate/utils.d.ts +3 -0
  19. package/dist/components/widget/SwapRate/utils.d.ts.map +1 -0
  20. package/dist/components/widget/SwapRate/utils.js +26 -0
  21. package/dist/components/widget/SwapRate/utils.js.map +1 -0
  22. package/dist/components/widget/SwapRateWithPriceImpactRow/SwapRateWithPriceImpactRow.d.ts.map +1 -1
  23. package/dist/components/widget/SwapRateWithPriceImpactRow/SwapRateWithPriceImpactRow.js +20 -27
  24. package/dist/components/widget/SwapRateWithPriceImpactRow/SwapRateWithPriceImpactRow.js.map +1 -1
  25. package/dist/core/index.d.ts.map +1 -1
  26. package/dist/core/index.js +134 -131
  27. package/dist/core/index.js.map +1 -1
  28. package/dist/core/logger.d.ts +2 -2
  29. package/dist/core/logger.d.ts.map +1 -1
  30. package/dist/core/logger.js +8 -2
  31. package/dist/core/logger.js.map +1 -1
  32. package/dist/core/screen/hooks/useRunOnMount.d.ts +10 -0
  33. package/dist/core/screen/hooks/useRunOnMount.d.ts.map +1 -1
  34. package/dist/core/screen/hooks/useRunOnMount.js +6 -1
  35. package/dist/core/screen/hooks/useRunOnMount.js.map +1 -1
  36. package/dist/core/state/configActionsAtom.d.ts.map +1 -1
  37. package/dist/core/state/configActionsAtom.js +8 -8
  38. package/dist/core/state/configActionsAtom.js.map +1 -1
  39. package/dist/core/state/configAtom.d.ts +4 -2
  40. package/dist/core/state/configAtom.d.ts.map +1 -1
  41. package/dist/core/state/configAtom.js +7 -4
  42. package/dist/core/state/configAtom.js.map +1 -1
  43. package/dist/core/state/validatedReferrerConfigAtom.d.ts +3 -0
  44. package/dist/core/state/validatedReferrerConfigAtom.d.ts.map +1 -0
  45. package/dist/core/state/validatedReferrerConfigAtom.js +12 -0
  46. package/dist/core/state/validatedReferrerConfigAtom.js.map +1 -0
  47. package/dist/core/types.d.ts +6 -0
  48. package/dist/core/types.d.ts.map +1 -1
  49. package/dist/hooks/swap/tradeFlow/useDeltaFlow.d.ts.map +1 -1
  50. package/dist/hooks/swap/tradeFlow/useDeltaFlow.js +203 -201
  51. package/dist/hooks/swap/tradeFlow/useDeltaFlow.js.map +1 -1
  52. package/dist/hooks/swap/tradeFlow/useLimitOrderFlow.d.ts.map +1 -1
  53. package/dist/hooks/swap/tradeFlow/useLimitOrderFlow.js +85 -82
  54. package/dist/hooks/swap/tradeFlow/useLimitOrderFlow.js.map +1 -1
  55. package/dist/hooks/swap/tradeFlow/useMarketFlow.d.ts.map +1 -1
  56. package/dist/hooks/swap/tradeFlow/useMarketFlow.js +156 -154
  57. package/dist/hooks/swap/tradeFlow/useMarketFlow.js.map +1 -1
  58. package/dist/hooks/swap/tradeFlow/useTwapFlow.d.ts.map +1 -1
  59. package/dist/hooks/swap/tradeFlow/useTwapFlow.js +230 -228
  60. package/dist/hooks/swap/tradeFlow/useTwapFlow.js.map +1 -1
  61. package/dist/hooks/useReferrer.d.ts +2 -0
  62. package/dist/hooks/useReferrer.d.ts.map +1 -0
  63. package/dist/hooks/useReferrer.js +8 -0
  64. package/dist/hooks/useReferrer.js.map +1 -0
  65. package/dist/lib/utils/logger.d.ts +7 -4
  66. package/dist/lib/utils/logger.d.ts.map +1 -1
  67. package/dist/lib/utils/logger.js +70 -33
  68. package/dist/lib/utils/logger.js.map +1 -1
  69. package/dist/lib/web3/privy/config.js +1 -1
  70. package/dist/lib/web3/privy/config.js.map +1 -1
  71. package/dist/lib/web3/wagmi/config.js +1 -1
  72. package/dist/lib/web3/wagmi/config.js.map +1 -1
  73. package/dist/lib/web3/wagmi/isInsideSafeIframe.js +11 -11
  74. package/dist/lib/web3/wagmi/isInsideSafeIframe.js.map +1 -1
  75. package/dist/styles.css +1 -1
  76. package/dist/tokens/utils/transferAmountsFromReceipt.js +14 -14
  77. package/dist/tokens/utils/transferAmountsFromReceipt.js.map +1 -1
  78. package/dist/transactions/queries/ensureTxReceipt.js +8 -8
  79. package/dist/transactions/queries/ensureTxReceipt.js.map +1 -1
  80. package/package.json +7 -7
@@ -17,62 +17,63 @@ import { useMarkPermit1Or2NonceAsUsed as b } from "./common/useSignPermit1Or2.js
17
17
  import { useApproveOrPermit as ee } from "./common/useApproveOrPermit.js";
18
18
  import { useBatchWithApproveTxs as te } from "../../batch/useBatchWithApproveTxs.js";
19
19
  import { useSendBatchTx as ne } from "../../batch/useSendBatchTx.js";
20
- import { useSendMarketSwapTx as re } from "../prices/market/mutations/useSendMarketSwapTx.js";
21
- import { useBuildTx as ie } from "../prices/market/mutations/useBuildTx.js";
20
+ import { useReferrer as re } from "../../useReferrer.js";
21
+ import { useSendMarketSwapTx as ie } from "../prices/market/mutations/useSendMarketSwapTx.js";
22
+ import { useBuildTx as ae } from "../prices/market/mutations/useBuildTx.js";
22
23
  import { useRef as x } from "react";
23
- import { useMutation as ae } from "@tanstack/react-query";
24
+ import { useMutation as oe } from "@tanstack/react-query";
24
25
  import { assert as S } from "ts-essentials";
25
26
  import "viem";
26
- import { useAccount as oe } from "wagmi";
27
+ import { useAccount as se } from "wagmi";
27
28
  //#region src/hooks/swap/tradeFlow/useMarketFlow.ts
28
- var C = "marketSwap", w = "runMarketSwapFlow";
29
- function T({ marketPrice: T }) {
30
- let E = e("MarketFlow"), { resolvedSlippage: D } = o("swap"), se = t(), { priceParams: O, chainId: k } = l("swap"), { result: A, queryKey: ce } = i({
31
- priceParams: O,
32
- chainId: k,
29
+ var C = "marketSwap", ce = "runMarketSwapFlow";
30
+ function w({ marketPrice: w }) {
31
+ let T = e("MarketFlow"), { resolvedSlippage: E } = o("swap"), le = t(), { priceParams: D, chainId: O } = l("swap"), { result: k, queryKey: ue } = i({
32
+ priceParams: D,
33
+ chainId: O,
33
34
  query: { enabled: !1 }
34
- }), j = A.data || T, { approval: M, signPermit: N, approveTxMut: P, signPermitMut: F, events: I } = ee({
35
- srcToken: j?.srcToken,
36
- srcAmount: j?.srcAmount,
35
+ }), A = k.data || w, { approval: j, signPermit: M, approveTxMut: N, signPermitMut: P, events: F } = ee({
36
+ srcToken: A?.srcToken,
37
+ srcAmount: A?.srcAmount,
37
38
  spenderContractType: "AugustusSwapper",
38
- swapSide: j?.side ?? se,
39
+ swapSide: A?.side ?? le,
39
40
  tradeMode: "swap",
40
- chainId: k
41
- }), L = ie({
42
- chainId: k,
41
+ chainId: O
42
+ }), I = ae({
43
+ chainId: O,
43
44
  mutationOptions: {
44
45
  onSuccess: () => {
45
- E.log("Build tx success");
46
+ T.log("Build tx success");
46
47
  },
47
48
  onError: (e) => {
48
- E.error("Build tx error", e);
49
+ T.error("Build tx error", e);
49
50
  }
50
51
  }
51
- }), le = {
52
- isPending: L.isPending,
53
- isError: L.isError,
54
- isSuccess: L.isSuccess,
55
- error: L.error
56
- }, R = re({
52
+ }), de = {
53
+ isPending: I.isPending,
54
+ isError: I.isError,
55
+ isSuccess: I.isSuccess,
56
+ error: I.error
57
+ }, L = ie({
57
58
  onSuccess: () => {
58
- E.log("Swap tx success");
59
+ T.log("Swap tx success");
59
60
  },
60
61
  onError: (e) => {
61
- E.error("Swap tx error", e);
62
+ T.error("Swap tx error", e);
62
63
  }
63
- }), { forCurrentChain: z } = s(), { addTxWithApprovals: ue } = te(), B = ne({
64
+ }), { forCurrentChain: R } = s(), { addTxWithApprovals: fe } = te(), z = ne({
64
65
  onSuccess: () => {
65
- E.log("Batch tx success");
66
+ T.log("Batch tx success");
66
67
  },
67
68
  onError: (e) => {
68
- E.error("Batch tx error", e);
69
+ T.error("Batch tx error", e);
69
70
  }
70
- }), V = m({
71
- hash: R.txHash,
72
- chainId: k
73
- }), H = f({ id: B.data?.id }), U = g({
74
- chainId: k,
75
- txHash: R.txHash,
71
+ }), B = m({
72
+ hash: L.txHash,
73
+ chainId: O
74
+ }), V = f({ id: z.data?.id }), H = g({
75
+ chainId: O,
76
+ txHash: L.txHash,
76
77
  cancelTxType: "SWAP",
77
78
  onSuccess: (e) => {
78
79
  X?.({ event: {
@@ -83,76 +84,76 @@ function T({ marketPrice: T }) {
83
84
  }
84
85
  } });
85
86
  }
86
- }), W = x(null), de = {
87
- txHash: R.txHash,
88
- receipt: V.data,
89
- isConfirmingTX: R.isPending,
90
- isConfirmingTxError: R.isError,
91
- isTxSent: R.isSuccess,
92
- isTxPending: V.isLoading,
93
- isTxMined: V.isSuccess,
94
- isTxAwaitingError: V.isError,
95
- isPending: R.isPending || V.isLoading,
96
- isSuccess: V.isSuccess,
97
- isError: R.isError || V.isError,
98
- error: R.error || V.error,
99
- isTxCancellable: U.isWalletSupported && !!R.txHash && !V.data && !U.isSuccess,
87
+ }), U = x(null), pe = {
88
+ txHash: L.txHash,
89
+ receipt: B.data,
90
+ isConfirmingTX: L.isPending,
91
+ isConfirmingTxError: L.isError,
92
+ isTxSent: L.isSuccess,
93
+ isTxPending: B.isLoading,
94
+ isTxMined: B.isSuccess,
95
+ isTxAwaitingError: B.isError,
96
+ isPending: L.isPending || B.isLoading,
97
+ isSuccess: B.isSuccess,
98
+ isError: L.isError || B.isError,
99
+ error: L.error || B.error,
100
+ isTxCancellable: H.isWalletSupported && !!L.txHash && !B.data && !H.isSuccess,
100
101
  cancelSwapTx: async () => {
101
102
  try {
102
- S(R.txHash, "Swap tx hash is not available");
103
- let e = await U.replaceTx({
103
+ S(L.txHash, "Swap tx hash is not available");
104
+ let e = await H.replaceTx({
104
105
  action: "cancel",
105
- hash: R.txHash
106
+ hash: L.txHash
106
107
  });
107
- return e.replacementTxReceipt.status === "success" && W.current?.abort(new _("Swap tx cancelled", e)), e;
108
+ return e.replacementTxReceipt.status === "success" && U.current?.abort(new _("Swap tx cancelled", e)), e;
108
109
  } catch (e) {
109
- E.error("Cancel swap tx error", e), U.reset();
110
+ T.error("Cancel swap tx error", e), H.reset();
110
111
  }
111
112
  },
112
113
  cancellingState: {
113
- isPending: U.isPending,
114
- isError: U.isError,
115
- isSuccess: U.isSuccess,
116
- error: U.error,
117
- result: U.result,
118
- step: U.step
114
+ isPending: H.isPending,
115
+ isError: H.isError,
116
+ isSuccess: H.isSuccess,
117
+ error: H.error,
118
+ result: H.result,
119
+ step: H.step
119
120
  }
120
- }, G = H.data?.receipts?.[H.data.receipts.length - 1], fe = {
121
- canBatchTxs: z,
122
- callsId: B.data?.id,
123
- txHash: G?.transactionHash,
124
- receipt: G,
125
- isConfirmingCalls: B.isPending,
126
- isConfirmingCallsError: B.isError,
127
- isCallsSent: B.isSuccess,
128
- isCallsPending: H.isLoading,
129
- isCallsMined: H.isSuccess,
130
- isCallsAwaitingError: H.isError,
131
- isPending: B.isPending || H.isLoading,
132
- isSuccess: H.isSuccess,
133
- isError: B.isError || H.isError,
134
- error: B.error || H.error
135
- }, { address: K } = oe(), q = h(), pe = p(), J = x(null), me = () => {
136
- W.current?.abort(new v()), W.current = null, J.current = null;
137
- }, Y = n(), { markNonceAsUsed: he, clearNonce: ge } = b({ chainId: k }), { constructGasParams: _e } = d(), { partner: ve, partnerAddress: ye, partnerFeeBps: be, partnerTakesSurplus: xe } = c(), Se = a(), { onSwap: X } = r(), Z = ae({
121
+ }, W = V.data?.receipts?.[V.data.receipts.length - 1], me = {
122
+ canBatchTxs: R,
123
+ callsId: z.data?.id,
124
+ txHash: W?.transactionHash,
125
+ receipt: W,
126
+ isConfirmingCalls: z.isPending,
127
+ isConfirmingCallsError: z.isError,
128
+ isCallsSent: z.isSuccess,
129
+ isCallsPending: V.isLoading,
130
+ isCallsMined: V.isSuccess,
131
+ isCallsAwaitingError: V.isError,
132
+ isPending: z.isPending || V.isLoading,
133
+ isSuccess: V.isSuccess,
134
+ isError: z.isError || V.isError,
135
+ error: z.error || V.error
136
+ }, { address: G } = se(), K = h(), he = p(), q = x(null), ge = () => {
137
+ U.current?.abort(new v()), U.current = null, q.current = null;
138
+ }, J = n(), { markNonceAsUsed: _e, clearNonce: ve } = b({ chainId: O }), { constructGasParams: ye } = d(), { partner: be, partnerAddress: Y, partnerFeeBps: xe, partnerTakesSurplus: Se } = c(), { referrerAddress: Ce } = re(), we = a(), { onSwap: X } = r(), Z = oe({
138
139
  mutationFn: async ({ onTxSent: e, lastPrice: t } = {}) => {
139
- P.reset(), F.reset(), L.reset(), R.reset(), B.reset(), U.reset(), S(j, "Market price is not available");
140
+ N.reset(), P.reset(), I.reset(), L.reset(), z.reset(), H.reset(), S(A, "Market price is not available");
140
141
  let n = new AbortController();
141
- W.current = n;
142
- let r = n.signal, i, a, o, s = M.allowanceToSet, c = N.amountToPermit, l = j;
142
+ U.current = n;
143
+ let r = n.signal, i, a, o, s = j.allowanceToSet, c = M.amountToPermit, l = A;
143
144
  if (l.hmac === t?.hmac) {
144
- let e = await A.refetch({ cancelRefetch: !1 });
145
+ let e = await k.refetch({ cancelRefetch: !1 });
145
146
  r.throwIfAborted(), e.data && (l = e.data);
146
147
  }
147
148
  let d;
148
- J.current = l;
149
- let f = z && M.needsApproval && !!s;
149
+ q.current = l;
150
+ let f = R && j.needsApproval && !!s;
150
151
  try {
151
- if (!f && M.needsApproval && s) {
152
- let t = ce;
152
+ if (!f && j.needsApproval && s) {
153
+ let t = ue;
153
154
  if (t) {
154
155
  let e = s;
155
- d = Se({
156
+ d = we({
156
157
  queryKey: t,
157
158
  onData: (t) => {
158
159
  if (r.aborted) {
@@ -162,75 +163,76 @@ function T({ marketPrice: T }) {
162
163
  let n = u({
163
164
  srcAmount: t.srcAmount,
164
165
  destAmount: t.destAmount
165
- }, D, t.side);
166
- e >= BigInt(n.srcAmount) && (E.log("~ fresh price ~", t), l = t, J.current = l);
166
+ }, E, t.side);
167
+ e >= BigInt(n.srcAmount) && (T.log("~ fresh price ~", t), l = t, q.current = l);
167
168
  }
168
169
  });
169
170
  }
170
- let n = N.isPermitSupported && N.isPermitReadyToSign;
171
+ let n = M.isPermitSupported && M.isPermitReadyToSign;
171
172
  try {
172
- if (n) I.onSignPermit.request({ allowanceToSet: c }), i = await F.signPermitAsync({ value: c }), I.onSignPermit.confirmed({
173
+ if (n) F.onSignPermit.request({ allowanceToSet: c }), i = await P.signPermitAsync({ value: c }), F.onSignPermit.confirmed({
173
174
  allowanceToSet: c,
174
175
  permit: i?.permitEncodedArgs
175
176
  });
176
177
  else {
177
- I.onApproveTx.request({ allowanceToSet: s }), a = await P.approveAsync({ allowanceData: { allowanceToSet: s } }), I.onApproveTx.sent({
178
+ F.onApproveTx.request({ allowanceToSet: s }), a = await N.approveAsync({ allowanceData: { allowanceToSet: s } }), F.onApproveTx.sent({
178
179
  allowanceToSet: s,
179
180
  txHash: a
180
181
  }), r.throwIfAborted();
181
- let t = q({
182
+ let t = K({
182
183
  hash: a,
183
- chainId: k,
184
+ chainId: O,
184
185
  onReplaced: (e) => {
185
- E.log("onReplaced:approveTx", a, e);
186
+ T.log("onReplaced:approveTx", a, e);
186
187
  }
187
188
  });
188
189
  e && e({
189
- chainId: k,
190
+ chainId: O,
190
191
  action: "approve",
191
192
  transactionHash: a,
192
193
  receiptPromise: t,
193
194
  transactionSpecificData: {
194
195
  action: "approve",
195
196
  approvedAmount: s,
196
- tokenAddress: M.token,
197
- spenderAddress: M.spender
197
+ tokenAddress: j.token,
198
+ spenderAddress: j.spender
198
199
  }
199
- }), o = await t, I.onApproveTx.confirmed({
200
+ }), o = await t, F.onApproveTx.confirmed({
200
201
  allowanceToSet: s,
201
202
  txHash: a,
202
203
  txReceipt: o
203
- }), E.log("~ approveTx ~ receipt:", o);
204
+ }), T.log("~ approveTx ~ receipt:", o);
204
205
  }
205
206
  } catch (e) {
206
- throw n ? I.onSignPermit.failed({
207
+ throw n ? F.onSignPermit.failed({
207
208
  allowanceToSet: c,
208
209
  error: e
209
- }) : I.onApproveTx.failed({
210
+ }) : F.onApproveTx.failed({
210
211
  allowanceToSet: s,
211
212
  error: e,
212
213
  txHash: a
213
214
  }), e;
214
215
  }
215
216
  }
216
- r.throwIfAborted(), S(K, "Account is not connected");
217
+ r.throwIfAborted(), S(G, "Account is not connected");
217
218
  let t = l;
218
- J.current = t, d?.(), d = void 0, S(t, "Market price is not available");
219
+ q.current = t, d?.(), d = void 0, S(t, "Market price is not available");
219
220
  let n = u({
220
221
  srcAmount: t.srcAmount,
221
222
  destAmount: t.destAmount
222
- }, D, t.side), p = _e(), m = {
223
+ }, E, t.side), p = ye(), m = {
223
224
  swapTxInput: {
224
- userAddress: K,
225
- receiver: Y,
225
+ userAddress: G,
226
+ receiver: J,
226
227
  srcToken: t.srcToken,
227
228
  destToken: t.destToken,
228
229
  srcDecimals: t.srcDecimals,
229
230
  destDecimals: t.destDecimals,
230
- partner: ve,
231
- partnerAddress: ye,
232
- partnerFeeBps: be,
233
- takeSurplus: xe,
231
+ partner: be,
232
+ partnerAddress: Y,
233
+ partnerFeeBps: xe,
234
+ takeSurplus: Se,
235
+ referrer: Ce,
234
236
  permit: i?.permitEncodedArgs,
235
237
  priceRoute: t,
236
238
  ...n
@@ -238,10 +240,10 @@ function T({ marketPrice: T }) {
238
240
  swapTxOptions: {
239
241
  ignoreGasEstimate: f,
240
242
  ignoreAllowance: f,
241
- degenMode: O.degenMode,
243
+ degenMode: D.degenMode,
242
244
  ...p
243
245
  }
244
- }, h = await L.mutateAsync(m);
246
+ }, h = await I.mutateAsync(m);
245
247
  r.throwIfAborted();
246
248
  let g, _;
247
249
  if (X?.({ event: {
@@ -251,7 +253,7 @@ function T({ marketPrice: T }) {
251
253
  price: t
252
254
  }
253
255
  } }), f) {
254
- let { calls: e } = await ue({
256
+ let { calls: e } = await fe({
255
257
  txsParams: [{
256
258
  to: h.to,
257
259
  account: h.from,
@@ -260,13 +262,13 @@ function T({ marketPrice: T }) {
260
262
  chainId: h.chainId
261
263
  }],
262
264
  approveProps: [{
263
- spender: M.spender,
264
- allowanceToSet: M.allowanceToSet,
265
- token: M.token,
266
- chainId: M.chainId
265
+ spender: j.spender,
266
+ allowanceToSet: j.allowanceToSet,
267
+ token: j.token,
268
+ chainId: j.chainId
267
269
  }]
268
270
  });
269
- _ = (await B.sendCalls({ txsParams: e })).id, X?.({ event: {
271
+ _ = (await z.sendCalls({ txsParams: e })).id, X?.({ event: {
270
272
  name: "Swap:sent",
271
273
  params: {
272
274
  swapMode: "market",
@@ -274,9 +276,9 @@ function T({ marketPrice: T }) {
274
276
  callsId: _
275
277
  }
276
278
  } });
277
- } else g = await R.sendTransactionAsync({
279
+ } else g = await L.sendTransactionAsync({
278
280
  ...h,
279
- chainId: k
281
+ chainId: O
280
282
  }), X?.({ event: {
281
283
  name: "Swap:sent",
282
284
  params: {
@@ -285,12 +287,12 @@ function T({ marketPrice: T }) {
285
287
  txHash: g
286
288
  }
287
289
  } });
288
- i && he(i.signedPermitData);
290
+ i && _e(i.signedPermitData);
289
291
  let v, b;
290
292
  if (_) {
291
- let r = pe({ id: _ }).then((e) => e.receipts?.[e.receipts.length - 1]);
292
- E.log("~ swapTx ~ awaiting calls id :", _), e && e({
293
- chainId: k,
293
+ let r = he({ id: _ }).then((e) => e.receipts?.[e.receipts.length - 1]);
294
+ T.log("~ swapTx ~ awaiting calls id :", _), e && e({
295
+ chainId: O,
294
296
  action: "swap",
295
297
  callsId: _,
296
298
  receiptPromise: r,
@@ -316,14 +318,14 @@ function T({ marketPrice: T }) {
316
318
  }
317
319
  } });
318
320
  } else if (g) {
319
- let i = q({
321
+ let i = K({
320
322
  hash: g,
321
- chainId: k,
323
+ chainId: O,
322
324
  onReplaced: (e) => {
323
- E.log("onReplaced:swapTx", g, e);
325
+ T.log("onReplaced:swapTx", g, e);
324
326
  }
325
327
  });
326
- E.log("~ swapTx ~ awaiting tx hash :", g), r.throwIfAborted();
328
+ T.log("~ swapTx ~ awaiting tx hash :", g), r.throwIfAborted();
327
329
  let a = new Promise((e, t) => {
328
330
  r.onabort = () => {
329
331
  try {
@@ -334,7 +336,7 @@ function T({ marketPrice: T }) {
334
336
  };
335
337
  }), o = Promise.race([i, a]);
336
338
  e && e({
337
- chainId: k,
339
+ chainId: O,
338
340
  action: "swap",
339
341
  transactionHash: g,
340
342
  receiptPromise: o,
@@ -361,7 +363,7 @@ function T({ marketPrice: T }) {
361
363
  }
362
364
  } });
363
365
  }
364
- return E.log("~ swapTx ~ receipt:", v || b), {
366
+ return T.log("~ swapTx ~ receipt:", v || b), {
365
367
  tradeFlowType: C,
366
368
  approve: {
367
369
  txHash: a,
@@ -375,11 +377,11 @@ function T({ marketPrice: T }) {
375
377
  callsReceipt: v
376
378
  },
377
379
  marketPrice: t,
378
- account: K,
379
- receiverAddress: Y
380
+ account: G,
381
+ receiverAddress: J
380
382
  };
381
383
  } catch (e) {
382
- throw i && ge(i.signedPermitData), y(e) || X?.({ event: {
384
+ throw i && ve(i.signedPermitData), y(e) || X?.({ event: {
383
385
  name: "Swap:failed",
384
386
  params: {
385
387
  swapMode: "market",
@@ -390,48 +392,48 @@ function T({ marketPrice: T }) {
390
392
  d?.();
391
393
  }
392
394
  },
393
- mutationKey: [w],
395
+ mutationKey: [ce],
394
396
  onSuccess: (e) => {
395
- E.log("Swap tx success", e);
397
+ T.log("Swap tx success", e);
396
398
  },
397
399
  onError: (e) => {
398
- E.error("Swap tx error", e);
400
+ T.error("Swap tx error", e);
399
401
  },
400
402
  onSettled: () => {
401
- E.log("Swap tx settled");
403
+ T.log("Swap tx settled");
402
404
  }
403
405
  }), Q = Z.mutateAsync, $ = () => {
404
- J.current = null, P.reset(), F.reset(), L.reset(), R.reset(), B.reset(), Z.reset(), U.reset();
405
- }, Ce = (e) => {
406
- let t = J.current;
406
+ q.current = null, N.reset(), P.reset(), I.reset(), L.reset(), z.reset(), Z.reset(), H.reset();
407
+ }, Te = (e) => {
408
+ let t = q.current;
407
409
  return $(), Q({
408
410
  ...e,
409
411
  lastPrice: t
410
412
  });
411
- }, we = J.current || j, Te = Z.data?.swap.swapRequest;
413
+ }, Ee = q.current || A, De = Z.data?.swap.swapRequest;
412
414
  return {
413
415
  tradeFlowType: C,
414
- chainId: k,
416
+ chainId: O,
415
417
  runMarketSwapFlow: Q,
416
418
  reset: $,
417
- cancelFlow: me,
418
- retryFlow: Ce,
419
- approval: M,
420
- signPermit: N,
421
- buildTxParams: le,
422
- swap: de,
423
- swapBatch: fe,
419
+ cancelFlow: ge,
420
+ retryFlow: Te,
421
+ approval: j,
422
+ signPermit: M,
423
+ buildTxParams: de,
424
+ swap: pe,
425
+ swapBatch: me,
424
426
  isPending: Z.isPending,
425
427
  isSuccess: Z.isSuccess,
426
428
  isError: Z.isError,
427
429
  error: Z.error,
428
430
  result: Z.data,
429
- usedPrice: we,
430
- freshPrice: j,
431
- submittedSwapRequest: Te
431
+ usedPrice: Ee,
432
+ freshPrice: A,
433
+ submittedSwapRequest: De
432
434
  };
433
435
  }
434
436
  //#endregion
435
- export { T as useMarketFlow };
437
+ export { w as useMarketFlow };
436
438
 
437
439
  //# sourceMappingURL=useMarketFlow.js.map