@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.
Files changed (283) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +279 -2428
  3. package/dist/index.mjs +15 -24
  4. package/package.json +2 -2
  5. package/src/hooks/_apiKeyWire.test.ts +4 -29
  6. package/src/hooks/_mutationContract.test.ts +1 -8
  7. package/src/hooks/backend/index.ts +0 -13
  8. package/src/hooks/backend/useBackendAllMoneyMarketAssets.ts +0 -6
  9. package/src/hooks/backend/useBackendAllMoneyMarketBorrowers.ts +0 -10
  10. package/src/hooks/backend/useBackendIntentByHash.ts +0 -6
  11. package/src/hooks/backend/useBackendIntentByTxHash.ts +1 -10
  12. package/src/hooks/backend/useBackendMoneyMarketAsset.ts +0 -6
  13. package/src/hooks/backend/useBackendMoneyMarketAssetBorrowers.ts +0 -8
  14. package/src/hooks/backend/useBackendMoneyMarketAssetSuppliers.ts +0 -8
  15. package/src/hooks/backend/useBackendMoneyMarketPosition.ts +0 -6
  16. package/src/hooks/backend/useBackendOracleCandles.ts +1 -9
  17. package/src/hooks/backend/useBackendOracleMarkets.ts +1 -7
  18. package/src/hooks/backend/useBackendOrderbook.ts +0 -6
  19. package/src/hooks/backend/useBackendUserIntents.ts +0 -8
  20. package/src/hooks/bitcoin/resolveBtcReadAddress.test.ts +1 -3
  21. package/src/hooks/bitcoin/resolveBtcReadAddress.ts +2 -12
  22. package/src/hooks/bitcoin/useBitcoinBalance.ts +1 -7
  23. package/src/hooks/bitcoin/useBitcoinTradingSetup.ts +2 -4
  24. package/src/hooks/bitcoin/useEnsureRadfiAccessToken.ts +2 -13
  25. package/src/hooks/bitcoin/useFundTradingWallet.ts +0 -6
  26. package/src/hooks/bitcoin/useRadfiAuth.ts +1 -6
  27. package/src/hooks/bitcoin/useRadfiSession.ts +0 -1
  28. package/src/hooks/bitcoin/useRadfiWithdraw.ts +0 -6
  29. package/src/hooks/bitcoin/useRenewUtxos.ts +0 -5
  30. package/src/hooks/bitcoin/useTradingWallet.ts +1 -4
  31. package/src/hooks/bridge/getBridgeDetailedStatusRefetchInterval.test.ts +1 -7
  32. package/src/hooks/bridge/getBridgeDetailedStatusRefetchInterval.ts +7 -21
  33. package/src/hooks/bridge/useBridge.test.ts +1 -11
  34. package/src/hooks/bridge/useBridge.ts +2 -12
  35. package/src/hooks/bridge/useBridgeAllowance.ts +1 -2
  36. package/src/hooks/bridge/useBridgeApprovalStrategy.ts +2 -6
  37. package/src/hooks/bridge/useBridgeApprove.ts +2 -14
  38. package/src/hooks/bridge/useBridgeDetailedStatus.test.ts +2 -11
  39. package/src/hooks/bridge/useBridgeDetailedStatus.ts +3 -23
  40. package/src/hooks/bridge/useBridgeWithApproval.ts +2 -11
  41. package/src/hooks/bridgeApi/getBridgeSubmitTxStatusRefetchInterval.test.ts +2 -7
  42. package/src/hooks/bridgeApi/getBridgeSubmitTxStatusRefetchInterval.ts +2 -13
  43. package/src/hooks/bridgeApi/index.ts +11 -14
  44. package/src/hooks/bridgeApi/useBridgeApiAllowance.ts +1 -9
  45. package/src/hooks/bridgeApi/useBridgeApiApprove.ts +2 -17
  46. package/src/hooks/bridgeApi/useBridgeApiApproveAndBroadcast.test.ts +2 -13
  47. package/src/hooks/bridgeApi/useBridgeApiApproveAndBroadcast.ts +3 -20
  48. package/src/hooks/bridgeApi/useBridgeApiBridgeableAmount.ts +1 -12
  49. package/src/hooks/bridgeApi/useBridgeApiCreateBridgeIntent.ts +1 -14
  50. package/src/hooks/bridgeApi/useBridgeApiFee.ts +2 -11
  51. package/src/hooks/bridgeApi/useBridgeApiIsBridgeable.ts +1 -12
  52. package/src/hooks/bridgeApi/useBridgeApiSubmitTx.ts +2 -23
  53. package/src/hooks/bridgeApi/useBridgeApiSubmitTxStatus.test.ts +1 -9
  54. package/src/hooks/bridgeApi/useBridgeApiSubmitTxStatus.ts +1 -19
  55. package/src/hooks/bridgeApi/useBridgeApiTokens.ts +0 -8
  56. package/src/hooks/bridgeApi/useBridgeApiTokensByChain.ts +0 -7
  57. package/src/hooks/dex/useClaimRewards.ts +1 -12
  58. package/src/hooks/dex/useCreateDecreaseLiquidityParams.ts +1 -5
  59. package/src/hooks/dex/useCreateDepositParams.ts +1 -5
  60. package/src/hooks/dex/useCreateSupplyLiquidityParams.ts +1 -10
  61. package/src/hooks/dex/useCreateWithdrawParams.ts +1 -5
  62. package/src/hooks/dex/useDecreaseLiquidity.ts +2 -15
  63. package/src/hooks/dex/useDexAllowance.ts +1 -5
  64. package/src/hooks/dex/useDexApprove.ts +1 -12
  65. package/src/hooks/dex/useDexDeposit.ts +1 -23
  66. package/src/hooks/dex/useDexWithdraw.ts +1 -13
  67. package/src/hooks/dex/useLiquidityAmounts.ts +1 -4
  68. package/src/hooks/dex/usePoolBalances.ts +0 -4
  69. package/src/hooks/dex/usePoolData.ts +1 -4
  70. package/src/hooks/dex/usePools.ts +1 -4
  71. package/src/hooks/dex/usePositionInfo.ts +1 -4
  72. package/src/hooks/dex/useSupplyLiquidity.ts +3 -20
  73. package/src/hooks/leverageYield/useApproveLeveragePositionFunding.ts +2 -8
  74. package/src/hooks/leverageYield/useLeveragePositionAccount.ts +2 -13
  75. package/src/hooks/leverageYield/useLeveragePositionCollateral.ts +2 -14
  76. package/src/hooks/leverageYield/useLeveragePositionFundingAllowance.ts +2 -9
  77. package/src/hooks/leverageYield/useLeveragePositionInfo.ts +1 -13
  78. package/src/hooks/leverageYield/useLeveragePositionPayoutAddress.ts +3 -15
  79. package/src/hooks/leverageYield/useLeveragePositionPending.ts +2 -16
  80. package/src/hooks/leverageYield/useLeveragePositions.ts +1 -15
  81. package/src/hooks/leverageYield/useLeveragePositionsForUser.ts +1 -15
  82. package/src/hooks/leverageYield/useLeverageYieldApprovalStrategy.ts +1 -6
  83. package/src/hooks/leverageYield/useLeverageYieldDeposit.ts +1 -17
  84. package/src/hooks/leverageYield/useLeverageYieldDetailedStatus.test.ts +3 -14
  85. package/src/hooks/leverageYield/useLeverageYieldDetailedStatus.ts +2 -19
  86. package/src/hooks/leverageYield/useLeverageYieldEffectiveApr.ts +1 -12
  87. package/src/hooks/leverageYield/useLeverageYieldNotifySolver.ts +1 -11
  88. package/src/hooks/leverageYield/useLeverageYieldPosition.ts +1 -13
  89. package/src/hooks/leverageYield/useLeverageYieldPreviewRedeem.ts +1 -12
  90. package/src/hooks/leverageYield/useLeverageYieldQuote.test.ts +3 -13
  91. package/src/hooks/leverageYield/useLeverageYieldQuote.ts +5 -54
  92. package/src/hooks/leverageYield/useLeverageYieldShareBalances.ts +2 -29
  93. package/src/hooks/leverageYield/useLeverageYieldTotalAssets.ts +1 -9
  94. package/src/hooks/leverageYield/useLeverageYieldVaultSwap.ts +2 -25
  95. package/src/hooks/leverageYield/useLeverageYieldVaultSwapWithApproval.ts +1 -11
  96. package/src/hooks/leverageYield/useLeverageYieldWithdraw.ts +1 -17
  97. package/src/hooks/leverageYield/useOpenLeveragePosition.ts +5 -18
  98. package/src/hooks/leverageYield/useRunLeveragePositionOperation.ts +4 -20
  99. package/src/hooks/leverageYield/useSubmitLeveragePositionIntent.ts +3 -15
  100. package/src/hooks/leverageYieldApi/index.ts +0 -15
  101. package/src/hooks/leverageYieldApi/useLeverageYieldApiAllowance.ts +1 -8
  102. package/src/hooks/leverageYieldApi/useLeverageYieldApiApprove.ts +3 -6
  103. package/src/hooks/leverageYieldApi/useLeverageYieldApiApproveAndBroadcast.test.ts +4 -14
  104. package/src/hooks/leverageYieldApi/useLeverageYieldApiApproveAndBroadcast.ts +4 -26
  105. package/src/hooks/leverageYieldApi/useLeverageYieldApiApr.ts +1 -7
  106. package/src/hooks/leverageYieldApi/useLeverageYieldApiAsset.ts +0 -7
  107. package/src/hooks/leverageYieldApi/useLeverageYieldApiCancelIntent.ts +2 -8
  108. package/src/hooks/leverageYieldApi/useLeverageYieldApiCreateDepositIntent.ts +2 -8
  109. package/src/hooks/leverageYieldApi/useLeverageYieldApiCreateWithdrawIntent.ts +2 -8
  110. package/src/hooks/leverageYieldApi/useLeverageYieldApiDeadline.ts +1 -7
  111. package/src/hooks/leverageYieldApi/useLeverageYieldApiDepositQuote.ts +1 -15
  112. package/src/hooks/leverageYieldApi/useLeverageYieldApiEffectiveApr.ts +1 -7
  113. package/src/hooks/leverageYieldApi/useLeverageYieldApiEstimateGas.ts +1 -7
  114. package/src/hooks/leverageYieldApi/useLeverageYieldApiFilledIntent.ts +1 -6
  115. package/src/hooks/leverageYieldApi/useLeverageYieldApiIntent.ts +1 -6
  116. package/src/hooks/leverageYieldApi/useLeverageYieldApiIntentExtraData.ts +1 -8
  117. package/src/hooks/leverageYieldApi/useLeverageYieldApiIntentHash.ts +0 -7
  118. package/src/hooks/leverageYieldApi/useLeverageYieldApiIntentPacket.ts +1 -7
  119. package/src/hooks/leverageYieldApi/useLeverageYieldApiLsdApr.ts +1 -7
  120. package/src/hooks/leverageYieldApi/useLeverageYieldApiMaxWithdraw.ts +1 -7
  121. package/src/hooks/leverageYieldApi/useLeverageYieldApiPartnerFee.ts +1 -7
  122. package/src/hooks/leverageYieldApi/useLeverageYieldApiPosition.ts +0 -7
  123. package/src/hooks/leverageYieldApi/useLeverageYieldApiPreviewDeposit.ts +1 -7
  124. package/src/hooks/leverageYieldApi/useLeverageYieldApiPreviewRedeem.ts +1 -7
  125. package/src/hooks/leverageYieldApi/useLeverageYieldApiPreviewWithdraw.ts +1 -7
  126. package/src/hooks/leverageYieldApi/useLeverageYieldApiShareBalance.ts +0 -7
  127. package/src/hooks/leverageYieldApi/useLeverageYieldApiSolverFee.ts +1 -7
  128. package/src/hooks/leverageYieldApi/useLeverageYieldApiStatus.ts +2 -12
  129. package/src/hooks/leverageYieldApi/useLeverageYieldApiSubmitIntent.ts +2 -8
  130. package/src/hooks/leverageYieldApi/useLeverageYieldApiSubmitTx.ts +2 -8
  131. package/src/hooks/leverageYieldApi/useLeverageYieldApiSubmitTxStatus.ts +2 -17
  132. package/src/hooks/leverageYieldApi/useLeverageYieldApiTotalAssets.ts +0 -7
  133. package/src/hooks/leverageYieldApi/useLeverageYieldApiVault.ts +1 -7
  134. package/src/hooks/leverageYieldApi/useLeverageYieldApiVaults.ts +0 -7
  135. package/src/hooks/leverageYieldApi/useLeverageYieldApiWithdrawQuote.ts +1 -15
  136. package/src/hooks/migrate/useMigrateBaln.ts +1 -8
  137. package/src/hooks/migrate/useMigrateIcxToSoda.ts +1 -12
  138. package/src/hooks/migrate/useMigratebnUSD.ts +1 -12
  139. package/src/hooks/migrate/useMigrationAllowance.ts +3 -19
  140. package/src/hooks/migrate/useMigrationApprove.ts +2 -20
  141. package/src/hooks/migrate/useRevertMigrateSodaToIcx.ts +0 -7
  142. package/src/hooks/mm/useAToken.ts +1 -6
  143. package/src/hooks/mm/useATokensBalances.ts +0 -5
  144. package/src/hooks/mm/useBorrow.ts +1 -13
  145. package/src/hooks/mm/useEModes.ts +2 -13
  146. package/src/hooks/mm/useMMAllowance.test.ts +55 -0
  147. package/src/hooks/mm/useMMAllowance.ts +6 -16
  148. package/src/hooks/mm/useMMApprove.ts +1 -14
  149. package/src/hooks/mm/useRepay.ts +1 -12
  150. package/src/hooks/mm/useReservesData.ts +0 -4
  151. package/src/hooks/mm/useReservesHumanized.ts +0 -4
  152. package/src/hooks/mm/useReservesList.ts +0 -4
  153. package/src/hooks/mm/useReservesUsdFormat.ts +0 -4
  154. package/src/hooks/mm/useSupply.ts +1 -24
  155. package/src/hooks/mm/useUserFormattedSummary.ts +0 -7
  156. package/src/hooks/mm/useUserReservesData.ts +0 -4
  157. package/src/hooks/mm/useWithdraw.ts +1 -13
  158. package/src/hooks/partner/useApproveToken.ts +1 -7
  159. package/src/hooks/partner/useFeeClaimSwap.ts +1 -7
  160. package/src/hooks/partner/useFeeClaimWithdraw.ts +3 -20
  161. package/src/hooks/partner/useFetchAssetsBalances.ts +0 -4
  162. package/src/hooks/partner/useGetAutoSwapPreferences.ts +0 -4
  163. package/src/hooks/partner/useGetIntentDetails.ts +1 -8
  164. package/src/hooks/partner/useGetUserIntent.ts +1 -8
  165. package/src/hooks/partner/useIsTokenApproved.ts +0 -4
  166. package/src/hooks/partner/usePartnerCancelIntent.ts +2 -9
  167. package/src/hooks/partner/useSetSwapPreference.ts +1 -14
  168. package/src/hooks/recovery/useHubAssetBalances.ts +1 -6
  169. package/src/hooks/recovery/useWithdrawHubAsset.ts +1 -13
  170. package/src/hooks/shared/invalidateBalances.ts +2 -10
  171. package/src/hooks/shared/isUserRejectedError.test.ts +0 -3
  172. package/src/hooks/shared/isUserRejectedError.ts +2 -23
  173. package/src/hooks/shared/notFoundStreak.ts +5 -22
  174. package/src/hooks/shared/retryUnlessAuthFailure.test.ts +1 -2
  175. package/src/hooks/shared/retryUnlessAuthFailure.ts +1 -12
  176. package/src/hooks/shared/solverStatusPolicy.test.ts +0 -5
  177. package/src/hooks/shared/solverStatusPolicy.ts +8 -58
  178. package/src/hooks/shared/types.ts +4 -55
  179. package/src/hooks/shared/unwrapResult.ts +1 -8
  180. package/src/hooks/shared/useBalances.ts +6 -39
  181. package/src/hooks/shared/useEstablishTrustline.test.ts +1 -5
  182. package/src/hooks/shared/useEstablishTrustline.ts +3 -13
  183. package/src/hooks/shared/useEstablishXrpTrustline.test.ts +1 -2
  184. package/src/hooks/shared/useEstablishXrpTrustline.ts +3 -5
  185. package/src/hooks/shared/useEstimateGas.ts +0 -1
  186. package/src/hooks/shared/useGetUserHubWalletAddress.ts +1 -18
  187. package/src/hooks/shared/useNearStorageCheck.ts +2 -9
  188. package/src/hooks/shared/useNearStorageGate.ts +5 -15
  189. package/src/hooks/shared/useRegisterNearStorage.ts +2 -10
  190. package/src/hooks/shared/useRequestTrustline.test.ts +1 -7
  191. package/src/hooks/shared/useRequestTrustline.ts +4 -14
  192. package/src/hooks/shared/useSafeMutation.test.ts +0 -3
  193. package/src/hooks/shared/useSafeMutation.ts +2 -26
  194. package/src/hooks/shared/useSodaxContext.ts +0 -6
  195. package/src/hooks/shared/useStellarGate.test.ts +2 -9
  196. package/src/hooks/shared/useStellarGate.ts +3 -9
  197. package/src/hooks/shared/useStellarTrustlineCheck.test.ts +0 -2
  198. package/src/hooks/shared/useStellarTrustlineCheck.ts +1 -4
  199. package/src/hooks/shared/useXBalances.ts +2 -20
  200. package/src/hooks/shared/useXrpDestinationCheck.ts +1 -5
  201. package/src/hooks/shared/useXrpGate.test.ts +1 -3
  202. package/src/hooks/shared/useXrpGate.ts +2 -3
  203. package/src/hooks/shared/waitForApiAllowance.test.ts +0 -1
  204. package/src/hooks/shared/waitForApiAllowance.ts +2 -6
  205. package/src/hooks/sponsoring/useActivateStellarAccount.test.ts +1 -2
  206. package/src/hooks/sponsoring/useActivateStellarAccount.ts +1 -5
  207. package/src/hooks/sponsoring/useActivateStellarAccount.wire.test.ts +2 -13
  208. package/src/hooks/sponsoring/useSponsorConfig.ts +0 -1
  209. package/src/hooks/sponsoring/useStellarAccountActive.ts +0 -1
  210. package/src/hooks/sponsoring/useStellarAccountStatus.ts +1 -4
  211. package/src/hooks/staking/index.ts +0 -1
  212. package/src/hooks/staking/useCancelUnstake.ts +1 -7
  213. package/src/hooks/staking/useClaim.ts +1 -7
  214. package/src/hooks/staking/useConvertedAssets.ts +1 -4
  215. package/src/hooks/staking/useInstantUnstake.ts +1 -7
  216. package/src/hooks/staking/useInstantUnstakeAllowance.ts +1 -5
  217. package/src/hooks/staking/useInstantUnstakeApprove.ts +1 -11
  218. package/src/hooks/staking/useInstantUnstakeRatio.ts +1 -4
  219. package/src/hooks/staking/useStake.ts +1 -12
  220. package/src/hooks/staking/useStakeAllowance.ts +1 -5
  221. package/src/hooks/staking/useStakeApprove.ts +1 -11
  222. package/src/hooks/staking/useStakeRatio.ts +1 -4
  223. package/src/hooks/staking/useStakingConfig.ts +1 -4
  224. package/src/hooks/staking/useStakingInfo.ts +1 -5
  225. package/src/hooks/staking/useUnstake.ts +2 -9
  226. package/src/hooks/staking/useUnstakeAllowance.ts +1 -5
  227. package/src/hooks/staking/useUnstakeApprove.ts +1 -10
  228. package/src/hooks/staking/useUnstakingInfo.ts +1 -4
  229. package/src/hooks/staking/useUnstakingInfoWithPenalty.ts +1 -4
  230. package/src/hooks/swap/useCancelLimitOrder.ts +1 -7
  231. package/src/hooks/swap/useCancelSwap.ts +1 -7
  232. package/src/hooks/swap/useCreateLimitOrder.ts +2 -12
  233. package/src/hooks/swap/useDetailedStatus.test.ts +6 -18
  234. package/src/hooks/swap/useDetailedStatus.ts +2 -19
  235. package/src/hooks/swap/useQuote.test.ts +2 -8
  236. package/src/hooks/swap/useQuote.ts +5 -32
  237. package/src/hooks/swap/useStatus.ts +2 -10
  238. package/src/hooks/swap/useSwap.test.ts +1 -11
  239. package/src/hooks/swap/useSwap.ts +2 -12
  240. package/src/hooks/swap/useSwapAllowance.ts +1 -2
  241. package/src/hooks/swap/useSwapApprovalStrategy.ts +2 -7
  242. package/src/hooks/swap/useSwapApprove.ts +2 -14
  243. package/src/hooks/swap/useSwapLifecycle.test.ts +1 -2
  244. package/src/hooks/swap/useSwapLifecycle.ts +9 -27
  245. package/src/hooks/swap/useSwapWithApproval.ts +2 -11
  246. package/src/hooks/swapsApi/index.ts +2 -14
  247. package/src/hooks/swapsApi/isTerminalSwapIntentStatus.test.ts +1 -5
  248. package/src/hooks/swapsApi/isTerminalSwapIntentStatus.ts +1 -7
  249. package/src/hooks/swapsApi/useSwapsApiAllowance.ts +0 -7
  250. package/src/hooks/swapsApi/useSwapsApiApprove.ts +1 -14
  251. package/src/hooks/swapsApi/useSwapsApiApproveAndBroadcast.test.ts +5 -20
  252. package/src/hooks/swapsApi/useSwapsApiApproveAndBroadcast.ts +3 -24
  253. package/src/hooks/swapsApi/useSwapsApiBroadcastWithApproval.test.ts +2 -8
  254. package/src/hooks/swapsApi/useSwapsApiBroadcastWithApproval.ts +6 -41
  255. package/src/hooks/swapsApi/useSwapsApiCancelIntent.ts +0 -13
  256. package/src/hooks/swapsApi/useSwapsApiCreateIntent.ts +0 -13
  257. package/src/hooks/swapsApi/useSwapsApiCreateLimitOrder.ts +1 -13
  258. package/src/hooks/swapsApi/useSwapsApiDeadline.ts +1 -7
  259. package/src/hooks/swapsApi/useSwapsApiEstimateGas.ts +0 -7
  260. package/src/hooks/swapsApi/useSwapsApiFilledIntent.ts +0 -8
  261. package/src/hooks/swapsApi/useSwapsApiIntent.ts +1 -7
  262. package/src/hooks/swapsApi/useSwapsApiIntentExtraData.ts +1 -8
  263. package/src/hooks/swapsApi/useSwapsApiIntentHash.ts +0 -7
  264. package/src/hooks/swapsApi/useSwapsApiIntentPacket.ts +1 -10
  265. package/src/hooks/swapsApi/useSwapsApiPartnerFee.ts +0 -7
  266. package/src/hooks/swapsApi/useSwapsApiQuote.ts +2 -24
  267. package/src/hooks/swapsApi/useSwapsApiSolverFee.ts +0 -7
  268. package/src/hooks/swapsApi/useSwapsApiStatus.ts +1 -11
  269. package/src/hooks/swapsApi/useSwapsApiSubmitIntent.ts +1 -15
  270. package/src/hooks/swapsApi/useSwapsApiSubmitTx.ts +0 -21
  271. package/src/hooks/swapsApi/useSwapsApiSubmitTxStatus.ts +2 -19
  272. package/src/hooks/swapsApi/useSwapsApiTokens.ts +0 -7
  273. package/src/hooks/swapsApi/useSwapsApiTokensByChain.ts +0 -7
  274. package/src/index.ts +1 -1
  275. package/src/providers/SodaxProvider.test.ts +2 -9
  276. package/src/providers/SodaxProvider.tsx +1 -12
  277. package/src/providers/createSodaxQueryClient.ts +4 -56
  278. package/src/utils/approvalPlan.ts +9 -32
  279. package/src/utils/dex-utils.ts +5 -20
  280. package/src/utils/nearStorageGate.ts +3 -14
  281. package/src/utils/stellarGate.ts +3 -16
  282. package/src/utils/swapLifecycle.ts +7 -26
  283. 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
- * React hook to withdraw a partner fee token directly to the partner's wallet **without a swap**.
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
- * React hook to cancel a stuck partner fee-claim auto-swap intent and recover the locked tokens.
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
- /** The user's address on the spoke chain. The SDK derives the hub wallet abstraction internally. */
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
- * Invalidate every wallet-balance query for the given chains.
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
- * Predicate for the canonical "user cancelled the wallet prompt" outcome.
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
- * The consecutive-ambiguous-read budget shared by the status polls.
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 the counter once per successful query update. A `pollKey` change starts a new streak so
44
- * a prior transfer's count cannot stop the next one. React Query may call `refetchInterval` more
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 the one guard outcome that is NOT terminal — the key may be fine, verification is down.
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 } });