Skip to content

Conversation

@Jon-edge
Copy link
Contributor

@Jon-edge Jon-edge commented Dec 3, 2025

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Description

Polygon Gas Fee Bug Analysis

Root Cause

In src/ethereum/ethereumSchema.ts, the Polygon gas station response parser was incorrectly using maxPriorityFee instead of maxFee.

EIP-1559 Fee Structure

EIP-1559 transactions have two fee components:

Component Description Destination
Base Fee Set by network based on demand Burned (destroyed)
Priority Fee (Miner Tip) Set by user as incentive Paid to validator

Total Fee = Base Fee + Priority Fee

The Polygon Gas Station API

The Polygon gas station (https://gasstation.polygon.technology/v2) returns:

{
  "safeLow": { "maxPriorityFee": 20, "maxFee": 35 },
  "standard": { "maxPriorityFee": 25, "maxFee": 40 },
  "fast": { "maxPriorityFee": 30, "maxFee": 50 }
}
  • maxPriorityFee = just the tip portion (~20 Gwei)
  • maxFee = total fee needed (baseFee + tip, ~35 Gwei)

The Bug

// BEFORE (incorrect)
case 'polygon': {
  const polygonFees = asPolygonGasStation(raw)
  return {
    safeLow: polygonFees.safeLow.maxPriorityFee,  // ❌ Using tip only
    average: polygonFees.standard.maxPriorityFee,
    fast: polygonFees.fast.maxPriorityFee,
    fastest: polygonFees.fast.maxPriorityFee * 1.25
  }
}

The code used maxPriorityFee (20 Gwei) as if it were the total required fee, when it should have used maxFee (35 Gwei).

Impact

Transactions were underpriced by approximately the base fee amount:

Metric Value
Network required ~35 Gwei
Transaction used ~29 Gwei
Underpayment ~17%

This caused transactions to:

  • Take longer to confirm
  • Potentially get stuck during high-demand periods
  • Fail to be included in blocks when base fee spiked

Evidence

Transaction 0x79884703a6d10dcdae3e0caf50c4d0e193c52ad9708fb6098de287888272359b:

broadcastTx: edge-rjqa2 -- My Polygon wallet:polygon Ee9uY2IuBpERQGblRAcfYD2gKMWPotg8Xu970MnWSs0=\n09:38:15:418: 2025-12-02T17:38:15.418Z | \n  currencyCode: POL\n  nativeAmount: -1885606931818171000\n  txid: 0x79884703a6d10dcdae3e0caf50c4d0e193c52ad9708fb6098de287888272359b\n  networkFee: 606931818171000\n  parentNetworkFee: \n  deviceDescription: Apple iPhone16,2\n  networkFeeOption: standard\n  requestedCustomFee: {\"gasLimit\":\"\",\"gasPrice\":\"\"}\n  feeRateUsed: {\"gasPrice\":\"28.901515151\",\"minerTip\":\"19.911825379\",\"gasLimit\":\"21000\"}

The miner tip value (~20 Gwei) directly correlates with maxPriorityFee, confirming the bug.

The Fix

// AFTER (correct)
case 'polygon': {
  const polygonFees = asPolygonGasStation(raw)
  return {
    safeLow: polygonFees.safeLow.maxFee,  // ✅ Using total fee
    average: polygonFees.standard.maxFee,
    fast: polygonFees.fast.maxFee,
    fastest: polygonFees.fast.maxFee * 1.25
  }
}

Additional Fix: Reduced Fee Update Interval

The default fee polling interval is 10 minutes, which can lead to stale fees during volatile periods. Added feeUpdateFrequencyMs: 60000 to polygonInfo.ts to update fees every 1 minute instead.

Files Changed

  • src/ethereum/ethereumSchema.ts: Changed maxPriorityFeemaxFee for polygon gas station parsing
  • src/ethereum/info/polygonInfo.ts: Added feeUpdateFrequencyMs: 60000 to reduce fee polling from 10 minutes to 1 minute

Note

Switch Polygon gas parsing to maxFee and cut fee polling interval to 1 minute.

  • Polygon:
    • Gas station parsing: Use maxFee (not maxPriorityFee) for safeLow/average/fast/fastest in src/ethereum/ethereumSchema.ts.
    • Fee polling: Set feeUpdateFrequencyMs: 60000 in src/ethereum/info/polygonInfo.ts to update fees every minute.
  • Docs:
    • Update CHANGELOG.md to reflect the above changes.

Written by Cursor Bugbot for commit 40d6bcf. This will update automatically on new commits. Configure here.


@Jon-edge Jon-edge enabled auto-merge December 4, 2025 22:27
@Jon-edge Jon-edge merged commit 9e143e8 into master Dec 4, 2025
3 checks passed
@Jon-edge Jon-edge deleted the jon/fix/pol-fees branch December 4, 2025 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants