Add more detail to arbitrage test

This commit is contained in:
Luke Van Seters 2021-08-09 18:16:36 -04:00
parent 0f12b78e1e
commit d2bf2340a1

View File

@ -14,15 +14,16 @@ def test_two_pool_arbitrage(get_transaction_hashes, get_addresses):
account_address,
first_pool_address,
second_pool_address,
unrelated_pool_address,
first_token_address,
second_token_address,
] = get_addresses(5)
] = get_addresses(6)
first_token_in_amount = 10
first_token_out_amount = 10
second_token_amount = 15
swaps = [
arb_swaps = [
Swap(
abi_name=UNISWAP_V2_PAIR_ABI_NAME,
transaction_hash=transaction_hash,
@ -51,6 +52,34 @@ def test_two_pool_arbitrage(get_transaction_hashes, get_addresses):
),
]
unrelated_swap = Swap(
abi_name=UNISWAP_V3_POOL_ABI_NAME,
transaction_hash=transaction_hash,
block_number=block_number,
trace_address=[2, 0],
pool_address=unrelated_pool_address,
from_address=account_address,
to_address=account_address,
token_in_address=second_token_address,
token_in_amount=first_token_in_amount,
token_out_address=first_token_address,
token_out_amount=first_token_out_amount,
)
swaps = [
unrelated_swap,
*arb_swaps,
]
arbitrages = get_arbitrages(swaps)
assert len(arbitrages) == 1
arbitrage = arbitrages[0]
assert arbitrage.swaps == arb_swaps
assert arbitrage.account_address == account_address
assert arbitrage.profit_token_address == first_token_address
assert arbitrage.start_amount == first_token_in_amount
assert arbitrage.end_amount == first_token_out_amount
assert arbitrage.profit_amount == first_token_out_amount - first_token_in_amount