@exodus/ethereum-lib 2.12.0 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-lib",
3
- "version": "2.12.0",
3
+ "version": "2.13.0",
4
4
  "description": "Ethereum Library",
5
5
  "main": "src/index.js",
6
6
  "author": "Exodus Movement, Inc.",
@@ -23,5 +23,6 @@
23
23
  },
24
24
  "peerDependencies": {
25
25
  "@exodus/assets": "8.0.x"
26
- }
26
+ },
27
+ "gitHead": "65e6814fcebf5a3c4f3bc0d73cb092bca455fa17"
27
28
  }
@@ -0,0 +1,128 @@
1
+ // extended (with metadata: decimals, name, symbol) erc20
2
+ // compiled from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/extensions/IERC20Metadata.sol with solcjs, compiler 0.8.0
3
+ // `solcjs --abi --base-path . extensions/IERC20Metadata.sol`
4
+
5
+ export default [
6
+ {
7
+ anonymous: false,
8
+ inputs: [
9
+ { indexed: true, internalType: 'address', name: 'owner', type: 'address' },
10
+ {
11
+ indexed: true,
12
+ internalType: 'address',
13
+ name: 'spender',
14
+ type: 'address',
15
+ },
16
+ { indexed: false, internalType: 'uint256', name: 'value', type: 'uint256' },
17
+ ],
18
+ name: 'Approval',
19
+ type: 'event',
20
+ },
21
+ {
22
+ anonymous: false,
23
+ inputs: [
24
+ { indexed: true, internalType: 'address', name: 'from', type: 'address' },
25
+ {
26
+ indexed: true,
27
+ internalType: 'address',
28
+ name: 'to',
29
+ type: 'address',
30
+ },
31
+ { indexed: false, internalType: 'uint256', name: 'value', type: 'uint256' },
32
+ ],
33
+ name: 'Transfer',
34
+ type: 'event',
35
+ },
36
+ {
37
+ inputs: [
38
+ { internalType: 'address', name: 'owner', type: 'address' },
39
+ {
40
+ internalType: 'address',
41
+ name: 'spender',
42
+ type: 'address',
43
+ },
44
+ ],
45
+ name: 'allowance',
46
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
47
+ stateMutability: 'view',
48
+ type: 'function',
49
+ },
50
+ {
51
+ inputs: [
52
+ { internalType: 'address', name: 'spender', type: 'address' },
53
+ {
54
+ internalType: 'uint256',
55
+ name: 'amount',
56
+ type: 'uint256',
57
+ },
58
+ ],
59
+ name: 'approve',
60
+ outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
61
+ stateMutability: 'nonpayable',
62
+ type: 'function',
63
+ },
64
+ {
65
+ inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
66
+ name: 'balanceOf',
67
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
68
+ stateMutability: 'view',
69
+ type: 'function',
70
+ },
71
+ {
72
+ inputs: [],
73
+ name: 'decimals',
74
+ outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }],
75
+ stateMutability: 'view',
76
+ type: 'function',
77
+ },
78
+ {
79
+ inputs: [],
80
+ name: 'name',
81
+ outputs: [{ internalType: 'string', name: '', type: 'string' }],
82
+ stateMutability: 'view',
83
+ type: 'function',
84
+ },
85
+ {
86
+ inputs: [],
87
+ name: 'symbol',
88
+ outputs: [{ internalType: 'string', name: '', type: 'string' }],
89
+ stateMutability: 'view',
90
+ type: 'function',
91
+ },
92
+ {
93
+ inputs: [],
94
+ name: 'totalSupply',
95
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
96
+ stateMutability: 'view',
97
+ type: 'function',
98
+ },
99
+ {
100
+ inputs: [
101
+ { internalType: 'address', name: 'to', type: 'address' },
102
+ {
103
+ internalType: 'uint256',
104
+ name: 'amount',
105
+ type: 'uint256',
106
+ },
107
+ ],
108
+ name: 'transfer',
109
+ outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
110
+ stateMutability: 'nonpayable',
111
+ type: 'function',
112
+ },
113
+ {
114
+ inputs: [
115
+ { internalType: 'address', name: 'from', type: 'address' },
116
+ {
117
+ internalType: 'address',
118
+ name: 'to',
119
+ type: 'address',
120
+ },
121
+ { internalType: 'uint256', name: 'amount', type: 'uint256' },
122
+ ],
123
+ name: 'transferFrom',
124
+ outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
125
+ stateMutability: 'nonpayable',
126
+ type: 'function',
127
+ },
128
+ ]
package/src/abi/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import ant from './ant'
2
2
  import cdai from './cdai'
3
3
  import dai from './dai'
4
+ import erc20 from './ierc20-extended'
4
5
  import gnt from './gnt'
5
6
  import kyberv2 from './kyberv2.js'
6
7
  import loomv2Swap from './loomv2-swap'
@@ -11,6 +12,7 @@ export default {
11
12
  ant,
12
13
  cdai,
13
14
  dai,
15
+ erc20,
14
16
  gnt,
15
17
  kyberv2,
16
18
  loomv2Swap,
package/src/constants.js CHANGED
@@ -4,6 +4,7 @@ export const CHAIN_IDS = {
4
4
  bsc: 56,
5
5
  matic: 137,
6
6
  avalanchec: 43114,
7
+ fantommainnet: 250,
7
8
  }
8
9
  export const MIN_GASPRICE = 1e9 // 1 gwei
9
10
  export const DEFAULT_FEE_MONITOR_INTERVAL = '1m'
@@ -13,12 +14,21 @@ export const CONFIRMATIONS_NUMBER = {
13
14
  bsc: 15,
14
15
  matic: 355,
15
16
  avalanchec: 30,
17
+ fantommainnet: 3,
16
18
  }
17
- export const ETHEREUM_LIKE_ASSETS = ['bsc', 'ethereum', 'ethereumclassic', 'matic', 'avalanchec']
19
+ export const ETHEREUM_LIKE_ASSETS = [
20
+ 'bsc',
21
+ 'ethereum',
22
+ 'ethereumclassic',
23
+ 'matic',
24
+ 'avalanchec',
25
+ 'fantommainnet',
26
+ ]
18
27
  export const ETHEREUM_LIKE_TOKEN_TYPES = [
19
28
  'ETHEREUM_ERC20',
20
29
  'BSC_BEP20',
21
30
  'MATIC_ERC20',
22
31
  'AVAX_ERC20',
32
+ 'FTM_ERC20',
23
33
  ]
24
34
  export const BUMP_RATE = 1.2
@@ -7,7 +7,7 @@ export default new FeeData(
7
7
  gasPrice: '225 nAVAX',
8
8
  max: '1000 nAVAX',
9
9
  min: '25 nAVAX',
10
- erc20FuelThreshold: '20000 nAVAX',
10
+ fuelThreshold: '20000 nAVAX',
11
11
  gasPriceEconomicalRate: 0.8,
12
12
  gasPriceMinimumRate: 0.6,
13
13
  },
@@ -5,7 +5,7 @@ export default new FeeData(
5
5
  gasPrice: '20 Gwei',
6
6
  max: '200 Gwei',
7
7
  min: '1 Gwei',
8
- erc20FuelThreshold: '2500000 Gwei',
8
+ fuelThreshold: '2500000 Gwei',
9
9
  gasPriceEconomicalRate: 0.8,
10
10
  gasPriceMinimumRate: 0.6,
11
11
  },
@@ -5,7 +5,7 @@ export default new FeeData(
5
5
  gasPrice: '75 Gwei',
6
6
  max: '250 Gwei',
7
7
  min: '1 Gwei',
8
- erc20FuelThreshold: '0.025 ETH',
8
+ fuelThreshold: '0.025 ETH',
9
9
  swapFee: '0.05 ETH',
10
10
  gasPriceEconomicalRate: 0.7,
11
11
  gasPriceMinimumRate: 0.5,
@@ -0,0 +1,15 @@
1
+ import { FeeData } from '@exodus/asset-lib'
2
+
3
+ export default new FeeData(
4
+ {
5
+ // https://ftmscan.com/chart/gasprice
6
+ gasPrice: '400 Gwei',
7
+ max: '700 Gwei',
8
+ min: '100 Gwei',
9
+ erc20FuelThreshold: '2500000 Gwei',
10
+ gasPriceEconomicalRate: 0.8,
11
+ gasPriceMinimumRate: 0.6,
12
+ },
13
+ 'gasPrice',
14
+ 'fantommainnet'
15
+ )
@@ -3,3 +3,4 @@ export { default as ethereumclassic } from './ethereumclassic'
3
3
  export { default as bsc } from './bsc'
4
4
  export { default as matic } from './polygon'
5
5
  export { default as avalanchec } from './avalanchec'
6
+ export { default as fantommainnet } from './fantom'
@@ -6,7 +6,7 @@ export default new FeeData(
6
6
  gasPrice: '5 Gwei',
7
7
  max: '300 Gwei',
8
8
  min: '30 Gwei',
9
- erc20FuelThreshold: '2500000 Gwei',
9
+ fuelThreshold: '2500000 Gwei',
10
10
  gasPriceEconomicalRate: 0.8,
11
11
  gasPriceMinimumRate: 0.6,
12
12
  },
@@ -16,13 +16,16 @@ export const isAvalancheToken = (asset) => asset.assetType === 'AVAX_ERC20'
16
16
 
17
17
  // All ethereum-like tokens
18
18
  export const isEthereumLikeToken = (asset) => ETHEREUM_LIKE_TOKEN_TYPES.includes(asset.assetType)
19
+ export const isEthereumLikeTokenByName = (assetName) => isEthereumLikeToken(assets[assetName])
19
20
  export const isToken = isEthereumLikeToken
20
21
 
21
22
  // All ethereum-like assets (native coins)
22
- export const isEthereumLikeAsset = (asset) => ETHEREUM_LIKE_ASSETS.includes(asset.name)
23
+ export const isEthereumLikeAsset = (asset) => isEthereumLikeAssetByName(asset.name)
24
+ export const isEthereumLikeAssetByName = (assetName) => ETHEREUM_LIKE_ASSETS.includes(assetName)
23
25
 
24
26
  // All ethereum-like assets and tokens
25
27
  export const isEthereumLike = (asset) => ETHEREUM_LIKE_ASSETS.includes(asset.baseAsset.name)
28
+ export const isEthereumLikeByName = (assetName) => isEthereumLike(assets[assetName])
26
29
 
27
30
  export function buffer2currency({ asset, value }) {
28
31
  return asset.currency.baseUnit(base10.encode(value)).toDefault()