WIP
This commit is contained in:
parent
db78372c3e
commit
25fc22e576
1
cache/13002906-new.json
vendored
Normal file
1
cache/13002906-new.json
vendored
Normal file
File diff suppressed because one or more lines are too long
1
cache/13004256-new.json
vendored
Normal file
1
cache/13004256-new.json
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -18,20 +18,13 @@ from typing import List, Optional
|
|||||||
# TODO: adjust profit to new model
|
# TODO: adjust profit to new model
|
||||||
# unit test
|
# unit test
|
||||||
# coinbase check / collateral source
|
# coinbase check / collateral source
|
||||||
#
|
|
||||||
#
|
|
||||||
# Block inspect
|
|
||||||
# poetry run inspect -b 12498502 -r 'http://162.55.96.141:8546/'
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
|
|
||||||
liquidations = []
|
liquidations = []
|
||||||
result = []
|
result = []
|
||||||
final = []
|
|
||||||
|
|
||||||
# Protocol contract address must be in included, below is AaveLendingPoolCoreV1
|
# Protocol contract address must be in included, below is AaveLendingPoolCoreV1
|
||||||
addrs = ['0x3dfd23A6c5E8BbcFc9581d2E864a68feb6a076d3']
|
addrs = ['0x3dfd23A6c5E8BbcFc9581d2E864a68feb6a076d3']
|
||||||
|
# Used to remove double-counted 'from' transfers
|
||||||
from_doubles = []
|
from_doubles = []
|
||||||
transfers_to = []
|
transfers_to = []
|
||||||
transfers_from = []
|
transfers_from = []
|
||||||
@ -72,10 +65,10 @@ def find_liquidations(traces: List[ClassifiedTrace]):
|
|||||||
collateral_source="",
|
collateral_source="",
|
||||||
reserve=reserve,
|
reserve=reserve,
|
||||||
strategy=StrategyType.liquidation,
|
strategy=StrategyType.liquidation,
|
||||||
protocols=trace.protocol,)
|
protocols=[trace.protocol],)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check for transfer from a registered liquidator
|
# Check for transfer from a liquidator
|
||||||
elif (
|
elif (
|
||||||
trace.classification == Classification.transfer and
|
trace.classification == Classification.transfer and
|
||||||
'sender' in trace.inputs and
|
'sender' in trace.inputs and
|
||||||
@ -83,18 +76,19 @@ def find_liquidations(traces: List[ClassifiedTrace]):
|
|||||||
trace.transaction_hash not in from_doubles
|
trace.transaction_hash not in from_doubles
|
||||||
):
|
):
|
||||||
|
|
||||||
liquidator = next(addrs[i] for i in range(len(addrs)) if trace.inputs['sender'] == addrs[i])
|
#Add the transfer
|
||||||
transfers_from.append(["from", liquidator, trace.transaction_hash, trace.inputs['amount']])
|
liquidator = next(addrs[i] for i in range(len(addrs)) if trace.inputs['sender'] == addrs[i])
|
||||||
from_doubles.append(trace.transaction_hash)
|
transfers_from.append(["from", liquidator, trace.transaction_hash, trace.inputs['amount']])
|
||||||
|
from_doubles.append(trace.transaction_hash)
|
||||||
|
|
||||||
# Check for transfer to a registered liquidator
|
# Check for transfer to a liquidator
|
||||||
elif (
|
elif (
|
||||||
trace.classification == Classification.transfer and
|
trace.classification == Classification.transfer and
|
||||||
trace.inputs['recipient'] in addrs
|
trace.inputs['recipient'] in addrs
|
||||||
):
|
):
|
||||||
|
#Add the transfer
|
||||||
liquidator = next(addrs[i] for i in range(len(addrs)) if trace.inputs['recipient'] == addrs[i])
|
liquidator = next(addrs[i] for i in range(len(addrs)) if trace.inputs['recipient'] == addrs[i])
|
||||||
transfers_to.append(["to", liquidator, trace.transaction_hash, trace.inputs['amount']])
|
transfers_to.append(["to", liquidator, trace.transaction_hash, trace.inputs['amount']])
|
||||||
|
|
||||||
for count, trace in enumerate(liquidations):
|
for count, trace in enumerate(liquidations):
|
||||||
tx = trace.transaction_hash
|
tx = trace.transaction_hash
|
||||||
@ -102,18 +96,10 @@ def find_liquidations(traces: List[ClassifiedTrace]):
|
|||||||
#profit = transfers[count][2] - transfers[count+1][2]
|
#profit = transfers[count][2] - transfers[count+1][2]
|
||||||
|
|
||||||
|
|
||||||
profits = []
|
|
||||||
#for count, trace in enumerate(transfers_to):
|
#for count, trace in enumerate(transfers_to):
|
||||||
#profits.append({"liquidator" : transfers_to[count][1],
|
#profits.append({"liquidator" : transfers_to[count][1],
|
||||||
#"transaction" : transfers_to[count][2],
|
#"transaction" : transfers_to[count][2],
|
||||||
#"profit" : transfers_to[count][3] - transfers_from[count][3]})
|
#"profit" : transfers_to[count][3] - transfers_from[count][3]})
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
rpc = 'http://162.55.96.141:8546/'
|
|
||||||
block_number = 12972264
|
|
||||||
base_provider = Web3.HTTPProvider(rpc)
|
|
||||||
block_data = block.create_from_block_number(block_number, base_provider)
|
|
||||||
trace_clasifier = TraceClassifier(CLASSIFIER_SPECS)
|
|
||||||
classified_traces = trace_clasifier.classify(block_data.traces)
|
|
||||||
fin = print(find_liquidations(classified_traces))
|
|
||||||
|
@ -20,12 +20,10 @@ def get_abi(abi_name: str, protocol: Optional[Protocol]) -> Optional[ABI]:
|
|||||||
if protocol is None
|
if protocol is None
|
||||||
else ABI_DIRECTORY_PATH / protocol.value / abi_filename
|
else ABI_DIRECTORY_PATH / protocol.value / abi_filename
|
||||||
)
|
)
|
||||||
#import pdb; pdb.set_trace()
|
|
||||||
if abi_path.is_file():
|
if abi_path.is_file():
|
||||||
with abi_path.open() as abi_file:
|
with abi_path.open() as abi_file:
|
||||||
abi_json = json.load(abi_file)
|
abi_json = json.load(abi_file)
|
||||||
return parse_obj_as(ABI, abi_json)
|
return parse_obj_as(ABI, abi_json)
|
||||||
|
|
||||||
import pdb; pdb.set_trace()
|
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
@ -111,9 +111,7 @@ AAVE_CONTRACT_SPECS = [
|
|||||||
protocol= Protocol.aave,
|
protocol= Protocol.aave,
|
||||||
valid_contract_addresses=['0x24a42fD28C976A61Df5D00D0599C34c4f90748c8'],
|
valid_contract_addresses=['0x24a42fD28C976A61Df5D00D0599C34c4f90748c8'],
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASSIFIER_SPECS = [
|
CLASSIFIER_SPECS = [
|
||||||
|
@ -19,6 +19,7 @@ class Protocol(Enum):
|
|||||||
uniswap_v3 = "uniswap_v3"
|
uniswap_v3 = "uniswap_v3"
|
||||||
sushiswap = "sushiswap"
|
sushiswap = "sushiswap"
|
||||||
aave = "aave"
|
aave = "aave"
|
||||||
|
balancer = "balancer"
|
||||||
|
|
||||||
|
|
||||||
class ClassifiedTrace(BaseModel):
|
class ClassifiedTrace(BaseModel):
|
||||||
|
@ -4,12 +4,12 @@ from pydantic import BaseModel
|
|||||||
from .classified_traces import ClassifiedTrace, Protocol
|
from .classified_traces import ClassifiedTrace, Protocol
|
||||||
|
|
||||||
class StrategyType(Enum):
|
class StrategyType(Enum):
|
||||||
arbitrage = "arbitrage"
|
arbitrage = "arbitrage"
|
||||||
liquidation = "liquidation"
|
liquidation = "liquidation"
|
||||||
|
|
||||||
class Strategy(BaseModel):
|
class Strategy(BaseModel):
|
||||||
strategy: StrategyType
|
strategy: StrategyType
|
||||||
protocols: List[Protocol]
|
protocols: List[Protocol]
|
||||||
|
|
||||||
class Liquidation(Strategy):
|
class Liquidation(Strategy):
|
||||||
collateral_type: str
|
collateral_type: str
|
||||||
@ -19,4 +19,4 @@ class Liquidation(Strategy):
|
|||||||
|
|
||||||
class LiquidationData(Liquidation):
|
class LiquidationData(Liquidation):
|
||||||
profit: float
|
profit: float
|
||||||
traces: List[ClassifiedTrace]
|
traces: List[ClassifiedTrace]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user