From e09834a562cf3b0a2a78ed6fc59cd4c6fa61007e Mon Sep 17 00:00:00 2001 From: Slav Keremidchiev Date: Tue, 29 Mar 2022 17:51:08 +0300 Subject: [PATCH 1/2] feat: send fees --- src/assets/erc20/index.ts | 16 +++++++++++----- src/assets/native.ts | 40 ++++++++++++++++++++++++++------------- src/assets/sendFees.ts | 11 +++++++++++ src/types.ts | 1 + 4 files changed, 50 insertions(+), 18 deletions(-) create mode 100644 src/assets/sendFees.ts diff --git a/src/assets/erc20/index.ts b/src/assets/erc20/index.ts index f016781fa..c144d534f 100644 --- a/src/assets/erc20/index.ts +++ b/src/assets/erc20/index.ts @@ -8,30 +8,36 @@ import terraTokens from './terra-tokens.json' import { TESTNET_CONTRACT_ADDRESSES, TESTNET_TOKENS } from '../testnet' import { Asset, ChainId, AssetType, AssetMap } from '../../types' +import { sendFees } from '../sendFees' const rskTokensData = mapValues(rskTokens, (tokenData) => ({ ...tokenData, - chain: ChainId.Rootstock + chain: ChainId.Rootstock, + sendFee: sendFees.ERC20_EVM })) const ethereumTokensData = mapValues(ethereumTokens, (tokenData) => ({ ...tokenData, - chain: ChainId.Ethereum + chain: ChainId.Ethereum, + sendFee: sendFees.ERC20_EVM })) const polygonTokensData = mapValues(polygonTokens, (tokenData) => ({ ...tokenData, - chain: ChainId.Polygon + chain: ChainId.Polygon, + sendFee: sendFees.ERC20_EVM })) const avalancheTokensData = mapValues(avalancheTokens, (tokenData) => ({ ...tokenData, - chain: ChainId.Avalanche + chain: ChainId.Avalanche, + sendFee: sendFees.ERC20_EVM })) const terraTokensData = mapValues(terraTokens, (tokenData) => ({ ...tokenData, - chain: ChainId.Terra + chain: ChainId.Terra, + sendFee: sendFees.TERRA })) const erc20Assets: AssetMap = mapValues( diff --git a/src/assets/native.ts b/src/assets/native.ts index 2231d626e..98345acc1 100644 --- a/src/assets/native.ts +++ b/src/assets/native.ts @@ -1,5 +1,6 @@ import { TESTNET_NATIVE } from './testnet' import { AssetMap, ChainId } from '../types' +import { sendFees } from '../assets/sendFees' const nativeAssets: AssetMap = { BTC: { @@ -9,7 +10,8 @@ const nativeAssets: AssetMap = { code: 'BTC', coinGeckoId: 'bitcoin', color: '#f7931a', - decimals: 8 + decimals: 8, + sendFee: sendFees.BTC }, BCH: { name: 'Bitcoin Cash', @@ -18,7 +20,8 @@ const nativeAssets: AssetMap = { code: 'BCH', coinGeckoId: 'bitcoin-cash', color: '#a1db5e', - decimals: 8 + decimals: 8, + sendFee: sendFees.BTC // TODO: is this correct? }, ETH: { name: 'Ether', @@ -27,7 +30,8 @@ const nativeAssets: AssetMap = { code: 'ETH', coinGeckoId: 'ethereum', color: '#627eea', - decimals: 18 + decimals: 18, + sendFee: sendFees.NATIVE_EVM }, RBTC: { name: 'Rootstock BTC', @@ -36,7 +40,8 @@ const nativeAssets: AssetMap = { code: 'RBTC', coinGeckoId: 'rootstock', color: '#006e3c', - decimals: 18 + decimals: 18, + sendFee: sendFees.NATIVE_EVM }, BNB: { name: 'Binance Coin', @@ -45,7 +50,8 @@ const nativeAssets: AssetMap = { code: 'BNB', coinGeckoId: 'binancecoin', color: '#f9a825', - decimals: 18 + decimals: 18, + sendFee: sendFees.NATIVE_EVM }, NEAR: { name: 'Near', @@ -54,7 +60,8 @@ const nativeAssets: AssetMap = { code: 'NEAR', coinGeckoId: 'near', color: '#000000', - decimals: 24 + decimals: 24, + sendFee: sendFees.NEAR }, SOL: { name: 'Solana', @@ -63,7 +70,8 @@ const nativeAssets: AssetMap = { code: 'SOL', coinGeckoId: 'solana', color: '#008080', - decimals: 9 + decimals: 9, + sendFee: sendFees.SOL }, MATIC: { name: 'Matic', @@ -72,7 +80,8 @@ const nativeAssets: AssetMap = { code: 'MATIC', coinGeckoId: 'matic-network', color: '#8247E5', - decimals: 18 + decimals: 18, + sendFee: sendFees.NATIVE_EVM }, ARBETH: { name: 'Arbitrum ETH', @@ -82,7 +91,8 @@ const nativeAssets: AssetMap = { coinGeckoId: 'ethereum', color: '#28A0EF', decimals: 18, - matchingAsset: 'ETH' + matchingAsset: 'ETH', + sendFee: sendFees.ARBETH }, FUSE: { name: 'Fuse Network', @@ -91,7 +101,8 @@ const nativeAssets: AssetMap = { code: 'FUSE', coinGeckoId: 'fuse-network-token', color: '#46e8b6', - decimals: 18 + decimals: 18, + sendFee: sendFees.NATIVE_EVM }, LUNA: { name: 'Luna', @@ -100,7 +111,8 @@ const nativeAssets: AssetMap = { code: 'LUNA', coinGeckoId: 'terra-luna', color: '#008080', - decimals: 6 + decimals: 6, + sendFee: sendFees.TERRA }, UST: { name: 'TerraUSD', @@ -110,7 +122,8 @@ const nativeAssets: AssetMap = { decimals: 6, color: '#0083ff', coinGeckoId: 'terrausd', - feeAsset: 'UST' + feeAsset: 'UST', + sendFee: sendFees.TERRA }, AVAX: { name: 'Avalanche', @@ -119,7 +132,8 @@ const nativeAssets: AssetMap = { code: 'AVAX', coinGeckoId: 'avalanche-2', color: '#E84141', - decimals: 18 + decimals: 18, + sendFee: sendFees.NATIVE_EVM } } diff --git a/src/assets/sendFees.ts b/src/assets/sendFees.ts new file mode 100644 index 000000000..5e0cddb01 --- /dev/null +++ b/src/assets/sendFees.ts @@ -0,0 +1,11 @@ +const sendFees = { + BTC: 290, + NATIVE_EVM: 21000, // EVM -> ETH, RBTC, MATIC, BNB, AVAX, FUSE + ERC20_EVM: 90000, // EVM -> ETH, RBTC, MATIC, BNB, AVAX, FUSE + TERRA: 100000, // applies on both native and ERC2 Terra assets + ARBETH: 620000, + NEAR: 10000000000000, + SOL: 1000000 +} + +export { sendFees } diff --git a/src/types.ts b/src/types.ts index a46bc8146..b5b283b81 100644 --- a/src/types.ts +++ b/src/types.ts @@ -41,6 +41,7 @@ export interface Asset { contractAddress?: string // ERC20 only matchingAsset?: string feeAsset?: string + sendFee: number } export type AssetMap = Record From c22deb6149469bf2db249b831e464740ff733c13 Mon Sep 17 00:00:00 2001 From: Slav Keremidchiev Date: Wed, 30 Mar 2022 13:07:05 +0300 Subject: [PATCH 2/2] fix: rename fees to gasLimit --- src/assets/erc20/index.ts | 12 ++++----- src/assets/native.ts | 28 ++++++++++---------- src/assets/{sendFees.ts => sendGasLimits.ts} | 4 +-- src/types.ts | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) rename src/assets/{sendFees.ts => sendGasLimits.ts} (84%) diff --git a/src/assets/erc20/index.ts b/src/assets/erc20/index.ts index c144d534f..d875ebc02 100644 --- a/src/assets/erc20/index.ts +++ b/src/assets/erc20/index.ts @@ -8,36 +8,36 @@ import terraTokens from './terra-tokens.json' import { TESTNET_CONTRACT_ADDRESSES, TESTNET_TOKENS } from '../testnet' import { Asset, ChainId, AssetType, AssetMap } from '../../types' -import { sendFees } from '../sendFees' +import { sendGasLimits } from '../sendGasLimits' const rskTokensData = mapValues(rskTokens, (tokenData) => ({ ...tokenData, chain: ChainId.Rootstock, - sendFee: sendFees.ERC20_EVM + sendGasLimit: sendGasLimits.ERC20_EVM })) const ethereumTokensData = mapValues(ethereumTokens, (tokenData) => ({ ...tokenData, chain: ChainId.Ethereum, - sendFee: sendFees.ERC20_EVM + sendGasLimit: sendGasLimits.ERC20_EVM })) const polygonTokensData = mapValues(polygonTokens, (tokenData) => ({ ...tokenData, chain: ChainId.Polygon, - sendFee: sendFees.ERC20_EVM + sendGasLimit: sendGasLimits.ERC20_EVM })) const avalancheTokensData = mapValues(avalancheTokens, (tokenData) => ({ ...tokenData, chain: ChainId.Avalanche, - sendFee: sendFees.ERC20_EVM + sendGasLimit: sendGasLimits.ERC20_EVM })) const terraTokensData = mapValues(terraTokens, (tokenData) => ({ ...tokenData, chain: ChainId.Terra, - sendFee: sendFees.TERRA + sendGasLimit: sendGasLimits.TERRA })) const erc20Assets: AssetMap = mapValues( diff --git a/src/assets/native.ts b/src/assets/native.ts index 98345acc1..0f46a7e42 100644 --- a/src/assets/native.ts +++ b/src/assets/native.ts @@ -1,6 +1,6 @@ import { TESTNET_NATIVE } from './testnet' import { AssetMap, ChainId } from '../types' -import { sendFees } from '../assets/sendFees' +import { sendGasLimits } from '../assets/sendGasLimits' const nativeAssets: AssetMap = { BTC: { @@ -11,7 +11,7 @@ const nativeAssets: AssetMap = { coinGeckoId: 'bitcoin', color: '#f7931a', decimals: 8, - sendFee: sendFees.BTC + sendGasLimit: sendGasLimits.BTC }, BCH: { name: 'Bitcoin Cash', @@ -21,7 +21,7 @@ const nativeAssets: AssetMap = { coinGeckoId: 'bitcoin-cash', color: '#a1db5e', decimals: 8, - sendFee: sendFees.BTC // TODO: is this correct? + sendGasLimit: sendGasLimits.BTC // TODO: is this correct? }, ETH: { name: 'Ether', @@ -31,7 +31,7 @@ const nativeAssets: AssetMap = { coinGeckoId: 'ethereum', color: '#627eea', decimals: 18, - sendFee: sendFees.NATIVE_EVM + sendGasLimit: sendGasLimits.NATIVE_EVM }, RBTC: { name: 'Rootstock BTC', @@ -41,7 +41,7 @@ const nativeAssets: AssetMap = { coinGeckoId: 'rootstock', color: '#006e3c', decimals: 18, - sendFee: sendFees.NATIVE_EVM + sendGasLimit: sendGasLimits.NATIVE_EVM }, BNB: { name: 'Binance Coin', @@ -51,7 +51,7 @@ const nativeAssets: AssetMap = { coinGeckoId: 'binancecoin', color: '#f9a825', decimals: 18, - sendFee: sendFees.NATIVE_EVM + sendGasLimit: sendGasLimits.NATIVE_EVM }, NEAR: { name: 'Near', @@ -61,7 +61,7 @@ const nativeAssets: AssetMap = { coinGeckoId: 'near', color: '#000000', decimals: 24, - sendFee: sendFees.NEAR + sendGasLimit: sendGasLimits.NEAR }, SOL: { name: 'Solana', @@ -71,7 +71,7 @@ const nativeAssets: AssetMap = { coinGeckoId: 'solana', color: '#008080', decimals: 9, - sendFee: sendFees.SOL + sendGasLimit: sendGasLimits.SOL }, MATIC: { name: 'Matic', @@ -81,7 +81,7 @@ const nativeAssets: AssetMap = { coinGeckoId: 'matic-network', color: '#8247E5', decimals: 18, - sendFee: sendFees.NATIVE_EVM + sendGasLimit: sendGasLimits.NATIVE_EVM }, ARBETH: { name: 'Arbitrum ETH', @@ -92,7 +92,7 @@ const nativeAssets: AssetMap = { color: '#28A0EF', decimals: 18, matchingAsset: 'ETH', - sendFee: sendFees.ARBETH + sendGasLimit: sendGasLimits.ARBETH }, FUSE: { name: 'Fuse Network', @@ -102,7 +102,7 @@ const nativeAssets: AssetMap = { coinGeckoId: 'fuse-network-token', color: '#46e8b6', decimals: 18, - sendFee: sendFees.NATIVE_EVM + sendGasLimit: sendGasLimits.NATIVE_EVM }, LUNA: { name: 'Luna', @@ -112,7 +112,7 @@ const nativeAssets: AssetMap = { coinGeckoId: 'terra-luna', color: '#008080', decimals: 6, - sendFee: sendFees.TERRA + sendGasLimit: sendGasLimits.TERRA }, UST: { name: 'TerraUSD', @@ -123,7 +123,7 @@ const nativeAssets: AssetMap = { color: '#0083ff', coinGeckoId: 'terrausd', feeAsset: 'UST', - sendFee: sendFees.TERRA + sendGasLimit: sendGasLimits.TERRA }, AVAX: { name: 'Avalanche', @@ -133,7 +133,7 @@ const nativeAssets: AssetMap = { coinGeckoId: 'avalanche-2', color: '#E84141', decimals: 18, - sendFee: sendFees.NATIVE_EVM + sendGasLimit: sendGasLimits.NATIVE_EVM } } diff --git a/src/assets/sendFees.ts b/src/assets/sendGasLimits.ts similarity index 84% rename from src/assets/sendFees.ts rename to src/assets/sendGasLimits.ts index 5e0cddb01..111f98358 100644 --- a/src/assets/sendFees.ts +++ b/src/assets/sendGasLimits.ts @@ -1,4 +1,4 @@ -const sendFees = { +const sendGasLimits = { BTC: 290, NATIVE_EVM: 21000, // EVM -> ETH, RBTC, MATIC, BNB, AVAX, FUSE ERC20_EVM: 90000, // EVM -> ETH, RBTC, MATIC, BNB, AVAX, FUSE @@ -8,4 +8,4 @@ const sendFees = { SOL: 1000000 } -export { sendFees } +export { sendGasLimits } diff --git a/src/types.ts b/src/types.ts index b5b283b81..6ac86c56a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -41,7 +41,7 @@ export interface Asset { contractAddress?: string // ERC20 only matchingAsset?: string feeAsset?: string - sendFee: number + sendGasLimit: number } export type AssetMap = Record