Description
Spot-price NAV is manipulable. Add a time-weighted average price (TWAP) accumulator that downstream consumers can read for valuations and concentration checks, sampled by report_revenue and bounded to a configurable window.
Requirements and context
- Must be secure, tested, and documented
- Should be efficient and easy to review
- Relevant code:
Revora-Contracts/src/lib.rs
- TWAP must be capped at MAX_TWAP_WINDOW_SECS and ignore samples older than the window
Suggested execution
- Fork the repo and create a branch
git checkout -b feat/twap-valuation-oracle
- Implement changes
- Add
TwapAccumulator { last_ts, last_price, cumulative_price_secs }
- Sample on each report_revenue with payment-token price
- Expose
get_twap(offering_id, window_secs) -> i128
- Validate security and correctness assumptions
Test and commit
- Run tests
- Cover edge cases
- Identical timestamps must not double-count cumulative price
- Include test output and security notes
Example commit message
feat: add TWAP valuation accumulator for offering NAV
Guidelines
- Minimum 95 percent test coverage
- Clear documentation
- Timeframe: 96 hours
Description
Spot-price NAV is manipulable. Add a time-weighted average price (TWAP) accumulator that downstream consumers can read for valuations and concentration checks, sampled by
report_revenueand bounded to a configurable window.Requirements and context
Revora-Contracts/src/lib.rsSuggested execution
git checkout -b feat/twap-valuation-oracleTwapAccumulator { last_ts, last_price, cumulative_price_secs }get_twap(offering_id, window_secs) -> i128Test and commit
cargo test --allExample commit message
feat: add TWAP valuation accumulator for offering NAVGuidelines