@dodoex/widgets 1.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/LICENSE +674 -0
- package/README.md +69 -0
- package/dist/cjs/e2e/connect.test.d.ts +6 -0
- package/dist/cjs/e2e/constants.d.ts +79 -0
- package/dist/cjs/e2e/default.test.d.ts +6 -0
- package/dist/cjs/e2e/setup.d.ts +4 -0
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/locales/en-US.js +5 -0
- package/dist/cjs/locales/zh-CN.js +5 -0
- package/dist/cjs/src/components/Swap/components/ConnectWallet/ConnectWalletDialog.d.ts +5 -0
- package/dist/cjs/src/components/Swap/components/ConnectWallet/index.d.ts +9 -0
- package/dist/cjs/src/components/Swap/components/Dialog.d.ts +12 -0
- package/dist/cjs/src/components/Swap/components/ReviewDialog.d.ts +20 -0
- package/dist/cjs/src/components/Swap/components/SettingsDialog/NumberInput.d.ts +8 -0
- package/dist/cjs/src/components/Swap/components/SettingsDialog/index.d.ts +6 -0
- package/dist/cjs/src/components/Swap/components/SwitchBox.d.ts +4 -0
- package/dist/cjs/src/components/Swap/components/TokenCard/BalanceText.d.ts +9 -0
- package/dist/cjs/src/components/Swap/components/TokenCard/NumberInput.d.ts +12 -0
- package/dist/cjs/src/components/Swap/components/TokenCard/TokenLogoCollapse.d.ts +6 -0
- package/dist/cjs/src/components/Swap/components/TokenCard/TokenPickerDialog.d.ts +10 -0
- package/dist/cjs/src/components/Swap/components/TokenCard/index.d.ts +16 -0
- package/dist/cjs/src/components/Swap/components/TokenPairPriceWithToggle.d.ts +10 -0
- package/dist/cjs/src/components/Swap/index.d.ts +2 -0
- package/dist/cjs/src/components/TokenLogo.d.ts +15 -0
- package/dist/cjs/src/components/TokenPicker/PopularToken.d.ts +7 -0
- package/dist/cjs/src/components/TokenPicker/TokenItem.d.ts +8 -0
- package/dist/cjs/src/components/TokenPicker/index.d.ts +14 -0
- package/dist/cjs/src/components/Tooltip/QuestionTooltip.d.ts +3 -0
- package/dist/cjs/src/components/Tooltip/index.d.ts +1 -0
- package/dist/cjs/src/components/Widget/i18n.d.ts +9 -0
- package/dist/cjs/src/components/Widget/index.d.ts +23 -0
- package/dist/cjs/src/components/WithExecutionDialog/index.d.ts +5 -0
- package/dist/cjs/src/constants/address.d.ts +1 -0
- package/dist/cjs/src/constants/api.d.ts +4 -0
- package/dist/cjs/src/constants/chains.d.ts +205 -0
- package/dist/cjs/src/constants/locales.d.ts +3 -0
- package/dist/cjs/src/constants/swap.d.ts +6 -0
- package/dist/cjs/src/constants/testId.d.ts +10 -0
- package/dist/cjs/src/constants/token.d.ts +2 -0
- package/dist/cjs/src/constants/tokenList.d.ts +9 -0
- package/dist/cjs/src/constants/wallet.d.ts +23 -0
- package/dist/cjs/src/hooks/ConnectWallet/Connectors/JsonRpcConnector.d.ts +6 -0
- package/dist/cjs/src/hooks/ConnectWallet/index.d.ts +3 -0
- package/dist/cjs/src/hooks/ConnectWallet/useCurrentChainId.d.ts +2 -0
- package/dist/cjs/src/hooks/ConnectWallet/useWeb3Connectors.d.ts +14 -0
- package/dist/cjs/src/hooks/ConnectWallet/web3.d.ts +10 -0
- package/dist/cjs/src/hooks/Submission/getExecutionErrorMsg.d.ts +2 -0
- package/dist/cjs/src/hooks/Submission/index.d.ts +10 -0
- package/dist/cjs/src/hooks/Submission/spec.d.ts +56 -0
- package/dist/cjs/src/hooks/Submission/types.d.ts +49 -0
- package/dist/cjs/src/hooks/Submission/useExecution.d.ts +23 -0
- package/dist/cjs/src/hooks/Submission/useInflights.d.ts +5 -0
- package/dist/cjs/src/hooks/Swap/index.d.ts +5 -0
- package/dist/cjs/src/hooks/Swap/useExecuteSwap.d.ts +14 -0
- package/dist/cjs/src/hooks/Swap/useFetchFiatPrice.d.ts +13 -0
- package/dist/cjs/src/hooks/Swap/useFetchFiatPrice.test.d.ts +1 -0
- package/dist/cjs/src/hooks/Swap/useFetchRoutePrice.d.ts +25 -0
- package/dist/cjs/src/hooks/Swap/useFetchRoutePrice.test.d.ts +1 -0
- package/dist/cjs/src/hooks/Swap/useMarginAmount.d.ts +8 -0
- package/dist/cjs/src/hooks/Swap/useMarginAmount.test.d.ts +1 -0
- package/dist/cjs/src/hooks/Swap/usePriceTimer.d.ts +5 -0
- package/dist/cjs/src/hooks/Token/index.d.ts +4 -0
- package/dist/cjs/src/hooks/Token/type.d.ts +18 -0
- package/dist/cjs/src/hooks/Token/useFindTokenByAddress.d.ts +1 -0
- package/dist/cjs/src/hooks/Token/useFindTokenByAddress.test.d.ts +1 -0
- package/dist/cjs/src/hooks/Token/useGetAllowance.d.ts +3 -0
- package/dist/cjs/src/hooks/Token/useGetAllowance.test.d.ts +1 -0
- package/dist/cjs/src/hooks/Token/useGetBalance.d.ts +2 -0
- package/dist/cjs/src/hooks/Token/useGetBalance.test.d.ts +1 -0
- package/dist/cjs/src/hooks/Token/useGetTokenStatus.d.ts +13 -0
- package/dist/cjs/src/hooks/Token/useGetTokenStatus.test.d.ts +1 -0
- package/dist/cjs/src/hooks/Token/useInitTokenList.d.ts +6 -0
- package/dist/cjs/src/hooks/Token/useTokenList.d.ts +20 -0
- package/dist/cjs/src/hooks/Token/useTokenList.test.d.ts +1 -0
- package/dist/cjs/src/hooks/Widget/useInitPropsToRedux.d.ts +2 -0
- package/dist/cjs/src/hooks/contract/abis/erc20ABI.d.ts +30 -0
- package/dist/cjs/src/hooks/contract/abis/erc20Helper.d.ts +16 -0
- package/dist/cjs/src/hooks/contract/abis/multicallABI.d.ts +34 -0
- package/dist/cjs/src/hooks/contract/batch.d.ts +18 -0
- package/dist/cjs/src/hooks/contract/contractConfig.d.ts +78 -0
- package/dist/cjs/src/hooks/contract/index.d.ts +4 -0
- package/dist/cjs/src/hooks/contract/useFetchBlockNumber.d.ts +1 -0
- package/dist/cjs/src/hooks/contract/useFetchETHBalance.d.ts +1 -0
- package/dist/cjs/src/hooks/contract/useFetchTokens.d.ts +18 -0
- package/dist/cjs/src/hooks/contract/useMultiContract.d.ts +70 -0
- package/dist/cjs/src/hooks/contract/wallet.d.ts +16 -0
- package/dist/cjs/src/index.d.ts +5 -0
- package/dist/cjs/src/store/actions/globals.d.ts +3 -0
- package/dist/cjs/src/store/actions/index.d.ts +4 -0
- package/dist/cjs/src/store/actions/settings.d.ts +6 -0
- package/dist/cjs/src/store/actions/token.d.ts +15 -0
- package/dist/cjs/src/store/actions/wallet.d.ts +4 -0
- package/dist/cjs/src/store/index.d.ts +6 -0
- package/dist/cjs/src/store/reducers/globals.d.ts +6 -0
- package/dist/cjs/src/store/reducers/index.d.ts +17 -0
- package/dist/cjs/src/store/reducers/settings.d.ts +13 -0
- package/dist/cjs/src/store/reducers/token.d.ts +29 -0
- package/dist/cjs/src/store/reducers/wallet.d.ts +9 -0
- package/dist/cjs/src/store/selectors/globals.d.ts +2 -0
- package/dist/cjs/src/store/selectors/settings.d.ts +4 -0
- package/dist/cjs/src/store/selectors/token.d.ts +16 -0
- package/dist/cjs/src/store/selectors/wallet.d.ts +3 -0
- package/dist/cjs/src/utils/address.d.ts +7 -0
- package/dist/cjs/src/utils/address.test.d.ts +1 -0
- package/dist/cjs/src/utils/chains.d.ts +2 -0
- package/dist/cjs/src/utils/chains.test.d.ts +1 -0
- package/dist/cjs/src/utils/formatter.d.ts +23 -0
- package/dist/cjs/src/utils/formatter.test.d.ts +1 -0
- package/dist/cjs/src/utils/index.d.ts +5 -0
- package/dist/cjs/src/utils/token.d.ts +9 -0
- package/dist/cjs/src/utils/token.test.d.ts +1 -0
- package/dist/cjs/src/utils/wallet.d.ts +8 -0
- package/dist/cjs/src/utils/wallet.test.d.ts +1 -0
- package/dist/cjs/tokenList-ee5e15c8.cjs +1 -0
- package/dist/e2e/connect.test.d.ts +6 -0
- package/dist/e2e/constants.d.ts +79 -0
- package/dist/e2e/default.test.d.ts +6 -0
- package/dist/e2e/setup.d.ts +4 -0
- package/dist/index.js +1 -0
- package/dist/locales/en-US.js +5 -0
- package/dist/locales/zh-CN.js +5 -0
- package/dist/src/components/Swap/components/ConnectWallet/ConnectWalletDialog.d.ts +5 -0
- package/dist/src/components/Swap/components/ConnectWallet/index.d.ts +9 -0
- package/dist/src/components/Swap/components/Dialog.d.ts +12 -0
- package/dist/src/components/Swap/components/ReviewDialog.d.ts +20 -0
- package/dist/src/components/Swap/components/SettingsDialog/NumberInput.d.ts +8 -0
- package/dist/src/components/Swap/components/SettingsDialog/index.d.ts +6 -0
- package/dist/src/components/Swap/components/SwitchBox.d.ts +4 -0
- package/dist/src/components/Swap/components/TokenCard/BalanceText.d.ts +9 -0
- package/dist/src/components/Swap/components/TokenCard/NumberInput.d.ts +12 -0
- package/dist/src/components/Swap/components/TokenCard/TokenLogoCollapse.d.ts +6 -0
- package/dist/src/components/Swap/components/TokenCard/TokenPickerDialog.d.ts +10 -0
- package/dist/src/components/Swap/components/TokenCard/index.d.ts +16 -0
- package/dist/src/components/Swap/components/TokenPairPriceWithToggle.d.ts +10 -0
- package/dist/src/components/Swap/index.d.ts +2 -0
- package/dist/src/components/TokenLogo.d.ts +15 -0
- package/dist/src/components/TokenPicker/PopularToken.d.ts +7 -0
- package/dist/src/components/TokenPicker/TokenItem.d.ts +8 -0
- package/dist/src/components/TokenPicker/index.d.ts +14 -0
- package/dist/src/components/Tooltip/QuestionTooltip.d.ts +3 -0
- package/dist/src/components/Tooltip/index.d.ts +1 -0
- package/dist/src/components/Widget/i18n.d.ts +9 -0
- package/dist/src/components/Widget/index.d.ts +23 -0
- package/dist/src/components/WithExecutionDialog/index.d.ts +5 -0
- package/dist/src/constants/address.d.ts +1 -0
- package/dist/src/constants/api.d.ts +4 -0
- package/dist/src/constants/chains.d.ts +205 -0
- package/dist/src/constants/locales.d.ts +3 -0
- package/dist/src/constants/swap.d.ts +6 -0
- package/dist/src/constants/testId.d.ts +10 -0
- package/dist/src/constants/token.d.ts +2 -0
- package/dist/src/constants/tokenList.d.ts +9 -0
- package/dist/src/constants/wallet.d.ts +23 -0
- package/dist/src/hooks/ConnectWallet/Connectors/JsonRpcConnector.d.ts +6 -0
- package/dist/src/hooks/ConnectWallet/index.d.ts +3 -0
- package/dist/src/hooks/ConnectWallet/useCurrentChainId.d.ts +2 -0
- package/dist/src/hooks/ConnectWallet/useWeb3Connectors.d.ts +14 -0
- package/dist/src/hooks/ConnectWallet/web3.d.ts +10 -0
- package/dist/src/hooks/Submission/getExecutionErrorMsg.d.ts +2 -0
- package/dist/src/hooks/Submission/index.d.ts +10 -0
- package/dist/src/hooks/Submission/spec.d.ts +56 -0
- package/dist/src/hooks/Submission/types.d.ts +49 -0
- package/dist/src/hooks/Submission/useExecution.d.ts +23 -0
- package/dist/src/hooks/Submission/useInflights.d.ts +5 -0
- package/dist/src/hooks/Swap/index.d.ts +5 -0
- package/dist/src/hooks/Swap/useExecuteSwap.d.ts +14 -0
- package/dist/src/hooks/Swap/useFetchFiatPrice.d.ts +13 -0
- package/dist/src/hooks/Swap/useFetchFiatPrice.test.d.ts +1 -0
- package/dist/src/hooks/Swap/useFetchRoutePrice.d.ts +25 -0
- package/dist/src/hooks/Swap/useFetchRoutePrice.test.d.ts +1 -0
- package/dist/src/hooks/Swap/useMarginAmount.d.ts +8 -0
- package/dist/src/hooks/Swap/useMarginAmount.test.d.ts +1 -0
- package/dist/src/hooks/Swap/usePriceTimer.d.ts +5 -0
- package/dist/src/hooks/Token/index.d.ts +4 -0
- package/dist/src/hooks/Token/type.d.ts +18 -0
- package/dist/src/hooks/Token/useFindTokenByAddress.d.ts +1 -0
- package/dist/src/hooks/Token/useFindTokenByAddress.test.d.ts +1 -0
- package/dist/src/hooks/Token/useGetAllowance.d.ts +3 -0
- package/dist/src/hooks/Token/useGetAllowance.test.d.ts +1 -0
- package/dist/src/hooks/Token/useGetBalance.d.ts +2 -0
- package/dist/src/hooks/Token/useGetBalance.test.d.ts +1 -0
- package/dist/src/hooks/Token/useGetTokenStatus.d.ts +13 -0
- package/dist/src/hooks/Token/useGetTokenStatus.test.d.ts +1 -0
- package/dist/src/hooks/Token/useInitTokenList.d.ts +6 -0
- package/dist/src/hooks/Token/useTokenList.d.ts +20 -0
- package/dist/src/hooks/Token/useTokenList.test.d.ts +1 -0
- package/dist/src/hooks/Widget/useInitPropsToRedux.d.ts +2 -0
- package/dist/src/hooks/contract/abis/erc20ABI.d.ts +30 -0
- package/dist/src/hooks/contract/abis/erc20Helper.d.ts +16 -0
- package/dist/src/hooks/contract/abis/multicallABI.d.ts +34 -0
- package/dist/src/hooks/contract/batch.d.ts +18 -0
- package/dist/src/hooks/contract/contractConfig.d.ts +78 -0
- package/dist/src/hooks/contract/index.d.ts +4 -0
- package/dist/src/hooks/contract/useFetchBlockNumber.d.ts +1 -0
- package/dist/src/hooks/contract/useFetchETHBalance.d.ts +1 -0
- package/dist/src/hooks/contract/useFetchTokens.d.ts +18 -0
- package/dist/src/hooks/contract/useMultiContract.d.ts +70 -0
- package/dist/src/hooks/contract/wallet.d.ts +16 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/store/actions/globals.d.ts +3 -0
- package/dist/src/store/actions/index.d.ts +4 -0
- package/dist/src/store/actions/settings.d.ts +6 -0
- package/dist/src/store/actions/token.d.ts +15 -0
- package/dist/src/store/actions/wallet.d.ts +4 -0
- package/dist/src/store/index.d.ts +6 -0
- package/dist/src/store/reducers/globals.d.ts +6 -0
- package/dist/src/store/reducers/index.d.ts +17 -0
- package/dist/src/store/reducers/settings.d.ts +13 -0
- package/dist/src/store/reducers/token.d.ts +29 -0
- package/dist/src/store/reducers/wallet.d.ts +9 -0
- package/dist/src/store/selectors/globals.d.ts +2 -0
- package/dist/src/store/selectors/settings.d.ts +4 -0
- package/dist/src/store/selectors/token.d.ts +16 -0
- package/dist/src/store/selectors/wallet.d.ts +3 -0
- package/dist/src/utils/address.d.ts +7 -0
- package/dist/src/utils/address.test.d.ts +1 -0
- package/dist/src/utils/chains.d.ts +2 -0
- package/dist/src/utils/chains.test.d.ts +1 -0
- package/dist/src/utils/formatter.d.ts +23 -0
- package/dist/src/utils/formatter.test.d.ts +1 -0
- package/dist/src/utils/index.d.ts +5 -0
- package/dist/src/utils/token.d.ts +9 -0
- package/dist/src/utils/token.test.d.ts +1 -0
- package/dist/src/utils/wallet.d.ts +8 -0
- package/dist/src/utils/wallet.test.d.ts +1 -0
- package/dist/tokenList-4ef211de.js +1 -0
- package/package.json +131 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BoxProps } from '@dodoex/components';
|
|
3
|
+
import { TokenInfo } from '../hooks/Token';
|
|
4
|
+
export interface TokenLogoProps {
|
|
5
|
+
address?: string;
|
|
6
|
+
token?: TokenInfo;
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
marginRight?: number;
|
|
10
|
+
url?: string;
|
|
11
|
+
zIndex?: number;
|
|
12
|
+
cross?: boolean;
|
|
13
|
+
sx?: BoxProps['sx'];
|
|
14
|
+
}
|
|
15
|
+
export default function TokenLogo({ width, height, marginRight, url, zIndex, cross, address: addressProps, token: tokenProps, sx, }: TokenLogoProps): React.ReactElement;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { TokenInfo } from './../../hooks/Token';
|
|
3
|
+
export default function TokenItem({ token, disabled, style, onClick, }: {
|
|
4
|
+
token: TokenInfo;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
style?: CSSProperties;
|
|
7
|
+
onClick: () => void;
|
|
8
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { TokenInfo } from '../../hooks/Token';
|
|
3
|
+
export interface TokenPickerProps {
|
|
4
|
+
value?: TokenInfo | null;
|
|
5
|
+
onChange: (token: TokenInfo, isOccupied: boolean) => void;
|
|
6
|
+
/** token pair usage */
|
|
7
|
+
occupiedAddrs?: string[];
|
|
8
|
+
/** hide props */
|
|
9
|
+
hiddenAddrs?: string[];
|
|
10
|
+
/** only show props */
|
|
11
|
+
showAddrs?: string[];
|
|
12
|
+
visible?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export default function TokenPicker({ value, onChange, occupiedAddrs, hiddenAddrs, showAddrs, visible, }: TokenPickerProps): JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as QuestionTooltip } from './QuestionTooltip';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SupportedLang } from '../../constants/locales';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
interface LangProviderProps {
|
|
4
|
+
locale?: SupportedLang;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare function loadI18(locale?: SupportedLang): Promise<void>;
|
|
8
|
+
export declare function LangProvider({ locale, children }: LangProviderProps): JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { PaletteMode, ThemeOptions } from '@dodoex/components';
|
|
3
|
+
import { SupportedLang } from '../../constants/locales';
|
|
4
|
+
import { Web3ConnectorsProps } from '../../hooks/ConnectWallet';
|
|
5
|
+
import { InitTokenListProps } from '../../hooks/Token/useInitTokenList';
|
|
6
|
+
import { ExecutionProps } from '../../hooks/Submission';
|
|
7
|
+
import { ChainId } from '../../constants/chains';
|
|
8
|
+
import { TokenInfo } from '../../hooks/Token/type';
|
|
9
|
+
export declare const WIDGET_CLASS_NAME = "dodo-widget-container";
|
|
10
|
+
export interface WidgetProps extends Web3ConnectorsProps, InitTokenListProps, ExecutionProps {
|
|
11
|
+
theme?: ThemeOptions;
|
|
12
|
+
colorMode?: PaletteMode;
|
|
13
|
+
accessToken?: string;
|
|
14
|
+
defaultChainId?: ChainId;
|
|
15
|
+
width?: string | number;
|
|
16
|
+
height?: string | number;
|
|
17
|
+
feeRate?: number;
|
|
18
|
+
rebateTo?: string;
|
|
19
|
+
defaultFromToken?: TokenInfo;
|
|
20
|
+
defaultToToken?: TokenInfo;
|
|
21
|
+
locale?: SupportedLang;
|
|
22
|
+
}
|
|
23
|
+
export declare function Widget(props: PropsWithChildren<WidgetProps>): JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EmptyAddress = "0x0000000000000000000000000000000000000000";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const RoutePriceAPI = "https://route-api.dodoex.io";
|
|
2
|
+
export declare const RoutePriceDevAPI = "https://test-route-api.dodoex.io";
|
|
3
|
+
export declare const FiatPriceAPI = "https://api.dodoex.io/price-api";
|
|
4
|
+
export declare const AppUrl = "https://app.dodoex.io";
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
export declare enum ChainId {
|
|
2
|
+
MAINNET = 1,
|
|
3
|
+
RINKEBY = 4,
|
|
4
|
+
GOERLI = 5,
|
|
5
|
+
BSC = 56,
|
|
6
|
+
HECO = 128,
|
|
7
|
+
POLYGON = 137,
|
|
8
|
+
ARBITRUM_ONE = 42161,
|
|
9
|
+
ARBITRUM_RINKEBY = 421611,
|
|
10
|
+
AURORA = 1313161554,
|
|
11
|
+
MOONRIVER = 1285,
|
|
12
|
+
OKCHAIN = 66,
|
|
13
|
+
OPTIMISM = 10,
|
|
14
|
+
BOBA = 288,
|
|
15
|
+
AVALANCHE = 43114,
|
|
16
|
+
CRONOS = 25
|
|
17
|
+
}
|
|
18
|
+
export declare const rpcServerMap: {
|
|
19
|
+
1: string[];
|
|
20
|
+
4: string[];
|
|
21
|
+
5: string[];
|
|
22
|
+
56: string[];
|
|
23
|
+
128: string[];
|
|
24
|
+
137: string[];
|
|
25
|
+
42161: string[];
|
|
26
|
+
421611: string[];
|
|
27
|
+
1313161554: string[];
|
|
28
|
+
1285: string[];
|
|
29
|
+
66: string[];
|
|
30
|
+
10: string[];
|
|
31
|
+
288: string[];
|
|
32
|
+
43114: string[];
|
|
33
|
+
25: string[];
|
|
34
|
+
};
|
|
35
|
+
export declare const basicTokenMap: {
|
|
36
|
+
1: {
|
|
37
|
+
wrappedTokenAddress: string;
|
|
38
|
+
symbol: string;
|
|
39
|
+
address: string;
|
|
40
|
+
name: string;
|
|
41
|
+
decimals: number;
|
|
42
|
+
showDecimals: number;
|
|
43
|
+
wrappedTokenSymbol: string;
|
|
44
|
+
};
|
|
45
|
+
4: {
|
|
46
|
+
wrappedTokenAddress: string;
|
|
47
|
+
symbol: string;
|
|
48
|
+
address: string;
|
|
49
|
+
name: string;
|
|
50
|
+
decimals: number;
|
|
51
|
+
showDecimals: number;
|
|
52
|
+
wrappedTokenSymbol: string;
|
|
53
|
+
};
|
|
54
|
+
5: {
|
|
55
|
+
wrappedTokenAddress: string;
|
|
56
|
+
symbol: string;
|
|
57
|
+
address: string;
|
|
58
|
+
name: string;
|
|
59
|
+
decimals: number;
|
|
60
|
+
showDecimals: number;
|
|
61
|
+
wrappedTokenSymbol: string;
|
|
62
|
+
};
|
|
63
|
+
10: {
|
|
64
|
+
wrappedTokenAddress: string;
|
|
65
|
+
symbol: string;
|
|
66
|
+
address: string;
|
|
67
|
+
name: string;
|
|
68
|
+
decimals: number;
|
|
69
|
+
showDecimals: number;
|
|
70
|
+
wrappedTokenSymbol: string;
|
|
71
|
+
};
|
|
72
|
+
25: {
|
|
73
|
+
symbol: string;
|
|
74
|
+
name: string;
|
|
75
|
+
wrappedTokenSymbol: string;
|
|
76
|
+
wrappedTokenAddress: string;
|
|
77
|
+
address: string;
|
|
78
|
+
decimals: number;
|
|
79
|
+
showDecimals: number;
|
|
80
|
+
};
|
|
81
|
+
288: {
|
|
82
|
+
wrappedTokenAddress: string;
|
|
83
|
+
symbol: string;
|
|
84
|
+
address: string;
|
|
85
|
+
name: string;
|
|
86
|
+
decimals: number;
|
|
87
|
+
showDecimals: number;
|
|
88
|
+
wrappedTokenSymbol: string;
|
|
89
|
+
};
|
|
90
|
+
56: {
|
|
91
|
+
symbol: string;
|
|
92
|
+
name: string;
|
|
93
|
+
wrappedTokenSymbol: string;
|
|
94
|
+
wrappedTokenAddress: string;
|
|
95
|
+
address: string;
|
|
96
|
+
decimals: number;
|
|
97
|
+
showDecimals: number;
|
|
98
|
+
};
|
|
99
|
+
66: {
|
|
100
|
+
symbol: string;
|
|
101
|
+
name: string;
|
|
102
|
+
wrappedTokenSymbol: string;
|
|
103
|
+
wrappedTokenAddress: string;
|
|
104
|
+
address: string;
|
|
105
|
+
decimals: number;
|
|
106
|
+
showDecimals: number;
|
|
107
|
+
};
|
|
108
|
+
128: {
|
|
109
|
+
symbol: string;
|
|
110
|
+
name: string;
|
|
111
|
+
showDecimals: number;
|
|
112
|
+
wrappedTokenSymbol: string;
|
|
113
|
+
wrappedTokenAddress: string;
|
|
114
|
+
address: string;
|
|
115
|
+
decimals: number;
|
|
116
|
+
};
|
|
117
|
+
137: {
|
|
118
|
+
symbol: string;
|
|
119
|
+
name: string;
|
|
120
|
+
showDecimals: number;
|
|
121
|
+
wrappedTokenSymbol: string;
|
|
122
|
+
wrappedTokenAddress: string;
|
|
123
|
+
address: string;
|
|
124
|
+
decimals: number;
|
|
125
|
+
};
|
|
126
|
+
1285: {
|
|
127
|
+
symbol: string;
|
|
128
|
+
name: string;
|
|
129
|
+
showDecimals: number;
|
|
130
|
+
wrappedTokenSymbol: string;
|
|
131
|
+
wrappedTokenAddress: string;
|
|
132
|
+
address: string;
|
|
133
|
+
decimals: number;
|
|
134
|
+
};
|
|
135
|
+
42161: {
|
|
136
|
+
name: string;
|
|
137
|
+
showDecimals: number;
|
|
138
|
+
wrappedTokenAddress: string;
|
|
139
|
+
symbol: string;
|
|
140
|
+
address: string;
|
|
141
|
+
decimals: number;
|
|
142
|
+
wrappedTokenSymbol: string;
|
|
143
|
+
};
|
|
144
|
+
421611: {
|
|
145
|
+
name: string;
|
|
146
|
+
showDecimals: number;
|
|
147
|
+
wrappedTokenAddress: string;
|
|
148
|
+
symbol: string;
|
|
149
|
+
address: string;
|
|
150
|
+
decimals: number;
|
|
151
|
+
wrappedTokenSymbol: string;
|
|
152
|
+
};
|
|
153
|
+
1313161554: {
|
|
154
|
+
name: string;
|
|
155
|
+
showDecimals: number;
|
|
156
|
+
wrappedTokenAddress: string;
|
|
157
|
+
symbol: string;
|
|
158
|
+
address: string;
|
|
159
|
+
decimals: number;
|
|
160
|
+
wrappedTokenSymbol: string;
|
|
161
|
+
};
|
|
162
|
+
43114: {
|
|
163
|
+
symbol: string;
|
|
164
|
+
name: string;
|
|
165
|
+
showDecimals: number;
|
|
166
|
+
wrappedTokenSymbol: string;
|
|
167
|
+
wrappedTokenAddress: string;
|
|
168
|
+
address: string;
|
|
169
|
+
decimals: number;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
export declare const platformIdMap: {
|
|
173
|
+
1: string;
|
|
174
|
+
4: string;
|
|
175
|
+
5: string;
|
|
176
|
+
10: string;
|
|
177
|
+
25: string;
|
|
178
|
+
288: string;
|
|
179
|
+
56: string;
|
|
180
|
+
66: string;
|
|
181
|
+
128: string;
|
|
182
|
+
137: string;
|
|
183
|
+
1285: string;
|
|
184
|
+
42161: string;
|
|
185
|
+
421611: string;
|
|
186
|
+
1313161554: string;
|
|
187
|
+
43114: string;
|
|
188
|
+
};
|
|
189
|
+
export declare const scanUrlDomainMap: {
|
|
190
|
+
1: string;
|
|
191
|
+
4: string;
|
|
192
|
+
5: string;
|
|
193
|
+
10: string;
|
|
194
|
+
25: string;
|
|
195
|
+
288: string;
|
|
196
|
+
56: string;
|
|
197
|
+
66: string;
|
|
198
|
+
128: string;
|
|
199
|
+
137: string;
|
|
200
|
+
1285: string;
|
|
201
|
+
42161: string;
|
|
202
|
+
421611: string;
|
|
203
|
+
1313161554: string;
|
|
204
|
+
43114: string;
|
|
205
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const AUTO_SWAP_SLIPPAGE_PROTECTION = "auto";
|
|
2
|
+
export declare const PRICE_IMPACT_THRESHOLD = 15;
|
|
3
|
+
export declare const DEFAULT_SWAP_SLIPPAGE = 3;
|
|
4
|
+
export declare const MAX_SWAP_SLIPPAGE = 50;
|
|
5
|
+
export declare const DEFAULT_SWAP_DDL = 20;
|
|
6
|
+
export declare const MIN_GAS_LIMIT = 30000;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const connectWalletBtn = "connect-wallet-btn";
|
|
2
|
+
export declare const swapAlertSelectTokenBtn = "swap-alert-select-token-btn";
|
|
3
|
+
export declare const swapReviewBtn = "swap-review-btn";
|
|
4
|
+
export declare const swapSelectTokenBtn = "swap-select-token-btn";
|
|
5
|
+
export declare const swapAlertEnterAmountBtn = "swap-alert-enter-amount-btn";
|
|
6
|
+
export declare const swapAlertFetchPriceBtn = "swap-alert-fetch-price-btn";
|
|
7
|
+
export declare const swapAlertInsufficientBalanceBtn = "swap-alert-insufficient-balance-btn";
|
|
8
|
+
export declare const numberInputWrapper = "number-input-wrapper";
|
|
9
|
+
export declare const tokenPickerWrapper = "token-picker-wrapper";
|
|
10
|
+
export declare const tokenPickerItem = "token-picker-item";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare enum WalletType {
|
|
3
|
+
INTEGRATOR = "integrator",
|
|
4
|
+
METAMASK = "metamask",
|
|
5
|
+
WALLET_CONNECT = "walletConnect"
|
|
6
|
+
}
|
|
7
|
+
export declare const WalletMap: {
|
|
8
|
+
metamask: {
|
|
9
|
+
name: string;
|
|
10
|
+
type: WalletType;
|
|
11
|
+
icon: import("react").FunctionComponent<import("react").SVGProps<SVGSVGElement> & {
|
|
12
|
+
title?: string | undefined;
|
|
13
|
+
}>;
|
|
14
|
+
link: string;
|
|
15
|
+
};
|
|
16
|
+
walletConnect: {
|
|
17
|
+
name: string;
|
|
18
|
+
type: WalletType;
|
|
19
|
+
icon: import("react").FunctionComponent<import("react").SVGProps<SVGSVGElement> & {
|
|
20
|
+
title?: string | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { JsonRpcProvider } from '@ethersproject/providers';
|
|
2
|
+
import { Actions, Connector } from '@web3-react/types';
|
|
3
|
+
export default class JsonRpcConnector extends Connector {
|
|
4
|
+
constructor(actions: Actions, customProvider: JsonRpcProvider);
|
|
5
|
+
activate(): Promise<void>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Provider as Eip1193Provider } from '@web3-react/types';
|
|
2
|
+
import { JsonRpcProvider } from '@ethersproject/providers';
|
|
3
|
+
import { ChainId } from '../../constants/chains';
|
|
4
|
+
import { Web3Connection } from './web3';
|
|
5
|
+
import { WalletType } from '../../constants/wallet';
|
|
6
|
+
export interface Web3ConnectorsProps {
|
|
7
|
+
provider?: Eip1193Provider | JsonRpcProvider;
|
|
8
|
+
jsonRpcUrlMap?: {
|
|
9
|
+
[chainId: number]: string[];
|
|
10
|
+
};
|
|
11
|
+
defaultChainId?: ChainId;
|
|
12
|
+
}
|
|
13
|
+
export declare function useWeb3Connectors({ provider, jsonRpcUrlMap: jsonRpcUrlMapProps, defaultChainId, }: Web3ConnectorsProps): Web3Connection[];
|
|
14
|
+
export declare function connectToWallet(type: WalletType, chainId: number | undefined, onError: (error: Error) => void): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Web3ReactHooks } from '@web3-react/core';
|
|
2
|
+
import { Connector, Provider as Eip1193Provider } from '@web3-react/types';
|
|
3
|
+
import { JsonRpcProvider } from '@ethersproject/providers';
|
|
4
|
+
import type { ChainId } from '../../constants/chains';
|
|
5
|
+
export declare type Web3Connection = [Connector, Web3ReactHooks];
|
|
6
|
+
export declare function getConnectionFromProvider(onError: (error: Error) => void, provider?: JsonRpcProvider | Eip1193Provider): Web3Connection | undefined;
|
|
7
|
+
export declare function getConnectionFromWalletConnect(useDefault: boolean, jsonRpcUrlMap: {
|
|
8
|
+
[chainId: number]: string[];
|
|
9
|
+
}, defaultChainId: ChainId | undefined, onError: (error: Error) => void): Web3Connection;
|
|
10
|
+
export declare function getConnectionFromMetaMask(onError: (error: Error) => void): Web3Connection;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ExecutionCtx } from './types';
|
|
3
|
+
export { default as useExecution } from './useExecution';
|
|
4
|
+
export type { ExecutionProps } from './useExecution';
|
|
5
|
+
export { default as useInflights } from './useInflights';
|
|
6
|
+
export declare const ExecutionContext: import("react").Context<ExecutionCtx>;
|
|
7
|
+
/**
|
|
8
|
+
* Get the submission context
|
|
9
|
+
*/
|
|
10
|
+
export declare function useSubmission(): ExecutionCtx;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Let's pretend that typescript has ADT
|
|
3
|
+
*/
|
|
4
|
+
import { BigNumber } from 'bignumber.js';
|
|
5
|
+
import { BigNumber as EthersBigNumber } from '@ethersproject/bignumber';
|
|
6
|
+
/**
|
|
7
|
+
* All supported opcodes, as tagged union discriminants
|
|
8
|
+
*/
|
|
9
|
+
export declare enum OpCode {
|
|
10
|
+
Approval = "APPROVAL",
|
|
11
|
+
TX = "TX",
|
|
12
|
+
TypedSign = "TypedSign"
|
|
13
|
+
}
|
|
14
|
+
export declare enum SwapType {
|
|
15
|
+
Normal = "Normal",
|
|
16
|
+
Privacy = "Privacy",
|
|
17
|
+
LimitOrder = "LimitOrder",
|
|
18
|
+
RFQ = "RFQ"
|
|
19
|
+
}
|
|
20
|
+
export declare type TokenData = {
|
|
21
|
+
address: string;
|
|
22
|
+
};
|
|
23
|
+
export declare type ApprovalStep = {
|
|
24
|
+
opcode: OpCode.Approval;
|
|
25
|
+
/**
|
|
26
|
+
* The address of the token
|
|
27
|
+
*/
|
|
28
|
+
token: TokenData;
|
|
29
|
+
/**
|
|
30
|
+
* The approved contract address
|
|
31
|
+
*/
|
|
32
|
+
contract: string;
|
|
33
|
+
/**
|
|
34
|
+
* The amount to set the allowance to, in Wei, in base-10. If omitted, a (very) big constants is used
|
|
35
|
+
* TODO(meow): bigint shows a 87% support rate. Can we use it here?
|
|
36
|
+
*/
|
|
37
|
+
amt?: BigNumber;
|
|
38
|
+
};
|
|
39
|
+
export declare type TXStep = {
|
|
40
|
+
opcode: OpCode.TX;
|
|
41
|
+
value: number | string;
|
|
42
|
+
to: string;
|
|
43
|
+
data: string;
|
|
44
|
+
swapType?: SwapType;
|
|
45
|
+
gasLimit?: EthersBigNumber;
|
|
46
|
+
gasPrice?: number;
|
|
47
|
+
ddlSecRel?: number;
|
|
48
|
+
};
|
|
49
|
+
export declare type TypedSignStep = {
|
|
50
|
+
opcode: OpCode.TypedSign;
|
|
51
|
+
swapType?: SwapType;
|
|
52
|
+
signer?: string;
|
|
53
|
+
typedData: Record<string, unknown>;
|
|
54
|
+
};
|
|
55
|
+
export declare type Step = ApprovalStep | TXStep | TypedSignStep;
|
|
56
|
+
export declare type Steps = Step[];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Step as StepSpec } from './spec';
|
|
3
|
+
export declare enum State {
|
|
4
|
+
Running = 0,
|
|
5
|
+
Success = 1,
|
|
6
|
+
Failed = 2,
|
|
7
|
+
Warning = 3
|
|
8
|
+
}
|
|
9
|
+
export declare type Request = {
|
|
10
|
+
brief: string;
|
|
11
|
+
spec: StepSpec;
|
|
12
|
+
subtitle?: string | React.ReactNode | null;
|
|
13
|
+
tx: string;
|
|
14
|
+
nonce?: number;
|
|
15
|
+
};
|
|
16
|
+
export declare type Requests = Map<string, [Request, State]>;
|
|
17
|
+
export declare enum ExecutionResult {
|
|
18
|
+
Canceled = "canceled",
|
|
19
|
+
Failed = "failed",
|
|
20
|
+
Success = "success",
|
|
21
|
+
Submitted = "submitted"
|
|
22
|
+
}
|
|
23
|
+
export interface Showing {
|
|
24
|
+
brief: string;
|
|
25
|
+
subtitle?: string | React.ReactNode;
|
|
26
|
+
spec: StepSpec;
|
|
27
|
+
}
|
|
28
|
+
export declare type ExecutionCtx = {
|
|
29
|
+
/**
|
|
30
|
+
* Execute an on-chain operation
|
|
31
|
+
* @param breif: TX title. e.g.: "Swap"
|
|
32
|
+
* @param spec: TX specification.
|
|
33
|
+
* @param subtitle: Additional hint text. e.g.: "10 USDT to 10 USDC"
|
|
34
|
+
* @param early: When given, the returned promise resolves when user confirmed in their wallet.
|
|
35
|
+
* @param mixpanelProps: mixpanel properties
|
|
36
|
+
* @param submittedConfirmBack: dismiss callback
|
|
37
|
+
*/
|
|
38
|
+
execute: (brief: string, spec: StepSpec, subtitle?: string | React.ReactNode | null, early?: boolean, submittedBack?: () => void, mixpanelProps?: Record<string, any>, submittedConfirmBack?: () => void, successBack?: (tx: string) => void) => Promise<ExecutionResult>;
|
|
39
|
+
/**
|
|
40
|
+
* order
|
|
41
|
+
*/
|
|
42
|
+
requests?: Requests;
|
|
43
|
+
setShowing?: React.Dispatch<React.SetStateAction<Showing | null>>;
|
|
44
|
+
waitingSubmit: boolean;
|
|
45
|
+
};
|
|
46
|
+
export declare enum WatchResult {
|
|
47
|
+
Failed = 0,
|
|
48
|
+
Success = 1
|
|
49
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Step as StepSpec } from './spec';
|
|
3
|
+
import { ExecutionResult, State, Request, Showing } from './types';
|
|
4
|
+
export interface ExecutionProps {
|
|
5
|
+
onTxFail?: (error: Error, data: any) => void;
|
|
6
|
+
onTxSubmit?: (tx: string, data: any) => void;
|
|
7
|
+
onTxSuccess?: (tx: string, data: any) => void;
|
|
8
|
+
}
|
|
9
|
+
export default function useExecution({ onTxFail, onTxSubmit, onTxSuccess, }?: ExecutionProps): {
|
|
10
|
+
showing: Showing | null;
|
|
11
|
+
showingDone: boolean;
|
|
12
|
+
transactionTx: string;
|
|
13
|
+
errorMessage: string | null;
|
|
14
|
+
setErrorMessage: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
15
|
+
closeShowing: () => void;
|
|
16
|
+
ctxVal: {
|
|
17
|
+
execute: (brief: string, spec: StepSpec, subtitle?: string | React.ReactNode | null, early?: boolean, submittedBack?: () => void, mixpanelProps?: Record<string, any>, submittedConfirmBack?: () => void, successBack?: ((tx: string) => void) | undefined) => Promise<ExecutionResult.Failed | ExecutionResult.Success | ExecutionResult.Submitted>;
|
|
18
|
+
requests: Map<string, [Request, State]>;
|
|
19
|
+
setShowing: import("react").Dispatch<import("react").SetStateAction<Showing | null>>;
|
|
20
|
+
waitingSubmit: boolean;
|
|
21
|
+
};
|
|
22
|
+
requests: Map<string, [Request, State]>;
|
|
23
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BigNumber as EthersBigNumber } from '@ethersproject/bignumber';
|
|
2
|
+
import BigNumber from 'bignumber.js';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export default function useExecuteSwap(): ({ fromTokenAddress, parsedFromAmt, to, data, useSource, duration, ddl, gasLimit, subtitle, }: {
|
|
5
|
+
fromTokenAddress: string;
|
|
6
|
+
parsedFromAmt: BigNumber;
|
|
7
|
+
to: string;
|
|
8
|
+
data: string;
|
|
9
|
+
useSource?: string | undefined;
|
|
10
|
+
duration?: number | undefined;
|
|
11
|
+
ddl: number;
|
|
12
|
+
gasLimit?: EthersBigNumber | undefined;
|
|
13
|
+
subtitle: React.ReactNode;
|
|
14
|
+
}) => void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ChainId } from '../../constants/chains';
|
|
2
|
+
import { TokenInfo } from '../Token';
|
|
3
|
+
export interface FetchFiatPriceProps {
|
|
4
|
+
chainId: ChainId | undefined;
|
|
5
|
+
fromToken: TokenInfo | null;
|
|
6
|
+
toToken: TokenInfo | null;
|
|
7
|
+
}
|
|
8
|
+
export declare function useFetchFiatPrice({ fromToken, toToken, chainId }: FetchFiatPriceProps): {
|
|
9
|
+
loading: boolean;
|
|
10
|
+
refetch: () => void;
|
|
11
|
+
toFiatPrice: string;
|
|
12
|
+
fromFiatPrice: string;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TokenInfo } from '../Token';
|
|
3
|
+
export declare enum RoutePriceStatus {
|
|
4
|
+
Initial = "Initial",
|
|
5
|
+
Loading = "Loading",
|
|
6
|
+
Failed = "Failed",
|
|
7
|
+
Success = "Success"
|
|
8
|
+
}
|
|
9
|
+
export interface FetchRoutePrice {
|
|
10
|
+
fromToken: TokenInfo | null;
|
|
11
|
+
toToken: TokenInfo | null;
|
|
12
|
+
marginAmount: string;
|
|
13
|
+
fromAmount: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function useFetchRoutePrice({ toToken, fromToken, fromAmount, marginAmount, }: FetchRoutePrice): {
|
|
16
|
+
status: RoutePriceStatus;
|
|
17
|
+
refetch: () => Promise<void>;
|
|
18
|
+
priceImpact: number | null;
|
|
19
|
+
executeSwap: (subtitle: React.ReactNode) => void;
|
|
20
|
+
baseFeeAmount: number | null;
|
|
21
|
+
resAmount: number | null;
|
|
22
|
+
additionalFeeAmount: number | null;
|
|
23
|
+
resPricePerToToken: number | null;
|
|
24
|
+
resPricePerFromToken: number | null;
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|