Skip to content

Commit

Permalink
Process staking withdrawals
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderLill committed Feb 10, 2024
1 parent 6dfaf64 commit d996ba1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
__pycache__
input
output
output
build/
dist/

old/
13 changes: 11 additions & 2 deletions src/ledger_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,12 +638,17 @@ def _process_staking(self, transaction_id, transaction):
def __is_staking_transfer(self, transaction):
for t in transaction.get("raw", []):
subtype = t.get("subtype", "")
if subtype == "spotfromfutures" or subtype == "spottostaking" or subtype == "stakingfromspot":
if subtype == "spotfromfutures" or \
subtype == "spottostaking" or \
subtype == "stakingfromspot" or \
subtype == "stakingtospot" or \
subtype == "spotfromstaking":
return True
return False

def __print_transaction_debug_info(self, message, transaction):
print(message + "-".join(list(set(transaction.get("types", [])))) + " info: " + transaction.get("meta", {}).get("parsing_info", ""))
print(json.dumps(transaction))

def _process_transaction(self, transaction_id, transaction):

Expand Down Expand Up @@ -671,6 +676,8 @@ def _process_transaction(self, transaction_id, transaction):
else:
self.__print_transaction_debug_info("Can't process case: ", transaction)
return [], []
elif transaction.get("meta", {}).get("parsing_info", "") == "nondup" and set(transaction.get("types", [])) == {"withdrawal"}:
return self._process_fiat_withdrawal(transaction_id, transaction)
else:
self.__print_transaction_debug_info("Can't process case: ", transaction)
return [], []
Expand Down Expand Up @@ -745,6 +752,7 @@ def _parse_transactions(self):
etype = entry["type"]
txid = entry["txid"]
time = entry["time"]
date = entry["Date"]

asset = entry["asset"]
amount = entry["amount"]
Expand All @@ -759,6 +767,7 @@ def _parse_transactions(self):
other_etype = other_entry["type"]
other_txid = other_entry["txid"]
other_time = other_entry["time"]
other_date = other_entry["Date"]

if refid == other_refid and txid == other_txid and etype == other_etype and time == other_time:
# Skip same entry
Expand All @@ -767,7 +776,7 @@ def _parse_transactions(self):
other_asset = other_entry["asset"]
other_amount = other_entry["amount"]

if asset == other_asset and amount == other_amount:
if asset == other_asset and amount == other_amount and date == other_date:

# TODO: Could additionally check for transactions within a few minutes

Expand Down

0 comments on commit d996ba1

Please sign in to comment.