Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Handle Zero CollateralPerOrder (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
AurevoirXavier authored and jiguantong committed Sep 29, 2022
1 parent c0c0fc9 commit fa2d416
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion modules/fee-market/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ pub mod pallet {
#[pallet::constant]
type MinimumRelayFee: Get<BalanceOf<Self, I>>;
/// The collateral relayer need to lock for each order.
///
/// This also represents the maximum slash value for a single delayed order.
/// Please note that if this value is set to zero the fee market will be suspended.
#[pallet::constant]
type CollateralPerOrder: Get<BalanceOf<Self, I>>;
/// The slot times set
Expand Down Expand Up @@ -503,7 +506,13 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
}

fn collateral_to_order_capacity(collateral: BalanceOf<T, I>) -> u32 {
(collateral / T::CollateralPerOrder::get()).saturated_into::<u32>()
let collateral_per_order = T::CollateralPerOrder::get();

if collateral_per_order.is_zero() {
0
} else {
(collateral / collateral_per_order).saturated_into::<u32>()
}
}
}

Expand Down

0 comments on commit fa2d416

Please sign in to comment.