-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds deterministic testing for Ethereum
- Loading branch information
1 parent
4346089
commit 5917f2f
Showing
14 changed files
with
2,067 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
6 changes: 6 additions & 0 deletions
6
fastlane_bot/tests/deterministic/_data/static_pool_data_testing.csv
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,6 @@ | ||
cid,last_updated,last_updated_block,descr,pair_name,exchange_name,fee,fee_float,address,anchor,tkn0_address,tkn1_address,tkn0_decimals,tkn1_decimals,exchange_id,tkn0_symbol,tkn1_symbol,timestamp,tkn0_balance,tkn1_balance,liquidity,sqrt_price_q96,tick,tick_spacing,exchange,pool_type,tkn0_weight,tkn1_weight,tkn2_address,tkn2_decimals,tkn2_symbol,tkn2_balance,tkn2_weight,tkn3_address,tkn3_decimals,tkn3_symbol,tkn3_balance,tkn3_weight,tkn4_address,tkn4_decimals,tkn4_symbol,tkn4_balance,tkn4_weight,tkn5_address,tkn5_decimals,tkn5_symbol,tkn5_balance,tkn5_weight,tkn6_address,tkn6_decimals,tkn6_symbol,tkn6_balance,tkn6_weight,tkn7_address,tkn7_decimals,tkn7_symbol,tkn7_balance,tkn7_weight,test,exchange_type,pool_address,tkn0_setBalance,tkn1_setBalance,slots,param_lists,param_blockTimestampLast,param_blockTimestampLast_type,param_reserve0,param_reserve0_type,param_reserve1,param_reserve1_type,param_liquidity,param_liquidity_type,param_sqrtPriceX96,param_sqrtPriceX96_type,param_tick,param_tick_type,param_observationIndex,param_observationIndex_type,param_observationCardinality,param_observationCardinality_type,param_observationCardinalityNext,param_observationCardinalityNext_type,param_feeProtocol,param_feeProtocol_type,param_unlocked,param_unlocked_type | ||
,,0,uniswap_v2 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 0.003,0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2,uniswap_v2,3000,0.003,0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc,,0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48,0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2,6,18,3,USDC,WETH,,,,,,,60,uniswap_v2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,uniswap_v2,0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc,49204613674917,21734090459912674200000,"[8,]","[['blockTimestampLast','reserve1','reserve0'],]",,uint32,49204613674917,uint112,21734090459912674200000,uint112,,,,,,,,,,,,,,,, | ||
,,0,uniswap_v3 0x514910771AF9Ca656af840dff83E8264EcF986CA/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 0.003,0x514910771AF9Ca656af840dff83E8264EcF986CA/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2,uniswap_v3,3000,0.003,0xa6Cc3C2531FdaA6Ae1A3CA84c2855806728693e8,,0x514910771AF9Ca656af840dff83E8264EcF986CA,0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2,18,18,4,LINK,WETH,,,,,,,60,uniswap_v3,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,uniswap_v3,0xa6Cc3C2531FdaA6Ae1A3CA84c2855806728693e8,1312731411619255420525571,7101396323681156262130,"[4,0,]","[['liquidity'],['unlocked', 'feeProtocol', 'observationCardinalityNext', 'observationCardinality', 'observationIndex', 'tick', 'sqrtPriceX96']]",,,,,,,1456862313731161106039763,"uint128",6362445213301469813433370622,"uint160",-50441,"int24",85,"uint16",180,"uint16",180,"uint16",0,"uint8",True,bool | ||
,,0,pancakeswap_v3 0x6B175474E89094C44Da98b954EedeAC495271d0F/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 0.0001,0x6B175474E89094C44Da98b954EedeAC495271d0F/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48,pancakeswap_v3,100,0.0001,0xD9e497BD8f491fE163b42A62c296FB54CaEA74B7,,0x6B175474E89094C44Da98b954EedeAC495271d0F,0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48,18,6,10,DAI,USDC,0,0,0,0,0,0,1,pancakeswap_v3,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,3,pancakeswap_v3,0xD9e497BD8f491fE163b42A62c296FB54CaEA74B7,13653990890660798693042,135975525713,"[4,0,1,]","[['liquidity'],['observationCardinalityNext', 'observationCardinality', 'observationIndex', 'tick', 'sqrtPriceX96'],['unlocked', 'feeProtocol']]",,,,,,,1275240832730323472063,"uint128",79228147574959555694268,"uint160",-276325,"int24",0,"uint16",1,"uint16",1,"uint16",216272100,"uint32",True,bool | ||
,,0,pancakeswap_v2 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 0.0025,0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2,pancakeswap_v2,2500,0.0025,0x4AB6702B3Ed3877e9b1f203f90cbEF13d663B0e8,,0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599,0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2,8,18,9,WBTC,WETH,0,0,0,,,,,pancakeswap_v2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,pancakeswap_v2,0x4AB6702B3Ed3877e9b1f203f90cbEF13d663B0e8,421419304,78852853048776778963,"[8,]","[['blockTimestampLast','reserve1','reserve0'],]",,uint32,421419304,uint112,78852853048776778963,uint112,,,,,,,,,,,,,,,, | ||
,,0,uniswap_v3 0x6B175474E89094C44Da98b954EedeAC495271d0F/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 0.0005,0x6B175474E89094C44Da98b954EedeAC495271d0F/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2,uniswap_v3,500,0.0005,0x60594a405d53811d3BC4766596EFD80fd545A270,,0x6B175474E89094C44Da98b954EedeAC495271d0F,0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2,18,18,4,DAI,WETH,,,,,,,10,uniswap_v3,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,3,uniswap_v3,0x60594a405d53811d3BC4766596EFD80fd545A270,2850299295281281234085971,1147049345011454055669,"[4,0,]","[['liquidity'],['unlocked', 'feeProtocol', 'observationCardinalityNext', 'observationCardinality', 'observationIndex', 'tick', 'sqrtPriceX96']]",,,,,,,451613902936689743409876,"uint128",1659826732499374354385938036,"uint160",-77317,"int24",110,"uint16",180,"uint16",180,"uint16",0,"uint8",True,bool |
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,122 @@ | ||
""" | ||
This file contains constants used in the deterministic tests. | ||
(c) Copyright Bprotocol foundation 2024. | ||
Licensed under MIT License. | ||
""" | ||
from dataclasses import dataclass | ||
|
||
from fastlane_bot.tools.cpc import T | ||
|
||
KNOWN_UNABLE_TO_DELETE = { | ||
68737038118029569619601670701217178714718: ("pDFS", "ETH"), | ||
} | ||
TEST_MODE_AMT = ( | ||
115792089237316195423570985008687907853269984665640564039457584007913129639935 | ||
) | ||
ETH_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" | ||
SUPPORTED_EXCHANGES = ["uniswap_v2", "uniswap_v3", "pancakeswap_v2", "pancakeswap_v3"] | ||
BNT_ADDRESS = "0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C" | ||
USDC_ADDRESS = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" | ||
USDT_ADDRESS = "0xdAC17F958D2ee523a2206206994597C13D831ec7" | ||
DEFAULT_GAS = 2000000 | ||
DEFAULT_GAS_PRICE = 0 | ||
DEFAULT_FROM_BLOCK = 1000000 | ||
TENDERLY_RPC_KEY = "fb866397-29bd-4886-8406-a2cc7b7c5b1f" # https://virtual.mainnet.rpc.tenderly.co/9ea4ceb3-d0f5-4faf-959e-f51cf1f6b52b, from_block: 19325893, fb866397-29bd-4886-8406-a2cc7b7c5b1f | ||
FILE_DATA_DIR = "fastlane_bot/data/blockchain_data" | ||
TEST_FILE_DATA_DIR = "fastlane_bot/tests/deterministic/_data" | ||
binance14 = "0x28C6c06298d514Db089934071355E5743bf21d60" | ||
TOKENS_MODIFICATIONS = { | ||
"0x0": { | ||
"address": "0x5a3e6A77ba2f983eC0d371ea3B475F8Bc0811AD5", | ||
"modifications": { | ||
"before": { | ||
"0x0000000000000000000000000000000000000000000000000000000000000006": "0x01", | ||
"0x0000000000000000000000000000000000000000000000000000000000000007": "0x01", | ||
"0x000000000000000000000000000000000000000000000000000000000000000d": "0x01", | ||
}, | ||
"after": { | ||
"0x0000000000000000000000000000000000000000000000000000000000000006": "0x0000000000000000000000000000000000000000000000000000000000000019", | ||
"0x0000000000000000000000000000000000000000000000000000000000000007": "0x0000000000000000000000000000000000000000000000000000000000000005", | ||
"0x000000000000000000000000000000000000000000000000000000000000000d": "0x2386f26fc10000", | ||
}, | ||
"balance": 288551667147, | ||
}, | ||
"strategy_id": 9868188640707215440437863615521278132277, | ||
"strategy_beneficiary": "0xe3d51681Dc2ceF9d7373c71D9b02c5308D852dDe", | ||
}, | ||
"PAXG": { | ||
"address": "0x45804880De22913dAFE09f4980848ECE6EcbAf78", | ||
"modifications": { | ||
"before": { | ||
"0x000000000000000000000000000000000000000000000000000000000000000d": "0x00", | ||
}, | ||
"after": { | ||
"0x000000000000000000000000000000000000000000000000000000000000000d": "0x00000000000000000000000000000000000000000000000000000000000000c8", | ||
}, | ||
"balance": 395803389286127, | ||
}, | ||
"strategy_id": 15312706511442230855851857334429569515620, | ||
"strategy_beneficiary": "0xFf365375777069eBd8Fa575635EB31a0787Afa6c", | ||
}, | ||
} | ||
|
||
|
||
@dataclass | ||
class TestCommandLineArgs: | ||
""" | ||
This class is used to mock the command line arguments for the main.py | ||
""" | ||
|
||
cache_latest_only: str = "True" | ||
backdate_pools: str = "True" | ||
static_pool_data_filename: str = "static_pool_data_testing" | ||
arb_mode: str = "multi_pairwise_all" | ||
flashloan_tokens: str = ( | ||
f"{T.LINK},{T.NATIVE_ETH},{T.BNT},{T.WBTC},{T.DAI},{T.USDC},{T.USDT},{T.WETH}" | ||
) | ||
n_jobs: int = -1 | ||
exchanges: str = "carbon_v1,bancor_v3,bancor_v2,bancor_pol,uniswap_v3,uniswap_v2,sushiswap_v2,balancer,pancakeswap_v2,pancakeswap_v3" | ||
polling_interval: int = 0 | ||
alchemy_max_block_fetch: int = 1 | ||
reorg_delay: int = 0 | ||
logging_path: str = "" | ||
loglevel: str = "INFO" | ||
use_cached_events: str = "False" | ||
run_data_validator: str = "False" | ||
randomizer: int = 1 | ||
limit_bancor3_flashloan_tokens: str = "True" | ||
default_min_profit_gas_token: str = "0.002" # "0.01" | ||
timeout: int = None | ||
target_tokens: str = None | ||
replay_from_block: int = None | ||
tenderly_fork_id: int = None | ||
tenderly_event_exchanges: str = "pancakeswap_v2,pancakeswap_v3" | ||
increment_time: int = 1 | ||
increment_blocks: int = 1 | ||
blockchain: str = "ethereum" | ||
pool_data_update_frequency: int = -1 | ||
use_specific_exchange_for_target_tokens: str = None | ||
prefix_path: str = "" | ||
version_check_frequency: int = 1 | ||
self_fund: str = "False" | ||
read_only: str = "False" | ||
is_args_test: str = "False" | ||
rpc_url: str = None | ||
|
||
@staticmethod | ||
def args_to_command_line(args): | ||
""" | ||
Convert a TestCommandLineArgs instance to a list of command-line arguments. | ||
Args: | ||
args: An instance of TestCommandLineArgs. | ||
Returns: | ||
A list of command-line arguments. | ||
""" | ||
cmd_args = [] | ||
for field, value in args.__dict__.items(): | ||
if value is not None: # Only include fields that have a value | ||
cmd_args.extend((f"--{field}", str(value))) | ||
return cmd_args |
Oops, something went wrong.