Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
09b74a3
Implement build.rs bindings generation
jmg-duarte Oct 27, 2025
b879cfa
wip
jmg-duarte Oct 27, 2025
df03e93
wip
jmg-duarte Oct 27, 2025
63f914a
wip
jmg-duarte Oct 28, 2025
319f708
Migrate the remaining ERC20
jmg-duarte Oct 29, 2025
a197a1f
fmt
jmg-duarte Oct 30, 2025
386295c
commetn
jmg-duarte Oct 30, 2025
f57e73d
address comments
jmg-duarte Oct 30, 2025
495dbb7
fix
jmg-duarte Oct 30, 2025
865e32e
fix errors
jmg-duarte Oct 30, 2025
c259961
address comment
jmg-duarte Oct 30, 2025
0592d9f
fix clippy
jmg-duarte Oct 30, 2025
e95a825
Fix contract error handling
jmg-duarte Oct 30, 2025
40d9bf8
Merge branch 'main' into jmgd/alloy/erc20
jmg-duarte Oct 30, 2025
442203f
lints
jmg-duarte Oct 30, 2025
9e7b790
More details for the error mapping
jmg-duarte Oct 31, 2025
bdf4a97
Merge branch 'main' into jmgd/alloy/erc20
jmg-duarte Oct 31, 2025
e13888c
Merge branch 'jmgd/alloy/erc20' into jmgd/alloy/generate
jmg-duarte Oct 31, 2025
e6a6eb5
wip
jmg-duarte Oct 31, 2025
57c71e8
Merge branch 'main' into jmgd/alloy/generate
jmg-duarte Nov 3, 2025
9f08fac
wip
jmg-duarte Nov 3, 2025
2f8b2d0
Merge branch 'main' into jmgd/alloy/generate
jmg-duarte Nov 3, 2025
f32040d
modules
jmg-duarte Nov 3, 2025
b811309
almost there
jmg-duarte Nov 3, 2025
d9a4486
Revert "wip"
jmg-duarte Nov 3, 2025
33b6570
should be ok
jmg-duarte Nov 3, 2025
7e17ee9
fmt fix
jmg-duarte Nov 4, 2025
691ecb6
Further fixes and simplifications
jmg-duarte Nov 4, 2025
e1b4ef7
more simplifications
jmg-duarte Nov 4, 2025
d7c325e
fix doctest build
jmg-duarte Nov 4, 2025
9d27684
fix doc compilation
jmg-duarte Nov 4, 2025
f4381f7
deps manicure
jmg-duarte Nov 4, 2025
dada99d
check artifacts on build.rs
jmg-duarte Nov 4, 2025
2a5a46f
clean main toml
jmg-duarte Nov 4, 2025
457f2a2
Merge branch 'main' into jmgd/alloy/generate
jmg-duarte Nov 5, 2025
65e646b
Merge branch 'main' into jmgd/alloy/generate
jmg-duarte Nov 5, 2025
c5c5816
wip
jmg-duarte Nov 5, 2025
c244ac5
reduce dep surface
jmg-duarte Nov 5, 2025
9d8878b
Merge branch 'main' into jmgd/alloy/generate
jmg-duarte Nov 5, 2025
0583047
Revert flate2 upgrade
jmg-duarte Nov 5, 2025
b00f81c
fix doctest
jmg-duarte Nov 5, 2025
8c3a0ec
move contracts-generate to contracts/build.rs
jmg-duarte Nov 7, 2025
5e95aaa
const fix
jmg-duarte Nov 7, 2025
6a4fe80
Merge branch 'main' into jmgd/alloy/generate
jmg-duarte Nov 25, 2025
e013220
update linea
jmg-duarte Nov 25, 2025
bde15e7
Merge branch 'main' into jmgd/alloy/generate
jmg-duarte Nov 26, 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
150 changes: 98 additions & 52 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ tower-http = "0.4"
tracing-opentelemetry = "0.31"
tracing-serde = "0.2"
vergen = "8"
walkdir = "2.5.0"
quote = "1.0.41"
syn = "2.0.108"
prettyplease = "0.2.37"
proc-macro2 = "1.0.103"
alloy-sol-macro-input = "1.4.1"
alloy-sol-macro-expander = "1.4.1"

[workspace.lints]
clippy.cast_possible_wrap = "deny"
2 changes: 1 addition & 1 deletion crates/autopilot/src/boundary/events/settlement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl AlloyEventRetrieving for GPv2SettlementContract {
Filter::new().address(self.address)
}

fn provider(&self) -> &contracts::alloy::Provider {
fn provider(&self) -> &alloy::providers::DynProvider {
&self.provider
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl EthFlowRefundRetriever {
impl AlloyEventRetrieving for EthFlowRefundRetriever {
type Event = CoWSwapEthFlow::CoWSwapEthFlowEvents;

fn provider(&self) -> &contracts::alloy::Provider {
fn provider(&self) -> &alloy::providers::DynProvider {
&self.web3.alloy
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl AlloyEventRetrieving for CoWSwapOnchainOrdersContract {
]))
}

fn provider(&self) -> &contracts::alloy::Provider {
fn provider(&self) -> &alloy::providers::DynProvider {
&self.web3.alloy
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ mod test {
super::*,
crate::database::Config,
alloy::primitives::U256,
contracts::alloy::{CoWSwapOnchainOrders, InstanceExt},
contracts::alloy::CoWSwapOnchainOrders,
database::{byte_array::ByteArray, onchain_broadcasted_orders::OnchainOrderPlacement},
ethcontract::H160,
ethrpc::Web3,
Expand Down
1 change: 0 additions & 1 deletion crates/autopilot/src/infra/blockchain/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use {
GPv2AllowListAuthentication,
GPv2Settlement,
HooksTrampoline,
InstanceExt,
WETH9,
support::Balances,
},
Expand Down
2 changes: 1 addition & 1 deletion crates/autopilot/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use {
alloy::eips::BlockNumberOrTag,
chain::Chain,
clap::Parser,
contracts::alloy::{BalancerV2Vault, GPv2Settlement, IUniswapV3Factory, InstanceExt, WETH9},
contracts::alloy::{BalancerV2Vault, GPv2Settlement, IUniswapV3Factory, WETH9},
ethcontract::H160,
ethrpc::{
Web3,
Expand Down
2 changes: 2 additions & 0 deletions crates/contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Generated by build.rs, will contain the contract bindings
src/alloy
13 changes: 10 additions & 3 deletions crates/contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ bin = [

[dependencies]
alloy = { workspace = true, features = ["sol-types", "json", "contract", "json-abi"] }
paste = { workspace = true }
ethcontract = { workspace = true }
paste = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }

# [bin-dependencies]
Expand All @@ -33,8 +34,14 @@ tracing = { workspace = true, optional = true }
tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"], optional = true }

[build-dependencies]
ethcontract = { workspace = true }
ethcontract-generate = { workspace = true }
anyhow = { workspace = true }
alloy-sol-macro-expander = {workspace = true}
alloy-sol-macro-input = {workspace = true, features = ["json"]}
prettyplease = {workspace = true}
proc-macro2 = {workspace = true}
quote = {workspace = true}
syn = {workspace = true}
walkdir = {workspace = true}

[lints]
workspace = true
1,186 changes: 1,186 additions & 0 deletions crates/contracts/build.rs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no clue how to review this other than by asking AI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do them one by one. I did this whole with AI too and did multilple rounds with different contexts. But this was more about proving that I was able to migrate everything with minimal changes on the main codebase

Large diffs are not rendered by default.

988 changes: 0 additions & 988 deletions crates/contracts/src/alloy.rs

This file was deleted.

83 changes: 3 additions & 80 deletions crates/contracts/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,88 +1,11 @@
#![allow(clippy::let_unit_value)]

pub use ethcontract;
// This module get's auto-generated by the contracts build.rs
#[rustfmt::skip]
pub mod alloy;
pub mod errors;
use {
anyhow::{Result, anyhow, bail},
ethcontract::{
Contract,
common::{DeploymentInformation, contract::Network},
},
};

pub fn deployment(contract: &Contract, chain_id: u64) -> Result<&Network> {
contract
.networks
.get(&chain_id.to_string())
// Note that we are conflating network IDs with chain IDs. In general
// they cannot be considered the same, but for the networks that we
// support (xDAI, Görli and Mainnet) they are.
.ok_or_else(|| anyhow!("missing {} deployment for {}", contract.name, chain_id))
}

pub fn deployment_block(contract: &Contract, chain_id: u64) -> Result<u64> {
let deployment_info = deployment(contract, chain_id)?
.deployment_information
.ok_or_else(|| anyhow!("missing deployment information for {}", contract.name))?;

match deployment_info {
DeploymentInformation::BlockNumber(block) => Ok(block),
DeploymentInformation::TransactionHash(tx) => {
bail!("missing deployment block number for {}", tx)
}
}
}

#[macro_use]
mod macros;
pub mod errors;

#[cfg(feature = "bin")]
pub mod paths;
pub mod vault;
pub mod web3;

#[cfg(test)]
mod tests {
use {
super::*,
crate::alloy::networks::{ARBITRUM_ONE, GNOSIS, MAINNET, SEPOLIA},
};

#[test]
fn deployment_addresses() {
for network in &[MAINNET, GNOSIS, SEPOLIA, ARBITRUM_ONE] {
assert!(
alloy::BalancerV2NoProtocolFeeLiquidityBootstrappingPoolFactory::deployment_address(network).is_some()
)
}
for network in &[MAINNET, ARBITRUM_ONE] {
assert!(
alloy::BalancerV2WeightedPool2TokensFactory::deployment_address(network).is_some()
);
assert!(
alloy::BalancerV2LiquidityBootstrappingPoolFactory::deployment_address(network)
.is_some()
);
}

assert!(alloy::BalancerV2WeightedPoolFactory::deployment_address(&MAINNET).is_some());

for network in &[MAINNET, GNOSIS, ARBITRUM_ONE] {
assert!(alloy::BalancerV2StablePoolFactoryV2::deployment_address(network).is_some());
}
}

#[test]
fn deployment_information() {
assert!(alloy::BalancerV2WeightedPoolFactory::deployment_address(&MAINNET).is_some());
for network in &[MAINNET, ARBITRUM_ONE] {
assert!(
alloy::BalancerV2WeightedPool2TokensFactory::deployment_address(network).is_some()
);
}
for network in &[MAINNET, GNOSIS, ARBITRUM_ONE] {
assert!(alloy::BalancerV2StablePoolFactoryV2::deployment_address(network).is_some());
}
}
}
6 changes: 0 additions & 6 deletions crates/contracts/src/macros.rs

This file was deleted.

44 changes: 0 additions & 44 deletions crates/contracts/src/web3.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/driver/src/boundary/liquidity/zeroex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use {
infra::{self, Ethereum},
},
anyhow::anyhow,
contracts::alloy::InstanceExt,
ethrpc::block_stream::CurrentBlockWatcher,
shared::{
http_client::HttpClientFactory,
Expand Down
1 change: 0 additions & 1 deletion crates/e2e/src/setup/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use {
GPv2AllowListAuthentication,
GPv2Settlement,
HooksTrampoline,
InstanceExt,
UniswapV2Factory,
UniswapV2Router02,
WETH9,
Expand Down
6 changes: 4 additions & 2 deletions crates/e2e/src/setup/onchain_components/safe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,10 @@ impl Safe {
to: alloy::primitives::Address,
data: Vec<u8>,
nonce: alloy::primitives::U256,
) -> alloy::contract::CallBuilder<&contracts::alloy::Provider, PhantomData<execTransactionCall>>
{
) -> alloy::contract::CallBuilder<
&alloy::providers::DynProvider,
PhantomData<execTransactionCall>,
> {
let signature = self.sign({
// `SafeTx` struct hash computation ported from the Safe Solidity code:
// <https://etherscan.io/address/0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552#code#F1#L377>
Expand Down
2 changes: 1 addition & 1 deletion crates/e2e/tests/e2e/liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use {
providers::ext::{AnvilApi, ImpersonateConfig},
},
chrono::{NaiveDateTime, Utc},
contracts::alloy::{ERC20, IZeroex, InstanceExt},
contracts::alloy::{ERC20, IZeroex},
driver::domain::eth::H160,
e2e::{
api::zeroex::{Eip712TypedZeroExOrder, ZeroExApi},
Expand Down
2 changes: 1 addition & 1 deletion crates/e2e/tests/e2e/liquidity_source_notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use {
signers::{SignerSync, local::PrivateKeySigner},
},
chrono::Utc,
contracts::alloy::{ERC20, InstanceExt, LiquoriceSettlement},
contracts::alloy::{ERC20, LiquoriceSettlement},
driver::infra,
e2e::{
api,
Expand Down
1 change: 0 additions & 1 deletion crates/orderbook/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use {
GPv2Settlement,
HooksTrampoline,
IUniswapV3Factory,
InstanceExt,
WETH9,
support::Balances,
},
Expand Down
2 changes: 1 addition & 1 deletion crates/shared/src/bad_token/trace_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ mod tests {
},
alloy::primitives::address,
chain::Chain,
contracts::alloy::{BalancerV2Vault, GPv2Settlement, IUniswapV3Factory, InstanceExt},
contracts::alloy::{BalancerV2Vault, GPv2Settlement, IUniswapV3Factory},
ethrpc::{Web3, alloy::conversions::IntoLegacy},
std::{env, time::Duration},
web3::types::{
Expand Down
4 changes: 2 additions & 2 deletions crates/shared/src/event_handling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ mod tests {
use {
super::*,
alloy::eips::BlockNumberOrTag,
contracts::alloy::{GPv2Settlement, InstanceExt},
contracts::alloy::GPv2Settlement,
ethcontract::{BlockNumber, H256},
ethrpc::{Web3, block_stream::block_number_to_block_number_hash},
std::str::FromStr,
Expand All @@ -786,7 +786,7 @@ mod tests {
Filter::new().address(*self.address())
}

fn provider(&self) -> &contracts::alloy::Provider {
fn provider(&self) -> &alloy::providers::DynProvider {
self.provider()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ use {
BalancerV2WeightedPoolFactory,
BalancerV2WeightedPoolFactoryV3,
BalancerV2WeightedPoolFactoryV4,
InstanceExt,
},
ethcontract::{BlockId, H160, H256},
ethrpc::block_stream::{BlockRetrieving, CurrentBlockWatcher},
Expand Down
10 changes: 4 additions & 6 deletions crates/solvers/src/boundary/liquidity/concentrated.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use {
alloy::primitives::aliases::U24,
contracts::{
alloy::UniswapV3QuoterV2::IQuoterV2::{
QuoteExactInputSingleParams,
QuoteExactOutputSingleParams,
},
ethcontract::{H160, U256},
contracts::alloy::UniswapV3QuoterV2::IQuoterV2::{
QuoteExactInputSingleParams,
QuoteExactOutputSingleParams,
},
ethcontract::{H160, U256},
ethrpc::alloy::conversions::{IntoAlloy, IntoLegacy},
model::TokenPair,
shared::baseline_solver::BaselineSolvable,
Expand Down
4 changes: 2 additions & 2 deletions crates/solvers/src/boundary/liquidity/limit_order.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use {
crate::domain::liquidity::limit_order::LimitOrder,
contracts::ethcontract::{H160, U256},
ethcontract::{H160, U256},
shared::{baseline_solver::BaselineSolvable, price_estimation::gas::GAS_PER_ZEROEX_ORDER},
};

Expand Down Expand Up @@ -50,7 +50,7 @@ mod tests {
use {
super::*,
crate::domain::{eth, liquidity::limit_order::TakerAmount},
contracts::ethcontract::U256,
ethcontract::U256,
shared::addr,
};

Expand Down
1 change: 0 additions & 1 deletion crates/solvers/src/domain/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use {
},
infra::metrics,
},
contracts::alloy::InstanceExt,
ethereum_types::U256,
reqwest::Url,
std::{cmp, collections::HashSet, sync::Arc},
Expand Down
Loading