Skip to content

Commit

Permalink
Update gas.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
rouzwelt committed Jan 16, 2025
1 parent 31ce5d8 commit b6527b8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/gas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b6527b8

Please sign in to comment.