From 8700c6334144b35d3ab88ae136b7fcf3d956a063 Mon Sep 17 00:00:00 2001 From: David Salami Date: Tue, 12 Nov 2024 10:34:41 +0000 Subject: [PATCH] cap dot protocol fees at 100 dot --- modules/ismp/pallets/asset-gateway/src/xcm_utilities.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/ismp/pallets/asset-gateway/src/xcm_utilities.rs b/modules/ismp/pallets/asset-gateway/src/xcm_utilities.rs index 3a12b07f7..a11043675 100644 --- a/modules/ismp/pallets/asset-gateway/src/xcm_utilities.rs +++ b/modules/ismp/pallets/asset-gateway/src/xcm_utilities.rs @@ -1,7 +1,7 @@ use crate::{AssetIds, Config, Pallet}; use alloc::vec::Vec; use codec::Encode; -use core::marker::PhantomData; +use core::{cmp::min, marker::PhantomData}; use frame_support::traits::{ fungibles::{self, Mutate}, Contains, @@ -200,7 +200,9 @@ where // messages let base_fee = if who.dest_state_machine == StateMachine::Evm(1) { 20_000_000_000u128 } else { 0 }; - let protocol_fees = protocol_percentage * u128::from(amount) + base_fee; + // Cap protocol fees at 100 DOT + let protocol_fees = + min(protocol_percentage * u128::from(amount) + base_fee, 1000_000_000_000u128); let remainder = u128::from(amount) .checked_sub(protocol_fees.into()) .ok_or_else(|| XcmError::Overflow)?