agent0.hyperfuzz.unit_fuzz.fuzz_profit_check
Script for fuzzing profit values on immediately opening & closing a long or short.
# Test procedure - spin up local chain, deploy hyperdrive with fees - open a long for a random amount - advance time, but not enough to trigger a new checkpoint - close the long - open a short for a random amount - advance time, but not enough to trigger a new checkpoint - close the short - invariance checks
# Invariance checks (these should be True): # We are checking that the agent made made no profit - Repeat these two checks for the longs & shorts
transaction receipt: base amount returned < base amount provided
agent wallet: final balance <= initial balance
Specific values checked - trade amount - agent initial balance - agent final balance
Classes
Command line arguments for the invariant checker. |
Functions
|
Primary entrypoint. |
|
Fuzzes invariant checks for profit from long and short positions. |
|
Converts argprase.Namespace to Args. |
|
Parses input arguments. |
|
Check the pool state invariants. |
Module Contents
- agent0.hyperfuzz.unit_fuzz.fuzz_profit_check.main(argv: Sequence[str] | None = None)
Primary entrypoint.
- Parameters:
argv (Sequence[str]) – The argv values returned from argparser.
- agent0.hyperfuzz.unit_fuzz.fuzz_profit_check.fuzz_profit_check(chain_config: agent0.core.hyperdrive.interactive.LocalChain.Config, steth: bool = False, pause_on_fail: bool = False)
Fuzzes invariant checks for profit from long and short positions.
- Parameters:
chain_config (LocalChain.Config, optional) – Configuration options for the local chain.
steth (bool) – Whether to use steth instead of erc4626
pause_on_fail (bool) – If True, pause on test failure.
- class agent0.hyperfuzz.unit_fuzz.fuzz_profit_check.Args
Bases:
NamedTupleCommand line arguments for the invariant checker.
- chain_config: agent0.core.hyperdrive.interactive.LocalChain.Config
- agent0.hyperfuzz.unit_fuzz.fuzz_profit_check.namespace_to_args(namespace: argparse.Namespace) Args
Converts argprase.Namespace to Args.
- Parameters:
namespace (argparse.Namespace) – Object for storing arg attributes.
- Returns:
Formatted arguments
- Return type:
- agent0.hyperfuzz.unit_fuzz.fuzz_profit_check.parse_arguments(argv: Sequence[str] | None = None) Args
Parses input arguments.
- Parameters:
argv (Sequence[str]) – The argv values returned from argparser.
- Returns:
Formatted arguments
- Return type:
- agent0.hyperfuzz.unit_fuzz.fuzz_profit_check.invariant_check(check_data: dict[str, Any]) None
Check the pool state invariants.
- Parameters:
check_data (dict[str, Any]) – The trade data to check.