Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions Cargo.lock

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

3 changes: 0 additions & 3 deletions crates/contracts/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@ fn main() {
generate_contract_with_config("BalancerV2Authorizer", |builder| {
builder.contract_mod_override("balancer_v2_authorizer")
});
generate_contract_with_config("BalancerV2BasePool", |builder| {
builder.contract_mod_override("balancer_v2_base_pool")
});
generate_contract_with_config("BalancerV2BasePoolFactory", |builder| {
builder.contract_mod_override("balancer_v2_base_pool_factory")
});
Expand Down
26 changes: 26 additions & 0 deletions crates/contracts/src/alloy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,32 @@ crate::bindings!(GnosisSafeCompatibilityFallbackHandler);
crate::bindings!(GnosisSafeProxy);
crate::bindings!(GnosisSafeProxyFactory);

crate::bindings!(BalancerV2BasePool);
crate::bindings!(
BalancerV2Vault,
crate::deployments! {
// <https://etherscan.io/tx/0x28c44bb10d469cbd42accf97bd00b73eabbace138e9d44593e851231fbed1cb7>
MAINNET => (address!("0xBA12222222228d8Ba445958a75a0704d566BF2C8"), 12272146),
// <https://gnosisscan.io/tx/0x21947751661e1b9197492f22779af1f5175b71dc7057869e5a8593141d40edf1>
GNOSIS => (address!("0xBA12222222228d8Ba445958a75a0704d566BF2C8"), 24821598),
// <https://sepolia.etherscan.io/tx/0xb22509c6725dd69a975ecb96a0c594901eeee6a279cc66d9d5191022a7039ee6>
SEPOLIA => (address!("0xBA12222222228d8Ba445958a75a0704d566BF2C8"), 3418831),
// <https://arbiscan.io/tx/0xe2c3826bd7b15ef8d338038769fe6140a44f1957a36b0f27ab321ab6c68d5a8e>
ARBITRUM_ONE => (address!("0xBA12222222228d8Ba445958a75a0704d566BF2C8"), 222832),
// <https://basescan.org/tx/0x0dc2e3d436424f2f038774805116896d31828c0bf3795a6901337bdec4e0dff6>
BASE => (address!("0xBA12222222228d8Ba445958a75a0704d566BF2C8"), 1196036),
// <https://snowscan.xyz/tx/0xc49af0372feb032e0edbba6988410304566b1fd65546c01ced620ac3c934120f>
AVALANCHE => (address!("0xBA12222222228d8Ba445958a75a0704d566BF2C8"), 26386141),
// <https://bscscan.com/tx/0x1de8caa6c54ff9a25600e26d80865d84c9cc4d33c2b98611240529ee7de5cd74>
BNB => (address!("0xBA12222222228d8Ba445958a75a0704d566BF2C8"), 22691002),
// <https://optimistic.etherscan.io/tx/0xa03cb990595df9eed6c5db17a09468cab534aed5f5589a06c0bb3d19dd2f7ce9>
OPTIMISM => (address!("0xBA12222222228d8Ba445958a75a0704d566BF2C8"), 7003431),
// <https://polygonscan.com/tx/0x66f275a2ed102a5b679c0894ced62c4ebcb2a65336d086a916eb83bd1fe5c8d2>
POLYGON => (address!("0xBA12222222228d8Ba445958a75a0704d566BF2C8"), 15832990),
// Not available on Lens
}
);

pub use alloy::providers::DynProvider as Provider;

/// Extension trait to attach some useful functions to the contract instance.
Expand Down
1 change: 0 additions & 1 deletion crates/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ macro_rules! include_contracts {
include_contracts! {
AaveFlashLoanSolverWrapper;
BalancerV2Authorizer;
BalancerV2BasePool;
BalancerV2BasePoolFactory;
BalancerV2ComposableStablePool;
BalancerV2ComposableStablePoolFactory;
Expand Down
11 changes: 7 additions & 4 deletions crates/driver/src/boundary/liquidity/balancer/v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ use {
BalancerV2ComposableStablePoolFactory,
BalancerV2LiquidityBootstrappingPoolFactory,
BalancerV2StablePoolFactoryV2,
BalancerV2Vault,
BalancerV2WeightedPoolFactory,
BalancerV2WeightedPoolFactoryV3,
GPv2Settlement,
alloy::BalancerV2Vault,
},
ethrpc::{
alloy::conversions::IntoAlloy,
block_stream::{BlockRetrieving, CurrentBlockWatcher},
},
ethrpc::block_stream::{BlockRetrieving, CurrentBlockWatcher},
shared::{
http_solver::model::TokenAmount,
sources::balancer_v2::{
Expand Down Expand Up @@ -56,7 +59,7 @@ fn to_interaction(
// also baked into the Balancer V2 logic in the `shared` crate, so to
// change this assumption, we would need to change it there as well.
GPv2Settlement::at(&web3, receiver.0),
BalancerV2Vault::at(&web3, pool.vault.into()),
BalancerV2Vault::Instance::new(pool.vault.0.into_alloy(), ethrpc::mock::web3().alloy),
Comment thread
squadgazzz marked this conversation as resolved.
Allowances::empty(receiver.0),
);

Expand Down Expand Up @@ -107,7 +110,7 @@ async fn init_liquidity(
) -> Result<impl LiquidityCollecting + use<>> {
let web3 = eth.web3().clone();
let contracts = BalancerContracts {
vault: BalancerV2Vault::at(&web3, config.vault.into()),
vault: BalancerV2Vault::Instance::new(config.vault.0.into_alloy(), web3.alloy.clone()),
factories: [
config
.weighted
Expand Down
2 changes: 2 additions & 0 deletions crates/driver/src/boundary/liquidity/balancer/v2/stable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use {
liquidity::{self, balancer},
},
},
ethrpc::alloy::conversions::IntoLegacy,
solver::liquidity::{StablePoolOrder, balancer_v2},
};

Expand Down Expand Up @@ -52,6 +53,7 @@ fn vault(pool: &StablePoolOrder) -> eth::ContractAddress {
.expect("downcast balancer settlement handler")
.vault()
.address()
.into_legacy()
.into()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use {
liquidity::{self, balancer},
},
},
ethrpc::alloy::conversions::IntoLegacy,
shared::sources::balancer_v2::pool_fetching::WeightedPoolVersion,
solver::liquidity::{WeightedProductOrder, balancer_v2},
};
Expand Down Expand Up @@ -56,6 +57,7 @@ fn vault(pool: &WeightedProductOrder) -> eth::ContractAddress {
.expect("downcast balancer settlement handler")
.vault()
.address()
.into_legacy()
.into()
}

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 @@ -400,5 +400,5 @@ async fn fill_or_kill_zeroex_limit_order(
.watch()
.await?;

Ok(tx_hash.into_alloy())
Ok(tx_hash.into_legacy())
}
12 changes: 10 additions & 2 deletions crates/ethrpc/src/alloy/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ impl IntoAlloy for web3::types::BlockId {
}
}

impl IntoAlloy for ethcontract::tokens::Bytes<Vec<u8>> {
type To = alloy::primitives::Bytes;

fn into_alloy(self) -> Self::To {
alloy::primitives::Bytes::copy_from_slice(self.0.as_slice())
}
}

pub enum Account {
Address(alloy::primitives::Address),
Signer(Box<dyn TxSigner<Signature> + Send + Sync + 'static>),
Expand Down Expand Up @@ -160,10 +168,10 @@ impl IntoLegacy for alloy::primitives::Address {
}
}

impl IntoAlloy for alloy::primitives::aliases::B256 {
impl IntoLegacy for alloy::primitives::aliases::B256 {
type To = primitive_types::H256;

fn into_alloy(self) -> Self::To {
fn into_legacy(self) -> Self::To {
primitive_types::H256(self.into())
}
}
8 changes: 4 additions & 4 deletions crates/shared/src/sources/balancer_v2/pool_fetching/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ use {
BalancerV2LiquidityBootstrappingPoolFactory,
BalancerV2NoProtocolFeeLiquidityBootstrappingPoolFactory,
BalancerV2StablePoolFactoryV2,
BalancerV2Vault,
BalancerV2WeightedPool2TokensFactory,
BalancerV2WeightedPoolFactory,
BalancerV2WeightedPoolFactoryV3,
BalancerV2WeightedPoolFactoryV4,
alloy::{BalancerV2Vault, InstanceExt},
},
ethcontract::{BlockId, H160, H256, Instance, dyns::DynInstance},
ethrpc::block_stream::{BlockRetrieving, CurrentBlockWatcher},
Expand Down Expand Up @@ -225,14 +225,14 @@ impl BalancerFactoryKind {

/// All balancer related contracts that we expect to exist.
pub struct BalancerContracts {
pub vault: BalancerV2Vault,
pub vault: BalancerV2Vault::Instance,
pub factories: Vec<(BalancerFactoryKind, DynInstance)>,
}

impl BalancerContracts {
pub async fn try_new(web3: &Web3, factory_kinds: Vec<BalancerFactoryKind>) -> Result<Self> {
let web3 = ethrpc::instrumented::instrument_with_label(web3, "balancerV2".into());
let vault = BalancerV2Vault::deployed(&web3)
let vault = BalancerV2Vault::Instance::deployed(&web3.alloy)
.await
.context("Cannot retrieve balancer vault")?;

Expand Down Expand Up @@ -463,7 +463,7 @@ async fn create_aggregate_pool_fetcher(
/// Helper method for creating a boxed `InternalPoolFetching` instance for the
/// specified factory and parameters.
fn create_internal_pool_fetcher<Factory>(
vault: BalancerV2Vault,
vault: BalancerV2Vault::Instance,
factory: Factory,
block_retriever: Arc<dyn BlockRetrieving>,
token_infos: Arc<dyn TokenInfoFetching>,
Expand Down
Loading
Loading