Skip to content

[#881] Add buy points sync cron#900

Merged
realproject7 merged 2 commits intomainfrom
task/881-buy-points-cron
Apr 21, 2026
Merged

[#881] Add buy points sync cron#900
realproject7 merged 2 commits intomainfrom
task/881-buy-points-cron

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • New POST /api/cron/airdrop-points endpoint — syncs trade_history mint events to pl_points
  • Points = PLOT spent x streak boost multiplier (from pl_streaks)
  • Referral points (20% of buyer's points) awarded to referrers with their own streak boost
  • Filters out ZAP_PLOTLINK self-mints, respects campaign window
  • Idempotent via metadata.trade_id dedup — re-running won't create duplicates
  • New lib/airdrop/points.ts with computeBuyPoints() and computeReferralPoints() helpers

Files Changed

  • src/app/api/cron/airdrop-points/route.ts — cron endpoint
  • lib/airdrop/points.ts — points computation with streak boost

Test plan

  • npm run typecheck passes
  • POST to /api/cron/airdrop-points with valid CRON_SECRET — verify points inserted
  • Re-run same request — verify no duplicates created
  • Verify ZAP_PLOTLINK trades are skipped
  • Verify referral points created when buyer has referrer in pl_referrals
  • Verify campaign end check returns early after CAMPAIGN_END

Fixes #881

🤖 Generated with Claude Code

- New POST /api/cron/airdrop-points endpoint (every 5 min)
- Syncs trade_history mint events → pl_points with streak boost
- Awards referral points (20%) to referrers with their own streak boost
- Filters out ZAP_PLOTLINK self-mints
- Idempotent via metadata.trade_id dedup
- Respects campaign window (no points after CAMPAIGN_END)
- New lib/airdrop/points.ts with computeBuyPoints/computeReferralPoints

Fixes #881

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
plotlink Ignored Ignored Apr 21, 2026 0:00am

Request Review

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST CHANGES

Summary

The cron structure is reasonable, but the referral points calculation does not currently match the issue requirements. As written, referrers receive 20% of the buyer's unboosted base spend instead of 20% of the buyer's actual awarded buy points.

Findings

  • [high] Referral points ignore the buyer's streak boost, even though the issue explicitly says referral points should be 20% of the buyer's buy points.
    • File: lib/airdrop/points.ts:43
    • Suggestion: compute referral points from the already-calculated buyPoints value (or pass the buyer streak into the helper), then apply the referrer's own streak boost on top if that is the intended product rule.
  • [high] The route passes plotSpent into computeReferralPoints() instead of the buyer's awarded buy points, which bakes the same under-award into every referral insert.
    • File: src/app/api/cron/airdrop-points/route.ts:149
    • Suggestion: reuse buyPoints from the buy branch when deriving referral points for the referrer.

Decision

Requesting changes because the current implementation under-awards referral points relative to the ticket spec.

computeReferralPoints now takes the buyer's streak-boosted buyPoints
instead of raw plotSpent, so referral awards correctly reflect 20%
of the buyer's actual earned points.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

The referral-points calculation now matches the ticket requirement. Referral awards are derived from the buyer's actual boosted buyPoints, then adjusted by the referrer's own streak boost as implemented in the helper.

Findings

  • No blocking findings in the updated patch.

Decision

Approving from a code-review standpoint. The blocker from my previous review is resolved, and the cron logic now matches the spec for buy and referral point calculation.

@realproject7 realproject7 merged commit acd1b3b into main Apr 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Airdrop P2] Buy points sync cron

2 participants