diff --git a/src/cli/config/bundler.ts b/src/cli/config/bundler.ts index 87780231..7e8ace8e 100644 --- a/src/cli/config/bundler.ts +++ b/src/cli/config/bundler.ts @@ -30,6 +30,7 @@ export const bundlerArgsSchema = z.object({ (v) => (v === "" ? undefined : v), addressSchema.optional() ), + "refill-helper-contract": addressSchema.optional(), "no-profit-bundling": z.boolean(), "safe-mode": z.boolean(), "utility-private-key": hexData32Schema diff --git a/src/cli/config/options.ts b/src/cli/config/options.ts index 833b9950..3f96492b 100644 --- a/src/cli/config/options.ts +++ b/src/cli/config/options.ts @@ -26,6 +26,11 @@ export const bundlerOptions: CliCommandOptions = { require: false, default: "0xBbe8A301FbDb2a4CD58c4A37c262ecef8f889c47" }, + "refill-helper-contract": { + description: "Address of the Executor refill helper contract", + type: "string", + require: false + }, "executor-private-keys": { description: "Private keys of the executor accounts split by commas", type: "string", diff --git a/src/cli/handler.ts b/src/cli/handler.ts index 1f4d195d..0f4749d3 100644 --- a/src/cli/handler.ts +++ b/src/cli/handler.ts @@ -22,17 +22,17 @@ import { deploySimulationsContract } from "./deploySimulationsContract" const preFlightChecks = async (config: AltoConfig): Promise => { for (const entrypoint of config.entrypoints) { - const entryPointCode = await config.publicClient.getBytecode({ + const entryPointCode = await config.publicClient.getCode({ address: entrypoint }) - if (entryPointCode === "0x") { + if (entryPointCode === undefined || entryPointCode === "0x") { throw new Error(`entry point ${entrypoint} does not exist`) } } if (config.entrypointSimulationContract) { const simulations = config.entrypointSimulationContract - const simulationsCode = await config.publicClient.getBytecode({ + const simulationsCode = await config.publicClient.getCode({ address: simulations }) if (simulationsCode === undefined || simulationsCode === "0x") { @@ -41,6 +41,18 @@ const preFlightChecks = async (config: AltoConfig): Promise => { ) } } + + if (config.refillHelperContract) { + const refillHelper = config.refillHelperContract + const refillHelperCode = await config.publicClient.getCode({ + address: refillHelper + }) + if (refillHelperCode === undefined || refillHelperCode === "0x") { + throw new Error( + `RefillHelper contract ${refillHelper} does not exist` + ) + } + } } export async function bundlerHandler(args_: IOptionsInput): Promise { diff --git a/src/executor/senderManager.ts b/src/executor/senderManager.ts index 4bd7a2a8..b804919e 100644 --- a/src/executor/senderManager.ts +++ b/src/executor/senderManager.ts @@ -140,11 +140,7 @@ export class SenderManager { const { maxFeePerGas, maxPriorityFeePerGas } = await this.gasPriceManager.getGasPrice() - if ( - this.config.walletClient.chain.id === 59140 || - this.config.walletClient.chain.id === 137 || - this.config.walletClient.chain.id === 10 - ) { + if (this.config.refillHelperContract) { const instructions = [] for (const [address, missingBalance] of Object.entries( balancesMissing @@ -156,18 +152,9 @@ export class SenderManager { }) } - let refillAddress: `0x${string}` - if (this.config.walletClient.chain.id === 59140) { - refillAddress = "0xEad1aC3DF6F96b91491d6396F4d1610C5638B4Db" - } else if (this.config.walletClient.chain.id === 137) { - refillAddress = "0x3402DB43152dAB9ab72fa805fdD5f391cD3E3822" - } else { - refillAddress = "0x3402DB43152dAB9ab72fa805fdD5f391cD3E3822" - } - const callEngine = getContract({ abi: CallEngineAbi, - address: refillAddress, + address: this.config.refillHelperContract, client: { public: this.config.publicClient, wallet: this.config.walletClient