@dhedge/trading-widget 4.1.1 → 4.1.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/core-kit/hooks/trading/use-swaps-data-query.d.ts +12 -3
- package/core-kit/hooks/trading/withdraw-v2/init-step/use-fetch-init-withdraw-aave-swap-data.d.ts +1 -1
- package/core-kit/utils/aave.d.ts +2 -1
- package/core-kit/utils/swap-data.d.ts +12 -0
- package/core-kit/utils/transaction.d.ts +2 -2
- package/index.cjs +10 -10
- package/index.js +1956 -1930
- package/package.json +1 -1
|
@@ -2,13 +2,22 @@ import { type UseQueryOptions } from '@tanstack/react-query';
|
|
|
2
2
|
import type { Address } from 'viem';
|
|
3
3
|
import { useGetSwapData } from '../../hooks/state';
|
|
4
4
|
import type { SwapDataRequest, SwapDataResponse } from '../../types';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import type { AssetWithoutFromAddress, SwapsDataMap } from '../../utils/swap-data';
|
|
6
|
+
interface FetchSwapsDataParams {
|
|
7
|
+
assets: AssetWithoutFromAddress[];
|
|
7
8
|
getSwapData: ReturnType<typeof useGetSwapData>;
|
|
8
9
|
signal: AbortSignal;
|
|
9
|
-
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Aave-specific variant: during Aave swaps it is possible to have two entries
|
|
13
|
+
* with the same source asset and the same destination asset but different amounts.
|
|
14
|
+
* To avoid key collisions it includes the amount.
|
|
15
|
+
*/
|
|
16
|
+
export declare const fetchSwapsDataForAave: ({ assets, getSwapData, signal, }: FetchSwapsDataParams) => Promise<SwapsDataMap<string>>;
|
|
17
|
+
export declare const fetchSwapsData: ({ assets, getSwapData, signal, }: FetchSwapsDataParams) => Promise<SwapsDataMap<Address>>;
|
|
10
18
|
export declare const useSwapsDataQuery: (assets: Omit<SwapDataRequest, 'fromAddress'>[], options?: Omit<UseQueryOptions<Record<Address, SwapDataResponse | null>, Error, Record<Address, SwapDataResponse | null>, [
|
|
11
19
|
string,
|
|
12
20
|
Omit<SwapDataRequest, 'fromAddress'>[],
|
|
13
21
|
string[]
|
|
14
22
|
]>, 'queryKey' | 'queryFn'>) => import("@tanstack/react-query/build/legacy/types").UseQueryResult<Record<`0x${string}`, SwapDataResponse | null>, Error>;
|
|
23
|
+
export {};
|
package/core-kit/hooks/trading/withdraw-v2/init-step/use-fetch-init-withdraw-aave-swap-data.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ import type { CalculateSwapDataParamsResponse, PoolConfig } from '../../../../ty
|
|
|
2
2
|
export declare const useFetchInitWithdrawAaveSwapData: ({ chainId, }: Pick<PoolConfig, 'chainId'>) => ({ swapParams, slippage, }: {
|
|
3
3
|
swapParams: CalculateSwapDataParamsResponse | undefined;
|
|
4
4
|
slippage: number;
|
|
5
|
-
}) => Promise<
|
|
5
|
+
}) => Promise<import("../../../../utils/swap-data").SwapsDataMap<string>>;
|
package/core-kit/utils/aave.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { Address, ChainId } from '../types';
|
|
1
|
+
import type { Address, ChainId, SwapDataRequest } from '../types';
|
|
2
2
|
export interface IsLendAndBorrowAssetParams {
|
|
3
3
|
address: Address;
|
|
4
4
|
chainId: ChainId;
|
|
5
5
|
}
|
|
6
6
|
export declare const isAaveLendAndBorrowAsset: ({ address, chainId, }: IsLendAndBorrowAssetParams) => boolean;
|
|
7
|
+
export declare const buildSwapDataKeyForAave: ({ sourceAddress, amount, }: Pick<SwapDataRequest, 'sourceAddress' | 'amount'>) => string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { useGetSwapData } from '../hooks/state';
|
|
2
|
+
import type { SwapDataRequest, SwapDataResponse } from '../types';
|
|
3
|
+
export type AssetWithoutFromAddress = Omit<SwapDataRequest, 'fromAddress'>;
|
|
4
|
+
export type SwapsDataMap<T extends string> = Record<T, SwapDataResponse | null>;
|
|
5
|
+
interface FetchSwapsDataWithKeyParams<K extends string> {
|
|
6
|
+
assets: AssetWithoutFromAddress[];
|
|
7
|
+
getSwapData: ReturnType<typeof useGetSwapData>;
|
|
8
|
+
signal: AbortSignal;
|
|
9
|
+
buildKey: (asset: AssetWithoutFromAddress) => K;
|
|
10
|
+
}
|
|
11
|
+
export declare const fetchSwapsDataWithKey: <K extends string>({ assets, getSwapData, signal, buildKey, }: FetchSwapsDataWithKeyParams<K>) => Promise<SwapsDataMap<K>>;
|
|
12
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Address, Hex } from 'viem';
|
|
2
|
-
import type { useSwapsDataQuery } from '../hooks/trading/use-swaps-data-query';
|
|
2
|
+
import type { fetchSwapsDataForAave, useSwapsDataQuery } from '../hooks/trading/use-swaps-data-query';
|
|
3
3
|
import type { useCompleteWithdrawTrackedAssets } from '../hooks/trading/withdraw-v2/complete-step/use-complete-withdraw-tracked-assets';
|
|
4
4
|
import type { CalculateSwapDataParamsResponse } from '../types';
|
|
5
5
|
/**
|
|
@@ -30,7 +30,7 @@ export declare const buildSwapWithdrawTransactionData: ({ receiveAssetAddress, s
|
|
|
30
30
|
export declare const buildAaveWithdrawAssetTransactionData: ({ assetAddress, swapData, swapParams, slippageToleranceForContractTransaction, }: {
|
|
31
31
|
assetAddress: Address;
|
|
32
32
|
swapParams: CalculateSwapDataParamsResponse | undefined;
|
|
33
|
-
swapData: ReturnType<typeof
|
|
33
|
+
swapData: Awaited<ReturnType<typeof fetchSwapsDataForAave>>;
|
|
34
34
|
slippageToleranceForContractTransaction: bigint;
|
|
35
35
|
}) => {
|
|
36
36
|
supportedAsset: `0x${string}`;
|