@sodax/dapp-kit 2.4.0-rc.2 → 2.4.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.ts +279 -2428
- package/dist/index.mjs +15 -24
- package/package.json +2 -2
- package/src/hooks/_apiKeyWire.test.ts +4 -29
- package/src/hooks/_mutationContract.test.ts +1 -8
- package/src/hooks/backend/index.ts +0 -13
- package/src/hooks/backend/useBackendAllMoneyMarketAssets.ts +0 -6
- package/src/hooks/backend/useBackendAllMoneyMarketBorrowers.ts +0 -10
- package/src/hooks/backend/useBackendIntentByHash.ts +0 -6
- package/src/hooks/backend/useBackendIntentByTxHash.ts +1 -10
- package/src/hooks/backend/useBackendMoneyMarketAsset.ts +0 -6
- package/src/hooks/backend/useBackendMoneyMarketAssetBorrowers.ts +0 -8
- package/src/hooks/backend/useBackendMoneyMarketAssetSuppliers.ts +0 -8
- package/src/hooks/backend/useBackendMoneyMarketPosition.ts +0 -6
- package/src/hooks/backend/useBackendOracleCandles.ts +1 -9
- package/src/hooks/backend/useBackendOracleMarkets.ts +1 -7
- package/src/hooks/backend/useBackendOrderbook.ts +0 -6
- package/src/hooks/backend/useBackendUserIntents.ts +0 -8
- package/src/hooks/bitcoin/resolveBtcReadAddress.test.ts +1 -3
- package/src/hooks/bitcoin/resolveBtcReadAddress.ts +2 -12
- package/src/hooks/bitcoin/useBitcoinBalance.ts +1 -7
- package/src/hooks/bitcoin/useBitcoinTradingSetup.ts +2 -4
- package/src/hooks/bitcoin/useEnsureRadfiAccessToken.ts +2 -13
- package/src/hooks/bitcoin/useFundTradingWallet.ts +0 -6
- package/src/hooks/bitcoin/useRadfiAuth.ts +1 -6
- package/src/hooks/bitcoin/useRadfiSession.ts +0 -1
- package/src/hooks/bitcoin/useRadfiWithdraw.ts +0 -6
- package/src/hooks/bitcoin/useRenewUtxos.ts +0 -5
- package/src/hooks/bitcoin/useTradingWallet.ts +1 -4
- package/src/hooks/bridge/getBridgeDetailedStatusRefetchInterval.test.ts +1 -7
- package/src/hooks/bridge/getBridgeDetailedStatusRefetchInterval.ts +7 -21
- package/src/hooks/bridge/useBridge.test.ts +1 -11
- package/src/hooks/bridge/useBridge.ts +2 -12
- package/src/hooks/bridge/useBridgeAllowance.ts +1 -2
- package/src/hooks/bridge/useBridgeApprovalStrategy.ts +2 -6
- package/src/hooks/bridge/useBridgeApprove.ts +2 -14
- package/src/hooks/bridge/useBridgeDetailedStatus.test.ts +2 -11
- package/src/hooks/bridge/useBridgeDetailedStatus.ts +3 -23
- package/src/hooks/bridge/useBridgeWithApproval.ts +2 -11
- package/src/hooks/bridgeApi/getBridgeSubmitTxStatusRefetchInterval.test.ts +2 -7
- package/src/hooks/bridgeApi/getBridgeSubmitTxStatusRefetchInterval.ts +2 -13
- package/src/hooks/bridgeApi/index.ts +11 -14
- package/src/hooks/bridgeApi/useBridgeApiAllowance.ts +1 -9
- package/src/hooks/bridgeApi/useBridgeApiApprove.ts +2 -17
- package/src/hooks/bridgeApi/useBridgeApiApproveAndBroadcast.test.ts +2 -13
- package/src/hooks/bridgeApi/useBridgeApiApproveAndBroadcast.ts +3 -20
- package/src/hooks/bridgeApi/useBridgeApiBridgeableAmount.ts +1 -12
- package/src/hooks/bridgeApi/useBridgeApiCreateBridgeIntent.ts +1 -14
- package/src/hooks/bridgeApi/useBridgeApiFee.ts +2 -11
- package/src/hooks/bridgeApi/useBridgeApiIsBridgeable.ts +1 -12
- package/src/hooks/bridgeApi/useBridgeApiSubmitTx.ts +2 -23
- package/src/hooks/bridgeApi/useBridgeApiSubmitTxStatus.test.ts +1 -9
- package/src/hooks/bridgeApi/useBridgeApiSubmitTxStatus.ts +1 -19
- package/src/hooks/bridgeApi/useBridgeApiTokens.ts +0 -8
- package/src/hooks/bridgeApi/useBridgeApiTokensByChain.ts +0 -7
- package/src/hooks/dex/useClaimRewards.ts +1 -12
- package/src/hooks/dex/useCreateDecreaseLiquidityParams.ts +1 -5
- package/src/hooks/dex/useCreateDepositParams.ts +1 -5
- package/src/hooks/dex/useCreateSupplyLiquidityParams.ts +1 -10
- package/src/hooks/dex/useCreateWithdrawParams.ts +1 -5
- package/src/hooks/dex/useDecreaseLiquidity.ts +2 -15
- package/src/hooks/dex/useDexAllowance.ts +1 -5
- package/src/hooks/dex/useDexApprove.ts +1 -12
- package/src/hooks/dex/useDexDeposit.ts +1 -23
- package/src/hooks/dex/useDexWithdraw.ts +1 -13
- package/src/hooks/dex/useLiquidityAmounts.ts +1 -4
- package/src/hooks/dex/usePoolBalances.ts +0 -4
- package/src/hooks/dex/usePoolData.ts +1 -4
- package/src/hooks/dex/usePools.ts +1 -4
- package/src/hooks/dex/usePositionInfo.ts +1 -4
- package/src/hooks/dex/useSupplyLiquidity.ts +3 -20
- package/src/hooks/leverageYield/useApproveLeveragePositionFunding.ts +2 -8
- package/src/hooks/leverageYield/useLeveragePositionAccount.ts +2 -13
- package/src/hooks/leverageYield/useLeveragePositionCollateral.ts +2 -14
- package/src/hooks/leverageYield/useLeveragePositionFundingAllowance.ts +2 -9
- package/src/hooks/leverageYield/useLeveragePositionInfo.ts +1 -13
- package/src/hooks/leverageYield/useLeveragePositionPayoutAddress.ts +3 -15
- package/src/hooks/leverageYield/useLeveragePositionPending.ts +2 -16
- package/src/hooks/leverageYield/useLeveragePositions.ts +1 -15
- package/src/hooks/leverageYield/useLeveragePositionsForUser.ts +1 -15
- package/src/hooks/leverageYield/useLeverageYieldApprovalStrategy.ts +1 -6
- package/src/hooks/leverageYield/useLeverageYieldDeposit.ts +1 -17
- package/src/hooks/leverageYield/useLeverageYieldDetailedStatus.test.ts +3 -14
- package/src/hooks/leverageYield/useLeverageYieldDetailedStatus.ts +2 -19
- package/src/hooks/leverageYield/useLeverageYieldEffectiveApr.ts +1 -12
- package/src/hooks/leverageYield/useLeverageYieldNotifySolver.ts +1 -11
- package/src/hooks/leverageYield/useLeverageYieldPosition.ts +1 -13
- package/src/hooks/leverageYield/useLeverageYieldPreviewRedeem.ts +1 -12
- package/src/hooks/leverageYield/useLeverageYieldQuote.test.ts +3 -13
- package/src/hooks/leverageYield/useLeverageYieldQuote.ts +5 -54
- package/src/hooks/leverageYield/useLeverageYieldShareBalances.ts +2 -29
- package/src/hooks/leverageYield/useLeverageYieldTotalAssets.ts +1 -9
- package/src/hooks/leverageYield/useLeverageYieldVaultSwap.ts +2 -25
- package/src/hooks/leverageYield/useLeverageYieldVaultSwapWithApproval.ts +1 -11
- package/src/hooks/leverageYield/useLeverageYieldWithdraw.ts +1 -17
- package/src/hooks/leverageYield/useOpenLeveragePosition.ts +5 -18
- package/src/hooks/leverageYield/useRunLeveragePositionOperation.ts +4 -20
- package/src/hooks/leverageYield/useSubmitLeveragePositionIntent.ts +3 -15
- package/src/hooks/leverageYieldApi/index.ts +0 -15
- package/src/hooks/leverageYieldApi/useLeverageYieldApiAllowance.ts +1 -8
- package/src/hooks/leverageYieldApi/useLeverageYieldApiApprove.ts +3 -6
- package/src/hooks/leverageYieldApi/useLeverageYieldApiApproveAndBroadcast.test.ts +4 -14
- package/src/hooks/leverageYieldApi/useLeverageYieldApiApproveAndBroadcast.ts +4 -26
- package/src/hooks/leverageYieldApi/useLeverageYieldApiApr.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiAsset.ts +0 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiCancelIntent.ts +2 -8
- package/src/hooks/leverageYieldApi/useLeverageYieldApiCreateDepositIntent.ts +2 -8
- package/src/hooks/leverageYieldApi/useLeverageYieldApiCreateWithdrawIntent.ts +2 -8
- package/src/hooks/leverageYieldApi/useLeverageYieldApiDeadline.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiDepositQuote.ts +1 -15
- package/src/hooks/leverageYieldApi/useLeverageYieldApiEffectiveApr.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiEstimateGas.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiFilledIntent.ts +1 -6
- package/src/hooks/leverageYieldApi/useLeverageYieldApiIntent.ts +1 -6
- package/src/hooks/leverageYieldApi/useLeverageYieldApiIntentExtraData.ts +1 -8
- package/src/hooks/leverageYieldApi/useLeverageYieldApiIntentHash.ts +0 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiIntentPacket.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiLsdApr.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiMaxWithdraw.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiPartnerFee.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiPosition.ts +0 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiPreviewDeposit.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiPreviewRedeem.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiPreviewWithdraw.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiShareBalance.ts +0 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiSolverFee.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiStatus.ts +2 -12
- package/src/hooks/leverageYieldApi/useLeverageYieldApiSubmitIntent.ts +2 -8
- package/src/hooks/leverageYieldApi/useLeverageYieldApiSubmitTx.ts +2 -8
- package/src/hooks/leverageYieldApi/useLeverageYieldApiSubmitTxStatus.ts +2 -17
- package/src/hooks/leverageYieldApi/useLeverageYieldApiTotalAssets.ts +0 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiVault.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiVaults.ts +0 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiWithdrawQuote.ts +1 -15
- package/src/hooks/migrate/useMigrateBaln.ts +1 -8
- package/src/hooks/migrate/useMigrateIcxToSoda.ts +1 -12
- package/src/hooks/migrate/useMigratebnUSD.ts +1 -12
- package/src/hooks/migrate/useMigrationAllowance.ts +3 -19
- package/src/hooks/migrate/useMigrationApprove.ts +2 -20
- package/src/hooks/migrate/useRevertMigrateSodaToIcx.ts +0 -7
- package/src/hooks/mm/useAToken.ts +1 -6
- package/src/hooks/mm/useATokensBalances.ts +0 -5
- package/src/hooks/mm/useBorrow.ts +1 -13
- package/src/hooks/mm/useEModes.ts +2 -13
- package/src/hooks/mm/useMMAllowance.test.ts +55 -0
- package/src/hooks/mm/useMMAllowance.ts +6 -16
- package/src/hooks/mm/useMMApprove.ts +1 -14
- package/src/hooks/mm/useRepay.ts +1 -12
- package/src/hooks/mm/useReservesData.ts +0 -4
- package/src/hooks/mm/useReservesHumanized.ts +0 -4
- package/src/hooks/mm/useReservesList.ts +0 -4
- package/src/hooks/mm/useReservesUsdFormat.ts +0 -4
- package/src/hooks/mm/useSupply.ts +1 -24
- package/src/hooks/mm/useUserFormattedSummary.ts +0 -7
- package/src/hooks/mm/useUserReservesData.ts +0 -4
- package/src/hooks/mm/useWithdraw.ts +1 -13
- package/src/hooks/partner/useApproveToken.ts +1 -7
- package/src/hooks/partner/useFeeClaimSwap.ts +1 -7
- package/src/hooks/partner/useFeeClaimWithdraw.ts +3 -20
- package/src/hooks/partner/useFetchAssetsBalances.ts +0 -4
- package/src/hooks/partner/useGetAutoSwapPreferences.ts +0 -4
- package/src/hooks/partner/useGetIntentDetails.ts +1 -8
- package/src/hooks/partner/useGetUserIntent.ts +1 -8
- package/src/hooks/partner/useIsTokenApproved.ts +0 -4
- package/src/hooks/partner/usePartnerCancelIntent.ts +2 -9
- package/src/hooks/partner/useSetSwapPreference.ts +1 -14
- package/src/hooks/recovery/useHubAssetBalances.ts +1 -6
- package/src/hooks/recovery/useWithdrawHubAsset.ts +1 -13
- package/src/hooks/shared/invalidateBalances.ts +2 -10
- package/src/hooks/shared/isUserRejectedError.test.ts +0 -3
- package/src/hooks/shared/isUserRejectedError.ts +2 -23
- package/src/hooks/shared/notFoundStreak.ts +5 -22
- package/src/hooks/shared/retryUnlessAuthFailure.test.ts +1 -2
- package/src/hooks/shared/retryUnlessAuthFailure.ts +1 -12
- package/src/hooks/shared/solverStatusPolicy.test.ts +0 -5
- package/src/hooks/shared/solverStatusPolicy.ts +8 -58
- package/src/hooks/shared/types.ts +4 -55
- package/src/hooks/shared/unwrapResult.ts +1 -8
- package/src/hooks/shared/useBalances.ts +6 -39
- package/src/hooks/shared/useEstablishTrustline.test.ts +1 -5
- package/src/hooks/shared/useEstablishTrustline.ts +3 -13
- package/src/hooks/shared/useEstablishXrpTrustline.test.ts +1 -2
- package/src/hooks/shared/useEstablishXrpTrustline.ts +3 -5
- package/src/hooks/shared/useEstimateGas.ts +0 -1
- package/src/hooks/shared/useGetUserHubWalletAddress.ts +1 -18
- package/src/hooks/shared/useNearStorageCheck.ts +2 -9
- package/src/hooks/shared/useNearStorageGate.ts +5 -15
- package/src/hooks/shared/useRegisterNearStorage.ts +2 -10
- package/src/hooks/shared/useRequestTrustline.test.ts +1 -7
- package/src/hooks/shared/useRequestTrustline.ts +4 -14
- package/src/hooks/shared/useSafeMutation.test.ts +0 -3
- package/src/hooks/shared/useSafeMutation.ts +2 -26
- package/src/hooks/shared/useSodaxContext.ts +0 -6
- package/src/hooks/shared/useStellarGate.test.ts +2 -9
- package/src/hooks/shared/useStellarGate.ts +3 -9
- package/src/hooks/shared/useStellarTrustlineCheck.test.ts +0 -2
- package/src/hooks/shared/useStellarTrustlineCheck.ts +1 -4
- package/src/hooks/shared/useXBalances.ts +2 -20
- package/src/hooks/shared/useXrpDestinationCheck.ts +1 -5
- package/src/hooks/shared/useXrpGate.test.ts +1 -3
- package/src/hooks/shared/useXrpGate.ts +2 -3
- package/src/hooks/shared/waitForApiAllowance.test.ts +0 -1
- package/src/hooks/shared/waitForApiAllowance.ts +2 -6
- package/src/hooks/sponsoring/useActivateStellarAccount.test.ts +1 -2
- package/src/hooks/sponsoring/useActivateStellarAccount.ts +1 -5
- package/src/hooks/sponsoring/useActivateStellarAccount.wire.test.ts +2 -13
- package/src/hooks/sponsoring/useSponsorConfig.ts +0 -1
- package/src/hooks/sponsoring/useStellarAccountActive.ts +0 -1
- package/src/hooks/sponsoring/useStellarAccountStatus.ts +1 -4
- package/src/hooks/staking/index.ts +0 -1
- package/src/hooks/staking/useCancelUnstake.ts +1 -7
- package/src/hooks/staking/useClaim.ts +1 -7
- package/src/hooks/staking/useConvertedAssets.ts +1 -4
- package/src/hooks/staking/useInstantUnstake.ts +1 -7
- package/src/hooks/staking/useInstantUnstakeAllowance.ts +1 -5
- package/src/hooks/staking/useInstantUnstakeApprove.ts +1 -11
- package/src/hooks/staking/useInstantUnstakeRatio.ts +1 -4
- package/src/hooks/staking/useStake.ts +1 -12
- package/src/hooks/staking/useStakeAllowance.ts +1 -5
- package/src/hooks/staking/useStakeApprove.ts +1 -11
- package/src/hooks/staking/useStakeRatio.ts +1 -4
- package/src/hooks/staking/useStakingConfig.ts +1 -4
- package/src/hooks/staking/useStakingInfo.ts +1 -5
- package/src/hooks/staking/useUnstake.ts +2 -9
- package/src/hooks/staking/useUnstakeAllowance.ts +1 -5
- package/src/hooks/staking/useUnstakeApprove.ts +1 -10
- package/src/hooks/staking/useUnstakingInfo.ts +1 -4
- package/src/hooks/staking/useUnstakingInfoWithPenalty.ts +1 -4
- package/src/hooks/swap/useCancelLimitOrder.ts +1 -7
- package/src/hooks/swap/useCancelSwap.ts +1 -7
- package/src/hooks/swap/useCreateLimitOrder.ts +2 -12
- package/src/hooks/swap/useDetailedStatus.test.ts +6 -18
- package/src/hooks/swap/useDetailedStatus.ts +2 -19
- package/src/hooks/swap/useQuote.test.ts +2 -8
- package/src/hooks/swap/useQuote.ts +5 -32
- package/src/hooks/swap/useStatus.ts +2 -10
- package/src/hooks/swap/useSwap.test.ts +1 -11
- package/src/hooks/swap/useSwap.ts +2 -12
- package/src/hooks/swap/useSwapAllowance.ts +1 -2
- package/src/hooks/swap/useSwapApprovalStrategy.ts +2 -7
- package/src/hooks/swap/useSwapApprove.ts +2 -14
- package/src/hooks/swap/useSwapLifecycle.test.ts +1 -2
- package/src/hooks/swap/useSwapLifecycle.ts +9 -27
- package/src/hooks/swap/useSwapWithApproval.ts +2 -11
- package/src/hooks/swapsApi/index.ts +2 -14
- package/src/hooks/swapsApi/isTerminalSwapIntentStatus.test.ts +1 -5
- package/src/hooks/swapsApi/isTerminalSwapIntentStatus.ts +1 -7
- package/src/hooks/swapsApi/useSwapsApiAllowance.ts +0 -7
- package/src/hooks/swapsApi/useSwapsApiApprove.ts +1 -14
- package/src/hooks/swapsApi/useSwapsApiApproveAndBroadcast.test.ts +5 -20
- package/src/hooks/swapsApi/useSwapsApiApproveAndBroadcast.ts +3 -24
- package/src/hooks/swapsApi/useSwapsApiBroadcastWithApproval.test.ts +2 -8
- package/src/hooks/swapsApi/useSwapsApiBroadcastWithApproval.ts +6 -41
- package/src/hooks/swapsApi/useSwapsApiCancelIntent.ts +0 -13
- package/src/hooks/swapsApi/useSwapsApiCreateIntent.ts +0 -13
- package/src/hooks/swapsApi/useSwapsApiCreateLimitOrder.ts +1 -13
- package/src/hooks/swapsApi/useSwapsApiDeadline.ts +1 -7
- package/src/hooks/swapsApi/useSwapsApiEstimateGas.ts +0 -7
- package/src/hooks/swapsApi/useSwapsApiFilledIntent.ts +0 -8
- package/src/hooks/swapsApi/useSwapsApiIntent.ts +1 -7
- package/src/hooks/swapsApi/useSwapsApiIntentExtraData.ts +1 -8
- package/src/hooks/swapsApi/useSwapsApiIntentHash.ts +0 -7
- package/src/hooks/swapsApi/useSwapsApiIntentPacket.ts +1 -10
- package/src/hooks/swapsApi/useSwapsApiPartnerFee.ts +0 -7
- package/src/hooks/swapsApi/useSwapsApiQuote.ts +2 -24
- package/src/hooks/swapsApi/useSwapsApiSolverFee.ts +0 -7
- package/src/hooks/swapsApi/useSwapsApiStatus.ts +1 -11
- package/src/hooks/swapsApi/useSwapsApiSubmitIntent.ts +1 -15
- package/src/hooks/swapsApi/useSwapsApiSubmitTx.ts +0 -21
- package/src/hooks/swapsApi/useSwapsApiSubmitTxStatus.ts +2 -19
- package/src/hooks/swapsApi/useSwapsApiTokens.ts +0 -7
- package/src/hooks/swapsApi/useSwapsApiTokensByChain.ts +0 -7
- package/src/index.ts +1 -1
- package/src/providers/SodaxProvider.test.ts +2 -9
- package/src/providers/SodaxProvider.tsx +1 -12
- package/src/providers/createSodaxQueryClient.ts +4 -56
- package/src/utils/approvalPlan.ts +9 -32
- package/src/utils/dex-utils.ts +5 -20
- package/src/utils/nearStorageGate.ts +3 -14
- package/src/utils/stellarGate.ts +3 -16
- package/src/utils/swapLifecycle.ts +7 -26
- package/src/utils/xrpGate.ts +1 -4
|
@@ -5,10 +5,6 @@ import type { ReadHookParams } from '../shared/types.js';
|
|
|
5
5
|
|
|
6
6
|
export type UseReservesHumanizedParams = ReadHookParams<ReservesDataHumanized>;
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* React hook for fetching the human-readable (decimal-normalized, string-formatted) reserves
|
|
10
|
-
* snapshot from the Sodax money market.
|
|
11
|
-
*/
|
|
12
8
|
export function useReservesHumanized({
|
|
13
9
|
queryOptions,
|
|
14
10
|
}: UseReservesHumanizedParams = {}): UseQueryResult<ReservesDataHumanized, Error> {
|
|
@@ -5,10 +5,6 @@ import type { ReadHookParams } from '../shared/types.js';
|
|
|
5
5
|
|
|
6
6
|
export type UseReservesListParams = ReadHookParams<readonly Address[]>;
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* React hook for fetching the list of reserve asset addresses currently registered in the
|
|
10
|
-
* Sodax money market.
|
|
11
|
-
*/
|
|
12
8
|
export function useReservesList({
|
|
13
9
|
queryOptions,
|
|
14
10
|
}: UseReservesListParams = {}): UseQueryResult<readonly Address[], Error> {
|
|
@@ -7,10 +7,6 @@ export type ReserveUsdFormat = ReserveDataHumanized & FormatReserveUSDResponse;
|
|
|
7
7
|
|
|
8
8
|
export type UseReservesUsdFormatParams = ReadHookParams<ReserveUsdFormat[]>;
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* React hook returning reserves with USD-formatted values for the Sodax money market.
|
|
12
|
-
* Chains `getReservesHumanized` → `buildReserveDataWithPrice` → `formatReservesUSD`.
|
|
13
|
-
*/
|
|
14
10
|
export function useReservesUsdFormat({
|
|
15
11
|
queryOptions,
|
|
16
12
|
}: UseReservesUsdFormatParams = {}): UseQueryResult<ReserveUsdFormat[], Error> {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// packages/dapp-kit/src/hooks/mm/useSupply.ts
|
|
2
1
|
import type { MoneyMarketSupplyActionParams, SpokeChainKey, TxHashPair } from '@sodax/sdk';
|
|
3
2
|
import { useQueryClient } from '@tanstack/react-query';
|
|
4
3
|
import { useSodaxContext } from '../shared/useSodaxContext.js';
|
|
@@ -8,34 +7,12 @@ import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMu
|
|
|
8
7
|
import { retryBeforeSubmission } from '../shared/retryBeforeSubmission.js';
|
|
9
8
|
import { unwrapResult } from '../shared/unwrapResult.js';
|
|
10
9
|
|
|
11
|
-
/**
|
|
12
|
-
* Mutation variables for {@link useSupply}. Generic over `K extends SpokeChainKey` (defaults to
|
|
13
|
-
* the full union). Sophisticated callers can lock K at the hook call site to narrow the
|
|
14
|
-
* `walletProvider` and `params.srcChainKey` types.
|
|
15
|
-
*/
|
|
16
10
|
export type UseSupplyVars<K extends SpokeChainKey = SpokeChainKey> = Omit<
|
|
17
11
|
MoneyMarketSupplyActionParams<K, false>,
|
|
18
12
|
'raw'
|
|
19
13
|
>;
|
|
20
14
|
|
|
21
|
-
/**
|
|
22
|
-
* React hook for supplying tokens to the Sodax money market protocol.
|
|
23
|
-
*
|
|
24
|
-
* Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
|
|
25
|
-
* `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```tsx
|
|
29
|
-
* const walletProvider = useWalletProvider({ xChainId: chainKey });
|
|
30
|
-
* const { mutateAsync: supply, isError, error } = useSupply();
|
|
31
|
-
* if (!walletProvider) return;
|
|
32
|
-
* try {
|
|
33
|
-
* const { spokeTxHash, hubTxHash } = await supply({ params: supplyParams, walletProvider });
|
|
34
|
-
* } catch (e) {
|
|
35
|
-
* // surfaced via mutation.error / onError
|
|
36
|
-
* }
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
15
|
+
/** Throws on SDK failure (React Query error state); resolves to the unwrapped `TxHashPair`. */
|
|
39
16
|
export function useSupply<K extends SpokeChainKey = SpokeChainKey>({
|
|
40
17
|
mutationOptions,
|
|
41
18
|
}: MutationHookParams<TxHashPair, UseSupplyVars<K>> = {}): SafeUseMutationResult<TxHashPair, Error, UseSupplyVars<K>> {
|
|
@@ -13,13 +13,6 @@ export type UseUserFormattedSummaryParams = ReadHookParams<
|
|
|
13
13
|
}
|
|
14
14
|
>;
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* React hook returning the user's formatted money market portfolio summary (collateral, borrows,
|
|
18
|
-
* health factor, available borrow power, etc.) for the given spoke chain.
|
|
19
|
-
*
|
|
20
|
-
* Internally chains `getReservesHumanized` → `formatReservesUSD` → `getUserReservesHumanized`
|
|
21
|
-
* → `formatUserSummary`.
|
|
22
|
-
*/
|
|
23
16
|
export function useUserFormattedSummary({
|
|
24
17
|
params,
|
|
25
18
|
queryOptions,
|
|
@@ -13,10 +13,6 @@ export type UseUserReservesDataParams = ReadHookParams<
|
|
|
13
13
|
}
|
|
14
14
|
>;
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* React hook for fetching the raw user reserves data (positions on the hub) for a given spoke
|
|
18
|
-
* chain and user address.
|
|
19
|
-
*/
|
|
20
16
|
export function useUserReservesData({
|
|
21
17
|
params,
|
|
22
18
|
queryOptions,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// packages/dapp-kit/src/hooks/mm/useWithdraw.ts
|
|
2
1
|
import type { MoneyMarketWithdrawActionParams, SpokeChainKey, OutboundSettlement } from '@sodax/sdk';
|
|
3
2
|
import { useQueryClient } from '@tanstack/react-query';
|
|
4
3
|
import { useSodaxContext } from '../shared/useSodaxContext.js';
|
|
@@ -8,23 +7,12 @@ import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMu
|
|
|
8
7
|
import { unwrapResult } from '../shared/unwrapResult.js';
|
|
9
8
|
import { retryBeforeSubmission } from '../shared/retryBeforeSubmission.js';
|
|
10
9
|
|
|
11
|
-
/**
|
|
12
|
-
* Mutation variables for {@link useWithdraw}. Generic over `K extends SpokeChainKey` (defaults to
|
|
13
|
-
* the full union). Sophisticated callers can lock K at the hook call site to narrow the
|
|
14
|
-
* `walletProvider` and `params.srcChainKey` types.
|
|
15
|
-
*/
|
|
16
10
|
export type UseWithdrawVars<K extends SpokeChainKey = SpokeChainKey> = Omit<
|
|
17
11
|
MoneyMarketWithdrawActionParams<K, false>,
|
|
18
12
|
'raw'
|
|
19
13
|
>;
|
|
20
14
|
|
|
21
|
-
/**
|
|
22
|
-
* React hook for withdrawing supplied tokens from the Sodax money market protocol.
|
|
23
|
-
*
|
|
24
|
-
* Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
|
|
25
|
-
* `onError`, `retry`). Returns the unwrapped {@link OutboundSettlement} on success: a tx pair, or
|
|
26
|
-
* from Tron the relay's `trackingId` beside the destination tx.
|
|
27
|
-
*/
|
|
15
|
+
/** Throws on SDK failure; resolves to an {@link OutboundSettlement} (tx pair, or Tron relay `trackingId` + dst tx). */
|
|
28
16
|
export function useWithdraw<K extends SpokeChainKey = SpokeChainKey>({
|
|
29
17
|
mutationOptions,
|
|
30
18
|
}: MutationHookParams<OutboundSettlement<K>, UseWithdrawVars<K>> = {}): SafeUseMutationResult<
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// packages/dapp-kit/src/hooks/partner/useApproveToken.ts
|
|
2
1
|
import type { FeeTokenApproveAction, HubChainKey, TxReturnType } from '@sodax/sdk';
|
|
3
2
|
import { useQueryClient } from '@tanstack/react-query';
|
|
4
3
|
import { useSodaxContext } from '../shared/useSodaxContext.js';
|
|
@@ -10,12 +9,7 @@ export type UseApproveTokenVars = Omit<FeeTokenApproveAction<HubChainKey, false>
|
|
|
10
9
|
|
|
11
10
|
type ApproveTokenData = TxReturnType<HubChainKey, false>;
|
|
12
11
|
|
|
13
|
-
/**
|
|
14
|
-
* React hook to approve a token to the protocol-intents contract on Sonic with max allowance.
|
|
15
|
-
*
|
|
16
|
-
* Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
|
|
17
|
-
* `onError`, `retry`). Returns the unwrapped tx return value on success.
|
|
18
|
-
*/
|
|
12
|
+
/** Approves max allowance to the protocol-intents contract on Sonic. */
|
|
19
13
|
export function useApproveToken({
|
|
20
14
|
mutationOptions,
|
|
21
15
|
}: MutationHookParams<ApproveTokenData, UseApproveTokenVars> = {}): SafeUseMutationResult<
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// packages/dapp-kit/src/hooks/partner/useFeeClaimSwap.ts
|
|
2
1
|
import type { HubChainKey, IntentAutoSwapResult, PartnerFeeClaimSwapAction } from '@sodax/sdk';
|
|
3
2
|
import { useQueryClient } from '@tanstack/react-query';
|
|
4
3
|
import { useSodaxContext } from '../shared/useSodaxContext.js';
|
|
@@ -8,12 +7,7 @@ import { unwrapResult } from '../shared/unwrapResult.js';
|
|
|
8
7
|
|
|
9
8
|
export type UseFeeClaimSwapVars = Omit<PartnerFeeClaimSwapAction<HubChainKey, false>, 'raw'>;
|
|
10
9
|
|
|
11
|
-
/**
|
|
12
|
-
* React hook to create a partner-fee auto-swap intent and wait for the solver execution.
|
|
13
|
-
*
|
|
14
|
-
* Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
|
|
15
|
-
* `onError`, `retry`). Returns the unwrapped `IntentAutoSwapResult` on success.
|
|
16
|
-
*/
|
|
10
|
+
/** Creates a partner-fee auto-swap intent and waits for solver execution. */
|
|
17
11
|
export function useFeeClaimSwap({
|
|
18
12
|
mutationOptions,
|
|
19
13
|
}: MutationHookParams<IntentAutoSwapResult, UseFeeClaimSwapVars> = {}): SafeUseMutationResult<
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// packages/dapp-kit/src/hooks/partner/useFeeClaimWithdraw.ts
|
|
2
1
|
import {
|
|
3
2
|
ChainKeys,
|
|
4
3
|
type Address,
|
|
@@ -15,13 +14,7 @@ import type { MutationHookParams } from '../shared/types.js';
|
|
|
15
14
|
import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
|
|
16
15
|
import { unwrapResult } from '../shared/unwrapResult.js';
|
|
17
16
|
|
|
18
|
-
/**
|
|
19
|
-
* Mutation variables for {@link useFeeClaimWithdraw}. Maps a partner fee balance to a
|
|
20
|
-
* Sonic-sourced bridge: `feeToken` is the wrapped hub-asset address on Sonic
|
|
21
|
-
* (`PartnerFeeClaimAssetBalance.address`); `dstToken` is the original token address on
|
|
22
|
-
* `dstChainKey` (`PartnerFeeClaimAssetBalance.originalAddress`, or `feeToken` for same-chain
|
|
23
|
-
* delivery to a Sonic address).
|
|
24
|
-
*/
|
|
17
|
+
/** `feeToken` is the hub asset `address` on Sonic; `dstToken` is its `originalAddress` (or `feeToken` for Sonic). */
|
|
25
18
|
export type UseFeeClaimWithdrawVars = {
|
|
26
19
|
params: {
|
|
27
20
|
srcAddress: string;
|
|
@@ -35,18 +28,8 @@ export type UseFeeClaimWithdrawVars = {
|
|
|
35
28
|
};
|
|
36
29
|
|
|
37
30
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* For fees the partner wants to keep as-is (the desired output equals the fee token, e.g. BTC→BTC),
|
|
41
|
-
* an auto-swap is impossible — the solver rejects a same-token swap. This bridges the wrapped fee
|
|
42
|
-
* token from Sonic to its native chain (or transfers it on Sonic when `dstChainKey` is Sonic),
|
|
43
|
-
* bypassing the solver entirely.
|
|
44
|
-
*
|
|
45
|
-
* Bridging from Sonic pulls the token via the partner's hub-wallet router, which requires a prior
|
|
46
|
-
* allowance to that spender — a different approval than the ProtocolIntents one used by the swap
|
|
47
|
-
* claim. Use `useBridgeAllowance` / `useBridgeApprove` (with the same mapped bridge params) first.
|
|
48
|
-
*
|
|
49
|
-
* Throws on SDK failure so React Query's native error model engages. Returns the `TxHashPair`.
|
|
31
|
+
* Bridges a fee token out without a swap (the solver rejects same-token swaps). Needs a prior hub-wallet
|
|
32
|
+
* router allowance via `useBridgeAllowance` / `useBridgeApprove`, not the ProtocolIntents approval.
|
|
50
33
|
*/
|
|
51
34
|
export function useFeeClaimWithdraw({
|
|
52
35
|
mutationOptions,
|
|
@@ -10,10 +10,6 @@ export type UseFetchAssetsBalancesParams = ReadHookParams<
|
|
|
10
10
|
}
|
|
11
11
|
>;
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* React hook to fetch hub-asset balances on Sonic for a given EVM address. Disabled when
|
|
15
|
-
* `queryAddress` is missing. Throws on `!ok`.
|
|
16
|
-
*/
|
|
17
13
|
export function useFetchAssetsBalances({
|
|
18
14
|
params,
|
|
19
15
|
queryOptions,
|
|
@@ -10,10 +10,6 @@ export type UseGetAutoSwapPreferencesParams = ReadHookParams<
|
|
|
10
10
|
}
|
|
11
11
|
>;
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* React hook to fetch the auto-swap preferences (output token, destination chain, destination
|
|
15
|
-
* address) for a given EVM address. Disabled when `queryAddress` is missing. Throws on `!ok`.
|
|
16
|
-
*/
|
|
17
13
|
export function useGetAutoSwapPreferences({
|
|
18
14
|
params,
|
|
19
15
|
queryOptions,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// packages/dapp-kit/src/hooks/partner/useGetIntentDetails.ts
|
|
2
1
|
import type { Hex, Intent } from '@sodax/sdk';
|
|
3
2
|
import { useQuery, type UseQueryResult } from '@tanstack/react-query';
|
|
4
3
|
import { useSodaxContext } from '../shared/useSodaxContext.js';
|
|
@@ -8,13 +7,7 @@ const ZERO_HASH = '0x00000000000000000000000000000000000000000000000000000000000
|
|
|
8
7
|
|
|
9
8
|
export type UseGetIntentDetailsParams = ReadHookParams<Intent, { intentHash: Hex | undefined }>;
|
|
10
9
|
|
|
11
|
-
/**
|
|
12
|
-
* React hook to fetch the full {@link Intent} details for a ProtocolIntents intent hash.
|
|
13
|
-
*
|
|
14
|
-
* Pair with {@link useGetUserIntent} to display a stuck intent (e.g. its locked `inputAmount`)
|
|
15
|
-
* before recovering it. Disabled when the hash is missing or the zero hash (no intent). Throws
|
|
16
|
-
* on `!ok`.
|
|
17
|
-
*/
|
|
10
|
+
/** Disabled for a missing or zero hash; pair with {@link useGetUserIntent} to inspect a stuck intent. */
|
|
18
11
|
export function useGetIntentDetails({
|
|
19
12
|
params,
|
|
20
13
|
queryOptions,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// packages/dapp-kit/src/hooks/partner/useGetUserIntent.ts
|
|
2
1
|
import type { GetUserIntentParams, Hex } from '@sodax/sdk';
|
|
3
2
|
import { useQuery, type UseQueryResult } from '@tanstack/react-query';
|
|
4
3
|
import { useSodaxContext } from '../shared/useSodaxContext.js';
|
|
@@ -6,13 +5,7 @@ import type { ReadHookParams } from '../shared/types.js';
|
|
|
6
5
|
|
|
7
6
|
export type UseGetUserIntentParams = ReadHookParams<Hex, Partial<GetUserIntentParams>>;
|
|
8
7
|
|
|
9
|
-
/**
|
|
10
|
-
* React hook to look up the stored intent hash for a partner's `(user, fromToken, toToken)` pair.
|
|
11
|
-
*
|
|
12
|
-
* A non-zero hash means an open auto-swap intent exists for that token pair (e.g. an unfilled
|
|
13
|
-
* same-token claim) and can be recovered via {@link usePartnerCancelIntent}. Disabled until all
|
|
14
|
-
* three inputs are present. Throws on `!ok`.
|
|
15
|
-
*/
|
|
8
|
+
/** A non-zero hash is an open auto-swap intent, recoverable via {@link usePartnerCancelIntent}. */
|
|
16
9
|
export function useGetUserIntent({ params, queryOptions }: UseGetUserIntentParams = {}): UseQueryResult<Hex, Error> {
|
|
17
10
|
const { sodax } = useSodaxContext();
|
|
18
11
|
const user = params?.user;
|
|
@@ -10,10 +10,6 @@ export type UseIsTokenApprovedParams = ReadHookParams<
|
|
|
10
10
|
}
|
|
11
11
|
>;
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* React hook to check whether a token is approved to the protocol-intents contract on Sonic for
|
|
15
|
-
* a given owner. Read-only; throws on `!ok`.
|
|
16
|
-
*/
|
|
17
13
|
export function useIsTokenApproved({
|
|
18
14
|
params,
|
|
19
15
|
queryOptions,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// packages/dapp-kit/src/hooks/partner/usePartnerCancelIntent.ts
|
|
2
1
|
import type { HubChainKey, PartnerFeeClaimCancelAction, TxReturnType } from '@sodax/sdk';
|
|
3
2
|
import { useQueryClient } from '@tanstack/react-query';
|
|
4
3
|
import { useSodaxContext } from '../shared/useSodaxContext.js';
|
|
@@ -9,14 +8,8 @@ import { unwrapResult } from '../shared/unwrapResult.js';
|
|
|
9
8
|
export type UsePartnerCancelIntentVars = Omit<PartnerFeeClaimCancelAction<HubChainKey, false>, 'raw'>;
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* Calls `ProtocolIntents.cancelIntent(fromToken, toToken)` — the only authorized cancel path for
|
|
15
|
-
* partner auto-swap intents (the generic swap-cancel reverts because ProtocolIntents, not the
|
|
16
|
-
* partner, is the intent creator). The contract cancels the intent and refunds the input amount to
|
|
17
|
-
* the partner. Use this to recover funds from an unfillable same-token claim.
|
|
18
|
-
*
|
|
19
|
-
* Throws on SDK failure so React Query's native error model engages. Returns the transaction hash.
|
|
11
|
+
* The only authorized cancel for partner auto-swap intents (ProtocolIntents is the creator, so the generic
|
|
12
|
+
* swap cancel reverts); refunds the locked input to the partner.
|
|
20
13
|
*/
|
|
21
14
|
export function usePartnerCancelIntent({
|
|
22
15
|
mutationOptions,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// packages/dapp-kit/src/hooks/partner/useSetSwapPreference.ts
|
|
2
1
|
import type { HubChainKey, SetSwapPreferenceAction, SpokeChainKey, TxReturnType } from '@sodax/sdk';
|
|
3
2
|
import { useQueryClient } from '@tanstack/react-query';
|
|
4
3
|
import { useSodaxContext } from '../shared/useSodaxContext.js';
|
|
@@ -6,23 +5,12 @@ import type { MutationHookParams } from '../shared/types.js';
|
|
|
6
5
|
import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
|
|
7
6
|
import { unwrapResult } from '../shared/unwrapResult.js';
|
|
8
7
|
|
|
9
|
-
/**
|
|
10
|
-
* Mutation variables for {@link useSetSwapPreference}. Generic over `K extends SpokeChainKey`
|
|
11
|
-
* for compatibility with the SDK signature; at runtime the SDK enforces hub-only
|
|
12
|
-
* (`isHubChainKeyType(srcChainKey)`).
|
|
13
|
-
*/
|
|
8
|
+
/** Generic only for SDK signature compatibility; the SDK enforces hub-only at runtime. */
|
|
14
9
|
export type UseSetSwapPreferenceVars<K extends SpokeChainKey = SpokeChainKey> = Omit<
|
|
15
10
|
SetSwapPreferenceAction<K, false>,
|
|
16
11
|
'raw'
|
|
17
12
|
>;
|
|
18
13
|
|
|
19
|
-
/**
|
|
20
|
-
* React hook to set the partner's auto-swap preferences (output token + destination chain +
|
|
21
|
-
* destination address) on the protocol-intents contract.
|
|
22
|
-
*
|
|
23
|
-
* Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
|
|
24
|
-
* `onError`, `retry`). Returns the unwrapped tx return value on success.
|
|
25
|
-
*/
|
|
26
14
|
export function useSetSwapPreference<K extends SpokeChainKey = SpokeChainKey>({
|
|
27
15
|
mutationOptions,
|
|
28
16
|
}: MutationHookParams<TxReturnType<K, false>, UseSetSwapPreferenceVars<K>> = {}): SafeUseMutationResult<
|
|
@@ -46,5 +34,4 @@ export function useSetSwapPreference<K extends SpokeChainKey = SpokeChainKey>({
|
|
|
46
34
|
});
|
|
47
35
|
}
|
|
48
36
|
|
|
49
|
-
// Helper alias for the common Sonic-only call shape.
|
|
50
37
|
export type UseSetSwapPreferenceVarsHub = UseSetSwapPreferenceVars<HubChainKey>;
|
|
@@ -8,16 +8,11 @@ export type UseHubAssetBalancesParams = ReadHookParams<
|
|
|
8
8
|
HubAssetBalance[],
|
|
9
9
|
{
|
|
10
10
|
chainKey: SpokeChainKey | undefined;
|
|
11
|
-
/**
|
|
11
|
+
/** Spoke address; the SDK derives the hub wallet from it. */
|
|
12
12
|
srcAddress: string | undefined;
|
|
13
13
|
}
|
|
14
14
|
>;
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* React hook to fetch the hub-side balances of every supported token on the given spoke chain
|
|
18
|
-
* for the user's hub wallet (derived internally from `srcAddress` + `chainKey`). Disabled when
|
|
19
|
-
* either input is missing. Throws on `!ok`.
|
|
20
|
-
*/
|
|
21
16
|
export function useHubAssetBalances({
|
|
22
17
|
params,
|
|
23
18
|
queryOptions,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// packages/dapp-kit/src/hooks/recovery/useWithdrawHubAsset.ts
|
|
2
1
|
import type { SpokeChainKey, SendMessageReturnType, WithdrawHubAssetAction } from '@sodax/sdk';
|
|
3
2
|
import { useQueryClient } from '@tanstack/react-query';
|
|
4
3
|
import { useSodaxContext } from '../shared/useSodaxContext.js';
|
|
@@ -8,23 +7,12 @@ import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMu
|
|
|
8
7
|
import { retryBeforeSubmission } from '../shared/retryBeforeSubmission.js';
|
|
9
8
|
import { unwrapResult } from '../shared/unwrapResult.js';
|
|
10
9
|
|
|
11
|
-
/**
|
|
12
|
-
* Mutation variables for {@link useWithdrawHubAsset}. Generic over `K extends SpokeChainKey`
|
|
13
|
-
* (defaults to the full union). Sophisticated callers can lock K at the hook call site to narrow
|
|
14
|
-
* the `walletProvider` and `params.srcChainKey` types.
|
|
15
|
-
*/
|
|
16
10
|
export type UseWithdrawHubAssetVars<K extends SpokeChainKey = SpokeChainKey> = Omit<
|
|
17
11
|
WithdrawHubAssetAction<K, false>,
|
|
18
12
|
'raw'
|
|
19
13
|
>;
|
|
20
14
|
|
|
21
|
-
/**
|
|
22
|
-
* React hook for withdrawing a hub-side asset back to the user's spoke chain wallet.
|
|
23
|
-
*
|
|
24
|
-
* Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
|
|
25
|
-
* `onError`, `retry`). Returns the spoke tx hash on success, or from an MPC-relay chain (Tron) the
|
|
26
|
-
* relay's `trackingId`, which is not a tx hash: never link it to an explorer.
|
|
27
|
-
*/
|
|
15
|
+
/** Resolves the spoke tx hash, or for an MPC-relay chain a relay `trackingId` that is not a tx hash: never link it to an explorer. */
|
|
28
16
|
export function useWithdrawHubAsset<K extends SpokeChainKey = SpokeChainKey>({
|
|
29
17
|
mutationOptions,
|
|
30
18
|
}: MutationHookParams<SendMessageReturnType<K, false>, UseWithdrawHubAssetVars<K>> = {}): SafeUseMutationResult<
|
|
@@ -2,16 +2,8 @@ import type { QueryClient } from '@tanstack/react-query';
|
|
|
2
2
|
import type { SpokeChainKey } from '@sodax/sdk';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Two balance hooks ship side by side — {@link useBalances} (SDK-backed, keyed under
|
|
8
|
-
* `['shared','balances', …]`) and {@link useXBalances} (wallet-layer, `['shared','xBalances', …]`) —
|
|
9
|
-
* and an app may mount either. React Query matches query keys element-wise, so one key never
|
|
10
|
-
* matches the other; a mutation hook that invalidates only one silently leaves the other stale.
|
|
11
|
-
* Route every post-transaction balance refresh through here so the two cannot drift apart again.
|
|
12
|
-
*
|
|
13
|
-
* `undefined` chain keys are skipped and duplicates collapse, so callers can pass
|
|
14
|
-
* `(src, dst)` without guarding either.
|
|
5
|
+
* Invalidates both `useBalances` and `useXBalances` keys; invalidating only one leaves the other stale.
|
|
6
|
+
* `undefined` keys are skipped and duplicates collapse.
|
|
15
7
|
*/
|
|
16
8
|
export function invalidateBalances(
|
|
17
9
|
queryClient: QueryClient,
|
|
@@ -20,9 +20,6 @@ describe('isUserRejectedError', () => {
|
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
it('does not match a plain Error whose message contains rejection prose', () => {
|
|
23
|
-
// The predicate trusts SDK classification; it does NOT re-scan message content. A bare
|
|
24
|
-
// Error from outside the SDK boundary (e.g. a non-canonical throw in a queryFn) is not a
|
|
25
|
-
// canonical USER_REJECTED — it should fall through to the generic failure UI.
|
|
26
23
|
expect(isUserRejectedError(new Error('User rejected the request'))).toBe(false);
|
|
27
24
|
});
|
|
28
25
|
|
|
@@ -1,29 +1,8 @@
|
|
|
1
1
|
import { isSodaxError } from '@sodax/sdk';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* The SDK classifies wallet rejection at the source: `intentCreationFailed` / `approveFailed`
|
|
7
|
-
* wrappers emit `SodaxError<'USER_REJECTED'>` whenever the underlying cause matches a known
|
|
8
|
-
* rejection shape (viem `4001` / `UserRejectedRequestError`, ICON Hana `CANCEL_SIGNING`,
|
|
9
|
-
* Solana / Sui / Stellar / Stacks / NEAR / Injective name + message patterns). Consumers
|
|
10
|
-
* branch on this code to render a "Cancelled" UI instead of a "Failed" toast — user
|
|
11
|
-
* cancellation is a normal flow, not a failure.
|
|
12
|
-
*
|
|
13
|
-
* Use after `mutateAsyncSafe` (or inside an `onError` / `catch`):
|
|
14
|
-
*
|
|
15
|
-
* ```ts
|
|
16
|
-
* const result = await swap.mutateAsyncSafe({ params, walletProvider });
|
|
17
|
-
* if (!result.ok) {
|
|
18
|
-
* if (isUserRejectedError(result.error)) return; // silent — user cancelled
|
|
19
|
-
* toast.error(getErrorMessage(result.error)); // real failure
|
|
20
|
-
* }
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* The check trusts the SDK's classification — it does NOT re-scan message content. Errors
|
|
24
|
-
* raised outside the SDK boundary (e.g. a non-SodaxError thrown from a `queryFn`) will not
|
|
25
|
-
* match, which is intentional: only the SDK's `USER_REJECTED` is the canonical "cancelled"
|
|
26
|
-
* signal.
|
|
4
|
+
* True only for the SDK's `USER_REJECTED` (wallet prompt cancelled); does not re-scan messages, so
|
|
5
|
+
* non-SodaxError rejections intentionally do not match.
|
|
27
6
|
*/
|
|
28
7
|
export function isUserRejectedError(error: unknown): boolean {
|
|
29
8
|
return isSodaxError(error) && error.code === 'USER_REJECTED';
|
|
@@ -1,29 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Some reads cannot distinguish "still in flight" from "will never resolve" — a solver that has not
|
|
5
|
-
* seen an intent, a relay with no packet for a source tx. Polling those forever is the failure mode
|
|
6
|
-
* a budget exists to stop, but only for that shape: a dependency failing *right now* must keep
|
|
7
|
-
* polling, or a two-minute outage would permanently stick a transfer that is fine.
|
|
8
|
-
*
|
|
9
|
-
* Each feature decides what counts as an ambiguous miss and passes a boolean; the counting,
|
|
10
|
-
* identity and de-duplication are the same everywhere and live here.
|
|
11
|
-
*
|
|
12
|
-
* Kept free of React and context imports so it is unit-testable in dapp-kit's `node` test
|
|
13
|
-
* environment — importing a hook pulls in `useSodaxContext`.
|
|
14
|
-
*/
|
|
1
|
+
// Budget only for ambiguous misses; a dependency failing right now must keep polling.
|
|
2
|
+
// Kept free of React/context imports so it is unit-testable in the `node` test env.
|
|
15
3
|
|
|
16
4
|
export const STATUS_POLL_MS = 3000;
|
|
17
5
|
/** Cap consecutive ambiguous polls (~2 min at 3s). The first one is a race, not a stop. */
|
|
18
6
|
export const MAX_NOT_FOUND_POLLS = 40;
|
|
19
|
-
/**
|
|
20
|
-
* The cap for a read the SDK tags `context.mpcRelay` (~5 min at 3s). An MPC-relay leg waits on confirmations,
|
|
21
|
-
* the NEAR signature and the hub tx, and the SDK itself allows it at least 5 minutes.
|
|
22
|
-
*/
|
|
7
|
+
/** Cap for reads tagged `context.mpcRelay` (~5 min at 3s); the SDK allows an MPC-relay leg at least 5 min. */
|
|
23
8
|
export const MAX_MPC_RELAY_NOT_FOUND_POLLS = 100;
|
|
24
9
|
|
|
25
10
|
export type NotFoundStreakState = {
|
|
26
|
-
/** Identity of what is being polled — an intent tx hash, or a composite source-chain/tx key. */
|
|
27
11
|
pollKey: string | undefined;
|
|
28
12
|
seenUpdates: number;
|
|
29
13
|
consecutiveNotFound: number;
|
|
@@ -40,9 +24,8 @@ export function nextNotFoundStreak(isAmbiguousMiss: boolean, previousStreak: num
|
|
|
40
24
|
}
|
|
41
25
|
|
|
42
26
|
/**
|
|
43
|
-
* Advances
|
|
44
|
-
*
|
|
45
|
-
* than once per fetch — same `dataUpdateCount` is a no-op.
|
|
27
|
+
* Advances once per query update; a new `pollKey` resets the streak. React Query may call
|
|
28
|
+
* `refetchInterval` more than once per fetch, so a repeated `dataUpdateCount` is a no-op.
|
|
46
29
|
*/
|
|
47
30
|
export function advanceNotFoundStreak(
|
|
48
31
|
state: NotFoundStreakState,
|
|
@@ -2,7 +2,6 @@ import { SodaxError } from '@sodax/sdk';
|
|
|
2
2
|
import { describe, expect, it } from 'vitest';
|
|
3
3
|
import { retryUnlessAuthFailure } from './retryUnlessAuthFailure.js';
|
|
4
4
|
|
|
5
|
-
/** A backend failure as the swaps API surfaces it: `EXTERNAL_API_ERROR` with the status on context. */
|
|
6
5
|
const apiError = (status?: number): SodaxError =>
|
|
7
6
|
new SodaxError('EXTERNAL_API_ERROR', `responded with ${status}`, {
|
|
8
7
|
feature: 'backend',
|
|
@@ -18,7 +17,7 @@ describe('retryUnlessAuthFailure', () => {
|
|
|
18
17
|
});
|
|
19
18
|
|
|
20
19
|
it("retries the apiguard's transient 503 and other server failures", () => {
|
|
21
|
-
// 503 is
|
|
20
|
+
// 503 is not terminal: the key may be fine while verification is down.
|
|
22
21
|
for (const status of [408, 429, 500, 502, 503, 504]) {
|
|
23
22
|
expect(retryUnlessAuthFailure(0, apiError(status))).toBe(true);
|
|
24
23
|
}
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
import { isAuthFailure } from '@sodax/sdk';
|
|
2
2
|
|
|
3
|
-
/** Retries a repeatable failure gets, matching the `retry: 3` these hooks used before. */
|
|
4
3
|
const MAX_RETRIES = 3;
|
|
5
4
|
|
|
6
|
-
/**
|
|
7
|
-
* Default React Query `retry` policy for the backend API hooks (swaps, leverage-yield, bridge): replay a transport blip, never a
|
|
8
|
-
* terminal API-key rejection (see `isAuthFailure`). Retrying a rejected key only multiplies doomed
|
|
9
|
-
* requests before the consumer sees the error.
|
|
10
|
-
*
|
|
11
|
-
* Override or compose it through `queryOptions` / `mutationOptions`:
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* useSwapsApiQuote({ params: { body }, queryOptions: { retry: 5 } });
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
5
|
+
/** Default `retry` for backend API hooks: retries transport failures, never a rejected API key. */
|
|
17
6
|
export const retryUnlessAuthFailure = (failureCount: number, error: unknown): boolean =>
|
|
18
7
|
!isAuthFailure(error) && failureCount < MAX_RETRIES;
|
|
@@ -9,11 +9,6 @@ import {
|
|
|
9
9
|
} from './notFoundStreak.js';
|
|
10
10
|
import { getSolverStatusRefetchInterval, isSolverNotFound } from './solverStatusPolicy.js';
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* Guards the polling-stop invariant for `useStatus.refetchInterval`: keep polling until SOLVED/
|
|
14
|
-
* FAILED, or until NOT_FOUND has been consecutive for MAX_NOT_FOUND_POLLS successful fetches.
|
|
15
|
-
* Tested as a pure function because dapp-kit's vitest runs in the `node` environment.
|
|
16
|
-
*/
|
|
17
12
|
const HASH_A = '0xaaa';
|
|
18
13
|
const HASH_B = '0xbbb';
|
|
19
14
|
const ok = (status: SolverIntentStatusCode) => ({ ok: true as const, value: { status } });
|