Add transaction position to Swap and ClassifiedTrace schemas - weave throughout
This commit is contained in:
parent
54a6023464
commit
8a8c85b73b
@ -41,6 +41,7 @@ def create_swap_from_transfers(
|
||||
return Swap(
|
||||
abi_name=trace.abi_name,
|
||||
transaction_hash=trace.transaction_hash,
|
||||
transaction_position=trace.transaction_position,
|
||||
block_number=trace.block_number,
|
||||
trace_address=trace.trace_address,
|
||||
contract_address=pool_address,
|
||||
|
@ -40,6 +40,7 @@ class ZeroExSwapClassifier(SwapClassifier):
|
||||
return Swap(
|
||||
abi_name=trace.abi_name,
|
||||
transaction_hash=trace.transaction_hash,
|
||||
transaction_position=trace.transaction_position,
|
||||
block_number=trace.block_number,
|
||||
trace_address=trace.trace_address,
|
||||
contract_address=trace.to_address,
|
||||
|
@ -28,6 +28,7 @@ def write_classified_traces(
|
||||
models.append(
|
||||
ClassifiedTraceModel(
|
||||
transaction_hash=trace.transaction_hash,
|
||||
transaction_position=trace.transaction_position,
|
||||
block_number=trace.block_number,
|
||||
classification=trace.classification.value,
|
||||
trace_type=trace.type.value,
|
||||
|
@ -8,6 +8,7 @@ class SwapModel(Base):
|
||||
|
||||
abi_name = Column(String, nullable=False)
|
||||
transaction_hash = Column(String, primary_key=True)
|
||||
transaction_position = Column(Numeric, nullable=True) # TODO - backfill
|
||||
block_number = Column(Numeric, nullable=False)
|
||||
trace_address = Column(ARRAY(Integer), nullable=False)
|
||||
protocol = Column(String, nullable=True)
|
||||
|
@ -7,6 +7,7 @@ class ClassifiedTraceModel(Base):
|
||||
__tablename__ = "classified_traces"
|
||||
|
||||
transaction_hash = Column(String, primary_key=True)
|
||||
transaction_position = Column(Numeric, nullable=True)
|
||||
block_number = Column(Numeric, nullable=False)
|
||||
classification = Column(String, nullable=False)
|
||||
trace_type = Column(String, nullable=False)
|
||||
|
@ -8,6 +8,7 @@ from mev_inspect.schemas.traces import Protocol
|
||||
class Swap(BaseModel):
|
||||
abi_name: str
|
||||
transaction_hash: str
|
||||
transaction_position: int
|
||||
block_number: int
|
||||
trace_address: List[int]
|
||||
contract_address: str
|
||||
|
@ -57,6 +57,7 @@ class ClassifiedTrace(Trace):
|
||||
value: Optional[int]
|
||||
gas_used: Optional[int]
|
||||
transaction_hash: str
|
||||
transaction_position: int
|
||||
protocol: Optional[Protocol]
|
||||
function_name: Optional[str]
|
||||
function_signature: Optional[str]
|
||||
|
@ -20,6 +20,7 @@ def make_transfer_trace(
|
||||
):
|
||||
return DecodedCallTrace(
|
||||
transaction_hash=transaction_hash,
|
||||
transaction_position=0,
|
||||
block_number=block_number,
|
||||
type=TraceType.call,
|
||||
trace_address=trace_address,
|
||||
@ -53,6 +54,7 @@ def make_swap_trace(
|
||||
):
|
||||
return DecodedCallTrace(
|
||||
transaction_hash=transaction_hash,
|
||||
transaction_position=0,
|
||||
block_number=block_number,
|
||||
type=TraceType.call,
|
||||
trace_address=trace_address,
|
||||
@ -78,6 +80,7 @@ def make_unknown_trace(
|
||||
return ClassifiedTrace(
|
||||
block_number=block_number,
|
||||
transaction_hash=transaction_hash,
|
||||
transaction_position=0,
|
||||
trace_address=trace_address,
|
||||
action={},
|
||||
subtraces=0,
|
||||
|
@ -11,10 +11,12 @@ def test_fillLimitOrder_swap():
|
||||
"0xa043976d736ec8dc930c0556dffd0a86a4bfc80bf98fb7995c791fb4dc488b5d"
|
||||
)
|
||||
block_number = 13666312
|
||||
transaction_position = 0
|
||||
|
||||
swap = Swap(
|
||||
abi_name="INativeOrdersFeature",
|
||||
transaction_hash=transaction_hash,
|
||||
transaction_position=transaction_position,
|
||||
block_number=block_number,
|
||||
trace_address=[0, 2, 0, 1],
|
||||
contract_address="0xdef1c0ded9bec7f1a1670819833240f027b25eff",
|
||||
@ -42,10 +44,12 @@ def test__fillLimitOrder_swap():
|
||||
"0x9255addffa2dbeb9560c5e20e78a78c949488d2054c70b2155c39f9e28394cbf"
|
||||
)
|
||||
block_number = 13666184
|
||||
transaction_position = 0
|
||||
|
||||
swap = Swap(
|
||||
abi_name="INativeOrdersFeature",
|
||||
transaction_hash=transaction_hash,
|
||||
transaction_position=transaction_position,
|
||||
block_number=block_number,
|
||||
trace_address=[0, 1],
|
||||
contract_address="0xdef1c0ded9bec7f1a1670819833240f027b25eff",
|
||||
@ -73,10 +77,12 @@ def test_RfqLimitOrder_swap():
|
||||
"0x1c948eb7c59ddbe6b916cf68f5df86eb44a7c9e728221fcd8ab750f137fd2a0f"
|
||||
)
|
||||
block_number = 13666326
|
||||
transaction_position = 0
|
||||
|
||||
swap = Swap(
|
||||
abi_name="INativeOrdersFeature",
|
||||
transaction_hash=transaction_hash,
|
||||
transaction_position=transaction_position,
|
||||
block_number=block_number,
|
||||
trace_address=[0, 1, 13, 0, 1],
|
||||
contract_address="0xdef1c0ded9bec7f1a1670819833240f027b25eff",
|
||||
@ -104,10 +110,12 @@ def test__RfqLimitOrder_swap():
|
||||
"0x4f66832e654f8a4d773d9769571155df3722401343247376d6bb56626db29b90"
|
||||
)
|
||||
block_number = 13666363
|
||||
transaction_position = 0
|
||||
|
||||
swap = Swap(
|
||||
abi_name="INativeOrdersFeature",
|
||||
transaction_hash=transaction_hash,
|
||||
transaction_position=transaction_position,
|
||||
block_number=block_number,
|
||||
trace_address=[1, 0, 1, 0, 1],
|
||||
contract_address="0xdef1c0ded9bec7f1a1670819833240f027b25eff",
|
||||
|
@ -25,11 +25,13 @@ def test_two_pool_arbitrage(get_transaction_hashes, get_addresses):
|
||||
first_token_in_amount = 10
|
||||
first_token_out_amount = 11
|
||||
second_token_amount = 15
|
||||
transaction_position = 0
|
||||
|
||||
arb_swaps = [
|
||||
Swap(
|
||||
abi_name=UNISWAP_V2_PAIR_ABI_NAME,
|
||||
transaction_hash=transaction_hash,
|
||||
transaction_position=transaction_position,
|
||||
block_number=block_number,
|
||||
trace_address=[0],
|
||||
contract_address=first_pool_address,
|
||||
@ -43,6 +45,7 @@ def test_two_pool_arbitrage(get_transaction_hashes, get_addresses):
|
||||
Swap(
|
||||
abi_name=UNISWAP_V3_POOL_ABI_NAME,
|
||||
transaction_hash=transaction_hash,
|
||||
transaction_position=transaction_position,
|
||||
block_number=block_number,
|
||||
trace_address=[1],
|
||||
contract_address=second_pool_address,
|
||||
@ -58,6 +61,7 @@ def test_two_pool_arbitrage(get_transaction_hashes, get_addresses):
|
||||
unrelated_swap = Swap(
|
||||
abi_name=UNISWAP_V3_POOL_ABI_NAME,
|
||||
transaction_hash=transaction_hash,
|
||||
transaction_position=transaction_position,
|
||||
block_number=block_number,
|
||||
trace_address=[2, 0],
|
||||
contract_address=unrelated_pool_address,
|
||||
@ -106,11 +110,13 @@ def test_three_pool_arbitrage(get_transaction_hashes, get_addresses):
|
||||
first_token_out_amount = 11
|
||||
second_token_amount = 15
|
||||
third_token_amount = 40
|
||||
transaction_position = 0
|
||||
|
||||
swaps = [
|
||||
Swap(
|
||||
abi_name=UNISWAP_V2_PAIR_ABI_NAME,
|
||||
transaction_hash=transaction_hash,
|
||||
transaction_position=transaction_position,
|
||||
block_number=block_number,
|
||||
trace_address=[0],
|
||||
contract_address=first_pool_address,
|
||||
@ -124,6 +130,7 @@ def test_three_pool_arbitrage(get_transaction_hashes, get_addresses):
|
||||
Swap(
|
||||
abi_name=UNISWAP_V3_POOL_ABI_NAME,
|
||||
transaction_hash=transaction_hash,
|
||||
transaction_position=transaction_position,
|
||||
block_number=block_number,
|
||||
trace_address=[1],
|
||||
contract_address=second_pool_address,
|
||||
@ -137,6 +144,7 @@ def test_three_pool_arbitrage(get_transaction_hashes, get_addresses):
|
||||
Swap(
|
||||
abi_name=UNISWAP_V3_POOL_ABI_NAME,
|
||||
transaction_hash=transaction_hash,
|
||||
transaction_position=transaction_position,
|
||||
block_number=block_number,
|
||||
trace_address=[2],
|
||||
contract_address=third_pool_address,
|
||||
@ -218,6 +226,7 @@ def create_generic_swap(
|
||||
return Swap(
|
||||
abi_name=UNISWAP_V3_POOL_ABI_NAME,
|
||||
transaction_hash="0xfake",
|
||||
transaction_position=0,
|
||||
block_number=0,
|
||||
trace_address=trace_address,
|
||||
contract_address="0xfake",
|
||||
|
Loading…
x
Reference in New Issue
Block a user