@orbs-network/spot-react 1.1.21 → 1.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,382 @@
1
+ # @orbs-network/spot-react
2
+
3
+ React SDK for building TWAP, Limit, Stop-Loss, and Take-Profit order interfaces on top of the [Orbs Spot protocol](https://www.orbs.com/).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @orbs-network/spot-react
9
+ ```
10
+
11
+ ### Peer Dependencies
12
+
13
+ These must be installed in your application:
14
+
15
+ ```bash
16
+ npm install @tanstack/react-query bignumber.js react-error-boundary zustand react react-dom
17
+ ```
18
+
19
+ | Package | Version |
20
+ | ---------------------- | ---------- |
21
+ | `@tanstack/react-query`| `^5.90.12` |
22
+ | `bignumber.js` | `^9.3.1` |
23
+ | `react-error-boundary` | `^6.0.0` |
24
+ | `zustand` | `^5.0.9` |
25
+ | `react` | `^18 \|\| ^19` |
26
+ | `react-dom` | `^18 \|\| ^19` |
27
+
28
+ ## Quick Start
29
+
30
+ ```tsx
31
+ import {
32
+ SpotProvider,
33
+ useSpot,
34
+ Module,
35
+ Partners,
36
+ type WalletInteractions,
37
+ } from "@orbs-network/spot-react";
38
+
39
+ function App() {
40
+ return (
41
+ <SpotProvider
42
+ chainId={137} // Polygon
43
+ walletInteractions={walletInteractions} // Wallet interaction handlers
44
+ account={walletAddress} // Connected wallet address
45
+ partner={Partners.Quick} // DEX partner
46
+ module={Module.TWAP} // Order type
47
+ typedInputAmount={inputAmount} // User-typed amount (string)
48
+ priceProtection={0.5} // Slippage tolerance %
49
+ minChunkSizeUsd={5} // Min chunk size in USD
50
+ srcToken={srcToken} // { address, symbol, decimals, logoUrl }
51
+ dstToken={dstToken}
52
+ srcBalance={srcBalanceWei} // Balance in wei (string)
53
+ dstBalance={dstBalanceWei}
54
+ srcUsd1Token={srcUsdPrice} // USD price of 1 token (string)
55
+ dstUsd1Token={dstUsdPrice}
56
+ marketReferencePrice={marketPrice} // { value?: string, isLoading?: boolean }
57
+ callbacks={callbacks} // Lifecycle event handlers
58
+ fees={0.25} // Fee percentage
59
+ >
60
+ <SwapForm />
61
+ </SpotProvider>
62
+ );
63
+ }
64
+ ```
65
+
66
+ ## WalletInteractions
67
+
68
+ The host app provides wallet interaction handlers via the `walletInteractions` prop. This keeps spot-react wallet-agnostic — it works with viem, ethers, web3.js, or any wallet library.
69
+
70
+ ```tsx
71
+ const walletInteractions: WalletInteractions = {
72
+ // Wrap native token (e.g. ETH -> WETH). Wait for receipt, return tx hash.
73
+ wrapNativeToken: async (amountWei) => { ... },
74
+
75
+ // Approve ERC-20 token spending. Wait for receipt, return tx hash.
76
+ approveToken: async ({ token, amount, spender }) => { ... },
77
+
78
+ // Cancel an order on-chain. Wait for receipt, return tx hash.
79
+ cancelOrder: async ({ order, contractAddress, args }) => { ... },
80
+
81
+ // Sign EIP-712 typed data for order creation. Return signature hex.
82
+ signOrder: async ({ domain, types, primaryType, message, account }) => { ... },
83
+
84
+ // Read ERC-20 allowance. Return allowance as string.
85
+ getAllowance: async ({ tokenAddress, spenderAddress }) => { ... },
86
+ };
87
+ ```
88
+
89
+ Each write method (`wrapNativeToken`, `approveToken`, `cancelOrder`) should wait for tx confirmation and throw if the transaction reverts.
90
+
91
+ ### Example with viem/wagmi
92
+
93
+ ```tsx
94
+ import { erc20Abi } from "viem";
95
+
96
+ const walletInteractions: WalletInteractions = {
97
+ wrapNativeToken: async (amountWei) => {
98
+ const hash = await walletClient.writeContract({
99
+ abi: [{ name: "deposit", type: "function", stateMutability: "payable", inputs: [], outputs: [] }],
100
+ functionName: "deposit",
101
+ address: wTokenAddress,
102
+ args: [],
103
+ value: BigInt(amountWei),
104
+ chain: walletClient.chain,
105
+ account: walletClient.account!,
106
+ });
107
+ await publicClient.waitForTransactionReceipt({ hash, confirmations: 2 });
108
+ return hash;
109
+ },
110
+ approveToken: async ({ token, spender }) => {
111
+ const maxUint256 = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
112
+ const hash = await walletClient.writeContract({
113
+ abi: erc20Abi,
114
+ functionName: "approve",
115
+ address: token as `0x${string}`,
116
+ args: [spender as `0x${string}`, maxUint256],
117
+ chain: walletClient.chain,
118
+ account: walletClient.account!,
119
+ });
120
+ await publicClient.waitForTransactionReceipt({ hash, confirmations: 2 });
121
+ return hash;
122
+ },
123
+ cancelOrder: async ({ order, contractAddress, args }) => {
124
+ const hash = await walletClient.writeContract({
125
+ abi: cancelAbi, // TWAP_ABI for v1, REPERMIT_ABI for v2
126
+ functionName: "cancel",
127
+ address: contractAddress as `0x${string}`,
128
+ args: args as any,
129
+ chain: walletClient.chain,
130
+ account: walletClient.account!,
131
+ });
132
+ await publicClient.waitForTransactionReceipt({ hash, confirmations: 2 });
133
+ return hash;
134
+ },
135
+ signOrder: async ({ domain, types, primaryType, message, account }) => {
136
+ return walletClient.signTypedData({ domain, types, primaryType, message, account });
137
+ },
138
+ getAllowance: async ({ tokenAddress, spenderAddress }) => {
139
+ const result = await publicClient.readContract({
140
+ address: tokenAddress as `0x${string}`,
141
+ abi: erc20Abi,
142
+ functionName: "allowance",
143
+ args: [walletClient.account!.address, spenderAddress as `0x${string}`],
144
+ });
145
+ return String(result);
146
+ },
147
+ };
148
+ ```
149
+
150
+ ## SpotProvider Props
151
+
152
+ | Prop | Type | Required | Description |
153
+ | --- | --- | --- | --- |
154
+ | `partner` | `Partners` | Yes | DEX partner enum |
155
+ | `module` | `Module` | Yes | `TWAP`, `LIMIT`, `STOP_LOSS`, or `TAKE_PROFIT` |
156
+ | `typedInputAmount` | `string` | Yes | User-typed source amount |
157
+ | `priceProtection` | `number` | Yes | Slippage tolerance percentage |
158
+ | `minChunkSizeUsd` | `number` | Yes | Minimum trade chunk size in USD |
159
+ | `marketReferencePrice` | `MarketReferencePrice` | Yes | `{ value?: string, isLoading?: boolean, noLiquidity?: boolean }` |
160
+ | `walletInteractions` | `WalletInteractions` | Yes | Wallet interaction handlers |
161
+ | `chainId` | `number` | No | Connected chain ID |
162
+ | `account` | `string` | No | Connected wallet address |
163
+ | `srcToken` | `Token` | No | `{ address, symbol, decimals, logoUrl }` |
164
+ | `dstToken` | `Token` | No | `{ address, symbol, decimals, logoUrl }` |
165
+ | `srcBalance` | `string` | No | Source balance in wei |
166
+ | `dstBalance` | `string` | No | Destination balance in wei |
167
+ | `srcUsd1Token` | `string` | No | USD price of 1 source token |
168
+ | `dstUsd1Token` | `string` | No | USD price of 1 destination token |
169
+ | `callbacks` | `Callbacks` | No | Lifecycle event handlers |
170
+ | `fees` | `number` | No | Fee percentage (e.g. 0.25) |
171
+ | `isDev` | `boolean` | No | Enable dev mode |
172
+ | `overrides` | `Overrides` | No | Initial state overrides |
173
+
174
+ ## useSpot() Hook
175
+
176
+ The main hook returns all data and controls for building the UI:
177
+
178
+ ```tsx
179
+ const spot = useSpot();
180
+ ```
181
+
182
+ ### Returned panels
183
+
184
+ | Panel | Description |
185
+ | --- | --- |
186
+ | `spot.dstTokenPanel` | `{ value, isLoading }` — estimated output amount |
187
+ | `spot.tradesAmountPanel` | Total trades input, per-trade amounts, validation |
188
+ | `spot.durationPanel` | Order expiry duration input |
189
+ | `spot.fillDelayPanel` | Trade interval input |
190
+ | `spot.limitPricePanel` | Limit price input with percentage, toggle, reset |
191
+ | `spot.triggerPricePanel` | Trigger price for stop-loss / take-profit |
192
+ | `spot.pricePanel` | Market price display, inversion toggle |
193
+ | `spot.disclaimerPanel` | Disclaimer key string (or `undefined`) |
194
+ | `spot.inputError` | Validation error `{ type, args }` (or `undefined`) |
195
+ | `spot.submitOrderButton` | `{ disabled, loading }` |
196
+ | `spot.orderExecutionPanel` | Full submission lifecycle (see below) |
197
+ | `spot.orderHistoryPanel` | `{ orders: { all: Order[] } }` |
198
+ | `spot.derivedFormData` | Computed values: amounts, prices, deadline, fees |
199
+ | `spot.supportedChains` | Partner's supported chain IDs |
200
+ | `spot.module` | Current `Module` enum |
201
+
202
+ ### Order Execution Panel
203
+
204
+ ```tsx
205
+ const {
206
+ onSubmit, // Trigger order creation
207
+ status, // SwapStatus: LOADING | SUCCESS | FAILED
208
+ step, // Current step: WRAP | APPROVE | CREATE
209
+ stepIndex, // Current step index (0-based)
210
+ totalSteps, // Total number of steps
211
+ parsedError, // { code, message } on failure
212
+ onSwapSuccess, // Call when user acknowledges success
213
+ confirmButtonLoading, // Loading state for confirm button
214
+ srcToken, // Resolved source token
215
+ dstToken, // Resolved destination token
216
+ wrapTxHash, // Wrap transaction hash
217
+ approveTxHash, // Approve transaction hash
218
+ } = useSpot().orderExecutionPanel;
219
+ ```
220
+
221
+ ### Cancel Order
222
+
223
+ ```tsx
224
+ import { useCancelOrder } from "@orbs-network/spot-react";
225
+
226
+ // Inside a component rendered within SpotProvider:
227
+ const { cancelOrder, isLoading, isSuccess, isError, error, txHash } = useCancelOrder(order);
228
+
229
+ // Cancel the order
230
+ await cancelOrder();
231
+
232
+ // Or use getCancelStatus for any order by ID:
233
+ const { getCancelStatus } = useCancelOrder();
234
+ const status = getCancelStatus(orderId); // { status, txHash?, error? } | undefined
235
+ ```
236
+
237
+ ## Callbacks
238
+
239
+ Pass lifecycle callbacks to `SpotProvider` for wallet notifications:
240
+
241
+ ```tsx
242
+ const callbacks: Callbacks = {
243
+ // Token wrapping
244
+ onWrapRequest: () => {},
245
+ onWrapSuccess: ({ txHash, explorerUrl, amount }) => {},
246
+
247
+ // Token approval
248
+ onApproveRequest: () => {},
249
+ onApproveSuccess: ({ txHash, explorerUrl, token, amount }) => {},
250
+
251
+ // Order lifecycle
252
+ onSignOrderRequest: () => {},
253
+ onSignOrderSuccess: (signature) => {},
254
+ onSignOrderError: (error) => {},
255
+ onOrderCreated: (order) => {},
256
+ onOrderFilled: (order) => {},
257
+
258
+ // Errors
259
+ onSubmitOrderFailed: ({ code, message }) => {},
260
+ onSubmitOrderRejected: () => {},
261
+
262
+ // Order cancellation
263
+ onCancelOrderRequest: (order) => {},
264
+ onCancelOrderSuccess: ({ order, txHash, explorerUrl }) => {},
265
+ onCancelOrderFailed: (error) => {},
266
+
267
+ // Progress (good place to refetch balances)
268
+ onOrdersProgressUpdate: (orders) => {},
269
+
270
+ // Clipboard
271
+ onCopy: () => {},
272
+
273
+ // State change callbacks
274
+ onLimitPriceChange: (price) => {},
275
+ onTriggerPriceChange: (price) => {},
276
+ onDurationChange: (duration) => {},
277
+ onFillDelayChange: (fillDelay) => {},
278
+ onChunksChange: (chunks) => {},
279
+ };
280
+ ```
281
+
282
+ ## Translations / i18n
283
+
284
+ The SDK returns string keys for user-facing messages. You should resolve these through your own i18n system.
285
+
286
+ ### Disclaimer keys
287
+
288
+ `useSpot().disclaimerPanel` returns one of:
289
+ - `"limitOrderDisclaimer"` — shown for limit and TWAP-limit orders
290
+ - `"marketOrderDisclaimer"` — shown for market orders
291
+ - `"triggerMarketPriceDisclaimer"` — shown for stop-loss at market price
292
+
293
+ ### Input error keys
294
+
295
+ `useSpot().inputError` returns `{ type, args }` where `type` is a key like:
296
+ - `"enterAmount"`, `"insufficientFunds"`, `"emptyLimitPrice"`, `"emptyTriggerPrice"`
297
+ - `"maxChunksError"` (args: `{ maxChunks }`)
298
+ - `"minChunksError"` (args: `{ minChunks }`)
299
+ - `"minTradeSizeError"` (args: `{ minTradeSize }`)
300
+ - `"minDurationError"` / `"maxDurationError"` (args: `{ duration }`)
301
+ - `"minFillDelayError"` / `"maxFillDelayError"` (args: `{ fillDelay }`)
302
+ - `"noLiquidity"`
303
+
304
+ ## Order Types
305
+
306
+ | Module | Description |
307
+ | --- | --- |
308
+ | `Module.TWAP` | Time-Weighted Average Price — splits order into multiple trades over time |
309
+ | `Module.LIMIT` | Limit order — executes at specified price or better |
310
+ | `Module.STOP_LOSS` | Stop-loss — triggers when price drops to threshold |
311
+ | `Module.TAKE_PROFIT` | Take-profit — triggers when price rises to threshold |
312
+
313
+ ### Panel visibility by module
314
+
315
+ | Panel | TWAP | LIMIT | STOP_LOSS | TAKE_PROFIT |
316
+ | --- | --- | --- | --- | --- |
317
+ | Trades amount | Yes | — | — | — |
318
+ | Fill delay | Yes | — | — | — |
319
+ | Duration | — | Yes | Yes | Yes |
320
+ | Limit price | Yes | Yes | Yes | Yes |
321
+ | Trigger price | — | — | Yes | Yes |
322
+
323
+ ## Helper Hooks
324
+
325
+ ```tsx
326
+ import {
327
+ useExplorerLink, // (txHash?: string) => explorer URL
328
+ useNetwork, // () => network info (name, native, wToken, explorer)
329
+ useAmountUi, // (amount: string, decimals: number) => formatted amount
330
+ } from "@orbs-network/spot-react";
331
+ ```
332
+
333
+ ## Utility Functions
334
+
335
+ ```tsx
336
+ import {
337
+ getPartners, // () => all registered partners
338
+ getPartnerChains, // (partner) => supported chain IDs
339
+ getNetwork, // (chainId) => network config
340
+ isNativeAddress, // (address) => boolean
341
+ eqIgnoreCase, // (a, b) => case-insensitive address comparison
342
+ getConfig, // (partner, chainId) => SpotConfig
343
+ } from "@orbs-network/spot-react";
344
+ ```
345
+
346
+ ## Overrides
347
+
348
+ For initial form state, pass `overrides` to `SpotProvider`:
349
+
350
+ ```tsx
351
+ <SpotProvider
352
+ overrides={{
353
+ state: {
354
+ isMarketOrder: false,
355
+ chunks: 10,
356
+ limitPrice: "1.5",
357
+ triggerPrice: "1.2",
358
+ fillDelay: { value: 5, unit: TimeUnit.Minutes },
359
+ duration: { value: 1, unit: TimeUnit.Days },
360
+ },
361
+ }}
362
+ // ...other props
363
+ />
364
+ ```
365
+
366
+ ## Constants
367
+
368
+ ```tsx
369
+ import {
370
+ SPOT_VERSION, // SDK version identifier
371
+ DISCLAIMER_URL, // Orbs disclaimer page
372
+ ORBS_TWAP_FAQ_URL, // TWAP FAQ page
373
+ ORBS_SLTP_FAQ_URL, // Stop-Loss/Take-Profit FAQ page
374
+ ORBS_LOGO, // Orbs logo URL
375
+ ORBS_WEBSITE_URL, // Orbs website
376
+ networks, // All supported network configs
377
+ } from "@orbs-network/spot-react";
378
+ ```
379
+
380
+ ## License
381
+
382
+ MIT
@@ -1,6 +1,6 @@
1
1
  declare const _default: {
2
2
  "name": "@orbs-network/spot-react",
3
- "version": "1.1.21",
3
+ "version": "1.1.23",
4
4
  "description": "Spot React Components - React components for Spot SDK",
5
5
  "type": "module",
6
6
  "main": "./dist/spot-react.umd.cjs",
@@ -35,7 +35,6 @@ declare const _default: {
35
35
  "react": "^18.0.0 || ^19.0.0",
36
36
  "react-dom": "^18.0.0 || ^19.0.0",
37
37
  "react-error-boundary": "^6.0.0",
38
- "viem": "^2.43.3",
39
38
  "zustand": "^5.0.9"
40
39
  },
41
40
  "dependencies": {
@@ -1,6 +1,17 @@
1
+ import { SwapStatus } from '../types';
1
2
  import { Order } from '../../../spot-ui/src/index.ts';
2
- export declare const useCancelOrderRefetchUntilStatusSynced: () => import('@tanstack/react-query').UseMutationResult<void, Error, string[], unknown>;
3
- export declare const useCancelOrderMutation: () => import('@tanstack/react-query').UseMutationResult<(string | undefined)[] | undefined, Error, {
4
- orders: Order[];
5
- }, unknown>;
3
+ export declare const useCancelOrderRefetchUntilStatusSynced: () => import('@tanstack/react-query').UseMutationResult<void, Error, string, unknown>;
4
+ export type CancelOrderStatus = {
5
+ status: SwapStatus;
6
+ txHash?: string;
7
+ error?: string;
8
+ };
9
+ export declare const useCancelOrder: (order?: Order) => {
10
+ isLoading: boolean;
11
+ isSuccess: boolean;
12
+ isError: boolean;
13
+ error: string | undefined;
14
+ txHash: string | undefined;
15
+ cancelOrder: () => Promise<`0x${string}` | undefined>;
16
+ };
6
17
  //# sourceMappingURL=use-cancel-order.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-cancel-order.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-cancel-order.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,EAIN,MAAM,uBAAuB,CAAC;AAU/B,eAAO,MAAM,sCAAsC,yFA0BlD,CAAC;AAEF,eAAO,MAAM,sBAAsB;YAgEU,KAAK,EAAE;WA+CnD,CAAC"}
1
+ {"version":3,"file":"use-cancel-order.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-cancel-order.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAa,KAAK,EAAe,MAAM,uBAAuB,CAAC;AAUtE,eAAO,MAAM,sCAAsC,uFAwBlD,CAAC;AAuBF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,QAAQ,KAAK;;;;;;;CAqF3C,CAAC"}
@@ -12,8 +12,7 @@ import { useSubmitOrderButton, useSubmitOrderPanel } from './use-submit-order-pa
12
12
  import { useFormData } from './use-form-data';
13
13
  import { useOrderHistoryPanel } from './order-hooks';
14
14
  import { usePartnerChains } from './use-partner-chains';
15
- import { useCancelOrderMutation, useCancelOrderRefetchUntilStatusSynced } from './use-cancel-order';
16
- import { useSignOrder, useSubmitOrderMutation } from './use-submit-order';
15
+ import { useCancelOrderRefetchUntilStatusSynced } from './use-cancel-order';
17
16
  import { Module } from '../../../spot-ui/src/index.ts';
18
17
  type SpotData = {
19
18
  tradesAmountPanel: ReturnType<typeof useTradesPanel>;
@@ -31,12 +30,7 @@ type SpotData = {
31
30
  derivedFormData: ReturnType<typeof useFormData>;
32
31
  supportedChains: ReturnType<typeof usePartnerChains>;
33
32
  module: Module;
34
- mutations: {
35
- cancelOrder: ReturnType<typeof useCancelOrderMutation>;
36
- signOrder: ReturnType<typeof useSignOrder>;
37
- submitOrder: ReturnType<typeof useSubmitOrderMutation>;
38
- refetchUntilStatusSynced: ReturnType<typeof useCancelOrderRefetchUntilStatusSynced>;
39
- };
33
+ refetchUntilStatusSynced: ReturnType<typeof useCancelOrderRefetchUntilStatusSynced>;
40
34
  };
41
35
  export declare const SpotDataProvider: ({ children, }: {
42
36
  children: React.ReactNode;
@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c,CAAC,CAAC;IAC9C,iBAAiB,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;IAC3D,iBAAiB,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;IAC3D,mBAAmB,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;IAC5D,eAAe,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;IAChD,eAAe,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB,EAAE,UAAU,CAClC,OAAO,sCAAsC,CAC9C,CAAC;CACH,CAAC;AAIF,eAAO,MAAM,gBAAgB,GAAI,eAE9B;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,4CA0CA,CAAC;AAEF,eAAO,MAAM,OAAO,gBAMnB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-submit-order-panel.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-submit-order-panel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAStC,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;CAkC/B,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;CAsChC,CAAC"}
1
+ {"version":3,"file":"use-submit-order-panel.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-submit-order-panel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAStC,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;CAmC/B,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;CAsChC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-submit-order.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-submit-order.ts"],"names":[],"mappings":"AAqGA,eAAO,MAAM,YAAY,sHAmDxB,CAAC;AAyLF,eAAO,MAAM,sBAAsB,sHA8GlC,CAAC"}
1
+ {"version":3,"file":"use-submit-order.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-submit-order.ts"],"names":[],"mappings":"AAwFA,eAAO,MAAM,YAAY,sHAmDxB,CAAC;AAiKF,eAAO,MAAM,sBAAsB,sHA+GlC,CAAC"}
@@ -1,10 +1,13 @@
1
1
  import { SpotProvider } from './spot-context';
2
2
  import { useDerivedHistoryOrder } from './hooks/use-history-order';
3
3
  import { useSpot } from './hooks/use-spot';
4
+ import { useCancelOrder } from './hooks/use-cancel-order';
5
+ import { useSignOrder, useSubmitOrderMutation } from './hooks/use-submit-order';
4
6
  export * from './types';
5
7
  export * from './utils';
6
8
  export { useAmountUi, useExplorerLink, useNetwork } from './hooks/helper-hooks';
7
9
  export { useSwapExecution } from './hooks/use-swap-execution';
8
- export { type Config, type SpotConfig, type TimeDuration, type PartnerPayloadItem, type RePermitOrder, type Signature, type Address, type Hex, type InputError, Module, OrderStatus, OrderFilter, OrderType, TimeUnit, Partners, InputErrors, getConfig, getPartners, getMinChunkSizeUsd, buildRePermitOrderData, submitOrder, getNetwork, getPartnerChains, isNativeAddress, eqIgnoreCase, getOrderExecutionRate, getOrderLimitPriceRate, getOrderFillDelayMillis, getTriggerPriceRate, SPOT_VERSION, DISCLAIMER_URL, ORBS_TWAP_FAQ_URL, ORBS_SLTP_FAQ_URL, ORBS_LOGO, ORBS_WEBSITE_URL, networks, IWETH_ABI, ERC20_ABI, REPERMIT_ABI, TWAP_ABI, } from '../../spot-ui/src/index.ts';
9
- export { SpotProvider, useSpot, useDerivedHistoryOrder, };
10
+ export { type CancelOrderStatus } from './hooks/use-cancel-order';
11
+ export { type Config, type SpotConfig, type TimeDuration, type PartnerPayloadItem, type RePermitOrder, type Signature, type Address, type Hex, type InputError, Module, OrderStatus, OrderFilter, OrderType, TimeUnit, Partners, InputErrors, getConfig, getPartners, getMinChunkSizeUsd, buildRePermitOrderData, submitOrder, getNetwork, getPartnerChains, isNativeAddress, eqIgnoreCase, getOrderExecutionRate, getOrderLimitPriceRate, getOrderFillDelayMillis, getTriggerPriceRate, SPOT_VERSION, DISCLAIMER_URL, ORBS_TWAP_FAQ_URL, ORBS_SLTP_FAQ_URL, ORBS_LOGO, ORBS_WEBSITE_URL, networks, } from '../../spot-ui/src/index.ts';
12
+ export { SpotProvider, useSpot, useDerivedHistoryOrder, useCancelOrder, useSignOrder, useSubmitOrderMutation as useSubmitOrder };
10
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAO9D,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,GAAG,EACR,KAAK,UAAU,EAGf,MAAM,EACN,WAAW,EACX,WAAW,EACX,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,WAAW,EAGX,SAAS,EACT,WAAW,EACX,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EAGnB,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,QAAQ,EAGR,SAAS,EAC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AAC;AAG/B,OAAO,EACL,YAAY,EACZ,OAAO,EACP,sBAAsB,EACtB,cAAc,EACd,YAAY,EACZ,sBAAsB,IAAI,cAAc,EACzC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"spot-context.d.ts","sourceRoot":"","sources":["../../../src/spot-context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwD,MAAM,OAAO,CAAC;AAU7E,OAAO,EACL,SAAS,EACT,eAAe,EAGhB,MAAM,SAAS,CAAC;AAiEjB,eAAO,MAAM,WAAW,uCAA8C,CAAC;AA2LvE,eAAO,MAAM,YAAY,GAAI,OAAO,SAAS,4CAM5C,CAAC;AAEF,eAAO,MAAM,cAAc,uBAM1B,CAAC"}
1
+ {"version":3,"file":"spot-context.d.ts","sourceRoot":"","sources":["../../../src/spot-context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwD,MAAM,OAAO,CAAC;AAU7E,OAAO,EACL,SAAS,EACT,eAAe,EAEhB,MAAM,SAAS,CAAC;AAoCjB,eAAO,MAAM,WAAW,uCAA8C,CAAC;AAqLvE,eAAO,MAAM,YAAY,GAAI,OAAO,SAAS,4CAM5C,CAAC;AAEF,eAAO,MAAM,cAAc,uBAM1B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE/C,UAAU,SAAS;IACjB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,WAAW,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IAC7C,yBAAyB,EAAE,MAAM,IAAI,CAAC;IACtC,0BAA0B,EAAE,CAC1B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,KAC1B,IAAI,CAAC;IACV,KAAK,EAAE,KAAK,CAAC;CACd;AAUD,eAAO,MAAM,YAAY,wEA+BtB,CAAC"}
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE/C,UAAU,SAAS;IACjB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,WAAW,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IAC7C,yBAAyB,EAAE,MAAM,IAAI,CAAC;IACtC,0BAA0B,EAAE,CAC1B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,KAC1B,IAAI,CAAC;IACV,KAAK,EAAE,KAAK,CAAC;CACd;AAWD,eAAO,MAAM,YAAY,wEA+BtB,CAAC"}
@@ -1,5 +1,4 @@
1
1
  import { Partners, Module, Order, SpotConfig, TimeDuration } from '../../spot-ui/src/index.ts';
2
- import { createPublicClient, createWalletClient, Abi } from 'viem';
3
2
  export declare enum SwapStatus {
4
3
  LOADING = 1,
5
4
  SUCCESS = 2,
@@ -7,29 +6,29 @@ export declare enum SwapStatus {
7
6
  }
8
7
  export type { Order } from '../../spot-ui/src/index.ts';
9
8
  export { OrderStatus, type OrderFill, OrderType, Module } from '../../spot-ui/src/index.ts';
10
- export interface Provider {
11
- request(...args: any): Promise<any>;
12
- [key: string]: any;
13
- }
14
- export type PublicClient = ReturnType<typeof createPublicClient>;
15
- export type WalletClient = ReturnType<typeof createWalletClient>;
16
- export type ApproveProps = {
17
- tokenAddress: string;
18
- amount: bigint;
19
- spenderAddress: string;
20
- };
21
- export type CreateOrderProps = {
22
- contractAddress: string;
23
- abi: Abi;
24
- functionName: string;
25
- args: [string[]];
9
+ export type SignOrderProps = {
10
+ domain: Record<string, unknown>;
11
+ types: Record<string, unknown[]>;
12
+ primaryType: string;
13
+ message: Record<string, unknown>;
14
+ account: `0x${string}`;
26
15
  };
27
16
  export type CancelOrderProps = {
17
+ order: Order;
28
18
  contractAddress: string;
29
- abi: Abi;
30
- functionName: string;
31
- args: number[];
32
- orderId: number;
19
+ args: string[] | string[][];
20
+ };
21
+ export type ApproveTokenProps = {
22
+ tokenAddress: string;
23
+ amount: string;
24
+ spenderAddress: string;
25
+ };
26
+ export type WalletInteractions = {
27
+ cancelOrder: (props: CancelOrderProps) => Promise<`0x${string}`>;
28
+ signOrder: (props: SignOrderProps) => Promise<`0x${string}`>;
29
+ wrapNativeToken: (amount: string) => Promise<`0x${string}`>;
30
+ approveToken: (props: ApproveTokenProps) => Promise<`0x${string}`>;
31
+ getAllowance: (props: GetAllowanceProps) => Promise<string>;
33
32
  };
34
33
  export type GetAllowanceProps = {
35
34
  tokenAddress: string;
@@ -51,10 +50,6 @@ export declare enum Disclaimer {
51
50
  LIMIT_PRICE = "limitOrderDisclaimer"
52
51
  }
53
52
  export type Overrides = {
54
- wrap?: (amountWei: string) => Promise<`0x${string}`>;
55
- approveOrder?: (props: ApproveProps) => Promise<`0x${string}`>;
56
- createOrder?: (props: CreateOrderProps) => Promise<`0x${string}`>;
57
- getAllowance?: (props: GetAllowanceProps) => Promise<string>;
58
53
  state?: Partial<InitialState>;
59
54
  };
60
55
  export type OnApproveSuccessCallback = {
@@ -69,8 +64,8 @@ export type OnWrapSuccessCallback = {
69
64
  amount: string;
70
65
  };
71
66
  export type OnCancelOrderSuccess = {
72
- orders: Order[];
73
- txHash: string;
67
+ order: Order;
68
+ txHash: `0x${string}`;
74
69
  explorerUrl: string;
75
70
  };
76
71
  export type ParsedError = {
@@ -78,7 +73,7 @@ export type ParsedError = {
78
73
  code: number;
79
74
  };
80
75
  export type Callbacks = {
81
- onCancelOrderRequest?: (orders: Order[]) => void;
76
+ onCancelOrderRequest?: (order: Order) => void;
82
77
  onCancelOrderSuccess?: (props: OnCancelOrderSuccess) => void;
83
78
  onCancelOrderFailed?: (error: Error) => void;
84
79
  onOrdersProgressUpdate?: (orders: Order[]) => void;
@@ -109,7 +104,7 @@ export type MarketReferencePrice = {
109
104
  };
110
105
  export interface SpotProps {
111
106
  children?: React.ReactNode;
112
- provider?: Provider;
107
+ walletInteractions: WalletInteractions;
113
108
  chainId?: number;
114
109
  account?: string;
115
110
  enableQueryParams?: boolean;
@@ -131,8 +126,7 @@ export interface SpotProps {
131
126
  isDev?: boolean;
132
127
  }
133
128
  export interface SpotContextType {
134
- walletClient?: ReturnType<typeof createWalletClient>;
135
- publicClient?: PublicClient;
129
+ walletInteractions?: WalletInteractions;
136
130
  marketPrice?: string;
137
131
  marketPriceLoading?: boolean;
138
132
  account?: `0x${string}`;
@@ -196,10 +190,11 @@ export interface State {
196
190
  limitPricePercent?: string | null;
197
191
  isMarketOrder?: boolean;
198
192
  currentTime: number;
199
- cancelOrderStatus?: SwapStatus;
200
- cancelOrderTxHash?: string;
201
- cancelOrderError?: string;
202
- cancelOrderId?: number;
193
+ cancelOrders: Record<string, {
194
+ status: SwapStatus;
195
+ txHash?: string;
196
+ error?: string;
197
+ }>;
203
198
  swapExecutions: SwapExecution[];
204
199
  swapExecutionIndex: number;
205
200
  }