Skip to content

Commit

Permalink
add IsSep40 starter
Browse files Browse the repository at this point in the history
  • Loading branch information
pselle committed Jul 22, 2024
1 parent 4889d9b commit cc81122
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
37 changes: 37 additions & 0 deletions contracts/data-feed/src/data_feed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,43 @@ impl IsSep40Admin for DataFeed {
}
}

impl IsSep40 for DataFeed {
#[doc = " Return all assets quoted by the price feed"]
fn assets(&self) -> loam_sdk::soroban_sdk::Vec<Asset> {
self.assets.keys()
}

#[doc = " Return the base asset the price is reported in"]
fn base(&self) -> Asset {
self.base.clone()
}

#[doc = " Return the number of decimals for all assets quoted by the oracle"]
fn decimals(&self) -> u32 {
self.decimals
}

#[doc = " Get the most recent price for an asset"]
fn lastprice(&self, asset: Asset) -> Option<PriceData> {
todo!()
}

#[doc = " Get price in base asset at specific timestamp"]
fn price(&self, asset: Asset, timestamp: u64) -> Option<PriceData> {
todo!()
}

#[doc = " Get last N price records"]
fn prices(&self, asset: Asset, records: u32) -> Option<Vec<PriceData>> {
todo!()
}

#[doc = " Return default tick period timeframe (&self, in seconds)"]
fn resolution(&self) -> u32 {
todo!()
}
}

/// Get the timestamp from env, converted to milliseconds
fn now() -> u64 {
env().ledger().timestamp() * 1000
Expand Down
1 change: 1 addition & 0 deletions contracts/data-feed/src/sep40.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use loam_sdk::{

//quoted asset definition
#[loam_sdk::soroban_sdk::contracttype]
#[derive(Clone)]
pub enum Asset {
/// Can be a Stellar Classic or Soroban asset
Stellar(loam_sdk::soroban_sdk::Address),
Expand Down

0 comments on commit cc81122

Please sign in to comment.