diff --git a/crates/e2e/src/setup/deploy.rs b/crates/e2e/src/setup/deploy.rs index 85cb82dfb7..74cb9cc5b2 100644 --- a/crates/e2e/src/setup/deploy.rs +++ b/crates/e2e/src/setup/deploy.rs @@ -1,4 +1,5 @@ use { + alloy::primitives::{Address, B256, U256}, contracts::alloy::{ BalancerV2Authorizer, BalancerV2Vault, @@ -12,11 +13,7 @@ use { WETH9, support::{Balances, Signatures}, }, - ethcontract::{Address, H256}, - ethrpc::alloy::{ - CallBuilderExt, - conversions::{IntoAlloy, IntoLegacy}, - }, + ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, model::DomainSeparator, shared::ethrpc::Web3, }; @@ -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,27 +123,33 @@ 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()) - .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(), *weth.address(), - alloy::primitives::U256::ZERO, - alloy::primitives::U256::ZERO, + U256::ZERO, + U256::ZERO, ) .await .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 +164,7 @@ impl Contracts { .await .unwrap(); gp_authenticator - .initializeManager(admin.into_alloy()) + .initializeManager(admin) .send_and_watch() .await .expect("failed to initialize manager"); @@ -196,8 +198,7 @@ impl Contracts { .vaultRelayer() .call() .await - .expect("Couldn't get vault relayer address") - .into_legacy(); + .expect("Couldn't get vault relayer address"); let domain_separator = DomainSeparator( gp_settlement .domainSeparator() @@ -250,10 +251,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/src/setup/onchain_components/mod.rs b/crates/e2e/src/setup/onchain_components/mod.rs index ecaa0b1e41..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(), ) @@ -568,7 +550,7 @@ impl OnchainComponents { self.web3.alloy.clone(), holder.address().into_alloy(), holder.address().into_alloy(), - supply.into_alloy(), + supply, ) .await .expect("CowProtocolToken deployment failed"); @@ -586,7 +568,7 @@ impl OnchainComponents { self.contracts .weth .deposit() - .value(weth_amount.into_alloy()) + .value(weth_amount) .from(cow.holder.address().into_alloy()) .send_and_watch() .await @@ -599,20 +581,14 @@ impl OnchainComponents { .send_and_watch() .await .unwrap(); - cow.approve( - *self.contracts.uniswap_v2_router.address(), - cow_amount.into_alloy(), - ) - .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.into_alloy(), - ) + .approve(*self.contracts.uniswap_v2_router.address(), weth_amount) .from(cow.holder.address().into_alloy()) .send_and_watch() .await @@ -622,12 +598,12 @@ impl OnchainComponents { .addLiquidity( *cow.address(), *self.contracts.weth.address(), - cow_amount.into_alloy(), - weth_amount.into_alloy(), - ::alloy::primitives::U256::ZERO, - ::alloy::primitives::U256::ZERO, + cow_amount, + weth_amount, + U256::ZERO, + U256::ZERO, cow.holder.address().into_alloy(), - ::alloy::primitives::U256::MAX, + U256::MAX, ) .from(cow.holder.address().into_alloy()) .send_and_watch() @@ -637,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/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/app_data.rs b/crates/e2e/tests/e2e/app_data.rs index 5b5a81d679..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, 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..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, 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 189d80a0a5..a10684702d 100644 --- a/crates/e2e/tests/e2e/autopilot_leader.rs +++ b/crates/e2e/tests/e2e/autopilot_leader.rs @@ -1,13 +1,7 @@ use { autopilot::shutdown_controller::ShutdownController, e2e::setup::{OnchainComponents, Services, TIMEOUT, colocation, run_test, wait_for_condition}, - ethrpc::{ - Web3, - alloy::{ - CallBuilderExt, - conversions::{IntoAlloy, IntoLegacy}, - }, - }, + ethrpc::{Web3, alloy::CallBuilderExt}, model::order::{OrderCreation, OrderKind}, number::units::EthUnit, secp256k1::SecretKey, @@ -39,7 +33,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 @@ -131,7 +125,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 +161,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/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..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, 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..841c42f688 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, IntoLegacy}, - }, + ethrpc::alloy::{CallBuilderExt, conversions::IntoAlloy}, model::{ order::{OrderClass, OrderCreation, OrderKind, OrderUid}, quote::{OrderQuoteRequest, OrderQuoteSide, SellAmount}, @@ -220,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), @@ -271,17 +268,14 @@ async fn cow_amm_jit(web3: Web3) { .weth .deposit() .from(bob.address()) - .value(alloy::primitives::U256::from(10u64.pow(17))) + .value(0.1.eth()) .send_and_watch() .await .unwrap(); onchain .contracts() .weth - .approve( - onchain.contracts().allowance.into_alloy(), - alloy::primitives::U256::MAX, - ) + .approve(onchain.contracts().allowance, U256::MAX) .from(bob.address()) .send_and_watch() .await @@ -290,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: 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, @@ -307,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 = 0.01.eth(); // 0.01 WETH mock_solver.configure_solution(Some(Solution { id: 1, @@ -394,8 +388,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; @@ -431,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 @@ -476,7 +468,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 @@ -849,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), @@ -896,14 +888,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.into_alloy(), - 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 @@ -926,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| { @@ -997,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/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..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, 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..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, @@ -10,10 +13,7 @@ use { safe::Safe, wait_for_condition, }, - ethrpc::alloy::{ - CallBuilderExt, - conversions::{IntoAlloy, IntoLegacy}, - }, + ethrpc::alloy::{CallBuilderExt, conversions::IntoLegacy}, model::{ order::{OrderCreation, OrderCreationAppData, OrderKind}, quote::{OrderQuoteRequest, OrderQuoteSide, SellAmount}, @@ -63,16 +63,12 @@ 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 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 @@ -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 @@ -133,17 +125,13 @@ async fn allowance(web3: Web3) { // Sign a permit pre-interaction for trading. let permit = cow - .permit( - &trader, - onchain.contracts().allowance, - 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. 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(), @@ -155,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(), @@ -230,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 @@ -241,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 @@ -251,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 @@ -259,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; @@ -279,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(), @@ -313,14 +301,10 @@ 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( - *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() @@ -434,7 +418,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 @@ -546,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; @@ -560,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(), @@ -587,7 +571,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 @@ -601,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 diff --git a/crates/e2e/tests/e2e/jit_orders.rs b/crates/e2e/tests/e2e/jit_orders.rs index 34cb1efd14..a64d6dc4f1 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, model::{ order::{OrderClass, OrderCreation, OrderKind}, signature::EcdsaSigningScheme, @@ -47,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 @@ -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..d8cc7bd7a2 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, fee::{FeePolicyOrderClass, ProtocolFee, ProtocolFeesConfig}, model::{ order::{OrderClass, OrderCreation, OrderKind}, @@ -158,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 @@ -280,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 @@ -382,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 @@ -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 @@ -608,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 @@ -690,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 @@ -845,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 @@ -945,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 @@ -1010,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 1c31e0e2e5..cb78c760fa 100644 --- a/crates/e2e/tests/e2e/liquidity_source_notification.rs +++ b/crates/e2e/tests/e2e/liquidity_source_notification.rs @@ -19,13 +19,7 @@ use { wait_for_condition, }, }, - ethrpc::{ - Web3, - alloy::{ - CallBuilderExt, - conversions::{IntoAlloy, IntoLegacy}, - }, - }, + ethrpc::{Web3, alloy::CallBuilderExt}, model::{ order::{OrderCreation, OrderKind}, signature::EcdsaSigningScheme, @@ -120,10 +114,7 @@ async fn liquidity_source_notification(web3: Web3) { // Trader gives approval to the CoW allowance contract token_usdc - .approve( - onchain.contracts().allowance.into_alloy(), - alloy::primitives::U256::MAX, - ) + .approve(onchain.contracts().allowance, U256::MAX) .from(trader.address()) .send_and_watch() .await @@ -163,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 @@ -311,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), }, )], @@ -320,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, @@ -343,7 +331,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/order_cancellation.rs b/crates/e2e/tests/e2e/order_cancellation.rs index 00e1445cac..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, 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 472735e144..a13af551cb 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, model::{ order::{OrderCreation, OrderKind}, signature::{EcdsaSigningScheme, Signature, SigningScheme}, @@ -36,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 @@ -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/partially_fillable_balance.rs b/crates/e2e/tests/e2e/partially_fillable_balance.rs index 1b85a75402..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, 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..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, 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..82f49cd359 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 @@ -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/protocol_fee.rs b/crates/e2e/tests/e2e/protocol_fee.rs index 98daf2ede9..71e2729afe 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 @@ -173,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( [ @@ -184,8 +183,8 @@ 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, quote_valid_to, @@ -198,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) @@ -209,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) @@ -220,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(), @@ -249,8 +248,8 @@ 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, model::time::now_in_epoch_seconds() + 300, @@ -279,8 +278,8 @@ 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, 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..34e0fe671b 100644 --- a/crates/e2e/tests/e2e/quote_verification.rs +++ b/crates/e2e/tests/e2e/quote_verification.rs @@ -5,11 +5,7 @@ use { }, bigdecimal::{BigDecimal, Zero}, e2e::setup::*, - ethcontract::H160, - ethrpc::{ - Web3, - alloy::{CallBuilderExt, conversions::IntoAlloy}, - }, + ethrpc::{Web3, alloy::CallBuilderExt}, model::{ interaction::InteractionData, order::{BuyTokenDestination, OrderKind, SellTokenSource}, @@ -95,7 +91,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 @@ -187,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, }), ) @@ -199,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: H160::from_str("0xe3067c7c27c1038de4e8ad95a83b927d23dfbd99").unwrap(), + 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![], @@ -255,7 +250,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,15 +388,12 @@ 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(), ), - ( - ::alloy::primitives::U256::ZERO, - ::alloy::primitives::U256::ZERO - ), + (U256::ZERO, U256::ZERO), ); let response = services .submit_quote(&OrderQuoteRequest { @@ -437,7 +429,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..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, 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..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, 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..3c8e9e5a42 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, + ::alloy::primitives::{Address, U256}, e2e::setup::{safe::Safe, *}, - ethcontract::U256, - ethrpc::alloy::{ - CallBuilderExt, - conversions::{IntoAlloy, IntoLegacy}, - }, + ethrpc::alloy::CallBuilderExt, model::{ order::{OrderCreation, OrderCreationAppData, OrderKind, OrderStatus, OrderUid}, signature::Signature, @@ -43,7 +39,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; @@ -164,21 +160,13 @@ 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 cow.fund(*trader.address(), 5u64.eth()).await; trader - .approve( - *cow.address(), - onchain.contracts().allowance.into_alloy(), - 10u64.eth(), - ) + .approve(*cow.address(), onchain.contracts().allowance, 10u64.eth()) .from(solver.address()) .send_and_watch() .await @@ -196,8 +184,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 = U256::from(1_000_000).to_be_bytes::<32>(); let order = OrderCreation { sell_token: *cow.address(), diff --git a/crates/e2e/tests/e2e/solver_competition.rs b/crates/e2e/tests/e2e/solver_competition.rs index b3c9ce4025..0b59f0bb88 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, model::{ order::{OrderCreation, OrderKind}, signature::EcdsaSigningScheme, @@ -51,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 @@ -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(); @@ -183,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 @@ -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"); @@ -323,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 @@ -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/solver_participation_guard.rs b/crates/e2e/tests/e2e/solver_participation_guard.rs index c8c63428cc..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, conversions::IntoAlloy}, - }, + ethrpc::{Web3, alloy::CallBuilderExt}, model::{ order::{OrderClass, OrderCreation, OrderKind}, signature::EcdsaSigningScheme, @@ -290,7 +287,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..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}, @@ -16,7 +12,10 @@ use { secp256k1::SecretKey, shared::ethrpc::Web3, std::time::Duration, - web3::signing::SecretKeyRef, + web3::{ + signing::SecretKeyRef, + types::{BlockId, H160, H256}, + }, }; #[tokio::test] @@ -50,7 +49,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 @@ -149,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 @@ -177,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 { @@ -265,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 diff --git a/crates/e2e/tests/e2e/tracking_insufficient_funds.rs b/crates/e2e/tests/e2e/tracking_insufficient_funds.rs index 9f24ac2305..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, 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..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, 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..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, 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..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, conversions::IntoAlloy}, + 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.into_alloy(), - 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 5eee690181..bf350666e2 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, model::{ order::{OrderCreation, OrderCreationAppData, OrderKind}, quote::{OrderQuoteRequest, OrderQuoteSide, SellAmount}, @@ -97,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 @@ -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); 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) + } +}