@exodus/ethereum-api 8.13.2 → 8.14.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 CHANGED
@@ -3,6 +3,25 @@
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.14.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.13.3...@exodus/ethereum-api@8.14.0) (2024-08-26)
7
+
8
+
9
+ ### Features
10
+
11
+ * allow custom gasPriceEconomicalRate ([#3236](https://github.com/ExodusMovement/assets/issues/3236)) ([acdf78e](https://github.com/ExodusMovement/assets/commit/acdf78e20c9f93da2cafa0045f24e5ad4f2e0a5d))
12
+ * forceGasLimitEstimation asset plugin param ([#3237](https://github.com/ExodusMovement/assets/issues/3237)) ([7da77dd](https://github.com/ExodusMovement/assets/commit/7da77dd8f09bddc752dc113b5ef875bf1ff5263c))
13
+
14
+
15
+
16
+ ## [8.13.3](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.13.2...@exodus/ethereum-api@8.13.3) (2024-08-13)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * **ethereum-api:** enhance gasLimit default value ([#3140](https://github.com/ExodusMovement/assets/issues/3140)) ([4522a65](https://github.com/ExodusMovement/assets/commit/4522a6518afb617acb5ab82df9f8c4836fe95236))
22
+
23
+
24
+
6
25
  ## [8.13.2](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.13.1...@exodus/ethereum-api@8.13.2) (2024-08-12)
7
26
 
8
27
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-api",
3
- "version": "8.13.2",
3
+ "version": "8.14.0",
4
4
  "description": "Ethereum Api",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -21,8 +21,8 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@exodus/asset": "^1.2.0",
24
- "@exodus/asset-lib": "^4.2.0",
25
- "@exodus/assets": "^9.1.1",
24
+ "@exodus/asset-lib": "^4.2.2",
25
+ "@exodus/assets": "^11.0.0",
26
26
  "@exodus/basic-utils": "^2.1.0",
27
27
  "@exodus/bip44-constants": "^195.0.0",
28
28
  "@exodus/crypto": "^1.0.0-rc.0",
@@ -65,5 +65,5 @@
65
65
  "type": "git",
66
66
  "url": "git+https://github.com/ExodusMovement/assets.git"
67
67
  },
68
- "gitHead": "fc7420fbe8a8acf647ee9319de3eb2d3832b87f6"
68
+ "gitHead": "12dda1cbba91cbfeaeb0811570baa671b8557c2c"
69
69
  }
@@ -158,6 +158,7 @@ export const fromAddEthereumChainParameterToFactoryParams = (params) => {
158
158
  confirmationsNumber: 5,
159
159
  monitorType: 'no-history',
160
160
  isTestnet: params.isTestnet,
161
+ ...params.plugin, // extra plugin configuration
161
162
  },
162
163
  baseFeePerGas: params.baseFeePerGas,
163
164
  gasPrice: params.gasPrice,
@@ -57,6 +57,7 @@ export const createAssetFactory = ({
57
57
  serverUrl,
58
58
  stakingConfiguration = {},
59
59
  useEip1191ChainIdChecksum = false,
60
+ forceGasLimitEstimation = false,
60
61
  }) => {
61
62
  assert(assetsList, 'assetsList is required')
62
63
  assert(feeData, 'feeData is required')
@@ -160,17 +161,28 @@ export const createAssetFactory = ({
160
161
  let monitor
161
162
  switch (monitorType) {
162
163
  case 'clarity':
163
- monitor = new ClarityMonitor({ interval: ms(monitorInterval || '5m'), server, ...args })
164
+ monitor = new ClarityMonitor({
165
+ assetClientInterface,
166
+ interval: ms(monitorInterval || '5m'),
167
+ server,
168
+ ...args,
169
+ })
164
170
  break
165
171
  case 'no-history':
166
172
  monitor = new EthereumNoHistoryMonitor({
173
+ assetClientInterface,
167
174
  interval: ms(monitorInterval || '15s'),
168
175
  server,
169
176
  ...args,
170
177
  })
171
178
  break
172
179
  case 'magnifier':
173
- monitor = new EthereumMonitor({ interval: ms(monitorInterval || '15s'), server, ...args })
180
+ monitor = new EthereumMonitor({
181
+ assetClientInterface,
182
+ interval: ms(monitorInterval || '15s'),
183
+ server,
184
+ ...args,
185
+ })
174
186
  break
175
187
  default:
176
188
  throw new Error(`Monitor type ${monitorType} of evm asset ${asset.name} is unknown`)
@@ -258,6 +270,7 @@ export const createAssetFactory = ({
258
270
  chainId,
259
271
  monitorType,
260
272
  estimateL1DataFee,
273
+ forceGasLimitEstimation,
261
274
  server,
262
275
  ...(erc20FuelBuffer && { erc20FuelBuffer }),
263
276
  ...(fuelThreshold && { fuelThreshold: asset.currency.defaultUnit(fuelThreshold) }),
@@ -1,9 +1,9 @@
1
1
  import {
2
- // eslint-disable-next-line import/no-deprecated
2
+ // eslint-disable-next-line @exodus/import/no-deprecated
3
3
  DEFAULT_SERVER_URLS,
4
- // eslint-disable-next-line import/no-deprecated
4
+ // eslint-disable-next-line @exodus/import/no-deprecated
5
5
  ETHEREUM_LIKE_ASSETS,
6
- // eslint-disable-next-line import/no-deprecated
6
+ // eslint-disable-next-line @exodus/import/no-deprecated
7
7
  ETHEREUM_LIKE_MONITOR_TYPES,
8
8
  } from '@exodus/ethereum-lib'
9
9
  import assert from 'minimalistic-assert'
@@ -30,11 +30,11 @@ export function createEvmServer({ assetName, serverUrl, monitorType }) {
30
30
 
31
31
  // @Deprecated
32
32
  const serverMap = Object.fromEntries(
33
- // eslint-disable-next-line import/no-deprecated
33
+ // eslint-disable-next-line @exodus/import/no-deprecated
34
34
  ETHEREUM_LIKE_ASSETS.map((assetName) => {
35
- // eslint-disable-next-line import/no-deprecated
35
+ // eslint-disable-next-line @exodus/import/no-deprecated
36
36
  const monitorType = ETHEREUM_LIKE_MONITOR_TYPES[assetName]
37
- // eslint-disable-next-line import/no-deprecated
37
+ // eslint-disable-next-line @exodus/import/no-deprecated
38
38
  const serverUrl = DEFAULT_SERVER_URLS[assetName]
39
39
  return [assetName, createEvmServer({ assetName, serverUrl, monitorType })]
40
40
  })
@@ -74,8 +74,9 @@ export async function fetchGasLimit({
74
74
  toAddress = asset.contract.address
75
75
  } else if (
76
76
  !isContract &&
77
- // hacky, convert this to a fetchGasLimit forceGasLimitEstimation plugin flag!
77
+ !asset.forceGasLimitEstimation &&
78
78
  ![
79
+ // back compatiblity until all plugins are updated. Then remove this array
79
80
  'ethereumarbone',
80
81
  'ethereumarbonesepolia',
81
82
  'ethereumarbnova',
package/src/get-fee.js CHANGED
@@ -7,16 +7,19 @@ const taxes = {
7
7
 
8
8
  const getGasPriceMultiplier = ({ asset, feeData, isExchange, isSendAll, isRbfAllowed }) => {
9
9
  // exchanges quotes expire, do not risk having a stuck tx
10
- if (isExchange) return 1
10
+
11
+ const gasPriceMultiplier = feeData.gasPriceMultiplier || 1
12
+
13
+ if (isExchange) return gasPriceMultiplier
11
14
 
12
15
  // if eip1559 enabled, do not risk not leaving enough ETH to cover base fee (applies only for native asset)
13
16
  // (gasPrice difference will be reimbursed anyway: users do not overpay)
14
- if (isSendAll && isEthereumLike(asset) && feeData.eip1559Enabled) return 1
17
+ if (isSendAll && isEthereumLike(asset) && feeData.eip1559Enabled) return gasPriceMultiplier
15
18
 
16
19
  // do not risk having a stuck tx if we're not able to accelerate it
17
- if (!isRbfAllowed || !feeData.rbfEnabled) return 1
20
+ if (!isRbfAllowed || !feeData.rbfEnabled) return gasPriceMultiplier
18
21
 
19
- return feeData.gasPriceEconomicalRate
22
+ return feeData.gasPriceEconomicalRate || gasPriceMultiplier
20
23
  }
21
24
 
22
25
  const getExtraFeeData = ({ asset, amount }) => {
@@ -39,7 +42,7 @@ export const getFeeFactory =
39
42
  asset,
40
43
  feeData,
41
44
  customFee,
42
- gasLimit = defaultGasLimit,
45
+ gasLimit: providedGasLimit,
43
46
  isExchange,
44
47
  isSendAll,
45
48
  amount,
@@ -55,6 +58,8 @@ export const getFeeFactory =
55
58
  isSendAll,
56
59
  })
57
60
 
61
+ const gasLimit = providedGasLimit || asset.gasLimit || defaultGasLimit
62
+
58
63
  const extraFeeData = getExtraFeeData({ asset, amount })
59
64
  if (calculateEffectiveFee && eip1559Enabled) {
60
65
  const maxFeePerGas = customFee || gasPrice
@@ -65,7 +70,7 @@ export const getFeeFactory =
65
70
  return { fee: effectiveGasPrice.mul(gasLimit), extraFeeData }
66
71
  }
67
72
 
68
- const fee = (customFee || gasPrice.mul(gasPriceMultiplier)).mul(gasLimit || asset.gasLimit)
73
+ const fee = (customFee || gasPrice.mul(gasPriceMultiplier)).mul(gasLimit)
69
74
  return { fee, extraFeeData }
70
75
  }
71
76
 
@@ -96,7 +96,7 @@ export class MaticStakingApi {
96
96
  /**
97
97
  * UnbondNonce is a counter stored in the contract that tracks each time a delegator unstakes
98
98
  * @param address delegator address
99
- * @return current unbonded nonce
99
+ * @returns current unbonded nonce
100
100
  */
101
101
  getCurrentUnbondNonce = async (address) => {
102
102
  const unbondNonce = await this.callReadFunctionContract(