@sodax/dapp-kit 0.0.1-rc.1 → 0.0.1-rc.11
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 +15 -13
- package/dist/contexts/index.d.ts +2 -1
- package/dist/contexts/index.d.ts.map +1 -1
- package/dist/core/index.d.ts +2 -3
- package/dist/core/index.d.ts.map +1 -1
- package/dist/hooks/mm/index.d.ts +3 -1
- package/dist/hooks/mm/index.d.ts.map +1 -1
- package/dist/hooks/mm/useBorrow.d.ts +13 -4
- package/dist/hooks/mm/useBorrow.d.ts.map +1 -1
- package/dist/hooks/mm/useMMAllowance.d.ts +26 -0
- package/dist/hooks/mm/useMMAllowance.d.ts.map +1 -0
- package/dist/hooks/mm/useMMApprove.d.ts +27 -0
- package/dist/hooks/mm/useMMApprove.d.ts.map +1 -0
- package/dist/hooks/mm/useRepay.d.ts +13 -4
- package/dist/hooks/mm/useRepay.d.ts.map +1 -1
- package/dist/hooks/mm/useReservesData.d.ts +19 -0
- package/dist/hooks/mm/useReservesData.d.ts.map +1 -0
- package/dist/hooks/mm/useSupply.d.ts +4 -2
- package/dist/hooks/mm/useSupply.d.ts.map +1 -1
- package/dist/hooks/mm/useUserReservesData.d.ts +1 -7
- package/dist/hooks/mm/useUserReservesData.d.ts.map +1 -1
- package/dist/hooks/mm/useWithdraw.d.ts +11 -4
- package/dist/hooks/mm/useWithdraw.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 +16 -2
- package/dist/hooks/provider/useSpokeProvider.d.ts.map +1 -1
- package/dist/hooks/shared/index.d.ts +1 -2
- package/dist/hooks/shared/index.d.ts.map +1 -1
- package/dist/hooks/shared/useEstimateGas.d.ts +4 -0
- package/dist/hooks/shared/useEstimateGas.d.ts.map +1 -0
- package/dist/hooks/swap/index.d.ts +2 -0
- package/dist/hooks/swap/index.d.ts.map +1 -1
- package/dist/hooks/swap/useCreateIntentOrder.d.ts +6 -6
- package/dist/hooks/swap/useCreateIntentOrder.d.ts.map +1 -1
- package/dist/hooks/swap/useQuote.d.ts +4 -4
- package/dist/hooks/swap/useQuote.d.ts.map +1 -1
- package/dist/hooks/swap/useStatus.d.ts +3 -3
- package/dist/hooks/swap/useStatus.d.ts.map +1 -1
- package/dist/hooks/swap/useSwapAllowance.d.ts +23 -0
- package/dist/hooks/swap/useSwapAllowance.d.ts.map +1 -0
- package/dist/hooks/swap/useSwapApprove.d.ts +26 -0
- package/dist/hooks/swap/useSwapApprove.d.ts.map +1 -0
- package/dist/index.js +242 -189
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +239 -188
- package/dist/index.mjs.map +1 -1
- package/dist/providers/SodaxProvider.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/contexts/index.ts +2 -1
- package/src/core/index.ts +5 -35
- package/src/hooks/mm/index.ts +3 -1
- package/src/hooks/mm/useBorrow.ts +20 -10
- package/src/hooks/mm/useMMAllowance.ts +55 -0
- package/src/hooks/mm/useMMApprove.ts +67 -0
- package/src/hooks/mm/useRepay.ts +20 -10
- package/src/hooks/mm/useReservesData.ts +37 -0
- package/src/hooks/mm/useSupply.ts +9 -6
- package/src/hooks/mm/useUserReservesData.ts +17 -34
- package/src/hooks/mm/useWithdraw.ts +17 -11
- package/src/hooks/provider/useHubProvider.ts +2 -21
- package/src/hooks/provider/useSpokeProvider.ts +87 -10
- package/src/hooks/shared/index.ts +1 -2
- package/src/hooks/shared/useEstimateGas.ts +20 -0
- package/src/hooks/swap/index.ts +2 -0
- package/src/hooks/swap/useCreateIntentOrder.ts +9 -11
- package/src/hooks/swap/useQuote.ts +5 -5
- package/src/hooks/swap/useStatus.ts +3 -3
- package/src/hooks/swap/useSwapAllowance.ts +44 -0
- package/src/hooks/swap/useSwapApprove.ts +68 -0
- package/src/providers/SodaxProvider.tsx +18 -3
- package/dist/hooks/mm/useHubWalletAddress.d.ts +0 -24
- package/dist/hooks/mm/useHubWalletAddress.d.ts.map +0 -1
- package/dist/hooks/shared/useAllowance.d.ts +0 -3
- package/dist/hooks/shared/useAllowance.d.ts.map +0 -1
- package/dist/hooks/shared/useApprove.d.ts +0 -10
- package/dist/hooks/shared/useApprove.d.ts.map +0 -1
- package/src/hooks/mm/useHubWalletAddress.ts +0 -49
- package/src/hooks/shared/useAllowance.ts +0 -31
- package/src/hooks/shared/useApprove.ts +0 -53
package/README.md
CHANGED
|
@@ -11,23 +11,22 @@ dApp Kit is a collection of React components, hooks, and utilities designed to s
|
|
|
11
11
|
- Borrow tokens from the money market (`useBorrow`)
|
|
12
12
|
- Repay borrowed tokens (`useRepay`)
|
|
13
13
|
- Get user reserves data (`useUserReservesData`)
|
|
14
|
-
-
|
|
14
|
+
- Get reserves data (`useReservesData`)
|
|
15
|
+
- Check token allowance (`useMMAllowance`)
|
|
16
|
+
- Approve token spending (`useMMApprove`)
|
|
15
17
|
|
|
16
18
|
- Swap/Intent
|
|
17
19
|
- Get quote for an intent order (`useQuote`)
|
|
18
20
|
- Create and submit an intent order (`useCreateIntentOrder`)
|
|
19
21
|
- Get status of an intent order (`useStatus`)
|
|
22
|
+
- Check token allowance (`useSwapAllowance`)
|
|
23
|
+
- Approve token spending (`useSwapApprove`)
|
|
20
24
|
|
|
21
25
|
- Provider
|
|
22
26
|
- Get hub chain provider (`useHubProvider`)
|
|
23
27
|
- Get spoke chain provider (`useSpokeProvider`)
|
|
24
28
|
- Get wallet provider (`useWalletProvider`)
|
|
25
29
|
|
|
26
|
-
- Token Management
|
|
27
|
-
- Check token allowance (`useAllowance`)
|
|
28
|
-
- Approve token spending (`useApprove`)
|
|
29
|
-
|
|
30
|
-
|
|
31
30
|
## Installation
|
|
32
31
|
|
|
33
32
|
```bash
|
|
@@ -65,7 +64,7 @@ const sodaxConfig = {
|
|
|
65
64
|
moneyMarket: getMoneyMarketConfig(SONIC_MAINNET_CHAIN_ID),
|
|
66
65
|
solver: {
|
|
67
66
|
intentsContract: '0x6382D6ccD780758C5e8A6123c33ee8F4472F96ef',
|
|
68
|
-
solverApiEndpoint: 'https://
|
|
67
|
+
solverApiEndpoint: 'https://sodax-solver-staging.iconblockchain.xyz',
|
|
69
68
|
partnerFee: {
|
|
70
69
|
address: '0x0Ab764AB3816cD036Ea951bE973098510D8105A6',
|
|
71
70
|
percentage: 100, // 1%
|
|
@@ -146,11 +145,11 @@ function MoneyMarketComponent() {
|
|
|
146
145
|
}
|
|
147
146
|
|
|
148
147
|
// Token Management
|
|
149
|
-
import {
|
|
148
|
+
import { useMMAllowance, useApprove } from '@sodax/dapp-kit';
|
|
150
149
|
|
|
151
150
|
function TokenManagementComponent() {
|
|
152
151
|
// Check token allowance
|
|
153
|
-
const { data: hasAllowed } =
|
|
152
|
+
const { data: hasAllowed } = useMMAllowance(token, amount);
|
|
154
153
|
|
|
155
154
|
// Approve token spending
|
|
156
155
|
const { approve, isLoading: isApproving } = useApprove(token);
|
|
@@ -210,18 +209,21 @@ function SwapComponent() {
|
|
|
210
209
|
- [`useRepay()`](./src/hooks/mm/useRepay.ts) - Repay borrowed tokens
|
|
211
210
|
- [`useSupply()`](./src/hooks/mm/useSupply.ts) - Supply tokens to the money market
|
|
212
211
|
- [`useWithdraw()`](./src/hooks/mm/useWithdraw.ts) - Withdraw supplied tokens
|
|
213
|
-
- [`useUserReservesData()`](./src/hooks/mm/useUserReservesData.ts) - Get
|
|
214
|
-
- [`
|
|
212
|
+
- [`useUserReservesData()`](./src/hooks/mm/useUserReservesData.ts) - Get user's reserves data(supplied asset and debt)
|
|
213
|
+
- [`useReservesData()`](./src/hooks/mm/useReservesData.ts) - Get reserves data
|
|
214
|
+
- [`useMMAllowance()`](./src/hooks/mm/useMMAllowance.ts) - Check token allowance for a specific amount
|
|
215
|
+
- [`useMMApprove()`](./src/hooks/mm/useMMApprove.ts) - Approve token spending
|
|
215
216
|
|
|
216
217
|
#### Swap Hooks
|
|
217
218
|
- [`useQuote()`](./src/hooks/swap/useQuote.ts) - Get quote for an intent order
|
|
218
219
|
- [`useCreateIntentOrder()`](./src/hooks/swap/useCreateIntentOrder.ts) - Create and submit an intent order
|
|
219
220
|
- [`useStatus()`](./src/hooks/swap/useStatus.ts) - Get status of an intent order
|
|
221
|
+
- [`useSwapAllowance()`](./src/hooks/swap/useSwapAllowance.ts) - Check token allowance for an intent order
|
|
222
|
+
- [`useSwapApprove()`](./src/hooks/swap/useSwapApprove.ts) - Approve token spending
|
|
220
223
|
|
|
221
224
|
#### Shared Hooks
|
|
222
225
|
- [`useSodaxContext()`](./src/hooks/shared/useSodaxContext.ts) - Access Sodax context and configuration
|
|
223
|
-
- [`
|
|
224
|
-
- [`useApprove()`](./src/hooks/shared/useApprove.ts) - Approve token spending
|
|
226
|
+
- [`useEstimateGas()`](./src/hooks/shared/useEstimateGas.ts) - Estimate gas costs for transactions
|
|
225
227
|
|
|
226
228
|
|
|
227
229
|
## Contributing
|
package/dist/contexts/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { Sodax } from '@sodax/sdk';
|
|
1
|
+
import type { EvmHubProvider, Sodax } from '@sodax/sdk';
|
|
2
2
|
export interface SodaxContextType {
|
|
3
3
|
sodax: Sodax;
|
|
4
4
|
testnet: boolean;
|
|
5
|
+
hubProvider: EvmHubProvider | undefined;
|
|
5
6
|
}
|
|
6
7
|
export declare const SodaxContext: import("react").Context<SodaxContextType | null>;
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contexts/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,cAAc,GAAG,SAAS,CAAC;CACzC;AAED,eAAO,MAAM,YAAY,kDAA+C,CAAC"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const getSpokeTokenAddressByVault: (spokeChainId: ChainId, vault: string) => string;
|
|
1
|
+
import type { ChainId } from '@sodax/types';
|
|
2
|
+
export declare const getSpokeTokenAddressByVault: (spokeChainId: ChainId, vault: string) => string | undefined;
|
|
4
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAI5C,eAAO,MAAM,2BAA2B,iBAAkB,OAAO,SAAS,MAAM,uBAO/E,CAAC"}
|
package/dist/hooks/mm/index.d.ts
CHANGED
|
@@ -3,5 +3,7 @@ export * from './useRepay';
|
|
|
3
3
|
export * from './useSupply';
|
|
4
4
|
export * from './useWithdraw';
|
|
5
5
|
export * from './useUserReservesData';
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './useReservesData';
|
|
7
|
+
export * from './useMMAllowance';
|
|
8
|
+
export * from './useMMApprove';
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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,
|
|
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,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { XToken } from '@sodax/types';
|
|
2
2
|
import { type UseMutationResult } from '@tanstack/react-query';
|
|
3
|
+
import type { SpokeProvider } from '@sodax/sdk';
|
|
3
4
|
interface BorrowResponse {
|
|
4
5
|
ok: true;
|
|
5
|
-
value: [
|
|
6
|
+
value: [string, string];
|
|
6
7
|
}
|
|
7
8
|
/**
|
|
8
9
|
* Hook for borrowing tokens from the Sodax money market.
|
|
@@ -11,9 +12,17 @@ interface BorrowResponse {
|
|
|
11
12
|
* handling the entire borrow process including transaction creation, submission,
|
|
12
13
|
* and cross-chain communication.
|
|
13
14
|
*
|
|
15
|
+
* @param {XToken} spokeToken - The token to borrow from the spoke chain. Must be an XToken with valid address and chain information.
|
|
16
|
+
* @param {SpokeProvider} spokeProvider - The spoke provider to use for the borrow transaction. Must be a valid SpokeProvider instance.
|
|
17
|
+
*
|
|
18
|
+
* @returns {UseMutationResult<BorrowResponse, Error, string>} A mutation result object with the following properties:
|
|
19
|
+
* - mutateAsync: Function to execute the borrow transaction
|
|
20
|
+
* - isPending: Boolean indicating if a transaction is in progress
|
|
21
|
+
* - error: Error object if the last transaction failed, null otherwise
|
|
22
|
+
*
|
|
14
23
|
* @example
|
|
15
24
|
* ```typescript
|
|
16
|
-
* const { mutateAsync: borrow, isPending, error } = useBorrow(
|
|
25
|
+
* const { mutateAsync: borrow, isPending, error } = useBorrow(spokeToken);
|
|
17
26
|
* await borrow('100');
|
|
18
27
|
* ```
|
|
19
28
|
*
|
|
@@ -21,6 +30,6 @@ interface BorrowResponse {
|
|
|
21
30
|
* - spokeProvider is not available
|
|
22
31
|
* - Transaction execution fails
|
|
23
32
|
*/
|
|
24
|
-
export declare function useBorrow(
|
|
33
|
+
export declare function useBorrow(spokeToken: XToken, spokeProvider: SpokeProvider | undefined): UseMutationResult<BorrowResponse, Error, string>;
|
|
25
34
|
export {};
|
|
26
35
|
//# sourceMappingURL=useBorrow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBorrow.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useBorrow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"useBorrow.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useBorrow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,UAAU,cAAc;IACtB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,SAAS,CACvB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,cAAc,EAAE,KAAK,EAAE,MAAM,CAAC,CA0BlD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import type { XToken } from '@sodax/types';
|
|
3
|
+
import type { MoneyMarketAction, SpokeProvider } from '@sodax/sdk';
|
|
4
|
+
/**
|
|
5
|
+
* Hook for checking token allowance for money market operations.
|
|
6
|
+
*
|
|
7
|
+
* This hook verifies if the user has approved enough tokens for a specific money market action
|
|
8
|
+
* (borrow/repay). It automatically queries and tracks the allowance status.
|
|
9
|
+
*
|
|
10
|
+
* @param {XToken} token - The token to check allowance for. Must be an XToken with valid address and chain information.
|
|
11
|
+
* @param {string} amount - The amount to check allowance for, as a decimal string
|
|
12
|
+
* @param {MoneyMarketAction} action - The money market action to check allowance for ('borrow' or 'repay')
|
|
13
|
+
* @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks
|
|
14
|
+
*
|
|
15
|
+
* @returns {UseQueryResult<boolean, Error>} A React Query result containing:
|
|
16
|
+
* - data: Boolean indicating if allowance is sufficient
|
|
17
|
+
* - isLoading: Loading state indicator
|
|
18
|
+
* - error: Any error that occurred during the check
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const { data: hasAllowed, isLoading } = useMMAllowance(token, "100", "repay", provider);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function useMMAllowance(token: XToken, amount: string, action: MoneyMarketAction, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
|
|
26
|
+
//# sourceMappingURL=useMMAllowance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMMAllowance.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useMMAllowance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,iBAAiB,EACzB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAsBhC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { XToken } from '@sodax/types';
|
|
2
|
+
import type { MoneyMarketAction, SpokeProvider } from '@sodax/sdk';
|
|
3
|
+
interface UseApproveReturn {
|
|
4
|
+
approve: ({ amount, action }: {
|
|
5
|
+
amount: string;
|
|
6
|
+
action: MoneyMarketAction;
|
|
7
|
+
}) => Promise<boolean>;
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
error: Error | null;
|
|
10
|
+
resetError: () => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Hook for approving token spending for money market actions
|
|
14
|
+
* @param token The token to approve spending for
|
|
15
|
+
* @param spokeProvider The spoke provider instance for the chain
|
|
16
|
+
* @returns Object containing approve function, loading state, error state and reset function
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* const { approve, isLoading, error } = useMMApprove(token, spokeProvider);
|
|
20
|
+
*
|
|
21
|
+
* // Approve tokens for supply action
|
|
22
|
+
* await approve({ amount: "100", action: "supply" });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function useMMApprove(token: XToken, spokeProvider: SpokeProvider | undefined): UseApproveReturn;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=useMMApprove.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMMApprove.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useMMApprove.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEnE,UAAU,gBAAgB;IACxB,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,iBAAiB,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjG,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;;;;;;;;;;;GAYG;AAEH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,GAAG,SAAS,GAAG,gBAAgB,CAuCtG"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SpokeProvider } from '@sodax/sdk';
|
|
2
|
+
import type { XToken } from '@sodax/types';
|
|
2
3
|
import { type UseMutationResult } from '@tanstack/react-query';
|
|
3
4
|
interface RepayResponse {
|
|
4
5
|
ok: true;
|
|
5
|
-
value: [
|
|
6
|
+
value: [string, string];
|
|
6
7
|
}
|
|
7
8
|
/**
|
|
8
9
|
* Hook for repaying borrowed tokens to the Sodax money market.
|
|
@@ -11,9 +12,17 @@ interface RepayResponse {
|
|
|
11
12
|
* handling the entire repayment process including transaction creation, submission,
|
|
12
13
|
* and cross-chain communication.
|
|
13
14
|
*
|
|
15
|
+
* @param {XToken} spokeToken - The token to repay on the spoke chain. Must be an XToken with valid address and chain information.
|
|
16
|
+
* @param {SpokeProvider} spokeProvider - The spoke provider to use for the repay transaction. Must be a valid SpokeProvider instance.
|
|
17
|
+
*
|
|
18
|
+
* @returns {UseMutationResult<RepayResponse, Error, string>} A mutation result object with the following properties:
|
|
19
|
+
* - mutateAsync: Function to execute the repay transaction
|
|
20
|
+
* - isPending: Boolean indicating if a transaction is in progress
|
|
21
|
+
* - error: Error object if the last transaction failed, null otherwise
|
|
22
|
+
*
|
|
14
23
|
* @example
|
|
15
24
|
* ```typescript
|
|
16
|
-
* const { mutateAsync: repay, isPending, error } = useRepay(
|
|
25
|
+
* const { mutateAsync: repay, isPending, error } = useRepay(spokeToken);
|
|
17
26
|
* await repay('100');
|
|
18
27
|
* ```
|
|
19
28
|
*
|
|
@@ -21,6 +30,6 @@ interface RepayResponse {
|
|
|
21
30
|
* - spokeProvider is not available
|
|
22
31
|
* - Transaction execution fails
|
|
23
32
|
*/
|
|
24
|
-
export declare function useRepay(
|
|
33
|
+
export declare function useRepay(spokeToken: XToken, spokeProvider: SpokeProvider | undefined): UseMutationResult<RepayResponse, Error, string>;
|
|
25
34
|
export {};
|
|
26
35
|
//# sourceMappingURL=useRepay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRepay.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useRepay.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useRepay.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useRepay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI5E,UAAU,aAAa;IACrB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,QAAQ,CACtB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,aAAa,EAAE,KAAK,EAAE,MAAM,CAAC,CA0BjD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for fetching reserves data from the Sodax money market.
|
|
3
|
+
*
|
|
4
|
+
* This hook provides access to the current state of all reserves in the money market protocol,
|
|
5
|
+
* including liquidity, interest rates, and other key metrics. The data is automatically
|
|
6
|
+
* fetched and cached using React Query.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const { data: reservesData, isLoading, error } = useReservesData();
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @returns A React Query result object containing:
|
|
14
|
+
* - data: The reserves data when available
|
|
15
|
+
* - isLoading: Loading state indicator
|
|
16
|
+
* - error: Any error that occurred during data fetching
|
|
17
|
+
*/
|
|
18
|
+
export declare function useReservesData(): import("@tanstack/react-query").UseQueryResult<readonly [readonly import("@sodax/sdk").AggregatedReserveData[], import("@sodax/sdk").BaseCurrencyInfo], Error>;
|
|
19
|
+
//# sourceMappingURL=useReservesData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReservesData.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useReservesData.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAAgB,eAAe,mKAc9B"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { SpokeProvider } from '@sodax/sdk';
|
|
1
2
|
import type { XToken } from '@sodax/types';
|
|
2
3
|
import { type UseMutationResult } from '@tanstack/react-query';
|
|
3
4
|
interface SupplyResponse {
|
|
4
5
|
ok: true;
|
|
5
|
-
value: [
|
|
6
|
+
value: [string, string];
|
|
6
7
|
}
|
|
7
8
|
/**
|
|
8
9
|
* Hook for supplying tokens to the Sodax money market.
|
|
@@ -12,6 +13,7 @@ interface SupplyResponse {
|
|
|
12
13
|
* and cross-chain communication.
|
|
13
14
|
*
|
|
14
15
|
* @param {XToken} spokeToken - The token to supply on the spoke chain. Must be an XToken with valid address and chain information.
|
|
16
|
+
* @param {SpokeProvider} spokeProvider - The spoke provider to use for the supply transaction. Must be a valid SpokeProvider instance.
|
|
15
17
|
*
|
|
16
18
|
* @returns {UseMutationResult<SupplyResponse, Error, string>} A mutation result object with the following properties:
|
|
17
19
|
* - mutateAsync: Function to execute the supply transaction
|
|
@@ -27,6 +29,6 @@ interface SupplyResponse {
|
|
|
27
29
|
* @throws {Error} When:
|
|
28
30
|
* - spokeProvider is not available
|
|
29
31
|
*/
|
|
30
|
-
export declare function useSupply(spokeToken: XToken): UseMutationResult<SupplyResponse, Error, string>;
|
|
32
|
+
export declare function useSupply(spokeToken: XToken, spokeProvider: SpokeProvider | undefined): UseMutationResult<SupplyResponse, Error, string>;
|
|
31
33
|
export {};
|
|
32
34
|
//# sourceMappingURL=useSupply.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSupply.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useSupply.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSupply.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useSupply.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI5E,UAAU,cAAc;IACtB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,SAAS,CACvB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,cAAc,EAAE,KAAK,EAAE,MAAM,CAAC,CA0BlD"}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
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;
|
|
2
|
+
export declare function useUserReservesData(spokeChainId: ChainId, address: string | undefined): readonly import("@sodax/sdk").UserReserveData[] | undefined;
|
|
9
3
|
//# sourceMappingURL=useUserReservesData.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUserReservesData.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useUserReservesData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useUserReservesData.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useUserReservesData.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAK5C,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,+DAiCrF"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SpokeProvider } from '@sodax/sdk';
|
|
2
|
+
import type { XToken } from '@sodax/types';
|
|
2
3
|
import { type UseMutationResult } from '@tanstack/react-query';
|
|
3
4
|
interface WithdrawResponse {
|
|
4
5
|
ok: true;
|
|
5
|
-
value: [
|
|
6
|
+
value: [string, string];
|
|
6
7
|
}
|
|
7
8
|
/**
|
|
8
9
|
* Hook for withdrawing supplied tokens from the Sodax money market.
|
|
@@ -11,9 +12,15 @@ interface WithdrawResponse {
|
|
|
11
12
|
* handling the entire withdrawal process including transaction creation, submission,
|
|
12
13
|
* and cross-chain communication.
|
|
13
14
|
*
|
|
15
|
+
* @param {XToken} spokeToken - The token to withdraw from the spoke chain. Must be an XToken with valid address and chain information.
|
|
16
|
+
* @param {SpokeProvider} spokeProvider - The spoke provider to use for the withdraw transaction. Must be a valid SpokeProvider instance.
|
|
17
|
+
*
|
|
18
|
+
* @returns {UseMutationResult<WithdrawResponse, Error, string>} A mutation result object with the following properties:
|
|
19
|
+
* - mutateAsync: Function to execute the withdraw transaction
|
|
20
|
+
* - isPending: Boolean indicating if a transaction is in progress
|
|
14
21
|
* @example
|
|
15
22
|
* ```typescript
|
|
16
|
-
* const { mutateAsync: withdraw, isPending, error } = useWithdraw(
|
|
23
|
+
* const { mutateAsync: withdraw, isPending, error } = useWithdraw(spokeToken);
|
|
17
24
|
* await withdraw('100');
|
|
18
25
|
* ```
|
|
19
26
|
*
|
|
@@ -21,6 +28,6 @@ interface WithdrawResponse {
|
|
|
21
28
|
* - spokeProvider is not available
|
|
22
29
|
* - Transaction execution fails
|
|
23
30
|
*/
|
|
24
|
-
export declare function useWithdraw(
|
|
31
|
+
export declare function useWithdraw(spokeToken: XToken, spokeProvider: SpokeProvider | undefined): UseMutationResult<WithdrawResponse, Error, string>;
|
|
25
32
|
export {};
|
|
26
33
|
//# sourceMappingURL=useWithdraw.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWithdraw.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useWithdraw.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useWithdraw.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useWithdraw.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI5E,UAAU,gBAAgB;IACxB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CACzB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,gBAAgB,EAAE,KAAK,EAAE,MAAM,CAAC,CA2BpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHubProvider.d.ts","sourceRoot":"","sources":["../../../src/hooks/provider/useHubProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"useHubProvider.d.ts","sourceRoot":"","sources":["../../../src/hooks/provider/useHubProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD,wBAAgB,cAAc,IAAI,cAAc,GAAG,SAAS,CAI3D"}
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type SpokeProvider, type IWalletProvider } from '@sodax/sdk';
|
|
2
2
|
import type { SpokeChainId } from '@sodax/types';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get the appropriate spoke provider based on the chain type.
|
|
5
|
+
* Supports EVM, SUI, ICON and INJECTIVE chains.
|
|
6
|
+
*
|
|
7
|
+
* @param {SpokeChainId | undefined} spokeChainId - The spoke chain ID to get the provider for
|
|
8
|
+
* @param {IWalletProvider | undefined} walletProvider - The wallet provider to use
|
|
9
|
+
* @returns {SpokeProvider | undefined} The appropriate spoke provider instance for the given chain ID, or undefined if invalid/unsupported
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* // Using a specific SpokeChainId and wallet provider
|
|
14
|
+
* const spokeProvider = useSpokeProvider(spokeChainId, walletProvider);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function useSpokeProvider(spokeChainId: SpokeChainId | undefined, walletProvider?: IWalletProvider | undefined): SpokeProvider | undefined;
|
|
4
18
|
//# sourceMappingURL=useSpokeProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSpokeProvider.d.ts","sourceRoot":"","sources":["../../../src/hooks/provider/useSpokeProvider.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useSpokeProvider.d.ts","sourceRoot":"","sources":["../../../src/hooks/provider/useSpokeProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAYL,KAAK,aAAa,EAClB,KAAK,eAAe,EAGrB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAIV,YAAY,EAIb,MAAM,cAAc,CAAC;AAItB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,YAAY,GAAG,SAAS,EACtC,cAAc,CAAC,EAAE,eAAe,GAAG,SAAS,GAC3C,aAAa,GAAG,SAAS,CAqD3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type GetEstimateGasReturnType, type SpokeProvider, type TxReturnType } from '@sodax/sdk';
|
|
2
|
+
import { type UseMutationResult } from '@tanstack/react-query';
|
|
3
|
+
export declare function useEstimateGas<T extends SpokeProvider = SpokeProvider>(spokeProvider: T | undefined): UseMutationResult<GetEstimateGasReturnType<T>, Error, TxReturnType<T, true>>;
|
|
4
|
+
//# sourceMappingURL=useEstimateGas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEstimateGas.d.ts","sourceRoot":"","sources":["../../../src/hooks/shared/useEstimateGas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,wBAAwB,EAAE,KAAK,aAAa,EAAgB,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAChH,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5E,wBAAgB,cAAc,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,EACpE,aAAa,EAAE,CAAC,GAAG,SAAS,GAC3B,iBAAiB,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAa9E"}
|
|
@@ -1 +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"}
|
|
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;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import type { CreateIntentParams,
|
|
1
|
+
import type { CreateIntentParams, SolverExecutionResponse, Result, IntentErrorCode, Intent, PacketData, IntentError, SpokeProvider } from '@sodax/sdk';
|
|
2
2
|
import { type UseMutationResult } from '@tanstack/react-query';
|
|
3
3
|
type CreateIntentResult = Result<[
|
|
4
|
-
|
|
4
|
+
SolverExecutionResponse,
|
|
5
5
|
Intent,
|
|
6
6
|
PacketData
|
|
7
|
-
],
|
|
7
|
+
], IntentError<IntentErrorCode>>;
|
|
8
8
|
/**
|
|
9
9
|
* Hook for creating and submitting an intent order for cross-chain swaps.
|
|
10
10
|
* Uses React Query's useMutation for better state management and caching.
|
|
11
11
|
*
|
|
12
|
-
* @param {
|
|
12
|
+
* @param {SpokeProvider} spokeProvider - The spoke provider to use for the swap
|
|
13
13
|
* @returns {UseMutationResult} Mutation result object containing mutation function and state
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```typescript
|
|
17
|
-
* const { mutateAsync: createIntent, isPending } = useCreateIntentOrder(
|
|
17
|
+
* const { mutateAsync: createIntent, isPending } = useCreateIntentOrder(spokeProvider);
|
|
18
18
|
*
|
|
19
19
|
* const handleSwap = async () => {
|
|
20
20
|
* const result = await createIntent({
|
|
@@ -28,6 +28,6 @@ type CreateIntentResult = Result<[
|
|
|
28
28
|
* };
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
|
-
export declare function useCreateIntentOrder(
|
|
31
|
+
export declare function useCreateIntentOrder(spokeProvider: SpokeProvider | undefined): UseMutationResult<CreateIntentResult, Error, CreateIntentParams>;
|
|
32
32
|
export {};
|
|
33
33
|
//# sourceMappingURL=useCreateIntentOrder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCreateIntentOrder.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useCreateIntentOrder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"useCreateIntentOrder.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useCreateIntentOrder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACvB,MAAM,EACN,eAAe,EACf,MAAM,EACN,UAAU,EACV,WAAW,EACX,aAAa,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5E,KAAK,kBAAkB,GAAG,MAAM,CAC9B;IAAC,uBAAuB;IAAE,MAAM;IAAE,UAAU;CAAC,EAC7C,WAAW,CAAC,eAAe,CAAC,CAC7B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,kBAAkB,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAWlE"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SolverErrorResponse, SolverIntentQuoteRequest, SolverIntentQuoteResponse, Result } from '@sodax/sdk';
|
|
2
2
|
import { type UseQueryResult } from '@tanstack/react-query';
|
|
3
3
|
/**
|
|
4
4
|
* Hook for fetching a quote for an intent-based swap.
|
|
5
5
|
*
|
|
6
6
|
* This hook provides real-time quote data for an intent-based swap.
|
|
7
7
|
*
|
|
8
|
-
* @param {
|
|
8
|
+
* @param {SolverIntentQuoteRequest | undefined} payload - The intent quote request parameters. If undefined, the query will be disabled.
|
|
9
9
|
*
|
|
10
|
-
* @returns {UseQueryResult<Result<
|
|
10
|
+
* @returns {UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined>} A query result object containing:
|
|
11
11
|
* - data: The quote result from the solver
|
|
12
12
|
* - isLoading: Boolean indicating if the quote is being fetched
|
|
13
13
|
* - error: Error object if the quote request failed
|
|
@@ -35,5 +35,5 @@ import { type UseQueryResult } from '@tanstack/react-query';
|
|
|
35
35
|
* - The query is disabled when payload is undefined
|
|
36
36
|
* - Uses React Query for efficient caching and state management
|
|
37
37
|
*/
|
|
38
|
-
export declare const useQuote: (payload:
|
|
38
|
+
export declare const useQuote: (payload: SolverIntentQuoteRequest | undefined) => UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined>;
|
|
39
39
|
//# sourceMappingURL=useQuote.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuote.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useQuote.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"useQuote.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useQuote.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEnH,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,QAAQ,YACV,wBAAwB,GAAG,SAAS,KAC5C,cAAc,CAAC,MAAM,CAAC,yBAAyB,EAAE,mBAAmB,CAAC,GAAG,SAAS,CAanF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Hex,
|
|
1
|
+
import type { Hex, SolverErrorResponse, SolverIntentStatusResponse, Result } from '@sodax/sdk';
|
|
2
2
|
import { type UseQueryResult } from '@tanstack/react-query';
|
|
3
3
|
/**
|
|
4
4
|
* Hook for monitoring the status of an intent-based swap.
|
|
@@ -7,7 +7,7 @@ import { type UseQueryResult } from '@tanstack/react-query';
|
|
|
7
7
|
*
|
|
8
8
|
* @param {Hex} intent_tx_hash - The transaction hash of the intent order on the hub chain
|
|
9
9
|
*
|
|
10
|
-
* @returns {UseQueryResult<Result<
|
|
10
|
+
* @returns {UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined>} A query result object containing:
|
|
11
11
|
* - data: The status result from the solver
|
|
12
12
|
* - isLoading: Boolean indicating if the status is being fetched
|
|
13
13
|
* - error: Error object if the status request failed
|
|
@@ -27,5 +27,5 @@ import { type UseQueryResult } from '@tanstack/react-query';
|
|
|
27
27
|
* - The status is automatically refreshed every 3 seconds
|
|
28
28
|
* - Uses React Query for efficient caching and state management
|
|
29
29
|
*/
|
|
30
|
-
export declare const useStatus: (intent_tx_hash: Hex) => UseQueryResult<Result<
|
|
30
|
+
export declare const useStatus: (intent_tx_hash: Hex) => UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined>;
|
|
31
31
|
//# sourceMappingURL=useStatus.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStatus.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"useStatus.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAC/F,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGtE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,eAAO,MAAM,SAAS,mBACJ,GAAG,KAClB,cAAc,CAAC,MAAM,CAAC,0BAA0B,EAAE,mBAAmB,CAAC,GAAG,SAAS,CASpF,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import type { CreateIntentParams, SpokeProvider } from '@sodax/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for checking token allowance for money market operations.
|
|
5
|
+
*
|
|
6
|
+
* This hook verifies if the user has approved enough tokens for a specific money market action
|
|
7
|
+
* (borrow/repay). It automatically queries and tracks the allowance status.
|
|
8
|
+
*
|
|
9
|
+
* @param {CreateIntentParams} params - The parameters for the intent 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 } = useMMAllowance(params, spokeProvider);
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function useSwapAllowance(params: CreateIntentParams | undefined, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
|
|
23
|
+
//# sourceMappingURL=useSwapAllowance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSwapAllowance.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useSwapAllowance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEpE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,kBAAkB,GAAG,SAAS,EACtC,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAiBhC"}
|