COINBASE_TOKEN_NAMES => COINBASE_TOKEN_NAME_BY_ADDRESS
This commit is contained in:
parent
f5233a17fd
commit
4f34316afb
@ -6,17 +6,17 @@ from mev_inspect.schemas.coinbase import CoinbasePrices, CoinbasePricesResponse
|
|||||||
|
|
||||||
|
|
||||||
COINBASE_API_BASE = "https://www.coinbase.com/api/v2"
|
COINBASE_API_BASE = "https://www.coinbase.com/api/v2"
|
||||||
COINBASE_TOKEN_NAMES = {
|
COINBASE_TOKEN_NAME_BY_ADDRESS = {
|
||||||
WETH_ADDRESS: "weth",
|
WETH_ADDRESS: "weth",
|
||||||
ETH_TOKEN_ADDRESS: "ethereum",
|
ETH_TOKEN_ADDRESS: "ethereum",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def fetch_coinbase_prices(token_address: str) -> CoinbasePrices:
|
async def fetch_coinbase_prices(token_address: str) -> CoinbasePrices:
|
||||||
if token_address not in COINBASE_TOKEN_NAMES:
|
if token_address not in COINBASE_TOKEN_NAME_BY_ADDRESS:
|
||||||
raise ValueError(f"Unsupported token_address {token_address}")
|
raise ValueError(f"Unsupported token_address {token_address}")
|
||||||
|
|
||||||
coinbase_token_name = COINBASE_TOKEN_NAMES[token_address]
|
coinbase_token_name = COINBASE_TOKEN_NAME_BY_ADDRESS[token_address]
|
||||||
url = f"{COINBASE_API_BASE}/assets/prices/{coinbase_token_name}"
|
url = f"{COINBASE_API_BASE}/assets/prices/{coinbase_token_name}"
|
||||||
|
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user