Skip to content

[#1304] Add TWAP minimum samples validation#1309

Merged
realproject7 merged 2 commits into
mainfrom
task/1304-twap-validation
May 26, 2026
Merged

[#1304] Add TWAP minimum samples validation#1309
realproject7 merged 2 commits into
mainfrom
task/1304-twap-validation

Conversation

@realproject7

Copy link
Copy Markdown
Owner

Summary

  • Finalize script now requires >=5 daily price samples for 7-day TWAP calculation
  • <5 samples → throws with clear error message (no silent single-sample TWAP)
  • 5-6 samples → warns but proceeds (defensible TWAP)
  • 7 samples → clean (expected)
  • Emergency override: AIRDROP_FINALIZE_ALLOW_PARTIAL_TWAP=1 env var for operator to proceed with partial data

Version

1.41.0 → 1.41.1

Closes #1304

🤖 Generated with Claude Code

Finalize script now requires >=5 daily price samples for TWAP
(throws with clear message if insufficient). Warns for 5-6 samples
(expected 7). Operator override via AIRDROP_FINALIZE_ALLOW_PARTIAL_TWAP=1
for emergency partial data.

Closes #1304

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

vercel Bot commented May 26, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
plotlink Ignored Ignored May 26, 2026 1:47pm

Request Review

@realproject7 realproject7 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@re2 review — APPROVE ✅

Criterion Status
<5 samples → throws with clear message
5-6 samples → warns, proceeds
7 samples → clean
Override: AIRDROP_FINALIZE_ALLOW_PARTIAL_TWAP=1
Version 1.41.0 → 1.41.1 (patch)

Clean 14-line addition in the right place (after data fetch, before TWAP computation). Error message includes actionable guidance. No issues found.

@project7-interns project7-interns left a comment

Copy link
Copy Markdown
Collaborator

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 script-level minimum sample guard is in the right place, but the PR does not satisfy the issue acceptance criteria for settlement-integrity coverage. This code gates final airdrop settlement math, so the boundary behavior needs automated verification rather than inspection only.

Findings

  • [medium] Missing TWAP sample-count tests required by #1304 acceptance criteria.

    • File: scripts/airdrop-finalize.ts:37
    • Suggestion: Add focused tests for the requested cases: 1 sample throws without AIRDROP_FINALIZE_ALLOW_PARTIAL_TWAP, 5 samples proceeds and warns, 7 samples proceeds cleanly, and the override path permits <5 samples while still warning. If this script is hard to test directly, extract the sample-count validation into a small pure helper and cover that helper.
  • [low] Override documentation acceptance item is not addressed in the PR.

    • File: scripts/airdrop-finalize.ts:52
    • Suggestion: Document AIRDROP_FINALIZE_ALLOW_PARTIAL_TWAP=1 in the relevant T6.1/operator settlement notes, or add an explicit PR note/comment linking where that emergency override is documented.

Decision

Request changes. The main guard looks correct, but #1304 explicitly requires tests for the settlement boundary cases and documentation of the emergency override.

Extract validateTwapSamples to lib/airdrop/twap.ts for testability.
7 tests: 0 samples rejects, 1/4 rejects without override, 1 with
override succeeds, 5/6 warn, 7 clean. Finalize script uses helper.
Override env documented in airdrop-contracts.md settlement section.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

@project7-interns project7-interns left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verdict: APPROVE

Summary

The requested #1304 follow-up is now covered: TWAP sample validation is extracted into a focused helper, the finalize script uses it, boundary tests cover the insufficient/override/warning/clean cases, and the emergency override is documented for settlement.

Findings

  • None.

Decision

Approve. CI is green for lint/typecheck/unit tests and E2E on run 26452072662.

@realproject7 realproject7 merged commit ba2f101 into main May 26, 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.

[T2.13] TWAP minimum samples validation (T6.1 settlement integrity)

2 participants