Skip to content
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

Switch to the Hermes v2 API #79

Merged
merged 1 commit into from
Aug 30, 2024
Merged
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
12 changes: 6 additions & 6 deletions pyth_observer/crosschain.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ async def get_crosschain_prices(self) -> Dict[str, CrosschainPrice]:
async with ClientSession(
headers={"content-type": "application/json"}
) as session:
price_feed_ids_url = f"{self.url}/api/price_feed_ids"
price_feeds_index_url = f"{self.url}/v2/price_feeds"

async with session.get(price_feed_ids_url) as response:
price_feed_ids = await response.json()
async with session.get(price_feeds_index_url) as response:
price_feeds_index = await response.json()

price_feeds = []

for ids in chunked(price_feed_ids, 25):
price_feeds_url = f"{self.url}/api/latest_price_feeds"
for feeds in chunked(price_feeds_index, 25):
price_feeds_url = f"{self.url}/v2/updates/price/latest"

# aiohttp does not support encoding array params using PHP-style `ids=[]`
# naming, so we encode it manually and append to the URL.
query_string = "?" + "&".join(f"ids[]={v}" for v in ids)
query_string = "?" + "&".join(f"ids[]={v['id']}" for v in feeds)
async with session.get(
price_feeds_url + query_string,
) as response:
Expand Down
Loading