Skip to content

Commit

Permalink
Merge pull request #81 from liquality/send-fees
Browse files Browse the repository at this point in the history
feat: send fees
  • Loading branch information
skeremidchiev committed Mar 30, 2022
2 parents 12743c9 + c22deb6 commit 9f6e332
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 18 deletions.
16 changes: 11 additions & 5 deletions src/assets/erc20/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 { sendGasLimits } from '../sendGasLimits'

const rskTokensData = mapValues(rskTokens, (tokenData) => ({
...tokenData,
chain: ChainId.Rootstock
chain: ChainId.Rootstock,
sendGasLimit: sendGasLimits.ERC20_EVM
}))

const ethereumTokensData = mapValues(ethereumTokens, (tokenData) => ({
...tokenData,
chain: ChainId.Ethereum
chain: ChainId.Ethereum,
sendGasLimit: sendGasLimits.ERC20_EVM
}))

const polygonTokensData = mapValues(polygonTokens, (tokenData) => ({
...tokenData,
chain: ChainId.Polygon
chain: ChainId.Polygon,
sendGasLimit: sendGasLimits.ERC20_EVM
}))

const avalancheTokensData = mapValues(avalancheTokens, (tokenData) => ({
...tokenData,
chain: ChainId.Avalanche
chain: ChainId.Avalanche,
sendGasLimit: sendGasLimits.ERC20_EVM
}))

const terraTokensData = mapValues(terraTokens, (tokenData) => ({
...tokenData,
chain: ChainId.Terra
chain: ChainId.Terra,
sendGasLimit: sendGasLimits.TERRA
}))

const erc20Assets: AssetMap = mapValues(
Expand Down
40 changes: 27 additions & 13 deletions src/assets/native.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { TESTNET_NATIVE } from './testnet'
import { AssetMap, ChainId } from '../types'
import { sendGasLimits } from '../assets/sendGasLimits'

const nativeAssets: AssetMap = {
BTC: {
Expand All @@ -9,7 +10,8 @@ const nativeAssets: AssetMap = {
code: 'BTC',
coinGeckoId: 'bitcoin',
color: '#f7931a',
decimals: 8
decimals: 8,
sendGasLimit: sendGasLimits.BTC
},
BCH: {
name: 'Bitcoin Cash',
Expand All @@ -18,7 +20,8 @@ const nativeAssets: AssetMap = {
code: 'BCH',
coinGeckoId: 'bitcoin-cash',
color: '#a1db5e',
decimals: 8
decimals: 8,
sendGasLimit: sendGasLimits.BTC // TODO: is this correct?
},
ETH: {
name: 'Ether',
Expand All @@ -27,7 +30,8 @@ const nativeAssets: AssetMap = {
code: 'ETH',
coinGeckoId: 'ethereum',
color: '#627eea',
decimals: 18
decimals: 18,
sendGasLimit: sendGasLimits.NATIVE_EVM
},
RBTC: {
name: 'Rootstock BTC',
Expand All @@ -36,7 +40,8 @@ const nativeAssets: AssetMap = {
code: 'RBTC',
coinGeckoId: 'rootstock',
color: '#006e3c',
decimals: 18
decimals: 18,
sendGasLimit: sendGasLimits.NATIVE_EVM
},
BNB: {
name: 'Binance Coin',
Expand All @@ -45,7 +50,8 @@ const nativeAssets: AssetMap = {
code: 'BNB',
coinGeckoId: 'binancecoin',
color: '#f9a825',
decimals: 18
decimals: 18,
sendGasLimit: sendGasLimits.NATIVE_EVM
},
NEAR: {
name: 'Near',
Expand All @@ -54,7 +60,8 @@ const nativeAssets: AssetMap = {
code: 'NEAR',
coinGeckoId: 'near',
color: '#000000',
decimals: 24
decimals: 24,
sendGasLimit: sendGasLimits.NEAR
},
SOL: {
name: 'Solana',
Expand All @@ -63,7 +70,8 @@ const nativeAssets: AssetMap = {
code: 'SOL',
coinGeckoId: 'solana',
color: '#008080',
decimals: 9
decimals: 9,
sendGasLimit: sendGasLimits.SOL
},
MATIC: {
name: 'Matic',
Expand All @@ -72,7 +80,8 @@ const nativeAssets: AssetMap = {
code: 'MATIC',
coinGeckoId: 'matic-network',
color: '#8247E5',
decimals: 18
decimals: 18,
sendGasLimit: sendGasLimits.NATIVE_EVM
},
ARBETH: {
name: 'Arbitrum ETH',
Expand All @@ -82,7 +91,8 @@ const nativeAssets: AssetMap = {
coinGeckoId: 'ethereum',
color: '#28A0EF',
decimals: 18,
matchingAsset: 'ETH'
matchingAsset: 'ETH',
sendGasLimit: sendGasLimits.ARBETH
},
FUSE: {
name: 'Fuse Network',
Expand All @@ -91,7 +101,8 @@ const nativeAssets: AssetMap = {
code: 'FUSE',
coinGeckoId: 'fuse-network-token',
color: '#46e8b6',
decimals: 18
decimals: 18,
sendGasLimit: sendGasLimits.NATIVE_EVM
},
LUNA: {
name: 'Luna',
Expand All @@ -100,7 +111,8 @@ const nativeAssets: AssetMap = {
code: 'LUNA',
coinGeckoId: 'terra-luna',
color: '#008080',
decimals: 6
decimals: 6,
sendGasLimit: sendGasLimits.TERRA
},
UST: {
name: 'TerraUSD',
Expand All @@ -110,7 +122,8 @@ const nativeAssets: AssetMap = {
decimals: 6,
color: '#0083ff',
coinGeckoId: 'terrausd',
feeAsset: 'UST'
feeAsset: 'UST',
sendGasLimit: sendGasLimits.TERRA
},
AVAX: {
name: 'Avalanche',
Expand All @@ -119,7 +132,8 @@ const nativeAssets: AssetMap = {
code: 'AVAX',
coinGeckoId: 'avalanche-2',
color: '#E84141',
decimals: 18
decimals: 18,
sendGasLimit: sendGasLimits.NATIVE_EVM
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/assets/sendGasLimits.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const sendGasLimits = {
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 { sendGasLimits }
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface Asset {
contractAddress?: string // ERC20 only
matchingAsset?: string
feeAsset?: string
sendGasLimit: number
}

export type AssetMap = Record<string, Asset>

0 comments on commit 9f6e332

Please sign in to comment.