Skip to content

Update price to get price from pyth api#1176

Merged
bbalser merged 7 commits into
mainfrom
bbalser/price-pyth-api
Apr 21, 2026
Merged

Update price to get price from pyth api#1176
bbalser merged 7 commits into
mainfrom
bbalser/price-pyth-api

Conversation

@bbalser
Copy link
Copy Markdown
Collaborator

@bbalser bbalser commented Apr 20, 2026

Summary

Switch the price service from reading HNT prices on-chain (via Solana RPC + helium-lib Pyth account
reads) to pulling them directly from the Pyth Hermes HTTP API. The Hermes URL (including the HNT feed id) is
configurable via the existing source setting.

Multi-token support is dropped — the service now emits HNT prices only. The solana path dependency is
removed from the price crate entirely, and unused workspace deps are trimmed.

Changes

  • HTTP fetcher: PriceGenerator now holds a reqwest::Client and fetches
    /v2/updates/price/latest?ids[]=<hnt_feed_id>. The parsed response is scaled by 10^(HNT_DECIMALS + expo)
    to preserve the same u64 integer semantics (price × 10^8) that downstream consumers expect. Stale-price
    fallback, file caching, metrics, and the 60s poll cadence are unchanged.
  • Settings (price/src/settings.rs):
    • Dropped TokenSetting / tokens Vec and the JSON-or-struct deserializer helper.
    • Promoted default_price to a top-level optional field (for testing).
    • source now defaults to the Hermes HNT endpoint.
  • price check CLI (price/src/cli/check.rs): rewrote to fetch Hermes once and print the feed id, raw
    price, confidence, exponent, publish time, and the scaled integer the daemon would emit. Takes an optional
    --url override; otherwise uses the source setting.
  • main.rs: removed the per-token spawn loop; one PriceGenerator is started. Check args reduced to
    --url.
  • metrics.rs: hardcoded token_type = "hnt"; dropped solana::Token.
  • Cargo.toml:
    • Added reqwest = { version = "0.12", features = ["json"] } (pinned locally, mirroring helium_iceberg).
    • Removed solana = { path = "../solana" }.
    • Removed unused deps: thiserror, futures-util, prost, tracing-subscriber, tokio-util,
      metrics-exporter-prometheus, rust_decimal_macros.
  • pkg/settings-template.toml: replaced Solana RPC URL with the Hermes URL; removed [cluster] section
    and legacy per-token commented fields.
  • README.md: updated to describe the Hermes HTTP flow.

@bbalser bbalser requested a review from michaeldjeffrey April 20, 2026 16:51
Comment thread price/src/cli/check.rs Outdated
Comment thread price/src/cli/check.rs Outdated
Comment thread price/pkg/settings-template.toml Outdated
Comment thread price/src/price_generator.rs Outdated
Comment thread price/src/price_generator.rs Outdated
Comment thread price/src/price_generator.rs Outdated
Comment thread price/src/price_generator.rs
Comment thread price/src/price_generator.rs Outdated
Comment thread price/src/settings.rs
@bbalser bbalser merged commit 4bcc8c5 into main Apr 21, 2026
54 of 55 checks passed
@bbalser bbalser deleted the bbalser/price-pyth-api branch April 21, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants