@exodus/ethereum-lib 4.9.0 → 5.0.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/package.json +10 -21
- package/src/constants.js +0 -17
- package/src/encode.js +44 -29
- package/src/index.js +0 -2
- package/src/unsigned-tx/create-and-sign-tx.js +6 -5
- package/src/unsigned-tx/create-unsigned-tx.js +57 -61
- package/src/unsigned-tx/index.js +2 -2
- package/src/unsigned-tx/parse-unsigned-tx.js +2 -7
- package/src/fee-data/aurora.js +0 -16
- package/src/fee-data/avalanchec.js +0 -20
- package/src/fee-data/basemainnet.js +0 -18
- package/src/fee-data/bsc.js +0 -16
- package/src/fee-data/cronos.js +0 -18
- package/src/fee-data/ethereum.js +0 -21
- package/src/fee-data/ethereumarbnova.js +0 -16
- package/src/fee-data/ethereumarbone.js +0 -16
- package/src/fee-data/ethereumclassic.js +0 -13
- package/src/fee-data/ethereumgoerli.js +0 -20
- package/src/fee-data/ethereumholesky.js +0 -20
- package/src/fee-data/ethereumsepolia.js +0 -20
- package/src/fee-data/fantom.js +0 -17
- package/src/fee-data/flare.js +0 -16
- package/src/fee-data/harmony.js +0 -16
- package/src/fee-data/index.js +0 -18
- package/src/fee-data/optimism.js +0 -16
- package/src/fee-data/polygon.js +0 -19
- package/src/fee-data/rootstock.js +0 -16
- package/src/fee-monitor/ethereum-like.js +0 -32
- package/src/fee-monitor/index.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ethereum-lib",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Ethereum Library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -20,31 +20,18 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@exodus/asset-lib": "^4.1.0",
|
|
23
|
-
"@exodus/aurora-meta": "^1.0.3",
|
|
24
|
-
"@exodus/avalanchec-meta": "^1.0.4",
|
|
25
|
-
"@exodus/basemainnet-meta": "^1.0.6",
|
|
26
23
|
"@exodus/basic-utils": "^0.7.0",
|
|
27
|
-
"@exodus/bsc-meta": "^1.
|
|
28
|
-
"@exodus/cronos-meta": "^1.0.
|
|
24
|
+
"@exodus/bsc-meta": "^1.2.2",
|
|
25
|
+
"@exodus/cronos-meta": "^1.0.7",
|
|
29
26
|
"@exodus/currency": "^2.3.2",
|
|
30
|
-
"@exodus/ethereum-meta": "^1.
|
|
31
|
-
"@exodus/ethereumarbnova-meta": "^1.0.2",
|
|
32
|
-
"@exodus/ethereumarbone-meta": "^1.1.5",
|
|
33
|
-
"@exodus/ethereumclassic-meta": "^1.0.1",
|
|
34
|
-
"@exodus/ethereumgoerli-meta": "^1.0.3",
|
|
35
|
-
"@exodus/ethereumholesky-meta": "^1.0.1",
|
|
27
|
+
"@exodus/ethereum-meta": "^1.5.1",
|
|
36
28
|
"@exodus/ethereumjs-common": "^2.4.0-exodus.6",
|
|
37
29
|
"@exodus/ethereumjs-tx": "^3.3.0-exodus.7",
|
|
38
30
|
"@exodus/ethereumjs-util": "^7.1.0-exodus.7",
|
|
39
|
-
"@exodus/
|
|
40
|
-
"@exodus/fantommainnet-meta": "^1.0.5",
|
|
41
|
-
"@exodus/flare-meta": "^1.0.4",
|
|
42
|
-
"@exodus/harmonymainnet-meta": "^1.0.0",
|
|
31
|
+
"@exodus/flare-meta": "^1.0.6",
|
|
43
32
|
"@exodus/key-utils": "^3.1.0",
|
|
44
|
-
"@exodus/matic-meta": "^1.
|
|
33
|
+
"@exodus/matic-meta": "^1.3.0",
|
|
45
34
|
"@exodus/models": "^11.0.0",
|
|
46
|
-
"@exodus/optimism-meta": "^1.2.10",
|
|
47
|
-
"@exodus/rootstock-meta": "^1.0.5",
|
|
48
35
|
"@exodus/solidity-contract": "^1.1.3",
|
|
49
36
|
"@metamask/eth-sig-util": "^4.0.1",
|
|
50
37
|
"base-x": "^3.0.2",
|
|
@@ -58,7 +45,9 @@
|
|
|
58
45
|
"@exodus/assets": "^9.1.1",
|
|
59
46
|
"@exodus/bitcoin-meta": "^1.0.2",
|
|
60
47
|
"@exodus/bnbmainnet-meta": "^1.0.0",
|
|
61
|
-
"@exodus/elliptic": "^6.5.4-precomputed"
|
|
48
|
+
"@exodus/elliptic": "^6.5.4-precomputed",
|
|
49
|
+
"@exodus/ethereumclassic-meta": "^1.0.3",
|
|
50
|
+
"@exodus/fantommainnet-meta": "^1.1.2"
|
|
62
51
|
},
|
|
63
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "a5992c8a158d486d6e95c03b17136b67ee06459c"
|
|
64
53
|
}
|
package/src/constants.js
CHANGED
|
@@ -89,7 +89,6 @@ const CHAIN_DATA = {
|
|
|
89
89
|
confirmationsNumber: 3,
|
|
90
90
|
monitorType: 'no-history',
|
|
91
91
|
tokenType: 'RSK_ERC20',
|
|
92
|
-
eip1191ChainIdChecksum: true,
|
|
93
92
|
},
|
|
94
93
|
flare: {
|
|
95
94
|
chainId: 14,
|
|
@@ -128,10 +127,6 @@ export const ETHEREUM_LIKE_MONITOR_TYPES = mapValues(
|
|
|
128
127
|
)
|
|
129
128
|
export const CHAIN_IDS = mapValues(CHAIN_DATA, ({ chainId }) => chainId)
|
|
130
129
|
|
|
131
|
-
export const EIP1191_ASSET_NAMES = Object.entries(CHAIN_DATA)
|
|
132
|
-
.filter(([, data]) => data.eip1191ChainIdChecksum)
|
|
133
|
-
.map(([assetName]) => assetName)
|
|
134
|
-
|
|
135
130
|
export const MIN_GASPRICE = 1e9 // 1 gwei
|
|
136
131
|
export const DEFAULT_FEE_MONITOR_INTERVAL = '1m'
|
|
137
132
|
export const CONFIRMATIONS_NUMBER = mapValues(
|
|
@@ -146,15 +141,3 @@ export const BUMP_RATE = 1.2
|
|
|
146
141
|
export const ETHEREUM_LIKE_NO_HISTORY_ASSET_NAMES = Object.keys(CHAIN_DATA).filter(
|
|
147
142
|
(key) => CHAIN_DATA[key].monitorType === 'no-history'
|
|
148
143
|
)
|
|
149
|
-
|
|
150
|
-
export const CUSTOM_CHAINS = ['avalanchec', 'matic'].map((name) => ({
|
|
151
|
-
chainId: CHAIN_IDS[name],
|
|
152
|
-
networkId: CHAIN_IDS[name],
|
|
153
|
-
name,
|
|
154
|
-
genesis: {},
|
|
155
|
-
bootstrapNodes: [],
|
|
156
|
-
hardforks: [
|
|
157
|
-
{ name: 'berlin', block: null },
|
|
158
|
-
{ name: 'london', block: null },
|
|
159
|
-
],
|
|
160
|
-
}))
|
package/src/encode.js
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import * as etherUtil from '@exodus/ethereumjs-util'
|
|
2
|
-
import
|
|
2
|
+
import assert from 'minimalistic-assert'
|
|
3
3
|
|
|
4
|
-
export
|
|
5
|
-
|
|
4
|
+
export const validateFactory = ({ chainId, useEip1191ChainIdChecksum }) => {
|
|
5
|
+
assert(
|
|
6
|
+
chainId || !useEip1191ChainIdChecksum,
|
|
7
|
+
'chainId is required when useEip1191ChainIdChecksum is true'
|
|
8
|
+
)
|
|
9
|
+
return (address) => {
|
|
10
|
+
if (typeof address !== 'string') return false
|
|
6
11
|
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
// https://github.com/ethereumjs/ethereumjs-util/issues/54
|
|
13
|
+
if (address.slice(0, 2) !== '0x' || address.length !== 42) return false
|
|
9
14
|
|
|
10
|
-
|
|
15
|
+
if (!hasChecksum(address)) return true
|
|
11
16
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
)
|
|
17
|
+
return (
|
|
18
|
+
(useEip1191ChainIdChecksum && etherUtil.isValidChecksumAddress(address, chainId)) ||
|
|
19
|
+
etherUtil.isValidChecksumAddress(address)
|
|
20
|
+
)
|
|
21
|
+
}
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
export function hasChecksum(address) {
|
|
@@ -25,29 +29,40 @@ export function encodePrivate(privKey) {
|
|
|
25
29
|
return '0x' + privKey.toString('hex')
|
|
26
30
|
}
|
|
27
31
|
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const chainId = CHAIN_IDS[baseAssetName]
|
|
33
|
-
|
|
34
|
-
const basicAddress = etherUtil.toChecksumAddress(
|
|
35
|
-
'0x' + hash160bits.toString('hex'),
|
|
36
|
-
eip1191ChainIdChecksum ? chainId : undefined
|
|
32
|
+
export const encodePublicFactory = ({ chainId, useEip1191ChainIdChecksum }) => {
|
|
33
|
+
assert(
|
|
34
|
+
chainId || !useEip1191ChainIdChecksum,
|
|
35
|
+
'chainId is required when useEip1191ChainIdChecksum is true'
|
|
37
36
|
)
|
|
38
|
-
return
|
|
37
|
+
return (compressedPubKey) => {
|
|
38
|
+
const hash160bits = etherUtil.publicToAddress(compressedPubKey, true)
|
|
39
|
+
|
|
40
|
+
const basicAddress = etherUtil.toChecksumAddress(
|
|
41
|
+
'0x' + hash160bits.toString('hex'),
|
|
42
|
+
useEip1191ChainIdChecksum ? chainId : undefined
|
|
43
|
+
)
|
|
44
|
+
return useEip1191ChainIdChecksum ? basicAddress.toLowerCase() : basicAddress
|
|
45
|
+
}
|
|
39
46
|
}
|
|
40
47
|
|
|
41
48
|
export function isValidPrivate(privateKey) {
|
|
42
49
|
return !(privateKey.length !== 32 || !etherUtil.isValidPrivate(privateKey))
|
|
43
50
|
}
|
|
44
51
|
|
|
45
|
-
export
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return etherUtil.toChecksumAddress(
|
|
50
|
-
'0x' + etherUtil.privateToAddress(privateKey).toString('hex'),
|
|
51
|
-
eip1191ChainIdChecksum ? chainId : undefined
|
|
52
|
+
export const encodePublicFromPrivateFactory = ({ chainId, useEip1191ChainIdChecksum }) => {
|
|
53
|
+
assert(
|
|
54
|
+
chainId || !useEip1191ChainIdChecksum,
|
|
55
|
+
'chainId is required when useEip1191ChainIdChecksum is true'
|
|
52
56
|
)
|
|
57
|
+
return (privateKey) => {
|
|
58
|
+
return etherUtil.toChecksumAddress(
|
|
59
|
+
'0x' + etherUtil.privateToAddress(privateKey).toString('hex'),
|
|
60
|
+
useEip1191ChainIdChecksum ? chainId : undefined
|
|
61
|
+
)
|
|
62
|
+
}
|
|
53
63
|
}
|
|
64
|
+
|
|
65
|
+
// back compatiblity (except rsk)
|
|
66
|
+
export const validate = validateFactory({})
|
|
67
|
+
export const encodePublic = encodePublicFactory({})
|
|
68
|
+
export const encodePublicFromPrivate = encodePublicFromPrivateFactory({})
|
package/src/index.js
CHANGED
|
@@ -3,13 +3,11 @@ export * from './encode'
|
|
|
3
3
|
export * from './unsigned-tx'
|
|
4
4
|
export * from './utils'
|
|
5
5
|
export * from './constants'
|
|
6
|
-
export * from './fee-monitor'
|
|
7
6
|
export * from './selectors'
|
|
8
7
|
export { signMessage, signMessageWithSigner } from './sign-message'
|
|
9
8
|
export { default as createGetKeyIdentifier } from './key-identifier'
|
|
10
9
|
export { default as createEthereumLikeAccountState } from './account-state'
|
|
11
10
|
|
|
12
11
|
export { default as createContract } from './create-contract'
|
|
13
|
-
export * as feeData from './fee-data'
|
|
14
12
|
export { default as ABI } from './abi'
|
|
15
13
|
export { ethStakeAccountState } from './account-state/staking-data'
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import createUnsignedTxFactory from './create-unsigned-tx'
|
|
2
2
|
import signUnsignedTx from './sign-unsigned-tx'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export default function createAndSignTxFactory({ chainId }) {
|
|
5
|
+
return (input, privateKey) => {
|
|
6
|
+
const unsignedTx = createUnsignedTxFactory({ chainId })(input)
|
|
7
|
+
return signUnsignedTx(unsignedTx, privateKey)
|
|
8
|
+
}
|
|
8
9
|
}
|
|
@@ -1,67 +1,63 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toBuffer } from '@exodus/ethereumjs-util'
|
|
2
2
|
import { intToBuffer } from 'ethjs-util'
|
|
3
3
|
|
|
4
4
|
import { isToken, currency2buffer } from '../utils'
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
export default function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
chainId,
|
|
19
|
-
eip1559Enabled,
|
|
20
|
-
}) {
|
|
21
|
-
const baseAsset = asset.baseAsset
|
|
22
|
-
if (!chainId) chainId = CHAIN_IDS[baseAsset.name] // mainnet
|
|
23
|
-
|
|
24
|
-
if (txInput) {
|
|
25
|
-
txInput = toBuffer(txInput) // If txInput is already a Buffer, then it is passed through
|
|
26
|
-
} else {
|
|
27
|
-
txInput = Buffer.alloc(0)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const _isToken = isToken(asset)
|
|
31
|
-
const to = _isToken ? asset.contract.address : address
|
|
32
|
-
let value = currency2buffer(_isToken ? baseAsset.currency.ZERO : amount)
|
|
33
|
-
|
|
34
|
-
// TODO: check: present on desktop missing on mobile. This insures we never have a buffer specifying 0.
|
|
35
|
-
// In ETH, a buffer of zero length and a buffer specifying 0 imply different things
|
|
36
|
-
if (value.equals(Buffer.from([0]))) value = Buffer.alloc(0)
|
|
37
|
-
|
|
38
|
-
if (!fromAddress) {
|
|
39
|
-
if (privateKey) fromAddress = bufferToHex(privateToAddress(privateKey))
|
|
40
|
-
else throw new Error('createTx: Must pass fromAddress or privateKey in options')
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const txData = {
|
|
44
|
-
nonce: nonce === 0 ? Buffer.alloc(0) : intToBuffer(nonce),
|
|
45
|
-
gasPrice: currency2buffer(gasPrice),
|
|
46
|
-
tipGasPrice: tipGasPrice ? currency2buffer(tipGasPrice) : undefined,
|
|
47
|
-
gasLimit: intToBuffer(gasLimit),
|
|
48
|
-
to,
|
|
49
|
-
value,
|
|
50
|
-
data: txInput,
|
|
51
|
-
chainId,
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const txMeta = {
|
|
55
|
-
assetName: asset.name,
|
|
56
|
-
// TODO: We should move away from putting the PK into txMeta, it is a bad practice. It is a potential PK exposure risk if the wrong PK gets included here.
|
|
57
|
-
privateKey, // Used for importing private key
|
|
58
|
-
fee: baseAsset.currency.baseUnit(gasPrice.toBaseNumber() * gasLimit),
|
|
59
|
-
eip1559Enabled: !!eip1559Enabled,
|
|
5
|
+
import assert from 'minimalistic-assert'
|
|
6
|
+
|
|
7
|
+
export default function createUnsignedTxFactory({ chainId }) {
|
|
8
|
+
assert(typeof chainId === 'number', 'chainId is required')
|
|
9
|
+
return ({
|
|
10
|
+
asset,
|
|
11
|
+
address,
|
|
12
|
+
amount,
|
|
13
|
+
nonce,
|
|
14
|
+
txInput,
|
|
15
|
+
gasLimit,
|
|
16
|
+
gasPrice, // eip 1559: `maxFeePerGas`
|
|
17
|
+
tipGasPrice, // eip 1559: `maxPriorityPerGas`
|
|
60
18
|
fromAddress,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
19
|
+
eip1559Enabled,
|
|
20
|
+
}) => {
|
|
21
|
+
const baseAsset = asset.baseAsset
|
|
22
|
+
assert(chainId, 'chainId is required')
|
|
23
|
+
|
|
24
|
+
if (txInput) {
|
|
25
|
+
txInput = toBuffer(txInput) // If txInput is already a Buffer, then it is passed through
|
|
26
|
+
} else {
|
|
27
|
+
txInput = Buffer.alloc(0)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const _isToken = isToken(asset)
|
|
31
|
+
const to = _isToken ? asset.contract.address : address
|
|
32
|
+
let value = currency2buffer(_isToken ? baseAsset.currency.ZERO : amount)
|
|
33
|
+
|
|
34
|
+
// TODO: check: present on desktop missing on mobile. This insures we never have a buffer specifying 0.
|
|
35
|
+
// In ETH, a buffer of zero length and a buffer specifying 0 imply different things
|
|
36
|
+
if (value.equals(Buffer.from([0]))) value = Buffer.alloc(0)
|
|
37
|
+
|
|
38
|
+
assert(fromAddress, 'createTx: fromAddress is requied')
|
|
39
|
+
|
|
40
|
+
const txData = {
|
|
41
|
+
nonce: nonce === 0 ? Buffer.alloc(0) : intToBuffer(nonce),
|
|
42
|
+
gasPrice: currency2buffer(gasPrice),
|
|
43
|
+
tipGasPrice: tipGasPrice ? currency2buffer(tipGasPrice) : undefined,
|
|
44
|
+
gasLimit: intToBuffer(gasLimit),
|
|
45
|
+
to,
|
|
46
|
+
value,
|
|
47
|
+
data: txInput,
|
|
48
|
+
chainId,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const txMeta = {
|
|
52
|
+
assetName: asset.name,
|
|
53
|
+
fee: baseAsset.currency.baseUnit(gasPrice.toBaseNumber() * gasLimit),
|
|
54
|
+
eip1559Enabled: !!eip1559Enabled,
|
|
55
|
+
fromAddress,
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
txData,
|
|
60
|
+
txMeta,
|
|
61
|
+
}
|
|
66
62
|
}
|
|
67
63
|
}
|
package/src/unsigned-tx/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { default as
|
|
1
|
+
export { default as createUnsignedTxFactory } from './create-unsigned-tx'
|
|
2
2
|
export { default as parseUnsignedTx } from './parse-unsigned-tx'
|
|
3
3
|
export { default as signUnsignedTx, signUnsignedTxWithSigner } from './sign-unsigned-tx'
|
|
4
|
-
export { default as
|
|
4
|
+
export { default as createAndSignTxFactory } from './create-and-sign-tx'
|
|
5
5
|
export { default as createEthereumJsTx } from './create-ethereumjs-tx'
|
|
6
6
|
export { signHardwareFactory } from './sign-hardware'
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as ethUtil from '@exodus/ethereumjs-util'
|
|
2
2
|
import { isToken, buffer2currency } from '../utils'
|
|
3
|
-
import { CHAIN_IDS } from '../constants'
|
|
4
3
|
|
|
5
4
|
export default function parseUnsignedTx(asset, unsignedTx) {
|
|
6
5
|
const { txData } = unsignedTx
|
|
@@ -9,7 +8,7 @@ export default function parseUnsignedTx(asset, unsignedTx) {
|
|
|
9
8
|
const gasPrice = buffer2currency({ asset: baseAsset, value: txData.gasPrice })
|
|
10
9
|
const gasLimit = ethUtil.bufferToInt(txData.gasLimit)
|
|
11
10
|
|
|
12
|
-
let { to,
|
|
11
|
+
let { to, data, value } = txData
|
|
13
12
|
let amount
|
|
14
13
|
const fee = gasPrice.mul(gasLimit)
|
|
15
14
|
if (_isToken) {
|
|
@@ -22,11 +21,7 @@ export default function parseUnsignedTx(asset, unsignedTx) {
|
|
|
22
21
|
amount = asset.currency.ZERO
|
|
23
22
|
}
|
|
24
23
|
} else {
|
|
25
|
-
amount = buffer2currency({ asset, value
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (chainId !== CHAIN_IDS[baseAsset.name]) {
|
|
29
|
-
throw new Error(`invalid chainId ${chainId} for asset ${asset.name}`)
|
|
24
|
+
amount = buffer2currency({ asset, value })
|
|
30
25
|
}
|
|
31
26
|
|
|
32
27
|
return {
|
package/src/fee-data/aurora.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FeeData } from '@exodus/asset-lib'
|
|
2
|
-
import { asset } from '@exodus/aurora-meta'
|
|
3
|
-
|
|
4
|
-
export default new FeeData({
|
|
5
|
-
config: {
|
|
6
|
-
gasPrice: '0.07 Gwei',
|
|
7
|
-
max: '1 Gwei',
|
|
8
|
-
min: '0.001 Gwei',
|
|
9
|
-
fuelThreshold: '7500 Gwei',
|
|
10
|
-
gasPriceEconomicalRate: 0.8,
|
|
11
|
-
gasPriceMinimumRate: 0.6,
|
|
12
|
-
eip1559Enabled: false,
|
|
13
|
-
},
|
|
14
|
-
mainKey: 'gasPrice',
|
|
15
|
-
currency: asset.currency,
|
|
16
|
-
})
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { FeeData } from '@exodus/asset-lib'
|
|
2
|
-
import { asset } from '@exodus/avalanchec-meta'
|
|
3
|
-
|
|
4
|
-
export default new FeeData({
|
|
5
|
-
config: {
|
|
6
|
-
// https://snowtrace.io/chart/gasprice
|
|
7
|
-
// https://stats.avax.network/dashboard/c-chain-activity/
|
|
8
|
-
gasPrice: '225 nAVAX',
|
|
9
|
-
baseFeePerGas: '100 nAVAX',
|
|
10
|
-
max: '1000 nAVAX',
|
|
11
|
-
min: '25 nAVAX',
|
|
12
|
-
fuelThreshold: '20000 nAVAX',
|
|
13
|
-
gasPriceEconomicalRate: 0.8,
|
|
14
|
-
gasPriceMinimumRate: 0.6,
|
|
15
|
-
eip1559Enabled: true,
|
|
16
|
-
tipGasPrice: '4 nAVAX',
|
|
17
|
-
},
|
|
18
|
-
mainKey: 'gasPrice',
|
|
19
|
-
currency: asset.currency,
|
|
20
|
-
})
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { FeeData } from '@exodus/asset-lib'
|
|
2
|
-
import { asset } from '@exodus/basemainnet-meta'
|
|
3
|
-
|
|
4
|
-
export default new FeeData({
|
|
5
|
-
config: {
|
|
6
|
-
gasPrice: '0.2 Gwei',
|
|
7
|
-
baseFeePerGas: '0.2 Gwei',
|
|
8
|
-
tipGasPrice: '0.02 Gwei',
|
|
9
|
-
max: '1 Gwei',
|
|
10
|
-
min: '0.001 Gwei',
|
|
11
|
-
fuelThreshold: '750000 Gwei',
|
|
12
|
-
gasPriceEconomicalRate: 0.8,
|
|
13
|
-
gasPriceMinimumRate: 0.6,
|
|
14
|
-
eip1559Enabled: true,
|
|
15
|
-
},
|
|
16
|
-
mainKey: 'gasPrice',
|
|
17
|
-
currency: asset.currency,
|
|
18
|
-
})
|
package/src/fee-data/bsc.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FeeData } from '@exodus/asset-lib'
|
|
2
|
-
import { asset } from '@exodus/bsc-meta'
|
|
3
|
-
|
|
4
|
-
export default new FeeData({
|
|
5
|
-
config: {
|
|
6
|
-
gasPrice: '20 Gwei',
|
|
7
|
-
max: '200 Gwei',
|
|
8
|
-
min: '1 Gwei',
|
|
9
|
-
fuelThreshold: '2500000 Gwei',
|
|
10
|
-
gasPriceEconomicalRate: 0.8,
|
|
11
|
-
gasPriceMinimumRate: 0.6,
|
|
12
|
-
eip1559Enabled: false,
|
|
13
|
-
},
|
|
14
|
-
mainKey: 'gasPrice',
|
|
15
|
-
currency: asset.currency,
|
|
16
|
-
})
|
package/src/fee-data/cronos.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { FeeData } from '@exodus/asset-lib'
|
|
2
|
-
import { asset } from '@exodus/cronos-meta'
|
|
3
|
-
|
|
4
|
-
// https://cronoscan.com/chart/gasprice
|
|
5
|
-
export default new FeeData({
|
|
6
|
-
config: {
|
|
7
|
-
gasPrice: '11250 Gwei',
|
|
8
|
-
max: '250000 Gwei',
|
|
9
|
-
min: '10000 Gwei',
|
|
10
|
-
fuelThreshold: '10000 Gwei',
|
|
11
|
-
gasPriceEconomicalRate: 0.8,
|
|
12
|
-
gasPriceMinimumRate: 0.6,
|
|
13
|
-
enableFeeDelegation: false,
|
|
14
|
-
eip1559Enabled: false,
|
|
15
|
-
},
|
|
16
|
-
mainKey: 'gasPrice',
|
|
17
|
-
currency: asset.currency,
|
|
18
|
-
})
|
package/src/fee-data/ethereum.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { FeeData } from '@exodus/asset-lib'
|
|
2
|
-
import { asset } from '@exodus/ethereum-meta'
|
|
3
|
-
|
|
4
|
-
export default new FeeData({
|
|
5
|
-
config: {
|
|
6
|
-
gasPrice: '75 Gwei',
|
|
7
|
-
baseFeePerGas: '50 Gwei',
|
|
8
|
-
max: '250 Gwei',
|
|
9
|
-
min: '1 Gwei',
|
|
10
|
-
fuelThreshold: '0.025 ETH',
|
|
11
|
-
swapFee: '0.05 ETH',
|
|
12
|
-
gasPriceEconomicalRate: 0.7,
|
|
13
|
-
gasPriceMinimumRate: 0.5,
|
|
14
|
-
enableFeeDelegation: false,
|
|
15
|
-
tipGasPrice: '2 Gwei',
|
|
16
|
-
eip1559Enabled: true,
|
|
17
|
-
rbfEnabled: true,
|
|
18
|
-
},
|
|
19
|
-
mainKey: 'gasPrice',
|
|
20
|
-
currency: asset.currency,
|
|
21
|
-
})
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FeeData } from '@exodus/asset-lib'
|
|
2
|
-
import { asset } from '@exodus/ethereumarbnova-meta'
|
|
3
|
-
|
|
4
|
-
export default new FeeData({
|
|
5
|
-
config: {
|
|
6
|
-
gasPrice: '1.25 Gwei',
|
|
7
|
-
max: '25 Gwei',
|
|
8
|
-
min: '0.01 Gwei',
|
|
9
|
-
fuelThreshold: '25 Gwei',
|
|
10
|
-
gasPriceEconomicalRate: 0.7,
|
|
11
|
-
gasPriceMinimumRate: 0.5,
|
|
12
|
-
eip1559Enabled: false,
|
|
13
|
-
},
|
|
14
|
-
mainKey: 'gasPrice',
|
|
15
|
-
currency: asset.currency,
|
|
16
|
-
})
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FeeData } from '@exodus/asset-lib'
|
|
2
|
-
import { asset } from '@exodus/ethereumarbone-meta'
|
|
3
|
-
|
|
4
|
-
export default new FeeData({
|
|
5
|
-
config: {
|
|
6
|
-
gasPrice: '1.25 Gwei',
|
|
7
|
-
max: '25 Gwei',
|
|
8
|
-
min: '0.1 Gwei',
|
|
9
|
-
fuelThreshold: '25 Gwei',
|
|
10
|
-
gasPriceEconomicalRate: 0.7,
|
|
11
|
-
gasPriceMinimumRate: 0.5,
|
|
12
|
-
eip1559Enabled: false,
|
|
13
|
-
},
|
|
14
|
-
mainKey: 'gasPrice',
|
|
15
|
-
currency: asset.currency,
|
|
16
|
-
})
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { FeeData } from '@exodus/asset-lib'
|
|
2
|
-
import { asset } from '@exodus/ethereumclassic-meta'
|
|
3
|
-
|
|
4
|
-
export default new FeeData({
|
|
5
|
-
config: {
|
|
6
|
-
gasPrice: '20 Gwei',
|
|
7
|
-
max: '250 Gwei',
|
|
8
|
-
min: '1 Gwei',
|
|
9
|
-
eip1559Enabled: false,
|
|
10
|
-
},
|
|
11
|
-
mainKey: 'gasPrice',
|
|
12
|
-
currency: asset.currency,
|
|
13
|
-
})
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { FeeData } from '@exodus/asset-lib'
|
|
2
|
-
import { asset } from '@exodus/ethereumgoerli-meta'
|
|
3
|
-
|
|
4
|
-
export default new FeeData({
|
|
5
|
-
config: {
|
|
6
|
-
gasPrice: '75 Gwei',
|
|
7
|
-
baseFeePerGas: '50 Gwei',
|
|
8
|
-
max: '250 Gwei',
|
|
9
|
-
min: '1 Gwei',
|
|
10
|
-
fuelThreshold: '0.025 GOETH',
|
|
11
|
-
swapFee: '0.05 GOETH',
|
|
12
|
-
gasPriceEconomicalRate: 0.7,
|
|
13
|
-
gasPriceMinimumRate: 0.5,
|
|
14
|
-
enableFeeDelegation: false,
|
|
15
|
-
tipGasPrice: '2 Gwei',
|
|
16
|
-
eip1559Enabled: true,
|
|
17
|
-
},
|
|
18
|
-
mainKey: 'gasPrice',
|
|
19
|
-
currency: asset.currency,
|
|
20
|
-
})
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { FeeData } from '@exodus/asset-lib'
|
|
2
|
-
import { asset } from '@exodus/ethereumholesky-meta'
|
|
3
|
-
|
|
4
|
-
export default new FeeData({
|
|
5
|
-
config: {
|
|
6
|
-
gasPrice: '75 Gwei',
|
|
7
|
-
baseFeePerGas: '50 Gwei',
|
|
8
|
-
max: '250 Gwei',
|
|
9
|
-
min: '1 Gwei',
|
|
10
|
-
fuelThreshold: '0.025 HOETH',
|
|
11
|
-
swapFee: '0.05 HOETH',
|
|
12
|
-
gasPriceEconomicalRate: 0.7,
|
|
13
|
-
gasPriceMinimumRate: 0.5,
|
|
14
|
-
enableFeeDelegation: false,
|
|
15
|
-
tipGasPrice: '2 Gwei',
|
|
16
|
-
eip1559Enabled: true,
|
|
17
|
-
},
|
|
18
|
-
mainKey: 'gasPrice',
|
|
19
|
-
currency: asset.currency,
|
|
20
|
-
})
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { FeeData } from '@exodus/asset-lib'
|
|
2
|
-
import { asset } from '@exodus/ethereumsepolia-meta'
|
|
3
|
-
|
|
4
|
-
export default new FeeData({
|
|
5
|
-
config: {
|
|
6
|
-
gasPrice: '75 Gwei',
|
|
7
|
-
baseFeePerGas: '50 Gwei',
|
|
8
|
-
max: '250 Gwei',
|
|
9
|
-
min: '1 Gwei',
|
|
10
|
-
fuelThreshold: '0.025 SETH',
|
|
11
|
-
swapFee: '0.05 SETH',
|
|
12
|
-
gasPriceEconomicalRate: 0.7,
|
|
13
|
-
gasPriceMinimumRate: 0.5,
|
|
14
|
-
enableFeeDelegation: false,
|
|
15
|
-
tipGasPrice: '2 Gwei',
|
|
16
|
-
eip1559Enabled: true,
|
|
17
|
-
},
|
|
18
|
-
mainKey: 'gasPrice',
|
|
19
|
-
currency: asset.currency,
|
|
20
|
-
})
|
package/src/fee-data/fantom.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { FeeData } from '@exodus/asset-lib'
|
|
2
|
-
import { asset } from '@exodus/fantommainnet-meta'
|
|
3
|
-
|
|
4
|
-
export default new FeeData({
|
|
5
|
-
config: {
|
|
6
|
-
// https://ftmscan.com/chart/gasprice
|
|
7
|
-
gasPrice: '400 Gwei',
|
|
8
|
-
max: '700 Gwei',
|
|
9
|
-
min: '100 Gwei',
|
|
10
|
-
fuelThreshold: '2500000 Gwei',
|
|
11
|
-
gasPriceEconomicalRate: 0.8,
|
|
12
|
-
gasPriceMinimumRate: 0.6,
|
|
13
|
-
eip1559Enabled: false,
|
|
14
|
-
},
|
|
15
|
-
mainKey: 'gasPrice',
|
|
16
|
-
currency: asset.currency,
|
|
17
|
-
})
|
package/src/fee-data/flare.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FeeData } from '@exodus/asset-lib'
|
|
2
|
-
import { asset } from '@exodus/flare-meta'
|
|
3
|
-
|
|
4
|
-
export default new FeeData({
|
|
5
|
-
config: {
|
|
6
|
-
gasPrice: '25 Gwei',
|
|
7
|
-
max: '250 Gwei',
|
|
8
|
-
min: '0.1 Gwei',
|
|
9
|
-
fuelThreshold: '1500000 Gwei',
|
|
10
|
-
gasPriceEconomicalRate: 0.8,
|
|
11
|
-
gasPriceMinimumRate: 0.6,
|
|
12
|
-
eip1559Enabled: false,
|
|
13
|
-
},
|
|
14
|
-
mainKey: 'gasPrice',
|
|
15
|
-
currency: asset.currency,
|
|
16
|
-
})
|
package/src/fee-data/harmony.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FeeData } from '@exodus/asset-lib'
|
|
2
|
-
import { asset } from '@exodus/harmonymainnet-meta'
|
|
3
|
-
|
|
4
|
-
export default new FeeData({
|
|
5
|
-
config: {
|
|
6
|
-
gasPrice: '10 Gwei',
|
|
7
|
-
max: '700 Gwei',
|
|
8
|
-
min: '30 Gwei',
|
|
9
|
-
fuelThreshold: '2500000 Gwei',
|
|
10
|
-
gasPriceEconomicalRate: 0.8,
|
|
11
|
-
gasPriceMinimumRate: 0.6,
|
|
12
|
-
eip1559Enabled: false,
|
|
13
|
-
},
|
|
14
|
-
mainKey: 'gasPrice',
|
|
15
|
-
currency: asset.currency,
|
|
16
|
-
})
|
package/src/fee-data/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export { default as ethereum } from './ethereum'
|
|
2
|
-
export { default as ethereumarbnova } from './ethereumarbnova'
|
|
3
|
-
export { default as ethereumarbone } from './ethereumarbone'
|
|
4
|
-
export { default as ethereumclassic } from './ethereumclassic'
|
|
5
|
-
export { default as ethereumgoerli } from './ethereumgoerli'
|
|
6
|
-
export { default as ethereumholesky } from './ethereumholesky'
|
|
7
|
-
export { default as ethereumsepolia } from './ethereumsepolia'
|
|
8
|
-
export { default as bsc } from './bsc'
|
|
9
|
-
export { default as matic } from './polygon'
|
|
10
|
-
export { default as avalanchec } from './avalanchec'
|
|
11
|
-
export { default as fantommainnet } from './fantom'
|
|
12
|
-
export { default as harmonymainnet } from './harmony'
|
|
13
|
-
export { default as rootstock } from './rootstock'
|
|
14
|
-
export { default as optimism } from './optimism'
|
|
15
|
-
export { default as flare } from './flare'
|
|
16
|
-
export { default as aurora } from './aurora'
|
|
17
|
-
export { default as cronos } from './cronos'
|
|
18
|
-
export { default as basemainnet } from './basemainnet'
|
package/src/fee-data/optimism.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FeeData } from '@exodus/asset-lib'
|
|
2
|
-
import { asset } from '@exodus/optimism-meta'
|
|
3
|
-
|
|
4
|
-
export default new FeeData({
|
|
5
|
-
config: {
|
|
6
|
-
gasPrice: '0.001 Gwei',
|
|
7
|
-
max: '5 Gwei',
|
|
8
|
-
min: '0.0001 Gwei',
|
|
9
|
-
fuelThreshold: '25 Gwei',
|
|
10
|
-
gasPriceEconomicalRate: 0.7,
|
|
11
|
-
gasPriceMinimumRate: 0.5,
|
|
12
|
-
eip1559Enabled: false,
|
|
13
|
-
},
|
|
14
|
-
mainKey: 'gasPrice',
|
|
15
|
-
currency: asset.currency,
|
|
16
|
-
})
|
package/src/fee-data/polygon.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { FeeData } from '@exodus/asset-lib'
|
|
2
|
-
import { asset } from '@exodus/matic-meta'
|
|
3
|
-
|
|
4
|
-
export default new FeeData({
|
|
5
|
-
config: {
|
|
6
|
-
// https://polygonscan.com/chart/gasprice
|
|
7
|
-
baseFeePerGas: '100 Gwei',
|
|
8
|
-
tipGasPrice: '35 Gwei',
|
|
9
|
-
gasPrice: '135 Gwei',
|
|
10
|
-
max: '300 Gwei',
|
|
11
|
-
min: '40 Gwei',
|
|
12
|
-
fuelThreshold: '2500000 Gwei',
|
|
13
|
-
gasPriceEconomicalRate: 0.8,
|
|
14
|
-
gasPriceMinimumRate: 0.6,
|
|
15
|
-
eip1559Enabled: true,
|
|
16
|
-
},
|
|
17
|
-
mainKey: 'gasPrice',
|
|
18
|
-
currency: asset.currency,
|
|
19
|
-
})
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FeeData } from '@exodus/asset-lib'
|
|
2
|
-
import { asset } from '@exodus/rootstock-meta'
|
|
3
|
-
|
|
4
|
-
export default new FeeData({
|
|
5
|
-
config: {
|
|
6
|
-
gasPrice: '0.06 Gwei',
|
|
7
|
-
max: '5 Gwei',
|
|
8
|
-
min: '0.001 Gwei',
|
|
9
|
-
fuelThreshold: '4000 Gwei',
|
|
10
|
-
gasPriceEconomicalRate: 0.8,
|
|
11
|
-
gasPriceMinimumRate: 0.6,
|
|
12
|
-
eip1559Enabled: false,
|
|
13
|
-
},
|
|
14
|
-
mainKey: 'gasPrice',
|
|
15
|
-
currency: asset.currency,
|
|
16
|
-
})
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { FeeMonitor } from '@exodus/asset-lib'
|
|
2
|
-
import { DEFAULT_FEE_MONITOR_INTERVAL } from '../constants'
|
|
3
|
-
|
|
4
|
-
export default class EthereumLikeFeeMonitor extends FeeMonitor {
|
|
5
|
-
constructor({
|
|
6
|
-
updateFee,
|
|
7
|
-
interval = DEFAULT_FEE_MONITOR_INTERVAL,
|
|
8
|
-
assetName,
|
|
9
|
-
getGasPrice,
|
|
10
|
-
minGasPrice = 0,
|
|
11
|
-
}) {
|
|
12
|
-
super({ updateFee, interval, assetName })
|
|
13
|
-
this.getGasPrice = getGasPrice
|
|
14
|
-
this.minGasPrice = minGasPrice
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async fetchFee() {
|
|
18
|
-
let gasPrice = parseInt(await this.getGasPrice(), 16)
|
|
19
|
-
|
|
20
|
-
if (!Number.isFinite(gasPrice)) {
|
|
21
|
-
throw new TypeError(`Invalid gas price: ${gasPrice}`)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (gasPrice < this.minGasPrice) {
|
|
25
|
-
gasPrice = this.minGasPrice
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
gasPrice: `${gasPrice} wei`,
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
package/src/fee-monitor/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as EthereumLikeFeeMonitor } from './ethereum-like'
|