fix(utxo): calculate min_trading_vol based on fixed tx fees#2564
fix(utxo): calculate min_trading_vol based on fixed tx fees#2564
Conversation
Adds support for the `FeeRate::FixedPerKbDingo` case, which was introduced in a recent merge. Refactored the logic to handle all fixed-fee variants idiomatically.
cipig
left a comment
There was a problem hiding this comment.
default min_vol for ZEC before this PR was 0.0001, now it is 0.00496 (0.0496 for RVN)... idk how the 0.00496 is calculated, but trading exactly that min_volume works fine
makerpaymentspent: https://blockchair.com/zcash/transaction/24715490971e72a2f9a438f61cc4d93464a6241bde268707c69b61d71c4b08ff (got 0.004464 ZEC and payed 0.000496 ZEC txfee)
the default min_volume for dynamic fee coins, like LTC, is the same as before... 0.000546 LTC (= 10x dust)
minimum trading volume is now |
There was a problem hiding this comment.
Recalculated volumes sighted for UTXO coins as below. Non-UTXO included for reference / regression testing. Values compare dev branch responses to this branch.
[
{
"min_trading_vol": "0.0001",
"min_trading_vol_AFTER": "0.0001",
"ticker": "ARRR"
},
{
"ticker": "DOGE",,
"min_trading_vol": "0.1",
"min_trading_vol_AFTER": "0.1"
},
{
"min_trading_vol": "0.000000000000000001",
"min_trading_vol_AFTER": "0.000000000000000001",
"ticker": "MATIC"
},
{
"ticker": "ATOM"
"min_trading_vol": "0.000001",
"min_trading_vol_AFTER": "0.000001",
},
{
"min_trading_vol": "0.0001",
"min_trading_vol_AFTER": "0.0496",
"ticker": "RVN"
},
{
"min_trading_vol": "0.000546",
"min_trading_vol_AFTER": "0.000546",
"ticker": "LTC"
}
]* dev: fix(Trezor): fix utxo and eth calls due to firmware changes (#2565) fix(utxo): calculate min_trading_vol based on fixed tx fees (#2564) feat(protocol): [0] solana support (#2586) fix(utxo): fix header deserialization; guard AuxPoW (#2583) chore(rust 1.89): make CI clippy/fmt pass (wasm32, all-targets) (#2581) fix(utxo): deserialize sapling root for PIVX block headers (#2572) improvement(dep-stack): security bumps (#2562) # Conflicts: # mm2src/mm2_main/tests/docker_tests/eth_docker_tests.rs
* dev: fix(ordermatch): ignore loop-back; clear on null root; reject stale keep-alives (#2580) fix(clippy): fix clippy warnings for #2565 (#2589) fix(Trezor): fix utxo and eth calls due to firmware changes (#2565) fix(utxo): calculate min_trading_vol based on fixed tx fees (#2564) feat(protocol): [0] solana support (#2586) fix(utxo): fix header deserialization; guard AuxPoW (#2583) chore(rust 1.89): make CI clippy/fmt pass (wasm32, all-targets) (#2581) fix(utxo): deserialize sapling root for PIVX block headers (#2572) improvement(dep-stack): security bumps (#2562) fix(utxo): correct block header deserialization for AuxPow and KAWPOW coins (#2563)
* dev: (24 commits) fix(ordermatch): ignore loop-back; clear on null root; reject stale keep-alives (#2580) fix(clippy): fix clippy warnings for #2565 (#2589) fix(Trezor): fix utxo and eth calls due to firmware changes (#2565) fix(utxo): calculate min_trading_vol based on fixed tx fees (#2564) feat(protocol): [0] solana support (#2586) fix(utxo): fix header deserialization; guard AuxPoW (#2583) chore(rust 1.89): make CI clippy/fmt pass (wasm32, all-targets) (#2581) fix(utxo): deserialize sapling root for PIVX block headers (#2572) improvement(dep-stack): security bumps (#2562) fix(utxo): correct block header deserialization for AuxPow and KAWPOW coins (#2563) feat(wallet-connect): impl BTC (UTxO) activation via WalletConnect (#2499) feat(utxo): add new fixed txfee option for DINGO-like coins (#2454) ci(pull-requests): review notification bot (#2468) improvement(walletconnect): return the `pairing_topic` in `new_connection` response (#2538) bless clippy (#2560) refactor(toolchain): use latest available stable compiler (#2557) feat(wallet): implement unified offline private key export API (#2542) improve note for docker test start failure (#2550) fix(DOCS): add note for macos to fix docker containers startup failure (#2544) refactor(toolchain): general stabilization for stable rust (#2528) ... # Conflicts: # mm2src/coins/eth.rs # mm2src/coins/eth/eth_swap_v2/eth_maker_swap_v2.rs # mm2src/coins/eth/eth_swap_v2/eth_taker_swap_v2.rs # mm2src/coins/eth/eth_tests.rs # mm2src/coins/eth/eth_withdraw.rs # mm2src/coins/eth/v2_activation.rs # mm2src/coins/nft.rs # mm2src/coins/qrc20.rs # mm2src/mm2_main/src/rpc/dispatcher/dispatcher.rs # mm2src/mm2_main/src/rpc/lp_commands/one_inch/rpcs.rs # mm2src/mm2_main/src/rpc/lp_commands/tokens.rs # mm2src/mm2_main/tests/docker_tests/eth_docker_tests.rs
* dev: improvement(`static mut`s): `static mut` removal (#2590) fix(orders): set subscription on kickstart and skip GC of own pubkeys (#2597) fix(ordermatch): ignore loop-back; clear on null root; reject stale keep-alives (#2580) fix(clippy): fix clippy warnings for #2565 (#2589) fix(Trezor): fix utxo and eth calls due to firmware changes (#2565) fix(utxo): calculate min_trading_vol based on fixed tx fees (#2564) feat(protocol): [0] solana support (#2586) fix(utxo): fix header deserialization; guard AuxPoW (#2583) chore(rust 1.89): make CI clippy/fmt pass (wasm32, all-targets) (#2581) fix(utxo): deserialize sapling root for PIVX block headers (#2572) improvement(dep-stack): security bumps (#2562) fix(utxo): correct block header deserialization for AuxPow and KAWPOW coins (#2563) feat(wallet-connect): impl BTC (UTxO) activation via WalletConnect (#2499) feat(utxo): add new fixed txfee option for DINGO-like coins (#2454) ci(pull-requests): review notification bot (#2468) improvement(walletconnect): return the `pairing_topic` in `new_connection` response (#2538) bless clippy (#2560) refactor(toolchain): use latest available stable compiler (#2557) feat(wallet): implement unified offline private key export API (#2542) chore(release): v2.3.0-beta (#2284) # Conflicts: # mm2src/mm2_main/tests/docker_tests/eth_docker_tests.rs
* dev: (28 commits) fix build script failing to find .git/HEAD (GLEECBTC#2601) refactor(EVM): rename fn, fix timeouts, add activation req validation (GLEECBTC#2543) improvement(`static mut`s): `static mut` removal (GLEECBTC#2590) fix(orders): set subscription on kickstart and skip GC of own pubkeys (GLEECBTC#2597) fix(ordermatch): ignore loop-back; clear on null root; reject stale keep-alives (GLEECBTC#2580) fix(clippy): fix clippy warnings for GLEECBTC#2565 (GLEECBTC#2589) fix(Trezor): fix utxo and eth calls due to firmware changes (GLEECBTC#2565) fix(utxo): calculate min_trading_vol based on fixed tx fees (GLEECBTC#2564) feat(protocol): [0] solana support (GLEECBTC#2586) fix(utxo): fix header deserialization; guard AuxPoW (GLEECBTC#2583) chore(rust 1.89): make CI clippy/fmt pass (wasm32, all-targets) (GLEECBTC#2581) fix(utxo): deserialize sapling root for PIVX block headers (GLEECBTC#2572) improvement(dep-stack): security bumps (GLEECBTC#2562) fix(utxo): correct block header deserialization for AuxPow and KAWPOW coins (GLEECBTC#2563) feat(wallet-connect): impl BTC (UTxO) activation via WalletConnect (GLEECBTC#2499) feat(utxo): add new fixed txfee option for DINGO-like coins (GLEECBTC#2454) ci(pull-requests): review notification bot (GLEECBTC#2468) improvement(walletconnect): return the `pairing_topic` in `new_connection` response (GLEECBTC#2538) bless clippy (GLEECBTC#2560) refactor(toolchain): use latest available stable compiler (GLEECBTC#2557) ... # Conflicts: # mm2src/coins/eth.rs # mm2src/coins/eth/eth_rpc.rs # mm2src/coins/eth/eth_swap_v2/eth_maker_swap_v2.rs # mm2src/coins/eth/eth_swap_v2/eth_taker_swap_v2.rs # mm2src/coins/eth/eth_withdraw.rs # mm2src/coins/eth/v2_activation.rs # mm2src/coins/lightning.rs # mm2src/coins/lp_coins.rs # mm2src/coins/nft.rs # mm2src/coins/qrc20.rs # mm2src/coins/siacoin.rs # mm2src/coins/tendermint/tendermint_token.rs # mm2src/coins/test_coin.rs # mm2src/coins/utxo/bch.rs # mm2src/coins/utxo/qtum.rs # mm2src/coins/utxo/slp.rs # mm2src/coins/utxo/utxo_standard.rs # mm2src/coins/z_coin.rs # mm2src/coins_activation/src/bch_with_tokens_activation.rs # mm2src/coins_activation/src/erc20_token_activation.rs # mm2src/coins_activation/src/eth_with_token_activation.rs # mm2src/coins_activation/src/init_erc20_token_activation.rs # mm2src/coins_activation/src/init_token.rs # mm2src/coins_activation/src/platform_coin_with_tokens.rs # mm2src/coins_activation/src/slp_token_activation.rs # mm2src/coins_activation/src/tendermint_with_assets_activation.rs # mm2src/coins_activation/src/token.rs # mm2src/mm2_main/src/lp_swap.rs # mm2src/mm2_main/src/lp_swap/check_balance.rs # mm2src/mm2_main/src/lp_swap/maker_swap.rs # mm2src/mm2_main/src/lp_swap/max_maker_vol_rpc.rs # mm2src/mm2_main/src/lp_swap/swap_v2_rpcs.rs # mm2src/mm2_main/src/lp_swap/taker_swap.rs # mm2src/mm2_main/src/lp_swap/trade_preimage.rs # mm2src/mm2_main/src/rpc/dispatcher/dispatcher.rs # mm2src/mm2_main/src/rpc/lp_commands/legacy.rs # mm2src/mm2_main/src/rpc/lp_commands/lr_swap.rs # mm2src/mm2_main/src/rpc/lp_commands/lr_swap/lr_impl.rs # mm2src/mm2_main/src/rpc/lp_commands/one_inch/errors.rs # mm2src/mm2_main/src/rpc/lp_commands/one_inch/rpcs.rs # mm2src/mm2_main/src/rpc/lp_commands/tokens.rs # mm2src/mm2_main/tests/docker_tests/docker_tests_common.rs # mm2src/mm2_main/tests/docker_tests/docker_tests_inner.rs # mm2src/mm2_main/tests/docker_tests/eth_docker_tests.rs # mm2src/mm2_main/tests/integration_tests_common/mod.rs # mm2src/trading_api/src/one_inch_api/client.rs
For fixed-fee UTXO coins, use max(10×dust, 10×(fee_per_kB × 496B)) so swaps remain economical. Dynamic-fee coins remain dust-based. Fixes #1567.
Fixes #1567
This fix prevents swap failures on UTXO coins with high fixed fees (e.g., ZEC, RVN), where the HTLC spend fee could exceed the traded amount.
The
min_trading_volcalculation is now enhanced:For coins with a fixed fee rate, the minimum volume is set to 10x the estimated HTLC spend fee, ensuring it's always economical to complete the swap.
For coins with dynamic fees, the calculation remains based on the dust amount to preserve synchronous behavior.