diff --git a/src/modules/chains/schemas.ts b/src/modules/chains/schemas.ts index 39856a28..2f664742 100644 --- a/src/modules/chains/schemas.ts +++ b/src/modules/chains/schemas.ts @@ -67,6 +67,8 @@ const chainConfigSchemaBase = z.object({ gasCacheDuration: z.number().default(30000), // TODO: Add schema feeHistoryBlockTagOverride: z.string().optional(), eip1559: z.boolean().default(false), + /** Optional minimum maxFeePerGas (wei) for legacy chains; RPC may reject below this (e.g. BSC). */ + minMaxFeePerGas: bigIntLikeSchema.optional(), paymasterFunding: etherSchema.default("0.025"), paymasterFundingThreshold: etherSchema.default("0"), paymasterInitCode: hexSchema.optional(), diff --git a/src/modules/gas-estimator/gas-estimator-v2.service.ts b/src/modules/gas-estimator/gas-estimator-v2.service.ts index 9cc434ab..1b68571f 100644 --- a/src/modules/gas-estimator/gas-estimator-v2.service.ts +++ b/src/modules/gas-estimator/gas-estimator-v2.service.ts @@ -62,11 +62,18 @@ export class GasEstimatorServiceV2 { }, )(); + // Chain config may set a minimum (e.g. BSC); apply floor so RPC does not reject + const minGas = chainSettings.minMaxFeePerGas + ? BigInt(chainSettings.minMaxFeePerGas) + : 0n; + const effectiveGasPrice = + minGas > 0n && gasPrice < minGas ? minGas : gasPrice; + conditions = { - maxFeePerGas: gasPrice, - maxPriorityFeePerGas: gasPrice, + maxFeePerGas: effectiveGasPrice, + maxPriorityFeePerGas: effectiveGasPrice, l1GasPrice: 0n, - baseFee: gasPrice, + baseFee: effectiveGasPrice, }; } else { // EIP-1559 chain - use fee history for prediction