Skip to content

Commit 7e4b069

Browse files
committed
Migrate orderbook::database::auction_prices to alloy
1 parent f5018ab commit 7e4b069

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use {
22
super::Postgres,
3+
alloy::primitives::Address,
34
anyhow::Result,
45
bigdecimal::BigDecimal,
5-
primitive_types::H160,
66
std::collections::HashMap,
77
};
88

99
impl Postgres {
10-
pub async fn fetch_latest_prices(&self) -> Result<HashMap<H160, BigDecimal>> {
10+
pub async fn fetch_latest_prices(&self) -> Result<HashMap<Address, BigDecimal>> {
1111
let _timer = super::Metrics::get()
1212
.database_queries
1313
.with_label_values(&["fetch_latest_prices"])
@@ -17,7 +17,7 @@ impl Postgres {
1717
Ok(database::auction_prices::fetch_latest_prices(&mut ex)
1818
.await?
1919
.into_iter()
20-
.map(|auction_price| (H160::from(auction_price.token.0), auction_price.price))
20+
.map(|auction_price| (Address::new(auction_price.token.0), auction_price.price))
2121
.collect::<HashMap<_, _>>())
2222
}
2323
}

crates/orderbook/src/run.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,13 @@ pub async fn run(args: Arguments) {
331331
)
332332
.await
333333
.unwrap();
334-
let prices = postgres_write.fetch_latest_prices().await.unwrap();
334+
let prices = postgres_write
335+
.fetch_latest_prices()
336+
.await
337+
.unwrap()
338+
.into_iter()
339+
.map(|(k, v)| (k.into_legacy(), v))
340+
.collect();
335341
native_price_estimator.initialize_cache(prices);
336342

337343
let price_estimator = price_estimator_factory

0 commit comments

Comments
 (0)