Add assertion and move constants up
This commit is contained in:
parent
d7872db45c
commit
c334441e95
@ -5,6 +5,7 @@ from mev_inspect.schemas.transfers import Transfer, ETH_TOKEN_ADDRESS
|
|||||||
|
|
||||||
from mev_inspect.schemas.traces import DecodedCallTrace, ClassifiedTrace
|
from mev_inspect.schemas.traces import DecodedCallTrace, ClassifiedTrace
|
||||||
|
|
||||||
|
ANY_TAKER_ADDRESS = "0x0000000000000000000000000000000000000000"
|
||||||
|
|
||||||
RFQ_SIGNATURES = [
|
RFQ_SIGNATURES = [
|
||||||
"fillRfqOrder((address,address,uint128,uint128,address,address,address,bytes32,uint64,uint256),(uint8,uint8,bytes32,bytes32),uint128)",
|
"fillRfqOrder((address,address,uint128,uint128,address,address,address,bytes32,uint64,uint256),(uint8,uint8,bytes32,bytes32),uint128)",
|
||||||
@ -114,6 +115,8 @@ def is_valid_0x_swap(
|
|||||||
f"0x orderbook function {trace.function_signature} is not supported"
|
f"0x orderbook function {trace.function_signature} is not supported"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# 3. The swap should not be a child of previous swaps in the block
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@ -121,9 +124,7 @@ def _get_taker_token_in_amount(
|
|||||||
taker_address: str, token_in_address: str, child_transfers: List[Transfer]
|
taker_address: str, token_in_address: str, child_transfers: List[Transfer]
|
||||||
) -> int:
|
) -> int:
|
||||||
|
|
||||||
ANY_TAKER = "0x0000000000000000000000000000000000000000"
|
if taker_address == ANY_TAKER_ADDRESS:
|
||||||
|
|
||||||
if taker_address == ANY_TAKER:
|
|
||||||
for transfer in child_transfers:
|
for transfer in child_transfers:
|
||||||
if transfer.token_address == token_in_address:
|
if transfer.token_address == token_in_address:
|
||||||
return transfer.amount
|
return transfer.amount
|
||||||
|
@ -34,6 +34,7 @@ def test_fillLimitOrder_swap():
|
|||||||
result = get_swaps(classified_traces)
|
result = get_swaps(classified_traces)
|
||||||
|
|
||||||
assert swap in result
|
assert swap in result
|
||||||
|
assert result.count(swap) == 1
|
||||||
|
|
||||||
|
|
||||||
def test__fillLimitOrder_swap():
|
def test__fillLimitOrder_swap():
|
||||||
@ -65,6 +66,7 @@ def test__fillLimitOrder_swap():
|
|||||||
result = get_swaps(classified_traces)
|
result = get_swaps(classified_traces)
|
||||||
|
|
||||||
assert swap in result
|
assert swap in result
|
||||||
|
assert result.count(swap) == 1
|
||||||
|
|
||||||
|
|
||||||
def test_RfqLimitOrder_swap():
|
def test_RfqLimitOrder_swap():
|
||||||
@ -96,6 +98,7 @@ def test_RfqLimitOrder_swap():
|
|||||||
result = get_swaps(classified_traces)
|
result = get_swaps(classified_traces)
|
||||||
|
|
||||||
assert swap in result
|
assert swap in result
|
||||||
|
assert result.count(swap) == 1
|
||||||
|
|
||||||
|
|
||||||
def test__RfqLimitOrder_swap():
|
def test__RfqLimitOrder_swap():
|
||||||
@ -127,3 +130,4 @@ def test__RfqLimitOrder_swap():
|
|||||||
result = get_swaps(classified_traces)
|
result = get_swaps(classified_traces)
|
||||||
|
|
||||||
assert swap in result
|
assert swap in result
|
||||||
|
assert result.count(swap) == 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user