-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from bancorprotocol/42-b3_two_hop-arb-mode-res…
…ulting-in-losses-due-to-lack-of-data-validation Adds data validation to `b3_two_hop` mode by default.
- Loading branch information
Showing
26 changed files
with
3,633 additions
and
3,994 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ topaze | |
*.gif | ||
*.json | ||
|
||
.sourcery.yaml | ||
.DS_Store | ||
.idea/* | ||
.idea/modules.xml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"args": {"reserve0": 984915892997597, "reserve1": 7623238753074956607}, "event": "Sync", "logIndex": 303, "transactionIndex": 176, "transactionHash": "0x1aac951dd058168778d5e278e5055fe3246164e86431e2e1fcf131bb09c9a2f5", "address": "0xbe19C32B4CD202407e8eEB73e4E2949438461Ae3", "blockHash": "0x170ea019b162bb02315eb79bed861fa3758cfb798ff8263773d0b37a9afa9b89", "blockNumber": 17805789}, {"args": {"reserve0": 29940707366020, "reserve1": 15986480636095531285587}, "event": "Sync", "logIndex": 203, "transactionIndex": 125, "transactionHash": "0x73bffbb865696ec0974da3303c020e16e72e9a7529a5a982d8bfbebb15161ee1", "address": "0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc", "blockHash": "0x170ea019b162bb02315eb79bed861fa3758cfb798ff8263773d0b37a9afa9b89", "blockNumber": 17805789}, {"args": {"reserve0": 92268010355902189420181, "reserve1": 67150867012221180436}, "event": "Sync", "logIndex": 81, "transactionIndex": 53, "transactionHash": "0x5e40c742092cf4d428a36b8184e7e695ff9b361d1846714ed283ffcabbe633af", "address": "0x7825dE5586E4d2FD04459091bbe783fa243E1bf3", "blockHash": "0x170ea019b162bb02315eb79bed861fa3758cfb798ff8263773d0b37a9afa9b89", "blockNumber": 17805789}, {"args": {"reserve0": 2075897365998792292569, "reserve1": 28159850537826581922}, "event": "Sync", "logIndex": 64, "transactionIndex": 23, "transactionHash": "0x40228d3ab11b1f8caef5b72ad2c3f9aaafde07fb6e0066af63362a658f185f3d", "address": "0x56feAccb7f750B997B36A68625C7C596F0B41A58", "blockHash": "0xfac660eabe94f6e667916cf5ad4f5055458922fd12af9afa122f8a4518a46efb", "blockNumber": 17805788}, {"args": {"reserve0": 18841458115861660229, "reserve1": 440621902342402444540009318}, "event": "Sync", "logIndex": 266, "transactionIndex": 121, "transactionHash": "0x23b68fdb274e632849350e359f7eca45551cb48d1b61ad912ffac17a11a0c821", "address": "0x60a39010e4892b862d1bb6bdDe908215Ac5af6F3", "blockHash": "0xe2014e3d7138eb7eab4be2ab9f034662391bf053a16aac2ea64952e742cbde7e", "blockNumber": 17805787}, {"args": {"reserve0": 1987444095978300349610411, "reserve1": 171719984771536823693}, "event": "Sync", "logIndex": 242, "transactionIndex": 107, "transactionHash": "0xb24a762665ce5d9049d3c548b60d0710df2faff431bc794f154f665a0396caea", "address": "0xd8C1C327a7045B0fA27aa7e40Ea38c9aC52C1C13", "blockHash": "0xe2014e3d7138eb7eab4be2ab9f034662391bf053a16aac2ea64952e742cbde7e", "blockNumber": 17805787}, {"args": {"reserve0": 17155775813841714843776, "reserve1": 32219409385236}, "event": "Sync", "logIndex": 120, "transactionIndex": 46, "transactionHash": "0x67837340fd25da518d905677fb412a5a2dd0e142a6d975949664eadf1671f570", "address": "0x0d4a11d5EEaaC28EC3F61d100daF4d40471f1852", "blockHash": "0xe2014e3d7138eb7eab4be2ab9f034662391bf053a16aac2ea64952e742cbde7e", "blockNumber": 17805787}, {"args": {"reserve0": 569488821150808607303, "reserve1": 14495800016}, "event": "Sync", "logIndex": 107, "transactionIndex": 42, "transactionHash": "0x66fa4e899bf77cdcae71c5c7ba5cdf63c0abf817953a7712417132c6ef1aa24f", "address": "0x514906FC121c7878424a5C928cad1852CC545892", "blockHash": "0xe2014e3d7138eb7eab4be2ab9f034662391bf053a16aac2ea64952e742cbde7e", "blockNumber": 17805787}, {"args": {"reserve0": 13185887808642567645609476, "reserve1": 11223110447652764429}, "event": "Sync", "logIndex": 20, "transactionIndex": 3, "transactionHash": "0xb33069ef052a0409e2e8bda150d32a79869d47807ad7d0a6b073505f23985a76", "address": "0x67aed537eEBA768a07567cBa400489DDd4715Fa5", "blockHash": "0xe2014e3d7138eb7eab4be2ab9f034662391bf053a16aac2ea64952e742cbde7e", "blockNumber": 17805787}, {"args": {"reserve0": 1673359029633663, "reserve1": 609831018217025003505}, "event": "Sync", "logIndex": 167, "transactionIndex": 87, "transactionHash": "0x5f52c46f3cc8b09b84f848e57745fbafe9a4e253e5063b15d6b7714b5bed7f7e", "address": "0x2cC846fFf0b08FB3bFfaD71f53a60B4b6E6d6482", "blockHash": "0xdd9f2838ee952c6ba1bd86fd4fba3bb1d703cc9635b3c8040c73517464101476", "blockNumber": 17805786}, {"args": {"reserve0": 4199825380902928735406984385, "reserve1": 450985118034813734017}, "event": "Sync", "logIndex": 127, "transactionIndex": 74, "transactionHash": "0x2b5762c294b4d3dffdd66937730bb1d3b68f939e25d1c6baa844385df166ffcc", "address": "0xc6A45EcDC8bCEF94c476647be1303fd83D438cD0", "blockHash": "0xdd9f2838ee952c6ba1bd86fd4fba3bb1d703cc9635b3c8040c73517464101476", "blockNumber": 17805786}, {"args": {"reserve0": 1361477230294798219873473, "reserve1": 256198542693727576026}, "event": "Sync", "logIndex": 62, "transactionIndex": 9, "transactionHash": "0x684a17b3dc6c4ae078161198a8db3eef156a4ddc0860dd19dd9acf410ba3590e", "address": "0x9b7DaD79FC16106b47a3DAb791F389C167e15Eb0", "blockHash": "0xdd9f2838ee952c6ba1bd86fd4fba3bb1d703cc9635b3c8040c73517464101476", "blockNumber": 17805786}, {"args": {"reserve0": 18759976093858495798228598, "reserve1": 74155406144105097769}, "event": "Sync", "logIndex": 392, "transactionIndex": 148, "transactionHash": "0x808f27d5594f663cd8d2790ed81ee313c7f5b0a885b596f1ecdb2e03646b7104", "address": "0x87B958067FD665f3937de4439450B4950Eb68e15", "blockHash": "0x5c323f784cecbe7f9bfdbe6a5f3e43ae4a5288375e4079ca6d54c17292849a17", "blockNumber": 17805785}, {"args": {"reserve0": 91550537093485355400883, "reserve1": 187340170617735872969}, "event": "Sync", "logIndex": 193, "transactionIndex": 67, "transactionHash": "0xc7568a42f9f16cf7cd504eda491e5a6618be53562049a0c5017e5ace301d6efe", "address": "0x05767d9EF41dC40689678fFca0608878fb3dE906", "blockHash": "0x5c323f784cecbe7f9bfdbe6a5f3e43ae4a5288375e4079ca6d54c17292849a17", "blockNumber": 17805785}, {"args": {"reserve0": 180413102703478365987727, "reserve1": 66522823759623404926}, "event": "Sync", "logIndex": 56, "transactionIndex": 5, "transactionHash": "0x0b69daeef1018b23b0c31de4b877884a0dba0e629d5d3452002a942c26b11068", "address": "0xCE84867c3c02B05dc570d0135103d3fB9CC19433", "blockHash": "0x5c323f784cecbe7f9bfdbe6a5f3e43ae4a5288375e4079ca6d54c17292849a17", "blockNumber": 17805785}, {"args": {"sender": "0x92F3f71CeF740ED5784874B8C70Ff87ECdF33588", "recipient": "0x1111111254fb6c44bAC0beD2854e76F90643097d", "amount0": -1739493242500594860, "amount1": 4958296224, "sqrtPriceX96": 4224020051622363472625339, "liquidity": 458199188514823742, "tick": -196796}, "event": "Swap", "logIndex": 190, "transactionIndex": 121, "transactionHash": "0x51f82abfd09a87e47fbaa140d462df4aa90623731f3e2027581b606a44dd5867", "address": "0x08f68110f1e0Ca67C80a24B4Bd206675610f445D", "blockHash": "0x170ea019b162bb02315eb79bed861fa3758cfb798ff8263773d0b37a9afa9b89", "blockNumber": 17805789}, {"args": {"sender": "0xE592427A0AEce92De3Edee1F18E0157C05861564", "recipient": "0xcbF04EaC5a3443941CE6A41ff38D7E238406f0E4", "amount0": -49415894948820013438, "amount1": 1705902422381439744, "sqrtPriceX96": 14699216908678091626714211931, "liquidity": 1277138653211081126522, "tick": -33693}, "event": "Swap", "logIndex": 15, "transactionIndex": 3, "transactionHash": "0xe2877aa4eeee3e88c686a4396037adbbfe0b73744b43f3300230d0187ef7e60f", "address": "0x11B7a6bc0259ed6Cf9DB8F499988F9eCc7167bf5", "blockHash": "0x170ea019b162bb02315eb79bed861fa3758cfb798ff8263773d0b37a9afa9b89", "blockNumber": 17805789}, {"args": {"sender": "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD", "recipient": "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD", "amount0": 347700000000, "amount1": -611849448180004690, "sqrtPriceX96": 105424922620005800414225896484783, "liquidity": 118829016464869136, "tick": 143875}, "event": "Swap", "logIndex": 253, "transactionIndex": 103, "transactionHash": "0xebc32f7735265aa51cd086850b2b6e9408035a1bfa5bef91567b35c5d339c437", "address": "0xfE8C1aceE975592BdF5465F42364e5a5597e5004", "blockHash": "0xfac660eabe94f6e667916cf5ad4f5055458922fd12af9afa122f8a4518a46efb", "blockNumber": 17805788}, {"args": {"sender": "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD", "recipient": "0x34d82c9FEa23aA0D92574aFbAA4F3c3eFE905395", "amount0": -56605078041658310314393213, "amount1": 40000000000000000, "sqrtPriceX96": 2102954452085073506558130, "liquidity": 806400033269961586841676526, "tick": -210746}, "event": "Swap", "logIndex": 114, "transactionIndex": 47, "transactionHash": "0x088e6dc979739abb52d072b21eb04609ab82b28988c8610ebb1bd8d8364b5e27", "address": "0x11950d141EcB863F01007AdD7D1A342041227b58", "blockHash": "0xfac660eabe94f6e667916cf5ad4f5055458922fd12af9afa122f8a4518a46efb", "blockNumber": 17805788}, {"args": {"sender": "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", "recipient": "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", "amount0": 1030711460000000000, "amount1": -61945854719340793, "sqrtPriceX96": 19452041896685551475470626247, "liquidity": 12506375127173582573597, "tick": -28089}, "event": "Swap", "logIndex": 92, "transactionIndex": 38, "transactionHash": "0xb5cf81eeb7274aedb4f3961224ee699732faad5e6b07f24abc937854a74372e1", "address": "0x24EE2c6B9597F035088CDa8575E9D5e15a84B9DF", "blockHash": "0xfac660eabe94f6e667916cf5ad4f5055458922fd12af9afa122f8a4518a46efb", "blockNumber": 17805788}, {"args": {"sender": "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD", "recipient": "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD", "amount0": 300000000000000000000, "amount1": -234665168792452738, "sqrtPriceX96": 2218994442505082048529738608, "liquidity": 46081051035841935610169, "tick": -71510}, "event": "Swap", "logIndex": 4, "transactionIndex": 0, "transactionHash": "0x87a2f1aba8fda7e82ec589b8158cd5911a67329f36d6f8ab051eb8bdf3d9bd0e", "address": "0xb011e4EB4111ef00b620A5ed195836dCd69dB1FF", "blockHash": "0xfac660eabe94f6e667916cf5ad4f5055458922fd12af9afa122f8a4518a46efb", "blockNumber": 17805788}, {"args": {"sender": "0xfbEedCFe378866DaB6abbaFd8B2986F5C1768737", "recipient": "0xfbEedCFe378866DaB6abbaFd8B2986F5C1768737", "amount0": 7635905077886216000000, "amount1": -1433890539025418040, "sqrtPriceX96": 1086063779045237940313078701, "liquidity": 44978309692821762618535, "tick": -85800}, "event": "Swap", "logIndex": 69, "transactionIndex": 26, "transactionHash": "0xd03277a54a08f5ee3c4956d776ca63ec9b567e37fe9ad13265891ff39e439352", "address": "0x283E2E83b7f3e297C4B7c02114Ab0196B001a109", "blockHash": "0xe2014e3d7138eb7eab4be2ab9f034662391bf053a16aac2ea64952e742cbde7e", "blockNumber": 17805787}, {"args": {"sender": "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD", "recipient": "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD", "amount0": 7105458524672886907042, "amount1": -150000000000000000, "sqrtPriceX96": 365252464019109369794409820, "liquidity": 9818445383381187572191, "tick": -107596}, "event": "Swap", "logIndex": 315, "transactionIndex": 113, "transactionHash": "0x7f864b187689bc0e25feea449ddace24feb75e223433abc97d50bdc09adc54c5", "address": "0x7fb33DfFbb7eB142053aC1787eFB6C0Bb9178168", "blockHash": "0x5c323f784cecbe7f9bfdbe6a5f3e43ae4a5288375e4079ca6d54c17292849a17", "blockNumber": 17805785}, {"args": {"sender": "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD", "recipient": "0xc2ef1173a4B051BbCc4474c407BBb2ac7E02e363", "amount0": 540240780615055042, "amount1": -1012767644, "sqrtPriceX96": 3431222782168746837506863, "liquidity": 10262983856223310290, "tick": -200954}, "event": "Swap", "logIndex": 311, "transactionIndex": 111, "transactionHash": "0x0e8484e8efc90a99e016d4c973fe0d0b782844e84a33dd0974cf3ffdd1ddd901", "address": "0x11b815efB8f581194ae79006d24E0d814B7697F6", "blockHash": "0x5c323f784cecbe7f9bfdbe6a5f3e43ae4a5288375e4079ca6d54c17292849a17", "blockNumber": 17805785}, {"args": {"sender": "0x1111111254EEB25477B68fb85Ed929f73A960582", "recipient": "0xa7Ca2C8673bcFA5a26d8ceeC2887f2CC2b0Db22A", "amount0": -445175026364413852, "amount1": 33408920515, "sqrtPriceX96": 21689339444929437149678994, "liquidity": 74835646771732054, "tick": -164074}, "event": "Swap", "logIndex": 182, "transactionIndex": 63, "transactionHash": "0x35f8dd5f17d09bd02e953c8da044e04c4fbf8608bbd136c51b278ee432b8e543", "address": "0x127452F3f9cDc0389b0Bf59ce6131aA3Bd763598", "blockHash": "0x5c323f784cecbe7f9bfdbe6a5f3e43ae4a5288375e4079ca6d54c17292849a17", "blockNumber": 17805785}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# ------------------------------------------------------------ | ||
# Auto generated test file `test_903_FlashloanTokens.py` | ||
# ------------------------------------------------------------ | ||
# source file = NBTest_903_FlashloanTokens.py | ||
# test id = 903 | ||
# test comment = FlashloanTokens | ||
# ------------------------------------------------------------ | ||
|
||
|
||
|
||
""" | ||
This module contains the tests which ensure the the flashloan_tokens parameter is respected when using the b3_two_hop and bancor_v3 arb modes. | ||
""" | ||
from fastlane_bot import Bot | ||
from fastlane_bot.tools.cpc import ConstantProductCurve as CPC | ||
from fastlane_bot.events.exchanges import UniswapV2, UniswapV3, SushiswapV2, CarbonV1, BancorV3 | ||
import subprocess | ||
import pytest | ||
print("{0.__name__} v{0.__VERSION__} ({0.__DATE__})".format(CPC)) | ||
print("{0.__name__} v{0.__VERSION__} ({0.__DATE__})".format(Bot)) | ||
print("{0.__name__} v{0.__VERSION__} ({0.__DATE__})".format(UniswapV2)) | ||
print("{0.__name__} v{0.__VERSION__} ({0.__DATE__})".format(UniswapV3)) | ||
print("{0.__name__} v{0.__VERSION__} ({0.__DATE__})".format(SushiswapV2)) | ||
print("{0.__name__} v{0.__VERSION__} ({0.__DATE__})".format(CarbonV1)) | ||
print("{0.__name__} v{0.__VERSION__} ({0.__DATE__})".format(BancorV3)) | ||
from fastlane_bot.testing import * | ||
plt.rcParams['figure.figsize'] = [12,6] | ||
from fastlane_bot import __VERSION__ | ||
require("3.0", __VERSION__) | ||
|
||
|
||
|
||
|
||
def run_command(mode): | ||
import os | ||
import time | ||
import subprocess | ||
|
||
try: | ||
main_script_path = os.path.abspath(os.path.join(os.getcwd(), os.pardir, os.pardir, 'main.py')) | ||
cmd = [ | ||
"python", | ||
main_script_path, | ||
f"--arb_mode={mode}", | ||
"--default_min_profit_bnt=60", | ||
"--limit_bancor3_flashloan_tokens=True", | ||
"--use_cached_events=True", | ||
"--logging_path=fastlane_bot/data/", | ||
"--timeout=45" | ||
] | ||
except subprocess.CalledProcessError: | ||
main_script_path = os.path.abspath(os.path.join(os.getcwd(), os.pardir, 'main.py')) | ||
cmd = [ | ||
"python", | ||
main_script_path, | ||
f"--arb_mode={mode}", | ||
"--default_min_profit_bnt=60", | ||
"--limit_bancor3_flashloan_tokens=True", | ||
"--use_cached_events=True", | ||
"--logging_path=fastlane_bot/data/", | ||
"--timeout=45" | ||
] | ||
subprocess.Popen(cmd) | ||
|
||
start_time = time.time() | ||
expected_log_line = "limiting flashloan_tokens to [" | ||
result = subprocess.run(cmd, text=True, capture_output=True, check=True) | ||
|
||
found = expected_log_line in result.stderr | ||
if not found: | ||
pytest.fail("Expected log line was not found within 1 minute") # If we reach this point, the test has failed | ||
|
||
|
||
|
||
# ------------------------------------------------------------ | ||
# Test 903 | ||
# File test_903_FlashloanTokens.py | ||
# Segment Test Flashloan Tokens b3_two_hop | ||
# ------------------------------------------------------------ | ||
# def test_test_flashloan_tokens_b3_two_hop(): | ||
# # ------------------------------------------------------------ | ||
# | ||
run_command("b3_two_hop") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Searching for main.py in /Users/mikewcasale/Documents/GitHub/fastlane-bot |
Oops, something went wrong.