feat(dex-fee): update fee rate, migrate fee addresses and default netid#2710
feat(dex-fee): update fee rate, migrate fee addresses and default netid#2710
Conversation
- Update DEX_FEE_ADDR_PUBKEY to new value - Set DEX_BURN_ADDR_PUBKEY to same as fee address (burn disabled) - Add TODO comment for ED25519 pubkey (Sia) - Update abbreviated pubkeys in AGENTS.md documentation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update DEX fee and burn Z-addresses to new value. Burn is disabled by setting burn address to same value as fee address. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Disable all burn mechanisms - fees now go entirely to DEX fee address: - should_burn_directly() returns false (was KMD-specific OP_RETURN burn) - should_burn_dex_fee() returns false with updated doc comment Code preserved for potential future re-enablement. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- dex_fee_rate() now returns 2% flat for all trades (was ~0.129% with KMD discount at ~0.116%). Original discount logic preserved as comments for reference, with instructions for adapting to 2% base. - Simplified dex_fee_rate() signature (no parameters needed for flat rate) - Removed KMD NoFee exemption from swap v2 state machines. Old logic preserved as comments with instructions for re-enabling (e.g., GLEEC). - Cleaned up TODO in should_burn_dex_fee() Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add #[ignore] to tests that verify KMD discount behavior which has been removed. The fee is now 2% flat for all trades. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update "wrong pubkey" test values in qrc20_tests.rs to use the new DEX fee pubkey base with intentionally wrong ending (bbd0 instead of bbd1) to maintain test validation logic. Note: z_coin_tests.rs not updated as it validates historical transaction data that actually went to the old z-address. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Now that the DEX fee is a flat 2% for all trades, the base/rel ticker parameters used for KMD discount calculation are no longer needed. Removed parameters: - DexFee::new_from_taker_coin: maker_ticker - DexFee::new_with_taker_pubkey: maker_ticker - max_taker_vol_from_available: base, rel - calc_max_taker_vol: other_coin MaxTakerVolRequest.trade_with kept with deprecation comment for backward compatibility with existing API clients. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fixes clippy::test_attr_in_doctest warning introduced in newer Rust. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update test_dex_fee_amount and test_max_taker_vol_from_available for 2% flat fee rate (removed KMD discount) - Fix address validation tests by mocking dex_fee_addr/dex_pubkey to return legacy addresses for historical transaction fixtures - Add mockable dex_fee_addr() and dex_burn_addr() methods to ZCoin for proper WithBurn validation testing with different addresses - Update docker tests for 2% fee rate and Standard fees (burn disabled) - Move legacy DEX fee constants to mm2_test_helpers crate - Update swap watcher tests to account for non-refundable DEX fee Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Rename test_kmd_taker_dex_fee_calculation to test_with_burn_fee_calculation - Rename test_dex_fee_from_taker_coin_discount to test_uniform_fee_rate_no_discounts - Remove #[ignore] - tests now verify current behavior - Update assertions to test uniform 2% fee rate (no KMD discount) - Add TODO comments for adding discount tests when implemented for GLEEC Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Restore the TODO comment reminding that if burn is re-enabled, negotiation version checking needs to be implemented to prevent breaking swaps between different client versions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- z_coin: use correct legacy burn z-address (was invalid checksum) - tendermint: add legacy burn pubkey constant and mock burn_pubkey() - qrc20: increase dust tolerance from 0.001 to 0.002 for 2% fee rate Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
mariocynicys
left a comment
There was a problem hiding this comment.
Thanks for the fixes. LGTM!
For the tests that still use the old dex address. Maybe we better invest in moving them to docker instead of replaying the fixtures needed for those tests with the new dex address.
Restore the ticker-based fee discount mechanism that was removed when switching to a 2% flat rate. GLEEC trades now get a 50% discount (1% fee rate) while all other pairs use the standard 2% rate. The discount applies when either base or rel is GLEEC. Key changes: - Restore dex_fee_rate(base, rel) signature with GLEEC discount logic - Thread maker_ticker parameter through all DexFee call sites - Comment out (not remove) NoFee branches in V2 swaps for future reference - Add GLEEC-specific test coverage alongside existing burn fee tests - Restore MaxTakerVolRequest.trade_with field from deprecated to active Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…iscount rate The test sets MYCOIN_FEE_DISCOUNT env var and uses trade_with: "MYCOIN", which triggers the 1% discount rate. The expected denominator should be 101000000 (1.01) not 102000000 (1.02). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Migrate the default P2P network ID to 6133 ("GLEE" in leet-speak) as
part of the GLEEC rebranding. Add 8762 to the deprecated netid list,
following the same pattern used for the 7777 → 8762 migration.
mariocynicys
left a comment
There was a problem hiding this comment.
was really smart not to wipe out the discount logic xD
few queries, looks good otherwise.
| // 1% fee (50% discount) | ||
| BigRational::new(1.into(), 100.into()).into() |
There was a problem hiding this comment.
i think discounting more than 50% (e.g. 70%) would incentives more ppl to perform the trades with GLEEC as an intermediate coin.
currently there is no incentive to do such a thing since that requires two swaps each costing 1% fee, so still 2% total (+ more chain fees).
| /// Tests that GLEEC trades get a 50% fee discount (1% vs 2% standard rate) | ||
| /// and that the 75/25 fee/burn split is applied on the discounted amount. | ||
| #[test] | ||
| fn test_gleec_taker_dex_fee_calculation() { |
There was a problem hiding this comment.
this test mainly checks the burn interaction with the discount/non-discount coin variations. i think this should be made clearer in the test name.
| /// Tests that MYCOIN gets GLEEC-like discount when MYCOIN_FEE_DISCOUNT env is set. | ||
| #[test] | ||
| fn test_dex_fee_from_taker_coin_discount() { |
There was a problem hiding this comment.
and what's the point of such a test? what's the point of testing if an env variable (that's used in tests) work as expected.
edit: i mean, if it doesn't work as expected, the relevant tests will just fail.
| /// Tests WithBurn fee calculation when burn is enabled via mocking. | ||
| /// Verifies that non-discount coins use the same 2% fee rate and correct 75/25 fee/burn split. | ||
| /// Uses KMD and RICK (neither is a discount ticker) to avoid env var race with other tests. | ||
| #[test] | ||
| fn test_kmd_taker_dex_fee_calculation() { | ||
| std::env::set_var("MYCOIN_FEE_DISCOUNT", ""); | ||
|
|
||
| fn test_with_burn_fee_calculation() { | ||
| let kmd = coins::TestCoin::new("KMD"); | ||
| TestCoin::should_burn_dex_fee.mock_safe(|_| MockResult::Return(true)); | ||
| let (kmd_fee_amount, kmd_burn_amount) = match DexFee::new_from_taker_coin(&kmd, "ETH", &MmNumber::from(6150)) { |
There was a problem hiding this comment.
nit: i think these tests mainly tests DexFee::new_from_taker_coin, why are they in lp_swap.rs?
Summary
Updates the global DEX fee configuration:
0348685437335ec43ba6211caf848576ca3d34abbe9e089f861471b4ed9ee9bbd1Netid Migration
8762to6133("GLEE" in leet-speak)8762to deprecated netid list (same pattern as7777→8762migration)adex_clidefault and help messagesBreaking Changes
Addresses Derived from New Pubkey
RR1RS8UFiufoLe9hwZgSBTjutiZvKV62v51GjEMcay85sEGdnWUPhK5wQi8T7KkBvQG20x2CA50934E704624e3e035056d066C887abc123bdZ-Address:
zs18egqw99pw5846jfrqntu4neup4hjjchx874j6krmeq88yh4adws9djmuplg5hfx9f0wdsscgr5jTODOs
Fee Discount
The
dex_fee_rate(base, rel)function applies a ticker-based discount:MYCOIN_FEE_DISCOUNTenv var adds MYCOIN to the discount listThe
MaxTakerVolRequest.trade_withfield is restored to active use for pair-aware fee calculation.Test Updates
All tests have been updated to work with the new configuration:
Fee Rate Changes (2% standard, 1% GLEEC discount)
test_dex_fee_amount- Updated expected values for 2% rate, added GLEEC discount casestest_max_taker_vol_from_available- Updated max volume calculations with GLEEC boundary valuestest_with_burn_fee_calculation- Verifies 2% rate and 75/25 burn split for non-discount coinstest_gleec_taker_dex_fee_calculation- Verifies 1% GLEEC discount with burn splittest_dex_fee_from_taker_coin_discount- Verifies MYCOIN_FEE_DISCOUNT env var behaviorutxo_swaps_v1_tests,swap_proto_v2_tests) - Updated fee expectationsV2 Swap NoFee
Address Validation Tests
Tests that validate historical transaction fixtures now mock the DEX fee address to return the legacy pubkey:
qrc20_tests::test_validate_feetendermint_coin::validate_taker_fee_test/validate_taker_fee_with_burn_testutxo_tests::test_validate_old_fee_tx/test_validate_fee_bch_70_bytes_signaturez_unit_tests::test_validate_zcoin_dex_feeZCoin Changes
dex_fee_addr()anddex_burn_addr()methods for test mockingStandardfees (burn disabled)WithBurnvalidation with legacy addressesSwap Watcher Tests
Legacy Constants
DEX_FEE_ADDR_PUBKEY_LEGACYandDEX_FEE_ADDR_RAW_PUBKEY_LEGACYtomm2_test_helperscrate🤖 Generated with Claude Code