@dhedge/trading-widget 1.1.3 → 1.1.5
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 +13 -12
- package/core-kit/const/config.d.ts +3 -0
- package/core-kit/const/default-data.d.ts +2 -1
- package/core-kit/hooks/state/default-data.d.ts +1 -0
- package/core-kit/hooks/state/index.d.ts +1 -0
- package/core-kit/hooks/trading/index.d.ts +1 -1
- package/core-kit/hooks/trading/synthetix-v3/use-oracles-update-transaction-data.d.ts +15 -0
- package/core-kit/hooks/trading/synthetix-v3/use-send-oracles-update-transaction.d.ts +4 -0
- package/core-kit/hooks/trading/{use-synthetix-v3-oracles-update.d.ts → synthetix-v3/use-synthetix-v3-oracles-update.d.ts} +0 -4
- package/core-kit/types/state.types.d.ts +1 -0
- package/core-kit/utils/synthetix.d.ts +0 -8
- package/{index-658eed6d.cjs → index-58b74a3d.cjs} +44 -44
- package/{index-037c1d88.js → index-f50a343e.js} +3463 -3462
- package/index.cjs +1 -1
- package/index.d.ts +2 -2
- package/index.js +241 -243
- package/package.json +1 -1
- package/{pyth-adapter-9083af33.js → pyth-adapter-0488bb72.js} +1 -1
- package/{pyth-adapter-4374c971.cjs → pyth-adapter-db7181dd.cjs} +1 -1
package/README.md
CHANGED
|
@@ -79,18 +79,19 @@ Top level provider component. Headless part of trading logic. API handles params
|
|
|
79
79
|
<details>
|
|
80
80
|
<summary><code>initialState</code> <code><b>/</b></code> <code>Optional initial state of trading panel</code></summary>
|
|
81
81
|
|
|
82
|
-
> | name
|
|
83
|
-
>
|
|
84
|
-
> | `poolAddress`
|
|
85
|
-
> | `poolConfigMap`
|
|
86
|
-
> | `settings`
|
|
87
|
-
> | `type`
|
|
88
|
-
> | `input`
|
|
89
|
-
> | `entryFee`
|
|
90
|
-
> | `meta`
|
|
91
|
-
> | `modal`
|
|
92
|
-
> | `transactions`
|
|
93
|
-
> | `poolFallbackData`
|
|
82
|
+
> | name | type | default value | description |
|
|
83
|
+
> |--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------|
|
|
84
|
+
> | `poolAddress` | Address | `AddressZero` | Current active pool address |
|
|
85
|
+
> | `poolConfigMap` | Record<Address, PoolConfig> | `{}` | Map of pool configs available for trading |
|
|
86
|
+
> | `settings` | { slippage: `number \| 'auto'`; minSlippage?: `number`; isInfiniteAllowance: `boolean`; isMultiAssetWithdrawalEnabled: `boolean`; isMaxSlippageLoading: `boolean` } | { slippage: `'auto'`; isInfiniteAllowance: `false`; isMultiAssetWithdrawalEnabled: `true`; isMaxSlippageLoading: `false` } | Panel settings |
|
|
87
|
+
> | `type` | 'deposit' \| 'withdraw' | `'deposit'` | Trading type |
|
|
88
|
+
> | `input` | { sendToken: { address: `Address`; symbol: `string`; value: `string`; decimals: `number`; isLoading?: `boolean` }; receiveToken: { address: `Address`; symbol: `string`; value: `string`; decimals: `number`; isLoading?: `boolean` } } | `poolConfigMap[poolAddress]` | Send/receive tokens pair |
|
|
89
|
+
> | `entryFee` | { deposit: `number`; depositWithCustomCooldown: `number`; } | { deposit: `0`; depositWithCustomCooldown: `0.1` } | Entry fee config map |
|
|
90
|
+
> | `meta` | { approvingStatus?: `'pending' \| 'success'` } | `{}` | Trading meta info |
|
|
91
|
+
> | `modal` | { isOpen: `boolean`; status: `'Success' \| 'None' \| 'Mining' \| 'Wallet'`; action: `'deposit' \| 'withdraw' \| 'approve \| 'oraclesUpdate'`; link?: `string`; sendToken: TradingToken \| null; receiveToken: TradingToken \| null } | `{ isOpen: `false`,status: `'None'`, receiveToken: `null`, sendToken: `null` }` | Trading modal state |
|
|
92
|
+
> | `transactions` | { action: `'deposit' \| 'withdraw' \| 'approve'`; symbol: `string`; chainId: `ChainId`; txHash?: `Address` }[] | `[]` | Pending transactions |
|
|
93
|
+
> | `poolFallbackData` | { address: `Address`; managerLogicAddress?: `Address`; poolCompositions: `PoolComposition[]`; tokenPrice?: `string`; apy?: { value: `number`; currency: `'USD' \| 'ETH'` } } | { address: `AddressZero` } | Current active pool fallback data to override or extend contract's response |
|
|
94
|
+
> | `defaultChainId` | number (optional) | undefined | Chain id that will be returned from useNetwork wagmi hook when connected to unsupported network |
|
|
94
95
|
|
|
95
96
|
###### Source: `packages/trading-widget/src/core-kit/providers/index.tsx`
|
|
96
97
|
###### Default values: `packages/trading-widget/src/core-kit/providers/index.tsx`
|
|
@@ -4,10 +4,11 @@ import type { PoolDepositMethodName } from 'core-kit/types/trading.types';
|
|
|
4
4
|
export declare const DEFAULT_PRECISION = 18;
|
|
5
5
|
export declare const DEFAULT_POLLING_INTERVAL = 59000;
|
|
6
6
|
export declare const SHORTEN_POLLING_INTERVAL = 30000;
|
|
7
|
+
export declare const EXTREMELY_SHORT_POLLING_INTERVAL = 15000;
|
|
8
|
+
export declare const DEFAULT_RETRIES_NUMBER = 5;
|
|
7
9
|
export declare const DEFAULT_LOCK_TIME: string;
|
|
8
10
|
export declare const CUSTOM_LOCK_TIME: string;
|
|
9
11
|
export declare const DEFAULT_DEPOSIT_LOCKTIME_MAP: Record<PoolDepositMethodName, string>;
|
|
10
|
-
export declare const DEFAULT_CHAIN_ID: 10;
|
|
11
12
|
export declare const EMPTY_POOL_CONFIG: PoolConfig;
|
|
12
13
|
export declare const DEFAULT_DEPOSIT_METHOD: DepositMethodName;
|
|
13
14
|
export declare const DEFAULT_WITHDRAW_SLIPPAGE = 3;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useTradingPanelDefaultChainId: () => number | undefined;
|
|
@@ -7,3 +7,4 @@ export { useTradingPanelModal } from './modal';
|
|
|
7
7
|
export { useTradingPanelType, useIsDepositTradingPanelType } from './type';
|
|
8
8
|
export { useTradingPanelTransactions } from './transaction';
|
|
9
9
|
export { useTradingPanelActions, useTradingPanelState } from './context';
|
|
10
|
+
export { useTradingPanelDefaultChainId } from './default-data';
|
|
@@ -10,7 +10,7 @@ export { useExchangeRate } from './use-exchange-rate';
|
|
|
10
10
|
export { useHandleTrade } from './use-handle-trade';
|
|
11
11
|
export { useMinReceiveText } from './use-min-receive-text';
|
|
12
12
|
export { useMaxSlippagePlaceholder } from './use-max-slippage-placeholder';
|
|
13
|
-
export { useSynthetixV3OraclesUpdate } from './use-synthetix-v3-oracles-update';
|
|
13
|
+
export { useSynthetixV3OraclesUpdate } from './synthetix-v3/use-synthetix-v3-oracles-update';
|
|
14
14
|
export { useDepositProjectedEarnings } from './projected-earnings/use-deposit-projected-earnings';
|
|
15
15
|
export { useProjectedEarningsCore } from './projected-earnings/use-projected-earnings-core';
|
|
16
16
|
export { useIsEasySwapperTrading } from './use-is-easy-swapper-trading';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DefaultError, UseQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import type { usePublicClient } from 'wagmi';
|
|
3
|
+
import type { Address, TransactionRequest } from 'core-kit/types';
|
|
4
|
+
interface UseOraclesUpdateQueryVariables {
|
|
5
|
+
account?: Address;
|
|
6
|
+
chainId: number;
|
|
7
|
+
vaultAddress: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const useOraclesUpdateTransactionData: ({ publicClient, account, chainId, vaultAddress, }: {
|
|
10
|
+
publicClient: NonNullable<ReturnType<typeof usePublicClient>> | undefined;
|
|
11
|
+
} & UseOraclesUpdateQueryVariables, options?: Omit<UseQueryOptions<TransactionRequest | null, DefaultError, TransactionRequest | null, [
|
|
12
|
+
string,
|
|
13
|
+
UseOraclesUpdateQueryVariables
|
|
14
|
+
]>, 'queryKey' | 'queryFn'>) => import("@tanstack/react-query/build/legacy/types").UseQueryResult<TransactionRequest | null, Error>;
|
|
15
|
+
export {};
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { useSendTransaction } from '../web3';
|
|
2
|
-
export declare const useSendUpdateTransaction: ({ chainId, }: {
|
|
3
|
-
chainId: number;
|
|
4
|
-
}) => ReturnType<typeof useSendTransaction>;
|
|
5
1
|
export declare const useSynthetixV3OraclesUpdate: ({ disabled, }: {
|
|
6
2
|
disabled?: boolean | undefined;
|
|
7
3
|
}) => {
|
|
@@ -32,6 +32,7 @@ export interface TradingPanelState {
|
|
|
32
32
|
poolConfigMap: Record<PoolConfig['address'], PoolConfig>;
|
|
33
33
|
transactions: PendingTransaction[];
|
|
34
34
|
poolFallbackData: PoolFallbackData;
|
|
35
|
+
defaultChainId?: ChainId;
|
|
35
36
|
}
|
|
36
37
|
export interface TradingPanelSetters {
|
|
37
38
|
setPoolAddress: (payload: TradingPanelState['poolAddress']) => void;
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
import type { usePublicClient } from 'core-kit/hooks/web3';
|
|
2
|
-
import type { Address, TransactionRequest } from 'core-kit/types';
|
|
3
1
|
export declare const isSynthetixV3Vault: (address: string) => boolean;
|
|
4
2
|
export declare const isSynthetixV3Asset: (address: string) => boolean;
|
|
5
|
-
export declare const getOracleUpdateTransaction: ({ publicClient, account, chainId, vaultAddress, }: {
|
|
6
|
-
publicClient: NonNullable<ReturnType<typeof usePublicClient>>;
|
|
7
|
-
account?: `0x${string}` | undefined;
|
|
8
|
-
chainId: number;
|
|
9
|
-
vaultAddress: string;
|
|
10
|
-
}) => Promise<TransactionRequest | null>;
|