From e358a6ec4ec44a29190a7187539551f1bb17bc60 Mon Sep 17 00:00:00 2001 From: owen-eth Date: Mon, 11 May 2026 19:27:01 -0400 Subject: [PATCH] floor miles bid-cost gasLimit at 400k to match backend The mev-commit fastswap executor now enforces a 400k floor on gasLimit to avoid the EIP-150 63/64 cascade OOG on simple routes. Mirror that floor here so the bid-cost calc doesn't understate while Edge Config still has stale pre-floor data from the cron. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/app/api/config/gas-estimate/route.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app/api/config/gas-estimate/route.ts b/src/app/api/config/gas-estimate/route.ts index 868d5567..b32bffb8 100644 --- a/src/app/api/config/gas-estimate/route.ts +++ b/src/app/api/config/gas-estimate/route.ts @@ -6,6 +6,9 @@ export const runtime = "edge" const DEFAULT_GAS_LIMIT = 450_000 const DEFAULT_GAS_USED = 180_000 const DEFAULT_SURPLUS_RATE = 0.0056 +/** Matches the mev-commit fastswap gasLimit floor. Prevents the bid-cost calc + * from understating when Edge Config has stale pre-floor data. */ +const MIN_GAS_LIMIT = 400_000 /** Default upper bound the miles calculator will plan against, in percent. */ const DEFAULT_MILES_CALC_MAX_SLIPPAGE = 50 /** Hard floors and ceilings for the calc cap so a bad Edge Config value can't @@ -30,7 +33,10 @@ export async function GET() { return NextResponse.json( { - gasEstimate: typeof gasLimit === "number" && gasLimit > 0 ? gasLimit : DEFAULT_GAS_LIMIT, + gasEstimate: Math.max( + typeof gasLimit === "number" && gasLimit > 0 ? gasLimit : DEFAULT_GAS_LIMIT, + MIN_GAS_LIMIT + ), gasUsedEstimate: typeof gasUsed === "number" && gasUsed > 0 ? gasUsed : DEFAULT_GAS_USED, surplusRate: typeof surplusRate === "number" && surplusRate > 0 ? surplusRate : DEFAULT_SURPLUS_RATE,