Skip to content

Add TWAP valuation oracle for offering NAV computation independent of spot price #454

Description

@thlpkee20-wq

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
    • cargo test --all
  • 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

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions