From 39b9a44e1936c0dd27bff7c50c0cb14cfa0f67ed Mon Sep 17 00:00:00 2001 From: Omer Yacine Date: Sat, 27 Apr 2024 14:19:36 +0200 Subject: [PATCH] add fixmes, amend me --- mm2src/coins/utxo/utxo_common.rs | 11 ++++++++++ mm2src/mm2_main/src/lp_swap.rs | 1 + mm2src/mm2_main/src/lp_swap/taker_swap_v2.rs | 21 ++++++++++++++------ 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/mm2src/coins/utxo/utxo_common.rs b/mm2src/coins/utxo/utxo_common.rs index 25567fde452..a7cfc25c79f 100644 --- a/mm2src/coins/utxo/utxo_common.rs +++ b/mm2src/coins/utxo/utxo_common.rs @@ -1427,6 +1427,7 @@ pub async fn validate_taker_funding_spend_preimage( let fee_div = expected_fee as f64 / actual_fee as f64; + // FIXME: Should negotiate the fee beforehand, accept fee >= negotiated_fee if !(0.9..=1.1).contains(&fee_div) { return MmError::err(ValidateTakerFundingSpendPreimageError::UnexpectedPreimageFee(format!( "Too large difference between expected {} and actual {} fees", @@ -4202,6 +4203,9 @@ pub fn get_trade_fee(coin: T) -> Box taker payment -> preimage (to the maker & dex) + // Chain B: maker payment -> claimation (to the taker) + // FIXME: Add taker payment fee + preimage fee + // Qs: + // 1- Who pays the maker payment fee? Take in considration that a nicer UX would be to hand the taker the full amount they requested. (so account for maker payment fee and taker claimation fee) let total_amount = &args.dex_fee.total_spend_amount().to_decimal() + &args.premium_amount + &args.trading_amount; let SwapPaymentOutputsResult { diff --git a/mm2src/mm2_main/src/lp_swap.rs b/mm2src/mm2_main/src/lp_swap.rs index c4b7a405a0a..149134671be 100644 --- a/mm2src/mm2_main/src/lp_swap.rs +++ b/mm2src/mm2_main/src/lp_swap.rs @@ -766,6 +766,7 @@ pub fn lp_atomic_locktime_v2( if taker_coin.contains("-lightning") { // A good value for lightning taker locktime is about 24 hours to find a good 3 hop or less path for the payment get_payment_locktime() * 12 + // FIXME: Shouldn't BTC get x10 time, like in V1? } else if maker_coin == "BTC" || taker_coin == "BTC" || coin_with_4x_locktime(maker_coin) diff --git a/mm2src/mm2_main/src/lp_swap/taker_swap_v2.rs b/mm2src/mm2_main/src/lp_swap/taker_swap_v2.rs index 77b34e476f6..42eb7631b48 100644 --- a/mm2src/mm2_main/src/lp_swap/taker_swap_v2.rs +++ b/mm2src/mm2_main/src/lp_swap/taker_swap_v2.rs @@ -793,11 +793,7 @@ impl { + TakerSwapEvent::Initialized { taker_payment_fee, .. } => { let swaps_ctx = SwapsContext::from_ctx(&self.ctx).expect("from_ctx should not fail at this point"); let taker_coin_ticker: String = self.taker_coin.ticker().into(); let new_locked = LockedAmountInfo { @@ -923,11 +919,14 @@ impl TransitionFrom> for TakerPaymentSent { } + +// FIXME: We should use consistent namings. FundingSpendPreimage is a partially signed TakerPayment. +// We should either call FundingSpendPreimage -> TakerPaymentPreimage or we call TakerPayment -> FundingSpend. impl TransitionFrom> for TakerPaymentSent