flashbots-cli
Version:
Flashbots CLI tool.
56 lines (55 loc) • 2.76 kB
JavaScript
;
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
// lib
const error_1 = require("../lib/error");
const flashbots_1 = require("../lib/flashbots");
class SendBundle extends core_1.Command {
async catch(e) {
(0, error_1.handleGenericError)(e, this);
}
async run() {
const { args, flags } = await this.parse(SendBundle);
const flashbotsProvider = await (0, flashbots_1.getFlashbotsProvider)();
let targetBlock;
if (flags['target-block']) {
targetBlock = flags['target-block'];
}
else {
const provider = (0, flashbots_1.getStandardProvider)();
targetBlock = (await provider.getBlockNumber()) + 1;
}
this.log(`Targeting block ${targetBlock} for bundle submission.`);
const optionalArgs = {
minTimestamp: flags['min-timestamp'],
maxTimestamp: flags['max-timestamp'],
revertingTxHashes: flags['reverting-tx'],
};
const res = await flashbotsProvider.sendRawBundle(JSON.parse(args.bundle_txs), targetBlock, optionalArgs);
if (res['error']) {
this.error(JSON.stringify(res.error));
}
this.log(JSON.stringify(res));
}
}
exports.default = SendBundle;
_a = SendBundle;
SendBundle.description = `Send a bundle to the Flashbots relay.
All flags are optional.`;
SendBundle.exampleBundle = `'["0x02f8d37c496de...", "0x02f8d38a7bf47..."]'`;
SendBundle.examples = [
`# Send a bundle in the next available block
<%= config.bin %> <%= command.id %> ${_a.exampleBundle}`,
`# Send a bundle with specific timestamp(s)
<%= config.bin %> <%= command.id %> ${_a.exampleBundle} --min-timestamp 1652856500 --max-timestamp 1652856700`,
`# Send a bundle with reverting transactions
<%= config.bin %> <%= command.id %> ${_a.exampleBundle} --reverting-tx 0x60929406276058bc757bc84a576857e6a6118566690fd3604d4f1cdb5ebd89d3 --reverting-tx 0x548efb5c5de7df6d76f8aca4391def510fa575c81dd588d2ff4e8fc5a7c4eb79`,
];
SendBundle.flags = {
'target-block': core_1.Flags.integer({ char: 'b', description: 'Block to target for bundle submission (default latest+1)' }),
'min-timestamp': core_1.Flags.integer({ description: 'Minimum timestamp at which this bundle can be included' }),
'max-timestamp': core_1.Flags.integer({ description: 'Maximum timestamp at which this bundle can be included' }),
'reverting-tx': core_1.Flags.string({ description: 'Tx hash that is allowed to revert, can be set multiple times', multiple: true }),
};
SendBundle.args = [{ name: 'bundle_txs', description: 'JSON string-encoded array of raw signed transactions (0x-prefixed)', required: true }];