WIP
This commit is contained in:
parent
771df11093
commit
db78372c3e
1
cache/12932986-new.json
vendored
Normal file
1
cache/12932986-new.json
vendored
Normal file
File diff suppressed because one or more lines are too long
1
cache/12972264-new.json
vendored
Normal file
1
cache/12972264-new.json
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -28,6 +28,7 @@ from typing import List, Optional
|
|||||||
|
|
||||||
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']
|
||||||
@ -50,9 +51,6 @@ def find_liquidations(traces: List[ClassifiedTrace]):
|
|||||||
liquidations.append(trace)
|
liquidations.append(trace)
|
||||||
addrs.append(trace.from_address)
|
addrs.append(trace.from_address)
|
||||||
tx.append(trace.transaction_hash)
|
tx.append(trace.transaction_hash)
|
||||||
print(f"\nLiquidation found: \n\t{trace.from_address}")
|
|
||||||
print(f"\nHash: \n\t{trace.transaction_hash}\n")
|
|
||||||
print(f"\nGas Used: {trace.gas_used}\n")
|
|
||||||
|
|
||||||
# Found liquidation, now parse inputs for data
|
# Found liquidation, now parse inputs for data
|
||||||
for i in trace.inputs:
|
for i in trace.inputs:
|
||||||
@ -61,11 +59,9 @@ def find_liquidations(traces: List[ClassifiedTrace]):
|
|||||||
liquidation_amount = trace.inputs[i]
|
liquidation_amount = trace.inputs[i]
|
||||||
elif (i == '_collateral'):
|
elif (i == '_collateral'):
|
||||||
collateral_type = trace.inputs[i]
|
collateral_type = trace.inputs[i]
|
||||||
print(f"Collateral type: {collateral_type}")
|
|
||||||
#This will be the address of the sent token
|
#This will be the address of the sent token
|
||||||
elif (i == '_reserve'):
|
elif (i == '_reserve'):
|
||||||
reserve = trace.inputs[i]
|
reserve = trace.inputs[i]
|
||||||
print(f"Reserve: {reserve}")
|
|
||||||
#This will be the address of the received token
|
#This will be the address of the received token
|
||||||
elif(i == '_user'):
|
elif(i == '_user'):
|
||||||
liquidated_usr = trace.inputs[i]
|
liquidated_usr = trace.inputs[i]
|
||||||
@ -76,8 +72,7 @@ def find_liquidations(traces: List[ClassifiedTrace]):
|
|||||||
collateral_source="",
|
collateral_source="",
|
||||||
reserve=reserve,
|
reserve=reserve,
|
||||||
strategy=StrategyType.liquidation,
|
strategy=StrategyType.liquidation,
|
||||||
traces=liquidations,
|
protocols=trace.protocol,)
|
||||||
protocols=[trace.protocol],)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check for transfer from a registered liquidator
|
# Check for transfer from a registered liquidator
|
||||||
@ -92,13 +87,6 @@ def find_liquidations(traces: List[ClassifiedTrace]):
|
|||||||
transfers_from.append(["from", liquidator, trace.transaction_hash, trace.inputs['amount']])
|
transfers_from.append(["from", liquidator, trace.transaction_hash, trace.inputs['amount']])
|
||||||
from_doubles.append(trace.transaction_hash)
|
from_doubles.append(trace.transaction_hash)
|
||||||
|
|
||||||
print(f"""
|
|
||||||
\nTransfer from liquidator {liquidator}:
|
|
||||||
\n\tAmount sent: {trace.inputs['amount']} to
|
|
||||||
\n\t{trace.inputs['recipient']}
|
|
||||||
\n\tTransaction: {trace.transaction_hash}\n
|
|
||||||
""")
|
|
||||||
|
|
||||||
# Check for transfer to a registered liquidator
|
# Check for transfer to a registered liquidator
|
||||||
elif (
|
elif (
|
||||||
trace.classification == Classification.transfer and
|
trace.classification == Classification.transfer and
|
||||||
@ -108,13 +96,6 @@ def find_liquidations(traces: List[ClassifiedTrace]):
|
|||||||
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']])
|
||||||
|
|
||||||
print(f"""
|
|
||||||
\nTransfer to liquidator {liquidator}:
|
|
||||||
\n\tAmount in received token: {trace.inputs['amount']} from
|
|
||||||
\n\t{trace.from_address}
|
|
||||||
\n\tTransaction: {trace.transaction_hash}\n
|
|
||||||
""")
|
|
||||||
|
|
||||||
for count, trace in enumerate(liquidations):
|
for count, trace in enumerate(liquidations):
|
||||||
tx = trace.transaction_hash
|
tx = trace.transaction_hash
|
||||||
#convert token to ETH
|
#convert token to ETH
|
||||||
@ -122,20 +103,17 @@ def find_liquidations(traces: List[ClassifiedTrace]):
|
|||||||
|
|
||||||
|
|
||||||
profits = []
|
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]})
|
||||||
|
|
||||||
print(profits)
|
|
||||||
print(liquidations)
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
rpc = 'http://162.55.96.141:8546/'
|
rpc = 'http://162.55.96.141:8546/'
|
||||||
block_number = 12498502
|
block_number = 12972264
|
||||||
base_provider = Web3.HTTPProvider(rpc)
|
base_provider = Web3.HTTPProvider(rpc)
|
||||||
block_data = block.create_from_block_number(block_number, base_provider)
|
block_data = block.create_from_block_number(block_number, base_provider)
|
||||||
trace_clasifier = TraceClassifier(CLASSIFIER_SPECS)
|
trace_clasifier = TraceClassifier(CLASSIFIER_SPECS)
|
||||||
classified_traces = trace_clasifier.classify(block_data.traces)
|
classified_traces = trace_clasifier.classify(block_data.traces)
|
||||||
fin = find_liquidations(classified_traces)
|
fin = print(find_liquidations(classified_traces))
|
||||||
|
@ -9,7 +9,6 @@ class StrategyType(Enum):
|
|||||||
|
|
||||||
class Strategy(BaseModel):
|
class Strategy(BaseModel):
|
||||||
strategy: StrategyType
|
strategy: StrategyType
|
||||||
traces: List[ClassifiedTrace]
|
|
||||||
protocols: List[Protocol]
|
protocols: List[Protocol]
|
||||||
|
|
||||||
class Liquidation(Strategy):
|
class Liquidation(Strategy):
|
||||||
@ -20,3 +19,4 @@ class Liquidation(Strategy):
|
|||||||
|
|
||||||
class LiquidationData(Liquidation):
|
class LiquidationData(Liquidation):
|
||||||
profit: float
|
profit: float
|
||||||
|
traces: List[ClassifiedTrace]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user