Skip to content

feat(eth): improve gas fee policy code#2533

Merged
shamardy merged 33 commits intodevfrom
refactor-gas-fee-policy
Sep 6, 2025
Merged

feat(eth): improve gas fee policy code#2533
shamardy merged 33 commits intodevfrom
refactor-gas-fee-policy

Conversation

@dimxy
Copy link
Copy Markdown
Collaborator

@dimxy dimxy commented Jul 16, 2025

This PR adds a few fixes and improvements in handling gas fee policy:

  • fix getting max_eth_tx_type from the platform coin config: first it gets this param from the platform coin conf then from the token conf.
  • adds new params to the coins file for adjustment of gas price and eip1559 fee per gas:
            "gas_price_adjust": {
                "legacy_price_mult": 0.25,
                "base_fee_mult": [0.1, 0.2, 0.3],
                "priority_fee_mult": [0.4, 0.5, 0.6]
            },

Those params allow to adjust legacy or priority gas price for specific EVM coins or tokens. First the params are searched in the token config, if none, then in the platform coin config (cc @cipig).

  • renamed the "set_swap_transaction_fee_policy" RPC in "set_swap_gas_fee_policy" and store the gas policy value always in the EVM platform coin. This renamed RPC is a BREAKING CHANGE.
  • allow to use the gas fee policy set by the "set_swap_gas_fee_policy" RPC in the sign_raw_tx call (needed for signing LR txns with the same policy used in atomic swaps)
  • added an optional param swap_gas_fee_policy to the enable (if EVM) and enable_eth_with_tokens RPCs. The swap_gas_fee_policy param can have the values: Legacy, Low, Medium and High. The param is relevant only for the platform coin.
  • refactored gas policy enums to simplify them.
  • refactor: renamed fn's like wei_from_big_decimal into u256_from_big_decimal bcs this conversion is used not only for wei but for token smallest units as well.

More fixes added:

  • removed minimal value of 1 gwei for the gas price (see the updated increase_by_percent fn) to allow BNB low fees
  • add check for the ticker to match the "coin" value in the coin conf for the legacy "enable" RPC
  • fix nonce lock (mutex use) to prevent duplicate nonces if the legacy "enable" RPC used to activate tokens - fixes this issue: Replacement transaction underpriced error for Maker payment spend transaction #2573
  • added a new estimate_gas_mult param to the coins file. If it is set to some floating point value, then eth_estimateGas RPC will be used to get gas limit for swap transactions. The received gas limit value will be also adjusted by multiplying by the estimate_gas_mult value (therefore recommended to set it to value > 1.0).

This PR is also preliminary for the upcoming new liquidity routing feature.

dimxy added 4 commits July 15, 2025 22:22
…s fee adjust coin params, rename "set_swap_transaction_fee_policy" rpc to "set_swap_gas_fee_policy", force set_swap_gas_fee_policy to store policy in the platform coin
@dimxy dimxy added status: in progress priority: medium Moderately important tasks that should be completed but are not urgent. breaking-change: RPC labels Jul 16, 2025
@cipig
Copy link
Copy Markdown

cipig commented Jul 16, 2025

How can i set eip1559 for all enabled tokens without having to call "set_swap_transaction_fee_policy" for each of them in part? I want to avoid this since i have several dozen tokens...
Can i pass "set_swap_transaction_fee_policy" in the enable_eth_with_tokens call, which btw looks like this:

curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable_eth_with_tokens\",\"mmrpc\":\"2.0\",\"params\":{\"get_balances\":false,\"ticker\":\"POL\",\"mm2\":1,\"priv_key_policy\":{\"type\":\"ContextPrivKey\"},\"swap_contract_address\":\"0x9130b257D37A52E52F21054c4DA3450c72f595CE\",\"fallback_swap_contract\":\"0x9130b257D37A52E52F21054c4DA3450c72f595CE\",\"nodes\":[{\"url\":\"https://electrum3.cipig.net:18755\"},{\"url\":\"https://polygon-bor-rpc.publicnode.com\"}],\"tx_history\":false,\"erc20_tokens_requests\":[{\"ticker\":\"1INCH-PLG20\"},{\"ticker\":\"AAVE-PLG20\"},{\"ticker\":\"AGEUR-PLG20\"},{\"ticker\":\"ANKR-PLG20\"},{\"ticker\":\"APE-PLG20\"},{\"ticker\":\"ARPA-PLG20\"},{\"ticker\":\"ATOM-PLG20\"},{\"ticker\":\"BAL-PLG20\"},{\"ticker\":\"BRZ-PLG20\"},{\"ticker\":\"CADC-PLG20\"},{\"ticker\":\"COMP-PLG20\"},{\"ticker\":\"CRV-PLG20\"},{\"ticker\":\"DAI-PLG20\"},{\"ticker\":\"ETH-PLG20\"},{\"ticker\":\"EURE-PLG20\"},{\"ticker\":\"EUROE-PLG20\"},{\"ticker\":\"EURS-PLG20\"},{\"ticker\":\"FXS-PLG20\"},{\"ticker\":\"GLM-PLG20\"},{\"ticker\":\"GMT-PLG20\"},{\"ticker\":\"GNS-PLG20\"},{\"ticker\":\"GRT-PLG20\"},{\"ticker\":\"HEX-PLG20\"},{\"ticker\":\"IDRT-PLG20\"},{\"ticker\":\"JAUD-PLG20\"},{\"ticker\":\"JBRL-PLG20\"},{\"ticker\":\"JCAD-PLG20\"},{\"ticker\":\"JCHF-PLG20\"},{\"ticker\":\"JCNY-PLG20\"},{\"ticker\":\"JEUR-PLG20\"},{\"ticker\":\"JGBP-PLG20\"},{\"ticker\":\"JGOLD-PLG20\"},{\"ticker\":\"JJPY-PLG20\"},{\"ticker\":\"JKRW-PLG20\"},{\"ticker\":\"JMXN-PLG20\"},{\"ticker\":\"JNZD-PLG20\"},{\"ticker\":\"JPLN-PLG20\"},{\"ticker\":\"SYN-PLG20\"},{\"ticker\":\"JSGD-PLG20\"},{\"ticker\":\"JTRY-PLG20\"},{\"ticker\":\"SPACE-PLG20\"},{\"ticker\":\"JPYC-PLG20\"},{\"ticker\":\"KNC-PLG20\"},{\"ticker\":\"LDO-PLG20\"},{\"ticker\":\"LINK-PLG20\"},{\"ticker\":\"MANA-PLG20\"},{\"ticker\":\"MASK-PLG20\"},{\"ticker\":\"MKR-PLG20\"},{\"ticker\":\"NEXO-PLG20\"},{\"ticker\":\"PGX-PLG20\"},{\"ticker\":\"PAXG-PLG20\"},{\"ticker\":\"POT-PLG20\"},{\"ticker\":\"PYR-PLG20\"},{\"ticker\":\"REQ-PLG20\"},{\"ticker\":\"RNDR-PLG20\"},{\"ticker\":\"SAND-PLG20\"},{\"ticker\":\"SHIB-PLG20\"},{\"ticker\":\"SNX-PLG20\"},{\"ticker\":\"SOL-PLG20\"},{\"ticker\":\"SUSHI-PLG20\"},{\"ticker\":\"TBTC-PLG20\"},{\"ticker\":\"TEL-PLG20\"},{\"ticker\":\"DFX-PLG20\"},{\"ticker\":\"TRYB-PLG20\"},{\"ticker\":\"UNI-PLG20\"},{\"ticker\":\"OM-PLG20\"},{\"ticker\":\"USDT-PLG20\"},{\"ticker\":\"WBTC-PLG20\"},{\"ticker\":\"WOO-PLG20\"},{\"ticker\":\"YFI-PLG20\"},{\"ticker\":\"XIDR-PLG20\"},{\"ticker\":\"XSGD-PLG20\"}]}}"

can i also use this in the old enable call? i need to use the old enable call, because i need to use other RPC endpoints for the base coin then for all others... eg like here for USDC-PLG20

curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"USDC-PLG20\",\"urls\":[\"https://electrum3.cipig.net:18755\",\"https://polygon.lava.build\"],\"swap_contract_address\":\"0x9130b257D37A52E52F21054c4DA3450c72f595CE\",\"fallback_swap_contract\":\"0x9130b257D37A52E52F21054c4DA3450c72f595CE\"}"

i can't use the same endpoints because kdf does lots of requests to the RPC endpoints and if i use the same for both tokens of a pair in orderbook, it will be too slow and public endpoints also tend to block you or slow you down if you send too many requests

@dimxy
Copy link
Copy Markdown
Collaborator Author

dimxy commented Jul 16, 2025

Can i pass "set_swap_transaction_fee_policy" in the enable_eth_with_tokens call, which btw looks like this:

Yes, I forgot to mention this in this PR description, added: there is a swap_gas_fee_policy param.
Note that if it is passed in the 'enable' RPC for a ERC20 it will be ignored as the gas fee policy now is always taken from the platform coin. Maybe I should return a error if swap_gas_fee_policy param is used for a ERC20 enable call.

@cipig
Copy link
Copy Markdown

cipig commented Jul 17, 2025

Note that if it is passed in the 'enable' RPC for a ERC20 it will be ignored as the gas fee policy now is always taken from the platform coin.

So, in my example from above, what will happen if i pass swap_gas_fee_policy to both calls, or just to the first one, the enable_eth_with_tokens?
Since the platform coin is enabled first, together with a bunch of tokens, what happens to the fees of USDC-PLG20, which is enabled later with the simple enable call? Will USDC-PLG20 use the swap_gas_fee_policy of the parent coin if that is passed in the enable_eth_with_tokens call?

@shamardy
Copy link
Copy Markdown
Collaborator

Since the platform coin is enabled first, together with a bunch of tokens, what happens to the fees of USDC-PLG20, which is enabled later with the simple enable call?

Didn't look at the code yet, but how it worked before is that tokens inherit from platform in v2 activations, so you need to use enable_erc20 RPC

@cipig
Copy link
Copy Markdown

cipig commented Jul 17, 2025

Didn't look at the code yet, but how it worked before is that tokens inherit from platform in v2 activations, so you need to use enable_erc20 RPC

I can't use v2 activation for the base coin, in this case USDC-PLG20 because i need to use other RPC endpoints for the base coin then for all other PLG20 tokens. If i use the same public server for both, it will not work, i need to spread the load over several distinct servers.
The only solution i found for this is to use enable_eth_with_tokens for POL and all tokens and enable for USDC-PLG20 (or whatever the PLG20 base coin is on that maker node).

@dimxy
Copy link
Copy Markdown
Collaborator Author

dimxy commented Jul 18, 2025

Since the platform coin is enabled first, together with a bunch of tokens, what happens to the fees of USDC-PLG20, which is enabled later with the simple enable call? Will USDC-PLG20 use the swap_gas_fee_policy of the parent coin if that is passed in the enable_eth_with_tokens call?

Yes, in this PR the gas fee policy is stored only in the platform coin (MATIC) so for USDC-PLG20 and any other token one and the same policy will be used. I think, this is consistent.
I may return an error if set_swap_gas_fee_policy rpc is used for a non-platform token.

@cipig
Copy link
Copy Markdown

cipig commented Jul 22, 2025

switched to this branch for testing and the console is flooded with entries like this

pay_for_gas=Ok(Legacy { gas_price: 25000000120 })
pay_for_gas=Ok(Legacy { gas_price: 3000000000 })
pay_for_gas=Ok(Legacy { gas_price: 1000000000 })
pay_for_gas=Ok(Legacy { gas_price: 1000000000 })
pay_for_gas=Ok(Legacy { gas_price: 1000000000 })
pay_for_gas=Ok(Legacy { gas_price: 1000000000 })

how can i disable them?

@shamardy
Copy link
Copy Markdown
Collaborator

shamardy commented Jul 22, 2025

switched to this branch for testing and the console is flooded with entries like this

pay_for_gas=Ok(Legacy { gas_price: 25000000120 })
pay_for_gas=Ok(Legacy { gas_price: 3000000000 })
pay_for_gas=Ok(Legacy { gas_price: 1000000000 })
pay_for_gas=Ok(Legacy { gas_price: 1000000000 })
pay_for_gas=Ok(Legacy { gas_price: 1000000000 })
pay_for_gas=Ok(Legacy { gas_price: 1000000000 })

how can i disable them?

Will remove this println now, it was done for testing by @dimxy I suppose

@shamardy
Copy link
Copy Markdown
Collaborator

shamardy commented Jul 22, 2025

Sorry about asking you to try with this PR @cipig , it's still in progress. @dimxy I pushed 2 commits, feel free to remove them if you want.

@shamardy
Copy link
Copy Markdown
Collaborator

there is one debug output left, i now get this all the time: get_swap_pay_for_gas_option get_eip1559_gas_fee result=FeePerGasEstimated { base_fee: 0, low: FeePerGasLevel { max_priority_fee_per_gas: 100000000, max_fee_per_gas: 100000000, min_wait_time: None, max_wait_time: None }, medium: FeePerGasLevel { max_priority_fee_per_gas: 110000000, max_fee_per_gas: 110000000, min_wait_time: None, max_wait_time: None }, high: FeePerGasLevel { max_priority_fee_per_gas: 110000000, max_fee_per_gas: 110000000, min_wait_time: None, max_wait_time: None }, source: Simple, base_fee_trend: "", priority_fee_trend: "" }

Already removed here ea071a8 :)

@dimxy
Copy link
Copy Markdown
Collaborator Author

dimxy commented Jul 22, 2025

Sorry I forgot to remove println's
Thank you for the fix @shamardy

@cipig
Copy link
Copy Markdown

cipig commented Jul 22, 2025

i used this in RPC call set_swap_gas_fee_policy and also with the enable_eth_with_tokens and both worked
question: can i use swap_gas_fee_policy in coins file too? and if so, would it break older kdf versions if i add it and they don't "understand" it? for BNB and all BEP20 tokens using "Low" is fine, it then uses 0.11 gwei, while 0.1 gwei is their fixed gas price atm, so we could actually add it to coins file directly

@dimxy
Copy link
Copy Markdown
Collaborator Author

dimxy commented Jul 22, 2025

can i use swap_gas_fee_policy in coins file too?

I can add this param to the coins file as well. It should not break old kdf's.
Added @cipig.

Copy link
Copy Markdown

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Some notes from my side after the initial review:

Comment on lines +12 to +15
const MAX_ETH_TX_TYPE_SUPPORTED: &str = "max_eth_tx_type";
const LEGACY_GAS_PRICE_MULTIPLIER: &str = "gas_price_mult";
const GAS_FEE_BASE_ADJUST: &str = "gas_fee_base_adjust";
const GAS_FEE_PRIORITY_ADJUST: &str = "gas_fee_priority_adjust";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these? I haven't looked at the use cases of them but it shouldn't be necessary to do that just to know what they are. An example, the one that called LEGACY_GAS_PRICE_MULTIPLIER implies it's a multiplier but it's a plain string value. It's worth to document them (or give an explicit/clear name).

Comment on lines +134 to +138
if let Some(val) = get_conf_param(conf, param)? {
Ok(Some(val))
} else {
get_conf_param(&coin_conf(ctx, platform), param)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use or/or_else.

Comment on lines +123 to +129
fn get_conf_param(conf: &Json, param: &str) -> Result<Option<Json>, String> {
if !conf[param].is_null() {
Ok(Some(conf[param].clone()))
} else {
Ok(None)
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it returning Result? You could also use get on conf and remove is_null and Some/None dances.

Comment on lines +149 to +160
match get_conf_param_or_from_plaform(ctx, conf, MAX_ETH_TX_TYPE_SUPPORTED, coin_type) {
Ok(Some(val)) => {
let max_eth_tx_type = val
.as_u64()
.ok_or_else(|| format!("{MAX_ETH_TX_TYPE_SUPPORTED} in coins is invalid"))?;
if max_eth_tx_type > ETH_MAX_TX_TYPE {
return Err(format!("{MAX_ETH_TX_TYPE_SUPPORTED} in coins is too big"));
}
Ok(Some(max_eth_tx_type))
},
Ok(None) => Ok(None),
Err(err) => Err(err),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Err(err) => Err(err) part isn't necessary. You can do match get_conf_param_or_from_plaform(ctx, conf, MAX_ETH_TX_TYPE_SUPPORTED, coin_type)? and match on Some and None directly.

This applies to all the other functions below.

Comment on lines +172 to +176
let gas_price_mult = val
.as_f64()
.ok_or_else(|| format!("{LEGACY_GAS_PRICE_MULTIPLIER} in coins is invalid"))?;
if gas_price_mult <= 0.0 {
return Err(format!("{LEGACY_GAS_PRICE_MULTIPLIER} in coins is negative"));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we create a good first issue for validating the coins file on the fly using proper types instead of relying on plain Json values and validating fields on demand? Using proper types would allow the coins file to be automatically validated at KDF startup.

We could also reject unknown fields to help keep the file clean and up to date.

cc @shamardy

Copy link
Copy Markdown
Collaborator

@shamardy shamardy Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is this #1995
ref. #1995 (comment)

Some(gas_price) => EthTxFeeDetails::new(
gas_used,
PayForGasOption::Legacy(LegacyGasPrice { gas_price }),
PayForGasOption::Legacy { gas_price }, // TODO: is this always legacy?
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
PayForGasOption::Legacy { gas_price }, // TODO: is this always legacy?
// TODO: is this always legacy?
PayForGasOption::Legacy { gas_price },

Comment on lines +2649 to +2651
/// Use legacy gas price
#[default]
Unsupported,
Internal,
Legacy,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "legacy gas price" mean? Could you elaborate the comment a bit more?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added more doc comments (btw Legacy means pre-EIp1559)

@shamardy
Copy link
Copy Markdown
Collaborator

shamardy commented Jul 22, 2025

for BNB and all BEP20 tokens using "Low" is fine, it then uses 0.11 gwei, while 0.1 gwei is their fixed gas price atm

This is due to this https://github.com/KomodoPlatform/komodo-defi-framework/blob/6bd2a172999220bb10e4973e3b860df02a85b5eb/mm2src/coins/eth.rs#L6734-L6745
Do we still need this increase @dimxy ?

P.S. it should be fixed in this other PR #2454 if it needs fixing

Edit: nevermind as I saw this https://github.com/KomodoPlatform/komodo-defi-framework/blob/6bd2a172999220bb10e4973e3b860df02a85b5eb/mm2src/coins/eth.rs#L6731 Why the increase then as when I tried using withdraw it used exactly 0.1 gwei for low priority

@dimxy
Copy link
Copy Markdown
Collaborator Author

dimxy commented Jul 22, 2025

fixed @onur-ozkan notes, tyvm 0788385

dimxy added 5 commits August 15, 2025 21:01
… mutex (to prevent dup nonce in enable legacy rpc)
* 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
@dimxy dimxy force-pushed the refactor-gas-fee-policy branch from 934f4e1 to 093afd5 Compare August 15, 2025 17:54
@dimxy
Copy link
Copy Markdown
Collaborator Author

dimxy commented Aug 15, 2025

Merged latest dev.
Also removed the refactoring code breaking eth.rs into more sources - for a later dedicated PR, for easier review @shamardy

* dev:
  fix build script failing to find .git/HEAD (#2601)
  refactor(EVM): rename fn, fix timeouts, add activation req validation (#2543)
  improvement(`static mut`s): `static mut` removal (#2590)
  fix(orders): set subscription on kickstart and skip GC of own pubkeys (#2597)

# Conflicts:
#	mm2src/coins/eth.rs
@dimxy dimxy marked this pull request as ready for review August 21, 2025 17:06
Copy link
Copy Markdown
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next review iteration, most of these comments are non blockers.

))?;
let gas_price = pay_for_gas_option.get_gas_price();
let (max_fee_per_gas, max_priority_fee_per_gas) = pay_for_gas_option.get_fee_per_gas();
// TODO: we should get _nonce_lock here (when WalletConnect is supported for swaps)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swaps are already supported for WalletConnect, I suppose it works the same way as metamask if we pass nonce as None. But we use our internal nonce fetching logic here https://github.com/KomodoPlatform/komodo-defi-framework/blob/093afd5280e678562743d22ae37c4e96725fe59e/mm2src/coins/eth/wallet_connect.rs#L286 so I think we should do this for WC asap c.c. @mariocynicys

In the future, we should make nonce usage configurable for metamask and WC, the config option should be about if we should let the connected wallets decide it or not, it can be paired with the broadcast parameter or separate from it.

.await
);

coin.sign_and_send_transaction(0.into(), Call(token_addr), data, gas_limit)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This used to use the estimate without the multiplier but it will now use it even if it was meant for other things, is this acceptable?

Copy link
Copy Markdown
Collaborator Author

@dimxy dimxy Sep 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this call as redundant, to always use estimate_gas_for_contract_call_if_conf.
Indeed, estimate_gas_for_contract_call_if_conf will apply the multiplier, if it is set. I thought it's okay to use multiplier for all calls, including 'approve'

Comment on lines +6625 to +6627
if conf["coin"].as_str() != Some(ticker) {
return ERR!("Failed to activate '{}': ticker does not match coins config", ticker);
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious why we needed this

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I added this for sanity check in tests (when I used this fn to enable many coins and messed with configs/tickers).
If fact, we can eliminate the ticker param and get it from the conf param in all coin enable functions.

@shamardy shamardy added the status: pending docs Adding this label will automatically open an issue in the docs repo label Sep 6, 2025
@shamardy shamardy merged commit ea91c0d into dev Sep 6, 2025
20 of 27 checks passed
@shamardy shamardy deleted the refactor-gas-fee-policy branch September 6, 2025 04:31
dimxy pushed a commit that referenced this pull request Oct 15, 2025
This commit does the following:
- Adds SwapGasFeePolicy (Legacy/EIP-1559) stored on the platform coin; tokens inherit it
- Supports GasPriceRpcParam in sign_raw_transaction (uses policy or explicit Legacy/EIP-1559 fees)
- Adds gas_price_adjust (legacy/base/priority) and estimate_gas_mult; token→platform fallback; same for max_eth_tx_type
- enable and enable_eth_with_tokens accept swap_gas_fee_policy (platform coin only)
- Renames wei_from_big_decimal → u256_from_big_decimal; removes 1 gwei minimum bump; validates enable ticker vs conf
- Replaces global nonce lock with per-network, per-address locks

BREAKING CHANGE: renames RPCs get/set_swap_transaction_fee_policy → get/set_swap_gas_fee_policy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change: RPC priority: medium Moderately important tasks that should be completed but are not urgent. status: pending docs Adding this label will automatically open an issue in the docs repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants