Skip to content

Commit 81ec86a

Browse files
committed
cleanup
1 parent 59777f6 commit 81ec86a

File tree

5 files changed

+22
-101
lines changed

5 files changed

+22
-101
lines changed

Justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ test-e2e-local: (test-e2e "local_node")
2222
test-e2e-forked: (test-e2e "forked_node")
2323

2424
# Run End-to-end tests with custom filters
25-
test-e2e *filters:
26-
cargo nextest run -p e2e '{{filters}}' --test-threads 1 --failure-output final --run-ignored ignored-only
25+
test-e2e filters="" *extra="":
26+
cargo nextest run -p e2e '{{filters}}' --test-threads 1 --failure-output final --run-ignored ignored-only {{extra}}
2727

2828
test-driver:
2929
RUST_MIN_STACK=3145728 cargo nextest run -p driver --test-threads 1 --run-ignored ignored-only

crates/driver/src/domain/quote.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ impl Order {
9696
liquidity
9797
.fetch(&pairs, infra::liquidity::AtBlock::Recent)
9898
.await
99-
},
100-
_ => Default::default(),
99+
}
100+
_ => Default::default(),
101101
};
102102

103103
let auction = self
@@ -228,7 +228,8 @@ impl Order {
228228
/// Returns the token pairs to fetch liquidity for.
229229
fn liquidity_pairs(&self) -> Option<HashSet<liquidity::TokenPair>> {
230230
liquidity::TokenPair::try_new(self.tokens.sell(), self.tokens.buy())
231-
.map(|pair| iter::once(pair).collect()).ok()
231+
.map(|pair| iter::once(pair).collect())
232+
.ok()
232233
}
233234
}
234235

crates/e2e/tests/e2e/place_order_with_quote.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
use {
2-
crate::liquidity::USDC_WHALE, ::alloy::{primitives::{U256, address}, providers::ext::{AnvilApi, ImpersonateConfig}}, contracts::alloy::ERC20, driver::domain::eth::NonZeroU256, e2e::{nodes::local_node::TestNodeApi, setup::*}, ethrpc::alloy::{
2+
::alloy::primitives::U256,
3+
driver::domain::eth::NonZeroU256,
4+
e2e::{nodes::local_node::TestNodeApi, setup::*},
5+
ethrpc::alloy::{
36
CallBuilderExt,
47
conversions::{IntoAlloy, IntoLegacy},
5-
}, model::{
8+
},
9+
model::{
610
order::{OrderCreation, OrderKind},
711
quote::{OrderQuoteRequest, OrderQuoteSide, SellAmount},
812
signature::EcdsaSigningScheme,
9-
}, secp256k1::SecretKey, shared::ethrpc::Web3, std::ops::DerefMut, web3::signing::SecretKeyRef
13+
},
14+
secp256k1::SecretKey,
15+
shared::ethrpc::Web3,
16+
std::ops::DerefMut,
17+
web3::signing::SecretKeyRef,
1018
};
1119

1220
#[tokio::test]
@@ -122,14 +130,13 @@ async fn place_order_with_quote_same_token_pair(web3: Web3) {
122130

123131
let [solver] = onchain.make_solvers(to_wei(10)).await;
124132
let [trader] = onchain.make_accounts(to_wei(10)).await;
125-
let amount = to_wei_with_exp(5, 8).into_alloy();
126133
let [token] = onchain
127134
.deploy_tokens_with_weth_uni_v2_pools(to_wei(1_000), to_wei(1_000))
128135
.await;
129136

130137
token.mint(trader.address(), to_wei(10)).await;
131138

132-
onchain
139+
/*onchain
133140
.contracts()
134141
.weth
135142
.approve(onchain.contracts().allowance.into_alloy(), eth(3))
@@ -145,8 +152,9 @@ async fn place_order_with_quote_same_token_pair(web3: Web3) {
145152
.value(eth(3))
146153
.send_and_watch()
147154
.await
148-
.unwrap();
149-
token.approve(onchain.contracts().allowance.into_alloy(), eth(10))
155+
.unwrap();*/
156+
token
157+
.approve(onchain.contracts().allowance.into_alloy(), eth(10))
150158
.from(trader.address().into_alloy())
151159
.send_and_watch()
152160
.await
@@ -186,12 +194,6 @@ async fn place_order_with_quote_same_token_pair(web3: Web3) {
186194
tracing::debug!(?quote_metadata);
187195

188196
tracing::info!("Placing order");
189-
let balance = token
190-
.balanceOf(trader.address().into_alloy())
191-
.call()
192-
.await
193-
.unwrap();
194-
// assert_eq!(balance, U256::ZERO);
195197
let order = OrderCreation {
196198
quote_id: quote_response.id,
197199
sell_token: token.address().into_legacy(),

crates/orderbook/src/run.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ pub async fn run(args: Arguments) {
410410
.await
411411
.ok();
412412
let order_validator = Arc::new(OrderValidator::new(
413-
native_token.clone(),
414413
Arc::new(order_validation::banned::Users::new(
415414
chainalysis_oracle,
416415
args.banned_users,

crates/shared/src/order_validation.rs

Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -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)]
218217
pub 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 {
290286
impl 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

Comments
 (0)