treat WETH->ETH as sametoken trade#4531
Conversation
where we drop the volume fee
|
Claude encountered an error after 2m 31s —— View job PR Review in progress
|
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
AryanGodara
left a comment
There was a problem hiding this comment.
LGTM 👌🏼
[nit]native_token could move onto VolumeFeePolicy itself, since both callers (ProtocolFees and QuoteHandler) already construct the policy with the chain's native token immediately after receiving it.
I tried this locally and it works, but is like a 2/10 refactor. So not pushing for it 😅
Tradeoff I think is binding the policy to a specific chain 🤔
jmg-duarte
left a comment
There was a problem hiding this comment.
did you test this in staging? and shouldnt the unwraps not even be considered this kind of trade?
MartinquaXD
left a comment
There was a problem hiding this comment.
Logic makes sense to me and test coverage is good.
|
tested on base staging now: note: no without my PR: |

Skip volume fee on wrapped↔native (WETH→ETH) same-token trades
Same-token trades (
sell_token == buy_token) already skip the volume fee unlessenable_sell_equals_buy_volume_fee(off by default) is set. This extends "same-token" to native ETH buys:WETH → ETH(buy_token == BUY_ETH_ADDRESS) and the fee is dropped on both the quote and the settlement.Changes
shared/fee.rs:get_applicable_volume_fee_factortakesnative_tokenand skips the fee for the native same-token case.model/order.rs: extractedis_same_buy_and_sell_token(sell, buy, native), reused by both the fee policy and order validation.orderbook(QuoteHandler) andautopilot(ProtocolFees) threadnative_tokenthrough so quote and settlement agree.Tests
shared::fee::tests::test_same_token_volume_fee_skippedlocal_node_volume_fee_{dropped_on_same_token, charged_on_same_token_when_enabled, dropped_on_wrapped_to_native_token}