Skip to content

fix: cargo update, zero price handling #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 16, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/rustfmt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
profile: minimal
toolchain: nightly
components: rustfmt
- uses: pre-commit/action@v2.0.3
- uses: pre-commit/action@v3.0.1
8 changes: 4 additions & 4 deletions Cargo.lock

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

16 changes: 13 additions & 3 deletions src/agent/services/lazer_exporter.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use {
crate::agent::state,
anyhow::Result,
anyhow::{
anyhow,
Result,
},
futures_util::{
stream::{
SplitSink,
Expand Down Expand Up @@ -135,7 +138,7 @@ struct SymbolResponse {

async fn fetch_symbols(history_url: &Url) -> Result<Vec<SymbolResponse>> {
let mut url = history_url.clone();
url.set_scheme("http").unwrap();
url.set_scheme("http").map_err(|_| anyhow!("invalid url"))?;
url.set_path("/history/v1/symbols");
let client = Client::new();
let response = client.get(url).send().await?.error_for_status()?;
Expand Down Expand Up @@ -181,6 +184,7 @@ mod lazer_exporter {
time::Duration,
},
tokio_stream::StreamMap,
tracing::warn,
};

pub async fn lazer_exporter<S>(config: Config, state: Arc<S>)
Expand Down Expand Up @@ -245,8 +249,14 @@ mod lazer_exporter {
// TODO: This read locks and clones local::Store::prices, which may not meet performance needs.
for (identifier, price_info) in state.get_all_price_infos().await {
if let Some(symbol) = lazer_symbols.get(&identifier.to_string()) {
let price = if let Ok(price) = NonZeroI64::try_from(price_info.price) {
Some(Price(price))
} else {
warn!("Zero price in local state identifier: {identifier} price_info: {price_info:?}");
continue;
};
if let Err(e) = relayer_sender.send_price_update(&PriceFeedDataV1 {
price: Some(Price(NonZeroI64::try_from(price_info.price).unwrap())),
price,
best_ask_price: None,
best_bid_price: None,
price_feed_id: PriceFeedId(symbol.pyth_lazer_id),
Expand Down
Loading