@@ -1402,7 +1402,8 @@ export default class BlockchainServiceBase {
14021402 try {
14031403 // eth_feeHistory params: blockCount, newestBlock, rewardPercentiles
14041404 // [50] = median priority fee per block
1405- const feeHistory = await web3Instance . eth . getFeeHistory ( blockCount , 'latest' , [ 50 ] ) ;
1405+ const priorityFeePercentile = blockchain . priorityFeePercentile ?? 80 ;
1406+ const feeHistory = await web3Instance . eth . getFeeHistory ( blockCount , 'latest' , [ priorityFeePercentile ] ) ;
14061407
14071408 // Extract median priority fees from each block (reward[blockIndex][percentileIndex])
14081409 const priorityFees = feeHistory . reward
@@ -1426,13 +1427,14 @@ export default class BlockchainServiceBase {
14261427
14271428 /**
14281429 * Apply buffer percentage to a gas price
1429- * @param {BigInt } gasPrice - Gas price in wei
1430+ * @param {BigInt } maxBaseFee - base fee in wei
1431+ * @param {BigInt } maxPriorityFee - priority fee in wei
14301432 * @param {number } gasPriceBufferPercent - Buffer percentage to add
14311433 * @returns {BigInt } Gas price with buffer applied
14321434 */
1433- applyGasPriceBuffer ( gasPrice , gasPriceBufferPercent ) {
1434- if ( ! gasPriceBufferPercent ) return gasPrice ;
1435- return ( gasPrice * BigInt ( 100 + Number ( gasPriceBufferPercent ) ) ) / 100n ;
1435+ applyGasPriceBuffer ( maxBaseFee , maxPriorityFee , gasPriceBufferPercent ) {
1436+ if ( ! gasPriceBufferPercent ) return maxBaseFee + maxPriorityFee ;
1437+ return ( ( maxBaseFee * BigInt ( 100 + Number ( gasPriceBufferPercent ) ) ) / 100n ) + maxPriorityFee ;
14361438 }
14371439
14381440 /**
@@ -1449,6 +1451,7 @@ export default class BlockchainServiceBase {
14491451 // Fallback to network gas price if feeHistory not supported or empty
14501452 if ( ! feeHistory . supported ) {
14511453 return this . applyGasPriceBuffer (
1454+ 0n ,
14521455 BigInt ( await this . getNetworkGasPrice ( blockchain ) ) ,
14531456 gasPriceBufferPercent ,
14541457 ) ;
@@ -1459,6 +1462,7 @@ export default class BlockchainServiceBase {
14591462
14601463 if ( baseFees . length === 0 || priorityFees . length === 0 ) {
14611464 return this . applyGasPriceBuffer (
1465+ 0n ,
14621466 BigInt ( await this . getNetworkGasPrice ( blockchain ) ) ,
14631467 gasPriceBufferPercent ,
14641468 ) ;
@@ -1468,7 +1472,7 @@ export default class BlockchainServiceBase {
14681472 const maxBaseFee = baseFees . reduce ( ( max , bf ) => ( bf > max ? bf : max ) , 0n ) ;
14691473 const maxPriorityFee = priorityFees . reduce ( ( max , pf ) => ( pf > max ? pf : max ) , 0n ) ;
14701474
1471- return this . applyGasPriceBuffer ( maxBaseFee + maxPriorityFee , gasPriceBufferPercent ) ;
1475+ return this . applyGasPriceBuffer ( maxBaseFee , maxPriorityFee , gasPriceBufferPercent ) ;
14721476 }
14731477
14741478 /**
0 commit comments