@sodax/dapp-kit 2.2.0-rc.2 → 2.2.0-rc.4

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 (44) hide show
  1. package/dist/index.d.ts +505 -2
  2. package/dist/index.mjs +608 -3
  3. package/package.json +2 -2
  4. package/src/hooks/_apiKeyWire.test.ts +383 -17
  5. package/src/hooks/_mutationContract.test.ts +7 -0
  6. package/src/hooks/index.ts +1 -0
  7. package/src/hooks/leverageYieldApi/index.ts +55 -0
  8. package/src/hooks/leverageYieldApi/useLeverageYieldApiAllowance.ts +50 -0
  9. package/src/hooks/leverageYieldApi/useLeverageYieldApiApprove.ts +37 -0
  10. package/src/hooks/leverageYieldApi/useLeverageYieldApiApproveAndBroadcast.test.ts +176 -0
  11. package/src/hooks/leverageYieldApi/useLeverageYieldApiApproveAndBroadcast.ts +83 -0
  12. package/src/hooks/leverageYieldApi/useLeverageYieldApiApr.ts +41 -0
  13. package/src/hooks/leverageYieldApi/useLeverageYieldApiAsset.ts +41 -0
  14. package/src/hooks/leverageYieldApi/useLeverageYieldApiCancelIntent.ts +37 -0
  15. package/src/hooks/leverageYieldApi/useLeverageYieldApiCreateDepositIntent.ts +37 -0
  16. package/src/hooks/leverageYieldApi/useLeverageYieldApiCreateWithdrawIntent.ts +37 -0
  17. package/src/hooks/leverageYieldApi/useLeverageYieldApiDeadline.ts +38 -0
  18. package/src/hooks/leverageYieldApi/useLeverageYieldApiDepositQuote.ts +57 -0
  19. package/src/hooks/leverageYieldApi/useLeverageYieldApiEffectiveApr.ts +41 -0
  20. package/src/hooks/leverageYieldApi/useLeverageYieldApiEstimateGas.ts +41 -0
  21. package/src/hooks/leverageYieldApi/useLeverageYieldApiFilledIntent.ts +40 -0
  22. package/src/hooks/leverageYieldApi/useLeverageYieldApiIntent.ts +40 -0
  23. package/src/hooks/leverageYieldApi/useLeverageYieldApiIntentExtraData.ts +42 -0
  24. package/src/hooks/leverageYieldApi/useLeverageYieldApiIntentHash.ts +41 -0
  25. package/src/hooks/leverageYieldApi/useLeverageYieldApiIntentPacket.ts +41 -0
  26. package/src/hooks/leverageYieldApi/useLeverageYieldApiLsdApr.ts +41 -0
  27. package/src/hooks/leverageYieldApi/useLeverageYieldApiMaxWithdraw.ts +43 -0
  28. package/src/hooks/leverageYieldApi/useLeverageYieldApiPartnerFee.ts +41 -0
  29. package/src/hooks/leverageYieldApi/useLeverageYieldApiPosition.ts +41 -0
  30. package/src/hooks/leverageYieldApi/useLeverageYieldApiPreviewDeposit.ts +43 -0
  31. package/src/hooks/leverageYieldApi/useLeverageYieldApiPreviewRedeem.ts +43 -0
  32. package/src/hooks/leverageYieldApi/useLeverageYieldApiPreviewWithdraw.ts +43 -0
  33. package/src/hooks/leverageYieldApi/useLeverageYieldApiShareBalance.ts +43 -0
  34. package/src/hooks/leverageYieldApi/useLeverageYieldApiSolverFee.ts +41 -0
  35. package/src/hooks/leverageYieldApi/useLeverageYieldApiStatus.ts +48 -0
  36. package/src/hooks/leverageYieldApi/useLeverageYieldApiSubmitIntent.ts +36 -0
  37. package/src/hooks/leverageYieldApi/useLeverageYieldApiSubmitTx.ts +37 -0
  38. package/src/hooks/leverageYieldApi/useLeverageYieldApiSubmitTxStatus.ts +60 -0
  39. package/src/hooks/leverageYieldApi/useLeverageYieldApiTotalAssets.ts +41 -0
  40. package/src/hooks/leverageYieldApi/useLeverageYieldApiVault.ts +41 -0
  41. package/src/hooks/leverageYieldApi/useLeverageYieldApiVaults.ts +36 -0
  42. package/src/hooks/leverageYieldApi/useLeverageYieldApiWithdrawQuote.ts +56 -0
  43. package/src/hooks/swapsApi/useSwapsApiApproveAndBroadcast.test.ts +5 -1
  44. 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';
@@ -1678,7 +1678,9 @@ function resolveChainSender(srcChainKey, walletProvider, hookName) {
1678
1678
  if (isHubChainKeyType(srcChainKey) || isEvmSpokeOnlyChainKeyType(srcChainKey)) {
1679
1679
  const evm = walletProvider;
1680
1680
  return {
1681
- 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 }),
1682
1684
  confirm: async (hash, step) => {
1683
1685
  const receipt = await evm.waitForTransactionReceipt(hash);
1684
1686
  if (isRevertedEvmReceiptStatus(receipt.status)) {
@@ -3846,6 +3848,609 @@ function useLeverageYieldWithdraw({
3846
3848
  mutationFn: async (vars) => unwrapResult(await sodax.leverageYield.withdraw(vars))
3847
3849
  });
3848
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
+ };
3849
4454
  function getSponsorConfigQueryOptions({ sodax }) {
3850
4455
  return {
3851
4456
  queryKey: ["sponsoring", "sponsorConfig"],
@@ -3922,4 +4527,4 @@ function createSodaxQueryClient({
3922
4527
  });
3923
4528
  }
3924
4529
 
3925
- 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, 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 };
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "access": "public"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "2.2.0-rc.2",
8
+ "version": "2.2.0-rc.4",
9
9
  "description": "React hooks for building dApps on the SODAX cross-chain DeFi platform",
10
10
  "keywords": [
11
11
  "sodax",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "viem": "2.29.2",
37
- "@sodax/sdk": "2.2.0-rc.2"
37
+ "@sodax/sdk": "2.2.0-rc.4"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@arethetypeswrong/cli": "0.17.4",