Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
cea1b2f
fix UtxoTxBuilder::build() tx fee calculation to include change output;
Jan 8, 2025
455403c
Merge branch 'dev' into fix-utxo-tx-fee-for-change
Jan 8, 2025
8d2fe79
fix qrc20 gas fee calc in trade preimage
Jan 9, 2025
bc69a42
revert qtum gas_fee calc in trade preimage,
Jan 9, 2025
40cfbda
fix: err if change < dust (was <=)
Jan 23, 2025
50a38f8
refactor (onur-ozkan): use refs instead of clone in add_tx_inputs
Jan 23, 2025
615ff3e
refactor (mariocynicys): fix return_err_if macro to check if cond is …
Jan 23, 2025
3f709fc
refactor: rename vars to use always 'fee rate' root word
Jan 23, 2025
459a379
fix (mariocynicys): recalc kmd interest when tx inputs reselected and…
Feb 24, 2025
534006e
Merge branch 'dev' into fix-utxo-tx-fee-for-change
Feb 24, 2025
ad0699e
fix after merge
Feb 24, 2025
1b2c538
refactor (mariocynicys) removed unnecessary checks
Feb 24, 2025
110a236
fix fee_amount in AdditionalTxData, get rid of unused_change, add reu…
Feb 25, 2025
b5994e6
add extra test to check tx builder calc with many inputs
Feb 25, 2025
ae8c3ee
remove unused_change in utxo tx builder (var not used any more)
Mar 4, 2025
9126c49
fix utxo tx builder test: add randomizer, catch overpay
Mar 6, 2025
997dcee
Merge remote-tracking branch 'origin/dev' into fix-utxo-tx-fee-for-ch…
shamardy Mar 24, 2025
de945e6
fix: remove txsize round up (for old doge support)
Mar 24, 2025
de206b5
add DINGO txfee coin param
Mar 24, 2025
8a0ba28
revert 'txfee' coin param to number, add 'dingo_fee' bool param
Mar 24, 2025
529815f
fix txfee config parse with empty dingo_fee
Mar 24, 2025
53ce954
fix utxo tests for the updated 'no-doge' tx fee calculation
Mar 25, 2025
201648e
fix tx fee for change calc for no dingo coins
Mar 27, 2025
0bb1756
fix partially tests broken due to fee fix
Mar 29, 2025
49fa8e9
dont start non utxo containers
Mar 29, 2025
c2715d0
TODO trade preimage error and more test fix
Mar 29, 2025
fb555b6
dont pull non utxo images
Mar 29, 2025
caefe5d
more tests
Mar 29, 2025
6707f8c
fix test
Mar 29, 2025
c4550a5
more tests fixed
Mar 31, 2025
5619e8f
add new stages to FeeApproxStage enum to calc max volume for utxo and…
Mar 31, 2025
ca3bc0e
fix more tests
Mar 31, 2025
474d3ec
fixed more tests
Apr 1, 2025
027a6e0
fix fee approx stages
Apr 1, 2025
20bd99f
more tests fixed
Apr 1, 2025
06fe4ec
eth tests approx fee fixed
Apr 1, 2025
385cf3d
fix qrc20 test max fee
Apr 1, 2025
5a880da
fix buy test const
Apr 1, 2025
6644f13
clean up debug logs
Apr 2, 2025
a1ef11a
add env vars to disable selected docker containers
Apr 2, 2025
0343492
outdated comment removed
Apr 6, 2025
864b5b0
Merge branch 'dev' into fix-utxo-tx-fee-no-doge
May 13, 2025
8c18b8d
Merge remote-tracking branch 'origin/dev' into fix-utxo-tx-fee-no-doge
shamardy Jun 13, 2025
438df3c
Merge branch 'dev' into fix-utxo-tx-fee-no-doge
Jun 27, 2025
ad1cdf4
fix expected in tests due to DEFAULT_SWAP_TX_SPEND_SIZE changed to 496
Jun 28, 2025
11f75a5
restore envs to disable docker containers
Jun 28, 2025
a9b872f
test: make docker containers all start before use
Jun 28, 2025
6bd2a17
Merge branch 'dev' into fix-utxo-tx-fee-no-doge
Jul 13, 2025
a1f09ed
Merge branch 'dev' into fix-utxo-tx-fee-no-doge
shamardy Jul 30, 2025
be6cf93
fix expected balance in test_electrum_tx_history
Jul 30, 2025
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
9 changes: 4 additions & 5 deletions mm2src/coins/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5987,7 +5987,6 @@ impl MmCoin for EthCoin {
&self,
value: TradePreimageValue,
stage: FeeApproxStage,
include_refund_fee: bool,
) -> TradePreimageResult<TradeFee> {
let pay_for_gas_option = self
.get_swap_pay_for_gas_option(self.get_swap_transaction_fee_policy())
Expand All @@ -5997,7 +5996,7 @@ impl MmCoin for EthCoin {
let gas_limit = match self.coin_type {
EthCoinType::Eth => {
// this gas_limit includes gas for `ethPayment` and optionally `senderRefund` contract calls
if include_refund_fee {
if matches!(stage, FeeApproxStage::OrderIssueMax | FeeApproxStage::TradePreimageMax) {
U256::from(self.gas_limit.eth_payment) + U256::from(self.gas_limit.eth_sender_refund)
} else {
U256::from(self.gas_limit.eth_payment)
Expand Down Expand Up @@ -6027,7 +6026,7 @@ impl MmCoin for EthCoin {
gas += approve_gas_limit;
}
// add 'senderRefund' gas if requested
if include_refund_fee {
if matches!(stage, FeeApproxStage::TradePreimage | FeeApproxStage::TradePreimageMax) {
gas += U256::from(self.gas_limit.erc20_sender_refund);
}
gas
Expand Down Expand Up @@ -6808,10 +6807,10 @@ fn increase_gas_price_by_stage(pay_for_gas_option: PayForGasOption, level: &FeeA
FeeApproxStage::StartSwap => {
increase_by_percent_one_gwei(gas_price, GAS_PRICE_APPROXIMATION_PERCENT_ON_START_SWAP)
},
FeeApproxStage::OrderIssue => {
FeeApproxStage::OrderIssue | FeeApproxStage::OrderIssueMax => {
increase_by_percent_one_gwei(gas_price, GAS_PRICE_APPROXIMATION_PERCENT_ON_ORDER_ISSUE)
},
FeeApproxStage::TradePreimage => {
FeeApproxStage::TradePreimage | FeeApproxStage::TradePreimageMax => {
increase_by_percent_one_gwei(gas_price, GAS_PRICE_APPROXIMATION_PERCENT_ON_TRADE_PREIMAGE)
},
FeeApproxStage::WatcherPreimage => {
Expand Down
58 changes: 19 additions & 39 deletions mm2src/coins/eth/eth_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,34 +331,26 @@ fn get_sender_trade_preimage() {
let actual = block_on(coin.get_sender_trade_fee(
TradePreimageValue::UpperBound(150.into()),
FeeApproxStage::WithoutApprox,
true,
))
.expect("!get_sender_trade_fee");
let expected = expected_fee(GAS_PRICE, gas_limit::ETH_PAYMENT + gas_limit::ETH_SENDER_REFUND);
let expected = expected_fee(GAS_PRICE, gas_limit::ETH_PAYMENT);
assert_eq!(actual, expected);

let value = u256_to_big_decimal(100.into(), 18).expect("!u256_to_big_decimal");
let actual =
block_on(coin.get_sender_trade_fee(TradePreimageValue::Exact(value), FeeApproxStage::OrderIssue, true))
.expect("!get_sender_trade_fee");
let expected = expected_fee(
GAS_PRICE_APPROXIMATION_ON_ORDER_ISSUE,
gas_limit::ETH_PAYMENT + gas_limit::ETH_SENDER_REFUND,
);
let actual = block_on(coin.get_sender_trade_fee(TradePreimageValue::Exact(value), FeeApproxStage::OrderIssue))
.expect("!get_sender_trade_fee");
let expected = expected_fee(GAS_PRICE_APPROXIMATION_ON_ORDER_ISSUE, gas_limit::ETH_PAYMENT);
assert_eq!(actual, expected);

let value = u256_to_big_decimal(1.into(), 18).expect("!u256_to_big_decimal");
let actual = block_on(coin.get_sender_trade_fee(TradePreimageValue::Exact(value), FeeApproxStage::StartSwap, true))
let actual = block_on(coin.get_sender_trade_fee(TradePreimageValue::Exact(value), FeeApproxStage::StartSwap))
.expect("!get_sender_trade_fee");
let expected = expected_fee(
GAS_PRICE_APPROXIMATION_ON_START_SWAP,
gas_limit::ETH_PAYMENT + gas_limit::ETH_SENDER_REFUND,
);
let expected = expected_fee(GAS_PRICE_APPROXIMATION_ON_START_SWAP, gas_limit::ETH_PAYMENT);
assert_eq!(actual, expected);

let value = u256_to_big_decimal(10000000000u64.into(), 18).expect("!u256_to_big_decimal");
let actual =
block_on(coin.get_sender_trade_fee(TradePreimageValue::Exact(value), FeeApproxStage::TradePreimage, true))
block_on(coin.get_sender_trade_fee(TradePreimageValue::Exact(value), FeeApproxStage::TradePreimageMax))
.expect("!get_sender_trade_fee");
let expected = expected_fee(
GAS_PRICE_APPROXIMATION_ON_TRADE_PREIMAGE,
Expand Down Expand Up @@ -405,58 +397,46 @@ fn get_erc20_sender_trade_preimage() {
// value is allowed
unsafe { ALLOWANCE = 1000 };
let value = u256_to_big_decimal(1000.into(), 18).expect("u256_to_big_decimal");
let actual = block_on(coin.get_sender_trade_fee(
TradePreimageValue::UpperBound(value),
FeeApproxStage::WithoutApprox,
true,
))
.expect("!get_sender_trade_fee");
let actual =
block_on(coin.get_sender_trade_fee(TradePreimageValue::UpperBound(value), FeeApproxStage::WithoutApprox))
.expect("!get_sender_trade_fee");
log!("{:?}", actual.amount.to_decimal());
unsafe { assert!(!ESTIMATE_GAS_CALLED) }
assert_eq!(
actual,
expected_trade_fee(gas_limit::ERC20_PAYMENT + gas_limit::ERC20_SENDER_REFUND, GAS_PRICE)
);
assert_eq!(actual, expected_trade_fee(gas_limit::ERC20_PAYMENT, GAS_PRICE));

// value is greater than allowance
unsafe { ALLOWANCE = 999 };
let value = u256_to_big_decimal(1000.into(), 18).expect("u256_to_big_decimal");
let actual =
block_on(coin.get_sender_trade_fee(TradePreimageValue::UpperBound(value), FeeApproxStage::StartSwap, true))
.expect("!get_sender_trade_fee");
let actual = block_on(coin.get_sender_trade_fee(TradePreimageValue::UpperBound(value), FeeApproxStage::StartSwap))
.expect("!get_sender_trade_fee");
unsafe {
assert!(ESTIMATE_GAS_CALLED);
ESTIMATE_GAS_CALLED = false;
}
assert_eq!(
actual,
expected_trade_fee(
gas_limit::ERC20_PAYMENT + gas_limit::ERC20_SENDER_REFUND + APPROVE_GAS_LIMIT,
gas_limit::ERC20_PAYMENT + APPROVE_GAS_LIMIT,
GAS_PRICE_APPROXIMATION_ON_START_SWAP
)
);

// value is allowed
unsafe { ALLOWANCE = 1000 };
let value = u256_to_big_decimal(999.into(), 18).expect("u256_to_big_decimal");
let actual =
block_on(coin.get_sender_trade_fee(TradePreimageValue::Exact(value), FeeApproxStage::OrderIssue, true))
.expect("!get_sender_trade_fee");
let actual = block_on(coin.get_sender_trade_fee(TradePreimageValue::Exact(value), FeeApproxStage::OrderIssue))
.expect("!get_sender_trade_fee");
unsafe { assert!(!ESTIMATE_GAS_CALLED) }
assert_eq!(
actual,
expected_trade_fee(
gas_limit::ERC20_PAYMENT + gas_limit::ERC20_SENDER_REFUND,
GAS_PRICE_APPROXIMATION_ON_ORDER_ISSUE
)
expected_trade_fee(gas_limit::ERC20_PAYMENT, GAS_PRICE_APPROXIMATION_ON_ORDER_ISSUE)
);

// value is greater than allowance
unsafe { ALLOWANCE = 1000 };
let value = u256_to_big_decimal(1500.into(), 18).expect("u256_to_big_decimal");
let actual =
block_on(coin.get_sender_trade_fee(TradePreimageValue::Exact(value), FeeApproxStage::TradePreimage, true))
.expect("!get_sender_trade_fee");
let actual = block_on(coin.get_sender_trade_fee(TradePreimageValue::Exact(value), FeeApproxStage::TradePreimage))
.expect("!get_sender_trade_fee");
unsafe {
assert!(ESTIMATE_GAS_CALLED);
ESTIMATE_GAS_CALLED = false;
Expand Down
1 change: 0 additions & 1 deletion mm2src/coins/lightning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,6 @@ impl MmCoin for LightningCoin {
&self,
_value: TradePreimageValue,
_stage: FeeApproxStage,
_include_refund_fee: bool,
) -> TradePreimageResult<TradeFee> {
Ok(TradeFee {
coin: self.ticker().to_owned(),
Expand Down
10 changes: 8 additions & 2 deletions mm2src/coins/lp_coins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2627,6 +2627,7 @@ impl TransactionDetails {
}
}

/// Transaction fee to pay for swap transactions (could be total for two transactions: taker fee and payment fee txns)
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct TradeFee {
pub coin: String,
Expand Down Expand Up @@ -2712,6 +2713,8 @@ impl AddAssign for CoinBalance {
}

/// The approximation is needed to cover the dynamic miner fee changing during a swap.
/// Also used to indicate refund fee is needed for eth
/// Also used to indicate utxo fee correction is needed due to a possible change output
#[derive(Clone, Copy, Debug)]
pub enum FeeApproxStage {
/// Do not increase the trade fee.
Expand All @@ -2722,8 +2725,12 @@ pub enum FeeApproxStage {
WatcherPreimage,
/// Increase the trade fee significantly.
OrderIssue,
/// Increase the trade fee largely.
/// Increase the trade fee significantly (used to calculate max volume).
OrderIssueMax,
/// Increase the trade fee largely in the trade_preimage rpc.
TradePreimage,
/// Increase the trade fee in the trade_preimage rpc (used to calculate max volume for trade preimage).
TradePreimageMax,
}

#[derive(Debug)]
Expand Down Expand Up @@ -3622,7 +3629,6 @@ pub trait MmCoin: SwapOps + WatcherOps + MarketCoinOps + Send + Sync + 'static {
&self,
value: TradePreimageValue,
stage: FeeApproxStage,
include_refund_fee: bool,
) -> TradePreimageResult<TradeFee>;

/// Get fee to be paid by receiver per whole swap and check if the wallet has sufficient balance to pay the fee.
Expand Down
7 changes: 4 additions & 3 deletions mm2src/coins/qrc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,9 @@ impl Qrc20Coin {
/// or should be sum of gas fee of all contract calls.
pub async fn get_qrc20_tx_fee(&self, gas_fee: u64) -> Result<u64, String> {
match try_s!(self.get_fee_rate().await) {
ActualFeeRate::Dynamic(amount) | ActualFeeRate::FixedPerKb(amount) => Ok(amount + gas_fee),
ActualFeeRate::Dynamic(amount)
| ActualFeeRate::FixedPerKb(amount)
| ActualFeeRate::FixedPerKbDingo(amount) => Ok(amount + gas_fee),
}
}

Expand Down Expand Up @@ -1289,7 +1291,6 @@ impl MmCoin for Qrc20Coin {
&self,
value: TradePreimageValue,
stage: FeeApproxStage,
include_refund_fee: bool,
) -> TradePreimageResult<TradeFee> {
let decimals = self.utxo.decimals;
// pass the dummy params
Expand Down Expand Up @@ -1323,7 +1324,7 @@ impl MmCoin for Qrc20Coin {
};

// Optionally calculate refund fee.
let sender_refund_fee = if include_refund_fee {
let sender_refund_fee = if matches!(stage, FeeApproxStage::TradePreimage | FeeApproxStage::TradePreimageMax) {
let sender_refund_output = self
.sender_refund_output(&self.swap_contract_address, swap_id, value, secret_hash, receiver_addr)
.map_mm_err()?;
Expand Down
70 changes: 38 additions & 32 deletions mm2src/coins/qrc20/qrc20_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ cfg_native!(
use mocktopus::mocking::{MockResult, Mockable};
);

const EXPECTED_TX_FEE: i64 = 1000;
const DEFAULT_TX_FEE_RATE: i64 = 1000;
const CONTRACT_CALL_GAS_FEE: i64 = (QRC20_GAS_LIMIT_DEFAULT * QRC20_GAS_PRICE_DEFAULT) as i64;
const SWAP_PAYMENT_GAS_FEE: i64 = (QRC20_PAYMENT_GAS_LIMIT * QRC20_GAS_PRICE_DEFAULT) as i64;
const TAKER_PAYMENT_SPEND_SEARCH_INTERVAL: f64 = 1.;
Expand Down Expand Up @@ -59,9 +59,9 @@ pub fn qrc20_coin_for_test(priv_key: [u8; 32], fallback_swap: Option<&str>) -> (
(ctx, coin)
}

fn check_tx_fee(coin: &Qrc20Coin, expected_tx_fee: ActualFeeRate) {
let actual_tx_fee = block_on(coin.get_fee_rate()).unwrap();
assert_eq!(actual_tx_fee, expected_tx_fee);
fn check_fee_rate(coin: &Qrc20Coin, expected_fee_rate: ActualFeeRate) {
let actual_fee_rate = block_on(coin.get_fee_rate()).unwrap();
assert_eq!(actual_fee_rate, expected_fee_rate);
}

#[cfg(not(target_arch = "wasm32"))]
Expand Down Expand Up @@ -144,7 +144,7 @@ fn test_withdraw_impl_fee_details() {
// 1000 from satoshi,
// where decimals = 8,
// 1000 is fixed fee
"miner_fee": "0.00001",
"miner_fee": "0.00000299",
"gas_limit": 2_500_000,
"gas_price": 40,
// (gas_limit * gas_price) from satoshi in Qtum
Expand Down Expand Up @@ -715,12 +715,12 @@ fn test_get_trade_fee() {
172, 110, 180, 13, 123, 179, 10, 49,
];
let (_ctx, coin) = qrc20_coin_for_test(priv_key, None);
// check if the coin's tx fee is expected
check_tx_fee(&coin, ActualFeeRate::FixedPerKb(EXPECTED_TX_FEE as u64));
// check if the coin's tx fee rate is expected
check_fee_rate(&coin, ActualFeeRate::FixedPerKb(DEFAULT_TX_FEE_RATE as u64));

let actual_trade_fee = block_on_f01(coin.get_trade_fee()).unwrap();
let expected_trade_fee_amount = big_decimal_from_sat(
2 * CONTRACT_CALL_GAS_FEE + SWAP_PAYMENT_GAS_FEE + EXPECTED_TX_FEE,
2 * CONTRACT_CALL_GAS_FEE + SWAP_PAYMENT_GAS_FEE + DEFAULT_TX_FEE_RATE,
coin.utxo.decimals,
);
let expected = TradeFee {
Expand All @@ -742,20 +742,22 @@ fn test_sender_trade_preimage_zero_allowance() {
231, 153, 202, 20, 238, 120, 64,
];
let (_ctx, coin) = qrc20_coin_for_test(priv_key, None);
// check if the coin's tx fee is expected
check_tx_fee(&coin, ActualFeeRate::FixedPerKb(EXPECTED_TX_FEE as u64));
const EXPECTED_PAYMENT_TX_FEE: i64 = 535;
const EXPECTED_REFUND_TX_FEE: i64 = 396;
// check if the coin's tx fee rate is expected
check_fee_rate(&coin, ActualFeeRate::FixedPerKb(DEFAULT_TX_FEE_RATE as u64));

let allowance = block_on(coin.allowance(coin.swap_contract_address)).expect("!allowance");
assert_eq!(allowance, 0.into());

let erc20_payment_fee_with_one_approve = big_decimal_from_sat(
CONTRACT_CALL_GAS_FEE + SWAP_PAYMENT_GAS_FEE + EXPECTED_TX_FEE,
CONTRACT_CALL_GAS_FEE + SWAP_PAYMENT_GAS_FEE + EXPECTED_PAYMENT_TX_FEE,
coin.utxo.decimals,
);
let sender_refund_fee = big_decimal_from_sat(CONTRACT_CALL_GAS_FEE + EXPECTED_TX_FEE, coin.utxo.decimals);
let sender_refund_fee = big_decimal_from_sat(CONTRACT_CALL_GAS_FEE + EXPECTED_REFUND_TX_FEE, coin.utxo.decimals);

let actual =
block_on(coin.get_sender_trade_fee(TradePreimageValue::Exact(1.into()), FeeApproxStage::WithoutApprox, true))
block_on(coin.get_sender_trade_fee(TradePreimageValue::Exact(1.into()), FeeApproxStage::TradePreimageMax)) // pass TradePreimageMax to add change output txfee, to correct the max vol calc
.expect("!get_sender_trade_fee");
// one `approve` contract call should be included into the expected trade fee
let expected = TradeFee {
Expand All @@ -778,24 +780,28 @@ fn test_sender_trade_preimage_with_allowance() {
143, 221, 19, 47, 74, 175, 100,
];
let (_ctx, coin) = qrc20_coin_for_test(priv_key, None);
// check if the coin's tx fee is expected
check_tx_fee(&coin, ActualFeeRate::FixedPerKb(EXPECTED_TX_FEE as u64));
const EXPECTED_PAYMENT_WITHOUT_APPROVE_TX_FEE: i64 = 576;
const EXPECTED_PAYMENT_WITH_APPROVES_TX_FEE: i64 = 790;
const EXPECTED_REFUND_TX_FEE: i64 = 544;
// check if the coin's tx fee rate is expected
check_fee_rate(&coin, ActualFeeRate::FixedPerKb(DEFAULT_TX_FEE_RATE as u64));

let allowance = block_on(coin.allowance(coin.swap_contract_address)).expect("!allowance");
assert_eq!(allowance, 300_000_000.into());

let erc20_payment_fee_without_approve =
big_decimal_from_sat(SWAP_PAYMENT_GAS_FEE + EXPECTED_TX_FEE, coin.utxo.decimals);
let erc20_payment_fee_without_approve = big_decimal_from_sat(
SWAP_PAYMENT_GAS_FEE + EXPECTED_PAYMENT_WITHOUT_APPROVE_TX_FEE,
coin.utxo.decimals,
);
let erc20_payment_fee_with_two_approves = big_decimal_from_sat(
2 * CONTRACT_CALL_GAS_FEE + SWAP_PAYMENT_GAS_FEE + EXPECTED_TX_FEE,
2 * CONTRACT_CALL_GAS_FEE + SWAP_PAYMENT_GAS_FEE + EXPECTED_PAYMENT_WITH_APPROVES_TX_FEE,
coin.utxo.decimals,
);
let sender_refund_fee = big_decimal_from_sat(CONTRACT_CALL_GAS_FEE + EXPECTED_TX_FEE, coin.utxo.decimals);
let sender_refund_fee = big_decimal_from_sat(CONTRACT_CALL_GAS_FEE + EXPECTED_REFUND_TX_FEE, coin.utxo.decimals);

let actual = block_on(coin.get_sender_trade_fee(
TradePreimageValue::Exact(BigDecimal::try_from(2.5).unwrap()),
FeeApproxStage::WithoutApprox,
true,
FeeApproxStage::TradePreimageMax,
))
.expect("!get_sender_trade_fee");
// the expected fee should not include any `approve` contract call
Expand All @@ -808,8 +814,7 @@ fn test_sender_trade_preimage_with_allowance() {

let actual = block_on(coin.get_sender_trade_fee(
TradePreimageValue::Exact(BigDecimal::try_from(3.5).unwrap()),
FeeApproxStage::WithoutApprox,
true,
FeeApproxStage::TradePreimageMax,
))
.expect("!get_sender_trade_fee");
// two `approve` contract calls should be included into the expected trade fee
Expand Down Expand Up @@ -865,11 +870,10 @@ fn test_get_sender_trade_fee_preimage_for_correct_ticker() {
))
.unwrap();

let actual =
block_on(coin.get_sender_trade_fee(TradePreimageValue::Exact(0.into()), FeeApproxStage::OrderIssue, true))
.err()
.unwrap()
.into_inner();
let actual = block_on(coin.get_sender_trade_fee(TradePreimageValue::Exact(0.into()), FeeApproxStage::OrderIssue))
.err()
.unwrap()
.into_inner();
// expecting TradePreimageError::NotSufficientBalance
let expected = TradePreimageError::NotSufficientBalance {
coin: "tQTUM".to_string(),
Expand All @@ -889,8 +893,9 @@ fn test_receiver_trade_preimage() {
143, 221, 19, 47, 74, 175, 100,
];
let (_ctx, coin) = qrc20_coin_for_test(priv_key, None);
// check if the coin's tx fee is expected
check_tx_fee(&coin, ActualFeeRate::FixedPerKb(EXPECTED_TX_FEE as u64));
const EXPECTED_TX_FEE: i64 = 544;
// check if the coin's tx fee rate is expected
check_fee_rate(&coin, ActualFeeRate::FixedPerKb(DEFAULT_TX_FEE_RATE as u64));

let actual =
block_on_f01(coin.get_receiver_trade_fee(FeeApproxStage::WithoutApprox)).expect("!get_receiver_trade_fee");
Expand All @@ -914,8 +919,9 @@ fn test_taker_fee_tx_fee() {
143, 221, 19, 47, 74, 175, 100,
];
let (_ctx, coin) = qrc20_coin_for_test(priv_key, None);
// check if the coin's tx fee is expected
check_tx_fee(&coin, ActualFeeRate::FixedPerKb(EXPECTED_TX_FEE as u64));
const EXPECTED_TX_FEE: i64 = 447;
// check if the coin's tx fee rate is expected
check_fee_rate(&coin, ActualFeeRate::FixedPerKb(DEFAULT_TX_FEE_RATE as u64));
let expected_balance = CoinBalance {
spendable: BigDecimal::from(5u32),
unspendable: BigDecimal::from(0u32),
Expand Down
1 change: 0 additions & 1 deletion mm2src/coins/siacoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ impl MmCoin for SiaCoin {
&self,
_value: TradePreimageValue,
_stage: FeeApproxStage,
_include_refund_fee: bool,
) -> TradePreimageResult<TradeFee> {
unimplemented!()
}
Expand Down
Loading
Loading