Skip to content

Commit 25cf92a

Browse files
owen-ethclaude
andcommitted
fix(miles): bump sweep multiplier 2.2x → 2.5x for non-ETH output
Daily p50 of realized (bid + overhead) / bid swings 0.9 to 2.9 across the last 10 days — the 7-day aggregate p50 of 1.21 that justified 2.2x washed out that variance. On elevated-gas days (Apr 12, 13, 15) 2.2x still under-subtracts and leaks "7-miles-estimated → 0-miles-actual" surprises. 2.5x covers the median of those bad days while staying tolerable on cheap days like Apr 10/11. Still a bandaid — the structural fix is an Edge Config-driven sweep overhead term computed from recent finalized rows, tracked as a TODO in the comment. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 40dd972 commit 25cf92a

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/hooks/use-estimated-miles.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,15 @@ export function useEstimatedMiles({
174174
const gasCostEth = isPermitPath ? Number(curBaseFee * curAvgGasUsed) / 1e18 : 0
175175

176176
// Sweep overhead: non-ETH output requires a sweep tx (batched fastswap).
177-
// 2.2x multiplier derived from realized (bid + overhead) / bid on processed
178-
// ETH→ERC20 rows — median ratio is ~1.21, so total deduction ≈ 2.2x bid.
179-
// Batches are effectively size-1 at current volume, so each user eats the
180-
// whole sweep gas share instead of the ~3-tx pro-rata the old 1.5x assumed.
181-
const sweepMultiplier = isEthOutput ? 1 : 2.2
177+
// 2.5x is a conservative proxy — batches are effectively size-1 at current
178+
// volume, so each user eats the whole sweep gas share. Daily p50 of
179+
// realized (bid + overhead) / bid varies widely (0.9–2.9 over the last
180+
// 10 days), so any fixed multiplier is a bandaid. 2.5 covers the median
181+
// of "bad" days (p50 ≈ 1.9) while staying tolerable on cheap days.
182+
// TODO: replace with an Edge Config-driven sweep overhead term computed
183+
// from `surplus_eth - net_profit_eth - bid_cost` on recent finalized rows
184+
// — same pattern as `miles_estimate_surplus_rate`.
185+
const sweepMultiplier = isEthOutput ? 1 : 2.5
182186
const totalBidCost = bidCostEth * sweepMultiplier
183187
const totalGasCost = gasCostEth * sweepMultiplier
184188

0 commit comments

Comments
 (0)