@@ -18,11 +18,10 @@ use {
1818 signature_validator:: { SignatureCheck , SignatureValidating , SignatureValidationError } ,
1919 trade_finding,
2020 } ,
21- alloy:: primitives:: Address ,
2221 anyhow:: { Result , anyhow} ,
2322 app_data:: { AppDataHash , Hook , Hooks , ValidatedAppData , Validator } ,
2423 async_trait:: async_trait,
25- contracts:: alloy:: { HooksTrampoline , WETH9 } ,
24+ contracts:: alloy:: HooksTrampoline ,
2625 ethcontract:: { H160 , H256 , U256 } ,
2726 ethrpc:: alloy:: conversions:: { IntoAlloy , IntoLegacy } ,
2827 model:: {
@@ -216,9 +215,6 @@ pub trait LimitOrderCounting: Send + Sync {
216215
217216#[ derive( Clone ) ]
218217pub struct OrderValidator {
219- /// For Pre/Partial-Validation: performed during fee & quote phase
220- /// when only part of the order data is available
221- native_token : WETH9 :: Instance ,
222218 banned_users : Arc < order_validation:: banned:: Users > ,
223219 validity_configuration : OrderValidPeriodConfiguration ,
224220 eip1271_skip_creation_validation : bool ,
@@ -290,7 +286,6 @@ pub struct OrderAppData {
290286impl OrderValidator {
291287 #[ expect( clippy:: too_many_arguments) ]
292288 pub fn new (
293- native_token : WETH9 :: Instance ,
294289 banned_users : Arc < order_validation:: banned:: Users > ,
295290 validity_configuration : OrderValidPeriodConfiguration ,
296291 eip1271_skip_creation_validation : bool ,
@@ -306,7 +301,6 @@ impl OrderValidator {
306301 max_gas_per_order : u64 ,
307302 ) -> Self {
308303 Self {
309- native_token,
310304 banned_users,
311305 validity_configuration,
312306 eip1271_skip_creation_validation,
@@ -849,15 +843,6 @@ pub enum OrderValidToError {
849843 Excessive ,
850844}
851845
852- /// Returns true if the orders have same buy and sell tokens.
853- ///
854- /// This also checks for orders selling wrapped native token for native token.
855- fn has_same_buy_and_sell_token ( order : & PreOrderData , native_token : & Address ) -> bool {
856- order. sell_token == order. buy_token
857- || ( order. sell_token == native_token. into_legacy ( )
858- && order. buy_token . into_alloy ( ) == BUY_ETH_ADDRESS . into_alloy ( ) )
859- }
860-
861846/// Retrieves the quote for an order that is being created and verify that its
862847/// fee is sufficient.
863848///
@@ -1034,49 +1019,8 @@ mod tests {
10341019 std:: str:: FromStr ,
10351020 } ;
10361021
1037- #[ test]
1038- fn detects_orders_with_same_buy_and_sell_token ( ) {
1039- let native_token = [ 0xef ; 20 ] . into ( ) ;
1040- assert ! ( has_same_buy_and_sell_token(
1041- & PreOrderData {
1042- sell_token: H160 ( [ 0x01 ; 20 ] ) ,
1043- buy_token: H160 ( [ 0x01 ; 20 ] ) ,
1044- ..Default :: default ( )
1045- } ,
1046- & native_token,
1047- ) ) ;
1048- assert ! ( has_same_buy_and_sell_token(
1049- & PreOrderData {
1050- sell_token: native_token. into_legacy( ) ,
1051- buy_token: BUY_ETH_ADDRESS ,
1052- ..Default :: default ( )
1053- } ,
1054- & native_token,
1055- ) ) ;
1056-
1057- assert ! ( !has_same_buy_and_sell_token(
1058- & PreOrderData {
1059- sell_token: H160 ( [ 0x01 ; 20 ] ) ,
1060- buy_token: H160 ( [ 0x02 ; 20 ] ) ,
1061- ..Default :: default ( )
1062- } ,
1063- & native_token,
1064- ) ) ;
1065- // Sell token set to 0xeee...eee has no special meaning, so it isn't
1066- // considered buying and selling the same token.
1067- assert ! ( !has_same_buy_and_sell_token(
1068- & PreOrderData {
1069- sell_token: BUY_ETH_ADDRESS ,
1070- buy_token: native_token. into_legacy( ) ,
1071- ..Default :: default ( )
1072- } ,
1073- & native_token,
1074- ) ) ;
1075- }
1076-
10771022 #[ tokio:: test]
10781023 async fn pre_validate_err ( ) {
1079- let native_token = WETH9 :: Instance :: new ( [ 0xef ; 20 ] . into ( ) , ethrpc:: mock:: web3 ( ) . alloy ) ;
10801024 let validity_configuration = OrderValidPeriodConfiguration {
10811025 min : Duration :: from_secs ( 1 ) ,
10821026 max_market : Duration :: from_secs ( 100 ) ,
@@ -1088,7 +1032,6 @@ mod tests {
10881032 let mut limit_order_counter = MockLimitOrderCounting :: new ( ) ;
10891033 limit_order_counter. expect_count ( ) . returning ( |_| Ok ( 0u64 ) ) ;
10901034 let validator = OrderValidator :: new (
1091- native_token,
10921035 Arc :: new ( order_validation:: banned:: Users :: from_set ( banned_users) ) ,
10931036 validity_configuration,
10941037 false ,
@@ -1228,9 +1171,7 @@ mod tests {
12281171
12291172 let mut limit_order_counter = MockLimitOrderCounting :: new ( ) ;
12301173 limit_order_counter. expect_count ( ) . returning ( |_| Ok ( 0u64 ) ) ;
1231- let native_token = WETH9 :: Instance :: new ( [ 0xef ; 20 ] . into ( ) , ethrpc:: mock:: web3 ( ) . alloy ) ;
12321174 let validator = OrderValidator :: new (
1233- native_token,
12341175 Arc :: new ( order_validation:: banned:: Users :: none ( ) ) ,
12351176 validity_configuration,
12361177 false ,
@@ -1329,9 +1270,7 @@ mod tests {
13291270
13301271 let mut limit_order_counter = MockLimitOrderCounting :: new ( ) ;
13311272 limit_order_counter. expect_count ( ) . returning ( |_| Ok ( 0u64 ) ) ;
1332- let native_token = WETH9 :: Instance :: new ( [ 0xef ; 20 ] . into ( ) , ethrpc:: mock:: web3 ( ) . alloy ) ;
13331273 let validator = OrderValidator :: new (
1334- native_token,
13351274 Arc :: new ( order_validation:: banned:: Users :: none ( ) ) ,
13361275 OrderValidPeriodConfiguration {
13371276 min : Duration :: from_secs ( 1 ) ,
@@ -1540,9 +1479,7 @@ mod tests {
15401479 . expect_count ( )
15411480 . returning ( |_| Ok ( MAX_LIMIT_ORDERS_PER_USER ) ) ;
15421481
1543- let native_token = WETH9 :: Instance :: new ( [ 0xef ; 20 ] . into ( ) , ethrpc:: mock:: web3 ( ) . alloy ) ;
15441482 let validator = OrderValidator :: new (
1545- native_token,
15461483 Arc :: new ( order_validation:: banned:: Users :: none ( ) ) ,
15471484 OrderValidPeriodConfiguration {
15481485 min : Duration :: from_secs ( 1 ) ,
@@ -1621,9 +1558,7 @@ mod tests {
16211558 . expect_count ( )
16221559 . returning ( |_| Ok ( MAX_LIMIT_ORDERS_PER_USER ) ) ;
16231560
1624- let native_token = WETH9 :: Instance :: new ( [ 0xef ; 20 ] . into ( ) , ethrpc:: mock:: web3 ( ) . alloy ) ;
16251561 let validator = OrderValidator :: new (
1626- native_token,
16271562 Arc :: new ( order_validation:: banned:: Users :: none ( ) ) ,
16281563 OrderValidPeriodConfiguration :: any ( ) ,
16291564 false ,
@@ -1685,9 +1620,7 @@ mod tests {
16851620 . returning ( |_, _| Ok ( ( ) ) ) ;
16861621 let mut limit_order_counter = MockLimitOrderCounting :: new ( ) ;
16871622 limit_order_counter. expect_count ( ) . returning ( |_| Ok ( 0u64 ) ) ;
1688- let native_token = WETH9 :: Instance :: new ( [ 0xef ; 20 ] . into ( ) , ethrpc:: mock:: web3 ( ) . alloy ) ;
16891623 let validator = OrderValidator :: new (
1690- native_token,
16911624 Arc :: new ( order_validation:: banned:: Users :: none ( ) ) ,
16921625 OrderValidPeriodConfiguration :: any ( ) ,
16931626 false ,
@@ -1742,9 +1675,7 @@ mod tests {
17421675 . returning ( |_, _| Ok ( ( ) ) ) ;
17431676 let mut limit_order_counter = MockLimitOrderCounting :: new ( ) ;
17441677 limit_order_counter. expect_count ( ) . returning ( |_| Ok ( 0u64 ) ) ;
1745- let native_token = WETH9 :: Instance :: new ( [ 0xef ; 20 ] . into ( ) , ethrpc:: mock:: web3 ( ) . alloy ) ;
17461678 let validator = OrderValidator :: new (
1747- native_token,
17481679 Arc :: new ( order_validation:: banned:: Users :: none ( ) ) ,
17491680 OrderValidPeriodConfiguration :: any ( ) ,
17501681 false ,
@@ -1802,9 +1733,7 @@ mod tests {
18021733 . returning ( |_, _| Ok ( ( ) ) ) ;
18031734 let mut limit_order_counter = MockLimitOrderCounting :: new ( ) ;
18041735 limit_order_counter. expect_count ( ) . returning ( |_| Ok ( 0u64 ) ) ;
1805- let native_token = WETH9 :: Instance :: new ( [ 0xef ; 20 ] . into ( ) , ethrpc:: mock:: web3 ( ) . alloy ) ;
18061736 let validator = OrderValidator :: new (
1807- native_token,
18081737 Arc :: new ( order_validation:: banned:: Users :: none ( ) ) ,
18091738 OrderValidPeriodConfiguration :: any ( ) ,
18101739 false ,
@@ -1865,9 +1794,7 @@ mod tests {
18651794 . returning ( |_, _| Err ( TransferSimulationError :: InsufficientBalance ) ) ;
18661795 let mut limit_order_counter = MockLimitOrderCounting :: new ( ) ;
18671796 limit_order_counter. expect_count ( ) . returning ( |_| Ok ( 0u64 ) ) ;
1868- let native_token = WETH9 :: Instance :: new ( [ 0xef ; 20 ] . into ( ) , ethrpc:: mock:: web3 ( ) . alloy ) ;
18691797 let validator = OrderValidator :: new (
1870- native_token,
18711798 Arc :: new ( order_validation:: banned:: Users :: none ( ) ) ,
18721799 OrderValidPeriodConfiguration :: any ( ) ,
18731800 false ,
@@ -1927,9 +1854,7 @@ mod tests {
19271854 . returning ( |_| Err ( SignatureValidationError :: Invalid ) ) ;
19281855 let mut limit_order_counter = MockLimitOrderCounting :: new ( ) ;
19291856 limit_order_counter. expect_count ( ) . returning ( |_| Ok ( 0u64 ) ) ;
1930- let native_token = WETH9 :: Instance :: new ( [ 0xef ; 20 ] . into ( ) , ethrpc:: mock:: web3 ( ) . alloy ) ;
19311857 let validator = OrderValidator :: new (
1932- native_token,
19331858 Arc :: new ( order_validation:: banned:: Users :: none ( ) ) ,
19341859 OrderValidPeriodConfiguration :: any ( ) ,
19351860 false ,
@@ -1996,9 +1921,7 @@ mod tests {
19961921 . returning ( move |_, _| Err ( create_error ( ) ) ) ;
19971922 let mut limit_order_counter = MockLimitOrderCounting :: new ( ) ;
19981923 limit_order_counter. expect_count ( ) . returning ( |_| Ok ( 0u64 ) ) ;
1999- let native_token = WETH9 :: Instance :: new ( [ 0xef ; 20 ] . into ( ) , ethrpc:: mock:: web3 ( ) . alloy ) ;
20001924 let validator = OrderValidator :: new (
2001- native_token,
20021925 Arc :: new ( order_validation:: banned:: Users :: none ( ) ) ,
20031926 OrderValidPeriodConfiguration :: any ( ) ,
20041927 false ,
@@ -2087,9 +2010,7 @@ mod tests {
20872010 . returning ( |_, _| Err ( TransferSimulationError :: InsufficientBalance ) ) ;
20882011 let mut limit_order_counter = MockLimitOrderCounting :: new ( ) ;
20892012 limit_order_counter. expect_count ( ) . returning ( |_| Ok ( 0u64 ) ) ;
2090- let native_token = WETH9 :: Instance :: new ( [ 0xef ; 20 ] . into ( ) , ethrpc:: mock:: web3 ( ) . alloy ) ;
20912013 let validator = OrderValidator :: new (
2092- native_token,
20932014 Arc :: new ( order_validation:: banned:: Users :: none ( ) ) ,
20942015 OrderValidPeriodConfiguration :: any ( ) ,
20952016 false ,
@@ -2498,9 +2419,7 @@ mod tests {
24982419 . returning ( |_| Ok ( default_verification_gas_limit ( ) ) ) ;
24992420 let mut limit_order_counter = MockLimitOrderCounting :: new ( ) ;
25002421 limit_order_counter. expect_count ( ) . returning ( |_| Ok ( 0u64 ) ) ;
2501- let native_token = WETH9 :: Instance :: new ( [ 0xef ; 20 ] . into ( ) , ethrpc:: mock:: web3 ( ) . alloy ) ;
25022422 let validator = OrderValidator :: new (
2503- native_token,
25042423 Arc :: new ( order_validation:: banned:: Users :: none ( ) ) ,
25052424 OrderValidPeriodConfiguration {
25062425 min : Duration :: from_secs ( 1 ) ,
0 commit comments