@sodax/dapp-kit 2.4.0-rc.1 → 2.4.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (288) hide show
  1. package/README.md +11 -3
  2. package/dist/index.d.ts +395 -2413
  3. package/dist/index.mjs +206 -31
  4. package/package.json +2 -2
  5. package/src/hooks/_apiKeyWire.test.ts +4 -29
  6. package/src/hooks/_mutationContract.test.ts +2 -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/index.ts +4 -0
  171. package/src/hooks/shared/invalidateBalances.ts +2 -10
  172. package/src/hooks/shared/isUserRejectedError.test.ts +0 -3
  173. package/src/hooks/shared/isUserRejectedError.ts +2 -23
  174. package/src/hooks/shared/notFoundStreak.ts +5 -22
  175. package/src/hooks/shared/retryUnlessAuthFailure.test.ts +1 -2
  176. package/src/hooks/shared/retryUnlessAuthFailure.ts +1 -12
  177. package/src/hooks/shared/solverStatusPolicy.test.ts +0 -5
  178. package/src/hooks/shared/solverStatusPolicy.ts +8 -58
  179. package/src/hooks/shared/types.ts +4 -55
  180. package/src/hooks/shared/unwrapResult.ts +1 -8
  181. package/src/hooks/shared/useBalances.ts +6 -39
  182. package/src/hooks/shared/useEstablishTrustline.test.ts +1 -5
  183. package/src/hooks/shared/useEstablishTrustline.ts +3 -13
  184. package/src/hooks/shared/useEstablishXrpTrustline.test.ts +112 -0
  185. package/src/hooks/shared/useEstablishXrpTrustline.ts +63 -0
  186. package/src/hooks/shared/useEstimateGas.ts +0 -1
  187. package/src/hooks/shared/useGetUserHubWalletAddress.ts +1 -18
  188. package/src/hooks/shared/useNearStorageCheck.ts +2 -9
  189. package/src/hooks/shared/useNearStorageGate.ts +5 -15
  190. package/src/hooks/shared/useRegisterNearStorage.ts +2 -10
  191. package/src/hooks/shared/useRequestTrustline.test.ts +1 -7
  192. package/src/hooks/shared/useRequestTrustline.ts +4 -14
  193. package/src/hooks/shared/useSafeMutation.test.ts +0 -3
  194. package/src/hooks/shared/useSafeMutation.ts +2 -26
  195. package/src/hooks/shared/useSodaxContext.ts +0 -6
  196. package/src/hooks/shared/useStellarGate.test.ts +2 -9
  197. package/src/hooks/shared/useStellarGate.ts +3 -9
  198. package/src/hooks/shared/useStellarTrustlineCheck.test.ts +0 -2
  199. package/src/hooks/shared/useStellarTrustlineCheck.ts +1 -4
  200. package/src/hooks/shared/useXBalances.ts +2 -20
  201. package/src/hooks/shared/useXrpDestinationCheck.ts +71 -0
  202. package/src/hooks/shared/useXrpGate.test.ts +116 -0
  203. package/src/hooks/shared/useXrpGate.ts +80 -0
  204. package/src/hooks/shared/useXrpTrustlineReserveCheck.ts +45 -0
  205. package/src/hooks/shared/waitForApiAllowance.test.ts +0 -1
  206. package/src/hooks/shared/waitForApiAllowance.ts +2 -6
  207. package/src/hooks/sponsoring/useActivateStellarAccount.test.ts +1 -2
  208. package/src/hooks/sponsoring/useActivateStellarAccount.ts +1 -5
  209. package/src/hooks/sponsoring/useActivateStellarAccount.wire.test.ts +2 -13
  210. package/src/hooks/sponsoring/useSponsorConfig.ts +0 -1
  211. package/src/hooks/sponsoring/useStellarAccountActive.ts +0 -1
  212. package/src/hooks/sponsoring/useStellarAccountStatus.ts +1 -4
  213. package/src/hooks/staking/index.ts +0 -1
  214. package/src/hooks/staking/useCancelUnstake.ts +1 -7
  215. package/src/hooks/staking/useClaim.ts +1 -7
  216. package/src/hooks/staking/useConvertedAssets.ts +1 -4
  217. package/src/hooks/staking/useInstantUnstake.ts +1 -7
  218. package/src/hooks/staking/useInstantUnstakeAllowance.ts +1 -5
  219. package/src/hooks/staking/useInstantUnstakeApprove.ts +1 -11
  220. package/src/hooks/staking/useInstantUnstakeRatio.ts +1 -4
  221. package/src/hooks/staking/useStake.ts +1 -12
  222. package/src/hooks/staking/useStakeAllowance.ts +1 -5
  223. package/src/hooks/staking/useStakeApprove.ts +1 -11
  224. package/src/hooks/staking/useStakeRatio.ts +1 -4
  225. package/src/hooks/staking/useStakingConfig.ts +1 -4
  226. package/src/hooks/staking/useStakingInfo.ts +1 -5
  227. package/src/hooks/staking/useUnstake.ts +2 -9
  228. package/src/hooks/staking/useUnstakeAllowance.ts +1 -5
  229. package/src/hooks/staking/useUnstakeApprove.ts +1 -10
  230. package/src/hooks/staking/useUnstakingInfo.ts +1 -4
  231. package/src/hooks/staking/useUnstakingInfoWithPenalty.ts +1 -4
  232. package/src/hooks/swap/useCancelLimitOrder.ts +1 -7
  233. package/src/hooks/swap/useCancelSwap.ts +1 -7
  234. package/src/hooks/swap/useCreateLimitOrder.ts +2 -12
  235. package/src/hooks/swap/useDetailedStatus.test.ts +6 -18
  236. package/src/hooks/swap/useDetailedStatus.ts +2 -19
  237. package/src/hooks/swap/useQuote.test.ts +2 -8
  238. package/src/hooks/swap/useQuote.ts +5 -32
  239. package/src/hooks/swap/useStatus.ts +2 -10
  240. package/src/hooks/swap/useSwap.test.ts +1 -11
  241. package/src/hooks/swap/useSwap.ts +2 -12
  242. package/src/hooks/swap/useSwapAllowance.ts +1 -2
  243. package/src/hooks/swap/useSwapApprovalStrategy.ts +2 -7
  244. package/src/hooks/swap/useSwapApprove.ts +2 -14
  245. package/src/hooks/swap/useSwapLifecycle.test.ts +47 -2
  246. package/src/hooks/swap/useSwapLifecycle.ts +36 -30
  247. package/src/hooks/swap/useSwapWithApproval.ts +2 -11
  248. package/src/hooks/swapsApi/index.ts +2 -14
  249. package/src/hooks/swapsApi/isTerminalSwapIntentStatus.test.ts +1 -5
  250. package/src/hooks/swapsApi/isTerminalSwapIntentStatus.ts +1 -7
  251. package/src/hooks/swapsApi/useSwapsApiAllowance.ts +0 -7
  252. package/src/hooks/swapsApi/useSwapsApiApprove.ts +1 -14
  253. package/src/hooks/swapsApi/useSwapsApiApproveAndBroadcast.test.ts +5 -20
  254. package/src/hooks/swapsApi/useSwapsApiApproveAndBroadcast.ts +3 -24
  255. package/src/hooks/swapsApi/useSwapsApiBroadcastWithApproval.test.ts +2 -8
  256. package/src/hooks/swapsApi/useSwapsApiBroadcastWithApproval.ts +6 -41
  257. package/src/hooks/swapsApi/useSwapsApiCancelIntent.ts +0 -13
  258. package/src/hooks/swapsApi/useSwapsApiCreateIntent.ts +0 -13
  259. package/src/hooks/swapsApi/useSwapsApiCreateLimitOrder.ts +1 -13
  260. package/src/hooks/swapsApi/useSwapsApiDeadline.ts +1 -7
  261. package/src/hooks/swapsApi/useSwapsApiEstimateGas.ts +0 -7
  262. package/src/hooks/swapsApi/useSwapsApiFilledIntent.ts +0 -8
  263. package/src/hooks/swapsApi/useSwapsApiIntent.ts +1 -7
  264. package/src/hooks/swapsApi/useSwapsApiIntentExtraData.ts +1 -8
  265. package/src/hooks/swapsApi/useSwapsApiIntentHash.ts +0 -7
  266. package/src/hooks/swapsApi/useSwapsApiIntentPacket.ts +1 -10
  267. package/src/hooks/swapsApi/useSwapsApiPartnerFee.ts +0 -7
  268. package/src/hooks/swapsApi/useSwapsApiQuote.ts +2 -24
  269. package/src/hooks/swapsApi/useSwapsApiSolverFee.ts +0 -7
  270. package/src/hooks/swapsApi/useSwapsApiStatus.ts +1 -11
  271. package/src/hooks/swapsApi/useSwapsApiSubmitIntent.ts +1 -15
  272. package/src/hooks/swapsApi/useSwapsApiSubmitTx.ts +0 -21
  273. package/src/hooks/swapsApi/useSwapsApiSubmitTxStatus.ts +2 -19
  274. package/src/hooks/swapsApi/useSwapsApiTokens.ts +0 -7
  275. package/src/hooks/swapsApi/useSwapsApiTokensByChain.ts +0 -7
  276. package/src/index.ts +1 -1
  277. package/src/providers/SodaxProvider.test.ts +2 -9
  278. package/src/providers/SodaxProvider.tsx +1 -12
  279. package/src/providers/createSodaxQueryClient.ts +4 -56
  280. package/src/utils/approvalPlan.ts +9 -32
  281. package/src/utils/dex-utils.ts +5 -20
  282. package/src/utils/index.ts +1 -0
  283. package/src/utils/nearStorageGate.ts +3 -14
  284. package/src/utils/stellarGate.ts +3 -16
  285. package/src/utils/swapLifecycle.test.ts +35 -0
  286. package/src/utils/swapLifecycle.ts +21 -28
  287. package/src/utils/xrpGate.test.ts +112 -0
  288. package/src/utils/xrpGate.ts +69 -0
@@ -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,
@@ -5,34 +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 useBridgeApiSubmitTx}. The per-request `apiConfig` override
10
- * (e.g. base URL) belongs here rather than at the hook level — different submissions in the same
11
- * component can target different endpoints without re-rendering.
12
- */
13
8
  export type UseBridgeApiSubmitTxVars = {
14
9
  request: BridgeSubmitTxRequestV2;
15
10
  apiConfig?: RequestOverrideConfig;
16
11
  };
17
12
 
18
- /**
19
- * React hook for submitting a broadcast bridge (spoke-deposit) transaction to be processed
20
- * (relayed server-side) via the bridge API — `sodax.api.bridge.submitTx`. Called AFTER signing +
21
- * broadcasting the spoke-deposit tx, handing it (with the FULL `relayData { address, payload }`
22
- * envelope) to the backend.
23
- *
24
- * Pure mutation: pass `{ request, apiConfig? }` to `mutate({...})`. Retries up to 3 times at the
25
- * hook level, except on a terminal API-key rejection (401/403) — see `retryUnlessAuthFailure`.
26
- * Consumers can override via `mutationOptions.retry`.
27
- *
28
- * @example
29
- * const { mutateAsync: submitBridgeTx, isPending, error } = useBridgeApiSubmitTx();
30
- *
31
- * const result = await submitBridgeTx({
32
- * request: { txHash: '0x123...', srcChainKey: '0xa4b1.arbitrum', walletAddress: '0xabc...', relayData: { address: '0x...', payload: '0x...' } },
33
- * apiConfig: { baseURL: 'https://...' },
34
- * });
35
- */
13
+ /** Call after broadcasting the spoke-deposit tx, passing the FULL `relayData { address, payload }` envelope.
14
+ * Retries up to 3 times except on API-key rejection (401/403). */
36
15
  export const useBridgeApiSubmitTx = ({
37
16
  mutationOptions,
38
17
  }: MutationHookParams<BridgeSubmitTxResponseV2, UseBridgeApiSubmitTxVars> = {}): SafeUseMutationResult<
@@ -2,15 +2,7 @@ import { SodaxError } from '@sodax/sdk';
2
2
  import { describe, expect, it, vi } from 'vitest';
3
3
  import { retryUnlessAuthFailure } from '../shared/retryUnlessAuthFailure.js';
4
4
 
5
- /**
6
- * Pins the WIRING of the auth stop, which `getBridgeSubmitTxStatusRefetchInterval.test.ts` cannot
7
- * see: the policy is only reached if the hook hands it `query.state.error`. Passing the wrong
8
- * argument (or none) reproduces the original defect — a rejected key re-requested every second —
9
- * with the policy's own unit tests still green.
10
- *
11
- * No renderer, per the package convention (see `_apiKeyWire.test.ts`): the React Query wrapper is
12
- * mocked so the captured options bag can be driven directly.
13
- */
5
+ // Pins that the hook hands `query.state.error` to the refetch policy, which the policy's own unit tests cannot see.
14
6
 
15
7
  // The captured options bag is opaque, like the real wrapper's.
16
8
  let captured: any;
@@ -15,23 +15,7 @@ export type UseBridgeApiSubmitTxStatusParams = ReadHookParams<
15
15
  }
16
16
  >;
17
17
 
18
- /**
19
- * React hook for polling the processing status of a submitted bridge transaction via the bridge
20
- * API — `sodax.api.bridge.getSubmitTxStatus`. Both `txHash` and `srcChainKey` are required for the
21
- * query to run.
22
- *
23
- * @example
24
- * const { data: status } = useBridgeApiSubmitTxStatus({
25
- * params: { txHash: '0x123...', srcChainKey: '0xa4b1.arbitrum' },
26
- * });
27
- *
28
- * @remarks
29
- * - Default refetch interval is 1 second; stops on 'executed' or 'failed' status, when the
30
- * backend marks the submission abandoned (`abandonedAt`) while `status` stays non-terminal, or
31
- * once the backend rejects the API key (401/403 is terminal — a retry cannot fix it) —
32
- * mirroring the SDK's backend submit-tx poll (no solver `posting_execution` state — bridge has
33
- * no post-execution).
34
- */
18
+ /** Polls every 1s until 'executed'/'failed', `abandonedAt`, or API-key rejection (401/403). */
35
19
  export const useBridgeApiSubmitTxStatus = ({
36
20
  params,
37
21
  queryOptions,
@@ -44,8 +28,6 @@ export const useBridgeApiSubmitTxStatus = ({
44
28
  return useQuery({
45
29
  queryKey: ['bridgeApi', 'submitTx', 'status', txHash, srcChainKey],
46
30
  queryFn: async (): Promise<BridgeSubmitTxStatusResponseV2 | undefined> => {
47
- // `srcChainKey` is required by the bridge API status query. The `enabled` gate below ensures
48
- // both are present; this guard also narrows the types for the call.
49
31
  if (!txHash || !srcChainKey) return undefined;
50
32
  return unwrapResult(await sodax.api.bridge.getSubmitTxStatus({ txHash, srcChainKey }, apiConfig));
51
33
  },
@@ -12,14 +12,6 @@ export type UseBridgeApiTokensParams = ReadHookParams<
12
12
  }
13
13
  >;
14
14
 
15
- /**
16
- * React hook to fetch all supported bridge tokens grouped by SpokeChainKey via the bridge API —
17
- * `sodax.api.bridge.getTokens`. The token list is backend-served; the bridgeable-amount quote is
18
- * computable client-side via `useGetBridgeableAmount` (also mirrored by `useBridgeApiBridgeableAmount`).
19
- *
20
- * @example
21
- * const { data: tokensByChain } = useBridgeApiTokens();
22
- */
23
15
  export const useBridgeApiTokens = ({
24
16
  params,
25
17
  queryOptions,
@@ -13,13 +13,6 @@ export type UseBridgeApiTokensByChainParams = ReadHookParams<
13
13
  }
14
14
  >;
15
15
 
16
- /**
17
- * React hook to fetch supported bridge tokens for a single SpokeChainKey via the bridge API —
18
- * `sodax.api.bridge.getTokensByChain`. Use `useBridgeApiTokens` for every chain at once.
19
- *
20
- * @example
21
- * const { data: tokens } = useBridgeApiTokensByChain({ params: { chainKey: '0xa4b1.arbitrum' } });
22
- */
23
16
  export const useBridgeApiTokensByChain = ({
24
17
  params,
25
18
  queryOptions,
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/dex/useClaimRewards.ts
2
1
  import type { ClLiquidityClaimRewardsAction, SpokeChainKey, TxHashPair } from '@sodax/sdk';
3
2
  import { useQueryClient } from '@tanstack/react-query';
4
3
  import { useSodaxContext } from '../shared/useSodaxContext.js';
@@ -6,22 +5,12 @@ import type { MutationHookParams } from '../shared/types.js';
6
5
  import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
7
6
  import { unwrapResult } from '../shared/unwrapResult.js';
8
7
 
9
- /**
10
- * Mutation variables for {@link useClaimRewards}. Generic over `K extends SpokeChainKey` (defaults
11
- * to the full union). Sophisticated callers can lock K at the hook call site to narrow the
12
- * `walletProvider` and `params.srcChainKey` types.
13
- */
14
8
  export type UseClaimRewardsVars<K extends SpokeChainKey = SpokeChainKey> = Omit<
15
9
  ClLiquidityClaimRewardsAction<K, false>,
16
10
  'raw'
17
11
  >;
18
12
 
19
- /**
20
- * React hook for claiming accrued fees on a concentrated-liquidity position.
21
- *
22
- * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
23
- * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.
24
- */
13
+ /** Throws on SDK failure (React Query error state); resolves to the unwrapped `TxHashPair`. */
25
14
  export function useClaimRewards<K extends SpokeChainKey = SpokeChainKey>({
26
15
  mutationOptions,
27
16
  }: MutationHookParams<TxHashPair, UseClaimRewardsVars<K>> = {}): SafeUseMutationResult<
@@ -10,11 +10,7 @@ export type UseCreateDecreaseLiquidityParamsProps = {
10
10
  slippageTolerance: string | number;
11
11
  };
12
12
 
13
- /**
14
- * React hook to memoize the decrease-liquidity-specific subset of {@link ClDecreaseLiquidityParams}
15
- * (`{ poolKey, tokenId, liquidity, amount0Min, amount1Min }`). Callers add `srcChainKey` +
16
- * `srcAddress` at the mutation call site.
17
- */
13
+ /** Memoizes the decrease-liquidity fields; callers add `srcChainKey` + `srcAddress` at mutation time. */
18
14
  export function useCreateDecreaseLiquidityParams({
19
15
  poolKey,
20
16
  tokenId,
@@ -9,11 +9,7 @@ export type UseCreateDepositParamsProps = {
9
9
  poolSpokeAssets: PoolSpokeAssets;
10
10
  };
11
11
 
12
- /**
13
- * React hook to memoize the deposit-specific subset of {@link CreateAssetDepositParams}
14
- * (`{ asset, amount, poolToken, dst? }`). Callers add `srcChainKey` + `srcAddress` at the mutation
15
- * call site.
16
- */
12
+ /** Memoizes the deposit fields; callers add `srcChainKey` + `srcAddress` at mutation time. */
17
13
  export function useCreateDepositParams({
18
14
  tokenIndex,
19
15
  amount,
@@ -15,11 +15,7 @@ export type UseCreateSupplyLiquidityParamsProps = {
15
15
  isValidPosition?: boolean;
16
16
  };
17
17
 
18
- /**
19
- * Subset of {@link ClSupplyParams} / {@link ClIncreaseLiquidityParams} produced by
20
- * {@link useCreateSupplyLiquidityParams}. Callers add `srcChainKey` + `srcAddress` at the mutation
21
- * call site. `tokenId` and `isValidPosition` distinguish the mint-new vs increase-existing path.
22
- */
18
+ /** `tokenId` + `isValidPosition` select increase-existing over mint-new; callers add `srcChainKey` + `srcAddress`. */
23
19
  export type UseCreateSupplyLiquidityParamsResult = Omit<ClSupplyParams<SpokeChainKey>, 'srcChainKey' | 'srcAddress'> &
24
20
  Omit<ClIncreaseLiquidityParams<SpokeChainKey>, 'srcChainKey' | 'srcAddress' | 'tokenId'> & {
25
21
  tokenId?: string | bigint;
@@ -27,11 +23,6 @@ export type UseCreateSupplyLiquidityParamsResult = Omit<ClSupplyParams<SpokeChai
27
23
  isValidPosition?: boolean;
28
24
  };
29
25
 
30
- /**
31
- * React hook to memoize concentrated-liquidity supply parameters for a given pool. Returns the
32
- * pool/tick/liquidity/amount fields without `srcChainKey`/`srcAddress` — callers add those at the
33
- * mutation call site.
34
- */
35
26
  export function useCreateSupplyLiquidityParams({
36
27
  poolData,
37
28
  poolKey,
@@ -10,11 +10,7 @@ export type UseCreateWithdrawParamsProps = {
10
10
  dst?: DestinationParamsType;
11
11
  };
12
12
 
13
- /**
14
- * React hook to memoize the withdraw-specific subset of {@link CreateAssetWithdrawParams}
15
- * (`{ asset, amount, poolToken, dst? }`). Callers add `srcChainKey` + `srcAddress` at the mutation
16
- * call site.
17
- */
13
+ /** Memoizes the withdraw fields; callers add `srcChainKey` + `srcAddress` at mutation time. */
18
14
  export function useCreateWithdrawParams({
19
15
  tokenIndex,
20
16
  amount,
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/dex/useDecreaseLiquidity.ts
2
1
  import type { ClLiquidityDecreaseLiquidityAction, SpokeChainKey, TxHashPair } from '@sodax/sdk';
3
2
  import { useQueryClient } from '@tanstack/react-query';
4
3
  import { useSodaxContext } from '../shared/useSodaxContext.js';
@@ -6,22 +5,12 @@ import type { MutationHookParams } from '../shared/types.js';
6
5
  import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
7
6
  import { unwrapResult } from '../shared/unwrapResult.js';
8
7
 
9
- /**
10
- * Mutation variables for {@link useDecreaseLiquidity}. 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
- */
14
8
  export type UseDecreaseLiquidityVars<K extends SpokeChainKey = SpokeChainKey> = Omit<
15
9
  ClLiquidityDecreaseLiquidityAction<K, false>,
16
10
  'raw'
17
11
  >;
18
12
 
19
- /**
20
- * React hook for decreasing liquidity in an existing concentrated-liquidity position.
21
- *
22
- * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
23
- * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.
24
- */
13
+ /** Throws on SDK failure (React Query error state); resolves to the unwrapped `TxHashPair`. */
25
14
  export function useDecreaseLiquidity<K extends SpokeChainKey = SpokeChainKey>({
26
15
  mutationOptions,
27
16
  }: MutationHookParams<TxHashPair, UseDecreaseLiquidityVars<K>> = {}): SafeUseMutationResult<
@@ -38,9 +27,7 @@ export function useDecreaseLiquidity<K extends SpokeChainKey = SpokeChainKey>({
38
27
  mutationFn: async vars => unwrapResult(await sodax.dex.clService.decreaseLiquidity({ ...vars, raw: false })),
39
28
  onSuccess: async (data, vars, ctx) => {
40
29
  const { params } = vars;
41
- // Decrease always targets a known position — scope invalidation to (tokenId, poolKey) instead
42
- // of wiping all positions. `usePositionInfo` keys by string tokenId, so stringify the bigint
43
- // here to keep the structural match.
30
+ // Scope invalidation to this position; `usePositionInfo` keys by string tokenId, so stringify the bigint.
44
31
  queryClient.invalidateQueries({
45
32
  queryKey: ['dex', 'positionInfo', params.tokenId.toString(), params.poolKey],
46
33
  });
@@ -11,11 +11,7 @@ export type UseDexAllowanceParams<K extends SpokeChainKey = SpokeChainKey> = Rea
11
11
  }
12
12
  >;
13
13
 
14
- /**
15
- * React hook to check whether the user has approved sufficient token allowance (or established a
16
- * trustline, on Stellar) for a DEX deposit. Read-only — calls `assetService.isAllowanceValid`
17
- * with `raw: true` so no `walletProvider` is required.
18
- */
14
+ /** Read-only (`raw: true`), so no `walletProvider` is needed; covers Stellar trustlines too. */
19
15
  export function useDexAllowance<K extends SpokeChainKey = SpokeChainKey>({
20
16
  params,
21
17
  queryOptions,
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/dex/useDexApprove.ts
2
1
  import type { AssetDepositAction, SpokeChainKey, TxReturnType } from '@sodax/sdk';
3
2
  import { useQueryClient } from '@tanstack/react-query';
4
3
  import { useSodaxContext } from '../shared/useSodaxContext.js';
@@ -6,19 +5,9 @@ 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 useDexApprove}. Generic over `K extends SpokeChainKey` (defaults
11
- * to the full union). Sophisticated callers can lock K at the hook call site to narrow the
12
- * `walletProvider` and `params.srcChainKey` types.
13
- */
14
8
  export type UseDexApproveVars<K extends SpokeChainKey = SpokeChainKey> = Omit<AssetDepositAction<K, false>, 'raw'>;
15
9
 
16
- /**
17
- * React hook for approving ERC-20 token spending (or trustline establishment) for a DEX deposit.
18
- *
19
- * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
20
- * `onError`, `retry`). Returns the unwrapped tx return value on success.
21
- */
10
+ /** Throws on SDK failure (React Query error state); resolves to the unwrapped tx return value. */
22
11
  export function useDexApprove<K extends SpokeChainKey = SpokeChainKey>({
23
12
  mutationOptions,
24
13
  }: MutationHookParams<TxReturnType<K, false>, UseDexApproveVars<K>> = {}): SafeUseMutationResult<
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/dex/useDexDeposit.ts
2
1
  import type { AssetDepositAction, SpokeChainKey, TxHashPair } from '@sodax/sdk';
3
2
  import { useQueryClient } from '@tanstack/react-query';
4
3
  import { useSodaxContext } from '../shared/useSodaxContext.js';
@@ -8,30 +7,9 @@ import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMu
8
7
  import { retryBeforeSubmission } from '../shared/retryBeforeSubmission.js';
9
8
  import { unwrapResult } from '../shared/unwrapResult.js';
10
9
 
11
- /**
12
- * Mutation variables for {@link useDexDeposit}. Generic over `K extends SpokeChainKey` (defaults
13
- * to the full union). Sophisticated callers can lock K at the hook call site to narrow the
14
- * `walletProvider` and `params.srcChainKey` types.
15
- */
16
10
  export type UseDexDepositVars<K extends SpokeChainKey = SpokeChainKey> = Omit<AssetDepositAction<K, false>, 'raw'>;
17
11
 
18
- /**
19
- * React hook for depositing an asset into a DEX pool.
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
- *
24
- * @example
25
- * ```tsx
26
- * const walletProvider = useWalletProvider({ xChainId: chainKey });
27
- * const { mutateAsync: deposit } = useDexDeposit();
28
- * try {
29
- * const { spokeTxHash, hubTxHash } = await deposit({ params, walletProvider });
30
- * } catch (e) {
31
- * // surfaced via mutation.error / onError
32
- * }
33
- * ```
34
- */
12
+ /** Throws on SDK failure (React Query error state); resolves to the unwrapped `TxHashPair`. */
35
13
  export function useDexDeposit<K extends SpokeChainKey = SpokeChainKey>({
36
14
  mutationOptions,
37
15
  }: MutationHookParams<TxHashPair, UseDexDepositVars<K>> = {}): SafeUseMutationResult<
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/dex/useDexWithdraw.ts
2
1
  import type { AssetWithdrawAction, SpokeChainKey, OutboundSettlement } from '@sodax/sdk';
3
2
  import { useQueryClient } from '@tanstack/react-query';
4
3
  import { useSodaxContext } from '../shared/useSodaxContext.js';
@@ -8,20 +7,9 @@ import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMu
8
7
  import { retryBeforeSubmission } from '../shared/retryBeforeSubmission.js';
9
8
  import { unwrapResult } from '../shared/unwrapResult.js';
10
9
 
11
- /**
12
- * Mutation variables for {@link useDexWithdraw}. Generic over `K extends SpokeChainKey` (defaults
13
- * to the full union). Sophisticated callers can lock K at the hook call site to narrow the
14
- * `walletProvider` and `params.srcChainKey` types.
15
- */
16
10
  export type UseDexWithdrawVars<K extends SpokeChainKey = SpokeChainKey> = Omit<AssetWithdrawAction<K, false>, 'raw'>;
17
11
 
18
- /**
19
- * React hook for withdrawing an asset from a DEX pool.
20
- *
21
- * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
22
- * `onError`, `retry`). Returns the unwrapped {@link OutboundSettlement} on success: a tx pair, or
23
- * from Tron the relay's `trackingId` beside the destination tx.
24
- */
12
+ /** Throws on SDK failure; resolves to an {@link OutboundSettlement} (tx pair, or Tron relay `trackingId` + dst tx). */
25
13
  export function useDexWithdraw<K extends SpokeChainKey = SpokeChainKey>({
26
14
  mutationOptions,
27
15
  }: MutationHookParams<OutboundSettlement<K>, UseDexWithdrawVars<K>> = {}): SafeUseMutationResult<
@@ -11,10 +11,7 @@ export type UseLiquidityAmountsResult = {
11
11
  handleToken1AmountChange: (value: string) => void;
12
12
  };
13
13
 
14
- /**
15
- * Hook for calculating concentrated-liquidity amounts based on the price range. Pure state +
16
- * math; no SDK calls beyond the static {@link ClService} helpers.
17
- */
14
+ /** Pure state + math; no SDK calls beyond the static {@link ClService} helpers. */
18
15
  export function useLiquidityAmounts(
19
16
  minPrice: string,
20
17
  maxPrice: string,