@exodus/ethereum-api 8.21.3 → 8.22.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/CHANGELOG.md +10 -0
- package/package.json +2 -2
- package/src/create-asset-plugin-factory.js +9 -57
- package/src/create-asset.js +6 -2
- package/src/fee-data-factory.js +56 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [8.22.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.21.3...@exodus/ethereum-api@8.22.0) (2024-12-02)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
* feat: gasPriceMaximumRate in evm fee data (#4578)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
6
16
|
## [8.21.3](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.21.2...@exodus/ethereum-api@8.21.3) (2024-11-27)
|
|
7
17
|
|
|
8
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ethereum-api",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.22.0",
|
|
4
4
|
"description": "Transaction monitors, fee monitors, RPC with the blockchain node, and other networking code for Ethereum and EVM-based blockchains",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"type": "git",
|
|
65
65
|
"url": "git+https://github.com/ExodusMovement/assets.git"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "9888fd7b7356fd52f0bf92e505071565c8fa19ce"
|
|
68
68
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { createMetaDef } from '@exodus/asset'
|
|
2
|
-
import { FeeData } from '@exodus/asset-lib'
|
|
3
|
-
import { UnitType } from '@exodus/currency'
|
|
4
2
|
import assert from 'minimalistic-assert'
|
|
5
3
|
|
|
6
4
|
import { createAssetFactory } from './create-asset.js'
|
|
@@ -27,8 +25,6 @@ export const createAssetPluginFactory = (config) => {
|
|
|
27
25
|
[ticker]: decimals || 18,
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
const currency = UnitType.create(units)
|
|
31
|
-
|
|
32
28
|
// adds lots of validation in config
|
|
33
29
|
const tokenOverrides = (token) => ({
|
|
34
30
|
...token,
|
|
@@ -43,7 +39,7 @@ export const createAssetPluginFactory = (config) => {
|
|
|
43
39
|
}
|
|
44
40
|
|
|
45
41
|
const assetType = 'ETHEREUM_LIKE'
|
|
46
|
-
const {
|
|
42
|
+
const { assetsList } = createMetaDef({
|
|
47
43
|
assetParams: {
|
|
48
44
|
...meta,
|
|
49
45
|
name,
|
|
@@ -56,61 +52,17 @@ export const createAssetPluginFactory = (config) => {
|
|
|
56
52
|
tokensParams: meta.tokens || [],
|
|
57
53
|
tokenOverrides,
|
|
58
54
|
})
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
gasPriceEconomicalRate: 0.8,
|
|
65
|
-
gasPriceMinimumRate: 0.6,
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (config.eip1559Enabled === true) {
|
|
69
|
-
assert(config.baseFeePerGas, 'baseFeePerGas is required')
|
|
70
|
-
const baseFeePerGas = currency.parse(config.baseFeePerGas)
|
|
71
|
-
const gasPrice = config.gasPrice ? currency.parse(config.gasPrice) : baseFeePerGas.mul(1.5)
|
|
72
|
-
return {
|
|
73
|
-
gasPrice: gasPrice.toBaseString({ unit: true }),
|
|
74
|
-
baseFeePerGas: baseFeePerGas.toBaseString({ unit: true }),
|
|
75
|
-
max: gasPrice.mul(5).toBaseString({ unit: true }),
|
|
76
|
-
min: gasPrice.div(5).toBaseString({ unit: true }),
|
|
77
|
-
eip1559Enabled: config.eip1559Enabled,
|
|
78
|
-
...shared,
|
|
79
|
-
...config.feeData,
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (config.eip1559Enabled === false) {
|
|
84
|
-
assert(config.gasPrice, 'gasPrice is required')
|
|
85
|
-
const gasPrice = currency.parse(config.gasPrice)
|
|
86
|
-
return {
|
|
87
|
-
gasPrice: gasPrice.toBaseString({ unit: true }),
|
|
88
|
-
max: gasPrice.mul(5).toBaseString({ unit: true }),
|
|
89
|
-
min: gasPrice.div(5).toBaseString({ unit: true }),
|
|
90
|
-
eip1559Enabled: config.eip1559Enabled,
|
|
91
|
-
...shared,
|
|
92
|
-
...config.feeData,
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return {
|
|
97
|
-
gasPrice: '0.02 Gwei',
|
|
98
|
-
baseFeePerGas: '0.02 Gwei',
|
|
99
|
-
eip1559Enabled: true,
|
|
100
|
-
...shared,
|
|
55
|
+
const feeDataConfig = Object.fromEntries(
|
|
56
|
+
Object.entries({
|
|
57
|
+
gasPrice: config.gasPrice,
|
|
58
|
+
baseFeePerGas: config.baseFeePerGas,
|
|
59
|
+
eip1559Enabled: config.eip1559Enabled,
|
|
101
60
|
...config.feeData,
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const feeData = new FeeData({
|
|
106
|
-
config: resolveFeeDataConfigDefaults(),
|
|
107
|
-
mainKey: 'gasPrice',
|
|
108
|
-
currency: asset.currency,
|
|
109
|
-
})
|
|
110
|
-
|
|
61
|
+
}).filter(([_, value]) => value !== undefined)
|
|
62
|
+
)
|
|
111
63
|
const createAsset = createAssetFactory({
|
|
112
64
|
assetsList,
|
|
113
|
-
|
|
65
|
+
feeDataConfig,
|
|
114
66
|
...config.plugin,
|
|
115
67
|
})
|
|
116
68
|
|
package/src/create-asset.js
CHANGED
|
@@ -23,6 +23,7 @@ import ms from 'ms'
|
|
|
23
23
|
import { addressHasHistoryFactory } from './address-has-history.js'
|
|
24
24
|
import { createTokenFactory } from './create-token-factory.js'
|
|
25
25
|
import { createEvmServer } from './exodus-eth-server/index.js'
|
|
26
|
+
import { createFeeData } from './fee-data-factory.js'
|
|
26
27
|
import { createGetBalanceForAddress } from './get-balance-for-address.js'
|
|
27
28
|
import { getBalancesFactory } from './get-balances.js'
|
|
28
29
|
import { getEffectiveGasPrice, getFeeFactory } from './get-fee.js'
|
|
@@ -47,7 +48,8 @@ export const createAssetFactory = ({
|
|
|
47
48
|
customCreateGetKeyIdentifier,
|
|
48
49
|
customTokens: defaultCustomTokens = true,
|
|
49
50
|
erc20FuelBuffer,
|
|
50
|
-
feeData,
|
|
51
|
+
feeData: providedFeeData,
|
|
52
|
+
feeDataConfig,
|
|
51
53
|
feeMonitorInterval,
|
|
52
54
|
fuelThreshold,
|
|
53
55
|
isMaxFeeAsset = false,
|
|
@@ -62,11 +64,13 @@ export const createAssetFactory = ({
|
|
|
62
64
|
forceGasLimitEstimation = false,
|
|
63
65
|
}) => {
|
|
64
66
|
assert(assetsList, 'assetsList is required')
|
|
65
|
-
assert(
|
|
67
|
+
assert(providedFeeData || feeDataConfig, 'feeData or feeDataConfig is required')
|
|
66
68
|
assert(serverUrl, 'serverUrl is required')
|
|
67
69
|
assert(confirmationsNumber, 'confirmationsNumber is required')
|
|
68
70
|
|
|
69
71
|
const base = assetsList.find((asset) => asset.name === asset.baseAssetName)
|
|
72
|
+
|
|
73
|
+
const feeData = providedFeeData || createFeeData({ currency: base.currency, feeDataConfig })
|
|
70
74
|
assert(base, 'base is required')
|
|
71
75
|
|
|
72
76
|
const chainId = base.chainId
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { FeeData } from '@exodus/asset-lib'
|
|
2
|
+
import assert from 'minimalistic-assert'
|
|
3
|
+
|
|
4
|
+
const createFeeDataConfigDefaults = ({ currency, feeDataConfig }) => {
|
|
5
|
+
const shared = {
|
|
6
|
+
tipGasPrice: '0 Gwei',
|
|
7
|
+
fuelThreshold: '0 Gwei',
|
|
8
|
+
gasPriceEconomicalRate: 0.8,
|
|
9
|
+
gasPriceMinimumRate: 0.6,
|
|
10
|
+
gasPriceMaximumRate: 1.3,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (feeDataConfig.eip1559Enabled === true) {
|
|
14
|
+
assert(feeDataConfig.baseFeePerGas, 'baseFeePerGas is required')
|
|
15
|
+
const baseFeePerGas = currency.parse(feeDataConfig.baseFeePerGas)
|
|
16
|
+
const gasPrice = feeDataConfig.gasPrice
|
|
17
|
+
? currency.parse(feeDataConfig.gasPrice)
|
|
18
|
+
: baseFeePerGas.mul(1.5)
|
|
19
|
+
return {
|
|
20
|
+
gasPrice: gasPrice.toBaseString({ unit: true }),
|
|
21
|
+
baseFeePerGas: baseFeePerGas.toBaseString({ unit: true }),
|
|
22
|
+
eip1559Enabled: feeDataConfig.eip1559Enabled,
|
|
23
|
+
...shared,
|
|
24
|
+
...feeDataConfig,
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (feeDataConfig.eip1559Enabled === false) {
|
|
29
|
+
assert(feeDataConfig.gasPrice, 'gasPrice is required')
|
|
30
|
+
const gasPrice = currency.parse(feeDataConfig.gasPrice)
|
|
31
|
+
return {
|
|
32
|
+
gasPrice: gasPrice.toBaseString({ unit: true }),
|
|
33
|
+
max: gasPrice.mul(5).toBaseString({ unit: true }),
|
|
34
|
+
min: gasPrice.div(5).toBaseString({ unit: true }),
|
|
35
|
+
eip1559Enabled: feeDataConfig.eip1559Enabled,
|
|
36
|
+
...shared,
|
|
37
|
+
...feeDataConfig,
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
gasPrice: '0.02 Gwei',
|
|
43
|
+
baseFeePerGas: '0.02 Gwei',
|
|
44
|
+
eip1559Enabled: true,
|
|
45
|
+
...shared,
|
|
46
|
+
...feeDataConfig,
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const createFeeData = ({ currency, feeDataConfig }) => {
|
|
51
|
+
return new FeeData({
|
|
52
|
+
config: createFeeDataConfigDefaults({ currency, feeDataConfig }),
|
|
53
|
+
mainKey: 'gasPrice',
|
|
54
|
+
currency,
|
|
55
|
+
})
|
|
56
|
+
}
|