Write prices on fetch-all
This commit is contained in:
parent
2dc14218bf
commit
bed8520bc8
9
cli.py
9
cli.py
@ -5,6 +5,7 @@ import sys
|
||||
import click
|
||||
|
||||
from mev_inspect.concurrency import coro
|
||||
from mev_inspect.crud.prices import write_prices
|
||||
from mev_inspect.db import get_inspect_session, get_trace_session
|
||||
from mev_inspect.inspector import MEVInspector
|
||||
from mev_inspect.prices import fetch_all_supported_prices
|
||||
@ -83,9 +84,13 @@ async def inspect_many_blocks_command(
|
||||
@cli.command()
|
||||
@coro
|
||||
async def fetch_all_prices():
|
||||
print("fetching")
|
||||
inspect_db_session = get_inspect_session()
|
||||
|
||||
print("Fetching prices")
|
||||
prices = await fetch_all_supported_prices()
|
||||
print(prices[0])
|
||||
|
||||
print("Writing prices")
|
||||
write_prices(inspect_db_session, prices)
|
||||
|
||||
|
||||
def get_rpc_url() -> str:
|
||||
|
@ -21,7 +21,7 @@ async def fetch_all_supported_prices() -> List[Price]:
|
||||
price = Price(
|
||||
token_address=token_address,
|
||||
usd_price=usd_price,
|
||||
timestamp_seconds=timestamp_seconds,
|
||||
timestamp=timestamp_seconds,
|
||||
)
|
||||
|
||||
prices.append(price)
|
||||
|
@ -1,7 +1,9 @@
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class Price(BaseModel):
|
||||
token_address: str
|
||||
timestamp_seconds: int
|
||||
timestamp: datetime
|
||||
usd_price: float
|
||||
|
Loading…
x
Reference in New Issue
Block a user