-
Notifications
You must be signed in to change notification settings - Fork 299
feat: HIP-3 oracle pusher #3060
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
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls dont forget to add a readme!
dependencies = [ | ||
"asn1crypto>=1.5.1", | ||
"boto3>=1.40.31", | ||
"cryptography>=45.0.7", | ||
"hyperliquid-python-sdk>=0.19.0", | ||
"loguru>=0.7.3", | ||
"toml>=0.10.2", | ||
"websockets>=15.0.1", | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using >= opens us to to breaking major version changes. Let's use ^ (minor version updates allowed) or ~= (patch version updates allowed).
# Install the project's dependencies using the lockfile and settings | ||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
--mount=type=bind,source=apps/hip-3-pusher/uv.lock,target=uv.lock \ | ||
--mount=type=bind,source=apps/hip-3-pusher/pyproject.toml,target=pyproject.toml \ | ||
uv sync --locked --no-install-project --no-dev | ||
|
||
# Then, add the rest of the project source code and install it | ||
# Installing separately from its dependencies allows optimal layer caching | ||
COPY apps/hip-3-pusher/src/ ./src/ | ||
COPY apps/hip-3-pusher/config/ ./config/ | ||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
uv sync --locked --no-dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great that we have proper layer caching :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that was courtesy of the uv docker example. Astral is crushing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add **/config.toml
to avoid accidentally pushing secrets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intent is for the config.toml in git to be an example. Locally I use separately named config files, and of course k8s mounts our deployment configs.
self.price_state.latest_oracle_price = ctx["oraclePx"] | ||
self.price_state.latest_mark_price = ctx["markPx"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also store the timestamp so we know how stale the price is in case the data source disconnects and have to serve stale prices. It could also inform fallback behavior (it can choose the most recent price from the backup data sources.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nvm, i see you do this in #3061 ✅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will hold off on reviewing this file since its WIP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately yes, hopefully I can get it to match, it's unfortunately a bit of reverse engineering both KMS and the sdk and eth libraries.
hermes_listener = HermesListener(config, price_state) | ||
|
||
# TODO: Probably pull this out of the sdk. | ||
hyperliquid_listener.subscribe() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know if the HL subscribe()
function uses asyncio? Asking because the other components use asyncio which is convenient because its a single-threaded event loop, and there's no locking/synchronization needed on price_state
. But if the HL SDK isn't using that, we might have to worry about synchronizing price_state
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per other comment, planning to do this myself.
self.enable_kms = True | ||
oracle_account = None | ||
kms_key_path = config["kms"]["key_path"] | ||
kms_key_id = open(kms_key_path, "r").read().strip() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use Pathlib's read_text
for FS operations like this (it also closes the file for you)
if feed_id == self.base_feed_id: | ||
self.price_state.lazer_base_price = price | ||
if feed_id == self.quote_feed_id: | ||
self.price_state.lazer_quote_price = price |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are we using base_price and quote_price for? i noticed we don't push them anywhere in publisher.py.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HL oracle prices are denominated in USDT, so for pyth prices I'm dividing BTCUSD / USDTUSD.
pull_request: | ||
paths: | ||
- "apps/hip-3-pusher/**" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably don't want to build and push whenever a PR is opened/updated. Would remove this trigger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The push part actually doesn't happen on PRs for whatever reason. Somebody on the team explained it to me at some point when I was working on agent.
Summary
HIP-3 pusher application draft.
Rationale
Serve as market data provider for HIP-3 deployers.
How has this been tested?