Skip to content

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

Merged
Chucks1093 merged 5 commits into
accesslayerorg:mainfrom
Seunfunmi-319509:feat/price-oracle-803
Sep 7, 2026
Merged

feat: add price oracle interface for approved callers (#803)#815
Chucks1093 merged 5 commits into
accesslayerorg:mainfrom
Seunfunmi-319509:feat/price-oracle-803

Conversation

@Seunfunmi-319509

Copy link
Copy Markdown
Contributor

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

@Chucks1093

Copy link
Copy Markdown
Member

❌ CI Failed — verify (Contracts CI)

The verify check is failing on this PR.

Likely causes:

  • Compile error in the updated fee logic — possibly wrong type cast or arithmetic overflow
  • Formatting not applied before push
  • Clippy warning treated as error

Steps to fix:

  1. Run cargo build and check for arithmetic or type errors
  2. Run cargo fmt --all and commit
  3. Push

@Chucks1093 Chucks1093 closed this Sep 7, 2026
@Chucks1093 Chucks1093 reopened this Sep 7, 2026
Seunfunmi-319509 and others added 2 commits September 7, 2026 07:56
The oracle code added in accesslayerorg#803 referenced supporting definitions that were
lost when main was merged into feat/price-oracle-803: the CallerNotApproved
error variant, the APPROVED_CALLERS/price_history storage helpers and the
PriceQueriedEvent definitions. main also gained its own get_price(creator,
supply) view, which collided with the oracle's get_price(creator, caller);
rename the supply query to get_price_at_supply so both entrypoints coexist,
and align the oracle tests with the current admin-first fee setup.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@Seunfunmi-319509

Copy link
Copy Markdown
Contributor Author

@Chucks1093 I am doneeeeeeeeeeeeeee, please mergeeeeeeeeeeee

@Chucks1093
Chucks1093 merged commit dde1723 into accesslayerorg:main Sep 7, 2026
1 check 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.

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

2 participants