@sodax/dapp-kit 0.0.1-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +260 -0
  2. package/dist/contexts/index.d.ts +7 -0
  3. package/dist/contexts/index.d.ts.map +1 -0
  4. package/dist/core/index.d.ts +4 -0
  5. package/dist/core/index.d.ts.map +1 -0
  6. package/dist/hooks/index.d.ts +5 -0
  7. package/dist/hooks/index.d.ts.map +1 -0
  8. package/dist/hooks/mm/index.d.ts +7 -0
  9. package/dist/hooks/mm/index.d.ts.map +1 -0
  10. package/dist/hooks/mm/useBorrow.d.ts +26 -0
  11. package/dist/hooks/mm/useBorrow.d.ts.map +1 -0
  12. package/dist/hooks/mm/useHubWalletAddress.d.ts +24 -0
  13. package/dist/hooks/mm/useHubWalletAddress.d.ts.map +1 -0
  14. package/dist/hooks/mm/useRepay.d.ts +26 -0
  15. package/dist/hooks/mm/useRepay.d.ts.map +1 -0
  16. package/dist/hooks/mm/useSupply.d.ts +32 -0
  17. package/dist/hooks/mm/useSupply.d.ts.map +1 -0
  18. package/dist/hooks/mm/useUserReservesData.d.ts +9 -0
  19. package/dist/hooks/mm/useUserReservesData.d.ts.map +1 -0
  20. package/dist/hooks/mm/useWithdraw.d.ts +26 -0
  21. package/dist/hooks/mm/useWithdraw.d.ts.map +1 -0
  22. package/dist/hooks/provider/index.d.ts +3 -0
  23. package/dist/hooks/provider/index.d.ts.map +1 -0
  24. package/dist/hooks/provider/useHubProvider.d.ts +3 -0
  25. package/dist/hooks/provider/useHubProvider.d.ts.map +1 -0
  26. package/dist/hooks/provider/useSpokeProvider.d.ts +4 -0
  27. package/dist/hooks/provider/useSpokeProvider.d.ts.map +1 -0
  28. package/dist/hooks/shared/index.d.ts +4 -0
  29. package/dist/hooks/shared/index.d.ts.map +1 -0
  30. package/dist/hooks/shared/useAllowance.d.ts +3 -0
  31. package/dist/hooks/shared/useAllowance.d.ts.map +1 -0
  32. package/dist/hooks/shared/useApprove.d.ts +10 -0
  33. package/dist/hooks/shared/useApprove.d.ts.map +1 -0
  34. package/dist/hooks/shared/useSodaxContext.d.ts +8 -0
  35. package/dist/hooks/shared/useSodaxContext.d.ts.map +1 -0
  36. package/dist/hooks/swap/index.d.ts +4 -0
  37. package/dist/hooks/swap/index.d.ts.map +1 -0
  38. package/dist/hooks/swap/useCreateIntentOrder.d.ts +33 -0
  39. package/dist/hooks/swap/useCreateIntentOrder.d.ts.map +1 -0
  40. package/dist/hooks/swap/useQuote.d.ts +39 -0
  41. package/dist/hooks/swap/useQuote.d.ts.map +1 -0
  42. package/dist/hooks/swap/useStatus.d.ts +31 -0
  43. package/dist/hooks/swap/useStatus.d.ts.map +1 -0
  44. package/dist/index.d.ts +4 -0
  45. package/dist/index.d.ts.map +1 -0
  46. package/dist/index.js +363 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/index.mjs +341 -0
  49. package/dist/index.mjs.map +1 -0
  50. package/dist/providers/SodaxProvider.d.ts +10 -0
  51. package/dist/providers/SodaxProvider.d.ts.map +1 -0
  52. package/dist/providers/index.d.ts +2 -0
  53. package/dist/providers/index.d.ts.map +1 -0
  54. package/package.json +54 -0
  55. package/src/contexts/index.ts +9 -0
  56. package/src/core/index.ts +42 -0
  57. package/src/hooks/index.ts +4 -0
  58. package/src/hooks/mm/index.ts +6 -0
  59. package/src/hooks/mm/useBorrow.ts +55 -0
  60. package/src/hooks/mm/useHubWalletAddress.ts +49 -0
  61. package/src/hooks/mm/useRepay.ts +56 -0
  62. package/src/hooks/mm/useSupply.ts +62 -0
  63. package/src/hooks/mm/useUserReservesData.ts +58 -0
  64. package/src/hooks/mm/useWithdraw.ts +59 -0
  65. package/src/hooks/provider/index.ts +2 -0
  66. package/src/hooks/provider/useHubProvider.ts +27 -0
  67. package/src/hooks/provider/useSpokeProvider.ts +23 -0
  68. package/src/hooks/shared/index.ts +3 -0
  69. package/src/hooks/shared/useAllowance.ts +31 -0
  70. package/src/hooks/shared/useApprove.ts +53 -0
  71. package/src/hooks/shared/useSodaxContext.ts +16 -0
  72. package/src/hooks/swap/index.ts +3 -0
  73. package/src/hooks/swap/useCreateIntentOrder.ts +57 -0
  74. package/src/hooks/swap/useQuote.ts +55 -0
  75. package/src/hooks/swap/useStatus.ts +44 -0
  76. package/src/index.ts +3 -0
  77. package/src/providers/SodaxProvider.tsx +16 -0
  78. package/src/providers/index.ts +1 -0
package/README.md ADDED
@@ -0,0 +1,260 @@
1
+ # @sodax/dapp-kit
2
+
3
+ dApp Kit is a collection of React components, hooks, and utilities designed to streamline dApp development within the Sodax ecosystem. It provides seamless integration with Sodax smart contracts, enabling easy data querying and transaction execution. Additionally, it offers built-in wallet connectivity for all supported wallets in the Sodax network, simplifying the user onboarding experience. Under the hood, dApp Kit leverages @sodax/wallet-kit and @sodax/sdk for seamless functionality.
4
+
5
+
6
+ ## Features
7
+
8
+ - Money Market
9
+ - Supply tokens to the money market (`useSupply`)
10
+ - Withdraw tokens from the money market (`useWithdraw`)
11
+ - Borrow tokens from the money market (`useBorrow`)
12
+ - Repay borrowed tokens (`useRepay`)
13
+ - Get user reserves data (`useUserReservesData`)
14
+ - Calculate hub wallet address by using spoke chain id and spoke chain wallet address (`useHubWalletAddress`)
15
+
16
+ - Swap/Intent
17
+ - Get quote for an intent order (`useQuote`)
18
+ - Create and submit an intent order (`useCreateIntentOrder`)
19
+ - Get status of an intent order (`useStatus`)
20
+
21
+ - Provider
22
+ - Get hub chain provider (`useHubProvider`)
23
+ - Get spoke chain provider (`useSpokeProvider`)
24
+ - Get wallet provider (`useWalletProvider`)
25
+
26
+ - Token Management
27
+ - Check token allowance (`useAllowance`)
28
+ - Approve token spending (`useApprove`)
29
+
30
+
31
+ ## Installation
32
+
33
+ ```bash
34
+ npm install @sodax/dapp-kit
35
+ # or
36
+ yarn add @sodax/dapp-kit
37
+ # or
38
+ pnpm add @sodax/dapp-kit
39
+ ```
40
+
41
+ ## Quick Start
42
+
43
+ 1. First, install the required dependencies:
44
+
45
+ ```bash
46
+ npm install @sodax/dapp-kit @tanstack/react-query @sodax/wallet-sdk
47
+ ```
48
+
49
+ 2. Set up the providers in your app:
50
+
51
+ ```typescript
52
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
53
+ import { XWagmiProviders } from '@sodax/wallet-sdk';
54
+ import { SodaxProvider } from '@sodax/dapp-kit';
55
+ import { SONIC_MAINNET_CHAIN_ID } from '@sodax/types';
56
+
57
+ const queryClient = new QueryClient();
58
+
59
+ // Configure Sodax
60
+ const sodaxConfig = {
61
+ hubProviderConfig: {
62
+ hubRpcUrl: 'https://rpc.soniclabs.com',
63
+ chainConfig: getHubChainConfig(SONIC_MAINNET_CHAIN_ID),
64
+ },
65
+ moneyMarket: getMoneyMarketConfig(SONIC_MAINNET_CHAIN_ID),
66
+ solver: {
67
+ intentsContract: '0x6382D6ccD780758C5e8A6123c33ee8F4472F96ef',
68
+ solverApiEndpoint: 'https://staging-new-world.iconblockchain.xyz',
69
+ partnerFee: {
70
+ address: '0x0Ab764AB3816cD036Ea951bE973098510D8105A6',
71
+ percentage: 100, // 1%
72
+ },
73
+ },
74
+ relayerApiEndpoint: 'https://xcall-relay.nw.iconblockchain.xyz',
75
+ };
76
+
77
+ function App() {
78
+ return (
79
+ <SodaxProvider testnet={false} config={sodaxConfig}>
80
+ <QueryClientProvider client={queryClient}>
81
+ <XWagmiProviders
82
+ config={{
83
+ EVM: {
84
+ wagmiConfig: wagmiConfig,
85
+ },
86
+ SUI: {
87
+ isMainnet: true,
88
+ },
89
+ SOLANA: {
90
+ endpoint: 'https://solana-mainnet.g.alchemy.com/v2/your-api-key',
91
+ },
92
+ }}
93
+ >
94
+ <YourApp />
95
+ </XWagmiProviders>
96
+ </QueryClientProvider>
97
+ </SodaxProvider>
98
+ );
99
+ }
100
+ ```
101
+
102
+ 3. Use the hooks in your components:
103
+
104
+ ```typescript
105
+ // Connect Wallet Operations
106
+ import { useXConnectors, useXConnect, useXAccount } from '@sodax/wallet-sdk';
107
+ const evmConnectors = useXConnectors('EVM');
108
+ const { mutateAsync: connect, isPending } = useXConnect();
109
+ const account = useXAccount('EVM');
110
+
111
+ const handleConnect = () => {
112
+ connect(evmConnectors[0]);
113
+ };
114
+
115
+ return (
116
+ <div>
117
+ <button onClick={handleConnect}>Connect EVM Wallet</button>
118
+ <div>Connected wallet: {account.address}</div>
119
+ </div>
120
+ );
121
+
122
+ // Money Market Operations
123
+ import { useSupply, useWithdraw, useBorrow, useRepay, useUserReservesData } from '@sodax/dapp-kit';
124
+
125
+ function MoneyMarketComponent() {
126
+ // Supply tokens
127
+ const { mutateAsync: supply, isPending: isSupplying } = useSupply(token);
128
+ const handleSupply = async (amount: string) => {
129
+ await supply(amount);
130
+ };
131
+
132
+ // Withdraw tokens
133
+ const { mutateAsync: withdraw, isPending: isWithdrawing } = useWithdraw(token, chainId);
134
+ const handleWithdraw = async (amount: string) => {
135
+ await withdraw(amount);
136
+ };
137
+
138
+ // Borrow tokens
139
+ const { mutateAsync: borrow, isPending: isBorrowing } = useBorrow(token, chainId);
140
+ const handleBorrow = async (amount: string) => {
141
+ await borrow(amount);
142
+ };
143
+
144
+ // Get user's supplied assets
145
+ const userReserves = useUserReservesData(chainId);
146
+ }
147
+
148
+ // Token Management
149
+ import { useAllowance, useApprove } from '@sodax/dapp-kit';
150
+
151
+ function TokenManagementComponent() {
152
+ // Check token allowance
153
+ const { data: hasAllowed } = useAllowance(token, amount);
154
+
155
+ // Approve token spending
156
+ const { approve, isLoading: isApproving } = useApprove(token);
157
+ const handleApprove = async (amount: string) => {
158
+ await approve(amount);
159
+ };
160
+ }
161
+
162
+ // Swap Operations
163
+ import { useQuote, useCreateIntentOrder, useStatus } from '@sodax/dapp-kit';
164
+
165
+ function SwapComponent() {
166
+ // Get quote for an intent order
167
+ const { data: quote, isLoading: isQuoteLoading } = useQuote({
168
+ token_src: '0x...',
169
+ token_src_blockchain_id: '0xa86a.avax',
170
+ token_dst: '0x...',
171
+ token_dst_blockchain_id: '0xa4b1.arbitrum',
172
+ amount: '1000000000000000000',
173
+ quote_type: 'exact_input',
174
+ });
175
+
176
+ // Create and submit an intent order
177
+ const { mutateAsync: createOrder, isPending: isCreating } = useCreateIntentOrder();
178
+ const handleCreateOrder = async () => {
179
+ const order = await createOrder({
180
+ token_src: '0x...',
181
+ token_src_blockchain_id: '0xa86a.avax',
182
+ token_dst: '0x...',
183
+ token_dst_blockchain_id: '0xa4b1.arbitrum',
184
+ amount: '1000000000000000000',
185
+ quote_type: 'exact_input',
186
+ });
187
+ };
188
+
189
+ // Get status of an intent order
190
+ const { data: orderStatus } = useStatus('0x...');
191
+ }
192
+ ```
193
+
194
+ ## Requirements
195
+
196
+ - Node.js >= 18.0.0
197
+ - React >= 19
198
+ - TypeScript
199
+
200
+ ## API Reference
201
+
202
+ ### Components
203
+
204
+ - [`SodaxProvider`](./src/providers/SodaxProvider.tsx) - Main provider component for Sodax ecosystem integration
205
+
206
+ ### Hooks
207
+
208
+ #### Money Market Hooks
209
+ - [`useBorrow()`](./src/hooks/mm/useBorrow.ts) - Borrow tokens from the money market
210
+ - [`useRepay()`](./src/hooks/mm/useRepay.ts) - Repay borrowed tokens
211
+ - [`useSupply()`](./src/hooks/mm/useSupply.ts) - Supply tokens to the money market
212
+ - [`useWithdraw()`](./src/hooks/mm/useWithdraw.ts) - Withdraw supplied tokens
213
+ - [`useUserReservesData()`](./src/hooks/mm/useUserReservesData.ts) - Get list of supplied assets
214
+ - [`useHubWalletAddress()`](./src/hooks/mm/useHubWalletAddress.ts) - Get hub wallet address for a spoke chain
215
+
216
+ #### Swap Hooks
217
+ - [`useQuote()`](./src/hooks/swap/useQuote.ts) - Get quote for an intent order
218
+ - [`useCreateIntentOrder()`](./src/hooks/swap/useCreateIntentOrder.ts) - Create and submit an intent order
219
+ - [`useStatus()`](./src/hooks/swap/useStatus.ts) - Get status of an intent order
220
+
221
+ #### Shared Hooks
222
+ - [`useSodaxContext()`](./src/hooks/shared/useSodaxContext.ts) - Access Sodax context and configuration
223
+ - [`useAllowance()`](./src/hooks/shared/useAllowance.ts) - Check token allowance for a specific amount
224
+ - [`useApprove()`](./src/hooks/shared/useApprove.ts) - Approve token spending
225
+
226
+
227
+ ## Contributing
228
+
229
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
230
+
231
+ ## Development
232
+
233
+ ```bash
234
+ # Install dependencies
235
+ pnpm install
236
+
237
+ # Build the package
238
+ pnpm build
239
+
240
+ # Run in development mode
241
+ pnpm dev
242
+
243
+ # Run type checking
244
+ pnpm checkTs
245
+
246
+ # Format code
247
+ pnpm pretty
248
+
249
+ # Lint code
250
+ pnpm lint
251
+ ```
252
+
253
+ ## License
254
+
255
+ [MIT](LICENSE)
256
+
257
+ ## Support
258
+
259
+ - [GitHub Issues](https://github.com/icon-project/sodax-frontend/issues)
260
+ - [Discord Community](https://discord.gg/sodax-formerly-icon-880651922682560582)
@@ -0,0 +1,7 @@
1
+ import type { Sodax } from '@sodax/sdk';
2
+ export interface SodaxContextType {
3
+ sodax: Sodax;
4
+ testnet: boolean;
5
+ }
6
+ export declare const SodaxContext: import("react").Context<SodaxContextType | null>;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contexts/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,eAAO,MAAM,YAAY,kDAA+C,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { XToken, ChainId } from '@sodax/types';
2
+ export declare const allXTokens: XToken[];
3
+ export declare const getSpokeTokenAddressByVault: (spokeChainId: ChainId, vault: string) => string;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAKpD,eAAO,MAAM,UAAU,EAAE,MAAM,EAAO,CAAC;AA0BvC,eAAO,MAAM,2BAA2B,iBAAkB,OAAO,SAAS,MAAM,WAU/E,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './shared';
2
+ export * from './provider';
3
+ export * from './mm';
4
+ export * from './swap';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,MAAM,CAAC;AACrB,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from './useBorrow';
2
+ export * from './useRepay';
3
+ export * from './useSupply';
4
+ export * from './useWithdraw';
5
+ export * from './useUserReservesData';
6
+ export * from './useHubWalletAddress';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { ChainId, XToken } from '@sodax/types';
2
+ import { type UseMutationResult } from '@tanstack/react-query';
3
+ interface BorrowResponse {
4
+ ok: true;
5
+ value: [`0x${string}`, `0x${string}`];
6
+ }
7
+ /**
8
+ * Hook for borrowing tokens from the Sodax money market.
9
+ *
10
+ * This hook provides functionality to borrow tokens from the money market protocol,
11
+ * handling the entire borrow process including transaction creation, submission,
12
+ * and cross-chain communication.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const { mutateAsync: borrow, isPending, error } = useBorrow(hubToken, spokeChainId);
17
+ * await borrow('100');
18
+ * ```
19
+ *
20
+ * @throws {Error} When:
21
+ * - spokeProvider is not available
22
+ * - Transaction execution fails
23
+ */
24
+ export declare function useBorrow(hubToken: XToken, spokeChainId: ChainId): UseMutationResult<BorrowResponse, Error, string>;
25
+ export {};
26
+ //# sourceMappingURL=useBorrow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBorrow.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useBorrow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAK5E,UAAU,cAAc;IACtB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,KAAK,MAAM,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,iBAAiB,CAAC,cAAc,EAAE,KAAK,EAAE,MAAM,CAAC,CA0BnH"}
@@ -0,0 +1,24 @@
1
+ import { type EvmHubProvider, type SpokeChainId } from '@sodax/sdk';
2
+ import { type UseQueryResult } from '@tanstack/react-query';
3
+ /**
4
+ * Hook for retrieving the hub wallet address for a given spoke chain and address.
5
+ *
6
+ * This hook fetches the hub wallet address associated with a user's address on a specific spoke chain.
7
+ * It uses the EvmWalletAbstraction to query the hub wallet address from the hub provider.
8
+ *
9
+ * @param spokeChainId - The chain ID of the spoke chain
10
+ * @param address - The user's address on the spoke chain
11
+ * @param hubProvider - The hub provider instance
12
+ *
13
+ * @returns {UseQueryResult<string | null>} A query result object containing:
14
+ * - data: The hub wallet address or null if not found
15
+ * - isLoading: Boolean indicating if the query is in progress
16
+ * - error: Error object if the query failed, null otherwise
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const { data: hubWalletAddress, isLoading, error } = useHubWalletAddress(spokeChainId, address, hubProvider);
21
+ * ```
22
+ */
23
+ export declare function useHubWalletAddress(spokeChainId: SpokeChainId, address: string | undefined, hubProvider: EvmHubProvider): UseQueryResult<string | null>;
24
+ //# sourceMappingURL=useHubWalletAddress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHubWalletAddress.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useHubWalletAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAwB,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1F,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,WAAW,EAAE,cAAc,GAC1B,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC,CAoB/B"}
@@ -0,0 +1,26 @@
1
+ import type { ChainId, XToken } from '@sodax/types';
2
+ import { type UseMutationResult } from '@tanstack/react-query';
3
+ interface RepayResponse {
4
+ ok: true;
5
+ value: [`0x${string}`, `0x${string}`];
6
+ }
7
+ /**
8
+ * Hook for repaying borrowed tokens to the Sodax money market.
9
+ *
10
+ * This hook provides functionality to repay borrowed tokens back to the money market protocol,
11
+ * handling the entire repayment process including transaction creation, submission,
12
+ * and cross-chain communication.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const { mutateAsync: repay, isPending, error } = useRepay(hubToken, spokeChainId);
17
+ * await repay('100');
18
+ * ```
19
+ *
20
+ * @throws {Error} When:
21
+ * - spokeProvider is not available
22
+ * - Transaction execution fails
23
+ */
24
+ export declare function useRepay(hubToken: XToken, spokeChainId: ChainId): UseMutationResult<RepayResponse, Error, string>;
25
+ export {};
26
+ //# sourceMappingURL=useRepay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRepay.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useRepay.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAK5E,UAAU,aAAa;IACrB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,KAAK,MAAM,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,iBAAiB,CAAC,aAAa,EAAE,KAAK,EAAE,MAAM,CAAC,CA0BjH"}
@@ -0,0 +1,32 @@
1
+ import type { XToken } from '@sodax/types';
2
+ import { type UseMutationResult } from '@tanstack/react-query';
3
+ interface SupplyResponse {
4
+ ok: true;
5
+ value: [`0x${string}`, `0x${string}`];
6
+ }
7
+ /**
8
+ * Hook for supplying tokens to the Sodax money market.
9
+ *
10
+ * This hook provides functionality to supply tokens to the money market protocol,
11
+ * handling the entire supply process including transaction creation, submission,
12
+ * and cross-chain communication.
13
+ *
14
+ * @param {XToken} spokeToken - The token to supply on the spoke chain. Must be an XToken with valid address and chain information.
15
+ *
16
+ * @returns {UseMutationResult<SupplyResponse, Error, string>} A mutation result object with the following properties:
17
+ * - mutateAsync: Function to execute the supply transaction
18
+ * - isPending: Boolean indicating if a transaction is in progress
19
+ * - error: Error object if the last transaction failed, null otherwise
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const { mutateAsync: supply, isPending, error } = useSupply(spokeToken);
24
+ * await supply('100');
25
+ * ```
26
+ *
27
+ * @throws {Error} When:
28
+ * - spokeProvider is not available
29
+ */
30
+ export declare function useSupply(spokeToken: XToken): UseMutationResult<SupplyResponse, Error, string>;
31
+ export {};
32
+ //# sourceMappingURL=useSupply.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSupply.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useSupply.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAK5E,UAAU,cAAc;IACtB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,KAAK,MAAM,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB,CAAC,cAAc,EAAE,KAAK,EAAE,MAAM,CAAC,CA0B9F"}
@@ -0,0 +1,9 @@
1
+ import type { ChainId } from '@sodax/types';
2
+ export declare function useUserReservesData(spokeChainId: ChainId): {
3
+ token: import("@sodax/sdk").XToken | undefined;
4
+ underlyingAsset: string;
5
+ scaledATokenBalance: bigint;
6
+ usageAsCollateralEnabledOnUser: boolean;
7
+ scaledVariableDebt: bigint;
8
+ }[] | undefined;
9
+ //# sourceMappingURL=useUserReservesData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useUserReservesData.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useUserReservesData.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAM5C,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,OAAO;;;;;;gBA+CxD"}
@@ -0,0 +1,26 @@
1
+ import type { ChainId, XToken } from '@sodax/types';
2
+ import { type UseMutationResult } from '@tanstack/react-query';
3
+ interface WithdrawResponse {
4
+ ok: true;
5
+ value: [`0x${string}`, `0x${string}`];
6
+ }
7
+ /**
8
+ * Hook for withdrawing supplied tokens from the Sodax money market.
9
+ *
10
+ * This hook provides functionality to withdraw previously supplied tokens from the money market protocol,
11
+ * handling the entire withdrawal process including transaction creation, submission,
12
+ * and cross-chain communication.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const { mutateAsync: withdraw, isPending, error } = useWithdraw(hubToken, spokeChainId);
17
+ * await withdraw('100');
18
+ * ```
19
+ *
20
+ * @throws {Error} When:
21
+ * - spokeProvider is not available
22
+ * - Transaction execution fails
23
+ */
24
+ export declare function useWithdraw(hubToken: XToken, spokeChainId: ChainId): UseMutationResult<WithdrawResponse, Error, string>;
25
+ export {};
26
+ //# sourceMappingURL=useWithdraw.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWithdraw.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useWithdraw.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAK5E,UAAU,gBAAgB;IACxB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,KAAK,MAAM,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,OAAO,GACpB,iBAAiB,CAAC,gBAAgB,EAAE,KAAK,EAAE,MAAM,CAAC,CA0BpD"}
@@ -0,0 +1,3 @@
1
+ export * from './useHubProvider';
2
+ export * from './useSpokeProvider';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/provider/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { EvmHubProvider } from '@sodax/sdk';
2
+ export declare function useHubProvider(): EvmHubProvider | undefined;
3
+ //# sourceMappingURL=useHubProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHubProvider.d.ts","sourceRoot":"","sources":["../../../src/hooks/provider/useHubProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAsC,MAAM,YAAY,CAAC;AAKhF,wBAAgB,cAAc,IAAI,cAAc,GAAG,SAAS,CAqB3D"}
@@ -0,0 +1,4 @@
1
+ import { EvmSpokeProvider, SuiSpokeProvider } from '@sodax/sdk';
2
+ import type { SpokeChainId } from '@sodax/types';
3
+ export declare function useSpokeProvider(spokeChainId: SpokeChainId): EvmSpokeProvider | SuiSpokeProvider | undefined;
4
+ //# sourceMappingURL=useSpokeProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSpokeProvider.d.ts","sourceRoot":"","sources":["../../../src/hooks/provider/useSpokeProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAoB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAClF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAIjD,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,YAAY,mDAiB1D"}
@@ -0,0 +1,4 @@
1
+ export * from './useSodaxContext';
2
+ export * from './useAllowance';
3
+ export * from './useApprove';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { XToken } from '@sodax/types';
2
+ export declare function useAllowance(token: XToken, amount: string): import("@tanstack/react-query").UseQueryResult<boolean, Error>;
3
+ //# sourceMappingURL=useAllowance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAllowance.d.ts","sourceRoot":"","sources":["../../../src/hooks/shared/useAllowance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgB,MAAM,EAAE,MAAM,cAAc,CAAC;AAKzD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kEAwBzD"}
@@ -0,0 +1,10 @@
1
+ import type { XToken } from '@sodax/types';
2
+ interface UseApproveReturn {
3
+ approve: (amount: string) => Promise<boolean>;
4
+ isLoading: boolean;
5
+ error: Error | null;
6
+ resetError: () => void;
7
+ }
8
+ export declare function useApprove(token: XToken): UseApproveReturn;
9
+ export {};
10
+ //# sourceMappingURL=useApprove.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useApprove.d.ts","sourceRoot":"","sources":["../../../src/hooks/shared/useApprove.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgB,MAAM,EAAE,MAAM,cAAc,CAAC;AAKzD,UAAU,gBAAgB;IACxB,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9C,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAsC1D"}
@@ -0,0 +1,8 @@
1
+ import { type SodaxContextType } from '@/contexts';
2
+ /**
3
+ * Hook to access the Sodax context which provides access to the Sodax SDK instance and chain configuration
4
+ * @throws {Error} If used outside of a SodaxProvider
5
+ * @returns {SodaxContextType} The Sodax context containing SDK instance and configuration
6
+ */
7
+ export declare const useSodaxContext: () => SodaxContextType;
8
+ //# sourceMappingURL=useSodaxContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSodaxContext.d.ts","sourceRoot":"","sources":["../../../src/hooks/shared/useSodaxContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGjE;;;;GAIG;AAEH,eAAO,MAAM,eAAe,QAAO,gBAMlC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './useQuote';
2
+ export * from './useCreateIntentOrder';
3
+ export * from './useStatus';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { CreateIntentParams, SpokeChainId, IntentExecutionResponse, Result, IntentSubmitErrorCode, Intent, PacketData, IntentSubmitError } from '@sodax/sdk';
2
+ import { type UseMutationResult } from '@tanstack/react-query';
3
+ type CreateIntentResult = Result<[
4
+ IntentExecutionResponse,
5
+ Intent,
6
+ PacketData
7
+ ], IntentSubmitError<IntentSubmitErrorCode>>;
8
+ /**
9
+ * Hook for creating and submitting an intent order for cross-chain swaps.
10
+ * Uses React Query's useMutation for better state management and caching.
11
+ *
12
+ * @param {SpokeChainId} chainId - The source chain ID where the swap will originate
13
+ * @returns {UseMutationResult} Mutation result object containing mutation function and state
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const { mutateAsync: createIntent, isPending } = useCreateIntentOrder('0xa4b1.arbitrum');
18
+ *
19
+ * const handleSwap = async () => {
20
+ * const result = await createIntent({
21
+ * token_src: '0x...',
22
+ * token_src_blockchain_id: 'arbitrum',
23
+ * token_dst: '0x...',
24
+ * token_dst_blockchain_id: 'polygon',
25
+ * amount: '1000000000000000000',
26
+ * min_output_amount: '900000000000000000'
27
+ * });
28
+ * };
29
+ * ```
30
+ */
31
+ export declare function useCreateIntentOrder(chainId: SpokeChainId): UseMutationResult<CreateIntentResult, Error, CreateIntentParams>;
32
+ export {};
33
+ //# sourceMappingURL=useCreateIntentOrder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCreateIntentOrder.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useCreateIntentOrder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,uBAAuB,EACvB,MAAM,EACN,qBAAqB,EACrB,MAAM,EACN,UAAU,EACV,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5E,KAAK,kBAAkB,GAAG,MAAM,CAC9B;IAAC,uBAAuB;IAAE,MAAM;IAAE,UAAU;CAAC,EAC7C,iBAAiB,CAAC,qBAAqB,CAAC,CACzC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,YAAY,GACpB,iBAAiB,CAAC,kBAAkB,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAYlE"}
@@ -0,0 +1,39 @@
1
+ import type { IntentErrorResponse, IntentQuoteRequest, IntentQuoteResponse, Result } from '@sodax/sdk';
2
+ import { type UseQueryResult } from '@tanstack/react-query';
3
+ /**
4
+ * Hook for fetching a quote for an intent-based swap.
5
+ *
6
+ * This hook provides real-time quote data for an intent-based swap.
7
+ *
8
+ * @param {IntentQuoteRequest | undefined} payload - The intent quote request parameters. If undefined, the query will be disabled.
9
+ *
10
+ * @returns {UseQueryResult<Result<IntentQuoteResponse, IntentErrorResponse> | undefined>} A query result object containing:
11
+ * - data: The quote result from the solver
12
+ * - isLoading: Boolean indicating if the quote is being fetched
13
+ * - error: Error object if the quote request failed
14
+ * - refetch: Function to manually trigger a quote refresh
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const { data: quote, isLoading } = useQuote({
19
+ * token_src: '0x...',
20
+ * token_src_blockchain_id: '1',
21
+ * token_dst: '0x...',
22
+ * token_dst_blockchain_id: '2',
23
+ * amount: '1000000000000000000',
24
+ * quote_type: 'exact_input',
25
+ * });
26
+ *
27
+ * if (isLoading) return <div>Loading quote...</div>;
28
+ * if (quote) {
29
+ * console.log('Quote received:', quote);
30
+ * }
31
+ * ```
32
+ *
33
+ * @remarks
34
+ * - The quote is automatically refreshed every 3 seconds
35
+ * - The query is disabled when payload is undefined
36
+ * - Uses React Query for efficient caching and state management
37
+ */
38
+ export declare const useQuote: (payload: IntentQuoteRequest | undefined) => UseQueryResult<Result<IntentQuoteResponse, IntentErrorResponse> | undefined>;
39
+ //# sourceMappingURL=useQuote.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useQuote.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useQuote.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEvG,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,QAAQ,YACV,kBAAkB,GAAG,SAAS,KACtC,cAAc,CAAC,MAAM,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,GAAG,SAAS,CAa7E,CAAC"}