Skip to content

Commit 4a9f247

Browse files
committed
don't fail on zero fee rate
1 parent 558b538 commit 4a9f247

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

asset-registry/src/lib.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,12 @@ impl<W: WeightToFeeConverter, R: TakeRevenue> WeightTrader for AssetRegistryTrad
248248

249249
if let Some(amount) = W::convert_weight_to_fee(location, new_weight) {
250250
let fee_increase = amount.saturating_sub(existing_fee);
251-
if let Ok(unused) = payment.clone().checked_sub((asset.clone(), fee_increase).into()) {
251+
if fee_increase == 0 {
252+
// if the fee is set very low it lead to zero fees, in which case constructing
253+
// the fee asset item to subtract from payment would fail. Therefore, provide
254+
// early exit
255+
return Ok(payment);
256+
} else if let Ok(unused) = payment.clone().checked_sub((asset.clone(), fee_increase).into()) {
252257
self.bought_weight = Some(BoughtWeight {
253258
amount,
254259
weight: new_weight,

0 commit comments

Comments
 (0)