@sodax/dapp-kit 2.2.0-rc.1 → 2.2.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +2 -0
  2. package/dist/index.d.ts +96 -3
  3. package/dist/index.mjs +98 -39
  4. package/package.json +3 -3
  5. package/src/hooks/_apiKeyWire.test.ts +1 -1
  6. package/src/hooks/_mutationContract.test.ts +6 -0
  7. package/src/hooks/backend/index.ts +4 -0
  8. package/src/hooks/backend/useBackendOracleCandles.ts +47 -0
  9. package/src/hooks/backend/useBackendOracleMarkets.ts +30 -0
  10. package/src/hooks/bitcoin/useFundTradingWallet.ts +2 -1
  11. package/src/hooks/bitcoin/useRadfiWithdraw.ts +2 -1
  12. package/src/hooks/bridge/useBridge.ts +2 -2
  13. package/src/hooks/dex/useDexDeposit.ts +2 -1
  14. package/src/hooks/dex/useDexWithdraw.ts +2 -1
  15. package/src/hooks/dex/useSupplyLiquidity.ts +2 -1
  16. package/src/hooks/leverageYield/useLeverageYieldVaultSwap.ts +2 -2
  17. package/src/hooks/migrate/useMigrateBaln.ts +2 -2
  18. package/src/hooks/migrate/useMigrateIcxToSoda.ts +2 -2
  19. package/src/hooks/migrate/useMigratebnUSD.ts +2 -2
  20. package/src/hooks/migrate/useRevertMigrateSodaToIcx.ts +2 -2
  21. package/src/hooks/mm/useBorrow.ts +2 -4
  22. package/src/hooks/mm/useRepay.ts +2 -1
  23. package/src/hooks/mm/useSupply.ts +2 -1
  24. package/src/hooks/mm/useWithdraw.ts +2 -4
  25. package/src/hooks/partner/useFeeClaimWithdraw.ts +2 -1
  26. package/src/hooks/recovery/useWithdrawHubAsset.ts +2 -1
  27. package/src/hooks/shared/index.ts +2 -0
  28. package/src/hooks/shared/invalidateBalances.test.ts +71 -0
  29. package/src/hooks/shared/invalidateBalances.ts +25 -0
  30. package/src/hooks/shared/useBalances.test.ts +118 -0
  31. package/src/hooks/shared/useBalances.ts +81 -0
  32. package/src/hooks/shared/useEstablishTrustline.test.ts +2 -0
  33. package/src/hooks/shared/useEstablishTrustline.ts +2 -1
  34. package/src/hooks/shared/useStellarGate.test.ts +1 -1
  35. package/src/hooks/sponsoring/useActivateStellarAccount.test.ts +6 -4
  36. package/src/hooks/sponsoring/useActivateStellarAccount.ts +2 -1
  37. package/src/hooks/sponsoring/useSponsorConfig.test.ts +8 -2
  38. package/src/hooks/sponsoring/useStellarAccountActive.test.ts +2 -2
  39. package/src/hooks/sponsoring/useStellarAccountStatus.test.ts +8 -2
  40. package/src/hooks/staking/useClaim.ts +2 -1
  41. package/src/hooks/staking/useInstantUnstake.ts +2 -1
  42. package/src/hooks/staking/useStake.ts +2 -1
  43. package/src/hooks/swap/useDetailedStatus.test.ts +2 -2
  44. package/src/hooks/swap/useSwap.ts +2 -2
  45. package/src/providers/SodaxProvider.test.ts +1 -1
package/README.md CHANGED
@@ -275,6 +275,8 @@ These drive sponsored activation, where the SODAX sponsor pays the account's bas
275
275
  - [`useBackendMoneyMarketAssetBorrowers()`](https://github.com/icon-project/sodax-sdks/blob/main/packages/dapp-kit/src/hooks/backend/useBackendMoneyMarketAssetBorrowers.ts) — Asset borrowers
276
276
  - [`useBackendMoneyMarketAssetSuppliers()`](https://github.com/icon-project/sodax-sdks/blob/main/packages/dapp-kit/src/hooks/backend/useBackendMoneyMarketAssetSuppliers.ts) — Asset suppliers
277
277
  - [`useBackendAllMoneyMarketBorrowers()`](https://github.com/icon-project/sodax-sdks/blob/main/packages/dapp-kit/src/hooks/backend/useBackendAllMoneyMarketBorrowers.ts) — All borrowers
278
+ - [`useBackendOracleMarkets()`](https://github.com/icon-project/sodax-sdks/blob/main/packages/dapp-kit/src/hooks/backend/useBackendOracleMarkets.ts) — Oracle candle discovery: quote, intervals, symbols (cached 60s)
279
+ - [`useBackendOracleCandles()`](https://github.com/icon-project/sodax-sdks/blob/main/packages/dapp-kit/src/hooks/backend/useBackendOracleCandles.ts) — USD OHLC candles for a symbol over `[from, to)` (cached 10s)
278
280
 
279
281
  ### Swaps API Hooks (`sodax.api.swaps`)
280
282
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { UseMutationOptions, UseQueryOptions, UseMutationResult, MutateOptions, UseQueryResult, QueryClientConfig, QueryClient } from '@tanstack/react-query';
1
+ import { UseMutationOptions, UseQueryOptions, UseMutationResult, MutateOptions, UseQueryResult, QueryClient, QueryClientConfig } from '@tanstack/react-query';
2
2
  import * as _sodax_sdk from '@sodax/sdk';
3
- import { Result, Sodax, SpokeChainKey, GetEstimateGasReturnType, EstimateGasParams, StellarChainKey, IStellarWalletProvider, INearWalletProvider, GetWalletProviderType, StellarAccountStatus, ActivateStellarAccountResult, IXServiceBase, XToken, EvmHubProvider, IBitcoinWalletProvider, RadfiWalletBalance, IWalletProvider, RadfiUtxo, MoneyMarketBorrowActionParams, TxHashPair, MoneyMarketRepayActionParams, MoneyMarketSupplyActionParams, MoneyMarketWithdrawActionParams, UserReserveData, AggregatedReserveData, BaseCurrencyInfo, ReservesDataHumanized, Address as Address$1, MoneyMarketParams, MoneyMarketApproveActionParams, TxReturnType, Erc20Token, ChainKey, ReserveDataHumanized, FormatReserveUSDResponse, FormatUserSummaryResponse, SolverIntentQuoteRequest, SwapActionParams, SwapResponse, SolverIntentStatusResponse, SolverErrorResponse, Hex, DetailedSwapStatus, DetailedStatusError, CreateIntentParams, CreateLimitOrderParams, Intent, LimitOrderActionParams, IntentResponse, UserIntentsResponse, OrderbookResponse, MoneyMarketPosition, MoneyMarketAsset, MoneyMarketAssetBorrowers, MoneyMarketAssetSuppliers, MoneyMarketBorrowers, GetSwapTokensResponseV2, RequestOverrideConfig, GetSwapTokensByChainResponseV2, QuoteResponseV2, QuoteRequestV2, QuoteQueryV2, DeadlineResponseV2, DeadlineQueryV2, AllowanceCheckResponseV2, CreateIntentParamsV2, ApproveResponseV2, RawTxReturnType, CreateIntentResponseV2, SubmitIntentRequestV2, SubmitIntentResponseV2, StatusResponseV2, SwapIntentStatusCodeV2, CancelIntentRequestV2, CancelIntentResponseV2, IntentHashResponseV2, IntentRequestV2, IntentPacketResponseV2, IntentPacketRequestV2, IntentExtraDataResponseV2, IntentExtraDataRequestV2, IntentStateV2, GetIntentResponseV2, CreateLimitOrderParamsV2, CreateLimitOrderResponseV2, GasEstimateResponseV2, GasEstimateRequestV2, FeeResponseV2, SubmitTxRequestV2, SubmitTxResponseV2, SubmitTxStatusResponseV2, BridgeParams, CreateBridgeIntentParams, BridgeLimit, BridgeAllowanceCheckResponseV2, CreateBridgeIntentParamsV2, BridgeApproveResponseV2, BridgeableAmountResponseV2, BridgeQuoteRequestV2, CreateBridgeIntentResponseV2, BridgeFeeResponseV2, BridgeFeeRequestV2, BridgeableCheckResponseV2, BridgeSubmitTxRequestV2, BridgeSubmitTxResponseV2, BridgeSubmitTxStatusResponseV2, GetBridgeTokensResponseV2, GetBridgeTokensByChainResponseV2, StakeAction, StakeParams, UnstakeAction, ClaimAction, CancelUnstakeAction, StakingInfo, UnstakingInfo, UnstakeRequestWithPenalty, StakingConfig, InstantUnstakeAction, UnstakeParams, InstantUnstakeParams, PartnerFeeClaimAssetBalance, AutoSwapPreferences, FeeTokenApproveParams, FeeTokenApproveAction, HubChainKey, SetSwapPreferenceAction, PartnerFeeClaimSwapAction, IntentAutoSwapResult, PartnerFeeClaimCancelAction, GetUserIntentParams, HubAssetBalance, WithdrawHubAssetAction, IcxMigrateAction, IcxRevertMigrationAction, UnifiedBnUSDMigrateAction, BalnMigrateAction, MigrationAction, IcxMigrateParams, IcxCreateRevertMigrationParams, UnifiedBnUSDMigrateParams, BalnMigrateParams, PoolKey, PoolData, ClPositionInfo, AssetDepositAction, AssetWithdrawAction, CreateAssetDepositParams, ClSupplyParams, ClIncreaseLiquidityParams, ClLiquidityDecreaseLiquidityAction, ClDecreaseLiquidityParams, CreateAssetWithdrawParams, PoolSpokeAssets, DestinationParamsType, ClLiquidityClaimRewardsAction, LeverageYieldQuoteParams, LeverageYieldEffectiveApr, LeverageYieldPosition, LeverageYieldSwapDepositParams, LeverageYieldSwapPayload, SolverExecutionRequest, SolverExecutionResponse, VaultSwapActionParams, VaultSwapResponse, LeverageYieldSwapWithdrawParams, ActivateStellarAccountParams, StellarSponsorConfig, SodaxOptions } from '@sodax/sdk';
3
+ import { Result, Sodax, SpokeChainKey, GetEstimateGasReturnType, EstimateGasParams, StellarChainKey, IStellarWalletProvider, INearWalletProvider, GetWalletProviderType, StellarAccountStatus, ActivateStellarAccountResult, IXServiceBase, XToken, EvmHubProvider, IBitcoinWalletProvider, RadfiWalletBalance, IWalletProvider, RadfiUtxo, MoneyMarketBorrowActionParams, TxHashPair, MoneyMarketRepayActionParams, MoneyMarketSupplyActionParams, MoneyMarketWithdrawActionParams, UserReserveData, AggregatedReserveData, BaseCurrencyInfo, ReservesDataHumanized, Address as Address$1, MoneyMarketParams, MoneyMarketApproveActionParams, TxReturnType, Erc20Token, ChainKey, ReserveDataHumanized, FormatReserveUSDResponse, FormatUserSummaryResponse, SolverIntentQuoteRequest, SwapActionParams, SwapResponse, SolverIntentStatusResponse, SolverErrorResponse, Hex, DetailedSwapStatus, DetailedStatusError, CreateIntentParams, CreateLimitOrderParams, Intent, LimitOrderActionParams, IntentResponse, UserIntentsResponse, OrderbookResponse, MoneyMarketPosition, MoneyMarketAsset, MoneyMarketAssetBorrowers, MoneyMarketAssetSuppliers, MoneyMarketBorrowers, OracleMarketsResponse, OracleCandlesResponse, OracleCandleInterval, GetSwapTokensResponseV2, RequestOverrideConfig, GetSwapTokensByChainResponseV2, QuoteResponseV2, QuoteRequestV2, QuoteQueryV2, DeadlineResponseV2, DeadlineQueryV2, AllowanceCheckResponseV2, CreateIntentParamsV2, ApproveResponseV2, RawTxReturnType, CreateIntentResponseV2, SubmitIntentRequestV2, SubmitIntentResponseV2, StatusResponseV2, SwapIntentStatusCodeV2, CancelIntentRequestV2, CancelIntentResponseV2, IntentHashResponseV2, IntentRequestV2, IntentPacketResponseV2, IntentPacketRequestV2, IntentExtraDataResponseV2, IntentExtraDataRequestV2, IntentStateV2, GetIntentResponseV2, CreateLimitOrderParamsV2, CreateLimitOrderResponseV2, GasEstimateResponseV2, GasEstimateRequestV2, FeeResponseV2, SubmitTxRequestV2, SubmitTxResponseV2, SubmitTxStatusResponseV2, BridgeParams, CreateBridgeIntentParams, BridgeLimit, BridgeAllowanceCheckResponseV2, CreateBridgeIntentParamsV2, BridgeApproveResponseV2, BridgeableAmountResponseV2, BridgeQuoteRequestV2, CreateBridgeIntentResponseV2, BridgeFeeResponseV2, BridgeFeeRequestV2, BridgeableCheckResponseV2, BridgeSubmitTxRequestV2, BridgeSubmitTxResponseV2, BridgeSubmitTxStatusResponseV2, GetBridgeTokensResponseV2, GetBridgeTokensByChainResponseV2, StakeAction, StakeParams, UnstakeAction, ClaimAction, CancelUnstakeAction, StakingInfo, UnstakingInfo, UnstakeRequestWithPenalty, StakingConfig, InstantUnstakeAction, UnstakeParams, InstantUnstakeParams, PartnerFeeClaimAssetBalance, AutoSwapPreferences, FeeTokenApproveParams, FeeTokenApproveAction, HubChainKey, SetSwapPreferenceAction, PartnerFeeClaimSwapAction, IntentAutoSwapResult, PartnerFeeClaimCancelAction, GetUserIntentParams, HubAssetBalance, WithdrawHubAssetAction, IcxMigrateAction, IcxRevertMigrationAction, UnifiedBnUSDMigrateAction, BalnMigrateAction, MigrationAction, IcxMigrateParams, IcxCreateRevertMigrationParams, UnifiedBnUSDMigrateParams, BalnMigrateParams, PoolKey, PoolData, ClPositionInfo, AssetDepositAction, AssetWithdrawAction, CreateAssetDepositParams, ClSupplyParams, ClIncreaseLiquidityParams, ClLiquidityDecreaseLiquidityAction, ClDecreaseLiquidityParams, CreateAssetWithdrawParams, PoolSpokeAssets, DestinationParamsType, ClLiquidityClaimRewardsAction, LeverageYieldQuoteParams, LeverageYieldEffectiveApr, LeverageYieldPosition, LeverageYieldSwapDepositParams, LeverageYieldSwapPayload, SolverExecutionRequest, SolverExecutionResponse, VaultSwapActionParams, VaultSwapResponse, LeverageYieldSwapWithdrawParams, ActivateStellarAccountParams, StellarSponsorConfig, SodaxOptions } from '@sodax/sdk';
4
4
  export * from '@sodax/sdk';
5
5
  import { Address } from 'viem';
6
6
  import { ReactNode, ReactElement } from 'react';
@@ -417,6 +417,70 @@ declare function getXBalancesQueryOptions({ xService, xChainId, xTokens, address
417
417
  */
418
418
  declare function useXBalances({ params, queryOptions, }?: UseXBalancesParams): UseQueryResult<Record<string, bigint>>;
419
419
 
420
+ /**
421
+ * Domain inputs for {@link useBalances}. `chainKey` is optional so the hook can be mounted before a
422
+ * chain is selected; `enabled` gates execution on every required field being present.
423
+ *
424
+ * The SDK reads the chain named by `chainKey` and ignores `token.chainKey`, so a token that does
425
+ * not live on that chain reads as `0n` rather than erroring — keep the two in step.
426
+ */
427
+ interface BalancesInputs {
428
+ chainKey: SpokeChainKey | undefined;
429
+ tokens: readonly XToken[];
430
+ address: string | undefined;
431
+ }
432
+ type UseBalancesParams = ReadHookParams<Record<string, bigint>, BalancesInputs>;
433
+ /**
434
+ * Pure builder for {@link useBalances} query options. Exported for unit tests and for advanced
435
+ * callers that compose their own `useQuery` wrapper. Takes the SDK instance explicitly (the hook
436
+ * supplies it from context).
437
+ */
438
+ declare function getBalancesQueryOptions(sodax: Sodax, { chainKey, tokens, address }: BalancesInputs): {
439
+ queryKey: readonly ["shared", "balances", "0xa86a.avax" | "0xa4b1.arbitrum" | "0x2105.base" | "0x38.bsc" | "injective-1" | "sonic" | "0x1.icon" | "sui" | "0xa.optimism" | "0x89.polygon" | "solana" | "stellar" | "hyper" | "lightlink" | "near" | "ethereum" | "bitcoin" | "redbelly" | "0x2019.kaia" | "stacks" | "hedera" | "robinhood" | undefined, (readonly [string, string])[], string | undefined];
440
+ queryFn: () => Promise<Record<string, bigint>>;
441
+ enabled: boolean;
442
+ refetchInterval: number;
443
+ };
444
+ /**
445
+ * Fetch a user's own wallet balances for multiple tokens on a specific chain, straight from the
446
+ * core SDK (`sodax.spoke.getWalletBalances`) — no wallet SDK / `xService` required. Returns an
447
+ * object mapping each token's address to its balance in smallest units.
448
+ *
449
+ * This is the SDK-backed successor to {@link useXBalances} (which wraps a wallet-layer `xService`).
450
+ * Prefer this when the app already has a `SodaxProvider`.
451
+ *
452
+ * Failure model: a token that could not be read is logged by the SDK and reported as `0n`, so a
453
+ * flaky RPC is indistinguishable from an empty wallet — always the conservative direction, since
454
+ * under-reporting blocks a spend rather than permitting one. The query only errors when the whole
455
+ * batch is unusable: a shared round-trip every token depends on, or a batch in which no token
456
+ * could be read at all.
457
+ *
458
+ * Chain-specific notes: Stellar XLM reports the *spendable* amount (total minus the minimum reserve
459
+ * and selling liabilities); Bitcoin returns `0n` for Rune tokens, whose amounts are not exposed by
460
+ * the UTXO endpoint.
461
+ *
462
+ * @example
463
+ * ```tsx
464
+ * const { data: balances } = useBalances({ params: { chainKey, address, tokens } });
465
+ * const usdcBalance = balances?.[usdc.address] ?? 0n;
466
+ * ```
467
+ */
468
+ declare function useBalances({ params, queryOptions }?: UseBalancesParams): UseQueryResult<Record<string, bigint>>;
469
+
470
+ /**
471
+ * Invalidate every wallet-balance query for the given chains.
472
+ *
473
+ * Two balance hooks ship side by side — {@link useBalances} (SDK-backed, keyed under
474
+ * `['shared','balances', …]`) and {@link useXBalances} (wallet-layer, `['shared','xBalances', …]`) —
475
+ * and an app may mount either. React Query matches query keys element-wise, so one key never
476
+ * matches the other; a mutation hook that invalidates only one silently leaves the other stale.
477
+ * Route every post-transaction balance refresh through here so the two cannot drift apart again.
478
+ *
479
+ * `undefined` chain keys are skipped and duplicates collapse, so callers can pass
480
+ * `(src, dst)` without guarding either.
481
+ */
482
+ declare function invalidateBalances(queryClient: QueryClient, ...chainKeys: readonly (SpokeChainKey | undefined)[]): void;
483
+
420
484
  declare function useHubProvider(): EvmHubProvider;
421
485
 
422
486
  type RadfiSession = {
@@ -1049,6 +1113,35 @@ type UseBackendAllMoneyMarketBorrowersParams = ReadHookParams<MoneyMarketBorrowe
1049
1113
  */
1050
1114
  declare const useBackendAllMoneyMarketBorrowers: ({ params, queryOptions, }?: UseBackendAllMoneyMarketBorrowersParams) => UseQueryResult<MoneyMarketBorrowers | undefined>;
1051
1115
 
1116
+ type UseBackendOracleMarketsParams = ReadHookParams<OracleMarketsResponse>;
1117
+ /**
1118
+ * Hook for fetching the oracle candle store's discovery payload (quote currency,
1119
+ * selectable intervals, and covered symbols) from the backend API.
1120
+ *
1121
+ * @example
1122
+ * const { data: markets } = useBackendOracleMarkets();
1123
+ */
1124
+ declare const useBackendOracleMarkets: ({ queryOptions, }?: UseBackendOracleMarketsParams) => UseQueryResult<OracleMarketsResponse, Error>;
1125
+
1126
+ type UseBackendOracleCandlesParams = ReadHookParams<OracleCandlesResponse, {
1127
+ symbol: string;
1128
+ interval: OracleCandleInterval;
1129
+ /** Range start, UNIX seconds, inclusive. */
1130
+ from: number;
1131
+ /** Range end, UNIX seconds, exclusive; the range may cover at most 5000 buckets. */
1132
+ to: number;
1133
+ }>;
1134
+ /**
1135
+ * Hook for fetching USD OHLC candles for a symbol over the half-open range `[from, to)`
1136
+ * from the backend API. Responses are cached server-side for roughly 10 seconds.
1137
+ *
1138
+ * @example
1139
+ * const { data } = useBackendOracleCandles({
1140
+ * params: { symbol: 'ETH', interval: '1h', from: 1756000000, to: 1756360000 },
1141
+ * });
1142
+ */
1143
+ declare const useBackendOracleCandles: ({ params, queryOptions, }?: UseBackendOracleCandlesParams) => UseQueryResult<OracleCandlesResponse, Error>;
1144
+
1052
1145
  type UseSwapsApiTokensParams = ReadHookParams<GetSwapTokensResponseV2, {
1053
1146
  apiConfig?: RequestOverrideConfig;
1054
1147
  }>;
@@ -2885,4 +2978,4 @@ interface NearStorageGateState {
2885
2978
  */
2886
2979
  declare function resolveNearStorageGate(chainKey: SpokeChainKey, check: NearStorageCheckResult): NearStorageGateState;
2887
2980
 
2888
- export { type ATokenData, type ApprovalHashes, type ApprovalPlan, type ApprovalProgress, type ApprovalProgressListener, type BackendPaginationParams, type BitcoinTradingSetup, type BridgeApiApprovalHashes, type CreateSodaxQueryClientOptions, type DecreaseLiquidityParamsCore, type DepositParamsCore, type LeverageYieldShareHolder, type LeverageYieldShareHolding, type MutationHookOptions, type MutationHookParams, type NearStorageCheckResult, type NearStorageGateState, type RadfiSession, type ReadHookParams, type ReadQueryOptions, type ReserveUsdFormat, type SafeUseMutationResult, SodaxProvider, type StellarCheckResult, type StellarGate, type StellarGateInputs, type StellarGateState, type SwapsApiApprovalHashes, type UseATokenParams, type UseATokensBalancesParams, type UseActivateStellarAccountVars, type UseApproveTokenVars, type UseBitcoinBalanceParams, type UseBitcoinTradingSetupParams, type UseBorrowVars, type UseBridgeAllowanceParams, type UseBridgeApiAllowanceParams, type UseBridgeApiApproveAndBroadcastVars, type UseBridgeApiApproveVars, type UseBridgeApiBridgeableAmountParams, type UseBridgeApiCreateBridgeIntentVars, type UseBridgeApiFeeParams, type UseBridgeApiIsBridgeableParams, type UseBridgeApiSubmitTxStatusParams, type UseBridgeApiSubmitTxVars, type UseBridgeApiTokensByChainParams, type UseBridgeApiTokensParams, type UseBridgeApproveVars, type UseBridgeVars, type UseClaimRewardsVars, type UseCreateDecreaseLiquidityParamsProps, type UseCreateDepositParamsProps, type UseCreateLimitOrderVars, type UseCreateSupplyLiquidityParamsProps, type UseCreateSupplyLiquidityParamsResult, type UseCreateWithdrawParamsProps, type UseDecreaseLiquidityVars, type UseDeriveUserWalletAddressParams, type UseDetailedStatusParams, type UseDetailedStatusResult, type UseDexAllowanceParams, type UseDexApproveVars, type UseDexDepositVars, type UseDexWithdrawVars, type UseEnsureRadfiAccessTokenVars, type UseEstablishTrustlineVars, type UseExpiredUtxosParams, type UseFeeClaimSwapVars, type UseFeeClaimWithdrawVars, type UseFetchAssetsBalancesParams, type UseFundTradingWalletVars, type UseGetAutoSwapPreferencesParams, type UseGetBridgeableAmountParams, type UseGetBridgeableTokensParams, type UseGetIntentDetailsParams, type UseGetUserHubWalletAddressParams, type UseGetUserIntentParams, type UseHubAssetBalancesParams, type UseIsTokenApprovedParams, type UseLeverageYieldDepositVars, type UseLeverageYieldEffectiveAprParams, type UseLeverageYieldNotifySolverVars, type UseLeverageYieldPositionParams, type UseLeverageYieldPreviewRedeemParams, type UseLeverageYieldQuoteParams, type UseLeverageYieldShareBalancesParams, type UseLeverageYieldTotalAssetsParams, type UseLeverageYieldVaultSwapVars, type UseLeverageYieldWithdrawVars, type UseLiquidityAmountsResult, type UseMMAllowanceParams, type UseMMApproveVars, type UseMigrateBalnVars, type UseMigrateIcxToSodaVars, type UseMigratebnUSDVars, type UseMigrationAllowanceInputs, type UseMigrationAllowanceParams, type UseMigrationApproveVars, type UseNearStorageCheckParams, type UsePartnerCancelIntentVars, type UsePoolBalancesParams, type UsePoolBalancesResponse, type UsePoolDataParams, type UsePoolsParams, type UsePositionInfoParams, type UsePositionInfoResponse, type UseQuoteParams, type UseRadfiAuthVars, type UseRadfiSessionReturn, type UseRadfiWithdrawVars, type UseRegisterNearStorageVars, type UseRenewUtxosVars, type UseRepayVars, type UseReservesDataParams, type UseReservesHumanizedParams, type UseReservesListParams, type UseReservesUsdFormatParams, type UseRevertMigrateSodaToIcxVars, type UseSetSwapPreferenceVars, type UseSetSwapPreferenceVarsHub, type UseSponsorConfigParams, type UseStatusParams, type UseStellarAccountActiveParams, type UseStellarAccountStatusParams, type UseStellarGateParams, type UseStellarTrustlineCheckParams, type UseSupplyLiquidityVars, type UseSupplyVars, type UseSwapAllowanceParams, type UseSwapApproveVars, type UseSwapVars, type UseSwapsApiAllowanceParams, type UseSwapsApiApproveAndBroadcastVars, type UseSwapsApiApproveVars, type UseSwapsApiCancelIntentVars, type UseSwapsApiCreateIntentVars, type UseSwapsApiCreateLimitOrderVars, type UseSwapsApiDeadlineParams, type UseSwapsApiEstimateGasParams, type UseSwapsApiFilledIntentParams, type UseSwapsApiIntentExtraDataParams, type UseSwapsApiIntentHashParams, type UseSwapsApiIntentPacketParams, type UseSwapsApiIntentParams, type UseSwapsApiPartnerFeeParams, type UseSwapsApiQuoteParams, type UseSwapsApiSolverFeeParams, type UseSwapsApiStatusParams, type UseSwapsApiSubmitIntentVars, type UseSwapsApiSubmitTxStatusParams, type UseSwapsApiSubmitTxVars, type UseSwapsApiTokensByChainParams, type UseSwapsApiTokensParams, type UseTradingWalletBalanceParams, type UseUserFormattedSummaryParams, type UseUserReservesDataParams, type UseWithdrawHubAssetVars, type UseWithdrawVars, type UseXBalancesParams, type WithdrawParamsCore, type XBalancesInputs, clearRadfiSession, createDecreaseLiquidityParamsProps, createDepositParamsProps, createSodaxQueryClient, createSupplyLiquidityParamsProps, createWithdrawParamsProps, getLeverageYieldQuoteQueryOptions, getSponsorConfigQueryOptions, getStellarAccountActiveQueryOptions, getStellarAccountStatusQueryOptions, getStellarTrustlineCheckQueryOptions, getSwapQuoteQueryOptions, getXBalancesQueryOptions, isTerminalSwapIntentStatus, isUserRejectedError, loadRadfiSession, resolveNearStorageGate, resolveStellarGate, retryUnlessAuthFailure, runApprovalPlan, saveRadfiSession, toResult, unwrapResult, useAToken, useATokensBalances, useActivateStellarAccount, useApproveToken, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOrderbook, useBackendUserIntents, useBitcoinBalance, useBitcoinTradingSetup, useBorrow, useBridge, useBridgeAllowance, useBridgeApiAllowance, useBridgeApiApprove, useBridgeApiApproveAndBroadcast, useBridgeApiBridgeableAmount, useBridgeApiCreateBridgeIntent, useBridgeApiFee, useBridgeApiIsBridgeable, useBridgeApiSubmitTx, useBridgeApiSubmitTxStatus, useBridgeApiTokens, useBridgeApiTokensByChain, useBridgeApprove, useCancelLimitOrder, useCancelSwap, useCancelUnstake, useClaim, useClaimRewards, useConvertedAssets, useCreateDecreaseLiquidityParams, useCreateDepositParams, useCreateLimitOrder, useCreateSupplyLiquidityParams, useCreateWithdrawParams, useDecreaseLiquidity, useDeriveUserWalletAddress, useDetailedStatus, useDexAllowance, useDexApprove, useDexDeposit, useDexWithdraw, useEnsureRadfiAccessToken, useEstablishTrustline, useEstimateGas, useExpiredUtxos, useFeeClaimSwap, useFeeClaimWithdraw, useFetchAssetsBalances, useFundTradingWallet, useGetAutoSwapPreferences, useGetBridgeableAmount, useGetBridgeableTokens, useGetIntentDetails, useGetUserHubWalletAddress, useGetUserIntent, useHubAssetBalances, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useIsTokenApproved, useLeverageYieldDeposit, useLeverageYieldEffectiveApr, useLeverageYieldNotifySolver, useLeverageYieldPosition, useLeverageYieldPreviewRedeem, useLeverageYieldQuote, useLeverageYieldShareBalances, useLeverageYieldTotalAssets, useLeverageYieldVaultSwap, useLeverageYieldWithdraw, useLiquidityAmounts, useMMAllowance, useMMApprove, useMigrateBaln, useMigrateIcxToSoda, useMigratebnUSD, useMigrationAllowance, useMigrationApprove, useNearStorageCheck, useNearStorageGate, usePartnerCancelIntent, usePoolBalances, usePoolData, usePools, usePositionInfo, useQuote, useRadfiAuth, useRadfiSession, useRadfiWithdraw, useRegisterNearStorage, useRenewUtxos, useRepay, useRequestTrustline, useReservesData, useReservesHumanized, useReservesList, useReservesUsdFormat, useRevertMigrateSodaToIcx, useSafeMutation, useSetSwapPreference, useSodaxContext, useSponsorConfig, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarAccountActive, useStellarAccountStatus, useStellarGate, useStellarTrustlineCheck, useSupply, useSupplyLiquidity, useSwap, useSwapAllowance, useSwapApprove, useSwapsApiAllowance, useSwapsApiApprove, useSwapsApiApproveAndBroadcast, useSwapsApiCancelIntent, useSwapsApiCreateIntent, useSwapsApiCreateLimitOrder, useSwapsApiDeadline, useSwapsApiEstimateGas, useSwapsApiFilledIntent, useSwapsApiIntent, useSwapsApiIntentExtraData, useSwapsApiIntentHash, useSwapsApiIntentPacket, useSwapsApiPartnerFee, useSwapsApiQuote, useSwapsApiSolverFee, useSwapsApiStatus, useSwapsApiSubmitIntent, useSwapsApiSubmitTx, useSwapsApiSubmitTxStatus, useSwapsApiTokens, useSwapsApiTokensByChain, useTradingWallet, useTradingWalletBalance, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserFormattedSummary, useUserReservesData, useWithdraw, useWithdrawHubAsset, useXBalances };
2981
+ export { type ATokenData, type ApprovalHashes, type ApprovalPlan, type ApprovalProgress, type ApprovalProgressListener, type BackendPaginationParams, type BalancesInputs, type BitcoinTradingSetup, type BridgeApiApprovalHashes, type CreateSodaxQueryClientOptions, type DecreaseLiquidityParamsCore, type DepositParamsCore, type LeverageYieldShareHolder, type LeverageYieldShareHolding, type MutationHookOptions, type MutationHookParams, type NearStorageCheckResult, type NearStorageGateState, type RadfiSession, type ReadHookParams, type ReadQueryOptions, type ReserveUsdFormat, type SafeUseMutationResult, SodaxProvider, type StellarCheckResult, type StellarGate, type StellarGateInputs, type StellarGateState, type SwapsApiApprovalHashes, type UseATokenParams, type UseATokensBalancesParams, type UseActivateStellarAccountVars, type UseApproveTokenVars, type UseBalancesParams, type UseBitcoinBalanceParams, type UseBitcoinTradingSetupParams, type UseBorrowVars, type UseBridgeAllowanceParams, type UseBridgeApiAllowanceParams, type UseBridgeApiApproveAndBroadcastVars, type UseBridgeApiApproveVars, type UseBridgeApiBridgeableAmountParams, type UseBridgeApiCreateBridgeIntentVars, type UseBridgeApiFeeParams, type UseBridgeApiIsBridgeableParams, type UseBridgeApiSubmitTxStatusParams, type UseBridgeApiSubmitTxVars, type UseBridgeApiTokensByChainParams, type UseBridgeApiTokensParams, type UseBridgeApproveVars, type UseBridgeVars, type UseClaimRewardsVars, type UseCreateDecreaseLiquidityParamsProps, type UseCreateDepositParamsProps, type UseCreateLimitOrderVars, type UseCreateSupplyLiquidityParamsProps, type UseCreateSupplyLiquidityParamsResult, type UseCreateWithdrawParamsProps, type UseDecreaseLiquidityVars, type UseDeriveUserWalletAddressParams, type UseDetailedStatusParams, type UseDetailedStatusResult, type UseDexAllowanceParams, type UseDexApproveVars, type UseDexDepositVars, type UseDexWithdrawVars, type UseEnsureRadfiAccessTokenVars, type UseEstablishTrustlineVars, type UseExpiredUtxosParams, type UseFeeClaimSwapVars, type UseFeeClaimWithdrawVars, type UseFetchAssetsBalancesParams, type UseFundTradingWalletVars, type UseGetAutoSwapPreferencesParams, type UseGetBridgeableAmountParams, type UseGetBridgeableTokensParams, type UseGetIntentDetailsParams, type UseGetUserHubWalletAddressParams, type UseGetUserIntentParams, type UseHubAssetBalancesParams, type UseIsTokenApprovedParams, type UseLeverageYieldDepositVars, type UseLeverageYieldEffectiveAprParams, type UseLeverageYieldNotifySolverVars, type UseLeverageYieldPositionParams, type UseLeverageYieldPreviewRedeemParams, type UseLeverageYieldQuoteParams, type UseLeverageYieldShareBalancesParams, type UseLeverageYieldTotalAssetsParams, type UseLeverageYieldVaultSwapVars, type UseLeverageYieldWithdrawVars, type UseLiquidityAmountsResult, type UseMMAllowanceParams, type UseMMApproveVars, type UseMigrateBalnVars, type UseMigrateIcxToSodaVars, type UseMigratebnUSDVars, type UseMigrationAllowanceInputs, type UseMigrationAllowanceParams, type UseMigrationApproveVars, type UseNearStorageCheckParams, type UsePartnerCancelIntentVars, type UsePoolBalancesParams, type UsePoolBalancesResponse, type UsePoolDataParams, type UsePoolsParams, type UsePositionInfoParams, type UsePositionInfoResponse, type UseQuoteParams, type UseRadfiAuthVars, type UseRadfiSessionReturn, type UseRadfiWithdrawVars, type UseRegisterNearStorageVars, type UseRenewUtxosVars, type UseRepayVars, type UseReservesDataParams, type UseReservesHumanizedParams, type UseReservesListParams, type UseReservesUsdFormatParams, type UseRevertMigrateSodaToIcxVars, type UseSetSwapPreferenceVars, type UseSetSwapPreferenceVarsHub, type UseSponsorConfigParams, type UseStatusParams, type UseStellarAccountActiveParams, type UseStellarAccountStatusParams, type UseStellarGateParams, type UseStellarTrustlineCheckParams, type UseSupplyLiquidityVars, type UseSupplyVars, type UseSwapAllowanceParams, type UseSwapApproveVars, type UseSwapVars, type UseSwapsApiAllowanceParams, type UseSwapsApiApproveAndBroadcastVars, type UseSwapsApiApproveVars, type UseSwapsApiCancelIntentVars, type UseSwapsApiCreateIntentVars, type UseSwapsApiCreateLimitOrderVars, type UseSwapsApiDeadlineParams, type UseSwapsApiEstimateGasParams, type UseSwapsApiFilledIntentParams, type UseSwapsApiIntentExtraDataParams, type UseSwapsApiIntentHashParams, type UseSwapsApiIntentPacketParams, type UseSwapsApiIntentParams, type UseSwapsApiPartnerFeeParams, type UseSwapsApiQuoteParams, type UseSwapsApiSolverFeeParams, type UseSwapsApiStatusParams, type UseSwapsApiSubmitIntentVars, type UseSwapsApiSubmitTxStatusParams, type UseSwapsApiSubmitTxVars, type UseSwapsApiTokensByChainParams, type UseSwapsApiTokensParams, type UseTradingWalletBalanceParams, type UseUserFormattedSummaryParams, type UseUserReservesDataParams, type UseWithdrawHubAssetVars, type UseWithdrawVars, type UseXBalancesParams, type WithdrawParamsCore, type XBalancesInputs, clearRadfiSession, createDecreaseLiquidityParamsProps, createDepositParamsProps, createSodaxQueryClient, createSupplyLiquidityParamsProps, createWithdrawParamsProps, getBalancesQueryOptions, getLeverageYieldQuoteQueryOptions, getSponsorConfigQueryOptions, getStellarAccountActiveQueryOptions, getStellarAccountStatusQueryOptions, getStellarTrustlineCheckQueryOptions, getSwapQuoteQueryOptions, getXBalancesQueryOptions, invalidateBalances, isTerminalSwapIntentStatus, isUserRejectedError, loadRadfiSession, resolveNearStorageGate, resolveStellarGate, retryUnlessAuthFailure, runApprovalPlan, saveRadfiSession, toResult, unwrapResult, useAToken, useATokensBalances, useActivateStellarAccount, useApproveToken, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOracleCandles, useBackendOracleMarkets, useBackendOrderbook, useBackendUserIntents, useBalances, useBitcoinBalance, useBitcoinTradingSetup, useBorrow, useBridge, useBridgeAllowance, useBridgeApiAllowance, useBridgeApiApprove, useBridgeApiApproveAndBroadcast, useBridgeApiBridgeableAmount, useBridgeApiCreateBridgeIntent, useBridgeApiFee, useBridgeApiIsBridgeable, useBridgeApiSubmitTx, useBridgeApiSubmitTxStatus, useBridgeApiTokens, useBridgeApiTokensByChain, useBridgeApprove, useCancelLimitOrder, useCancelSwap, useCancelUnstake, useClaim, useClaimRewards, useConvertedAssets, useCreateDecreaseLiquidityParams, useCreateDepositParams, useCreateLimitOrder, useCreateSupplyLiquidityParams, useCreateWithdrawParams, useDecreaseLiquidity, useDeriveUserWalletAddress, useDetailedStatus, useDexAllowance, useDexApprove, useDexDeposit, useDexWithdraw, useEnsureRadfiAccessToken, useEstablishTrustline, useEstimateGas, useExpiredUtxos, useFeeClaimSwap, useFeeClaimWithdraw, useFetchAssetsBalances, useFundTradingWallet, useGetAutoSwapPreferences, useGetBridgeableAmount, useGetBridgeableTokens, useGetIntentDetails, useGetUserHubWalletAddress, useGetUserIntent, useHubAssetBalances, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useIsTokenApproved, useLeverageYieldDeposit, useLeverageYieldEffectiveApr, useLeverageYieldNotifySolver, useLeverageYieldPosition, useLeverageYieldPreviewRedeem, useLeverageYieldQuote, useLeverageYieldShareBalances, useLeverageYieldTotalAssets, useLeverageYieldVaultSwap, useLeverageYieldWithdraw, useLiquidityAmounts, useMMAllowance, useMMApprove, useMigrateBaln, useMigrateIcxToSoda, useMigratebnUSD, useMigrationAllowance, useMigrationApprove, useNearStorageCheck, useNearStorageGate, usePartnerCancelIntent, usePoolBalances, usePoolData, usePools, usePositionInfo, useQuote, useRadfiAuth, useRadfiSession, useRadfiWithdraw, useRegisterNearStorage, useRenewUtxos, useRepay, useRequestTrustline, useReservesData, useReservesHumanized, useReservesList, useReservesUsdFormat, useRevertMigrateSodaToIcx, useSafeMutation, useSetSwapPreference, useSodaxContext, useSponsorConfig, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarAccountActive, useStellarAccountStatus, useStellarGate, useStellarTrustlineCheck, useSupply, useSupplyLiquidity, useSwap, useSwapAllowance, useSwapApprove, useSwapsApiAllowance, useSwapsApiApprove, useSwapsApiApproveAndBroadcast, useSwapsApiCancelIntent, useSwapsApiCreateIntent, useSwapsApiCreateLimitOrder, useSwapsApiDeadline, useSwapsApiEstimateGas, useSwapsApiFilledIntent, useSwapsApiIntent, useSwapsApiIntentExtraData, useSwapsApiIntentHash, useSwapsApiIntentPacket, useSwapsApiPartnerFee, useSwapsApiQuote, useSwapsApiSolverFee, useSwapsApiStatus, useSwapsApiSubmitIntent, useSwapsApiSubmitTx, useSwapsApiSubmitTxStatus, useSwapsApiTokens, useSwapsApiTokensByChain, useTradingWallet, useTradingWalletBalance, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserFormattedSummary, useUserReservesData, useWithdraw, useWithdrawHubAsset, useXBalances };
package/dist/index.mjs CHANGED
@@ -113,6 +113,17 @@ function useStellarTrustlineCheck({
113
113
  ...queryOptions
114
114
  });
115
115
  }
116
+
117
+ // src/hooks/shared/invalidateBalances.ts
118
+ function invalidateBalances(queryClient, ...chainKeys) {
119
+ for (const chainKey of new Set(chainKeys)) {
120
+ if (!chainKey) continue;
121
+ queryClient.invalidateQueries({ queryKey: ["shared", "balances", chainKey] });
122
+ queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", chainKey] });
123
+ }
124
+ }
125
+
126
+ // src/hooks/shared/useEstablishTrustline.ts
116
127
  function useEstablishTrustline({
117
128
  mutationOptions
118
129
  } = {}) {
@@ -143,7 +154,7 @@ function useEstablishTrustline({
143
154
  queryClient.invalidateQueries({
144
155
  queryKey: srcAddress ? ["sponsoring", "stellarAccountStatus", srcAddress] : ["sponsoring", "stellarAccountStatus"]
145
156
  });
146
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", ChainKeys.STELLAR_MAINNET] });
157
+ invalidateBalances(queryClient, ChainKeys.STELLAR_MAINNET);
147
158
  await mutationOptions?.onSuccess?.(data, vars, ctx);
148
159
  }
149
160
  });
@@ -288,7 +299,7 @@ function useActivateStellarAccount({
288
299
  queryClient.invalidateQueries({ queryKey: ["sponsoring", "stellarAccountActive", vars.address] });
289
300
  queryClient.invalidateQueries({ queryKey: ["sponsoring", "stellarAccountStatus", vars.address] });
290
301
  queryClient.invalidateQueries({ queryKey: ["shared", "stellarTrustlineCheck"] });
291
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", ChainKeys.STELLAR_MAINNET] });
302
+ invalidateBalances(queryClient, ChainKeys.STELLAR_MAINNET);
292
303
  await mutationOptions?.onSuccess?.(data, vars, ctx);
293
304
  }
294
305
  });
@@ -504,6 +515,34 @@ function useXBalances({
504
515
  ...queryOptions
505
516
  });
506
517
  }
518
+ var REFETCH_INTERVAL_MS2 = 5e3;
519
+ function getBalancesQueryOptions(sodax, { chainKey, tokens, address }) {
520
+ return {
521
+ // Pair symbol + address: readable in devtools, unique on-chain (symbol alone can collide —
522
+ // e.g. scam tokens copying a legitimate ticker).
523
+ queryKey: ["shared", "balances", chainKey, tokens.map((t) => [t.symbol, t.address]), address],
524
+ queryFn: async () => {
525
+ if (!chainKey || !address) return {};
526
+ return unwrapResult(await sodax.spoke.getWalletBalances({ srcChainKey: chainKey, srcAddress: address, tokens }));
527
+ },
528
+ enabled: !!chainKey && !!address && tokens.length > 0,
529
+ refetchInterval: REFETCH_INTERVAL_MS2
530
+ // Deliberately NOT `placeholderData: keepPreviousData`: the query key carries the chain, so a
531
+ // chain switch would surface the previous chain's map — and every EVM chain shares the native
532
+ // token address, so its native balance would render as the new chain's until the fetch lands.
533
+ };
534
+ }
535
+ function useBalances({ params, queryOptions } = {}) {
536
+ const { sodax } = useSodaxContext();
537
+ return useQuery({
538
+ ...getBalancesQueryOptions(sodax, {
539
+ chainKey: params?.chainKey,
540
+ tokens: params?.tokens ?? [],
541
+ address: params?.address
542
+ }),
543
+ ...queryOptions
544
+ });
545
+ }
507
546
 
508
547
  // src/hooks/provider/useHubProvider.ts
509
548
  function useHubProvider() {
@@ -622,7 +661,7 @@ function useFundTradingWallet({
622
661
  onSuccess: async (data, vars, ctx) => {
623
662
  queryClient.invalidateQueries({ queryKey: ["bitcoin", "balance"] });
624
663
  queryClient.invalidateQueries({ queryKey: ["bitcoin", "tradingWalletBalance"] });
625
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", ChainKeys.BITCOIN_MAINNET] });
664
+ invalidateBalances(queryClient, ChainKeys.BITCOIN_MAINNET);
626
665
  await mutationOptions?.onSuccess?.(data, vars, ctx);
627
666
  }
628
667
  });
@@ -760,7 +799,7 @@ function useRadfiWithdraw({
760
799
  onSuccess: async (data, vars, ctx) => {
761
800
  queryClient.invalidateQueries({ queryKey: ["bitcoin", "tradingWalletBalance"] });
762
801
  queryClient.invalidateQueries({ queryKey: ["bitcoin", "balance"] });
763
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", ChainKeys.BITCOIN_MAINNET] });
802
+ invalidateBalances(queryClient, ChainKeys.BITCOIN_MAINNET);
764
803
  await mutationOptions?.onSuccess?.(data, vars, ctx);
765
804
  }
766
805
  });
@@ -781,10 +820,7 @@ function useBorrow({
781
820
  queryKey: ["mm", "userFormattedSummary", params.srcChainKey, params.srcAddress]
782
821
  });
783
822
  queryClient.invalidateQueries({ queryKey: ["mm", "aTokensBalances"] });
784
- const balanceChains = /* @__PURE__ */ new Set([params.srcChainKey, params.dstChainKey ?? params.srcChainKey]);
785
- for (const chainKey of balanceChains) {
786
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", chainKey] });
787
- }
823
+ invalidateBalances(queryClient, params.srcChainKey, params.dstChainKey);
788
824
  await mutationOptions?.onSuccess?.(data, vars, ctx);
789
825
  }
790
826
  });
@@ -806,7 +842,7 @@ function useRepay({
806
842
  });
807
843
  queryClient.invalidateQueries({ queryKey: ["mm", "aTokensBalances"] });
808
844
  queryClient.invalidateQueries({ queryKey: ["mm", "allowance", params.srcChainKey, params.token, params.action] });
809
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.srcChainKey] });
845
+ invalidateBalances(queryClient, params.srcChainKey);
810
846
  await mutationOptions?.onSuccess?.(data, vars, ctx);
811
847
  }
812
848
  });
@@ -828,7 +864,7 @@ function useSupply({
828
864
  });
829
865
  queryClient.invalidateQueries({ queryKey: ["mm", "aTokensBalances"] });
830
866
  queryClient.invalidateQueries({ queryKey: ["mm", "allowance", params.srcChainKey, params.token, params.action] });
831
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.srcChainKey] });
867
+ invalidateBalances(queryClient, params.srcChainKey);
832
868
  await mutationOptions?.onSuccess?.(data, vars, ctx);
833
869
  }
834
870
  });
@@ -849,10 +885,7 @@ function useWithdraw({
849
885
  queryKey: ["mm", "userFormattedSummary", params.srcChainKey, params.srcAddress]
850
886
  });
851
887
  queryClient.invalidateQueries({ queryKey: ["mm", "aTokensBalances"] });
852
- const balanceChains = /* @__PURE__ */ new Set([params.srcChainKey, params.dstChainKey ?? params.srcChainKey]);
853
- for (const chainKey of balanceChains) {
854
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", chainKey] });
855
- }
888
+ invalidateBalances(queryClient, params.srcChainKey, params.dstChainKey);
856
889
  await mutationOptions?.onSuccess?.(data, vars, ctx);
857
890
  }
858
891
  });
@@ -1103,8 +1136,7 @@ function useSwap({
1103
1136
  ...mutationOptions,
1104
1137
  mutationFn: async (vars) => unwrapResult(await sodax.swaps.swap({ ...vars, raw: false })),
1105
1138
  onSuccess: async (data, vars, ctx) => {
1106
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", vars.params.srcChainKey] });
1107
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", vars.params.dstChainKey] });
1139
+ invalidateBalances(queryClient, vars.params.srcChainKey, vars.params.dstChainKey);
1108
1140
  await mutationOptions?.onSuccess?.(data, vars, ctx);
1109
1141
  }
1110
1142
  });
@@ -1502,6 +1534,39 @@ var useBackendAllMoneyMarketBorrowers = ({
1502
1534
  ...queryOptions
1503
1535
  });
1504
1536
  };
1537
+ var useBackendOracleMarkets = ({
1538
+ queryOptions
1539
+ } = {}) => {
1540
+ const { sodax } = useSodaxContext();
1541
+ return useQuery({
1542
+ queryKey: ["backend", "oracle", "markets"],
1543
+ queryFn: async () => {
1544
+ return unwrapResult(await sodax.backendApi.getOracleMarkets());
1545
+ },
1546
+ staleTime: 60 * 1e3,
1547
+ retry: 3,
1548
+ ...queryOptions
1549
+ });
1550
+ };
1551
+ var useBackendOracleCandles = ({
1552
+ params,
1553
+ queryOptions
1554
+ } = {}) => {
1555
+ const { sodax } = useSodaxContext();
1556
+ return useQuery({
1557
+ queryKey: ["backend", "oracle", "candles", params?.symbol, params?.interval, params?.from, params?.to],
1558
+ queryFn: async () => {
1559
+ if (!params) {
1560
+ throw new Error("symbol, interval, from and to are required");
1561
+ }
1562
+ return unwrapResult(await sodax.backendApi.getOracleCandles(params));
1563
+ },
1564
+ enabled: !!params?.symbol && !!params?.interval && params?.from != null && params?.to != null,
1565
+ staleTime: 10 * 1e3,
1566
+ retry: 3,
1567
+ ...queryOptions
1568
+ });
1569
+ };
1505
1570
  var useSwapsApiTokens = ({
1506
1571
  params,
1507
1572
  queryOptions
@@ -1972,8 +2037,7 @@ function useBridge({
1972
2037
  ...mutationOptions,
1973
2038
  mutationFn: async (vars) => unwrapResult(await sodax.bridge.bridge({ ...vars, raw: false })),
1974
2039
  onSuccess: async (data, vars, ctx) => {
1975
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", vars.params.srcChainKey] });
1976
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", vars.params.dstChainKey] });
2040
+ invalidateBalances(queryClient, vars.params.srcChainKey, vars.params.dstChainKey);
1977
2041
  await mutationOptions?.onSuccess?.(data, vars, ctx);
1978
2042
  }
1979
2043
  });
@@ -2280,7 +2344,7 @@ function useStake({
2280
2344
  queryClient.invalidateQueries({ queryKey: ["staking", "allowance", params.srcChainKey, "stake"] });
2281
2345
  queryClient.invalidateQueries({ queryKey: ["staking", "stakeRatio"] });
2282
2346
  queryClient.invalidateQueries({ queryKey: ["staking", "convertedAssets"] });
2283
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.srcChainKey] });
2347
+ invalidateBalances(queryClient, params.srcChainKey);
2284
2348
  await mutationOptions?.onSuccess?.(data, vars, ctx);
2285
2349
  }
2286
2350
  });
@@ -2367,7 +2431,7 @@ function useClaim({
2367
2431
  queryClient.invalidateQueries({
2368
2432
  queryKey: ["staking", "unstakingInfoWithPenalty", params.srcChainKey, params.srcAddress]
2369
2433
  });
2370
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.srcChainKey] });
2434
+ invalidateBalances(queryClient, params.srcChainKey);
2371
2435
  await mutationOptions?.onSuccess?.(data, vars, ctx);
2372
2436
  }
2373
2437
  });
@@ -2526,7 +2590,7 @@ function useInstantUnstake({
2526
2590
  queryClient.invalidateQueries({ queryKey: ["staking", "info", params.srcChainKey, params.srcAddress] });
2527
2591
  queryClient.invalidateQueries({ queryKey: ["staking", "instantUnstakeRatio"] });
2528
2592
  queryClient.invalidateQueries({ queryKey: ["staking", "allowance", params.srcChainKey, "instantUnstake"] });
2529
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.srcChainKey] });
2593
+ invalidateBalances(queryClient, params.srcChainKey);
2530
2594
  await mutationOptions?.onSuccess?.(data, vars, ctx);
2531
2595
  }
2532
2596
  });
@@ -2871,7 +2935,7 @@ function useFeeClaimWithdraw({
2871
2935
  queryClient.invalidateQueries({
2872
2936
  queryKey: ["partner", "feeClaim", "assetsBalances", vars.params.srcAddress]
2873
2937
  });
2874
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", vars.params.dstChainKey] });
2938
+ invalidateBalances(queryClient, vars.params.dstChainKey);
2875
2939
  await mutationOptions?.onSuccess?.(data, vars, ctx);
2876
2940
  }
2877
2941
  });
@@ -2912,7 +2976,7 @@ function useWithdrawHubAsset({
2912
2976
  queryClient.invalidateQueries({
2913
2977
  queryKey: ["recovery", "hubAssetBalances", params.srcChainKey, params.srcAddress]
2914
2978
  });
2915
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.srcChainKey] });
2979
+ invalidateBalances(queryClient, params.srcChainKey);
2916
2980
  await mutationOptions?.onSuccess?.(data, vars, ctx);
2917
2981
  }
2918
2982
  });
@@ -2928,8 +2992,7 @@ function useMigrateIcxToSoda({
2928
2992
  mutationFn: async (vars) => unwrapResult(await sodax.migration.migrateIcxToSoda({ ...vars, raw: false })),
2929
2993
  onSuccess: async (data, vars, ctx) => {
2930
2994
  queryClient.invalidateQueries({ queryKey: ["migrate", "allowance"] });
2931
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", vars.params.srcChainKey] });
2932
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", ChainKeys.SONIC_MAINNET] });
2995
+ invalidateBalances(queryClient, vars.params.srcChainKey, ChainKeys.SONIC_MAINNET);
2933
2996
  await mutationOptions?.onSuccess?.(data, vars, ctx);
2934
2997
  }
2935
2998
  });
@@ -2945,8 +3008,7 @@ function useRevertMigrateSodaToIcx({
2945
3008
  mutationFn: async (vars) => unwrapResult(await sodax.migration.revertMigrateSodaToIcx({ ...vars, raw: false })),
2946
3009
  onSuccess: async (data, vars, ctx) => {
2947
3010
  queryClient.invalidateQueries({ queryKey: ["migrate", "allowance"] });
2948
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", vars.params.srcChainKey] });
2949
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", ChainKeys.ICON_MAINNET] });
3011
+ invalidateBalances(queryClient, vars.params.srcChainKey, ChainKeys.ICON_MAINNET);
2950
3012
  await mutationOptions?.onSuccess?.(data, vars, ctx);
2951
3013
  }
2952
3014
  });
@@ -2963,8 +3025,7 @@ function useMigratebnUSD({
2963
3025
  onSuccess: async (data, vars, ctx) => {
2964
3026
  const { params } = vars;
2965
3027
  queryClient.invalidateQueries({ queryKey: ["migrate", "allowance"] });
2966
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.srcChainKey] });
2967
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.dstChainKey] });
3028
+ invalidateBalances(queryClient, params.srcChainKey, params.dstChainKey);
2968
3029
  await mutationOptions?.onSuccess?.(data, vars, ctx);
2969
3030
  }
2970
3031
  });
@@ -2980,8 +3041,7 @@ function useMigrateBaln({
2980
3041
  mutationFn: async (vars) => unwrapResult(await sodax.migration.migrateBaln({ ...vars, raw: false })),
2981
3042
  onSuccess: async (data, vars, ctx) => {
2982
3043
  queryClient.invalidateQueries({ queryKey: ["migrate", "allowance"] });
2983
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", ChainKeys.ICON_MAINNET] });
2984
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", ChainKeys.SONIC_MAINNET] });
3044
+ invalidateBalances(queryClient, ChainKeys.ICON_MAINNET, ChainKeys.SONIC_MAINNET);
2985
3045
  queryClient.invalidateQueries({ queryKey: ["staking", "info"] });
2986
3046
  await mutationOptions?.onSuccess?.(data, vars, ctx);
2987
3047
  }
@@ -3007,7 +3067,7 @@ function useMigrationApprove({
3007
3067
  }
3008
3068
  });
3009
3069
  }
3010
- var REFETCH_INTERVAL_MS2 = 2e3;
3070
+ var REFETCH_INTERVAL_MS3 = 2e3;
3011
3071
  function useMigrationAllowance({
3012
3072
  params,
3013
3073
  queryOptions
@@ -3033,7 +3093,7 @@ function useMigrationAllowance({
3033
3093
  return result.ok ? result.value : false;
3034
3094
  },
3035
3095
  enabled: !!migrationParams && !!action,
3036
- refetchInterval: REFETCH_INTERVAL_MS2,
3096
+ refetchInterval: REFETCH_INTERVAL_MS3,
3037
3097
  ...queryOptions
3038
3098
  });
3039
3099
  }
@@ -3142,7 +3202,7 @@ function useDexDeposit({
3142
3202
  queryClient.invalidateQueries({
3143
3203
  queryKey: ["dex", "allowance", params.srcChainKey, params.asset, params.amount.toString()]
3144
3204
  });
3145
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.srcChainKey] });
3205
+ invalidateBalances(queryClient, params.srcChainKey);
3146
3206
  await mutationOptions?.onSuccess?.(data, vars, ctx);
3147
3207
  }
3148
3208
  });
@@ -3159,7 +3219,7 @@ function useDexWithdraw({
3159
3219
  onSuccess: async (data, vars, ctx) => {
3160
3220
  const { params } = vars;
3161
3221
  queryClient.invalidateQueries({ queryKey: ["dex", "poolBalances", params.srcChainKey, params.srcAddress] });
3162
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.srcChainKey] });
3222
+ invalidateBalances(queryClient, params.srcChainKey);
3163
3223
  await mutationOptions?.onSuccess?.(data, vars, ctx);
3164
3224
  }
3165
3225
  });
@@ -3346,7 +3406,7 @@ function useSupplyLiquidity({
3346
3406
  }
3347
3407
  queryClient.invalidateQueries({ queryKey: ["dex", "poolData", params.poolKey] });
3348
3408
  queryClient.invalidateQueries({ queryKey: ["dex", "poolBalances", params.srcChainKey, params.srcAddress] });
3349
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.srcChainKey] });
3409
+ invalidateBalances(queryClient, params.srcChainKey);
3350
3410
  await mutationOptions?.onSuccess?.(data, vars, ctx);
3351
3411
  }
3352
3412
  });
@@ -3769,8 +3829,7 @@ function useLeverageYieldVaultSwap({
3769
3829
  ...mutationOptions,
3770
3830
  mutationFn: async (vars) => unwrapResult(await sodax.leverageYield.vaultSwap({ ...vars, raw: false })),
3771
3831
  onSuccess: async (data, vars, ctx) => {
3772
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", vars.params.srcChainKey] });
3773
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", vars.params.dstChainKey] });
3832
+ invalidateBalances(queryClient, vars.params.srcChainKey, vars.params.dstChainKey);
3774
3833
  await mutationOptions?.onSuccess?.(data, vars, ctx);
3775
3834
  }
3776
3835
  });
@@ -3863,4 +3922,4 @@ function createSodaxQueryClient({
3863
3922
  });
3864
3923
  }
3865
3924
 
3866
- export { SodaxProvider, clearRadfiSession, createDecreaseLiquidityParamsProps, createDepositParamsProps, createSodaxQueryClient, createSupplyLiquidityParamsProps, createWithdrawParamsProps, getLeverageYieldQuoteQueryOptions, getSponsorConfigQueryOptions, getStellarAccountActiveQueryOptions, getStellarAccountStatusQueryOptions, getStellarTrustlineCheckQueryOptions, getSwapQuoteQueryOptions, getXBalancesQueryOptions, isTerminalSwapIntentStatus, isUserRejectedError, loadRadfiSession, resolveNearStorageGate, resolveStellarGate, retryUnlessAuthFailure, runApprovalPlan, saveRadfiSession, toResult, unwrapResult, useAToken, useATokensBalances, useActivateStellarAccount, useApproveToken, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOrderbook, useBackendUserIntents, useBitcoinBalance, useBitcoinTradingSetup, useBorrow, useBridge, useBridgeAllowance, useBridgeApiAllowance, useBridgeApiApprove, useBridgeApiApproveAndBroadcast, useBridgeApiBridgeableAmount, useBridgeApiCreateBridgeIntent, useBridgeApiFee, useBridgeApiIsBridgeable, useBridgeApiSubmitTx, useBridgeApiSubmitTxStatus, useBridgeApiTokens, useBridgeApiTokensByChain, useBridgeApprove, useCancelLimitOrder, useCancelSwap, useCancelUnstake, useClaim, useClaimRewards, useConvertedAssets, useCreateDecreaseLiquidityParams, useCreateDepositParams, useCreateLimitOrder, useCreateSupplyLiquidityParams, useCreateWithdrawParams, useDecreaseLiquidity, useDeriveUserWalletAddress, useDetailedStatus, useDexAllowance, useDexApprove, useDexDeposit, useDexWithdraw, useEnsureRadfiAccessToken, useEstablishTrustline, useEstimateGas, useExpiredUtxos, useFeeClaimSwap, useFeeClaimWithdraw, useFetchAssetsBalances, useFundTradingWallet, useGetAutoSwapPreferences, useGetBridgeableAmount, useGetBridgeableTokens, useGetIntentDetails, useGetUserHubWalletAddress, useGetUserIntent, useHubAssetBalances, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useIsTokenApproved, useLeverageYieldDeposit, useLeverageYieldEffectiveApr, useLeverageYieldNotifySolver, useLeverageYieldPosition, useLeverageYieldPreviewRedeem, useLeverageYieldQuote, useLeverageYieldShareBalances, useLeverageYieldTotalAssets, useLeverageYieldVaultSwap, useLeverageYieldWithdraw, useLiquidityAmounts, useMMAllowance, useMMApprove, useMigrateBaln, useMigrateIcxToSoda, useMigratebnUSD, useMigrationAllowance, useMigrationApprove, useNearStorageCheck, useNearStorageGate, usePartnerCancelIntent, usePoolBalances, usePoolData, usePools, usePositionInfo, useQuote, useRadfiAuth, useRadfiSession, useRadfiWithdraw, useRegisterNearStorage, useRenewUtxos, useRepay, useRequestTrustline, useReservesData, useReservesHumanized, useReservesList, useReservesUsdFormat, useRevertMigrateSodaToIcx, useSafeMutation, useSetSwapPreference, useSodaxContext, useSponsorConfig, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarAccountActive, useStellarAccountStatus, useStellarGate, useStellarTrustlineCheck, useSupply, useSupplyLiquidity, useSwap, useSwapAllowance, useSwapApprove, useSwapsApiAllowance, useSwapsApiApprove, useSwapsApiApproveAndBroadcast, useSwapsApiCancelIntent, useSwapsApiCreateIntent, useSwapsApiCreateLimitOrder, useSwapsApiDeadline, useSwapsApiEstimateGas, useSwapsApiFilledIntent, useSwapsApiIntent, useSwapsApiIntentExtraData, useSwapsApiIntentHash, useSwapsApiIntentPacket, useSwapsApiPartnerFee, useSwapsApiQuote, useSwapsApiSolverFee, useSwapsApiStatus, useSwapsApiSubmitIntent, useSwapsApiSubmitTx, useSwapsApiSubmitTxStatus, useSwapsApiTokens, useSwapsApiTokensByChain, useTradingWallet, useTradingWalletBalance, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserFormattedSummary, useUserReservesData, useWithdraw, useWithdrawHubAsset, useXBalances };
3925
+ export { SodaxProvider, clearRadfiSession, createDecreaseLiquidityParamsProps, createDepositParamsProps, createSodaxQueryClient, createSupplyLiquidityParamsProps, createWithdrawParamsProps, getBalancesQueryOptions, getLeverageYieldQuoteQueryOptions, getSponsorConfigQueryOptions, getStellarAccountActiveQueryOptions, getStellarAccountStatusQueryOptions, getStellarTrustlineCheckQueryOptions, getSwapQuoteQueryOptions, getXBalancesQueryOptions, invalidateBalances, isTerminalSwapIntentStatus, isUserRejectedError, loadRadfiSession, resolveNearStorageGate, resolveStellarGate, retryUnlessAuthFailure, runApprovalPlan, saveRadfiSession, toResult, unwrapResult, useAToken, useATokensBalances, useActivateStellarAccount, useApproveToken, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOracleCandles, useBackendOracleMarkets, useBackendOrderbook, useBackendUserIntents, useBalances, useBitcoinBalance, useBitcoinTradingSetup, useBorrow, useBridge, useBridgeAllowance, useBridgeApiAllowance, useBridgeApiApprove, useBridgeApiApproveAndBroadcast, useBridgeApiBridgeableAmount, useBridgeApiCreateBridgeIntent, useBridgeApiFee, useBridgeApiIsBridgeable, useBridgeApiSubmitTx, useBridgeApiSubmitTxStatus, useBridgeApiTokens, useBridgeApiTokensByChain, useBridgeApprove, useCancelLimitOrder, useCancelSwap, useCancelUnstake, useClaim, useClaimRewards, useConvertedAssets, useCreateDecreaseLiquidityParams, useCreateDepositParams, useCreateLimitOrder, useCreateSupplyLiquidityParams, useCreateWithdrawParams, useDecreaseLiquidity, useDeriveUserWalletAddress, useDetailedStatus, useDexAllowance, useDexApprove, useDexDeposit, useDexWithdraw, useEnsureRadfiAccessToken, useEstablishTrustline, useEstimateGas, useExpiredUtxos, useFeeClaimSwap, useFeeClaimWithdraw, useFetchAssetsBalances, useFundTradingWallet, useGetAutoSwapPreferences, useGetBridgeableAmount, useGetBridgeableTokens, useGetIntentDetails, useGetUserHubWalletAddress, useGetUserIntent, useHubAssetBalances, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useIsTokenApproved, useLeverageYieldDeposit, useLeverageYieldEffectiveApr, useLeverageYieldNotifySolver, useLeverageYieldPosition, useLeverageYieldPreviewRedeem, useLeverageYieldQuote, useLeverageYieldShareBalances, useLeverageYieldTotalAssets, useLeverageYieldVaultSwap, useLeverageYieldWithdraw, useLiquidityAmounts, useMMAllowance, useMMApprove, useMigrateBaln, useMigrateIcxToSoda, useMigratebnUSD, useMigrationAllowance, useMigrationApprove, useNearStorageCheck, useNearStorageGate, usePartnerCancelIntent, usePoolBalances, usePoolData, usePools, usePositionInfo, useQuote, useRadfiAuth, useRadfiSession, useRadfiWithdraw, useRegisterNearStorage, useRenewUtxos, useRepay, useRequestTrustline, useReservesData, useReservesHumanized, useReservesList, useReservesUsdFormat, useRevertMigrateSodaToIcx, useSafeMutation, useSetSwapPreference, useSodaxContext, useSponsorConfig, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarAccountActive, useStellarAccountStatus, useStellarGate, useStellarTrustlineCheck, useSupply, useSupplyLiquidity, useSwap, useSwapAllowance, useSwapApprove, useSwapsApiAllowance, useSwapsApiApprove, useSwapsApiApproveAndBroadcast, useSwapsApiCancelIntent, useSwapsApiCreateIntent, useSwapsApiCreateLimitOrder, useSwapsApiDeadline, useSwapsApiEstimateGas, useSwapsApiFilledIntent, useSwapsApiIntent, useSwapsApiIntentExtraData, useSwapsApiIntentHash, useSwapsApiIntentPacket, useSwapsApiPartnerFee, useSwapsApiQuote, useSwapsApiSolverFee, useSwapsApiStatus, useSwapsApiSubmitIntent, useSwapsApiSubmitTx, useSwapsApiSubmitTxStatus, useSwapsApiTokens, useSwapsApiTokensByChain, useTradingWallet, useTradingWalletBalance, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserFormattedSummary, useUserReservesData, useWithdraw, useWithdrawHubAsset, useXBalances };
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "access": "public"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "2.2.0-rc.1",
8
+ "version": "2.2.0-rc.2",
9
9
  "description": "React hooks for building dApps on the SODAX cross-chain DeFi platform",
10
10
  "keywords": [
11
11
  "sodax",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "viem": "2.29.2",
37
- "@sodax/sdk": "2.2.0-rc.1"
37
+ "@sodax/sdk": "2.2.0-rc.2"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@arethetypeswrong/cli": "0.17.4",
@@ -67,7 +67,7 @@
67
67
  "test": "vitest run",
68
68
  "clean": "rm -rf dist && rm -rf node_modules && rm -rf .turbo",
69
69
  "pretty": "biome format . --write",
70
- "checkTs": "tsc --noEmit",
70
+ "checkTs": "tsc --noEmit && node ../../scripts/check-tests-typechecked.mjs",
71
71
  "check-exports": "attw --pack --profile esm-only",
72
72
  "check:knip": "knip",
73
73
  "lint": "biome lint . --write"
@@ -42,7 +42,7 @@ vi.mock('./shared/useSafeMutation.js', () => ({
42
42
  const swapsApi = await import('./swapsApi/index.js');
43
43
  const bridgeApi = await import('./bridgeApi/index.js');
44
44
 
45
- const fetchMock = vi.fn(
45
+ const fetchMock = vi.fn<typeof globalThis.fetch>(
46
46
  async () => new Response('{}', { status: 200, headers: { 'content-type': 'application/json' } }),
47
47
  );
48
48
  vi.stubGlobal('fetch', fetchMock);
@@ -111,6 +111,12 @@ describe.each(HOOKS)('mutation hook contract: $path', ({ path, nativeThrow }) =>
111
111
  expect(fnIdx).toBeGreaterThan(spreadIdx);
112
112
  });
113
113
 
114
+ it('routes balance invalidation through invalidateBalances', () => {
115
+ // Hand-rolling one balance key invalidates only one of the two balance hooks (useBalances vs
116
+ // useXBalances) and leaves the other stale — the exact drift the shared helper exists to stop.
117
+ expect(src).not.toMatch(/invalidateQueries\(\{\s*queryKey:\s*\[\s*'shared',\s*'x?[bB]alances'/);
118
+ });
119
+
114
120
  if (!nativeThrow) {
115
121
  it('translates SDK Result via unwrapResult', () => {
116
122
  expect(src).toMatch(/unwrapResult\(/);
@@ -22,4 +22,8 @@ export { useBackendMoneyMarketAsset } from './useBackendMoneyMarketAsset.js';
22
22
  export { useBackendMoneyMarketAssetBorrowers } from './useBackendMoneyMarketAssetBorrowers.js';
23
23
  export { useBackendMoneyMarketAssetSuppliers } from './useBackendMoneyMarketAssetSuppliers.js';
24
24
  export { useBackendAllMoneyMarketBorrowers } from './useBackendAllMoneyMarketBorrowers.js';
25
+
26
+ // Oracle hooks
27
+ export { useBackendOracleMarkets } from './useBackendOracleMarkets.js';
28
+ export { useBackendOracleCandles } from './useBackendOracleCandles.js';
25
29
  export * from './types.js';
@@ -0,0 +1,47 @@
1
+ import { useQuery, type UseQueryResult } from '@tanstack/react-query';
2
+ import type { OracleCandleInterval, OracleCandlesResponse } from '@sodax/sdk';
3
+ import { useSodaxContext } from '../shared/useSodaxContext.js';
4
+ import { unwrapResult } from './unwrapResult.js';
5
+ import type { ReadHookParams } from '../shared/types.js';
6
+
7
+ export type UseBackendOracleCandlesParams = ReadHookParams<
8
+ OracleCandlesResponse,
9
+ {
10
+ symbol: string;
11
+ interval: OracleCandleInterval;
12
+ /** Range start, UNIX seconds, inclusive. */
13
+ from: number;
14
+ /** Range end, UNIX seconds, exclusive; the range may cover at most 5000 buckets. */
15
+ to: number;
16
+ }
17
+ >;
18
+
19
+ /**
20
+ * Hook for fetching USD OHLC candles for a symbol over the half-open range `[from, to)`
21
+ * from the backend API. Responses are cached server-side for roughly 10 seconds.
22
+ *
23
+ * @example
24
+ * const { data } = useBackendOracleCandles({
25
+ * params: { symbol: 'ETH', interval: '1h', from: 1756000000, to: 1756360000 },
26
+ * });
27
+ */
28
+ export const useBackendOracleCandles = ({
29
+ params,
30
+ queryOptions,
31
+ }: UseBackendOracleCandlesParams = {}): UseQueryResult<OracleCandlesResponse, Error> => {
32
+ const { sodax } = useSodaxContext();
33
+
34
+ return useQuery<OracleCandlesResponse, Error>({
35
+ queryKey: ['backend', 'oracle', 'candles', params?.symbol, params?.interval, params?.from, params?.to],
36
+ queryFn: async (): Promise<OracleCandlesResponse> => {
37
+ if (!params) {
38
+ throw new Error('symbol, interval, from and to are required');
39
+ }
40
+ return unwrapResult(await sodax.backendApi.getOracleCandles(params));
41
+ },
42
+ enabled: !!params?.symbol && !!params?.interval && params?.from != null && params?.to != null,
43
+ staleTime: 10 * 1000,
44
+ retry: 3,
45
+ ...queryOptions,
46
+ });
47
+ };