diff --git a/lib/ain-ocean/src/indexer/loan_token.rs b/lib/ain-ocean/src/indexer/loan_token.rs index 46fc56be97..060f9f745c 100644 --- a/lib/ain-ocean/src/indexer/loan_token.rs +++ b/lib/ain-ocean/src/indexer/loan_token.rs @@ -107,29 +107,29 @@ fn map_active_price( block: &BlockContext, aggregated_price: OraclePriceAggregated, prev_price: Option, -) -> OraclePriceActive { - let next_price = if is_aggregate_valid(&aggregated_price, block) { - Some(aggregated_price.aggregated) - } else { - None - }; - +) -> Option { let active_price = if let Some(prev_price) = prev_price { if let Some(next) = prev_price.next { Some(next) } else { prev_price.active } + } else { + return None + }; + + let next_price = if is_aggregate_valid(&aggregated_price, block) { + Some(aggregated_price.aggregated) } else { None }; - OraclePriceActive { + Some(OraclePriceActive { active: active_price.clone(), next: next_price.clone(), is_live: is_live(active_price, next_price), block: block.clone(), - } + }) } pub fn invalidate_active_price(services: &Arc, block: &BlockContext) -> Result<()> { @@ -205,6 +205,9 @@ pub fn perform_active_price_tick( }; let active_price = map_active_price(block, aggregated_price, prev_price); + let Some(active_price) = active_price else { + return Ok(()) + }; repo.by_id .put(&(id.0, id.1, block.height.to_be_bytes()), &active_price)?;