@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
@@ -20,10 +20,6 @@ export type UsePoolBalancesParams = ReadHookParams<
20
20
  }
21
21
  >;
22
22
 
23
- /**
24
- * React hook to query the user's hub-side deposit balances for both pool tokens. Derives the hub
25
- * wallet once and reads both pool-token balances in parallel via the hub `publicClient`.
26
- */
27
23
  export function usePoolBalances({
28
24
  params,
29
25
  queryOptions,
@@ -5,10 +5,7 @@ import type { ReadHookParams } from '../shared/types.js';
5
5
 
6
6
  export type UsePoolDataParams = ReadHookParams<PoolData, { poolKey: PoolKey | null }>;
7
7
 
8
- /**
9
- * React hook to fetch on-chain pool data (sqrt price, tick, fees, token info, etc.) for a given
10
- * pool key. Reads via the hub `publicClient`. Disabled when `poolKey` is null.
11
- */
8
+ /** Disabled when `poolKey` is null. */
12
9
  export function usePoolData({ params, queryOptions }: UsePoolDataParams = {}): UseQueryResult<PoolData, Error> {
13
10
  const { sodax } = useSodaxContext();
14
11
  const poolKey = params?.poolKey ?? null;
@@ -5,10 +5,7 @@ import type { ReadHookParams } from '../shared/types.js';
5
5
 
6
6
  export type UsePoolsParams = ReadHookParams<PoolKey[]>;
7
7
 
8
- /**
9
- * Loads the list of concentrated-liquidity pools known to the SDK config. The SDK's `getPools()`
10
- * is synchronous in v2 (no network), so this hook caches indefinitely by default.
11
- */
8
+ /** `getPools()` is synchronous (no network), so the result is cached indefinitely. */
12
9
  export function usePools({ queryOptions }: UsePoolsParams = {}): UseQueryResult<PoolKey[], Error> {
13
10
  const { sodax } = useSodaxContext();
14
11
 
@@ -16,10 +16,7 @@ export type UsePositionInfoParams = ReadHookParams<
16
16
  }
17
17
  >;
18
18
 
19
- /**
20
- * React hook to fetch a CL position by NFT token id and validate it against an expected pool key.
21
- * Reads via the hub `publicClient`. Disabled when `tokenId` or `poolKey` is missing.
22
- */
19
+ /** Validates the position against the expected pool key; disabled when `tokenId` or `poolKey` is missing. */
23
20
  export function usePositionInfo({
24
21
  params,
25
22
  queryOptions,
@@ -1,4 +1,3 @@
1
- // packages/dapp-kit/src/hooks/dex/useSupplyLiquidity.ts
2
1
  import type {
3
2
  ClIncreaseLiquidityParams,
4
3
  ClSupplyParams,
@@ -14,12 +13,6 @@ import type { MutationHookParams } from '../shared/types.js';
14
13
  import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
15
14
  import { unwrapResult } from '../shared/unwrapResult.js';
16
15
 
17
- /**
18
- * Mutation variables for {@link useSupplyLiquidity}. Generic over `K extends SpokeChainKey`
19
- * (defaults to the full union). The hook fans out internally to either
20
- * `clService.increaseLiquidity` (when `params.tokenId` + `params.isValidPosition` are present) or
21
- * `clService.supplyLiquidity` (mint a new position).
22
- */
23
16
  export type UseSupplyLiquidityVars<K extends SpokeChainKey = SpokeChainKey> = {
24
17
  params: UseCreateSupplyLiquidityParamsResult & { srcChainKey: K; srcAddress: string };
25
18
  walletProvider: GetWalletProviderType<K>;
@@ -27,14 +20,7 @@ export type UseSupplyLiquidityVars<K extends SpokeChainKey = SpokeChainKey> = {
27
20
  timeout?: number;
28
21
  };
29
22
 
30
- /**
31
- * React hook for supplying liquidity to a concentrated-liquidity pool. If the input vars include a
32
- * valid `tokenId` for an existing position, the hook calls `increaseLiquidity`; otherwise it mints
33
- * a new position via `supplyLiquidity`.
34
- *
35
- * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
36
- * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.
37
- */
23
+ /** Calls `increaseLiquidity` when vars carry a valid `tokenId`, else mints via `supplyLiquidity`. Throws on SDK failure. */
38
24
  export function useSupplyLiquidity<K extends SpokeChainKey = SpokeChainKey>({
39
25
  mutationOptions,
40
26
  }: MutationHookParams<TxHashPair, UseSupplyLiquidityVars<K>> = {}): SafeUseMutationResult<
@@ -77,12 +63,9 @@ export function useSupplyLiquidity<K extends SpokeChainKey = SpokeChainKey>({
77
63
  },
78
64
  onSuccess: async (data, vars, ctx) => {
79
65
  const { params } = vars;
80
- // Increase-liquidity branch knows the affected position — scope to it. Mint-new-position
81
- // branch creates a fresh tokenId that's only known after the tx, so a bare invalidation is
82
- // the right fallback (refetches all positions, including the new one once it lands).
66
+ // Mint-new has no tokenId until the tx lands, so it falls back to invalidating all positions.
83
67
  if (params.tokenId !== undefined && params.isValidPosition) {
84
- // `usePositionInfo` keys by string tokenId — coerce here to match its shape regardless of
85
- // whether the caller passed bigint or string.
68
+ // `usePositionInfo` keys by string tokenId; caller may pass bigint or string.
86
69
  const tokenIdStr = String(params.tokenId);
87
70
  queryClient.invalidateQueries({ queryKey: ['dex', 'positionInfo', tokenIdStr, params.poolKey] });
88
71
  } else {
@@ -5,7 +5,6 @@ import type { MutationHookParams } from '../shared/types.js';
5
5
  import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
6
6
  import { unwrapResult } from '../shared/unwrapResult.js';
7
7
 
8
- /** Mutation variables for {@link useApproveLeveragePositionFunding}. */
9
8
  export type UseApproveLeveragePositionFundingVars<K extends SpokeChainKey = SpokeChainKey> = {
10
9
  srcChainKey: K;
11
10
  srcAddress: string;
@@ -16,13 +15,8 @@ export type UseApproveLeveragePositionFundingVars<K extends SpokeChainKey = Spok
16
15
  };
17
16
 
18
17
  /**
19
- * Approves the funding token for an open, against the spender the SDK resolves.
20
- *
21
- * THE SPENDER IS CHAIN-DEPENDENT — the hub wallet on the hub, the spoke asset manager elsewhere.
22
- * Nothing is ever approved to the position factory: it pulls from nobody.
23
- *
24
- * Wait for this before opening, and gate it on {@link useLeveragePositionFundingAllowance}, whose
25
- * query is invalidated here on success.
18
+ * Approves the funding token for an open; the spender is chain-dependent (hub wallet on hub, spoke asset manager elsewhere).
19
+ * Await before opening; invalidates {@link useLeveragePositionFundingAllowance} on success.
26
20
  */
27
21
  export function useApproveLeveragePositionFunding<K extends SpokeChainKey = SpokeChainKey>({
28
22
  mutationOptions,
@@ -9,19 +9,8 @@ export type UseLeveragePositionAccountParams = ReadHookParams<
9
9
  >;
10
10
 
11
11
  /**
12
- * Reads the live AAVE account snapshot for a leverage position — collateral, debt, LTV and
13
- * health factor.
14
- *
15
- * The figures come from the pool's `getUserAccountData`, not from the position contract,
16
- * which keeps no accounting of its own. Health factor is WAD (1e18); below 1e18 the position
17
- * is liquidatable, and there is no keeper deleveraging on the owner's behalf, so this is the
18
- * number a UI should surface most prominently. Debt accrues continuously, hence the 30s
19
- * default refresh.
20
- *
21
- * @example
22
- * ```typescript
23
- * const { data: account } = useLeveragePositionAccount({ params: { position } });
24
- * ```
12
+ * Live AAVE account snapshot (pool `getUserAccountData`). Health factor is WAD; below 1e18 the position
13
+ * is liquidatable with no keeper to deleverage it. Polled every 30s since debt accrues continuously.
25
14
  */
26
15
  export function useLeveragePositionAccount({
27
16
  params,
@@ -9,19 +9,8 @@ export type UseLeveragePositionCollateralParams = ReadHookParams<
9
9
  >;
10
10
 
11
11
  /**
12
- * Reads a leverage position's collateral as an exact aToken balance.
13
- *
14
- * Use this, not `useLeveragePositionAccount().totalCollateralBase`, whenever an amount is going into
15
- * a transaction. The account snapshot is denominated in the oracle's base currency at 8 decimals, so
16
- * dividing it back out by a price gives an amount near the balance rather than the balance — and a
17
- * decrease-leverage call for more collateral than the position holds expires as an unfillable intent
18
- * instead of failing up front.
19
- *
20
- * @example
21
- * ```typescript
22
- * const { data: collateral } = useLeveragePositionCollateral({ params: { position } });
23
- * // collateral.balance is what a full exit sells
24
- * ```
12
+ * Exact aToken collateral balance; use this (not the account snapshot's oracle-priced total) for transaction
13
+ * amounts, since over-asking on decrease-leverage expires as an unfillable intent instead of failing up front.
25
14
  */
26
15
  export function useLeveragePositionCollateral({
27
16
  params,
@@ -40,7 +29,6 @@ export function useLeveragePositionCollateral({
40
29
  return result.value;
41
30
  },
42
31
  enabled: !!position,
43
- // Interest accrues into the balance continuously, so match the account snapshot's cadence.
44
32
  refetchInterval: 30_000,
45
33
  ...queryOptions,
46
34
  });
@@ -3,12 +3,10 @@ import type { SpokeChainKey } from '@sodax/sdk';
3
3
  import { useSodaxContext } from '../shared/useSodaxContext.js';
4
4
  import type { ReadHookParams } from '../shared/types.js';
5
5
 
6
- /** Params for {@link useLeveragePositionFundingAllowance}. */
7
6
  export type UseLeveragePositionFundingAllowanceParams = ReadHookParams<
8
7
  boolean,
9
8
  {
10
9
  srcChainKey: SpokeChainKey;
11
- /** The user's address on `srcChainKey`. */
12
10
  srcAddress: string | undefined;
13
11
  /** Funding token, from `resolvePositionFunding` — not the reserve and not the vault. */
14
12
  token: string | undefined;
@@ -17,13 +15,8 @@ export type UseLeveragePositionFundingAllowanceParams = ReadHookParams<
17
15
  >;
18
16
 
19
17
  /**
20
- * Whether the funding token is already approved for an open from `srcChainKey`.
21
- *
22
- * THE SPENDER IS CHAIN-DEPENDENT — the hub wallet on the hub, the spoke asset manager elsewhere —
23
- * so a hand-rolled `allowance` call against a guessed spender is right half the time. The SDK
24
- * resolves it; this only supplies React Query.
25
- *
26
- * Returns the SDK's answer as data. A chain with no allowance concept answers `true` without a call.
18
+ * Whether the funding token is approved for an open; the SDK resolves the chain-dependent spender.
19
+ * Chains with no allowance concept answer `true`.
27
20
  */
28
21
  export function useLeveragePositionFundingAllowance({
29
22
  params,
@@ -5,19 +5,7 @@ import type { ReadHookParams } from '../shared/types.js';
5
5
 
6
6
  export type UseLeveragePositionInfoParams = ReadHookParams<LeveragePosition, { position: Address | undefined }>;
7
7
 
8
- /**
9
- * Reads a leverage position's static descriptor — owner, collateral, borrow token, and the
10
- * eMode category it was created with.
11
- *
12
- * All four are fixed at creation, so this never goes stale for a given position and is left
13
- * on the default cache behaviour rather than polled. Pair it with
14
- * `useLeveragePositionAccount` for the values that do move.
15
- *
16
- * @example
17
- * ```typescript
18
- * const { data: info } = useLeveragePositionInfo({ params: { position } });
19
- * ```
20
- */
8
+ /** A position's static descriptor (fixed at creation, so not polled); see `useLeveragePositionAccount` for live values. */
21
9
  export function useLeveragePositionInfo({
22
10
  params,
23
11
  queryOptions,
@@ -1,29 +1,17 @@
1
1
  import type { Address, SpokeChainKey } from '@sodax/sdk';
2
2
  import { useSodaxContext } from '../shared/useSodaxContext.js';
3
3
 
4
- /** Params for {@link useLeveragePositionPayoutAddress}. */
5
4
  export type UseLeveragePositionPayoutAddressParams = {
6
- /** The chain the user signs on. */
7
5
  chainKey: SpokeChainKey;
8
- /**
9
- * Their address on that chain. Supplied by the caller — this package does not depend on a wallet
10
- * layer, so it cannot read the connected account itself.
11
- */
6
+ /** Supplied by the caller: this package has no wallet layer to read the connected account. */
12
7
  signerAddress: Address | undefined;
13
8
  /** The position's owner, from `useGetUserHubWalletAddress`. */
14
9
  owner: Address | undefined;
15
10
  };
16
11
 
17
12
  /**
18
- * Where funds leaving a position can actually be paid.
19
- *
20
- * `withdraw` is a plain pool withdrawal, so it pays out to an address ON THE HUB. For a hub-chain
21
- * user that can be their own address; for anyone else it cannot — their signing address belongs to
22
- * another chain, and for a non-EVM chain it is not an address the hub could pay at all. The hub
23
- * wallet is the one destination that is always theirs, and bridging onward is a separate operation.
24
- *
25
- * Returns `undefined` while either address is still resolving, which is the disabled state for a
26
- * withdraw button rather than a reason to fall back to the signer.
13
+ * Hub address a position withdrawal can pay to: the signer on the hub chain, else the hub wallet (owner).
14
+ * `undefined` while resolving means disable withdraw — do not fall back to the signer.
27
15
  */
28
16
  export function useLeveragePositionPayoutAddress({
29
17
  params,
@@ -9,22 +9,8 @@ export type UseLeveragePositionPendingParams = ReadHookParams<
9
9
  >;
10
10
 
11
11
  /**
12
- * A position's operation slot: what it recorded, whether that intent is still live, and whether it
13
- * is stuck resolved-but-unswept.
14
- *
15
- * Gate leverage controls on `isLive` — a position permits one intent at a time, so offering a button
16
- * that can only revert is worse than disabling it. Offer a settle on `needsSettle`: that is the state
17
- * where the intent is gone but the position still holds the grant and any contribution, and it is
18
- * invisible from `isLive` alone.
19
- *
20
- * Polled, because both change without the user acting: a solver fills, or the intent expires. The
21
- * interval sits well inside the 5-minute intent deadline so a resolution shows up while it matters.
22
- *
23
- * @example
24
- * ```typescript
25
- * const { data: slot } = useLeveragePositionPending({ params: { position } });
26
- * if (slot?.needsSettle) offerSettle();
27
- * ```
12
+ * A position's operation slot. Gate controls on `isLive` (one intent at a time); offer settle on `needsSettle`.
13
+ * Polled well inside the 5-minute intent deadline since fills/expiry happen without user action.
28
14
  */
29
15
  export function useLeveragePositionPending({
30
16
  params,
@@ -5,21 +5,7 @@ import type { ReadHookParams } from '../shared/types.js';
5
5
 
6
6
  export type UseLeveragePositionsParams = ReadHookParams<readonly Address[], { owner: Address | undefined }>;
7
7
 
8
- /**
9
- * Lists the leverage-position clones owned by `owner`, in creation order.
10
- *
11
- * Positions are the unpooled counterpart to leverage-yield vaults: each is its own AAVE
12
- * account, so one owner can hold several at different eMode categories and leverage tiers.
13
- * There is no static registry — discovery goes through the factory.
14
- *
15
- * Requires `leverageYield.positionFactory` in the `Sodax` config; without it the underlying
16
- * SDK call fails with a lookup error rather than guessing an address.
17
- *
18
- * @example
19
- * ```typescript
20
- * const { data: positions } = useLeveragePositions({ params: { owner } });
21
- * ```
22
- */
8
+ /** Position clones owned by a hub `owner`, in creation order. Requires `leverageYield.positionFactory` in the Sodax config. */
23
9
  export function useLeveragePositions({
24
10
  params,
25
11
  queryOptions,
@@ -8,21 +8,7 @@ export type UseLeveragePositionsForUserParams = ReadHookParams<
8
8
  { spokeChainKey: SpokeChainKey | undefined; spokeAddress: string | undefined }
9
9
  >;
10
10
 
11
- /**
12
- * Lists a user's leverage positions from their spoke-side address and chain.
13
- *
14
- * Positions are owned by the user's hub wallet, not their EOA, so discovery resolves that address
15
- * first — the wallet router for a Sonic user, the cross-chain wallet for a spoke user, via one
16
- * call. Use this in user-facing code; {@link useLeveragePositions} takes a hub address directly
17
- * and will find nothing if handed an EOA.
18
- *
19
- * @example
20
- * ```typescript
21
- * const { data: positions } = useLeveragePositionsForUser({
22
- * params: { spokeChainKey: chain, spokeAddress: account.address },
23
- * });
24
- * ```
25
- */
11
+ /** Resolves the user's hub wallet first, since positions are owned by it; {@link useLeveragePositions} finds nothing for an EOA. */
26
12
  export function useLeveragePositionsForUser({
27
13
  params,
28
14
  queryOptions,
@@ -7,7 +7,6 @@ import { unwrapResult } from '../shared/unwrapResult.js';
7
7
  export type UseLeverageYieldApprovalStrategyParams<K extends SpokeChainKey = SpokeChainKey> = ReadHookParams<
8
8
  ApprovalStrategy,
9
9
  {
10
- /** The payload `useLeverageYieldDeposit` / `useLeverageYieldWithdraw` built. */
11
10
  payload: LeverageYieldSwapPayload | undefined;
12
11
  walletProvider: GetWalletProviderType<K> | undefined;
13
12
  /** `false` keeps a wallet that would first ask to upgrade the account (EIP-5792 `'ready'`) off the batch path. Defaults to `true`. */
@@ -16,11 +15,7 @@ export type UseLeverageYieldApprovalStrategyParams<K extends SpokeChainKey = Spo
16
15
  >;
17
16
 
18
17
  /**
19
- * Which approval path {@link useLeverageYieldVaultSwapWithApproval} would take: `'not-required'`
20
- * (always for a withdraw), `'atomic-batch'` (approve + deposit in one EIP-5792 signature) or
21
- * `'sequential'` (approve, then deposit). Use it to label the deposit button. Pass the same
22
- * `allowAccountUpgrade` you give the vault swap.
23
- *
18
+ * Which approval path {@link useLeverageYieldVaultSwapWithApproval} would take; pass it the same `allowAccountUpgrade`.
24
19
  * Not polled: the vault swap invalidates it on success and re-reads the strategy at execution.
25
20
  */
26
21
  export function useLeverageYieldApprovalStrategy<K extends SpokeChainKey = SpokeChainKey>({
@@ -4,25 +4,9 @@ import type { MutationHookParams } from '../shared/types.js';
4
4
  import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
5
5
  import { unwrapResult } from '../shared/unwrapResult.js';
6
6
 
7
- /** Mutation variables for {@link useLeverageYieldDeposit} — the swap-style deposit inputs. */
8
7
  export type UseLeverageYieldDepositVars = LeverageYieldSwapDepositParams;
9
8
 
10
- /**
11
- * Builds the `LeverageYieldSwapPayload` for a leverage-yield deposit (any token → `lsoda*` shares,
12
- * delivered to the user's hub wallet). Spread the returned payload into
13
- * {@link useLeverageYieldVaultSwap}.
14
- *
15
- * This is a builder, not an executor — it derives the hub wallet and assembles the intent; the
16
- * actual swap is relayed by `useLeverageYieldVaultSwap`. Throws on SDK failure so React Query's
17
- * error model engages; returns the unwrapped `LeverageYieldSwapPayload` on success.
18
- *
19
- * @example
20
- * ```typescript
21
- * const { mutateAsyncSafe: buildDeposit } = useLeverageYieldDeposit();
22
- * const built = await buildDeposit({ vault, srcChainKey, srcAddress, inputToken, inputAmount, minOutputAmount });
23
- * if (built.ok) vaultSwap({ ...built.value, walletProvider });
24
- * ```
25
- */
9
+ /** Builds (does not execute) a deposit payload; spread it into {@link useLeverageYieldVaultSwap}. */
26
10
  export function useLeverageYieldDeposit({
27
11
  mutationOptions,
28
12
  }: MutationHookParams<LeverageYieldSwapPayload, UseLeverageYieldDepositVars> = {}): SafeUseMutationResult<
@@ -2,14 +2,7 @@ import { describe, expect, it, vi } from 'vitest';
2
2
  import { SodaxError, SolverIntentStatusCode } from '@sodax/sdk';
3
3
  import { MAX_NOT_FOUND_POLLS, STATUS_POLL_MS } from '../shared/notFoundStreak.js';
4
4
 
5
- /**
6
- * Pins the WIRING the pure-policy test cannot see: the hook must pass the read into the policy and
7
- * advance the budget once per query update. Feeding the policy the wrong argument reproduces a poll
8
- * that never stops, with the policy's own tests still green.
9
- *
10
- * No renderer, per the package convention (see `_apiKeyWire.test.ts`): the React Query wrapper is
11
- * mocked so the captured options bag can be driven directly.
12
- */
5
+ // Pins hook-to-policy wiring the pure-policy test cannot see; React Query is mocked to drive the options bag directly.
13
6
 
14
7
  // The captured options bag is opaque, like the real wrapper's.
15
8
  let captured: any;
@@ -17,8 +10,7 @@ let captured: any;
17
10
  const refSlots: Array<{ current: unknown }> = [];
18
11
  let refCursor = 0;
19
12
 
20
- // Only useRef is needed, and call order is stable, so this replays React's slot semantics well
21
- // enough to observe the budget across refetchInterval calls.
13
+ // Replays React's useRef slot semantics (stable call order) to observe the budget across calls.
22
14
  vi.mock('react', () => ({
23
15
  useRef: (initial: unknown) => {
24
16
  const slot = refSlots[refCursor] ?? { current: initial };
@@ -93,9 +85,7 @@ describe('useLeverageYieldDetailedStatus wiring', () => {
93
85
  it('stops outright on a rejected API key, without spending the budget', () => {
94
86
  refSlots.length = 0;
95
87
  render();
96
- // A real SodaxError, not a shaped literal: `isAuthFailure` goes through `isSodaxError`, which
97
- // checks the instance. The SDK returns 401/403 as a Result, so React Query never sees an error
98
- // to withhold a retry from — the policy is the only thing that can stop this poll.
88
+ // Must be a real SodaxError: `isAuthFailure` checks the instance via `isSodaxError`.
99
89
  const rejected = {
100
90
  ok: false,
101
91
  error: new SodaxError('LOOKUP_FAILED', 'rejected', { feature: 'leverageYield', context: { status: 401 } }),
@@ -122,7 +112,6 @@ describe('useLeverageYieldDetailedStatus wiring', () => {
122
112
  for (let update = 1; update <= MAX_NOT_FOUND_POLLS - 1; update++) {
123
113
  captured.refetchInterval({ state: { data: notFound, dataUpdateCount: update } });
124
114
  }
125
- // One real answer in between clears the streak, so the next miss starts from zero.
126
115
  captured.refetchInterval({
127
116
  state: { data: solverRead(SolverIntentStatusCode.NOT_STARTED_YET), dataUpdateCount: 40 },
128
117
  });
@@ -30,25 +30,8 @@ export type UseLeverageYieldDetailedStatusParams = ReadHookParams<
30
30
  >;
31
31
 
32
32
  /**
33
- * Hook for monitoring a leverage-yield vault swap from its source-chain transaction.
34
- *
35
- * `useLeverageYieldApiSubmitTxStatus` needs the backend to still hold a usable record; this takes
36
- * `(srcChainKey, srcTxHash)` — the pair you hold after `vaultSwap()` — and routes to whichever
37
- * source can answer, so it also covers a vault swap the client-side fallback completed. `data.value`
38
- * is discriminated on `source`, and each variant carries that source's payload unmodified.
39
- *
40
- * Polls every 3s. Stops once the answering source is terminal, once the backend rejects the API
41
- * key, and — like `useDetailedStatus` — after 40 consecutive *ambiguous* reads: a solver
42
- * `NOT_FOUND`, or a `LOOKUP_FAILED` whose relay has no packet for the tx. Neither can distinguish "still in flight" from "never will be", so the
43
- * budget is what stops a vault swap nothing can resolve. A dependency outage — relay unreachable,
44
- * solver down — keeps polling instead, so the read recovers by itself; any real status resets the
45
- * budget. Override with `queryOptions.refetchInterval`.
46
- *
47
- * @example
48
- * ```typescript
49
- * const { data } = useLeverageYieldDetailedStatus({ params: { srcChainKey, srcTxHash } });
50
- * if (data?.ok && data.value.source === 'backend') console.log(data.value.data.status);
51
- * ```
33
+ * Vault-swap status from `(srcChainKey, srcTxHash)`, routed to whichever source can answer. Polls until terminal,
34
+ * auth rejection, or 40 consecutive ambiguous reads (solver NOT_FOUND / relay not delivered); outages keep polling.
52
35
  */
53
36
  export const useLeverageYieldDetailedStatus = ({
54
37
  params,
@@ -8,18 +8,7 @@ export type UseLeverageYieldEffectiveAprParams = ReadHookParams<
8
8
  { vault: Address | undefined }
9
9
  >;
10
10
 
11
- /**
12
- * Reads a leverage-yield vault's effective APR — AAVE supply/borrow rates plus the LSD
13
- * staking yield, with the vault's leverage formula re-applied on the boosted supply side.
14
- *
15
- * The underlying SDK call does the on-chain reads (AAVE rates + `targetLTV`) and the
16
- * off-chain LSD fetch in parallel. Rates drift slowly, so the default refresh is 60s.
17
- *
18
- * @example
19
- * ```typescript
20
- * const { data: apr } = useLeverageYieldEffectiveApr({ params: { vault: vault.vault } });
21
- * ```
22
- */
11
+ /** Vault APR: AAVE supply/borrow rates plus LSD staking yield, with the vault's leverage applied. */
23
12
  export function useLeverageYieldEffectiveApr({
24
13
  params,
25
14
  queryOptions,
@@ -4,19 +4,9 @@ import type { MutationHookParams } from '../shared/types.js';
4
4
  import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
5
5
  import { unwrapResult } from '../shared/unwrapResult.js';
6
6
 
7
- /** Mutation variables for {@link useLeverageYieldNotifySolver} — the hub-side intent tx hash. */
8
7
  export type UseLeverageYieldNotifySolverVars = SolverExecutionRequest;
9
8
 
10
- /**
11
- * Notifies the solver that a leverage-yield vault intent landed on the hub, triggering the fill.
12
- * The standalone notify step for the manual create → relay → notify flow: build the intent with
13
- * `sodax.leverageYield.createVaultIntent`, relay it yourself, then call this with the hub-side
14
- * intent tx hash. The end-to-end {@link useLeverageYieldVaultSwap} already calls notifySolver
15
- * internally — only reach for this hook when driving the relay manually.
16
- *
17
- * Throws on SDK failure so React Query's error model engages; returns the unwrapped
18
- * `SolverExecutionResponse` (`{ answer: 'OK', intent_hash }`) on success.
19
- */
9
+ /** Manual-relay notify step with the hub-side intent tx hash; {@link useLeverageYieldVaultSwap} already does this. */
20
10
  export function useLeverageYieldNotifySolver({
21
11
  mutationOptions,
22
12
  }: MutationHookParams<SolverExecutionResponse, UseLeverageYieldNotifySolverVars> = {}): SafeUseMutationResult<
@@ -5,19 +5,7 @@ import type { ReadHookParams } from '../shared/types.js';
5
5
 
6
6
  export type UseLeverageYieldPositionParams = ReadHookParams<LeverageYieldPosition, { vault: Address | undefined }>;
7
7
 
8
- /**
9
- * Reads a leverage-yield vault's live position snapshot via the vault's `getPositionDetails`:
10
- * collateral, debt, current LTV (drift vs `targetLTV`), health factor (∞ when no debt), and
11
- * idle (not-yet-deployed) asset.
12
- *
13
- * LTV shifts with each rebalance/rate tick, so the default refresh (30s) is faster than the
14
- * APR/stats reads.
15
- *
16
- * @example
17
- * ```typescript
18
- * const { data: position } = useLeverageYieldPosition({ params: { vault: vault.vault } });
19
- * ```
20
- */
8
+ /** Vault position snapshot (`getPositionDetails`); health factor is ∞ when there is no debt. */
21
9
  export function useLeverageYieldPosition({
22
10
  params,
23
11
  queryOptions,
@@ -8,18 +8,7 @@ export type UseLeverageYieldPreviewRedeemParams = ReadHookParams<
8
8
  { vault: Address | undefined; shares: bigint | undefined }
9
9
  >;
10
10
 
11
- /**
12
- * Reads the assets received for redeeming `shares` of a leverage-yield vault (ERC-4626
13
- * `previewRedeem`). Passing `10n ** 18n` (one share) yields the per-share price that creeps
14
- * up as the vault accrues interest. Moves slowly, so the default refresh is 60s.
15
- *
16
- * @example
17
- * ```typescript
18
- * const { data: sharePrice } = useLeverageYieldPreviewRedeem({
19
- * params: { vault: vault.vault, shares: 10n ** 18n },
20
- * });
21
- * ```
22
- */
11
+ /** ERC-4626 `previewRedeem`; pass `10n ** 18n` (one share) for the per-share price. */
23
12
  export function useLeverageYieldPreviewRedeem({
24
13
  params,
25
14
  queryOptions,
@@ -22,7 +22,6 @@ const PAYLOAD: LeverageYieldQuoteParams = {
22
22
  quote_type: 'exact_input',
23
23
  };
24
24
 
25
- /** The SDK's own quote Result, derived so the doubles stay honest without an unsafe cast. */
26
25
  type QuoteResult = Awaited<ReturnType<Sodax['leverageYield']['getQuote']>>;
27
26
 
28
27
  const QUOTE: QuoteResult = { ok: true, value: { quoted_amount: 990_000n } };
@@ -63,8 +62,7 @@ describe('getLeverageYieldQuoteQueryOptions', () => {
63
62
  expect(getQuote).not.toHaveBeenCalled();
64
63
  });
65
64
 
66
- // React Query hashes keys with JSON.stringify, which throws on bigint. Both bigint sites
67
- // (`amount` and a fixed-amount `partnerFee`) must be stringified or every render crashes.
65
+ // React Query hashes keys with JSON.stringify, which throws on bigint.
68
66
  it('produces a hashable key for a percentage partner fee', () => {
69
67
  const partnerFee = { address: FEE_RECIPIENT, percentage: 100 } satisfies PartnerFee;
70
68
  const { sodax } = makeSodax();
@@ -87,7 +85,6 @@ describe('getLeverageYieldQuoteQueryOptions', () => {
87
85
  sodax,
88
86
  payload: { ...PAYLOAD, partnerFee: { address: FEE_RECIPIENT, percentage: 100 } },
89
87
  }).queryKey;
90
- // Sharing a cache entry would serve a quote priced on a different net input.
91
88
  expect(hashKey(base)).not.toBe(hashKey(withFee));
92
89
  });
93
90
 
@@ -97,9 +94,6 @@ describe('getLeverageYieldQuoteQueryOptions', () => {
97
94
  expect(hashKey(queryKey)).toContain('"amount":"1000000"');
98
95
  });
99
96
 
100
- // The configured fee is a real input to the quote whenever payload.partnerFee is omitted, so it
101
- // has to participate in the key — otherwise differently-configured providers share a cache entry
102
- // and a reconfigured provider serves the previous fee's quote.
103
97
  it('keys the configured leverageYield fee when the payload omits partnerFee', () => {
104
98
  const noFee = getLeverageYieldQuoteQueryOptions({ sodax: makeSodax().sodax, payload: PAYLOAD }).queryKey;
105
99
  const withConfigFee = getLeverageYieldQuoteQueryOptions({
@@ -130,9 +124,7 @@ describe('getLeverageYieldQuoteQueryOptions', () => {
130
124
  expect(hashKey(queryKey)).toContain('7000');
131
125
  });
132
126
 
133
- // Pins the allow-list. If `LeverageYieldQuoteParams` gains a field, this fails and forces a
134
- // decision about whether it belongs in the key — rather than a spread silently carrying a new
135
- // bigint in and crashing `hashKey` at render time.
127
+ // Fails when `LeverageYieldQuoteParams` gains a field, forcing a decision on whether it belongs in the key.
136
128
  it('keys exactly the known request fields', () => {
137
129
  const { sodax } = makeSodax();
138
130
  const { queryKey } = getLeverageYieldQuoteQueryOptions({ sodax, payload: PAYLOAD });
@@ -150,10 +142,9 @@ describe('getLeverageYieldQuoteQueryOptions', () => {
150
142
  );
151
143
  });
152
144
 
153
- // Key derivation runs during render, so it must not throw on a payload assembled from
154
- // partially-validated form state — the SDK's own validation reports that as a Result.
155
145
  it('derives a hashable key even when amount is missing', () => {
156
146
  const { sodax } = makeSodax();
147
+ // Simulates half-filled form state that the type forbids; key derivation must not throw during render.
157
148
  const malformed = { ...PAYLOAD, amount: undefined } as unknown as LeverageYieldQuoteParams;
158
149
 
159
150
  const { queryKey } = getLeverageYieldQuoteQueryOptions({ sodax, payload: malformed });
@@ -169,7 +160,6 @@ describe('getLeverageYieldQuoteQueryOptions', () => {
169
160
  sodax,
170
161
  payload: { ...PAYLOAD, partnerFee: explicitFee },
171
162
  });
172
- // Mirrors getQuote's own precedence: per-call override beats the configured fee.
173
163
  expect(hashKey(queryKey)).toContain('"percentage":10');
174
164
  });
175
165
  });