@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.
Files changed (227) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +69 -0
  3. package/dist/cjs/e2e/connect.test.d.ts +6 -0
  4. package/dist/cjs/e2e/constants.d.ts +79 -0
  5. package/dist/cjs/e2e/default.test.d.ts +6 -0
  6. package/dist/cjs/e2e/setup.d.ts +4 -0
  7. package/dist/cjs/index.cjs +1 -0
  8. package/dist/cjs/locales/en-US.js +5 -0
  9. package/dist/cjs/locales/zh-CN.js +5 -0
  10. package/dist/cjs/src/components/Swap/components/ConnectWallet/ConnectWalletDialog.d.ts +5 -0
  11. package/dist/cjs/src/components/Swap/components/ConnectWallet/index.d.ts +9 -0
  12. package/dist/cjs/src/components/Swap/components/Dialog.d.ts +12 -0
  13. package/dist/cjs/src/components/Swap/components/ReviewDialog.d.ts +20 -0
  14. package/dist/cjs/src/components/Swap/components/SettingsDialog/NumberInput.d.ts +8 -0
  15. package/dist/cjs/src/components/Swap/components/SettingsDialog/index.d.ts +6 -0
  16. package/dist/cjs/src/components/Swap/components/SwitchBox.d.ts +4 -0
  17. package/dist/cjs/src/components/Swap/components/TokenCard/BalanceText.d.ts +9 -0
  18. package/dist/cjs/src/components/Swap/components/TokenCard/NumberInput.d.ts +12 -0
  19. package/dist/cjs/src/components/Swap/components/TokenCard/TokenLogoCollapse.d.ts +6 -0
  20. package/dist/cjs/src/components/Swap/components/TokenCard/TokenPickerDialog.d.ts +10 -0
  21. package/dist/cjs/src/components/Swap/components/TokenCard/index.d.ts +16 -0
  22. package/dist/cjs/src/components/Swap/components/TokenPairPriceWithToggle.d.ts +10 -0
  23. package/dist/cjs/src/components/Swap/index.d.ts +2 -0
  24. package/dist/cjs/src/components/TokenLogo.d.ts +15 -0
  25. package/dist/cjs/src/components/TokenPicker/PopularToken.d.ts +7 -0
  26. package/dist/cjs/src/components/TokenPicker/TokenItem.d.ts +8 -0
  27. package/dist/cjs/src/components/TokenPicker/index.d.ts +14 -0
  28. package/dist/cjs/src/components/Tooltip/QuestionTooltip.d.ts +3 -0
  29. package/dist/cjs/src/components/Tooltip/index.d.ts +1 -0
  30. package/dist/cjs/src/components/Widget/i18n.d.ts +9 -0
  31. package/dist/cjs/src/components/Widget/index.d.ts +23 -0
  32. package/dist/cjs/src/components/WithExecutionDialog/index.d.ts +5 -0
  33. package/dist/cjs/src/constants/address.d.ts +1 -0
  34. package/dist/cjs/src/constants/api.d.ts +4 -0
  35. package/dist/cjs/src/constants/chains.d.ts +205 -0
  36. package/dist/cjs/src/constants/locales.d.ts +3 -0
  37. package/dist/cjs/src/constants/swap.d.ts +6 -0
  38. package/dist/cjs/src/constants/testId.d.ts +10 -0
  39. package/dist/cjs/src/constants/token.d.ts +2 -0
  40. package/dist/cjs/src/constants/tokenList.d.ts +9 -0
  41. package/dist/cjs/src/constants/wallet.d.ts +23 -0
  42. package/dist/cjs/src/hooks/ConnectWallet/Connectors/JsonRpcConnector.d.ts +6 -0
  43. package/dist/cjs/src/hooks/ConnectWallet/index.d.ts +3 -0
  44. package/dist/cjs/src/hooks/ConnectWallet/useCurrentChainId.d.ts +2 -0
  45. package/dist/cjs/src/hooks/ConnectWallet/useWeb3Connectors.d.ts +14 -0
  46. package/dist/cjs/src/hooks/ConnectWallet/web3.d.ts +10 -0
  47. package/dist/cjs/src/hooks/Submission/getExecutionErrorMsg.d.ts +2 -0
  48. package/dist/cjs/src/hooks/Submission/index.d.ts +10 -0
  49. package/dist/cjs/src/hooks/Submission/spec.d.ts +56 -0
  50. package/dist/cjs/src/hooks/Submission/types.d.ts +49 -0
  51. package/dist/cjs/src/hooks/Submission/useExecution.d.ts +23 -0
  52. package/dist/cjs/src/hooks/Submission/useInflights.d.ts +5 -0
  53. package/dist/cjs/src/hooks/Swap/index.d.ts +5 -0
  54. package/dist/cjs/src/hooks/Swap/useExecuteSwap.d.ts +14 -0
  55. package/dist/cjs/src/hooks/Swap/useFetchFiatPrice.d.ts +13 -0
  56. package/dist/cjs/src/hooks/Swap/useFetchFiatPrice.test.d.ts +1 -0
  57. package/dist/cjs/src/hooks/Swap/useFetchRoutePrice.d.ts +25 -0
  58. package/dist/cjs/src/hooks/Swap/useFetchRoutePrice.test.d.ts +1 -0
  59. package/dist/cjs/src/hooks/Swap/useMarginAmount.d.ts +8 -0
  60. package/dist/cjs/src/hooks/Swap/useMarginAmount.test.d.ts +1 -0
  61. package/dist/cjs/src/hooks/Swap/usePriceTimer.d.ts +5 -0
  62. package/dist/cjs/src/hooks/Token/index.d.ts +4 -0
  63. package/dist/cjs/src/hooks/Token/type.d.ts +18 -0
  64. package/dist/cjs/src/hooks/Token/useFindTokenByAddress.d.ts +1 -0
  65. package/dist/cjs/src/hooks/Token/useFindTokenByAddress.test.d.ts +1 -0
  66. package/dist/cjs/src/hooks/Token/useGetAllowance.d.ts +3 -0
  67. package/dist/cjs/src/hooks/Token/useGetAllowance.test.d.ts +1 -0
  68. package/dist/cjs/src/hooks/Token/useGetBalance.d.ts +2 -0
  69. package/dist/cjs/src/hooks/Token/useGetBalance.test.d.ts +1 -0
  70. package/dist/cjs/src/hooks/Token/useGetTokenStatus.d.ts +13 -0
  71. package/dist/cjs/src/hooks/Token/useGetTokenStatus.test.d.ts +1 -0
  72. package/dist/cjs/src/hooks/Token/useInitTokenList.d.ts +6 -0
  73. package/dist/cjs/src/hooks/Token/useTokenList.d.ts +20 -0
  74. package/dist/cjs/src/hooks/Token/useTokenList.test.d.ts +1 -0
  75. package/dist/cjs/src/hooks/Widget/useInitPropsToRedux.d.ts +2 -0
  76. package/dist/cjs/src/hooks/contract/abis/erc20ABI.d.ts +30 -0
  77. package/dist/cjs/src/hooks/contract/abis/erc20Helper.d.ts +16 -0
  78. package/dist/cjs/src/hooks/contract/abis/multicallABI.d.ts +34 -0
  79. package/dist/cjs/src/hooks/contract/batch.d.ts +18 -0
  80. package/dist/cjs/src/hooks/contract/contractConfig.d.ts +78 -0
  81. package/dist/cjs/src/hooks/contract/index.d.ts +4 -0
  82. package/dist/cjs/src/hooks/contract/useFetchBlockNumber.d.ts +1 -0
  83. package/dist/cjs/src/hooks/contract/useFetchETHBalance.d.ts +1 -0
  84. package/dist/cjs/src/hooks/contract/useFetchTokens.d.ts +18 -0
  85. package/dist/cjs/src/hooks/contract/useMultiContract.d.ts +70 -0
  86. package/dist/cjs/src/hooks/contract/wallet.d.ts +16 -0
  87. package/dist/cjs/src/index.d.ts +5 -0
  88. package/dist/cjs/src/store/actions/globals.d.ts +3 -0
  89. package/dist/cjs/src/store/actions/index.d.ts +4 -0
  90. package/dist/cjs/src/store/actions/settings.d.ts +6 -0
  91. package/dist/cjs/src/store/actions/token.d.ts +15 -0
  92. package/dist/cjs/src/store/actions/wallet.d.ts +4 -0
  93. package/dist/cjs/src/store/index.d.ts +6 -0
  94. package/dist/cjs/src/store/reducers/globals.d.ts +6 -0
  95. package/dist/cjs/src/store/reducers/index.d.ts +17 -0
  96. package/dist/cjs/src/store/reducers/settings.d.ts +13 -0
  97. package/dist/cjs/src/store/reducers/token.d.ts +29 -0
  98. package/dist/cjs/src/store/reducers/wallet.d.ts +9 -0
  99. package/dist/cjs/src/store/selectors/globals.d.ts +2 -0
  100. package/dist/cjs/src/store/selectors/settings.d.ts +4 -0
  101. package/dist/cjs/src/store/selectors/token.d.ts +16 -0
  102. package/dist/cjs/src/store/selectors/wallet.d.ts +3 -0
  103. package/dist/cjs/src/utils/address.d.ts +7 -0
  104. package/dist/cjs/src/utils/address.test.d.ts +1 -0
  105. package/dist/cjs/src/utils/chains.d.ts +2 -0
  106. package/dist/cjs/src/utils/chains.test.d.ts +1 -0
  107. package/dist/cjs/src/utils/formatter.d.ts +23 -0
  108. package/dist/cjs/src/utils/formatter.test.d.ts +1 -0
  109. package/dist/cjs/src/utils/index.d.ts +5 -0
  110. package/dist/cjs/src/utils/token.d.ts +9 -0
  111. package/dist/cjs/src/utils/token.test.d.ts +1 -0
  112. package/dist/cjs/src/utils/wallet.d.ts +8 -0
  113. package/dist/cjs/src/utils/wallet.test.d.ts +1 -0
  114. package/dist/cjs/tokenList-ee5e15c8.cjs +1 -0
  115. package/dist/e2e/connect.test.d.ts +6 -0
  116. package/dist/e2e/constants.d.ts +79 -0
  117. package/dist/e2e/default.test.d.ts +6 -0
  118. package/dist/e2e/setup.d.ts +4 -0
  119. package/dist/index.js +1 -0
  120. package/dist/locales/en-US.js +5 -0
  121. package/dist/locales/zh-CN.js +5 -0
  122. package/dist/src/components/Swap/components/ConnectWallet/ConnectWalletDialog.d.ts +5 -0
  123. package/dist/src/components/Swap/components/ConnectWallet/index.d.ts +9 -0
  124. package/dist/src/components/Swap/components/Dialog.d.ts +12 -0
  125. package/dist/src/components/Swap/components/ReviewDialog.d.ts +20 -0
  126. package/dist/src/components/Swap/components/SettingsDialog/NumberInput.d.ts +8 -0
  127. package/dist/src/components/Swap/components/SettingsDialog/index.d.ts +6 -0
  128. package/dist/src/components/Swap/components/SwitchBox.d.ts +4 -0
  129. package/dist/src/components/Swap/components/TokenCard/BalanceText.d.ts +9 -0
  130. package/dist/src/components/Swap/components/TokenCard/NumberInput.d.ts +12 -0
  131. package/dist/src/components/Swap/components/TokenCard/TokenLogoCollapse.d.ts +6 -0
  132. package/dist/src/components/Swap/components/TokenCard/TokenPickerDialog.d.ts +10 -0
  133. package/dist/src/components/Swap/components/TokenCard/index.d.ts +16 -0
  134. package/dist/src/components/Swap/components/TokenPairPriceWithToggle.d.ts +10 -0
  135. package/dist/src/components/Swap/index.d.ts +2 -0
  136. package/dist/src/components/TokenLogo.d.ts +15 -0
  137. package/dist/src/components/TokenPicker/PopularToken.d.ts +7 -0
  138. package/dist/src/components/TokenPicker/TokenItem.d.ts +8 -0
  139. package/dist/src/components/TokenPicker/index.d.ts +14 -0
  140. package/dist/src/components/Tooltip/QuestionTooltip.d.ts +3 -0
  141. package/dist/src/components/Tooltip/index.d.ts +1 -0
  142. package/dist/src/components/Widget/i18n.d.ts +9 -0
  143. package/dist/src/components/Widget/index.d.ts +23 -0
  144. package/dist/src/components/WithExecutionDialog/index.d.ts +5 -0
  145. package/dist/src/constants/address.d.ts +1 -0
  146. package/dist/src/constants/api.d.ts +4 -0
  147. package/dist/src/constants/chains.d.ts +205 -0
  148. package/dist/src/constants/locales.d.ts +3 -0
  149. package/dist/src/constants/swap.d.ts +6 -0
  150. package/dist/src/constants/testId.d.ts +10 -0
  151. package/dist/src/constants/token.d.ts +2 -0
  152. package/dist/src/constants/tokenList.d.ts +9 -0
  153. package/dist/src/constants/wallet.d.ts +23 -0
  154. package/dist/src/hooks/ConnectWallet/Connectors/JsonRpcConnector.d.ts +6 -0
  155. package/dist/src/hooks/ConnectWallet/index.d.ts +3 -0
  156. package/dist/src/hooks/ConnectWallet/useCurrentChainId.d.ts +2 -0
  157. package/dist/src/hooks/ConnectWallet/useWeb3Connectors.d.ts +14 -0
  158. package/dist/src/hooks/ConnectWallet/web3.d.ts +10 -0
  159. package/dist/src/hooks/Submission/getExecutionErrorMsg.d.ts +2 -0
  160. package/dist/src/hooks/Submission/index.d.ts +10 -0
  161. package/dist/src/hooks/Submission/spec.d.ts +56 -0
  162. package/dist/src/hooks/Submission/types.d.ts +49 -0
  163. package/dist/src/hooks/Submission/useExecution.d.ts +23 -0
  164. package/dist/src/hooks/Submission/useInflights.d.ts +5 -0
  165. package/dist/src/hooks/Swap/index.d.ts +5 -0
  166. package/dist/src/hooks/Swap/useExecuteSwap.d.ts +14 -0
  167. package/dist/src/hooks/Swap/useFetchFiatPrice.d.ts +13 -0
  168. package/dist/src/hooks/Swap/useFetchFiatPrice.test.d.ts +1 -0
  169. package/dist/src/hooks/Swap/useFetchRoutePrice.d.ts +25 -0
  170. package/dist/src/hooks/Swap/useFetchRoutePrice.test.d.ts +1 -0
  171. package/dist/src/hooks/Swap/useMarginAmount.d.ts +8 -0
  172. package/dist/src/hooks/Swap/useMarginAmount.test.d.ts +1 -0
  173. package/dist/src/hooks/Swap/usePriceTimer.d.ts +5 -0
  174. package/dist/src/hooks/Token/index.d.ts +4 -0
  175. package/dist/src/hooks/Token/type.d.ts +18 -0
  176. package/dist/src/hooks/Token/useFindTokenByAddress.d.ts +1 -0
  177. package/dist/src/hooks/Token/useFindTokenByAddress.test.d.ts +1 -0
  178. package/dist/src/hooks/Token/useGetAllowance.d.ts +3 -0
  179. package/dist/src/hooks/Token/useGetAllowance.test.d.ts +1 -0
  180. package/dist/src/hooks/Token/useGetBalance.d.ts +2 -0
  181. package/dist/src/hooks/Token/useGetBalance.test.d.ts +1 -0
  182. package/dist/src/hooks/Token/useGetTokenStatus.d.ts +13 -0
  183. package/dist/src/hooks/Token/useGetTokenStatus.test.d.ts +1 -0
  184. package/dist/src/hooks/Token/useInitTokenList.d.ts +6 -0
  185. package/dist/src/hooks/Token/useTokenList.d.ts +20 -0
  186. package/dist/src/hooks/Token/useTokenList.test.d.ts +1 -0
  187. package/dist/src/hooks/Widget/useInitPropsToRedux.d.ts +2 -0
  188. package/dist/src/hooks/contract/abis/erc20ABI.d.ts +30 -0
  189. package/dist/src/hooks/contract/abis/erc20Helper.d.ts +16 -0
  190. package/dist/src/hooks/contract/abis/multicallABI.d.ts +34 -0
  191. package/dist/src/hooks/contract/batch.d.ts +18 -0
  192. package/dist/src/hooks/contract/contractConfig.d.ts +78 -0
  193. package/dist/src/hooks/contract/index.d.ts +4 -0
  194. package/dist/src/hooks/contract/useFetchBlockNumber.d.ts +1 -0
  195. package/dist/src/hooks/contract/useFetchETHBalance.d.ts +1 -0
  196. package/dist/src/hooks/contract/useFetchTokens.d.ts +18 -0
  197. package/dist/src/hooks/contract/useMultiContract.d.ts +70 -0
  198. package/dist/src/hooks/contract/wallet.d.ts +16 -0
  199. package/dist/src/index.d.ts +5 -0
  200. package/dist/src/store/actions/globals.d.ts +3 -0
  201. package/dist/src/store/actions/index.d.ts +4 -0
  202. package/dist/src/store/actions/settings.d.ts +6 -0
  203. package/dist/src/store/actions/token.d.ts +15 -0
  204. package/dist/src/store/actions/wallet.d.ts +4 -0
  205. package/dist/src/store/index.d.ts +6 -0
  206. package/dist/src/store/reducers/globals.d.ts +6 -0
  207. package/dist/src/store/reducers/index.d.ts +17 -0
  208. package/dist/src/store/reducers/settings.d.ts +13 -0
  209. package/dist/src/store/reducers/token.d.ts +29 -0
  210. package/dist/src/store/reducers/wallet.d.ts +9 -0
  211. package/dist/src/store/selectors/globals.d.ts +2 -0
  212. package/dist/src/store/selectors/settings.d.ts +4 -0
  213. package/dist/src/store/selectors/token.d.ts +16 -0
  214. package/dist/src/store/selectors/wallet.d.ts +3 -0
  215. package/dist/src/utils/address.d.ts +7 -0
  216. package/dist/src/utils/address.test.d.ts +1 -0
  217. package/dist/src/utils/chains.d.ts +2 -0
  218. package/dist/src/utils/chains.test.d.ts +1 -0
  219. package/dist/src/utils/formatter.d.ts +23 -0
  220. package/dist/src/utils/formatter.test.d.ts +1 -0
  221. package/dist/src/utils/index.d.ts +5 -0
  222. package/dist/src/utils/token.d.ts +9 -0
  223. package/dist/src/utils/token.test.d.ts +1 -0
  224. package/dist/src/utils/wallet.d.ts +8 -0
  225. package/dist/src/utils/wallet.test.d.ts +1 -0
  226. package/dist/tokenList-4ef211de.js +1 -0
  227. package/package.json +131 -0
@@ -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,3 @@
1
+ /// <reference types="react" />
2
+ import { QuestionTooltipProps } from '@dodoex/components';
3
+ export default function QuestionTooltip(props: QuestionTooltipProps): 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,5 @@
1
+ import React from 'react';
2
+ import { ExecutionProps } from '../../hooks/Submission';
3
+ export default function WithExecutionDialog({ children, ...props }: {
4
+ children: React.ReactNode;
5
+ } & ExecutionProps): 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,3 @@
1
+ export declare const supportedLang: string[];
2
+ export declare type SupportedLang = typeof supportedLang[number];
3
+ export declare const defaultLang: SupportedLang;
@@ -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,2 @@
1
+ import BigNumber from 'bignumber.js';
2
+ export declare const BIG_ALLOWANCE: BigNumber;
@@ -0,0 +1,9 @@
1
+ declare const _default: {
2
+ chainId: number;
3
+ address: string;
4
+ name: string;
5
+ decimals: number;
6
+ symbol: string;
7
+ logoURI: string;
8
+ }[];
9
+ export default _default;
@@ -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,3 @@
1
+ export { connectToWallet, useWeb3Connectors } from './useWeb3Connectors';
2
+ export { useCurrentChainId } from './useCurrentChainId';
3
+ export type { Web3ConnectorsProps } from './useWeb3Connectors';
@@ -0,0 +1,2 @@
1
+ import { ChainId } from '../../constants/chains';
2
+ export declare function useCurrentChainId(): ChainId;
@@ -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,2 @@
1
+ import { ChainId } from '../../constants/chains';
2
+ export default function getExecutionErrorMsg(chainId: ChainId, message: string): string;
@@ -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,5 @@
1
+ import { Request } from './types';
2
+ export default function useInflights(): {
3
+ runningRequests: Request[];
4
+ isInflight: boolean;
5
+ };
@@ -0,0 +1,5 @@
1
+ export * from './useMarginAmount';
2
+ export * from '../Widget/useInitPropsToRedux';
3
+ export * from './useFetchFiatPrice';
4
+ export * from './useFetchRoutePrice';
5
+ export { default as useExecuteSwap } from './useExecuteSwap';
@@ -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,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,8 @@
1
+ import { TokenInfo } from '../Token';
2
+ export interface MarginAmountProps {
3
+ fromToken: TokenInfo | null;
4
+ fromFiatPrice: string;
5
+ }
6
+ export declare function useMarginAmount({ fromToken, fromFiatPrice }: MarginAmountProps): {
7
+ marginAmount: string;
8
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export interface PriceTimerProps {
2
+ refetch: () => void;
3
+ interval?: number;
4
+ }
5
+ export declare function usePriceTimer({ refetch, interval }: PriceTimerProps): void;
@@ -0,0 +1,4 @@
1
+ export { default as useInitTokenList } from './useInitTokenList';
2
+ export { default as useFindTokenByAddress } from './useFindTokenByAddress';
3
+ export { default as useTokenList } from './useTokenList';
4
+ export type { TokenList, TokenInfo } from './type';
@@ -0,0 +1,18 @@
1
+ export interface TokenInfo {
2
+ readonly chainId: number;
3
+ readonly address: string;
4
+ readonly name: string;
5
+ readonly decimals: number;
6
+ readonly symbol: string;
7
+ readonly logoURI?: string;
8
+ readonly tags?: string[];
9
+ readonly extensions?: any;
10
+ }
11
+ export declare type TokenList = TokenInfo[];
12
+ export declare enum ApprovalState {
13
+ Loading = "Loading",
14
+ Insufficient = "ApprovalInsufficient",
15
+ Approving = "Approving",
16
+ Sufficient = "Sufficient",
17
+ Unchecked = "Unchecked"
18
+ }
@@ -0,0 +1 @@
1
+ export default function useFindTokenByAddress(address?: string): import("./type").TokenInfo | undefined;