Skip to content

[Airdrop P4] Daily price snapshot cron #890

@realproject7

Description

@realproject7

Parent: #877
Depends on: #878

Scope

Daily cron job that records PLOT USD price, supply, and mcap for TWAP calculation.

Logic

  1. Fetch PLOT USD price via getPlotUsdPrice() (existing in lib/usd-price.ts)
  2. Fetch circulating supply from MCV2 Bond or Mint Club SDK
  3. Compute mcap = price × supply
  4. Insert into pl_daily_prices (date-unique — skip if today already has an entry)

Error handling: If getPlotUsdPrice() returns null (all 3 sources failed), skip the day's snapshot — do NOT insert a zero or stale value. The TWAP calculation at campaign end uses AVG() over available days, so a missing day is better than a wrong value. Log the failure for monitoring.

Endpoint

POST /api/cron/airdrop-price

Schedule: Once/day at midnight UTC (0 0 * * *)
Auth: CRON_SECRET header

TWAP Usage

At campaign end, the final milestone is determined by the 7-day TWAP:
AVG(mcap_usd) FROM pl_daily_prices WHERE recorded_at >= (end_date - 7 days)

Files

  • src/app/api/cron/airdrop-price/route.ts

Acceptance Criteria

  • Records daily PLOT price + supply + mcap
  • Idempotent — one entry per day
  • Uses existing getPlotUsdPrice() (no new price source)
  • Skips snapshot if price fetch fails (no zero/stale values)
  • Logs failure when price fetch returns null
  • Registered in vercel.json crons (see [Airdrop P4] Weekly stats snapshot cron + vercel.json #891)

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/T3Assigned to T3 builder agentairdropPLOT 10x Airdrop Campaign

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions