Skip to content

[Airdrop P2] Buy points sync cron #881

@realproject7

Description

@realproject7

Parent: #877
Depends on: #878, #879

Scope

New Vercel cron that syncs trade_historypl_points for buy events within the campaign window.

Logic

  1. Query trade_history for event_type = 'mint' where block_timestamp is within campaign window
  2. Filter out ZAP_PLOTLINK address (self-mints via zap contract)
  3. For each unprocessed trade:
    • Compute points: reserve_amount converted to PLOT (1 PL per 1 PLOT spent)
    • Look up user's current streak tier from pl_streaks → apply boost multiplier
    • Insert pl_points row with action = 'buy', boosted points, metadata = { trade_id }
  4. Check if buyer has a referrer in pl_referrals:
    • If yes: insert action = 'referral' points (20% of buyer's buy points, also boosted by referrer's streak) for the referrer
  5. Dedup via metadata->>'trade_id' — skip if already processed

Endpoint

POST /api/cron/airdrop-points

Schedule: Every 5 min (*/5 * * * *)
Auth: CRON_SECRET header (same pattern as existing crons)

Existing Infrastructure

  • trade_history table already populated by src/app/api/cron/trade-history/route.ts (every 5 min)
  • ZAP_PLOTLINK address defined in lib/contracts/constants.ts
  • Streak boost lookup from lib/airdrop/streak.ts (see [Airdrop P2] Streak check-in system (SIWE) #882)

Files

  • src/app/api/cron/airdrop-points/route.ts
  • lib/airdrop/points.ts (helper: compute points with boost)

Acceptance Criteria

  • Cron syncs mint events from trade_history to pl_points
  • Points = PLOT spent × streak boost multiplier
  • Referral points (20%) inserted for referrer when applicable
  • ZAP_PLOTLINK trades filtered out
  • Idempotent — re-running doesn't create duplicates
  • Only processes trades within campaign window
  • Campaign end check — no points after CAMPAIGN_END

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