@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
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/bitcoin/useRadfiWithdraw.ts
2
1
  import { normalizePsbtToBase64, ChainKeys, type IBitcoinWalletProvider } from '@sodax/sdk';
3
2
  import { useQueryClient } from '@tanstack/react-query';
4
3
  import { loadRadfiSession } from './useRadfiAuth.js';
@@ -19,11 +18,6 @@ type WithdrawResult = {
19
18
  fee: number;
20
19
  };
21
20
 
22
- /**
23
- * React hook for withdrawing BTC from the user's Bound Exchange trading wallet back to their personal
24
- * Bitcoin wallet. Pure mutation: pass all inputs (including the wallet provider) to
25
- * `mutate({...})`.
26
- */
27
21
  export function useRadfiWithdraw({
28
22
  mutationOptions,
29
23
  }: MutationHookParams<WithdrawResult, UseRadfiWithdrawVars> = {}): SafeUseMutationResult<
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/bitcoin/useRenewUtxos.ts
2
1
  import { normalizePsbtToBase64, type IBitcoinWalletProvider } from '@sodax/sdk';
3
2
  import { useQueryClient } from '@tanstack/react-query';
4
3
  import { loadRadfiSession } from './useRadfiAuth.js';
@@ -11,10 +10,6 @@ export type UseRenewUtxosVars = {
11
10
  walletProvider: IBitcoinWalletProvider;
12
11
  };
13
12
 
14
- /**
15
- * React hook for renewing expired UTXOs in the user's Bound Exchange trading wallet. Pure mutation: pass
16
- * `{ txIdVouts, walletProvider }` to `mutate({...})`.
17
- */
18
13
  export function useRenewUtxos({
19
14
  mutationOptions,
20
15
  }: MutationHookParams<string, UseRenewUtxosVars> = {}): SafeUseMutationResult<string, Error, UseRenewUtxosVars> {
@@ -4,10 +4,7 @@ type UseTradingWalletReturn = {
4
4
  tradingAddress: string | undefined;
5
5
  };
6
6
 
7
- /**
8
- * Returns the Bound Exchange trading wallet address from the persisted session.
9
- * Trading wallet is created automatically during authentication — no API call needed.
10
- */
7
+ /** Reads the trading address from the persisted session (created during auth); no API call. */
11
8
  export function useTradingWallet(walletAddress: string | undefined): UseTradingWalletReturn {
12
9
  if (!walletAddress) return { tradingAddress: undefined };
13
10
  const session = loadRadfiSession(walletAddress);
@@ -19,13 +19,7 @@ import {
19
19
  isBridgeNotDelivered,
20
20
  } from './getBridgeDetailedStatusRefetchInterval.js';
21
21
 
22
- /**
23
- * Guards the polling-stop invariant for `useBridgeDetailedStatus.refetchInterval`: stop on a
24
- * terminal or abandoned backend record, on any relay packet or MPC deposit record (always
25
- * terminal), on a rejected API key, and on an exhausted not-delivered budget — but keep polling
26
- * through an outage. Tested as a pure function because dapp-kit's vitest runs in the `node`
27
- * environment.
28
- */
22
+ // Tested as a pure function because dapp-kit's vitest runs in the `node` environment.
29
23
  const KEY_A = 'arb:0xaaa';
30
24
  const KEY_B = 'arb:0xbbb';
31
25
 
@@ -7,17 +7,12 @@ import {
7
7
  } from '@sodax/sdk';
8
8
  import { MAX_MPC_RELAY_NOT_FOUND_POLLS, MAX_NOT_FOUND_POLLS, STATUS_POLL_MS } from '../shared/notFoundStreak.js';
9
9
 
10
- /**
11
- * Structural mirror of `useBridgeDetailedStatus`'s data type. Declared locally rather than imported
12
- * so this module does not own the hook's public contract.
13
- */
10
+ /** Mirrors `useBridgeDetailedStatus`'s data type locally so this module does not own the hook's contract. */
14
11
  type DetailedBridgeStatusRead = Result<DetailedBridgeStatus, BridgeDetailedStatusError> | undefined;
15
12
 
16
13
  /**
17
- * The read the budget counts: the relay has no packet for this source tx *and* the backend answered,
18
- * so the miss is real rather than unprovable. Every other `LOOKUP_FAILED` is a dependency failing
19
- * right now — the relay unreachable, a malformed response — and those keep polling, because that is
20
- * how the read recovers when the outage ends.
14
+ * The only read the budget counts: no relay packet *and* the backend answered, so the miss is real.
15
+ * Other `LOOKUP_FAILED`s are outages and keep polling so the read recovers.
21
16
  */
22
17
  export function isBridgeNotDelivered(data: DetailedBridgeStatusRead): boolean {
23
18
  return data !== undefined && !data.ok && data.error?.context?.reason === DETAILED_STATUS_NOT_DELIVERED;
@@ -29,16 +24,8 @@ export function isBridgeMpcRelayRead(data: DetailedBridgeStatusRead): boolean {
29
24
  }
30
25
 
31
26
  /**
32
- * Polling interval for `useBridgeDetailedStatus`.
33
- *
34
- * Unlike the swap analog there is no in-flight second arm to wait on: the relay arm only ever
35
- * carries a matched `executed` packet, and the MPC-relay arm a minted deposit record, so both are
36
- * terminal on arrival. That leaves three stops — a terminal or abandoned backend record, a rejected
37
- * API key, and the ambiguous relay miss once it has run `MAX_NOT_FOUND_POLLS` times in a row, or
38
- * `MAX_MPC_RELAY_NOT_FOUND_POLLS` when the SDK tags it `context.mpcRelay`.
39
- *
40
- * Kept in its own pure module (no React/context imports) so it is unit-testable in dapp-kit's `node`
41
- * test environment — importing the hook itself pulls in `useSodaxContext`.
27
+ * Relay and MPC-relay answers are terminal on arrival; stops on a terminal/abandoned backend record, a rejected key, or an exhausted miss budget.
28
+ * Kept free of React imports so it is unit-testable in the `node` test environment.
42
29
  */
43
30
  export function getBridgeDetailedStatusRefetchInterval(
44
31
  data: DetailedBridgeStatusRead,
@@ -46,13 +33,12 @@ export function getBridgeDetailedStatusRefetchInterval(
46
33
  ): number | false {
47
34
  if (data?.ok) {
48
35
  if (data.value.source !== 'backend') return false;
49
- // The two terminal states of the bridge wire contract, plus a record the backend abandoned
50
- // while its status was still non-terminal.
36
+ // `abandonedAt` marks a record the backend gave up on while still non-terminal.
51
37
  const { status, abandonedAt } = data.value.data;
52
38
  return status === 'executed' || status === 'failed' || abandonedAt ? false : STATUS_POLL_MS;
53
39
  }
54
40
  if (data && !data.ok) {
55
- // A rejected key is terminal — only a corrected key changes the answer, so stop asking.
41
+ // Only a corrected key changes the answer, so stop asking.
56
42
  if (isAuthFailure(data.error)) return false;
57
43
  const budget = isBridgeMpcRelayRead(data) ? MAX_MPC_RELAY_NOT_FOUND_POLLS : MAX_NOT_FOUND_POLLS;
58
44
  if (isBridgeNotDelivered(data) && consecutiveNotFound >= budget) return false;
@@ -1,14 +1,4 @@
1
- /**
2
- * `useBridge` wire test for the per-action API key: `extras.apiKey` in the mutation vars must reach
3
- * the backend submit-tx leg as `x-api-key` — on the POST and on the status poll — beating the
4
- * instance-level key.
5
- *
6
- * Follows the package convention of testing hooks without a renderer (captured `mutationFn`), with
7
- * the SDK stubbed at the same seams its own backend submit-tx tests use: `createBridgeIntent` is
8
- * spied on a real keyed `Sodax` so no wallet or chain is touched, while `POST /bridge/submit-tx`
9
- * and `GET /bridge/submit-tx/status` run call-through to a stubbed global fetch serving the
10
- * schema-valid fixtures from packages/sdk/src/bridge/BridgeService.test.ts.
11
- */
1
+ // `createBridgeIntent` is spied on a real keyed `Sodax` (no wallet/chain); submit-tx calls hit a stubbed global fetch.
12
2
 
13
3
  import { ChainKeys, Sodax } from '@sodax/sdk';
14
4
  import { beforeEach, describe, expect, it, vi } from 'vitest';
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/bridge/useBridge.ts
2
1
  import { useSodaxContext } from '../shared/useSodaxContext.js';
3
2
  import { invalidateBalances } from '../shared/invalidateBalances.js';
4
3
  import type { BridgeParams, SpokeChainKey, TxHashPair } from '@sodax/sdk';
@@ -8,19 +7,10 @@ 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 useBridge}. 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
- */
10
+ /** Lock `K` at the call site to narrow `walletProvider` and `params.srcChainKey`. */
16
11
  export type UseBridgeVars<K extends SpokeChainKey = SpokeChainKey> = Omit<BridgeParams<K, false>, 'raw'>;
17
12
 
18
- /**
19
- * React hook for executing a cross-chain bridge transfer.
20
- *
21
- * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
22
- * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.
23
- */
13
+ /** Throws on SDK failure; resolves to the unwrapped `TxHashPair` and invalidates balances. */
24
14
  export function useBridge<K extends SpokeChainKey = SpokeChainKey>({
25
15
  mutationOptions,
26
16
  }: MutationHookParams<TxHashPair, UseBridgeVars<K>> = {}): SafeUseMutationResult<TxHashPair, Error, UseBridgeVars<K>> {
@@ -20,8 +20,7 @@ export function useBridgeAllowance<K extends SpokeChainKey>({
20
20
  const walletProvider = params?.walletProvider;
21
21
 
22
22
  return useQuery<boolean, Error>({
23
- // Extract the (chain, owner, token, amount) tuple that actually scopes the allowance —
24
- // raw-object keys break per Rule 4 (bigints) and churn on every render.
23
+ // Key on the scoping tuple only: raw payload objects hold bigints and churn every render.
25
24
  queryKey: [
26
25
  'bridge',
27
26
  'allowance',
@@ -15,12 +15,8 @@ export type UseBridgeApprovalStrategyParams<K extends SpokeChainKey = SpokeChain
15
15
  >;
16
16
 
17
17
  /**
18
- * Which approval path {@link useBridgeWithApproval} would take for this bridge: `'not-required'`,
19
- * `'atomic-batch'` (approve + deposit in one EIP-5792 signature) or `'sequential'` (approve, then
20
- * bridge). Use it to label the bridge button. Pass the same `allowAccountUpgrade` you give the bridge.
21
- *
22
- * Not polled: `useBridgeWithApproval` invalidates it after a successful bridge, and the bridge
23
- * re-reads the strategy at execution, so a stale label never picks the wrong path.
18
+ * Predicts the approval path {@link useBridgeWithApproval} will take; pass the same `allowAccountUpgrade`.
19
+ * Not polled: the bridge re-reads the strategy at execution, so a stale label never picks the wrong path.
24
20
  */
25
21
  export function useBridgeApprovalStrategy<K extends SpokeChainKey = SpokeChainKey>({
26
22
  params,
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/bridge/useBridgeApprove.ts
2
1
  import type { BridgeParams, SpokeChainKey, TxReturnType } from '@sodax/sdk';
3
2
  import { useQueryClient } from '@tanstack/react-query';
4
3
  import { useSodaxContext } from '../shared/useSodaxContext.js';
@@ -6,21 +5,10 @@ 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 useBridgeApprove}. Generic over `K extends SpokeChainKey`
11
- * (defaults to the full union). Sophisticated callers can lock K at the hook call site to narrow
12
- * the `walletProvider` and `params.srcChainKey` types.
13
- */
8
+ /** Lock `K` at the call site to narrow `walletProvider` and `params.srcChainKey`. */
14
9
  export type UseBridgeApproveVars<K extends SpokeChainKey = SpokeChainKey> = Omit<BridgeParams<K, false>, 'raw'>;
15
10
 
16
- /**
17
- * React hook for approving ERC-20 token spending (or trustline establishment) for a bridge
18
- * action.
19
- *
20
- * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
21
- * `onError`, `retry`). Returns the unwrapped tx return value on success. Invalidates all
22
- * `['bridge', 'allowance', ...]` queries so any pending allowance check refreshes.
23
- */
11
+ /** Approves spending (or sets a trustline). Throws on SDK failure; invalidates `['bridge', 'allowance']` on success. */
24
12
  export function useBridgeApprove<K extends SpokeChainKey = SpokeChainKey>({
25
13
  mutationOptions,
26
14
  }: MutationHookParams<TxReturnType<K, false>, UseBridgeApproveVars<K>> = {}): SafeUseMutationResult<
@@ -1,14 +1,7 @@
1
1
  import { describe, expect, it, vi } from 'vitest';
2
2
  import { MAX_MPC_RELAY_NOT_FOUND_POLLS, MAX_NOT_FOUND_POLLS, STATUS_POLL_MS } from '../shared/notFoundStreak.js';
3
3
 
4
- /**
5
- * Pins the WIRING the pure-policy test cannot see: the hook must pass the read into the policy and
6
- * advance the budget once per query update. Feeding the policy the wrong argument reproduces a
7
- * poll that never stops, with the policy's own tests still green.
8
- *
9
- * No renderer, per the package convention (see `_apiKeyWire.test.ts`): the React Query wrapper is
10
- * mocked so the captured options bag can be driven directly.
11
- */
4
+ // Pins the hook-to-policy wiring the pure-policy test cannot see: a wrong argument polls forever with those tests green.
12
5
 
13
6
  // The captured options bag is opaque, like the real wrapper's.
14
7
  let captured: any;
@@ -16,9 +9,7 @@ let captured: any;
16
9
  const refSlots: Array<{ current: unknown }> = [];
17
10
  let refCursor = 0;
18
11
 
19
- // Only useRef is needed, and call order is stable, so this replays React's slot semantics well
20
- // enough to observe the budget across refetchInterval calls — the same shape
21
- // `shared/useRequestTrustline.test.ts` uses.
12
+ // Only useRef is needed and call order is stable, so this replays React's slot semantics well enough.
22
13
  vi.mock('react', () => ({
23
14
  useRef: (initial: unknown) => {
24
15
  const slot = refSlots[refCursor] ?? { current: initial };
@@ -36,28 +36,9 @@ function onwardHubTxHash(data: UseBridgeDetailedStatusResult): string | undefine
36
36
  }
37
37
 
38
38
  /**
39
- * Hook for monitoring a bridge from its source-chain transaction.
40
- *
41
- * `useBridgeApiSubmitTxStatus` needs the backend to still hold a usable record; this takes
42
- * `(srcChainKey, srcTxHash)` — the pair you hold after `bridge()`, plus `dstChainKey` for a bridge from Tron —
43
- * and routes to whichever source
44
- * can answer, so it also covers a bridge the client-side fallback completed. `data.value` is
45
- * discriminated on `source`, and each variant carries that source's payload unmodified.
46
- *
47
- * Polls every 3s. Stops once the answering source is terminal (a relay packet always is), once the
48
- * backend rejects the API key, and — like `useDetailedStatus` — after 40 consecutive *ambiguous*
49
- * reads, meaning a `LOOKUP_FAILED` whose relay has no packet for the tx — 100, about 5 minutes, for a bridge
50
- * with an MPC-relay end (`context.mpcRelay`), which settles more slowly. A dependency outage keeps
51
- * polling instead, so the read recovers by itself; any real answer resets the budget. Override with
52
- * `queryOptions.refetchInterval`.
53
- *
54
- * @example
55
- * ```typescript
56
- * const { data } = useBridgeDetailedStatus({ params: { srcChainKey, srcTxHash, dstChainKey } });
57
- * if (data?.ok && data.value.source === 'relay') console.log(data.value.data.dst_tx_hash);
58
- * ```
39
+ * Status by source tx (plus `dstChainKey` from Tron), routed to whichever source can answer; `data.value` is discriminated on `source`.
40
+ * Polls every 3s until terminal, API-key rejection, or 40 (MPC-relay: 100) consecutive no-packet misses; outages keep polling.
59
41
  */
60
-
61
42
  export const useBridgeDetailedStatus = ({
62
43
  params,
63
44
  queryOptions,
@@ -79,8 +60,7 @@ export const useBridgeDetailedStatus = ({
79
60
  },
80
61
  enabled: !!srcChainKey && !!srcTxHash,
81
62
  refetchInterval: query => {
82
- // Reaching the hub is progress, so the leg after it gets a budget of its own. An MPC-relay miss counts
83
- // on its own streak too, so one untagged miss in between cannot cut its longer budget short.
63
+ // Reaching the hub starts a fresh budget for the next leg; MPC-relay misses keep their own streak.
84
64
  const { data } = query.state;
85
65
  const leg = [onwardHubTxHash(data), isBridgeMpcRelayRead(data) ? 'mpcRelay' : undefined].filter(Boolean);
86
66
  notFoundStreakRef.current = advanceNotFoundStreak(
@@ -7,23 +7,14 @@ import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMu
7
7
  import { retryBeforeSubmission } from '../shared/retryBeforeSubmission.js';
8
8
  import { unwrapResult } from '../shared/unwrapResult.js';
9
9
 
10
- /**
11
- * Mutation variables for {@link useBridgeWithApproval}: `useBridge`'s, plus `allowAccountUpgrade`, `resumeBatchId` and
12
- * `resumeBatchCallCount`.
13
- */
14
10
  export type UseBridgeWithApprovalVars<K extends SpokeChainKey = SpokeChainKey> = Omit<
15
11
  BridgeWithApprovalParams<K>,
16
12
  'raw'
17
13
  >;
18
14
 
19
15
  /**
20
- * `useBridge` with the source-token approval folded in (`sodax.bridge.bridgeWithApproval`): no approval
21
- * when the allowance suffices, approve + deposit as one EIP-5792 batch (one signature) on a
22
- * batch-capable EVM wallet, otherwise approve, wait for it, then bridge. `data.approvalStrategy`
23
- * says which ran; {@link useBridgeApprovalStrategy} predicts it.
24
- *
25
- * Throws on SDK failure so React Query's error model engages. On success invalidates balances and
26
- * the bridge allowance and approval-strategy queries.
16
+ * `useBridge` with approval folded in (one EIP-5792 batch where supported); `data.approvalStrategy` says which path ran.
17
+ * Throws on SDK failure; on success invalidates balances, allowance and approval-strategy queries.
27
18
  */
28
19
  export function useBridgeWithApproval<K extends SpokeChainKey = SpokeChainKey>({
29
20
  mutationOptions,
@@ -5,11 +5,7 @@ import {
5
5
  getBridgeSubmitTxStatusRefetchInterval,
6
6
  } from './getBridgeSubmitTxStatusRefetchInterval.js';
7
7
 
8
- /**
9
- * Guards the polling-stop invariant for `useBridgeApiSubmitTxStatus.refetchInterval`: keep polling
10
- * a live record, stop on a terminal or abandoned one, and stop on a rejected API key. Tested as a
11
- * pure function because dapp-kit's vitest runs in the `node` environment.
12
- */
8
+ /** Tested as a pure function because dapp-kit's vitest runs in the `node` environment. */
13
9
  const record = (data: Partial<BridgeSubmitTxStatusDataV2>): BridgeSubmitTxStatusDataV2 => ({
14
10
  txHash: '0xabc',
15
11
  srcChainKey: '0xa4b1.arbitrum',
@@ -74,8 +70,7 @@ describe('getBridgeSubmitTxStatusRefetchInterval', () => {
74
70
  });
75
71
 
76
72
  it('stops on an auth failure even when a live record is still cached', () => {
77
- // Order matters: the key was rejected on a later poll, so the stale in-flight record must not
78
- // keep the interval alive.
73
+ // Order matters: a key rejected on a later poll must stop polling despite the stale in-flight record.
79
74
  expect(getBridgeSubmitTxStatusRefetchInterval(apiError(401), record({ status: 'relaying' }))).toBe(false);
80
75
  });
81
76
  });
@@ -2,19 +2,8 @@ import { isAuthFailure, type BridgeSubmitTxStatusDataV2 } from '@sodax/sdk';
2
2
 
3
3
  export const BRIDGE_SUBMIT_TX_STATUS_POLL_MS = 1000;
4
4
 
5
- /**
6
- * Polling interval for {@link useBridgeApiSubmitTxStatus}. Stops on a terminal record, on a record
7
- * the backend abandoned, and on a terminal API-key rejection.
8
- *
9
- * `abandonedAt` is terminal even when `status` is still non-terminal (e.g. `'relayed'`) — same rule
10
- * as the SDK's `pollBackendSubmitTx`. The auth stop is separate from the hook's `retry` policy:
11
- * `retry` bounds attempts *within* a tick, so without this the interval would keep firing a request
12
- * a corrected key is the only fix for.
13
- *
14
- * Kept in its own pure module (no React/context imports) so it is unit-testable in dapp-kit's
15
- * `node` test environment — importing the hook itself pulls in `useSodaxContext`. Same reason as
16
- * `swapsApi/isTerminalSwapIntentStatus`.
17
- */
5
+ /** Stops on a terminal status, on `abandonedAt` (even while `status` is non-terminal) or on API-key rejection
6
+ * (`retry` only bounds attempts within a tick). Kept React-free so it is unit-testable under `node`. */
18
7
  export function getBridgeSubmitTxStatusRefetchInterval(
19
8
  error: unknown,
20
9
  data: BridgeSubmitTxStatusDataV2 | undefined,
@@ -1,14 +1,11 @@
1
- // bridgeApi/ — React Query hooks over the HTTP Bridge API (`sodax.api.bridge.*`).
2
- // Distinct from the on-chain `bridge/` hooks (which call `sodax.bridge.*` directly).
3
-
4
- export * from './useBridgeApiAllowance.js'; // query
5
- export * from './useBridgeApiApprove.js'; // mutation (unsigned txs only)
6
- export * from './useBridgeApiApproveAndBroadcast.js'; // mutation (request → sign → broadcast → wait)
7
- export * from './useBridgeApiBridgeableAmount.js'; // query (deposit capacity / withdrawal liquidity)
8
- export * from './useBridgeApiCreateBridgeIntent.js'; // mutation
9
- export * from './useBridgeApiFee.js'; // query (partner fee — per-request override or configured default)
10
- export * from './useBridgeApiIsBridgeable.js'; // query (pair bridgeable?)
11
- export * from './useBridgeApiSubmitTx.js'; // mutation
12
- export * from './useBridgeApiSubmitTxStatus.js'; // query (poll)
13
- export * from './useBridgeApiTokens.js'; // query (backend-served token list)
14
- export * from './useBridgeApiTokensByChain.js'; // query (backend-served token list for one chain)
1
+ export * from './useBridgeApiAllowance.js';
2
+ export * from './useBridgeApiApprove.js';
3
+ export * from './useBridgeApiApproveAndBroadcast.js';
4
+ export * from './useBridgeApiBridgeableAmount.js';
5
+ export * from './useBridgeApiCreateBridgeIntent.js';
6
+ export * from './useBridgeApiFee.js';
7
+ export * from './useBridgeApiIsBridgeable.js';
8
+ export * from './useBridgeApiSubmitTx.js';
9
+ export * from './useBridgeApiSubmitTxStatus.js';
10
+ export * from './useBridgeApiTokens.js';
11
+ export * from './useBridgeApiTokensByChain.js';
@@ -13,15 +13,7 @@ export type UseBridgeApiAllowanceParams = ReadHookParams<
13
13
  }
14
14
  >;
15
15
 
16
- /**
17
- * React hook to check whether the source-token allowance is already sufficient for a bridge via
18
- * the bridge API — `sodax.api.bridge.checkAllowance`. Returns `{ valid }`.
19
- *
20
- * The `body` uses the wire DTO field names (`inputToken`/`inputAmount`).
21
- *
22
- * @example
23
- * const { data: allowance } = useBridgeApiAllowance({ params: { body: createBridgeIntentParams } });
24
- */
16
+ /** `body` uses the wire DTO field names (`inputToken`/`inputAmount`). */
25
17
  export const useBridgeApiAllowance = ({
26
18
  params,
27
19
  queryOptions,
@@ -5,28 +5,13 @@ import { unwrapResult } from '../shared/unwrapResult.js';
5
5
  import type { MutationHookParams } from '../shared/types.js';
6
6
  import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
7
7
 
8
- /**
9
- * Mutation variables for {@link useBridgeApiApprove}. The per-request `apiConfig` override belongs
10
- * here rather than at the hook level — different calls in the same component can target different
11
- * endpoints without re-rendering.
12
- */
13
8
  export type UseBridgeApiApproveVars = {
14
9
  body: CreateBridgeIntentParamsV2;
15
10
  apiConfig?: RequestOverrideConfig;
16
11
  };
17
12
 
18
- /**
19
- * React hook to build the unsigned token-approval transaction(s) for the source token via the bridge
20
- * API — `sodax.api.bridge.approve`. Returns `{ tx, resetTx? }` (chain-specific unsigned txs) to sign
21
- * and broadcast yourself; it does not change state, so no queries are invalidated.
22
- *
23
- * `resetTx`, when present, must be MINED before `tx` is a valid state transition. Prefer
24
- * {@link useBridgeApiApproveAndBroadcast}, which owns that ordering and invalidates the allowance query.
25
- *
26
- * @example
27
- * const { mutateAsync: approve } = useBridgeApiApprove();
28
- * const { tx, resetTx } = await approve({ body: createBridgeIntentParams });
29
- */
13
+ /** Returns unsigned `{ tx, resetTx? }`; `resetTx` must be MINED before `tx` is valid.
14
+ * Prefer {@link useBridgeApiApproveAndBroadcast}, which owns that ordering. */
30
15
  export const useBridgeApiApprove = ({
31
16
  mutationOptions,
32
17
  }: MutationHookParams<BridgeApproveResponseV2, UseBridgeApiApproveVars> = {}): SafeUseMutationResult<
@@ -1,10 +1,4 @@
1
- /**
2
- * The bridge API can return two approval transactions, and the second is only a valid state
3
- * transition once the first has been mined. That ordering is what this hook exists to own.
4
- *
5
- * Follows the package convention of testing hooks without a renderer: the React Query wrapper is
6
- * mocked so `mutationFn` can be captured and driven directly.
7
- */
1
+ // A second approval tx is only valid once the first is mined; this hook exists to own that ordering.
8
2
 
9
3
  import { ChainKeys } from '@sodax/sdk';
10
4
  import type { ApprovalProgress } from '../../utils/approvalPlan.js';
@@ -38,10 +32,7 @@ const APPROVE_HASH = '0xapprove-hash';
38
32
 
39
33
  const body = (srcChainKey: string) => ({ srcChainKey, inputToken: '0xtoken', inputAmount: '1' });
40
34
 
41
- /**
42
- * Records the interleaving of sends and waits so ordering can be asserted, not assumed.
43
- * `onWait` either throws (the receipt never arrives) or returns the mined status.
44
- */
35
+ /** Records send/wait interleaving; `onWait` throws (receipt never arrives) or returns the mined status. */
45
36
  function evmProvider(calls: string[], onWait?: (hash: string) => string | void) {
46
37
  return {
47
38
  sendTransaction: vi.fn(async (tx: { data: string }) => {
@@ -59,10 +50,8 @@ const onEvent = (sink: ApprovalProgress[]) => (progress: ApprovalProgress) => {
59
50
  sink.push(progress);
60
51
  };
61
52
 
62
- /** Compact rendering, so a sequence can be asserted as one readable list. */
63
53
  const trace = (p: ApprovalProgress): string => `${p.step}:${p.phase}:${p.index}/${p.total}`;
64
54
 
65
- /** One render, then the captured `mutationFn` invoked with `vars`. */
66
55
  // biome-ignore lint/suspicious/noExplicitAny: vars mirror the hook's generic mutation variables.
67
56
  const run = (vars: any) => {
68
57
  useBridgeApiApproveAndBroadcast();
@@ -24,26 +24,9 @@ export type UseBridgeApiApproveAndBroadcastVars<K extends SpokeChainKey = SpokeC
24
24
  };
25
25
 
26
26
  /**
27
- * React hook that runs the whole bridge-API approval: asks the API for the transactions, then signs,
28
- * broadcasts, and waits for each one.
29
- *
30
- * Prefer this over {@link useBridgeApiApprove}, which hands back the unsigned `{ tx, resetTx? }` and
31
- * leaves the ordering — reset mined first, then approve — to the caller. Confirmation happens inside
32
- * the hook, so it invalidates `['bridgeApi','allowance']` itself — after waiting up to about 15 seconds for
33
- * the API to report the allowance as valid, since its RPC can trail the node that confirmed the approve.
34
- * It resolves after that wait either way, so read the allowance rather than treating success as `valid`.
35
- *
36
- * Supports the chains the bridge API can approve on — the hub (Sonic), EVM spokes, and Stellar.
37
- * Every other chain reports its allowance as always sufficient, so approval never runs for it.
38
- *
39
- * `onProgress` reports each transaction as `{ step, phase, index, total }`, so the UI can name the
40
- * wallet prompt the user is looking at instead of one flat "Approving…" across two signatures.
41
- *
42
- * @example
43
- * const { mutateAsyncSafe: approve } = useBridgeApiApproveAndBroadcast();
44
- * const result = await approve({ body: createBridgeIntentParams, walletProvider, onProgress: setStep });
45
- * if (!result.ok) return;
46
- * const { resetTxHash, approveTxHash } = result.value; // resetTxHash only on a guarded token
27
+ * Signs, broadcasts and waits for each approval tx (reset mined first), then waits up to ~15s for the API allowance to
28
+ * report valid since its RPC can lag; resolves either way, so read the allowance rather than treating success as `valid`.
29
+ * Approval runs only on the hub, EVM spokes and Stellar; other chains report the allowance as always sufficient.
47
30
  */
48
31
  export const useBridgeApiApproveAndBroadcast = <K extends SpokeChainKey = SpokeChainKey>({
49
32
  mutationOptions,
@@ -13,18 +13,7 @@ export type UseBridgeApiBridgeableAmountParams = ReadHookParams<
13
13
  }
14
14
  >;
15
15
 
16
- /**
17
- * React hook to fetch the deposit capacity / withdrawal liquidity limit for a (from, to) token pair
18
- * via the bridge API — `sodax.api.bridge.getBridgeableAmount`. Returns `{ limit }`.
19
- *
20
- * Computable client-side from config + vault reserves — prefer `sodax.bridge.getBridgeableAmount`
21
- * for a no-round-trip read; this HTTP variant mirrors the `/bridge/bridgeable-amount` endpoint.
22
- *
23
- * The `body` uses the wire DTO field names (`srcChainKey`/`dstChainKey`/`inputToken`/`outputToken`).
24
- *
25
- * @example
26
- * const { data } = useBridgeApiBridgeableAmount({ params: { body: quote } });
27
- */
16
+ /** HTTP mirror of `sodax.bridge.getBridgeableAmount` (prefer that for a no-round-trip read); `body` uses wire DTO field names. */
28
17
  export const useBridgeApiBridgeableAmount = ({
29
18
  params,
30
19
  queryOptions,
@@ -5,25 +5,12 @@ import { unwrapResult } from '../shared/unwrapResult.js';
5
5
  import type { MutationHookParams } from '../shared/types.js';
6
6
  import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
7
7
 
8
- /**
9
- * Mutation variables for {@link useBridgeApiCreateBridgeIntent}. The per-request `apiConfig`
10
- * override belongs here rather than at the hook level.
11
- */
12
8
  export type UseBridgeApiCreateBridgeIntentVars = {
13
9
  body: CreateBridgeIntentParamsV2;
14
10
  apiConfig?: RequestOverrideConfig;
15
11
  };
16
12
 
17
- /**
18
- * React hook to build an unsigned spoke-deposit (create-bridge-intent) transaction via the bridge
19
- * API — `sodax.api.bridge.createBridgeIntent`. Returns `{ tx, relayData }` (no `intent` struct —
20
- * bridge is vault-backed) to sign and broadcast yourself; it does not change state, so no queries
21
- * are invalidated.
22
- *
23
- * @example
24
- * const { mutateAsync: createBridgeIntent } = useBridgeApiCreateBridgeIntent();
25
- * const { tx, relayData } = await createBridgeIntent({ body: createBridgeIntentParams });
26
- */
13
+ /** Returns the unsigned spoke-deposit `{ tx, relayData }` to sign and broadcast yourself; invalidates no queries. */
27
14
  export const useBridgeApiCreateBridgeIntent = ({
28
15
  mutationOptions,
29
16
  }: MutationHookParams<CreateBridgeIntentResponseV2, UseBridgeApiCreateBridgeIntentVars> = {}): SafeUseMutationResult<
@@ -13,17 +13,8 @@ export type UseBridgeApiFeeParams = ReadHookParams<
13
13
  }
14
14
  >;
15
15
 
16
- /**
17
- * React hook to fetch the bridge partner fee for an input amount via the bridge API (uses a per-request
18
- * `body.partnerFee` override when supplied, else the backend-configured fee) —
19
- * `sodax.api.bridge.getFee`. Returns `{ fee }` (smallest unit, decimal string).
20
- *
21
- * The fee is computable client-side (config-driven, token-independent) — prefer `sodax.bridge.getFee`
22
- * for a no-round-trip read; this HTTP variant mirrors the `/bridge/fee` endpoint for parity.
23
- *
24
- * @example
25
- * const { data: fee } = useBridgeApiFee({ params: { body: { inputAmount } } });
26
- */
16
+ /** Uses `body.partnerFee` when supplied, else the backend-configured fee; `fee` is a smallest-unit decimal string.
17
+ * Prefer `sodax.bridge.getFee` for a no-round-trip read. */
27
18
  export const useBridgeApiFee = ({
28
19
  params,
29
20
  queryOptions,
@@ -13,18 +13,7 @@ export type UseBridgeApiIsBridgeableParams = ReadHookParams<
13
13
  }
14
14
  >;
15
15
 
16
- /**
17
- * React hook to check whether a (from, to) token pair is bridgeable via the bridge API —
18
- * `sodax.api.bridge.isBridgeable`. Returns `{ bridgeable }`.
19
- *
20
- * Computable client-side from config + vault reserves — prefer `sodax.bridge.isBridgeable`
21
- * for a no-round-trip read; this HTTP variant mirrors the `/bridge/bridgeable/check` endpoint.
22
- *
23
- * The `body` uses the wire DTO field names (`srcChainKey`/`dstChainKey`/`inputToken`/`outputToken`).
24
- *
25
- * @example
26
- * const { data } = useBridgeApiIsBridgeable({ params: { body: quote } });
27
- */
16
+ /** HTTP mirror of `sodax.bridge.isBridgeable` (prefer that for a no-round-trip read); `body` uses wire DTO field names. */
28
17
  export const useBridgeApiIsBridgeable = ({
29
18
  params,
30
19
  queryOptions,