Skip to content

Conversation

merolish
Copy link
Contributor

Summary

Rationale

How has this been tested?

  • Current tests cover my changes
  • Added new tests
  • Manually tested the code

Copy link

vercel bot commented Sep 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
api-reference Ready Ready Preview Comment Sep 18, 2025 7:00pm
component-library Ready Ready Preview Comment Sep 18, 2025 7:00pm
developer-hub Ready Ready Preview Comment Sep 18, 2025 7:00pm
entropy-explorer Ready Ready Preview Comment Sep 18, 2025 7:00pm
insights Ready Ready Preview Comment Sep 18, 2025 7:00pm
proposals Ready Ready Preview Comment Sep 18, 2025 7:00pm
staking Ready Ready Preview Comment Sep 18, 2025 7:00pm

@merolish merolish merged commit 59f1019 into main Sep 18, 2025
9 checks passed
@merolish merolish deleted the mike/hip3-part2 branch September 18, 2025 21:21
@tejasbadadare tejasbadadare mentioned this pull request Sep 18, 2025
3 tasks
Comment on lines +32 to +35
self.price_state.hl_oracle_price = ctx["oraclePx"]
self.price_state.hl_mark_price = ctx["markPx"]
logger.debug("on_activeAssetCtx: oraclePx: {} marketPx: {}", self.price_state.hl_oracle_price, self.price_state.hl_mark_price)
self.price_state.latest_hl_timestamp = time.time()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would recommend storing the timestamp together with the price in one type to enforce they are updated together. something like

class PriceUpdate:
    asset_id: str
    price: float
    timestamp: int

self.hermes_quote_exponent = config["hermes"]["quote_feed_exponent"]
self.latest_hermes_timestamp = now

def get_current_oracle_price(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth thinking through how this evolves as we need to support pushing multiple prices. Also, we might want to have this orchestration in a different module and split up the state to be managed by the individual data sources instead of a single mono-state.

Comment on lines +42 to +63
# fall back to Hermes
if self.hermes_base_price and self.hermes_quote_price:
time_diff = now - self.latest_hermes_timestamp
if time_diff < self.stale_price_threshold_seconds:
return self.get_hermes_price()
else:
logger.error("Hermes price stale by {} seconds", time_diff)
else:
logger.error("Hermes base/quote prices not received yet")

# fall back to Lazer
if self.lazer_base_price and self.lazer_quote_price:
time_diff = now - self.latest_lazer_timestamp
if time_diff < self.stale_price_threshold_seconds:
return self.get_lazer_price()
else:
logger.error("Lazer price stale by {} seconds", time_diff)
else:
logger.error("Lazer base/quote prices not received yet")

logger.error("All prices missing or stale!")
return None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason we fall back to Hermes before Lazer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I think I just mixed up the order you guys suggested for whatever reason. Dunno if currently we trust one more than the other.


mark_pxs = []
#if self.price_state.hl_mark_price:
# mark_pxs.append({self.market_symbol: self.price_state.hl_mark_price})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not publish the mark prices?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They told us not to for now. Note that this will also include the actual HIP-3's market data in the calculation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are just mark prices for the HyperCore perps which are useful data points but separate.

Comment on lines +25 to +29
hermes_urls = ["wss://hermes.pyth.network/ws"]
base_feed_id = "e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43" # BTC
base_feed_exponent = -8
quote_feed_id = "2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b" # USDT
quote_feed_exponent = -8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll eventually need to split out the price config into its own file and source the metadata (like exponent) from the data sources themselves.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, will need to scale this into a general set of prices and calcs.

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