This repository has been archived by the owner on Dec 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds a simple job that pushes all prices collected in the `prices` table of the analytics db to Dune. It mimics PR #103, and is meant to run as a cronjob. I followed the "legacy method" as there are some concerns about the current way Prefect has been integrated in this repo. I also prepared this PR in the infra repo. cowprotocol/infrastructure#2217 Note: there are currently not any tests. I saw there are some tests for the app-data sync, so i could try to basically copy-paste those, as i am not sure what's the best way to test this
- Loading branch information
Showing
7 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- Selects all prices collected in the analytics db | ||
SELECT | ||
concat('0x', encode(p.token_address, 'hex')) as token_address, | ||
p.time, | ||
p.price, | ||
td.decimals, | ||
p.source | ||
FROM prices p INNER JOIN token_decimals td ON p.token_address = td.token_address |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
"""Re-exported sync methods.""" | ||
from .app_data import sync_app_data | ||
from .price_feed import sync_price_feed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""Main Entry point for price feed sync""" | ||
|
||
from dune_client.client import DuneClient | ||
|
||
from src.fetch.orderbook import OrderbookFetcher | ||
from src.logger import set_log | ||
from src.sync.config import PriceFeedSyncConfig | ||
|
||
log = set_log(__name__) | ||
|
||
|
||
async def sync_price_feed( | ||
orderbook: OrderbookFetcher, | ||
dune: DuneClient, | ||
config: PriceFeedSyncConfig, | ||
dry_run: bool, | ||
) -> None: | ||
"""Price Feed Sync Logic""" | ||
prices = orderbook.get_price_feed() | ||
if not dry_run: | ||
dune.upload_csv( | ||
data=prices.to_csv(index=False), | ||
table_name=config.table, | ||
description=config.description, | ||
is_private=False, | ||
) | ||
log.info("price feed sync run completed successfully") |