@sodax/dapp-kit 0.0.1-rc.21 → 0.0.1-rc.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 +83 -1
- package/dist/contexts/index.d.ts +1 -2
- package/dist/contexts/index.d.ts.map +1 -1
- package/dist/hooks/backend/index.d.ts +17 -0
- package/dist/hooks/backend/index.d.ts.map +1 -0
- package/dist/hooks/backend/useBackendAllMoneyMarketAssets.d.ts +37 -0
- package/dist/hooks/backend/useBackendAllMoneyMarketAssets.d.ts.map +1 -0
- package/dist/hooks/backend/useBackendAllMoneyMarketBorrowers.d.ts +45 -0
- package/dist/hooks/backend/useBackendAllMoneyMarketBorrowers.d.ts.map +1 -0
- package/dist/hooks/backend/useBackendIntentByHash.d.ts +36 -0
- package/dist/hooks/backend/useBackendIntentByHash.d.ts.map +1 -0
- package/dist/hooks/backend/useBackendIntentByTxHash.d.ts +35 -0
- package/dist/hooks/backend/useBackendIntentByTxHash.d.ts.map +1 -0
- package/dist/hooks/backend/useBackendMoneyMarketAsset.d.ts +38 -0
- package/dist/hooks/backend/useBackendMoneyMarketAsset.d.ts.map +1 -0
- package/dist/hooks/backend/useBackendMoneyMarketAssetBorrowers.d.ts +47 -0
- package/dist/hooks/backend/useBackendMoneyMarketAssetBorrowers.d.ts.map +1 -0
- package/dist/hooks/backend/useBackendMoneyMarketAssetSuppliers.d.ts +47 -0
- package/dist/hooks/backend/useBackendMoneyMarketAssetSuppliers.d.ts.map +1 -0
- package/dist/hooks/backend/useBackendMoneyMarketPosition.d.ts +37 -0
- package/dist/hooks/backend/useBackendMoneyMarketPosition.d.ts.map +1 -0
- package/dist/hooks/backend/useBackendOrderbook.d.ts +46 -0
- package/dist/hooks/backend/useBackendOrderbook.d.ts.map +1 -0
- package/dist/hooks/bridge/index.d.ts +6 -0
- package/dist/hooks/bridge/index.d.ts.map +1 -0
- package/dist/hooks/bridge/useBridge.d.ts +33 -0
- package/dist/hooks/bridge/useBridge.d.ts.map +1 -0
- package/dist/hooks/bridge/useBridgeAllowance.d.ts +23 -0
- package/dist/hooks/bridge/useBridgeAllowance.d.ts.map +1 -0
- package/dist/hooks/bridge/useBridgeApprove.d.ts +29 -0
- package/dist/hooks/bridge/useBridgeApprove.d.ts.map +1 -0
- package/dist/hooks/bridge/useGetBridgeableAmount.d.ts +26 -0
- package/dist/hooks/bridge/useGetBridgeableAmount.d.ts.map +1 -0
- package/dist/hooks/bridge/useGetBridgeableTokens.d.ts +37 -0
- package/dist/hooks/bridge/useGetBridgeableTokens.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/mm/useUserFormattedSummary.d.ts +1 -1
- package/dist/hooks/mm/useUserFormattedSummary.d.ts.map +1 -1
- package/dist/hooks/mm/useUserReservesData.d.ts +1 -1
- package/dist/hooks/mm/useUserReservesData.d.ts.map +1 -1
- package/dist/hooks/provider/useHubProvider.d.ts +1 -1
- package/dist/hooks/provider/useHubProvider.d.ts.map +1 -1
- package/dist/hooks/provider/useSpokeProvider.d.ts.map +1 -1
- package/dist/hooks/shared/index.d.ts +1 -0
- package/dist/hooks/shared/index.d.ts.map +1 -1
- package/dist/hooks/shared/useDeriveUserWalletAddress.d.ts +24 -0
- package/dist/hooks/shared/useDeriveUserWalletAddress.d.ts.map +1 -0
- package/dist/index.js +278 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +265 -21
- package/dist/index.mjs.map +1 -1
- package/dist/providers/SodaxProvider.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/contexts/index.ts +1 -2
- package/src/hooks/backend/README.md +135 -0
- package/src/hooks/backend/index.ts +23 -0
- package/src/hooks/backend/useBackendAllMoneyMarketAssets.ts +49 -0
- package/src/hooks/backend/useBackendAllMoneyMarketBorrowers.ts +61 -0
- package/src/hooks/backend/useBackendIntentByHash.ts +53 -0
- package/src/hooks/backend/useBackendIntentByTxHash.ts +52 -0
- package/src/hooks/backend/useBackendMoneyMarketAsset.ts +57 -0
- package/src/hooks/backend/useBackendMoneyMarketAssetBorrowers.ts +67 -0
- package/src/hooks/backend/useBackendMoneyMarketAssetSuppliers.ts +67 -0
- package/src/hooks/backend/useBackendMoneyMarketPosition.ts +56 -0
- package/src/hooks/backend/useBackendOrderbook.ts +63 -0
- package/src/hooks/bridge/index.ts +5 -0
- package/src/hooks/bridge/useBridge.ts +57 -0
- package/src/hooks/bridge/useBridgeAllowance.ts +49 -0
- package/src/hooks/bridge/useBridgeApprove.ts +68 -0
- package/src/hooks/bridge/useGetBridgeableAmount.ts +50 -0
- package/src/hooks/bridge/useGetBridgeableTokens.ts +62 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/mm/useUserFormattedSummary.ts +1 -1
- package/src/hooks/mm/useUserReservesData.ts +1 -1
- package/src/hooks/provider/useHubProvider.ts +3 -3
- package/src/hooks/provider/useSpokeProvider.ts +10 -4
- package/src/hooks/shared/index.ts +1 -0
- package/src/hooks/shared/useDeriveUserWalletAddress.ts +44 -0
- package/src/providers/SodaxProvider.tsx +4 -18
package/README.md
CHANGED
|
@@ -32,6 +32,16 @@ dApp Kit is a collection of React components, hooks, and utilities designed to s
|
|
|
32
32
|
- Get spoke chain provider (`useSpokeProvider`)
|
|
33
33
|
- Get wallet provider (`useWalletProvider`)
|
|
34
34
|
|
|
35
|
+
- Bridge
|
|
36
|
+
- Bridge tokens between chains (`useBridge`)
|
|
37
|
+
- Check token allowance for bridging (`useBridgeAllowance`)
|
|
38
|
+
- Approve source token for bridging (`useBridgeApprove`)
|
|
39
|
+
- Get max amount available to be bridged (`useGetBridgeableAmount`)
|
|
40
|
+
- Get available destination tokens based on provided source token (`useGetBridgeableTokens`)
|
|
41
|
+
|
|
42
|
+
- Shared
|
|
43
|
+
- Derive user wallet address for hub abstraction (`useDeriveUserWalletAddress`)
|
|
44
|
+
|
|
35
45
|
## Installation
|
|
36
46
|
|
|
37
47
|
```bash
|
|
@@ -148,6 +158,24 @@ function TokenManagementComponent() {
|
|
|
148
158
|
};
|
|
149
159
|
}
|
|
150
160
|
|
|
161
|
+
// Wallet Address Derivation
|
|
162
|
+
import { useDeriveUserWalletAddress, useSpokeProvider } from '@sodax/dapp-kit';
|
|
163
|
+
|
|
164
|
+
function WalletAddressComponent() {
|
|
165
|
+
const spokeProvider = useSpokeProvider(chainId, walletProvider);
|
|
166
|
+
|
|
167
|
+
// Derive user wallet address for hub abstraction
|
|
168
|
+
const { data: derivedAddress, isLoading, error } = useDeriveUserWalletAddress(spokeProvider, userAddress);
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
<div>
|
|
172
|
+
{isLoading && <div>Deriving wallet address...</div>}
|
|
173
|
+
{error && <div>Error: {error.message}</div>}
|
|
174
|
+
{derivedAddress && <div>Derived Address: {derivedAddress}</div>}
|
|
175
|
+
</div>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
151
179
|
// Swap Operations
|
|
152
180
|
import { useQuote, useSwap, useStatus } from '@sodax/dapp-kit';
|
|
153
181
|
|
|
@@ -178,6 +206,53 @@ function SwapComponent() {
|
|
|
178
206
|
// Get status of an intent order
|
|
179
207
|
const { data: orderStatus } = useStatus('0x...');
|
|
180
208
|
}
|
|
209
|
+
|
|
210
|
+
// Bridge Operations
|
|
211
|
+
import { useBridge, useBridgeAllowance, useBridgeApprove, useGetBridgeableAmount, useGetBridgeableTokens } from '@sodax/dapp-kit';
|
|
212
|
+
|
|
213
|
+
function BridgeComponent() {
|
|
214
|
+
const spokeProvider = useSpokeProvider(chainId, walletProvider);
|
|
215
|
+
|
|
216
|
+
// Get available destination tokens for bridging
|
|
217
|
+
const { data: bridgeableTokens, isLoading: isTokensLoading } = useGetBridgeableTokens(
|
|
218
|
+
'0x2105.base', // from chain
|
|
219
|
+
'0x89.polygon', // to chain
|
|
220
|
+
'0x...' // source token address
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
// Get maximum amount available to bridge
|
|
224
|
+
const { data: bridgeableAmount } = useGetBridgeableAmount(
|
|
225
|
+
{ address: '0x...', xChainId: '0x2105.base' }, // from token
|
|
226
|
+
{ address: '0x...', xChainId: '0x89.polygon' } // to token
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
// Check token allowance for bridge
|
|
230
|
+
const { data: hasAllowed } = useBridgeAllowance(bridgeParams, spokeProvider);
|
|
231
|
+
|
|
232
|
+
// Approve tokens for bridge
|
|
233
|
+
const { approve: approveBridge, isLoading: isApproving } = useBridgeApprove(spokeProvider);
|
|
234
|
+
const handleApprove = async () => {
|
|
235
|
+
await approveBridge(bridgeParams);
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
// Execute bridge transaction
|
|
239
|
+
const { mutateAsync: bridge, isPending: isBridging } = useBridge(spokeProvider);
|
|
240
|
+
const handleBridge = async () => {
|
|
241
|
+
const result = await bridge({
|
|
242
|
+
srcChainId: '0x2105.base',
|
|
243
|
+
srcAsset: '0x...',
|
|
244
|
+
amount: 1000n,
|
|
245
|
+
dstChainId: '0x89.polygon',
|
|
246
|
+
dstAsset: '0x...',
|
|
247
|
+
recipient: '0x...'
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
console.log('Bridge transaction hashes:', {
|
|
251
|
+
spokeTxHash: result.value[0],
|
|
252
|
+
hubTxHash: result.value[1]
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
}
|
|
181
256
|
```
|
|
182
257
|
|
|
183
258
|
## Requirements
|
|
@@ -215,7 +290,14 @@ function SwapComponent() {
|
|
|
215
290
|
#### Shared Hooks
|
|
216
291
|
- [`useSodaxContext()`](./src/hooks/shared/useSodaxContext.ts) - Access Sodax context and configuration
|
|
217
292
|
- [`useEstimateGas()`](./src/hooks/shared/useEstimateGas.ts) - Estimate gas costs for transactions
|
|
218
|
-
|
|
293
|
+
- [`useDeriveUserWalletAddress()`](./src/hooks/shared/useDeriveUserWalletAddress.ts) - Derive user wallet address for hub abstraction
|
|
294
|
+
|
|
295
|
+
#### Bridge Hooks
|
|
296
|
+
- [`useBridge()`](./src/hooks/bridge/useBridge.ts) - Execute bridge transactions to transfer tokens between chains
|
|
297
|
+
- [`useBridgeAllowance()`](./src/hooks/bridge/useBridgeAllowance.ts) - Check token allowance for bridge operations
|
|
298
|
+
- [`useBridgeApprove()`](./src/hooks/bridge/useBridgeApprove.ts) - Approve token spending for bridge actions
|
|
299
|
+
- [`useGetBridgeableAmount()`](./src/hooks/bridge/useGetBridgeableAmount.ts) - Get maximum amount available to be bridged
|
|
300
|
+
- [`useGetBridgeableTokens()`](./src/hooks/bridge/useGetBridgeableTokens.ts) - Get available destination tokens for bridging
|
|
219
301
|
|
|
220
302
|
## Contributing
|
|
221
303
|
|
package/dist/contexts/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Sodax } from '@sodax/sdk';
|
|
2
2
|
import type { RpcConfig } from '@/types';
|
|
3
3
|
export interface SodaxContextType {
|
|
4
4
|
sodax: Sodax;
|
|
5
5
|
testnet: boolean;
|
|
6
|
-
hubProvider: EvmHubProvider | undefined;
|
|
7
6
|
rpcConfig: RpcConfig;
|
|
8
7
|
}
|
|
9
8
|
export declare const SodaxContext: import("react").Context<SodaxContextType | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contexts/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contexts/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,YAAY,kDAA+C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend API Hooks
|
|
3
|
+
*
|
|
4
|
+
* This module exports all hooks for interacting with the BackendApiService.
|
|
5
|
+
* These hooks provide a React-friendly interface to the Sodax Backend API,
|
|
6
|
+
* including intent management, solver orderbook, and money market operations.
|
|
7
|
+
*/
|
|
8
|
+
export { useBackendIntentByTxHash } from './useBackendIntentByTxHash';
|
|
9
|
+
export { useBackendIntentByHash } from './useBackendIntentByHash';
|
|
10
|
+
export { useBackendOrderbook } from './useBackendOrderbook';
|
|
11
|
+
export { useBackendMoneyMarketPosition } from './useBackendMoneyMarketPosition';
|
|
12
|
+
export { useBackendAllMoneyMarketAssets } from './useBackendAllMoneyMarketAssets';
|
|
13
|
+
export { useBackendMoneyMarketAsset } from './useBackendMoneyMarketAsset';
|
|
14
|
+
export { useBackendMoneyMarketAssetBorrowers } from './useBackendMoneyMarketAssetBorrowers';
|
|
15
|
+
export { useBackendMoneyMarketAssetSuppliers } from './useBackendMoneyMarketAssetSuppliers';
|
|
16
|
+
export { useBackendAllMoneyMarketBorrowers } from './useBackendAllMoneyMarketBorrowers';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/backend/index.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAGH,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import type { MoneyMarketAsset } from '@sodax/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for fetching all money market assets from the backend API.
|
|
5
|
+
*
|
|
6
|
+
* This hook provides access to all available money market assets, including
|
|
7
|
+
* their reserve information, liquidity rates, borrow rates, and market statistics.
|
|
8
|
+
* The data is automatically fetched and cached using React Query.
|
|
9
|
+
*
|
|
10
|
+
* @returns {UseQueryResult<MoneyMarketAsset[]>} A query result object containing:
|
|
11
|
+
* - data: Array of money market asset data when available
|
|
12
|
+
* - isLoading: Boolean indicating if the request is in progress
|
|
13
|
+
* - error: Error object if the request failed
|
|
14
|
+
* - refetch: Function to manually trigger a data refresh
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const { data: assets, isLoading, error } = useAllMoneyMarketAssets();
|
|
19
|
+
*
|
|
20
|
+
* if (isLoading) return <div>Loading assets...</div>;
|
|
21
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
22
|
+
* if (assets) {
|
|
23
|
+
* console.log('Total assets:', assets.length);
|
|
24
|
+
* assets.forEach(asset => {
|
|
25
|
+
* console.log(`${asset.symbol}: ${asset.liquidityRate} liquidity rate`);
|
|
26
|
+
* });
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* - Uses React Query for efficient caching and state management
|
|
32
|
+
* - Automatically handles error states and loading indicators
|
|
33
|
+
* - Returns comprehensive asset information including rates and statistics
|
|
34
|
+
* - No parameters required - fetches all available assets
|
|
35
|
+
*/
|
|
36
|
+
export declare const useBackendAllMoneyMarketAssets: () => UseQueryResult<MoneyMarketAsset[]>;
|
|
37
|
+
//# sourceMappingURL=useBackendAllMoneyMarketAssets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBackendAllMoneyMarketAssets.d.ts","sourceRoot":"","sources":["../../../src/hooks/backend/useBackendAllMoneyMarketAssets.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,8BAA8B,QAAO,cAAc,CAAC,gBAAgB,EAAE,CAUlF,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import type { MoneyMarketBorrowers } from '@sodax/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for fetching all money market borrowers from the backend API.
|
|
5
|
+
*
|
|
6
|
+
* This hook provides access to the list of all borrowers across all money market assets,
|
|
7
|
+
* with pagination support. The data is automatically fetched and cached using React Query.
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} params - Pagination parameters for fetching all borrowers
|
|
10
|
+
* @param {string} params.offset - The offset for pagination (number as string)
|
|
11
|
+
* @param {string} params.limit - The limit for pagination (number as string)
|
|
12
|
+
*
|
|
13
|
+
* @returns {UseQueryResult<MoneyMarketBorrowers | undefined>} A query result object containing:
|
|
14
|
+
* - data: The all borrowers data when available
|
|
15
|
+
* - isLoading: Boolean indicating if the request is in progress
|
|
16
|
+
* - error: Error object if the request failed
|
|
17
|
+
* - refetch: Function to manually trigger a data refresh
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const { data: borrowers, isLoading, error } = useAllMoneyMarketBorrowers({
|
|
22
|
+
* offset: '0',
|
|
23
|
+
* limit: '50'
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* if (isLoading) return <div>Loading borrowers...</div>;
|
|
27
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
28
|
+
* if (borrowers) {
|
|
29
|
+
* console.log('Total borrowers:', borrowers.total);
|
|
30
|
+
* console.log('Borrowers:', borrowers.borrowers);
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* - The query is disabled when params are undefined or invalid
|
|
36
|
+
* - Uses React Query for efficient caching and state management
|
|
37
|
+
* - Automatically handles error states and loading indicators
|
|
38
|
+
* - Supports pagination through offset and limit parameters
|
|
39
|
+
* - Returns borrowers across all money market assets
|
|
40
|
+
*/
|
|
41
|
+
export declare const useBackendAllMoneyMarketBorrowers: (params: {
|
|
42
|
+
offset: string;
|
|
43
|
+
limit: string;
|
|
44
|
+
} | undefined) => UseQueryResult<MoneyMarketBorrowers | undefined>;
|
|
45
|
+
//# sourceMappingURL=useBackendAllMoneyMarketBorrowers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBackendAllMoneyMarketBorrowers.d.ts","sourceRoot":"","sources":["../../../src/hooks/backend/useBackendAllMoneyMarketBorrowers.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,iCAAiC,WACpC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,KACpD,cAAc,CAAC,oBAAoB,GAAG,SAAS,CAejD,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import type { IntentResponse } from '@sodax/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for fetching intent details by intent hash from the backend API.
|
|
5
|
+
*
|
|
6
|
+
* This hook provides access to intent data using the intent hash directly,
|
|
7
|
+
* including intent details, events, and transaction information. The data is automatically
|
|
8
|
+
* fetched and cached using React Query.
|
|
9
|
+
*
|
|
10
|
+
* @param {string | undefined} intentHash - The intent hash to fetch intent for. If undefined, the query will be disabled.
|
|
11
|
+
*
|
|
12
|
+
* @returns {UseQueryResult<IntentResponse | undefined>} A query result object containing:
|
|
13
|
+
* - data: The intent response data when available
|
|
14
|
+
* - isLoading: Boolean indicating if the request is in progress
|
|
15
|
+
* - error: Error object if the request failed
|
|
16
|
+
* - refetch: Function to manually trigger a data refresh
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const { data: intent, isLoading, error } = useIntentByHash('0xabc...');
|
|
21
|
+
*
|
|
22
|
+
* if (isLoading) return <div>Loading intent...</div>;
|
|
23
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
24
|
+
* if (intent) {
|
|
25
|
+
* console.log('Intent found:', intent.intentHash);
|
|
26
|
+
* console.log('Open status:', intent.open);
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* - The query is disabled when intentHash is undefined or empty
|
|
32
|
+
* - Uses React Query for efficient caching and state management
|
|
33
|
+
* - Automatically handles error states and loading indicators
|
|
34
|
+
*/
|
|
35
|
+
export declare const useBackendIntentByHash: (intentHash: string | undefined) => UseQueryResult<IntentResponse | undefined>;
|
|
36
|
+
//# sourceMappingURL=useBackendIntentByHash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBackendIntentByHash.d.ts","sourceRoot":"","sources":["../../../src/hooks/backend/useBackendIntentByHash.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,sBAAsB,eAAgB,MAAM,GAAG,SAAS,KAAG,cAAc,CAAC,cAAc,GAAG,SAAS,CAehH,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import type { IntentResponse } from '@sodax/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for fetching intent details by transaction hash from the backend API.
|
|
5
|
+
*
|
|
6
|
+
* This hook provides access to intent data associated with a specific transaction hash,
|
|
7
|
+
* including intent details, events, and transaction information. The data is automatically
|
|
8
|
+
* fetched and cached using React Query.
|
|
9
|
+
*
|
|
10
|
+
* @param {string | undefined} txHash - The transaction hash to fetch intent for. If undefined, the query will be disabled.
|
|
11
|
+
*
|
|
12
|
+
* @returns {UseQueryResult<IntentResponse | undefined>} A query result object containing:
|
|
13
|
+
* - data: The intent response data when available
|
|
14
|
+
* - isLoading: Boolean indicating if the request is in progress
|
|
15
|
+
* - error: Error object if the request failed
|
|
16
|
+
* - refetch: Function to manually trigger a data refresh
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const { data: intent, isLoading, error } = useIntentByTxHash('0x123...');
|
|
21
|
+
*
|
|
22
|
+
* if (isLoading) return <div>Loading intent...</div>;
|
|
23
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
24
|
+
* if (intent) {
|
|
25
|
+
* console.log('Intent found:', intent.intentHash);
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* - The query is disabled when txHash is undefined or empty
|
|
31
|
+
* - Uses React Query for efficient caching and state management
|
|
32
|
+
* - Automatically handles error states and loading indicators
|
|
33
|
+
*/
|
|
34
|
+
export declare const useBackendIntentByTxHash: (txHash: string | undefined) => UseQueryResult<IntentResponse | undefined>;
|
|
35
|
+
//# sourceMappingURL=useBackendIntentByTxHash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBackendIntentByTxHash.d.ts","sourceRoot":"","sources":["../../../src/hooks/backend/useBackendIntentByTxHash.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,wBAAwB,WAAY,MAAM,GAAG,SAAS,KAAG,cAAc,CAAC,cAAc,GAAG,SAAS,CAe9G,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import type { MoneyMarketAsset } from '@sodax/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for fetching specific money market asset details from the backend API.
|
|
5
|
+
*
|
|
6
|
+
* This hook provides access to detailed information for a specific money market asset,
|
|
7
|
+
* including reserve information, liquidity rates, borrow rates, and market statistics.
|
|
8
|
+
* The data is automatically fetched and cached using React Query.
|
|
9
|
+
*
|
|
10
|
+
* @param {string | undefined} reserveAddress - The reserve contract address. If undefined, the query will be disabled.
|
|
11
|
+
*
|
|
12
|
+
* @returns {UseQueryResult<MoneyMarketAsset | undefined>} A query result object containing:
|
|
13
|
+
* - data: The money market asset data when available
|
|
14
|
+
* - isLoading: Boolean indicating if the request is in progress
|
|
15
|
+
* - error: Error object if the request failed
|
|
16
|
+
* - refetch: Function to manually trigger a data refresh
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const { data: asset, isLoading, error } = useMoneyMarketAsset('0xabc...');
|
|
21
|
+
*
|
|
22
|
+
* if (isLoading) return <div>Loading asset...</div>;
|
|
23
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
24
|
+
* if (asset) {
|
|
25
|
+
* console.log('Asset symbol:', asset.symbol);
|
|
26
|
+
* console.log('Liquidity rate:', asset.liquidityRate);
|
|
27
|
+
* console.log('Variable borrow rate:', asset.variableBorrowRate);
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* - The query is disabled when reserveAddress is undefined or empty
|
|
33
|
+
* - Uses React Query for efficient caching and state management
|
|
34
|
+
* - Automatically handles error states and loading indicators
|
|
35
|
+
* - Returns comprehensive asset information for the specified reserve
|
|
36
|
+
*/
|
|
37
|
+
export declare const useBackendMoneyMarketAsset: (reserveAddress: string | undefined) => UseQueryResult<MoneyMarketAsset | undefined>;
|
|
38
|
+
//# sourceMappingURL=useBackendMoneyMarketAsset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBackendMoneyMarketAsset.d.ts","sourceRoot":"","sources":["../../../src/hooks/backend/useBackendMoneyMarketAsset.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,0BAA0B,mBACrB,MAAM,GAAG,SAAS,KACjC,cAAc,CAAC,gBAAgB,GAAG,SAAS,CAe7C,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import type { MoneyMarketAssetBorrowers } from '@sodax/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for fetching borrowers for a specific money market asset from the backend API.
|
|
5
|
+
*
|
|
6
|
+
* This hook provides access to the list of borrowers for a specific money market asset,
|
|
7
|
+
* with pagination support. The data is automatically fetched and cached using React Query.
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} params - Parameters for fetching asset borrowers
|
|
10
|
+
* @param {string | undefined} params.reserveAddress - The reserve contract address. If undefined, the query will be disabled.
|
|
11
|
+
* @param {string} params.offset - The offset for pagination (number as string)
|
|
12
|
+
* @param {string} params.limit - The limit for pagination (number as string)
|
|
13
|
+
*
|
|
14
|
+
* @returns {UseQueryResult<MoneyMarketAssetBorrowers | undefined>} A query result object containing:
|
|
15
|
+
* - data: The asset borrowers data when available
|
|
16
|
+
* - isLoading: Boolean indicating if the request is in progress
|
|
17
|
+
* - error: Error object if the request failed
|
|
18
|
+
* - refetch: Function to manually trigger a data refresh
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const { data: borrowers, isLoading, error } = useMoneyMarketAssetBorrowers({
|
|
23
|
+
* reserveAddress: '0xabc...',
|
|
24
|
+
* offset: '0',
|
|
25
|
+
* limit: '20'
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* if (isLoading) return <div>Loading borrowers...</div>;
|
|
29
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
30
|
+
* if (borrowers) {
|
|
31
|
+
* console.log('Total borrowers:', borrowers.total);
|
|
32
|
+
* console.log('Borrowers:', borrowers.borrowers);
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* - The query is disabled when reserveAddress is undefined or empty
|
|
38
|
+
* - Uses React Query for efficient caching and state management
|
|
39
|
+
* - Automatically handles error states and loading indicators
|
|
40
|
+
* - Supports pagination through offset and limit parameters
|
|
41
|
+
*/
|
|
42
|
+
export declare const useBackendMoneyMarketAssetBorrowers: (params: {
|
|
43
|
+
reserveAddress: string | undefined;
|
|
44
|
+
offset: string;
|
|
45
|
+
limit: string;
|
|
46
|
+
}) => UseQueryResult<MoneyMarketAssetBorrowers | undefined>;
|
|
47
|
+
//# sourceMappingURL=useBackendMoneyMarketAssetBorrowers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBackendMoneyMarketAssetBorrowers.d.ts","sourceRoot":"","sources":["../../../src/hooks/backend/useBackendMoneyMarketAssetBorrowers.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAG5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,mCAAmC,WAAY;IAC1D,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,KAAG,cAAc,CAAC,yBAAyB,GAAG,SAAS,CAkBvD,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import type { MoneyMarketAssetSuppliers } from '@sodax/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for fetching suppliers for a specific money market asset from the backend API.
|
|
5
|
+
*
|
|
6
|
+
* This hook provides access to the list of suppliers for a specific money market asset,
|
|
7
|
+
* with pagination support. The data is automatically fetched and cached using React Query.
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} params - Parameters for fetching asset suppliers
|
|
10
|
+
* @param {string | undefined} params.reserveAddress - The reserve contract address. If undefined, the query will be disabled.
|
|
11
|
+
* @param {string} params.offset - The offset for pagination (number as string)
|
|
12
|
+
* @param {string} params.limit - The limit for pagination (number as string)
|
|
13
|
+
*
|
|
14
|
+
* @returns {UseQueryResult<MoneyMarketAssetSuppliers | undefined>} A query result object containing:
|
|
15
|
+
* - data: The asset suppliers data when available
|
|
16
|
+
* - isLoading: Boolean indicating if the request is in progress
|
|
17
|
+
* - error: Error object if the request failed
|
|
18
|
+
* - refetch: Function to manually trigger a data refresh
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const { data: suppliers, isLoading, error } = useMoneyMarketAssetSuppliers({
|
|
23
|
+
* reserveAddress: '0xabc...',
|
|
24
|
+
* offset: '0',
|
|
25
|
+
* limit: '20'
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* if (isLoading) return <div>Loading suppliers...</div>;
|
|
29
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
30
|
+
* if (suppliers) {
|
|
31
|
+
* console.log('Total suppliers:', suppliers.total);
|
|
32
|
+
* console.log('Suppliers:', suppliers.suppliers);
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* - The query is disabled when reserveAddress is undefined or empty
|
|
38
|
+
* - Uses React Query for efficient caching and state management
|
|
39
|
+
* - Automatically handles error states and loading indicators
|
|
40
|
+
* - Supports pagination through offset and limit parameters
|
|
41
|
+
*/
|
|
42
|
+
export declare const useBackendMoneyMarketAssetSuppliers: (params: {
|
|
43
|
+
reserveAddress: string | undefined;
|
|
44
|
+
offset: string;
|
|
45
|
+
limit: string;
|
|
46
|
+
}) => UseQueryResult<MoneyMarketAssetSuppliers | undefined>;
|
|
47
|
+
//# sourceMappingURL=useBackendMoneyMarketAssetSuppliers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBackendMoneyMarketAssetSuppliers.d.ts","sourceRoot":"","sources":["../../../src/hooks/backend/useBackendMoneyMarketAssetSuppliers.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAG5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,mCAAmC,WAAY;IAC1D,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,KAAG,cAAc,CAAC,yBAAyB,GAAG,SAAS,CAkBvD,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import type { MoneyMarketPosition } from '@sodax/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for fetching money market position for a specific user from the backend API.
|
|
5
|
+
*
|
|
6
|
+
* This hook provides access to a user's money market positions, including their
|
|
7
|
+
* aToken balances, variable debt token balances, and associated reserve information.
|
|
8
|
+
* The data is automatically fetched and cached using React Query.
|
|
9
|
+
*
|
|
10
|
+
* @param {string | undefined} userAddress - The user's wallet address. If undefined, the query will be disabled.
|
|
11
|
+
*
|
|
12
|
+
* @returns {UseQueryResult<MoneyMarketPosition | undefined>} A query result object containing:
|
|
13
|
+
* - data: The money market position data when available
|
|
14
|
+
* - isLoading: Boolean indicating if the request is in progress
|
|
15
|
+
* - error: Error object if the request failed
|
|
16
|
+
* - refetch: Function to manually trigger a data refresh
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const { data: position, isLoading, error } = useMoneyMarketPosition('0x123...');
|
|
21
|
+
*
|
|
22
|
+
* if (isLoading) return <div>Loading position...</div>;
|
|
23
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
24
|
+
* if (position) {
|
|
25
|
+
* console.log('User address:', position.userAddress);
|
|
26
|
+
* console.log('Positions:', position.positions);
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* - The query is disabled when userAddress is undefined or empty
|
|
32
|
+
* - Uses React Query for efficient caching and state management
|
|
33
|
+
* - Automatically handles error states and loading indicators
|
|
34
|
+
* - Includes user's aToken and debt token balances across all reserves
|
|
35
|
+
*/
|
|
36
|
+
export declare const useBackendMoneyMarketPosition: (userAddress: string | undefined) => UseQueryResult<MoneyMarketPosition | undefined>;
|
|
37
|
+
//# sourceMappingURL=useBackendMoneyMarketPosition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBackendMoneyMarketPosition.d.ts","sourceRoot":"","sources":["../../../src/hooks/backend/useBackendMoneyMarketPosition.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,6BAA6B,gBAC3B,MAAM,GAAG,SAAS,KAC9B,cAAc,CAAC,mBAAmB,GAAG,SAAS,CAehD,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import type { OrderbookResponse } from '@sodax/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for fetching the solver orderbook from the backend API.
|
|
5
|
+
*
|
|
6
|
+
* This hook provides access to the solver orderbook data, including intent states
|
|
7
|
+
* and intent data for all available intents. The data is automatically fetched
|
|
8
|
+
* and cached using React Query with pagination support.
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} params - Pagination parameters for the orderbook
|
|
11
|
+
* @param {string} params.offset - The offset for pagination (number as string)
|
|
12
|
+
* @param {string} params.limit - The limit for pagination (number as string)
|
|
13
|
+
*
|
|
14
|
+
* @returns {UseQueryResult<OrderbookResponse | undefined>} A query result object containing:
|
|
15
|
+
* - data: The orderbook response data when available
|
|
16
|
+
* - isLoading: Boolean indicating if the request is in progress
|
|
17
|
+
* - error: Error object if the request failed
|
|
18
|
+
* - refetch: Function to manually trigger a data refresh
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const { data: orderbook, isLoading, error } = useOrderbook({
|
|
23
|
+
* offset: '0',
|
|
24
|
+
* limit: '10'
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* if (isLoading) return <div>Loading orderbook...</div>;
|
|
28
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
29
|
+
* if (orderbook) {
|
|
30
|
+
* console.log('Total intents:', orderbook.total);
|
|
31
|
+
* console.log('Intents:', orderbook.data);
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* - The query is disabled when params are undefined or invalid
|
|
37
|
+
* - Uses React Query for efficient caching and state management
|
|
38
|
+
* - Automatically handles error states and loading indicators
|
|
39
|
+
* - Stale time of 30 seconds for real-time orderbook data
|
|
40
|
+
* - Supports pagination through offset and limit parameters
|
|
41
|
+
*/
|
|
42
|
+
export declare const useBackendOrderbook: (params: {
|
|
43
|
+
offset: string;
|
|
44
|
+
limit: string;
|
|
45
|
+
} | undefined) => UseQueryResult<OrderbookResponse | undefined>;
|
|
46
|
+
//# sourceMappingURL=useBackendOrderbook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBackendOrderbook.d.ts","sourceRoot":"","sources":["../../../src/hooks/backend/useBackendOrderbook.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAGpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,mBAAmB,WACtB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,KACpD,cAAc,CAAC,iBAAiB,GAAG,SAAS,CAgB9C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/bridge/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { BridgeError, BridgeErrorCode, SpokeTxHash, HubTxHash, Result, CreateBridgeIntentParams } from '@sodax/sdk';
|
|
2
|
+
import { type UseMutationResult } from '@tanstack/react-query';
|
|
3
|
+
import type { SpokeProvider } from '@sodax/sdk';
|
|
4
|
+
/**
|
|
5
|
+
* Hook for executing bridge transactions to transfer tokens between chains.
|
|
6
|
+
* Uses React Query's useMutation for better state management and caching.
|
|
7
|
+
*
|
|
8
|
+
* @param {SpokeProvider} spokeProvider - The spoke provider to use for the bridge
|
|
9
|
+
* @returns {UseMutationResult} Mutation result object containing mutation function and state
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const { mutateAsync: bridge, isPending } = useBridge(spokeProvider);
|
|
14
|
+
*
|
|
15
|
+
* const handleBridge = async () => {
|
|
16
|
+
* const result = await bridge({
|
|
17
|
+
* srcChainId: '0x2105.base',
|
|
18
|
+
* srcAsset: '0x...',
|
|
19
|
+
* amount: 1000n,
|
|
20
|
+
* dstChainId: '0x89.polygon',
|
|
21
|
+
* dstAsset: '0x...',
|
|
22
|
+
* recipient: '0x...'
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* console.log('Bridge transaction hashes:', {
|
|
26
|
+
* spokeTxHash: result.spokeTxHash,
|
|
27
|
+
* hubTxHash: result.hubTxHash
|
|
28
|
+
* });
|
|
29
|
+
* };
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function useBridge(spokeProvider: SpokeProvider | undefined): UseMutationResult<Result<[SpokeTxHash, HubTxHash], BridgeError<BridgeErrorCode>>, Error, CreateBridgeIntentParams>;
|
|
33
|
+
//# sourceMappingURL=useBridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBridge.d.ts","sourceRoot":"","sources":["../../../src/hooks/bridge/useBridge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACzH,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,SAAS,CACvB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,SAAS,CAAC,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,wBAAwB,CAAC,CAqBpH"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import type { SpokeProvider, CreateBridgeIntentParams } from '@sodax/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for checking token allowance for bridge operations.
|
|
5
|
+
*
|
|
6
|
+
* This hook verifies if the user has approved enough tokens for a specific bridge action.
|
|
7
|
+
* It automatically queries and tracks the allowance status.
|
|
8
|
+
*
|
|
9
|
+
* @param {BridgeParams} params - The parameters for the bridge to check allowance for.
|
|
10
|
+
* @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks
|
|
11
|
+
*
|
|
12
|
+
* @returns {UseQueryResult<boolean, Error>} A React Query result containing:
|
|
13
|
+
* - data: Boolean indicating if allowance is sufficient
|
|
14
|
+
* - isLoading: Loading state indicator
|
|
15
|
+
* - error: Any error that occurred during the check
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const { data: hasAllowed, isLoading } = useBridgeAllowance(params, spokeProvider);
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function useBridgeAllowance(params: CreateBridgeIntentParams | undefined, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
|
|
23
|
+
//# sourceMappingURL=useBridgeAllowance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBridgeAllowance.d.ts","sourceRoot":"","sources":["../../../src/hooks/bridge/useBridgeAllowance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE1E;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,wBAAwB,GAAG,SAAS,EAC5C,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAsBhC"}
|