agent0.hyperfuzz.system_fuzz.run_fuzz_bots
Helper function for running random fuzz bots.
Attributes
Functions
Fuzz over hyperdrive config. |
|
|
Runs fuzz bots on a hyperdrive pool. |
Module Contents
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.ONE_HOUR_IN_SECONDS = 3600
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.ONE_DAY_IN_SECONDS = 86400
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.ONE_YEAR_IN_SECONDS = 31449600
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.ONE_YEAR_IN_HOURS = 8736
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.INITIAL_LIQUIDITY_RANGE: tuple[float, float] = (10, 100000)
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.INITIAL_VAULT_SHARE_PRICE_RANGE: tuple[float, float] = (0.5, 2.5)
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.MINIMUM_SHARE_RESERVES_RANGE: tuple[float, float] = (0.1, 1)
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.MINIMUM_TRANSACTION_AMOUNT_RANGE: tuple[float, float] = (0.1, 10)
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.CIRCUIT_BREAKER_DELTA_RANGE: tuple[float, float] = (0.15, 2)
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.POSITION_DURATION_HOURS_RANGE: tuple[int, int]
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.CHECKPOINT_DURATION_HOURS_RANGE: tuple[int, int] = (1, 24)
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.INITIAL_TIME_STRETCH_APR_RANGE: tuple[float, float] = (0.005, 0.5)
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.VARIABLE_RATE_RANGE: tuple[float, float] = (0, 1)
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.ADVANCE_TIME_SECONDS_RANGE: tuple[int, int]
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.FEE_RANGE: tuple[float, float] = (0.0001, 0.2)
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.LP_SHARE_PRICE_VARIABLE_RATE_RANGE: tuple[float, float] = (0, 0.1)
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.LP_SHARE_PRICE_FLAT_FEE_RANGE: tuple[float, float] = (0, 0)
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.LP_SHARE_PRICE_CURVE_FEE_RANGE: tuple[float, float] = (0, 0)
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.LP_SHARE_PRICE_GOVERNANCE_LP_FEE_RANGE: tuple[float, float] = (0, 0)
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.LP_SHARE_PRICE_GOVERNANCE_ZOMBIE_FEE_RANGE: tuple[float, float] = (0, 0)
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.TRADE_COUNT_CHECK = 100
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.generate_fuzz_hyperdrive_config(rng: numpy.random.Generator, lp_share_price_test: bool, steth: bool) agent0.LocalHyperdrive.Config
Fuzz over hyperdrive config.
- Parameters:
rng (np.random.Generator) – Random number generator.
lp_share_price_test (bool) – If True, uses lp share price test fuzz parameters.
steth (bool) – If True, uses steth instead of erc4626
- Returns:
Fuzzed hyperdrive config.
- Return type:
- agent0.hyperfuzz.system_fuzz.run_fuzz_bots.run_fuzz_bots(chain: agent0.Chain, hyperdrive_pools: agent0.Hyperdrive | Sequence[agent0.Hyperdrive], check_invariance: bool, num_random_agents: int | None = None, num_random_hold_agents: int | None = None, agents: Sequence[agent0.core.hyperdrive.interactive.hyperdrive_agent.HyperdriveAgent] | None = None, base_budget_per_bot: fixedpointmath.FixedPoint | None = None, eth_budget_per_bot: fixedpointmath.FixedPoint | None = None, slippage_tolerance: fixedpointmath.FixedPoint | None = None, raise_error_on_crash: bool = False, raise_error_on_failed_invariance_checks: bool = False, ignore_raise_error_func: Callable[[Exception], bool] | None = None, minimum_avg_agent_base: fixedpointmath.FixedPoint | None = None, minimum_avg_agent_eth: fixedpointmath.FixedPoint | None = None, log_to_rollbar: bool = True, run_async: bool = False, random_advance_time: bool = False, random_variable_rate: bool = False, num_iterations: int | None = None, lp_share_price_test: bool = False, whale_accounts: dict[eth_typing.ChecksumAddress, eth_typing.ChecksumAddress] | None = None, accrue_interest_func: Callable[[agent0.ethpy.hyperdrive.HyperdriveReadWriteInterface, fixedpointmath.FixedPoint, int], None] | None = None, accrue_interest_rate: fixedpointmath.FixedPoint | None = None) Sequence[agent0.core.hyperdrive.interactive.hyperdrive_agent.HyperdriveAgent]
Runs fuzz bots on a hyperdrive pool.
- Parameters:
chain (Chain) – The chain to run the bots on.
hyperdrive_pools (Hyperdrive | Sequence[Hyperdrive]) – The hyperdrive pool(s) to run the bots on.
check_invariance (bool) – If True, will run invariance checks after each set of trades.
agents (Sequence[HyperdriveAgent] | None, optional) – The agents making trades. If None, will create random agents.
num_random_agents (int | None, optional) – The number of random agents to create. Defaults to 2.
num_random_hold_agents (int | None, optional) – The number of random agents to create. Defaults to 2.
base_budget_per_bot (FixedPoint | None, optional) – The base budget per bot. Defaults to 10_000_000
eth_budget_per_bot (FixedPoint | None, optional) – The ETH budget per bot. Defaults to 1_000
slippage_tolerance (FixedPoint | None, optional) – The slippage tolerance. Defaults to 1% slippage
raise_error_on_crash (bool, optional) – If True, will exit the process if a bot crashes. Defaults to False.
raise_error_on_failed_invariance_checks (bool, optional) – If True, will exit the process if the pool fails an invariance check. Defaults to False.
ignore_raise_error_func (Callable[[Exception], bool] | None, optional) – A function that determines if an exception should be ignored when raising error on crash. The function takes an exception as an an argument and returns True if the exception should be ignored. Defaults to raising all errors.
minimum_avg_agent_base (FixedPoint | None, optional) – The minimum average agent base. Will refund bots if average agent base drops below this. Defaults to 1/10 of base_budget_per_bot
minimum_avg_agent_eth (FixedPoint | None, optional) – The minimum average agent eth. Will refund bots if average agent base drops below this. Defaults to 1/10 of eth_budget_per_bot
log_to_rollbar (bool, optional) – If True, log errors rollbar. Defaults to True.
run_async (bool, optional) – If True, will run the bots asynchronously. Defaults to False.
random_advance_time (bool, optional) – If True, will advance the time randomly between sets of trades. Defaults to False.
random_variable_rate (bool, optional) – If True, will randomly change the rate between sets of trades. Defaults to False.
num_iterations (int | None, optional) – The number of iterations to run. Defaults to None (infinite)
lp_share_price_test (bool, optional) – If True, will test the LP share price. Defaults to False.
whale_accounts (dict[ChecksumAddress, ChecksumAddress] | None, optional) – A mapping between token -> whale addresses to use to fund the fuzz agent. If the token is not in the mapping, fuzzing will attempt to call mint on the token contract. Defaults to an empty mapping.
accrue_interest_func (Callable[[HyperdriveReadWriteInterface, FixedPoint, int], None] | None, optional) – A function that will accrue interest on the hyperdrive pool. This function will get called after advancing time, with the following signature: accrue_interest_func(hyperdrive_interface, variable_rate, block_number_before_advance).
accrue_interest_rate (FixedPoint | None, optional) – The variable rate to be passed into the accrue_interest_func. Note this value is only used when forking, as variable interest is handled by a mock yield source when simulating. If random_variable_rate is True, this value will be ignored.
- Returns:
The set of agents making trades.
- Return type:
Sequence[HyperdriveAgent]