@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
@@ -12,13 +12,6 @@ export type UseSwapsApiTokensParams = ReadHookParams<
12
12
  }
13
13
  >;
14
14
 
15
- /**
16
- * React hook to fetch all supported swap tokens grouped by SpokeChainKey via the swaps API —
17
- * `sodax.api.swaps.getTokens`.
18
- *
19
- * @example
20
- * const { data: tokensByChain } = useSwapsApiTokens();
21
- */
22
15
  export const useSwapsApiTokens = ({
23
16
  params,
24
17
  queryOptions,
@@ -13,13 +13,6 @@ export type UseSwapsApiTokensByChainParams = ReadHookParams<
13
13
  }
14
14
  >;
15
15
 
16
- /**
17
- * React hook to fetch supported swap tokens for a single SpokeChainKey via the swaps API —
18
- * `sodax.api.swaps.getTokensByChain`.
19
- *
20
- * @example
21
- * const { data: tokens } = useSwapsApiTokensByChain({ params: { chainKey: '0xa4b1.arbitrum' } });
22
- */
23
16
  export const useSwapsApiTokensByChain = ({
24
17
  params,
25
18
  queryOptions,
package/src/index.ts CHANGED
@@ -2,4 +2,4 @@ export * from './hooks/index.js';
2
2
  export * from './providers/index.js';
3
3
  export * from './utils/index.js';
4
4
 
5
- export * from '@sodax/sdk'; // export all sdk entities
5
+ export * from '@sodax/sdk';
@@ -1,12 +1,5 @@
1
- /**
2
- * `SodaxProvider` wire test for the consumer-supplied API key: `config.apiKey` handed to the
3
- * provider must reach the backend as `x-api-key` on requests made through the provided instance.
4
- *
5
- * Covers the one key-supply surface the hook manifests' hand-built `Sodax` does not: the provider's
6
- * own `new Sodax(config)`. No renderer — `useMemo` is patched to evaluate its factory so the
7
- * component can be called as a plain function and the provided `sodax` read off the element's
8
- * context value.
9
- */
1
+ // `config.apiKey` given to the provider must reach the backend as `x-api-key`.
2
+ // `useMemo` is patched to run its factory so the component can be called without a renderer.
10
3
 
11
4
  import type { Sodax } from '@sodax/sdk';
12
5
  import type { ReactElement } from 'react';
@@ -4,18 +4,7 @@ import { SodaxContext } from '@/contexts/index.js';
4
4
 
5
5
  interface SodaxProviderProps {
6
6
  children: ReactNode;
7
- /**
8
- * Sodax SDK config. Tracked by **reference** - a new identity re-instantiates the
9
- * SDK. Hoist to a module constant or wrap in `useMemo`; include any value the SDK
10
- * should react to (e.g. solver env) in the deps. Inline `{...}` re-creates the SDK
11
- * every parent render and resets every `useSodaxContext` consumer.
12
- *
13
- * @example
14
- * ```tsx
15
- * const config = useMemo(() => ({ solver: solverMap[env] }), [env]);
16
- * <SodaxProvider config={config}>...</SodaxProvider>
17
- * ```
18
- */
7
+ /** Tracked by reference: a new identity re-creates the SDK and resets consumers, so memoize it. */
19
8
  config?: SodaxOptions;
20
9
  }
21
10
 
@@ -1,36 +1,11 @@
1
- // packages/dapp-kit/src/providers/createSodaxQueryClient.ts
2
1
  import { MutationCache, QueryClient, type QueryClientConfig } from '@tanstack/react-query';
3
2
 
4
3
  export type CreateSodaxQueryClientOptions = {
5
4
  /**
6
- * Called for every mutation failure (i.e. every time `mutationFn` throws) that does NOT opt out
7
- * via `meta: { silent: true }` on the mutation. Defaults to `console.error`.
8
- *
9
- * This is **global observability** — it runs alongside any per-hook `onError` handler the
10
- * consumer set, NOT instead of them. In particular, it fires:
11
- * - whether or not `mutateAsync` was awaited inside `try/catch`
12
- * - whether or not `mutateAsyncSafe` was used (the wrapper packs into `Result<T>` AFTER React
13
- * Query has already entered the error state and dispatched its callbacks)
14
- * - whether or not the consumer's `mutationOptions.onError` already toasted/logged
15
- *
16
- * It is NOT a "did this rejection escape to the global handler?" detector — accurate
17
- * unhandled-rejection detection lives at `window.onunhandledrejection`, not here.
18
- *
19
- * To silence the default for a specific mutation that the consumer is handling locally, set
20
- * `meta: { silent: true }`:
21
- *
22
- * ```ts
23
- * useSwap({ mutationOptions: { meta: { silent: true }, onError: (e) => toast(e.message) } });
24
- * ```
25
- *
26
- * To disable the default globally (e.g. wire your own error boundary), pass a no-op:
27
- *
28
- * ```ts
29
- * createSodaxQueryClient({ onMutationError: () => {} });
30
- * ```
5
+ * Fires on every mutation failure, alongside per-hook `onError`, unless the mutation sets `meta: { silent: true }`.
6
+ * Defaults to `console.error`.
31
7
  */
32
8
  onMutationError?: (error: unknown) => void;
33
- /** Pass-through for any other QueryClient config (default queries options, etc.) */
34
9
  config?: QueryClientConfig;
35
10
  };
36
11
 
@@ -38,39 +13,12 @@ const defaultOnMutationError = (error: unknown): void => {
38
13
  console.error('[sodax] Mutation error:', error);
39
14
  };
40
15
 
41
- /**
42
- * Creates a `QueryClient` pre-wired with a mutation-error observability hook that gives dapp-kit
43
- * consumers a single seam for every mutation failure across the app — wire to Sentry/Datadog/console
44
- * as you like. Optional opt-in: consumers who construct their own `QueryClient` are unaffected.
45
- *
46
- * **Composition with a custom `MutationCache`.** If you pass `config.mutationCache`, we keep your
47
- * cache instance (preserving its own `onError` / `onSuccess` / etc.) and *additionally* subscribe
48
- * to its event stream to dispatch `onMutationError`. Both your handler and the dapp-kit handler
49
- * fire — neither replaces the other. If you don't pass one, we install our own.
50
- *
51
- * @example default — logs to console
52
- * const queryClient = createSodaxQueryClient();
53
- *
54
- * @example custom — Sentry
55
- * const queryClient = createSodaxQueryClient({
56
- * onMutationError: (e) => Sentry.captureException(e),
57
- * });
58
- *
59
- * @example silent — disable the default
60
- * const queryClient = createSodaxQueryClient({ onMutationError: () => {} });
61
- *
62
- * @example bring-your-own MutationCache
63
- * const myCache = new MutationCache({ onError: myOwnErrorHandler });
64
- * const queryClient = createSodaxQueryClient({ config: { mutationCache: myCache } });
65
- * // myOwnErrorHandler still runs; onMutationError ALSO runs (unless meta.silent).
66
- */
16
+ /** A custom `config.mutationCache` is kept and subscribed to, so its own handlers still fire too. */
67
17
  export function createSodaxQueryClient({
68
18
  onMutationError = defaultOnMutationError,
69
19
  config,
70
20
  }: CreateSodaxQueryClientOptions = {}): QueryClient {
71
21
  if (config?.mutationCache) {
72
- // Compose: keep the consumer's cache, attach our observability as an extra subscriber.
73
- // The consumer's own `MutationCache.onError` (if any) still fires — subscribe is additive.
74
22
  config.mutationCache.subscribe(event => {
75
23
  if (event.type === 'updated' && event.action.type === 'error' && event.mutation.options.meta?.silent !== true) {
76
24
  onMutationError(event.action.error);
@@ -79,7 +27,7 @@ export function createSodaxQueryClient({
79
27
  return new QueryClient(config);
80
28
  }
81
29
 
82
- // No consumer cache: install our own with `onError` directly (cheaper than a subscribe loop).
30
+ // No consumer cache: install our own `onError` (cheaper than a subscribe loop).
83
31
  return new QueryClient({
84
32
  ...config,
85
33
  mutationCache: new MutationCache({
@@ -57,21 +57,12 @@ type ChainSender = {
57
57
  /** Reads better than the id inside an error sentence. */
58
58
  const stepLabel = (step: ApprovalStepId): string => (step === 'allowance-reset' ? 'allowance reset' : 'approve');
59
59
 
60
- /**
61
- * `EvmRawTransactionReceipt.status` is documented as the JSON-RPC hex flag, but `EvmWalletProvider`
62
- * passes viem's `'reverted'` through unchanged, so both spellings reach here. A receipt without a
63
- * status is pre-Byzantium and inconclusive — not a revert.
64
- */
60
+ /** Matches both the JSON-RPC hex flag and viem's `'reverted'`, which `EvmWalletProvider` passes through unchanged.
61
+ * A missing status is pre-Byzantium and inconclusive, not a revert. */
65
62
  const isRevertedEvmReceiptStatus = (status: string | undefined): boolean => status === 'reverted' || status === '0x0';
66
63
 
67
- /**
68
- * How to send and confirm on the chains a SODAX approve route can act on — the hub (Sonic), EVM
69
- * spokes, and Stellar. Every other chain reports its allowance as always sufficient, so approval
70
- * never runs for it.
71
- *
72
- * Resolved once, before anything is sent: an unsupported chain or a Stellar wallet that cannot sign
73
- * then fails without first asking the user for a signature that could never be broadcast.
74
- */
64
+ /** Resolved before anything is sent, so an unsupported chain or a Stellar wallet that cannot sign fails
65
+ * without prompting for a signature that could never be broadcast. */
75
66
  function resolveChainSender(
76
67
  srcChainKey: SpokeChainKey,
77
68
  walletProvider: GetWalletProviderType<SpokeChainKey>,
@@ -79,9 +70,7 @@ function resolveChainSender(
79
70
  ): ChainSender {
80
71
  const fail = (message: string): Error => new Error(`[${hookName}] ${message}`);
81
72
 
82
- // Single SDK-exported source for "which chains support approval" — the same partition
83
- // SpokeService's approve-params guards resolve to, so a chain added there isn't silently
84
- // missed here too.
73
+ // Same SDK partition SpokeService's approve guards use, so a newly added chain isn't missed here.
85
74
  if (!isApprovalSupportedChainKeyType(srcChainKey)) {
86
75
  throw fail(
87
76
  `${srcChainKey} cannot be approved — SODAX approve routes support the hub (Sonic), EVM spokes, and Stellar.`,
@@ -92,8 +81,7 @@ function resolveChainSender(
92
81
  const evm = walletProvider as IEvmWalletProvider;
93
82
 
94
83
  return {
95
- // Chain-bind the send: the wallet broadcasts on ITS active chain, so refuse when that differs
96
- // from the srcChainKey the user asked for. (Verifying the tx CONTENT is a separate concern.)
84
+ // Chain-bind the send: the wallet broadcasts on ITS active chain, so refuse when it differs from srcChainKey.
97
85
  send: raw => evm.sendTransaction(raw as EvmRawTransaction, { expectedChainId: getEvmViemChain(srcChainKey).id }),
98
86
  confirm: async (hash, step) => {
99
87
  const receipt = await evm.waitForTransactionReceipt(hash as Hex);
@@ -124,25 +112,14 @@ function resolveChainSender(
124
112
  };
125
113
  }
126
114
 
127
- // Unreachable: isApprovalSupportedChainKeyType above already confirmed srcChainKey is hub, EVM-spoke,
128
- // or Stellar, and the two branches above cover all three — kept only to satisfy TypeScript's
129
- // return-path check (the guard is a plain boolean, so it doesn't narrow srcChainKey's type here).
115
+ // Unreachable: the boolean guard above doesn't narrow srcChainKey, so TypeScript needs this return path.
130
116
  throw fail(
131
117
  `${srcChainKey} cannot be approved — SODAX approve routes support the hub (Sonic), EVM spokes, and Stellar.`,
132
118
  );
133
119
  }
134
120
 
135
- /**
136
- * Broadcasts an approval plan in the only order that can work: `resetTx` mined first, then the
137
- * approve, which is not a valid state transition until the allowance has been zeroed on-chain.
138
- *
139
- * Not a pure helper like its neighbours here — it signs and sends through the caller's wallet
140
- * provider — but it is framework-free, and shared by the swaps and bridge approve-and-broadcast
141
- * hooks so the ordering is not re-derived per feature. `hookName` prefixes the errors.
142
- *
143
- * `onProgress` reports which transaction the user is being prompted for — `isPending` alone cannot
144
- * say whether a popup is the reset or the approve.
145
- */
121
+ /** Broadcasts `resetTx` and waits for it to be mined before the approve, which is invalid until the allowance is zeroed.
122
+ * `hookName` prefixes errors; `onProgress` says which tx the wallet is prompting for. */
146
123
  export async function runApprovalPlan({
147
124
  plan,
148
125
  srcChainKey,
@@ -14,22 +14,13 @@ import {
14
14
  import type { SpokeChainKey } from '@sodax/sdk';
15
15
  import { parseUnits } from 'viem';
16
16
 
17
- /**
18
- * Subset of {@link CreateAssetDepositParams} produced by {@link createDepositParamsProps}.
19
- * Callers add `srcChainKey` + `srcAddress` at the mutation call site.
20
- */
17
+ /** Callers add `srcChainKey` + `srcAddress` at the mutation call site. */
21
18
  export type DepositParamsCore = Omit<CreateAssetDepositParams<SpokeChainKey>, 'srcChainKey' | 'srcAddress'>;
22
19
 
23
- /**
24
- * Subset of {@link CreateAssetWithdrawParams} produced by {@link createWithdrawParamsProps}.
25
- * Callers add `srcChainKey` + `srcAddress` at the mutation call site.
26
- */
20
+ /** Callers add `srcChainKey` + `srcAddress` at the mutation call site. */
27
21
  export type WithdrawParamsCore = Omit<CreateAssetWithdrawParams<SpokeChainKey>, 'srcChainKey' | 'srcAddress'>;
28
22
 
29
- /**
30
- * Subset of {@link ClDecreaseLiquidityParams} produced by {@link createDecreaseLiquidityParamsProps}.
31
- * Callers add `srcChainKey` + `srcAddress` at the mutation call site.
32
- */
23
+ /** Callers add `srcChainKey` + `srcAddress` at the mutation call site. */
33
24
  export type DecreaseLiquidityParamsCore = Omit<ClDecreaseLiquidityParams<SpokeChainKey>, 'srcChainKey' | 'srcAddress'>;
34
25
 
35
26
  export function createDecreaseLiquidityParamsProps({
@@ -50,13 +41,11 @@ export function createDecreaseLiquidityParamsProps({
50
41
  throw new Error('Slippage must be between 0 and 100');
51
42
  }
52
43
 
53
- // Calculate liquidity to remove based on percentage
54
44
  const liquidityToRemove =
55
45
  percentageNum === 100
56
46
  ? positionInfo.liquidity
57
47
  : (positionInfo.liquidity * BigInt(Math.floor(percentageNum * 100))) / 10000n;
58
48
 
59
- // Calculate expected token amounts from this liquidity
60
49
  const expectedAmount0 =
61
50
  percentageNum === 100
62
51
  ? positionInfo.amount0
@@ -66,7 +55,6 @@ export function createDecreaseLiquidityParamsProps({
66
55
  ? positionInfo.amount1
67
56
  : (positionInfo.amount1 * BigInt(Math.floor(percentageNum * 100))) / 10000n;
68
57
 
69
- // Apply slippage to minimum amounts
70
58
  const slippageMultiplier = BigInt(Math.floor((100 - slippage) * 100));
71
59
  const amount0Min = (expectedAmount0 * slippageMultiplier) / 10000n;
72
60
  const amount1Min = (expectedAmount1 * slippageMultiplier) / 10000n;
@@ -97,7 +85,7 @@ export function createDepositParamsProps({
97
85
 
98
86
  return {
99
87
  asset: originalAsset.address,
100
- // Use deposit token decimals (original asset) for correct unit parsing
88
+ // Deposit token (original asset) decimals, not the pool token's.
101
89
  amount: parseUnits(String(amount), originalAsset.decimals),
102
90
  poolToken: token.address,
103
91
  };
@@ -135,7 +123,6 @@ export function createSupplyLiquidityParamsProps({
135
123
  const amount0BigInt = parseUnits(liquidityToken0Amount, poolData.token0.decimals);
136
124
  const amount1BigInt = parseUnits(liquidityToken1Amount, poolData.token1.decimals);
137
125
 
138
- // Convert prices to ticks
139
126
  const token0 = poolData.token0;
140
127
  const token1 = poolData.token1;
141
128
  const tickSpacing = poolData.tickSpacing;
@@ -143,7 +130,6 @@ export function createSupplyLiquidityParamsProps({
143
130
  const tickLower = ClService.priceToTick(minPriceNum, token0, token1, tickSpacing);
144
131
  const tickUpper = ClService.priceToTick(maxPriceNum, token0, token1, tickSpacing);
145
132
 
146
- // Calculate liquidity from full amounts (the desired deposit)
147
133
  const liquidity = ClService.calculateLiquidityFromAmounts(
148
134
  amount0BigInt,
149
135
  amount1BigInt,
@@ -152,8 +138,7 @@ export function createSupplyLiquidityParamsProps({
152
138
  BigInt(poolData.currentTick),
153
139
  );
154
140
 
155
- // Apply slippage to get max amounts — the ceiling the contract is allowed to pull.
156
- // If price moves unfavorably, the contract may need slightly more tokens than expected.
141
+ // Max amounts are the slippage-padded ceiling the contract may pull if price moves unfavorably.
157
142
  const { amount0Max, amount1Max } = ClService.calculateMaxAmountsForSlippage(
158
143
  liquidity,
159
144
  tickLower,
@@ -10,23 +10,12 @@ export interface NearStorageGateState {
10
10
  isNear: boolean;
11
11
  /** Show the "register storage" action: the check resolved and the recipient is not registered. */
12
12
  needsRegistration: boolean;
13
- /**
14
- * Keep the downstream action (swap/bridge/borrow/withdraw) disabled: the NEAR gate is unresolved
15
- * (still checking) or unmet (needs registration).
16
- */
13
+ /** True while the check is unresolved or registration is needed. */
17
14
  blocksAction: boolean;
18
15
  }
19
16
 
20
- /**
21
- * Derives the NEP-141 storage-registration UI gate state for a flow that delivers a token to a user
22
- * on NEAR — NEAR's analogue of the Stellar trustline gate. Unwrapped (no hook): pass the destination
23
- * `chainKey` and the `useNearStorageCheck` result; the util owns the `=== NEAR` test and reads
24
- * `isLoading` (NOT `isPending`, which stays `true` for a disabled query and would block forever).
25
- *
26
- * `blocksAction` deliberately also covers the in-flight check window so the action can't be
27
- * triggered before registration status is known; `needsRegistration` only flips once the check has
28
- * resolved (so the "register" button isn't shown speculatively while still checking).
29
- */
17
+ /** NEAR analogue of the Stellar trustline gate. Reads `isLoading`, not `isPending` (stays true for a disabled query);
18
+ * `blocksAction` also covers the in-flight check, while `needsRegistration` waits for it to resolve. */
30
19
  export function resolveNearStorageGate(
31
20
  chainKey: SpokeChainKey | undefined,
32
21
  check: NearStorageCheckResult,
@@ -1,21 +1,13 @@
1
1
  import { ChainKeys, type SpokeChainKey, type StellarAccountStatus } from '@sodax/sdk';
2
2
  import type { UseQueryResult } from '@tanstack/react-query';
3
3
 
4
- /**
5
- * The subset of a query result the gate reads. A full `UseQueryResult<T>` satisfies it.
6
- *
7
- * `isLoading` is intentional: `isPending` remains true for disabled queries.
8
- * Errors remain distinct from unmet prerequisites.
9
- */
4
+ /** Reads `isLoading` because `isPending` stays true for disabled queries; errors stay distinct from unmet prerequisites. */
10
5
  export type StellarCheckResult<T> = Pick<UseQueryResult<T>, 'isLoading' | 'isError' | 'data'>;
11
6
 
12
7
  export interface StellarGateState {
13
8
  isStellar: boolean;
14
9
  needsActivation: boolean;
15
- /**
16
- * The account needs a trustline but lacks spendable XLM. Never set for
17
- * native XLM or an existing trustline.
18
- */
10
+ /** Never set for native XLM or an existing trustline. */
19
11
  needsFunding: boolean;
20
12
  needsTrustline: boolean;
21
13
  /** A query failed; disabled or unresolved queries do not set this. */
@@ -45,12 +37,7 @@ const NOT_STELLAR: StellarGateState = {
45
37
  blocksAction: false,
46
38
  };
47
39
 
48
- /**
49
- * Resolve activation, trustline, and funding prerequisites in order.
50
- *
51
- * Check the trustline before affordability because an existing trustline needs
52
- * no additional XLM. Unknown states fail closed.
53
- */
40
+ /** Checks the trustline before affordability because an existing trustline needs no extra XLM. Unknown states fail closed. */
54
41
  export function resolveStellarGate(chainKey: SpokeChainKey | undefined, inputs: StellarGateInputs): StellarGateState {
55
42
  const { statusCheck, trustlineCheck, isNativeToken } = inputs;
56
43
 
@@ -26,21 +26,7 @@ export type SwapSetupReason =
26
26
  | 'xrpCheckFailed'
27
27
  | 'external';
28
28
 
29
- /**
30
- * Where a swap form stands, discriminated on `kind`. `useSwapLifecycle`'s `next()` acts on it.
31
- *
32
- * - `checking` — waiting before anything can be done: a gate or the approval strategy is still reading, or a
33
- * setup tx (activation, trustline, NEAR storage) is in flight or its check is refreshing.
34
- * - `submitting` — the swap call is in flight: signing, and on the default backend path settlement too.
35
- * - `pending` — the source tx status is being read, or a recovery handle is waiting for identification.
36
- * `error` is set when the swap call
37
- * failed after broadcast, or when the status read cannot recover (a rejected API key); the swap may
38
- * still complete either way. The read can also stop polling without an error (after its budget of
39
- * ambiguous reads), so keep `reset()` reachable here.
40
- * - `unconfirmed` — the wallet accepted an approve + swap batch that was not confirmed in time. It may
41
- * still land, so `next()` never sends it again: it waits for that batch and finishes the swap once it
42
- * lands. `reset()` stops tracking it.
43
- */
29
+ /** Where a swap form stands, discriminated on `kind`; `useSwapLifecycle`'s `next()` acts on it. */
44
30
  export type SwapLifecycleState =
45
31
  | { kind: 'idle' }
46
32
  | { kind: 'checking' }
@@ -48,8 +34,10 @@ export type SwapLifecycleState =
48
34
  | { kind: 'needsSetup'; reason: SwapSetupReason }
49
35
  | { kind: 'ready'; approvalStrategy: SwapApprovalStrategy }
50
36
  | { kind: 'submitting' }
37
+ // `error`: failed after broadcast or unrecoverable status read; may still complete, and polling can stop silently, so keep `reset()` reachable.
51
38
  | { kind: 'pending'; srcChainKey: SpokeChainKey; srcTxHash: string; error?: Error }
52
39
  | { kind: 'pending'; srcChainKey: SpokeChainKey; srcTxHash?: never; recovery: unknown; error: Error }
40
+ // A wallet-accepted approve + swap batch not confirmed in time: may still land, so `next()` waits for it instead of resending.
53
41
  | { kind: 'unconfirmed'; batchId: string; callCount?: number; error: Error }
54
42
  | { kind: 'settled'; srcChainKey: SpokeChainKey; srcTxHash: string; fillTxHash?: Hex }
55
43
  | { kind: 'failed'; error: Error; srcChainKey?: SpokeChainKey; srcTxHash?: string };
@@ -109,12 +97,8 @@ export function isSameIntent(a: CreateIntentParams, b: CreateIntentParams): bool
109
97
  );
110
98
  }
111
99
 
112
- /**
113
- * The attempt the lifecycle tracks. A swap in flight, or one that may still land (a failure after
114
- * broadcast, which keeps its source tx from `error.context.srcTxHash`, or an unconfirmed batch), counts
115
- * until `reset()` whatever the params, so a param edit cannot re-enable the button and swap twice. A
116
- * completed or never-sent swap counts only while it is for the current params.
117
- */
100
+ /** A swap in flight or one that may still land counts until `reset()` whatever the params, so a param edit cannot
101
+ * re-enable the button and swap twice; a completed or never-sent swap counts only for the current params. */
118
102
  export function toSwapAttempt(mutation: SwapAttemptSource, intentParams: CreateIntentParams | undefined): SwapAttempt {
119
103
  if (mutation.status === 'pending') return { phase: 'submitting' };
120
104
  const attempted = mutation.variables?.params;
@@ -149,11 +133,8 @@ function toFinishedAttempt(mutation: SwapAttemptSource, attempted: CreateIntentP
149
133
  return { phase: 'failed', error };
150
134
  }
151
135
 
152
- /**
153
- * Derives the lifecycle state. Order: an attempt in flight or broadcast wins; then missing inputs;
154
- * then destination prerequisites (Stellar, NEAR, XRPL, app-owned); then the source chain; then the
155
- * approval strategy. Pure — `useSwapLifecycle` feeds it from its sub-hooks.
156
- */
136
+ /** Order: an attempt in flight or broadcast wins; then missing inputs; then destination prerequisites (Stellar, NEAR,
137
+ * XRPL, app-owned); then the source chain; then the approval strategy. */
157
138
  export function resolveSwapLifecycle(inputs: SwapLifecycleInputs): SwapLifecycleState {
158
139
  const { attempt, status } = inputs;
159
140
  if (attempt.phase === 'submitting') return { kind: 'submitting' };
@@ -47,10 +47,7 @@ function unresolved<T>(check: XrpCheckResult<T>): boolean {
47
47
  return check.isLoading || check.data === undefined;
48
48
  }
49
49
 
50
- /**
51
- * Resolve the XRPL destination prerequisites for an issued token. Native XRP and other chains pass through:
52
- * the SDK still refuses an unreceivable payout before signing. Unknown states fail closed.
53
- */
50
+ /** Native XRP and other chains pass through: the SDK still refuses an unreceivable payout before signing. Unknown states fail closed. */
54
51
  export function resolveXrpGate(chainKey: SpokeChainKey | undefined, inputs: XrpGateInputs): XrpGateState {
55
52
  const { readinessCheck, reserveCheck, requiresTrustline } = inputs;
56
53
  if (chainKey !== ChainKeys.XRP_MAINNET || !requiresTrustline) return NOT_XRP_ISSUED_TOKEN;