Skip to content
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
20 changes: 18 additions & 2 deletions mm2src/coins/utxo/utxo_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading