@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
@@ -13,13 +13,7 @@ export type UseLeverageYieldApiSolverFeeParams = ReadHookParams<
13
13
  }
14
14
  >;
15
15
 
16
- /**
17
- * React hook to compute the protocol (solver) fee for a given input amount via the leverage-yield API — `sodax.api.leverageYield.getSolverFee`.
18
- * Returns `{ fee }` (decimal string).
19
- *
20
- * @example
21
- * const { data } = useLeverageYieldApiSolverFee({ params: { amount: '1000000' } });
22
- */
16
+ /** Maximum solver fee for `amount`, as a decimal string `{ fee }`. */
23
17
  export const useLeverageYieldApiSolverFee = ({
24
18
  params,
25
19
  queryOptions,
@@ -4,8 +4,7 @@ import { useSodaxContext } from '../shared/useSodaxContext.js';
4
4
  import { retryUnlessAuthFailure } from '../shared/retryUnlessAuthFailure.js';
5
5
  import { unwrapResult } from '../shared/unwrapResult.js';
6
6
  import type { ReadHookParams } from '../shared/types.js';
7
- // Leverage-yield intents share the solver status codes with swaps, so the terminal-status predicate
8
- // is reused rather than duplicated.
7
+ // Leverage-yield intents share the solver status codes with swaps.
9
8
  import { isTerminalSwapIntentStatus } from '../swapsApi/isTerminalSwapIntentStatus.js';
10
9
 
11
10
  export type UseLeverageYieldApiStatusParams = ReadHookParams<
@@ -16,16 +15,7 @@ export type UseLeverageYieldApiStatusParams = ReadHookParams<
16
15
  }
17
16
  >;
18
17
 
19
- /**
20
- * React hook for polling the solver intent status by hub-chain intent tx hash via the leverage-yield
21
- * API — `sodax.api.leverageYield.getStatus`. Returns `{ status, fillTxHash? }`.
22
- *
23
- * @example
24
- * const { data } = useLeverageYieldApiStatus({ params: { intentTxHash: '0x123...' } });
25
- *
26
- * @remarks
27
- * - Default refetch interval is 1 second; stops once `status` is `3` (SOLVED) or `4` (FAILED).
28
- */
18
+ /** Polls every 1s until `status` is 3 (SOLVED) or 4 (FAILED). */
29
19
  export const useLeverageYieldApiStatus = ({
30
20
  params,
31
21
  queryOptions,
@@ -4,19 +4,13 @@ import { unwrapResult } from '../shared/unwrapResult.js';
4
4
  import type { MutationHookParams } from '../shared/types.js';
5
5
  import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
6
6
 
7
- /**
8
- * Mutation variables for {@link useLeverageYieldApiSubmitIntent}. The per-request `apiConfig` override belongs here
9
- * rather than at the hook level — different calls in the same component can target different
10
- * endpoints without re-rendering.
11
- */
7
+ /** Per-call `apiConfig` so calls in one component can target different endpoints. */
12
8
  export type UseLeverageYieldApiSubmitIntentVars = {
13
9
  body: SubmitIntentRequestV2;
14
10
  apiConfig?: RequestOverrideConfig;
15
11
  };
16
12
 
17
- /**
18
- * React hook to submit the broadcast intent tx to the relay via the leverage-yield API — `sodax.api.leverageYield.submitIntent`.
19
- */
13
+ /** Submits the already-broadcast intent tx to the relay. */
20
14
  export const useLeverageYieldApiSubmitIntent = ({
21
15
  mutationOptions,
22
16
  }: MutationHookParams<SubmitIntentResponseV2, UseLeverageYieldApiSubmitIntentVars> = {}): SafeUseMutationResult<
@@ -5,19 +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 useLeverageYieldApiSubmitTx}. The per-request `apiConfig` override belongs here
10
- * rather than at the hook level — different calls in the same component can target different
11
- * endpoints without re-rendering.
12
- */
8
+ /** Per-call `apiConfig` so calls in one component can target different endpoints. */
13
9
  export type UseLeverageYieldApiSubmitTxVars = {
14
10
  request: LeverageYieldSubmitTxRequestV2;
15
11
  apiConfig?: RequestOverrideConfig;
16
12
  };
17
13
 
18
- /**
19
- * React hook to submit a vault-swap transaction to be processed (relay, post-execution, etc.) via the leverage-yield API — `sodax.api.leverageYield.submitTx`.
20
- */
14
+ /** Submits a vault-swap tx for backend processing (relay, post-execution). */
21
15
  export const useLeverageYieldApiSubmitTx = ({
22
16
  mutationOptions,
23
17
  }: MutationHookParams<SubmitTxResponseV2, UseLeverageYieldApiSubmitTxVars> = {}): SafeUseMutationResult<
@@ -14,21 +14,7 @@ export type UseLeverageYieldApiSubmitTxStatusParams = ReadHookParams<
14
14
  }
15
15
  >;
16
16
 
17
- /**
18
- * React hook for polling the processing status of a submitted vault-swap transaction via the
19
- * leverage-yield API — `sodax.api.leverageYield.getSubmitTxStatus`. Both `txHash` and `srcChainKey`
20
- * are required for the query to run.
21
- *
22
- * @example
23
- * const { data: status } = useLeverageYieldApiSubmitTxStatus({
24
- * params: { txHash: '0x123...', srcChainKey: 'sonic' },
25
- * });
26
- *
27
- * @remarks
28
- * - Default refetch interval is 1 second; stops on 'solved' or 'failed' status, when the backend
29
- * marks the submission abandoned (`abandonedAt`) while `status` stays non-terminal, or once the
30
- * backend rejects the API key (401/403 is terminal — a retry cannot fix it).
31
- */
17
+ /** Polls every 1s until 'solved'/'failed', `abandonedAt` is set, or the API key is rejected (401/403 is terminal). */
32
18
  export const useLeverageYieldApiSubmitTxStatus = ({
33
19
  params,
34
20
  queryOptions,
@@ -50,8 +36,7 @@ export const useLeverageYieldApiSubmitTxStatus = ({
50
36
  // `retry` bounds attempts within a tick, not the interval itself — so stop it here too.
51
37
  if (isAuthFailure(query.state.error)) return false;
52
38
  const data = query.state.data?.data;
53
- // `abandonedAt` is terminal even when `status` is still non-terminal — same rule as the
54
- // SDK's pollBackendSubmitTx and the swaps-api status hook.
39
+ // `abandonedAt` is terminal even while `status` is not (same rule as the SDK's pollBackendSubmitTx).
55
40
  if (data?.status === 'solved' || data?.status === 'failed' || data?.abandonedAt) return false;
56
41
  return 1000;
57
42
  },
@@ -13,13 +13,6 @@ export type UseLeverageYieldApiTotalAssetsParams = ReadHookParams<
13
13
  }
14
14
  >;
15
15
 
16
- /**
17
- * React hook to fetch the total assets managed by the vault for a leverage-yield vault via the leverage-yield API —
18
- * `sodax.api.leverageYield.getTotalAssets`.
19
- *
20
- * @example
21
- * const { data } = useLeverageYieldApiTotalAssets({ params: { vault: '0x...' } });
22
- */
23
16
  export const useLeverageYieldApiTotalAssets = ({
24
17
  params,
25
18
  queryOptions,
@@ -13,13 +13,7 @@ export type UseLeverageYieldApiVaultParams = ReadHookParams<
13
13
  }
14
14
  >;
15
15
 
16
- /**
17
- * React hook to fetch a single vault descriptor by its lsoda* share-token name via the
18
- * leverage-yield API — `sodax.api.leverageYield.getVault`.
19
- *
20
- * @example
21
- * const { data: vault } = useLeverageYieldApiVault({ params: { name: 'lsodaWEETH' } });
22
- */
16
+ /** Looks up one vault by its lsoda* share-token name (e.g. `lsodaWEETH`). */
23
17
  export const useLeverageYieldApiVault = ({
24
18
  params,
25
19
  queryOptions,
@@ -12,13 +12,6 @@ export type UseLeverageYieldApiVaultsParams = ReadHookParams<
12
12
  }
13
13
  >;
14
14
 
15
- /**
16
- * React hook to fetch the registry of deployed leverage-yield vaults via the leverage-yield API —
17
- * `sodax.api.leverageYield.getVaults`.
18
- *
19
- * @example
20
- * const { data: vaults } = useLeverageYieldApiVaults();
21
- */
22
15
  export const useLeverageYieldApiVaults = ({
23
16
  params,
24
17
  queryOptions,
@@ -19,21 +19,7 @@ export type UseLeverageYieldApiWithdrawQuoteParams = ReadHookParams<
19
19
  }
20
20
  >;
21
21
 
22
- /**
23
- * React hook to quote a swap-style leverage-yield withdraw (lsoda* shares → any token) via the
24
- * leverage-yield API — `sodax.api.leverageYield.getWithdrawQuote`. Pass `query.includeTxData = true`
25
- * to also build the unsigned transaction (`srcAddress`/`dstAddress` then required in the body).
26
- *
27
- * @example
28
- * const { data: quote } = useLeverageYieldApiWithdrawQuote({
29
- * params: {
30
- * body: {
31
- * vault: '0x...', srcChainKey: 'sonic', tokenDst: '0x...', tokenDstChainKey: '0xa4b1.arbitrum',
32
- * amount: '1000000000000000000', quoteType: 'exact_input',
33
- * },
34
- * },
35
- * });
36
- */
22
+ /** `query.includeTxData = true` also builds the unsigned tx and requires `srcAddress`/`dstAddress` in the body. */
37
23
  export const useLeverageYieldApiWithdrawQuote = ({
38
24
  params,
39
25
  queryOptions,
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/migrate/useMigrateBaln.ts
2
1
  import type { BalnMigrateAction, TxHashPair } from '@sodax/sdk';
3
2
  import { ChainKeys } from '@sodax/sdk';
4
3
  import { useQueryClient } from '@tanstack/react-query';
@@ -10,13 +9,7 @@ import { unwrapResult } from '../shared/unwrapResult.js';
10
9
 
11
10
  export type UseMigrateBalnVars = Omit<BalnMigrateAction<false>, 'raw'>;
12
11
 
13
- /**
14
- * React hook for migrating BALN → SODA on the Sonic hub. Source chain is always Icon. Supports
15
- * lockup periods (0–24 months) which multiply the SODA reward (0.5x–1.5x).
16
- *
17
- * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
18
- * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.
19
- */
12
+ /** Source chain is always Icon; a 0–24 month lockup scales the SODA reward 0.5x–1.5x. */
20
13
  export function useMigrateBaln({
21
14
  mutationOptions,
22
15
  }: MutationHookParams<TxHashPair, UseMigrateBalnVars> = {}): SafeUseMutationResult<
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/migrate/useMigrateIcxToSoda.ts
2
1
  import type { IcxMigrateAction, TxHashPair } from '@sodax/sdk';
3
2
  import { ChainKeys } from '@sodax/sdk';
4
3
  import { useQueryClient } from '@tanstack/react-query';
@@ -8,19 +7,9 @@ import type { MutationHookParams } from '../shared/types.js';
8
7
  import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
9
8
  import { unwrapResult } from '../shared/unwrapResult.js';
10
9
 
11
- /**
12
- * Mutation variables for {@link useMigrateIcxToSoda}. Wraps `IcxMigrateAction<false>` with `raw`
13
- * stripped — the hook always submits non-raw and unwraps the SDK Result.
14
- */
15
10
  export type UseMigrateIcxToSodaVars = Omit<IcxMigrateAction<false>, 'raw'>;
16
11
 
17
- /**
18
- * React hook for migrating ICX/wICX → SODA on the Sonic hub. Forward-only direction; for the
19
- * reverse (SODA → ICX) use {@link useRevertMigrateSodaToIcx}.
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
- */
12
+ /** Forward only; use {@link useRevertMigrateSodaToIcx} for SODA → ICX. */
24
13
  export function useMigrateIcxToSoda({
25
14
  mutationOptions,
26
15
  }: MutationHookParams<TxHashPair, UseMigrateIcxToSodaVars> = {}): SafeUseMutationResult<
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/migrate/useMigratebnUSD.ts
2
1
  import type { SpokeChainKey, TxHashPair, UnifiedBnUSDMigrateAction } from '@sodax/sdk';
3
2
  import { useQueryClient } from '@tanstack/react-query';
4
3
  import { useSodaxContext } from '../shared/useSodaxContext.js';
@@ -7,22 +6,12 @@ import type { MutationHookParams } from '../shared/types.js';
7
6
  import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
8
7
  import { unwrapResult } from '../shared/unwrapResult.js';
9
8
 
10
- /**
11
- * Mutation variables for {@link useMigratebnUSD}. Generic over `K extends SpokeChainKey` (defaults
12
- * to the full union). Bidirectional — handles both legacy → new and new → legacy bnUSD migration
13
- * via the same SDK call; the SDK detects direction from the token addresses.
14
- */
9
+ /** Bidirectional: the SDK detects legacy ↔ new direction from the token addresses. */
15
10
  export type UseMigratebnUSDVars<K extends SpokeChainKey = SpokeChainKey> = Omit<
16
11
  UnifiedBnUSDMigrateAction<K, false>,
17
12
  'raw'
18
13
  >;
19
14
 
20
- /**
21
- * React hook for migrating bnUSD between legacy and new formats across spoke chains via Sonic.
22
- *
23
- * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
24
- * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.
25
- */
26
15
  export function useMigratebnUSD<K extends SpokeChainKey = SpokeChainKey>({
27
16
  mutationOptions,
28
17
  }: MutationHookParams<TxHashPair, UseMigratebnUSDVars<K>> = {}): SafeUseMutationResult<
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/migrate/useMigrationAllowance.ts
2
1
  import type {
3
2
  BalnMigrateParams,
4
3
  IcxCreateRevertMigrationParams,
@@ -11,15 +10,7 @@ import { useQuery, type UseQueryResult } from '@tanstack/react-query';
11
10
  import { useSodaxContext } from '../shared/useSodaxContext.js';
12
11
  import type { ReadHookParams } from '../shared/types.js';
13
12
 
14
- /**
15
- * Domain inputs for {@link useMigrationAllowance}. `params` is the underlying migration params
16
- * (NOT the action wrapper — no `walletProvider`/`raw`); `action` is the `'migrate' | 'revert'`
17
- * discriminator the SDK uses to pick the right allowance check path.
18
- *
19
- * For ICX forward migration (`migrate`, params={IcxMigrateParams}) and BALN migration the SDK
20
- * always returns `true` (Icon has no ERC-20-style allowance) — but the hook still works there
21
- * for code-uniformity at the call site.
22
- */
13
+ /** `params` excludes `walletProvider`/`raw`; ICX forward and BALN always resolve `true` (Icon has no allowance). */
23
14
  export type UseMigrationAllowanceInputs<K extends SpokeChainKey = SpokeChainKey> = {
24
15
  params:
25
16
  | IcxMigrateParams
@@ -37,13 +28,7 @@ export type UseMigrationAllowanceParams<K extends SpokeChainKey = SpokeChainKey>
37
28
 
38
29
  const REFETCH_INTERVAL_MS = 2_000;
39
30
 
40
- /**
41
- * React hook to check if migration spending is approved.
42
- *
43
- * Returns `false` when params are missing (so the call site can disable the action button).
44
- * Hook lifecycle (`enabled`, `queryKey`, `queryFn`) is owned internally; consumers can override
45
- * other React Query knobs via `queryOptions`.
46
- */
31
+ /** Resolves `false` when params are missing. */
47
32
  export function useMigrationAllowance<K extends SpokeChainKey = SpokeChainKey>({
48
33
  params,
49
34
  queryOptions,
@@ -53,8 +38,7 @@ export function useMigrationAllowance<K extends SpokeChainKey = SpokeChainKey>({
53
38
  const action = params?.action;
54
39
 
55
40
  return useQuery<boolean, Error>({
56
- // Extract the (chain, owner, token, amount) tuple that actually scopes the allowance —
57
- // raw-object keys break per Rule 4 (bigints) and churn on every render.
41
+ // Key on the scoping tuple: raw params hold bigints and churn every render.
58
42
  queryKey: [
59
43
  'migrate',
60
44
  'allowance',
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/migrate/useMigrationApprove.ts
2
1
  import type {
3
2
  IcxRevertMigrationAction,
4
3
  MigrationAction,
@@ -12,27 +11,12 @@ import type { MutationHookParams } from '../shared/types.js';
12
11
  import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
13
12
  import { unwrapResult } from '../shared/unwrapResult.js';
14
13
 
15
- /**
16
- * Mutation variables for {@link useMigrationApprove}. The SDK's `approve` accepts a union of
17
- * action wrappers (Icx-revert OR bnUSD bidirectional) plus a separate `'migrate' | 'revert'`
18
- * discriminator. Both ride along in `TVars` here so the hook stays a pure pass-through.
19
- */
20
14
  export type UseMigrationApproveVars<K extends SpokeChainKey = SpokeChainKey> = (
21
15
  | Omit<IcxRevertMigrationAction<false>, 'raw'>
22
16
  | Omit<UnifiedBnUSDMigrateAction<K, false>, 'raw'>
23
17
  ) & { action: MigrationAction };
24
18
 
25
- /**
26
- * React hook for approving token spending on a migration intent. Required before:
27
- * - SODA → ICX revert (consumes SODA on Sonic via the user's hub router)
28
- * - bnUSD migrations on EVM/Stellar source chains (consumes the source bnUSD via asset manager)
29
- *
30
- * NOT required for ICX → SODA forward migrations or BALN migrations (both originate on Icon
31
- * which doesn't use ERC-20 allowances).
32
- *
33
- * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
34
- * `onError`, `retry`). Returns the unwrapped tx return value on success.
35
- */
19
+ /** Required for SODA → ICX revert and EVM/Stellar bnUSD migrations; not for ICX → SODA or BALN (Icon). */
36
20
  export function useMigrationApprove<K extends SpokeChainKey = SpokeChainKey>({
37
21
  mutationOptions,
38
22
  }: MutationHookParams<TxReturnType<K, false>, UseMigrationApproveVars<K>> = {}): SafeUseMutationResult<
@@ -54,9 +38,7 @@ export function useMigrationApprove<K extends SpokeChainKey = SpokeChainKey>({
54
38
  ),
55
39
  ),
56
40
  onSuccess: async (data, vars, ctx) => {
57
- // Broad — wipes all migrate allowance variants. The mutation can't know exactly which
58
- // (action, params) tuple the consumer was reading, so refetch all and let the active
59
- // queries reconcile.
41
+ // Broad: the mutation can't know which (action, params) allowance the consumer reads.
60
42
  queryClient.invalidateQueries({ queryKey: ['migrate', 'allowance'] });
61
43
  await mutationOptions?.onSuccess?.(data, vars, ctx);
62
44
  },
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/migrate/useRevertMigrateSodaToIcx.ts
2
1
  import type { IcxRevertMigrationAction, TxHashPair } from '@sodax/sdk';
3
2
  import { ChainKeys } from '@sodax/sdk';
4
3
  import { useQueryClient } from '@tanstack/react-query';
@@ -10,12 +9,6 @@ import { unwrapResult } from '../shared/unwrapResult.js';
10
9
 
11
10
  export type UseRevertMigrateSodaToIcxVars = Omit<IcxRevertMigrationAction<false>, 'raw'>;
12
11
 
13
- /**
14
- * React hook for reverting SODA → ICX (the inverse of {@link useMigrateIcxToSoda}).
15
- *
16
- * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
17
- * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.
18
- */
19
12
  export function useRevertMigrateSodaToIcx({
20
13
  mutationOptions,
21
14
  }: MutationHookParams<TxHashPair, UseRevertMigrateSodaToIcxVars> = {}): SafeUseMutationResult<
@@ -14,12 +14,7 @@ export type UseATokenParams = ReadHookParams<
14
14
  }
15
15
  >;
16
16
 
17
- /**
18
- * React hook to fetch ERC-20 metadata for a given aToken address on the hub chain.
19
- * Returns `Erc20Token` (`name`, `symbol`, `decimals`, `address`) augmented with the hub
20
- * `chainKey`. Note: the returned shape is a subset of `XToken` — `hubAsset` and `vault` fields
21
- * must be resolved separately if needed.
22
- */
17
+ /** Returns ERC-20 metadata plus hub `chainKey` only; `hubAsset` and `vault` are not resolved. */
23
18
  export function useAToken({ params, queryOptions }: UseATokenParams = {}): UseQueryResult<ATokenData, Error> {
24
19
  const { sodax } = useSodaxContext();
25
20
  const aToken = params?.aToken;
@@ -14,11 +14,6 @@ export type UseATokensBalancesParams = ReadHookParams<
14
14
  }
15
15
  >;
16
16
 
17
- /**
18
- * React hook to fetch aToken balances for a list of addresses in a single multicall.
19
- * Derives the user's hub wallet via `EvmHubProvider.getUserHubWalletAddress` from the
20
- * spoke `chainKey` + spoke wallet `userAddress`.
21
- */
22
17
  export function useATokensBalances({
23
18
  params,
24
19
  queryOptions,
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/mm/useBorrow.ts
2
1
  import type { MoneyMarketBorrowActionParams, SpokeChainKey, OutboundSettlement } from '@sodax/sdk';
3
2
  import { useQueryClient } from '@tanstack/react-query';
4
3
  import { useSodaxContext } from '../shared/useSodaxContext.js';
@@ -8,23 +7,12 @@ import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMu
8
7
  import { unwrapResult } from '../shared/unwrapResult.js';
9
8
  import { retryBeforeSubmission } from '../shared/retryBeforeSubmission.js';
10
9
 
11
- /**
12
- * Mutation variables for {@link useBorrow}. Generic over `K extends SpokeChainKey` (defaults to
13
- * the full union). Sophisticated callers can lock K at the hook call site to narrow the
14
- * `walletProvider` and `params.srcChainKey` types.
15
- */
16
10
  export type UseBorrowVars<K extends SpokeChainKey = SpokeChainKey> = Omit<
17
11
  MoneyMarketBorrowActionParams<K, false>,
18
12
  'raw'
19
13
  >;
20
14
 
21
- /**
22
- * React hook for borrowing tokens from the Sodax money market protocol.
23
- *
24
- * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
25
- * `onError`, `retry`). Returns the unwrapped {@link OutboundSettlement} on success: a tx pair, or
26
- * from Tron the relay's `trackingId` beside the destination tx.
27
- */
15
+ /** Throws on SDK failure; resolves to an {@link OutboundSettlement} (tx pair, or Tron relay `trackingId` + dst tx). */
28
16
  export function useBorrow<K extends SpokeChainKey = SpokeChainKey>({
29
17
  mutationOptions,
30
18
  }: MutationHookParams<OutboundSettlement<K>, UseBorrowVars<K>> = {}): SafeUseMutationResult<
@@ -6,19 +6,8 @@ import type { ReadHookParams } from '../shared/types.js';
6
6
  export type UseEModesParams = ReadHookParams<EmodeDataHumanized[]>;
7
7
 
8
8
  /**
9
- * Reads the pool's configured eMode categories — LTV, liquidation threshold and bonus in basis
10
- * points, plus the collateral/borrowable bitmaps and label.
11
- *
12
- * A category's LTV replaces the reserve's own when a user opts into it, so anything projecting
13
- * borrowing power for an eMode position must read it from here rather than from the reserve.
14
- * Categories only change by governance, so this is not polled.
15
- *
16
- * @example
17
- * ```typescript
18
- * const { data: categories } = useEModes();
19
- * const cat = categories?.find(c => Number(c.id) === selected);
20
- * const ltv = Number(cat?.eMode.ltv ?? 0) / 10_000;
21
- * ```
9
+ * A category's LTV replaces the reserve's own when a user opts in, so eMode borrow-power projections
10
+ * must read it from here. Categories change only by governance, so this is not polled.
22
11
  */
23
12
  export function useEModes({ queryOptions }: UseEModesParams = {}): UseQueryResult<EmodeDataHumanized[], Error> {
24
13
  const { sodax } = useSodaxContext();
@@ -0,0 +1,55 @@
1
+ import { afterEach, describe, expect, it, vi } from 'vitest';
2
+ import type { MoneyMarketParams, SpokeChainKey } from '@sodax/sdk';
3
+ import type { QueryObserverOptions } from '@tanstack/react-query';
4
+
5
+ // No renderer, per the package convention: capture the options bag and drive a real observer with it.
6
+ let captured: QueryObserverOptions<boolean, Error> | undefined;
7
+
8
+ const isAllowanceValid = vi.fn();
9
+ vi.mock('../shared/useSodaxContext.js', () => ({
10
+ useSodaxContext: () => ({ sodax: { moneyMarket: { isAllowanceValid } } }),
11
+ }));
12
+ vi.mock('@tanstack/react-query', async importOriginal => ({
13
+ ...(await importOriginal<typeof import('@tanstack/react-query')>()),
14
+ useQuery: (options: QueryObserverOptions<boolean, Error>) => {
15
+ captured = options;
16
+ return {};
17
+ },
18
+ }));
19
+
20
+ const { QueryClient, QueryObserver } = await import('@tanstack/react-query');
21
+ const { useMMAllowance } = await import('./useMMAllowance.js');
22
+
23
+ type Action = 'supply' | 'borrow' | 'withdraw' | 'repay';
24
+
25
+ const observe = (action: Action) => {
26
+ const fields = { srcChainKey: '0xa4b1.arbitrum', token: '0xtoken', action };
27
+ // The hook only reads these fields; a full MoneyMarketParams needs real chain/wallet config.
28
+ const payload = fields as unknown as MoneyMarketParams<SpokeChainKey>;
29
+ useMMAllowance({ params: { payload } });
30
+ if (!captured) throw new Error('useQuery was not called');
31
+ const client = new QueryClient();
32
+ return { client, result: new QueryObserver(client, captured).getCurrentResult() };
33
+ };
34
+
35
+ afterEach(() => {
36
+ captured = undefined;
37
+ isAllowanceValid.mockReset();
38
+ });
39
+
40
+ describe('useMMAllowance', () => {
41
+ it.each<Action>(['borrow', 'withdraw'])('reports %s as approved without querying the SDK', action => {
42
+ const { client, result } = observe(action);
43
+ expect(result.data).toBe(true);
44
+ expect(result.isLoading).toBe(false);
45
+ expect(isAllowanceValid).not.toHaveBeenCalled();
46
+ client.clear();
47
+ });
48
+
49
+ it.each<Action>(['supply', 'repay'])('leaves %s pending until the SDK answers', action => {
50
+ const { client, result } = observe(action);
51
+ expect(result.data).toBeUndefined();
52
+ expect(captured?.enabled).toBe(true);
53
+ client.clear();
54
+ });
55
+ });
@@ -12,19 +12,8 @@ export type UseMMAllowanceParams<K extends SpokeChainKey> = ReadHookParams<
12
12
  >;
13
13
 
14
14
  /**
15
- * Hook for checking token allowance / trustline sufficiency for money market operations.
16
- *
17
- * Skips the on-chain check entirely for `borrow` and `withdraw` actions — those don't require
18
- * approval, and the SDK already short-circuits to `true` for them. The early `enabled: false`
19
- * here additionally avoids a render flash with `isLoading: true`.
20
- *
21
- * The query key matches the invalidation keys emitted by `useMMApprove` and the four mutation
22
- * hooks: `['mm', 'allowance', srcChainKey, token, action]`.
23
- *
24
- * @example
25
- * ```tsx
26
- * const { data: hasAllowance } = useMMAllowance({ params: { payload: supplyParams } });
27
- * ```
15
+ * `borrow`/`withdraw` need no approval: the query stays disabled and `data` is seeded with `true`. Query key must
16
+ * match the `['mm', 'allowance', srcChainKey, token, action]` invalidations from `useMMApprove` and mutations.
28
17
  */
29
18
  export function useMMAllowance<K extends SpokeChainKey>({
30
19
  params,
@@ -32,6 +21,7 @@ export function useMMAllowance<K extends SpokeChainKey>({
32
21
  }: UseMMAllowanceParams<K> = {}): UseQueryResult<boolean, Error> {
33
22
  const { sodax } = useSodaxContext();
34
23
  const payload = params?.payload;
24
+ const needsApproval = payload?.action !== 'borrow' && payload?.action !== 'withdraw';
35
25
 
36
26
  return useQuery<boolean, Error>({
37
27
  queryKey: ['mm', 'allowance', payload?.srcChainKey, payload?.token, payload?.action],
@@ -40,8 +30,7 @@ export function useMMAllowance<K extends SpokeChainKey>({
40
30
  throw new Error('Params are required');
41
31
  }
42
32
 
43
- // Borrow and withdraw don't require approval; SDK returns true instantly anyway.
44
- if (payload.action === 'borrow' || payload.action === 'withdraw') {
33
+ if (!needsApproval) {
45
34
  return true;
46
35
  }
47
36
 
@@ -49,7 +38,8 @@ export function useMMAllowance<K extends SpokeChainKey>({
49
38
  if (!result.ok) throw result.error;
50
39
  return result.value;
51
40
  },
52
- enabled: !!payload && payload.action !== 'borrow' && payload.action !== 'withdraw',
41
+ initialData: () => (payload && !needsApproval ? true : undefined),
42
+ enabled: !!payload && needsApproval,
53
43
  refetchInterval: 5000,
54
44
  gcTime: 0,
55
45
  ...queryOptions,
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/mm/useMMApprove.ts
2
1
  import type { MoneyMarketApproveActionParams, SpokeChainKey, TxReturnType } from '@sodax/sdk';
3
2
  import { useQueryClient } from '@tanstack/react-query';
4
3
  import { useSodaxContext } from '../shared/useSodaxContext.js';
@@ -6,24 +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 useMMApprove}. 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 UseMMApproveVars<K extends SpokeChainKey = SpokeChainKey> = Omit<
15
9
  MoneyMarketApproveActionParams<K, false>,
16
10
  'raw'
17
11
  >;
18
12
 
19
- /**
20
- * React hook for approving ERC-20 token spending (or trustline establishment) for a Sodax money
21
- * market action.
22
- *
23
- * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
24
- * `onError`, `retry`). Returns the unwrapped tx return value on success. Invalidates the matching
25
- * `['mm', 'allowance', srcChainKey, token, action]` query on confirmed success.
26
- */
13
+ /** Throws on SDK failure; invalidates the matching `['mm', 'allowance', ...]` query on success. */
27
14
  export function useMMApprove<K extends SpokeChainKey = SpokeChainKey>({
28
15
  mutationOptions,
29
16
  }: MutationHookParams<TxReturnType<K, false>, UseMMApproveVars<K>> = {}): SafeUseMutationResult<
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/mm/useRepay.ts
2
1
  import type { MoneyMarketRepayActionParams, SpokeChainKey, TxHashPair } from '@sodax/sdk';
3
2
  import { useQueryClient } from '@tanstack/react-query';
4
3
  import { useSodaxContext } from '../shared/useSodaxContext.js';
@@ -8,19 +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 useRepay}. Generic over `K extends SpokeChainKey` (defaults to
13
- * the full union). Sophisticated callers can lock K at the hook call site to narrow the
14
- * `walletProvider` and `params.srcChainKey` types.
15
- */
16
10
  export type UseRepayVars<K extends SpokeChainKey = SpokeChainKey> = Omit<MoneyMarketRepayActionParams<K, false>, 'raw'>;
17
11
 
18
- /**
19
- * React hook for repaying a borrow in the Sodax money market protocol.
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
- */
12
+ /** Throws on SDK failure (React Query error state); resolves to the unwrapped `TxHashPair`. */
24
13
  export function useRepay<K extends SpokeChainKey = SpokeChainKey>({
25
14
  mutationOptions,
26
15
  }: MutationHookParams<TxHashPair, UseRepayVars<K>> = {}): SafeUseMutationResult<TxHashPair, Error, UseRepayVars<K>> {
@@ -5,10 +5,6 @@ import type { ReadHookParams } from '../shared/types.js';
5
5
 
6
6
  export type UseReservesDataParams = ReadHookParams<readonly [readonly AggregatedReserveData[], BaseCurrencyInfo]>;
7
7
 
8
- /**
9
- * React hook for fetching the latest aggregated reserves data and base-currency info from the
10
- * Sodax money market.
11
- */
12
8
  export function useReservesData({
13
9
  queryOptions,
14
10
  }: UseReservesDataParams = {}): UseQueryResult<readonly [readonly AggregatedReserveData[], BaseCurrencyInfo], Error> {