Added data types
This commit is contained in:
parent
1201623c1f
commit
790fbee002
@ -26,6 +26,7 @@ class LiquidationInspector(StrategyInspector):
|
|||||||
# For each trace
|
# For each trace
|
||||||
for i in range(1, len(traces)):
|
for i in range(1, len(traces)):
|
||||||
trace = traces[i]
|
trace = traces[i]
|
||||||
|
next = traces[i+1]
|
||||||
|
|
||||||
# Liquidation condition
|
# Liquidation condition
|
||||||
if trace.classification == Classification.liquidate:
|
if trace.classification == Classification.liquidate:
|
||||||
@ -34,8 +35,8 @@ class LiquidationInspector(StrategyInspector):
|
|||||||
# The inputs will differ by DEX, this is AAVE
|
# The inputs will differ by DEX, this is AAVE
|
||||||
|
|
||||||
for i in trace.inputs:
|
for i in trace.inputs:
|
||||||
if( i["name"] == '_purchaseAmount'):
|
if(i["name"] == '_purchaseAmount'):
|
||||||
value = trace.inputs[i]
|
liquidation_amount = trace.inputs[i]
|
||||||
elif (i["name"] == '_collateral'):
|
elif (i["name"] == '_collateral'):
|
||||||
collateral_type = trace.inputs[i]
|
collateral_type = trace.inputs[i]
|
||||||
elif (i["name"] == '_reserve'):
|
elif (i["name"] == '_reserve'):
|
||||||
@ -46,10 +47,14 @@ class LiquidationInspector(StrategyInspector):
|
|||||||
liquidator = trace.from_address
|
liquidator = trace.from_address
|
||||||
|
|
||||||
# Find a transfer before liquidation with a to_address corresponding to the liquidator
|
# Find a transfer before liquidation with a to_address corresponding to the liquidator
|
||||||
for trace in traces[:i]:
|
for tx in traces:
|
||||||
if (trace.classification == Classification.transfer & trace.to_address == liquidator):
|
if (tx.classification == Classification.transfer & tx.to_address == liquidator):
|
||||||
profit =
|
|
||||||
#Calculate profit
|
#Calculate profit
|
||||||
|
amount_sent = tx.value
|
||||||
|
amount_received = next.value
|
||||||
|
profit = amount_received - amount_sent
|
||||||
|
# Add gas used*price and coinbase check
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Tag liquidation
|
# Tag liquidation
|
||||||
|
22
mev_inspect/schemas/strategy.py
Normal file
22
mev_inspect/schemas/strategy.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
from typing import Optional
|
||||||
|
from enum import Enum
|
||||||
|
from pydantic import BaseModel
|
||||||
|
from .classified_traces import ClassifiedTrace, Protocol
|
||||||
|
|
||||||
|
class StrategyType(Enum):
|
||||||
|
arbitrage = "arbitrage"
|
||||||
|
liquidation = "liquidation"
|
||||||
|
|
||||||
|
class Strategy(BaseModel):
|
||||||
|
strategy: StrategyType
|
||||||
|
traces: List[ClassifiedTrace]
|
||||||
|
protocols: List[Protocol]
|
||||||
|
|
||||||
|
class Liquidation(Strategy):
|
||||||
|
collateral_type: str
|
||||||
|
collateral_amount: int
|
||||||
|
collateral_source: str
|
||||||
|
profit: int
|
||||||
|
|
||||||
|
class Arbitrage(Strategy):
|
||||||
|
# strategy: Literal[StrategyType.arbitrage]
|
Loading…
x
Reference in New Issue
Block a user