Skip to content

Document price precision and TWAP aggregation on submit_price - #270

Merged
Jaydbrown merged 1 commit into
conduit-protocol:mainfrom
Alimzy:docs/twap-submit-price-219
Jul 29, 2026
Merged

Document price precision and TWAP aggregation on submit_price#270
Jaydbrown merged 1 commit into
conduit-protocol:mainfrom
Alimzy:docs/twap-submit-price-219

Conversation

@Alimzy

@Alimzy Alimzy commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Note on scope

The issue states submit_price has no doc comment. It actually already
had a short one — but it didn't cover price precision/decimals or how
submissions feed into TWAP aggregation, which is the real gap this PR
addresses.

What this PR does

Extends submit_price's existing doc comment with:

  • price is a fixed-point integer scaled by 10^decimals, where decimals
    comes from the oracle's OracleConfig (max 38, validated in
    configure_oracle), with a concrete example (decimals: 8 -> 100.0 is
    submitted as 100_00000000).
  • Clarification that there is no fixed time-bucketed TWAP window:
    every feeder's latest submission is kept independently, and
    get_twap_price aggregates the median (or average of the two middle
    values on an even count) across submissions within max_staleness
    seconds of current ledger time.
  • A cross-reference to calculate_fiat_stream_payout, which divides by
    10^decimals, to make clear submissions must use the currently
    configured decimals scale or downstream payouts will be off by that
    scale factor.

No behavior change - doc comment only.

Verification

  • cargo build: clean
  • cargo test (oracle crate): 42 passed, 0 failed
  • cargo fmt --check: clean
  • cargo clippy -p drip-oracle: clean

Closes #219.

Addresses conduit-protocol#219. submit_price already had a short doc comment, but it
did not explain the expected price precision/decimals or how
submissions feed into TWAP aggregation, which was the real gap
behind the issue.

Added:
- price is a fixed-point integer scaled by 10^decimals, where
  decimals comes from OracleConfig (max 38, validated in
  configure_oracle). Documented with a concrete example.
- Clarified there is no fixed time-bucketed TWAP window: each
  feeder's latest submission is kept independently, and
  get_twap_price aggregates the median (or average of the two middle
  values on an even count) across submissions within max_staleness
  seconds of current ledger time.
- Cross-referenced calculate_fiat_stream_payout, which divides by
  10^decimals, to make clear submissions must match the currently
  configured decimals scale.

No behavior change — doc comment only. cargo build, cargo test (42
passed), cargo fmt --check, and cargo clippy all clean on the oracle
crate.
@Alimzy
Alimzy requested a review from Jaydbrown as a code owner July 29, 2026 12:43
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@Alimzy Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Jaydbrown
Jaydbrown merged commit 93764bc into conduit-protocol:main Jul 29, 2026
3 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.

Enhancement: TwapOracle::submit_price has no doc comment

2 participants