Skip to content

Commit

Permalink
Feat/add solana tokens (#91)
Browse files Browse the repository at this point in the history
* feat: Add solana tokens

* feat: Add solana tokens and prop support custom fees

* fix: Link asset
  • Loading branch information
AndonMitev authored Jul 29, 2022
1 parent c28fb94 commit 4036ed2
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/assets/erc20/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -47,14 +48,21 @@ 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,
...ethereumTokensData,
...polygonTokensData,
...terraTokensData,
...avalancheTokensData,
...arbitrumTokensData
...arbitrumTokensData,
...solanaTokensData
},
(tokenData) => ({
...tokenData,
Expand Down
40 changes: 40 additions & 0 deletions src/assets/erc20/solana-tokens.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
2 changes: 1 addition & 1 deletion src/assets/sendGasLimits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
14 changes: 13 additions & 1 deletion src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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)),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4036ed2

Please sign in to comment.