From 3b90b85380a19c757b24dbe17a49eba42980d0cc Mon Sep 17 00:00:00 2001 From: canonbrother Date: Fri, 25 Oct 2024 13:21:17 +0800 Subject: [PATCH] safe add --- lib/ain-ocean/src/indexer/oracle.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ain-ocean/src/indexer/oracle.rs b/lib/ain-ocean/src/indexer/oracle.rs index f251ce1a30..1e65935dfc 100644 --- a/lib/ain-ocean/src/indexer/oracle.rs +++ b/lib/ain-ocean/src/indexer/oracle.rs @@ -308,7 +308,9 @@ fn map_price_aggregated( let weighted_amount = Decimal::from(feed.amount) .checked_mul(Decimal::from(oracle.weightage)) .context(ArithmeticOverflowSnafu)?; - aggregated_total += weighted_amount; + aggregated_total = aggregated_total + .checked_add(weighted_amount) + .context(ArithmeticOverflowSnafu)?; } }