@sodax/dapp-kit 0.0.1-rc.30 → 0.0.1-rc.32
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/dist/index.d.mts +109 -20
- package/dist/index.d.ts +109 -20
- package/dist/index.js +225 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +223 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/hooks/index.ts +1 -0
- package/src/hooks/migrate/index.ts +4 -0
- package/src/hooks/migrate/types.ts +15 -0
- package/src/hooks/migrate/useMigrate.tsx +110 -0
- package/src/hooks/migrate/useMigrationAllowance.tsx +79 -0
- package/src/hooks/migrate/useMigrationApprove.tsx +129 -0
- package/src/hooks/mm/useMMAllowance.ts +2 -1
- package/src/hooks/mm/useMMApprove.ts +2 -1
- package/src/hooks/shared/useRequestTrustline.ts +55 -34
package/dist/index.d.mts
CHANGED
|
@@ -83,29 +83,28 @@ declare function useStellarTrustlineCheck<T extends SpokeProvider = SpokeProvide
|
|
|
83
83
|
/**
|
|
84
84
|
* React hook to request a Stellar trustline for a given token and amount.
|
|
85
85
|
*
|
|
86
|
-
* This hook provides a
|
|
86
|
+
* This hook provides a callback function for requesting a trustline on the Stellar network
|
|
87
87
|
* using the provided SpokeProvider. It is intended for use with StellarSpokeProvider
|
|
88
88
|
* and will throw if used with a non-Stellar provider. Upon success, it invalidates
|
|
89
89
|
* the trustline check query to ensure UI reflects the updated trustline state.
|
|
90
90
|
*
|
|
91
91
|
* @template T - The type of SpokeProvider, defaults to SpokeProvider.
|
|
92
92
|
* @param {string | undefined} token - The Stellar asset code or token address for which to request a trustline.
|
|
93
|
-
* @returns {
|
|
94
|
-
*
|
|
95
|
-
* - `
|
|
96
|
-
* - `
|
|
93
|
+
* @returns {Object} An object containing:
|
|
94
|
+
* - `requestTrustline`: Function to trigger the trustline request.
|
|
95
|
+
* - `isLoading`: Whether the request is in progress.
|
|
96
|
+
* - `isRequested`: Whether a trustline has been successfully requested.
|
|
97
97
|
* - `error`: Any error encountered during the request.
|
|
98
|
-
* - `
|
|
99
|
-
* - Other React Query mutation state.
|
|
98
|
+
* - `data`: The transaction result if successful.
|
|
100
99
|
*
|
|
101
100
|
* @example
|
|
102
101
|
* ```tsx
|
|
103
102
|
* import { useRequestTrustline } from '@sodax/dapp-kit';
|
|
104
103
|
*
|
|
105
|
-
* const {
|
|
104
|
+
* const { requestTrustline, isLoading, isRequested, error, data } = useRequestTrustline('USDC-G...TOKEN');
|
|
106
105
|
*
|
|
107
106
|
* // To request a trustline:
|
|
108
|
-
* requestTrustline({
|
|
107
|
+
* await requestTrustline({
|
|
109
108
|
* token: 'USDC-G...TOKEN',
|
|
110
109
|
* amount: 10000000n,
|
|
111
110
|
* spokeProvider: stellarProvider,
|
|
@@ -113,14 +112,20 @@ declare function useStellarTrustlineCheck<T extends SpokeProvider = SpokeProvide
|
|
|
113
112
|
*
|
|
114
113
|
* if (isLoading) return <span>Requesting trustline...</span>;
|
|
115
114
|
* if (error) return <span>Error: {error.message}</span>;
|
|
116
|
-
* if (
|
|
115
|
+
* if (isRequested) return <span>Trustline requested! Tx: {data?.txHash}</span>;
|
|
117
116
|
* ```
|
|
118
117
|
*/
|
|
119
|
-
declare function useRequestTrustline<T extends SpokeProvider = SpokeProvider>(token: string | undefined):
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
declare function useRequestTrustline<T extends SpokeProvider = SpokeProvider>(token: string | undefined): {
|
|
119
|
+
requestTrustline: (params: {
|
|
120
|
+
token: string;
|
|
121
|
+
amount: bigint;
|
|
122
|
+
spokeProvider: T;
|
|
123
|
+
}) => Promise<TxReturnType<StellarSpokeProvider, false>>;
|
|
124
|
+
isLoading: boolean;
|
|
125
|
+
isRequested: boolean;
|
|
126
|
+
error: Error | null;
|
|
127
|
+
data: TxReturnType<StellarSpokeProvider, false> | null;
|
|
128
|
+
};
|
|
124
129
|
|
|
125
130
|
declare function useHubProvider(): EvmHubProvider;
|
|
126
131
|
|
|
@@ -321,7 +326,7 @@ declare function useReservesData(): _tanstack_react_query.UseQueryResult<readonl
|
|
|
321
326
|
*/
|
|
322
327
|
declare function useMMAllowance(token: XToken, amount: string, action: MoneyMarketAction, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
|
|
323
328
|
|
|
324
|
-
interface UseApproveReturn$
|
|
329
|
+
interface UseApproveReturn$2 {
|
|
325
330
|
approve: ({ amount, action }: {
|
|
326
331
|
amount: string;
|
|
327
332
|
action: MoneyMarketAction;
|
|
@@ -343,7 +348,7 @@ interface UseApproveReturn$1 {
|
|
|
343
348
|
* await approve({ amount: "100", action: "supply" });
|
|
344
349
|
* ```
|
|
345
350
|
*/
|
|
346
|
-
declare function useMMApprove(token: XToken, spokeProvider: SpokeProvider | undefined): UseApproveReturn$
|
|
351
|
+
declare function useMMApprove(token: XToken, spokeProvider: SpokeProvider | undefined): UseApproveReturn$2;
|
|
347
352
|
|
|
348
353
|
/**
|
|
349
354
|
* Hook for fetching a quote for an intent-based swap.
|
|
@@ -458,7 +463,7 @@ declare const useStatus: (intent_tx_hash: Hex) => UseQueryResult<Result<SolverIn
|
|
|
458
463
|
*/
|
|
459
464
|
declare function useSwapAllowance(params: CreateIntentParams | undefined, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
|
|
460
465
|
|
|
461
|
-
interface UseApproveReturn {
|
|
466
|
+
interface UseApproveReturn$1 {
|
|
462
467
|
approve: ({ params }: {
|
|
463
468
|
params: CreateIntentParams;
|
|
464
469
|
}) => Promise<boolean>;
|
|
@@ -479,7 +484,7 @@ interface UseApproveReturn {
|
|
|
479
484
|
* await approve({ amount: "100", action: "supply" });
|
|
480
485
|
* ```
|
|
481
486
|
*/
|
|
482
|
-
declare function useSwapApprove(params: CreateIntentParams | undefined, spokeProvider: SpokeProvider | undefined): UseApproveReturn;
|
|
487
|
+
declare function useSwapApprove(params: CreateIntentParams | undefined, spokeProvider: SpokeProvider | undefined): UseApproveReturn$1;
|
|
483
488
|
|
|
484
489
|
type CancelIntentParams = {
|
|
485
490
|
intent: Intent;
|
|
@@ -1412,6 +1417,90 @@ declare function useInstantUnstakeApprove(spokeProvider: SpokeProvider | undefin
|
|
|
1412
1417
|
*/
|
|
1413
1418
|
declare function useInstantUnstakeAllowance(params: Omit<InstantUnstakeParams, 'action'> | undefined, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
|
|
1414
1419
|
|
|
1420
|
+
declare const MIGRATION_MODE_ICX_SODA = "icxsoda";
|
|
1421
|
+
declare const MIGRATION_MODE_BNUSD = "bnusd";
|
|
1422
|
+
type MigrationMode = typeof MIGRATION_MODE_ICX_SODA | typeof MIGRATION_MODE_BNUSD;
|
|
1423
|
+
interface MigrationIntentParams {
|
|
1424
|
+
token: XToken | undefined;
|
|
1425
|
+
amount: string | undefined;
|
|
1426
|
+
sourceAddress: string | undefined;
|
|
1427
|
+
migrationMode?: MigrationMode;
|
|
1428
|
+
toToken?: XToken;
|
|
1429
|
+
destinationAddress?: string;
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
/**
|
|
1433
|
+
* Hook for executing migration operations between chains.
|
|
1434
|
+
*
|
|
1435
|
+
* This hook handles ICX/SODA and bnUSD migrations by accepting a spoke provider
|
|
1436
|
+
* and returning a mutation function that accepts migration parameters.
|
|
1437
|
+
*
|
|
1438
|
+
* @param {SpokeProvider} spokeProvider - The spoke provider to use for the migration
|
|
1439
|
+
* @returns {UseMutationResult} Mutation result object containing migration function and state
|
|
1440
|
+
*
|
|
1441
|
+
* @example
|
|
1442
|
+
* ```typescript
|
|
1443
|
+
* const { mutateAsync: migrate, isPending } = useMigrate(spokeProvider);
|
|
1444
|
+
*
|
|
1445
|
+
* const result = await migrate({
|
|
1446
|
+
* token: { address: "0x...", decimals: 18 },
|
|
1447
|
+
* amount: "100",
|
|
1448
|
+
* migrationMode: MIGRATION_MODE_ICX_SODA,
|
|
1449
|
+
* toToken: { address: "0x...", decimals: 18 },
|
|
1450
|
+
* destinationAddress: "0x..."
|
|
1451
|
+
* });
|
|
1452
|
+
* ```
|
|
1453
|
+
*/
|
|
1454
|
+
declare function useMigrate(spokeProvider: SpokeProvider | undefined): UseMutationResult<{
|
|
1455
|
+
spokeTxHash: string;
|
|
1456
|
+
hubTxHash: `0x${string}`;
|
|
1457
|
+
}, Error, MigrationIntentParams>;
|
|
1458
|
+
|
|
1459
|
+
/**
|
|
1460
|
+
* Hook for checking token allowance for migration operations.
|
|
1461
|
+
*
|
|
1462
|
+
* This hook verifies if the user has approved enough tokens for migration operations.
|
|
1463
|
+
* It handles both ICX/SODA and bnUSD migration allowance checks.
|
|
1464
|
+
*
|
|
1465
|
+
* @param {MigrationIntentParams} params - The parameters for the migration allowance check
|
|
1466
|
+
* @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks
|
|
1467
|
+
*
|
|
1468
|
+
* @returns {UseQueryResult<boolean, Error>} A React Query result containing:
|
|
1469
|
+
* - data: Boolean indicating if allowance is sufficient
|
|
1470
|
+
* - isLoading: Loading state indicator
|
|
1471
|
+
* - error: Any error that occurred during the check
|
|
1472
|
+
*
|
|
1473
|
+
* @example
|
|
1474
|
+
* ```typescript
|
|
1475
|
+
* const { data: hasAllowed, isLoading } = useMigrationAllowance(params, spokeProvider);
|
|
1476
|
+
* ```
|
|
1477
|
+
*/
|
|
1478
|
+
declare function useMigrationAllowance(params: MigrationIntentParams | undefined, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
|
|
1479
|
+
|
|
1480
|
+
interface UseApproveReturn {
|
|
1481
|
+
approve: ({ params }: {
|
|
1482
|
+
params: MigrationIntentParams;
|
|
1483
|
+
}) => Promise<boolean>;
|
|
1484
|
+
isLoading: boolean;
|
|
1485
|
+
error: Error | null;
|
|
1486
|
+
resetError: () => void;
|
|
1487
|
+
isApproved: boolean;
|
|
1488
|
+
}
|
|
1489
|
+
/**
|
|
1490
|
+
* Hook for approving token spending for migration actions
|
|
1491
|
+
* @param params The parameters for the migration approval
|
|
1492
|
+
* @param spokeProvider The spoke provider instance for the chain
|
|
1493
|
+
* @returns Object containing approve function, loading state, error state and reset function
|
|
1494
|
+
* @example
|
|
1495
|
+
* ```tsx
|
|
1496
|
+
* const { approve, isLoading, error } = useMigrationApprove(params, spokeProvider);
|
|
1497
|
+
*
|
|
1498
|
+
* // Approve tokens for migration
|
|
1499
|
+
* await approve({ params });
|
|
1500
|
+
* ```
|
|
1501
|
+
*/
|
|
1502
|
+
declare function useMigrationApprove(params: MigrationIntentParams | undefined, spokeProvider: SpokeProvider | undefined): UseApproveReturn;
|
|
1503
|
+
|
|
1415
1504
|
interface SodaxProviderProps {
|
|
1416
1505
|
children: ReactNode;
|
|
1417
1506
|
testnet?: boolean;
|
|
@@ -1422,4 +1511,4 @@ declare const SodaxProvider: ({ children, testnet, config, rpcConfig }: SodaxPro
|
|
|
1422
1511
|
|
|
1423
1512
|
declare const getSpokeTokenAddressByVault: (spokeChainId: ChainId, vault: string) => string | undefined;
|
|
1424
1513
|
|
|
1425
|
-
export { SodaxProvider, getSpokeTokenAddressByVault, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOrderbook, useBorrow, useBridge, useBridgeAllowance, useBridgeApprove, useCancelSwap, useCancelUnstake, useClaim, useConvertedAssets, useDeriveUserWalletAddress, useEstimateGas, useGetBridgeableAmount, useGetBridgeableTokens, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useMMAllowance, useMMApprove, useQuote, useRepay, useRequestTrustline, useReservesData, useSodaxContext, useSpokeProvider, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarTrustlineCheck, useSupply, useSwap, useSwapAllowance, useSwapApprove, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserReservesData, useWithdraw };
|
|
1514
|
+
export { MIGRATION_MODE_BNUSD, MIGRATION_MODE_ICX_SODA, type MigrationIntentParams, type MigrationMode, SodaxProvider, getSpokeTokenAddressByVault, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOrderbook, useBorrow, useBridge, useBridgeAllowance, useBridgeApprove, useCancelSwap, useCancelUnstake, useClaim, useConvertedAssets, useDeriveUserWalletAddress, useEstimateGas, useGetBridgeableAmount, useGetBridgeableTokens, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useMMAllowance, useMMApprove, useMigrate, useMigrationAllowance, useMigrationApprove, useQuote, useRepay, useRequestTrustline, useReservesData, useSodaxContext, useSpokeProvider, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarTrustlineCheck, useSupply, useSwap, useSwapAllowance, useSwapApprove, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserReservesData, useWithdraw };
|
package/dist/index.d.ts
CHANGED
|
@@ -83,29 +83,28 @@ declare function useStellarTrustlineCheck<T extends SpokeProvider = SpokeProvide
|
|
|
83
83
|
/**
|
|
84
84
|
* React hook to request a Stellar trustline for a given token and amount.
|
|
85
85
|
*
|
|
86
|
-
* This hook provides a
|
|
86
|
+
* This hook provides a callback function for requesting a trustline on the Stellar network
|
|
87
87
|
* using the provided SpokeProvider. It is intended for use with StellarSpokeProvider
|
|
88
88
|
* and will throw if used with a non-Stellar provider. Upon success, it invalidates
|
|
89
89
|
* the trustline check query to ensure UI reflects the updated trustline state.
|
|
90
90
|
*
|
|
91
91
|
* @template T - The type of SpokeProvider, defaults to SpokeProvider.
|
|
92
92
|
* @param {string | undefined} token - The Stellar asset code or token address for which to request a trustline.
|
|
93
|
-
* @returns {
|
|
94
|
-
*
|
|
95
|
-
* - `
|
|
96
|
-
* - `
|
|
93
|
+
* @returns {Object} An object containing:
|
|
94
|
+
* - `requestTrustline`: Function to trigger the trustline request.
|
|
95
|
+
* - `isLoading`: Whether the request is in progress.
|
|
96
|
+
* - `isRequested`: Whether a trustline has been successfully requested.
|
|
97
97
|
* - `error`: Any error encountered during the request.
|
|
98
|
-
* - `
|
|
99
|
-
* - Other React Query mutation state.
|
|
98
|
+
* - `data`: The transaction result if successful.
|
|
100
99
|
*
|
|
101
100
|
* @example
|
|
102
101
|
* ```tsx
|
|
103
102
|
* import { useRequestTrustline } from '@sodax/dapp-kit';
|
|
104
103
|
*
|
|
105
|
-
* const {
|
|
104
|
+
* const { requestTrustline, isLoading, isRequested, error, data } = useRequestTrustline('USDC-G...TOKEN');
|
|
106
105
|
*
|
|
107
106
|
* // To request a trustline:
|
|
108
|
-
* requestTrustline({
|
|
107
|
+
* await requestTrustline({
|
|
109
108
|
* token: 'USDC-G...TOKEN',
|
|
110
109
|
* amount: 10000000n,
|
|
111
110
|
* spokeProvider: stellarProvider,
|
|
@@ -113,14 +112,20 @@ declare function useStellarTrustlineCheck<T extends SpokeProvider = SpokeProvide
|
|
|
113
112
|
*
|
|
114
113
|
* if (isLoading) return <span>Requesting trustline...</span>;
|
|
115
114
|
* if (error) return <span>Error: {error.message}</span>;
|
|
116
|
-
* if (
|
|
115
|
+
* if (isRequested) return <span>Trustline requested! Tx: {data?.txHash}</span>;
|
|
117
116
|
* ```
|
|
118
117
|
*/
|
|
119
|
-
declare function useRequestTrustline<T extends SpokeProvider = SpokeProvider>(token: string | undefined):
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
declare function useRequestTrustline<T extends SpokeProvider = SpokeProvider>(token: string | undefined): {
|
|
119
|
+
requestTrustline: (params: {
|
|
120
|
+
token: string;
|
|
121
|
+
amount: bigint;
|
|
122
|
+
spokeProvider: T;
|
|
123
|
+
}) => Promise<TxReturnType<StellarSpokeProvider, false>>;
|
|
124
|
+
isLoading: boolean;
|
|
125
|
+
isRequested: boolean;
|
|
126
|
+
error: Error | null;
|
|
127
|
+
data: TxReturnType<StellarSpokeProvider, false> | null;
|
|
128
|
+
};
|
|
124
129
|
|
|
125
130
|
declare function useHubProvider(): EvmHubProvider;
|
|
126
131
|
|
|
@@ -321,7 +326,7 @@ declare function useReservesData(): _tanstack_react_query.UseQueryResult<readonl
|
|
|
321
326
|
*/
|
|
322
327
|
declare function useMMAllowance(token: XToken, amount: string, action: MoneyMarketAction, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
|
|
323
328
|
|
|
324
|
-
interface UseApproveReturn$
|
|
329
|
+
interface UseApproveReturn$2 {
|
|
325
330
|
approve: ({ amount, action }: {
|
|
326
331
|
amount: string;
|
|
327
332
|
action: MoneyMarketAction;
|
|
@@ -343,7 +348,7 @@ interface UseApproveReturn$1 {
|
|
|
343
348
|
* await approve({ amount: "100", action: "supply" });
|
|
344
349
|
* ```
|
|
345
350
|
*/
|
|
346
|
-
declare function useMMApprove(token: XToken, spokeProvider: SpokeProvider | undefined): UseApproveReturn$
|
|
351
|
+
declare function useMMApprove(token: XToken, spokeProvider: SpokeProvider | undefined): UseApproveReturn$2;
|
|
347
352
|
|
|
348
353
|
/**
|
|
349
354
|
* Hook for fetching a quote for an intent-based swap.
|
|
@@ -458,7 +463,7 @@ declare const useStatus: (intent_tx_hash: Hex) => UseQueryResult<Result<SolverIn
|
|
|
458
463
|
*/
|
|
459
464
|
declare function useSwapAllowance(params: CreateIntentParams | undefined, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
|
|
460
465
|
|
|
461
|
-
interface UseApproveReturn {
|
|
466
|
+
interface UseApproveReturn$1 {
|
|
462
467
|
approve: ({ params }: {
|
|
463
468
|
params: CreateIntentParams;
|
|
464
469
|
}) => Promise<boolean>;
|
|
@@ -479,7 +484,7 @@ interface UseApproveReturn {
|
|
|
479
484
|
* await approve({ amount: "100", action: "supply" });
|
|
480
485
|
* ```
|
|
481
486
|
*/
|
|
482
|
-
declare function useSwapApprove(params: CreateIntentParams | undefined, spokeProvider: SpokeProvider | undefined): UseApproveReturn;
|
|
487
|
+
declare function useSwapApprove(params: CreateIntentParams | undefined, spokeProvider: SpokeProvider | undefined): UseApproveReturn$1;
|
|
483
488
|
|
|
484
489
|
type CancelIntentParams = {
|
|
485
490
|
intent: Intent;
|
|
@@ -1412,6 +1417,90 @@ declare function useInstantUnstakeApprove(spokeProvider: SpokeProvider | undefin
|
|
|
1412
1417
|
*/
|
|
1413
1418
|
declare function useInstantUnstakeAllowance(params: Omit<InstantUnstakeParams, 'action'> | undefined, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
|
|
1414
1419
|
|
|
1420
|
+
declare const MIGRATION_MODE_ICX_SODA = "icxsoda";
|
|
1421
|
+
declare const MIGRATION_MODE_BNUSD = "bnusd";
|
|
1422
|
+
type MigrationMode = typeof MIGRATION_MODE_ICX_SODA | typeof MIGRATION_MODE_BNUSD;
|
|
1423
|
+
interface MigrationIntentParams {
|
|
1424
|
+
token: XToken | undefined;
|
|
1425
|
+
amount: string | undefined;
|
|
1426
|
+
sourceAddress: string | undefined;
|
|
1427
|
+
migrationMode?: MigrationMode;
|
|
1428
|
+
toToken?: XToken;
|
|
1429
|
+
destinationAddress?: string;
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
/**
|
|
1433
|
+
* Hook for executing migration operations between chains.
|
|
1434
|
+
*
|
|
1435
|
+
* This hook handles ICX/SODA and bnUSD migrations by accepting a spoke provider
|
|
1436
|
+
* and returning a mutation function that accepts migration parameters.
|
|
1437
|
+
*
|
|
1438
|
+
* @param {SpokeProvider} spokeProvider - The spoke provider to use for the migration
|
|
1439
|
+
* @returns {UseMutationResult} Mutation result object containing migration function and state
|
|
1440
|
+
*
|
|
1441
|
+
* @example
|
|
1442
|
+
* ```typescript
|
|
1443
|
+
* const { mutateAsync: migrate, isPending } = useMigrate(spokeProvider);
|
|
1444
|
+
*
|
|
1445
|
+
* const result = await migrate({
|
|
1446
|
+
* token: { address: "0x...", decimals: 18 },
|
|
1447
|
+
* amount: "100",
|
|
1448
|
+
* migrationMode: MIGRATION_MODE_ICX_SODA,
|
|
1449
|
+
* toToken: { address: "0x...", decimals: 18 },
|
|
1450
|
+
* destinationAddress: "0x..."
|
|
1451
|
+
* });
|
|
1452
|
+
* ```
|
|
1453
|
+
*/
|
|
1454
|
+
declare function useMigrate(spokeProvider: SpokeProvider | undefined): UseMutationResult<{
|
|
1455
|
+
spokeTxHash: string;
|
|
1456
|
+
hubTxHash: `0x${string}`;
|
|
1457
|
+
}, Error, MigrationIntentParams>;
|
|
1458
|
+
|
|
1459
|
+
/**
|
|
1460
|
+
* Hook for checking token allowance for migration operations.
|
|
1461
|
+
*
|
|
1462
|
+
* This hook verifies if the user has approved enough tokens for migration operations.
|
|
1463
|
+
* It handles both ICX/SODA and bnUSD migration allowance checks.
|
|
1464
|
+
*
|
|
1465
|
+
* @param {MigrationIntentParams} params - The parameters for the migration allowance check
|
|
1466
|
+
* @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks
|
|
1467
|
+
*
|
|
1468
|
+
* @returns {UseQueryResult<boolean, Error>} A React Query result containing:
|
|
1469
|
+
* - data: Boolean indicating if allowance is sufficient
|
|
1470
|
+
* - isLoading: Loading state indicator
|
|
1471
|
+
* - error: Any error that occurred during the check
|
|
1472
|
+
*
|
|
1473
|
+
* @example
|
|
1474
|
+
* ```typescript
|
|
1475
|
+
* const { data: hasAllowed, isLoading } = useMigrationAllowance(params, spokeProvider);
|
|
1476
|
+
* ```
|
|
1477
|
+
*/
|
|
1478
|
+
declare function useMigrationAllowance(params: MigrationIntentParams | undefined, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
|
|
1479
|
+
|
|
1480
|
+
interface UseApproveReturn {
|
|
1481
|
+
approve: ({ params }: {
|
|
1482
|
+
params: MigrationIntentParams;
|
|
1483
|
+
}) => Promise<boolean>;
|
|
1484
|
+
isLoading: boolean;
|
|
1485
|
+
error: Error | null;
|
|
1486
|
+
resetError: () => void;
|
|
1487
|
+
isApproved: boolean;
|
|
1488
|
+
}
|
|
1489
|
+
/**
|
|
1490
|
+
* Hook for approving token spending for migration actions
|
|
1491
|
+
* @param params The parameters for the migration approval
|
|
1492
|
+
* @param spokeProvider The spoke provider instance for the chain
|
|
1493
|
+
* @returns Object containing approve function, loading state, error state and reset function
|
|
1494
|
+
* @example
|
|
1495
|
+
* ```tsx
|
|
1496
|
+
* const { approve, isLoading, error } = useMigrationApprove(params, spokeProvider);
|
|
1497
|
+
*
|
|
1498
|
+
* // Approve tokens for migration
|
|
1499
|
+
* await approve({ params });
|
|
1500
|
+
* ```
|
|
1501
|
+
*/
|
|
1502
|
+
declare function useMigrationApprove(params: MigrationIntentParams | undefined, spokeProvider: SpokeProvider | undefined): UseApproveReturn;
|
|
1503
|
+
|
|
1415
1504
|
interface SodaxProviderProps {
|
|
1416
1505
|
children: ReactNode;
|
|
1417
1506
|
testnet?: boolean;
|
|
@@ -1422,4 +1511,4 @@ declare const SodaxProvider: ({ children, testnet, config, rpcConfig }: SodaxPro
|
|
|
1422
1511
|
|
|
1423
1512
|
declare const getSpokeTokenAddressByVault: (spokeChainId: ChainId, vault: string) => string | undefined;
|
|
1424
1513
|
|
|
1425
|
-
export { SodaxProvider, getSpokeTokenAddressByVault, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOrderbook, useBorrow, useBridge, useBridgeAllowance, useBridgeApprove, useCancelSwap, useCancelUnstake, useClaim, useConvertedAssets, useDeriveUserWalletAddress, useEstimateGas, useGetBridgeableAmount, useGetBridgeableTokens, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useMMAllowance, useMMApprove, useQuote, useRepay, useRequestTrustline, useReservesData, useSodaxContext, useSpokeProvider, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarTrustlineCheck, useSupply, useSwap, useSwapAllowance, useSwapApprove, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserReservesData, useWithdraw };
|
|
1514
|
+
export { MIGRATION_MODE_BNUSD, MIGRATION_MODE_ICX_SODA, type MigrationIntentParams, type MigrationMode, SodaxProvider, getSpokeTokenAddressByVault, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOrderbook, useBorrow, useBridge, useBridgeAllowance, useBridgeApprove, useCancelSwap, useCancelUnstake, useClaim, useConvertedAssets, useDeriveUserWalletAddress, useEstimateGas, useGetBridgeableAmount, useGetBridgeableTokens, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useMMAllowance, useMMApprove, useMigrate, useMigrationAllowance, useMigrationApprove, useQuote, useRepay, useRequestTrustline, useReservesData, useSodaxContext, useSpokeProvider, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarTrustlineCheck, useSupply, useSwap, useSwapAllowance, useSwapApprove, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserReservesData, useWithdraw };
|