Skip to content

Commit a992afb

Browse files
committed
ran linter
1 parent 062d535 commit a992afb

File tree

49 files changed

+475
-343
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+475
-343
lines changed

crates/contracts/build.rs

Lines changed: 87 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -510,85 +510,90 @@ fn main() {
510510
// <https://docs.balancer.fi/reference/contracts/deployment-addresses/sepolia.html>
511511
// <https://docs.balancer.fi/reference/contracts/deployment-addresses/base.html>
512512
});
513-
generate_contract_with_config("BalancerV2NoProtocolFeeLiquidityBootstrappingPoolFactory",|builder| {
514-
builder
515-
.contract_mod_override("balancer_v2_no_protocol_fee_liquidity_bootstrapping_pool_factory")
516-
.add_network(
517-
// <https://docs.balancer.fi/reference/contracts/deployment-addresses/mainnet.html#ungrouped-active-current-contracts>
518-
MAINNET,
519-
Network {
520-
address: addr("0x0F3e0c4218b7b0108a3643cFe9D3ec0d4F57c54e"),
521-
// <https://etherscan.io/tx/0x298381e567ff6643d9b32e8e7e9ff0f04a80929dce3e004f6fa1a0104b2b69c3>
522-
deployment_information: Some(DeploymentInformation::BlockNumber(13730248)),
523-
},
524-
)
525-
.add_network(
526-
// <https://docs.balancer.fi/reference/contracts/deployment-addresses/gnosis.html#ungrouped-active-current-contracts>
527-
GNOSIS,
528-
Network {
529-
address: addr("0x85a80afee867aDf27B50BdB7b76DA70f1E853062"),
530-
// <https://gnosis.blockscout.com/tx/0xbd56fefdb27e4ff1c0852e405f78311d6bc2befabaf6c87a405ab19de8c1506a>
531-
deployment_information: Some(DeploymentInformation::BlockNumber(25415236)),
532-
},
533-
)
534-
.add_network(
535-
// <https://docs.balancer.fi/reference/contracts/deployment-addresses/sepolia.html#ungrouped-active-current-contracts>
536-
SEPOLIA,
537-
Network {
538-
address: addr("0x45fFd460cC6642B8D8Fb12373DFd77Ceb0f4932B"),
539-
// <https://sepolia.etherscan.io/tx/0xe0e8feb509a8aa8a1eaa0b0c4b34395ff2fd880fb854fbeeccc0af1826e395c9>
540-
deployment_information: Some(DeploymentInformation::BlockNumber(3419649)),
541-
},
542-
)
543-
.add_network(
544-
ARBITRUM_ONE,
545-
Network {
546-
address: addr("0x1802953277FD955f9a254B80Aa0582f193cF1d77"),
547-
// <https://arbiscan.io/tx/0x5265176961ba08450afc1d7c7d34321da11b2f1f106a7d652e6c11d923caed24>
548-
deployment_information: Some(DeploymentInformation::BlockNumber(4859669)),
549-
},
550-
)
551-
.add_network(
552-
BASE,
553-
Network {
554-
address: addr("0x0c6052254551EAe3ECac77B01DFcf1025418828f"),
555-
// <https://basescan.org/tx/0x0529de9dbe772f4b4f48da93ae2c2d2c46e3d3221ced9e0c4063a7a5bc47e874>
556-
deployment_information: Some(DeploymentInformation::BlockNumber(1206531)),
557-
},
558-
)
559-
.add_network(
560-
AVALANCHE,
561-
Network {
562-
address: addr("0x0F3e0c4218b7b0108a3643cFe9D3ec0d4F57c54e"),
563-
// <https://snowscan.xyz/tx/0x33a75d83436ae9fcda4b4986713417bf3dc80d9ceb8d2541817846b1ac579d9f>
564-
deployment_information: Some(DeploymentInformation::BlockNumber(26386552)),
565-
},
566-
)
567-
.add_network(
568-
BNB,
569-
Network {
570-
address: addr("0xC128468b7Ce63eA702C1f104D55A2566b13D3ABD"),
571-
// <https://bscscan.com/tx/0x8b964b97e6091bd41c93002c558d49adc26b8b31d2b30f3a33babbbbe8c55f47>
572-
deployment_information: Some(DeploymentInformation::BlockNumber(22691243)),
573-
},
574-
)
575-
.add_network(
576-
OPTIMISM,
577-
Network {
578-
address: addr("0xf302f9F50958c5593770FDf4d4812309fF77414f"),
579-
// <https://optimistic.etherscan.io/tx/0x14fb43f051eebdec645abf0125e52348dc875b0887b689f8db026d75f9c78dda>
580-
deployment_information: Some(DeploymentInformation::BlockNumber(7005915)),
581-
},
582-
)
583-
.add_network(
584-
POLYGON,
585-
Network {
586-
address: addr("0x41B953164995c11C81DA73D212ED8Af25741b7Ac"),
587-
// <https://polygonscan.com/tx/0x125bc007a86d771f8dc8f5fa1017de6e5a11162a458a72f25814503404bbeb0b>
588-
deployment_information: Some(DeploymentInformation::BlockNumber(22067480)),
589-
},
590-
)
591-
});
513+
generate_contract_with_config(
514+
"BalancerV2NoProtocolFeeLiquidityBootstrappingPoolFactory",
515+
|builder| {
516+
builder
517+
.contract_mod_override(
518+
"balancer_v2_no_protocol_fee_liquidity_bootstrapping_pool_factory",
519+
)
520+
.add_network(
521+
// <https://docs.balancer.fi/reference/contracts/deployment-addresses/mainnet.html#ungrouped-active-current-contracts>
522+
MAINNET,
523+
Network {
524+
address: addr("0x0F3e0c4218b7b0108a3643cFe9D3ec0d4F57c54e"),
525+
// <https://etherscan.io/tx/0x298381e567ff6643d9b32e8e7e9ff0f04a80929dce3e004f6fa1a0104b2b69c3>
526+
deployment_information: Some(DeploymentInformation::BlockNumber(13730248)),
527+
},
528+
)
529+
.add_network(
530+
// <https://docs.balancer.fi/reference/contracts/deployment-addresses/gnosis.html#ungrouped-active-current-contracts>
531+
GNOSIS,
532+
Network {
533+
address: addr("0x85a80afee867aDf27B50BdB7b76DA70f1E853062"),
534+
// <https://gnosis.blockscout.com/tx/0xbd56fefdb27e4ff1c0852e405f78311d6bc2befabaf6c87a405ab19de8c1506a>
535+
deployment_information: Some(DeploymentInformation::BlockNumber(25415236)),
536+
},
537+
)
538+
.add_network(
539+
// <https://docs.balancer.fi/reference/contracts/deployment-addresses/sepolia.html#ungrouped-active-current-contracts>
540+
SEPOLIA,
541+
Network {
542+
address: addr("0x45fFd460cC6642B8D8Fb12373DFd77Ceb0f4932B"),
543+
// <https://sepolia.etherscan.io/tx/0xe0e8feb509a8aa8a1eaa0b0c4b34395ff2fd880fb854fbeeccc0af1826e395c9>
544+
deployment_information: Some(DeploymentInformation::BlockNumber(3419649)),
545+
},
546+
)
547+
.add_network(
548+
ARBITRUM_ONE,
549+
Network {
550+
address: addr("0x1802953277FD955f9a254B80Aa0582f193cF1d77"),
551+
// <https://arbiscan.io/tx/0x5265176961ba08450afc1d7c7d34321da11b2f1f106a7d652e6c11d923caed24>
552+
deployment_information: Some(DeploymentInformation::BlockNumber(4859669)),
553+
},
554+
)
555+
.add_network(
556+
BASE,
557+
Network {
558+
address: addr("0x0c6052254551EAe3ECac77B01DFcf1025418828f"),
559+
// <https://basescan.org/tx/0x0529de9dbe772f4b4f48da93ae2c2d2c46e3d3221ced9e0c4063a7a5bc47e874>
560+
deployment_information: Some(DeploymentInformation::BlockNumber(1206531)),
561+
},
562+
)
563+
.add_network(
564+
AVALANCHE,
565+
Network {
566+
address: addr("0x0F3e0c4218b7b0108a3643cFe9D3ec0d4F57c54e"),
567+
// <https://snowscan.xyz/tx/0x33a75d83436ae9fcda4b4986713417bf3dc80d9ceb8d2541817846b1ac579d9f>
568+
deployment_information: Some(DeploymentInformation::BlockNumber(26386552)),
569+
},
570+
)
571+
.add_network(
572+
BNB,
573+
Network {
574+
address: addr("0xC128468b7Ce63eA702C1f104D55A2566b13D3ABD"),
575+
// <https://bscscan.com/tx/0x8b964b97e6091bd41c93002c558d49adc26b8b31d2b30f3a33babbbbe8c55f47>
576+
deployment_information: Some(DeploymentInformation::BlockNumber(22691243)),
577+
},
578+
)
579+
.add_network(
580+
OPTIMISM,
581+
Network {
582+
address: addr("0xf302f9F50958c5593770FDf4d4812309fF77414f"),
583+
// <https://optimistic.etherscan.io/tx/0x14fb43f051eebdec645abf0125e52348dc875b0887b689f8db026d75f9c78dda>
584+
deployment_information: Some(DeploymentInformation::BlockNumber(7005915)),
585+
},
586+
)
587+
.add_network(
588+
POLYGON,
589+
Network {
590+
address: addr("0x41B953164995c11C81DA73D212ED8Af25741b7Ac"),
591+
// <https://polygonscan.com/tx/0x125bc007a86d771f8dc8f5fa1017de6e5a11162a458a72f25814503404bbeb0b>
592+
deployment_information: Some(DeploymentInformation::BlockNumber(22067480)),
593+
},
594+
)
595+
},
596+
);
592597
generate_contract_with_config("BalancerV2ComposableStablePoolFactory", |builder| {
593598
builder
594599
.contract_mod_override("balancer_v2_composable_stable_pool_factory")
@@ -1198,11 +1203,11 @@ fn main() {
11981203
deployment_information: Some(DeploymentInformation::BlockNumber(7944011)),
11991204
},
12001205
)
1201-
});
1202-
1206+
});
1207+
12031208
generate_contract("BalancerV3WeightedPool");
12041209
generate_contract("BalancerV3StablePool");
1205-
1210+
12061211
generate_contract_with_config("BaoswapRouter", |builder| {
12071212
builder.add_network_str(GNOSIS, "0x6093AeBAC87d62b1A5a4cEec91204e35020E38bE")
12081213
});

crates/contracts/src/lib.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ mod tests {
150150
const BASE: u64 = 8453;
151151
const ARBITRUM_ONE: u64 = 42161;
152152
const AVALANCHE: u64 = 43114;
153-
const SEPOLIA: u64 = 11155111;
153+
const SEPOLIA: u64 = 11155111;
154154

155155
use {
156156
super::*,
@@ -213,7 +213,17 @@ mod tests {
213213
}};
214214
}
215215

216-
for network in &[MAINNET, GNOSIS, SEPOLIA, ARBITRUM_ONE, OPTIMISM, BNB, AVALANCHE, POLYGON, BASE] {
216+
for network in &[
217+
MAINNET,
218+
GNOSIS,
219+
SEPOLIA,
220+
ARBITRUM_ONE,
221+
OPTIMISM,
222+
BNB,
223+
AVALANCHE,
224+
POLYGON,
225+
BASE,
226+
] {
217227
assert_has_deployment_address!(GPv2Settlement for *network);
218228
assert_has_deployment_address!(WETH9 for *network);
219229
assert_has_deployment_address!(HooksTrampoline for *network);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
pub mod v2;
2-
pub mod v3;
2+
pub mod v3;

crates/driver/src/boundary/liquidity/balancer/v2/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ use {
2424
sources::balancer_v2::{
2525
BalancerFactoryKind,
2626
BalancerPoolFetcher,
27-
pool_fetching::BalancerContracts,
2827
GqlChain,
28+
pool_fetching::BalancerContracts,
2929
},
3030
token_info::{CachedTokenInfoFetcher, TokenInfoFetcher},
3131
},

crates/driver/src/boundary/liquidity/balancer/v3/mod.rs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ use {
1111
chain::Chain,
1212
contracts::{
1313
BalancerV3BatchRouter,
14-
BalancerV3Vault,
15-
BalancerV3WeightedPoolFactory,
1614
BalancerV3StablePoolFactory,
1715
BalancerV3StablePoolFactoryV2,
16+
BalancerV3Vault,
17+
BalancerV3WeightedPoolFactory,
1818
GPv2Settlement,
1919
},
2020
ethrpc::block_stream::{BlockRetrieving, CurrentBlockWatcher},
@@ -23,8 +23,8 @@ use {
2323
sources::balancer_v3::{
2424
BalancerFactoryKind,
2525
BalancerPoolFetcher,
26-
pool_fetching::BalancerContracts,
2726
GqlChain,
27+
pool_fetching::BalancerContracts,
2828
},
2929
token_info::{CachedTokenInfoFetcher, TokenInfoFetcher},
3030
},
@@ -36,8 +36,8 @@ use {
3636
std::sync::Arc,
3737
};
3838

39-
pub mod weighted;
4039
pub mod stable;
40+
pub mod weighted;
4141

4242
/// Maps a Chain to the corresponding GqlChain for Balancer V3 API.
4343
fn chain_to_gql_chain(chain: &Chain) -> GqlChain {
@@ -124,7 +124,7 @@ async fn init_liquidity(
124124
config: &infra::liquidity::config::BalancerV3,
125125
) -> Result<impl LiquidityCollecting + use<>> {
126126
let web3 = boundary::web3(eth);
127-
127+
128128
// Create Balancer V3 contracts configuration
129129
let contracts = BalancerContracts {
130130
vault: BalancerV3Vault::at(&web3, config.vault.into()),
@@ -134,21 +134,36 @@ async fn init_liquidity(
134134
.weighted
135135
.iter()
136136
.map(|&factory| {
137-
(BalancerFactoryKind::Weighted, BalancerV3WeightedPoolFactory::at(&web3, factory.into()).raw_instance().clone())
137+
(
138+
BalancerFactoryKind::Weighted,
139+
BalancerV3WeightedPoolFactory::at(&web3, factory.into())
140+
.raw_instance()
141+
.clone(),
142+
)
138143
})
139144
.collect::<Vec<_>>(),
140145
config
141146
.stable
142147
.iter()
143148
.map(|&factory| {
144-
(BalancerFactoryKind::Stable, BalancerV3StablePoolFactory::at(&web3, factory.into()).raw_instance().clone())
149+
(
150+
BalancerFactoryKind::Stable,
151+
BalancerV3StablePoolFactory::at(&web3, factory.into())
152+
.raw_instance()
153+
.clone(),
154+
)
145155
})
146156
.collect::<Vec<_>>(),
147157
config
148158
.stable_v2
149159
.iter()
150160
.map(|&factory| {
151-
(BalancerFactoryKind::StableV2, BalancerV3StablePoolFactoryV2::at(&web3, factory.into()).raw_instance().clone())
161+
(
162+
BalancerFactoryKind::StableV2,
163+
BalancerV3StablePoolFactoryV2::at(&web3, factory.into())
164+
.raw_instance()
165+
.clone(),
166+
)
152167
})
153168
.collect::<Vec<_>>(),
154169
]
@@ -183,4 +198,4 @@ async fn init_liquidity(
183198
eth.contracts().settlement().clone(),
184199
contracts.batch_router,
185200
))
186-
}
201+
}

crates/driver/src/boundary/liquidity/balancer/v3/stable.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ use {
1212

1313
/// Median gas used per BalancerV3SwapGivenOutInteraction.
1414
// TODO: Estimate actual gas usage for Balancer V3 stable pools
15-
// Using same estimate as V2 for now, should be updated with actual V3 measurements
15+
// Using same estimate as V2 for now, should be updated with actual V3
16+
// measurements
1617
const GAS_PER_SWAP: u64 = 88_892;
1718

18-
pub fn to_domain(id: liquidity::Id, pool: BalancerV3StablePoolOrder) -> Result<liquidity::Liquidity> {
19+
pub fn to_domain(
20+
id: liquidity::Id,
21+
pool: BalancerV3StablePoolOrder,
22+
) -> Result<liquidity::Liquidity> {
1923
Ok(liquidity::Liquidity {
2024
id,
2125
gas: GAS_PER_SWAP.into(),
@@ -85,4 +89,4 @@ pub fn to_interaction(
8589
output,
8690
receiver,
8791
)
88-
}
92+
}

crates/driver/src/boundary/liquidity/balancer/v3/weighted.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ use {
1414
// TODO: Estimate actual gas usage for Balancer V3
1515
const GAS_PER_SWAP: u64 = 100_000;
1616

17-
pub fn to_domain(id: liquidity::Id, pool: BalancerV3WeightedProductOrder) -> Result<liquidity::Liquidity> {
17+
pub fn to_domain(
18+
id: liquidity::Id,
19+
pool: BalancerV3WeightedProductOrder,
20+
) -> Result<liquidity::Liquidity> {
1821
Ok(liquidity::Liquidity {
1922
id,
2023
gas: GAS_PER_SWAP.into(),
@@ -82,4 +85,4 @@ pub fn to_interaction(
8285
output,
8386
receiver,
8487
)
85-
}
88+
}

crates/driver/src/boundary/liquidity/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ impl Fetcher {
9595
let bal_v3: Vec<_> = config
9696
.balancer_v3
9797
.iter()
98-
.map(|config| balancer::v3::collector(eth, block_stream.clone(), block_retriever.clone(), config))
98+
.map(|config| {
99+
balancer::v3::collector(eth, block_stream.clone(), block_retriever.clone(), config)
100+
})
99101
.collect();
100102

101103
let uni_v3: Vec<_> = config
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
pub mod v2;
2-
pub mod v3;
2+
pub mod v3;

crates/driver/src/domain/liquidity/balancer/v3/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ use {
33
derive_more::{From, Into},
44
};
55

6-
pub mod weighted;
76
pub mod stable;
7+
pub mod weighted;
88

99
/// A Balancer V3 pool ID.
1010
///
1111
/// In Balancer V3, pool IDs are simply the pool contract addresses (20 bytes).
12-
/// This is different from V2 which used 32-byte pool IDs with additional metadata.
12+
/// This is different from V2 which used 32-byte pool IDs with additional
13+
/// metadata.
1314
#[derive(Clone, Copy, Debug, Eq, PartialEq, From, Into)]
1415
pub struct Id(pub eth::H160);
1516

@@ -72,4 +73,4 @@ impl ScalingFactor {
7273

7374
#[derive(Debug, thiserror::Error)]
7475
#[error("scaling factor must be non-zero")]
75-
pub struct ZeroScalingFactor;
76+
pub struct ZeroScalingFactor;

0 commit comments

Comments
 (0)