2021-04-02 00:57:00 +02:00
|
|
|
import {
|
|
|
|
MAINNET_CHAIN_ID,
|
|
|
|
ETH_SYMBOL,
|
|
|
|
TEST_ETH_SYMBOL,
|
|
|
|
BNB_SYMBOL,
|
|
|
|
TEST_ETH_TOKEN_IMAGE_URL,
|
|
|
|
BNB_TOKEN_IMAGE_URL,
|
2021-04-07 17:37:04 +02:00
|
|
|
BSC_CHAIN_ID,
|
2021-07-20 19:17:15 +02:00
|
|
|
POLYGON_CHAIN_ID,
|
|
|
|
MATIC_SYMBOL,
|
|
|
|
MATIC_TOKEN_IMAGE_URL,
|
2021-07-30 13:35:30 +02:00
|
|
|
RINKEBY_CHAIN_ID,
|
2022-02-18 15:24:47 +01:00
|
|
|
AVALANCHE_CHAIN_ID,
|
|
|
|
AVALANCHE_SYMBOL,
|
|
|
|
AVAX_TOKEN_IMAGE_URL,
|
2021-04-02 00:57:00 +02:00
|
|
|
} from './network';
|
2021-03-18 11:20:06 +01:00
|
|
|
|
|
|
|
export const QUOTES_EXPIRED_ERROR = 'quotes-expired';
|
|
|
|
export const SWAP_FAILED_ERROR = 'swap-failed-error';
|
|
|
|
export const ERROR_FETCHING_QUOTES = 'error-fetching-quotes';
|
|
|
|
export const QUOTES_NOT_AVAILABLE_ERROR = 'quotes-not-avilable';
|
2021-05-13 21:49:00 +02:00
|
|
|
export const CONTRACT_DATA_DISABLED_ERROR = 'contract-data-disabled';
|
2021-03-18 11:20:06 +01:00
|
|
|
export const OFFLINE_FOR_MAINTENANCE = 'offline-for-maintenance';
|
|
|
|
export const SWAPS_FETCH_ORDER_CONFLICT = 'swaps-fetch-order-conflict';
|
|
|
|
|
2021-03-25 21:52:37 +01:00
|
|
|
// An address that the metaswap-api recognizes as the default token for the current network, in place of the token address that ERC-20 tokens have
|
|
|
|
const DEFAULT_TOKEN_ADDRESS = '0x0000000000000000000000000000000000000000';
|
2020-10-06 20:28:38 +02:00
|
|
|
|
|
|
|
export const ETH_SWAPS_TOKEN_OBJECT = {
|
2021-04-02 00:57:00 +02:00
|
|
|
symbol: ETH_SYMBOL,
|
2020-10-06 20:28:38 +02:00
|
|
|
name: 'Ether',
|
2021-03-25 21:52:37 +01:00
|
|
|
address: DEFAULT_TOKEN_ADDRESS,
|
2020-10-06 20:28:38 +02:00
|
|
|
decimals: 18,
|
2021-04-02 00:57:00 +02:00
|
|
|
iconUrl: './images/black-eth-logo.svg',
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-10-06 20:28:38 +02:00
|
|
|
|
2021-04-02 00:57:00 +02:00
|
|
|
export const BNB_SWAPS_TOKEN_OBJECT = {
|
|
|
|
symbol: BNB_SYMBOL,
|
2021-03-25 21:52:37 +01:00
|
|
|
name: 'Binance Coin',
|
|
|
|
address: DEFAULT_TOKEN_ADDRESS,
|
|
|
|
decimals: 18,
|
2021-04-02 00:57:00 +02:00
|
|
|
iconUrl: BNB_TOKEN_IMAGE_URL,
|
2021-03-25 21:52:37 +01:00
|
|
|
};
|
|
|
|
|
2021-07-20 19:17:15 +02:00
|
|
|
export const MATIC_SWAPS_TOKEN_OBJECT = {
|
|
|
|
symbol: MATIC_SYMBOL,
|
|
|
|
name: 'Matic',
|
|
|
|
address: DEFAULT_TOKEN_ADDRESS,
|
|
|
|
decimals: 18,
|
|
|
|
iconUrl: MATIC_TOKEN_IMAGE_URL,
|
|
|
|
};
|
|
|
|
|
2022-02-18 15:24:47 +01:00
|
|
|
export const AVAX_SWAPS_TOKEN_OBJECT = {
|
|
|
|
symbol: AVALANCHE_SYMBOL,
|
|
|
|
name: 'Avalanche',
|
|
|
|
address: DEFAULT_TOKEN_ADDRESS,
|
|
|
|
decimals: 18,
|
|
|
|
iconUrl: AVAX_TOKEN_IMAGE_URL,
|
|
|
|
};
|
|
|
|
|
2021-04-02 00:57:00 +02:00
|
|
|
export const TEST_ETH_SWAPS_TOKEN_OBJECT = {
|
|
|
|
symbol: TEST_ETH_SYMBOL,
|
2021-03-18 11:20:06 +01:00
|
|
|
name: 'Test Ether',
|
2021-03-25 21:52:37 +01:00
|
|
|
address: DEFAULT_TOKEN_ADDRESS,
|
2021-03-18 11:20:06 +01:00
|
|
|
decimals: 18,
|
2021-04-02 00:57:00 +02:00
|
|
|
iconUrl: TEST_ETH_TOKEN_IMAGE_URL,
|
2021-03-18 11:20:06 +01:00
|
|
|
};
|
2020-10-06 20:28:38 +02:00
|
|
|
|
2021-07-30 13:35:30 +02:00
|
|
|
export const RINKEBY_SWAPS_TOKEN_OBJECT = {
|
|
|
|
symbol: ETH_SYMBOL,
|
|
|
|
name: 'Ether',
|
|
|
|
address: DEFAULT_TOKEN_ADDRESS,
|
|
|
|
decimals: 18,
|
|
|
|
iconUrl: TEST_ETH_TOKEN_IMAGE_URL,
|
|
|
|
};
|
|
|
|
|
2020-10-06 20:28:38 +02:00
|
|
|
// A gas value for ERC20 approve calls that should be sufficient for all ERC20 approve implementations
|
2021-02-04 19:15:23 +01:00
|
|
|
export const DEFAULT_ERC20_APPROVE_GAS = '0x1d4c0';
|
2020-10-06 20:28:38 +02:00
|
|
|
|
2021-03-18 11:20:06 +01:00
|
|
|
const MAINNET_CONTRACT_ADDRESS = '0x881d40237659c251811cec9c364ef91dc08d300c';
|
|
|
|
|
|
|
|
const TESTNET_CONTRACT_ADDRESS = '0x881d40237659c251811cec9c364ef91dc08d300c';
|
|
|
|
|
2021-04-01 19:31:45 +02:00
|
|
|
const BSC_CONTRACT_ADDRESS = '0x1a1ec25dc08e98e5e93f1104b5e5cdd298707d31';
|
2021-03-25 21:52:37 +01:00
|
|
|
|
2021-07-20 19:17:15 +02:00
|
|
|
// It's the same as we use for BSC.
|
|
|
|
const POLYGON_CONTRACT_ADDRESS = '0x1a1ec25dc08e98e5e93f1104b5e5cdd298707d31';
|
|
|
|
|
2022-02-18 15:24:47 +01:00
|
|
|
const AVALANCHE_CONTRACT_ADDRESS = '0x1a1ec25dc08e98e5e93f1104b5e5cdd298707d31';
|
|
|
|
|
2021-09-08 20:08:55 +02:00
|
|
|
export const WETH_CONTRACT_ADDRESS =
|
2021-04-23 16:53:10 +02:00
|
|
|
'0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2';
|
2021-09-08 20:08:55 +02:00
|
|
|
export const WETH_RINKEBY_CONTRACT_ADDRESS =
|
|
|
|
'0xc778417e063141139fce010982780140aa0cd5ab';
|
|
|
|
export const WBNB_CONTRACT_ADDRESS =
|
|
|
|
'0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c';
|
|
|
|
export const WMATIC_CONTRACT_ADDRESS =
|
|
|
|
'0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270';
|
2022-02-18 15:24:47 +01:00
|
|
|
export const WAVAX_CONTRACT_ADDRESS =
|
|
|
|
'0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7';
|
2021-04-23 16:53:10 +02:00
|
|
|
|
2021-03-18 11:20:06 +01:00
|
|
|
const SWAPS_TESTNET_CHAIN_ID = '0x539';
|
2021-03-09 17:06:44 +01:00
|
|
|
|
2022-03-21 10:26:52 +01:00
|
|
|
export const SWAPS_API_V2_BASE_URL = 'https://swap.metaswap.codefi.network';
|
2021-09-08 19:26:37 +02:00
|
|
|
export const SWAPS_DEV_API_V2_BASE_URL =
|
2022-02-18 15:24:47 +01:00
|
|
|
'https://swap.metaswap-dev.codefi.network';
|
2021-09-08 19:26:37 +02:00
|
|
|
export const GAS_API_BASE_URL = 'https://gas-api.metaswap.codefi.network';
|
|
|
|
export const GAS_DEV_API_BASE_URL =
|
|
|
|
'https://gas-api.metaswap-dev.codefi.network';
|
|
|
|
|
2021-03-29 14:54:27 +02:00
|
|
|
const BSC_DEFAULT_BLOCK_EXPLORER_URL = 'https://bscscan.com/';
|
2021-06-03 18:08:37 +02:00
|
|
|
const MAINNET_DEFAULT_BLOCK_EXPLORER_URL = 'https://etherscan.io/';
|
2021-07-30 13:35:30 +02:00
|
|
|
const RINKEBY_DEFAULT_BLOCK_EXPLORER_URL = 'https://rinkeby.etherscan.io/';
|
2021-07-20 19:17:15 +02:00
|
|
|
const POLYGON_DEFAULT_BLOCK_EXPLORER_URL = 'https://polygonscan.com/';
|
2022-02-18 15:24:47 +01:00
|
|
|
const AVALANCHE_DEFAULT_BLOCK_EXPLORER_URL = 'https://snowtrace.io/';
|
2021-03-29 14:54:27 +02:00
|
|
|
|
2022-04-14 17:02:38 +02:00
|
|
|
export const ALLOWED_PROD_SWAPS_CHAIN_IDS = [
|
|
|
|
MAINNET_CHAIN_ID,
|
|
|
|
SWAPS_TESTNET_CHAIN_ID,
|
|
|
|
BSC_CHAIN_ID,
|
|
|
|
POLYGON_CHAIN_ID,
|
|
|
|
AVALANCHE_CHAIN_ID,
|
|
|
|
];
|
|
|
|
|
|
|
|
export const ALLOWED_DEV_SWAPS_CHAIN_IDS = [
|
|
|
|
...ALLOWED_PROD_SWAPS_CHAIN_IDS,
|
|
|
|
RINKEBY_CHAIN_ID,
|
|
|
|
];
|
2021-03-18 11:20:06 +01:00
|
|
|
|
2022-02-18 17:48:38 +01:00
|
|
|
export const ALLOWED_SMART_TRANSACTIONS_CHAIN_IDS = [
|
|
|
|
MAINNET_CHAIN_ID,
|
|
|
|
RINKEBY_CHAIN_ID,
|
|
|
|
];
|
|
|
|
|
2021-03-18 11:20:06 +01:00
|
|
|
export const SWAPS_CHAINID_CONTRACT_ADDRESS_MAP = {
|
|
|
|
[MAINNET_CHAIN_ID]: MAINNET_CONTRACT_ADDRESS,
|
|
|
|
[SWAPS_TESTNET_CHAIN_ID]: TESTNET_CONTRACT_ADDRESS,
|
2021-04-07 17:37:04 +02:00
|
|
|
[BSC_CHAIN_ID]: BSC_CONTRACT_ADDRESS,
|
2021-07-20 19:17:15 +02:00
|
|
|
[POLYGON_CHAIN_ID]: POLYGON_CONTRACT_ADDRESS,
|
2021-07-30 13:35:30 +02:00
|
|
|
[RINKEBY_CHAIN_ID]: TESTNET_CONTRACT_ADDRESS,
|
2022-02-18 15:24:47 +01:00
|
|
|
[AVALANCHE_CHAIN_ID]: AVALANCHE_CONTRACT_ADDRESS,
|
2021-03-18 11:20:06 +01:00
|
|
|
};
|
|
|
|
|
2021-09-08 20:08:55 +02:00
|
|
|
export const SWAPS_WRAPPED_TOKENS_ADDRESSES = {
|
|
|
|
[MAINNET_CHAIN_ID]: WETH_CONTRACT_ADDRESS,
|
|
|
|
[SWAPS_TESTNET_CHAIN_ID]: WETH_CONTRACT_ADDRESS,
|
|
|
|
[BSC_CHAIN_ID]: WBNB_CONTRACT_ADDRESS,
|
|
|
|
[POLYGON_CHAIN_ID]: WMATIC_CONTRACT_ADDRESS,
|
|
|
|
[RINKEBY_CHAIN_ID]: WETH_RINKEBY_CONTRACT_ADDRESS,
|
2022-02-18 15:24:47 +01:00
|
|
|
[AVALANCHE_CHAIN_ID]: WAVAX_CONTRACT_ADDRESS,
|
2021-09-08 20:08:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export const ALLOWED_CONTRACT_ADDRESSES = {
|
|
|
|
[MAINNET_CHAIN_ID]: [
|
|
|
|
SWAPS_CHAINID_CONTRACT_ADDRESS_MAP[MAINNET_CHAIN_ID],
|
|
|
|
SWAPS_WRAPPED_TOKENS_ADDRESSES[MAINNET_CHAIN_ID],
|
|
|
|
],
|
|
|
|
[SWAPS_TESTNET_CHAIN_ID]: [
|
|
|
|
SWAPS_CHAINID_CONTRACT_ADDRESS_MAP[SWAPS_TESTNET_CHAIN_ID],
|
|
|
|
SWAPS_WRAPPED_TOKENS_ADDRESSES[SWAPS_TESTNET_CHAIN_ID],
|
|
|
|
],
|
|
|
|
[RINKEBY_CHAIN_ID]: [
|
|
|
|
SWAPS_CHAINID_CONTRACT_ADDRESS_MAP[RINKEBY_CHAIN_ID],
|
|
|
|
SWAPS_WRAPPED_TOKENS_ADDRESSES[RINKEBY_CHAIN_ID],
|
|
|
|
],
|
|
|
|
[BSC_CHAIN_ID]: [
|
|
|
|
SWAPS_CHAINID_CONTRACT_ADDRESS_MAP[BSC_CHAIN_ID],
|
|
|
|
SWAPS_WRAPPED_TOKENS_ADDRESSES[BSC_CHAIN_ID],
|
|
|
|
],
|
|
|
|
[POLYGON_CHAIN_ID]: [
|
|
|
|
SWAPS_CHAINID_CONTRACT_ADDRESS_MAP[POLYGON_CHAIN_ID],
|
|
|
|
SWAPS_WRAPPED_TOKENS_ADDRESSES[POLYGON_CHAIN_ID],
|
|
|
|
],
|
2022-02-18 15:24:47 +01:00
|
|
|
[AVALANCHE_CHAIN_ID]: [
|
|
|
|
SWAPS_CHAINID_CONTRACT_ADDRESS_MAP[AVALANCHE_CHAIN_ID],
|
|
|
|
SWAPS_WRAPPED_TOKENS_ADDRESSES[AVALANCHE_CHAIN_ID],
|
|
|
|
],
|
2021-09-08 20:08:55 +02:00
|
|
|
};
|
|
|
|
|
2021-03-18 11:20:06 +01:00
|
|
|
export const SWAPS_CHAINID_DEFAULT_TOKEN_MAP = {
|
|
|
|
[MAINNET_CHAIN_ID]: ETH_SWAPS_TOKEN_OBJECT,
|
|
|
|
[SWAPS_TESTNET_CHAIN_ID]: TEST_ETH_SWAPS_TOKEN_OBJECT,
|
2021-04-07 17:37:04 +02:00
|
|
|
[BSC_CHAIN_ID]: BNB_SWAPS_TOKEN_OBJECT,
|
2021-07-20 19:17:15 +02:00
|
|
|
[POLYGON_CHAIN_ID]: MATIC_SWAPS_TOKEN_OBJECT,
|
2021-07-30 13:35:30 +02:00
|
|
|
[RINKEBY_CHAIN_ID]: RINKEBY_SWAPS_TOKEN_OBJECT,
|
2022-02-18 15:24:47 +01:00
|
|
|
[AVALANCHE_CHAIN_ID]: AVAX_SWAPS_TOKEN_OBJECT,
|
2021-03-18 11:20:06 +01:00
|
|
|
};
|
2021-03-29 14:54:27 +02:00
|
|
|
|
|
|
|
export const SWAPS_CHAINID_DEFAULT_BLOCK_EXPLORER_URL_MAP = {
|
2021-04-07 17:37:04 +02:00
|
|
|
[BSC_CHAIN_ID]: BSC_DEFAULT_BLOCK_EXPLORER_URL,
|
2021-06-03 18:08:37 +02:00
|
|
|
[MAINNET_CHAIN_ID]: MAINNET_DEFAULT_BLOCK_EXPLORER_URL,
|
2021-07-20 19:17:15 +02:00
|
|
|
[POLYGON_CHAIN_ID]: POLYGON_DEFAULT_BLOCK_EXPLORER_URL,
|
2021-07-30 13:35:30 +02:00
|
|
|
[RINKEBY_CHAIN_ID]: RINKEBY_DEFAULT_BLOCK_EXPLORER_URL,
|
2022-02-18 15:24:47 +01:00
|
|
|
[AVALANCHE_CHAIN_ID]: AVALANCHE_DEFAULT_BLOCK_EXPLORER_URL,
|
2021-03-29 14:54:27 +02:00
|
|
|
};
|
2021-07-09 17:24:00 +02:00
|
|
|
|
|
|
|
export const ETHEREUM = 'ethereum';
|
|
|
|
export const POLYGON = 'polygon';
|
|
|
|
export const BSC = 'bsc';
|
2021-07-30 13:35:30 +02:00
|
|
|
export const RINKEBY = 'rinkeby';
|
2022-02-18 15:24:47 +01:00
|
|
|
export const AVALANCHE = 'avalanche';
|
2021-09-29 15:11:19 +02:00
|
|
|
|
|
|
|
export const SWAPS_CLIENT_ID = 'extension';
|
2022-04-15 14:57:58 +02:00
|
|
|
|
|
|
|
export const TOKEN_BUCKET_PRIORITY = {
|
|
|
|
OWNED: 'owned',
|
|
|
|
TOP: 'top',
|
|
|
|
};
|
2022-06-07 18:28:59 +02:00
|
|
|
|
|
|
|
export const SLIPPAGE = {
|
|
|
|
DEFAULT: 2,
|
|
|
|
HIGH: 3,
|
|
|
|
};
|