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

Handle Zero CollateralPerOrder #176

Merged
merged 3 commits into from
Aug 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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