@@ -962,52 +962,57 @@ impl CostProfitService {
962962 let mut l1_data_fee_wei = U256 :: ZERO ;
963963 let mut l1_data_fee_buffer_wei = U256 :: ZERO ;
964964
965- match self
966- . build_fill_tx_for_quote (
967- request,
968- context,
969- & swap_amounts_with_info,
970- config,
971- solver_address,
972- )
973- . await
974- {
975- Ok ( mut fill_tx) => {
976- fill_tx. gas_limit = Some ( gas_units. fill_units ) ;
977- let ( raw, buffer) = self
978- . estimate_extra_native_fee_wei ( config, dest_chain_id, & fill_tx)
979- . await ?;
980- l1_data_fee_wei = l1_data_fee_wei. saturating_add ( raw) ;
981- l1_data_fee_buffer_wei = l1_data_fee_buffer_wei. saturating_add ( buffer) ;
982- } ,
983- Err ( e) => {
984- fail_closed_on_extra_fee_build_error ( config, dest_chain_id, "fill" , e) ?;
985- } ,
986- }
965+ // Only chains with an extra_native_fee policy (OP Stack L1 data fee) need
966+ // a per-transaction fee estimate. On every other chain the synthetic-tx
967+ // builds below are pure waste (the estimate would be zero), so skip them.
968+ if extra_native_fee_configured ( config, dest_chain_id) {
969+ match self
970+ . build_fill_tx_for_quote (
971+ request,
972+ context,
973+ & swap_amounts_with_info,
974+ config,
975+ solver_address,
976+ )
977+ . await
978+ {
979+ Ok ( mut fill_tx) => {
980+ fill_tx. gas_limit = Some ( gas_units. fill_units ) ;
981+ let ( raw, buffer) = self
982+ . estimate_extra_native_fee_wei ( config, dest_chain_id, & fill_tx)
983+ . await ?;
984+ l1_data_fee_wei = l1_data_fee_wei. saturating_add ( raw) ;
985+ l1_data_fee_buffer_wei = l1_data_fee_buffer_wei. saturating_add ( buffer) ;
986+ } ,
987+ Err ( e) => {
988+ fail_closed_on_extra_fee_build_error ( config, dest_chain_id, "fill" , e) ?;
989+ } ,
990+ }
987991
988- match self
989- . build_post_fill_tx_for_quote (
990- request,
991- context,
992- & swap_amounts_with_info,
993- config,
994- solver_address,
995- settlement_fee_wei,
996- )
997- . await
998- {
999- Ok ( Some ( mut post_fill) ) => {
1000- post_fill. tx . gas_limit = Some ( gas_units. post_fill_units ) ;
1001- let ( raw, buffer) = self
1002- . estimate_extra_native_fee_wei ( config, dest_chain_id, & post_fill. tx )
1003- . await ?;
1004- l1_data_fee_wei = l1_data_fee_wei. saturating_add ( raw) ;
1005- l1_data_fee_buffer_wei = l1_data_fee_buffer_wei. saturating_add ( buffer) ;
1006- } ,
1007- Ok ( None ) => { } ,
1008- Err ( e) => {
1009- fail_closed_on_extra_fee_build_error ( config, dest_chain_id, "post-fill" , e) ?;
1010- } ,
992+ match self
993+ . build_post_fill_tx_for_quote (
994+ request,
995+ context,
996+ & swap_amounts_with_info,
997+ config,
998+ solver_address,
999+ settlement_fee_wei,
1000+ )
1001+ . await
1002+ {
1003+ Ok ( Some ( mut post_fill) ) => {
1004+ post_fill. tx . gas_limit = Some ( gas_units. post_fill_units ) ;
1005+ let ( raw, buffer) = self
1006+ . estimate_extra_native_fee_wei ( config, dest_chain_id, & post_fill. tx )
1007+ . await ?;
1008+ l1_data_fee_wei = l1_data_fee_wei. saturating_add ( raw) ;
1009+ l1_data_fee_buffer_wei = l1_data_fee_buffer_wei. saturating_add ( buffer) ;
1010+ } ,
1011+ Ok ( None ) => { } ,
1012+ Err ( e) => {
1013+ fail_closed_on_extra_fee_build_error ( config, dest_chain_id, "post-fill" , e) ?;
1014+ } ,
1015+ }
10111016 }
10121017
10131018 // Parse inputs/outputs to proper types for cost calculation
0 commit comments