@sodax/dapp-kit 2.4.0-rc.1 → 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 +11 -3
- package/dist/index.d.ts +395 -2413
- package/dist/index.mjs +206 -31
- package/package.json +2 -2
- package/src/hooks/_apiKeyWire.test.ts +4 -29
- package/src/hooks/_mutationContract.test.ts +2 -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/index.ts +4 -0
- 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 +112 -0
- package/src/hooks/shared/useEstablishXrpTrustline.ts +63 -0
- 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 +71 -0
- package/src/hooks/shared/useXrpGate.test.ts +116 -0
- package/src/hooks/shared/useXrpGate.ts +80 -0
- package/src/hooks/shared/useXrpTrustlineReserveCheck.ts +45 -0
- 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 +47 -2
- package/src/hooks/swap/useSwapLifecycle.ts +36 -30
- 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/index.ts +1 -0
- package/src/utils/nearStorageGate.ts +3 -14
- package/src/utils/stellarGate.ts +3 -16
- package/src/utils/swapLifecycle.test.ts +35 -0
- package/src/utils/swapLifecycle.ts +21 -28
- package/src/utils/xrpGate.test.ts +112 -0
- package/src/utils/xrpGate.ts +69 -0
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isSodaxError, isAuthFailure, ChainKeys, STELLAR_TRUSTLINE_MIN_XLM_STROOPS, RadfiApiError, normalizePsbtToBase64, summarizeSwapStatus, isEvmChainKeyType, resolveApprovalStrategy, isEvmSpokeOnlyChainKeyType, sendApprovalBatch, DEFAULT_RELAY_TX_TIMEOUT, isAtomicBatchRefusal, SodaxError, ATOMIC_BATCH_REFUSED, getEvmViemChain, DETAILED_STATUS_NOT_DELIVERED, ClService, SPONSOR_CONFIG_TTL_MS, Sodax, isIndeterminateOutcomeError, ATOMIC_BATCH_UNCONFIRMED, SolverIntentStatusCode, isApprovalSupportedChainKeyType, isHubChainKeyType, isStellarChainKeyType } from '@sodax/sdk';
|
|
1
|
+
import { isSodaxError, isAuthFailure, ChainKeys, STELLAR_TRUSTLINE_MIN_XLM_STROOPS, RadfiApiError, normalizePsbtToBase64, SOLVED_PAYOUT_HEADROOM_FACTOR, summarizeSwapStatus, isEvmChainKeyType, resolveApprovalStrategy, isEvmSpokeOnlyChainKeyType, sendApprovalBatch, DEFAULT_RELAY_TX_TIMEOUT, isAtomicBatchRefusal, SodaxError, ATOMIC_BATCH_REFUSED, getEvmViemChain, DETAILED_STATUS_NOT_DELIVERED, ClService, SPONSOR_CONFIG_TTL_MS, Sodax, isIndeterminateOutcomeError, ATOMIC_BATCH_UNCONFIRMED, SolverIntentStatusCode, isApprovalSupportedChainKeyType, isHubChainKeyType, isStellarChainKeyType } from '@sodax/sdk';
|
|
2
2
|
export * from '@sodax/sdk';
|
|
3
3
|
import { useQueryClient, useMutation, useQuery, useIsFetching, useQueries, QueryClient, MutationCache } from '@tanstack/react-query';
|
|
4
4
|
import { createContext, useCallback, useContext, useRef, useState, useEffect, useMemo } from 'react';
|
|
@@ -108,7 +108,6 @@ function getStellarTrustlineCheckQueryOptions({
|
|
|
108
108
|
walletAddress
|
|
109
109
|
}) {
|
|
110
110
|
return {
|
|
111
|
-
// Key on chain, token, account, amount so editing the amount (or switching account/chain) re-queries.
|
|
112
111
|
queryKey: ["shared", "stellarTrustlineCheck", chainId, token, walletAddress, amount?.toString()],
|
|
113
112
|
queryFn: async () => {
|
|
114
113
|
if (chainId !== ChainKeys.STELLAR_MAINNET) return true;
|
|
@@ -231,6 +230,7 @@ function useRegisterNearStorage({
|
|
|
231
230
|
return useSafeMutation({
|
|
232
231
|
mutationKey: ["shared", "registerNearStorage"],
|
|
233
232
|
...mutationOptions,
|
|
233
|
+
// `registerStorage` throws natively (no Result), hence `nativeThrow` in the mutation contract.
|
|
234
234
|
mutationFn: async ({ token, accountId, walletProvider, deposit }) => sodax.spoke.near.registerStorage({ token, accountId, walletProvider, deposit, raw: false }),
|
|
235
235
|
onSuccess: async (data, vars, ctx) => {
|
|
236
236
|
queryClient.invalidateQueries({
|
|
@@ -411,6 +411,171 @@ function useStellarGate({
|
|
|
411
411
|
requestTrustline
|
|
412
412
|
};
|
|
413
413
|
}
|
|
414
|
+
function getXrpDestinationCheckQueryOptions({
|
|
415
|
+
sodax,
|
|
416
|
+
chainId,
|
|
417
|
+
token,
|
|
418
|
+
address,
|
|
419
|
+
amount,
|
|
420
|
+
maxAmount
|
|
421
|
+
}) {
|
|
422
|
+
return {
|
|
423
|
+
queryKey: [
|
|
424
|
+
"shared",
|
|
425
|
+
"xrpDestinationCheck",
|
|
426
|
+
chainId,
|
|
427
|
+
token,
|
|
428
|
+
address,
|
|
429
|
+
amount?.toString(),
|
|
430
|
+
maxAmount?.toString()
|
|
431
|
+
],
|
|
432
|
+
queryFn: async () => {
|
|
433
|
+
if (!address || !token || amount === void 0) throw new Error("address, token and amount are required");
|
|
434
|
+
return sodax.spoke.xrp.checkDestination({ address, token, amount, maxAmount });
|
|
435
|
+
},
|
|
436
|
+
enabled: chainId === ChainKeys.XRP_MAINNET && !!address && !!token && amount !== void 0
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
function useXrpDestinationCheck({
|
|
440
|
+
params,
|
|
441
|
+
queryOptions
|
|
442
|
+
} = {}) {
|
|
443
|
+
const { sodax } = useSodaxContext();
|
|
444
|
+
return useQuery({
|
|
445
|
+
...getXrpDestinationCheckQueryOptions({
|
|
446
|
+
sodax,
|
|
447
|
+
chainId: params?.chainId,
|
|
448
|
+
token: params?.token,
|
|
449
|
+
address: params?.address,
|
|
450
|
+
amount: params?.amount,
|
|
451
|
+
maxAmount: params?.maxAmount
|
|
452
|
+
}),
|
|
453
|
+
...queryOptions
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
function getXrpTrustlineReserveCheckQueryOptions({
|
|
457
|
+
sodax,
|
|
458
|
+
token,
|
|
459
|
+
address
|
|
460
|
+
}) {
|
|
461
|
+
return {
|
|
462
|
+
queryKey: ["shared", "xrpTrustlineReserveCheck", token, address],
|
|
463
|
+
queryFn: async () => {
|
|
464
|
+
if (!address || !token) throw new Error("address and token are required");
|
|
465
|
+
return sodax.spoke.xrp.canAffordTrustline({ address, token });
|
|
466
|
+
},
|
|
467
|
+
enabled: !!address && !!token
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
function useXrpTrustlineReserveCheck({
|
|
471
|
+
params,
|
|
472
|
+
queryOptions
|
|
473
|
+
} = {}) {
|
|
474
|
+
const { sodax } = useSodaxContext();
|
|
475
|
+
return useQuery({
|
|
476
|
+
...getXrpTrustlineReserveCheckQueryOptions({ sodax, token: params?.token, address: params?.address }),
|
|
477
|
+
...queryOptions
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
function useEstablishXrpTrustline({
|
|
481
|
+
mutationOptions
|
|
482
|
+
} = {}) {
|
|
483
|
+
const { sodax } = useSodaxContext();
|
|
484
|
+
const queryClient = useQueryClient();
|
|
485
|
+
return useSafeMutation({
|
|
486
|
+
mutationKey: ["shared", "establishXrpTrustline"],
|
|
487
|
+
...mutationOptions,
|
|
488
|
+
// Each TrustSet costs a fee, so one that may have been sent is never signed again automatically.
|
|
489
|
+
retry: retryBeforeSubmission(
|
|
490
|
+
mutationOptions?.retry ?? queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ["shared", "establishXrpTrustline"])?.retry ?? queryClient.getDefaultOptions?.().mutations?.retry
|
|
491
|
+
),
|
|
492
|
+
mutationFn: async ({ token, address, walletProvider }) => {
|
|
493
|
+
const srcAddress = await walletProvider.getWalletAddress();
|
|
494
|
+
if (address !== void 0 && address !== srcAddress) {
|
|
495
|
+
throw new Error(
|
|
496
|
+
`The connected XRPL account ${srcAddress} is not ${address}, which needs the trustline \u2014 connect ${address} to add it`
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
return unwrapResult(await sodax.spoke.xrp.requestTrustline({ srcAddress, token, walletProvider }));
|
|
500
|
+
},
|
|
501
|
+
onSuccess: async (data, vars, ctx) => {
|
|
502
|
+
const address = vars.address ?? await vars.walletProvider.getWalletAddress().catch(() => void 0);
|
|
503
|
+
queryClient.invalidateQueries({
|
|
504
|
+
queryKey: address ? ["shared", "xrpDestinationCheck", ChainKeys.XRP_MAINNET, vars.token, address] : ["shared", "xrpDestinationCheck"]
|
|
505
|
+
});
|
|
506
|
+
queryClient.invalidateQueries({ queryKey: ["shared", "xrpTrustlineReserveCheck"] });
|
|
507
|
+
invalidateBalances(queryClient, ChainKeys.XRP_MAINNET);
|
|
508
|
+
await mutationOptions?.onSuccess?.(data, vars, ctx);
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
var NOT_XRP_ISSUED_TOKEN = {
|
|
513
|
+
isXrpIssuedToken: false,
|
|
514
|
+
needsTrustline: false,
|
|
515
|
+
needsFunding: false,
|
|
516
|
+
blockedReason: void 0,
|
|
517
|
+
checkFailed: false,
|
|
518
|
+
blocksAction: false
|
|
519
|
+
};
|
|
520
|
+
function unresolved2(check) {
|
|
521
|
+
return check.isLoading || check.data === void 0;
|
|
522
|
+
}
|
|
523
|
+
function resolveXrpGate(chainKey, inputs) {
|
|
524
|
+
const { readinessCheck, reserveCheck, requiresTrustline } = inputs;
|
|
525
|
+
if (chainKey !== ChainKeys.XRP_MAINNET || !requiresTrustline) return NOT_XRP_ISSUED_TOKEN;
|
|
526
|
+
const base = { ...NOT_XRP_ISSUED_TOKEN, isXrpIssuedToken: true };
|
|
527
|
+
if (readinessCheck.isError) return { ...base, checkFailed: true, blocksAction: true };
|
|
528
|
+
const readiness = readinessCheck.data;
|
|
529
|
+
if (readinessCheck.isLoading || readiness === void 0) return { ...base, blocksAction: true };
|
|
530
|
+
if (readiness.ready) return base;
|
|
531
|
+
if (readiness.reason !== "no_trustline" && readiness.reason !== "trustline_limit") {
|
|
532
|
+
return { ...base, blockedReason: readiness.reason, blocksAction: true };
|
|
533
|
+
}
|
|
534
|
+
if (reserveCheck.isError) return { ...base, checkFailed: true, blocksAction: true };
|
|
535
|
+
if (unresolved2(reserveCheck)) return { ...base, blocksAction: true };
|
|
536
|
+
if (reserveCheck.data !== true) return { ...base, needsFunding: true, blocksAction: true };
|
|
537
|
+
return { ...base, needsTrustline: true, blocksAction: true };
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// src/hooks/shared/useXrpGate.ts
|
|
541
|
+
function useXrpGate({
|
|
542
|
+
dstChainKey,
|
|
543
|
+
token,
|
|
544
|
+
address,
|
|
545
|
+
amount,
|
|
546
|
+
maxAmount,
|
|
547
|
+
walletProvider
|
|
548
|
+
}) {
|
|
549
|
+
const { sodax } = useSodaxContext();
|
|
550
|
+
const isXrpDestination = dstChainKey === ChainKeys.XRP_MAINNET;
|
|
551
|
+
const requiresTrustline = isXrpDestination && !!token && sodax.spoke.xrp.requiresTrustline(token);
|
|
552
|
+
const xrpWalletProvider = walletProvider?.chainType === "XRP" ? walletProvider : void 0;
|
|
553
|
+
const readinessCheck = useXrpDestinationCheck({
|
|
554
|
+
params: { chainId: requiresTrustline ? dstChainKey : void 0, token, address, amount, maxAmount }
|
|
555
|
+
});
|
|
556
|
+
const trustlineReason = readinessCheck.data?.ready === false && (readinessCheck.data.reason === "no_trustline" || readinessCheck.data.reason === "trustline_limit");
|
|
557
|
+
const reserveCheck = useXrpTrustlineReserveCheck({
|
|
558
|
+
params: { token: trustlineReason ? token : void 0, address: trustlineReason ? address : void 0 }
|
|
559
|
+
});
|
|
560
|
+
const state = resolveXrpGate(dstChainKey, { readinessCheck, reserveCheck, requiresTrustline });
|
|
561
|
+
const { mutateAsyncSafe: establishTrustline, isPending: isRequestingTrustline } = useEstablishXrpTrustline();
|
|
562
|
+
const requestTrustline = async () => {
|
|
563
|
+
if (!xrpWalletProvider || !token || !address) return void 0;
|
|
564
|
+
return establishTrustline({ token, address, walletProvider: xrpWalletProvider });
|
|
565
|
+
};
|
|
566
|
+
const retry = () => {
|
|
567
|
+
void readinessCheck.refetch();
|
|
568
|
+
if (trustlineReason) void reserveCheck.refetch();
|
|
569
|
+
};
|
|
570
|
+
return {
|
|
571
|
+
...state,
|
|
572
|
+
isChecking: readinessCheck.isLoading || reserveCheck.isLoading,
|
|
573
|
+
error: readinessCheck.error ?? reserveCheck.error ?? void 0,
|
|
574
|
+
retry,
|
|
575
|
+
isRequestingTrustline,
|
|
576
|
+
requestTrustline
|
|
577
|
+
};
|
|
578
|
+
}
|
|
414
579
|
var SESSION_KEY = (address) => `radfi_session_${address}`;
|
|
415
580
|
function saveRadfiSession(address, session) {
|
|
416
581
|
try {
|
|
@@ -513,8 +678,7 @@ function useGetUserHubWalletAddress({
|
|
|
513
678
|
var REFETCH_INTERVAL_MS = 5e3;
|
|
514
679
|
function getXBalancesQueryOptions({ xService, xChainId, xTokens, address }) {
|
|
515
680
|
return {
|
|
516
|
-
//
|
|
517
|
-
// can collide — e.g. scam tokens copying legitimate ticker).
|
|
681
|
+
// Symbol alone can collide (scam tokens copy tickers), so pair it with the address.
|
|
518
682
|
queryKey: ["shared", "xBalances", xChainId, xTokens.map((x) => [x.symbol, x.address]), address],
|
|
519
683
|
queryFn: async () => {
|
|
520
684
|
if (!xService) return {};
|
|
@@ -542,8 +706,7 @@ var REFETCH_INTERVAL_MS2 = 5e3;
|
|
|
542
706
|
function getBalancesQueryOptions(sodax, { chainKey, tokens, address, accountAddress }) {
|
|
543
707
|
const tonAccount = chainKey === ChainKeys.TON_MAINNET && accountAddress ? { accountAddress } : void 0;
|
|
544
708
|
return {
|
|
545
|
-
//
|
|
546
|
-
// e.g. scam tokens copying a legitimate ticker).
|
|
709
|
+
// Symbol alone can collide (scam tokens copy tickers), so pair it with the address.
|
|
547
710
|
queryKey: [
|
|
548
711
|
"shared",
|
|
549
712
|
"balances",
|
|
@@ -560,9 +723,8 @@ function getBalancesQueryOptions(sodax, { chainKey, tokens, address, accountAddr
|
|
|
560
723
|
},
|
|
561
724
|
enabled: !!chainKey && !!address && tokens.length > 0,
|
|
562
725
|
refetchInterval: REFETCH_INTERVAL_MS2
|
|
563
|
-
//
|
|
564
|
-
//
|
|
565
|
-
// token address, so its native balance would render as the new chain's until the fetch lands.
|
|
726
|
+
// No `keepPreviousData`: EVM chains share the native token address, so a chain switch would
|
|
727
|
+
// show the previous chain's native balance until the fetch lands.
|
|
566
728
|
};
|
|
567
729
|
}
|
|
568
730
|
function useBalances({ params, queryOptions } = {}) {
|
|
@@ -997,20 +1159,22 @@ function useMMAllowance({
|
|
|
997
1159
|
} = {}) {
|
|
998
1160
|
const { sodax } = useSodaxContext();
|
|
999
1161
|
const payload = params?.payload;
|
|
1162
|
+
const needsApproval = payload?.action !== "borrow" && payload?.action !== "withdraw";
|
|
1000
1163
|
return useQuery({
|
|
1001
1164
|
queryKey: ["mm", "allowance", payload?.srcChainKey, payload?.token, payload?.action],
|
|
1002
1165
|
queryFn: async () => {
|
|
1003
1166
|
if (!payload) {
|
|
1004
1167
|
throw new Error("Params are required");
|
|
1005
1168
|
}
|
|
1006
|
-
if (
|
|
1169
|
+
if (!needsApproval) {
|
|
1007
1170
|
return true;
|
|
1008
1171
|
}
|
|
1009
1172
|
const result = await sodax.moneyMarket.isAllowanceValid({ params: payload });
|
|
1010
1173
|
if (!result.ok) throw result.error;
|
|
1011
1174
|
return result.value;
|
|
1012
1175
|
},
|
|
1013
|
-
|
|
1176
|
+
initialData: () => payload && !needsApproval ? true : void 0,
|
|
1177
|
+
enabled: !!payload && needsApproval,
|
|
1014
1178
|
refetchInterval: 5e3,
|
|
1015
1179
|
gcTime: 0,
|
|
1016
1180
|
...queryOptions
|
|
@@ -1317,8 +1481,7 @@ function useSwapAllowance({
|
|
|
1317
1481
|
const srcChainKey = params?.srcChainKey;
|
|
1318
1482
|
const walletProvider = params?.walletProvider;
|
|
1319
1483
|
return useQuery({
|
|
1320
|
-
//
|
|
1321
|
-
// raw-object keys break per Rule 4 (bigints) and churn on every render.
|
|
1484
|
+
// Key on the scoping tuple only: raw payload objects hold bigints and churn every render.
|
|
1322
1485
|
queryKey: [
|
|
1323
1486
|
"swap",
|
|
1324
1487
|
"allowance",
|
|
@@ -1466,19 +1629,25 @@ function resolveSwapLifecycle(inputs) {
|
|
|
1466
1629
|
if (!inputs.hasInputs) return { kind: "idle" };
|
|
1467
1630
|
const reason = setupReason(inputs);
|
|
1468
1631
|
if (reason) return inputs.setupBusy ? { kind: "checking" } : { kind: "needsSetup", reason };
|
|
1469
|
-
if (inputs.stellar.blocksAction || inputs.nearStorage.blocksAction)
|
|
1632
|
+
if (inputs.stellar.blocksAction || inputs.nearStorage.blocksAction || inputs.xrp.blocksAction) {
|
|
1633
|
+
return { kind: "checking" };
|
|
1634
|
+
}
|
|
1470
1635
|
if (inputs.isWrongChain) return { kind: "needsChainSwitch" };
|
|
1471
1636
|
if (inputs.strategy.error && !inputs.strategy.data) return { kind: "failed", error: inputs.strategy.error };
|
|
1472
1637
|
if (!inputs.strategy.data) return { kind: "checking" };
|
|
1473
1638
|
return { kind: "ready", approvalStrategy: inputs.strategy.data };
|
|
1474
1639
|
}
|
|
1475
|
-
function setupReason({ stellar, nearStorage, externalBlocked }) {
|
|
1640
|
+
function setupReason({ stellar, nearStorage, xrp, externalBlocked }) {
|
|
1476
1641
|
if (stellar.needsActivation) return "stellarActivation";
|
|
1477
1642
|
if (stellar.needsFunding) return "stellarFunding";
|
|
1478
1643
|
if (stellar.needsTrustline) return "stellarTrustline";
|
|
1479
1644
|
if (stellar.checkFailed) return "stellarCheckFailed";
|
|
1480
1645
|
if (nearStorage.needsRegistration) return "nearStorage";
|
|
1481
1646
|
if (nearStorage.checkFailed) return "nearStorageCheckFailed";
|
|
1647
|
+
if (xrp.blockedReason) return "xrpBlocked";
|
|
1648
|
+
if (xrp.needsFunding) return "xrpFunding";
|
|
1649
|
+
if (xrp.needsTrustline) return "xrpTrustline";
|
|
1650
|
+
if (xrp.checkFailed) return "xrpCheckFailed";
|
|
1482
1651
|
if (externalBlocked) return "external";
|
|
1483
1652
|
return void 0;
|
|
1484
1653
|
}
|
|
@@ -1513,7 +1682,16 @@ function useSwapLifecycle({
|
|
|
1513
1682
|
accountId: intentParams?.dstAddress,
|
|
1514
1683
|
walletProvider: dstWalletProvider
|
|
1515
1684
|
});
|
|
1516
|
-
const
|
|
1685
|
+
const xrp = useXrpGate({
|
|
1686
|
+
dstChainKey: intentParams?.dstChainKey,
|
|
1687
|
+
token: intentParams?.outputToken,
|
|
1688
|
+
address: intentParams?.dstAddress,
|
|
1689
|
+
// Sized as the SDK's check before signing sizes it, so the gate never passes a swap the SDK then refuses.
|
|
1690
|
+
amount: intentParams?.minOutputAmount,
|
|
1691
|
+
maxAmount: intentParams && intentParams.minOutputAmount * SOLVED_PAYOUT_HEADROOM_FACTOR,
|
|
1692
|
+
walletProvider: dstWalletProvider
|
|
1693
|
+
});
|
|
1694
|
+
const fetchingSetupChecks = useIsFetching({ queryKey: ["sponsoring", "stellarAccountStatus"] }) + useIsFetching({ queryKey: ["shared", "stellarTrustlineCheck"] }) + useIsFetching({ queryKey: ["shared", "nearStorageCheck"] }) + useIsFetching({ queryKey: ["shared", "xrpDestinationCheck"] }) + useIsFetching({ queryKey: ["shared", "xrpTrustlineReserveCheck"] });
|
|
1517
1695
|
const attempt = toSwapAttempt(swap, intentParams);
|
|
1518
1696
|
const broadcast = attempt.phase === "broadcast" ? attempt : void 0;
|
|
1519
1697
|
const status = useDetailedStatus({
|
|
@@ -1526,8 +1704,9 @@ function useSwapLifecycle({
|
|
|
1526
1704
|
hasInputs: !!intentParams && !!srcWalletProvider,
|
|
1527
1705
|
stellar,
|
|
1528
1706
|
nearStorage,
|
|
1707
|
+
xrp,
|
|
1529
1708
|
externalBlocked,
|
|
1530
|
-
setupBusy: stellar.isActivating || stellar.isRequestingTrustline || nearStorage.isRegistering || fetchingSetupChecks > 0,
|
|
1709
|
+
setupBusy: stellar.isActivating || stellar.isRequestingTrustline || nearStorage.isRegistering || xrp.isRequestingTrustline || fetchingSetupChecks > 0,
|
|
1531
1710
|
isWrongChain: chainSwitch?.isWrongChain ?? false,
|
|
1532
1711
|
strategy: { data: approvalStrategy.data, error: approvalStrategy.error }
|
|
1533
1712
|
});
|
|
@@ -1547,6 +1726,8 @@ function useSwapLifecycle({
|
|
|
1547
1726
|
if (state.reason === "nearStorage") return nearStorage.registerStorage();
|
|
1548
1727
|
if (state.reason === "stellarCheckFailed") stellar.retry();
|
|
1549
1728
|
if (state.reason === "nearStorageCheckFailed") nearStorage.retry();
|
|
1729
|
+
if (state.reason === "xrpTrustline") return xrp.requestTrustline();
|
|
1730
|
+
if (state.reason === "xrpCheckFailed") xrp.retry();
|
|
1550
1731
|
return void 0;
|
|
1551
1732
|
case "ready":
|
|
1552
1733
|
if (!intentParams || !srcWalletProvider) return void 0;
|
|
@@ -1592,7 +1773,8 @@ function useSwapLifecycle({
|
|
|
1592
1773
|
swap,
|
|
1593
1774
|
status,
|
|
1594
1775
|
stellar,
|
|
1595
|
-
nearStorage
|
|
1776
|
+
nearStorage,
|
|
1777
|
+
xrp
|
|
1596
1778
|
};
|
|
1597
1779
|
}
|
|
1598
1780
|
|
|
@@ -1903,10 +2085,7 @@ var useSwapsApiQuote = ({
|
|
|
1903
2085
|
const query = params?.query;
|
|
1904
2086
|
const apiConfig = params?.apiConfig;
|
|
1905
2087
|
return useQuery({
|
|
1906
|
-
//
|
|
1907
|
-
// SwapExtrasV2 fields — is a cache dimension; a partnerFee change alters the quote and must
|
|
1908
|
-
// miss the cache. QuoteRequestV2 is bigint-free (compile-time guaranteed), so React Query's
|
|
1909
|
-
// default key hashing handles the object directly.
|
|
2088
|
+
// Key on the whole (bigint-free) body so every input, e.g. partnerFee, is a cache dimension.
|
|
1910
2089
|
queryKey: ["swapsApi", "quote", body, query?.includeTxData ?? false],
|
|
1911
2090
|
queryFn: async () => {
|
|
1912
2091
|
if (!body) return void 0;
|
|
@@ -2002,8 +2181,7 @@ function resolveChainSender(srcChainKey, walletProvider, hookName) {
|
|
|
2002
2181
|
if (isHubChainKeyType(srcChainKey) || isEvmSpokeOnlyChainKeyType(srcChainKey)) {
|
|
2003
2182
|
const evm = walletProvider;
|
|
2004
2183
|
return {
|
|
2005
|
-
// Chain-bind the send: the wallet broadcasts on ITS active chain, so refuse when
|
|
2006
|
-
// from the srcChainKey the user asked for. (Verifying the tx CONTENT is a separate concern.)
|
|
2184
|
+
// Chain-bind the send: the wallet broadcasts on ITS active chain, so refuse when it differs from srcChainKey.
|
|
2007
2185
|
send: (raw) => evm.sendTransaction(raw, { expectedChainId: getEvmViemChain(srcChainKey).id }),
|
|
2008
2186
|
confirm: async (hash, step) => {
|
|
2009
2187
|
const receipt = await evm.waitForTransactionReceipt(hash);
|
|
@@ -2512,8 +2690,7 @@ function useBridgeAllowance({
|
|
|
2512
2690
|
const payload = params?.payload;
|
|
2513
2691
|
const walletProvider = params?.walletProvider;
|
|
2514
2692
|
return useQuery({
|
|
2515
|
-
//
|
|
2516
|
-
// raw-object keys break per Rule 4 (bigints) and churn on every render.
|
|
2693
|
+
// Key on the scoping tuple only: raw payload objects hold bigints and churn every render.
|
|
2517
2694
|
queryKey: [
|
|
2518
2695
|
"bridge",
|
|
2519
2696
|
"allowance",
|
|
@@ -3595,8 +3772,7 @@ function useMigrationAllowance({
|
|
|
3595
3772
|
const migrationParams = params?.params;
|
|
3596
3773
|
const action = params?.action;
|
|
3597
3774
|
return useQuery({
|
|
3598
|
-
//
|
|
3599
|
-
// raw-object keys break per Rule 4 (bigints) and churn on every render.
|
|
3775
|
+
// Key on the scoping tuple: raw params hold bigints and churn every render.
|
|
3600
3776
|
queryKey: [
|
|
3601
3777
|
"migrate",
|
|
3602
3778
|
"allowance",
|
|
@@ -3999,7 +4175,7 @@ function createDepositParamsProps({
|
|
|
3999
4175
|
const originalAsset = tokenIndex === 0 ? poolSpokeAssets.token0 : poolSpokeAssets.token1;
|
|
4000
4176
|
return {
|
|
4001
4177
|
asset: originalAsset.address,
|
|
4002
|
-
//
|
|
4178
|
+
// Deposit token (original asset) decimals, not the pool token's.
|
|
4003
4179
|
amount: parseUnits(String(amount), originalAsset.decimals),
|
|
4004
4180
|
poolToken: token.address
|
|
4005
4181
|
};
|
|
@@ -4499,7 +4675,6 @@ function useLeveragePositionCollateral({
|
|
|
4499
4675
|
return result.value;
|
|
4500
4676
|
},
|
|
4501
4677
|
enabled: !!position,
|
|
4502
|
-
// Interest accrues into the balance continuously, so match the account snapshot's cadence.
|
|
4503
4678
|
refetchInterval: 3e4,
|
|
4504
4679
|
...queryOptions
|
|
4505
4680
|
});
|
|
@@ -5337,4 +5512,4 @@ function createSodaxQueryClient({
|
|
|
5337
5512
|
});
|
|
5338
5513
|
}
|
|
5339
5514
|
|
|
5340
|
-
export { SodaxProvider, clearRadfiSession, createDecreaseLiquidityParamsProps, createDepositParamsProps, createSodaxQueryClient, createSupplyLiquidityParamsProps, createWithdrawParamsProps, getBalancesQueryOptions, getBridgeDetailedStatusRefetchInterval, getLeverageYieldQuoteQueryOptions, getSponsorConfigQueryOptions, getStellarAccountActiveQueryOptions, getStellarAccountStatusQueryOptions, getStellarTrustlineCheckQueryOptions, getSwapQuoteQueryOptions, getXBalancesQueryOptions, invalidateBalances, isBridgeMpcRelayRead, isBridgeNotDelivered, isTerminalSwapIntentStatus, isUserRejectedError, loadRadfiSession, resolveNearStorageGate, resolveStellarGate, retryUnlessAuthFailure, runApprovalPlan, saveRadfiSession, toResult, unwrapResult, useAToken, useATokensBalances, useActivateStellarAccount, useApproveLeveragePositionFunding, 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, useBridgeApprovalStrategy, useBridgeApprove, useBridgeDetailedStatus, useBridgeWithApproval, useCancelLimitOrder, useCancelSwap, useCancelUnstake, useClaim, useClaimRewards, useConvertedAssets, useCreateDecreaseLiquidityParams, useCreateDepositParams, useCreateLimitOrder, useCreateSupplyLiquidityParams, useCreateWithdrawParams, useDecreaseLiquidity, useDeriveUserWalletAddress, useDetailedStatus, useDexAllowance, useDexApprove, useDexDeposit, useDexWithdraw, useEModes, useEnsureRadfiAccessToken, useEstablishTrustline, useEstimateGas, useExpiredUtxos, useFeeClaimSwap, useFeeClaimWithdraw, useFetchAssetsBalances, useFundTradingWallet, useGetAutoSwapPreferences, useGetBridgeableAmount, useGetBridgeableTokens, useGetIntentDetails, useGetUserHubWalletAddress, useGetUserIntent, useHubAssetBalances, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useIsTokenApproved, useLeveragePositionAccount, useLeveragePositionCollateral, useLeveragePositionFundingAllowance, useLeveragePositionInfo, useLeveragePositionPayoutAddress, useLeveragePositionPending, useLeveragePositions, useLeveragePositionsForUser, useLeverageYieldApiAllowance, useLeverageYieldApiApprove, useLeverageYieldApiApproveAndBroadcast, useLeverageYieldApiApr, useLeverageYieldApiAsset, useLeverageYieldApiCancelIntent, useLeverageYieldApiCreateDepositIntent, useLeverageYieldApiCreateWithdrawIntent, useLeverageYieldApiDeadline, useLeverageYieldApiDepositQuote, useLeverageYieldApiEffectiveApr, useLeverageYieldApiEstimateGas, useLeverageYieldApiFilledIntent, useLeverageYieldApiIntent, useLeverageYieldApiIntentExtraData, useLeverageYieldApiIntentHash, useLeverageYieldApiIntentPacket, useLeverageYieldApiLsdApr, useLeverageYieldApiMaxWithdraw, useLeverageYieldApiPartnerFee, useLeverageYieldApiPosition, useLeverageYieldApiPreviewDeposit, useLeverageYieldApiPreviewRedeem, useLeverageYieldApiPreviewWithdraw, useLeverageYieldApiShareBalance, useLeverageYieldApiSolverFee, useLeverageYieldApiStatus, useLeverageYieldApiSubmitIntent, useLeverageYieldApiSubmitTx, useLeverageYieldApiSubmitTxStatus, useLeverageYieldApiTotalAssets, useLeverageYieldApiVault, useLeverageYieldApiVaults, useLeverageYieldApiWithdrawQuote, useLeverageYieldApprovalStrategy, useLeverageYieldDeposit, useLeverageYieldDetailedStatus, useLeverageYieldEffectiveApr, useLeverageYieldNotifySolver, useLeverageYieldPosition, useLeverageYieldPreviewRedeem, useLeverageYieldQuote, useLeverageYieldShareBalances, useLeverageYieldTotalAssets, useLeverageYieldVaultSwap, useLeverageYieldVaultSwapWithApproval, useLeverageYieldWithdraw, useLiquidityAmounts, useMMAllowance, useMMApprove, useMigrateBaln, useMigrateIcxToSoda, useMigratebnUSD, useMigrationAllowance, useMigrationApprove, useNearStorageCheck, useNearStorageGate, useOpenLeveragePosition, usePartnerCancelIntent, usePoolBalances, usePoolData, usePools, usePositionInfo, useQuote, useRadfiAuth, useRadfiSession, useRadfiWithdraw, useRegisterNearStorage, useRenewUtxos, useRepay, useRequestTrustline, useReservesData, useReservesHumanized, useReservesList, useReservesUsdFormat, useRevertMigrateSodaToIcx, useRunLeveragePositionOperation, useSafeMutation, useSetSwapPreference, useSodaxContext, useSponsorConfig, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarAccountActive, useStellarAccountStatus, useStellarGate, useStellarTrustlineCheck, useSubmitLeveragePositionIntent, useSupply, useSupplyLiquidity, useSwap, useSwapAllowance, useSwapApprovalStrategy, useSwapApprove, useSwapLifecycle, useSwapWithApproval, useSwapsApiAllowance, useSwapsApiApprove, useSwapsApiApproveAndBroadcast, useSwapsApiBroadcastWithApproval, 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 };
|
|
5515
|
+
export { SodaxProvider, clearRadfiSession, createDecreaseLiquidityParamsProps, createDepositParamsProps, createSodaxQueryClient, createSupplyLiquidityParamsProps, createWithdrawParamsProps, getBalancesQueryOptions, getBridgeDetailedStatusRefetchInterval, getLeverageYieldQuoteQueryOptions, getSponsorConfigQueryOptions, getStellarAccountActiveQueryOptions, getStellarAccountStatusQueryOptions, getStellarTrustlineCheckQueryOptions, getSwapQuoteQueryOptions, getXBalancesQueryOptions, getXrpDestinationCheckQueryOptions, getXrpTrustlineReserveCheckQueryOptions, invalidateBalances, isBridgeMpcRelayRead, isBridgeNotDelivered, isTerminalSwapIntentStatus, isUserRejectedError, loadRadfiSession, resolveNearStorageGate, resolveStellarGate, resolveXrpGate, retryUnlessAuthFailure, runApprovalPlan, saveRadfiSession, toResult, unwrapResult, useAToken, useATokensBalances, useActivateStellarAccount, useApproveLeveragePositionFunding, 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, useBridgeApprovalStrategy, useBridgeApprove, useBridgeDetailedStatus, useBridgeWithApproval, useCancelLimitOrder, useCancelSwap, useCancelUnstake, useClaim, useClaimRewards, useConvertedAssets, useCreateDecreaseLiquidityParams, useCreateDepositParams, useCreateLimitOrder, useCreateSupplyLiquidityParams, useCreateWithdrawParams, useDecreaseLiquidity, useDeriveUserWalletAddress, useDetailedStatus, useDexAllowance, useDexApprove, useDexDeposit, useDexWithdraw, useEModes, useEnsureRadfiAccessToken, useEstablishTrustline, useEstablishXrpTrustline, useEstimateGas, useExpiredUtxos, useFeeClaimSwap, useFeeClaimWithdraw, useFetchAssetsBalances, useFundTradingWallet, useGetAutoSwapPreferences, useGetBridgeableAmount, useGetBridgeableTokens, useGetIntentDetails, useGetUserHubWalletAddress, useGetUserIntent, useHubAssetBalances, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useIsTokenApproved, useLeveragePositionAccount, useLeveragePositionCollateral, useLeveragePositionFundingAllowance, useLeveragePositionInfo, useLeveragePositionPayoutAddress, useLeveragePositionPending, useLeveragePositions, useLeveragePositionsForUser, useLeverageYieldApiAllowance, useLeverageYieldApiApprove, useLeverageYieldApiApproveAndBroadcast, useLeverageYieldApiApr, useLeverageYieldApiAsset, useLeverageYieldApiCancelIntent, useLeverageYieldApiCreateDepositIntent, useLeverageYieldApiCreateWithdrawIntent, useLeverageYieldApiDeadline, useLeverageYieldApiDepositQuote, useLeverageYieldApiEffectiveApr, useLeverageYieldApiEstimateGas, useLeverageYieldApiFilledIntent, useLeverageYieldApiIntent, useLeverageYieldApiIntentExtraData, useLeverageYieldApiIntentHash, useLeverageYieldApiIntentPacket, useLeverageYieldApiLsdApr, useLeverageYieldApiMaxWithdraw, useLeverageYieldApiPartnerFee, useLeverageYieldApiPosition, useLeverageYieldApiPreviewDeposit, useLeverageYieldApiPreviewRedeem, useLeverageYieldApiPreviewWithdraw, useLeverageYieldApiShareBalance, useLeverageYieldApiSolverFee, useLeverageYieldApiStatus, useLeverageYieldApiSubmitIntent, useLeverageYieldApiSubmitTx, useLeverageYieldApiSubmitTxStatus, useLeverageYieldApiTotalAssets, useLeverageYieldApiVault, useLeverageYieldApiVaults, useLeverageYieldApiWithdrawQuote, useLeverageYieldApprovalStrategy, useLeverageYieldDeposit, useLeverageYieldDetailedStatus, useLeverageYieldEffectiveApr, useLeverageYieldNotifySolver, useLeverageYieldPosition, useLeverageYieldPreviewRedeem, useLeverageYieldQuote, useLeverageYieldShareBalances, useLeverageYieldTotalAssets, useLeverageYieldVaultSwap, useLeverageYieldVaultSwapWithApproval, useLeverageYieldWithdraw, useLiquidityAmounts, useMMAllowance, useMMApprove, useMigrateBaln, useMigrateIcxToSoda, useMigratebnUSD, useMigrationAllowance, useMigrationApprove, useNearStorageCheck, useNearStorageGate, useOpenLeveragePosition, usePartnerCancelIntent, usePoolBalances, usePoolData, usePools, usePositionInfo, useQuote, useRadfiAuth, useRadfiSession, useRadfiWithdraw, useRegisterNearStorage, useRenewUtxos, useRepay, useRequestTrustline, useReservesData, useReservesHumanized, useReservesList, useReservesUsdFormat, useRevertMigrateSodaToIcx, useRunLeveragePositionOperation, useSafeMutation, useSetSwapPreference, useSodaxContext, useSponsorConfig, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarAccountActive, useStellarAccountStatus, useStellarGate, useStellarTrustlineCheck, useSubmitLeveragePositionIntent, useSupply, useSupplyLiquidity, useSwap, useSwapAllowance, useSwapApprovalStrategy, useSwapApprove, useSwapLifecycle, useSwapWithApproval, useSwapsApiAllowance, useSwapsApiApprove, useSwapsApiApproveAndBroadcast, useSwapsApiBroadcastWithApproval, 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, useXrpDestinationCheck, useXrpGate, useXrpTrustlineReserveCheck };
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"version": "2.4.0-rc.
|
|
8
|
+
"version": "2.4.0-rc.3",
|
|
9
9
|
"description": "React hooks for building dApps on the SODAX cross-chain DeFi platform",
|
|
10
10
|
"keywords": [
|
|
11
11
|
"sodax",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"viem": "2.29.2",
|
|
42
|
-
"@sodax/sdk": "2.4.0-rc.
|
|
42
|
+
"@sodax/sdk": "2.4.0-rc.3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@arethetypeswrong/cli": "0.17.4",
|
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Every hook that accepts a per-request `apiConfig` must land it on the outgoing HTTP request as
|
|
5
|
-
* `x-api-key`. Each row renders its hook without a renderer (the package convention: the React
|
|
6
|
-
* Query wrapper is mocked so `queryFn`/`mutationFn` can be captured and driven directly) against a
|
|
7
|
-
* REAL `Sodax` instance whose config carries a DIFFERENT key — so a hook that silently drops its
|
|
8
|
-
* `apiConfig` still makes a request, still sends a key, and fails its row. The stubbed fetch serves
|
|
9
|
-
* a minimal 200 body; post-request validation rejections are expected and tolerated, because the
|
|
10
|
-
* request that already went out is the whole subject. For the approveAndBroadcast hooks that
|
|
11
|
-
* rejection also means the wallet machinery is never touched.
|
|
12
|
-
*
|
|
13
|
-
* To add a new swapsApi/bridgeApi/leverageYieldApi hook, add its row here. The friction is
|
|
14
|
-
* intentional — it forces key-on-wire coverage from day one.
|
|
15
|
-
*/
|
|
1
|
+
// Every hook taking a per-request `apiConfig` must send it as `x-api-key`, beating the instance key; add a row per new hook.
|
|
2
|
+
// Post-request validation rejections are tolerated: the outgoing request is the subject.
|
|
16
3
|
|
|
17
4
|
import { ChainKeys, Sodax, type RequestOverrideConfig } from '@sodax/sdk';
|
|
18
5
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
@@ -48,7 +35,7 @@ const fetchMock = vi.fn<typeof globalThis.fetch>(
|
|
|
48
35
|
);
|
|
49
36
|
vi.stubGlobal('fetch', fetchMock);
|
|
50
37
|
|
|
51
|
-
//
|
|
38
|
+
// Wire DTOs carry string amounts; the intent bigint fields are serialized client-side.
|
|
52
39
|
|
|
53
40
|
const INTENT = {
|
|
54
41
|
intentId: 1n,
|
|
@@ -159,23 +146,17 @@ const LEVERAGE_WITHDRAW_QUOTE_BODY = {
|
|
|
159
146
|
quoteType: 'exact_input' as const,
|
|
160
147
|
};
|
|
161
148
|
|
|
162
|
-
/** The leverage-yield submit-tx body carries the required `operation` discriminator. */
|
|
163
149
|
const LEVERAGE_SUBMIT_TX_REQUEST = { ...SUBMIT_TX_REQUEST, operation: 'deposit' as const };
|
|
164
150
|
|
|
165
|
-
// --- manifest ---------------------------------------------------------------
|
|
166
|
-
|
|
167
151
|
type Row = {
|
|
168
152
|
hook: string;
|
|
169
153
|
/** Exact pathname (below the `/v1` gateway root) the row's single request must hit. */
|
|
170
154
|
path: string;
|
|
171
|
-
/** Exact HTTP method of that request — with `path`, pins the row to one endpoint. */
|
|
172
155
|
method: 'GET' | 'POST';
|
|
173
|
-
/** Renders the hook with `apiConfig` threaded in, then drives the captured queryFn/mutationFn. */
|
|
174
156
|
run: (apiConfig: RequestOverrideConfig) => Promise<unknown>;
|
|
175
157
|
};
|
|
176
158
|
|
|
177
159
|
const ROWS: Row[] = [
|
|
178
|
-
// swapsApi read hooks
|
|
179
160
|
{
|
|
180
161
|
hook: 'useSwapsApiTokens',
|
|
181
162
|
path: '/swaps/tokens',
|
|
@@ -315,7 +296,6 @@ const ROWS: Row[] = [
|
|
|
315
296
|
return captured.queryFn();
|
|
316
297
|
},
|
|
317
298
|
},
|
|
318
|
-
// swapsApi mutation hooks
|
|
319
299
|
{
|
|
320
300
|
hook: 'useSwapsApiApprove',
|
|
321
301
|
path: '/swaps/approve',
|
|
@@ -371,8 +351,7 @@ const ROWS: Row[] = [
|
|
|
371
351
|
},
|
|
372
352
|
},
|
|
373
353
|
{
|
|
374
|
-
// The `{}` 200 fails the approve schema, so the mutation rejects
|
|
375
|
-
// backend request this row asserts is the hook's first step.
|
|
354
|
+
// The `{}` 200 fails the approve schema, so the mutation rejects before any wallet work.
|
|
376
355
|
hook: 'useSwapsApiApproveAndBroadcast',
|
|
377
356
|
path: '/swaps/approve',
|
|
378
357
|
method: 'POST',
|
|
@@ -391,7 +370,6 @@ const ROWS: Row[] = [
|
|
|
391
370
|
return captured.mutationFn({ body: CREATE_INTENT_BODY, intentTx: {}, walletProvider: {}, apiConfig });
|
|
392
371
|
},
|
|
393
372
|
},
|
|
394
|
-
// bridgeApi read hooks
|
|
395
373
|
{
|
|
396
374
|
hook: 'useBridgeApiTokens',
|
|
397
375
|
path: '/bridge/tokens',
|
|
@@ -457,7 +435,6 @@ const ROWS: Row[] = [
|
|
|
457
435
|
return captured.queryFn();
|
|
458
436
|
},
|
|
459
437
|
},
|
|
460
|
-
// bridgeApi mutation hooks
|
|
461
438
|
{
|
|
462
439
|
hook: 'useBridgeApiApprove',
|
|
463
440
|
path: '/bridge/approve',
|
|
@@ -495,7 +472,6 @@ const ROWS: Row[] = [
|
|
|
495
472
|
return captured.mutationFn({ body: BRIDGE_INTENT_BODY, walletProvider: {}, apiConfig });
|
|
496
473
|
},
|
|
497
474
|
},
|
|
498
|
-
// leverageYieldApi read hooks
|
|
499
475
|
{
|
|
500
476
|
hook: 'useLeverageYieldApiVaults',
|
|
501
477
|
path: '/leverage-yield/vaults',
|
|
@@ -749,7 +725,6 @@ const ROWS: Row[] = [
|
|
|
749
725
|
return captured.queryFn();
|
|
750
726
|
},
|
|
751
727
|
},
|
|
752
|
-
// leverageYieldApi mutation hooks
|
|
753
728
|
{
|
|
754
729
|
hook: 'useLeverageYieldApiApprove',
|
|
755
730
|
path: '/leverage-yield/approve',
|
|
@@ -5,13 +5,7 @@ import { describe, expect, it } from 'vitest';
|
|
|
5
5
|
|
|
6
6
|
const HOOKS_DIR = resolve(fileURLToPath(import.meta.url), '..');
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* Manifest of every mutation hook. `nativeThrow: true` marks hooks whose underlying SDK methods
|
|
10
|
-
* throw natively (Bound Exchange APIs) and so don't need `unwrapResult`.
|
|
11
|
-
*
|
|
12
|
-
* To add a new mutation hook, add its path here. The friction is intentional — it forces explicit
|
|
13
|
-
* registration so the contract is enforced from day one.
|
|
14
|
-
*/
|
|
8
|
+
/** `nativeThrow` marks hooks whose SDK methods throw natively, so they need no `unwrapResult`. */
|
|
15
9
|
const HOOKS: Array<{ path: string; nativeThrow?: true }> = [
|
|
16
10
|
{ path: 'bitcoin/useEnsureRadfiAccessToken.ts', nativeThrow: true },
|
|
17
11
|
{ path: 'bitcoin/useFundTradingWallet.ts', nativeThrow: true },
|
|
@@ -60,6 +54,7 @@ const HOOKS: Array<{ path: string; nativeThrow?: true }> = [
|
|
|
60
54
|
{ path: 'partner/useSetSwapPreference.ts' },
|
|
61
55
|
{ path: 'recovery/useWithdrawHubAsset.ts' },
|
|
62
56
|
{ path: 'shared/useEstablishTrustline.ts', nativeThrow: true },
|
|
57
|
+
{ path: 'shared/useEstablishXrpTrustline.ts' },
|
|
63
58
|
{ path: 'shared/useEstimateGas.ts' },
|
|
64
59
|
{ path: 'shared/useRegisterNearStorage.ts', nativeThrow: true },
|
|
65
60
|
{ path: 'sponsoring/useActivateStellarAccount.ts' },
|
|
@@ -113,7 +108,6 @@ describe.each(HOOKS)('mutation hook contract: $path', ({ path, nativeThrow }) =>
|
|
|
113
108
|
});
|
|
114
109
|
|
|
115
110
|
it('mutationKey first segment matches feature directory', () => {
|
|
116
|
-
// Feature directory = first segment of `path`. e.g. `mm/useSupply.ts` → `mm`.
|
|
117
111
|
const featureDir = path.split('/')[0];
|
|
118
112
|
const match = src.match(/mutationKey:\s*\[\s*'([^']+)'/);
|
|
119
113
|
expect(match).not.toBeNull();
|
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
// packages/dapp-kit/src/hooks/backend/index.ts
|
|
2
|
-
/**
|
|
3
|
-
* Backend API Hooks
|
|
4
|
-
*
|
|
5
|
-
* This module exports all hooks for interacting with the BackendApiService.
|
|
6
|
-
* These hooks provide a React-friendly interface to the Sodax Backend API,
|
|
7
|
-
* including intent management, solver orderbook, and money market operations.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
// Intent hooks
|
|
11
1
|
export { useBackendIntentByTxHash } from './useBackendIntentByTxHash.js';
|
|
12
2
|
export { useBackendIntentByHash } from './useBackendIntentByHash.js';
|
|
13
3
|
export { useBackendUserIntents } from './useBackendUserIntents.js';
|
|
14
4
|
|
|
15
|
-
// Solver hooks
|
|
16
5
|
export { useBackendOrderbook } from './useBackendOrderbook.js';
|
|
17
6
|
|
|
18
|
-
// Money Market hooks
|
|
19
7
|
export { useBackendMoneyMarketPosition } from './useBackendMoneyMarketPosition.js';
|
|
20
8
|
export { useBackendAllMoneyMarketAssets } from './useBackendAllMoneyMarketAssets.js';
|
|
21
9
|
export { useBackendMoneyMarketAsset } from './useBackendMoneyMarketAsset.js';
|
|
@@ -23,7 +11,6 @@ export { useBackendMoneyMarketAssetBorrowers } from './useBackendMoneyMarketAsse
|
|
|
23
11
|
export { useBackendMoneyMarketAssetSuppliers } from './useBackendMoneyMarketAssetSuppliers.js';
|
|
24
12
|
export { useBackendAllMoneyMarketBorrowers } from './useBackendAllMoneyMarketBorrowers.js';
|
|
25
13
|
|
|
26
|
-
// Oracle hooks
|
|
27
14
|
export { useBackendOracleMarkets } from './useBackendOracleMarkets.js';
|
|
28
15
|
export { useBackendOracleCandles } from './useBackendOracleCandles.js';
|
|
29
16
|
export * from './types.js';
|
|
@@ -6,12 +6,6 @@ import type { ReadHookParams } from '../shared/types.js';
|
|
|
6
6
|
|
|
7
7
|
export type UseBackendAllMoneyMarketAssetsParams = ReadHookParams<MoneyMarketAsset[]>;
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* React hook to fetch all money market assets from the backend API.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* const { data: assets, isLoading, error } = useBackendAllMoneyMarketAssets();
|
|
14
|
-
*/
|
|
15
9
|
export const useBackendAllMoneyMarketAssets = ({
|
|
16
10
|
queryOptions,
|
|
17
11
|
}: UseBackendAllMoneyMarketAssetsParams = {}): UseQueryResult<MoneyMarketAsset[], Error> => {
|
|
@@ -12,16 +12,6 @@ export type UseBackendAllMoneyMarketBorrowersParams = ReadHookParams<
|
|
|
12
12
|
}
|
|
13
13
|
>;
|
|
14
14
|
|
|
15
|
-
/**
|
|
16
|
-
* Hook for fetching all money market borrowers from the backend API.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* const { data, isLoading, error } = useBackendAllMoneyMarketBorrowers({
|
|
21
|
-
* params: { pagination: { offset: '0', limit: '50' } },
|
|
22
|
-
* });
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
15
|
export const useBackendAllMoneyMarketBorrowers = ({
|
|
26
16
|
params,
|
|
27
17
|
queryOptions,
|
|
@@ -10,12 +10,6 @@ export type UseBackendIntentByHashParams = ReadHookParams<
|
|
|
10
10
|
}
|
|
11
11
|
>;
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* React hook to fetch intent details from the backend API using an intent hash.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* const { data: intent } = useBackendIntentByHash({ params: { intentHash: '0xabc...' } });
|
|
18
|
-
*/
|
|
19
13
|
export const useBackendIntentByHash = ({
|
|
20
14
|
params,
|
|
21
15
|
queryOptions,
|