From 4036ed2bd90c2adc735ccfd6253dcf3f8b750e64 Mon Sep 17 00:00:00 2001 From: Andon Mitev <32274987+AndonMitev@users.noreply.github.com> Date: Fri, 29 Jul 2022 11:55:54 +0300 Subject: [PATCH] Feat/add solana tokens (#91) * feat: Add solana tokens * feat: Add solana tokens and prop support custom fees * fix: Link asset --- src/assets/erc20/index.ts | 10 +++++++- src/assets/erc20/solana-tokens.json | 40 +++++++++++++++++++++++++++++ src/assets/sendGasLimits.ts | 2 +- src/chains.ts | 14 +++++++++- src/types.ts | 1 + 5 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 src/assets/erc20/solana-tokens.json diff --git a/src/assets/erc20/index.ts b/src/assets/erc20/index.ts index f0ac222f9..a2a6ed87d 100644 --- a/src/assets/erc20/index.ts +++ b/src/assets/erc20/index.ts @@ -6,6 +6,7 @@ import polygonTokens from './polygon-tokens.json' import avalancheTokens from './avalanche-tokens.json' import terraTokens from './terra-tokens.json' import arbitrumTokens from './arbitrum-tokens.json' +import solanaTokens from './solana-tokens.json' import { TESTNET_CONTRACT_ADDRESSES, TESTNET_TOKENS } from '../testnet' import { Asset, ChainId, AssetType, AssetMap } from '../../types' @@ -47,6 +48,12 @@ const arbitrumTokensData = mapValues(arbitrumTokens, (tokenData) => ({ sendGasLimit: sendGasLimits.ARBETH })) +const solanaTokensData = mapValues(solanaTokens, (tokenData) => ({ + ...tokenData, + chain: ChainId.Solana, + sendGasLimit: sendGasLimits.SOL +})) + const erc20Assets: AssetMap = mapValues( { ...rskTokensData, @@ -54,7 +61,8 @@ const erc20Assets: AssetMap = mapValues( ...polygonTokensData, ...terraTokensData, ...avalancheTokensData, - ...arbitrumTokensData + ...arbitrumTokensData, + ...solanaTokensData }, (tokenData) => ({ ...tokenData, diff --git a/src/assets/erc20/solana-tokens.json b/src/assets/erc20/solana-tokens.json new file mode 100644 index 000000000..666fbf501 --- /dev/null +++ b/src/assets/erc20/solana-tokens.json @@ -0,0 +1,40 @@ +{ + "sUSDT": { + "name": "sUSDT", + "code": "sUSDT", + "decimals": 6, + "coinGeckoId": "tether", + "contractAddress": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", + "matchingAsset": "USDT" + }, + "sUSDC": { + "name": "sUSDC", + "code": "sUSDC", + "decimals": 6, + "coinGeckoId": "tether", + "contractAddress": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", + "matchingAsset": "USDC" + }, + "RAY": { + "name": "RAY", + "code": "RAY", + "decimals": 6, + "coinGeckoId": "raydium", + "contractAddress": "4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R" + }, + "SRM": { + "name": "SERUM", + "code": "SRM", + "decimals": 6, + "coinGeckoId": "serum", + "contractAddress": "SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt" + }, + "soLINK": { + "name": "soLINK", + "code": "LINK", + "decimals": 6, + "coinGeckoId": "chainlink", + "contractAddress": "CWE8jPTUYhdCTZYWPTe1o5DFqfdjzWKc9WKz6rSjQUdG", + "matchingAsset": "LINK" + } +} diff --git a/src/assets/sendGasLimits.ts b/src/assets/sendGasLimits.ts index bed88abd2..74af42f6d 100644 --- a/src/assets/sendGasLimits.ts +++ b/src/assets/sendGasLimits.ts @@ -8,7 +8,7 @@ const sendGasLimits = { TERRA: 200000, // applies on both native and ERC2 Terra assets ARBETH: 620000, // for native asset is around ~420k and for ERC20 ~540k NEAR: 10000000000000, - SOL: 1000000 + SOL: 1000000000 } const getSendGasLimitERC20 = (chainId: ChainId): number | null => { diff --git a/src/chains.ts b/src/chains.ts index 1b006e38a..48e84c49b 100644 --- a/src/chains.ts +++ b/src/chains.ts @@ -31,6 +31,7 @@ const chains: { [key in ChainId]: Chain } = { txFailureTimeout: 10800000, // 3 hours in ms evmCompatible: false, hasTokens: false, + supportCustomFees: true, // TODO: include network types in validation isValidAddress: (address) => !!validateBitcoinAddress(address), formatAddress: (address) => address, @@ -49,6 +50,7 @@ const chains: { [key in ChainId]: Chain } = { txFailureTimeout: 10800000, // 3 hours in ms evmCompatible: false, hasTokens: false, + supportCustomFees: true, // TODO: include network types in validation isValidAddress: (address) => isValidBitcoinCashAddress(address), formatAddress: (address) => formatBitcoinCashAddress(address), @@ -67,6 +69,7 @@ const chains: { [key in ChainId]: Chain } = { txFailureTimeout: 1800000, // in ms evmCompatible: true, hasTokens: true, + supportCustomFees: true, isValidAddress: (hexAddress: string) => isValidAddress(with0x(hexAddress)), formatAddress: (hexAddress: string) => toChecksumAddress(with0x(hexAddress)), isValidTransactionHash: (hash: string) => isValidHexWith0xPrefix(hash), @@ -84,6 +87,7 @@ const chains: { [key in ChainId]: Chain } = { txFailureTimeout: 1800000, // in ms evmCompatible: true, hasTokens: true, + supportCustomFees: true, isValidAddress: (hexAddress: string) => isValidAddress(with0x(hexAddress)), formatAddress: (hexAddress: string, network?: string) => toChecksumAddress(with0x(hexAddress), getRSKChainID(network)), @@ -102,6 +106,7 @@ const chains: { [key in ChainId]: Chain } = { txFailureTimeout: 600000, // in ms evmCompatible: true, hasTokens: true, + supportCustomFees: true, isValidAddress: (hexAddress: string) => isValidAddress(with0x(hexAddress)), formatAddress: (hexAddress: string) => toChecksumAddress(with0x(hexAddress)), isValidTransactionHash: (hash: string) => isValidHexWith0xPrefix(hash), @@ -119,6 +124,7 @@ const chains: { [key in ChainId]: Chain } = { txFailureTimeout: 300000, // in ms evmCompatible: false, hasTokens: false, + supportCustomFees: true, isValidAddress: (address) => isValidNearAddress(address), formatAddress: (address) => address, isValidTransactionHash: (hash: string) => isValidNearTx(hash), @@ -131,11 +137,12 @@ const chains: { [key in ChainId]: Chain } = { fees: { unit: 'Lamports' }, - safeConfirmations: 31, + safeConfirmations: 10, // ~120 blocks per minute * 5 minutes -> 600 blocks wait period txFailureTimeout: 300000, // in ms evmCompatible: false, hasTokens: false, + supportCustomFees: false, isValidAddress: (address) => isValidSolanaAddress(address), formatAddress: (address) => address, isValidTransactionHash: (hash: string) => isValidSolanaTx(hash), @@ -153,6 +160,7 @@ const chains: { [key in ChainId]: Chain } = { txFailureTimeout: 900000, // in ms evmCompatible: false, hasTokens: true, + supportCustomFees: true, isValidAddress: (address) => isValidTerraAddress(address), formatAddress: (address) => address, isValidTransactionHash: (hash: string) => isValidTerraTx(hash), @@ -170,6 +178,7 @@ const chains: { [key in ChainId]: Chain } = { txFailureTimeout: 600000, // in ms evmCompatible: true, hasTokens: true, + supportCustomFees: true, isValidAddress: (hexAddress: string) => isValidAddress(with0x(hexAddress)), formatAddress: (hexAddress: string) => toChecksumAddress(with0x(hexAddress)), isValidTransactionHash: (hash: string) => isValidHexWith0xPrefix(hash), @@ -187,6 +196,7 @@ const chains: { [key in ChainId]: Chain } = { txFailureTimeout: 600000, // in ms evmCompatible: true, hasTokens: true, + supportCustomFees: true, isValidAddress: (hexAddress: string) => isValidAddress(with0x(hexAddress)), formatAddress: (hexAddress: string) => toChecksumAddress(with0x(hexAddress)), isValidTransactionHash: (hash: string) => isValidHexWith0xPrefix(hash), @@ -204,6 +214,7 @@ const chains: { [key in ChainId]: Chain } = { txFailureTimeout: 900000, // in ms evmCompatible: true, hasTokens: true, + supportCustomFees: true, isValidAddress: (hexAddress: string) => isValidAddress(with0x(hexAddress)), formatAddress: (hexAddress: string) => toChecksumAddress(with0x(hexAddress)), isValidTransactionHash: (hash: string) => isValidHexWith0xPrefix(hash), @@ -221,6 +232,7 @@ const chains: { [key in ChainId]: Chain } = { txFailureTimeout: 600000, // in ms evmCompatible: true, hasTokens: true, + supportCustomFees: true, isValidAddress: (hexAddress: string) => isValidAddress(with0x(hexAddress)), formatAddress: (hexAddress: string) => toChecksumAddress(with0x(hexAddress)), isValidTransactionHash: (hash: string) => isValidHexWith0xPrefix(hash), diff --git a/src/types.ts b/src/types.ts index cfcda73ca..f39ca3b8a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -9,6 +9,7 @@ export interface Chain { txFailureTimeout: number evmCompatible: boolean hasTokens: boolean + supportCustomFees: boolean isValidAddress: (address: string, network?: string) => boolean formatAddress: (address: string, network?: string) => string isValidTransactionHash: (hash: string) => boolean