Skip to content

Commit 23419c9

Browse files
committed
remove pair source rounding as Hyperliquid handles it
1 parent e690d57 commit 23419c9

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

apps/hip-3-pusher/src/pusher/price_state.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,14 @@ def get_prices(self, symbol_configs: dict[str, list[PriceSourceConfig]], oracle_
8585
pxs = {}
8686
for symbol in symbol_configs:
8787
for source_config in symbol_configs[symbol]:
88-
# find first valid price in the waterfall
89-
px = self.get_price(source_config, oracle_update)
90-
if px is not None:
91-
pxs[f"{self.market_name}:{symbol}"] = str(px)
92-
break
88+
try:
89+
# find first valid price in the waterfall
90+
px = self.get_price(source_config, oracle_update)
91+
if px is not None:
92+
pxs[f"{self.market_name}:{symbol}"] = str(px)
93+
break
94+
except Exception as e:
95+
logger.exception("get_price exception for symbol: {} source_config: {} error: {}", symbol, source_config, e)
9396
return pxs
9497

9598
def get_price(self, price_source_config: PriceSourceConfig, oracle_update: OracleUpdate):
@@ -125,10 +128,10 @@ def get_price_from_pair_source(self, base_source: PriceSource, quote_source: Pri
125128
if base_price is None:
126129
return None
127130
quote_price = self.get_price_from_single_source(quote_source)
128-
if quote_price is None:
131+
if quote_price is None or float(quote_price) == 0:
129132
return None
130133

131-
return str(round(float(base_price) / float(quote_price), 2))
134+
return str(float(base_price) / float(quote_price))
132135

133136
def get_price_from_oracle_mid_average(self, symbol: str, oracle_update: OracleUpdate):
134137
oracle_price = oracle_update.oracle.get(symbol)

apps/hip-3-pusher/tests/test_price_state.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_fallback_lazer():
6161
price_state.lazer_state.put(8, PriceUpdate("99000000", now - price_state.stale_price_threshold_seconds / 2.0))
6262

6363
oracle_update = price_state.get_all_prices()
64-
assert oracle_update.oracle == {f"{DEX}:{SYMBOL}": "111616.16"}
64+
assert oracle_update.oracle == {f"{DEX}:{SYMBOL}": "111616.16161616161"}
6565

6666

6767

@@ -81,7 +81,7 @@ def test_fallback_hermes():
8181
PriceUpdate("98000000", now - price_state.stale_price_threshold_seconds / 2.0))
8282

8383
oracle_update = price_state.get_all_prices()
84-
assert oracle_update.oracle == {f"{DEX}:{SYMBOL}": "113265.31"}
84+
assert oracle_update.oracle == {f"{DEX}:{SYMBOL}": "113265.30612244898"}
8585

8686

8787
def test_all_fail():

0 commit comments

Comments
 (0)