From 0f12b78e1ec719470fb01f27245ac47c2d91e66e Mon Sep 17 00:00:00 2001 From: Luke Van Seters Date: Mon, 9 Aug 2021 18:10:46 -0400 Subject: [PATCH] Add arbitrage test --- tests/test_arbitrages.py | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tests/test_arbitrages.py diff --git a/tests/test_arbitrages.py b/tests/test_arbitrages.py new file mode 100644 index 0000000..9920b8a --- /dev/null +++ b/tests/test_arbitrages.py @@ -0,0 +1,56 @@ +from mev_inspect.arbitrage import get_arbitrages +from mev_inspect.schemas.swaps import Swap +from mev_inspect.swaps import ( + UNISWAP_V2_PAIR_ABI_NAME, + UNISWAP_V3_POOL_ABI_NAME, +) + + +def test_two_pool_arbitrage(get_transaction_hashes, get_addresses): + block_number = 123 + [transaction_hash] = get_transaction_hashes(1) + + [ + account_address, + first_pool_address, + second_pool_address, + first_token_address, + second_token_address, + ] = get_addresses(5) + + first_token_in_amount = 10 + first_token_out_amount = 10 + second_token_amount = 15 + + swaps = [ + Swap( + abi_name=UNISWAP_V2_PAIR_ABI_NAME, + transaction_hash=transaction_hash, + block_number=block_number, + trace_address=[0], + pool_address=first_pool_address, + from_address=account_address, + to_address=second_pool_address, + token_in_address=first_token_address, + token_in_amount=first_token_in_amount, + token_out_address=second_token_address, + token_out_amount=second_token_amount, + ), + Swap( + abi_name=UNISWAP_V3_POOL_ABI_NAME, + transaction_hash=transaction_hash, + block_number=block_number, + trace_address=[1], + pool_address=second_pool_address, + from_address=first_pool_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, + ), + ] + + arbitrages = get_arbitrages(swaps) + + assert len(arbitrages) == 1