-
Notifications
You must be signed in to change notification settings - Fork 0
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
Use multiple price feeds always #64
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
462560b
use multiple price feeds always
harisang 0f05b80
simplify code
harisang 08755a5
fix type annotation in function
harisang 0cbdc3a
black fix
harisang b92c7b0
use standard list type
fhenneke 873af06
one more list typing fix
fhenneke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,3 +1,4 @@ | ||||||
import time | ||||||
from hexbytes import HexBytes | ||||||
from web3 import Web3 | ||||||
from src.helpers.blockchain_data import BlockchainData | ||||||
|
@@ -7,7 +8,6 @@ | |||||
from src.helpers.helper_functions import read_sql_file, set_params | ||||||
from src.helpers.config import CHAIN_SLEEP_TIME, logger | ||||||
from src.fees.compute_fees import compute_all_fees_of_batch | ||||||
import time | ||||||
|
||||||
|
||||||
class TransactionProcessor: | ||||||
|
@@ -191,7 +191,7 @@ def process_prices_for_tokens( | |||||
token_imbalances: dict[str, int], | ||||||
block_number: int, | ||||||
tx_hash: str, | ||||||
) -> dict[str, tuple[float, str]]: | ||||||
) -> dict[str, list[tuple[float, str]]]: | ||||||
"""Compute prices for tokens with non-null imbalances.""" | ||||||
prices = {} | ||||||
try: | ||||||
|
@@ -200,8 +200,7 @@ def process_prices_for_tokens( | |||||
set_params(token_address, block_number, tx_hash) | ||||||
) | ||||||
if price_data: | ||||||
price, source = price_data | ||||||
prices[token_address] = (price, source) | ||||||
prices[token_address] = price_data | ||||||
except Exception as e: | ||||||
logger.error(f"Failed to process prices for transaction {tx_hash}: {e}") | ||||||
|
||||||
|
@@ -290,15 +289,21 @@ def handle_fees( | |||||
) | ||||||
|
||||||
def handle_prices( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This name sounds a bit strange. Maybe |
||||||
self, prices: dict[str, tuple[float, str]], tx_hash: str, block_number: int | ||||||
self, | ||||||
prices: dict[str, list[tuple[float, str]]], | ||||||
tx_hash: str, | ||||||
block_number: int, | ||||||
) -> None: | ||||||
"""Function writes prices to table per token.""" | ||||||
try: | ||||||
for token_address, (price, source) in prices.items(): | ||||||
self.db.write_prices( | ||||||
source, block_number, tx_hash, token_address, price | ||||||
) | ||||||
self.log_message.append(f"Token: {token_address}, Price: {price} ETH") | ||||||
for token_address, list_of_prices in prices.items(): | ||||||
for price, source in list_of_prices: | ||||||
self.db.write_prices( | ||||||
source, block_number, tx_hash, token_address, price | ||||||
) | ||||||
self.log_message.append( | ||||||
f"Token: {token_address}, Price: {price} ETH, Source: {source}" | ||||||
) | ||||||
except Exception as err: | ||||||
logger.error(f"Error: {err}") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This being an error message sounds a bit strange. Most errors should be caught explicitly and would be more of a info type thing.