test-pkg-ngn
Version:
A library containing helper functions that facilitate scripting for keepers of the Keep3r Network
32 lines • 1.84 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.sendBundlesToFlashbots = void 0;
const tslib_1 = require("tslib");
const chalk_1 = tslib_1.__importDefault(require("chalk"));
/**
* @notice Sends bundles to flashbots.
*
* @dev Returns whether or not the first bundle was included. The reason to only return the response of the first bundle is because
* we want to always start building the next batch of bundles as soon as the first bundle of the batch fails. This is to ensure
* our batches cover all possible blocks until the job is worked.
*
* @param bundles The bundles to send to flashbots.
* @param flashbots An instance of Flashbots.
* @param staticDebugId Optional static id to help with debugging. Every batch will share this id.
* @param dynamicDebugId Optional dynamic id to help with debugging. Every batch will have a different dynamic id.
* This dynamic id will be recalculated every time a bundle is created.
*
* @returns A boolean to know whether the bundle was included or not.
*/
function sendBundlesToFlashbots(bundles, flashbots, staticDebugId, dynamicDebugId) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const targetBlocks = bundles.map((bundle) => bundle.targetBlock);
console.log(`${chalk_1.default.cyanBright('---------\n')}Sending bundle with id: ${chalk_1.default.green(staticDebugId)}#${chalk_1.default.cyanBright(dynamicDebugId)} to blocks ${chalk_1.default.bgGray(targetBlocks.join(', '))}`);
const included = bundles.map((bundle) => {
return flashbots.send(bundle.txs, bundle.targetBlock, staticDebugId, dynamicDebugId);
});
return included[0];
});
}
exports.sendBundlesToFlashbots = sendBundlesToFlashbots;
//# sourceMappingURL=sendBundlesToFlashbots.js.map