Merge pull request #223 from flashbots/aave-zero-bug
Support aave self-liquidations
This commit is contained in:
commit
de03b953a0
@ -36,13 +36,19 @@ def get_aave_liquidations(
|
|||||||
trace.transaction_hash, trace.trace_address, traces
|
trace.transaction_hash, trace.trace_address, traces
|
||||||
)
|
)
|
||||||
(debt_token_address, debt_purchase_amount) = _get_debt_data(
|
(debt_token_address, debt_purchase_amount) = _get_debt_data(
|
||||||
child_traces, liquidator
|
trace, child_traces, liquidator
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if debt_purchase_amount == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
(received_token_address, received_amount) = _get_received_data(
|
(received_token_address, received_amount) = _get_received_data(
|
||||||
child_traces, liquidator
|
trace, child_traces, liquidator
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if received_amount == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
liquidations.append(
|
liquidations.append(
|
||||||
Liquidation(
|
Liquidation(
|
||||||
liquidated_user=trace.inputs["_user"],
|
liquidated_user=trace.inputs["_user"],
|
||||||
@ -63,26 +69,26 @@ def get_aave_liquidations(
|
|||||||
|
|
||||||
|
|
||||||
def _get_received_data(
|
def _get_received_data(
|
||||||
child_traces: List[ClassifiedTrace], liquidator: str
|
liquidation_trace: DecodedCallTrace,
|
||||||
|
child_traces: List[ClassifiedTrace],
|
||||||
|
liquidator: str,
|
||||||
) -> Tuple[str, int]:
|
) -> Tuple[str, int]:
|
||||||
|
|
||||||
"""Look for and return liquidator payback from liquidation"""
|
"""Look for and return liquidator payback from liquidation"""
|
||||||
|
|
||||||
for child in child_traces:
|
for child in child_traces:
|
||||||
|
|
||||||
child_transfer: Optional[Transfer] = get_transfer(child)
|
child_transfer: Optional[Transfer] = get_transfer(child)
|
||||||
|
|
||||||
if child_transfer is not None:
|
if child_transfer is not None and child_transfer.to_address == liquidator:
|
||||||
|
return child_transfer.token_address, child_transfer.amount
|
||||||
|
|
||||||
if child_transfer.to_address == liquidator:
|
return liquidation_trace.inputs["_collateral"], 0
|
||||||
|
|
||||||
return child_transfer.token_address, child_transfer.amount
|
|
||||||
|
|
||||||
raise RuntimeError("Transfer from AAVE to liquidator not found!")
|
|
||||||
|
|
||||||
|
|
||||||
def _get_debt_data(
|
def _get_debt_data(
|
||||||
child_traces: List[ClassifiedTrace], liquidator: str
|
liquidation_trace: DecodedCallTrace,
|
||||||
|
child_traces: List[ClassifiedTrace],
|
||||||
|
liquidator: str,
|
||||||
) -> Tuple[str, int]:
|
) -> Tuple[str, int]:
|
||||||
"""Get transfer from liquidator to AAVE"""
|
"""Get transfer from liquidator to AAVE"""
|
||||||
|
|
||||||
@ -93,7 +99,9 @@ def _get_debt_data(
|
|||||||
if child_transfer is not None:
|
if child_transfer is not None:
|
||||||
|
|
||||||
if child_transfer.from_address == liquidator:
|
if child_transfer.from_address == liquidator:
|
||||||
|
|
||||||
return child_transfer.token_address, child_transfer.amount
|
return child_transfer.token_address, child_transfer.amount
|
||||||
|
|
||||||
raise RuntimeError("Transfer from liquidator to AAVE not found!")
|
return (
|
||||||
|
liquidation_trace.inputs["_reserve"],
|
||||||
|
0,
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user