From 50f79fc504ba382c1c217117ac58d671de8d6e1b Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Thu, 17 Oct 2024 10:09:41 +0800 Subject: [PATCH] Update oracle.rs In the ERC20 interface, the maximum number of decimals is 18, but it is better to use `saturating_sub` --- runtime/common/src/precompile/oracle.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/common/src/precompile/oracle.rs b/runtime/common/src/precompile/oracle.rs index 4086f8bac..03ec9e03c 100644 --- a/runtime/common/src/precompile/oracle.rs +++ b/runtime/common/src/precompile/oracle.rs @@ -76,7 +76,7 @@ where } }; - let maybe_adjustment_multiplier = 10u128.checked_pow((18 - decimals).into()); + let maybe_adjustment_multiplier = 10u128.checked_pow((18u8.saturating_sub(decimals)).into()); let adjustment_multiplier = match maybe_adjustment_multiplier { Some(adjustment_multiplier) => adjustment_multiplier, None => {