@sodax/dapp-kit 0.0.1-rc.3 → 0.0.1-rc.31
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/LICENSE +21 -0
- package/README.md +152 -53
- package/dist/index.d.mts +1514 -0
- package/dist/index.d.ts +1514 -4
- package/dist/index.js +1141 -189
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1096 -187
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -8
- package/src/contexts/index.ts +2 -0
- package/src/core/index.ts +5 -33
- 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 +4 -0
- package/src/hooks/migrate/index.ts +4 -0
- package/src/hooks/migrate/types.ts +15 -0
- package/src/hooks/migrate/useMigrate.tsx +110 -0
- package/src/hooks/migrate/useMigrationAllowance.tsx +79 -0
- package/src/hooks/migrate/useMigrationApprove.tsx +129 -0
- package/src/hooks/mm/index.ts +3 -1
- package/src/hooks/mm/useBorrow.ts +20 -10
- package/src/hooks/mm/useMMAllowance.ts +56 -0
- package/src/hooks/mm/useMMApprove.ts +68 -0
- package/src/hooks/mm/useRepay.ts +20 -10
- package/src/hooks/mm/useReservesData.ts +30 -0
- package/src/hooks/mm/useReservesHumanized.ts +30 -0
- package/src/hooks/mm/useReservesList.ts +29 -0
- package/src/hooks/mm/useReservesUsdFormat.ts +38 -0
- package/src/hooks/mm/useSupply.ts +9 -6
- package/src/hooks/mm/useUserFormattedSummary.ts +54 -0
- package/src/hooks/mm/useUserReservesData.ts +30 -48
- package/src/hooks/mm/useWithdraw.ts +17 -11
- package/src/hooks/provider/useHubProvider.ts +3 -21
- package/src/hooks/provider/useSpokeProvider.ts +97 -6
- package/src/hooks/shared/index.ts +4 -2
- package/src/hooks/shared/useDeriveUserWalletAddress.ts +44 -0
- package/src/hooks/shared/useEstimateGas.ts +18 -0
- package/src/hooks/shared/useRequestTrustline.ts +103 -0
- package/src/hooks/shared/useStellarTrustlineCheck.ts +71 -0
- package/src/hooks/staking/index.ts +19 -0
- package/src/hooks/staking/useCancelUnstake.ts +52 -0
- package/src/hooks/staking/useClaim.ts +46 -0
- package/src/hooks/staking/useConvertedAssets.ts +47 -0
- package/src/hooks/staking/useInstantUnstake.ts +50 -0
- package/src/hooks/staking/useInstantUnstakeAllowance.ts +59 -0
- package/src/hooks/staking/useInstantUnstakeApprove.ts +52 -0
- package/src/hooks/staking/useInstantUnstakeRatio.ts +54 -0
- package/src/hooks/staking/useStake.ts +47 -0
- package/src/hooks/staking/useStakeAllowance.ts +57 -0
- package/src/hooks/staking/useStakeApprove.ts +50 -0
- package/src/hooks/staking/useStakeRatio.ts +53 -0
- package/src/hooks/staking/useStakingConfig.ts +40 -0
- package/src/hooks/staking/useStakingInfo.ts +50 -0
- package/src/hooks/staking/useUnstake.ts +54 -0
- package/src/hooks/staking/useUnstakeAllowance.ts +58 -0
- package/src/hooks/staking/useUnstakeApprove.ts +52 -0
- package/src/hooks/staking/useUnstakingInfo.ts +53 -0
- package/src/hooks/staking/useUnstakingInfoWithPenalty.ts +59 -0
- package/src/hooks/swap/index.ts +4 -1
- package/src/hooks/swap/useCancelSwap.ts +44 -0
- package/src/hooks/swap/useQuote.ts +20 -6
- package/src/hooks/swap/useStatus.ts +3 -3
- package/src/hooks/swap/{useCreateIntentOrder.ts → useSwap.ts} +22 -19
- package/src/hooks/swap/useSwapAllowance.ts +48 -0
- package/src/hooks/swap/useSwapApprove.ts +68 -0
- package/src/providers/SodaxProvider.tsx +7 -4
- package/dist/contexts/index.d.ts +0 -7
- package/dist/contexts/index.d.ts.map +0 -1
- package/dist/core/index.d.ts +0 -4
- package/dist/core/index.d.ts.map +0 -1
- package/dist/hooks/index.d.ts +0 -5
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/mm/index.d.ts +0 -7
- package/dist/hooks/mm/index.d.ts.map +0 -1
- package/dist/hooks/mm/useBorrow.d.ts +0 -26
- package/dist/hooks/mm/useBorrow.d.ts.map +0 -1
- package/dist/hooks/mm/useHubWalletAddress.d.ts +0 -24
- package/dist/hooks/mm/useHubWalletAddress.d.ts.map +0 -1
- package/dist/hooks/mm/useRepay.d.ts +0 -26
- package/dist/hooks/mm/useRepay.d.ts.map +0 -1
- package/dist/hooks/mm/useSupply.d.ts +0 -32
- package/dist/hooks/mm/useSupply.d.ts.map +0 -1
- package/dist/hooks/mm/useUserReservesData.d.ts +0 -9
- package/dist/hooks/mm/useUserReservesData.d.ts.map +0 -1
- package/dist/hooks/mm/useWithdraw.d.ts +0 -26
- package/dist/hooks/mm/useWithdraw.d.ts.map +0 -1
- package/dist/hooks/provider/index.d.ts +0 -3
- package/dist/hooks/provider/index.d.ts.map +0 -1
- package/dist/hooks/provider/useHubProvider.d.ts +0 -3
- package/dist/hooks/provider/useHubProvider.d.ts.map +0 -1
- package/dist/hooks/provider/useSpokeProvider.d.ts +0 -4
- package/dist/hooks/provider/useSpokeProvider.d.ts.map +0 -1
- package/dist/hooks/shared/index.d.ts +0 -4
- package/dist/hooks/shared/index.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/dist/hooks/shared/useSodaxContext.d.ts +0 -8
- package/dist/hooks/shared/useSodaxContext.d.ts.map +0 -1
- package/dist/hooks/swap/index.d.ts +0 -4
- package/dist/hooks/swap/index.d.ts.map +0 -1
- package/dist/hooks/swap/useCreateIntentOrder.d.ts +0 -33
- package/dist/hooks/swap/useCreateIntentOrder.d.ts.map +0 -1
- package/dist/hooks/swap/useQuote.d.ts +0 -39
- package/dist/hooks/swap/useQuote.d.ts.map +0 -1
- package/dist/hooks/swap/useStatus.d.ts +0 -31
- package/dist/hooks/swap/useStatus.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/providers/SodaxProvider.d.ts +0 -10
- package/dist/providers/SodaxProvider.d.ts.map +0 -1
- package/dist/providers/index.d.ts +0 -2
- package/dist/providers/index.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
|
@@ -1,24 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,32 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/provider/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
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,CAoB3D"}
|
|
@@ -1,4 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSpokeProvider.d.ts","sourceRoot":"","sources":["../../../src/hooks/provider/useSpokeProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAGhB,gBAAgB,EAEjB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAA0C,YAAY,EAAE,MAAM,cAAc,CAAC;AAIzF,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,YAAY,mDAqB1D"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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,33 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,39 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { Hex, IntentErrorResponse, IntentStatusResponse, Result } from '@sodax/sdk';
|
|
2
|
-
import { type UseQueryResult } from '@tanstack/react-query';
|
|
3
|
-
/**
|
|
4
|
-
* Hook for monitoring the status of an intent-based swap.
|
|
5
|
-
*
|
|
6
|
-
* This hook provides real-time status updates for an intent-based swap transaction.
|
|
7
|
-
*
|
|
8
|
-
* @param {Hex} intent_tx_hash - The transaction hash of the intent order on the hub chain
|
|
9
|
-
*
|
|
10
|
-
* @returns {UseQueryResult<Result<IntentStatusResponse, IntentErrorResponse> | undefined>} A query result object containing:
|
|
11
|
-
* - data: The status result from the solver
|
|
12
|
-
* - isLoading: Boolean indicating if the status is being fetched
|
|
13
|
-
* - error: Error object if the status request failed
|
|
14
|
-
* - refetch: Function to manually trigger a status refresh
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const { data: status, isLoading } = useStatus('0x...');
|
|
19
|
-
*
|
|
20
|
-
* if (isLoading) return <div>Loading status...</div>;
|
|
21
|
-
* if (status?.ok) {
|
|
22
|
-
* console.log('Status:', status.value);
|
|
23
|
-
* }
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* @remarks
|
|
27
|
-
* - The status is automatically refreshed every 3 seconds
|
|
28
|
-
* - Uses React Query for efficient caching and state management
|
|
29
|
-
*/
|
|
30
|
-
export declare const useStatus: (intent_tx_hash: Hex) => UseQueryResult<Result<IntentStatusResponse, IntentErrorResponse> | undefined>;
|
|
31
|
-
//# sourceMappingURL=useStatus.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useStatus.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzF,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGtE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,eAAO,MAAM,SAAS,mBACJ,GAAG,KAClB,cAAc,CAAC,MAAM,CAAC,oBAAoB,EAAE,mBAAmB,CAAC,GAAG,SAAS,CAS9E,CAAC"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ReactNode, ReactElement } from 'react';
|
|
2
|
-
import { type SodaxConfig } from '@sodax/sdk';
|
|
3
|
-
interface SodaxProviderProps {
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
testnet?: boolean;
|
|
6
|
-
config: SodaxConfig;
|
|
7
|
-
}
|
|
8
|
-
export declare const SodaxProvider: ({ children, testnet, config }: SodaxProviderProps) => ReactElement;
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=SodaxProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SodaxProvider.d.ts","sourceRoot":"","sources":["../../src/providers/SodaxProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAS,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAIrD,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,WAAW,CAAC;CACrB;AAED,eAAO,MAAM,aAAa,kCAA2C,kBAAkB,KAAG,YAIzF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { type EvmHubProvider, EvmWalletAbstraction, type SpokeChainId } from '@sodax/sdk';
|
|
2
|
-
import { useQuery, type UseQueryResult } from '@tanstack/react-query';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Hook for retrieving the hub wallet address for a given spoke chain and address.
|
|
6
|
-
*
|
|
7
|
-
* This hook fetches the hub wallet address associated with a user's address on a specific spoke chain.
|
|
8
|
-
* It uses the EvmWalletAbstraction to query the hub wallet address from the hub provider.
|
|
9
|
-
*
|
|
10
|
-
* @param spokeChainId - The chain ID of the spoke chain
|
|
11
|
-
* @param address - The user's address on the spoke chain
|
|
12
|
-
* @param hubProvider - The hub provider instance
|
|
13
|
-
*
|
|
14
|
-
* @returns {UseQueryResult<string | null>} A query result object containing:
|
|
15
|
-
* - data: The hub wallet address or null if not found
|
|
16
|
-
* - isLoading: Boolean indicating if the query is in progress
|
|
17
|
-
* - error: Error object if the query failed, null otherwise
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* const { data: hubWalletAddress, isLoading, error } = useHubWalletAddress(spokeChainId, address, hubProvider);
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
export function useHubWalletAddress(
|
|
26
|
-
spokeChainId: SpokeChainId,
|
|
27
|
-
address: string | undefined,
|
|
28
|
-
hubProvider: EvmHubProvider,
|
|
29
|
-
): UseQueryResult<string | null> {
|
|
30
|
-
return useQuery({
|
|
31
|
-
queryKey: ['hubWallet', spokeChainId, address],
|
|
32
|
-
queryFn: async () => {
|
|
33
|
-
if (!address) return null;
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
const hubWalletAddress = await EvmWalletAbstraction.getUserHubWalletAddress(
|
|
37
|
-
spokeChainId,
|
|
38
|
-
address as `0x${string}`,
|
|
39
|
-
hubProvider,
|
|
40
|
-
);
|
|
41
|
-
return hubWalletAddress;
|
|
42
|
-
} catch (error) {
|
|
43
|
-
console.log('error', error);
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
enabled: !!address && !!hubProvider,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { useQuery } from '@tanstack/react-query';
|
|
2
|
-
import type { SpokeChainId, XToken } from '@sodax/types';
|
|
3
|
-
import { useSodaxContext } from '../shared/useSodaxContext';
|
|
4
|
-
import { useSpokeProvider } from '../provider/useSpokeProvider';
|
|
5
|
-
import { parseUnits } from 'viem';
|
|
6
|
-
|
|
7
|
-
export function useAllowance(token: XToken, amount: string) {
|
|
8
|
-
const { sodax } = useSodaxContext();
|
|
9
|
-
const spokeProvider = useSpokeProvider(token.xChainId as SpokeChainId);
|
|
10
|
-
|
|
11
|
-
return useQuery({
|
|
12
|
-
queryKey: ['allowance', token.address, amount],
|
|
13
|
-
queryFn: async () => {
|
|
14
|
-
if (!spokeProvider) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
const allowance = await sodax.moneyMarket.isAllowanceValid(
|
|
18
|
-
{
|
|
19
|
-
token: token.address,
|
|
20
|
-
amount: parseUnits(amount, token.decimals),
|
|
21
|
-
},
|
|
22
|
-
spokeProvider,
|
|
23
|
-
);
|
|
24
|
-
if (allowance.ok) {
|
|
25
|
-
return allowance.value;
|
|
26
|
-
}
|
|
27
|
-
return false;
|
|
28
|
-
},
|
|
29
|
-
enabled: !!spokeProvider,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { useSodaxContext } from '../shared/useSodaxContext';
|
|
2
|
-
import { useSpokeProvider } from '../provider/useSpokeProvider';
|
|
3
|
-
import type { SpokeChainId, XToken } from '@sodax/types';
|
|
4
|
-
import { parseUnits } from 'viem';
|
|
5
|
-
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
6
|
-
import type { Address } from '@sodax/sdk';
|
|
7
|
-
|
|
8
|
-
interface UseApproveReturn {
|
|
9
|
-
approve: (amount: string) => Promise<boolean>;
|
|
10
|
-
isLoading: boolean;
|
|
11
|
-
error: Error | null;
|
|
12
|
-
resetError: () => void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function useApprove(token: XToken): UseApproveReturn {
|
|
16
|
-
const { sodax } = useSodaxContext();
|
|
17
|
-
const spokeProvider = useSpokeProvider(token.xChainId as SpokeChainId);
|
|
18
|
-
const queryClient = useQueryClient();
|
|
19
|
-
|
|
20
|
-
const {
|
|
21
|
-
mutateAsync: approve,
|
|
22
|
-
isPending,
|
|
23
|
-
error,
|
|
24
|
-
reset: resetError,
|
|
25
|
-
} = useMutation({
|
|
26
|
-
mutationFn: async (amount: string) => {
|
|
27
|
-
if (!spokeProvider) {
|
|
28
|
-
throw new Error('Spoke provider not found');
|
|
29
|
-
}
|
|
30
|
-
const allowance = await sodax.moneyMarket.approve(
|
|
31
|
-
token.address as Address,
|
|
32
|
-
parseUnits(amount, token.decimals),
|
|
33
|
-
spokeProvider.chainConfig.addresses.assetManager as Address,
|
|
34
|
-
spokeProvider,
|
|
35
|
-
);
|
|
36
|
-
if (!allowance.ok) {
|
|
37
|
-
throw new Error('Failed to approve tokens');
|
|
38
|
-
}
|
|
39
|
-
return allowance.ok;
|
|
40
|
-
},
|
|
41
|
-
onSuccess: () => {
|
|
42
|
-
// Invalidate allowance query to refetch the new allowance
|
|
43
|
-
queryClient.invalidateQueries({ queryKey: ['allowance', token.address] });
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
approve,
|
|
49
|
-
isLoading: isPending,
|
|
50
|
-
error: error as Error | null,
|
|
51
|
-
resetError,
|
|
52
|
-
};
|
|
53
|
-
}
|