Skip to content

Commit

Permalink
addressed review
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhagarwal03 committed Aug 1, 2024
1 parent 8069c15 commit 1f3585b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
11 changes: 4 additions & 7 deletions src/coingecko_pricing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

coingecko_api_key = os.getenv("COINGECKO_API_KEY")


def load_cleaned_token_list(file_path):
with open(file_path, "r") as f:
return json.load(f)
# Load the coingecko token list
cleaned_token_list_path = "src/coingecko_tokens_list/filtered_coingecko_list.json"
with open(cleaned_token_list_path, "r") as f:
cleaned_token_list = json.load(f)


def get_token_id_by_address(cleaned_token_list, token_address):
Expand Down Expand Up @@ -58,9 +58,6 @@ def get_price(web3: Web3, block_number: int, token_address: str, tx_hash: str):
Function returns coingecko price for a token address,
closest to and at least as large as the block timestamp for a given tx hash.
"""
cleaned_token_list = load_cleaned_token_list(
"src/coingecko_tokens_list/filtered_coingecko_list.json"
)
# Coingecko doesn't store ETH address, which occurs commonly in imbalances.
if Web3.to_checksum_address(token_address) == NATIVE_ETH_TOKEN_ADDRESS:
return 1.0
Expand Down
10 changes: 1 addition & 9 deletions src/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
from sqlalchemy import text
from sqlalchemy.engine import Engine
from src.imbalances_script import RawTokenImbalances
from src.helper_functions import (
get_finalized_block_number,
)
from src.helper_functions import get_finalized_block_number, read_sql_file
from src.config import (
initialize_connections,
CHAIN_SLEEP_TIME,
Expand All @@ -21,12 +19,6 @@
from src.coingecko_pricing import get_price


def read_sql_file(file_path: str) -> str:
"""This function reads an SQL file and returns its content in string format"""
with open(file_path, "r") as file:
return file.read()


def get_start_block(
chain_name: str, solver_slippage_connection: Engine, web3: Web3
) -> int:
Expand Down
6 changes: 6 additions & 0 deletions src/helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,9 @@ def get_finalized_block_number(web3: Web3) -> int:
Get the number of the most recent finalized block.
"""
return web3.eth.block_number - 67


def read_sql_file(file_path: str) -> str:
"""This function reads a file (SQL) and returns its content as a string."""
with open(file_path, "r") as file:
return file.read()

0 comments on commit 1f3585b

Please sign in to comment.