Skip to content

Commit

Permalink
Fix: parsing swap events and None price (#98)
Browse files Browse the repository at this point in the history
* Enhanced parsing for assets::transfer event

* Check for not None price

---------

Co-authored-by: f33r0 <[email protected]>
Co-authored-by: Taras Rusakovich <[email protected]>
  • Loading branch information
3 people authored Oct 8, 2024
1 parent c636586 commit 61b5e81
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,10 @@ def process_swap_transaction(timestamp, extrinsicEvents, ex_dict, prices):
elif event["event_id"] == "ExtrinsicFailed":
swap_success = False
elif event['module_id'] == "Assets" and event["event_id"] == "Transfer":
_, to_address, token_obj, amount = event["attributes"]
if to_address == TECH_ACCOUNT:
intermediate_amounts.append((token_obj['code'], amount))
from_address, to_address, token_obj, amount = event["attributes"]
if not any(token_obj['code'] == token for token, _ in intermediate_amounts):
if TECH_ACCOUNT in [from_address, to_address]:
intermediate_amounts.append((token_obj['code'], amount))
elif event['module_id'] == "Tokens" and event["event_id"] == "Deposited":
token_obj, who, amount = event["attributes"].values()
if who == TECH_ACCOUNT:
Expand Down
3 changes: 3 additions & 0 deletions web.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ async def pairs(session=Depends(get_db)):
pairs[id]["base_volume"] += FormattedFloat(base_volume)
if quote_volume:
pairs[id]["quote_volume"] += FormattedFloat(quote_volume)
elif (quote_price is None and last_price == 0) or (last_price is None and quote_price == 0) or \
(last_price is None and quote_price is None):
continue
else:
pairs[id] = {
"base_id": base.hash,
Expand Down

0 comments on commit 61b5e81

Please sign in to comment.