From b6527b879bbf8c0551fbea9df9a84193646d696a Mon Sep 17 00:00:00 2001 From: rouzwelt Date: Thu, 16 Jan 2025 22:21:39 +0000 Subject: [PATCH] Update gas.ts --- src/gas.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gas.ts b/src/gas.ts index d0a49853..694c336c 100644 --- a/src/gas.ts +++ b/src/gas.ts @@ -6,6 +6,9 @@ import { publicActionsL2, walletActionsL2 } from "viem/op-stack"; import { BotConfig, BundledOrders, OperationState, RawTx, ViemClient } from "./types"; import { ArbitrumNodeInterfaceAbi, ArbitrumNodeInterfaceAddress, OrderbookQuoteAbi } from "./abis"; +// default gas price for bsc chain, 1 gwei +export const BSC_DEFAULT_GAS_PRICE = 1_000_000_000n as const; + /** * Estimates gas cost of the given tx, also takes into account L1 gas cost if the chain is a special L2. */ @@ -83,7 +86,11 @@ export async function getGasPrice(config: BotConfig, state: OperationState) { } const [gasPriceResult, l1GasPriceResult = undefined] = await Promise.allSettled(promises); if (gasPriceResult.status === "fulfilled") { - state.gasPrice = (gasPriceResult.value * BigInt(config.gasPriceMultiplier)) / 100n; + let gasPrice = gasPriceResult.value; + if (config.chain.id === ChainId.BSC && gasPrice < BSC_DEFAULT_GAS_PRICE) { + gasPrice = BSC_DEFAULT_GAS_PRICE; + } + state.gasPrice = (gasPrice * BigInt(config.gasPriceMultiplier)) / 100n; } if (l1GasPriceResult?.status === "fulfilled") { state.l1GasPrice = l1GasPriceResult.value;