Aave transfers

This commit is contained in:
Gui Heise 2021-10-13 00:53:14 -04:00
parent 5e111dd5b2
commit b2de07407c
2 changed files with 7 additions and 33 deletions

View File

@ -11,7 +11,7 @@ from mev_inspect.schemas.classified_traces import (
Protocol,
)
from mev_inspect.schemas.transfers import ERC20Transfer, aTokenTransfer, Transfer
from mev_inspect.schemas.transfers import ERC20Transfer, Transfer
from mev_inspect.schemas.liquidations import Liquidation
AAVE_CONTRACT_ADDRESSES: List[str] = [
@ -91,22 +91,13 @@ def _get_payback_token_and_amount(
if child.classification == Classification.transfer and isinstance(
child, DecodedCallTrace
):
if liquidation.inputs["_receiveAToken"]:
child_transfer = aTokenTransfer.from_trace(child)
child_transfer = ERC20Transfer.from_trace(child)
if (
child_transfer.to_address == liquidator
) and child.from_address in AAVE_CONTRACT_ADDRESSES:
return child_transfer.token_address, child_transfer.amount
else:
child_transfer = ERC20Transfer.from_trace(child)
if (
child_transfer.to_address == liquidator
) and child.from_address in AAVE_CONTRACT_ADDRESSES:
return child_transfer.token_address, child_transfer.amount
if (
child_transfer.to_address == liquidator
and child.from_address in AAVE_CONTRACT_ADDRESSES
):
return child_transfer.token_address, child_transfer.amount
return liquidation.inputs["_collateral"], 0

View File

@ -5,7 +5,6 @@ from pydantic import BaseModel
from .classified_traces import (
Classification,
ClassifiedTrace,
DecodedCallTrace,
Protocol,
)
@ -36,22 +35,6 @@ class EthTransfer(Transfer):
)
class aTokenTransfer(Transfer):
token_address: str
@classmethod
def from_trace(cls, trace: DecodedCallTrace) -> "aTokenTransfer":
return cls(
block_number=trace.block_number,
transaction_hash=trace.transaction_hash,
trace_address=trace.trace_address,
amount=trace.inputs["value"],
to_address=trace.inputs["to"],
from_address=trace.inputs["from"],
token_address=trace.to_address,
)
class ERC20Transfer(Transfer):
token_address: str