@sodax/dapp-kit 2.2.0-rc.1 → 2.2.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 (84) hide show
  1. package/README.md +2 -0
  2. package/dist/index.d.ts +599 -3
  3. package/dist/index.mjs +705 -41
  4. package/package.json +3 -3
  5. package/src/hooks/_apiKeyWire.test.ts +384 -18
  6. package/src/hooks/_mutationContract.test.ts +13 -0
  7. package/src/hooks/backend/index.ts +4 -0
  8. package/src/hooks/backend/useBackendOracleCandles.ts +47 -0
  9. package/src/hooks/backend/useBackendOracleMarkets.ts +30 -0
  10. package/src/hooks/bitcoin/useFundTradingWallet.ts +2 -1
  11. package/src/hooks/bitcoin/useRadfiWithdraw.ts +2 -1
  12. package/src/hooks/bridge/useBridge.ts +2 -2
  13. package/src/hooks/dex/useDexDeposit.ts +2 -1
  14. package/src/hooks/dex/useDexWithdraw.ts +2 -1
  15. package/src/hooks/dex/useSupplyLiquidity.ts +2 -1
  16. package/src/hooks/index.ts +1 -0
  17. package/src/hooks/leverageYield/useLeverageYieldVaultSwap.ts +2 -2
  18. package/src/hooks/leverageYieldApi/index.ts +55 -0
  19. package/src/hooks/leverageYieldApi/useLeverageYieldApiAllowance.ts +50 -0
  20. package/src/hooks/leverageYieldApi/useLeverageYieldApiApprove.ts +37 -0
  21. package/src/hooks/leverageYieldApi/useLeverageYieldApiApproveAndBroadcast.test.ts +176 -0
  22. package/src/hooks/leverageYieldApi/useLeverageYieldApiApproveAndBroadcast.ts +83 -0
  23. package/src/hooks/leverageYieldApi/useLeverageYieldApiApr.ts +41 -0
  24. package/src/hooks/leverageYieldApi/useLeverageYieldApiAsset.ts +41 -0
  25. package/src/hooks/leverageYieldApi/useLeverageYieldApiCancelIntent.ts +37 -0
  26. package/src/hooks/leverageYieldApi/useLeverageYieldApiCreateDepositIntent.ts +37 -0
  27. package/src/hooks/leverageYieldApi/useLeverageYieldApiCreateWithdrawIntent.ts +37 -0
  28. package/src/hooks/leverageYieldApi/useLeverageYieldApiDeadline.ts +38 -0
  29. package/src/hooks/leverageYieldApi/useLeverageYieldApiDepositQuote.ts +57 -0
  30. package/src/hooks/leverageYieldApi/useLeverageYieldApiEffectiveApr.ts +41 -0
  31. package/src/hooks/leverageYieldApi/useLeverageYieldApiEstimateGas.ts +41 -0
  32. package/src/hooks/leverageYieldApi/useLeverageYieldApiFilledIntent.ts +40 -0
  33. package/src/hooks/leverageYieldApi/useLeverageYieldApiIntent.ts +40 -0
  34. package/src/hooks/leverageYieldApi/useLeverageYieldApiIntentExtraData.ts +42 -0
  35. package/src/hooks/leverageYieldApi/useLeverageYieldApiIntentHash.ts +41 -0
  36. package/src/hooks/leverageYieldApi/useLeverageYieldApiIntentPacket.ts +41 -0
  37. package/src/hooks/leverageYieldApi/useLeverageYieldApiLsdApr.ts +41 -0
  38. package/src/hooks/leverageYieldApi/useLeverageYieldApiMaxWithdraw.ts +43 -0
  39. package/src/hooks/leverageYieldApi/useLeverageYieldApiPartnerFee.ts +41 -0
  40. package/src/hooks/leverageYieldApi/useLeverageYieldApiPosition.ts +41 -0
  41. package/src/hooks/leverageYieldApi/useLeverageYieldApiPreviewDeposit.ts +43 -0
  42. package/src/hooks/leverageYieldApi/useLeverageYieldApiPreviewRedeem.ts +43 -0
  43. package/src/hooks/leverageYieldApi/useLeverageYieldApiPreviewWithdraw.ts +43 -0
  44. package/src/hooks/leverageYieldApi/useLeverageYieldApiShareBalance.ts +43 -0
  45. package/src/hooks/leverageYieldApi/useLeverageYieldApiSolverFee.ts +41 -0
  46. package/src/hooks/leverageYieldApi/useLeverageYieldApiStatus.ts +48 -0
  47. package/src/hooks/leverageYieldApi/useLeverageYieldApiSubmitIntent.ts +36 -0
  48. package/src/hooks/leverageYieldApi/useLeverageYieldApiSubmitTx.ts +37 -0
  49. package/src/hooks/leverageYieldApi/useLeverageYieldApiSubmitTxStatus.ts +60 -0
  50. package/src/hooks/leverageYieldApi/useLeverageYieldApiTotalAssets.ts +41 -0
  51. package/src/hooks/leverageYieldApi/useLeverageYieldApiVault.ts +41 -0
  52. package/src/hooks/leverageYieldApi/useLeverageYieldApiVaults.ts +36 -0
  53. package/src/hooks/leverageYieldApi/useLeverageYieldApiWithdrawQuote.ts +56 -0
  54. package/src/hooks/migrate/useMigrateBaln.ts +2 -2
  55. package/src/hooks/migrate/useMigrateIcxToSoda.ts +2 -2
  56. package/src/hooks/migrate/useMigratebnUSD.ts +2 -2
  57. package/src/hooks/migrate/useRevertMigrateSodaToIcx.ts +2 -2
  58. package/src/hooks/mm/useBorrow.ts +2 -4
  59. package/src/hooks/mm/useRepay.ts +2 -1
  60. package/src/hooks/mm/useSupply.ts +2 -1
  61. package/src/hooks/mm/useWithdraw.ts +2 -4
  62. package/src/hooks/partner/useFeeClaimWithdraw.ts +2 -1
  63. package/src/hooks/recovery/useWithdrawHubAsset.ts +2 -1
  64. package/src/hooks/shared/index.ts +2 -0
  65. package/src/hooks/shared/invalidateBalances.test.ts +71 -0
  66. package/src/hooks/shared/invalidateBalances.ts +25 -0
  67. package/src/hooks/shared/useBalances.test.ts +118 -0
  68. package/src/hooks/shared/useBalances.ts +81 -0
  69. package/src/hooks/shared/useEstablishTrustline.test.ts +2 -0
  70. package/src/hooks/shared/useEstablishTrustline.ts +2 -1
  71. package/src/hooks/shared/useStellarGate.test.ts +1 -1
  72. package/src/hooks/sponsoring/useActivateStellarAccount.test.ts +6 -4
  73. package/src/hooks/sponsoring/useActivateStellarAccount.ts +2 -1
  74. package/src/hooks/sponsoring/useSponsorConfig.test.ts +8 -2
  75. package/src/hooks/sponsoring/useStellarAccountActive.test.ts +2 -2
  76. package/src/hooks/sponsoring/useStellarAccountStatus.test.ts +8 -2
  77. package/src/hooks/staking/useClaim.ts +2 -1
  78. package/src/hooks/staking/useInstantUnstake.ts +2 -1
  79. package/src/hooks/staking/useStake.ts +2 -1
  80. package/src/hooks/swap/useDetailedStatus.test.ts +2 -2
  81. package/src/hooks/swap/useSwap.ts +2 -2
  82. package/src/hooks/swapsApi/useSwapsApiApproveAndBroadcast.test.ts +5 -1
  83. package/src/providers/SodaxProvider.test.ts +1 -1
  84. package/src/utils/approvalPlan.ts +4 -1
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { isSodaxError, isAuthFailure, ChainKeys, STELLAR_TRUSTLINE_MIN_XLM_STROOPS, RadfiApiError, normalizePsbtToBase64, ClService, SPONSOR_CONFIG_TTL_MS, Sodax, SolverIntentStatusCode, DETAILED_STATUS_NOT_DELIVERED, isApprovalSupportedChainKeyType, isHubChainKeyType, isEvmSpokeOnlyChainKeyType, isStellarChainKeyType } from '@sodax/sdk';
1
+ import { isSodaxError, isAuthFailure, ChainKeys, STELLAR_TRUSTLINE_MIN_XLM_STROOPS, RadfiApiError, normalizePsbtToBase64, ClService, SPONSOR_CONFIG_TTL_MS, Sodax, SolverIntentStatusCode, DETAILED_STATUS_NOT_DELIVERED, isApprovalSupportedChainKeyType, isHubChainKeyType, isEvmSpokeOnlyChainKeyType, getEvmViemChain, isStellarChainKeyType } from '@sodax/sdk';
2
2
  export * from '@sodax/sdk';
3
3
  import { useMutation, useQuery, useQueryClient, useQueries, QueryClient, MutationCache } from '@tanstack/react-query';
4
4
  import { createContext, useCallback, useContext, useRef, useState, useEffect, useMemo } from 'react';
@@ -113,6 +113,17 @@ function useStellarTrustlineCheck({
113
113
  ...queryOptions
114
114
  });
115
115
  }
116
+
117
+ // src/hooks/shared/invalidateBalances.ts
118
+ function invalidateBalances(queryClient, ...chainKeys) {
119
+ for (const chainKey of new Set(chainKeys)) {
120
+ if (!chainKey) continue;
121
+ queryClient.invalidateQueries({ queryKey: ["shared", "balances", chainKey] });
122
+ queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", chainKey] });
123
+ }
124
+ }
125
+
126
+ // src/hooks/shared/useEstablishTrustline.ts
116
127
  function useEstablishTrustline({
117
128
  mutationOptions
118
129
  } = {}) {
@@ -143,7 +154,7 @@ function useEstablishTrustline({
143
154
  queryClient.invalidateQueries({
144
155
  queryKey: srcAddress ? ["sponsoring", "stellarAccountStatus", srcAddress] : ["sponsoring", "stellarAccountStatus"]
145
156
  });
146
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", ChainKeys.STELLAR_MAINNET] });
157
+ invalidateBalances(queryClient, ChainKeys.STELLAR_MAINNET);
147
158
  await mutationOptions?.onSuccess?.(data, vars, ctx);
148
159
  }
149
160
  });
@@ -288,7 +299,7 @@ function useActivateStellarAccount({
288
299
  queryClient.invalidateQueries({ queryKey: ["sponsoring", "stellarAccountActive", vars.address] });
289
300
  queryClient.invalidateQueries({ queryKey: ["sponsoring", "stellarAccountStatus", vars.address] });
290
301
  queryClient.invalidateQueries({ queryKey: ["shared", "stellarTrustlineCheck"] });
291
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", ChainKeys.STELLAR_MAINNET] });
302
+ invalidateBalances(queryClient, ChainKeys.STELLAR_MAINNET);
292
303
  await mutationOptions?.onSuccess?.(data, vars, ctx);
293
304
  }
294
305
  });
@@ -504,6 +515,34 @@ function useXBalances({
504
515
  ...queryOptions
505
516
  });
506
517
  }
518
+ var REFETCH_INTERVAL_MS2 = 5e3;
519
+ function getBalancesQueryOptions(sodax, { chainKey, tokens, address }) {
520
+ return {
521
+ // Pair symbol + address: readable in devtools, unique on-chain (symbol alone can collide —
522
+ // e.g. scam tokens copying a legitimate ticker).
523
+ queryKey: ["shared", "balances", chainKey, tokens.map((t) => [t.symbol, t.address]), address],
524
+ queryFn: async () => {
525
+ if (!chainKey || !address) return {};
526
+ return unwrapResult(await sodax.spoke.getWalletBalances({ srcChainKey: chainKey, srcAddress: address, tokens }));
527
+ },
528
+ enabled: !!chainKey && !!address && tokens.length > 0,
529
+ refetchInterval: REFETCH_INTERVAL_MS2
530
+ // Deliberately NOT `placeholderData: keepPreviousData`: the query key carries the chain, so a
531
+ // chain switch would surface the previous chain's map — and every EVM chain shares the native
532
+ // token address, so its native balance would render as the new chain's until the fetch lands.
533
+ };
534
+ }
535
+ function useBalances({ params, queryOptions } = {}) {
536
+ const { sodax } = useSodaxContext();
537
+ return useQuery({
538
+ ...getBalancesQueryOptions(sodax, {
539
+ chainKey: params?.chainKey,
540
+ tokens: params?.tokens ?? [],
541
+ address: params?.address
542
+ }),
543
+ ...queryOptions
544
+ });
545
+ }
507
546
 
508
547
  // src/hooks/provider/useHubProvider.ts
509
548
  function useHubProvider() {
@@ -622,7 +661,7 @@ function useFundTradingWallet({
622
661
  onSuccess: async (data, vars, ctx) => {
623
662
  queryClient.invalidateQueries({ queryKey: ["bitcoin", "balance"] });
624
663
  queryClient.invalidateQueries({ queryKey: ["bitcoin", "tradingWalletBalance"] });
625
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", ChainKeys.BITCOIN_MAINNET] });
664
+ invalidateBalances(queryClient, ChainKeys.BITCOIN_MAINNET);
626
665
  await mutationOptions?.onSuccess?.(data, vars, ctx);
627
666
  }
628
667
  });
@@ -760,7 +799,7 @@ function useRadfiWithdraw({
760
799
  onSuccess: async (data, vars, ctx) => {
761
800
  queryClient.invalidateQueries({ queryKey: ["bitcoin", "tradingWalletBalance"] });
762
801
  queryClient.invalidateQueries({ queryKey: ["bitcoin", "balance"] });
763
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", ChainKeys.BITCOIN_MAINNET] });
802
+ invalidateBalances(queryClient, ChainKeys.BITCOIN_MAINNET);
764
803
  await mutationOptions?.onSuccess?.(data, vars, ctx);
765
804
  }
766
805
  });
@@ -781,10 +820,7 @@ function useBorrow({
781
820
  queryKey: ["mm", "userFormattedSummary", params.srcChainKey, params.srcAddress]
782
821
  });
783
822
  queryClient.invalidateQueries({ queryKey: ["mm", "aTokensBalances"] });
784
- const balanceChains = /* @__PURE__ */ new Set([params.srcChainKey, params.dstChainKey ?? params.srcChainKey]);
785
- for (const chainKey of balanceChains) {
786
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", chainKey] });
787
- }
823
+ invalidateBalances(queryClient, params.srcChainKey, params.dstChainKey);
788
824
  await mutationOptions?.onSuccess?.(data, vars, ctx);
789
825
  }
790
826
  });
@@ -806,7 +842,7 @@ function useRepay({
806
842
  });
807
843
  queryClient.invalidateQueries({ queryKey: ["mm", "aTokensBalances"] });
808
844
  queryClient.invalidateQueries({ queryKey: ["mm", "allowance", params.srcChainKey, params.token, params.action] });
809
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.srcChainKey] });
845
+ invalidateBalances(queryClient, params.srcChainKey);
810
846
  await mutationOptions?.onSuccess?.(data, vars, ctx);
811
847
  }
812
848
  });
@@ -828,7 +864,7 @@ function useSupply({
828
864
  });
829
865
  queryClient.invalidateQueries({ queryKey: ["mm", "aTokensBalances"] });
830
866
  queryClient.invalidateQueries({ queryKey: ["mm", "allowance", params.srcChainKey, params.token, params.action] });
831
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.srcChainKey] });
867
+ invalidateBalances(queryClient, params.srcChainKey);
832
868
  await mutationOptions?.onSuccess?.(data, vars, ctx);
833
869
  }
834
870
  });
@@ -849,10 +885,7 @@ function useWithdraw({
849
885
  queryKey: ["mm", "userFormattedSummary", params.srcChainKey, params.srcAddress]
850
886
  });
851
887
  queryClient.invalidateQueries({ queryKey: ["mm", "aTokensBalances"] });
852
- const balanceChains = /* @__PURE__ */ new Set([params.srcChainKey, params.dstChainKey ?? params.srcChainKey]);
853
- for (const chainKey of balanceChains) {
854
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", chainKey] });
855
- }
888
+ invalidateBalances(queryClient, params.srcChainKey, params.dstChainKey);
856
889
  await mutationOptions?.onSuccess?.(data, vars, ctx);
857
890
  }
858
891
  });
@@ -1103,8 +1136,7 @@ function useSwap({
1103
1136
  ...mutationOptions,
1104
1137
  mutationFn: async (vars) => unwrapResult(await sodax.swaps.swap({ ...vars, raw: false })),
1105
1138
  onSuccess: async (data, vars, ctx) => {
1106
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", vars.params.srcChainKey] });
1107
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", vars.params.dstChainKey] });
1139
+ invalidateBalances(queryClient, vars.params.srcChainKey, vars.params.dstChainKey);
1108
1140
  await mutationOptions?.onSuccess?.(data, vars, ctx);
1109
1141
  }
1110
1142
  });
@@ -1502,6 +1534,39 @@ var useBackendAllMoneyMarketBorrowers = ({
1502
1534
  ...queryOptions
1503
1535
  });
1504
1536
  };
1537
+ var useBackendOracleMarkets = ({
1538
+ queryOptions
1539
+ } = {}) => {
1540
+ const { sodax } = useSodaxContext();
1541
+ return useQuery({
1542
+ queryKey: ["backend", "oracle", "markets"],
1543
+ queryFn: async () => {
1544
+ return unwrapResult(await sodax.backendApi.getOracleMarkets());
1545
+ },
1546
+ staleTime: 60 * 1e3,
1547
+ retry: 3,
1548
+ ...queryOptions
1549
+ });
1550
+ };
1551
+ var useBackendOracleCandles = ({
1552
+ params,
1553
+ queryOptions
1554
+ } = {}) => {
1555
+ const { sodax } = useSodaxContext();
1556
+ return useQuery({
1557
+ queryKey: ["backend", "oracle", "candles", params?.symbol, params?.interval, params?.from, params?.to],
1558
+ queryFn: async () => {
1559
+ if (!params) {
1560
+ throw new Error("symbol, interval, from and to are required");
1561
+ }
1562
+ return unwrapResult(await sodax.backendApi.getOracleCandles(params));
1563
+ },
1564
+ enabled: !!params?.symbol && !!params?.interval && params?.from != null && params?.to != null,
1565
+ staleTime: 10 * 1e3,
1566
+ retry: 3,
1567
+ ...queryOptions
1568
+ });
1569
+ };
1505
1570
  var useSwapsApiTokens = ({
1506
1571
  params,
1507
1572
  queryOptions
@@ -1613,7 +1678,9 @@ function resolveChainSender(srcChainKey, walletProvider, hookName) {
1613
1678
  if (isHubChainKeyType(srcChainKey) || isEvmSpokeOnlyChainKeyType(srcChainKey)) {
1614
1679
  const evm = walletProvider;
1615
1680
  return {
1616
- send: (raw) => evm.sendTransaction(raw),
1681
+ // Chain-bind the send: the wallet broadcasts on ITS active chain, so refuse when that differs
1682
+ // from the srcChainKey the user asked for. (Verifying the tx CONTENT is a separate concern.)
1683
+ send: (raw) => evm.sendTransaction(raw, { expectedChainId: getEvmViemChain(srcChainKey).id }),
1617
1684
  confirm: async (hash, step) => {
1618
1685
  const receipt = await evm.waitForTransactionReceipt(hash);
1619
1686
  if (isRevertedEvmReceiptStatus(receipt.status)) {
@@ -1972,8 +2039,7 @@ function useBridge({
1972
2039
  ...mutationOptions,
1973
2040
  mutationFn: async (vars) => unwrapResult(await sodax.bridge.bridge({ ...vars, raw: false })),
1974
2041
  onSuccess: async (data, vars, ctx) => {
1975
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", vars.params.srcChainKey] });
1976
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", vars.params.dstChainKey] });
2042
+ invalidateBalances(queryClient, vars.params.srcChainKey, vars.params.dstChainKey);
1977
2043
  await mutationOptions?.onSuccess?.(data, vars, ctx);
1978
2044
  }
1979
2045
  });
@@ -2280,7 +2346,7 @@ function useStake({
2280
2346
  queryClient.invalidateQueries({ queryKey: ["staking", "allowance", params.srcChainKey, "stake"] });
2281
2347
  queryClient.invalidateQueries({ queryKey: ["staking", "stakeRatio"] });
2282
2348
  queryClient.invalidateQueries({ queryKey: ["staking", "convertedAssets"] });
2283
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.srcChainKey] });
2349
+ invalidateBalances(queryClient, params.srcChainKey);
2284
2350
  await mutationOptions?.onSuccess?.(data, vars, ctx);
2285
2351
  }
2286
2352
  });
@@ -2367,7 +2433,7 @@ function useClaim({
2367
2433
  queryClient.invalidateQueries({
2368
2434
  queryKey: ["staking", "unstakingInfoWithPenalty", params.srcChainKey, params.srcAddress]
2369
2435
  });
2370
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.srcChainKey] });
2436
+ invalidateBalances(queryClient, params.srcChainKey);
2371
2437
  await mutationOptions?.onSuccess?.(data, vars, ctx);
2372
2438
  }
2373
2439
  });
@@ -2526,7 +2592,7 @@ function useInstantUnstake({
2526
2592
  queryClient.invalidateQueries({ queryKey: ["staking", "info", params.srcChainKey, params.srcAddress] });
2527
2593
  queryClient.invalidateQueries({ queryKey: ["staking", "instantUnstakeRatio"] });
2528
2594
  queryClient.invalidateQueries({ queryKey: ["staking", "allowance", params.srcChainKey, "instantUnstake"] });
2529
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.srcChainKey] });
2595
+ invalidateBalances(queryClient, params.srcChainKey);
2530
2596
  await mutationOptions?.onSuccess?.(data, vars, ctx);
2531
2597
  }
2532
2598
  });
@@ -2871,7 +2937,7 @@ function useFeeClaimWithdraw({
2871
2937
  queryClient.invalidateQueries({
2872
2938
  queryKey: ["partner", "feeClaim", "assetsBalances", vars.params.srcAddress]
2873
2939
  });
2874
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", vars.params.dstChainKey] });
2940
+ invalidateBalances(queryClient, vars.params.dstChainKey);
2875
2941
  await mutationOptions?.onSuccess?.(data, vars, ctx);
2876
2942
  }
2877
2943
  });
@@ -2912,7 +2978,7 @@ function useWithdrawHubAsset({
2912
2978
  queryClient.invalidateQueries({
2913
2979
  queryKey: ["recovery", "hubAssetBalances", params.srcChainKey, params.srcAddress]
2914
2980
  });
2915
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.srcChainKey] });
2981
+ invalidateBalances(queryClient, params.srcChainKey);
2916
2982
  await mutationOptions?.onSuccess?.(data, vars, ctx);
2917
2983
  }
2918
2984
  });
@@ -2928,8 +2994,7 @@ function useMigrateIcxToSoda({
2928
2994
  mutationFn: async (vars) => unwrapResult(await sodax.migration.migrateIcxToSoda({ ...vars, raw: false })),
2929
2995
  onSuccess: async (data, vars, ctx) => {
2930
2996
  queryClient.invalidateQueries({ queryKey: ["migrate", "allowance"] });
2931
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", vars.params.srcChainKey] });
2932
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", ChainKeys.SONIC_MAINNET] });
2997
+ invalidateBalances(queryClient, vars.params.srcChainKey, ChainKeys.SONIC_MAINNET);
2933
2998
  await mutationOptions?.onSuccess?.(data, vars, ctx);
2934
2999
  }
2935
3000
  });
@@ -2945,8 +3010,7 @@ function useRevertMigrateSodaToIcx({
2945
3010
  mutationFn: async (vars) => unwrapResult(await sodax.migration.revertMigrateSodaToIcx({ ...vars, raw: false })),
2946
3011
  onSuccess: async (data, vars, ctx) => {
2947
3012
  queryClient.invalidateQueries({ queryKey: ["migrate", "allowance"] });
2948
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", vars.params.srcChainKey] });
2949
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", ChainKeys.ICON_MAINNET] });
3013
+ invalidateBalances(queryClient, vars.params.srcChainKey, ChainKeys.ICON_MAINNET);
2950
3014
  await mutationOptions?.onSuccess?.(data, vars, ctx);
2951
3015
  }
2952
3016
  });
@@ -2963,8 +3027,7 @@ function useMigratebnUSD({
2963
3027
  onSuccess: async (data, vars, ctx) => {
2964
3028
  const { params } = vars;
2965
3029
  queryClient.invalidateQueries({ queryKey: ["migrate", "allowance"] });
2966
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.srcChainKey] });
2967
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.dstChainKey] });
3030
+ invalidateBalances(queryClient, params.srcChainKey, params.dstChainKey);
2968
3031
  await mutationOptions?.onSuccess?.(data, vars, ctx);
2969
3032
  }
2970
3033
  });
@@ -2980,8 +3043,7 @@ function useMigrateBaln({
2980
3043
  mutationFn: async (vars) => unwrapResult(await sodax.migration.migrateBaln({ ...vars, raw: false })),
2981
3044
  onSuccess: async (data, vars, ctx) => {
2982
3045
  queryClient.invalidateQueries({ queryKey: ["migrate", "allowance"] });
2983
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", ChainKeys.ICON_MAINNET] });
2984
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", ChainKeys.SONIC_MAINNET] });
3046
+ invalidateBalances(queryClient, ChainKeys.ICON_MAINNET, ChainKeys.SONIC_MAINNET);
2985
3047
  queryClient.invalidateQueries({ queryKey: ["staking", "info"] });
2986
3048
  await mutationOptions?.onSuccess?.(data, vars, ctx);
2987
3049
  }
@@ -3007,7 +3069,7 @@ function useMigrationApprove({
3007
3069
  }
3008
3070
  });
3009
3071
  }
3010
- var REFETCH_INTERVAL_MS2 = 2e3;
3072
+ var REFETCH_INTERVAL_MS3 = 2e3;
3011
3073
  function useMigrationAllowance({
3012
3074
  params,
3013
3075
  queryOptions
@@ -3033,7 +3095,7 @@ function useMigrationAllowance({
3033
3095
  return result.ok ? result.value : false;
3034
3096
  },
3035
3097
  enabled: !!migrationParams && !!action,
3036
- refetchInterval: REFETCH_INTERVAL_MS2,
3098
+ refetchInterval: REFETCH_INTERVAL_MS3,
3037
3099
  ...queryOptions
3038
3100
  });
3039
3101
  }
@@ -3142,7 +3204,7 @@ function useDexDeposit({
3142
3204
  queryClient.invalidateQueries({
3143
3205
  queryKey: ["dex", "allowance", params.srcChainKey, params.asset, params.amount.toString()]
3144
3206
  });
3145
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.srcChainKey] });
3207
+ invalidateBalances(queryClient, params.srcChainKey);
3146
3208
  await mutationOptions?.onSuccess?.(data, vars, ctx);
3147
3209
  }
3148
3210
  });
@@ -3159,7 +3221,7 @@ function useDexWithdraw({
3159
3221
  onSuccess: async (data, vars, ctx) => {
3160
3222
  const { params } = vars;
3161
3223
  queryClient.invalidateQueries({ queryKey: ["dex", "poolBalances", params.srcChainKey, params.srcAddress] });
3162
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.srcChainKey] });
3224
+ invalidateBalances(queryClient, params.srcChainKey);
3163
3225
  await mutationOptions?.onSuccess?.(data, vars, ctx);
3164
3226
  }
3165
3227
  });
@@ -3346,7 +3408,7 @@ function useSupplyLiquidity({
3346
3408
  }
3347
3409
  queryClient.invalidateQueries({ queryKey: ["dex", "poolData", params.poolKey] });
3348
3410
  queryClient.invalidateQueries({ queryKey: ["dex", "poolBalances", params.srcChainKey, params.srcAddress] });
3349
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", params.srcChainKey] });
3411
+ invalidateBalances(queryClient, params.srcChainKey);
3350
3412
  await mutationOptions?.onSuccess?.(data, vars, ctx);
3351
3413
  }
3352
3414
  });
@@ -3769,8 +3831,7 @@ function useLeverageYieldVaultSwap({
3769
3831
  ...mutationOptions,
3770
3832
  mutationFn: async (vars) => unwrapResult(await sodax.leverageYield.vaultSwap({ ...vars, raw: false })),
3771
3833
  onSuccess: async (data, vars, ctx) => {
3772
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", vars.params.srcChainKey] });
3773
- queryClient.invalidateQueries({ queryKey: ["shared", "xBalances", vars.params.dstChainKey] });
3834
+ invalidateBalances(queryClient, vars.params.srcChainKey, vars.params.dstChainKey);
3774
3835
  await mutationOptions?.onSuccess?.(data, vars, ctx);
3775
3836
  }
3776
3837
  });
@@ -3787,6 +3848,609 @@ function useLeverageYieldWithdraw({
3787
3848
  mutationFn: async (vars) => unwrapResult(await sodax.leverageYield.withdraw(vars))
3788
3849
  });
3789
3850
  }
3851
+ var useLeverageYieldApiVaults = ({
3852
+ params,
3853
+ queryOptions
3854
+ } = {}) => {
3855
+ const { sodax } = useSodaxContext();
3856
+ const apiConfig = params?.apiConfig;
3857
+ return useQuery({
3858
+ queryKey: ["leverageYieldApi", "vaults"],
3859
+ queryFn: async () => unwrapResult(await sodax.api.leverageYield.getVaults(apiConfig)),
3860
+ retry: retryUnlessAuthFailure,
3861
+ ...queryOptions
3862
+ });
3863
+ };
3864
+ var useLeverageYieldApiVault = ({
3865
+ params,
3866
+ queryOptions
3867
+ } = {}) => {
3868
+ const { sodax } = useSodaxContext();
3869
+ const name = params?.name;
3870
+ const apiConfig = params?.apiConfig;
3871
+ return useQuery({
3872
+ queryKey: ["leverageYieldApi", "vault", name],
3873
+ queryFn: async () => {
3874
+ if (!name) return void 0;
3875
+ return unwrapResult(await sodax.api.leverageYield.getVault(name, apiConfig));
3876
+ },
3877
+ enabled: !!name && name.length > 0,
3878
+ retry: retryUnlessAuthFailure,
3879
+ ...queryOptions
3880
+ });
3881
+ };
3882
+ var useLeverageYieldApiAsset = ({
3883
+ params,
3884
+ queryOptions
3885
+ } = {}) => {
3886
+ const { sodax } = useSodaxContext();
3887
+ const vault = params?.vault;
3888
+ const apiConfig = params?.apiConfig;
3889
+ return useQuery({
3890
+ queryKey: ["leverageYieldApi", "asset", vault],
3891
+ queryFn: async () => {
3892
+ if (!vault) return void 0;
3893
+ return unwrapResult(await sodax.api.leverageYield.getAsset({ vault }, apiConfig));
3894
+ },
3895
+ enabled: !!vault && vault.length > 0,
3896
+ retry: retryUnlessAuthFailure,
3897
+ ...queryOptions
3898
+ });
3899
+ };
3900
+ var useLeverageYieldApiPosition = ({
3901
+ params,
3902
+ queryOptions
3903
+ } = {}) => {
3904
+ const { sodax } = useSodaxContext();
3905
+ const vault = params?.vault;
3906
+ const apiConfig = params?.apiConfig;
3907
+ return useQuery({
3908
+ queryKey: ["leverageYieldApi", "position", vault],
3909
+ queryFn: async () => {
3910
+ if (!vault) return void 0;
3911
+ return unwrapResult(await sodax.api.leverageYield.getPosition({ vault }, apiConfig));
3912
+ },
3913
+ enabled: !!vault && vault.length > 0,
3914
+ retry: retryUnlessAuthFailure,
3915
+ ...queryOptions
3916
+ });
3917
+ };
3918
+ var useLeverageYieldApiApr = ({
3919
+ params,
3920
+ queryOptions
3921
+ } = {}) => {
3922
+ const { sodax } = useSodaxContext();
3923
+ const vault = params?.vault;
3924
+ const apiConfig = params?.apiConfig;
3925
+ return useQuery({
3926
+ queryKey: ["leverageYieldApi", "apr", vault],
3927
+ queryFn: async () => {
3928
+ if (!vault) return void 0;
3929
+ return unwrapResult(await sodax.api.leverageYield.getApr({ vault }, apiConfig));
3930
+ },
3931
+ enabled: !!vault && vault.length > 0,
3932
+ retry: retryUnlessAuthFailure,
3933
+ ...queryOptions
3934
+ });
3935
+ };
3936
+ var useLeverageYieldApiEffectiveApr = ({
3937
+ params,
3938
+ queryOptions
3939
+ } = {}) => {
3940
+ const { sodax } = useSodaxContext();
3941
+ const vault = params?.vault;
3942
+ const apiConfig = params?.apiConfig;
3943
+ return useQuery({
3944
+ queryKey: ["leverageYieldApi", "effectiveApr", vault],
3945
+ queryFn: async () => {
3946
+ if (!vault) return void 0;
3947
+ return unwrapResult(await sodax.api.leverageYield.getEffectiveApr({ vault }, apiConfig));
3948
+ },
3949
+ enabled: !!vault && vault.length > 0,
3950
+ retry: retryUnlessAuthFailure,
3951
+ ...queryOptions
3952
+ });
3953
+ };
3954
+ var useLeverageYieldApiLsdApr = ({
3955
+ params,
3956
+ queryOptions
3957
+ } = {}) => {
3958
+ const { sodax } = useSodaxContext();
3959
+ const vault = params?.vault;
3960
+ const apiConfig = params?.apiConfig;
3961
+ return useQuery({
3962
+ queryKey: ["leverageYieldApi", "lsdApr", vault],
3963
+ queryFn: async () => {
3964
+ if (!vault) return void 0;
3965
+ return unwrapResult(await sodax.api.leverageYield.getLsdApr({ vault }, apiConfig));
3966
+ },
3967
+ enabled: !!vault && vault.length > 0,
3968
+ retry: retryUnlessAuthFailure,
3969
+ ...queryOptions
3970
+ });
3971
+ };
3972
+ var useLeverageYieldApiTotalAssets = ({
3973
+ params,
3974
+ queryOptions
3975
+ } = {}) => {
3976
+ const { sodax } = useSodaxContext();
3977
+ const vault = params?.vault;
3978
+ const apiConfig = params?.apiConfig;
3979
+ return useQuery({
3980
+ queryKey: ["leverageYieldApi", "totalAssets", vault],
3981
+ queryFn: async () => {
3982
+ if (!vault) return void 0;
3983
+ return unwrapResult(await sodax.api.leverageYield.getTotalAssets({ vault }, apiConfig));
3984
+ },
3985
+ enabled: !!vault && vault.length > 0,
3986
+ retry: retryUnlessAuthFailure,
3987
+ ...queryOptions
3988
+ });
3989
+ };
3990
+ var useLeverageYieldApiPreviewDeposit = ({
3991
+ params,
3992
+ queryOptions
3993
+ } = {}) => {
3994
+ const { sodax } = useSodaxContext();
3995
+ const vault = params?.vault;
3996
+ const assets = params?.assets;
3997
+ const apiConfig = params?.apiConfig;
3998
+ return useQuery({
3999
+ queryKey: ["leverageYieldApi", "previewDeposit", vault, assets],
4000
+ queryFn: async () => {
4001
+ if (!vault || assets === void 0) return void 0;
4002
+ return unwrapResult(await sodax.api.leverageYield.previewDeposit({ vault, assets }, apiConfig));
4003
+ },
4004
+ enabled: !!vault && vault.length > 0 && assets !== void 0,
4005
+ retry: retryUnlessAuthFailure,
4006
+ ...queryOptions
4007
+ });
4008
+ };
4009
+ var useLeverageYieldApiPreviewWithdraw = ({
4010
+ params,
4011
+ queryOptions
4012
+ } = {}) => {
4013
+ const { sodax } = useSodaxContext();
4014
+ const vault = params?.vault;
4015
+ const assets = params?.assets;
4016
+ const apiConfig = params?.apiConfig;
4017
+ return useQuery({
4018
+ queryKey: ["leverageYieldApi", "previewWithdraw", vault, assets],
4019
+ queryFn: async () => {
4020
+ if (!vault || assets === void 0) return void 0;
4021
+ return unwrapResult(await sodax.api.leverageYield.previewWithdraw({ vault, assets }, apiConfig));
4022
+ },
4023
+ enabled: !!vault && vault.length > 0 && assets !== void 0,
4024
+ retry: retryUnlessAuthFailure,
4025
+ ...queryOptions
4026
+ });
4027
+ };
4028
+ var useLeverageYieldApiPreviewRedeem = ({
4029
+ params,
4030
+ queryOptions
4031
+ } = {}) => {
4032
+ const { sodax } = useSodaxContext();
4033
+ const vault = params?.vault;
4034
+ const shares = params?.shares;
4035
+ const apiConfig = params?.apiConfig;
4036
+ return useQuery({
4037
+ queryKey: ["leverageYieldApi", "previewRedeem", vault, shares],
4038
+ queryFn: async () => {
4039
+ if (!vault || shares === void 0) return void 0;
4040
+ return unwrapResult(await sodax.api.leverageYield.previewRedeem({ vault, shares }, apiConfig));
4041
+ },
4042
+ enabled: !!vault && vault.length > 0 && shares !== void 0,
4043
+ retry: retryUnlessAuthFailure,
4044
+ ...queryOptions
4045
+ });
4046
+ };
4047
+ var useLeverageYieldApiShareBalance = ({
4048
+ params,
4049
+ queryOptions
4050
+ } = {}) => {
4051
+ const { sodax } = useSodaxContext();
4052
+ const vault = params?.vault;
4053
+ const owner = params?.owner;
4054
+ const apiConfig = params?.apiConfig;
4055
+ return useQuery({
4056
+ queryKey: ["leverageYieldApi", "shareBalance", vault, owner],
4057
+ queryFn: async () => {
4058
+ if (!vault || owner === void 0) return void 0;
4059
+ return unwrapResult(await sodax.api.leverageYield.getShareBalance({ vault, owner }, apiConfig));
4060
+ },
4061
+ enabled: !!vault && vault.length > 0 && owner !== void 0,
4062
+ retry: retryUnlessAuthFailure,
4063
+ ...queryOptions
4064
+ });
4065
+ };
4066
+ var useLeverageYieldApiMaxWithdraw = ({
4067
+ params,
4068
+ queryOptions
4069
+ } = {}) => {
4070
+ const { sodax } = useSodaxContext();
4071
+ const vault = params?.vault;
4072
+ const owner = params?.owner;
4073
+ const apiConfig = params?.apiConfig;
4074
+ return useQuery({
4075
+ queryKey: ["leverageYieldApi", "maxWithdraw", vault, owner],
4076
+ queryFn: async () => {
4077
+ if (!vault || owner === void 0) return void 0;
4078
+ return unwrapResult(await sodax.api.leverageYield.getMaxWithdraw({ vault, owner }, apiConfig));
4079
+ },
4080
+ enabled: !!vault && vault.length > 0 && owner !== void 0,
4081
+ retry: retryUnlessAuthFailure,
4082
+ ...queryOptions
4083
+ });
4084
+ };
4085
+ var useLeverageYieldApiDepositQuote = ({
4086
+ params,
4087
+ queryOptions
4088
+ } = {}) => {
4089
+ const { sodax } = useSodaxContext();
4090
+ const body = params?.body;
4091
+ const query = params?.query;
4092
+ const apiConfig = params?.apiConfig;
4093
+ return useQuery({
4094
+ // Hash the whole request body so every quote input (incl. partnerFee) is a cache dimension.
4095
+ queryKey: ["leverageYieldApi", "depositQuote", body, query?.includeTxData ?? false],
4096
+ queryFn: async () => {
4097
+ if (!body) return void 0;
4098
+ return unwrapResult(await sodax.api.leverageYield.getDepositQuote(body, query, apiConfig));
4099
+ },
4100
+ enabled: !!body,
4101
+ retry: retryUnlessAuthFailure,
4102
+ ...queryOptions
4103
+ });
4104
+ };
4105
+ var useLeverageYieldApiWithdrawQuote = ({
4106
+ params,
4107
+ queryOptions
4108
+ } = {}) => {
4109
+ const { sodax } = useSodaxContext();
4110
+ const body = params?.body;
4111
+ const query = params?.query;
4112
+ const apiConfig = params?.apiConfig;
4113
+ return useQuery({
4114
+ queryKey: ["leverageYieldApi", "withdrawQuote", body, query?.includeTxData ?? false],
4115
+ queryFn: async () => {
4116
+ if (!body) return void 0;
4117
+ return unwrapResult(await sodax.api.leverageYield.getWithdrawQuote(body, query, apiConfig));
4118
+ },
4119
+ enabled: !!body,
4120
+ retry: retryUnlessAuthFailure,
4121
+ ...queryOptions
4122
+ });
4123
+ };
4124
+ var useLeverageYieldApiDeadline = ({
4125
+ params,
4126
+ queryOptions
4127
+ } = {}) => {
4128
+ const { sodax } = useSodaxContext();
4129
+ const query = params?.query;
4130
+ const apiConfig = params?.apiConfig;
4131
+ return useQuery({
4132
+ queryKey: ["leverageYieldApi", "deadline", query?.offsetSeconds ?? null],
4133
+ queryFn: async () => unwrapResult(await sodax.api.leverageYield.getDeadline(query, apiConfig)),
4134
+ retry: retryUnlessAuthFailure,
4135
+ ...queryOptions
4136
+ });
4137
+ };
4138
+ var useLeverageYieldApiAllowance = ({
4139
+ params,
4140
+ queryOptions
4141
+ } = {}) => {
4142
+ const { sodax } = useSodaxContext();
4143
+ const body = params?.body;
4144
+ const apiConfig = params?.apiConfig;
4145
+ return useQuery({
4146
+ queryKey: [
4147
+ "leverageYieldApi",
4148
+ "allowance",
4149
+ body?.vault,
4150
+ body?.srcChainKey,
4151
+ body?.inputToken,
4152
+ body?.inputAmount,
4153
+ body?.srcAddress
4154
+ ],
4155
+ queryFn: async () => {
4156
+ if (!body) return void 0;
4157
+ return unwrapResult(await sodax.api.leverageYield.checkAllowance(body, apiConfig));
4158
+ },
4159
+ enabled: !!body,
4160
+ retry: retryUnlessAuthFailure,
4161
+ ...queryOptions
4162
+ });
4163
+ };
4164
+
4165
+ // src/hooks/leverageYieldApi/useLeverageYieldApiApprove.ts
4166
+ var useLeverageYieldApiApprove = ({
4167
+ mutationOptions
4168
+ } = {}) => {
4169
+ const { sodax } = useSodaxContext();
4170
+ return useSafeMutation({
4171
+ mutationKey: ["leverageYieldApi", "approve"],
4172
+ retry: retryUnlessAuthFailure,
4173
+ ...mutationOptions,
4174
+ mutationFn: async ({ body, apiConfig }) => unwrapResult(await sodax.api.leverageYield.approve(body, apiConfig))
4175
+ });
4176
+ };
4177
+ var useLeverageYieldApiApproveAndBroadcast = ({
4178
+ mutationOptions
4179
+ } = {}) => {
4180
+ const { sodax } = useSodaxContext();
4181
+ const queryClient = useQueryClient();
4182
+ return useSafeMutation({
4183
+ mutationKey: ["leverageYieldApi", "approveAndBroadcast"],
4184
+ ...mutationOptions,
4185
+ mutationFn: async ({ body, walletProvider, apiConfig, onProgress }) => {
4186
+ const plan = unwrapResult(await sodax.api.leverageYield.approve(body, apiConfig));
4187
+ return runApprovalPlan({
4188
+ plan,
4189
+ srcChainKey: body.srcChainKey,
4190
+ walletProvider,
4191
+ hookName: "useLeverageYieldApiApproveAndBroadcast",
4192
+ onProgress
4193
+ });
4194
+ },
4195
+ onSuccess: async (data, vars, ctx) => {
4196
+ await queryClient.invalidateQueries({ queryKey: ["leverageYieldApi", "allowance"] });
4197
+ await mutationOptions?.onSuccess?.(data, vars, ctx);
4198
+ }
4199
+ });
4200
+ };
4201
+
4202
+ // src/hooks/leverageYieldApi/useLeverageYieldApiCreateDepositIntent.ts
4203
+ var useLeverageYieldApiCreateDepositIntent = ({
4204
+ mutationOptions
4205
+ } = {}) => {
4206
+ const { sodax } = useSodaxContext();
4207
+ return useSafeMutation({
4208
+ mutationKey: ["leverageYieldApi", "createDepositIntent"],
4209
+ retry: retryUnlessAuthFailure,
4210
+ ...mutationOptions,
4211
+ mutationFn: async ({ body, apiConfig }) => unwrapResult(await sodax.api.leverageYield.createDepositIntent(body, apiConfig))
4212
+ });
4213
+ };
4214
+
4215
+ // src/hooks/leverageYieldApi/useLeverageYieldApiCreateWithdrawIntent.ts
4216
+ var useLeverageYieldApiCreateWithdrawIntent = ({
4217
+ mutationOptions
4218
+ } = {}) => {
4219
+ const { sodax } = useSodaxContext();
4220
+ return useSafeMutation({
4221
+ mutationKey: ["leverageYieldApi", "createWithdrawIntent"],
4222
+ retry: retryUnlessAuthFailure,
4223
+ ...mutationOptions,
4224
+ mutationFn: async ({ body, apiConfig }) => unwrapResult(await sodax.api.leverageYield.createWithdrawIntent(body, apiConfig))
4225
+ });
4226
+ };
4227
+
4228
+ // src/hooks/leverageYieldApi/useLeverageYieldApiSubmitIntent.ts
4229
+ var useLeverageYieldApiSubmitIntent = ({
4230
+ mutationOptions
4231
+ } = {}) => {
4232
+ const { sodax } = useSodaxContext();
4233
+ return useSafeMutation({
4234
+ mutationKey: ["leverageYieldApi", "submitIntent"],
4235
+ retry: false,
4236
+ ...mutationOptions,
4237
+ mutationFn: async ({ body, apiConfig }) => unwrapResult(await sodax.api.leverageYield.submitIntent(body, apiConfig))
4238
+ });
4239
+ };
4240
+ var useLeverageYieldApiStatus = ({
4241
+ params,
4242
+ queryOptions
4243
+ } = {}) => {
4244
+ const { sodax } = useSodaxContext();
4245
+ const intentTxHash = params?.intentTxHash;
4246
+ const apiConfig = params?.apiConfig;
4247
+ return useQuery({
4248
+ queryKey: ["leverageYieldApi", "status", intentTxHash],
4249
+ queryFn: async () => {
4250
+ if (!intentTxHash) return void 0;
4251
+ return unwrapResult(await sodax.api.leverageYield.getStatus({ intentTxHash }, apiConfig));
4252
+ },
4253
+ enabled: !!intentTxHash && intentTxHash.length > 0,
4254
+ retry: retryUnlessAuthFailure,
4255
+ refetchInterval: (query) => isTerminalSwapIntentStatus(query.state.data?.status) ? false : 1e3,
4256
+ ...queryOptions
4257
+ });
4258
+ };
4259
+
4260
+ // src/hooks/leverageYieldApi/useLeverageYieldApiCancelIntent.ts
4261
+ var useLeverageYieldApiCancelIntent = ({
4262
+ mutationOptions
4263
+ } = {}) => {
4264
+ const { sodax } = useSodaxContext();
4265
+ return useSafeMutation({
4266
+ mutationKey: ["leverageYieldApi", "cancelIntent"],
4267
+ retry: retryUnlessAuthFailure,
4268
+ ...mutationOptions,
4269
+ mutationFn: async ({ body, apiConfig }) => unwrapResult(await sodax.api.leverageYield.cancelIntent(body, apiConfig))
4270
+ });
4271
+ };
4272
+ var useLeverageYieldApiIntentHash = ({
4273
+ params,
4274
+ queryOptions
4275
+ } = {}) => {
4276
+ const { sodax } = useSodaxContext();
4277
+ const intent = params?.intent;
4278
+ const apiConfig = params?.apiConfig;
4279
+ return useQuery({
4280
+ queryKey: ["leverageYieldApi", "intentHash", intent?.intentId?.toString()],
4281
+ queryFn: async () => {
4282
+ if (!intent) return void 0;
4283
+ return unwrapResult(await sodax.api.leverageYield.getIntentHash({ intent }, apiConfig));
4284
+ },
4285
+ enabled: !!intent,
4286
+ retry: retryUnlessAuthFailure,
4287
+ ...queryOptions
4288
+ });
4289
+ };
4290
+ var useLeverageYieldApiIntentPacket = ({
4291
+ params,
4292
+ queryOptions
4293
+ } = {}) => {
4294
+ const { sodax } = useSodaxContext();
4295
+ const body = params?.body;
4296
+ const apiConfig = params?.apiConfig;
4297
+ return useQuery({
4298
+ queryKey: ["leverageYieldApi", "intentPacket", body?.chainId, body?.fillTxHash],
4299
+ queryFn: async () => {
4300
+ if (!body) return void 0;
4301
+ return unwrapResult(await sodax.api.leverageYield.getSolvedIntentPacket(body, apiConfig));
4302
+ },
4303
+ enabled: !!body,
4304
+ retry: retryUnlessAuthFailure,
4305
+ ...queryOptions
4306
+ });
4307
+ };
4308
+ var useLeverageYieldApiIntentExtraData = ({
4309
+ params,
4310
+ queryOptions
4311
+ } = {}) => {
4312
+ const { sodax } = useSodaxContext();
4313
+ const body = params?.body;
4314
+ const apiConfig = params?.apiConfig;
4315
+ return useQuery({
4316
+ queryKey: ["leverageYieldApi", "intentExtraData", body?.txHash ?? body?.intent?.intentId?.toString()],
4317
+ queryFn: async () => {
4318
+ if (!body || !body.txHash && !body.intent) return void 0;
4319
+ return unwrapResult(await sodax.api.leverageYield.getIntentSubmitTxExtraData(body, apiConfig));
4320
+ },
4321
+ enabled: !!body && (!!body.txHash || !!body.intent),
4322
+ retry: retryUnlessAuthFailure,
4323
+ ...queryOptions
4324
+ });
4325
+ };
4326
+ var useLeverageYieldApiFilledIntent = ({
4327
+ params,
4328
+ queryOptions
4329
+ } = {}) => {
4330
+ const { sodax } = useSodaxContext();
4331
+ const txHash = params?.txHash;
4332
+ const apiConfig = params?.apiConfig;
4333
+ return useQuery({
4334
+ queryKey: ["leverageYieldApi", "filledIntent", txHash],
4335
+ queryFn: async () => {
4336
+ if (!txHash) return void 0;
4337
+ return unwrapResult(await sodax.api.leverageYield.getFilledIntent(txHash, apiConfig));
4338
+ },
4339
+ enabled: !!txHash && txHash.length > 0,
4340
+ retry: retryUnlessAuthFailure,
4341
+ ...queryOptions
4342
+ });
4343
+ };
4344
+ var useLeverageYieldApiIntent = ({
4345
+ params,
4346
+ queryOptions
4347
+ } = {}) => {
4348
+ const { sodax } = useSodaxContext();
4349
+ const txHash = params?.txHash;
4350
+ const apiConfig = params?.apiConfig;
4351
+ return useQuery({
4352
+ queryKey: ["leverageYieldApi", "intent", txHash],
4353
+ queryFn: async () => {
4354
+ if (!txHash) return void 0;
4355
+ return unwrapResult(await sodax.api.leverageYield.getIntent(txHash, apiConfig));
4356
+ },
4357
+ enabled: !!txHash && txHash.length > 0,
4358
+ retry: retryUnlessAuthFailure,
4359
+ ...queryOptions
4360
+ });
4361
+ };
4362
+ var useLeverageYieldApiEstimateGas = ({
4363
+ params,
4364
+ queryOptions
4365
+ } = {}) => {
4366
+ const { sodax } = useSodaxContext();
4367
+ const body = params?.body;
4368
+ const apiConfig = params?.apiConfig;
4369
+ return useQuery({
4370
+ queryKey: ["leverageYieldApi", "estimateGas", body?.chainKey, body?.tx],
4371
+ queryFn: async () => {
4372
+ if (!body) return void 0;
4373
+ return unwrapResult(await sodax.api.leverageYield.estimateGas(body, apiConfig));
4374
+ },
4375
+ enabled: !!body,
4376
+ retry: retryUnlessAuthFailure,
4377
+ ...queryOptions
4378
+ });
4379
+ };
4380
+ var useLeverageYieldApiPartnerFee = ({
4381
+ params,
4382
+ queryOptions
4383
+ } = {}) => {
4384
+ const { sodax } = useSodaxContext();
4385
+ const amount = params?.amount;
4386
+ const apiConfig = params?.apiConfig;
4387
+ return useQuery({
4388
+ queryKey: ["leverageYieldApi", "partnerFee", amount],
4389
+ queryFn: async () => {
4390
+ if (!amount) return void 0;
4391
+ return unwrapResult(await sodax.api.leverageYield.getPartnerFee({ amount }, apiConfig));
4392
+ },
4393
+ enabled: !!amount && amount.length > 0,
4394
+ retry: retryUnlessAuthFailure,
4395
+ ...queryOptions
4396
+ });
4397
+ };
4398
+ var useLeverageYieldApiSolverFee = ({
4399
+ params,
4400
+ queryOptions
4401
+ } = {}) => {
4402
+ const { sodax } = useSodaxContext();
4403
+ const amount = params?.amount;
4404
+ const apiConfig = params?.apiConfig;
4405
+ return useQuery({
4406
+ queryKey: ["leverageYieldApi", "solverFee", amount],
4407
+ queryFn: async () => {
4408
+ if (!amount) return void 0;
4409
+ return unwrapResult(await sodax.api.leverageYield.getSolverFee({ amount }, apiConfig));
4410
+ },
4411
+ enabled: !!amount && amount.length > 0,
4412
+ retry: retryUnlessAuthFailure,
4413
+ ...queryOptions
4414
+ });
4415
+ };
4416
+
4417
+ // src/hooks/leverageYieldApi/useLeverageYieldApiSubmitTx.ts
4418
+ var useLeverageYieldApiSubmitTx = ({
4419
+ mutationOptions
4420
+ } = {}) => {
4421
+ const { sodax } = useSodaxContext();
4422
+ return useSafeMutation({
4423
+ mutationKey: ["leverageYieldApi", "submitTx"],
4424
+ retry: retryUnlessAuthFailure,
4425
+ ...mutationOptions,
4426
+ mutationFn: async ({ request, apiConfig }) => unwrapResult(await sodax.api.leverageYield.submitTx(request, apiConfig))
4427
+ });
4428
+ };
4429
+ var useLeverageYieldApiSubmitTxStatus = ({
4430
+ params,
4431
+ queryOptions
4432
+ } = {}) => {
4433
+ const { sodax } = useSodaxContext();
4434
+ const txHash = params?.txHash;
4435
+ const srcChainKey = params?.srcChainKey;
4436
+ const apiConfig = params?.apiConfig;
4437
+ return useQuery({
4438
+ queryKey: ["leverageYieldApi", "submitTx", "status", txHash, srcChainKey],
4439
+ queryFn: async () => {
4440
+ if (!txHash || !srcChainKey) return void 0;
4441
+ return unwrapResult(await sodax.api.leverageYield.getSubmitTxStatus({ txHash, srcChainKey }, apiConfig));
4442
+ },
4443
+ enabled: !!txHash && txHash.length > 0 && !!srcChainKey,
4444
+ retry: retryUnlessAuthFailure,
4445
+ refetchInterval: (query) => {
4446
+ if (isAuthFailure(query.state.error)) return false;
4447
+ const data = query.state.data?.data;
4448
+ if (data?.status === "solved" || data?.status === "failed" || data?.abandonedAt) return false;
4449
+ return 1e3;
4450
+ },
4451
+ ...queryOptions
4452
+ });
4453
+ };
3790
4454
  function getSponsorConfigQueryOptions({ sodax }) {
3791
4455
  return {
3792
4456
  queryKey: ["sponsoring", "sponsorConfig"],
@@ -3863,4 +4527,4 @@ function createSodaxQueryClient({
3863
4527
  });
3864
4528
  }
3865
4529
 
3866
- export { SodaxProvider, clearRadfiSession, createDecreaseLiquidityParamsProps, createDepositParamsProps, createSodaxQueryClient, createSupplyLiquidityParamsProps, createWithdrawParamsProps, getLeverageYieldQuoteQueryOptions, getSponsorConfigQueryOptions, getStellarAccountActiveQueryOptions, getStellarAccountStatusQueryOptions, getStellarTrustlineCheckQueryOptions, getSwapQuoteQueryOptions, getXBalancesQueryOptions, isTerminalSwapIntentStatus, isUserRejectedError, loadRadfiSession, resolveNearStorageGate, resolveStellarGate, retryUnlessAuthFailure, runApprovalPlan, saveRadfiSession, toResult, unwrapResult, useAToken, useATokensBalances, useActivateStellarAccount, useApproveToken, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOrderbook, useBackendUserIntents, useBitcoinBalance, useBitcoinTradingSetup, useBorrow, useBridge, useBridgeAllowance, useBridgeApiAllowance, useBridgeApiApprove, useBridgeApiApproveAndBroadcast, useBridgeApiBridgeableAmount, useBridgeApiCreateBridgeIntent, useBridgeApiFee, useBridgeApiIsBridgeable, useBridgeApiSubmitTx, useBridgeApiSubmitTxStatus, useBridgeApiTokens, useBridgeApiTokensByChain, useBridgeApprove, useCancelLimitOrder, useCancelSwap, useCancelUnstake, useClaim, useClaimRewards, useConvertedAssets, useCreateDecreaseLiquidityParams, useCreateDepositParams, useCreateLimitOrder, useCreateSupplyLiquidityParams, useCreateWithdrawParams, useDecreaseLiquidity, useDeriveUserWalletAddress, useDetailedStatus, useDexAllowance, useDexApprove, useDexDeposit, useDexWithdraw, useEnsureRadfiAccessToken, useEstablishTrustline, useEstimateGas, useExpiredUtxos, useFeeClaimSwap, useFeeClaimWithdraw, useFetchAssetsBalances, useFundTradingWallet, useGetAutoSwapPreferences, useGetBridgeableAmount, useGetBridgeableTokens, useGetIntentDetails, useGetUserHubWalletAddress, useGetUserIntent, useHubAssetBalances, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useIsTokenApproved, useLeverageYieldDeposit, useLeverageYieldEffectiveApr, useLeverageYieldNotifySolver, useLeverageYieldPosition, useLeverageYieldPreviewRedeem, useLeverageYieldQuote, useLeverageYieldShareBalances, useLeverageYieldTotalAssets, useLeverageYieldVaultSwap, useLeverageYieldWithdraw, useLiquidityAmounts, useMMAllowance, useMMApprove, useMigrateBaln, useMigrateIcxToSoda, useMigratebnUSD, useMigrationAllowance, useMigrationApprove, useNearStorageCheck, useNearStorageGate, usePartnerCancelIntent, usePoolBalances, usePoolData, usePools, usePositionInfo, useQuote, useRadfiAuth, useRadfiSession, useRadfiWithdraw, useRegisterNearStorage, useRenewUtxos, useRepay, useRequestTrustline, useReservesData, useReservesHumanized, useReservesList, useReservesUsdFormat, useRevertMigrateSodaToIcx, useSafeMutation, useSetSwapPreference, useSodaxContext, useSponsorConfig, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarAccountActive, useStellarAccountStatus, useStellarGate, useStellarTrustlineCheck, useSupply, useSupplyLiquidity, useSwap, useSwapAllowance, useSwapApprove, useSwapsApiAllowance, useSwapsApiApprove, useSwapsApiApproveAndBroadcast, useSwapsApiCancelIntent, useSwapsApiCreateIntent, useSwapsApiCreateLimitOrder, useSwapsApiDeadline, useSwapsApiEstimateGas, useSwapsApiFilledIntent, useSwapsApiIntent, useSwapsApiIntentExtraData, useSwapsApiIntentHash, useSwapsApiIntentPacket, useSwapsApiPartnerFee, useSwapsApiQuote, useSwapsApiSolverFee, useSwapsApiStatus, useSwapsApiSubmitIntent, useSwapsApiSubmitTx, useSwapsApiSubmitTxStatus, useSwapsApiTokens, useSwapsApiTokensByChain, useTradingWallet, useTradingWalletBalance, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserFormattedSummary, useUserReservesData, useWithdraw, useWithdrawHubAsset, useXBalances };
4530
+ export { SodaxProvider, clearRadfiSession, createDecreaseLiquidityParamsProps, createDepositParamsProps, createSodaxQueryClient, createSupplyLiquidityParamsProps, createWithdrawParamsProps, getBalancesQueryOptions, getLeverageYieldQuoteQueryOptions, getSponsorConfigQueryOptions, getStellarAccountActiveQueryOptions, getStellarAccountStatusQueryOptions, getStellarTrustlineCheckQueryOptions, getSwapQuoteQueryOptions, getXBalancesQueryOptions, invalidateBalances, isTerminalSwapIntentStatus, isUserRejectedError, loadRadfiSession, resolveNearStorageGate, resolveStellarGate, retryUnlessAuthFailure, runApprovalPlan, saveRadfiSession, toResult, unwrapResult, useAToken, useATokensBalances, useActivateStellarAccount, useApproveToken, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOracleCandles, useBackendOracleMarkets, useBackendOrderbook, useBackendUserIntents, useBalances, useBitcoinBalance, useBitcoinTradingSetup, useBorrow, useBridge, useBridgeAllowance, useBridgeApiAllowance, useBridgeApiApprove, useBridgeApiApproveAndBroadcast, useBridgeApiBridgeableAmount, useBridgeApiCreateBridgeIntent, useBridgeApiFee, useBridgeApiIsBridgeable, useBridgeApiSubmitTx, useBridgeApiSubmitTxStatus, useBridgeApiTokens, useBridgeApiTokensByChain, useBridgeApprove, useCancelLimitOrder, useCancelSwap, useCancelUnstake, useClaim, useClaimRewards, useConvertedAssets, useCreateDecreaseLiquidityParams, useCreateDepositParams, useCreateLimitOrder, useCreateSupplyLiquidityParams, useCreateWithdrawParams, useDecreaseLiquidity, useDeriveUserWalletAddress, useDetailedStatus, useDexAllowance, useDexApprove, useDexDeposit, useDexWithdraw, useEnsureRadfiAccessToken, useEstablishTrustline, useEstimateGas, useExpiredUtxos, useFeeClaimSwap, useFeeClaimWithdraw, useFetchAssetsBalances, useFundTradingWallet, useGetAutoSwapPreferences, useGetBridgeableAmount, useGetBridgeableTokens, useGetIntentDetails, useGetUserHubWalletAddress, useGetUserIntent, useHubAssetBalances, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useIsTokenApproved, useLeverageYieldApiAllowance, useLeverageYieldApiApprove, useLeverageYieldApiApproveAndBroadcast, useLeverageYieldApiApr, useLeverageYieldApiAsset, useLeverageYieldApiCancelIntent, useLeverageYieldApiCreateDepositIntent, useLeverageYieldApiCreateWithdrawIntent, useLeverageYieldApiDeadline, useLeverageYieldApiDepositQuote, useLeverageYieldApiEffectiveApr, useLeverageYieldApiEstimateGas, useLeverageYieldApiFilledIntent, useLeverageYieldApiIntent, useLeverageYieldApiIntentExtraData, useLeverageYieldApiIntentHash, useLeverageYieldApiIntentPacket, useLeverageYieldApiLsdApr, useLeverageYieldApiMaxWithdraw, useLeverageYieldApiPartnerFee, useLeverageYieldApiPosition, useLeverageYieldApiPreviewDeposit, useLeverageYieldApiPreviewRedeem, useLeverageYieldApiPreviewWithdraw, useLeverageYieldApiShareBalance, useLeverageYieldApiSolverFee, useLeverageYieldApiStatus, useLeverageYieldApiSubmitIntent, useLeverageYieldApiSubmitTx, useLeverageYieldApiSubmitTxStatus, useLeverageYieldApiTotalAssets, useLeverageYieldApiVault, useLeverageYieldApiVaults, useLeverageYieldApiWithdrawQuote, useLeverageYieldDeposit, useLeverageYieldEffectiveApr, useLeverageYieldNotifySolver, useLeverageYieldPosition, useLeverageYieldPreviewRedeem, useLeverageYieldQuote, useLeverageYieldShareBalances, useLeverageYieldTotalAssets, useLeverageYieldVaultSwap, useLeverageYieldWithdraw, useLiquidityAmounts, useMMAllowance, useMMApprove, useMigrateBaln, useMigrateIcxToSoda, useMigratebnUSD, useMigrationAllowance, useMigrationApprove, useNearStorageCheck, useNearStorageGate, usePartnerCancelIntent, usePoolBalances, usePoolData, usePools, usePositionInfo, useQuote, useRadfiAuth, useRadfiSession, useRadfiWithdraw, useRegisterNearStorage, useRenewUtxos, useRepay, useRequestTrustline, useReservesData, useReservesHumanized, useReservesList, useReservesUsdFormat, useRevertMigrateSodaToIcx, useSafeMutation, useSetSwapPreference, useSodaxContext, useSponsorConfig, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarAccountActive, useStellarAccountStatus, useStellarGate, useStellarTrustlineCheck, useSupply, useSupplyLiquidity, useSwap, useSwapAllowance, useSwapApprove, useSwapsApiAllowance, useSwapsApiApprove, useSwapsApiApproveAndBroadcast, useSwapsApiCancelIntent, useSwapsApiCreateIntent, useSwapsApiCreateLimitOrder, useSwapsApiDeadline, useSwapsApiEstimateGas, useSwapsApiFilledIntent, useSwapsApiIntent, useSwapsApiIntentExtraData, useSwapsApiIntentHash, useSwapsApiIntentPacket, useSwapsApiPartnerFee, useSwapsApiQuote, useSwapsApiSolverFee, useSwapsApiStatus, useSwapsApiSubmitIntent, useSwapsApiSubmitTx, useSwapsApiSubmitTxStatus, useSwapsApiTokens, useSwapsApiTokensByChain, useTradingWallet, useTradingWalletBalance, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserFormattedSummary, useUserReservesData, useWithdraw, useWithdrawHubAsset, useXBalances };