diff --git a/mm2src/coins/utxo/utxo_common.rs b/mm2src/coins/utxo/utxo_common.rs index 3bdca4f103..842d9e65cd 100644 --- a/mm2src/coins/utxo/utxo_common.rs +++ b/mm2src/coins/utxo/utxo_common.rs @@ -3416,8 +3416,24 @@ pub fn min_tx_amount(coin: &UtxoCoinFields) -> BigDecimal { } pub fn min_trading_vol(coin: &UtxoCoinFields) -> MmNumber { - let dust_multiplier = MmNumber::from(10); - dust_multiplier * min_tx_amount(coin).into() + let min_from_dust = coin.dust_amount * 10; + + let fixed_fee_rate = match coin.tx_fee { + FeeRate::FixedPerKb(sats) => Some(ActualFeeRate::FixedPerKb(sats)), + FeeRate::FixedPerKbDingo(sats) => Some(ActualFeeRate::FixedPerKbDingo(sats)), + // The output of this function must be deterministic for the lifetime of + // an order / swap, we will use the dust-based calculation. + FeeRate::Dynamic(_) => None, + }; + + let min_from_fee = fixed_fee_rate.map_or(min_from_dust, |fee_rate| { + fee_rate.get_tx_fee(DEFAULT_SWAP_TX_SPEND_SIZE) * 10 + }); + + // The final minimum volume must be large enough to satisfy both the dust and the fee constraints. + let min_vol_sats = std::cmp::max(min_from_dust, min_from_fee); + + big_decimal_from_sat_unsigned(min_vol_sats, coin.decimals).into() } pub fn is_asset_chain(coin: &UtxoCoinFields) -> bool {