Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
379285e
Migrate quote DTO to alloy
jmg-duarte Nov 7, 2025
a360fb3
Migrate the native price estimation endpoint and trait to alloy
jmg-duarte Nov 7, 2025
1cf04a3
Clippy
jmg-duarte Nov 7, 2025
cffad67
Merge branch 'jmgd/alloy/quote-dto' into jmgd/alloy/native-price
jmg-duarte Nov 7, 2025
09209ba
Migrate get_orders_by_tx endpoint to alloy
jmg-duarte Nov 7, 2025
2873159
Merge branch 'main' into jmgd/alloy/quote-dto
jmg-duarte Nov 7, 2025
7b2c90e
Merge branch 'jmgd/alloy/quote-dto' into jmgd/alloy/native-price
jmg-duarte Nov 7, 2025
0c8d469
fix compilation error
jmg-duarte Nov 7, 2025
dd25d86
Merge branch 'jmgd/alloy/native-price' into jmgd/alloy/get_orders_by_tx
jmg-duarte Nov 7, 2025
cd115d9
Migrate solver competition endpoint to alloy
jmg-duarte Nov 7, 2025
93293d7
Migrate get_token_metadata endpoint to alloy
jmg-duarte Nov 7, 2025
38f47fb
Migrate get_total_surplus_endpoint to alloy
jmg-duarte Nov 7, 2025
e5b1671
Migrate get_trades endpoint to alloy
jmg-duarte Nov 7, 2025
f5018ab
Migrate get_user_orders endpoint to alloy
jmg-duarte Nov 7, 2025
7e4b069
Migrate orderbook::database::auction_prices to alloy
jmg-duarte Nov 7, 2025
8b15cd9
Migrate orderbook::database::solver_competition to alloy
jmg-duarte Nov 10, 2025
d104971
Migrate orderbook::database::solver_competition_v2 into alloy
jmg-duarte Nov 10, 2025
cb99ac4
compilation fix
jmg-duarte Nov 10, 2025
f10166b
Migrate OrderMetadata and OnchainOrderData models to alloy
jmg-duarte Nov 10, 2025
3b939f0
Merge branch 'main' into jmgd/alloy/models_order_data
jmg-duarte Nov 20, 2025
9e23e12
compilation fixes
jmg-duarte Nov 20, 2025
9543cc4
Migrate orderbook::orderbook to alloy
jmg-duarte Nov 20, 2025
e2b30b3
Migrate orderbook::quoter into alloy
jmg-duarte Nov 24, 2025
ee05631
force uint sizes through types
jmg-duarte Nov 24, 2025
aed17b3
Migrate QuoteSearchParameters into alloy
jmg-duarte Nov 24, 2025
2cbc736
fix fmt
jmg-duarte Nov 24, 2025
ff199b2
Migrate QuoteData to alloy
jmg-duarte Nov 24, 2025
0d37d9b
Migrate EthflowData into alloy
jmg-duarte Nov 25, 2025
9868db5
Merge branch 'jmgd/alloy/orderbook' into jmgd/temp_main
jmg-duarte Nov 25, 2025
337b4b5
Merge branch 'jmgd/alloy/quoter' into jmgd/temp_main
jmg-duarte Nov 25, 2025
d5a8b95
Merge branch 'jmgd/alloy/quote_search_parameters' into jmgd/temp_main
jmg-duarte Nov 25, 2025
17315f0
Merge branch 'jmgd/alloy/quote_data' into jmgd/temp_main
jmg-duarte Nov 25, 2025
4d30fd4
Merge branch 'jmgd/alloy/ethflow_data' into jmgd/temp_main
jmg-duarte Nov 25, 2025
e01f953
Migrate DTOs and validation to alloy types
jmg-duarte Nov 25, 2025
008b832
Merge branch 'main' into jmgd/alloy/quote_data
jmg-duarte Nov 25, 2025
93f9c21
fix merge
jmg-duarte Nov 25, 2025
5754902
Merge branch 'jmgd/alloy/quote_data' into jmgd/temp_main
jmg-duarte Nov 25, 2025
0763f8c
clippy
jmg-duarte Nov 25, 2025
4dc1e4e
Replace ethcontract primitives with alloy types in quote handling, or…
jmg-duarte Nov 25, 2025
7b46762
Migrate OrderQuoteRequest to use alloy Address types
jmg-duarte Nov 25, 2025
9a2dfcd
Migrate model::order,quote;solver_comp
jmg-duarte Nov 26, 2025
d88c446
Migrate more things
jmg-duarte Nov 26, 2025
3182053
fmt
jmg-duarte Nov 26, 2025
1665333
Merge branch 'main' into jmgd/alloy/models
jmg-duarte Nov 26, 2025
c7333d6
Merge branch 'main' into jmgd/alloy/models
jmg-duarte Nov 26, 2025
0327545
Migrate from H160 to alloy Address types
jmg-duarte Nov 26, 2025
e280d5a
simplifications
jmg-duarte Nov 27, 2025
593ad3a
fix bug
jmg-duarte Nov 27, 2025
3d0a652
Merge branch 'jmgd/alloy/models' into jmgd/alloy/h160_contract
jmg-duarte Nov 27, 2025
3030db3
fix compilation errors
jmg-duarte Nov 27, 2025
2fbfdab
Merge branch 'main' into jmgd/alloy/h160_contract
jmg-duarte Nov 27, 2025
ec1faf5
some issues with mocking
jmg-duarte Nov 27, 2025
6344901
fix clippy
jmg-duarte Nov 27, 2025
013690f
clippy
jmg-duarte Nov 27, 2025
2f4ba3b
address comments
jmg-duarte Nov 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 7 additions & 24 deletions crates/autopilot/src/infra/blockchain/contracts.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use {
crate::domain,
alloy::primitives::Address,
chain::Chain,
contracts::alloy::{
ChainalysisOracle,
Expand All @@ -9,11 +10,7 @@ use {
WETH9,
support::Balances,
},
ethrpc::{
Web3,
alloy::conversions::{IntoAlloy, IntoLegacy},
},
primitive_types::H160,
ethrpc::{Web3, alloy::conversions::IntoLegacy},
};

#[derive(Debug, Clone)]
Expand All @@ -34,19 +31,18 @@ pub struct Contracts {

#[derive(Debug, Clone)]
pub struct Addresses {
pub settlement: Option<H160>,
pub signatures: Option<H160>,
pub weth: Option<H160>,
pub balances: Option<H160>,
pub trampoline: Option<H160>,
pub settlement: Option<Address>,
pub signatures: Option<Address>,
pub weth: Option<Address>,
pub balances: Option<Address>,
pub trampoline: Option<Address>,
}

impl Contracts {
pub async fn new(web3: &Web3, chain: &Chain, addresses: Addresses) -> Self {
let settlement = GPv2Settlement::Instance::new(
addresses
.settlement
.map(IntoAlloy::into_alloy)
.or_else(|| GPv2Settlement::deployment_address(&chain.id()))
.unwrap(),
web3.alloy.clone(),
Expand All @@ -55,7 +51,6 @@ impl Contracts {
let signatures = contracts::alloy::support::Signatures::Instance::new(
addresses
.signatures
.map(IntoAlloy::into_alloy)
.or_else(|| contracts::alloy::support::Signatures::deployment_address(&chain.id()))
.unwrap(),
web3.alloy.clone(),
Expand All @@ -64,7 +59,6 @@ impl Contracts {
let weth = WETH9::Instance::new(
addresses
.weth
.map(IntoAlloy::into_alloy)
.or_else(|| WETH9::deployment_address(&chain.id()))
.unwrap(),
web3.alloy.clone(),
Expand All @@ -73,7 +67,6 @@ impl Contracts {
let balances = Balances::Instance::new(
addresses
.balances
.map(IntoAlloy::into_alloy)
.or_else(|| Balances::deployment_address(&chain.id()))
.unwrap(),
web3.alloy.clone(),
Expand All @@ -82,7 +75,6 @@ impl Contracts {
let trampoline = HooksTrampoline::Instance::new(
addresses
.trampoline
.map(IntoAlloy::into_alloy)
.or_else(|| HooksTrampoline::deployment_address(&chain.id()))
.unwrap(),
web3.alloy.clone(),
Expand Down Expand Up @@ -160,12 +152,3 @@ impl Contracts {
&self.authenticator
}
}

/// Returns the address of a contract for the specified chain, or `None` if
/// there is no known deployment for the contract on that chain.
pub fn deployment_address(contract: &ethcontract::Contract, chain: &Chain) -> Option<H160> {
contract
.networks
.get(&chain.id().to_string())
.map(|network| network.address)
}
18 changes: 6 additions & 12 deletions crates/autopilot/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,8 @@ pub async fn run(args: Arguments, shutdown_controller: ShutdownController) {
let contracts = infra::blockchain::contracts::Addresses {
settlement: args.shared.settlement_contract_address,
signatures: args.shared.signatures_contract_address,
weth: args
.shared
.native_token_address
.map(IntoLegacy::into_legacy),
balances: args
.shared
.balances_contract_address
.map(IntoLegacy::into_legacy),
weth: args.shared.native_token_address,
balances: args.shared.balances_contract_address,
trampoline: args.shared.hooks_contract_address,
};
let eth = ethereum(
Expand Down Expand Up @@ -322,11 +316,11 @@ pub async fn run(args: Arguments, shutdown_controller: ShutdownController) {
.await;

let base_tokens = Arc::new(BaseTokens::new(
eth.contracts().weth().address().into_legacy(),
*eth.contracts().weth().address(),
&args.shared.base_tokens,
));
let mut allowed_tokens = args.allowed_tokens.clone();
allowed_tokens.extend(base_tokens.tokens().iter().map(|t| t.into_alloy()));
allowed_tokens.extend(base_tokens.tokens().iter());
allowed_tokens.push(model::order::BUY_ETH_ADDRESS.into_alloy());
let unsupported_tokens = args.unsupported_tokens.clone();

Expand All @@ -339,7 +333,7 @@ pub async fn run(args: Arguments, shutdown_controller: ShutdownController) {
vault.as_ref(),
uniswapv3_factory.as_ref(),
&base_tokens,
eth.contracts().settlement().address().into_legacy(),
*eth.contracts().settlement().address(),
)
.instrument(info_span!("token_owner_finder_init"))
.await
Expand All @@ -354,7 +348,7 @@ pub async fn run(args: Arguments, shutdown_controller: ShutdownController) {
tracing_node_url,
"trace",
),
eth.contracts().settlement().address().into_legacy(),
*eth.contracts().settlement().address(),
finder,
)),
args.shared.token_quality_cache_expiry,
Expand Down
12 changes: 9 additions & 3 deletions crates/driver/src/boundary/liquidity/balancer/v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,18 @@ fn to_interaction(
// change this assumption, we would need to change it there as well.
receiver.0.into_alloy(),
pool.vault.0.into_alloy(),
Allowances::empty(receiver.0),
Allowances::empty(receiver.0.into_alloy()),
);

let interaction = handler.swap(
TokenAmount::new(input.0.token.into(), input.0.amount),
TokenAmount::new(output.0.token.into(), output.0.amount),
TokenAmount::new(
input.0.token.0.0.into_alloy(),
input.0.amount.0.into_alloy(),
),
TokenAmount::new(
output.0.token.0.0.into_alloy(),
output.0.amount.0.into_alloy(),
),
);

let (target, value, call_data) = interaction.encode_swap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn to_domain(id: liquidity::Id, pool: StablePoolOrder) -> Result<liquidity::
.map(|(token, reserve)| {
Ok(balancer::v2::stable::Reserve {
asset: eth::Asset {
token: token.into(),
token: token.into_legacy().into(),
amount: reserve.balance.into(),
},
scale: balancer::v2::ScalingFactor::from_raw(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn to_domain(id: liquidity::Id, pool: WeightedProductOrder) -> Result<liquid
.map(|(token, reserve)| {
Ok(balancer::v2::weighted::Reserve {
asset: eth::Asset {
token: token.into(),
token: token.into_legacy().into(),
amount: reserve.common.balance.into(),
},
weight: balancer::v2::weighted::Weight::from_raw(
Expand Down
10 changes: 3 additions & 7 deletions crates/driver/src/boundary/liquidity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ use {
infra::{self, blockchain::Ethereum},
},
anyhow::Result,
ethrpc::{
alloy::conversions::{IntoAlloy, IntoLegacy},
block_stream::CurrentBlockWatcher,
},
ethrpc::{alloy::conversions::IntoAlloy, block_stream::CurrentBlockWatcher},
futures::future,
model::TokenPair,
shared::{
Expand Down Expand Up @@ -103,12 +100,11 @@ impl Fetcher {
.await?;

let base_tokens = BaseTokens::new(
eth.contracts().weth().address().into_legacy(),
*eth.contracts().weth().address(),
&config
.base_tokens
.iter()
.copied()
.map(eth::H160::from)
.map(|t| t.0.0.into_alloy())
.collect::<Vec<_>>(),
);

Expand Down
23 changes: 13 additions & 10 deletions crates/driver/src/boundary/liquidity/uniswap/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use {
},
infra::{self, blockchain::Ethereum},
},
alloy::primitives::Address,
async_trait::async_trait,
contracts::alloy::IUniswapLikeRouter,
ethrpc::{
Expand Down Expand Up @@ -75,7 +76,7 @@ pub(in crate::boundary::liquidity) fn to_domain_pool(
);

Ok(liquidity::uniswap::v2::Pool {
address: pool.address.into(),
address: pool.address.into_legacy().into(),
router: router(&pool),
reserves: liquidity::uniswap::v2::Reserves::try_new(
eth::Asset {
Expand All @@ -100,12 +101,18 @@ pub fn to_interaction(
let handler = uniswap_v2::Inner::new(
pool.router.0.into_alloy(),
receiver.0.into_alloy(),
Mutex::new(Allowances::empty(receiver.0)),
Mutex::new(Allowances::empty(receiver.0.into_alloy())),
);

let (_, interaction) = handler.settle(
TokenAmount::new(input.0.token.into(), input.0.amount),
TokenAmount::new(output.0.token.into(), output.0.amount),
TokenAmount::new(
input.0.token.0.0.into_alloy(),
input.0.amount.0.into_alloy(),
),
TokenAmount::new(
output.0.token.0.0.into_alloy(),
output.0.amount.0.into_alloy(),
),
);

let (target, value, call_data) = interaction.encode_swap();
Expand Down Expand Up @@ -142,7 +149,7 @@ where
let pool_fetcher = {
let factory = router.factory().call().await?;
let pair_provider = PairProvider {
factory: factory.into_legacy(),
factory,
init_code_digest: config.pool_code.into(),
};

Expand Down Expand Up @@ -172,11 +179,7 @@ struct NoAllowanceManaging;

#[async_trait]
impl AllowanceManaging for NoAllowanceManaging {
async fn get_allowances(
&self,
_: HashSet<eth::H160>,
spender: eth::H160,
) -> Result<Allowances> {
async fn get_allowances(&self, _: HashSet<Address>, spender: Address) -> Result<Allowances> {
Ok(Allowances::empty(spender))
}

Expand Down
12 changes: 9 additions & 3 deletions crates/driver/src/boundary/liquidity/uniswap/v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,19 @@ pub fn to_interaction(
let handler = UniswapV3SettlementHandler::new(
pool.router.0.into_alloy(),
receiver.0.into_alloy(),
Mutex::new(Allowances::empty(receiver.0)),
Mutex::new(Allowances::empty(receiver.0.into_alloy())),
pool.fee.0,
);

let (_, interaction) = handler.settle(
TokenAmount::new(input.0.token.into(), input.0.amount),
TokenAmount::new(output.0.token.into(), output.0.amount),
TokenAmount::new(
input.0.token.0.0.into_alloy(),
input.0.amount.0.into_alloy(),
),
TokenAmount::new(
output.0.token.0.0.into_alloy(),
output.0.amount.0.into_alloy(),
),
);

let encoded = interaction.encode();
Expand Down
23 changes: 9 additions & 14 deletions crates/driver/src/domain/competition/bad_tokens/simulation.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
use {
crate::{
domain::{
competition::{
Order,
bad_tokens::{Quality, cache::Cache},
order,
},
eth,
domain::competition::{
Order,
bad_tokens::{Quality, cache::Cache},
order,
},
infra::{self, observe::metrics},
},
ethrpc::alloy::conversions::{IntoAlloy, IntoLegacy},
ethrpc::alloy::conversions::IntoAlloy,
futures::FutureExt,
model::interaction::InteractionData,
shared::{
Expand Down Expand Up @@ -38,10 +35,8 @@ struct Inner {

impl Detector {
pub fn new(max_age: Duration, eth: &infra::Ethereum) -> Self {
let detector = TraceCallDetectorRaw::new(
eth.web3().clone(),
eth.contracts().settlement().address().into_legacy(),
);
let detector =
TraceCallDetectorRaw::new(eth.web3().clone(), *eth.contracts().settlement().address());
Self(Arc::new(Inner {
cache: Cache::new(max_age),
detector,
Expand Down Expand Up @@ -79,7 +74,7 @@ impl Detector {
call_data: i.call_data.0.clone(),
})
.collect();
let trader = eth::Address::from(order.trader()).0;
let trader = order.trader().0.0.into_alloy();
let sell_amount = match order.partial {
order::Partial::Yes { available } => available.0,
order::Partial::No => order.sell.amount.0,
Expand All @@ -88,7 +83,7 @@ impl Detector {
async move {
let result = inner
.detector
.test_transfer(trader, sell_token.0 .0, sell_amount, &pre_interactions)
.test_transfer(trader, sell_token.0.0.into_alloy(), sell_amount, &pre_interactions)
.await;
match result {
Err(err) => {
Expand Down
Loading
Loading