Skip to content

Commit dde1723

Browse files
authored
Merge pull request #815 from Seunfunmi-319509/feat/price-oracle-803
feat: add price oracle interface for approved callers (#803)
2 parents 6ee9d6b + 95584e1 commit dde1723

5 files changed

Lines changed: 772 additions & 35 deletions

File tree

creator-keys/src/events.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,3 +1807,31 @@ pub struct MaxBuyQuantityUpdatedEvent {
18071807
pub fn max_buy_quantity_updated_topics(creator: &Address) -> (Symbol, Address) {
18081808
(MAX_BUY_QUANTITY_UPDATED_EVENT_NAME, creator.clone())
18091809
}
1810+
1811+
/// Event name for a price-oracle read.
1812+
pub const PRICE_QUERIED_EVENT_NAME: Symbol = symbol_short!("pri_qry");
1813+
1814+
/// Stable price-queried event payload for downstream indexers.
1815+
///
1816+
/// Event shape:
1817+
/// - topics: `(PRICE_QUERIED_EVENT_NAME, caller)`
1818+
/// - data: `PriceQueriedEvent`
1819+
///
1820+
/// Emitted on every successful price-oracle read (`get_price` /
1821+
/// `get_twap_price`), carrying the calling contract's address and the returned
1822+
/// price.
1823+
#[derive(Clone, Debug, Eq, PartialEq)]
1824+
#[contracttype]
1825+
pub struct PriceQueriedEvent {
1826+
/// Contract that invoked the oracle entrypoint.
1827+
pub caller: Address,
1828+
/// Creator whose key's price was read.
1829+
pub creator: Address,
1830+
/// Price returned to the caller.
1831+
pub price: i128,
1832+
}
1833+
1834+
/// Shared price-queried event topics tuple.
1835+
pub fn price_queried_topics(caller: &Address) -> (Symbol, Address) {
1836+
(PRICE_QUERIED_EVENT_NAME, caller.clone())
1837+
}

0 commit comments

Comments
 (0)