Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
142ce883b4 | ||
|
|
cdce2334e4 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "tx-manager",
|
||||
"version": "0.4.7",
|
||||
"version": "0.4.8",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -422,34 +422,6 @@ class Transaction {
|
||||
return this._wallet.getTransactionCount('latest')
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches priority fee from the chain
|
||||
*
|
||||
* @param blockNumber The newest number block
|
||||
* @returns {Promise<BigNumber>}
|
||||
* @private
|
||||
*/
|
||||
async _estimatePriorityFee() {
|
||||
const defaultPriorityFee = parseUnits(this.config.DEFAULT_PRIORITY_FEE.toString(), 'gwei')
|
||||
|
||||
try {
|
||||
const estimatedPriorityFee = await this._provider.send('eth_maxPriorityFeePerGas', [])
|
||||
|
||||
if (!estimatedPriorityFee || isNaN(estimatedPriorityFee)) {
|
||||
return defaultPriorityFee
|
||||
}
|
||||
|
||||
const bumpedPriorityFee = BigNumber.from(estimatedPriorityFee)
|
||||
.mul(100 + this.config.PRIORITY_FEE_RESERVE_PERCENTAGE)
|
||||
.div(100)
|
||||
|
||||
return max(bumpedPriorityFee, defaultPriorityFee)
|
||||
} catch (err) {
|
||||
console.error('_estimatePriorityFee has error:', err.message)
|
||||
return defaultPriorityFee
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Choose network gas params
|
||||
*
|
||||
@@ -462,7 +434,7 @@ class Transaction {
|
||||
|
||||
// Check network support for EIP-1559
|
||||
if (this.config.ENABLE_EIP1559 && block && block.baseFeePerGas) {
|
||||
const maxPriorityFeePerGas = await this._estimatePriorityFee()
|
||||
const maxPriorityFeePerGas = parseUnits(this.config.DEFAULT_PRIORITY_FEE.toString(), 'gwei')
|
||||
|
||||
const maxFeePerGas = block.baseFeePerGas
|
||||
.mul(100 + this.config.BASE_FEE_RESERVE_PERCENTAGE)
|
||||
|
||||
@@ -18,7 +18,6 @@ const defaultConfig = {
|
||||
ENABLE_EIP1559: true,
|
||||
DEFAULT_PRIORITY_FEE: 3,
|
||||
BASE_FEE_RESERVE_PERCENTAGE: 50,
|
||||
PRIORITY_FEE_RESERVE_PERCENTAGE: 10,
|
||||
}
|
||||
|
||||
class TxManager {
|
||||
|
||||
Reference in New Issue
Block a user