Skip to content

feat: add price oracle interface for approved callers (#803) - #815

Open
Seunfunmi-319509 wants to merge 3 commits into
accesslayerorg:mainfrom
Seunfunmi-319509:feat/price-oracle-803
Open

feat: add price oracle interface for approved callers (#803)#815
Seunfunmi-319509 wants to merge 3 commits into
accesslayerorg:mainfrom
Seunfunmi-319509:feat/price-oracle-803

Conversation

@Seunfunmi-319509

Copy link
Copy Markdown

Summary

Adds a cross-contract readable price oracle to creator-keys so verified external Soroban contracts can read key prices.

Changes

New entrypoints on CreatorKeysContract:

  • get_price(creator, caller) — current bonding-curve price for a creator's key.
  • get_twap_price(creator, window_ledgers, caller) — time-weighted average price over a ledger window.
  • add_approved_caller(admin, caller) / remove_approved_caller(admin, caller) / is_approved_caller(caller) — an admin-maintained allowlist of callers permitted to invoke the oracle.

Key design points:

  • Allowlist gating — only approved callers may read prices; unapproved callers are rejected with a new ContractError::CallerNotApproved (appended as #37). The mahout admin maintains the list via add/remove_approved_caller.
  • Caller identity — uses the calling contract's Address + require_auth() (the idiomatic pattern in this contract; env.caller() is unavailable in soroban-sdk 22). Address is used instead of the issue's literal BytesN<32> because the contract keys everything by creator Address and strkey (base32+CRC) conversion is fragile in #![no_std]/wasm.
  • TWAP — derived from a bounded per-creator observation history (MAX_PRICE_OBSERVATIONS = 100) recorded on each oracle call; each observed price is weighted by the ledgers it was in effect inside the window, falling back to the current price when there's no history.
  • Events — every successful read emits a price_queried event with the caller, creator, and returned price (stable shape for downstream indexers).

Testing

  • 17 new integration tests in creator-keys/tests/price_oracle.rs covering get_price, get_twap_price, allowlist admin functions (incl. auth and idempotency), and event emission.
  • Full creator-keys suite passes; cargo fmt and cargo clippy are clean.

Closes #803

oshowunm and others added 2 commits August 27, 2026 16:35
…#803)

Add a cross-contract readable price oracle to creator-keys exposing:
- get_price: current bonding-curve price for a creator's key
- get_twap_price: time-weighted average price over a ledger window
- add/remove/is_approved_caller: admin-maintained allowlist

Gating on an approved-caller allowlist lets verified external Soroban
contracts read key prices. Every successful read records a bounded
price observation (used for TWAP) and emits a price_queried event
carrying the calling contract's address.
@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@Seunfunmi-319509 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

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.

Add a price oracle interface function allowing verified external Soroban contracts to read the current key price

1 participant