Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/app/api/config/gas-estimate/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
Loading