@dhedge/trading-widget 4.6.2 → 5.0.0
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 +17 -18
- package/core-kit/const/storage.d.ts +3 -0
- package/core-kit/hooks/pool/use-pool-fees.d.ts +3 -0
- package/core-kit/hooks/state/action.d.ts +0 -4
- package/core-kit/hooks/state/index.d.ts +1 -1
- package/core-kit/hooks/trading/deposit-v2/deposit-transaction/use-deposit-common.d.ts +1 -1
- package/core-kit/hooks/trading/deposit-v2/index.d.ts +2 -2
- package/core-kit/hooks/trading/deposit-v2/use-get-vault-deposit-transaction-arguments.d.ts +3 -0
- package/core-kit/hooks/trading/index.d.ts +2 -1
- package/core-kit/hooks/trading/withdraw-v2/complete-step/index.d.ts +1 -0
- package/core-kit/hooks/trading/withdraw-v2/complete-step/use-auto-send-complete-withdraw-transaction.d.ts +1 -0
- package/core-kit/hooks/trading/withdraw-v2/init-step/use-fetch-init-withdraw-aave-swap-quotes.d.ts +5 -0
- package/core-kit/hooks/trading/withdraw-v2/init-step/use-fetch-init-withdraw-complex-asset-data.d.ts +8 -4
- package/core-kit/hooks/trading/withdraw-v2/init-step/use-get-init-withdraw-transaction-arguments.d.ts +2 -2
- package/core-kit/types/state.types.d.ts +1 -6
- package/core-kit/utils/aave.d.ts +1 -1
- package/core-kit/utils/complex-withdraw-asset-data.d.ts +22 -0
- package/core-kit/utils/deposit.d.ts +25 -0
- package/core-kit/utils/index.d.ts +1 -0
- package/core-kit/utils/number.d.ts +6 -0
- package/core-kit/utils/swap-data.d.ts +4 -12
- package/core-kit/utils/transaction.d.ts +6 -4
- package/index.cjs +1 -1
- package/index.js +3179 -3058
- package/package.json +1 -1
- package/trading-widget/providers/config-provider/config-provider.types.d.ts +0 -1
- package/core-kit/hooks/trading/deposit-v2/use-vault-deposit-transaction-arguments.d.ts +0 -2
- package/core-kit/hooks/trading/withdraw-v2/init-step/use-fetch-init-withdraw-aave-swap-data.d.ts +0 -5
- package/core-kit/hooks/user/multicall/use-user-multicall.d.ts +0 -1248
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ import { TradingPanelProvider, TradingWidget } from '@dhedge/trading-widget'
|
|
|
28
28
|
|
|
29
29
|
- Setup [Wagmi Provider](https://wagmi.sh/react/api/WagmiProvider) on top level or use existing one in your app
|
|
30
30
|
- Setup [TradingPanelProvider](#tradingpanelprovider)
|
|
31
|
-
#### Providing a `
|
|
31
|
+
#### Providing a `getSwapQuotes` callback is mandatory for depositing with off-chain swaps.
|
|
32
32
|
- Setup [TradingWidget](#tradingwidget)
|
|
33
33
|
|
|
34
34
|
3. Minimum required config
|
|
@@ -54,21 +54,21 @@ Top level provider component. Headless part of trading logic. API handles params
|
|
|
54
54
|
<details>
|
|
55
55
|
<summary><code>actions</code> <code><b>/</b></code> <code>Optional General callbacks to interact with 3rd party services</code></summary>
|
|
56
56
|
|
|
57
|
-
> | name | type
|
|
58
|
-
> | ------------------------------ |
|
|
59
|
-
> | `onUpdateSendTokenInput` | (payload: Partial\<{ address: `Address`; symbol: `string`; value: `string`; decimals: `number`; isLoading?: `boolean` }\>) => void
|
|
60
|
-
> | `onUpdateTradingSettings` | (payload: Partial\<{ slippage: `number \| 'auto'`; minSlippage?: `number` isInfiniteAllowance: `boolean`; isMultiAssetWithdrawalEnabled: `boolean`; isCustomDepositOptionsDisabled?: `boolean`; isMaxSlippageLoading: `boolean` }\>) => void
|
|
61
|
-
> | `onSetTradingType` | (payload: `'deposit' \| 'withdraw'`) => void
|
|
62
|
-
> | `onUpdateTradingModal` | (payload: Partial\<{ isOpen: `boolean`; status: `'Success' \| 'None' \| 'Mining' \| 'Wallet'` }\>) => void
|
|
63
|
-
> | `onUpdateTransactions` | (payload: AddTransaction \| UpdateTransaction \| RemoveTransaction) => void
|
|
64
|
-
> | `onTradingSettleError` | (error: `Error`) => void
|
|
65
|
-
> | `onTransactionError` | (error: `Error`, action: `TransactionAction` \| `undefined`, chainId?: `ChainId`, txHash?: `Address`) => void
|
|
66
|
-
> | `onTransactionSuccess` | (data: `WaitForTransactionReceiptReturnType`, action: `TransactionAction` \| `undefined`, link?: `string`) => void
|
|
67
|
-
> | `onTransactionEstimationError` | (error: `EstimationError`, address: `Address`, chainId?: `ChainId`, account?: `Address`) => void
|
|
68
|
-
> | `onTokenSelector` | (payload: { isOpen: `boolean`; entity: `'token' \| 'pool'` }) => void
|
|
69
|
-
> | `onLog` | (eventName: `string`, payload?: `Record<string, unknown>`) => void
|
|
70
|
-
> | `onSimulateTransaction` | (payload: { chainId: `ChainId`; from: `Address`: to: `Address`; input: `string`; gas: `number`; value?: `string` }) => Promise<{ link?: `string`; simulation: { status: `boolean`; error_message: `string` } } \| null>
|
|
71
|
-
> | `
|
|
57
|
+
> | name | type | default value | description |
|
|
58
|
+
> | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | --------------------------------------------------------------------------------- |
|
|
59
|
+
> | `onUpdateSendTokenInput` | (payload: Partial\<{ address: `Address`; symbol: `string`; value: `string`; decimals: `number`; isLoading?: `boolean` }\>) => void | undefined | triggers on send token change |
|
|
60
|
+
> | `onUpdateTradingSettings` | (payload: Partial\<{ slippage: `number \| 'auto'`; minSlippage?: `number` isInfiniteAllowance: `boolean`; isMultiAssetWithdrawalEnabled: `boolean`; isCustomDepositOptionsDisabled?: `boolean`; isMaxSlippageLoading: `boolean` }\>) => void | undefined | triggers on trading settings change |
|
|
61
|
+
> | `onSetTradingType` | (payload: `'deposit' \| 'withdraw'`) => void | undefined | triggers on trading type change |
|
|
62
|
+
> | `onUpdateTradingModal` | (payload: Partial\<{ isOpen: `boolean`; status: `'Success' \| 'None' \| 'Mining' \| 'Wallet'` }\>) => void | undefined | triggers on trading modal change |
|
|
63
|
+
> | `onUpdateTransactions` | (payload: AddTransaction \| UpdateTransaction \| RemoveTransaction) => void | undefined | triggers on transaction action change |
|
|
64
|
+
> | `onTradingSettleError` | (error: `Error`) => void | undefined | triggers on trading settle error |
|
|
65
|
+
> | `onTransactionError` | (error: `Error`, action: `TransactionAction` \| `undefined`, chainId?: `ChainId`, txHash?: `Address`) => void | undefined | triggers on transaction error |
|
|
66
|
+
> | `onTransactionSuccess` | (data: `WaitForTransactionReceiptReturnType`, action: `TransactionAction` \| `undefined`, link?: `string`) => void | undefined | triggers on transaction success |
|
|
67
|
+
> | `onTransactionEstimationError` | (error: `EstimationError`, address: `Address`, chainId?: `ChainId`, account?: `Address`) => void | undefined | triggers on transaction estimation error |
|
|
68
|
+
> | `onTokenSelector` | (payload: { isOpen: `boolean`; entity: `'token' \| 'pool'` }) => void | undefined | triggers on token selector change |
|
|
69
|
+
> | `onLog` | (eventName: `string`, payload?: `Record<string, unknown>`) => void | undefined | triggers on log event |
|
|
70
|
+
> | `onSimulateTransaction` | (payload: { chainId: `ChainId`; from: `Address`: to: `Address`; input: `string`; gas: `number`; value?: `string` }) => Promise<{ link?: `string`; simulation: { status: `boolean`; error_message: `string` } } \| null> | undefined | triggers to simulate transaction and get error details after failed tx estimation |
|
|
71
|
+
> | `getSwapQuotes` | ({ signal: `AbortSignal`, variables: { chainId: `number`; sourceAddress: `Address`; destinationAddress: `Address`; walletAddress: `Address`; fromAddress: `Address`; amount: `string`; slippage: `string` } }) => Promise<Array <{ destinationAmount: `string`; rawTransaction: `{ data: string }` ; routerKey: `'ONE_INCH' / 'ONE_INCH_V5' / 'ZERO_X' / 'PARASWAP' / 'PARASWAP_V6' / 'ODOS_V2' / 'KYBER_SWAP_V2'` } }> \| null> | undefined | provides off chain swap quotes based on send token value |
|
|
72
72
|
|
|
73
73
|
###### Source: `packages/trading-widget/src/core-kit/providers/index.tsx`
|
|
74
74
|
|
|
@@ -151,7 +151,6 @@ UI configuration provider. Manages params to configure custom styling, component
|
|
|
151
151
|
> | `isAllAssetsWithdrawOptionDefault` | `boolean` | `false` | Sets "All Assets" withdraw option by default |
|
|
152
152
|
> | `isCustomDepositOptionsDisabled` | `boolean` | `false` | When enabled, excludes custom deposit tokens and native tokens from deposit options. Only vault's default deposit tokens are available. |
|
|
153
153
|
> | `chainConfig` | `Partial<Record<ChainId, { name: string; iconPath: string }>>` | `{}` | Sets map of chain `name` and `iconPath` |
|
|
154
|
-
> | `aaveOffchainWithdrawMinValue` | `number` | `50` | Value in USD when off-chain Aave withdrawal is enabled |
|
|
155
154
|
> | `getFallbackIconPath` | `(tokenName: string) => string` | `buildIconLink` | Fallback token icon path getter |
|
|
156
155
|
> | `minLimitOrderValue` | `number` | `0` | Minimum USD value required to create a limit sell order |
|
|
157
156
|
> | `limitOrderThemeConfig` | `ThemeProviderConfigProps` | `{}` | Limit sell overlay content theme config |
|
|
@@ -630,7 +629,7 @@ Follow the steps below to set up the project for local development:
|
|
|
630
629
|
packages/trading-widget/src/core-kit/providers/wagmi-provider.tsx
|
|
631
630
|
```
|
|
632
631
|
|
|
633
|
-
3. **Implement**
|
|
632
|
+
3. **Implement** getSwapQuotes in:
|
|
634
633
|
```bash
|
|
635
634
|
packages/trading-widget/src/core-kit/providers/wagmi-provider.tsx
|
|
636
635
|
```
|
|
@@ -5,8 +5,11 @@ interface PoolFeesParams {
|
|
|
5
5
|
}
|
|
6
6
|
export declare const usePoolFees: ({ address, chainId }: PoolFeesParams) => {
|
|
7
7
|
performanceFee: string;
|
|
8
|
+
performanceFeeNumber: number;
|
|
8
9
|
streamingFee: string;
|
|
10
|
+
streamingFeeNumber: number;
|
|
9
11
|
entryFee: string;
|
|
12
|
+
entryFeeNumber: number;
|
|
10
13
|
exitFee: string;
|
|
11
14
|
exitFeeNumber: number;
|
|
12
15
|
};
|
|
@@ -23,10 +23,6 @@ export declare const useOnTransactionEstimationError: () => ((error: import("../
|
|
|
23
23
|
export declare const useOnTokenSelector: () => ((payload: import("../../types").TokenSelectorPayload) => void) | undefined;
|
|
24
24
|
export declare const useTradingPanelLogger: () => ((eventName: string, payload?: Record<string, unknown> | undefined) => void) | undefined;
|
|
25
25
|
export declare const useOnSimulateTransaction: () => ((params: import("../../types").SimulateTransactionParams) => Promise<import("../../types").SimulateTransactionResponse | null>) | undefined;
|
|
26
|
-
export declare const useGetSwapData: () => ({ signal, variables, }: {
|
|
27
|
-
signal: AbortSignal;
|
|
28
|
-
variables: SwapDataRequest;
|
|
29
|
-
}) => Promise<import("@shared/types").SwapDataResponse | null>;
|
|
30
26
|
export declare const useGetSwapQuotes: () => ({ signal, variables, }: {
|
|
31
27
|
signal: AbortSignal;
|
|
32
28
|
variables: SwapDataRequest;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { useSetTradingType, useUpdateTradingModal, useUpdateSendTokenInput, useSetPoolAddress, useUpdateReceiveTokenInput, useUpdateTradingSettings, useOnTransactionError, useOnTransactionSuccess, useOnTransactionEstimationError, useOnTokenSelector, useTradingPanelLogger, useOnSimulateTransaction, useUpdatePoolFallbackData, useOnTradingSettleError,
|
|
1
|
+
export { useSetTradingType, useUpdateTradingModal, useUpdateSendTokenInput, useSetPoolAddress, useUpdateReceiveTokenInput, useUpdateTradingSettings, useOnTransactionError, useOnTransactionSuccess, useOnTransactionEstimationError, useOnTokenSelector, useTradingPanelLogger, useOnSimulateTransaction, useUpdatePoolFallbackData, useOnTradingSettleError, useUpdatePoolConfig, useAddPoolConfig, useUpdateCustomDepositTokensPerChain, useGetSwapQuotes, } from '../../hooks/state/action';
|
|
2
2
|
export { useTradingPanelPoolAddress, useTradingPanelPoolConfig, useTradingPanelPoolConfigs, useTradingPanelPoolFallbackData, useIsPoolAddress, } from '../../hooks/state/pool';
|
|
3
3
|
export { useSendTokenInput, useReceiveTokenInput, } from '../../hooks/state/input';
|
|
4
4
|
export { useTradingPanelSettings, useCustomDepositTokensPerChain, } from '../../hooks/state/settings';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const useDepositCommon: () => {
|
|
2
2
|
chainId: number;
|
|
3
3
|
depositMethod: import("../../../../types").DepositMethodName;
|
|
4
|
-
|
|
4
|
+
buildDepositTransactionArgs: (estimate?: import("../../../../types").EstimateCall | undefined) => Promise<import("../../../../utils/deposit").DepositArguments>;
|
|
5
5
|
addPendingTransaction: () => void;
|
|
6
6
|
};
|
|
@@ -5,11 +5,11 @@ export { useDepositQuoteContractRead } from '../../../hooks/trading/deposit-v2/u
|
|
|
5
5
|
export { useDepositSlippage } from '../../../hooks/trading/deposit-v2/use-deposit-slippage';
|
|
6
6
|
export { useHandlePoolDepositData } from '../../../hooks/trading/deposit-v2/use-handle-pool-deposit-data';
|
|
7
7
|
export { useIsVaultDepositLocked } from '../../../hooks/trading/deposit-v2/use-is-vault-deposit-locked';
|
|
8
|
-
export {
|
|
8
|
+
export { useDepositSwapQuotesBasedOnSendToken } from '../../../hooks/trading/deposit-v2/use-deposit-swap-quotes-based-on-send-token';
|
|
9
9
|
export { useVaultDepositParams } from '../../../hooks/trading/deposit-v2/use-vault-deposit-params';
|
|
10
10
|
export { useVaultDepositTokenAmount } from '../../../hooks/trading/deposit-v2/use-vault-deposit-token-amount';
|
|
11
11
|
export { useVaultDepositTokens } from '../../../hooks/trading/deposit-v2/use-vault-deposit-tokens';
|
|
12
|
-
export {
|
|
12
|
+
export { useGetVaultDepositTransactionArguments } from '../../../hooks/trading/deposit-v2/use-get-vault-deposit-transaction-arguments';
|
|
13
13
|
export { useDepositLockTime } from '../../../hooks/trading/deposit-v2/use-deposit-lock-time';
|
|
14
14
|
export { useDepositPriceDiff } from '../../../hooks/trading/deposit-v2/use-deposit-price-diff';
|
|
15
15
|
export { useIsDepositWithSwapTransaction } from '../../../hooks/trading/deposit-v2/use-is-deposit-with-swap-transaction';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { EstimateCall, VaultDepositParams } from '../../../types';
|
|
2
|
+
import type { DepositArguments } from '../../../utils/deposit';
|
|
3
|
+
export declare const useGetVaultDepositTransactionArguments: ({ depositMethod, vaultDepositTokenAddress, }: VaultDepositParams) => (estimate?: EstimateCall) => Promise<DepositArguments>;
|
|
@@ -7,7 +7,8 @@ export { useExchangeRate } from '../../hooks/trading/use-exchange-rate';
|
|
|
7
7
|
export { useHandleTrade } from '../../hooks/trading/trade-handlers/use-handle-trade';
|
|
8
8
|
export { useDepositProjectedEarnings } from '../../hooks/trading/projected-earnings/use-deposit-projected-earnings';
|
|
9
9
|
export { useProjectedEarningsCore } from '../../hooks/trading/projected-earnings/use-projected-earnings-core';
|
|
10
|
-
export {
|
|
10
|
+
export { useSwapQuotesQuery } from '../../hooks/trading/swaps/use-swap-quotes-query';
|
|
11
|
+
export { useSwapsQuotesQuery, fetchSwapsQuotesForAave, } from '../../hooks/trading/swaps/use-swaps-quotes-query';
|
|
11
12
|
export { useSendTokenDebouncedValue } from '../../hooks/trading/use-send-token-debounced-value';
|
|
12
13
|
export { useEasySwapperTrackedAssets } from '../../hooks/trading/use-easy-swapper-tracked-assets';
|
|
13
14
|
export { useIsBatchContractWritesTrading } from '../../hooks/trading/use-is-batch-contract-writes-trading';
|
|
@@ -8,3 +8,4 @@ export { useCompleteWithdrawQuote } from '../../../../hooks/trading/withdraw-v2/
|
|
|
8
8
|
export { useHandleCompleteWithdraw } from '../../../../hooks/trading/withdraw-v2/complete-step/use-handle-complete-withdraw';
|
|
9
9
|
export { useCompleteWithdrawReceiveDiff } from '../../../../hooks/trading/withdraw-v2/complete-step/use-complete-withdraw-receive-diff';
|
|
10
10
|
export { useHasSwappableAssets } from '../../../../hooks/trading/withdraw-v2/complete-step/use-has-swappable-assets';
|
|
11
|
+
export { useAutoSendCompleteWithdrawTransaction } from '../../../../hooks/trading/withdraw-v2/complete-step/use-auto-send-complete-withdraw-transaction';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useAutoSendCompleteWithdrawTransaction: (handleTrade: () => Promise<void>) => void;
|
package/core-kit/hooks/trading/withdraw-v2/init-step/use-fetch-init-withdraw-aave-swap-quotes.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CalculateSwapDataParamsResponse, PoolConfig } from '../../../../types';
|
|
2
|
+
export declare const useFetchInitWithdrawAaveSwapQuotes: ({ chainId, }: Pick<PoolConfig, 'chainId'>) => ({ swapParams, slippage, }: {
|
|
3
|
+
swapParams: CalculateSwapDataParamsResponse | undefined;
|
|
4
|
+
slippage: number;
|
|
5
|
+
}) => Promise<import("../../../../utils/swap-data").SwapsQuotesMap<string>>;
|
package/core-kit/hooks/trading/withdraw-v2/init-step/use-fetch-init-withdraw-complex-asset-data.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { FetchAaveSwapParamsProps } from '../../../../hooks/trading/withdraw-v2/init-step/use-fetch-aave-swap-params';
|
|
2
|
-
import type { ComplexWithdrawAssetData, PoolConfig } from '../../../../types';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import type { Address, ComplexWithdrawAssetData, EstimateCall, PoolConfig } from '../../../../types';
|
|
3
|
+
export type CommonWithdrawTransactionArgs = [bigint] | [Address, bigint];
|
|
4
|
+
type FetchInitWithdrawComplexAssetDataParams = FetchAaveSwapParamsProps & {
|
|
5
|
+
estimate: EstimateCall;
|
|
6
|
+
transactionArgs: CommonWithdrawTransactionArgs;
|
|
7
|
+
};
|
|
8
|
+
export declare const useFetchInitWithdrawComplexAssetData: ({ address, chainId, }: Pick<PoolConfig, 'address' | 'chainId'>) => ({ withdrawAmountD18, slippage, estimate, transactionArgs, }: FetchInitWithdrawComplexAssetDataParams) => Promise<ComplexWithdrawAssetData[]>;
|
|
9
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { InitWithdrawTransactionArguments } from '../../../../types';
|
|
1
|
+
import type { EstimateCall, InitWithdrawTransactionArguments } from '../../../../types';
|
|
2
2
|
interface UseGetInitWithdrawTransactionArguments {
|
|
3
3
|
debounceTime?: number;
|
|
4
4
|
}
|
|
5
|
-
export declare const useGetInitWithdrawTransactionArguments: () => () => Promise<(bigint | `0x${string}` | import('../../../../types').ComplexWithdrawAssetData[])[]>;
|
|
5
|
+
export declare const useGetInitWithdrawTransactionArguments: () => (estimate: EstimateCall) => Promise<(bigint | `0x${string}` | import('../../../../types').ComplexWithdrawAssetData[])[]>;
|
|
6
6
|
export declare const useInitWithdrawTransactionArgumentsForSimulationOnly: ({ debounceTime, }?: UseGetInitWithdrawTransactionArguments) => InitWithdrawTransactionArguments;
|
|
7
7
|
export {};
|
|
@@ -67,10 +67,6 @@ export interface CallbackConfig {
|
|
|
67
67
|
onTokenSelector: (payload: TokenSelectorPayload) => void;
|
|
68
68
|
onLog: (eventName: string, payload?: Record<string, unknown>) => void;
|
|
69
69
|
onSimulateTransaction: (params: SimulateTransactionParams) => Promise<SimulateTransactionResponse | null>;
|
|
70
|
-
getSwapData: (args: {
|
|
71
|
-
signal: AbortSignal;
|
|
72
|
-
variables: SwapDataRequest;
|
|
73
|
-
}) => Promise<SwapDataResponse | null>;
|
|
74
70
|
getSwapQuotes: (args: {
|
|
75
71
|
signal: AbortSignal;
|
|
76
72
|
variables: SwapDataRequest;
|
|
@@ -111,7 +107,7 @@ export type TradingPanelAction = {
|
|
|
111
107
|
payload: Record<ChainId, TradingToken[]>;
|
|
112
108
|
};
|
|
113
109
|
export interface TradingPanelContextConfig {
|
|
114
|
-
actions: Partial<CallbackConfig> & Pick<CallbackConfig, '
|
|
110
|
+
actions: Partial<CallbackConfig> & Pick<CallbackConfig, 'getSwapQuotes'>;
|
|
115
111
|
initialState?: Partial<TradingPanelState>;
|
|
116
112
|
}
|
|
117
113
|
export type TradingPanelActionsState = TradingPanelSetters & {
|
|
@@ -122,6 +118,5 @@ export type TradingPanelActionsState = TradingPanelSetters & {
|
|
|
122
118
|
onTokenSelector: CallbackConfig['onTokenSelector'] | undefined;
|
|
123
119
|
onLog: CallbackConfig['onLog'] | undefined;
|
|
124
120
|
onSimulateTransaction: CallbackConfig['onSimulateTransaction'] | undefined;
|
|
125
|
-
getSwapData: CallbackConfig['getSwapData'];
|
|
126
121
|
getSwapQuotes: CallbackConfig['getSwapQuotes'];
|
|
127
122
|
};
|
package/core-kit/utils/aave.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export interface IsLendAndBorrowAssetParams {
|
|
|
4
4
|
chainId: ChainId;
|
|
5
5
|
}
|
|
6
6
|
export declare const isAaveLendAndBorrowAsset: ({ address, chainId, }: IsLendAndBorrowAssetParams) => boolean;
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const buildSwapQuoteKeyForAave: ({ sourceAddress, amount, }: Pick<SwapDataRequest, 'sourceAddress' | 'amount'>) => string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Address, SwapDataResponse } from '@shared/types';
|
|
2
|
+
import type { useFetchAaveSwapParams } from '../hooks/trading/withdraw-v2/init-step/use-fetch-aave-swap-params';
|
|
3
|
+
import type { useFetchInitWithdrawAaveSwapQuotes } from '../hooks/trading/withdraw-v2/init-step/use-fetch-init-withdraw-aave-swap-quotes';
|
|
4
|
+
import type { CalculateSwapDataParamsResponse, ComplexWithdrawAssetData, EstimateCall } from '../types';
|
|
5
|
+
import type { SwapsQuotesMap } from '../utils/swap-data';
|
|
6
|
+
type VaultAssetWithSwapQuotes = {
|
|
7
|
+
asset: Address;
|
|
8
|
+
swapParams?: CalculateSwapDataParamsResponse;
|
|
9
|
+
swapQuotes?: SwapsQuotesMap<string>;
|
|
10
|
+
};
|
|
11
|
+
interface EnrichAssetParams {
|
|
12
|
+
withdrawAmountD18: bigint;
|
|
13
|
+
slippage: number;
|
|
14
|
+
fetchAaveSwapParams: ReturnType<typeof useFetchAaveSwapParams>;
|
|
15
|
+
fetchAaveSwapQuotes: ReturnType<typeof useFetchInitWithdrawAaveSwapQuotes>;
|
|
16
|
+
}
|
|
17
|
+
export declare const extractAvailableRouterKeys: (vaultAssetsWithSwapQuotes: VaultAssetWithSwapQuotes[]) => Array<SwapDataResponse['routerKey']>;
|
|
18
|
+
export declare const buildComplexAssetDataForRouter: (vaultAssetsWithSwapQuotes: VaultAssetWithSwapQuotes[], routerKey: SwapDataResponse['routerKey'], slippageTolerance: bigint) => ComplexWithdrawAssetData[];
|
|
19
|
+
export declare const tryEstimateWithRouters: (availableRouterKeys: Array<SwapDataResponse['routerKey']>, vaultAssetsWithSwapQuotes: VaultAssetWithSwapQuotes[], slippageTolerance: bigint, estimate: EstimateCall, transactionArgs: unknown[]) => Promise<ComplexWithdrawAssetData[] | null>;
|
|
20
|
+
export declare const createDefaultComplexAssetData: (supportedVaultAssets: Address[] | undefined, slippageTolerance: bigint) => ComplexWithdrawAssetData[];
|
|
21
|
+
export declare const enrichAssetsWithSwapQuotes: (supportedVaultAssets: Address[] | undefined, aaveLendingPoolV3Address: Address, { fetchAaveSwapParams, fetchAaveSwapQuotes, withdrawAmountD18, slippage, }: EnrichAssetParams) => Promise<VaultAssetWithSwapQuotes[]>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { useDepositSwapQuotesBasedOnSendToken } from '../hooks/trading/deposit-v2';
|
|
2
|
+
import type { DepositMethodName, EstimateCall, VaultDepositParams } from '../types';
|
|
3
|
+
import type { Address } from '../types/web3.types';
|
|
4
|
+
export type DepositArguments = [Address, string, {
|
|
5
|
+
value: string;
|
|
6
|
+
}] | [Address, Address, string, string] | [...unknown[], {
|
|
7
|
+
value: string;
|
|
8
|
+
}] | unknown[];
|
|
9
|
+
export interface BuildZapDepositArgsParams {
|
|
10
|
+
baseArgs: {
|
|
11
|
+
vaultAddress: Address;
|
|
12
|
+
vaultDepositTokenAddress: Address;
|
|
13
|
+
vaultDepositTokenAmount: string;
|
|
14
|
+
minVaultTokensReceivedAmount: string;
|
|
15
|
+
sendTokenAmount: string;
|
|
16
|
+
};
|
|
17
|
+
swapQuotes: ReturnType<typeof useDepositSwapQuotesBasedOnSendToken>['data'];
|
|
18
|
+
estimate?: EstimateCall;
|
|
19
|
+
depositSlippage: number;
|
|
20
|
+
sendTokenAddress: Address;
|
|
21
|
+
depositMethod: VaultDepositParams['depositMethod'];
|
|
22
|
+
}
|
|
23
|
+
export declare const buildDepositTransactionArgumentsForMethod: (depositMethod: VaultDepositParams['depositMethod'], baseArgs: BuildZapDepositArgsParams['baseArgs'], zapArguments?: unknown[]) => DepositArguments;
|
|
24
|
+
export declare const buildZapDepositArguments: ({ baseArgs, swapQuotes, estimate, depositSlippage, sendTokenAddress, depositMethod, }: BuildZapDepositArgsParams) => Promise<DepositArguments>;
|
|
25
|
+
export declare const isZapDepositMethod: (depositMethod: DepositMethodName) => boolean;
|
|
@@ -2,3 +2,9 @@ export declare const getPercent: (numerator: number, denominator: number) => num
|
|
|
2
2
|
export declare const getConventionalTokenPriceDecimals: (tokenPrice: number) => number;
|
|
3
3
|
export declare const shiftBy: (value: bigint | string | number, n?: number) => string;
|
|
4
4
|
export declare const getPoolFraction: (poolTotalValue: string, amountToSell: string, poolTotalSupply: string, precision?: number) => number;
|
|
5
|
+
/**
|
|
6
|
+
* Parses a string amount to a bigint with 18 decimals precision (D18)
|
|
7
|
+
* @param value - The string value to parse
|
|
8
|
+
* @returns bigint representation with 18 decimals
|
|
9
|
+
*/
|
|
10
|
+
export declare const parseAmountToD18: (value: string) => bigint;
|
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
import type { SwapDataRequest, SwapDataResponse } from '@shared/types';
|
|
2
|
-
import type { useGetSwapData } from '../hooks/state';
|
|
3
2
|
import type { useGetSwapQuotes } from '../hooks/state/action';
|
|
4
3
|
export type AssetWithoutFromAddress = Omit<SwapDataRequest, 'fromAddress'>;
|
|
5
|
-
export type
|
|
4
|
+
export type SwapDataMap = Record<string, SwapDataResponse>;
|
|
6
5
|
export type SwapsQuotesMap<T extends string> = Record<T, SwapDataResponse[] | null>;
|
|
7
|
-
interface
|
|
8
|
-
assets: AssetWithoutFromAddress[];
|
|
9
|
-
getSwapData: ReturnType<typeof useGetSwapData>;
|
|
10
|
-
signal: AbortSignal;
|
|
11
|
-
buildKey: (asset: AssetWithoutFromAddress) => K;
|
|
12
|
-
}
|
|
13
|
-
interface FetchSwapsQueriesWithKeyParams<K extends string> {
|
|
6
|
+
export interface FetchSwapsQuotesWithKeyParams<K extends string> {
|
|
14
7
|
assets: AssetWithoutFromAddress[];
|
|
15
8
|
getSwapQuotes: ReturnType<typeof useGetSwapQuotes>;
|
|
16
9
|
signal: AbortSignal;
|
|
17
10
|
buildKey: (asset: AssetWithoutFromAddress) => K;
|
|
18
11
|
}
|
|
19
|
-
export declare const
|
|
20
|
-
export declare const
|
|
21
|
-
export {};
|
|
12
|
+
export declare const fetchSwapsQuotesWithKey: <K extends string>({ assets, getSwapQuotes, signal, buildKey, }: FetchSwapsQuotesWithKeyParams<K>) => Promise<SwapsQuotesMap<K>>;
|
|
13
|
+
export declare const getDefaultSwapQuoteIndex: (quotes: unknown[]) => 1 | 0;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { SwapDataResponse } from '@shared/types';
|
|
1
2
|
import type { Address, Hex } from 'viem';
|
|
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
|
+
import type { SwapDataMap, SwapsQuotesMap } from '../utils/swap-data';
|
|
5
6
|
/**
|
|
6
7
|
* Calculates the slippage tolerance for withdrawSafe.
|
|
7
8
|
* Returns an integer number from 0 to 10000,
|
|
@@ -24,13 +25,14 @@ export declare const buildZapDepositTransactionArguments: ({ vaultAddress, swapD
|
|
|
24
25
|
export declare const buildSwapWithdrawTransactionData: ({ receiveAssetAddress, assets, swapData, }: {
|
|
25
26
|
receiveAssetAddress: Address;
|
|
26
27
|
assets: ReturnType<typeof useCompleteWithdrawTrackedAssets>['data'];
|
|
27
|
-
swapData:
|
|
28
|
+
swapData: SwapDataMap;
|
|
28
29
|
}) => unknown[][];
|
|
29
|
-
export declare const buildAaveWithdrawAssetTransactionData: ({ assetAddress,
|
|
30
|
+
export declare const buildAaveWithdrawAssetTransactionData: ({ assetAddress, swapQuotes, swapParams, slippageToleranceForContractTransaction, routerKey, }: {
|
|
30
31
|
assetAddress: Address;
|
|
31
32
|
swapParams: CalculateSwapDataParamsResponse | undefined;
|
|
32
|
-
|
|
33
|
+
swapQuotes: SwapsQuotesMap<string>;
|
|
33
34
|
slippageToleranceForContractTransaction: bigint;
|
|
35
|
+
routerKey: SwapDataResponse['routerKey'];
|
|
34
36
|
}) => {
|
|
35
37
|
supportedAsset: `0x${string}`;
|
|
36
38
|
withdrawData: string;
|