Skip to content

Commit a4189e2

Browse files
committed
fix: only use ETH input swaps to estimate sweep overhead
1 parent 21b0451 commit a4189e2

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

tools/fastswap-miles/cost_estimator.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ func (c *costEstimator) Get(token string) costEstimate {
9090
// over the configured lookback window. This is the only method that touches
9191
// the database; intended to be called periodically by a background goroutine.
9292
func (c *costEstimator) Refresh(ctx context.Context) error {
93+
// Filter to ETH-input rows so per_row_oh isolates pure sweep_overhead.
94+
// ERC20-input rows have user_gas baked into (surplus_eth - net_profit_eth),
95+
// which would inflate the estimate and cause the miles formula (which
96+
// deducts user_gas separately) to over-deduct.
9397
rows, err := c.db.QueryContext(ctx, fmt.Sprintf(`
9498
SELECT output_token,
9599
COUNT(*) as n,
@@ -105,6 +109,7 @@ FROM (
105109
AND surplus_eth > 0
106110
AND surplus_eth IS NOT NULL
107111
AND surplus_eth < 1.0
112+
AND input_token = '0x0000000000000000000000000000000000000000'
108113
AND block_timestamp >= NOW() - INTERVAL %d DAY
109114
) t
110115
GROUP BY output_token`, costEstimateLookbackDays))

0 commit comments

Comments
 (0)