test-pkg-ngn
Version:
A library containing helper functions that facilitate scripting for keepers of the Keep3r Network
29 lines • 1.77 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatBundlesTxsToType2 = void 0;
const getMainnetGasType2Parameters_1 = require("./getMainnetGasType2Parameters");
/**
* @notice Helper function to format the transactions on every bundle to type 2.
*
* @dev This function will dynamically calculate the maximum possible baseFee in N blocks ahead determined with the blocksAhead property
* and then calculate the maxFeePerGas by adding the maxBaseFee to the provided priority fee.
*
* @param bundlesTxs An array of bundles to format to type 2.
* @param block The current block. This is used to get the current baseFee, which is required for the calculation of the maxBaseFee.
* @param priorityFeeInWei The desired priority fee in wei to use as maxPriorityFeePerGas.
* @param blocksAhead How many blocks ahead to calculate the maxFeePerGas for. This parameter usually coincides with the burst size we use
* for our bundles, as we want to ensure our calculation of the maxBaseFee is correct.
*
* @return An array containing all the formatted bundles.
*/
function formatBundlesTxsToType2(props) {
const { block, blocksAhead, bundlesTxs, priorityFeeInWei } = props;
const { priorityFeeInGwei, maxFeePerGas } = getMainnetGasType2Parameters_1.getMainnetGasType2Parameters({
block,
priorityFeeInWei,
blocksAhead,
});
return bundlesTxs.map((bundle) => (Object.assign(Object.assign({}, bundle), { txs: bundle.txs.map((tx) => (Object.assign(Object.assign({}, tx), { type: 2, maxPriorityFeePerGas: priorityFeeInGwei, maxFeePerGas }))) })));
}
exports.formatBundlesTxsToType2 = formatBundlesTxsToType2;
//# sourceMappingURL=formatBundlesTxsToType2.js.map