Skip to content

Commit cc417c0

Browse files
committed
Merge branch 'main' into jmgd/alloy/model_fee_trade
2 parents acc8efa + 0e8c829 commit cc417c0

File tree

11 files changed

+89
-96
lines changed

11 files changed

+89
-96
lines changed

Cargo.lock

Lines changed: 68 additions & 71 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ resolver = "3"
33
members = ["crates/*"]
44

55
[workspace.dependencies]
6-
alloy = { version = "1.0.41", default-features = false }
7-
anyhow = "=1.0.76"
6+
alloy = { version = "1.1.0", default-features = false }
7+
anyhow = "1.0.100"
88
async-trait = "0.1.80"
99
axum = "0.6"
1010
bigdecimal = "0.3"

crates/driver/src/domain/competition/solution/encoding.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,8 @@ pub fn liquidity_interaction(
376376
}
377377

378378
pub fn approve(allowance: &Allowance) -> eth::Interaction {
379-
let mut amount = [0u8; 32];
380379
let selector = hex_literal::hex!("095ea7b3");
381-
allowance.amount.to_big_endian(&mut amount);
380+
let amount: [_; 32] = allowance.amount.to_be_bytes();
382381
eth::Interaction {
383382
target: allowance.token.0.into(),
384383
value: eth::U256::zero().into(),
@@ -520,7 +519,7 @@ mod test {
520519
token: eth::H160::from_slice(&hex!("C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2")).into(),
521520
spender: eth::H160::from_slice(&hex!("000000000022D473030F116dDEE9F6B43aC78BA3"))
522521
.into(),
523-
amount: eth::U256::max_value(),
522+
amount: alloy::primitives::U256::MAX,
524523
};
525524
let interaction = approve(&allowance);
526525
assert_eq!(

crates/driver/src/domain/competition/solution/interaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl Interaction {
5656
eth::Allowance {
5757
token: interaction.input.token,
5858
spender: address.into(),
59-
amount: eth::U256::max_value(),
59+
amount: alloy::primitives::U256::MAX,
6060
}
6161
.into(),
6262
]

crates/driver/src/domain/competition/solution/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use {
1616
},
1717
},
1818
chrono::Utc,
19-
ethrpc::alloy::conversions::IntoLegacy,
19+
ethrpc::alloy::conversions::{IntoAlloy, IntoLegacy},
2020
futures::future::try_join_all,
2121
itertools::Itertools,
2222
num::{BigRational, One},
@@ -426,15 +426,15 @@ impl Solution {
426426
let amount = normalized
427427
.entry((allowance.0.token, allowance.0.spender))
428428
.or_insert(eth::U256::zero());
429-
*amount = amount.saturating_add(allowance.0.amount);
429+
*amount = amount.saturating_add(allowance.0.amount.into_legacy());
430430
}
431431
normalized
432432
.into_iter()
433433
.map(|((token, spender), amount)| {
434434
eth::Allowance {
435435
token,
436436
spender,
437-
amount,
437+
amount: amount.into_alloy(),
438438
}
439439
.into()
440440
})

crates/driver/src/domain/eth/allowance.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use {
2-
super::{Address, TokenAddress, U256},
2+
super::{Address, TokenAddress},
3+
alloy::primitives::U256,
34
derive_more::{From, Into},
45
};
56

@@ -47,15 +48,15 @@ impl Approval {
4748
/// [`U256::max_value`].
4849
pub fn max(self) -> Self {
4950
Self(Allowance {
50-
amount: U256::max_value(),
51+
amount: U256::MAX,
5152
..self.0
5253
})
5354
}
5455

5556
/// Revoke the approval, i.e. set the approved amount to [`U256::zero`].
5657
pub fn revoke(self) -> Self {
5758
Self(Allowance {
58-
amount: U256::zero(),
59+
amount: U256::ZERO,
5960
..self.0
6061
})
6162
}

crates/driver/src/infra/blockchain/token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl Erc20 {
4646
Ok(eth::Allowance {
4747
token: self.token.address().into_legacy().into(),
4848
spender,
49-
amount: amount.into_legacy(),
49+
amount,
5050
}
5151
.into())
5252
}

crates/driver/src/infra/solver/dto/solution.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use {
99
util::Bytes,
1010
},
1111
app_data::AppDataHash,
12+
ethrpc::alloy::conversions::IntoAlloy,
1213
itertools::Itertools,
1314
model::{
1415
DomainSeparator,
@@ -147,7 +148,7 @@ impl Solutions {
147148
eth::Allowance {
148149
token: allowance.token.into(),
149150
spender: allowance.spender.into(),
150-
amount: allowance.amount,
151+
amount: allowance.amount.into_alloy(),
151152
}
152153
.into()
153154
})

crates/refunder/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ async-trait = { workspace = true }
1212
clap = { workspace = true }
1313
contracts = { workspace = true }
1414
database = { workspace = true }
15-
ethcontract = { workspace = true }
1615
ethrpc = { workspace = true }
1716
futures = { workspace = true }
1817
gas-estimation = { workspace = true }

crates/refunder/src/lib.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ pub mod submitter;
44

55
use {
66
crate::arguments::Arguments,
7+
alloy::signers::local::PrivateKeySigner,
78
clap::Parser,
89
contracts::alloy::CoWSwapEthFlow,
9-
ethcontract::PrivateKey,
1010
observe::metrics::LivenessChecking,
1111
refund_service::RefundService,
1212
shared::http_client::HttpClientFactory,
@@ -69,13 +69,10 @@ pub async fn run(args: arguments::Arguments) {
6969
.iter()
7070
.map(|contract| CoWSwapEthFlow::Instance::new(*contract, web3.alloy.clone()))
7171
.collect();
72-
let refunder_pk = args
73-
.refunder_pk
74-
.parse::<PrivateKey>()
75-
.expect("couldn't parse refunder private key");
7672
let refunder_account = Box::new(
77-
alloy::signers::local::PrivateKeySigner::from_slice(&refunder_pk.secret_bytes())
78-
.expect("invalid refunder private key bytes"),
73+
args.refunder_pk
74+
.parse::<PrivateKeySigner>()
75+
.expect("couldn't parse refunder private key"),
7976
);
8077
let mut refunder = RefundService::new(
8178
pg_pool,

0 commit comments

Comments
 (0)