Skip to content

Commit

Permalink
Merge pull request #233 from pimlicolabs/feat/gas-bump-flag
Browse files Browse the repository at this point in the history
add flag for gas price bump
  • Loading branch information
mouseless0x authored Jun 2, 2024
2 parents 6d37ee3 + 4d08a19 commit d69b57e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 31 deletions.
4 changes: 4 additions & 0 deletions src/cli/config/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ export const bundlerArgsSchema = z.object({
"max-bundle-wait": z.number().int().min(0),
"max-bundle-size": z.number().int().min(0),

"gas-price-bump": z
.string()
.transform((val) => BigInt(val))
.default("100"),
"gas-price-floor-percent": z.number().int().min(0),
"gas-price-expiry": z.number().int().min(0),
"gas-price-multipliers": z
Expand Down
6 changes: 6 additions & 0 deletions src/cli/config/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ export const bundlerOptions: CliCommandOptions<IBundlerArgsInput> = {
require: true,
default: true
},
"gas-price-bump": {
description: "Amount to multiply the gas prices fetched from the node",
type: "string",
require: false,
default: "100"
},
"gas-price-floor-percent": {
description:
"The minimum percentage of incoming user operation gas prices compared to the gas price used by the bundler to submit bundles",
Expand Down
1 change: 1 addition & 0 deletions src/cli/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export async function bundlerHandler(args: IOptionsInput): Promise<void> {
parsedArgs["log-level"]
}
),
parsedArgs["gas-price-bump"],
parsedArgs["gas-price-expiry"]
)

Expand Down
35 changes: 4 additions & 31 deletions src/utils/gasPriceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,22 @@ export class GasPriceManager {
maxPriorityFeePerGas: bigint
}[] = [] // Store pairs of [price, timestamp]
private maxQueueSize
private gasBumpMultiplier: bigint

constructor(
chain: Chain,
publicClient: PublicClient,
legacyTransactions: boolean,
logger: Logger,
gasBumpMultiplier: bigint,
gasPriceTimeValidityInSeconds = 10
) {
this.maxQueueSize = gasPriceTimeValidityInSeconds
this.chain = chain
this.publicClient = publicClient
this.legacyTransactions = legacyTransactions
this.logger = logger
this.gasBumpMultiplier = gasBumpMultiplier
}

private getDefaultGasFee(
Expand Down Expand Up @@ -87,40 +90,10 @@ export class GasPriceManager {
}
}

private getBumpAmount(chainId: number) {
if (chainId === chains.sepolia.id) {
return 120n
}

if (chainId === chains.celo.id) {
return 150n
}

if (
chainId === chains.arbitrum.id ||
chainId === chains.scroll.id ||
chainId === chains.scrollSepolia.id ||
chainId === chains.arbitrumGoerli.id ||
chainId === chains.mainnet.id ||
chainId === chains.mantle.id ||
chainId === 22222 ||
chainId === chains.sepolia.id ||
chainId === chains.base.id ||
chainId === chains.dfk.id ||
chainId === chains.celoAlfajores.id ||
chainId === chains.avalanche.id ||
chainId === chains.linea.id
) {
return 111n
}

return 100n
}

private bumpTheGasPrice(
gasPriceParameters: GasPriceParameters
): GasPriceParameters {
const bumpAmount = this.getBumpAmount(this.chain.id)
const bumpAmount = this.gasBumpMultiplier

const maxPriorityFeePerGas = maxBigInt(
gasPriceParameters.maxPriorityFeePerGas,
Expand Down

0 comments on commit d69b57e

Please sign in to comment.