@dhedge/trading-widget 4.7.0 → 5.1.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 +46 -39
- package/core-kit/const/storage.d.ts +0 -3
- package/core-kit/const/trading.d.ts +2 -0
- package/core-kit/hooks/state/action.d.ts +0 -4
- package/core-kit/hooks/state/index.d.ts +2 -1
- package/core-kit/hooks/state/stepper.d.ts +5 -0
- package/core-kit/hooks/trading/allowance/use-approve.d.ts +3 -1
- package/core-kit/hooks/trading/allowance/use-can-spend.d.ts +4 -1
- package/core-kit/hooks/trading/index.d.ts +2 -3
- package/core-kit/hooks/trading/trade-handlers/use-handle-trade.d.ts +6 -1
- package/core-kit/hooks/trading/trade-handlers/use-trading-settle-handler.d.ts +7 -1
- package/core-kit/hooks/trading/withdraw-v2/complete-step/use-auto-send-complete-withdraw-transaction.d.ts +6 -1
- package/core-kit/hooks/trading/withdraw-v2/complete-step/use-complete-withdraw-transaction.d.ts +3 -1
- package/core-kit/hooks/trading/withdraw-v2/complete-step/use-handle-complete-withdraw.d.ts +2 -1
- 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/hooks/trading/withdraw-v2/init-step/use-init-withdraw-allowance.d.ts +7 -1
- package/core-kit/hooks/trading/withdraw-v2/init-step/use-init-withdraw-transaction.d.ts +6 -1
- package/core-kit/hooks/trading/withdraw-v2/init-step/use-is-unroll-and-claim-transaction.d.ts +5 -1
- package/core-kit/types/state.types.d.ts +7 -7
- package/core-kit/types/trading-panel.types.d.ts +7 -0
- 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/formatter.d.ts +1 -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 +3 -12
- package/core-kit/utils/transaction.d.ts +6 -4
- package/index.cjs +1 -1
- package/index.d.ts +2 -2
- package/index.js +4026 -3714
- package/package.json +1 -1
- package/style.css +1 -1
- package/trading-widget/components/widget/widget-buttons/add-to-wallet-button/add-to-wallet-button.d.ts +2 -0
- package/trading-widget/components/widget/widget-buttons/add-to-wallet-button/add-to-wallet-button.hooks.d.ts +3 -0
- package/trading-widget/components/widget/widget-buttons/index.d.ts +3 -0
- package/trading-widget/components/widget/widget-buttons/notifications-settings-button/notifications-settings-button.d.ts +3 -0
- package/trading-widget/components/widget/widget-buttons/withdraw-stepper-button/withdraw-stepper-button.d.ts +2 -0
- package/trading-widget/components/widget/widget-buttons/withdraw-stepper-button/withdraw-stepper-button.hooks.d.ts +4 -0
- package/trading-widget/components/widget/widget-overlay/index.d.ts +1 -1
- package/trading-widget/components/widget/widget-overlay/trading-overlay/trading-overlay.hooks.d.ts +1 -0
- package/trading-widget/components/widget/widget-overlay/trading-overlay/withdrawals/success-withdrawal-overlay.d.ts +3 -0
- package/trading-widget/components/widget/widget-overlay/trading-overlay/withdrawals/success-withdrawal-overlay.hooks.d.ts +9 -0
- package/trading-widget/components/widget/widget-overlay/withdraw-stepper-overlay/steps/approve-step.d.ts +3 -0
- package/trading-widget/components/widget/widget-overlay/withdraw-stepper-overlay/steps/approve-step.hooks.d.ts +10 -0
- package/trading-widget/components/widget/widget-overlay/withdraw-stepper-overlay/steps/complete-withdraw-step.d.ts +3 -0
- package/trading-widget/components/widget/widget-overlay/withdraw-stepper-overlay/steps/complete-withdraw-step.hooks.d.ts +10 -0
- package/trading-widget/components/widget/widget-overlay/withdraw-stepper-overlay/steps/init-withdraw-step.d.ts +3 -0
- package/trading-widget/components/widget/widget-overlay/withdraw-stepper-overlay/steps/init-withdraw-step.hooks.d.ts +13 -0
- package/trading-widget/components/widget/widget-overlay/withdraw-stepper-overlay/steps/step-item.d.ts +9 -0
- package/trading-widget/components/widget/widget-overlay/{fmp-withdrawal-overlay/fmp-withdrawal-overlay.d.ts → withdraw-stepper-overlay/withdraw-stepper-overlay.d.ts} +1 -1
- package/trading-widget/components/widget/widget-overlay/withdraw-stepper-overlay/withdraw-stepper-overlay.hooks.d.ts +14 -0
- package/trading-widget/components/widget/widget-overlay/withdraw-stepper-overlay/withdraw-steps.d.ts +11 -0
- package/trading-widget/components/withdraw/init-step/button/valid-init-withdraw-button/valid-init-withdraw-button.hooks.d.ts +1 -2
- package/trading-widget/hooks/index.d.ts +3 -0
- package/trading-widget/hooks/use-display-limit-sell-overlay.d.ts +1 -0
- package/trading-widget/hooks/use-step-description.d.ts +1 -0
- package/trading-widget/hooks/use-transaction-status-label.d.ts +5 -0
- package/trading-widget/providers/component-provider/component-provider.d.ts +1 -0
- package/trading-widget/providers/component-provider/component-provider.hooks.d.ts +1 -0
- package/trading-widget/providers/component-provider/component-provider.types.d.ts +5 -0
- package/trading-widget/providers/config-provider/config-provider.types.d.ts +1 -1
- package/trading-widget/providers/theme-provider/theme-provider.types.d.ts +5 -0
- package/trading-widget/providers/translation-provider/translation-provider.types.d.ts +11 -5
- package/trading-widget/types/overlay.types.d.ts +1 -1
- package/trading-widget/types/theme.types.d.ts +1 -1
- 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/trading-widget/components/widget/widget-overlay/fmp-withdrawal-overlay/fmp-withdrawal-overlay.hooks.d.ts +0 -10
- package/trading-widget/components/withdraw/complete-step/button/swap-button/swap-button.d.ts +0 -2
- package/trading-widget/components/withdraw/complete-step/button/swap-button/swap-button.hooks.d.ts +0 -6
- package/trading-widget/components/withdraw/complete-step/complete-step.hooks.d.ts +0 -3
- package/trading-widget/components/withdraw/init-step/button/init-withdraw-button/init-withdraw-button.d.ts +0 -2
- package/trading-widget/components/withdraw/init-step/button/init-withdraw-button/init-withdraw-button.hooks.d.ts +0 -6
- package/trading-widget/components/withdraw/stepper/withdraw-stepper.d.ts +0 -2
- package/trading-widget/components/withdraw/stepper/withdraw-stepper.hooks.d.ts +0 -8
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,17 +151,17 @@ 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 |
|
|
158
157
|
|
|
159
158
|
##### actions
|
|
160
159
|
|
|
161
|
-
> | name
|
|
162
|
-
> |
|
|
163
|
-
> | `onConnect`
|
|
164
|
-
> | `onAcceptTermsOfUse`
|
|
160
|
+
> | name | type | default value | description |
|
|
161
|
+
> | ----------------------------- | ------------------------ | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
162
|
+
> | `onConnect` | `() => void` | `() => {}` | Widget has built-in `Connect Wallet` action button that triggers `onConnect` callback assuming starting of abstract wallet connection process. After all the only requirement is to get connected wallet inside wagmi's `useAccount` hook to make trading operations possible |
|
|
163
|
+
> | `onAcceptTermsOfUse` | `() => Promise<boolean>` | `() => Promise.resolve(true)` | Callback is triggered after user's approval of Terms of Use statements assuming switching of external `config.termsOfUseAccepted` param to `true` state |
|
|
164
|
+
> | `onOpenNotificationsSettings` | `() => void` | `undefined` | Optional callback to open notifications settings modal. |
|
|
165
165
|
|
|
166
166
|
###### Source: `packages/trading-widget/src/trading-widget/providers/config-provider`
|
|
167
167
|
|
|
@@ -176,18 +176,19 @@ UI configuration provider. Manages params to configure custom styling, component
|
|
|
176
176
|
<code>Custom components to be injected into widget layout</code>
|
|
177
177
|
</summary>
|
|
178
178
|
|
|
179
|
-
> | name | type
|
|
180
|
-
> | ----------------------- |
|
|
181
|
-
> | `GeoBlockAlert` | ComponentType
|
|
182
|
-
> | `SanctionedAlert` | ComponentType
|
|
183
|
-
> | `MaxSupplyReachedAlert` | ComponentType
|
|
184
|
-
> | `DepositMetaInfo` | ComponentType
|
|
185
|
-
> | `WithdrawMetaInfo` | ComponentType
|
|
186
|
-
> | `CustomDepositMeta` | ComponentType
|
|
187
|
-
> | `Image` | ComponentType<ImageProps>
|
|
188
|
-
> | `LogoSpinner` | ComponentType<SVGProps<SVGElement>>
|
|
189
|
-
> | `DepositTermsOfUse` | ComponentType
|
|
190
|
-
> | `ActionButton` | ComponentType
|
|
179
|
+
> | name | type | default value | description |
|
|
180
|
+
> | ----------------------- | ---------------------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
|
|
181
|
+
> | `GeoBlockAlert` | ComponentType | `<GeoBlockAlert>` | Component replaces deposit button while `isGeoBlocked` config param is set to `true` |
|
|
182
|
+
> | `SanctionedAlert` | ComponentType | `<SanctionedAlert>` | Component replaces deposit button while `isSanctioned` config param is set to `true` |
|
|
183
|
+
> | `MaxSupplyReachedAlert` | ComponentType | `<MaxSupplyReachedAlert>` | Component rendered in the deposit meta when the expected total supply exceeds the max cap; warns that the deposit will not go through |
|
|
184
|
+
> | `DepositMetaInfo` | ComponentType | `undefined` | Component is injected into deposit meta part of widget layout nearby TransactionOverviewDisclosure |
|
|
185
|
+
> | `WithdrawMetaInfo` | ComponentType | `undefined` | Component is injected into withdraw meta part of widget layout nearby WithdrawTransactionOverviewDisclosure |
|
|
186
|
+
> | `CustomDepositMeta` | ComponentType | `undefined` | Custom extra component injected above deposit meta section in the deposit tab panel (e.g., chart, info, etc.) |
|
|
187
|
+
> | `Image` | ComponentType<ImageProps> | `<img>` | Component optionally can be used to pass `nextjs` Image component to be used for assets rendering |
|
|
188
|
+
> | `LogoSpinner` | ComponentType<SVGProps<SVGElement>> | `<Spinner>` | Component is injected into widget pending transaction overlay. Assume using of spinning animation |
|
|
189
|
+
> | `DepositTermsOfUse` | ComponentType | `undefined` | Component is injected into `TermsOfUseOverlay` to extend default terms of use statement points |
|
|
190
|
+
> | `ActionButton` | ComponentType | `<ActionButton>` | Component overrides default `ActionButton` and has `ButtonProps` API |
|
|
191
|
+
> | `BecomeReferrerButton` | ComponentType<BecomeReferrerButtonProps> | `undefined` | Component is rendered at the top of the action buttons in the success deposit overlay. Receives `vaultAddress` prop |
|
|
191
192
|
|
|
192
193
|
###### Source: `packages/trading-widget/src/trading-widget/providers/component-provider/component-provider.tsx`
|
|
193
194
|
|
|
@@ -293,6 +294,14 @@ path: `component.popup[name]`
|
|
|
293
294
|
> | `color.colorBorder` | string | `config?.global?.color?.colorTextSecondary ?? #9DA2AD` | Popup bg color |
|
|
294
295
|
> | `size.fontSize` | string | `config?.global?.size?.fontSizeXs ?? 12px` | Popup font size |
|
|
295
296
|
|
|
297
|
+
###### overlay
|
|
298
|
+
|
|
299
|
+
path: `component.overlay[name]`
|
|
300
|
+
|
|
301
|
+
> | name | type | default value | description |
|
|
302
|
+
> | --------------- | ------ | ----------------------------------------------------- | ---------------- |
|
|
303
|
+
> | `color.colorBg` | string | `config?.component?.popup?.color?.colorBg ?? #2B313E` | Overlay bg color |
|
|
304
|
+
|
|
296
305
|
###### popupList
|
|
297
306
|
|
|
298
307
|
path: `component.popupList[name]`
|
|
@@ -518,6 +527,7 @@ path: `component.meta[name]`
|
|
|
518
527
|
> | `allAssets` | string | All Assets | |
|
|
519
528
|
> | `all` | string | All | |
|
|
520
529
|
> | `sell` | string | Sell | |
|
|
530
|
+
> | `sellNow` | string | Sell now | |
|
|
521
531
|
> | `receiveEstimated` | string | Receive (estimated) | |
|
|
522
532
|
> | `confirmInWallet` | string | Please confirm in wallet | |
|
|
523
533
|
> | `pending` | string | Pending... | |
|
|
@@ -569,11 +579,6 @@ path: `component.meta[name]`
|
|
|
569
579
|
> | `claimLabel` | string | Claim Assets | |
|
|
570
580
|
> | `createLimitSellOrder` | string | Stop order set | |
|
|
571
581
|
> | `swapAndClaimTo` | string | Swap and claim assets to | |
|
|
572
|
-
> | `initWithdrawDescription` | string | Unroll | |
|
|
573
|
-
> | `initWithdrawTooltip` | string | Unroll prepares assets for single asset withdrawal | |
|
|
574
|
-
> | `completeWithdrawDescription` | string | Claim | |
|
|
575
|
-
> | `completeWithdrawTooltip` | string | This final step swaps all assets to a single asset and sends it to your wallet | |
|
|
576
|
-
> | `unrollAndClaimDescription` | string | Claim | |
|
|
577
582
|
> | `limitOrderWithdrawDescription` | string | You are about to create a withdrawal request. Your vault tokens will be withdrawn within a few minutes. | |
|
|
578
583
|
> | `total` | string | Total: | |
|
|
579
584
|
> | `showAll` | string | Show All | |
|
|
@@ -586,6 +591,8 @@ path: `component.meta[name]`
|
|
|
586
591
|
> | `batchTransactionsSwitchLabel` | string | Batch | |
|
|
587
592
|
> | `batchTransactionsTooltip` | string | Group approve and trade calls into a single batch transaction. Disable if you prefer separate prompts. | |
|
|
588
593
|
> | `openLimitOrderAfterBuySwitchLabel` | string | Add Stop Order | |
|
|
594
|
+
> | `openNotificationsSettingsLabel` | string | Enable alerts | |
|
|
595
|
+
> | `addToWallet` | string | add to wallet | |
|
|
589
596
|
> | `orderingLabel` | string | Ordering | |
|
|
590
597
|
> | `paidLabel` | string | Paid | |
|
|
591
598
|
> | `priceLabel` | string | Price | |
|
|
@@ -630,7 +637,7 @@ Follow the steps below to set up the project for local development:
|
|
|
630
637
|
packages/trading-widget/src/core-kit/providers/wagmi-provider.tsx
|
|
631
638
|
```
|
|
632
639
|
|
|
633
|
-
3. **Implement**
|
|
640
|
+
3. **Implement** getSwapQuotes in:
|
|
634
641
|
```bash
|
|
635
642
|
packages/trading-widget/src/core-kit/providers/wagmi-provider.tsx
|
|
636
643
|
```
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TransactionAction } from '../types';
|
|
1
2
|
export declare const EASY_SWAPPER_V2_DEPOSIT_METHODS: {
|
|
2
3
|
DEPOSIT: "deposit";
|
|
3
4
|
DEPOSIT_CUSTOM: "depositWithCustomCooldown";
|
|
@@ -8,3 +9,4 @@ export declare const EASY_SWAPPER_V2_DEPOSIT_METHODS: {
|
|
|
8
9
|
ZAP_DEPOSIT: "zapDeposit";
|
|
9
10
|
ZAP_DEPOSIT_CUSTOM: "zapDepositWithCustomCooldown";
|
|
10
11
|
};
|
|
12
|
+
export declare const COMPLETE_WITHDRAW_ACTIONS: TransactionAction[];
|
|
@@ -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,8 +1,9 @@
|
|
|
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';
|
|
5
5
|
export { useTradingPanelModal } from '../../hooks/state/modal';
|
|
6
|
+
export { useTradingPanelStepper } from '../../hooks/state/stepper';
|
|
6
7
|
export { useTradingPanelType, useIsDepositTradingPanelType, } from '../../hooks/state/type';
|
|
7
8
|
export { useTradingPanelTransactions } from '../../hooks/state/transaction';
|
|
8
9
|
export { useTradingPanelActions, useTradingPanelState, } from '../../hooks/state/context';
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { TradingToken } from '@shared/types';
|
|
2
|
+
import type { OnTradingSettleErrorCallback } from '../../../hooks/trading/trade-handlers/use-trading-settle-handler';
|
|
2
3
|
import type { Address } from '../../../types/web3.types';
|
|
3
4
|
interface UseApproveParams {
|
|
4
5
|
token: TradingToken;
|
|
5
6
|
rawTokenAmount: string;
|
|
6
7
|
spenderAddress: Address;
|
|
8
|
+
onErrorCallback?: OnTradingSettleErrorCallback;
|
|
7
9
|
}
|
|
8
|
-
export declare const useApprove: ({ token, rawTokenAmount, spenderAddress, }: UseApproveParams) => () => Promise<void>;
|
|
10
|
+
export declare const useApprove: ({ token, rawTokenAmount, spenderAddress, onErrorCallback, }: UseApproveParams) => () => Promise<void>;
|
|
9
11
|
export {};
|
|
@@ -7,5 +7,8 @@ interface UseCanSpendParams {
|
|
|
7
7
|
chainId: ChainId;
|
|
8
8
|
skip?: boolean;
|
|
9
9
|
}
|
|
10
|
-
export declare const useCanSpend: ({ rawAmountToSpend, tokenAddress, ownerAddress, spenderAddress, chainId, skip, }: UseCanSpendParams) =>
|
|
10
|
+
export declare const useCanSpend: ({ rawAmountToSpend, tokenAddress, ownerAddress, spenderAddress, chainId, skip, }: UseCanSpendParams) => {
|
|
11
|
+
canSpend: boolean;
|
|
12
|
+
isFetching: boolean;
|
|
13
|
+
};
|
|
11
14
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { useTradingResultHandling } from '../../hooks/trading/trade-handlers/use-trading-result-handling';
|
|
2
2
|
export { useTradingSettleHandler } from '../../hooks/trading/trade-handlers/use-trading-settle-handler';
|
|
3
|
+
export type { OnTradingSettleErrorCallback } from '../../hooks/trading/trade-handlers/use-trading-settle-handler';
|
|
3
4
|
export { useAssetPrice } from '../../hooks/trading/use-asset-price';
|
|
4
5
|
export { useRawAssetPrice } from '../../hooks/trading/use-raw-asset-price';
|
|
5
6
|
export { useIsTradingEnabled } from '../../hooks/trading/use-is-trading-enabled';
|
|
@@ -7,10 +8,8 @@ export { useExchangeRate } from '../../hooks/trading/use-exchange-rate';
|
|
|
7
8
|
export { useHandleTrade } from '../../hooks/trading/trade-handlers/use-handle-trade';
|
|
8
9
|
export { useDepositProjectedEarnings } from '../../hooks/trading/projected-earnings/use-deposit-projected-earnings';
|
|
9
10
|
export { useProjectedEarningsCore } from '../../hooks/trading/projected-earnings/use-projected-earnings-core';
|
|
10
|
-
export { useSwapDataQuery } from '../../hooks/trading/swaps/use-swap-data-query';
|
|
11
|
-
export { useSwapsDataQuery, fetchSwapsData, fetchSwapsDataForAave, } from '../../hooks/trading/swaps/use-swaps-data-query';
|
|
12
11
|
export { useSwapQuotesQuery } from '../../hooks/trading/swaps/use-swap-quotes-query';
|
|
13
|
-
export { useSwapsQuotesQuery } from '../../hooks/trading/swaps/use-swaps-quotes-query';
|
|
12
|
+
export { useSwapsQuotesQuery, fetchSwapsQuotesForAave, } from '../../hooks/trading/swaps/use-swaps-quotes-query';
|
|
14
13
|
export { useSendTokenDebouncedValue } from '../../hooks/trading/use-send-token-debounced-value';
|
|
15
14
|
export { useEasySwapperTrackedAssets } from '../../hooks/trading/use-easy-swapper-tracked-assets';
|
|
16
15
|
export { useIsBatchContractWritesTrading } from '../../hooks/trading/use-is-batch-contract-writes-trading';
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { ContractActionFunc } from '../../../types/web3.types';
|
|
2
|
-
|
|
2
|
+
interface UseHandleTradeParams {
|
|
3
|
+
trade: ContractActionFunc;
|
|
4
|
+
onErrorCallback?: () => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const useHandleTrade: ({ trade, onErrorCallback, }: UseHandleTradeParams) => {
|
|
3
7
|
disabled: boolean;
|
|
4
8
|
label: string;
|
|
5
9
|
handleTrade: () => Promise<void>;
|
|
6
10
|
};
|
|
11
|
+
export {};
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { PendingTransaction } from '../../../types/trading-panel.types';
|
|
2
2
|
import type { UseWriteContractParameters } from '../../../types/web3.types';
|
|
3
|
-
export
|
|
3
|
+
export type OnTradingSettleErrorCallback = (error: Error) => void;
|
|
4
|
+
interface UseTradingSettleHandlerParams {
|
|
5
|
+
action: PendingTransaction['action'];
|
|
6
|
+
onErrorCallback?: OnTradingSettleErrorCallback;
|
|
7
|
+
}
|
|
8
|
+
export declare const useTradingSettleHandler: ({ action, onErrorCallback, }: UseTradingSettleHandlerParams) => Required<Required<UseWriteContractParameters>['mutation']>['onSettled'];
|
|
9
|
+
export {};
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
interface UseAutoSendCompleteWithdrawTransactionParams {
|
|
2
|
+
handleTrade: () => Promise<void>;
|
|
3
|
+
onError: () => void;
|
|
4
|
+
}
|
|
5
|
+
export declare const useAutoSendCompleteWithdrawTransaction: ({ handleTrade, onError, }: UseAutoSendCompleteWithdrawTransactionParams) => void;
|
|
6
|
+
export {};
|
package/core-kit/hooks/trading/withdraw-v2/complete-step/use-complete-withdraw-transaction.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { OnTradingSettleErrorCallback } from '../../../../hooks/trading';
|
|
1
2
|
import type { ContractActionFunc } from '../../../../types/web3.types';
|
|
2
3
|
interface UseWithdrawSwapTransactionProps {
|
|
3
4
|
isClaim?: boolean;
|
|
5
|
+
onErrorCallback?: OnTradingSettleErrorCallback;
|
|
4
6
|
}
|
|
5
|
-
export declare const useCompleteWithdrawTransaction: ({ isClaim, }?: UseWithdrawSwapTransactionProps | undefined) => ContractActionFunc;
|
|
7
|
+
export declare const useCompleteWithdrawTransaction: ({ isClaim, onErrorCallback, }?: UseWithdrawSwapTransactionProps | undefined) => ContractActionFunc;
|
|
6
8
|
export {};
|
|
@@ -2,8 +2,9 @@ import type { ContractActionFunc } from '../../../../types/web3.types';
|
|
|
2
2
|
interface UseHandleWithdrawSwapProps {
|
|
3
3
|
withdraw: ContractActionFunc;
|
|
4
4
|
isClaim?: boolean;
|
|
5
|
+
onErrorCallback?: () => void;
|
|
5
6
|
}
|
|
6
|
-
export declare const useHandleCompleteWithdraw: ({ withdraw, isClaim, }: UseHandleWithdrawSwapProps) => {
|
|
7
|
+
export declare const useHandleCompleteWithdraw: ({ withdraw, isClaim, onErrorCallback, }: UseHandleWithdrawSwapProps) => {
|
|
7
8
|
disabled: boolean;
|
|
8
9
|
label: string;
|
|
9
10
|
handleTrade: () => Promise<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 {};
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import type { OnTradingSettleErrorCallback } from '../../../../hooks/trading';
|
|
2
|
+
interface UseInitWithdrawAllowanceParams {
|
|
3
|
+
onErrorCallback?: OnTradingSettleErrorCallback;
|
|
4
|
+
}
|
|
5
|
+
export declare const useInitWithdrawAllowance: ({ onErrorCallback, }?: UseInitWithdrawAllowanceParams | undefined) => {
|
|
2
6
|
canSpend: boolean;
|
|
3
7
|
approve: () => Promise<void>;
|
|
8
|
+
isCanSpendFetching: boolean;
|
|
4
9
|
};
|
|
10
|
+
export {};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import { type OnTradingSettleErrorCallback } from '../../../../hooks/trading';
|
|
1
2
|
import type { TransactionAction } from '../../../../types';
|
|
2
3
|
import type { ContractActionFunc } from '../../../../types/web3.types';
|
|
3
|
-
|
|
4
|
+
interface UseInitiateWithdrawTransactionParams {
|
|
5
|
+
onErrorCallback?: OnTradingSettleErrorCallback;
|
|
6
|
+
}
|
|
7
|
+
export declare const useInitWithdrawTransaction: ({ onErrorCallback, }?: UseInitiateWithdrawTransactionParams | undefined) => {
|
|
4
8
|
withdraw: ContractActionFunc;
|
|
5
9
|
action: TransactionAction;
|
|
6
10
|
};
|
|
11
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SwapDataRequest, SwapDataResponse, TradingToken } from '@shared/types';
|
|
2
2
|
import type { EstimationError } from '../models';
|
|
3
3
|
import type { PoolConfig, PoolFallbackData } from '../types/config.types';
|
|
4
|
-
import type { DynamicTradingToken, PendingTransaction, TokenSelectorPayload, TradingModalStatus, TradingPanelType, TransactionAction, UpdateTransactionsArguments } from '../types/trading-panel.types';
|
|
4
|
+
import type { DynamicTradingToken, PendingTransaction, StepperState, TokenSelectorPayload, TradingModalStatus, TradingPanelType, TransactionAction, UpdateTransactionsArguments } from '../types/trading-panel.types';
|
|
5
5
|
import type { Address, ChainId, SimulateTransactionParams, SimulateTransactionResponse, WaitForTransactionReceiptReturnType } from '../types/web3.types';
|
|
6
6
|
export interface TradingPanelStateModal {
|
|
7
7
|
isOpen: boolean;
|
|
@@ -32,6 +32,7 @@ export interface TradingPanelState {
|
|
|
32
32
|
receiveToken: DynamicTradingToken;
|
|
33
33
|
};
|
|
34
34
|
modal: TradingPanelStateModal;
|
|
35
|
+
stepper: StepperState | null;
|
|
35
36
|
poolAddress: PoolConfig['address'];
|
|
36
37
|
poolConfigMap: Record<PoolConfig['address'], PoolConfig>;
|
|
37
38
|
transactions: PendingTransaction[];
|
|
@@ -46,6 +47,7 @@ export interface TradingPanelSetters {
|
|
|
46
47
|
updateTradingSettings: (payload: Partial<TradingPanelState['settings']>) => void;
|
|
47
48
|
setTradingType: (payload: TradingPanelState['type']) => void;
|
|
48
49
|
updateTradingModal: (payload: Partial<TradingPanelState['modal']>) => void;
|
|
50
|
+
updateStepper: (payload: TradingPanelState['stepper']) => void;
|
|
49
51
|
updateTransactions: (payload: UpdateTransactionsArguments) => void;
|
|
50
52
|
updatePoolFallbackData: (payload: PoolFallbackData) => void;
|
|
51
53
|
updatePoolConfig: (payload: Record<PoolConfig['address'], Pick<PoolConfig, 'maintenance' | 'maintenanceDeposits' | 'maintenanceWithdrawals'>>) => void;
|
|
@@ -67,10 +69,6 @@ export interface CallbackConfig {
|
|
|
67
69
|
onTokenSelector: (payload: TokenSelectorPayload) => void;
|
|
68
70
|
onLog: (eventName: string, payload?: Record<string, unknown>) => void;
|
|
69
71
|
onSimulateTransaction: (params: SimulateTransactionParams) => Promise<SimulateTransactionResponse | null>;
|
|
70
|
-
getSwapData: (args: {
|
|
71
|
-
signal: AbortSignal;
|
|
72
|
-
variables: SwapDataRequest;
|
|
73
|
-
}) => Promise<SwapDataResponse | null>;
|
|
74
72
|
getSwapQuotes: (args: {
|
|
75
73
|
signal: AbortSignal;
|
|
76
74
|
variables: SwapDataRequest;
|
|
@@ -94,6 +92,9 @@ export type TradingPanelAction = {
|
|
|
94
92
|
} | {
|
|
95
93
|
type: 'UPDATE_TRADING_MODAL';
|
|
96
94
|
payload: Partial<TradingPanelState['modal']>;
|
|
95
|
+
} | {
|
|
96
|
+
type: 'UPDATE_STEPPER';
|
|
97
|
+
payload: TradingPanelState['stepper'];
|
|
97
98
|
} | {
|
|
98
99
|
type: 'UPDATE_TRADING_TRANSACTIONS';
|
|
99
100
|
payload: UpdateTransactionsArguments;
|
|
@@ -111,7 +112,7 @@ export type TradingPanelAction = {
|
|
|
111
112
|
payload: Record<ChainId, TradingToken[]>;
|
|
112
113
|
};
|
|
113
114
|
export interface TradingPanelContextConfig {
|
|
114
|
-
actions: Partial<CallbackConfig> & Pick<CallbackConfig, '
|
|
115
|
+
actions: Partial<CallbackConfig> & Pick<CallbackConfig, 'getSwapQuotes'>;
|
|
115
116
|
initialState?: Partial<TradingPanelState>;
|
|
116
117
|
}
|
|
117
118
|
export type TradingPanelActionsState = TradingPanelSetters & {
|
|
@@ -122,6 +123,5 @@ export type TradingPanelActionsState = TradingPanelSetters & {
|
|
|
122
123
|
onTokenSelector: CallbackConfig['onTokenSelector'] | undefined;
|
|
123
124
|
onLog: CallbackConfig['onLog'] | undefined;
|
|
124
125
|
onSimulateTransaction: CallbackConfig['onSimulateTransaction'] | undefined;
|
|
125
|
-
getSwapData: CallbackConfig['getSwapData'];
|
|
126
126
|
getSwapQuotes: CallbackConfig['getSwapQuotes'];
|
|
127
127
|
};
|
|
@@ -24,6 +24,13 @@ type RemoveTransaction = {
|
|
|
24
24
|
export type UpdateTransactionsArguments = AddTransaction | UpdateTransaction | RemoveTransaction;
|
|
25
25
|
export type TradingPanelType = 'deposit' | 'withdraw';
|
|
26
26
|
export type TransactionAction = 'deposit' | 'multi_withdraw' | 'single_withdraw' | 'approve' | 'swap' | 'claim' | 'single_withdraw_and_claim' | 'create_limit_sell_order' | 'limit_order_withdraw' | 'delete_limit_order_withdraw';
|
|
27
|
+
export interface StepperState {
|
|
28
|
+
type: TradingPanelType;
|
|
29
|
+
sendTokenAmount?: string;
|
|
30
|
+
sendTokenSymbol: string;
|
|
31
|
+
receiveTokenAmount?: string;
|
|
32
|
+
receiveTokenSymbol: string;
|
|
33
|
+
}
|
|
27
34
|
export type SwapEntity = 'token' | 'pool';
|
|
28
35
|
export interface TokenSelectorPayload {
|
|
29
36
|
isOpen: boolean;
|
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 {};
|
|
@@ -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,22 +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 fetchSwapsQuotesWithKey: <K extends string>({ assets, getSwapQuotes, signal, buildKey, }: FetchSwapsQueriesWithKeyParams<K>) => Promise<SwapsQuotesMap<K>>;
|
|
12
|
+
export declare const fetchSwapsQuotesWithKey: <K extends string>({ assets, getSwapQuotes, signal, buildKey, }: FetchSwapsQuotesWithKeyParams<K>) => Promise<SwapsQuotesMap<K>>;
|
|
21
13
|
export declare const getDefaultSwapQuoteIndex: (quotes: unknown[]) => 1 | 0;
|
|
22
|
-
export {};
|