Skip to content
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
9 changes: 4 additions & 5 deletions poetry.lock

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

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ loguru = "^0.6.0"
more-itertools = "^9.0.0"
prometheus-client = "0.15.0"
pycoingecko = "2.2.0"
pythclient = "^0.1.24"
pythclient = "^0.2.1"
pyyaml = "^6.0"
throttler = "1.2.1"
types-pyyaml = "^6.0.12"
Expand Down
3 changes: 3 additions & 0 deletions pyth_observer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from base58 import b58decode
from loguru import logger
from pythclient.market_schedule import MarketSchedule
from pythclient.pythaccounts import PythPriceAccount, PythPriceType, PythProductAccount
from pythclient.pythclient import PythClient
from pythclient.solana import (
Expand Down Expand Up @@ -120,6 +121,7 @@ async def run(self):
PriceFeedState(
symbol=product.attrs["symbol"],
asset_type=product.attrs["asset_type"],
schedule=MarketSchedule(product.attrs["schedule"]),
public_key=price_account.key,
status=price_account.aggregate_price_status,
# this is the solana block slot when price account was fetched
Expand All @@ -146,6 +148,7 @@ async def run(self):
publisher_name=publisher_name,
symbol=product.attrs["symbol"],
asset_type=product.attrs["asset_type"],
schedule=MarketSchedule(product.attrs["schedule"]),
public_key=component.publisher_key,
confidence_interval=component.latest_price_info.confidence_interval,
confidence_interval_aggregate=price_account.aggregate_price_info.confidence_interval,
Expand Down
12 changes: 5 additions & 7 deletions pyth_observer/check/price_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from zoneinfo import ZoneInfo

import arrow
from pythclient.calendar import is_market_open
from pythclient.market_schedule import MarketSchedule
from pythclient.pythaccounts import PythPriceStatus
from pythclient.solana import SolanaPublicKey

Expand All @@ -16,6 +16,7 @@
class PriceFeedState:
symbol: str
asset_type: str
schedule: MarketSchedule
public_key: SolanaPublicKey
status: PythPriceStatus
latest_block_slot: int
Expand Down Expand Up @@ -55,8 +56,7 @@ def state(self) -> PriceFeedState:
return self.__state

def run(self) -> bool:
market_open = is_market_open(
self.__state.asset_type.lower(),
market_open = self.__state.schedule.is_market_open(
datetime.now(ZoneInfo("America/New_York")),
)

Expand Down Expand Up @@ -176,8 +176,7 @@ def run(self) -> bool:
if self.__state.status != PythPriceStatus.TRADING:
return True

market_open = is_market_open(
self.__state.asset_type.lower(),
market_open = self.__state.schedule.is_market_open(
datetime.now(ZoneInfo("America/New_York")),
)

Expand Down Expand Up @@ -237,8 +236,7 @@ def run(self) -> bool:
if self.__state.status != PythPriceStatus.TRADING:
return True

market_open = is_market_open(
self.__state.asset_type.lower(),
market_open = self.__state.schedule.is_market_open(
datetime.now(ZoneInfo("America/New_York")),
)

Expand Down
9 changes: 4 additions & 5 deletions pyth_observer/check/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from zoneinfo import ZoneInfo

from loguru import logger
from pythclient.calendar import is_market_open
from pythclient.market_schedule import MarketSchedule
from pythclient.pythaccounts import PythPriceStatus
from pythclient.solana import SolanaPublicKey

Expand Down Expand Up @@ -36,6 +36,7 @@ class PublisherState:
publisher_name: str
symbol: str
asset_type: str
schedule: MarketSchedule
public_key: SolanaPublicKey
status: PythPriceStatus
aggregate_status: PythPriceStatus
Expand Down Expand Up @@ -161,8 +162,7 @@ def state(self) -> PublisherState:
return self.__state

def run(self) -> bool:
market_open = is_market_open(
self.__state.asset_type.lower(),
market_open = self.__state.schedule.is_market_open(
datetime.now(ZoneInfo("America/New_York")),
)

Expand Down Expand Up @@ -272,8 +272,7 @@ def state(self) -> PublisherState:
return self.__state

def run(self) -> bool:
market_open = is_market_open(
self.__state.asset_type.lower(),
market_open = self.__state.schedule.is_market_open(
datetime.now(ZoneInfo("America/New_York")),
)

Expand Down
2 changes: 2 additions & 0 deletions tests/test_checks_price_feed.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pythclient.market_schedule import MarketSchedule
from pythclient.pythaccounts import PythPriceStatus
from pythclient.solana import SolanaPublicKey

Expand All @@ -8,6 +9,7 @@ def test_price_feed_offline_check():
state = PriceFeedState(
symbol="Crypto.BTC/USD",
asset_type="Crypto",
schedule=MarketSchedule("America/New_York;O,O,O,O,O,O,O;"),
public_key=SolanaPublicKey("2hgu6Umyokvo8FfSDdMa9nDKhcdv9Q4VvGNhRCeSWeD3"),
status=PythPriceStatus.TRADING,
latest_block_slot=100,
Expand Down
2 changes: 2 additions & 0 deletions tests/test_checks_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from unittest.mock import patch

import pytest
from pythclient.market_schedule import MarketSchedule
from pythclient.pythaccounts import PythPriceStatus
from pythclient.solana import SolanaPublicKey

Expand All @@ -29,6 +30,7 @@ def make_publisher_state(
publisher_name="publisher",
symbol=symbol,
asset_type=asset_type,
schedule=MarketSchedule("America/New_York;O,O,O,O,O,O,O;"),
public_key=SolanaPublicKey("2hgu6Umyokvo8FfSDdMa9nDKhcdv9Q4VvGNhRCeSWeD3"),
status=PythPriceStatus.TRADING,
aggregate_status=PythPriceStatus.TRADING,
Expand Down