@sodax/dapp-kit 1.0.4-beta-rc1 → 1.0.4-beta
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/dist/index.d.mts +34 -5
- package/dist/index.d.ts +34 -5
- package/dist/index.js +20 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/hooks/bridge/useGetBridgeableAmount.ts +7 -6
- package/src/hooks/mm/useATokensBalances.ts +2 -7
- package/src/hooks/shared/index.ts +1 -0
- package/src/hooks/shared/useGetUserHubWalletAddress.ts +54 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Sodax, SpokeProvider, GetEstimateGasReturnType, TxReturnType, SpokeChainId, StellarSpokeProvider, EvmHubProvider, IWalletProvider, MoneyMarketBorrowParams, MoneyMarketError, RelayErrorCode, MoneyMarketRepayParams, MoneyMarketSupplyParams, MoneyMarketWithdrawParams, UserReserveData, AggregatedReserveData, BaseCurrencyInfo, MoneyMarketParams, XToken, ReserveData, FormatReserveUSDResponse, FormatUserSummaryResponse, SolverIntentQuoteRequest, Result, SolverIntentQuoteResponse, SolverErrorResponse, SolverExecutionResponse, Intent, IntentDeliveryInfo, IntentError, IntentErrorCode, CreateIntentParams, Hex, SolverIntentStatusResponse, CreateLimitOrderParams, IntentResponse, Address as Address$1, UserIntentsResponse, OrderbookResponse, MoneyMarketPosition, MoneyMarketAsset, MoneyMarketAssetBorrowers, MoneyMarketAssetSuppliers, MoneyMarketBorrowers, CreateBridgeIntentParams, SpokeTxHash, HubTxHash, BridgeError, BridgeErrorCode, StakeParams, UnstakeParams, ClaimParams, CancelUnstakeParams, StakingInfo, UnstakingInfo, UnstakeRequestWithPenalty, StakingConfig, InstantUnstakeParams, SodaxConfig } from '@sodax/sdk';
|
|
1
|
+
import { Sodax, SpokeProvider, GetEstimateGasReturnType, TxReturnType, SpokeChainId, StellarSpokeProvider, EvmHubProvider, IWalletProvider, MoneyMarketBorrowParams, MoneyMarketError, RelayErrorCode, MoneyMarketRepayParams, MoneyMarketSupplyParams, MoneyMarketWithdrawParams, UserReserveData, AggregatedReserveData, BaseCurrencyInfo, MoneyMarketParams, XToken, ReserveData, FormatReserveUSDResponse, FormatUserSummaryResponse, SolverIntentQuoteRequest, Result, SolverIntentQuoteResponse, SolverErrorResponse, SolverExecutionResponse, Intent, IntentDeliveryInfo, IntentError, IntentErrorCode, CreateIntentParams, Hex, SolverIntentStatusResponse, CreateLimitOrderParams, IntentResponse, Address as Address$1, UserIntentsResponse, OrderbookResponse, MoneyMarketPosition, MoneyMarketAsset, MoneyMarketAssetBorrowers, MoneyMarketAssetSuppliers, MoneyMarketBorrowers, CreateBridgeIntentParams, SpokeTxHash, HubTxHash, BridgeError, BridgeErrorCode, BridgeLimit, StakeParams, UnstakeParams, ClaimParams, CancelUnstakeParams, StakingInfo, UnstakingInfo, UnstakeRequestWithPenalty, StakingConfig, InstantUnstakeParams, SodaxConfig } from '@sodax/sdk';
|
|
2
2
|
import { RpcConfig, SpokeChainId as SpokeChainId$1, XToken as XToken$1 } from '@sodax/types';
|
|
3
3
|
import { UseMutationResult, UseQueryResult, UseQueryOptions } from '@tanstack/react-query';
|
|
4
4
|
import { Address } from 'viem';
|
|
@@ -132,6 +132,35 @@ declare function useRequestTrustline<T extends SpokeProvider = SpokeProvider>(to
|
|
|
132
132
|
data: TxReturnType<StellarSpokeProvider, false> | null;
|
|
133
133
|
};
|
|
134
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Hook for deriving user wallet address for hub abstraction.
|
|
137
|
+
*
|
|
138
|
+
* This hook derives the user's abstracted wallet address for the hub chain based on the spoke chain ID and address.
|
|
139
|
+
* If the spoke chain is the same as the hub chain, it returns the encoded spoke address.
|
|
140
|
+
* Otherwise, it derives and returns the abstracted wallet address for cross-chain operations.
|
|
141
|
+
* NOTE: This hook is different from useDeriveUserWalletAddress because it uses wallet router address instead of CREATE3 address for Sonic (hub).
|
|
142
|
+
*
|
|
143
|
+
* The query is automatically enabled when both `spokeChainId` and `spokeAddress` are provided.
|
|
144
|
+
* This is a deterministic operation, so the result is cached and not refetched automatically.
|
|
145
|
+
*
|
|
146
|
+
* @param spokeChainId - Optional spoke chain ID. If not provided, the query will be disabled.
|
|
147
|
+
* @param spokeAddress - Optional user wallet address on the spoke chain. If not provided, the query will be disabled.
|
|
148
|
+
* @returns A React Query result object containing:
|
|
149
|
+
* - data: The derived user wallet address (Address) when available
|
|
150
|
+
* - isLoading: Loading state indicator
|
|
151
|
+
* - error: Any error that occurred during derivation (Error)
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* const { data: derivedAddress, isLoading, error } = useDeriveUserWalletAddress(spokeChainId, userAddress);
|
|
156
|
+
*
|
|
157
|
+
* if (isLoading) return <div>Deriving address...</div>;
|
|
158
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
159
|
+
* if (derivedAddress) return <div>Derived Address: {derivedAddress}</div>;
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
declare function useGetUserHubWalletAddress(spokeChainId?: SpokeChainId | SpokeProvider | undefined, spokeAddress?: string | undefined): UseQueryResult<Address, Error>;
|
|
163
|
+
|
|
135
164
|
declare function useHubProvider(): EvmHubProvider;
|
|
136
165
|
|
|
137
166
|
/**
|
|
@@ -1232,8 +1261,8 @@ declare function useBridge(spokeProvider: SpokeProvider | undefined): UseMutatio
|
|
|
1232
1261
|
* @param {SpokeChainId | undefined} chainId - The chain ID to get the balance for
|
|
1233
1262
|
* @param {string | undefined} token - The token address to get the balance for
|
|
1234
1263
|
*
|
|
1235
|
-
* @returns {UseQueryResult<
|
|
1236
|
-
* - data:
|
|
1264
|
+
* @returns {UseQueryResult<BridgeLimit, Error>} A React Query result containing:
|
|
1265
|
+
* - data: Data about available amount to be bridged
|
|
1237
1266
|
* - error: Any error that occurred during the check
|
|
1238
1267
|
*
|
|
1239
1268
|
* @example
|
|
@@ -1245,7 +1274,7 @@ declare function useBridge(spokeProvider: SpokeProvider | undefined): UseMutatio
|
|
|
1245
1274
|
* }
|
|
1246
1275
|
* ```
|
|
1247
1276
|
*/
|
|
1248
|
-
declare function useGetBridgeableAmount(from: XToken | undefined, to: XToken | undefined): UseQueryResult<
|
|
1277
|
+
declare function useGetBridgeableAmount(from: XToken | undefined, to: XToken | undefined): UseQueryResult<BridgeLimit, Error>;
|
|
1249
1278
|
|
|
1250
1279
|
/**
|
|
1251
1280
|
/**
|
|
@@ -1792,4 +1821,4 @@ interface SodaxProviderProps {
|
|
|
1792
1821
|
}
|
|
1793
1822
|
declare const SodaxProvider: ({ children, testnet, config, rpcConfig }: SodaxProviderProps) => ReactElement;
|
|
1794
1823
|
|
|
1795
|
-
export { type BackendPaginationParams, MIGRATION_MODE_BNUSD, MIGRATION_MODE_ICX_SODA, type MigrationIntentParams, type MigrationMode, SodaxProvider, type UseATokenParams, type UseATokensBalancesParams, type UseBorrowParams, type UseMMAllowanceParams, type UseMMApproveParams, type UseRepayParams, type UseReservesDataParams, type UseReservesUsdFormatParams, type UseSupplyParams, type UseUserFormattedSummaryParams, type UseUserReservesDataParams, type UseWithdrawParams, useAToken, useATokensBalances, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOrderbook, useBackendUserIntents, useBorrow, useBridge, useBridgeAllowance, useBridgeApprove, useCancelLimitOrder, useCancelSwap, useCancelUnstake, useClaim, useConvertedAssets, useCreateLimitOrder, useDeriveUserWalletAddress, useEstimateGas, useGetBridgeableAmount, useGetBridgeableTokens, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useMMAllowance, useMMApprove, useMigrate, useMigrationAllowance, useMigrationApprove, useQuote, useRepay, useRequestTrustline, useReservesData, useReservesUsdFormat, useSodaxContext, useSpokeProvider, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarTrustlineCheck, useSupply, useSwap, useSwapAllowance, useSwapApprove, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserFormattedSummary, useUserReservesData, useWithdraw };
|
|
1824
|
+
export { type BackendPaginationParams, MIGRATION_MODE_BNUSD, MIGRATION_MODE_ICX_SODA, type MigrationIntentParams, type MigrationMode, SodaxProvider, type UseATokenParams, type UseATokensBalancesParams, type UseBorrowParams, type UseMMAllowanceParams, type UseMMApproveParams, type UseRepayParams, type UseReservesDataParams, type UseReservesUsdFormatParams, type UseSupplyParams, type UseUserFormattedSummaryParams, type UseUserReservesDataParams, type UseWithdrawParams, useAToken, useATokensBalances, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOrderbook, useBackendUserIntents, useBorrow, useBridge, useBridgeAllowance, useBridgeApprove, useCancelLimitOrder, useCancelSwap, useCancelUnstake, useClaim, useConvertedAssets, useCreateLimitOrder, useDeriveUserWalletAddress, useEstimateGas, useGetBridgeableAmount, useGetBridgeableTokens, useGetUserHubWalletAddress, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useMMAllowance, useMMApprove, useMigrate, useMigrationAllowance, useMigrationApprove, useQuote, useRepay, useRequestTrustline, useReservesData, useReservesUsdFormat, useSodaxContext, useSpokeProvider, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarTrustlineCheck, useSupply, useSwap, useSwapAllowance, useSwapApprove, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserFormattedSummary, useUserReservesData, useWithdraw };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Sodax, SpokeProvider, GetEstimateGasReturnType, TxReturnType, SpokeChainId, StellarSpokeProvider, EvmHubProvider, IWalletProvider, MoneyMarketBorrowParams, MoneyMarketError, RelayErrorCode, MoneyMarketRepayParams, MoneyMarketSupplyParams, MoneyMarketWithdrawParams, UserReserveData, AggregatedReserveData, BaseCurrencyInfo, MoneyMarketParams, XToken, ReserveData, FormatReserveUSDResponse, FormatUserSummaryResponse, SolverIntentQuoteRequest, Result, SolverIntentQuoteResponse, SolverErrorResponse, SolverExecutionResponse, Intent, IntentDeliveryInfo, IntentError, IntentErrorCode, CreateIntentParams, Hex, SolverIntentStatusResponse, CreateLimitOrderParams, IntentResponse, Address as Address$1, UserIntentsResponse, OrderbookResponse, MoneyMarketPosition, MoneyMarketAsset, MoneyMarketAssetBorrowers, MoneyMarketAssetSuppliers, MoneyMarketBorrowers, CreateBridgeIntentParams, SpokeTxHash, HubTxHash, BridgeError, BridgeErrorCode, StakeParams, UnstakeParams, ClaimParams, CancelUnstakeParams, StakingInfo, UnstakingInfo, UnstakeRequestWithPenalty, StakingConfig, InstantUnstakeParams, SodaxConfig } from '@sodax/sdk';
|
|
1
|
+
import { Sodax, SpokeProvider, GetEstimateGasReturnType, TxReturnType, SpokeChainId, StellarSpokeProvider, EvmHubProvider, IWalletProvider, MoneyMarketBorrowParams, MoneyMarketError, RelayErrorCode, MoneyMarketRepayParams, MoneyMarketSupplyParams, MoneyMarketWithdrawParams, UserReserveData, AggregatedReserveData, BaseCurrencyInfo, MoneyMarketParams, XToken, ReserveData, FormatReserveUSDResponse, FormatUserSummaryResponse, SolverIntentQuoteRequest, Result, SolverIntentQuoteResponse, SolverErrorResponse, SolverExecutionResponse, Intent, IntentDeliveryInfo, IntentError, IntentErrorCode, CreateIntentParams, Hex, SolverIntentStatusResponse, CreateLimitOrderParams, IntentResponse, Address as Address$1, UserIntentsResponse, OrderbookResponse, MoneyMarketPosition, MoneyMarketAsset, MoneyMarketAssetBorrowers, MoneyMarketAssetSuppliers, MoneyMarketBorrowers, CreateBridgeIntentParams, SpokeTxHash, HubTxHash, BridgeError, BridgeErrorCode, BridgeLimit, StakeParams, UnstakeParams, ClaimParams, CancelUnstakeParams, StakingInfo, UnstakingInfo, UnstakeRequestWithPenalty, StakingConfig, InstantUnstakeParams, SodaxConfig } from '@sodax/sdk';
|
|
2
2
|
import { RpcConfig, SpokeChainId as SpokeChainId$1, XToken as XToken$1 } from '@sodax/types';
|
|
3
3
|
import { UseMutationResult, UseQueryResult, UseQueryOptions } from '@tanstack/react-query';
|
|
4
4
|
import { Address } from 'viem';
|
|
@@ -132,6 +132,35 @@ declare function useRequestTrustline<T extends SpokeProvider = SpokeProvider>(to
|
|
|
132
132
|
data: TxReturnType<StellarSpokeProvider, false> | null;
|
|
133
133
|
};
|
|
134
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Hook for deriving user wallet address for hub abstraction.
|
|
137
|
+
*
|
|
138
|
+
* This hook derives the user's abstracted wallet address for the hub chain based on the spoke chain ID and address.
|
|
139
|
+
* If the spoke chain is the same as the hub chain, it returns the encoded spoke address.
|
|
140
|
+
* Otherwise, it derives and returns the abstracted wallet address for cross-chain operations.
|
|
141
|
+
* NOTE: This hook is different from useDeriveUserWalletAddress because it uses wallet router address instead of CREATE3 address for Sonic (hub).
|
|
142
|
+
*
|
|
143
|
+
* The query is automatically enabled when both `spokeChainId` and `spokeAddress` are provided.
|
|
144
|
+
* This is a deterministic operation, so the result is cached and not refetched automatically.
|
|
145
|
+
*
|
|
146
|
+
* @param spokeChainId - Optional spoke chain ID. If not provided, the query will be disabled.
|
|
147
|
+
* @param spokeAddress - Optional user wallet address on the spoke chain. If not provided, the query will be disabled.
|
|
148
|
+
* @returns A React Query result object containing:
|
|
149
|
+
* - data: The derived user wallet address (Address) when available
|
|
150
|
+
* - isLoading: Loading state indicator
|
|
151
|
+
* - error: Any error that occurred during derivation (Error)
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* const { data: derivedAddress, isLoading, error } = useDeriveUserWalletAddress(spokeChainId, userAddress);
|
|
156
|
+
*
|
|
157
|
+
* if (isLoading) return <div>Deriving address...</div>;
|
|
158
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
159
|
+
* if (derivedAddress) return <div>Derived Address: {derivedAddress}</div>;
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
declare function useGetUserHubWalletAddress(spokeChainId?: SpokeChainId | SpokeProvider | undefined, spokeAddress?: string | undefined): UseQueryResult<Address, Error>;
|
|
163
|
+
|
|
135
164
|
declare function useHubProvider(): EvmHubProvider;
|
|
136
165
|
|
|
137
166
|
/**
|
|
@@ -1232,8 +1261,8 @@ declare function useBridge(spokeProvider: SpokeProvider | undefined): UseMutatio
|
|
|
1232
1261
|
* @param {SpokeChainId | undefined} chainId - The chain ID to get the balance for
|
|
1233
1262
|
* @param {string | undefined} token - The token address to get the balance for
|
|
1234
1263
|
*
|
|
1235
|
-
* @returns {UseQueryResult<
|
|
1236
|
-
* - data:
|
|
1264
|
+
* @returns {UseQueryResult<BridgeLimit, Error>} A React Query result containing:
|
|
1265
|
+
* - data: Data about available amount to be bridged
|
|
1237
1266
|
* - error: Any error that occurred during the check
|
|
1238
1267
|
*
|
|
1239
1268
|
* @example
|
|
@@ -1245,7 +1274,7 @@ declare function useBridge(spokeProvider: SpokeProvider | undefined): UseMutatio
|
|
|
1245
1274
|
* }
|
|
1246
1275
|
* ```
|
|
1247
1276
|
*/
|
|
1248
|
-
declare function useGetBridgeableAmount(from: XToken | undefined, to: XToken | undefined): UseQueryResult<
|
|
1277
|
+
declare function useGetBridgeableAmount(from: XToken | undefined, to: XToken | undefined): UseQueryResult<BridgeLimit, Error>;
|
|
1249
1278
|
|
|
1250
1279
|
/**
|
|
1251
1280
|
/**
|
|
@@ -1792,4 +1821,4 @@ interface SodaxProviderProps {
|
|
|
1792
1821
|
}
|
|
1793
1822
|
declare const SodaxProvider: ({ children, testnet, config, rpcConfig }: SodaxProviderProps) => ReactElement;
|
|
1794
1823
|
|
|
1795
|
-
export { type BackendPaginationParams, MIGRATION_MODE_BNUSD, MIGRATION_MODE_ICX_SODA, type MigrationIntentParams, type MigrationMode, SodaxProvider, type UseATokenParams, type UseATokensBalancesParams, type UseBorrowParams, type UseMMAllowanceParams, type UseMMApproveParams, type UseRepayParams, type UseReservesDataParams, type UseReservesUsdFormatParams, type UseSupplyParams, type UseUserFormattedSummaryParams, type UseUserReservesDataParams, type UseWithdrawParams, useAToken, useATokensBalances, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOrderbook, useBackendUserIntents, useBorrow, useBridge, useBridgeAllowance, useBridgeApprove, useCancelLimitOrder, useCancelSwap, useCancelUnstake, useClaim, useConvertedAssets, useCreateLimitOrder, useDeriveUserWalletAddress, useEstimateGas, useGetBridgeableAmount, useGetBridgeableTokens, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useMMAllowance, useMMApprove, useMigrate, useMigrationAllowance, useMigrationApprove, useQuote, useRepay, useRequestTrustline, useReservesData, useReservesUsdFormat, useSodaxContext, useSpokeProvider, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarTrustlineCheck, useSupply, useSwap, useSwapAllowance, useSwapApprove, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserFormattedSummary, useUserReservesData, useWithdraw };
|
|
1824
|
+
export { type BackendPaginationParams, MIGRATION_MODE_BNUSD, MIGRATION_MODE_ICX_SODA, type MigrationIntentParams, type MigrationMode, SodaxProvider, type UseATokenParams, type UseATokensBalancesParams, type UseBorrowParams, type UseMMAllowanceParams, type UseMMApproveParams, type UseRepayParams, type UseReservesDataParams, type UseReservesUsdFormatParams, type UseSupplyParams, type UseUserFormattedSummaryParams, type UseUserReservesDataParams, type UseWithdrawParams, useAToken, useATokensBalances, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOrderbook, useBackendUserIntents, useBorrow, useBridge, useBridgeAllowance, useBridgeApprove, useCancelLimitOrder, useCancelSwap, useCancelUnstake, useClaim, useConvertedAssets, useCreateLimitOrder, useDeriveUserWalletAddress, useEstimateGas, useGetBridgeableAmount, useGetBridgeableTokens, useGetUserHubWalletAddress, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useMMAllowance, useMMApprove, useMigrate, useMigrationAllowance, useMigrationApprove, useQuote, useRepay, useRequestTrustline, useReservesData, useReservesUsdFormat, useSodaxContext, useSpokeProvider, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarTrustlineCheck, useSupply, useSwap, useSwapAllowance, useSwapApprove, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserFormattedSummary, useUserReservesData, useWithdraw };
|
package/dist/index.js
CHANGED
|
@@ -113,6 +113,22 @@ function useRequestTrustline(token) {
|
|
|
113
113
|
data
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
|
+
function useGetUserHubWalletAddress(spokeChainId, spokeAddress) {
|
|
117
|
+
const { sodax } = useSodaxContext();
|
|
118
|
+
return reactQuery.useQuery({
|
|
119
|
+
queryKey: ["getUserHubWalletAddress", spokeChainId, spokeAddress],
|
|
120
|
+
queryFn: async () => {
|
|
121
|
+
if (!spokeChainId || !spokeAddress) {
|
|
122
|
+
throw new Error("Spoke chain id and address are required");
|
|
123
|
+
}
|
|
124
|
+
spokeChainId = typeof spokeChainId === "object" ? spokeChainId.chainConfig.chain.id : spokeChainId;
|
|
125
|
+
return await sdk.HubService.getUserHubWalletAddress(spokeAddress, spokeChainId, sodax.hubProvider);
|
|
126
|
+
},
|
|
127
|
+
enabled: !!spokeChainId && !!spokeAddress,
|
|
128
|
+
refetchInterval: false
|
|
129
|
+
// This is a deterministic operation, no need to refetch
|
|
130
|
+
});
|
|
131
|
+
}
|
|
116
132
|
|
|
117
133
|
// src/hooks/provider/useHubProvider.ts
|
|
118
134
|
function useHubProvider() {
|
|
@@ -396,11 +412,7 @@ function useATokensBalances({
|
|
|
396
412
|
throw new Error(`Invalid aToken address: ${aToken}`);
|
|
397
413
|
}
|
|
398
414
|
}
|
|
399
|
-
const hubWalletAddress = await sdk.
|
|
400
|
-
sodax.hubProvider,
|
|
401
|
-
spokeProvider.chainConfig.chain.id,
|
|
402
|
-
userAddress
|
|
403
|
-
);
|
|
415
|
+
const hubWalletAddress = await sdk.HubService.getUserHubWalletAddress(userAddress, spokeProvider.chainConfig.chain.id, sodax.hubProvider);
|
|
404
416
|
return await sodax.moneyMarket.data.getATokensBalances(aTokens, hubWalletAddress);
|
|
405
417
|
}
|
|
406
418
|
});
|
|
@@ -898,14 +910,14 @@ function useGetBridgeableAmount(from, to) {
|
|
|
898
910
|
queryKey: ["spoke-asset-manager-token-balance", from, to],
|
|
899
911
|
queryFn: async () => {
|
|
900
912
|
if (!from || !to) {
|
|
901
|
-
return 0n;
|
|
913
|
+
return { amount: 0n, decimals: 0, type: "DEPOSIT_LIMIT" };
|
|
902
914
|
}
|
|
903
915
|
const result = await sodax.bridge.getBridgeableAmount(from, to);
|
|
904
916
|
if (result.ok) {
|
|
905
917
|
return result.value;
|
|
906
918
|
}
|
|
907
919
|
console.error("Error getting bridgeable amount:", result.error);
|
|
908
|
-
return 0n;
|
|
920
|
+
return { amount: 0n, decimals: 0, type: "DEPOSIT_LIMIT" };
|
|
909
921
|
},
|
|
910
922
|
enabled: !!from && !!to
|
|
911
923
|
});
|
|
@@ -1490,6 +1502,7 @@ exports.useDeriveUserWalletAddress = useDeriveUserWalletAddress;
|
|
|
1490
1502
|
exports.useEstimateGas = useEstimateGas;
|
|
1491
1503
|
exports.useGetBridgeableAmount = useGetBridgeableAmount;
|
|
1492
1504
|
exports.useGetBridgeableTokens = useGetBridgeableTokens;
|
|
1505
|
+
exports.useGetUserHubWalletAddress = useGetUserHubWalletAddress;
|
|
1493
1506
|
exports.useHubProvider = useHubProvider;
|
|
1494
1507
|
exports.useInstantUnstake = useInstantUnstake;
|
|
1495
1508
|
exports.useInstantUnstakeAllowance = useInstantUnstakeAllowance;
|