Skip to content
Open
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
11 changes: 5 additions & 6 deletions crates/driver/src/boundary/liquidity/balancer/v2/stable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use {
liquidity::{self, balancer},
},
},
ethrpc::alloy::conversions::IntoAlloy,
solver::liquidity::{StablePoolOrder, balancer_v2},
};

Expand All @@ -28,20 +27,20 @@ pub fn to_domain(id: liquidity::Id, pool: StablePoolOrder) -> Result<liquidity::
Ok(balancer::v2::stable::Reserve {
asset: eth::Asset {
token: token.into(),
amount: reserve.balance.into_alloy().into(),
amount: reserve.balance.into(),
},
scale: balancer::v2::ScalingFactor::from_raw(
reserve.scaling_factor.as_uint256().into_alloy(),
reserve.scaling_factor.as_uint256(),
)?,
})
})
.collect::<Result<_>>()?,
)?,
amplification_parameter: balancer::v2::stable::AmplificationParameter::new(
pool.amplification_parameter.factor().into_alloy(),
pool.amplification_parameter.precision().into_alloy(),
pool.amplification_parameter.factor(),
pool.amplification_parameter.precision(),
)?,
fee: balancer::v2::Fee::from_raw(pool.fee.as_uint256().into_alloy()),
fee: balancer::v2::Fee::from_raw(pool.fee.as_uint256()),
}),
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use {
liquidity::{self, balancer},
},
},
ethrpc::alloy::conversions::IntoAlloy,
shared::sources::balancer_v2::pool_fetching::WeightedPoolVersion,
solver::liquidity::{WeightedProductOrder, balancer_v2},
};
Expand All @@ -29,19 +28,19 @@ pub fn to_domain(id: liquidity::Id, pool: WeightedProductOrder) -> Result<liquid
Ok(balancer::v2::weighted::Reserve {
asset: eth::Asset {
token: token.into(),
amount: reserve.common.balance.into_alloy().into(),
amount: reserve.common.balance.into(),
},
weight: balancer::v2::weighted::Weight::from_raw(
reserve.weight.as_uint256().into_alloy(),
reserve.weight.as_uint256(),
),
scale: balancer::v2::ScalingFactor::from_raw(
reserve.common.scaling_factor.as_uint256().into_alloy(),
reserve.common.scaling_factor.as_uint256(),
)?,
})
})
.collect::<Result<_>>()?,
)?,
fee: balancer::v2::Fee::from_raw(pool.fee.as_uint256().into_alloy()),
fee: balancer::v2::Fee::from_raw(pool.fee.as_uint256()),
version: match pool.version {
WeightedPoolVersion::V0 => balancer::v2::weighted::Version::V0,
WeightedPoolVersion::V3Plus => balancer::v2::weighted::Version::V3Plus,
Expand Down
17 changes: 13 additions & 4 deletions crates/shared/src/sources/balancer_v2/graph_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ mod tests {
use {
super::*,
crate::sources::balancer_v2::swap::fixed_point::Bfp,
alloy::primitives::U256,
ethcontract::H256,
maplit::hashmap,
};
Expand Down Expand Up @@ -343,12 +344,16 @@ mod tests {
Token {
address: Address::repeat_byte(0x33),
decimals: 3,
weight: Some(Bfp::from_wei(500_000_000_000_000_000u128.into())),
weight: Some(Bfp::from_wei(U256::from(
500_000_000_000_000_000_u128
))),
},
Token {
address: Address::repeat_byte(0x44),
decimals: 4,
weight: Some(Bfp::from_wei(500_000_000_000_000_000u128.into())),
weight: Some(Bfp::from_wei(U256::from(
500_000_000_000_000_000_u128
))),
},
],
},
Expand Down Expand Up @@ -381,12 +386,16 @@ mod tests {
Token {
address: Address::repeat_byte(0x33),
decimals: 3,
weight: Some(Bfp::from_wei(500_000_000_000_000_000u128.into())),
weight: Some(Bfp::from_wei(U256::from(
500_000_000_000_000_000_u128
))),
},
Token {
address: Address::repeat_byte(0x44),
decimals: 4,
weight: Some(Bfp::from_wei(500_000_000_000_000_000u128.into())),
weight: Some(Bfp::from_wei(U256::from(
500_000_000_000_000_000_u128
))),
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ mod tests {
pools::{MockFactoryIndexing, common::MockPoolInfoFetching, weighted},
swap::fixed_point::Bfp,
},
alloy::primitives::U256,
maplit::{hashmap, hashset},
mockall::predicate::eq,
};
Expand All @@ -256,7 +257,9 @@ mod tests {
let tokens: Vec<Address> = (start..=end + 1)
.map(|i| Address::with_last_byte(i as u8))
.collect();
let weights: Vec<Bfp> = (start..=end + 1).map(|i| Bfp::from_wei(i.into())).collect();
let weights: Vec<Bfp> = (start..=end + 1)
.map(|i| Bfp::from_wei(U256::from(i)))
.collect();
let creation_events: Vec<(PoolCreated, u64)> = (start..=end)
.map(|i| {
(
Expand Down Expand Up @@ -284,8 +287,8 @@ mod tests {
block_created: 0,
},
weights: vec![
Bfp::from_wei(500_000_000_000_000_000u128.into()),
Bfp::from_wei(500_000_000_000_000_000u128.into()),
Bfp::from_wei(U256::from(500_000_000_000_000_000_u128)),
Bfp::from_wei(U256::from(500_000_000_000_000_000_u128)),
],
},
weighted::PoolInfo {
Expand All @@ -301,9 +304,9 @@ mod tests {
block_created: 0,
},
weights: vec![
Bfp::from_wei(500_000_000_000_000_000u128.into()),
Bfp::from_wei(250_000_000_000_000_000u128.into()),
Bfp::from_wei(250_000_000_000_000_000u128.into()),
Bfp::from_wei(U256::from(500_000_000_000_000_000_u128)),
Bfp::from_wei(U256::from(250_000_000_000_000_000_u128)),
Bfp::from_wei(U256::from(250_000_000_000_000_000_u128)),
],
},
weighted::PoolInfo {
Expand All @@ -315,8 +318,8 @@ mod tests {
block_created: 0,
},
weights: vec![
Bfp::from_wei(500_000_000_000_000_000u128.into()),
Bfp::from_wei(500_000_000_000_000_000u128.into()),
Bfp::from_wei(U256::from(500_000_000_000_000_000_u128)),
Bfp::from_wei(U256::from(500_000_000_000_000_000_u128)),
],
},
],
Expand Down Expand Up @@ -444,7 +447,7 @@ mod tests {
scaling_factors: vec![Bfp::exp10(0)],
block_created: 3,
},
weights: vec![Bfp::from_wei(1337.into())],
weights: vec![Bfp::from_wei(U256::from(1337u64))],
};
let new_creation = PoolCreated {
pool: new_pool.common.address,
Expand Down
Loading
Loading