agent0.hyperfuzz.unit_fuzz.fuzz_present_value ============================================= .. py:module:: agent0.hyperfuzz.unit_fuzz.fuzz_present_value .. autoapi-nested-parse:: Script to confirm present value and LP share price invariance. # Test procedure - spin up local chain, deploy hyperdrive without fees - given trade list [open_long, close_long, open_short, close_short, add_liquidity, remove_liquidity] - trade amount in uniform[min_trade_amount, max_trade_amount) base - execute the trade and allow the block to tick (12 seconds) - check invariances after each trade # Invariance checks (these should be True): - the following state values should equal: - for any trade, LP share price shouldn't change by more than 0.1% - for any trade, present value should always be >= idle - open or close trades shouldn't affect PV within 0.1 - removing liquidity shouldn't result in the PV increasing (it should decrease) - adding liquidity shouldn't result in the PV decreasing (it should increase) .. !! processed by numpydoc !! Classes ------- .. autoapisummary:: agent0.hyperfuzz.unit_fuzz.fuzz_present_value.Args Functions --------- .. autoapisummary:: agent0.hyperfuzz.unit_fuzz.fuzz_present_value.main agent0.hyperfuzz.unit_fuzz.fuzz_present_value.fuzz_present_value agent0.hyperfuzz.unit_fuzz.fuzz_present_value.namespace_to_args agent0.hyperfuzz.unit_fuzz.fuzz_present_value.parse_arguments agent0.hyperfuzz.unit_fuzz.fuzz_present_value.invariant_check Module Contents --------------- .. py:function:: main(argv: Sequence[str] | None = None) Primary entrypoint. :param argv: The argv values returned from argparser. :type argv: Sequence[str] .. !! processed by numpydoc !! .. py:function:: fuzz_present_value(test_epsilon: float, chain_config: agent0.core.hyperdrive.interactive.LocalChain.Config, steth: bool = False, pause_on_fail: bool = False) Does fuzzy invariant checks for opening and closing longs and shorts. :param test_epsilon: The allowed error for present value equality tests. :type test_epsilon: float :param chain_config: Configuration options for the local chain. :type chain_config: LocalChain.Config, optional :param steth: Whether to use steth instead of erc4626 :type steth: bool :param pause_on_fail: Whether to pause on failure. :type pause_on_fail: bool .. !! processed by numpydoc !! .. py:class:: Args Bases: :py:obj:`NamedTuple` Command line arguments for the invariant checker. .. !! processed by numpydoc !! .. py:attribute:: test_epsilon :type: float .. py:attribute:: chain_config :type: agent0.core.hyperdrive.interactive.LocalChain.Config .. py:function:: namespace_to_args(namespace: argparse.Namespace) -> Args Converts argprase.Namespace to Args. :param namespace: Object for storing arg attributes. :type namespace: argparse.Namespace :returns: Formatted arguments :rtype: Args .. !! processed by numpydoc !! .. py:function:: parse_arguments(argv: Sequence[str] | None = None) -> Args Parses input arguments. :param argv: The argv values returned from argparser. :type argv: Sequence[str] :returns: Formatted arguments :rtype: Args .. !! processed by numpydoc !! .. py:function:: invariant_check(check_data: dict[str, Any], test_epsilon: float, interactive_hyperdrive: agent0.core.hyperdrive.interactive.LocalHyperdrive) -> None Check the pool state invariants and throws an assertion exception if fails. :param check_data: The trade data to check. :type check_data: dict[str, Any] :param test_epsilon: The allowed error for present value equality tests. It is a float representing the proportional error tolerated. For example, test_epsilon = 0.01 means the actual_value must be within 1% of the expected_value. :type test_epsilon: float :param interactive_hyperdrive: An instantiated InteractiveHyperdrive object. :type interactive_hyperdrive: InteractiveHyperdrive .. !! processed by numpydoc !!