@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
@@ -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
  });
@@ -3,11 +3,7 @@ import { useQuery, type UseQueryResult } from '@tanstack/react-query';
3
3
  import { useSodaxContext } from '../shared/useSodaxContext.js';
4
4
  import type { ReadHookParams } from '../shared/types.js';
5
5
 
6
- /**
7
- * Derived from the SDK method rather than restated, so the public error union
8
- * (`SolverErrorResponse | LeverageYieldLookupError`) stays exact and cannot drift.
9
- * `undefined` is the disabled state, before a `payload` exists.
10
- */
6
+ // Derived from the SDK method so the error union cannot drift; `undefined` is the disabled state.
11
7
  type LeverageYieldQuote = Awaited<ReturnType<Sodax['leverageYield']['getQuote']>> | undefined;
12
8
 
13
9
  export type UseLeverageYieldQuoteParams = ReadHookParams<
@@ -27,20 +23,8 @@ function feeKeyPart(fee: PartnerFee | undefined) {
27
23
  }
28
24
 
29
25
  /**
30
- * Keys on the **effective** fee, not `payload.partnerFee`: when the caller omits it, `getQuote`
31
- * falls back to `config.leverageYieldPartnerFee`, so the configured fee is a real input to the
32
- * result. Leaving it out lets two providers configured with different fees share one cache entry,
33
- * and lets a reconfigured provider serve the previous fee's quote until the next poll — either way
34
- * a `minOutputAmount` derived from that quote can be unfillable.
35
- *
36
- * Fields are named explicitly rather than spread. A spread would carry any future bigint field on
37
- * `SolverIntentQuoteRequest` straight into the key, and React Query hashes keys with
38
- * `JSON.stringify`, which throws on bigint — so a spread fails *open* into a render crash, while an
39
- * allow-list fails *closed* into a missing key segment. Add new fields here deliberately.
40
- *
41
- * `String(...)` rather than `.toString()`: a payload assembled from partially-validated form state
42
- * may not have an `amount` yet, and key derivation runs during render. Staying total lets the SDK's
43
- * own validation surface it as a `VALIDATION_FAILED` result instead of throwing past React Query.
26
+ * Keys on the effective fee (configured fallback included) and an explicit field allow-list, since a spread could carry
27
+ * a bigint into the key; `String(amount)` keeps render-time key derivation total for half-filled form state.
44
28
  */
45
29
  function quoteKeyPart(payload: LeverageYieldQuoteParams | undefined, effectiveFee: PartnerFee | undefined) {
46
30
  if (!payload) return undefined;
@@ -75,41 +59,8 @@ export function getLeverageYieldQuoteQueryOptions({
75
59
  }
76
60
 
77
61
  /**
78
- * Quotes a leverage-yield vault deposit or withdraw. Pass the vault address as `token_dst` to
79
- * quote a deposit, or as `token_src` to quote a withdraw; subtract your slippage tolerance from
80
- * `quoted_amount` to size `minOutputAmount`.
81
- *
82
- * Use this rather than {@link useQuote}: the swap quote deducts the effective *swap* fee, while a
83
- * vault intent charges the effective *leverage-yield* fee, so the two disagree whenever the feature
84
- * fees differ. When overriding the fee per intent, pass the same `partnerFee` here and to whichever
85
- * builder you use — `useLeverageYieldDeposit`, `useLeverageYieldWithdraw`, or
86
- * `useLeverageYieldVaultSwap` — or omit it on all of them, which resolves the same configured fee on
87
- * each side. Both directions are charged, so this applies to withdrawals as much as deposits.
88
- *
89
- * Returns the SDK `Result` as query data rather than unwrapping it, matching {@link useQuote}: a
90
- * quote failure ("no path", thin liquidity) is an expected UI branch, and keeping the `Result`
91
- * preserves the solver's `detail.code` instead of flattening it to an error message.
92
- *
93
- * @example
94
- * ```typescript
95
- * const { data: quote } = useLeverageYieldQuote({
96
- * params: {
97
- * payload: {
98
- * token_src: inputToken,
99
- * token_src_blockchain_id: ChainKeys.ARBITRUM_MAINNET,
100
- * token_dst: vault.vault,
101
- * token_dst_blockchain_id: ChainKeys.SONIC_MAINNET,
102
- * amount: parseUnits('1', 18),
103
- * quote_type: 'exact_input',
104
- * },
105
- * },
106
- * });
107
- * if (quote?.ok) setMinOutput((quote.value.quoted_amount * 9_950n) / 10_000n);
108
- * ```
109
- *
110
- * @remarks
111
- * - Refreshes every 3 seconds, like `useQuote` — solver prices go stale.
112
- * - Disabled while `payload` is undefined.
62
+ * Vault deposit (vault as `token_dst`) or withdraw (as `token_src`) quote, priced on the leverage-yield fee, unlike {@link useQuote}.
63
+ * Pass the same `partnerFee` here as to the builder (or omit on both). Returns the SDK `Result` as data.
113
64
  */
114
65
  export function useLeverageYieldQuote({
115
66
  params,
@@ -3,14 +3,12 @@ import { useSodaxContext } from '../shared/useSodaxContext.js';
3
3
  import type { Address, SpokeChainKey } from '@sodax/sdk';
4
4
  import type { ReadHookParams } from '../shared/types.js';
5
5
 
6
- /** A single `(chain, hub-wallet holder, share balance)` row produced by {@link useLeverageYieldShareBalances}. */
7
6
  export type LeverageYieldShareHolding = {
8
7
  chainKey: SpokeChainKey;
9
8
  holder: Address;
10
9
  shares: bigint;
11
10
  };
12
11
 
13
- /** A `(chainKey, EOA address)` pair the user controls — one per spoke chain they may hold shares under. */
14
12
  export type LeverageYieldShareHolder = {
15
13
  chainKey: SpokeChainKey;
16
14
  address: string;
@@ -21,30 +19,7 @@ export type UseLeverageYieldShareBalancesParams = ReadHookParams<
21
19
  { vault: Address | undefined; holders: readonly LeverageYieldShareHolder[] | undefined }
22
20
  >;
23
21
 
24
- /**
25
- * Reads a user's leverage-vault share (`lsoda*`) balances across every chain they may hold a
26
- * position under — one query per holder, fanned out via `useQueries`.
27
- *
28
- * For each `(chainKey, address)` the holder is resolved to the address that actually owns the
29
- * shares: the user's **derived hub wallet** on every chain, including the hub itself. Leverage
30
- * deposits always deliver `lsoda*` to `getUserHubWalletAddress(srcAddress, srcChainKey)` (the
31
- * CREATE3 user-router on Sonic for a hub-sourced deposit, the per-spoke hub wallet otherwise) —
32
- * never the bare EOA — so a hub-chain deposit's shares live in the router, not the signing EOA.
33
- * Resolving the holder the same way the deposit does is what makes a Sonic-sourced position show
34
- * up here instead of reading a stale zero off the EOA.
35
- *
36
- * Returns the raw `useQueries` result array (15s refresh per query); callers aggregate as needed
37
- * (e.g. sum `shares` for a headline total, or pick the row for the active chain).
38
- *
39
- * `useQueries` has no top-level options slot, so `queryOptions` is spread into every individual
40
- * query config (and applies uniformly to each holder's query).
41
- *
42
- * @example
43
- * ```typescript
44
- * const balances = useLeverageYieldShareBalances({ params: { vault: vault.vault, holders } });
45
- * const total = balances.reduce((acc, q) => acc + (q.data?.shares ?? 0n), 0n);
46
- * ```
47
- */
22
+ /** One `lsoda*` share-balance query per `(chainKey, EOA)` holder; `queryOptions` applies to each query. */
48
23
  export function useLeverageYieldShareBalances({
49
24
  params,
50
25
  queryOptions,
@@ -61,9 +36,7 @@ export function useLeverageYieldShareBalances({
61
36
  enabled: !!vault,
62
37
  queryFn: async (): Promise<LeverageYieldShareHolding> => {
63
38
  if (!vault) throw new Error('vault is required');
64
- // Always the derived hub wallet — on the hub chain too. A leverage deposit delivers
65
- // shares to getUserHubWalletAddress(...), the CREATE3 router on Sonic, never the EOA,
66
- // so reading balanceOf(EOA) for the hub chain would always come back zero.
39
+ // Hub wallet even on the hub chain: deposits deliver shares there, never to the EOA.
67
40
  const holder = await sodax.hubProvider.getUserHubWalletAddress(address, chainKey);
68
41
  const result = await sodax.leverageYield.getShareBalance(vault, holder);
69
42
  if (!result.ok) throw result.error;
@@ -5,15 +5,7 @@ import type { ReadHookParams } from '../shared/types.js';
5
5
 
6
6
  export type UseLeverageYieldTotalAssetsParams = ReadHookParams<bigint, { vault: Address | undefined }>;
7
7
 
8
- /**
9
- * Reads a leverage-yield vault's total underlying assets (vault-asset units, 18 decimals) —
10
- * i.e. its TVL. Moves slowly, so the default refresh is 60s.
11
- *
12
- * @example
13
- * ```typescript
14
- * const { data: tvl } = useLeverageYieldTotalAssets({ params: { vault: vault.vault } });
15
- * ```
16
- */
8
+ /** Vault TVL in vault-asset units (18 decimals). */
17
9
  export function useLeverageYieldTotalAssets({
18
10
  params,
19
11
  queryOptions,
@@ -6,37 +6,14 @@ import type { MutationHookParams } from '../shared/types.js';
6
6
  import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
7
7
  import { unwrapResult } from '../shared/unwrapResult.js';
8
8
 
9
- /**
10
- * Mutation variables for {@link useLeverageYieldVaultSwap}. Generic over `K extends SpokeChainKey`
11
- * (defaults to the full union). Sophisticated callers can lock K at the hook call site to narrow
12
- * the `walletProvider` and `params.srcChainKey` types.
13
- */
14
9
  export type UseLeverageYieldVaultSwapVars<K extends SpokeChainKey = SpokeChainKey> = Omit<
15
10
  VaultSwapActionParams<K, false>,
16
11
  'raw'
17
12
  >;
18
13
 
19
14
  /**
20
- * React hook for executing an end-to-end leverage-yield vault swap (deposit or withdraw).
21
- *
22
- * Spread a `LeverageYieldSwapPayload` built by {@link useLeverageYieldDeposit} /
23
- * {@link useLeverageYieldWithdraw} into `mutate` alongside the wallet provider:
24
- * `vaultSwap({ ...payload, walletProvider })`. Runs `sodax.leverageYield.vaultSwap`, so vault flows
25
- * never touch the generic swap surface.
26
- *
27
- * Which transport it takes is config, not an argument. With `leverageYield.useBackendSubmitTx` on,
28
- * it creates the intent and hands the broadcast tx to the leverage-yield API, which relays and
29
- * post-executes server-side, falling back to the client-side path (verify → relay → notify solver)
30
- * on any non-success. With it off, that client-side path runs outright. Read the effective value on
31
- * `sodax.config.leverageYieldUseBackendSubmitTx` rather than assuming which way it points.
32
- * Either way the resolved value is the same `VaultSwapResponse`.
33
- *
34
- * Pass `extras.apiKey` to key the backend leg per action, overriding the instance key. Poll the
35
- * result with {@link useLeverageYieldDetailedStatus}, which reads a vault swap's status from the
36
- * source-chain tx hash whichever transport completed it.
37
- *
38
- * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
39
- * `onError`, `retry`). Returns the unwrapped `VaultSwapResponse` on success.
15
+ * Executes a vault swap from a {@link useLeverageYieldDeposit} / {@link useLeverageYieldWithdraw} payload; transport
16
+ * (backend submit with client fallback, or client-only) follows `sodax.config.leverageYieldUseBackendSubmitTx`.
40
17
  */
41
18
  export function useLeverageYieldVaultSwap<K extends SpokeChainKey = SpokeChainKey>({
42
19
  mutationOptions,
@@ -6,24 +6,14 @@ import type { MutationHookParams } from '../shared/types.js';
6
6
  import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
7
7
  import { unwrapResult } from '../shared/unwrapResult.js';
8
8
 
9
- /**
10
- * Mutation variables for {@link useLeverageYieldVaultSwapWithApproval}: `useLeverageYieldVaultSwap`'s, plus
11
- * `allowAccountUpgrade`, `resumeBatchId` and `resumeBatchCallCount`.
12
- */
13
9
  export type UseLeverageYieldVaultSwapWithApprovalVars<K extends SpokeChainKey = SpokeChainKey> = Omit<
14
10
  VaultSwapWithApprovalParams<K>,
15
11
  'raw'
16
12
  >;
17
13
 
18
14
  /**
19
- * `useLeverageYieldVaultSwap` with the deposit's source-token approval folded in
20
- * (`sodax.leverageYield.vaultSwapWithApproval`): approve + deposit as one EIP-5792 batch (one
21
- * signature) on a batch-capable EVM wallet, otherwise approve, wait for it, then deposit. A withdraw
22
- * (`hubWalletSwap`) needs no approval and runs as `useLeverageYieldVaultSwap` does.
15
+ * `useLeverageYieldVaultSwap` with the deposit approval folded in (EIP-5792 batch when supported, else sequential).
23
16
  * `data.approvalStrategy` says which path ran; {@link useLeverageYieldApprovalStrategy} predicts it.
24
- *
25
- * Throws on SDK failure so React Query's error model engages. On success invalidates balances, the
26
- * deposit allowance (read through `useSwapAllowance`) and the approval-strategy query.
27
17
  */
28
18
  export function useLeverageYieldVaultSwapWithApproval<K extends SpokeChainKey = SpokeChainKey>({
29
19
  mutationOptions,
@@ -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 useLeverageYieldWithdraw} — the swap-style withdraw inputs. */
8
7
  export type UseLeverageYieldWithdrawVars = LeverageYieldSwapWithdrawParams;
9
8
 
10
- /**
11
- * Builds the `LeverageYieldSwapPayload` for a leverage-yield withdraw (`lsoda*` shares → any token).
12
- * The returned payload carries `hubWalletSwap: true`; spread it into
13
- * {@link useLeverageYieldVaultSwap}, which authorises the hub wallet to spend the shares via a
14
- * `Connection.sendMessage`.
15
- *
16
- * This is a builder, not an executor. Throws on SDK failure so React Query's error model engages;
17
- * returns the unwrapped `LeverageYieldSwapPayload` on success.
18
- *
19
- * @example
20
- * ```typescript
21
- * const { mutateAsyncSafe: buildWithdraw } = useLeverageYieldWithdraw();
22
- * const built = await buildWithdraw({ vault, srcChainKey, srcAddress, dstChainKey, outputToken, inputAmount, minOutputAmount });
23
- * if (built.ok) vaultSwap({ ...built.value, walletProvider });
24
- * ```
25
- */
9
+ /** Builds (does not execute) a withdraw payload with `hubWalletSwap: true`; spread it into {@link useLeverageYieldVaultSwap}. */
26
10
  export function useLeverageYieldWithdraw({
27
11
  mutationOptions,
28
12
  }: MutationHookParams<LeverageYieldSwapPayload, UseLeverageYieldWithdrawVars> = {}): SafeUseMutationResult<
@@ -12,27 +12,15 @@ import type { MutationHookParams } from '../shared/types.js';
12
12
  import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
13
13
  import { unwrapResult } from '../shared/unwrapResult.js';
14
14
 
15
- /**
16
- * Mutation variables for {@link useOpenLeveragePosition}.
17
- *
18
- * `side` picks which asset funds the open, and the two take different params — so the union is
19
- * discriminated rather than merged, and the wrong field set is a type error instead of a revert.
20
- */
15
+ /** Discriminated on `side` so a wrong field set is a type error rather than a revert. */
21
16
  export type UseOpenLeveragePositionVars<K extends SpokeChainKey = SpokeChainKey> =
22
17
  | ({ side?: 'collateral' } & Omit<SpokeExecActionParams<K, false, OpenPositionParams<K>>, 'raw'>)
23
18
  | ({ side: 'debt' } & Omit<SpokeExecActionParams<K, false, OpenPositionFromDebtTokenParams<K>>, 'raw'>);
24
19
 
25
20
  /**
26
- * Opens a leveraged position, funded from any chain, and reports the intent it posts.
27
- *
28
- * Thin over `sodax.leverageYield.openLeveragePosition`, which owns the pairing — a non-React caller
29
- * gets the same guarantee. Resolving means the intent is LIVE, not that the position is open: read
30
- * `notified` before telling the owner to wait, since a failed notification still resolves.
31
- *
32
- * Positions are owned by the hub wallet, never the signing address — pass the signer as
33
- * `params.srcAddress` and the SDK resolves the owner.
34
- *
35
- * @experimental Off-hub (spoke) origins are unverified on-chain; see the SDK method.
21
+ * Resolving means the intent is live, not that the position is open; check `notified`, since a failed notification still resolves.
22
+ * Pass the signer as `params.srcAddress`; the SDK resolves the owning hub wallet.
23
+ * @experimental Off-hub (spoke) origins are unverified on-chain.
36
24
  */
37
25
  export function useOpenLeveragePosition<K extends SpokeChainKey = SpokeChainKey>({
38
26
  mutationOptions,
@@ -50,8 +38,7 @@ export function useOpenLeveragePosition<K extends SpokeChainKey = SpokeChainKey>
50
38
  mutationFn: async vars => unwrapResult(await sodax.leverageYield.openLeveragePosition({ ...vars, raw: false })),
51
39
  onSuccess: async (data, vars, ctx) => {
52
40
  invalidateBalances(queryClient, vars.params.srcChainKey);
53
- // A position write changes every position read — account, pending slot, the list itself — and a
54
- // partner that has to remember this leaves the UI stale after the one action it just took.
41
+ // A position write affects every position read (account, pending slot, list).
55
42
  queryClient.invalidateQueries({ queryKey: ['leverageYield'] });
56
43
  await mutationOptions?.onSuccess?.(data, vars, ctx);
57
44
  },