@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
package/dist/index.mjs CHANGED
@@ -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({
@@ -678,8 +678,7 @@ function useGetUserHubWalletAddress({
678
678
  var REFETCH_INTERVAL_MS = 5e3;
679
679
  function getXBalancesQueryOptions({ xService, xChainId, xTokens, address }) {
680
680
  return {
681
- // Pair symbol + address: readable in devtools, unique on-chain (symbol alone
682
- // can collide — e.g. scam tokens copying legitimate ticker).
681
+ // Symbol alone can collide (scam tokens copy tickers), so pair it with the address.
683
682
  queryKey: ["shared", "xBalances", xChainId, xTokens.map((x) => [x.symbol, x.address]), address],
684
683
  queryFn: async () => {
685
684
  if (!xService) return {};
@@ -707,8 +706,7 @@ var REFETCH_INTERVAL_MS2 = 5e3;
707
706
  function getBalancesQueryOptions(sodax, { chainKey, tokens, address, accountAddress }) {
708
707
  const tonAccount = chainKey === ChainKeys.TON_MAINNET && accountAddress ? { accountAddress } : void 0;
709
708
  return {
710
- // Pair symbol + address: readable in devtools, unique on-chain (symbol alone can collide —
711
- // e.g. scam tokens copying a legitimate ticker).
709
+ // Symbol alone can collide (scam tokens copy tickers), so pair it with the address.
712
710
  queryKey: [
713
711
  "shared",
714
712
  "balances",
@@ -725,9 +723,8 @@ function getBalancesQueryOptions(sodax, { chainKey, tokens, address, accountAddr
725
723
  },
726
724
  enabled: !!chainKey && !!address && tokens.length > 0,
727
725
  refetchInterval: REFETCH_INTERVAL_MS2
728
- // Deliberately NOT `placeholderData: keepPreviousData`: the query key carries the chain, so a
729
- // chain switch would surface the previous chain's map — and every EVM chain shares the native
730
- // 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.
731
728
  };
732
729
  }
733
730
  function useBalances({ params, queryOptions } = {}) {
@@ -1162,20 +1159,22 @@ function useMMAllowance({
1162
1159
  } = {}) {
1163
1160
  const { sodax } = useSodaxContext();
1164
1161
  const payload = params?.payload;
1162
+ const needsApproval = payload?.action !== "borrow" && payload?.action !== "withdraw";
1165
1163
  return useQuery({
1166
1164
  queryKey: ["mm", "allowance", payload?.srcChainKey, payload?.token, payload?.action],
1167
1165
  queryFn: async () => {
1168
1166
  if (!payload) {
1169
1167
  throw new Error("Params are required");
1170
1168
  }
1171
- if (payload.action === "borrow" || payload.action === "withdraw") {
1169
+ if (!needsApproval) {
1172
1170
  return true;
1173
1171
  }
1174
1172
  const result = await sodax.moneyMarket.isAllowanceValid({ params: payload });
1175
1173
  if (!result.ok) throw result.error;
1176
1174
  return result.value;
1177
1175
  },
1178
- enabled: !!payload && payload.action !== "borrow" && payload.action !== "withdraw",
1176
+ initialData: () => payload && !needsApproval ? true : void 0,
1177
+ enabled: !!payload && needsApproval,
1179
1178
  refetchInterval: 5e3,
1180
1179
  gcTime: 0,
1181
1180
  ...queryOptions
@@ -1482,8 +1481,7 @@ function useSwapAllowance({
1482
1481
  const srcChainKey = params?.srcChainKey;
1483
1482
  const walletProvider = params?.walletProvider;
1484
1483
  return useQuery({
1485
- // Extract the (chain, owner, token, amount) tuple that actually scopes the allowance —
1486
- // 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.
1487
1485
  queryKey: [
1488
1486
  "swap",
1489
1487
  "allowance",
@@ -2087,10 +2085,7 @@ var useSwapsApiQuote = ({
2087
2085
  const query = params?.query;
2088
2086
  const apiConfig = params?.apiConfig;
2089
2087
  return useQuery({
2090
- // Hash the whole request body so every quote input — including partnerFee and the other
2091
- // SwapExtrasV2 fields — is a cache dimension; a partnerFee change alters the quote and must
2092
- // miss the cache. QuoteRequestV2 is bigint-free (compile-time guaranteed), so React Query's
2093
- // 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.
2094
2089
  queryKey: ["swapsApi", "quote", body, query?.includeTxData ?? false],
2095
2090
  queryFn: async () => {
2096
2091
  if (!body) return void 0;
@@ -2186,8 +2181,7 @@ function resolveChainSender(srcChainKey, walletProvider, hookName) {
2186
2181
  if (isHubChainKeyType(srcChainKey) || isEvmSpokeOnlyChainKeyType(srcChainKey)) {
2187
2182
  const evm = walletProvider;
2188
2183
  return {
2189
- // Chain-bind the send: the wallet broadcasts on ITS active chain, so refuse when that differs
2190
- // 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.
2191
2185
  send: (raw) => evm.sendTransaction(raw, { expectedChainId: getEvmViemChain(srcChainKey).id }),
2192
2186
  confirm: async (hash, step) => {
2193
2187
  const receipt = await evm.waitForTransactionReceipt(hash);
@@ -2696,8 +2690,7 @@ function useBridgeAllowance({
2696
2690
  const payload = params?.payload;
2697
2691
  const walletProvider = params?.walletProvider;
2698
2692
  return useQuery({
2699
- // Extract the (chain, owner, token, amount) tuple that actually scopes the allowance —
2700
- // 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.
2701
2694
  queryKey: [
2702
2695
  "bridge",
2703
2696
  "allowance",
@@ -3779,8 +3772,7 @@ function useMigrationAllowance({
3779
3772
  const migrationParams = params?.params;
3780
3773
  const action = params?.action;
3781
3774
  return useQuery({
3782
- // Extract the (chain, owner, token, amount) tuple that actually scopes the allowance —
3783
- // 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.
3784
3776
  queryKey: [
3785
3777
  "migrate",
3786
3778
  "allowance",
@@ -4183,7 +4175,7 @@ function createDepositParamsProps({
4183
4175
  const originalAsset = tokenIndex === 0 ? poolSpokeAssets.token0 : poolSpokeAssets.token1;
4184
4176
  return {
4185
4177
  asset: originalAsset.address,
4186
- // Use deposit token decimals (original asset) for correct unit parsing
4178
+ // Deposit token (original asset) decimals, not the pool token's.
4187
4179
  amount: parseUnits(String(amount), originalAsset.decimals),
4188
4180
  poolToken: token.address
4189
4181
  };
@@ -4683,7 +4675,6 @@ function useLeveragePositionCollateral({
4683
4675
  return result.value;
4684
4676
  },
4685
4677
  enabled: !!position,
4686
- // Interest accrues into the balance continuously, so match the account snapshot's cadence.
4687
4678
  refetchInterval: 3e4,
4688
4679
  ...queryOptions
4689
4680
  });
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "access": "public"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "2.4.0-rc.2",
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.2"
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
- * Executable API-key wire manifest for the swapsApi + bridgeApi + leverageYieldApi hook families.
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
- // --- wire-DTO fixtures (string amounts; the six intent bigint fields are serialized client-side) ---
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 BEFORE any wallet work — the
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 },
@@ -114,7 +108,6 @@ describe.each(HOOKS)('mutation hook contract: $path', ({ path, nativeThrow }) =>
114
108
  });
115
109
 
116
110
  it('mutationKey first segment matches feature directory', () => {
117
- // Feature directory = first segment of `path`. e.g. `mm/useSupply.ts` → `mm`.
118
111
  const featureDir = path.split('/')[0];
119
112
  const match = src.match(/mutationKey:\s*\[\s*'([^']+)'/);
120
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,
@@ -10,16 +10,7 @@ export type UseBackendIntentByTxHashParams = ReadHookParams<
10
10
  }
11
11
  >;
12
12
 
13
- /**
14
- * React hook for fetching intent details from the backend API using a transaction hash.
15
- *
16
- * @example
17
- * const { data: intent } = useBackendIntentByTxHash({ params: { txHash: '0x123...' } });
18
- *
19
- * @remarks
20
- * - Intents are only created on the hub chain, so `txHash` must originate from there.
21
- * - Default refetch interval is 1 second.
22
- */
13
+ /** `txHash` must be a hub-chain tx: intents are only created there. */
23
14
  export const useBackendIntentByTxHash = ({
24
15
  params,
25
16
  queryOptions,
@@ -11,12 +11,6 @@ export type UseBackendMoneyMarketAssetParams = ReadHookParams<
11
11
  }
12
12
  >;
13
13
 
14
- /**
15
- * React hook to fetch a specific money market asset from the backend API.
16
- *
17
- * @example
18
- * const { data: asset } = useBackendMoneyMarketAsset({ params: { reserveAddress: '0xabc...' } });
19
- */
20
14
  export const useBackendMoneyMarketAsset = ({
21
15
  params,
22
16
  queryOptions,
@@ -13,14 +13,6 @@ export type UseBackendMoneyMarketAssetBorrowersParams = ReadHookParams<
13
13
  }
14
14
  >;
15
15
 
16
- /**
17
- * React hook for fetching borrowers for a specific money market asset from the backend API with pagination.
18
- *
19
- * @example
20
- * const { data: borrowers } = useBackendMoneyMarketAssetBorrowers({
21
- * params: { reserveAddress: '0xabc...', pagination: { offset: '0', limit: '20' } },
22
- * });
23
- */
24
16
  export const useBackendMoneyMarketAssetBorrowers = ({
25
17
  params,
26
18
  queryOptions,
@@ -13,14 +13,6 @@ export type UseBackendMoneyMarketAssetSuppliersParams = ReadHookParams<
13
13
  }
14
14
  >;
15
15
 
16
- /**
17
- * React hook for fetching suppliers for a specific money market asset from the backend API.
18
- *
19
- * @example
20
- * const { data: suppliers } = useBackendMoneyMarketAssetSuppliers({
21
- * params: { reserveAddress: '0xabc...', pagination: { offset: '0', limit: '20' } },
22
- * });
23
- */
24
16
  export const useBackendMoneyMarketAssetSuppliers = ({
25
17
  params,
26
18
  queryOptions,
@@ -11,12 +11,6 @@ export type UseBackendMoneyMarketPositionParams = ReadHookParams<
11
11
  }
12
12
  >;
13
13
 
14
- /**
15
- * React hook for fetching a user's money market position from the backend API.
16
- *
17
- * @example
18
- * const { data } = useBackendMoneyMarketPosition({ params: { userAddress: '0xabc...' } });
19
- */
20
14
  export const useBackendMoneyMarketPosition = ({
21
15
  params,
22
16
  queryOptions,
@@ -16,15 +16,7 @@ export type UseBackendOracleCandlesParams = ReadHookParams<
16
16
  }
17
17
  >;
18
18
 
19
- /**
20
- * Hook for fetching USD OHLC candles for a symbol over the half-open range `[from, to)`
21
- * from the backend API. Responses are cached server-side for roughly 10 seconds.
22
- *
23
- * @example
24
- * const { data } = useBackendOracleCandles({
25
- * params: { symbol: 'ETH', interval: '1h', from: 1756000000, to: 1756360000 },
26
- * });
27
- */
19
+ /** USD OHLC candles over the half-open range `[from, to)`; responses are cached server-side for ~10s. */
28
20
  export const useBackendOracleCandles = ({
29
21
  params,
30
22
  queryOptions,
@@ -6,13 +6,7 @@ import type { ReadHookParams } from '../shared/types.js';
6
6
 
7
7
  export type UseBackendOracleMarketsParams = ReadHookParams<OracleMarketsResponse>;
8
8
 
9
- /**
10
- * Hook for fetching the oracle candle store's discovery payload (quote currency,
11
- * selectable intervals, and covered symbols) from the backend API.
12
- *
13
- * @example
14
- * const { data: markets } = useBackendOracleMarkets();
15
- */
9
+ /** Oracle discovery payload: quote currency, selectable intervals and covered symbols. */
16
10
  export const useBackendOracleMarkets = ({
17
11
  queryOptions,
18
12
  }: UseBackendOracleMarketsParams = {}): UseQueryResult<OracleMarketsResponse, Error> => {
@@ -12,12 +12,6 @@ export type UseBackendOrderbookParams = ReadHookParams<
12
12
  }
13
13
  >;
14
14
 
15
- /**
16
- * Hook for fetching the solver orderbook from the backend API.
17
- *
18
- * @example
19
- * const { data } = useBackendOrderbook({ params: { pagination: { offset: '0', limit: '10' } } });
20
- */
21
15
  export const useBackendOrderbook = ({
22
16
  params,
23
17
  queryOptions,
@@ -13,14 +13,6 @@ export type UseBackendUserIntentsParams = ReadHookParams<
13
13
  }
14
14
  >;
15
15
 
16
- /**
17
- * React hook for fetching user-created intents from the backend API for a given user address.
18
- *
19
- * @example
20
- * const { data: userIntents } = useBackendUserIntents({
21
- * params: { userAddress: '0x123...' },
22
- * });
23
- */
24
16
  export const useBackendUserIntents = ({
25
17
  params,
26
18
  queryOptions,
@@ -4,8 +4,7 @@ import type { RadfiSession } from './useRadfiAuth.js';
4
4
  import { loadRadfiSession } from './useRadfiAuth.js';
5
5
  import { resolveBtcReadAddress } from './resolveBtcReadAddress.js';
6
6
 
7
- // resolveBtcReadAddress reads the Bound Exchange session via loadRadfiSession (localStorage-backed).
8
- // The dapp-kit test env is `node` (no localStorage), so mock the session lookup to drive each branch.
7
+ // The test env is `node` (no localStorage), so mock the session lookup to drive each branch.
9
8
  vi.mock('./useRadfiAuth.js', () => ({
10
9
  loadRadfiSession: vi.fn(),
11
10
  }));
@@ -40,7 +39,6 @@ describe('resolveBtcReadAddress', () => {
40
39
  const result = resolveBtcReadAddress(ChainKeys.BITCOIN_MAINNET, PERSONAL_ADDRESS);
41
40
 
42
41
  expect(result).toBe(TRADING_ADDRESS);
43
- // The session is keyed by the personal address.
44
42
  expect(mockLoadRadfiSession).toHaveBeenCalledWith(PERSONAL_ADDRESS);
45
43
  });
46
44
 
@@ -2,18 +2,8 @@ import { ChainKeys, type SpokeChainKey } from '@sodax/sdk';
2
2
  import { loadRadfiSession } from './useRadfiAuth.js';
3
3
 
4
4
  /**
5
- * Resolve a spoke address for READ queries (positions, balances, hub-wallet display).
6
- *
7
- * Bitcoin positions live under the Bound Exchange trading-wallet-derived hub wallet, so for Bitcoin we
8
- * resolve to the trading address from the locally-persisted Bound Exchange session. This is intentionally
9
- * a LOCAL lookup (no network call): a transient Bound Exchange API outage can never make a real position
10
- * read as empty, and reads never throw "Trading wallet not found". When there is no session, the
11
- * user has no Bitcoin position to show, so the original (personal) address is returned — deriving
12
- * an empty hub wallet, which is correct. Non-Bitcoin chains pass through unchanged.
13
- *
14
- * The WRITE path resolves the trading address authoritatively in the SDK
15
- * (`getEffectiveWalletAddress`, called from the money-market create*Intent flows); reads
16
- * deliberately use this lighter, fail-safe path.
5
+ * Bitcoin reads resolve the trading address from the LOCAL Bound session (no network), so an API outage never
6
+ * empties a real position; with no session the personal address is returned. Writes resolve it in the SDK.
17
7
  */
18
8
  export function resolveBtcReadAddress(chainKey: SpokeChainKey, address: string): string {
19
9
  if (chainKey !== ChainKeys.BITCOIN_MAINNET) return address;
@@ -11,13 +11,7 @@ export type UseBitcoinBalanceParams = ReadHookParams<
11
11
 
12
12
  const DEFAULT_RPC_URL = 'https://mempool.space/api';
13
13
 
14
- /**
15
- * Hook to fetch BTC balance for any Bitcoin address.
16
- * Sums all UTXOs (confirmed + unconfirmed) from mempool.space API.
17
- *
18
- * The UTXO set already excludes spent outputs (even from unconfirmed txs),
19
- * so the total is always the correct spendable balance.
20
- */
14
+ /** Sums all UTXOs (confirmed + unconfirmed); the UTXO set already excludes spent outputs. */
21
15
  export function useBitcoinBalance({
22
16
  params,
23
17
  queryOptions,
@@ -10,7 +10,6 @@ import { useTradingWalletBalance } from './useTradingWalletBalance.js';
10
10
 
11
11
  export interface UseBitcoinTradingSetupParams {
12
12
  chainKey: SpokeChainKey;
13
- /** This side's wallet provider + account, e.g. `useWalletProvider` / `useXAccount`. */
14
13
  walletProvider: IWalletProvider | undefined;
15
14
  address: string | undefined;
16
15
  }
@@ -23,9 +22,8 @@ export interface BitcoinTradingSetup {
23
22
  const INERT: BitcoinTradingSetup = { wallet: undefined, tradingBalance: undefined };
24
23
 
25
24
  /**
26
- * Bitcoin trading-wallet setup for one side of a cross-chain flow: Bitcoin funds move through a
27
- * Bound Exchange (Radfi) trading wallet, not the personal wallet. Inert (no work) unless `chainKey`
28
- * is Bitcoin. Wallet-layer inputs are passed in — this package doesn't depend on wallet-sdk-react.
25
+ * Bitcoin funds move through a Bound (Radfi) trading wallet; inert unless `chainKey` is Bitcoin.
26
+ * Wallet inputs are passed in because this package must not depend on wallet-sdk-react.
29
27
  */
30
28
  export function useBitcoinTradingSetup({
31
29
  chainKey,
@@ -9,19 +9,8 @@ export type UseEnsureRadfiAccessTokenVars = {
9
9
  };
10
10
 
11
11
  /**
12
- * Ensure a valid Bound Exchange access token and return it. Refreshes the existing token (no
13
- * signature prompt) when a refresh token is available, falling back to a full BIP322 re-auth only if
14
- * refresh fails. Bound tokens are short-lived, so call this right before a Bitcoin-source
15
- * createIntent — forward the returned token via the typed `extras.bound.accessToken` slot (SDK in-process)
16
- * or the `accessToken` body field on the backend DTO — or before the client-side sign + co-sign step.
17
- *
18
- * @example
19
- * const { mutateAsync: ensureToken } = useEnsureRadfiAccessToken();
20
- * const accessToken = await ensureToken({ walletProvider });
21
- * // SDK in-process (Bitcoin-gated extras):
22
- * await sodax.swaps.createIntent({ params, extras: { bound: { accessToken } }, raw: true });
23
- * // or backend createIntent — token in the body, not an x-bound-access-token header:
24
- * await createIntent({ body: { ...body, accessToken } });
12
+ * Bound tokens are short-lived: call right before a Bitcoin-source createIntent and pass the token as
13
+ * `extras.bound.accessToken` (SDK) or the `accessToken` body field (backend). Falls back to BIP322 re-auth.
25
14
  */
26
15
  export function useEnsureRadfiAccessToken({
27
16
  mutationOptions,
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/bitcoin/useFundTradingWallet.ts
2
1
  import { useQueryClient } from '@tanstack/react-query';
3
2
  import { ChainKeys, type IBitcoinWalletProvider } from '@sodax/sdk';
4
3
  import { useSodaxContext } from '../shared/useSodaxContext.js';
@@ -11,11 +10,6 @@ export type UseFundTradingWalletVars = {
11
10
  walletProvider: IBitcoinWalletProvider;
12
11
  };
13
12
 
14
- /**
15
- * React hook for funding the user's Bound Exchange trading wallet from their personal Bitcoin wallet.
16
- * Pure mutation: pass `{ amount, walletProvider }` to `mutate({...})`. Returns the broadcast tx
17
- * id on success.
18
- */
19
13
  export function useFundTradingWallet({
20
14
  mutationOptions,
21
15
  }: MutationHookParams<string, UseFundTradingWalletVars> = {}): SafeUseMutationResult<
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/bitcoin/useRadfiAuth.ts
2
1
  import { RadfiApiError, type IBitcoinWalletProvider } from '@sodax/sdk';
3
2
  import { useSodaxContext } from '../shared/useSodaxContext.js';
4
3
  import type { MutationHookParams } from '../shared/types.js';
@@ -44,11 +43,7 @@ export function clearRadfiSession(address: string): void {
44
43
  } catch {}
45
44
  }
46
45
 
47
- /**
48
- * React hook for authenticating with Bound Exchange via BIP322-signed message. Pure mutation: pass
49
- * `{ walletProvider }` to `mutate({...})`. The hook itself takes no arguments other than the
50
- * structural `mutationOptions` slot.
51
- */
46
+ /** Authenticates with Bound Exchange via a BIP322-signed message. */
52
47
  export function useRadfiAuth({
53
48
  mutationOptions,
54
49
  }: MutationHookParams<RadfiAuthResult, UseRadfiAuthVars> = {}): SafeUseMutationResult<
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/bitcoin/useRadfiSession.ts
2
1
  import { useState, useEffect, useRef, useCallback } from 'react';
3
2
  import type { IBitcoinWalletProvider } from '@sodax/sdk';
4
3
  import {