@sodax/dapp-kit 2.3.0 → 2.4.0-rc.2
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.
- package/README.md +10 -2
- package/dist/index.d.ts +182 -31
- package/dist/index.mjs +297 -25
- package/package.json +10 -5
- package/src/hooks/_mutationContract.test.ts +1 -0
- package/src/hooks/bridge/getBridgeDetailedStatusRefetchInterval.test.ts +28 -3
- package/src/hooks/bridge/getBridgeDetailedStatusRefetchInterval.ts +17 -8
- package/src/hooks/bridge/useBridge.ts +6 -0
- package/src/hooks/bridge/useBridgeDetailedStatus.test.ts +56 -1
- package/src/hooks/bridge/useBridgeDetailedStatus.ts +26 -9
- package/src/hooks/bridge/useBridgeWithApproval.test.ts +24 -1
- package/src/hooks/bridge/useBridgeWithApproval.ts +6 -0
- package/src/hooks/dex/useDexDeposit.ts +6 -0
- package/src/hooks/dex/useDexWithdraw.ts +12 -5
- package/src/hooks/mm/useBorrow.ts +15 -4
- package/src/hooks/mm/useRepay.ts +6 -0
- package/src/hooks/mm/useSupply.ts +6 -0
- package/src/hooks/mm/useWithdraw.ts +12 -5
- package/src/hooks/recovery/useWithdrawHubAsset.ts +12 -5
- package/src/hooks/shared/index.ts +4 -0
- package/src/hooks/shared/notFoundStreak.ts +5 -0
- package/src/hooks/shared/retryBeforeSubmission.ts +26 -0
- package/src/hooks/shared/useBalances.test.ts +10 -0
- package/src/hooks/shared/useBalances.ts +17 -4
- package/src/hooks/shared/useEstablishXrpTrustline.test.ts +113 -0
- package/src/hooks/shared/useEstablishXrpTrustline.ts +65 -0
- package/src/hooks/shared/useSafeMutation.retry.test.ts +47 -0
- package/src/hooks/shared/useSafeMutation.ts +8 -1
- package/src/hooks/shared/useXrpDestinationCheck.ts +75 -0
- package/src/hooks/shared/useXrpGate.test.ts +118 -0
- package/src/hooks/shared/useXrpGate.ts +81 -0
- package/src/hooks/shared/useXrpTrustlineReserveCheck.ts +45 -0
- package/src/hooks/swap/useCreateLimitOrder.ts +8 -0
- package/src/hooks/swap/useSwap.ts +6 -0
- package/src/hooks/swap/useSwapLifecycle.test.ts +73 -1
- package/src/hooks/swap/useSwapLifecycle.ts +29 -5
- package/src/hooks/swap/useSwapWithApproval.test.ts +24 -1
- package/src/hooks/swap/useSwapWithApproval.ts +6 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/swapLifecycle.test.ts +35 -0
- package/src/utils/swapLifecycle.ts +29 -5
- package/src/utils/xrpGate.test.ts +112 -0
- package/src/utils/xrpGate.ts +72 -0
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isSodaxError, isAuthFailure, ChainKeys, STELLAR_TRUSTLINE_MIN_XLM_STROOPS, RadfiApiError, normalizePsbtToBase64, summarizeSwapStatus, isEvmChainKeyType, resolveApprovalStrategy, isEvmSpokeOnlyChainKeyType, sendApprovalBatch, DEFAULT_RELAY_TX_TIMEOUT, isAtomicBatchRefusal, SodaxError, ATOMIC_BATCH_REFUSED, getEvmViemChain, DETAILED_STATUS_NOT_DELIVERED, ClService, SPONSOR_CONFIG_TTL_MS, Sodax, SolverIntentStatusCode, isApprovalSupportedChainKeyType, isHubChainKeyType, isStellarChainKeyType
|
|
1
|
+
import { isSodaxError, isAuthFailure, ChainKeys, STELLAR_TRUSTLINE_MIN_XLM_STROOPS, RadfiApiError, normalizePsbtToBase64, SOLVED_PAYOUT_HEADROOM_FACTOR, summarizeSwapStatus, isEvmChainKeyType, resolveApprovalStrategy, isEvmSpokeOnlyChainKeyType, sendApprovalBatch, DEFAULT_RELAY_TX_TIMEOUT, isAtomicBatchRefusal, SodaxError, ATOMIC_BATCH_REFUSED, getEvmViemChain, DETAILED_STATUS_NOT_DELIVERED, ClService, SPONSOR_CONFIG_TTL_MS, Sodax, isIndeterminateOutcomeError, ATOMIC_BATCH_UNCONFIRMED, SolverIntentStatusCode, isApprovalSupportedChainKeyType, isHubChainKeyType, isStellarChainKeyType } from '@sodax/sdk';
|
|
2
2
|
export * from '@sodax/sdk';
|
|
3
|
-
import { useMutation, useQuery,
|
|
3
|
+
import { useQueryClient, useMutation, useQuery, useIsFetching, useQueries, QueryClient, MutationCache } from '@tanstack/react-query';
|
|
4
4
|
import { createContext, useCallback, useContext, useRef, useState, useEffect, useMemo } from 'react';
|
|
5
5
|
import { isAddress, erc20Abi, parseUnits } from 'viem';
|
|
6
6
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -22,6 +22,22 @@ function unwrapResult(result) {
|
|
|
22
22
|
}
|
|
23
23
|
return result.value;
|
|
24
24
|
}
|
|
25
|
+
function retryBeforeSubmission(retry) {
|
|
26
|
+
return (failureCount, error) => {
|
|
27
|
+
if (isIndeterminateOutcomeError(error)) return false;
|
|
28
|
+
if (isSodaxError(error)) {
|
|
29
|
+
const { srcTxHash, hubTxHash, dstTxHash, trackingId, recovery, batchId, reason } = error.context ?? {};
|
|
30
|
+
if (srcTxHash || hubTxHash || dstTxHash || trackingId || recovery || batchId || reason === ATOMIC_BATCH_UNCONFIRMED) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (typeof retry === "function") return retry(failureCount, error);
|
|
35
|
+
if (typeof retry === "number") return failureCount < retry;
|
|
36
|
+
return retry === true;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// src/hooks/shared/useSafeMutation.ts
|
|
25
41
|
async function toResult(promise) {
|
|
26
42
|
try {
|
|
27
43
|
const value = await promise;
|
|
@@ -31,7 +47,12 @@ async function toResult(promise) {
|
|
|
31
47
|
}
|
|
32
48
|
}
|
|
33
49
|
function useSafeMutation(options) {
|
|
34
|
-
const
|
|
50
|
+
const queryClient = useQueryClient();
|
|
51
|
+
const { retry } = queryClient.defaultMutationOptions(options);
|
|
52
|
+
const mutation = useMutation({
|
|
53
|
+
...options,
|
|
54
|
+
retry: retryBeforeSubmission(retry)
|
|
55
|
+
});
|
|
35
56
|
const { mutateAsync } = mutation;
|
|
36
57
|
const mutateAsyncSafe = useCallback(
|
|
37
58
|
(vars, opts) => toResult(mutateAsync(vars, opts)),
|
|
@@ -390,6 +411,171 @@ function useStellarGate({
|
|
|
390
411
|
requestTrustline
|
|
391
412
|
};
|
|
392
413
|
}
|
|
414
|
+
function getXrpDestinationCheckQueryOptions({
|
|
415
|
+
sodax,
|
|
416
|
+
chainId,
|
|
417
|
+
token,
|
|
418
|
+
address,
|
|
419
|
+
amount,
|
|
420
|
+
maxAmount
|
|
421
|
+
}) {
|
|
422
|
+
return {
|
|
423
|
+
queryKey: [
|
|
424
|
+
"shared",
|
|
425
|
+
"xrpDestinationCheck",
|
|
426
|
+
chainId,
|
|
427
|
+
token,
|
|
428
|
+
address,
|
|
429
|
+
amount?.toString(),
|
|
430
|
+
maxAmount?.toString()
|
|
431
|
+
],
|
|
432
|
+
queryFn: async () => {
|
|
433
|
+
if (!address || !token || amount === void 0) throw new Error("address, token and amount are required");
|
|
434
|
+
return sodax.spoke.xrp.checkDestination({ address, token, amount, maxAmount });
|
|
435
|
+
},
|
|
436
|
+
enabled: chainId === ChainKeys.XRP_MAINNET && !!address && !!token && amount !== void 0
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
function useXrpDestinationCheck({
|
|
440
|
+
params,
|
|
441
|
+
queryOptions
|
|
442
|
+
} = {}) {
|
|
443
|
+
const { sodax } = useSodaxContext();
|
|
444
|
+
return useQuery({
|
|
445
|
+
...getXrpDestinationCheckQueryOptions({
|
|
446
|
+
sodax,
|
|
447
|
+
chainId: params?.chainId,
|
|
448
|
+
token: params?.token,
|
|
449
|
+
address: params?.address,
|
|
450
|
+
amount: params?.amount,
|
|
451
|
+
maxAmount: params?.maxAmount
|
|
452
|
+
}),
|
|
453
|
+
...queryOptions
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
function getXrpTrustlineReserveCheckQueryOptions({
|
|
457
|
+
sodax,
|
|
458
|
+
token,
|
|
459
|
+
address
|
|
460
|
+
}) {
|
|
461
|
+
return {
|
|
462
|
+
queryKey: ["shared", "xrpTrustlineReserveCheck", token, address],
|
|
463
|
+
queryFn: async () => {
|
|
464
|
+
if (!address || !token) throw new Error("address and token are required");
|
|
465
|
+
return sodax.spoke.xrp.canAffordTrustline({ address, token });
|
|
466
|
+
},
|
|
467
|
+
enabled: !!address && !!token
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
function useXrpTrustlineReserveCheck({
|
|
471
|
+
params,
|
|
472
|
+
queryOptions
|
|
473
|
+
} = {}) {
|
|
474
|
+
const { sodax } = useSodaxContext();
|
|
475
|
+
return useQuery({
|
|
476
|
+
...getXrpTrustlineReserveCheckQueryOptions({ sodax, token: params?.token, address: params?.address }),
|
|
477
|
+
...queryOptions
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
function useEstablishXrpTrustline({
|
|
481
|
+
mutationOptions
|
|
482
|
+
} = {}) {
|
|
483
|
+
const { sodax } = useSodaxContext();
|
|
484
|
+
const queryClient = useQueryClient();
|
|
485
|
+
return useSafeMutation({
|
|
486
|
+
mutationKey: ["shared", "establishXrpTrustline"],
|
|
487
|
+
...mutationOptions,
|
|
488
|
+
// Each TrustSet costs a fee, so one that may have been sent is never signed again automatically.
|
|
489
|
+
retry: retryBeforeSubmission(
|
|
490
|
+
mutationOptions?.retry ?? queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ["shared", "establishXrpTrustline"])?.retry ?? queryClient.getDefaultOptions?.().mutations?.retry
|
|
491
|
+
),
|
|
492
|
+
mutationFn: async ({ token, address, walletProvider }) => {
|
|
493
|
+
const srcAddress = await walletProvider.getWalletAddress();
|
|
494
|
+
if (address !== void 0 && address !== srcAddress) {
|
|
495
|
+
throw new Error(
|
|
496
|
+
`The connected XRPL account ${srcAddress} is not ${address}, which needs the trustline \u2014 connect ${address} to add it`
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
return unwrapResult(await sodax.spoke.xrp.requestTrustline({ srcAddress, token, walletProvider }));
|
|
500
|
+
},
|
|
501
|
+
onSuccess: async (data, vars, ctx) => {
|
|
502
|
+
const address = vars.address ?? await vars.walletProvider.getWalletAddress().catch(() => void 0);
|
|
503
|
+
queryClient.invalidateQueries({
|
|
504
|
+
queryKey: address ? ["shared", "xrpDestinationCheck", ChainKeys.XRP_MAINNET, vars.token, address] : ["shared", "xrpDestinationCheck"]
|
|
505
|
+
});
|
|
506
|
+
queryClient.invalidateQueries({ queryKey: ["shared", "xrpTrustlineReserveCheck"] });
|
|
507
|
+
invalidateBalances(queryClient, ChainKeys.XRP_MAINNET);
|
|
508
|
+
await mutationOptions?.onSuccess?.(data, vars, ctx);
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
var NOT_XRP_ISSUED_TOKEN = {
|
|
513
|
+
isXrpIssuedToken: false,
|
|
514
|
+
needsTrustline: false,
|
|
515
|
+
needsFunding: false,
|
|
516
|
+
blockedReason: void 0,
|
|
517
|
+
checkFailed: false,
|
|
518
|
+
blocksAction: false
|
|
519
|
+
};
|
|
520
|
+
function unresolved2(check) {
|
|
521
|
+
return check.isLoading || check.data === void 0;
|
|
522
|
+
}
|
|
523
|
+
function resolveXrpGate(chainKey, inputs) {
|
|
524
|
+
const { readinessCheck, reserveCheck, requiresTrustline } = inputs;
|
|
525
|
+
if (chainKey !== ChainKeys.XRP_MAINNET || !requiresTrustline) return NOT_XRP_ISSUED_TOKEN;
|
|
526
|
+
const base = { ...NOT_XRP_ISSUED_TOKEN, isXrpIssuedToken: true };
|
|
527
|
+
if (readinessCheck.isError) return { ...base, checkFailed: true, blocksAction: true };
|
|
528
|
+
const readiness = readinessCheck.data;
|
|
529
|
+
if (readinessCheck.isLoading || readiness === void 0) return { ...base, blocksAction: true };
|
|
530
|
+
if (readiness.ready) return base;
|
|
531
|
+
if (readiness.reason !== "no_trustline" && readiness.reason !== "trustline_limit") {
|
|
532
|
+
return { ...base, blockedReason: readiness.reason, blocksAction: true };
|
|
533
|
+
}
|
|
534
|
+
if (reserveCheck.isError) return { ...base, checkFailed: true, blocksAction: true };
|
|
535
|
+
if (unresolved2(reserveCheck)) return { ...base, blocksAction: true };
|
|
536
|
+
if (reserveCheck.data !== true) return { ...base, needsFunding: true, blocksAction: true };
|
|
537
|
+
return { ...base, needsTrustline: true, blocksAction: true };
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// src/hooks/shared/useXrpGate.ts
|
|
541
|
+
function useXrpGate({
|
|
542
|
+
dstChainKey,
|
|
543
|
+
token,
|
|
544
|
+
address,
|
|
545
|
+
amount,
|
|
546
|
+
maxAmount,
|
|
547
|
+
walletProvider
|
|
548
|
+
}) {
|
|
549
|
+
const { sodax } = useSodaxContext();
|
|
550
|
+
const isXrpDestination = dstChainKey === ChainKeys.XRP_MAINNET;
|
|
551
|
+
const requiresTrustline = isXrpDestination && !!token && sodax.spoke.xrp.requiresTrustline(token);
|
|
552
|
+
const xrpWalletProvider = walletProvider?.chainType === "XRP" ? walletProvider : void 0;
|
|
553
|
+
const readinessCheck = useXrpDestinationCheck({
|
|
554
|
+
params: { chainId: requiresTrustline ? dstChainKey : void 0, token, address, amount, maxAmount }
|
|
555
|
+
});
|
|
556
|
+
const trustlineReason = readinessCheck.data?.ready === false && (readinessCheck.data.reason === "no_trustline" || readinessCheck.data.reason === "trustline_limit");
|
|
557
|
+
const reserveCheck = useXrpTrustlineReserveCheck({
|
|
558
|
+
params: { token: trustlineReason ? token : void 0, address: trustlineReason ? address : void 0 }
|
|
559
|
+
});
|
|
560
|
+
const state = resolveXrpGate(dstChainKey, { readinessCheck, reserveCheck, requiresTrustline });
|
|
561
|
+
const { mutateAsyncSafe: establishTrustline, isPending: isRequestingTrustline } = useEstablishXrpTrustline();
|
|
562
|
+
const requestTrustline = async () => {
|
|
563
|
+
if (!xrpWalletProvider || !token || !address) return void 0;
|
|
564
|
+
return establishTrustline({ token, address, walletProvider: xrpWalletProvider });
|
|
565
|
+
};
|
|
566
|
+
const retry = () => {
|
|
567
|
+
void readinessCheck.refetch();
|
|
568
|
+
if (trustlineReason) void reserveCheck.refetch();
|
|
569
|
+
};
|
|
570
|
+
return {
|
|
571
|
+
...state,
|
|
572
|
+
isChecking: readinessCheck.isLoading || reserveCheck.isLoading,
|
|
573
|
+
error: readinessCheck.error ?? reserveCheck.error ?? void 0,
|
|
574
|
+
retry,
|
|
575
|
+
isRequestingTrustline,
|
|
576
|
+
requestTrustline
|
|
577
|
+
};
|
|
578
|
+
}
|
|
393
579
|
var SESSION_KEY = (address) => `radfi_session_${address}`;
|
|
394
580
|
function saveRadfiSession(address, session) {
|
|
395
581
|
try {
|
|
@@ -518,14 +704,24 @@ function useXBalances({
|
|
|
518
704
|
});
|
|
519
705
|
}
|
|
520
706
|
var REFETCH_INTERVAL_MS2 = 5e3;
|
|
521
|
-
function getBalancesQueryOptions(sodax, { chainKey, tokens, address }) {
|
|
707
|
+
function getBalancesQueryOptions(sodax, { chainKey, tokens, address, accountAddress }) {
|
|
708
|
+
const tonAccount = chainKey === ChainKeys.TON_MAINNET && accountAddress ? { accountAddress } : void 0;
|
|
522
709
|
return {
|
|
523
710
|
// Pair symbol + address: readable in devtools, unique on-chain (symbol alone can collide —
|
|
524
711
|
// e.g. scam tokens copying a legitimate ticker).
|
|
525
|
-
queryKey: [
|
|
712
|
+
queryKey: [
|
|
713
|
+
"shared",
|
|
714
|
+
"balances",
|
|
715
|
+
chainKey,
|
|
716
|
+
tokens.map((t) => [t.symbol, t.address]),
|
|
717
|
+
address,
|
|
718
|
+
...tonAccount ? [tonAccount.accountAddress] : []
|
|
719
|
+
],
|
|
526
720
|
queryFn: async () => {
|
|
527
721
|
if (!chainKey || !address) return {};
|
|
528
|
-
return unwrapResult(
|
|
722
|
+
return unwrapResult(
|
|
723
|
+
await sodax.spoke.getWalletBalances({ srcChainKey: chainKey, srcAddress: address, tokens, ...tonAccount })
|
|
724
|
+
);
|
|
529
725
|
},
|
|
530
726
|
enabled: !!chainKey && !!address && tokens.length > 0,
|
|
531
727
|
refetchInterval: REFETCH_INTERVAL_MS2
|
|
@@ -540,7 +736,8 @@ function useBalances({ params, queryOptions } = {}) {
|
|
|
540
736
|
...getBalancesQueryOptions(sodax, {
|
|
541
737
|
chainKey: params?.chainKey,
|
|
542
738
|
tokens: params?.tokens ?? [],
|
|
543
|
-
address: params?.address
|
|
739
|
+
address: params?.address,
|
|
740
|
+
accountAddress: params?.accountAddress
|
|
544
741
|
}),
|
|
545
742
|
...queryOptions
|
|
546
743
|
});
|
|
@@ -814,6 +1011,9 @@ function useBorrow({
|
|
|
814
1011
|
return useSafeMutation({
|
|
815
1012
|
mutationKey: ["mm", "borrow"],
|
|
816
1013
|
...mutationOptions,
|
|
1014
|
+
retry: retryBeforeSubmission(
|
|
1015
|
+
mutationOptions?.retry ?? queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ["mm", "borrow"])?.retry ?? queryClient.getDefaultOptions?.().mutations?.retry
|
|
1016
|
+
),
|
|
817
1017
|
mutationFn: async (vars) => unwrapResult(await sodax.moneyMarket.borrow({ ...vars, raw: false })),
|
|
818
1018
|
onSuccess: async (data, vars, ctx) => {
|
|
819
1019
|
const { params } = vars;
|
|
@@ -835,6 +1035,9 @@ function useRepay({
|
|
|
835
1035
|
return useSafeMutation({
|
|
836
1036
|
mutationKey: ["mm", "repay"],
|
|
837
1037
|
...mutationOptions,
|
|
1038
|
+
retry: retryBeforeSubmission(
|
|
1039
|
+
mutationOptions?.retry ?? queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ["mm", "repay"])?.retry ?? queryClient.getDefaultOptions?.().mutations?.retry
|
|
1040
|
+
),
|
|
838
1041
|
mutationFn: async (vars) => unwrapResult(await sodax.moneyMarket.repay({ ...vars, raw: false })),
|
|
839
1042
|
onSuccess: async (data, vars, ctx) => {
|
|
840
1043
|
const { params } = vars;
|
|
@@ -857,6 +1060,9 @@ function useSupply({
|
|
|
857
1060
|
return useSafeMutation({
|
|
858
1061
|
mutationKey: ["mm", "supply"],
|
|
859
1062
|
...mutationOptions,
|
|
1063
|
+
retry: retryBeforeSubmission(
|
|
1064
|
+
mutationOptions?.retry ?? queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ["mm", "supply"])?.retry ?? queryClient.getDefaultOptions?.().mutations?.retry
|
|
1065
|
+
),
|
|
860
1066
|
mutationFn: async (vars) => unwrapResult(await sodax.moneyMarket.supply({ ...vars, raw: false })),
|
|
861
1067
|
onSuccess: async (data, vars, ctx) => {
|
|
862
1068
|
const { params } = vars;
|
|
@@ -879,6 +1085,9 @@ function useWithdraw({
|
|
|
879
1085
|
return useSafeMutation({
|
|
880
1086
|
mutationKey: ["mm", "withdraw"],
|
|
881
1087
|
...mutationOptions,
|
|
1088
|
+
retry: retryBeforeSubmission(
|
|
1089
|
+
mutationOptions?.retry ?? queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ["mm", "withdraw"])?.retry ?? queryClient.getDefaultOptions?.().mutations?.retry
|
|
1090
|
+
),
|
|
882
1091
|
mutationFn: async (vars) => unwrapResult(await sodax.moneyMarket.withdraw({ ...vars, raw: false })),
|
|
883
1092
|
onSuccess: async (data, vars, ctx) => {
|
|
884
1093
|
const { params } = vars;
|
|
@@ -1144,6 +1353,9 @@ function useSwap({
|
|
|
1144
1353
|
return useSafeMutation({
|
|
1145
1354
|
mutationKey: ["swap"],
|
|
1146
1355
|
...mutationOptions,
|
|
1356
|
+
retry: retryBeforeSubmission(
|
|
1357
|
+
mutationOptions?.retry ?? queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ["swap"])?.retry ?? queryClient.getDefaultOptions?.().mutations?.retry
|
|
1358
|
+
),
|
|
1147
1359
|
mutationFn: async (vars) => unwrapResult(await sodax.swaps.swap({ ...vars, raw: false })),
|
|
1148
1360
|
onSuccess: async (data, vars, ctx) => {
|
|
1149
1361
|
invalidateBalances(queryClient, vars.params.srcChainKey, vars.params.dstChainKey);
|
|
@@ -1155,6 +1367,7 @@ function useSwap({
|
|
|
1155
1367
|
// src/hooks/shared/notFoundStreak.ts
|
|
1156
1368
|
var STATUS_POLL_MS = 3e3;
|
|
1157
1369
|
var MAX_NOT_FOUND_POLLS = 40;
|
|
1370
|
+
var MAX_MPC_RELAY_NOT_FOUND_POLLS = 100;
|
|
1158
1371
|
var INITIAL_NOT_FOUND_STREAK = {
|
|
1159
1372
|
pollKey: void 0,
|
|
1160
1373
|
seenUpdates: 0,
|
|
@@ -1352,6 +1565,9 @@ function useSwapWithApproval({
|
|
|
1352
1565
|
return useSafeMutation({
|
|
1353
1566
|
mutationKey: ["swap", "swapWithApproval"],
|
|
1354
1567
|
...mutationOptions,
|
|
1568
|
+
retry: retryBeforeSubmission(
|
|
1569
|
+
mutationOptions?.retry ?? queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ["swap", "swapWithApproval"])?.retry ?? queryClient.getDefaultOptions?.().mutations?.retry
|
|
1570
|
+
),
|
|
1355
1571
|
mutationFn: async (vars) => unwrapResult(await sodax.swaps.swapWithApproval({ ...vars, raw: false })),
|
|
1356
1572
|
onSuccess: async (data, vars, ctx) => {
|
|
1357
1573
|
invalidateBalances(queryClient, vars.params.srcChainKey, vars.params.dstChainKey);
|
|
@@ -1369,7 +1585,7 @@ function toSwapAttempt(mutation, intentParams) {
|
|
|
1369
1585
|
const attempted = mutation.variables?.params;
|
|
1370
1586
|
if (mutation.status === "idle" || !attempted) return { phase: "none" };
|
|
1371
1587
|
const attempt = toFinishedAttempt(mutation, attempted);
|
|
1372
|
-
const mayStillLand = attempt.phase === "unconfirmed" || attempt.phase === "broadcast" && attempt.error !== void 0;
|
|
1588
|
+
const mayStillLand = attempt.phase === "unconfirmed" || attempt.phase === "recovering" || attempt.phase === "broadcast" && attempt.error !== void 0;
|
|
1373
1589
|
if (mayStillLand || intentParams && isSameIntent(attempted, intentParams)) return attempt;
|
|
1374
1590
|
return { phase: "none" };
|
|
1375
1591
|
}
|
|
@@ -1383,6 +1599,9 @@ function toFinishedAttempt(mutation, attempted) {
|
|
|
1383
1599
|
if (typeof context?.srcTxHash === "string") {
|
|
1384
1600
|
return { phase: "broadcast", srcChainKey: attempted.srcChainKey, srcTxHash: context.srcTxHash, error };
|
|
1385
1601
|
}
|
|
1602
|
+
if (context?.recovery !== void 0) {
|
|
1603
|
+
return { phase: "recovering", srcChainKey: attempted.srcChainKey, recovery: context.recovery, error };
|
|
1604
|
+
}
|
|
1386
1605
|
if (context?.reason === ATOMIC_BATCH_UNCONFIRMED && typeof context.batchId === "string") {
|
|
1387
1606
|
return typeof context.callCount === "number" ? { phase: "unconfirmed", batchId: context.batchId, callCount: context.callCount, error } : { phase: "unconfirmed", batchId: context.batchId, error };
|
|
1388
1607
|
}
|
|
@@ -1400,6 +1619,10 @@ function resolveSwapLifecycle(inputs) {
|
|
|
1400
1619
|
const error = attempt.error ?? inputs.statusError;
|
|
1401
1620
|
return error ? { kind: "pending", srcChainKey, srcTxHash, error } : { kind: "pending", srcChainKey, srcTxHash };
|
|
1402
1621
|
}
|
|
1622
|
+
if (attempt.phase === "recovering") {
|
|
1623
|
+
const { srcChainKey, recovery, error } = attempt;
|
|
1624
|
+
return { kind: "pending", srcChainKey, recovery, error };
|
|
1625
|
+
}
|
|
1403
1626
|
if (attempt.phase === "unconfirmed") {
|
|
1404
1627
|
const { batchId, callCount, error } = attempt;
|
|
1405
1628
|
return callCount === void 0 ? { kind: "unconfirmed", batchId, error } : { kind: "unconfirmed", batchId, callCount, error };
|
|
@@ -1408,19 +1631,25 @@ function resolveSwapLifecycle(inputs) {
|
|
|
1408
1631
|
if (!inputs.hasInputs) return { kind: "idle" };
|
|
1409
1632
|
const reason = setupReason(inputs);
|
|
1410
1633
|
if (reason) return inputs.setupBusy ? { kind: "checking" } : { kind: "needsSetup", reason };
|
|
1411
|
-
if (inputs.stellar.blocksAction || inputs.nearStorage.blocksAction)
|
|
1634
|
+
if (inputs.stellar.blocksAction || inputs.nearStorage.blocksAction || inputs.xrp.blocksAction) {
|
|
1635
|
+
return { kind: "checking" };
|
|
1636
|
+
}
|
|
1412
1637
|
if (inputs.isWrongChain) return { kind: "needsChainSwitch" };
|
|
1413
1638
|
if (inputs.strategy.error && !inputs.strategy.data) return { kind: "failed", error: inputs.strategy.error };
|
|
1414
1639
|
if (!inputs.strategy.data) return { kind: "checking" };
|
|
1415
1640
|
return { kind: "ready", approvalStrategy: inputs.strategy.data };
|
|
1416
1641
|
}
|
|
1417
|
-
function setupReason({ stellar, nearStorage, externalBlocked }) {
|
|
1642
|
+
function setupReason({ stellar, nearStorage, xrp, externalBlocked }) {
|
|
1418
1643
|
if (stellar.needsActivation) return "stellarActivation";
|
|
1419
1644
|
if (stellar.needsFunding) return "stellarFunding";
|
|
1420
1645
|
if (stellar.needsTrustline) return "stellarTrustline";
|
|
1421
1646
|
if (stellar.checkFailed) return "stellarCheckFailed";
|
|
1422
1647
|
if (nearStorage.needsRegistration) return "nearStorage";
|
|
1423
1648
|
if (nearStorage.checkFailed) return "nearStorageCheckFailed";
|
|
1649
|
+
if (xrp.blockedReason) return "xrpBlocked";
|
|
1650
|
+
if (xrp.needsFunding) return "xrpFunding";
|
|
1651
|
+
if (xrp.needsTrustline) return "xrpTrustline";
|
|
1652
|
+
if (xrp.checkFailed) return "xrpCheckFailed";
|
|
1424
1653
|
if (externalBlocked) return "external";
|
|
1425
1654
|
return void 0;
|
|
1426
1655
|
}
|
|
@@ -1455,7 +1684,16 @@ function useSwapLifecycle({
|
|
|
1455
1684
|
accountId: intentParams?.dstAddress,
|
|
1456
1685
|
walletProvider: dstWalletProvider
|
|
1457
1686
|
});
|
|
1458
|
-
const
|
|
1687
|
+
const xrp = useXrpGate({
|
|
1688
|
+
dstChainKey: intentParams?.dstChainKey,
|
|
1689
|
+
token: intentParams?.outputToken,
|
|
1690
|
+
address: intentParams?.dstAddress,
|
|
1691
|
+
// Sized as the SDK's check before signing sizes it, so the gate never passes a swap the SDK then refuses.
|
|
1692
|
+
amount: intentParams?.minOutputAmount,
|
|
1693
|
+
maxAmount: intentParams && intentParams.minOutputAmount * SOLVED_PAYOUT_HEADROOM_FACTOR,
|
|
1694
|
+
walletProvider: dstWalletProvider
|
|
1695
|
+
});
|
|
1696
|
+
const fetchingSetupChecks = useIsFetching({ queryKey: ["sponsoring", "stellarAccountStatus"] }) + useIsFetching({ queryKey: ["shared", "stellarTrustlineCheck"] }) + useIsFetching({ queryKey: ["shared", "nearStorageCheck"] }) + useIsFetching({ queryKey: ["shared", "xrpDestinationCheck"] }) + useIsFetching({ queryKey: ["shared", "xrpTrustlineReserveCheck"] });
|
|
1459
1697
|
const attempt = toSwapAttempt(swap, intentParams);
|
|
1460
1698
|
const broadcast = attempt.phase === "broadcast" ? attempt : void 0;
|
|
1461
1699
|
const status = useDetailedStatus({
|
|
@@ -1468,8 +1706,9 @@ function useSwapLifecycle({
|
|
|
1468
1706
|
hasInputs: !!intentParams && !!srcWalletProvider,
|
|
1469
1707
|
stellar,
|
|
1470
1708
|
nearStorage,
|
|
1709
|
+
xrp,
|
|
1471
1710
|
externalBlocked,
|
|
1472
|
-
setupBusy: stellar.isActivating || stellar.isRequestingTrustline || nearStorage.isRegistering || fetchingSetupChecks > 0,
|
|
1711
|
+
setupBusy: stellar.isActivating || stellar.isRequestingTrustline || nearStorage.isRegistering || xrp.isRequestingTrustline || fetchingSetupChecks > 0,
|
|
1473
1712
|
isWrongChain: chainSwitch?.isWrongChain ?? false,
|
|
1474
1713
|
strategy: { data: approvalStrategy.data, error: approvalStrategy.error }
|
|
1475
1714
|
});
|
|
@@ -1489,6 +1728,8 @@ function useSwapLifecycle({
|
|
|
1489
1728
|
if (state.reason === "nearStorage") return nearStorage.registerStorage();
|
|
1490
1729
|
if (state.reason === "stellarCheckFailed") stellar.retry();
|
|
1491
1730
|
if (state.reason === "nearStorageCheckFailed") nearStorage.retry();
|
|
1731
|
+
if (state.reason === "xrpTrustline") return xrp.requestTrustline();
|
|
1732
|
+
if (state.reason === "xrpCheckFailed") xrp.retry();
|
|
1492
1733
|
return void 0;
|
|
1493
1734
|
case "ready":
|
|
1494
1735
|
if (!intentParams || !srcWalletProvider) return void 0;
|
|
@@ -1534,7 +1775,8 @@ function useSwapLifecycle({
|
|
|
1534
1775
|
swap,
|
|
1535
1776
|
status,
|
|
1536
1777
|
stellar,
|
|
1537
|
-
nearStorage
|
|
1778
|
+
nearStorage,
|
|
1779
|
+
xrp
|
|
1538
1780
|
};
|
|
1539
1781
|
}
|
|
1540
1782
|
|
|
@@ -1549,15 +1791,17 @@ function useCancelSwap({
|
|
|
1549
1791
|
mutationFn: async ({ srcChainKey, walletProvider, intent }) => unwrapResult(await sodax.swaps.cancelIntent({ params: { srcChainKey, intent }, walletProvider }))
|
|
1550
1792
|
});
|
|
1551
1793
|
}
|
|
1552
|
-
|
|
1553
|
-
// src/hooks/swap/useCreateLimitOrder.ts
|
|
1554
1794
|
function useCreateLimitOrder({
|
|
1555
1795
|
mutationOptions
|
|
1556
1796
|
} = {}) {
|
|
1557
1797
|
const { sodax } = useSodaxContext();
|
|
1798
|
+
const queryClient = useQueryClient();
|
|
1558
1799
|
return useSafeMutation({
|
|
1559
1800
|
mutationKey: ["swap", "limitOrder", "create"],
|
|
1560
1801
|
...mutationOptions,
|
|
1802
|
+
retry: retryBeforeSubmission(
|
|
1803
|
+
mutationOptions?.retry ?? queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ["swap", "limitOrder", "create"])?.retry ?? queryClient.getDefaultOptions?.().mutations?.retry
|
|
1804
|
+
),
|
|
1561
1805
|
mutationFn: async (vars) => unwrapResult(await sodax.swaps.createLimitOrder({ ...vars, raw: false }))
|
|
1562
1806
|
});
|
|
1563
1807
|
}
|
|
@@ -2374,14 +2618,20 @@ var useSwapsApiSubmitTxStatus = ({
|
|
|
2374
2618
|
function isBridgeNotDelivered(data) {
|
|
2375
2619
|
return data !== void 0 && !data.ok && data.error?.context?.reason === DETAILED_STATUS_NOT_DELIVERED;
|
|
2376
2620
|
}
|
|
2621
|
+
function isBridgeMpcRelayRead(data) {
|
|
2622
|
+
return data !== void 0 && !data.ok && data.error?.context?.mpcRelay === true;
|
|
2623
|
+
}
|
|
2377
2624
|
function getBridgeDetailedStatusRefetchInterval(data, consecutiveNotFound) {
|
|
2378
2625
|
if (data?.ok) {
|
|
2379
|
-
if (data.value.source
|
|
2626
|
+
if (data.value.source !== "backend") return false;
|
|
2380
2627
|
const { status, abandonedAt } = data.value.data;
|
|
2381
2628
|
return status === "executed" || status === "failed" || abandonedAt ? false : STATUS_POLL_MS;
|
|
2382
2629
|
}
|
|
2383
|
-
if (data && !data.ok
|
|
2384
|
-
|
|
2630
|
+
if (data && !data.ok) {
|
|
2631
|
+
if (isAuthFailure(data.error)) return false;
|
|
2632
|
+
const budget = isBridgeMpcRelayRead(data) ? MAX_MPC_RELAY_NOT_FOUND_POLLS : MAX_NOT_FOUND_POLLS;
|
|
2633
|
+
if (isBridgeNotDelivered(data) && consecutiveNotFound >= budget) return false;
|
|
2634
|
+
}
|
|
2385
2635
|
return STATUS_POLL_MS;
|
|
2386
2636
|
}
|
|
2387
2637
|
function useBridge({
|
|
@@ -2392,6 +2642,9 @@ function useBridge({
|
|
|
2392
2642
|
return useSafeMutation({
|
|
2393
2643
|
mutationKey: ["bridge"],
|
|
2394
2644
|
...mutationOptions,
|
|
2645
|
+
retry: retryBeforeSubmission(
|
|
2646
|
+
mutationOptions?.retry ?? queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ["bridge"])?.retry ?? queryClient.getDefaultOptions?.().mutations?.retry
|
|
2647
|
+
),
|
|
2395
2648
|
mutationFn: async (vars) => unwrapResult(await sodax.bridge.bridge({ ...vars, raw: false })),
|
|
2396
2649
|
onSuccess: async (data, vars, ctx) => {
|
|
2397
2650
|
invalidateBalances(queryClient, vars.params.srcChainKey, vars.params.dstChainKey);
|
|
@@ -2399,6 +2652,10 @@ function useBridge({
|
|
|
2399
2652
|
}
|
|
2400
2653
|
});
|
|
2401
2654
|
}
|
|
2655
|
+
function onwardHubTxHash(data) {
|
|
2656
|
+
const hubTxHash = data && !data.ok ? data.error.context?.hubTxHash : void 0;
|
|
2657
|
+
return typeof hubTxHash === "string" ? hubTxHash : void 0;
|
|
2658
|
+
}
|
|
2402
2659
|
var useBridgeDetailedStatus = ({
|
|
2403
2660
|
params,
|
|
2404
2661
|
queryOptions
|
|
@@ -2406,24 +2663,27 @@ var useBridgeDetailedStatus = ({
|
|
|
2406
2663
|
const { sodax } = useSodaxContext();
|
|
2407
2664
|
const srcChainKey = params?.srcChainKey;
|
|
2408
2665
|
const srcTxHash = params?.srcTxHash;
|
|
2666
|
+
const dstChainKey = params?.dstChainKey;
|
|
2409
2667
|
const apiConfig = params?.apiConfig;
|
|
2410
|
-
const pollKey = srcChainKey && srcTxHash ? `${srcChainKey}:${srcTxHash}` : void 0;
|
|
2668
|
+
const pollKey = srcChainKey && srcTxHash ? `${srcChainKey}:${srcTxHash}:${dstChainKey ?? ""}` : void 0;
|
|
2411
2669
|
const notFoundStreakRef = useRef({ ...INITIAL_NOT_FOUND_STREAK });
|
|
2412
2670
|
return useQuery({
|
|
2413
|
-
queryKey: ["bridge", "detailedStatus", srcChainKey, srcTxHash],
|
|
2671
|
+
queryKey: ["bridge", "detailedStatus", srcChainKey, srcTxHash, ...dstChainKey ? [dstChainKey] : []],
|
|
2414
2672
|
queryFn: async () => {
|
|
2415
2673
|
if (!srcChainKey || !srcTxHash) return void 0;
|
|
2416
|
-
return sodax.bridge.getDetailedStatus({ srcChainKey, srcTxHash }, apiConfig);
|
|
2674
|
+
return sodax.bridge.getDetailedStatus({ srcChainKey, srcTxHash, dstChainKey }, apiConfig);
|
|
2417
2675
|
},
|
|
2418
2676
|
enabled: !!srcChainKey && !!srcTxHash,
|
|
2419
2677
|
refetchInterval: (query) => {
|
|
2678
|
+
const { data } = query.state;
|
|
2679
|
+
const leg = [onwardHubTxHash(data), isBridgeMpcRelayRead(data) ? "mpcRelay" : void 0].filter(Boolean);
|
|
2420
2680
|
notFoundStreakRef.current = advanceNotFoundStreak(
|
|
2421
2681
|
notFoundStreakRef.current,
|
|
2422
|
-
pollKey,
|
|
2423
|
-
isBridgeNotDelivered(
|
|
2682
|
+
pollKey && [pollKey, ...leg].join(":"),
|
|
2683
|
+
isBridgeNotDelivered(data),
|
|
2424
2684
|
query.state.dataUpdateCount
|
|
2425
2685
|
);
|
|
2426
|
-
return getBridgeDetailedStatusRefetchInterval(
|
|
2686
|
+
return getBridgeDetailedStatusRefetchInterval(data, notFoundStreakRef.current.consecutiveNotFound);
|
|
2427
2687
|
},
|
|
2428
2688
|
...queryOptions
|
|
2429
2689
|
});
|
|
@@ -2514,6 +2774,9 @@ function useBridgeWithApproval({
|
|
|
2514
2774
|
return useSafeMutation({
|
|
2515
2775
|
mutationKey: ["bridge", "bridgeWithApproval"],
|
|
2516
2776
|
...mutationOptions,
|
|
2777
|
+
retry: retryBeforeSubmission(
|
|
2778
|
+
mutationOptions?.retry ?? queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ["bridge", "bridgeWithApproval"])?.retry ?? queryClient.getDefaultOptions?.().mutations?.retry
|
|
2779
|
+
),
|
|
2517
2780
|
mutationFn: async (vars) => unwrapResult(await sodax.bridge.bridgeWithApproval({ ...vars, raw: false })),
|
|
2518
2781
|
onSuccess: async (data, vars, ctx) => {
|
|
2519
2782
|
invalidateBalances(queryClient, vars.params.srcChainKey, vars.params.dstChainKey);
|
|
@@ -3407,6 +3670,9 @@ function useWithdrawHubAsset({
|
|
|
3407
3670
|
return useSafeMutation({
|
|
3408
3671
|
mutationKey: ["recovery", "withdrawHubAsset"],
|
|
3409
3672
|
...mutationOptions,
|
|
3673
|
+
retry: retryBeforeSubmission(
|
|
3674
|
+
mutationOptions?.retry ?? queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ["recovery", "withdrawHubAsset"])?.retry ?? queryClient.getDefaultOptions?.().mutations?.retry
|
|
3675
|
+
),
|
|
3410
3676
|
mutationFn: async (vars) => unwrapResult(await sodax.recovery.withdrawHubAsset({ ...vars, raw: false })),
|
|
3411
3677
|
onSuccess: async (data, vars, ctx) => {
|
|
3412
3678
|
const { params } = vars;
|
|
@@ -3632,6 +3898,9 @@ function useDexDeposit({
|
|
|
3632
3898
|
return useSafeMutation({
|
|
3633
3899
|
mutationKey: ["dex", "deposit"],
|
|
3634
3900
|
...mutationOptions,
|
|
3901
|
+
retry: retryBeforeSubmission(
|
|
3902
|
+
mutationOptions?.retry ?? queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ["dex", "deposit"])?.retry ?? queryClient.getDefaultOptions?.().mutations?.retry
|
|
3903
|
+
),
|
|
3635
3904
|
mutationFn: async (vars) => unwrapResult(await sodax.dex.assetService.deposit({ ...vars, raw: false })),
|
|
3636
3905
|
onSuccess: async (data, vars, ctx) => {
|
|
3637
3906
|
const { params } = vars;
|
|
@@ -3652,6 +3921,9 @@ function useDexWithdraw({
|
|
|
3652
3921
|
return useSafeMutation({
|
|
3653
3922
|
mutationKey: ["dex", "withdraw"],
|
|
3654
3923
|
...mutationOptions,
|
|
3924
|
+
retry: retryBeforeSubmission(
|
|
3925
|
+
mutationOptions?.retry ?? queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ["dex", "withdraw"])?.retry ?? queryClient.getDefaultOptions?.().mutations?.retry
|
|
3926
|
+
),
|
|
3655
3927
|
mutationFn: async (vars) => unwrapResult(await sodax.dex.assetService.withdraw({ ...vars, raw: false })),
|
|
3656
3928
|
onSuccess: async (data, vars, ctx) => {
|
|
3657
3929
|
const { params } = vars;
|
|
@@ -5249,4 +5521,4 @@ function createSodaxQueryClient({
|
|
|
5249
5521
|
});
|
|
5250
5522
|
}
|
|
5251
5523
|
|
|
5252
|
-
export { SodaxProvider, clearRadfiSession, createDecreaseLiquidityParamsProps, createDepositParamsProps, createSodaxQueryClient, createSupplyLiquidityParamsProps, createWithdrawParamsProps, getBalancesQueryOptions, getBridgeDetailedStatusRefetchInterval, getLeverageYieldQuoteQueryOptions, getSponsorConfigQueryOptions, getStellarAccountActiveQueryOptions, getStellarAccountStatusQueryOptions, getStellarTrustlineCheckQueryOptions, getSwapQuoteQueryOptions, getXBalancesQueryOptions, invalidateBalances, isBridgeNotDelivered, isTerminalSwapIntentStatus, isUserRejectedError, loadRadfiSession, resolveNearStorageGate, resolveStellarGate, retryUnlessAuthFailure, runApprovalPlan, saveRadfiSession, toResult, unwrapResult, useAToken, useATokensBalances, useActivateStellarAccount, useApproveLeveragePositionFunding, 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, useBridgeApprovalStrategy, useBridgeApprove, useBridgeDetailedStatus, useBridgeWithApproval, useCancelLimitOrder, useCancelSwap, useCancelUnstake, useClaim, useClaimRewards, useConvertedAssets, useCreateDecreaseLiquidityParams, useCreateDepositParams, useCreateLimitOrder, useCreateSupplyLiquidityParams, useCreateWithdrawParams, useDecreaseLiquidity, useDeriveUserWalletAddress, useDetailedStatus, useDexAllowance, useDexApprove, useDexDeposit, useDexWithdraw, useEModes, useEnsureRadfiAccessToken, useEstablishTrustline, useEstimateGas, useExpiredUtxos, useFeeClaimSwap, useFeeClaimWithdraw, useFetchAssetsBalances, useFundTradingWallet, useGetAutoSwapPreferences, useGetBridgeableAmount, useGetBridgeableTokens, useGetIntentDetails, useGetUserHubWalletAddress, useGetUserIntent, useHubAssetBalances, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useIsTokenApproved, useLeveragePositionAccount, useLeveragePositionCollateral, useLeveragePositionFundingAllowance, useLeveragePositionInfo, useLeveragePositionPayoutAddress, useLeveragePositionPending, useLeveragePositions, useLeveragePositionsForUser, 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, useLeverageYieldApprovalStrategy, useLeverageYieldDeposit, useLeverageYieldDetailedStatus, useLeverageYieldEffectiveApr, useLeverageYieldNotifySolver, useLeverageYieldPosition, useLeverageYieldPreviewRedeem, useLeverageYieldQuote, useLeverageYieldShareBalances, useLeverageYieldTotalAssets, useLeverageYieldVaultSwap, useLeverageYieldVaultSwapWithApproval, useLeverageYieldWithdraw, useLiquidityAmounts, useMMAllowance, useMMApprove, useMigrateBaln, useMigrateIcxToSoda, useMigratebnUSD, useMigrationAllowance, useMigrationApprove, useNearStorageCheck, useNearStorageGate, useOpenLeveragePosition, usePartnerCancelIntent, usePoolBalances, usePoolData, usePools, usePositionInfo, useQuote, useRadfiAuth, useRadfiSession, useRadfiWithdraw, useRegisterNearStorage, useRenewUtxos, useRepay, useRequestTrustline, useReservesData, useReservesHumanized, useReservesList, useReservesUsdFormat, useRevertMigrateSodaToIcx, useRunLeveragePositionOperation, useSafeMutation, useSetSwapPreference, useSodaxContext, useSponsorConfig, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarAccountActive, useStellarAccountStatus, useStellarGate, useStellarTrustlineCheck, useSubmitLeveragePositionIntent, useSupply, useSupplyLiquidity, useSwap, useSwapAllowance, useSwapApprovalStrategy, useSwapApprove, useSwapLifecycle, useSwapWithApproval, useSwapsApiAllowance, useSwapsApiApprove, useSwapsApiApproveAndBroadcast, useSwapsApiBroadcastWithApproval, 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 };
|
|
5524
|
+
export { SodaxProvider, clearRadfiSession, createDecreaseLiquidityParamsProps, createDepositParamsProps, createSodaxQueryClient, createSupplyLiquidityParamsProps, createWithdrawParamsProps, getBalancesQueryOptions, getBridgeDetailedStatusRefetchInterval, getLeverageYieldQuoteQueryOptions, getSponsorConfigQueryOptions, getStellarAccountActiveQueryOptions, getStellarAccountStatusQueryOptions, getStellarTrustlineCheckQueryOptions, getSwapQuoteQueryOptions, getXBalancesQueryOptions, getXrpDestinationCheckQueryOptions, getXrpTrustlineReserveCheckQueryOptions, invalidateBalances, isBridgeMpcRelayRead, isBridgeNotDelivered, isTerminalSwapIntentStatus, isUserRejectedError, loadRadfiSession, resolveNearStorageGate, resolveStellarGate, resolveXrpGate, retryUnlessAuthFailure, runApprovalPlan, saveRadfiSession, toResult, unwrapResult, useAToken, useATokensBalances, useActivateStellarAccount, useApproveLeveragePositionFunding, 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, useBridgeApprovalStrategy, useBridgeApprove, useBridgeDetailedStatus, useBridgeWithApproval, useCancelLimitOrder, useCancelSwap, useCancelUnstake, useClaim, useClaimRewards, useConvertedAssets, useCreateDecreaseLiquidityParams, useCreateDepositParams, useCreateLimitOrder, useCreateSupplyLiquidityParams, useCreateWithdrawParams, useDecreaseLiquidity, useDeriveUserWalletAddress, useDetailedStatus, useDexAllowance, useDexApprove, useDexDeposit, useDexWithdraw, useEModes, useEnsureRadfiAccessToken, useEstablishTrustline, useEstablishXrpTrustline, useEstimateGas, useExpiredUtxos, useFeeClaimSwap, useFeeClaimWithdraw, useFetchAssetsBalances, useFundTradingWallet, useGetAutoSwapPreferences, useGetBridgeableAmount, useGetBridgeableTokens, useGetIntentDetails, useGetUserHubWalletAddress, useGetUserIntent, useHubAssetBalances, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useIsTokenApproved, useLeveragePositionAccount, useLeveragePositionCollateral, useLeveragePositionFundingAllowance, useLeveragePositionInfo, useLeveragePositionPayoutAddress, useLeveragePositionPending, useLeveragePositions, useLeveragePositionsForUser, 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, useLeverageYieldApprovalStrategy, useLeverageYieldDeposit, useLeverageYieldDetailedStatus, useLeverageYieldEffectiveApr, useLeverageYieldNotifySolver, useLeverageYieldPosition, useLeverageYieldPreviewRedeem, useLeverageYieldQuote, useLeverageYieldShareBalances, useLeverageYieldTotalAssets, useLeverageYieldVaultSwap, useLeverageYieldVaultSwapWithApproval, useLeverageYieldWithdraw, useLiquidityAmounts, useMMAllowance, useMMApprove, useMigrateBaln, useMigrateIcxToSoda, useMigratebnUSD, useMigrationAllowance, useMigrationApprove, useNearStorageCheck, useNearStorageGate, useOpenLeveragePosition, usePartnerCancelIntent, usePoolBalances, usePoolData, usePools, usePositionInfo, useQuote, useRadfiAuth, useRadfiSession, useRadfiWithdraw, useRegisterNearStorage, useRenewUtxos, useRepay, useRequestTrustline, useReservesData, useReservesHumanized, useReservesList, useReservesUsdFormat, useRevertMigrateSodaToIcx, useRunLeveragePositionOperation, useSafeMutation, useSetSwapPreference, useSodaxContext, useSponsorConfig, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarAccountActive, useStellarAccountStatus, useStellarGate, useStellarTrustlineCheck, useSubmitLeveragePositionIntent, useSupply, useSupplyLiquidity, useSwap, useSwapAllowance, useSwapApprovalStrategy, useSwapApprove, useSwapLifecycle, useSwapWithApproval, useSwapsApiAllowance, useSwapsApiApprove, useSwapsApiApproveAndBroadcast, useSwapsApiBroadcastWithApproval, 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, useXrpDestinationCheck, useXrpGate, useXrpTrustlineReserveCheck };
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"version": "2.
|
|
8
|
+
"version": "2.4.0-rc.2",
|
|
9
9
|
"description": "React hooks for building dApps on the SODAX cross-chain DeFi platform",
|
|
10
10
|
"keywords": [
|
|
11
11
|
"sodax",
|
|
@@ -13,9 +13,13 @@
|
|
|
13
13
|
"react",
|
|
14
14
|
"react-query",
|
|
15
15
|
"hooks",
|
|
16
|
-
"defi"
|
|
16
|
+
"defi",
|
|
17
|
+
"cross-chain",
|
|
18
|
+
"swap",
|
|
19
|
+
"web3",
|
|
20
|
+
"sdk"
|
|
17
21
|
],
|
|
18
|
-
"homepage": "https://
|
|
22
|
+
"homepage": "https://docs.sodax.com/developers/packages/experience/dapp-kit",
|
|
19
23
|
"bugs": {
|
|
20
24
|
"url": "https://github.com/gosodax/sodax-sdks/issues"
|
|
21
25
|
},
|
|
@@ -30,11 +34,12 @@
|
|
|
30
34
|
],
|
|
31
35
|
"repository": {
|
|
32
36
|
"type": "git",
|
|
33
|
-
"url": "https://github.com/gosodax/sodax-sdks"
|
|
37
|
+
"url": "git+https://github.com/gosodax/sodax-sdks.git",
|
|
38
|
+
"directory": "packages/dapp-kit"
|
|
34
39
|
},
|
|
35
40
|
"dependencies": {
|
|
36
41
|
"viem": "2.29.2",
|
|
37
|
-
"@sodax/sdk": "2.
|
|
42
|
+
"@sodax/sdk": "2.4.0-rc.2"
|
|
38
43
|
},
|
|
39
44
|
"devDependencies": {
|
|
40
45
|
"@arethetypeswrong/cli": "0.17.4",
|
|
@@ -60,6 +60,7 @@ const HOOKS: Array<{ path: string; nativeThrow?: true }> = [
|
|
|
60
60
|
{ path: 'partner/useSetSwapPreference.ts' },
|
|
61
61
|
{ path: 'recovery/useWithdrawHubAsset.ts' },
|
|
62
62
|
{ path: 'shared/useEstablishTrustline.ts', nativeThrow: true },
|
|
63
|
+
{ path: 'shared/useEstablishXrpTrustline.ts' },
|
|
63
64
|
{ path: 'shared/useEstimateGas.ts' },
|
|
64
65
|
{ path: 'shared/useRegisterNearStorage.ts', nativeThrow: true },
|
|
65
66
|
{ path: 'sponsoring/useActivateStellarAccount.ts' },
|