From fed0e6bda58c294da377da760449695ddf7a32b9 Mon Sep 17 00:00:00 2001 From: Aryan Godara Date: Tue, 16 Dec 2025 21:37:22 +0530 Subject: [PATCH 1/8] Migrate e2e tests to use alloy B256 and Address types Replaces ethcontract H256 and H160 types with alloy B256 and Address types in e2e test setup and test files. Removes unnecessary IntoLegacy conversions when calling get_solver_competition, get_orders_for_tx, and get_orders_for_owner methods. Signed-off-by: Aryan Godara --- crates/e2e/src/setup/services.rs | 13 ++++++------- crates/e2e/tests/e2e/autopilot_leader.rs | 9 +++------ crates/e2e/tests/e2e/jit_orders.rs | 14 ++++---------- crates/e2e/tests/e2e/limit_orders.rs | 11 ++++------- .../tests/e2e/liquidity_source_notification.rs | 7 ++----- crates/e2e/tests/e2e/partial_fill.rs | 10 ++-------- crates/e2e/tests/e2e/solver_competition.rs | 17 +++++++---------- crates/e2e/tests/e2e/wrapper.rs | 9 ++------- 8 files changed, 30 insertions(+), 60 deletions(-) diff --git a/crates/e2e/src/setup/services.rs b/crates/e2e/src/setup/services.rs index 34a0cd9504..990fb00a52 100644 --- a/crates/e2e/src/setup/services.rs +++ b/crates/e2e/src/setup/services.rs @@ -10,11 +10,10 @@ use { wait_for_condition, }, }, - alloy::primitives::Address, + alloy::primitives::{Address, B256}, app_data::{AppDataDocument, AppDataHash}, autopilot::infra::persistence::dto, clap::Parser, - ethcontract::{H160, H256}, model::{ order::{Order, OrderCreation, OrderUid}, quote::{NativeTokenPrice, OrderQuoteRequest, OrderQuoteResponse}, @@ -54,11 +53,11 @@ fn order_status_endpoint(uid: &OrderUid) -> String { format!("/api/v1/orders/{uid}/status") } -fn orders_for_tx_endpoint(tx_hash: &H256) -> String { +fn orders_for_tx_endpoint(tx_hash: &B256) -> String { format!("/api/v1/transactions/{tx_hash:?}/orders") } -fn orders_for_owner(owner: &H160, offset: u64, limit: u64) -> String { +fn orders_for_owner(owner: &Address, offset: u64, limit: u64) -> String { format!("{ACCOUNT_ENDPOINT}/{owner:?}/orders?offset={offset}&limit={limit}") } @@ -436,7 +435,7 @@ impl<'a> Services<'a> { pub async fn get_solver_competition( &self, - hash: H256, + hash: B256, ) -> Result { let response = self .http @@ -598,7 +597,7 @@ impl<'a> Services<'a> { pub async fn get_orders_for_tx( &self, - tx_hash: &H256, + tx_hash: &B256, ) -> Result, (StatusCode, String)> { let response = self .http @@ -618,7 +617,7 @@ impl<'a> Services<'a> { pub async fn get_orders_for_owner( &self, - owner: &H160, + owner: &Address, offset: u64, limit: u64, ) -> Result, (StatusCode, String)> { diff --git a/crates/e2e/tests/e2e/autopilot_leader.rs b/crates/e2e/tests/e2e/autopilot_leader.rs index 189d80a0a5..773f04344a 100644 --- a/crates/e2e/tests/e2e/autopilot_leader.rs +++ b/crates/e2e/tests/e2e/autopilot_leader.rs @@ -3,10 +3,7 @@ use { e2e::setup::{OnchainComponents, Services, TIMEOUT, colocation, run_test, wait_for_condition}, ethrpc::{ Web3, - alloy::{ - CallBuilderExt, - conversions::{IntoAlloy, IntoLegacy}, - }, + alloy::{CallBuilderExt, conversions::IntoAlloy}, }, model::order::{OrderCreation, OrderKind}, number::units::EthUnit, @@ -131,7 +128,7 @@ async fn dual_autopilot_only_leader_produces_auctions(web3: Web3) { if let Some(trade) = services.get_trades(&uid).await.unwrap().first() { services - .get_solver_competition(trade.tx_hash.unwrap().into_legacy()) + .get_solver_competition(trade.tx_hash.unwrap()) .await .ok() .as_ref() @@ -167,7 +164,7 @@ async fn dual_autopilot_only_leader_produces_auctions(web3: Web3) { if let Some(trade) = services.get_trades(&uid).await.unwrap().first() { services - .get_solver_competition(trade.tx_hash.unwrap().into_legacy()) + .get_solver_competition(trade.tx_hash.unwrap()) .await .ok() .as_ref() diff --git a/crates/e2e/tests/e2e/jit_orders.rs b/crates/e2e/tests/e2e/jit_orders.rs index 34cb1efd14..743c5b7214 100644 --- a/crates/e2e/tests/e2e/jit_orders.rs +++ b/crates/e2e/tests/e2e/jit_orders.rs @@ -1,10 +1,7 @@ use { ::alloy::primitives::U256, e2e::setup::{colocation::SolverEngine, mock::Mock, solution::JitOrder, *}, - ethrpc::alloy::{ - CallBuilderExt, - conversions::{IntoAlloy, IntoLegacy}, - }, + ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, model::{ order::{OrderClass, OrderCreation, OrderKind}, signature::EcdsaSigningScheme, @@ -215,14 +212,11 @@ async fn single_limit_order_test(web3: Web3) { .tx_hash?; // jit order can be found on /api/v1/transactions/{tx_hash}/orders - let orders_by_tx = services - .get_orders_for_tx(&tx_hash.into_legacy()) - .await - .ok()?; + let orders_by_tx = services.get_orders_for_tx(&tx_hash).await.ok()?; // jit order can be found on /api/v1/account/{owner}/orders let orders_by_owner = services - .get_orders_for_owner(&jit_order_uid.parts().1.into_legacy(), 0, 10) + .get_orders_for_owner(&jit_order_uid.parts().1, 0, 10) .await .ok()?; let jit_order_by_owner = orders_by_owner @@ -236,7 +230,7 @@ async fn single_limit_order_test(web3: Web3) { // make sure the offset works let orders_by_owner = services - .get_orders_for_owner(&jit_order_uid.parts().1.into_legacy(), 1, 1) + .get_orders_for_owner(&jit_order_uid.parts().1, 1, 1) .await .unwrap(); assert!(orders_by_owner.is_empty()); diff --git a/crates/e2e/tests/e2e/limit_orders.rs b/crates/e2e/tests/e2e/limit_orders.rs index 6460e9c51e..9bf874ea94 100644 --- a/crates/e2e/tests/e2e/limit_orders.rs +++ b/crates/e2e/tests/e2e/limit_orders.rs @@ -9,10 +9,7 @@ use { database::byte_array::ByteArray, driver::domain::eth::NonZeroU256, e2e::setup::*, - ethrpc::alloy::{ - CallBuilderExt, - conversions::{IntoAlloy, IntoLegacy}, - }, + ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, fee::{FeePolicyOrderClass, ProtocolFee, ProtocolFeesConfig}, model::{ order::{OrderClass, OrderCreation, OrderKind}, @@ -484,10 +481,10 @@ async fn two_limit_orders_multiple_winners_test(web3: Web3) { matches!( ( services - .get_solver_competition(trade_a.tx_hash.unwrap().into_legacy()) + .get_solver_competition(trade_a.tx_hash.unwrap()) .await, services - .get_solver_competition(trade_b.tx_hash.unwrap().into_legacy()) + .get_solver_competition(trade_b.tx_hash.unwrap()) .await ), (Ok(_), Ok(_)) @@ -500,7 +497,7 @@ async fn two_limit_orders_multiple_winners_test(web3: Web3) { let trades = services.get_trades(&uid_a).await.unwrap(); let competition = services - .get_solver_competition(trades[0].tx_hash.unwrap().into_legacy()) + .get_solver_competition(trades[0].tx_hash.unwrap()) .await .unwrap(); // Verify that both transactions were properly indexed diff --git a/crates/e2e/tests/e2e/liquidity_source_notification.rs b/crates/e2e/tests/e2e/liquidity_source_notification.rs index 1c31e0e2e5..2105e9aede 100644 --- a/crates/e2e/tests/e2e/liquidity_source_notification.rs +++ b/crates/e2e/tests/e2e/liquidity_source_notification.rs @@ -21,10 +21,7 @@ use { }, ethrpc::{ Web3, - alloy::{ - CallBuilderExt, - conversions::{IntoAlloy, IntoLegacy}, - }, + alloy::{CallBuilderExt, conversions::IntoAlloy}, }, model::{ order::{OrderCreation, OrderKind}, @@ -343,7 +340,7 @@ http-timeout = "10s" let trade = services.get_trades(&order_id).await.unwrap().pop()?; Some( services - .get_solver_competition(trade.tx_hash?.into_legacy()) + .get_solver_competition(trade.tx_hash?) .await .is_ok(), ) diff --git a/crates/e2e/tests/e2e/partial_fill.rs b/crates/e2e/tests/e2e/partial_fill.rs index 472735e144..bdc6cfd7a3 100644 --- a/crates/e2e/tests/e2e/partial_fill.rs +++ b/crates/e2e/tests/e2e/partial_fill.rs @@ -1,10 +1,7 @@ use { ::alloy::primitives::U256, e2e::setup::*, - ethrpc::alloy::{ - CallBuilderExt, - conversions::{IntoAlloy, IntoLegacy}, - }, + ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, model::{ order::{OrderCreation, OrderKind}, signature::{EcdsaSigningScheme, Signature, SigningScheme}, @@ -118,10 +115,7 @@ async fn test(web3: Web3) { .unwrap(); let tx_hash = services.get_trades(&uid).await.unwrap()[0].tx_hash.unwrap(); - let competition = services - .get_solver_competition(tx_hash.into_legacy()) - .await - .unwrap(); + let competition = services.get_solver_competition(tx_hash).await.unwrap(); assert!(!competition.solutions.is_empty()); assert!(competition.auction.orders.contains(&uid)); let latest_competition = services.get_latest_solver_competition().await.unwrap(); diff --git a/crates/e2e/tests/e2e/solver_competition.rs b/crates/e2e/tests/e2e/solver_competition.rs index b3c9ce4025..59b8c9c90a 100644 --- a/crates/e2e/tests/e2e/solver_competition.rs +++ b/crates/e2e/tests/e2e/solver_competition.rs @@ -1,10 +1,7 @@ use { ::alloy::primitives::U256, e2e::setup::{colocation::SolverEngine, mock::Mock, *}, - ethrpc::alloy::{ - CallBuilderExt, - conversions::{IntoAlloy, IntoLegacy}, - }, + ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, model::{ order::{OrderCreation, OrderKind}, signature::EcdsaSigningScheme, @@ -130,7 +127,7 @@ async fn solver_competition(web3: Web3) { onchain.mint_block().await; match services.get_trades(&uid).await.unwrap().first() { Some(trade) => services - .get_solver_competition(trade.tx_hash.unwrap().into_legacy()) + .get_solver_competition(trade.tx_hash.unwrap()) .await .is_ok(), None => false, @@ -140,7 +137,7 @@ async fn solver_competition(web3: Web3) { let trades = services.get_trades(&uid).await.unwrap(); let competition = services - .get_solver_competition(trades[0].tx_hash.unwrap().into_legacy()) + .get_solver_competition(trades[0].tx_hash.unwrap()) .await .unwrap(); @@ -279,7 +276,7 @@ async fn wrong_solution_submission_address(web3: Web3) { onchain.mint_block().await; match services.get_trades(&uid_a).await.unwrap().first() { Some(trade) => services - .get_solver_competition(trade.tx_hash.unwrap().into_legacy()) + .get_solver_competition(trade.tx_hash.unwrap()) .await .is_ok(), None => false, @@ -290,7 +287,7 @@ async fn wrong_solution_submission_address(web3: Web3) { // Verify that test_solver was excluded due to wrong driver address let trades = services.get_trades(&uid_a).await.unwrap(); let competition = services - .get_solver_competition(trades[0].tx_hash.unwrap().into_legacy()) + .get_solver_competition(trades[0].tx_hash.unwrap()) .await .unwrap(); tracing::info!(?competition, "competition"); @@ -492,7 +489,7 @@ async fn store_filtered_solutions(web3: Web3) { let trade = services.get_trades(&order_ab_id).await.unwrap().pop()?; Some( services - .get_solver_competition(trade.tx_hash?.into_legacy()) + .get_solver_competition(trade.tx_hash?) .await .is_ok(), ) @@ -508,7 +505,7 @@ async fn store_filtered_solutions(web3: Web3) { .unwrap(); let competition = services - .get_solver_competition(trade.tx_hash.unwrap().into_legacy()) + .get_solver_competition(trade.tx_hash.unwrap()) .await .unwrap(); diff --git a/crates/e2e/tests/e2e/wrapper.rs b/crates/e2e/tests/e2e/wrapper.rs index 5eee690181..33d4f52a86 100644 --- a/crates/e2e/tests/e2e/wrapper.rs +++ b/crates/e2e/tests/e2e/wrapper.rs @@ -10,10 +10,7 @@ use { app_data::{AppDataHash, hash_full_app_data}, contracts::alloy::ERC20, e2e::setup::*, - ethrpc::alloy::{ - CallBuilderExt, - conversions::{IntoAlloy, IntoLegacy}, - }, + ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, model::{ order::{OrderCreation, OrderCreationAppData, OrderKind}, quote::{OrderQuoteRequest, OrderQuoteSide, SellAmount}, @@ -308,9 +305,7 @@ async fn forked_mainnet_wrapper_test(web3: Web3) { // Sometimes the API isnt ready to respond to the request immediately so we wait // a bit for success wait_for_condition(TIMEOUT, || async { - let auction_info = services - .get_solver_competition(solve_tx_hash.into_legacy()) - .await; + let auction_info = services.get_solver_competition(solve_tx_hash).await; if let Ok(a) = auction_info { tracing::info!("Pulled auction id {:?}", a.auction_id); From 9b54f1e5fe3d9993ebeb53293a6a3757dba4808d Mon Sep 17 00:00:00 2001 From: Aryan Godara Date: Tue, 16 Dec 2025 22:53:32 +0530 Subject: [PATCH 2/8] Migrate e2e tests to use alloy Address and B256 types Replaces ethcontract Address and H256 types with alloy Address and B256 types in e2e test setup and test files. Removes unnecessary IntoAlloy and IntoLegacy conversions throughout the codebase. Updates default_pool_code method to use B256::new constructor. Signed-off-by: Aryan Godara --- crates/e2e/src/setup/deploy.rs | 39 +++++++------- crates/e2e/tests/e2e/app_data.rs | 6 +-- crates/e2e/tests/e2e/app_data_signer.rs | 8 +-- crates/e2e/tests/e2e/autopilot_leader.rs | 4 +- crates/e2e/tests/e2e/banned_users.rs | 4 +- crates/e2e/tests/e2e/buffers.rs | 4 +- crates/e2e/tests/e2e/cow_amm.rs | 12 ++--- crates/e2e/tests/e2e/eth_integration.rs | 13 ++--- crates/e2e/tests/e2e/eth_safe.rs | 6 +-- crates/e2e/tests/e2e/hooks.rs | 12 ++--- crates/e2e/tests/e2e/jit_orders.rs | 6 +-- crates/e2e/tests/e2e/limit_orders.rs | 22 ++++---- crates/e2e/tests/e2e/liquidity.rs | 2 +- .../e2e/liquidity_source_notification.rs | 4 +- crates/e2e/tests/e2e/order_cancellation.rs | 4 +- crates/e2e/tests/e2e/partial_fill.rs | 4 +- .../tests/e2e/partially_fillable_balance.rs | 4 +- .../e2e/tests/e2e/partially_fillable_pool.rs | 4 +- .../e2e/tests/e2e/place_order_with_quote.rs | 4 +- crates/e2e/tests/e2e/protocol_fee.rs | 51 +++++++++---------- crates/e2e/tests/e2e/quote_verification.rs | 15 +++--- crates/e2e/tests/e2e/quoting.rs | 10 ++-- crates/e2e/tests/e2e/replace_order.rs | 10 ++-- crates/e2e/tests/e2e/smart_contract_orders.rs | 6 +-- crates/e2e/tests/e2e/solver_competition.rs | 10 ++-- .../tests/e2e/solver_participation_guard.rs | 4 +- crates/e2e/tests/e2e/submission.rs | 2 +- .../tests/e2e/tracking_insufficient_funds.rs | 6 +-- crates/e2e/tests/e2e/uncovered_order.rs | 4 +- crates/e2e/tests/e2e/univ2.rs | 4 +- crates/e2e/tests/e2e/vault_balances.rs | 4 +- crates/e2e/tests/e2e/wrapper.rs | 4 +- 32 files changed, 145 insertions(+), 147 deletions(-) diff --git a/crates/e2e/src/setup/deploy.rs b/crates/e2e/src/setup/deploy.rs index 85cb82dfb7..a940d36def 100644 --- a/crates/e2e/src/setup/deploy.rs +++ b/crates/e2e/src/setup/deploy.rs @@ -12,11 +12,8 @@ use { WETH9, support::{Balances, Signatures}, }, - ethcontract::{Address, H256}, - ethrpc::alloy::{ - CallBuilderExt, - conversions::{IntoAlloy, IntoLegacy}, - }, + alloy::primitives::{Address, B256}, + ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, model::DomainSeparator, shared::ethrpc::Web3, }; @@ -37,7 +34,7 @@ pub struct Contracts { pub uniswap_v2_factory: UniswapV2Factory::Instance, pub uniswap_v2_router: UniswapV2Router02::Instance, pub weth: WETH9::Instance, - pub allowance: Address, + pub allowance: alloy::primitives::Address, pub domain_separator: DomainSeparator, pub ethflows: Vec, pub hooks: HooksTrampoline::Instance, @@ -58,13 +55,13 @@ impl Contracts { .await .unwrap(); let balances = match deployed.balances { - Some(address) => Balances::Instance::new(address.into_alloy(), web3.alloy.clone()), + Some(address) => Balances::Instance::new(address, web3.alloy.clone()), None => Balances::Instance::deployed(&web3.alloy) .await .expect("failed to find balances contract"), }; let signatures = match deployed.signatures { - Some(address) => Signatures::Instance::new(address.into_alloy(), web3.alloy.clone()), + Some(address) => Signatures::Instance::new(address, web3.alloy.clone()), None => Signatures::Instance::deployed(&web3.alloy) .await .expect("failed to find signatures contract"), @@ -93,8 +90,7 @@ impl Contracts { .vaultRelayer() .call() .await - .expect("Couldn't get vault relayer address") - .into_legacy(), + .expect("Couldn't get vault relayer address"), domain_separator: DomainSeparator( gp_settlement .domainSeparator() @@ -127,13 +123,20 @@ impl Contracts { .to_string(); tracing::info!("connected to test network {}", network_id); - let accounts: Vec
= web3.eth().accounts().await.expect("get accounts failed"); + let accounts: Vec
= web3 + .eth() + .accounts() + .await + .expect("get accounts failed") + .into_iter() + .map(|a| a.into_alloy()) + .collect(); let admin = accounts[0]; let weth = WETH9::Instance::deploy(web3.alloy.clone()).await.unwrap(); let balancer_authorizer = - BalancerV2Authorizer::Instance::deploy(web3.alloy.clone(), admin.into_alloy()) + BalancerV2Authorizer::Instance::deploy(web3.alloy.clone(), admin) .await .unwrap(); let balancer_vault = BalancerV2Vault::Instance::deploy( @@ -147,7 +150,7 @@ impl Contracts { .unwrap(); let uniswap_v2_factory = - UniswapV2Factory::Instance::deploy(web3.alloy.clone(), accounts[0].into_alloy()) + UniswapV2Factory::Instance::deploy(web3.alloy.clone(), accounts[0]) .await .unwrap(); let uniswap_v2_router = UniswapV2Router02::Instance::deploy( @@ -162,7 +165,7 @@ impl Contracts { .await .unwrap(); gp_authenticator - .initializeManager(admin.into_alloy()) + .initializeManager(admin) .send_and_watch() .await .expect("failed to initialize manager"); @@ -197,7 +200,7 @@ impl Contracts { .call() .await .expect("Couldn't get vault relayer address") - .into_legacy(); +; let domain_separator = DomainSeparator( gp_settlement .domainSeparator() @@ -250,10 +253,10 @@ impl Contracts { } } - pub fn default_pool_code(&self) -> H256 { + pub fn default_pool_code(&self) -> B256 { match self.chain_id { - 100 => H256(shared::sources::uniswap_v2::HONEYSWAP_INIT), - _ => H256(shared::sources::uniswap_v2::UNISWAP_INIT), + 100 => B256::new(shared::sources::uniswap_v2::HONEYSWAP_INIT), + _ => B256::new(shared::sources::uniswap_v2::UNISWAP_INIT), } } } diff --git a/crates/e2e/tests/e2e/app_data.rs b/crates/e2e/tests/e2e/app_data.rs index 5b5a81d679..74e550e9e6 100644 --- a/crates/e2e/tests/e2e/app_data.rs +++ b/crates/e2e/tests/e2e/app_data.rs @@ -1,7 +1,7 @@ use { app_data::{AppDataHash, hash_full_app_data}, e2e::setup::*, - ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, + ethrpc::alloy::{CallBuilderExt}, model::{ order::{OrderCreation, OrderCreationAppData, OrderKind}, quote::{OrderQuoteRequest, OrderQuoteSide, SellAmount}, @@ -39,7 +39,7 @@ async fn app_data(web3: Web3) { token_a.mint(trader.address(), 10u64.eth()).await; token_a - .approve(onchain.contracts().allowance.into_alloy(), 10u64.eth()) + .approve(onchain.contracts().allowance, 10u64.eth()) .from(trader.address()) .send_and_watch() .await @@ -201,7 +201,7 @@ async fn app_data_full_format(web3: Web3) { token_a.mint(trader.address(), 10u64.eth()).await; token_a - .approve(onchain.contracts().allowance.into_alloy(), 10u64.eth()) + .approve(onchain.contracts().allowance, 10u64.eth()) .from(trader.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/app_data_signer.rs b/crates/e2e/tests/e2e/app_data_signer.rs index 49744fe628..5445ce8c7d 100644 --- a/crates/e2e/tests/e2e/app_data_signer.rs +++ b/crates/e2e/tests/e2e/app_data_signer.rs @@ -1,7 +1,7 @@ use { alloy::primitives::Address, e2e::setup::{OnchainComponents, Services, TestAccount, run_test, safe::Safe}, - ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, + ethrpc::alloy::{CallBuilderExt}, model::{ order::{OrderCreation, OrderCreationAppData, OrderKind}, signature::EcdsaSigningScheme, @@ -29,7 +29,7 @@ async fn order_creation_checks_metadata_signer(web3: Web3) { token_a.mint(trader.address(), 10u64.eth()).await; token_a - .approve(onchain.contracts().allowance.into_alloy(), 10u64.eth()) + .approve(onchain.contracts().allowance, 10u64.eth()) .from(trader.address()) .send_and_watch() .await @@ -37,7 +37,7 @@ async fn order_creation_checks_metadata_signer(web3: Web3) { token_a.mint(adversary.address(), 10u64.eth()).await; token_a - .approve(onchain.contracts().allowance.into_alloy(), 10u64.eth()) + .approve(onchain.contracts().allowance, 10u64.eth()) .from(adversary.address()) .send_and_watch() .await @@ -100,7 +100,7 @@ async fn order_creation_checks_metadata_signer(web3: Web3) { token_a.mint(safe.address(), 10u64.eth()).await; safe.exec_alloy_call( token_a - .approve(onchain.contracts().allowance.into_alloy(), 10u64.eth()) + .approve(onchain.contracts().allowance, 10u64.eth()) .into_transaction_request(), ) .await; diff --git a/crates/e2e/tests/e2e/autopilot_leader.rs b/crates/e2e/tests/e2e/autopilot_leader.rs index 773f04344a..4b18175a66 100644 --- a/crates/e2e/tests/e2e/autopilot_leader.rs +++ b/crates/e2e/tests/e2e/autopilot_leader.rs @@ -3,7 +3,7 @@ use { e2e::setup::{OnchainComponents, Services, TIMEOUT, colocation, run_test, wait_for_condition}, ethrpc::{ Web3, - alloy::{CallBuilderExt, conversions::IntoAlloy}, + alloy::{CallBuilderExt}, }, model::order::{OrderCreation, OrderKind}, number::units::EthUnit, @@ -36,7 +36,7 @@ async fn dual_autopilot_only_leader_produces_auctions(web3: Web3) { // Approve GPv2 for trading token_a - .approve(onchain.contracts().allowance.into_alloy(), 1000u64.eth()) + .approve(onchain.contracts().allowance, 1000u64.eth()) .from(trader.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/banned_users.rs b/crates/e2e/tests/e2e/banned_users.rs index eb912035de..5e4ab46dd3 100644 --- a/crates/e2e/tests/e2e/banned_users.rs +++ b/crates/e2e/tests/e2e/banned_users.rs @@ -5,7 +5,7 @@ use { }, contracts::alloy::ERC20, e2e::setup::{OnchainComponents, Services, run_forked_test_with_block_number}, - ethrpc::{Web3, alloy::conversions::IntoAlloy}, + ethrpc::Web3, model::quote::{OrderQuoteRequest, OrderQuoteSide, SellAmount}, number::units::EthUnit, reqwest::StatusCode, @@ -64,7 +64,7 @@ async fn forked_mainnet_onchain_banned_user_test(web3: Web3) { web3.alloy .anvil_send_impersonated_transaction_with_config( token_dai - .approve(onchain.contracts().allowance.into_alloy(), 1000u64.eth()) + .approve(onchain.contracts().allowance, 1000u64.eth()) .from(BANNED_USER) .into_transaction_request(), ImpersonateConfig { diff --git a/crates/e2e/tests/e2e/buffers.rs b/crates/e2e/tests/e2e/buffers.rs index 419781e4e9..b3b77830bf 100644 --- a/crates/e2e/tests/e2e/buffers.rs +++ b/crates/e2e/tests/e2e/buffers.rs @@ -1,7 +1,7 @@ use { ::alloy::primitives::U256, e2e::setup::*, - ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, + ethrpc::alloy::{CallBuilderExt}, model::{ order::{OrderCreation, OrderKind}, signature::EcdsaSigningScheme, @@ -38,7 +38,7 @@ async fn onchain_settlement_without_liquidity(web3: Web3) { // Approve GPv2 for trading token_a - .approve(onchain.contracts().allowance.into_alloy(), 100u64.eth()) + .approve(onchain.contracts().allowance, 100u64.eth()) .from(trader.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/cow_amm.rs b/crates/e2e/tests/e2e/cow_amm.rs index 88ad5b63cf..699b52585f 100644 --- a/crates/e2e/tests/e2e/cow_amm.rs +++ b/crates/e2e/tests/e2e/cow_amm.rs @@ -22,7 +22,7 @@ use { ethcontract::{BlockId, BlockNumber}, ethrpc::alloy::{ CallBuilderExt, - conversions::{IntoAlloy, IntoLegacy}, + conversions::IntoAlloy, }, model::{ order::{OrderClass, OrderCreation, OrderKind, OrderUid}, @@ -279,7 +279,7 @@ async fn cow_amm_jit(web3: Web3) { .contracts() .weth .approve( - onchain.contracts().allowance.into_alloy(), + onchain.contracts().allowance, alloy::primitives::U256::MAX, ) .from(bob.address()) @@ -394,8 +394,8 @@ async fn cow_amm_driver_support(web3: Web3) { .await .unwrap(); DeployedContracts { - balances: Some(balances.address().into_legacy()), - signatures: Some(signatures.address().into_legacy()), + balances: Some(*balances.address()), + signatures: Some(*signatures.address()), } }; let mut onchain = OnchainComponents::deployed_with(web3.clone(), deployed_contracts).await; @@ -476,7 +476,7 @@ async fn cow_amm_driver_support(web3: Web3) { .unwrap(); // Approve GPv2 for trading - usdc.approve(onchain.contracts().allowance.into_alloy(), 1000u64.matom()) + usdc.approve(onchain.contracts().allowance, 1000u64.matom()) .from(trader.address()) .send_and_watch() .await @@ -897,7 +897,7 @@ async fn cow_amm_opposite_direction(web3: Web3) { dai.mint(bob.address(), 250u64.eth()).await; dai.approve( - onchain.contracts().allowance.into_alloy(), + onchain.contracts().allowance, alloy::primitives::U256::MAX, ) .from(bob.address()) diff --git a/crates/e2e/tests/e2e/eth_integration.rs b/crates/e2e/tests/e2e/eth_integration.rs index d3d2786cfe..0847de6da8 100644 --- a/crates/e2e/tests/e2e/eth_integration.rs +++ b/crates/e2e/tests/e2e/eth_integration.rs @@ -1,10 +1,7 @@ use { + ::alloy::primitives::Address, e2e::setup::*, - ethcontract::prelude::Address, - ethrpc::alloy::{ - CallBuilderExt, - conversions::{IntoAlloy, IntoLegacy}, - }, + ethrpc::alloy::{CallBuilderExt, conversions::IntoLegacy}, model::{ order::{BUY_ETH_ADDRESS, OrderCreation, OrderKind}, quote::{OrderQuoteRequest, OrderQuoteSide, SellAmount}, @@ -38,14 +35,14 @@ async fn eth_integration(web3: Web3) { // Approve GPv2 for trading token - .approve(onchain.contracts().allowance.into_alloy(), 51u64.eth()) + .approve(onchain.contracts().allowance, 51u64.eth()) .from(trader_a.address()) .send_and_watch() .await .unwrap(); token - .approve(onchain.contracts().allowance.into_alloy(), 51u64.eth()) + .approve(onchain.contracts().allowance, 51u64.eth()) .from(trader_b.address()) .send_and_watch() .await @@ -66,7 +63,7 @@ async fn eth_integration(web3: Web3) { let request = OrderQuoteRequest { sell_token, buy_token, - from: Address::default().into_alloy(), + from: Address::default(), side: OrderQuoteSide::Sell { sell_amount: SellAmount::AfterFee { value: NonZeroU256::try_from(43u64.eth()).unwrap(), diff --git a/crates/e2e/tests/e2e/eth_safe.rs b/crates/e2e/tests/e2e/eth_safe.rs index 41ce8f02d6..9b438304d4 100644 --- a/crates/e2e/tests/e2e/eth_safe.rs +++ b/crates/e2e/tests/e2e/eth_safe.rs @@ -1,7 +1,7 @@ use { ::alloy::{primitives::U256, providers::Provider}, e2e::setup::{OnchainComponents, Services, TIMEOUT, run_test, safe::Safe, wait_for_condition}, - ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, + ethrpc::alloy::{CallBuilderExt}, model::{ order::{BUY_ETH_ADDRESS, OrderCreation, OrderKind}, signature::{Signature, hashed_eip712_message}, @@ -30,14 +30,14 @@ async fn test(web3: Web3) { token.mint(trader.address(), 4u64.eth()).await; safe.exec_alloy_call( token - .approve(onchain.contracts().allowance.into_alloy(), 4u64.eth()) + .approve(onchain.contracts().allowance, 4u64.eth()) .into_transaction_request(), ) .await; token.mint(safe.address(), 4u64.eth()).await; token - .approve(onchain.contracts().allowance.into_alloy(), 4u64.eth()) + .approve(onchain.contracts().allowance, 4u64.eth()) .from(trader.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/hooks.rs b/crates/e2e/tests/e2e/hooks.rs index 89c214fa7c..e3d681586d 100644 --- a/crates/e2e/tests/e2e/hooks.rs +++ b/crates/e2e/tests/e2e/hooks.rs @@ -12,7 +12,7 @@ use { }, ethrpc::alloy::{ CallBuilderExt, - conversions::{IntoAlloy, IntoLegacy}, + conversions::{IntoLegacy}, }, model::{ order::{OrderCreation, OrderCreationAppData, OrderKind}, @@ -72,7 +72,7 @@ async fn gas_limit(web3: Web3) { // Fund trader accounts and approve relayer cow.fund(trader.address(), 5u64.eth()).await; - cow.approve(onchain.contracts().allowance.into_alloy(), 5u64.eth()) + cow.approve(onchain.contracts().allowance, 5u64.eth()) .from(trader.address()) .send_and_watch() .await @@ -135,7 +135,7 @@ async fn allowance(web3: Web3) { let permit = cow .permit( &trader, - onchain.contracts().allowance, + onchain.contracts().allowance.into_legacy(), 5u64.eth().into_legacy(), ) .await; @@ -313,7 +313,7 @@ async fn signature(web3: Web3) { // Sign an approval transaction for trading. This will be at nonce 0 because // it is the first transaction evah! let approval_call_data = token - .approve(onchain.contracts().allowance.into_alloy(), 5u64.eth()) + .approve(onchain.contracts().allowance, 5u64.eth()) .calldata() .to_vec(); let approval_builder = safe.sign_transaction( @@ -434,7 +434,7 @@ async fn partial_fills(web3: Web3) { let sell_token = onchain.contracts().weth.clone(); sell_token - .approve(onchain.contracts().allowance.into_alloy(), 2u64.eth()) + .approve(onchain.contracts().allowance, 2u64.eth()) .from(trader.address()) .send_and_watch() .await @@ -587,7 +587,7 @@ async fn quote_verification(web3: Web3) { token.mint(safe.address(), 5u64.eth()).await; token - .approve(onchain.contracts().allowance.into_alloy(), 5u64.eth()) + .approve(onchain.contracts().allowance, 5u64.eth()) .from(trader.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/jit_orders.rs b/crates/e2e/tests/e2e/jit_orders.rs index 743c5b7214..dd1f152eca 100644 --- a/crates/e2e/tests/e2e/jit_orders.rs +++ b/crates/e2e/tests/e2e/jit_orders.rs @@ -1,7 +1,7 @@ use { ::alloy::primitives::U256, e2e::setup::{colocation::SolverEngine, mock::Mock, solution::JitOrder, *}, - ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, + ethrpc::alloy::{CallBuilderExt}, model::{ order::{OrderClass, OrderCreation, OrderKind}, signature::EcdsaSigningScheme, @@ -44,14 +44,14 @@ async fn single_limit_order_test(web3: Web3) { onchain .contracts() .weth - .approve(onchain.contracts().allowance.into_alloy(), U256::MAX) + .approve(onchain.contracts().allowance, U256::MAX) .from(trader.address()) .send_and_watch() .await .unwrap(); token - .approve(onchain.contracts().allowance.into_alloy(), U256::MAX) + .approve(onchain.contracts().allowance, U256::MAX) .from(solver.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/limit_orders.rs b/crates/e2e/tests/e2e/limit_orders.rs index 9bf874ea94..a657633072 100644 --- a/crates/e2e/tests/e2e/limit_orders.rs +++ b/crates/e2e/tests/e2e/limit_orders.rs @@ -9,7 +9,7 @@ use { database::byte_array::ByteArray, driver::domain::eth::NonZeroU256, e2e::setup::*, - ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, + ethrpc::alloy::{CallBuilderExt}, fee::{FeePolicyOrderClass, ProtocolFee, ProtocolFeesConfig}, model::{ order::{OrderClass, OrderCreation, OrderKind}, @@ -155,7 +155,7 @@ async fn single_limit_order_test(web3: Web3) { // Approve GPv2 for trading token_a - .approve(onchain.contracts().allowance.into_alloy(), 10u64.eth()) + .approve(onchain.contracts().allowance, 10u64.eth()) .from(trader_a.address()) .send_and_watch() .await @@ -277,14 +277,14 @@ async fn two_limit_orders_test(web3: Web3) { // Approve GPv2 for trading token_a - .approve(onchain.contracts().allowance.into_alloy(), 10u64.eth()) + .approve(onchain.contracts().allowance, 10u64.eth()) .from(trader_a.address()) .send_and_watch() .await .unwrap(); token_b - .approve(onchain.contracts().allowance.into_alloy(), 10u64.eth()) + .approve(onchain.contracts().allowance, 10u64.eth()) .from(trader_b.address()) .send_and_watch() .await @@ -379,14 +379,14 @@ async fn two_limit_orders_multiple_winners_test(web3: Web3) { // Approve GPv2 for trading token_a - .approve(onchain.contracts().allowance.into_alloy(), 100u64.eth()) + .approve(onchain.contracts().allowance, 100u64.eth()) .from(trader_a.address()) .send_and_watch() .await .unwrap(); token_b - .approve(onchain.contracts().allowance.into_alloy(), 100u64.eth()) + .approve(onchain.contracts().allowance, 100u64.eth()) .from(trader_b.address()) .send_and_watch() .await @@ -605,7 +605,7 @@ async fn too_many_limit_orders_test(web3: Web3) { // Approve GPv2 for trading token_a - .approve(onchain.contracts().allowance.into_alloy(), 101u64.eth()) + .approve(onchain.contracts().allowance, 101u64.eth()) .from(trader.address()) .send_and_watch() .await @@ -687,7 +687,7 @@ async fn limit_does_not_apply_to_in_market_orders_test(web3: Web3) { // Approve GPv2 for trading token - .approve(onchain.contracts().allowance.into_alloy(), 101u64.eth()) + .approve(onchain.contracts().allowance, 101u64.eth()) .from(trader.address()) .send_and_watch() .await @@ -842,7 +842,7 @@ async fn forked_mainnet_single_limit_order_test(web3: Web3) { // Approve GPv2 for trading token_usdc - .approve(onchain.contracts().allowance.into_alloy(), 1000u64.matom()) + .approve(onchain.contracts().allowance, 1000u64.matom()) .from(trader.address()) .send_and_watch() .await @@ -942,7 +942,7 @@ async fn forked_gnosis_single_limit_order_test(web3: Web3) { // Approve GPv2 for trading token_usdc - .approve(onchain.contracts().allowance.into_alloy(), 1000u64.matom()) + .approve(onchain.contracts().allowance, 1000u64.matom()) .from(trader.address()) .send_and_watch() .await @@ -1007,7 +1007,7 @@ async fn no_liquidity_limit_order(web3: Web3) { // Approve GPv2 for trading token_a - .approve(onchain.contracts().allowance.into_alloy(), 10u64.eth()) + .approve(onchain.contracts().allowance, 10u64.eth()) .from(trader_a.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/liquidity.rs b/crates/e2e/tests/e2e/liquidity.rs index 8fd5804065..4cad34300b 100644 --- a/crates/e2e/tests/e2e/liquidity.rs +++ b/crates/e2e/tests/e2e/liquidity.rs @@ -135,7 +135,7 @@ async fn zero_ex_liquidity(web3: Web3) { .unwrap(); token_usdc - .approve(onchain.contracts().allowance.into_alloy(), amount) + .approve(onchain.contracts().allowance, amount) .from(trader.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/liquidity_source_notification.rs b/crates/e2e/tests/e2e/liquidity_source_notification.rs index 2105e9aede..e3e3cccc13 100644 --- a/crates/e2e/tests/e2e/liquidity_source_notification.rs +++ b/crates/e2e/tests/e2e/liquidity_source_notification.rs @@ -21,7 +21,7 @@ use { }, ethrpc::{ Web3, - alloy::{CallBuilderExt, conversions::IntoAlloy}, + alloy::{CallBuilderExt}, }, model::{ order::{OrderCreation, OrderKind}, @@ -118,7 +118,7 @@ async fn liquidity_source_notification(web3: Web3) { // Trader gives approval to the CoW allowance contract token_usdc .approve( - onchain.contracts().allowance.into_alloy(), + onchain.contracts().allowance, alloy::primitives::U256::MAX, ) .from(trader.address()) diff --git a/crates/e2e/tests/e2e/order_cancellation.rs b/crates/e2e/tests/e2e/order_cancellation.rs index 00e1445cac..467239674f 100644 --- a/crates/e2e/tests/e2e/order_cancellation.rs +++ b/crates/e2e/tests/e2e/order_cancellation.rs @@ -2,7 +2,7 @@ use { ::alloy::primitives::U256, database::order_events::OrderEventLabel, e2e::setup::*, - ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, + ethrpc::alloy::{CallBuilderExt}, model::{ order::{ CancellationPayload, @@ -44,7 +44,7 @@ async fn order_cancellation(web3: Web3) { // Approve GPv2 for trading token - .approve(onchain.contracts().allowance.into_alloy(), 10u64.eth()) + .approve(onchain.contracts().allowance, 10u64.eth()) .from(trader.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/partial_fill.rs b/crates/e2e/tests/e2e/partial_fill.rs index bdc6cfd7a3..e324330bbf 100644 --- a/crates/e2e/tests/e2e/partial_fill.rs +++ b/crates/e2e/tests/e2e/partial_fill.rs @@ -1,7 +1,7 @@ use { ::alloy::primitives::U256, e2e::setup::*, - ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, + ethrpc::alloy::{CallBuilderExt}, model::{ order::{OrderCreation, OrderKind}, signature::{EcdsaSigningScheme, Signature, SigningScheme}, @@ -33,7 +33,7 @@ async fn test(web3: Web3) { onchain .contracts() .weth - .approve(onchain.contracts().allowance.into_alloy(), 4u64.eth()) + .approve(onchain.contracts().allowance, 4u64.eth()) .from(trader.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/partially_fillable_balance.rs b/crates/e2e/tests/e2e/partially_fillable_balance.rs index 1b85a75402..ecd79c42d3 100644 --- a/crates/e2e/tests/e2e/partially_fillable_balance.rs +++ b/crates/e2e/tests/e2e/partially_fillable_balance.rs @@ -1,7 +1,7 @@ use { ::alloy::primitives::U256, e2e::setup::*, - ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, + ethrpc::alloy::{CallBuilderExt}, model::{ order::{OrderCreation, OrderKind}, signature::EcdsaSigningScheme, @@ -78,7 +78,7 @@ async fn test(web3: Web3) { .unwrap(); token_a - .approve(onchain.contracts().allowance.into_alloy(), 500u64.eth()) + .approve(onchain.contracts().allowance, 500u64.eth()) .from(trader_a.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/partially_fillable_pool.rs b/crates/e2e/tests/e2e/partially_fillable_pool.rs index ddc79272a1..af7413586d 100644 --- a/crates/e2e/tests/e2e/partially_fillable_pool.rs +++ b/crates/e2e/tests/e2e/partially_fillable_pool.rs @@ -1,7 +1,7 @@ use { ::alloy::primitives::U256, e2e::setup::*, - ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, + ethrpc::alloy::{CallBuilderExt}, model::{ order::{OrderCreation, OrderKind}, signature::EcdsaSigningScheme, @@ -77,7 +77,7 @@ async fn test(web3: Web3) { .unwrap(); token_a - .approve(onchain.contracts().allowance.into_alloy(), 500u64.eth()) + .approve(onchain.contracts().allowance, 500u64.eth()) .from(trader_a.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/place_order_with_quote.rs b/crates/e2e/tests/e2e/place_order_with_quote.rs index a199f3a7bd..1d8ec1ac07 100644 --- a/crates/e2e/tests/e2e/place_order_with_quote.rs +++ b/crates/e2e/tests/e2e/place_order_with_quote.rs @@ -2,7 +2,7 @@ use { ::alloy::primitives::U256, driver::domain::eth::NonZeroU256, e2e::{nodes::local_node::TestNodeApi, setup::*}, - ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, + ethrpc::alloy::{CallBuilderExt}, model::{ order::{OrderCreation, OrderKind}, quote::{OrderQuoteRequest, OrderQuoteSide, SellAmount}, @@ -39,7 +39,7 @@ async fn place_order_with_quote(web3: Web3) { onchain .contracts() .weth - .approve(onchain.contracts().allowance.into_alloy(), 3u64.eth()) + .approve(onchain.contracts().allowance, 3u64.eth()) .from(trader.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/protocol_fee.rs b/crates/e2e/tests/e2e/protocol_fee.rs index 98daf2ede9..682df73ce7 100644 --- a/crates/e2e/tests/e2e/protocol_fee.rs +++ b/crates/e2e/tests/e2e/protocol_fee.rs @@ -1,11 +1,10 @@ use { - ::alloy::primitives::U256, + ::alloy::primitives::{Address, U256}, driver::domain::eth::NonZeroU256, e2e::{ assert_approximately_eq, setup::{fee::*, *}, }, - ethcontract::Address, ethrpc::alloy::{ CallBuilderExt, conversions::{IntoAlloy, IntoLegacy}, @@ -125,7 +124,7 @@ async fn combined_protocol_fees(web3: Web3) { onchain .contracts() .weth - .approve(onchain.contracts().allowance.into_alloy(), 100u64.eth()) + .approve(onchain.contracts().allowance, 100u64.eth()) .from(trader.address()) .send_and_watch() .await @@ -184,10 +183,10 @@ async fn combined_protocol_fees(web3: Web3) { .map(|token| { get_quote( &services, - onchain.contracts().weth.address().into_legacy(), - token.address().into_legacy(), + *onchain.contracts().weth.address(), + *token.address(), OrderKind::Sell, - sell_amount, + sell_amount.into_alloy(), quote_valid_to, ) }), @@ -249,10 +248,10 @@ async fn combined_protocol_fees(web3: Web3) { onchain.mint_block().await; let new_market_order_quote = get_quote( &services, - onchain.contracts().weth.address().into_legacy(), - market_order_token.address().into_legacy(), + *onchain.contracts().weth.address(), + *market_order_token.address(), OrderKind::Sell, - sell_amount, + sell_amount.into_alloy(), model::time::now_in_epoch_seconds() + 300, ) .await @@ -279,10 +278,10 @@ async fn combined_protocol_fees(web3: Web3) { .map(|token| { get_quote( &services, - onchain.contracts().weth.address().into_legacy(), - token.address().into_legacy(), + *onchain.contracts().weth.address(), + *token.address(), OrderKind::Sell, - sell_amount, + sell_amount.into_alloy(), quote_valid_to, ) }), @@ -490,7 +489,7 @@ async fn surplus_partner_fee(web3: Web3) { onchain .contracts() .weth - .approve(onchain.contracts().allowance.into_alloy(), 100u64.eth()) + .approve(onchain.contracts().allowance, 100u64.eth()) .from(trader.address()) .send_and_watch() .await @@ -623,22 +622,22 @@ async fn get_quote( sell_token: Address, buy_token: Address, kind: OrderKind, - amount: ethcontract::U256, + amount: U256, valid_to: u32, ) -> Result { let side = match kind { OrderKind::Sell => OrderQuoteSide::Sell { sell_amount: SellAmount::BeforeFee { - value: NonZeroU256::try_from(amount.as_u128()).unwrap(), + value: NonZeroU256::try_from(amount.to::()).unwrap(), }, }, OrderKind::Buy => OrderQuoteSide::Buy { - buy_amount_after_fee: NonZeroU256::try_from(amount.as_u128()).unwrap(), + buy_amount_after_fee: NonZeroU256::try_from(amount.to::()).unwrap(), }, }; let quote_request = OrderQuoteRequest { - sell_token: sell_token.into_alloy(), - buy_token: buy_token.into_alloy(), + sell_token, + buy_token, side, validity: Validity::To(valid_to), ..Default::default() @@ -752,7 +751,7 @@ async fn volume_fee_buy_order_test(web3: Web3) { // Approve GPv2 for trading token_gno - .approve(onchain.contracts().allowance.into_alloy(), 100u64.eth()) + .approve(onchain.contracts().allowance, 100u64.eth()) .from(trader.address()) .send_and_watch() .await @@ -772,10 +771,10 @@ async fn volume_fee_buy_order_test(web3: Web3) { let quote = get_quote( &services, - token_gno.address().into_legacy(), - token_dai.address().into_legacy(), + *token_gno.address(), + *token_dai.address(), OrderKind::Buy, - 5u64.eth().into_legacy(), + 5u64.eth(), model::time::now_in_epoch_seconds() + 300, ) .await @@ -909,7 +908,7 @@ async fn volume_fee_buy_order_upcoming_future_test(web3: Web3) { // Approve GPv2 for trading token_gno - .approve(onchain.contracts().allowance.into_alloy(), 100u64.eth()) + .approve(onchain.contracts().allowance, 100u64.eth()) .from(trader.address()) .send_and_watch() .await @@ -929,10 +928,10 @@ async fn volume_fee_buy_order_upcoming_future_test(web3: Web3) { let quote = get_quote( &services, - token_gno.address().into_legacy(), - token_dai.address().into_legacy(), + *token_gno.address(), + *token_dai.address(), OrderKind::Buy, - 5u64.eth().into_legacy(), + 5u64.eth(), model::time::now_in_epoch_seconds() + 300, ) .await diff --git a/crates/e2e/tests/e2e/quote_verification.rs b/crates/e2e/tests/e2e/quote_verification.rs index 6cd96a1f75..c3a4961c2d 100644 --- a/crates/e2e/tests/e2e/quote_verification.rs +++ b/crates/e2e/tests/e2e/quote_verification.rs @@ -5,10 +5,9 @@ use { }, bigdecimal::{BigDecimal, Zero}, e2e::setup::*, - ethcontract::H160, ethrpc::{ Web3, - alloy::{CallBuilderExt, conversions::IntoAlloy}, + alloy::{CallBuilderExt, conversions::IntoLegacy}, }, model::{ interaction::InteractionData, @@ -30,7 +29,7 @@ use { }, trade_finding::{Interaction, LegacyTrade, QuoteExecution, TradeKind}, }, - std::{str::FromStr, sync::Arc}, + std::sync::Arc, }; #[tokio::test] @@ -95,7 +94,7 @@ async fn standard_verified_quote(web3: Web3) { token.mint(trader.address(), 1u64.eth()).await; token - .approve(onchain.contracts().allowance.into_alloy(), 1u64.eth()) + .approve(onchain.contracts().allowance, 1u64.eth()) .from(trader.address()) .send_and_watch() .await @@ -199,7 +198,7 @@ async fn test_bypass_verification_for_rfq_quotes(web3: Web3) { let verified_quote = Estimate { out_amount: U256::from(16380122291179526144u128), gas: 225000, - solver: H160::from_str("0xe3067c7c27c1038de4e8ad95a83b927d23dfbd99").unwrap(), + solver: address!("e3067c7c27c1038de4e8ad95a83b927d23dfbd99").into_legacy(), verified: true, execution: QuoteExecution { interactions: vec![InteractionData { @@ -255,7 +254,7 @@ async fn verified_quote_eth_balance(web3: Web3) { .is_zero() ); assert!( - weth.allowance(trader.address(), onchain.contracts().allowance.into_alloy()) + weth.allowance(trader.address(), onchain.contracts().allowance) .call() .await .unwrap() @@ -393,7 +392,7 @@ async fn verified_quote_with_simulated_balance(web3: Web3) { ( token.balanceOf(trader.address()).call().await.unwrap(), token - .allowance(trader.address(), onchain.contracts().allowance.into_alloy()) + .allowance(trader.address(), onchain.contracts().allowance) .call() .await .unwrap(), @@ -437,7 +436,7 @@ async fn verified_quote_with_simulated_balance(web3: Web3) { .is_zero() ); assert!( - weth.allowance(trader.address(), onchain.contracts().allowance.into_alloy()) + weth.allowance(trader.address(), onchain.contracts().allowance) .call() .await .unwrap() diff --git a/crates/e2e/tests/e2e/quoting.rs b/crates/e2e/tests/e2e/quoting.rs index 01cb177645..cffcd51c84 100644 --- a/crates/e2e/tests/e2e/quoting.rs +++ b/crates/e2e/tests/e2e/quoting.rs @@ -1,6 +1,6 @@ use { e2e::setup::{colocation::SolverEngine, mock::Mock, *}, - ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, + ethrpc::alloy::{CallBuilderExt}, futures::FutureExt, model::{ order::{OrderCreation, OrderCreationAppData, OrderKind}, @@ -58,7 +58,7 @@ async fn test(web3: Web3) { onchain .contracts() .weth - .approve(onchain.contracts().allowance.into_alloy(), 3u64.eth()) + .approve(onchain.contracts().allowance, 3u64.eth()) .from(trader.address()) .send_and_watch() .await @@ -206,7 +206,7 @@ async fn uses_stale_liquidity(web3: Web3) { onchain .contracts() .weth - .approve(onchain.contracts().allowance.into_alloy(), 1u64.eth()) + .approve(onchain.contracts().allowance, 1u64.eth()) .from(trader.address()) .send_and_watch() .await @@ -383,7 +383,7 @@ async fn quote_timeout(web3: Web3) { sell_token.mint(trader.address(), 1u64.eth()).await; sell_token - .approve(onchain.contracts().allowance.into_alloy(), 1u64.eth()) + .approve(onchain.contracts().allowance, 1u64.eth()) .from(trader.address()) .send_and_watch() .await @@ -427,7 +427,7 @@ async fn volume_fee(web3: Web3) { onchain .contracts() .weth - .approve(onchain.contracts().allowance.into_alloy(), 3u64.eth()) + .approve(onchain.contracts().allowance, 3u64.eth()) .from(trader.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/replace_order.rs b/crates/e2e/tests/e2e/replace_order.rs index 4b175e98dc..98e2899c19 100644 --- a/crates/e2e/tests/e2e/replace_order.rs +++ b/crates/e2e/tests/e2e/replace_order.rs @@ -1,7 +1,7 @@ use { ::alloy::primitives::U256, e2e::{nodes::local_node::TestNodeApi, setup::*}, - ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, + ethrpc::alloy::{CallBuilderExt}, model::{ order::{OrderCreation, OrderCreationAppData, OrderKind, OrderStatus}, signature::EcdsaSigningScheme, @@ -100,7 +100,7 @@ async fn try_replace_unreplaceable_order_test(web3: Web3) { // Approve GPv2 for trading token_a - .approve(onchain.contracts().allowance.into_alloy(), 15u64.eth()) + .approve(onchain.contracts().allowance, 15u64.eth()) .from(trader.address()) .send_and_watch() .await @@ -279,14 +279,14 @@ async fn try_replace_someone_else_order_test(web3: Web3) { // Approve GPv2 for trading token_a - .approve(onchain.contracts().allowance.into_alloy(), 15u64.eth()) + .approve(onchain.contracts().allowance, 15u64.eth()) .from(trader_a.address()) .send_and_watch() .await .unwrap(); token_a - .approve(onchain.contracts().allowance.into_alloy(), 15u64.eth()) + .approve(onchain.contracts().allowance, 15u64.eth()) .from(trader_b.address()) .send_and_watch() .await @@ -416,7 +416,7 @@ async fn single_replace_order_test(web3: Web3) { // Approve GPv2 for trading token_a - .approve(onchain.contracts().allowance.into_alloy(), 15u64.eth()) + .approve(onchain.contracts().allowance, 15u64.eth()) .from(trader.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/smart_contract_orders.rs b/crates/e2e/tests/e2e/smart_contract_orders.rs index dbe1160e08..3f424349cc 100644 --- a/crates/e2e/tests/e2e/smart_contract_orders.rs +++ b/crates/e2e/tests/e2e/smart_contract_orders.rs @@ -4,7 +4,7 @@ use { ethcontract::U256, ethrpc::alloy::{ CallBuilderExt, - conversions::{IntoAlloy, IntoLegacy}, + conversions::{IntoLegacy}, }, model::{ order::{OrderCreation, OrderCreationAppData, OrderKind, OrderStatus, OrderUid}, @@ -43,7 +43,7 @@ async fn smart_contract_orders(web3: Web3) { // Approve GPv2 for trading safe.exec_alloy_call( token - .approve(onchain.contracts().allowance.into_alloy(), 10u64.eth()) + .approve(onchain.contracts().allowance, 10u64.eth()) .into_transaction_request(), ) .await; @@ -176,7 +176,7 @@ async fn erc1271_gas_limit(web3: Web3) { trader .approve( *cow.address(), - onchain.contracts().allowance.into_alloy(), + onchain.contracts().allowance, 10u64.eth(), ) .from(solver.address()) diff --git a/crates/e2e/tests/e2e/solver_competition.rs b/crates/e2e/tests/e2e/solver_competition.rs index 59b8c9c90a..829c55c94d 100644 --- a/crates/e2e/tests/e2e/solver_competition.rs +++ b/crates/e2e/tests/e2e/solver_competition.rs @@ -1,7 +1,7 @@ use { ::alloy::primitives::U256, e2e::setup::{colocation::SolverEngine, mock::Mock, *}, - ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, + ethrpc::alloy::{CallBuilderExt}, model::{ order::{OrderCreation, OrderKind}, signature::EcdsaSigningScheme, @@ -48,7 +48,7 @@ async fn solver_competition(web3: Web3) { // Approve GPv2 for trading token_a - .approve(onchain.contracts().allowance.into_alloy(), 100u64.eth()) + .approve(onchain.contracts().allowance, 100u64.eth()) .from(trader.address()) .send_and_watch() .await @@ -180,14 +180,14 @@ async fn wrong_solution_submission_address(web3: Web3) { // Approve GPv2 for trading token_a - .approve(onchain.contracts().allowance.into_alloy(), 100u64.eth()) + .approve(onchain.contracts().allowance, 100u64.eth()) .from(trader_a.address()) .send_and_watch() .await .unwrap(); token_b - .approve(onchain.contracts().allowance.into_alloy(), 100u64.eth()) + .approve(onchain.contracts().allowance, 100u64.eth()) .from(trader_b.address()) .send_and_watch() .await @@ -320,7 +320,7 @@ async fn store_filtered_solutions(web3: Web3) { token_a.mint(trader.address(), 2u64.eth()).await; token_a - .approve(onchain.contracts().allowance.into_alloy(), 2u64.eth()) + .approve(onchain.contracts().allowance, 2u64.eth()) .from(trader.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/solver_participation_guard.rs b/crates/e2e/tests/e2e/solver_participation_guard.rs index c8c63428cc..b18bcf518c 100644 --- a/crates/e2e/tests/e2e/solver_participation_guard.rs +++ b/crates/e2e/tests/e2e/solver_participation_guard.rs @@ -13,7 +13,7 @@ use { }, ethrpc::{ Web3, - alloy::{CallBuilderExt, conversions::IntoAlloy}, + alloy::{CallBuilderExt}, }, model::{ order::{OrderClass, OrderCreation, OrderKind}, @@ -290,7 +290,7 @@ async fn setup( // Approve GPv2 for trading token_a - .approve(onchain.contracts().allowance.into_alloy(), 1000u64.eth()) + .approve(onchain.contracts().allowance, 1000u64.eth()) .from(trader_a.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/submission.rs b/crates/e2e/tests/e2e/submission.rs index afce7daff0..f68524dd6e 100644 --- a/crates/e2e/tests/e2e/submission.rs +++ b/crates/e2e/tests/e2e/submission.rs @@ -50,7 +50,7 @@ async fn test_cancel_on_expiry(web3: Web3) { onchain .contracts() .weth - .approve(onchain.contracts().allowance.into_alloy(), 3u64.eth()) + .approve(onchain.contracts().allowance, 3u64.eth()) .from(trader.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/tracking_insufficient_funds.rs b/crates/e2e/tests/e2e/tracking_insufficient_funds.rs index 9f24ac2305..173b31166e 100644 --- a/crates/e2e/tests/e2e/tracking_insufficient_funds.rs +++ b/crates/e2e/tests/e2e/tracking_insufficient_funds.rs @@ -1,7 +1,7 @@ use { database::order_events::{OrderEvent, OrderEventLabel}, e2e::setup::*, - ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, + ethrpc::alloy::{CallBuilderExt}, model::{ order::{OrderCreation, OrderKind}, signature::EcdsaSigningScheme, @@ -31,7 +31,7 @@ async fn test(web3: Web3) { onchain .contracts() .weth - .approve(onchain.contracts().allowance.into_alloy(), 3u64.eth()) + .approve(onchain.contracts().allowance, 3u64.eth()) .from(trader_a.address()) .send_and_watch() .await @@ -48,7 +48,7 @@ async fn test(web3: Web3) { onchain .contracts() .weth - .approve(onchain.contracts().allowance.into_alloy(), 3u64.eth()) + .approve(onchain.contracts().allowance, 3u64.eth()) .from(trader_b.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/uncovered_order.rs b/crates/e2e/tests/e2e/uncovered_order.rs index be168dee90..a90bb05aff 100644 --- a/crates/e2e/tests/e2e/uncovered_order.rs +++ b/crates/e2e/tests/e2e/uncovered_order.rs @@ -1,6 +1,6 @@ use { e2e::setup::*, - ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, + ethrpc::alloy::{CallBuilderExt}, model::{ order::{OrderCreation, OrderKind}, signature::EcdsaSigningScheme, @@ -31,7 +31,7 @@ async fn test(web3: Web3) { .await; let weth = &onchain.contracts().weth; - weth.approve(onchain.contracts().allowance.into_alloy(), 3u64.eth()) + weth.approve(onchain.contracts().allowance, 3u64.eth()) .from(trader.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/univ2.rs b/crates/e2e/tests/e2e/univ2.rs index 6acff610d7..342272f204 100644 --- a/crates/e2e/tests/e2e/univ2.rs +++ b/crates/e2e/tests/e2e/univ2.rs @@ -3,7 +3,7 @@ use { contracts::alloy::GPv2Settlement, database::order_events::{OrderEvent, OrderEventLabel}, e2e::setup::*, - ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, + ethrpc::alloy::{CallBuilderExt}, model::{ order::{OrderCreation, OrderKind}, signature::EcdsaSigningScheme, @@ -33,7 +33,7 @@ async fn test(web3: Web3) { onchain .contracts() .weth - .approve(onchain.contracts().allowance.into_alloy(), 3u64.eth()) + .approve(onchain.contracts().allowance, 3u64.eth()) .from(trader.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/vault_balances.rs b/crates/e2e/tests/e2e/vault_balances.rs index 448ef3d7b7..cee939ae13 100644 --- a/crates/e2e/tests/e2e/vault_balances.rs +++ b/crates/e2e/tests/e2e/vault_balances.rs @@ -1,6 +1,6 @@ use { e2e::setup::*, - ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, + ethrpc::alloy::{CallBuilderExt}, model::{ order::{OrderCreation, OrderKind, SellTokenSource}, signature::EcdsaSigningScheme, @@ -41,7 +41,7 @@ async fn vault_balances(web3: Web3) { .balancer_vault .setRelayerApproval( trader.address(), - onchain.contracts().allowance.into_alloy(), + onchain.contracts().allowance, true, ) .from(trader.address()) diff --git a/crates/e2e/tests/e2e/wrapper.rs b/crates/e2e/tests/e2e/wrapper.rs index 33d4f52a86..6d5cccc191 100644 --- a/crates/e2e/tests/e2e/wrapper.rs +++ b/crates/e2e/tests/e2e/wrapper.rs @@ -10,7 +10,7 @@ use { app_data::{AppDataHash, hash_full_app_data}, contracts::alloy::ERC20, e2e::setup::*, - ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, + ethrpc::alloy::{CallBuilderExt}, model::{ order::{OrderCreation, OrderCreationAppData, OrderKind}, quote::{OrderQuoteRequest, OrderQuoteSide, SellAmount}, @@ -94,7 +94,7 @@ async fn forked_mainnet_wrapper_test(web3: Web3) { // Approve GPv2 for trading token_weth - .approve(onchain.contracts().allowance.into_alloy(), 1u64.eth()) + .approve(onchain.contracts().allowance, 1u64.eth()) .from(trader.address()) .send_and_watch() .await From 26f12f1c255516f022c2be56bbd3ccc99dc1722f Mon Sep 17 00:00:00 2001 From: Aryan Godara Date: Wed, 17 Dec 2025 02:09:01 +0530 Subject: [PATCH 3/8] remove more U256 from ethcontract and use alloy Signed-off-by: Aryan Godara --- .../e2e/src/setup/onchain_components/mod.rs | 20 +++++++++---------- crates/e2e/tests/e2e/hooks.rs | 12 ++--------- crates/e2e/tests/e2e/protocol_fee.rs | 14 ++++++------- crates/e2e/tests/e2e/smart_contract_orders.rs | 15 +++----------- 4 files changed, 22 insertions(+), 39 deletions(-) diff --git a/crates/e2e/src/setup/onchain_components/mod.rs b/crates/e2e/src/setup/onchain_components/mod.rs index ecaa0b1e41..40f7722cad 100644 --- a/crates/e2e/src/setup/onchain_components/mod.rs +++ b/crates/e2e/src/setup/onchain_components/mod.rs @@ -561,14 +561,14 @@ impl OnchainComponents { .expect("Uniswap V2 pair couldn't mint"); } - pub async fn deploy_cow_token(&self, supply: U256) -> CowToken { + pub async fn deploy_cow_token(&self, supply: ::alloy::primitives::U256) -> CowToken { let holder = NetworkWallet::::default_signer_address(&self.web3().wallet); let holder = Account::Local(holder.into_legacy(), None); let contract = CowProtocolToken::CowProtocolToken::deploy( self.web3.alloy.clone(), holder.address().into_alloy(), holder.address().into_alloy(), - supply.into_alloy(), + supply, ) .await .expect("CowProtocolToken deployment failed"); @@ -577,16 +577,16 @@ impl OnchainComponents { pub async fn deploy_cow_weth_pool( &self, - cow_supply: U256, - cow_amount: U256, - weth_amount: U256, + cow_supply: ::alloy::primitives::U256, + cow_amount: ::alloy::primitives::U256, + weth_amount: ::alloy::primitives::U256, ) -> CowToken { let cow = self.deploy_cow_token(cow_supply).await; self.contracts .weth .deposit() - .value(weth_amount.into_alloy()) + .value(weth_amount) .from(cow.holder.address().into_alloy()) .send_and_watch() .await @@ -601,7 +601,7 @@ impl OnchainComponents { .unwrap(); cow.approve( *self.contracts.uniswap_v2_router.address(), - cow_amount.into_alloy(), + cow_amount, ) .from(cow.holder.address().into_alloy()) .send_and_watch() @@ -611,7 +611,7 @@ impl OnchainComponents { .weth .approve( *self.contracts.uniswap_v2_router.address(), - weth_amount.into_alloy(), + weth_amount, ) .from(cow.holder.address().into_alloy()) .send_and_watch() @@ -622,8 +622,8 @@ impl OnchainComponents { .addLiquidity( *cow.address(), *self.contracts.weth.address(), - cow_amount.into_alloy(), - weth_amount.into_alloy(), + cow_amount, + weth_amount, ::alloy::primitives::U256::ZERO, ::alloy::primitives::U256::ZERO, cow.holder.address().into_alloy(), diff --git a/crates/e2e/tests/e2e/hooks.rs b/crates/e2e/tests/e2e/hooks.rs index e3d681586d..7272c2b6e5 100644 --- a/crates/e2e/tests/e2e/hooks.rs +++ b/crates/e2e/tests/e2e/hooks.rs @@ -63,11 +63,7 @@ async fn gas_limit(web3: Web3) { let [solver] = onchain.make_solvers(1u64.eth()).await; let [trader] = onchain.make_accounts(1u64.eth()).await; let cow = onchain - .deploy_cow_weth_pool( - 1_000_000u64.eth().into_legacy(), - 1_000u64.eth().into_legacy(), - 1_000u64.eth().into_legacy(), - ) + .deploy_cow_weth_pool(1_000_000u64.eth(), 1_000u64.eth(), 1_000u64.eth()) .await; // Fund trader accounts and approve relayer @@ -121,11 +117,7 @@ async fn allowance(web3: Web3) { let [solver] = onchain.make_solvers(1u64.eth()).await; let [trader] = onchain.make_accounts(1u64.eth()).await; let cow = onchain - .deploy_cow_weth_pool( - 1_000_000u64.eth().into_legacy(), - 1_000u64.eth().into_legacy(), - 1_000u64.eth().into_legacy(), - ) + .deploy_cow_weth_pool(1_000_000u64.eth(), 1_000u64.eth(), 1_000u64.eth()) .await; // Fund trader accounts diff --git a/crates/e2e/tests/e2e/protocol_fee.rs b/crates/e2e/tests/e2e/protocol_fee.rs index 682df73ce7..71e2729afe 100644 --- a/crates/e2e/tests/e2e/protocol_fee.rs +++ b/crates/e2e/tests/e2e/protocol_fee.rs @@ -172,7 +172,7 @@ async fn combined_protocol_fees(web3: Web3) { tracing::info!("Acquiring quotes."); let quote_valid_to = model::time::now_in_epoch_seconds() + 300; - let sell_amount = 10u64.eth().into_legacy(); + let sell_amount = 10u64.eth(); let [limit_quote_before, market_quote_before, partner_fee_quote] = futures::future::try_join_all( [ @@ -186,7 +186,7 @@ async fn combined_protocol_fees(web3: Web3) { *onchain.contracts().weth.address(), *token.address(), OrderKind::Sell, - sell_amount.into_alloy(), + sell_amount, quote_valid_to, ) }), @@ -197,7 +197,7 @@ async fn combined_protocol_fees(web3: Web3) { .expect("Expected exactly four elements"); let market_price_improvement_order = OrderCreation { - sell_amount: sell_amount.into_alloy(), + sell_amount, // to make sure the order is in-market buy_amount: market_quote_before.quote.buy_amount * U256::from(2) / U256::from(3), ..sell_order_from_quote(&market_quote_before) @@ -208,7 +208,7 @@ async fn combined_protocol_fees(web3: Web3) { SecretKeyRef::from(&SecretKey::from_slice(trader.private_key()).unwrap()), ); let limit_surplus_order = OrderCreation { - sell_amount: sell_amount.into_alloy(), + sell_amount, // to make sure the order is out-of-market buy_amount: limit_quote_before.quote.buy_amount * U256::from(3) / U256::from(2), ..sell_order_from_quote(&limit_quote_before) @@ -219,7 +219,7 @@ async fn combined_protocol_fees(web3: Web3) { SecretKeyRef::from(&SecretKey::from_slice(trader.private_key()).unwrap()), ); let partner_fee_order = OrderCreation { - sell_amount: sell_amount.into_alloy(), + sell_amount, // to make sure the order is out-of-market buy_amount: (partner_fee_quote.quote.buy_amount * U256::from(3) / U256::from(2)), app_data: partner_fee_app_data.clone(), @@ -251,7 +251,7 @@ async fn combined_protocol_fees(web3: Web3) { *onchain.contracts().weth.address(), *market_order_token.address(), OrderKind::Sell, - sell_amount.into_alloy(), + sell_amount, model::time::now_in_epoch_seconds() + 300, ) .await @@ -281,7 +281,7 @@ async fn combined_protocol_fees(web3: Web3) { *onchain.contracts().weth.address(), *token.address(), OrderKind::Sell, - sell_amount.into_alloy(), + sell_amount, quote_valid_to, ) }), diff --git a/crates/e2e/tests/e2e/smart_contract_orders.rs b/crates/e2e/tests/e2e/smart_contract_orders.rs index 3f424349cc..13b884056b 100644 --- a/crates/e2e/tests/e2e/smart_contract_orders.rs +++ b/crates/e2e/tests/e2e/smart_contract_orders.rs @@ -1,11 +1,7 @@ use { ::alloy::primitives::Address, e2e::setup::{safe::Safe, *}, - ethcontract::U256, - ethrpc::alloy::{ - CallBuilderExt, - conversions::{IntoLegacy}, - }, + ethrpc::alloy::CallBuilderExt, model::{ order::{OrderCreation, OrderCreationAppData, OrderKind, OrderStatus, OrderUid}, signature::Signature, @@ -164,11 +160,7 @@ async fn erc1271_gas_limit(web3: Web3) { .unwrap(); let cow = onchain - .deploy_cow_weth_pool( - 1_000_000u64.eth().into_legacy(), - 1_000u64.eth().into_legacy(), - 1_000u64.eth().into_legacy(), - ) + .deploy_cow_weth_pool(1_000_000u64.eth(), 1_000u64.eth(), 1_000u64.eth()) .await; // Fund trader accounts and approve relayer @@ -196,8 +188,7 @@ async fn erc1271_gas_limit(web3: Web3) { .await; // Use 1M gas units during signature verification - let mut signature = [0; 32]; - U256::exp10(6).to_big_endian(&mut signature); + let signature = ::alloy::primitives::U256::from(1_000_000).to_be_bytes::<32>(); let order = OrderCreation { sell_token: *cow.address(), From b9094a33429f1eca70182767833f5ed145928983 Mon Sep 17 00:00:00 2001 From: Aryan Godara Date: Wed, 17 Dec 2025 02:20:20 +0530 Subject: [PATCH 4/8] run the linter Signed-off-by: Aryan Godara --- crates/e2e/src/setup/deploy.rs | 12 ++++------ .../e2e/src/setup/onchain_components/mod.rs | 18 +++++---------- crates/e2e/tests/e2e/app_data.rs | 2 +- crates/e2e/tests/e2e/app_data_signer.rs | 2 +- crates/e2e/tests/e2e/autopilot_leader.rs | 5 +--- crates/e2e/tests/e2e/buffers.rs | 2 +- crates/e2e/tests/e2e/cow_amm.rs | 23 ++++++------------- crates/e2e/tests/e2e/eth_safe.rs | 2 +- crates/e2e/tests/e2e/hooks.rs | 5 +--- crates/e2e/tests/e2e/jit_orders.rs | 2 +- crates/e2e/tests/e2e/limit_orders.rs | 2 +- .../e2e/liquidity_source_notification.rs | 10 ++------ crates/e2e/tests/e2e/order_cancellation.rs | 2 +- crates/e2e/tests/e2e/partial_fill.rs | 2 +- .../tests/e2e/partially_fillable_balance.rs | 2 +- .../e2e/tests/e2e/partially_fillable_pool.rs | 2 +- .../e2e/tests/e2e/place_order_with_quote.rs | 2 +- crates/e2e/tests/e2e/quoting.rs | 2 +- crates/e2e/tests/e2e/replace_order.rs | 2 +- crates/e2e/tests/e2e/smart_contract_orders.rs | 6 +---- crates/e2e/tests/e2e/solver_competition.rs | 2 +- .../tests/e2e/solver_participation_guard.rs | 5 +--- .../tests/e2e/tracking_insufficient_funds.rs | 2 +- crates/e2e/tests/e2e/uncovered_order.rs | 2 +- crates/e2e/tests/e2e/univ2.rs | 2 +- crates/e2e/tests/e2e/vault_balances.rs | 8 ++----- crates/e2e/tests/e2e/wrapper.rs | 2 +- 27 files changed, 44 insertions(+), 84 deletions(-) diff --git a/crates/e2e/src/setup/deploy.rs b/crates/e2e/src/setup/deploy.rs index a940d36def..85600ab0ed 100644 --- a/crates/e2e/src/setup/deploy.rs +++ b/crates/e2e/src/setup/deploy.rs @@ -1,4 +1,5 @@ use { + alloy::primitives::{Address, B256}, contracts::alloy::{ BalancerV2Authorizer, BalancerV2Vault, @@ -12,7 +13,6 @@ use { WETH9, support::{Balances, Signatures}, }, - alloy::primitives::{Address, B256}, ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, model::DomainSeparator, shared::ethrpc::Web3, @@ -135,10 +135,9 @@ impl Contracts { let weth = WETH9::Instance::deploy(web3.alloy.clone()).await.unwrap(); - let balancer_authorizer = - BalancerV2Authorizer::Instance::deploy(web3.alloy.clone(), admin) - .await - .unwrap(); + let balancer_authorizer = BalancerV2Authorizer::Instance::deploy(web3.alloy.clone(), admin) + .await + .unwrap(); let balancer_vault = BalancerV2Vault::Instance::deploy( web3.alloy.clone(), *balancer_authorizer.address(), @@ -199,8 +198,7 @@ impl Contracts { .vaultRelayer() .call() .await - .expect("Couldn't get vault relayer address") -; + .expect("Couldn't get vault relayer address"); let domain_separator = DomainSeparator( gp_settlement .domainSeparator() diff --git a/crates/e2e/src/setup/onchain_components/mod.rs b/crates/e2e/src/setup/onchain_components/mod.rs index 40f7722cad..125775f4d0 100644 --- a/crates/e2e/src/setup/onchain_components/mod.rs +++ b/crates/e2e/src/setup/onchain_components/mod.rs @@ -599,20 +599,14 @@ impl OnchainComponents { .send_and_watch() .await .unwrap(); - cow.approve( - *self.contracts.uniswap_v2_router.address(), - cow_amount, - ) - .from(cow.holder.address().into_alloy()) - .send_and_watch() - .await - .unwrap(); + cow.approve(*self.contracts.uniswap_v2_router.address(), cow_amount) + .from(cow.holder.address().into_alloy()) + .send_and_watch() + .await + .unwrap(); self.contracts .weth - .approve( - *self.contracts.uniswap_v2_router.address(), - weth_amount, - ) + .approve(*self.contracts.uniswap_v2_router.address(), weth_amount) .from(cow.holder.address().into_alloy()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/app_data.rs b/crates/e2e/tests/e2e/app_data.rs index 74e550e9e6..656ec3a357 100644 --- a/crates/e2e/tests/e2e/app_data.rs +++ b/crates/e2e/tests/e2e/app_data.rs @@ -1,7 +1,7 @@ use { app_data::{AppDataHash, hash_full_app_data}, e2e::setup::*, - ethrpc::alloy::{CallBuilderExt}, + ethrpc::alloy::CallBuilderExt, model::{ order::{OrderCreation, OrderCreationAppData, OrderKind}, quote::{OrderQuoteRequest, OrderQuoteSide, SellAmount}, diff --git a/crates/e2e/tests/e2e/app_data_signer.rs b/crates/e2e/tests/e2e/app_data_signer.rs index 5445ce8c7d..aabe02445b 100644 --- a/crates/e2e/tests/e2e/app_data_signer.rs +++ b/crates/e2e/tests/e2e/app_data_signer.rs @@ -1,7 +1,7 @@ use { alloy::primitives::Address, e2e::setup::{OnchainComponents, Services, TestAccount, run_test, safe::Safe}, - ethrpc::alloy::{CallBuilderExt}, + ethrpc::alloy::CallBuilderExt, model::{ order::{OrderCreation, OrderCreationAppData, OrderKind}, signature::EcdsaSigningScheme, diff --git a/crates/e2e/tests/e2e/autopilot_leader.rs b/crates/e2e/tests/e2e/autopilot_leader.rs index 4b18175a66..a10684702d 100644 --- a/crates/e2e/tests/e2e/autopilot_leader.rs +++ b/crates/e2e/tests/e2e/autopilot_leader.rs @@ -1,10 +1,7 @@ use { autopilot::shutdown_controller::ShutdownController, e2e::setup::{OnchainComponents, Services, TIMEOUT, colocation, run_test, wait_for_condition}, - ethrpc::{ - Web3, - alloy::{CallBuilderExt}, - }, + ethrpc::{Web3, alloy::CallBuilderExt}, model::order::{OrderCreation, OrderKind}, number::units::EthUnit, secp256k1::SecretKey, diff --git a/crates/e2e/tests/e2e/buffers.rs b/crates/e2e/tests/e2e/buffers.rs index b3b77830bf..c3a2952095 100644 --- a/crates/e2e/tests/e2e/buffers.rs +++ b/crates/e2e/tests/e2e/buffers.rs @@ -1,7 +1,7 @@ use { ::alloy::primitives::U256, e2e::setup::*, - ethrpc::alloy::{CallBuilderExt}, + ethrpc::alloy::CallBuilderExt, model::{ order::{OrderCreation, OrderKind}, signature::EcdsaSigningScheme, diff --git a/crates/e2e/tests/e2e/cow_amm.rs b/crates/e2e/tests/e2e/cow_amm.rs index 699b52585f..7ba0390104 100644 --- a/crates/e2e/tests/e2e/cow_amm.rs +++ b/crates/e2e/tests/e2e/cow_amm.rs @@ -20,10 +20,7 @@ use { wait_for_condition, }, ethcontract::{BlockId, BlockNumber}, - ethrpc::alloy::{ - CallBuilderExt, - conversions::IntoAlloy, - }, + ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, model::{ order::{OrderClass, OrderCreation, OrderKind, OrderUid}, quote::{OrderQuoteRequest, OrderQuoteSide, SellAmount}, @@ -278,10 +275,7 @@ async fn cow_amm_jit(web3: Web3) { onchain .contracts() .weth - .approve( - onchain.contracts().allowance, - alloy::primitives::U256::MAX, - ) + .approve(onchain.contracts().allowance, alloy::primitives::U256::MAX) .from(bob.address()) .send_and_watch() .await @@ -896,14 +890,11 @@ async fn cow_amm_opposite_direction(web3: Web3) { // Fund trader "bob" with DAI and approve allowance dai.mint(bob.address(), 250u64.eth()).await; - dai.approve( - onchain.contracts().allowance, - alloy::primitives::U256::MAX, - ) - .from(bob.address()) - .send_and_watch() - .await - .unwrap(); + dai.approve(onchain.contracts().allowance, alloy::primitives::U256::MAX) + .from(bob.address()) + .send_and_watch() + .await + .unwrap(); // Get balances before the trade let amm_weth_balance_before = onchain diff --git a/crates/e2e/tests/e2e/eth_safe.rs b/crates/e2e/tests/e2e/eth_safe.rs index 9b438304d4..cdba2f6bfd 100644 --- a/crates/e2e/tests/e2e/eth_safe.rs +++ b/crates/e2e/tests/e2e/eth_safe.rs @@ -1,7 +1,7 @@ use { ::alloy::{primitives::U256, providers::Provider}, e2e::setup::{OnchainComponents, Services, TIMEOUT, run_test, safe::Safe, wait_for_condition}, - ethrpc::alloy::{CallBuilderExt}, + ethrpc::alloy::CallBuilderExt, model::{ order::{BUY_ETH_ADDRESS, OrderCreation, OrderKind}, signature::{Signature, hashed_eip712_message}, diff --git a/crates/e2e/tests/e2e/hooks.rs b/crates/e2e/tests/e2e/hooks.rs index 7272c2b6e5..4823949909 100644 --- a/crates/e2e/tests/e2e/hooks.rs +++ b/crates/e2e/tests/e2e/hooks.rs @@ -10,10 +10,7 @@ use { safe::Safe, wait_for_condition, }, - ethrpc::alloy::{ - CallBuilderExt, - conversions::{IntoLegacy}, - }, + ethrpc::alloy::{CallBuilderExt, conversions::IntoLegacy}, model::{ order::{OrderCreation, OrderCreationAppData, OrderKind}, quote::{OrderQuoteRequest, OrderQuoteSide, SellAmount}, diff --git a/crates/e2e/tests/e2e/jit_orders.rs b/crates/e2e/tests/e2e/jit_orders.rs index dd1f152eca..a64d6dc4f1 100644 --- a/crates/e2e/tests/e2e/jit_orders.rs +++ b/crates/e2e/tests/e2e/jit_orders.rs @@ -1,7 +1,7 @@ use { ::alloy::primitives::U256, e2e::setup::{colocation::SolverEngine, mock::Mock, solution::JitOrder, *}, - ethrpc::alloy::{CallBuilderExt}, + ethrpc::alloy::CallBuilderExt, model::{ order::{OrderClass, OrderCreation, OrderKind}, signature::EcdsaSigningScheme, diff --git a/crates/e2e/tests/e2e/limit_orders.rs b/crates/e2e/tests/e2e/limit_orders.rs index a657633072..d8cc7bd7a2 100644 --- a/crates/e2e/tests/e2e/limit_orders.rs +++ b/crates/e2e/tests/e2e/limit_orders.rs @@ -9,7 +9,7 @@ use { database::byte_array::ByteArray, driver::domain::eth::NonZeroU256, e2e::setup::*, - ethrpc::alloy::{CallBuilderExt}, + ethrpc::alloy::CallBuilderExt, fee::{FeePolicyOrderClass, ProtocolFee, ProtocolFeesConfig}, model::{ order::{OrderClass, OrderCreation, OrderKind}, diff --git a/crates/e2e/tests/e2e/liquidity_source_notification.rs b/crates/e2e/tests/e2e/liquidity_source_notification.rs index e3e3cccc13..dd76009445 100644 --- a/crates/e2e/tests/e2e/liquidity_source_notification.rs +++ b/crates/e2e/tests/e2e/liquidity_source_notification.rs @@ -19,10 +19,7 @@ use { wait_for_condition, }, }, - ethrpc::{ - Web3, - alloy::{CallBuilderExt}, - }, + ethrpc::{Web3, alloy::CallBuilderExt}, model::{ order::{OrderCreation, OrderKind}, signature::EcdsaSigningScheme, @@ -117,10 +114,7 @@ async fn liquidity_source_notification(web3: Web3) { // Trader gives approval to the CoW allowance contract token_usdc - .approve( - onchain.contracts().allowance, - alloy::primitives::U256::MAX, - ) + .approve(onchain.contracts().allowance, alloy::primitives::U256::MAX) .from(trader.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/order_cancellation.rs b/crates/e2e/tests/e2e/order_cancellation.rs index 467239674f..ac2637a98a 100644 --- a/crates/e2e/tests/e2e/order_cancellation.rs +++ b/crates/e2e/tests/e2e/order_cancellation.rs @@ -2,7 +2,7 @@ use { ::alloy::primitives::U256, database::order_events::OrderEventLabel, e2e::setup::*, - ethrpc::alloy::{CallBuilderExt}, + ethrpc::alloy::CallBuilderExt, model::{ order::{ CancellationPayload, diff --git a/crates/e2e/tests/e2e/partial_fill.rs b/crates/e2e/tests/e2e/partial_fill.rs index e324330bbf..a13af551cb 100644 --- a/crates/e2e/tests/e2e/partial_fill.rs +++ b/crates/e2e/tests/e2e/partial_fill.rs @@ -1,7 +1,7 @@ use { ::alloy::primitives::U256, e2e::setup::*, - ethrpc::alloy::{CallBuilderExt}, + ethrpc::alloy::CallBuilderExt, model::{ order::{OrderCreation, OrderKind}, signature::{EcdsaSigningScheme, Signature, SigningScheme}, diff --git a/crates/e2e/tests/e2e/partially_fillable_balance.rs b/crates/e2e/tests/e2e/partially_fillable_balance.rs index ecd79c42d3..d887908ac3 100644 --- a/crates/e2e/tests/e2e/partially_fillable_balance.rs +++ b/crates/e2e/tests/e2e/partially_fillable_balance.rs @@ -1,7 +1,7 @@ use { ::alloy::primitives::U256, e2e::setup::*, - ethrpc::alloy::{CallBuilderExt}, + ethrpc::alloy::CallBuilderExt, model::{ order::{OrderCreation, OrderKind}, signature::EcdsaSigningScheme, diff --git a/crates/e2e/tests/e2e/partially_fillable_pool.rs b/crates/e2e/tests/e2e/partially_fillable_pool.rs index af7413586d..925456785d 100644 --- a/crates/e2e/tests/e2e/partially_fillable_pool.rs +++ b/crates/e2e/tests/e2e/partially_fillable_pool.rs @@ -1,7 +1,7 @@ use { ::alloy::primitives::U256, e2e::setup::*, - ethrpc::alloy::{CallBuilderExt}, + ethrpc::alloy::CallBuilderExt, model::{ order::{OrderCreation, OrderKind}, signature::EcdsaSigningScheme, diff --git a/crates/e2e/tests/e2e/place_order_with_quote.rs b/crates/e2e/tests/e2e/place_order_with_quote.rs index 1d8ec1ac07..372c003346 100644 --- a/crates/e2e/tests/e2e/place_order_with_quote.rs +++ b/crates/e2e/tests/e2e/place_order_with_quote.rs @@ -2,7 +2,7 @@ use { ::alloy::primitives::U256, driver::domain::eth::NonZeroU256, e2e::{nodes::local_node::TestNodeApi, setup::*}, - ethrpc::alloy::{CallBuilderExt}, + ethrpc::alloy::CallBuilderExt, model::{ order::{OrderCreation, OrderKind}, quote::{OrderQuoteRequest, OrderQuoteSide, SellAmount}, diff --git a/crates/e2e/tests/e2e/quoting.rs b/crates/e2e/tests/e2e/quoting.rs index cffcd51c84..4bfe04f3e9 100644 --- a/crates/e2e/tests/e2e/quoting.rs +++ b/crates/e2e/tests/e2e/quoting.rs @@ -1,6 +1,6 @@ use { e2e::setup::{colocation::SolverEngine, mock::Mock, *}, - ethrpc::alloy::{CallBuilderExt}, + ethrpc::alloy::CallBuilderExt, futures::FutureExt, model::{ order::{OrderCreation, OrderCreationAppData, OrderKind}, diff --git a/crates/e2e/tests/e2e/replace_order.rs b/crates/e2e/tests/e2e/replace_order.rs index 98e2899c19..e97c8ba66a 100644 --- a/crates/e2e/tests/e2e/replace_order.rs +++ b/crates/e2e/tests/e2e/replace_order.rs @@ -1,7 +1,7 @@ use { ::alloy::primitives::U256, e2e::{nodes::local_node::TestNodeApi, setup::*}, - ethrpc::alloy::{CallBuilderExt}, + ethrpc::alloy::CallBuilderExt, model::{ order::{OrderCreation, OrderCreationAppData, OrderKind, OrderStatus}, signature::EcdsaSigningScheme, diff --git a/crates/e2e/tests/e2e/smart_contract_orders.rs b/crates/e2e/tests/e2e/smart_contract_orders.rs index 13b884056b..de6c7ed7f5 100644 --- a/crates/e2e/tests/e2e/smart_contract_orders.rs +++ b/crates/e2e/tests/e2e/smart_contract_orders.rs @@ -166,11 +166,7 @@ async fn erc1271_gas_limit(web3: Web3) { // Fund trader accounts and approve relayer cow.fund(*trader.address(), 5u64.eth()).await; trader - .approve( - *cow.address(), - onchain.contracts().allowance, - 10u64.eth(), - ) + .approve(*cow.address(), onchain.contracts().allowance, 10u64.eth()) .from(solver.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/solver_competition.rs b/crates/e2e/tests/e2e/solver_competition.rs index 829c55c94d..0b59f0bb88 100644 --- a/crates/e2e/tests/e2e/solver_competition.rs +++ b/crates/e2e/tests/e2e/solver_competition.rs @@ -1,7 +1,7 @@ use { ::alloy::primitives::U256, e2e::setup::{colocation::SolverEngine, mock::Mock, *}, - ethrpc::alloy::{CallBuilderExt}, + ethrpc::alloy::CallBuilderExt, model::{ order::{OrderCreation, OrderKind}, signature::EcdsaSigningScheme, diff --git a/crates/e2e/tests/e2e/solver_participation_guard.rs b/crates/e2e/tests/e2e/solver_participation_guard.rs index b18bcf518c..44c947beb9 100644 --- a/crates/e2e/tests/e2e/solver_participation_guard.rs +++ b/crates/e2e/tests/e2e/solver_participation_guard.rs @@ -11,10 +11,7 @@ use { run_test, wait_for_condition, }, - ethrpc::{ - Web3, - alloy::{CallBuilderExt}, - }, + ethrpc::{Web3, alloy::CallBuilderExt}, model::{ order::{OrderClass, OrderCreation, OrderKind}, signature::EcdsaSigningScheme, diff --git a/crates/e2e/tests/e2e/tracking_insufficient_funds.rs b/crates/e2e/tests/e2e/tracking_insufficient_funds.rs index 173b31166e..6188b73b7c 100644 --- a/crates/e2e/tests/e2e/tracking_insufficient_funds.rs +++ b/crates/e2e/tests/e2e/tracking_insufficient_funds.rs @@ -1,7 +1,7 @@ use { database::order_events::{OrderEvent, OrderEventLabel}, e2e::setup::*, - ethrpc::alloy::{CallBuilderExt}, + ethrpc::alloy::CallBuilderExt, model::{ order::{OrderCreation, OrderKind}, signature::EcdsaSigningScheme, diff --git a/crates/e2e/tests/e2e/uncovered_order.rs b/crates/e2e/tests/e2e/uncovered_order.rs index a90bb05aff..75c3784bd5 100644 --- a/crates/e2e/tests/e2e/uncovered_order.rs +++ b/crates/e2e/tests/e2e/uncovered_order.rs @@ -1,6 +1,6 @@ use { e2e::setup::*, - ethrpc::alloy::{CallBuilderExt}, + ethrpc::alloy::CallBuilderExt, model::{ order::{OrderCreation, OrderKind}, signature::EcdsaSigningScheme, diff --git a/crates/e2e/tests/e2e/univ2.rs b/crates/e2e/tests/e2e/univ2.rs index 342272f204..7cf55e3972 100644 --- a/crates/e2e/tests/e2e/univ2.rs +++ b/crates/e2e/tests/e2e/univ2.rs @@ -3,7 +3,7 @@ use { contracts::alloy::GPv2Settlement, database::order_events::{OrderEvent, OrderEventLabel}, e2e::setup::*, - ethrpc::alloy::{CallBuilderExt}, + ethrpc::alloy::CallBuilderExt, model::{ order::{OrderCreation, OrderKind}, signature::EcdsaSigningScheme, diff --git a/crates/e2e/tests/e2e/vault_balances.rs b/crates/e2e/tests/e2e/vault_balances.rs index cee939ae13..6391c721ee 100644 --- a/crates/e2e/tests/e2e/vault_balances.rs +++ b/crates/e2e/tests/e2e/vault_balances.rs @@ -1,6 +1,6 @@ use { e2e::setup::*, - ethrpc::alloy::{CallBuilderExt}, + ethrpc::alloy::CallBuilderExt, model::{ order::{OrderCreation, OrderKind, SellTokenSource}, signature::EcdsaSigningScheme, @@ -39,11 +39,7 @@ async fn vault_balances(web3: Web3) { onchain .contracts() .balancer_vault - .setRelayerApproval( - trader.address(), - onchain.contracts().allowance, - true, - ) + .setRelayerApproval(trader.address(), onchain.contracts().allowance, true) .from(trader.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/wrapper.rs b/crates/e2e/tests/e2e/wrapper.rs index 6d5cccc191..bf350666e2 100644 --- a/crates/e2e/tests/e2e/wrapper.rs +++ b/crates/e2e/tests/e2e/wrapper.rs @@ -10,7 +10,7 @@ use { app_data::{AppDataHash, hash_full_app_data}, contracts::alloy::ERC20, e2e::setup::*, - ethrpc::alloy::{CallBuilderExt}, + ethrpc::alloy::CallBuilderExt, model::{ order::{OrderCreation, OrderCreationAppData, OrderKind}, quote::{OrderQuoteRequest, OrderQuoteSide, SellAmount}, From 1d7c249528a9680a0b79e736643f7859b3415c58 Mon Sep 17 00:00:00 2001 From: Aryan Godara Date: Wed, 17 Dec 2025 04:26:39 +0530 Subject: [PATCH 5/8] migrate permit + submission primitives to alloy Signed-off-by: Aryan Godara --- .../e2e/src/setup/onchain_components/mod.rs | 100 +++++++----------- crates/e2e/tests/e2e/hooks.rs | 6 +- crates/e2e/tests/e2e/submission.rs | 5 +- 3 files changed, 46 insertions(+), 65 deletions(-) diff --git a/crates/e2e/src/setup/onchain_components/mod.rs b/crates/e2e/src/setup/onchain_components/mod.rs index 125775f4d0..6e99c8fc13 100644 --- a/crates/e2e/src/setup/onchain_components/mod.rs +++ b/crates/e2e/src/setup/onchain_components/mod.rs @@ -5,7 +5,7 @@ use { }, ::alloy::{ network::{Ethereum, NetworkWallet, TransactionBuilder}, - primitives::Address, + primitives::{Address, U256}, providers::Provider, rpc::types::TransactionRequest, signers::local::PrivateKeySigner, @@ -16,7 +16,7 @@ use { GPv2AllowListAuthentication::GPv2AllowListAuthentication, test::CowProtocolToken, }, - ethcontract::{Account, H160, PrivateKey, U256}, + ethcontract::{Account, PrivateKey}, ethrpc::alloy::{ CallBuilderExt, ProviderSignerExt, @@ -122,7 +122,7 @@ pub struct MintableToken { } impl MintableToken { - pub async fn mint(&self, to: Address, amount: ::alloy::primitives::U256) { + pub async fn mint(&self, to: Address, amount: U256) { self.contract .mint(to, amount) .from(self.minter.address().into_alloy()) @@ -147,7 +147,7 @@ pub struct CowToken { } impl CowToken { - pub async fn fund(&self, to: Address, amount: ::alloy::primitives::U256) { + pub async fn fund(&self, to: Address, amount: U256) { self.contract .transfer(to, amount) .from(self.holder.address().into_alloy()) @@ -156,16 +156,10 @@ impl CowToken { .unwrap(); } - pub async fn permit(&self, owner: &TestAccount, spender: H160, value: U256) -> Hook { + pub async fn permit(&self, owner: &TestAccount, spender: Address, value: U256) -> Hook { let domain = self.contract.DOMAIN_SEPARATOR().call().await.unwrap(); - let nonce = self - .contract - .nonces(owner.address()) - .call() - .await - .unwrap() - .into_legacy(); - let deadline = U256::max_value(); + let nonce = self.contract.nonces(owner.address()).call().await.unwrap(); + let deadline = U256::MAX; let struct_hash = { let mut buffer = [0_u8; 192]; @@ -173,10 +167,10 @@ impl CowToken { "6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9" )); buffer[44..64].copy_from_slice(owner.address().as_slice()); - buffer[76..96].copy_from_slice(spender.as_bytes()); - value.to_big_endian(&mut buffer[96..128]); - nonce.to_big_endian(&mut buffer[128..160]); - deadline.to_big_endian(&mut buffer[160..192]); + buffer[76..96].copy_from_slice(spender.as_slice()); + buffer[96..128].copy_from_slice(value.to_be_bytes::<32>().as_slice()); + buffer[128..160].copy_from_slice(nonce.to_be_bytes::<32>().as_slice()); + buffer[160..192].copy_from_slice(deadline.to_be_bytes::<32>().as_slice()); signing::keccak256(&buffer) }; @@ -185,9 +179,9 @@ impl CowToken { let permit = self.contract.permit( owner.address(), - spender.into_alloy(), - value.into_alloy(), - deadline.into_alloy(), + spender, + value, + deadline, signature.v, signature.r.0.into(), signature.s.0.into(), @@ -250,10 +244,7 @@ impl OnchainComponents { } /// Generate next `N` accounts with the given initial balance. - pub async fn make_accounts( - &mut self, - with_wei: ::alloy::primitives::U256, - ) -> [TestAccount; N] { + pub async fn make_accounts(&mut self, with_wei: U256) -> [TestAccount; N] { let res = self.accounts.borrow_mut().take(N).collect::>(); assert_eq!(res.len(), N); @@ -269,10 +260,7 @@ impl OnchainComponents { /// Generate next `N` accounts with the given initial balance and /// authenticate them as solvers. - pub async fn make_solvers( - &mut self, - with_wei: ::alloy::primitives::U256, - ) -> [TestAccount; N] { + pub async fn make_solvers(&mut self, with_wei: U256) -> [TestAccount; N] { let solvers = self.make_accounts::(with_wei).await; for solver in &solvers { @@ -313,7 +301,7 @@ impl OnchainComponents { /// authenticate them as solvers on a forked network. pub async fn make_solvers_forked( &mut self, - with_wei: ::alloy::primitives::U256, + with_wei: U256, ) -> [TestAccount; N] { let authenticator = &self.contracts.gp_authenticator; @@ -388,8 +376,8 @@ impl OnchainComponents { /// Deploy `N` tokens with WETH Uniswap pools. pub async fn deploy_tokens_with_weth_uni_v2_pools( &self, - token_amount: ::alloy::primitives::U256, - weth_amount: ::alloy::primitives::U256, + token_amount: U256, + weth_amount: U256, ) -> [MintableToken; N] { let minter = Account::Local( self.web3 @@ -408,8 +396,8 @@ impl OnchainComponents { pub async fn seed_weth_uni_v2_pools( &self, tokens: impl IntoIterator, - token_amount: ::alloy::primitives::U256, - weth_amount: ::alloy::primitives::U256, + token_amount: U256, + weth_amount: U256, ) { for MintableToken { contract, minter } in tokens { contract @@ -458,10 +446,10 @@ impl OnchainComponents { *self.contracts.weth.address(), token_amount, weth_amount, - ::alloy::primitives::U256::ZERO, - ::alloy::primitives::U256::ZERO, + U256::ZERO, + U256::ZERO, minter.address().into_alloy(), - ::alloy::primitives::U256::MAX, + U256::MAX, ) .from(minter.address().into_alloy()) .send_and_watch() @@ -472,8 +460,8 @@ impl OnchainComponents { pub async fn seed_uni_v2_pool( &self, - asset_a: (&MintableToken, ::alloy::primitives::U256), - asset_b: (&MintableToken, ::alloy::primitives::U256), + asset_a: (&MintableToken, U256), + asset_b: (&MintableToken, U256), ) { let lp = &asset_a.0.minter; asset_a.0.mint(lp.address().into_alloy(), asset_a.1).await; @@ -509,10 +497,10 @@ impl OnchainComponents { *asset_b.0.address(), asset_a.1, asset_b.1, - ::alloy::primitives::U256::ZERO, - ::alloy::primitives::U256::ZERO, + U256::ZERO, + U256::ZERO, lp.address().into_alloy(), - ::alloy::primitives::U256::MAX, + U256::MAX, ) .from(lp.address().into_alloy()) .send_and_watch() @@ -523,11 +511,7 @@ impl OnchainComponents { /// Mints `amount` tokens to its `token`-WETH Uniswap V2 pool. /// /// This can be used to modify the pool reserves during a test. - pub async fn mint_token_to_weth_uni_v2_pool( - &self, - token: &MintableToken, - amount: ::alloy::primitives::U256, - ) { + pub async fn mint_token_to_weth_uni_v2_pool(&self, token: &MintableToken, amount: U256) { let pair = contracts::alloy::IUniswapLikePair::Instance::new( self.contracts .uniswap_v2_factory @@ -541,17 +525,15 @@ impl OnchainComponents { // Mint amount + 1 to the pool, and then swap out 1 of the minted token // in order to force it to update its K-value. - token - .mint(*pair.address(), amount + ::alloy::primitives::U256::ONE) - .await; + token.mint(*pair.address(), amount + U256::ONE).await; let (out0, out1) = if self.contracts.weth.address() < token.address() { (1, 0) } else { (0, 1) }; pair.swap( - ::alloy::primitives::U256::from(out0), - ::alloy::primitives::U256::from(out1), + U256::from(out0), + U256::from(out1), token.minter.address().into_alloy(), Default::default(), ) @@ -561,7 +543,7 @@ impl OnchainComponents { .expect("Uniswap V2 pair couldn't mint"); } - pub async fn deploy_cow_token(&self, supply: ::alloy::primitives::U256) -> CowToken { + pub async fn deploy_cow_token(&self, supply: U256) -> CowToken { let holder = NetworkWallet::::default_signer_address(&self.web3().wallet); let holder = Account::Local(holder.into_legacy(), None); let contract = CowProtocolToken::CowProtocolToken::deploy( @@ -577,9 +559,9 @@ impl OnchainComponents { pub async fn deploy_cow_weth_pool( &self, - cow_supply: ::alloy::primitives::U256, - cow_amount: ::alloy::primitives::U256, - weth_amount: ::alloy::primitives::U256, + cow_supply: U256, + cow_amount: U256, + weth_amount: U256, ) -> CowToken { let cow = self.deploy_cow_token(cow_supply).await; @@ -618,10 +600,10 @@ impl OnchainComponents { *self.contracts.weth.address(), cow_amount, weth_amount, - ::alloy::primitives::U256::ZERO, - ::alloy::primitives::U256::ZERO, + U256::ZERO, + U256::ZERO, cow.holder.address().into_alloy(), - ::alloy::primitives::U256::MAX, + U256::MAX, ) .from(cow.holder.address().into_alloy()) .send_and_watch() @@ -631,7 +613,7 @@ impl OnchainComponents { cow } - pub async fn send_wei(&self, to: Address, amount: ::alloy::primitives::U256) { + pub async fn send_wei(&self, to: Address, amount: U256) { let balance_before = self.web3.alloy.get_balance(to).await.unwrap(); self.web3 .alloy diff --git a/crates/e2e/tests/e2e/hooks.rs b/crates/e2e/tests/e2e/hooks.rs index 4823949909..a5480363fc 100644 --- a/crates/e2e/tests/e2e/hooks.rs +++ b/crates/e2e/tests/e2e/hooks.rs @@ -122,11 +122,7 @@ async fn allowance(web3: Web3) { // Sign a permit pre-interaction for trading. let permit = cow - .permit( - &trader, - onchain.contracts().allowance.into_legacy(), - 5u64.eth().into_legacy(), - ) + .permit(&trader, onchain.contracts().allowance, 5u64.eth()) .await; // Setup a malicious interaction for setting approvals to steal funds from // the settlement contract. diff --git a/crates/e2e/tests/e2e/submission.rs b/crates/e2e/tests/e2e/submission.rs index f68524dd6e..3d7392a149 100644 --- a/crates/e2e/tests/e2e/submission.rs +++ b/crates/e2e/tests/e2e/submission.rs @@ -16,7 +16,10 @@ use { secp256k1::SecretKey, shared::ethrpc::Web3, std::time::Duration, - web3::signing::SecretKeyRef, + web3::{ + signing::SecretKeyRef, + types::{BlockId, H160, H256}, + }, }; #[tokio::test] From b82f6581b8fa4c0c848e0b2f66dd38effac57de0 Mon Sep 17 00:00:00 2001 From: Aryan Godara Date: Wed, 17 Dec 2025 14:41:12 +0530 Subject: [PATCH 6/8] Use direct U256, Address, and Bytes imports from alloy::primitives Signed-off-by: Aryan Godara --- crates/e2e/src/setup/deploy.rs | 8 ++--- crates/e2e/tests/e2e/cow_amm.rs | 12 +++---- crates/e2e/tests/e2e/hooks.rs | 57 ++++++++++++++++----------------- 3 files changed, 37 insertions(+), 40 deletions(-) diff --git a/crates/e2e/src/setup/deploy.rs b/crates/e2e/src/setup/deploy.rs index 85600ab0ed..74cb9cc5b2 100644 --- a/crates/e2e/src/setup/deploy.rs +++ b/crates/e2e/src/setup/deploy.rs @@ -1,5 +1,5 @@ use { - alloy::primitives::{Address, B256}, + alloy::primitives::{Address, B256, U256}, contracts::alloy::{ BalancerV2Authorizer, BalancerV2Vault, @@ -34,7 +34,7 @@ pub struct Contracts { pub uniswap_v2_factory: UniswapV2Factory::Instance, pub uniswap_v2_router: UniswapV2Router02::Instance, pub weth: WETH9::Instance, - pub allowance: alloy::primitives::Address, + pub allowance: Address, pub domain_separator: DomainSeparator, pub ethflows: Vec, pub hooks: HooksTrampoline::Instance, @@ -142,8 +142,8 @@ impl Contracts { web3.alloy.clone(), *balancer_authorizer.address(), *weth.address(), - alloy::primitives::U256::ZERO, - alloy::primitives::U256::ZERO, + U256::ZERO, + U256::ZERO, ) .await .unwrap(); diff --git a/crates/e2e/tests/e2e/cow_amm.rs b/crates/e2e/tests/e2e/cow_amm.rs index 7ba0390104..f184f9aa23 100644 --- a/crates/e2e/tests/e2e/cow_amm.rs +++ b/crates/e2e/tests/e2e/cow_amm.rs @@ -268,14 +268,14 @@ async fn cow_amm_jit(web3: Web3) { .weth .deposit() .from(bob.address()) - .value(alloy::primitives::U256::from(10u64.pow(17))) + .value(U256::from(10u64.pow(17))) .send_and_watch() .await .unwrap(); onchain .contracts() .weth - .approve(onchain.contracts().allowance, alloy::primitives::U256::MAX) + .approve(onchain.contracts().allowance, U256::MAX) .from(bob.address()) .send_and_watch() .await @@ -284,7 +284,7 @@ async fn cow_amm_jit(web3: Web3) { // place user order with the same limit price as the CoW AMM order let user_order = OrderCreation { sell_token: *onchain.contracts().weth.address(), - sell_amount: alloy::primitives::U256::from(10).pow(alloy::primitives::U256::from(17)), // 0.1 WETH + sell_amount: U256::from(10).pow(U256::from(17)), // 0.1 WETH buy_token: *dai.address(), buy_amount: 230u64.eth(), // 230 DAI valid_to: model::time::now_in_epoch_seconds() + 300, @@ -301,7 +301,7 @@ async fn cow_amm_jit(web3: Web3) { let amm_balance_before = dai.balanceOf(*cow_amm.address()).call().await.unwrap(); let bob_balance_before = dai.balanceOf(bob.address()).call().await.unwrap(); - let fee = alloy::primitives::U256::from(10).pow(alloy::primitives::U256::from(16)); // 0.01 WETH + let fee = U256::from(10).pow(U256::from(16)); // 0.01 WETH mock_solver.configure_solution(Some(Solution { id: 1, @@ -425,9 +425,7 @@ async fn cow_amm_driver_support(web3: Web3) { // Assuming that the pool is balanced, imbalance it by ~30%, so the driver can // crate a CoW AMM JIT order. This imbalance shouldn't exceed 50%, since // such an order will be rejected by the SC: - let weth_to_send = weth_balance - .checked_div(alloy::primitives::U256::from(3)) - .unwrap(); + let weth_to_send = weth_balance.checked_div(U256::from(3)).unwrap(); onchain .contracts() .weth diff --git a/crates/e2e/tests/e2e/hooks.rs b/crates/e2e/tests/e2e/hooks.rs index a5480363fc..b2b887fd1f 100644 --- a/crates/e2e/tests/e2e/hooks.rs +++ b/crates/e2e/tests/e2e/hooks.rs @@ -1,5 +1,8 @@ use { - alloy::providers::Provider, + alloy::{ + primitives::{Address, Bytes, U256}, + providers::Provider, + }, app_data::Hook, e2e::setup::{ OnchainComponents, @@ -128,7 +131,7 @@ async fn allowance(web3: Web3) { // the settlement contract. let steal_cow = { let tx = cow - .approve(trader.address(), alloy::primitives::U256::MAX) + .approve(trader.address(), U256::MAX) .from(solver.address()); Hook { target: *cow.address(), @@ -140,7 +143,7 @@ async fn allowance(web3: Web3) { let approve = onchain .contracts() .weth - .approve(trader.address(), ::alloy::primitives::U256::MAX); + .approve(trader.address(), U256::MAX); Hook { target: *onchain.contracts().weth.address(), call_data: approve.calldata().to_vec(), @@ -215,7 +218,7 @@ async fn allowance(web3: Web3) { .call() .await .unwrap(); - assert_eq!(allowance, alloy::primitives::U256::ZERO); + assert_eq!(allowance, U256::ZERO); let allowance = onchain .contracts() .weth @@ -226,7 +229,7 @@ async fn allowance(web3: Web3) { .call() .await .unwrap(); - assert_eq!(allowance, ::alloy::primitives::U256::ZERO); + assert_eq!(allowance, U256::ZERO); // Note that the allowances were set with the `HooksTrampoline` contract! // This is OK since the `HooksTrampoline` contract is not used for holding @@ -236,7 +239,7 @@ async fn allowance(web3: Web3) { .call() .await .unwrap(); - assert_eq!(allowance, alloy::primitives::U256::MAX); + assert_eq!(allowance, U256::MAX); let allowance = onchain .contracts() .weth @@ -244,13 +247,13 @@ async fn allowance(web3: Web3) { .call() .await .unwrap(); - assert_eq!(allowance, ::alloy::primitives::U256::MAX); + assert_eq!(allowance, U256::MAX); } async fn signature(web3: Web3) { let mut onchain = OnchainComponents::deploy(web3.clone()).await; - let chain_id = alloy::primitives::U256::from(web3.alloy.get_chain_id().await.unwrap()); + let chain_id = U256::from(web3.alloy.get_chain_id().await.unwrap()); let [solver] = onchain.make_solvers(1u64.eth()).await; let [trader] = onchain.make_accounts(1u64.eth()).await; @@ -264,14 +267,14 @@ async fn signature(web3: Web3) { safe_infra .singleton .setup( - vec![trader.address()], // owners - alloy::primitives::U256::ONE, // threshold - alloy::primitives::Address::default(), // delegate call - alloy::primitives::Bytes::default(), // delegate call bytes + vec![trader.address()], // owners + U256::ONE, // threshold + Address::default(), // delegate call + Bytes::default(), // delegate call bytes *safe_infra.fallback.address(), - alloy::primitives::Address::default(), // relayer payment token - alloy::primitives::U256::ZERO, // relayer payment amount - alloy::primitives::Address::default(), // relayer address + Address::default(), // relayer payment token + U256::ZERO, // relayer payment amount + Address::default(), // relayer address ) .calldata() .clone(), @@ -301,11 +304,7 @@ async fn signature(web3: Web3) { .approve(onchain.contracts().allowance, 5u64.eth()) .calldata() .to_vec(); - let approval_builder = safe.sign_transaction( - *token.address(), - approval_call_data, - alloy::primitives::U256::ZERO, - ); + let approval_builder = safe.sign_transaction(*token.address(), approval_call_data, U256::ZERO); let call_data = approval_builder.calldata().to_vec(); let target = approval_builder .into_transaction_request() @@ -531,7 +530,7 @@ async fn partial_fills(web3: Web3) { async fn quote_verification(web3: Web3) { let mut onchain = OnchainComponents::deploy(web3.clone()).await; - let chain_id = alloy::primitives::U256::from(web3.alloy.get_chain_id().await.unwrap()); + let chain_id = U256::from(web3.alloy.get_chain_id().await.unwrap()); let [trader] = onchain.make_accounts(1u64.eth()).await; let [solver] = onchain.make_solvers(1u64.eth()).await; @@ -545,14 +544,14 @@ async fn quote_verification(web3: Web3) { safe_infra .singleton .setup( - vec![trader.address()], // owners - alloy::primitives::U256::ONE, // threshold - alloy::primitives::Address::default(), // delegate call - alloy::primitives::Bytes::default(), // delegate call bytes + vec![trader.address()], // owners + U256::ONE, // threshold + Address::default(), // delegate call + Bytes::default(), // delegate call bytes *safe_infra.fallback.address(), - alloy::primitives::Address::default(), // relayer payment token - alloy::primitives::U256::ZERO, // relayer payment amount - alloy::primitives::Address::default(), // relayer address + Address::default(), // relayer payment token + U256::ZERO, // relayer payment amount + Address::default(), // relayer address ) .calldata() .clone(), @@ -586,7 +585,7 @@ async fn quote_verification(web3: Web3) { .transfer(trader.address(), 5u64.eth()) .calldata() .to_vec(), - alloy::primitives::U256::ZERO, + U256::ZERO, ); let call_data = transfer_builder.calldata().to_vec(); let target = transfer_builder From fbe58495e8ad0150b5d5ef553de2d81251c5ba18 Mon Sep 17 00:00:00 2001 From: Aryan Godara Date: Thu, 18 Dec 2025 12:43:57 +0530 Subject: [PATCH 7/8] fix acc to review comments Signed-off-by: Aryan Godara --- crates/e2e/tests/e2e/cow_amm.rs | 21 +++++++------------ .../e2e/liquidity_source_notification.rs | 11 ++++------ crates/e2e/tests/e2e/quote_verification.rs | 19 ++++++----------- crates/e2e/tests/e2e/smart_contract_orders.rs | 4 ++-- crates/number/src/units.rs | 9 ++++++++ 5 files changed, 29 insertions(+), 35 deletions(-) diff --git a/crates/e2e/tests/e2e/cow_amm.rs b/crates/e2e/tests/e2e/cow_amm.rs index f184f9aa23..841c42f688 100644 --- a/crates/e2e/tests/e2e/cow_amm.rs +++ b/crates/e2e/tests/e2e/cow_amm.rs @@ -217,7 +217,7 @@ async fn cow_amm_jit(web3: Web3) { sellToken: *onchain.contracts().weth.address(), buyToken: *dai.address(), receiver: Default::default(), - sellAmount: U256::from(10).pow(U256::from(17)), + sellAmount: 0.1.eth(), buyAmount: 230u64.eth(), validTo: valid_to, appData: FixedBytes(APP_DATA), @@ -268,7 +268,7 @@ async fn cow_amm_jit(web3: Web3) { .weth .deposit() .from(bob.address()) - .value(U256::from(10u64.pow(17))) + .value(0.1.eth()) .send_and_watch() .await .unwrap(); @@ -284,7 +284,7 @@ async fn cow_amm_jit(web3: Web3) { // place user order with the same limit price as the CoW AMM order let user_order = OrderCreation { sell_token: *onchain.contracts().weth.address(), - sell_amount: U256::from(10).pow(U256::from(17)), // 0.1 WETH + sell_amount: 0.1.eth(), // 0.1 WETH buy_token: *dai.address(), buy_amount: 230u64.eth(), // 230 DAI valid_to: model::time::now_in_epoch_seconds() + 300, @@ -301,7 +301,7 @@ async fn cow_amm_jit(web3: Web3) { let amm_balance_before = dai.balanceOf(*cow_amm.address()).call().await.unwrap(); let bob_balance_before = dai.balanceOf(bob.address()).call().await.unwrap(); - let fee = U256::from(10).pow(U256::from(16)); // 0.01 WETH + let fee = 0.01.eth(); // 0.01 WETH mock_solver.configure_solution(Some(Solution { id: 1, @@ -841,7 +841,7 @@ async fn cow_amm_opposite_direction(web3: Web3) { sellToken: *onchain.contracts().weth.address(), buyToken: *dai.address(), receiver: Default::default(), - sellAmount: U256::from(10).pow(U256::from(17)), + sellAmount: 0.1.eth(), buyAmount: executed_amount, validTo: valid_to, appData: FixedBytes(APP_DATA), @@ -915,7 +915,7 @@ async fn cow_amm_opposite_direction(web3: Web3) { tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; // Set the fees appropriately - let fee_cow_amm = alloy::primitives::U256::from(10).pow(alloy::primitives::U256::from(16)); // 0.01 WETH + let fee_cow_amm = 0.01.eth(); // 0.01 WETH let fee_user = 1u64.eth(); // 1 DAI let mocked_solutions = |order_uid: OrderUid| { @@ -986,19 +986,14 @@ async fn cow_amm_opposite_direction(web3: Web3) { ); // Ensure the amounts are the same as the solution proposes. assert_eq!(quote_response.quote.sell_amount, executed_amount); - assert_eq!( - quote_response.quote.buy_amount, - U256::from(10).pow(U256::from(17)) - ); + assert_eq!(quote_response.quote.buy_amount, 0.1.eth()); // Place user order where bob sells DAI to buy WETH (opposite direction) let user_order = OrderCreation { sell_token: *dai.address(), sell_amount: executed_amount, // 230 DAI buy_token: *onchain.contracts().weth.address(), - buy_amount: alloy::primitives::U256::from(90000000000000000u64), /* 0.09 WETH to generate - * some - * surplus */ + buy_amount: 0.09.eth(), // 0.09 WETH to generate some surplus valid_to: model::time::now_in_epoch_seconds() + 300, kind: OrderKind::Sell, ..Default::default() diff --git a/crates/e2e/tests/e2e/liquidity_source_notification.rs b/crates/e2e/tests/e2e/liquidity_source_notification.rs index dd76009445..cb78c760fa 100644 --- a/crates/e2e/tests/e2e/liquidity_source_notification.rs +++ b/crates/e2e/tests/e2e/liquidity_source_notification.rs @@ -114,7 +114,7 @@ async fn liquidity_source_notification(web3: Web3) { // Trader gives approval to the CoW allowance contract token_usdc - .approve(onchain.contracts().allowance, alloy::primitives::U256::MAX) + .approve(onchain.contracts().allowance, U256::MAX) .from(trader.address()) .send_and_watch() .await @@ -154,10 +154,7 @@ async fn liquidity_source_notification(web3: Web3) { // Maker gives approval to the Liquorice balance manager contract token_usdt - .approve( - liquorice_balance_manager_address, - alloy::primitives::U256::MAX, - ) + .approve(liquorice_balance_manager_address, U256::MAX) .from(liquorice_maker.address()) .send_and_watch() .await @@ -302,7 +299,7 @@ http-timeout = "10s" trades: vec![solvers_dto::solution::Trade::Fulfillment( solvers_dto::solution::Fulfillment { executed_amount: trade_amount, - fee: Some(alloy::primitives::U256::ZERO), + fee: Some(U256::ZERO), order: solvers_dto::solution::OrderUid(order_id.0), }, )], @@ -311,7 +308,7 @@ http-timeout = "10s" solvers_dto::solution::CustomInteraction { target: *liquorice_settlement.address(), calldata: liquorice_solution_calldata, - value: alloy::primitives::U256::ZERO, + value: U256::ZERO, allowances: vec![solvers_dto::solution::Allowance { token: *token_usdc.address(), spender: liquorice_balance_manager_address, diff --git a/crates/e2e/tests/e2e/quote_verification.rs b/crates/e2e/tests/e2e/quote_verification.rs index c3a4961c2d..34e0fe671b 100644 --- a/crates/e2e/tests/e2e/quote_verification.rs +++ b/crates/e2e/tests/e2e/quote_verification.rs @@ -5,10 +5,7 @@ use { }, bigdecimal::{BigDecimal, Zero}, e2e::setup::*, - ethrpc::{ - Web3, - alloy::{CallBuilderExt, conversions::IntoLegacy}, - }, + ethrpc::{Web3, alloy::CallBuilderExt}, model::{ interaction::InteractionData, order::{BuyTokenDestination, OrderKind, SellTokenSource}, @@ -29,7 +26,7 @@ use { }, trade_finding::{Interaction, LegacyTrade, QuoteExecution, TradeKind}, }, - std::sync::Arc, + std::{str::FromStr, sync::Arc}, }; #[tokio::test] @@ -186,8 +183,7 @@ async fn test_bypass_verification_for_rfq_quotes(web3: Web3) { data: const_hex::decode("aa77476c000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000000000000000000000000000e357b42c3a9d8ccf0000000000000000000000000000000000000000000000000000000004d0e79e000000000000000000000000a69babef1ca67a37ffaf7a485dfff3382056e78c0000000000000000000000009008d19f58aabd9ed0d60971565aa8510560ab41000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000066360af101ffffffffffffffffffffffffffffffffffffff0f3f47f166360a8d0000003f0000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000001c66b3383f287dd9c85ad90e7c5a576ea4ba1bdf5a001d794a9afa379e6b2517b47e487a1aef32e75af432cbdbd301ada42754eaeac21ec4ca744afd92732f47540000000000000000000000000000000000000000000000000000000004d0c80f").unwrap(), value: U256::ZERO, }], - solver: address!("0xe3067c7c27c1038de4e8ad95a83b927d23dfbd99") - , + solver: address!("e3067c7c27c1038de4e8ad95a83b927d23dfbd99"), tx_origin, }), ) @@ -198,12 +194,12 @@ async fn test_bypass_verification_for_rfq_quotes(web3: Web3) { let verified_quote = Estimate { out_amount: U256::from(16380122291179526144u128), gas: 225000, - solver: address!("e3067c7c27c1038de4e8ad95a83b927d23dfbd99").into_legacy(), + solver: ethcontract::H160::from_str("0xe3067c7c27c1038de4e8ad95a83b927d23dfbd99").unwrap(), verified: true, execution: QuoteExecution { interactions: vec![InteractionData { target: address!("0xdef1c0ded9bec7f1a1670819833240f027b25eff"), - value: ::alloy::primitives::U256::ZERO, + value: U256::ZERO, call_data: const_hex::decode("aa77476c000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000000000000000000000000000e357b42c3a9d8ccf0000000000000000000000000000000000000000000000000000000004d0e79e000000000000000000000000a69babef1ca67a37ffaf7a485dfff3382056e78c0000000000000000000000009008d19f58aabd9ed0d60971565aa8510560ab41000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000066360af101ffffffffffffffffffffffffffffffffffffff0f3f47f166360a8d0000003f0000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000001c66b3383f287dd9c85ad90e7c5a576ea4ba1bdf5a001d794a9afa379e6b2517b47e487a1aef32e75af432cbdbd301ada42754eaeac21ec4ca744afd92732f47540000000000000000000000000000000000000000000000000000000004d0c80f").unwrap() }], pre_interactions: vec![], @@ -397,10 +393,7 @@ async fn verified_quote_with_simulated_balance(web3: Web3) { .await .unwrap(), ), - ( - ::alloy::primitives::U256::ZERO, - ::alloy::primitives::U256::ZERO - ), + (U256::ZERO, U256::ZERO), ); let response = services .submit_quote(&OrderQuoteRequest { diff --git a/crates/e2e/tests/e2e/smart_contract_orders.rs b/crates/e2e/tests/e2e/smart_contract_orders.rs index de6c7ed7f5..3c8e9e5a42 100644 --- a/crates/e2e/tests/e2e/smart_contract_orders.rs +++ b/crates/e2e/tests/e2e/smart_contract_orders.rs @@ -1,5 +1,5 @@ use { - ::alloy::primitives::Address, + ::alloy::primitives::{Address, U256}, e2e::setup::{safe::Safe, *}, ethrpc::alloy::CallBuilderExt, model::{ @@ -184,7 +184,7 @@ async fn erc1271_gas_limit(web3: Web3) { .await; // Use 1M gas units during signature verification - let signature = ::alloy::primitives::U256::from(1_000_000).to_be_bytes::<32>(); + let signature = U256::from(1_000_000).to_be_bytes::<32>(); let order = OrderCreation { sell_token: *cow.address(), diff --git a/crates/number/src/units.rs b/crates/number/src/units.rs index 6bef7ade61..fde77ce0d4 100644 --- a/crates/number/src/units.rs +++ b/crates/number/src/units.rs @@ -31,3 +31,12 @@ impl EthUnit for u128 { U256::from(self) } } +impl EthUnit for f64 { + fn atom(self) -> U256 { + U256::from(self as u128) + } + + fn eth(self) -> U256 { + U256::from((self * 1e18) as u128) + } +} From 33aa0402870b881440e419c3ac90231683a9a8b7 Mon Sep 17 00:00:00 2001 From: Aryan Godara Date: Thu, 18 Dec 2025 12:54:45 +0530 Subject: [PATCH 8/8] fix linting and imports post rebasing Signed-off-by: Aryan Godara --- crates/e2e/tests/e2e/place_order_with_quote.rs | 2 +- crates/e2e/tests/e2e/submission.rs | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/crates/e2e/tests/e2e/place_order_with_quote.rs b/crates/e2e/tests/e2e/place_order_with_quote.rs index 372c003346..82f49cd359 100644 --- a/crates/e2e/tests/e2e/place_order_with_quote.rs +++ b/crates/e2e/tests/e2e/place_order_with_quote.rs @@ -131,7 +131,7 @@ async fn disabled_same_sell_and_buy_token_order_feature(web3: Web3) { token.mint(trader.address(), 10u64.eth()).await; token - .approve(onchain.contracts().allowance.into_alloy(), 10u64.eth()) + .approve(onchain.contracts().allowance, 10u64.eth()) .from(trader.address()) .send_and_watch() .await diff --git a/crates/e2e/tests/e2e/submission.rs b/crates/e2e/tests/e2e/submission.rs index 3d7392a149..fef0849d95 100644 --- a/crates/e2e/tests/e2e/submission.rs +++ b/crates/e2e/tests/e2e/submission.rs @@ -1,11 +1,7 @@ use { ::alloy::primitives::U256, e2e::{nodes::local_node::TestNodeApi, setup::*}, - ethcontract::{BlockId, H160, H256}, - ethrpc::alloy::{ - CallBuilderExt, - conversions::{IntoAlloy, IntoLegacy}, - }, + ethrpc::alloy::{CallBuilderExt, conversions::IntoLegacy}, futures::{Stream, StreamExt}, model::{ order::{OrderCreation, OrderKind}, @@ -152,7 +148,7 @@ async fn test_submit_same_sell_and_buy_token_order_without_quote(web3: Web3) { token.mint(trader.address(), 10u64.eth()).await; token - .approve(onchain.contracts().allowance.into_alloy(), 10u64.eth()) + .approve(onchain.contracts().allowance, 10u64.eth()) .from(trader.address()) .send_and_watch() .await @@ -180,7 +176,7 @@ async fn test_submit_same_sell_and_buy_token_order_without_quote(web3: Web3) { assert_eq!(initial_balance, 10u64.eth()); let sell_amount = 1u64.eth(); // Sell 1 eth - let buy_amount = 1u64.eth() - U256::from(10).pow(U256::from(16)); // For 0.99 wei, for order to execute + let buy_amount = 0.99.eth(); // For 0.99 ETH, for order to execute tracing::info!("Placing order"); let order = OrderCreation { @@ -268,7 +264,7 @@ async fn test_execute_same_sell_and_buy_token(web3: Web3) { token.mint(trader.address(), 10u64.eth()).await; token - .approve(onchain.contracts().allowance.into_alloy(), 10u64.eth()) + .approve(onchain.contracts().allowance, 10u64.eth()) .from(trader.address()) .send_and_watch() .await