Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
canonbrother committed Nov 19, 2024
1 parent d7e6bbd commit 259d1e4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 22 deletions.
32 changes: 14 additions & 18 deletions lib/ain-ocean/src/api/prices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,25 +259,21 @@ impl OraclePriceActiveResponse {
id: format!("{}-{}-{}", token, currency, v.block.height),
key: format!("{}-{}", token, currency),
sort: hex::encode(v.block.height.to_be_bytes()).to_string(),
active: v.active.map(|active| {
OraclePriceActiveNextResponse {
amount: format!("{:.8}", active.amount / Decimal::from(COIN)),
weightage: active.weightage,
oracles: OraclePriceActiveNextOraclesResponse {
active: active.oracles.active.to_i32().unwrap_or_default(),
total: active.oracles.total,
}
}
active: v.active.map(|active| OraclePriceActiveNextResponse {
amount: format!("{:.8}", active.amount / Decimal::from(COIN)),
weightage: active.weightage,
oracles: OraclePriceActiveNextOraclesResponse {
active: active.oracles.active.to_i32().unwrap_or_default(),
total: active.oracles.total,
},
}),
next: v.next.map(|next| {
OraclePriceActiveNextResponse {
amount: format!("{:.8}", next.amount / Decimal::from(COIN)),
weightage: next.weightage,
oracles: OraclePriceActiveNextOraclesResponse {
active: next.oracles.active.to_i32().unwrap_or_default(),
total: next.oracles.total,
}
}
next: v.next.map(|next| OraclePriceActiveNextResponse {
amount: format!("{:.8}", next.amount / Decimal::from(COIN)),
weightage: next.weightage,
oracles: OraclePriceActiveNextOraclesResponse {
active: next.oracles.active.to_i32().unwrap_or_default(),
total: next.oracles.total,
},
}),
is_live: v.is_live,
block: v.block,
Expand Down
2 changes: 1 addition & 1 deletion lib/ain-ocean/src/indexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ use std::{
use ain_dftx::{deserialize, is_skipped_tx, DfTx, Stack};
use defichain_rpc::json::blockchain::{Block, Transaction, Vin, VinStandard, Vout};
use helper::check_if_evm_tx;
use loan_token::{index_active_price, invalidate_active_price};
use log::trace;
pub use poolswap::PoolSwapAggregatedInterval;
use loan_token::{index_active_price, invalidate_active_price};
use poolswap::{index_pool_swap_aggregated, invalidate_pool_swap_aggregated};

use crate::{
Expand Down
12 changes: 10 additions & 2 deletions lib/ain-ocean/src/indexer/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,10 @@ fn map_price_aggregated(
let feed = services
.oracle_price_feed
.by_id
.list(Some((id.0, id.1, id.2, u32::MAX, base_id)), SortOrder::Descending)?
.list(
Some((id.0, id.1, id.2, u32::MAX, base_id)),
SortOrder::Descending,
)?
.next()
.transpose()?;

Expand Down Expand Up @@ -450,7 +453,12 @@ impl Index for SetOracleData {
let feeds = map_price_feeds(self, context);

for ((token, currency, _, _, _), _) in feeds.iter().rev() {
let id = (token.clone(), currency.clone(), context.block.median_time, context.block.height);
let id = (
token.clone(),
currency.clone(),
context.block.median_time,
context.block.height,
);

let aggregated = oracle_repo.by_id.get(&id)?;

Expand Down
5 changes: 4 additions & 1 deletion lib/ain-ocean/src/indexer/poolswap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,10 @@ pub fn index_pool_swap_aggregated(services: &Arc<Services>, block: &BlockContext
Ok(())
}

pub fn invalidate_pool_swap_aggregated(services: &Arc<Services>, block: &BlockContext) -> Result<()> {
pub fn invalidate_pool_swap_aggregated(
services: &Arc<Services>,
block: &BlockContext,
) -> Result<()> {
let mut pool_pairs = ain_cpp_imports::get_pool_pairs();
pool_pairs.sort_by(|a, b| b.creation_height.cmp(&a.creation_height));

Expand Down

0 comments on commit 259d1e4

Please sign in to comment.