Skip to content

Commit

Permalink
cleanup PriceTicker #2
Browse files Browse the repository at this point in the history
  • Loading branch information
canonbrother committed Sep 25, 2024
1 parent db6b4a1 commit 358c48f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
8 changes: 7 additions & 1 deletion lib/ain-ocean/src/api/prices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ impl From<((Token, Currency), PriceTicker)> for PriceTickerResponse {
let amount = price_ticker.price.aggregated.amount / Decimal::from(COIN);
Self {
id: format!("{}-{}", token, currency),
sort: price_ticker.sort,
sort: format!(
"{}{}{}-{}",
hex::encode(price_ticker.price.aggregated.oracles.total.to_be_bytes()),
hex::encode(price_ticker.price.block.height.to_be_bytes()),
token.clone(),
currency.clone(),
),
price: OraclePriceAggregatedResponse {
id: format!("{}-{}-{}", token, currency, price_ticker.price.block.height),
key: format!("{}-{}", token, currency),
Expand Down
7 changes: 0 additions & 7 deletions lib/ain-ocean/src/indexer/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,13 +495,6 @@ fn index_set_oracle_data(
ticker_repo.by_id.put(
&pair.clone(),
&PriceTicker {
sort: format!(
"{}{}{}-{}",
hex::encode(price_aggregated.aggregated.oracles.total.to_be_bytes()),
hex::encode(price_aggregated.block.height.to_be_bytes()),
id.0.clone(),
id.1.clone(),
),
price: price_aggregated,
},
)?;
Expand Down
1 change: 0 additions & 1 deletion lib/ain-ocean/src/model/price_ticker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ pub type PriceTickerKey = (i32, u32, String, String); // total-height-token-curr
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct PriceTicker {
pub sort: String, //count-height-token-currency
pub price: OraclePriceAggregated,
}

0 comments on commit 358c48f

Please sign in to comment.