feat: add price oracle interface for approved callers (#803) - #815
Open
Seunfunmi-319509 wants to merge 3 commits into
Open
feat: add price oracle interface for approved callers (#803)#815Seunfunmi-319509 wants to merge 3 commits into
Seunfunmi-319509 wants to merge 3 commits into
Conversation
…#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.
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a cross-contract readable price oracle to
creator-keysso 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:
ContractError::CallerNotApproved(appended as#37). The mahout admin maintains the list viaadd/remove_approved_caller.Address+require_auth()(the idiomatic pattern in this contract;env.caller()is unavailable in soroban-sdk 22).Addressis used instead of the issue's literalBytesN<32>because the contract keys everything by creatorAddressand strkey (base32+CRC) conversion is fragile in#![no_std]/wasm.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.price_queriedevent with the caller, creator, and returned price (stable shape for downstream indexers).Testing
creator-keys/tests/price_oracle.rscovering get_price, get_twap_price, allowlist admin functions (incl. auth and idempotency), and event emission.creator-keyssuite passes;cargo fmtandcargo clippyare clean.Closes #803