Skip to content

Commit 49925ad

Browse files
authored
Merge pull request #119 from primev/miles-cron-daily
chore(miles): run surplus-rate cron daily
2 parents 4a90f3c + 807cafd commit 49925ad

4 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/app/api/cron/update-edge-config/miles-estimate-gas/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ async function computeSurplusRateEstimate(): Promise<number> {
327327
* 4. Returns a JSON summary of the result.
328328
*
329329
* ### Schedule
330-
* Configured in `vercel.json` to run at 00:00 UTC on the 1st of every month.
330+
* Configured in `vercel.json` to run daily at 00:00 UTC.
331331
* Can also be triggered manually from the Vercel Dashboard → Cron Jobs tab.
332332
*/
333333
export async function GET(request: Request) {

src/components/dashboard/user-swaps-parts.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ export function SwapSide({
115115
)
116116
}
117117

118+
/**
119+
* Conservative miles estimate for pending rows. Uses the surplus rate
120+
* (from Edge Config, updated daily by cron) and the 90% user share /
121+
* 100k miles-per-ETH constants.
122+
*
123+
* This is a rough floor — actual miles are computed post-settlement and
124+
* will overwrite this value once processed.
125+
*/
118126
const DEFAULT_SURPLUS_RATE = 0.0056
119127
const USER_MEV_SHARE = 0.9
120128
const MILES_PER_ETH = 100_000

src/hooks/use-estimated-miles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function useEstimatedMiles({
4848
const [avgGasUsed, setAvgGasUsed] = useState<bigint>(DEFAULT_AVG_GAS_USED)
4949
const [surplusRate, setSurplusRate] = useState(DEFAULT_SURPLUS_RATE)
5050

51-
// Fetch gas estimates and surplus rate from Edge Config (updated monthly by cron).
51+
// Fetch gas estimates and surplus rate from Edge Config (updated daily by cron).
5252
// Runs on mount — not gated on `enabled` so data is ready before the first quote arrives.
5353
useEffect(() => {
5454
let cancelled = false

vercel.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"crons": [
88
{
99
"path": "/api/cron/update-edge-config/miles-estimate-gas",
10-
"schedule": "0 0 1 * *"
10+
"schedule": "0 0 * * *"
1111
}
1212
]
1313
}

0 commit comments

Comments
 (0)