From ee5e62317b56debe8da31c9ba968d9071e2cc245 Mon Sep 17 00:00:00 2001 From: Sheng Lundquist Date: Fri, 26 Jan 2024 15:09:54 -0800 Subject: [PATCH] Update to hyperdrive v0.6.0 (#59) --- .github/workflows/build_linux_wheel.yml | 2 +- .github/workflows/build_wheels.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/test.yml | 2 +- Cargo.lock | 2 +- README.md | 2 +- crates/hyperdrive-wasm/src/short.rs | 8 +- crates/hyperdrivepy/Cargo.toml | 2 +- crates/hyperdrivepy/pyproject.toml | 2 +- .../python/hyperdrivepy/__init__.py | 1 + .../python/hyperdrivepy/hyperdrive_state.py | 29 +- .../python/hyperdrivepy/hyperdrive_utils.py | 7 +- .../IERC4626HyperdriveContract.py | 367 ++++++++++++------ .../IERC4626HyperdriveTypes.py | 133 ++----- .../pypechain_types/IHyperdriveTypes.py | 111 ++++++ .../hyperdrivepy/pypechain_types/__init__.py | 5 + .../hyperdrivepy/pypechain_types/utilities.py | 9 +- .../hyperdrivepy/python/hyperdrivepy/types.py | 11 +- .../hyperdrivepy/python/hyperdrivepy/utils.py | 5 +- crates/hyperdrivepy/setup.py | 3 +- .../src/hyperdrive_state_methods.rs | 40 +- crates/hyperdrivepy/src/hyperdrive_utils.rs | 12 +- crates/hyperdrivepy/src/lib.rs | 3 +- crates/hyperdrivepy/src/pool_config.rs | 4 +- crates/hyperdrivepy/src/pool_info.rs | 4 +- requirements-dev.txt | 2 +- system_tests/wrapper_tests.py | 41 +- 27 files changed, 503 insertions(+), 308 deletions(-) create mode 100644 crates/hyperdrivepy/python/hyperdrivepy/pypechain_types/IHyperdriveTypes.py diff --git a/.github/workflows/build_linux_wheel.yml b/.github/workflows/build_linux_wheel.yml index 688e19b..e63b9e0 100644 --- a/.github/workflows/build_linux_wheel.yml +++ b/.github/workflows/build_linux_wheel.yml @@ -49,7 +49,7 @@ jobs: uses: actions/checkout@master with: repository: delvtech/hyperdrive - ref: "v0.5.1" + ref: "v0.6.0" path: "./hyperdrive" ssh-key: ${{ secrets.HYPERDRIVE_ACCESS_KEY }} diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 893fa8f..13a52de 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -40,7 +40,7 @@ jobs: uses: actions/checkout@master with: repository: delvtech/hyperdrive - ref: "v0.5.1" + ref: "v0.6.0" path: "./hyperdrive" ssh-key: ${{ secrets.HYPERDRIVE_ACCESS_KEY }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ff46486..25f875f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -30,7 +30,7 @@ jobs: uses: actions/checkout@master with: repository: delvtech/hyperdrive - ref: "v0.5.1" + ref: "v0.6.0" path: "./hyperdrive" ssh-key: ${{ secrets.HYPERDRIVE_ACCESS_KEY }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index faca2e3..e00ce42 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,7 +30,7 @@ jobs: uses: actions/checkout@master with: repository: delvtech/hyperdrive - ref: "v0.5.1" + ref: "v0.6.0" path: "./hyperdrive" ssh-key: ${{ secrets.HYPERDRIVE_ACCESS_KEY }} diff --git a/Cargo.lock b/Cargo.lock index 45cfe20..8ac95f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1579,7 +1579,7 @@ dependencies = [ [[package]] name = "hyperdrivepy" -version = "0.5.1" +version = "0.6.0" dependencies = [ "ethers", "eyre", diff --git a/README.md b/README.md index f59eab1..6a1c605 100644 --- a/README.md +++ b/README.md @@ -39,5 +39,5 @@ From the hyperdrive-sdk project root, run: ```shell pip install --upgrade -r requirements-dev.txt -pypechain --line_length 120 --output_dir crates/hyperdrivepy/python/hyperdrivepy/pypechain_types hyperdrive/out/IERC4626Hyperdrive.sol/ +pypechain --line-length 120 --output-dir crates/hyperdrivepy/python/hyperdrivepy/pypechain_types hyperdrive/out/IERC4626Hyperdrive.sol/ ``` diff --git a/crates/hyperdrive-wasm/src/short.rs b/crates/hyperdrive-wasm/src/short.rs index cd4bcb9..3e16a19 100644 --- a/crates/hyperdrive-wasm/src/short.rs +++ b/crates/hyperdrive-wasm/src/short.rs @@ -42,7 +42,7 @@ pub fn calcOpenShort( /// /// @param poolConfig - The pool's configuration /// -/// @param openSharePrice - The open share price of the pool's current +/// @param openVaultSharePrice - The open share price of the pool's current /// checkpoint /// /// @param checkpointExposure - The exposure of the pool's current checkpoint @@ -59,7 +59,7 @@ pub fn getMaxShort( poolInfo: &JsPoolInfo, poolConfig: &JsPoolConfig, budget: String, - openSharePrice: String, + openVaultSharePrice: String, checkpointExposure: String, maybeConservativePrice: Option, maybeMaxIterations: Option, @@ -72,7 +72,7 @@ pub fn getMaxShort( let _budget = U256::from_dec_str(&budget).unwrap(); let checkpoint_exposure: I256 = I256::from_raw(U256::from_dec_str(&checkpointExposure).unwrap()); - let open_share_price: I256 = I256::from_raw(U256::from_dec_str(&openSharePrice).unwrap()); + let open_vault_share_price: I256 = I256::from_raw(U256::from_dec_str(&openVaultSharePrice).unwrap()); let _maybe_conservative_price: Option = maybeConservativePrice .as_ref() @@ -80,7 +80,7 @@ pub fn getMaxShort( let result_fp = state.get_max_short( _budget, - open_share_price, + open_vault_share_price, checkpoint_exposure, _maybe_conservative_price, maybeMaxIterations.map(|x| x.into()), diff --git a/crates/hyperdrivepy/Cargo.toml b/crates/hyperdrivepy/Cargo.toml index 8adc854..23965fd 100644 --- a/crates/hyperdrivepy/Cargo.toml +++ b/crates/hyperdrivepy/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "hyperdrivepy" edition = "2021" -version = "0.5.1" +version = "0.6.0" authors = [ "Dylan Paiton", "Matt Brown", diff --git a/crates/hyperdrivepy/pyproject.toml b/crates/hyperdrivepy/pyproject.toml index 98af933..7cb390c 100644 --- a/crates/hyperdrivepy/pyproject.toml +++ b/crates/hyperdrivepy/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "hyperdrivepy" -version = "0.5.1" +version = "0.6.0" requires-python = ">=3.7" classifiers = [ "Programming Language :: Rust", diff --git a/crates/hyperdrivepy/python/hyperdrivepy/__init__.py b/crates/hyperdrivepy/python/hyperdrivepy/__init__.py index bd55067..0bb1735 100644 --- a/crates/hyperdrivepy/python/hyperdrivepy/__init__.py +++ b/crates/hyperdrivepy/python/hyperdrivepy/__init__.py @@ -1,3 +1,4 @@ """Python module wrapping the Rust implementation of HyperdriveMath""" + from .hyperdrive_state import * # pylint: disable=cyclic-import from .hyperdrive_utils import * # pylint: disable=cyclic-import diff --git a/crates/hyperdrivepy/python/hyperdrivepy/hyperdrive_state.py b/crates/hyperdrivepy/python/hyperdrivepy/hyperdrive_state.py index 8263156..f7afc9f 100644 --- a/crates/hyperdrivepy/python/hyperdrivepy/hyperdrive_state.py +++ b/crates/hyperdrivepy/python/hyperdrivepy/hyperdrive_state.py @@ -1,4 +1,5 @@ """Python wrapper for the rust hyperdrive_math::State module.""" + from __future__ import annotations from . import types @@ -76,7 +77,7 @@ def get_solvency( Returns ------- str (FixedPoint) - solvency = share_reserves - long_exposure / share_price - minimum_share_reserves + solvency = share_reserves - long_exposure / vault_share_price - minimum_share_reserves """ return _get_interface(pool_config, pool_info).get_solvency() @@ -187,7 +188,7 @@ def calculate_open_short( pool_info: types.PoolInfoType, short_amount: str, spot_price: str, - open_share_price: str | None = None, + open_vault_share_price: str | None = None, ) -> str: """Gets the amount of base the trader will need to deposit for a short of a given size. @@ -203,7 +204,7 @@ def calculate_open_short( The amount to of bonds to short. spot_price: str (FixedPoint) The pool's current price for bonds. - open_share_price: str (FixedPoint) | None, optional + open_vault_share_price: str (FixedPoint) | None, optional Optionally provide the open share price for the short. If this is not provided or is None, then we will use the pool's current share price. @@ -212,19 +213,19 @@ def calculate_open_short( str (FixedPoint) The amount of base required to short the bonds (aka the "max loss"). """ - if open_share_price is None: + if open_vault_share_price is None: # the underlying rust code uses current market share price if this is 0 # zero value is used because the smart contract will return 0 if the checkpoint hasn't been minted - open_share_price = "0" - return _get_interface(pool_config, pool_info).calculate_open_short(short_amount, spot_price, open_share_price) + open_vault_share_price = "0" + return _get_interface(pool_config, pool_info).calculate_open_short(short_amount, spot_price, open_vault_share_price) def calculate_close_short( pool_config: types.PoolConfigType, pool_info: types.PoolInfoType, bond_amount: str, - open_share_price: str, - close_share_price: str, + open_vault_share_price: str, + close_vault_share_price: str, normalized_time_remaining: str, ) -> str: """Gets the amount of shares the trader will receive from closing a short. @@ -239,9 +240,9 @@ def calculate_close_short( Includes attributes like reserve levels and share prices. bond_amount: str (FixedPoint) The amount to of bonds provided. - open_share_price: str (FixedPoint) + open_vault_share_price: str (FixedPoint) The share price when the short was opened. - close_share_price: str (FixedPoint) + close_vault_share_price: str (FixedPoint) The share price when the short was closed. normalized_time_remaining: str (FixedPoint) The time remaining before the short reaches maturity, normalized such that 0 is at opening and 1 is at maturity. @@ -252,7 +253,7 @@ def calculate_close_short( The amount of shares the trader will receive for closing the short. """ return _get_interface(pool_config, pool_info).calculate_close_short( - bond_amount, open_share_price, close_share_price, normalized_time_remaining + bond_amount, open_vault_share_price, close_vault_share_price, normalized_time_remaining ) @@ -318,7 +319,7 @@ def get_max_short( pool_config: types.PoolConfigType, pool_info: types.PoolInfoType, budget: str, - open_share_price: str, + open_vault_share_price: str, checkpoint_exposure: str, maybe_conservative_price: str | None, maybe_max_iterations: int | None, @@ -335,7 +336,7 @@ def get_max_short( Includes attributes like reserve levels and share prices. budget: str (FixedPoint) The account budget in base for making a short. - open_share_price: str (FixedPoint) + open_vault_share_price: str (FixedPoint) The share price of underlying vault. checkpoint_exposure: str (FixedPoint) The net exposure for the given checkpoint. @@ -351,7 +352,7 @@ def get_max_short( """ return _get_interface(pool_config, pool_info).get_max_short( budget, - open_share_price, + open_vault_share_price, checkpoint_exposure, maybe_conservative_price, maybe_max_iterations, diff --git a/crates/hyperdrivepy/python/hyperdrivepy/hyperdrive_utils.py b/crates/hyperdrivepy/python/hyperdrivepy/hyperdrive_utils.py index 82beab7..92d9965 100644 --- a/crates/hyperdrivepy/python/hyperdrivepy/hyperdrive_utils.py +++ b/crates/hyperdrivepy/python/hyperdrivepy/hyperdrive_utils.py @@ -1,4 +1,5 @@ """Python wrapper for the rust hyperdrive_math::utils module.""" + from __future__ import annotations # pylint: disable=no-name-in-module @@ -52,7 +53,7 @@ def get_effective_share_reserves( def calculate_initial_bond_reserves( effective_share_reserves: str, - initial_share_price: str, + initial_vault_share_price: str, apr: str, position_duration: str, time_stretch: str, @@ -71,7 +72,7 @@ def calculate_initial_bond_reserves( The pool's effective share reserves. The effective share reserves are a modified version of the share reserves used when pricing trades. - initial_share_price: str (FixedPoint) + initial_vault_share_price: str (FixedPoint) The pool's initial share price. apr: str (FixedPoint) The pool's APR. @@ -87,5 +88,5 @@ def calculate_initial_bond_reserves( the pool have a specified APR. """ return rust_module.calculate_initial_bond_reserves( - effective_share_reserves, initial_share_price, apr, position_duration, time_stretch + effective_share_reserves, initial_vault_share_price, apr, position_duration, time_stretch ) diff --git a/crates/hyperdrivepy/python/hyperdrivepy/pypechain_types/IERC4626HyperdriveContract.py b/crates/hyperdrivepy/python/hyperdrivepy/pypechain_types/IERC4626HyperdriveContract.py index cc43595..1273e2f 100644 --- a/crates/hyperdrivepy/python/hyperdrivepy/pypechain_types/IERC4626HyperdriveContract.py +++ b/crates/hyperdrivepy/python/hyperdrivepy/pypechain_types/IERC4626HyperdriveContract.py @@ -9,6 +9,8 @@ # contracts control how many attributes and arguments we have in generated code # pylint: disable=too-many-instance-attributes # pylint: disable=too-many-arguments +# pylint: disable=line-too-long +# pylint: disable=too-few-public-methods # we don't need else statement if the other conditionals all have return, # but it's easier to generate @@ -41,7 +43,7 @@ from web3.exceptions import FallbackNotFound from web3.types import ABI, BlockIdentifier, CallOverride, EventData, TxParams -from .IERC4626HyperdriveTypes import Checkpoint, Fees, MarketState, Options, PoolConfig, PoolInfo, WithdrawPool +from .IHyperdriveTypes import Checkpoint, Fees, MarketState, Options, PoolConfig, PoolInfo, WithdrawPool from .utilities import dataclass_to_tuple, rename_returned_types structs = { @@ -112,9 +114,10 @@ def call( class IERC4626HyperdriveAddLiquidityContractFunction(ContractFunction): """ContractFunction for the addLiquidity method.""" - def __call__(self, contribution: int, minApr: int, maxApr: int, options: Options) -> IERC4626HyperdriveAddLiquidityContractFunction: # type: ignore + def __call__(self, contribution: int, minLpSharePrice: int, minApr: int, maxApr: int, options: Options) -> IERC4626HyperdriveAddLiquidityContractFunction: # type: ignore clone = super().__call__( dataclass_to_tuple(contribution), + dataclass_to_tuple(minLpSharePrice), dataclass_to_tuple(minApr), dataclass_to_tuple(maxApr), dataclass_to_tuple(options), @@ -665,11 +668,11 @@ class ReturnValues(NamedTuple): maturityTime: int bondProceeds: int - def __call__(self, baseAmount: int, minOutput: int, minSharePrice: int, options: Options) -> IERC4626HyperdriveOpenLongContractFunction: # type: ignore + def __call__(self, baseAmount: int, minOutput: int, minVaultSharePrice: int, options: Options) -> IERC4626HyperdriveOpenLongContractFunction: # type: ignore clone = super().__call__( dataclass_to_tuple(baseAmount), dataclass_to_tuple(minOutput), - dataclass_to_tuple(minSharePrice), + dataclass_to_tuple(minVaultSharePrice), dataclass_to_tuple(options), ) self.kwargs = clone.kwargs @@ -703,11 +706,11 @@ class ReturnValues(NamedTuple): maturityTime: int traderDeposit: int - def __call__(self, bondAmount: int, maxDeposit: int, minSharePrice: int, options: Options) -> IERC4626HyperdriveOpenShortContractFunction: # type: ignore + def __call__(self, bondAmount: int, maxDeposit: int, minVaultSharePrice: int, options: Options) -> IERC4626HyperdriveOpenShortContractFunction: # type: ignore clone = super().__call__( dataclass_to_tuple(bondAmount), dataclass_to_tuple(maxDeposit), - dataclass_to_tuple(minSharePrice), + dataclass_to_tuple(minVaultSharePrice), dataclass_to_tuple(options), ) self.kwargs = clone.kwargs @@ -811,33 +814,6 @@ def call( # Call the function -class IERC4626HyperdrivePoolContractFunction(ContractFunction): - """ContractFunction for the pool method.""" - - def __call__(self) -> IERC4626HyperdrivePoolContractFunction: # type: ignore - clone = super().__call__() - self.kwargs = clone.kwargs - self.args = clone.args - return self - - def call( - self, - transaction: TxParams | None = None, - block_identifier: BlockIdentifier = "latest", - state_override: CallOverride | None = None, - ccip_read_enabled: bool | None = None, - ) -> str: - """returns str.""" - # Define the expected return types from the smart contract call - - return_types = str - - # Call the function - - raw_values = super().call(transaction, block_identifier, state_override, ccip_read_enabled) - return cast(str, rename_returned_types(structs, return_types, raw_values)) - - class IERC4626HyperdriveRedeemWithdrawalSharesContractFunction(ContractFunction): """ContractFunction for the redeemWithdrawalShares method.""" @@ -1255,6 +1231,33 @@ def call( # Call the function +class IERC4626HyperdriveVaultContractFunction(ContractFunction): + """ContractFunction for the vault method.""" + + def __call__(self) -> IERC4626HyperdriveVaultContractFunction: # type: ignore + clone = super().__call__() + self.kwargs = clone.kwargs + self.args = clone.args + return self + + def call( + self, + transaction: TxParams | None = None, + block_identifier: BlockIdentifier = "latest", + state_override: CallOverride | None = None, + ccip_read_enabled: bool | None = None, + ) -> str: + """returns str.""" + # Define the expected return types from the smart contract call + + return_types = str + + # Call the function + + raw_values = super().call(transaction, block_identifier, state_override, ccip_read_enabled) + return cast(str, rename_returned_types(structs, return_types, raw_values)) + + class IERC4626HyperdriveContractFunctions(ContractFunctions): """ContractFunctions for the IERC4626Hyperdrive contract.""" @@ -1312,8 +1315,6 @@ class IERC4626HyperdriveContractFunctions(ContractFunctions): permitForAll: IERC4626HyperdrivePermitForAllContractFunction - pool: IERC4626HyperdrivePoolContractFunction - redeemWithdrawalShares: IERC4626HyperdriveRedeemWithdrawalSharesContractFunction removeLiquidity: IERC4626HyperdriveRemoveLiquidityContractFunction @@ -1346,6 +1347,8 @@ class IERC4626HyperdriveContractFunctions(ContractFunctions): transferFromBridge: IERC4626HyperdriveTransferFromBridgeContractFunction + vault: IERC4626HyperdriveVaultContractFunction + def __init__( self, abi: ABI, @@ -1570,14 +1573,6 @@ def __init__( decode_tuples=decode_tuples, function_identifier="permitForAll", ) - self.pool = IERC4626HyperdrivePoolContractFunction.factory( - "pool", - w3=w3, - contract_abi=abi, - address=address, - decode_tuples=decode_tuples, - function_identifier="pool", - ) self.redeemWithdrawalShares = IERC4626HyperdriveRedeemWithdrawalSharesContractFunction.factory( "redeemWithdrawalShares", w3=w3, @@ -1706,6 +1701,14 @@ def __init__( decode_tuples=decode_tuples, function_identifier="transferFromBridge", ) + self.vault = IERC4626HyperdriveVaultContractFunction.factory( + "vault", + w3=w3, + contract_abi=abi, + address=address, + decode_tuples=decode_tuples, + function_identifier="vault", + ) class IERC4626HyperdriveAddLiquidityContractEvent(ContractEvent): @@ -2240,6 +2243,82 @@ def create_filter( # type: ignore ) +class IERC4626HyperdriveGovernanceUpdatedContractEvent(ContractEvent): + """ContractEvent for GovernanceUpdated.""" + + # super() get_logs and create_filter methods are generic, while our version adds values & types + # pylint: disable=arguments-differ + + # @combomethod destroys return types, so we are redefining functions as both class and instance + # pylint: disable=function-redefined + + # pylint: disable=useless-parent-delegation + def __init__(self, *argument_names: tuple[str]) -> None: + super().__init__(*argument_names) + + def get_logs( # type: ignore + self: "IERC4626HyperdriveGovernanceUpdatedContractEvent", + argument_filters: dict[str, Any] | None = None, + fromBlock: BlockIdentifier | None = None, + toBlock: BlockIdentifier | None = None, + block_hash: HexBytes | None = None, + ) -> Iterable[EventData]: + return cast( + Iterable[EventData], + super().get_logs( + argument_filters=argument_filters, fromBlock=fromBlock, toBlock=toBlock, block_hash=block_hash + ), + ) + + @classmethod + def get_logs( # type: ignore + cls: Type["IERC4626HyperdriveGovernanceUpdatedContractEvent"], + argument_filters: dict[str, Any] | None = None, + fromBlock: BlockIdentifier | None = None, + toBlock: BlockIdentifier | None = None, + block_hash: HexBytes | None = None, + ) -> Iterable[EventData]: + return cast( + Iterable[EventData], + super().get_logs( + argument_filters=argument_filters, fromBlock=fromBlock, toBlock=toBlock, block_hash=block_hash + ), + ) + + def create_filter( # type: ignore + self: "IERC4626HyperdriveGovernanceUpdatedContractEvent", + *, # PEP 3102 + argument_filters: dict[str, Any] | None = None, + fromBlock: BlockIdentifier | None = None, + toBlock: BlockIdentifier = "latest", + address: ChecksumAddress | None = None, + topics: Sequence[Any] | None = None, + ) -> LogFilter: + return cast( + LogFilter, + super().create_filter( + argument_filters=argument_filters, fromBlock=fromBlock, toBlock=toBlock, address=address, topics=topics + ), + ) + + @classmethod + def create_filter( # type: ignore + cls: Type["IERC4626HyperdriveGovernanceUpdatedContractEvent"], + *, # PEP 3102 + argument_filters: dict[str, Any] | None = None, + fromBlock: BlockIdentifier | None = None, + toBlock: BlockIdentifier = "latest", + address: ChecksumAddress | None = None, + topics: Sequence[Any] | None = None, + ) -> LogFilter: + return cast( + LogFilter, + super().create_filter( + argument_filters=argument_filters, fromBlock=fromBlock, toBlock=toBlock, address=address, topics=topics + ), + ) + + class IERC4626HyperdriveInitializeContractEvent(ContractEvent): """ContractEvent for Initialize.""" @@ -2468,6 +2547,82 @@ def create_filter( # type: ignore ) +class IERC4626HyperdrivePauserUpdatedContractEvent(ContractEvent): + """ContractEvent for PauserUpdated.""" + + # super() get_logs and create_filter methods are generic, while our version adds values & types + # pylint: disable=arguments-differ + + # @combomethod destroys return types, so we are redefining functions as both class and instance + # pylint: disable=function-redefined + + # pylint: disable=useless-parent-delegation + def __init__(self, *argument_names: tuple[str]) -> None: + super().__init__(*argument_names) + + def get_logs( # type: ignore + self: "IERC4626HyperdrivePauserUpdatedContractEvent", + argument_filters: dict[str, Any] | None = None, + fromBlock: BlockIdentifier | None = None, + toBlock: BlockIdentifier | None = None, + block_hash: HexBytes | None = None, + ) -> Iterable[EventData]: + return cast( + Iterable[EventData], + super().get_logs( + argument_filters=argument_filters, fromBlock=fromBlock, toBlock=toBlock, block_hash=block_hash + ), + ) + + @classmethod + def get_logs( # type: ignore + cls: Type["IERC4626HyperdrivePauserUpdatedContractEvent"], + argument_filters: dict[str, Any] | None = None, + fromBlock: BlockIdentifier | None = None, + toBlock: BlockIdentifier | None = None, + block_hash: HexBytes | None = None, + ) -> Iterable[EventData]: + return cast( + Iterable[EventData], + super().get_logs( + argument_filters=argument_filters, fromBlock=fromBlock, toBlock=toBlock, block_hash=block_hash + ), + ) + + def create_filter( # type: ignore + self: "IERC4626HyperdrivePauserUpdatedContractEvent", + *, # PEP 3102 + argument_filters: dict[str, Any] | None = None, + fromBlock: BlockIdentifier | None = None, + toBlock: BlockIdentifier = "latest", + address: ChecksumAddress | None = None, + topics: Sequence[Any] | None = None, + ) -> LogFilter: + return cast( + LogFilter, + super().create_filter( + argument_filters=argument_filters, fromBlock=fromBlock, toBlock=toBlock, address=address, topics=topics + ), + ) + + @classmethod + def create_filter( # type: ignore + cls: Type["IERC4626HyperdrivePauserUpdatedContractEvent"], + *, # PEP 3102 + argument_filters: dict[str, Any] | None = None, + fromBlock: BlockIdentifier | None = None, + toBlock: BlockIdentifier = "latest", + address: ChecksumAddress | None = None, + topics: Sequence[Any] | None = None, + ) -> LogFilter: + return cast( + LogFilter, + super().create_filter( + argument_filters=argument_filters, fromBlock=fromBlock, toBlock=toBlock, address=address, topics=topics + ), + ) + + class IERC4626HyperdriveRedeemWithdrawalSharesContractEvent(ContractEvent): """ContractEvent for RedeemWithdrawalShares.""" @@ -2713,12 +2868,16 @@ class IERC4626HyperdriveContractEvents(ContractEvents): CreateCheckpoint: IERC4626HyperdriveCreateCheckpointContractEvent + GovernanceUpdated: IERC4626HyperdriveGovernanceUpdatedContractEvent + Initialize: IERC4626HyperdriveInitializeContractEvent OpenLong: IERC4626HyperdriveOpenLongContractEvent OpenShort: IERC4626HyperdriveOpenShortContractEvent + PauserUpdated: IERC4626HyperdrivePauserUpdatedContractEvent + RedeemWithdrawalShares: IERC4626HyperdriveRedeemWithdrawalSharesContractEvent RemoveLiquidity: IERC4626HyperdriveRemoveLiquidityContractEvent @@ -2774,6 +2933,12 @@ def __init__( "CreateCheckpoint", w3=w3, contract_abi=abi, address=address, event_name="CreateCheckpoint" ), ) + self.GovernanceUpdated = cast( + IERC4626HyperdriveGovernanceUpdatedContractEvent, + IERC4626HyperdriveGovernanceUpdatedContractEvent.factory( + "GovernanceUpdated", w3=w3, contract_abi=abi, address=address, event_name="GovernanceUpdated" + ), + ) self.Initialize = cast( IERC4626HyperdriveInitializeContractEvent, IERC4626HyperdriveInitializeContractEvent.factory( @@ -2792,6 +2957,12 @@ def __init__( "OpenShort", w3=w3, contract_abi=abi, address=address, event_name="OpenShort" ), ) + self.PauserUpdated = cast( + IERC4626HyperdrivePauserUpdatedContractEvent, + IERC4626HyperdrivePauserUpdatedContractEvent.factory( + "PauserUpdated", w3=w3, contract_abi=abi, address=address, event_name="PauserUpdated" + ), + ) self.RedeemWithdrawalShares = cast( IERC4626HyperdriveRedeemWithdrawalSharesContractEvent, IERC4626HyperdriveRedeemWithdrawalSharesContractEvent.factory( @@ -2834,6 +3005,7 @@ def __init__( "name": "addLiquidity", "inputs": [ {"name": "_contribution", "type": "uint256", "internalType": "uint256"}, + {"name": "_minLpSharePrice", "type": "uint256", "internalType": "uint256"}, {"name": "_minApr", "type": "uint256", "internalType": "uint256"}, {"name": "_maxApr", "type": "uint256", "internalType": "uint256"}, { @@ -2955,7 +3127,7 @@ def __init__( "name": "", "type": "tuple", "internalType": "struct IHyperdrive.Checkpoint", - "components": [{"name": "sharePrice", "type": "uint128", "internalType": "uint128"}], + "components": [{"name": "vaultSharePrice", "type": "uint128", "internalType": "uint128"}], } ], "stateMutability": "view", @@ -3007,7 +3179,7 @@ def __init__( {"name": "baseToken", "type": "address", "internalType": "contract IERC20"}, {"name": "linkerFactory", "type": "address", "internalType": "address"}, {"name": "linkerCodeHash", "type": "bytes32", "internalType": "bytes32"}, - {"name": "initialSharePrice", "type": "uint256", "internalType": "uint256"}, + {"name": "initialVaultSharePrice", "type": "uint256", "internalType": "uint256"}, {"name": "minimumShareReserves", "type": "uint256", "internalType": "uint256"}, {"name": "minimumTransactionAmount", "type": "uint256", "internalType": "uint256"}, {"name": "positionDuration", "type": "uint256", "internalType": "uint256"}, @@ -3047,7 +3219,7 @@ def __init__( {"name": "zombieShareReserves", "type": "uint256", "internalType": "uint256"}, {"name": "bondReserves", "type": "uint256", "internalType": "uint256"}, {"name": "lpTotalSupply", "type": "uint256", "internalType": "uint256"}, - {"name": "sharePrice", "type": "uint256", "internalType": "uint256"}, + {"name": "vaultSharePrice", "type": "uint256", "internalType": "uint256"}, {"name": "longsOutstanding", "type": "uint256", "internalType": "uint256"}, {"name": "longAverageMaturityTime", "type": "uint256", "internalType": "uint256"}, {"name": "shortsOutstanding", "type": "uint256", "internalType": "uint256"}, @@ -3142,7 +3314,7 @@ def __init__( "inputs": [ {"name": "_baseAmount", "type": "uint256", "internalType": "uint256"}, {"name": "_minOutput", "type": "uint256", "internalType": "uint256"}, - {"name": "_minSharePrice", "type": "uint256", "internalType": "uint256"}, + {"name": "_minVaultSharePrice", "type": "uint256", "internalType": "uint256"}, { "name": "_options", "type": "tuple", @@ -3166,7 +3338,7 @@ def __init__( "inputs": [ {"name": "_bondAmount", "type": "uint256", "internalType": "uint256"}, {"name": "_maxDeposit", "type": "uint256", "internalType": "uint256"}, - {"name": "_minSharePrice", "type": "uint256", "internalType": "uint256"}, + {"name": "_minVaultSharePrice", "type": "uint256", "internalType": "uint256"}, { "name": "_options", "type": "tuple", @@ -3217,13 +3389,6 @@ def __init__( "outputs": [], "stateMutability": "nonpayable", }, - { - "type": "function", - "name": "pool", - "inputs": [], - "outputs": [{"name": "", "type": "address", "internalType": "contract IERC4626"}], - "stateMutability": "view", - }, { "type": "function", "name": "redeemWithdrawalShares", @@ -3394,6 +3559,13 @@ def __init__( "outputs": [], "stateMutability": "nonpayable", }, + { + "type": "function", + "name": "vault", + "inputs": [], + "outputs": [{"name": "", "type": "address", "internalType": "contract IERC4626"}], + "stateMutability": "view", + }, { "type": "event", "name": "AddLiquidity", @@ -3401,7 +3573,7 @@ def __init__( {"name": "provider", "type": "address", "indexed": True, "internalType": "address"}, {"name": "lpAmount", "type": "uint256", "indexed": False, "internalType": "uint256"}, {"name": "baseAmount", "type": "uint256", "indexed": False, "internalType": "uint256"}, - {"name": "sharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, + {"name": "vaultSharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, {"name": "lpSharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, ], "anonymous": False, @@ -3434,7 +3606,7 @@ def __init__( {"name": "assetId", "type": "uint256", "indexed": True, "internalType": "uint256"}, {"name": "maturityTime", "type": "uint256", "indexed": False, "internalType": "uint256"}, {"name": "baseAmount", "type": "uint256", "indexed": False, "internalType": "uint256"}, - {"name": "sharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, + {"name": "vaultSharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, {"name": "bondAmount", "type": "uint256", "indexed": False, "internalType": "uint256"}, ], "anonymous": False, @@ -3447,7 +3619,7 @@ def __init__( {"name": "assetId", "type": "uint256", "indexed": True, "internalType": "uint256"}, {"name": "maturityTime", "type": "uint256", "indexed": False, "internalType": "uint256"}, {"name": "baseAmount", "type": "uint256", "indexed": False, "internalType": "uint256"}, - {"name": "sharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, + {"name": "vaultSharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, {"name": "bondAmount", "type": "uint256", "indexed": False, "internalType": "uint256"}, ], "anonymous": False, @@ -3457,8 +3629,7 @@ def __init__( "name": "CollectGovernanceFee", "inputs": [ {"name": "collector", "type": "address", "indexed": True, "internalType": "address"}, - {"name": "baseFees", "type": "uint256", "indexed": False, "internalType": "uint256"}, - {"name": "sharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, + {"name": "fees", "type": "uint256", "indexed": False, "internalType": "uint256"}, ], "anonymous": False, }, @@ -3467,13 +3638,19 @@ def __init__( "name": "CreateCheckpoint", "inputs": [ {"name": "checkpointTime", "type": "uint256", "indexed": True, "internalType": "uint256"}, - {"name": "sharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, + {"name": "vaultSharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, {"name": "maturedShorts", "type": "uint256", "indexed": False, "internalType": "uint256"}, {"name": "maturedLongs", "type": "uint256", "indexed": False, "internalType": "uint256"}, {"name": "lpSharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, ], "anonymous": False, }, + { + "type": "event", + "name": "GovernanceUpdated", + "inputs": [{"name": "newGovernance", "type": "address", "indexed": True, "internalType": "address"}], + "anonymous": False, + }, { "type": "event", "name": "Initialize", @@ -3481,7 +3658,7 @@ def __init__( {"name": "provider", "type": "address", "indexed": True, "internalType": "address"}, {"name": "lpAmount", "type": "uint256", "indexed": False, "internalType": "uint256"}, {"name": "baseAmount", "type": "uint256", "indexed": False, "internalType": "uint256"}, - {"name": "sharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, + {"name": "vaultSharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, {"name": "apr", "type": "uint256", "indexed": False, "internalType": "uint256"}, ], "anonymous": False, @@ -3494,7 +3671,7 @@ def __init__( {"name": "assetId", "type": "uint256", "indexed": True, "internalType": "uint256"}, {"name": "maturityTime", "type": "uint256", "indexed": False, "internalType": "uint256"}, {"name": "baseAmount", "type": "uint256", "indexed": False, "internalType": "uint256"}, - {"name": "sharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, + {"name": "vaultSharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, {"name": "bondAmount", "type": "uint256", "indexed": False, "internalType": "uint256"}, ], "anonymous": False, @@ -3507,11 +3684,17 @@ def __init__( {"name": "assetId", "type": "uint256", "indexed": True, "internalType": "uint256"}, {"name": "maturityTime", "type": "uint256", "indexed": False, "internalType": "uint256"}, {"name": "baseAmount", "type": "uint256", "indexed": False, "internalType": "uint256"}, - {"name": "sharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, + {"name": "vaultSharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, {"name": "bondAmount", "type": "uint256", "indexed": False, "internalType": "uint256"}, ], "anonymous": False, }, + { + "type": "event", + "name": "PauserUpdated", + "inputs": [{"name": "newPauser", "type": "address", "indexed": True, "internalType": "address"}], + "anonymous": False, + }, { "type": "event", "name": "RedeemWithdrawalShares", @@ -3519,7 +3702,7 @@ def __init__( {"name": "provider", "type": "address", "indexed": True, "internalType": "address"}, {"name": "withdrawalShareAmount", "type": "uint256", "indexed": False, "internalType": "uint256"}, {"name": "baseAmount", "type": "uint256", "indexed": False, "internalType": "uint256"}, - {"name": "sharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, + {"name": "vaultSharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, ], "anonymous": False, }, @@ -3530,7 +3713,7 @@ def __init__( {"name": "provider", "type": "address", "indexed": True, "internalType": "address"}, {"name": "lpAmount", "type": "uint256", "indexed": False, "internalType": "uint256"}, {"name": "baseAmount", "type": "uint256", "indexed": False, "internalType": "uint256"}, - {"name": "sharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, + {"name": "vaultSharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, {"name": "withdrawalShareAmount", "type": "uint256", "indexed": False, "internalType": "uint256"}, {"name": "lpSharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"}, ], @@ -3548,82 +3731,48 @@ def __init__( ], "anonymous": False, }, - {"type": "error", "name": "AlreadyClosed", "inputs": []}, {"type": "error", "name": "BatchInputLengthMismatch", "inputs": []}, {"type": "error", "name": "BelowMinimumContribution", "inputs": []}, - {"type": "error", "name": "BelowMinimumShareReserves", "inputs": []}, - {"type": "error", "name": "BondMatured", "inputs": []}, - {"type": "error", "name": "BondNotMatured", "inputs": []}, + {"type": "error", "name": "ExpInvalidExponent", "inputs": []}, + {"type": "error", "name": "ExpiredDeadline", "inputs": []}, { "type": "error", - "name": "CallFailed", - "inputs": [{"name": "underlyingError", "type": "bytes4", "internalType": "bytes4"}], + "name": "InsufficientLiquidity", + "inputs": [ + {"name": "reason", "type": "uint8", "internalType": "enum IHyperdrive.InsufficientLiquidityReason"} + ], }, - {"type": "error", "name": "EndIndexTooLarge", "inputs": []}, - {"type": "error", "name": "ExpiredDeadline", "inputs": []}, - {"type": "error", "name": "FeeTooHigh", "inputs": []}, - {"type": "error", "name": "FixedPointMath_InvalidExponent", "inputs": []}, - {"type": "error", "name": "FixedPointMath_InvalidInput", "inputs": []}, - {"type": "error", "name": "FixedPointMath_NegativeInput", "inputs": []}, - {"type": "error", "name": "FixedPointMath_NegativeOrZeroInput", "inputs": []}, - {"type": "error", "name": "HyperdriveDeployerAlreadyAdded", "inputs": []}, - {"type": "error", "name": "HyperdriveDeployerIndexMismatch", "inputs": []}, - {"type": "error", "name": "HyperdriveDeployerNotAdded", "inputs": []}, - {"type": "error", "name": "InputLengthMismatch", "inputs": []}, - {"type": "error", "name": "InsufficientLiquidity", "inputs": []}, - {"type": "error", "name": "InsufficientPrice", "inputs": []}, {"type": "error", "name": "InvalidApr", "inputs": []}, {"type": "error", "name": "InvalidBaseToken", "inputs": []}, {"type": "error", "name": "InvalidCheckpointDuration", "inputs": []}, {"type": "error", "name": "InvalidCheckpointTime", "inputs": []}, - {"type": "error", "name": "InvalidContribution", "inputs": []}, - {"type": "error", "name": "InvalidDeployer", "inputs": []}, {"type": "error", "name": "InvalidERC20Bridge", "inputs": []}, {"type": "error", "name": "InvalidFeeAmounts", "inputs": []}, {"type": "error", "name": "InvalidFeeDestination", "inputs": []}, - {"type": "error", "name": "InvalidForwarderAddress", "inputs": []}, - {"type": "error", "name": "InvalidIndexes", "inputs": []}, - {"type": "error", "name": "InvalidInitialSharePrice", "inputs": []}, - {"type": "error", "name": "InvalidMaturityTime", "inputs": []}, + {"type": "error", "name": "InvalidInitialVaultSharePrice", "inputs": []}, {"type": "error", "name": "InvalidMinimumShareReserves", "inputs": []}, {"type": "error", "name": "InvalidPositionDuration", "inputs": []}, - { - "type": "error", - "name": "InvalidRecipient", - "inputs": [{"name": "recipient", "type": "address", "internalType": "address"}], - }, {"type": "error", "name": "InvalidShareReserves", "inputs": []}, {"type": "error", "name": "InvalidSignature", "inputs": []}, {"type": "error", "name": "InvalidTimestamp", "inputs": []}, - {"type": "error", "name": "InvalidToken", "inputs": []}, - {"type": "error", "name": "InvalidTradeSize", "inputs": []}, - {"type": "error", "name": "MaxFeeTooHigh", "inputs": []}, + {"type": "error", "name": "LnInvalidInput", "inputs": []}, {"type": "error", "name": "MinimumSharePrice", "inputs": []}, {"type": "error", "name": "MinimumTransactionAmount", "inputs": []}, - {"type": "error", "name": "MintPercentTooHigh", "inputs": []}, - {"type": "error", "name": "NegativeInterest", "inputs": []}, {"type": "error", "name": "NegativePresentValue", "inputs": []}, - {"type": "error", "name": "NoAssetsToWithdraw", "inputs": []}, - {"type": "error", "name": "NonPayableInitialization", "inputs": []}, {"type": "error", "name": "NotPayable", "inputs": []}, {"type": "error", "name": "OutputLimit", "inputs": []}, - {"type": "error", "name": "Paused", "inputs": []}, {"type": "error", "name": "PoolAlreadyInitialized", "inputs": []}, - {"type": "error", "name": "QueryOutOfRange", "inputs": []}, + {"type": "error", "name": "PoolIsPaused", "inputs": []}, {"type": "error", "name": "RestrictedZeroAddress", "inputs": []}, {"type": "error", "name": "ReturnData", "inputs": [{"name": "data", "type": "bytes", "internalType": "bytes"}]}, - {"type": "error", "name": "ShareReservesDeltaExceedsBondReservesDelta", "inputs": []}, {"type": "error", "name": "SweepFailed", "inputs": []}, {"type": "error", "name": "TransferFailed", "inputs": []}, {"type": "error", "name": "Unauthorized", "inputs": []}, - {"type": "error", "name": "UnexpectedAssetId", "inputs": []}, - {"type": "error", "name": "UnexpectedSender", "inputs": []}, {"type": "error", "name": "UnexpectedSuccess", "inputs": []}, {"type": "error", "name": "UnsafeCastToInt128", "inputs": []}, {"type": "error", "name": "UnsafeCastToUint112", "inputs": []}, {"type": "error", "name": "UnsafeCastToUint128", "inputs": []}, {"type": "error", "name": "UnsupportedToken", "inputs": []}, - {"type": "error", "name": "ZeroLpTotalSupply", "inputs": []}, ], ) # pylint: disable=line-too-long diff --git a/crates/hyperdrivepy/python/hyperdrivepy/pypechain_types/IERC4626HyperdriveTypes.py b/crates/hyperdrivepy/python/hyperdrivepy/pypechain_types/IERC4626HyperdriveTypes.py index 06105ea..113bbe8 100644 --- a/crates/hyperdrivepy/python/hyperdrivepy/pypechain_types/IERC4626HyperdriveTypes.py +++ b/crates/hyperdrivepy/python/hyperdrivepy/pypechain_types/IERC4626HyperdriveTypes.py @@ -17,109 +17,15 @@ # pylint: disable=no-else-return from __future__ import annotations -from dataclasses import dataclass - from web3.types import ABIEvent, ABIEventParams - -@dataclass -class Options: - """Options struct.""" - - destination: str - asBase: bool - extraData: bytes - - -@dataclass -class Checkpoint: - """Checkpoint struct.""" - - sharePrice: int - - -@dataclass -class MarketState: - """MarketState struct.""" - - shareReserves: int - bondReserves: int - longExposure: int - longsOutstanding: int - shareAdjustment: int - shortsOutstanding: int - longAverageMaturityTime: int - shortAverageMaturityTime: int - isInitialized: bool - isPaused: bool - zombieBaseProceeds: uint112 - zombieShareReserves: int - - -@dataclass -class Fees: - """Fees struct.""" - - curve: int - flat: int - governanceLP: int - governanceZombie: int - - -@dataclass -class PoolConfig: - """PoolConfig struct.""" - - baseToken: str - linkerFactory: str - linkerCodeHash: bytes - initialSharePrice: int - minimumShareReserves: int - minimumTransactionAmount: int - positionDuration: int - checkpointDuration: int - timeStretch: int - governance: str - feeCollector: str - fees: Fees - - -@dataclass -class PoolInfo: - """PoolInfo struct.""" - - shareReserves: int - shareAdjustment: int - zombieBaseProceeds: int - zombieShareReserves: int - bondReserves: int - lpTotalSupply: int - sharePrice: int - longsOutstanding: int - longAverageMaturityTime: int - shortsOutstanding: int - shortAverageMaturityTime: int - withdrawalSharesReadyToWithdraw: int - withdrawalSharesProceeds: int - lpSharePrice: int - longExposure: int - - -@dataclass -class WithdrawPool: - """WithdrawPool struct.""" - - readyToWithdraw: int - proceeds: int - - AddLiquidity = ABIEvent( anonymous=False, inputs=[ ABIEventParams(indexed=True, name="provider", type="address"), ABIEventParams(indexed=False, name="lpAmount", type="uint256"), ABIEventParams(indexed=False, name="baseAmount", type="uint256"), - ABIEventParams(indexed=False, name="sharePrice", type="uint256"), + ABIEventParams(indexed=False, name="vaultSharePrice", type="uint256"), ABIEventParams(indexed=False, name="lpSharePrice", type="uint256"), ], name="AddLiquidity", @@ -155,7 +61,7 @@ class WithdrawPool: ABIEventParams(indexed=True, name="assetId", type="uint256"), ABIEventParams(indexed=False, name="maturityTime", type="uint256"), ABIEventParams(indexed=False, name="baseAmount", type="uint256"), - ABIEventParams(indexed=False, name="sharePrice", type="uint256"), + ABIEventParams(indexed=False, name="vaultSharePrice", type="uint256"), ABIEventParams(indexed=False, name="bondAmount", type="uint256"), ], name="CloseLong", @@ -169,7 +75,7 @@ class WithdrawPool: ABIEventParams(indexed=True, name="assetId", type="uint256"), ABIEventParams(indexed=False, name="maturityTime", type="uint256"), ABIEventParams(indexed=False, name="baseAmount", type="uint256"), - ABIEventParams(indexed=False, name="sharePrice", type="uint256"), + ABIEventParams(indexed=False, name="vaultSharePrice", type="uint256"), ABIEventParams(indexed=False, name="bondAmount", type="uint256"), ], name="CloseShort", @@ -180,8 +86,7 @@ class WithdrawPool: anonymous=False, inputs=[ ABIEventParams(indexed=True, name="collector", type="address"), - ABIEventParams(indexed=False, name="baseFees", type="uint256"), - ABIEventParams(indexed=False, name="sharePrice", type="uint256"), + ABIEventParams(indexed=False, name="fees", type="uint256"), ], name="CollectGovernanceFee", type="event", @@ -191,7 +96,7 @@ class WithdrawPool: anonymous=False, inputs=[ ABIEventParams(indexed=True, name="checkpointTime", type="uint256"), - ABIEventParams(indexed=False, name="sharePrice", type="uint256"), + ABIEventParams(indexed=False, name="vaultSharePrice", type="uint256"), ABIEventParams(indexed=False, name="maturedShorts", type="uint256"), ABIEventParams(indexed=False, name="maturedLongs", type="uint256"), ABIEventParams(indexed=False, name="lpSharePrice", type="uint256"), @@ -200,13 +105,22 @@ class WithdrawPool: type="event", ) +GovernanceUpdated = ABIEvent( + anonymous=False, + inputs=[ + ABIEventParams(indexed=True, name="newGovernance", type="address"), + ], + name="GovernanceUpdated", + type="event", +) + Initialize = ABIEvent( anonymous=False, inputs=[ ABIEventParams(indexed=True, name="provider", type="address"), ABIEventParams(indexed=False, name="lpAmount", type="uint256"), ABIEventParams(indexed=False, name="baseAmount", type="uint256"), - ABIEventParams(indexed=False, name="sharePrice", type="uint256"), + ABIEventParams(indexed=False, name="vaultSharePrice", type="uint256"), ABIEventParams(indexed=False, name="apr", type="uint256"), ], name="Initialize", @@ -220,7 +134,7 @@ class WithdrawPool: ABIEventParams(indexed=True, name="assetId", type="uint256"), ABIEventParams(indexed=False, name="maturityTime", type="uint256"), ABIEventParams(indexed=False, name="baseAmount", type="uint256"), - ABIEventParams(indexed=False, name="sharePrice", type="uint256"), + ABIEventParams(indexed=False, name="vaultSharePrice", type="uint256"), ABIEventParams(indexed=False, name="bondAmount", type="uint256"), ], name="OpenLong", @@ -234,20 +148,29 @@ class WithdrawPool: ABIEventParams(indexed=True, name="assetId", type="uint256"), ABIEventParams(indexed=False, name="maturityTime", type="uint256"), ABIEventParams(indexed=False, name="baseAmount", type="uint256"), - ABIEventParams(indexed=False, name="sharePrice", type="uint256"), + ABIEventParams(indexed=False, name="vaultSharePrice", type="uint256"), ABIEventParams(indexed=False, name="bondAmount", type="uint256"), ], name="OpenShort", type="event", ) +PauserUpdated = ABIEvent( + anonymous=False, + inputs=[ + ABIEventParams(indexed=True, name="newPauser", type="address"), + ], + name="PauserUpdated", + type="event", +) + RedeemWithdrawalShares = ABIEvent( anonymous=False, inputs=[ ABIEventParams(indexed=True, name="provider", type="address"), ABIEventParams(indexed=False, name="withdrawalShareAmount", type="uint256"), ABIEventParams(indexed=False, name="baseAmount", type="uint256"), - ABIEventParams(indexed=False, name="sharePrice", type="uint256"), + ABIEventParams(indexed=False, name="vaultSharePrice", type="uint256"), ], name="RedeemWithdrawalShares", type="event", @@ -259,7 +182,7 @@ class WithdrawPool: ABIEventParams(indexed=True, name="provider", type="address"), ABIEventParams(indexed=False, name="lpAmount", type="uint256"), ABIEventParams(indexed=False, name="baseAmount", type="uint256"), - ABIEventParams(indexed=False, name="sharePrice", type="uint256"), + ABIEventParams(indexed=False, name="vaultSharePrice", type="uint256"), ABIEventParams(indexed=False, name="withdrawalShareAmount", type="uint256"), ABIEventParams(indexed=False, name="lpSharePrice", type="uint256"), ], diff --git a/crates/hyperdrivepy/python/hyperdrivepy/pypechain_types/IHyperdriveTypes.py b/crates/hyperdrivepy/python/hyperdrivepy/pypechain_types/IHyperdriveTypes.py new file mode 100644 index 0000000..4b9f420 --- /dev/null +++ b/crates/hyperdrivepy/python/hyperdrivepy/pypechain_types/IHyperdriveTypes.py @@ -0,0 +1,111 @@ +"""Dataclasses for all structs in the IHyperdrive contract. + +DO NOT EDIT. This file was generated by pypechain. See documentation at +https://github.com/delvtech/pypechain """ + +# super() call methods are generic, while our version adds values & types +# pylint: disable=arguments-differ +# contracts have PascalCase names +# pylint: disable=invalid-name +# contracts control how many attributes and arguments we have in generated code +# pylint: disable=too-many-instance-attributes +# pylint: disable=too-many-arguments +# unable to determine which imports will be used in the generated code +# pylint: disable=unused-import +# we don't need else statement if the other conditionals all have return, +# but it's easier to generate +# pylint: disable=no-else-return +from __future__ import annotations + +from dataclasses import dataclass + + +@dataclass +class Options: + """Options struct.""" + + destination: str + asBase: bool + extraData: bytes + + +@dataclass +class Checkpoint: + """Checkpoint struct.""" + + vaultSharePrice: int + + +@dataclass +class MarketState: + """MarketState struct.""" + + shareReserves: int + bondReserves: int + longExposure: int + longsOutstanding: int + shareAdjustment: int + shortsOutstanding: int + longAverageMaturityTime: int + shortAverageMaturityTime: int + isInitialized: bool + isPaused: bool + zombieBaseProceeds: int + zombieShareReserves: int + + +@dataclass +class Fees: + """Fees struct.""" + + curve: int + flat: int + governanceLP: int + governanceZombie: int + + +@dataclass +class PoolConfig: + """PoolConfig struct.""" + + baseToken: str + linkerFactory: str + linkerCodeHash: bytes + initialVaultSharePrice: int + minimumShareReserves: int + minimumTransactionAmount: int + positionDuration: int + checkpointDuration: int + timeStretch: int + governance: str + feeCollector: str + fees: Fees + + +@dataclass +class PoolInfo: + """PoolInfo struct.""" + + shareReserves: int + shareAdjustment: int + zombieBaseProceeds: int + zombieShareReserves: int + bondReserves: int + lpTotalSupply: int + vaultSharePrice: int + longsOutstanding: int + longAverageMaturityTime: int + shortsOutstanding: int + shortAverageMaturityTime: int + withdrawalSharesReadyToWithdraw: int + withdrawalSharesProceeds: int + lpSharePrice: int + longExposure: int + + +@dataclass +class WithdrawPool: + """WithdrawPool struct.""" + + readyToWithdraw: int + proceeds: int diff --git a/crates/hyperdrivepy/python/hyperdrivepy/pypechain_types/__init__.py b/crates/hyperdrivepy/python/hyperdrivepy/pypechain_types/__init__.py index 99b82f7..1637097 100644 --- a/crates/hyperdrivepy/python/hyperdrivepy/pypechain_types/__init__.py +++ b/crates/hyperdrivepy/python/hyperdrivepy/pypechain_types/__init__.py @@ -3,5 +3,10 @@ DO NOT EDIT. This file was generated by pypechain. See documentation at https://github.com/delvtech/pypechain""" +# python 3.10 causes this warning when sibling/child files import from one of the files listed here. +# remove this pylint diable when we upgreade to 3.11 +# pylint: disable=import-self + from .IERC4626HyperdriveContract import * from .IERC4626HyperdriveTypes import * +from .IHyperdriveTypes import * diff --git a/crates/hyperdrivepy/python/hyperdrivepy/pypechain_types/utilities.py b/crates/hyperdrivepy/python/hyperdrivepy/pypechain_types/utilities.py index 3c3b5c6..6d40773 100644 --- a/crates/hyperdrivepy/python/hyperdrivepy/pypechain_types/utilities.py +++ b/crates/hyperdrivepy/python/hyperdrivepy/pypechain_types/utilities.py @@ -2,6 +2,7 @@ DO NOT EDIT. This file was generated by pypechain. See documentation at https://github.com/delvtech/pypechain""" + from __future__ import annotations from dataclasses import fields, is_dataclass @@ -15,8 +16,8 @@ def tuple_to_dataclass(cls: type[T], structs: dict[str, Any], tuple_data: Any | Converts a tuple (including nested tuples) to a dataclass instance. If cls is not a dataclass, then the data will just be passed through this function. - Arguments - --------- + Parameters + ---------- cls: type[T] The dataclass type to which the tuple data is to be converted. tuple_data: Any | Tuple[Any, ...] @@ -88,8 +89,8 @@ def rename_returned_types( Returns ------- - tup - _description_ + tuple + The return types. """ # cover case of multiple return values if isinstance(return_types, list): diff --git a/crates/hyperdrivepy/python/hyperdrivepy/types.py b/crates/hyperdrivepy/python/hyperdrivepy/types.py index 64694b7..029d58b 100644 --- a/crates/hyperdrivepy/python/hyperdrivepy/types.py +++ b/crates/hyperdrivepy/python/hyperdrivepy/types.py @@ -1,4 +1,5 @@ """Types for the hyperdrive contract.""" + # contracts have PascalCase names # pylint: disable=invalid-name # We do not define the number of instance attributes @@ -27,7 +28,7 @@ class PoolConfig: baseToken: str linkerFactory: str linkerCodeHash: str - initialSharePrice: str + initialVaultSharePrice: str minimumShareReserves: str minimumTransactionAmount: str positionDuration: str @@ -48,7 +49,7 @@ class PoolInfo: zombieShareReserves: str bondReserves: str lpTotalSupply: str - sharePrice: str + vaultSharePrice: str longsOutstanding: str longAverageMaturityTime: str shortsOutstanding: str @@ -63,7 +64,7 @@ class PoolInfo: class CheckpointType(Protocol): """Checkpoint struct.""" - sharePrice: int + vaultSharePrice: int longExposure: int @@ -97,7 +98,7 @@ class PoolConfigType(Protocol): baseToken: str linkerFactory: str linkerCodeHash: bytes - initialSharePrice: int + initialVaultSharePrice: int minimumShareReserves: int minimumTransactionAmount: int positionDuration: int @@ -117,7 +118,7 @@ class PoolInfoType(Protocol): zombieBaseProceeds: int zombieShareReserves: int lpTotalSupply: int - sharePrice: int + vaultSharePrice: int longsOutstanding: int longAverageMaturityTime: int shortsOutstanding: int diff --git a/crates/hyperdrivepy/python/hyperdrivepy/utils.py b/crates/hyperdrivepy/python/hyperdrivepy/utils.py index bca81c0..42697a9 100644 --- a/crates/hyperdrivepy/python/hyperdrivepy/utils.py +++ b/crates/hyperdrivepy/python/hyperdrivepy/utils.py @@ -1,4 +1,5 @@ """Helper functions for the wrappers.""" + # pylint: disable=no-name-in-module from . import hyperdrivepy as rust_module # type: ignore from . import types @@ -20,7 +21,7 @@ def _serialize_pool_config( baseToken=str(pool_config.baseToken), linkerFactory=str(pool_config.linkerFactory), linkerCodeHash=pool_config.linkerCodeHash.hex(), # bytes to string in hex format - initialSharePrice=str(pool_config.initialSharePrice), + initialVaultSharePrice=str(pool_config.initialVaultSharePrice), minimumShareReserves=str(pool_config.minimumShareReserves), minimumTransactionAmount=str(pool_config.minimumTransactionAmount), positionDuration=str(pool_config.positionDuration), @@ -45,7 +46,7 @@ def _serialize_pool_info(pool_info: types.PoolInfoType) -> types.PoolInfo: zombieShareReserves=str(pool_info.zombieShareReserves), bondReserves=str(pool_info.bondReserves), lpTotalSupply=str(pool_info.lpTotalSupply), - sharePrice=str(pool_info.sharePrice), + vaultSharePrice=str(pool_info.vaultSharePrice), longsOutstanding=str(pool_info.longsOutstanding), longAverageMaturityTime=str(pool_info.longAverageMaturityTime), shortsOutstanding=str(pool_info.shortsOutstanding), diff --git a/crates/hyperdrivepy/setup.py b/crates/hyperdrivepy/setup.py index acf9842..7632e97 100644 --- a/crates/hyperdrivepy/setup.py +++ b/crates/hyperdrivepy/setup.py @@ -1,10 +1,11 @@ """Entry point for installing hyperdrive math python package""" + from setuptools import setup from setuptools_rust import Binding, RustExtension setup( name="hyperdrivepy", - version="0.5.1", + version="0.6.0", packages=["hyperdrivepy"], package_dir={"": "python"}, rust_extensions=[ diff --git a/crates/hyperdrivepy/src/hyperdrive_state_methods.rs b/crates/hyperdrivepy/src/hyperdrive_state_methods.rs index 8b4c3a9..d437418 100644 --- a/crates/hyperdrivepy/src/hyperdrive_state_methods.rs +++ b/crates/hyperdrivepy/src/hyperdrive_state_methods.rs @@ -89,7 +89,7 @@ impl HyperdriveState { &self, short_amount: &str, spot_price: &str, - open_share_price: &str, + open_vault_share_price: &str, ) -> PyResult { let short_amount_fp = FixedPoint::from(U256::from_dec_str(short_amount).map_err(|_| { PyErr::new::("Failed to convert short_amount string to U256") @@ -97,13 +97,13 @@ impl HyperdriveState { let spot_price_fp = FixedPoint::from(U256::from_dec_str(spot_price).map_err(|_| { PyErr::new::("Failed to convert spot_price string to U256") })?); - let open_share_price_fp = - FixedPoint::from(U256::from_dec_str(open_share_price).map_err(|_| { - PyErr::new::("Failed to convert open_share_price string to U256") + let open_vault_share_price_fp = + FixedPoint::from(U256::from_dec_str(open_vault_share_price).map_err(|_| { + PyErr::new::("Failed to convert open_vault_share_price string to U256") })?); let result_fp = self .state - .calculate_open_short(short_amount_fp, spot_price_fp, open_share_price_fp) + .calculate_open_short(short_amount_fp, spot_price_fp, open_vault_share_price_fp) .unwrap(); let result = U256::from(result_fp).to_string(); return Ok(result); @@ -112,20 +112,20 @@ impl HyperdriveState { pub fn calculate_close_short( &self, bond_amount: &str, - open_share_price: &str, - close_share_price: &str, + open_vault_share_price: &str, + close_vault_share_price: &str, normalized_time_remaining: &str, ) -> PyResult { let bond_amount_fp = FixedPoint::from(U256::from_dec_str(bond_amount).map_err(|_| { PyErr::new::("Failed to convert bond_amount string to U256") })?); - let open_share_price_fp = - FixedPoint::from(U256::from_dec_str(open_share_price).map_err(|_| { - PyErr::new::("Failed to convert open_share_price string to U256") + let open_vault_share_price_fp = + FixedPoint::from(U256::from_dec_str(open_vault_share_price).map_err(|_| { + PyErr::new::("Failed to convert open_vault_share_price string to U256") })?); - let close_share_price_fp = - FixedPoint::from(U256::from_dec_str(close_share_price).map_err(|_| { - PyErr::new::("Failed to convert close_share_price string to U256") + let close_vault_share_price_fp = + FixedPoint::from(U256::from_dec_str(close_vault_share_price).map_err(|_| { + PyErr::new::("Failed to convert close_vault_share_price string to U256") })?); let normalized_time_remaining_fp = FixedPoint::from(U256::from_dec_str(normalized_time_remaining).map_err(|_| { @@ -135,8 +135,8 @@ impl HyperdriveState { })?); let result_fp = self.state.calculate_close_short( bond_amount_fp, - open_share_price_fp, - close_share_price_fp, + open_vault_share_price_fp, + close_vault_share_price_fp, normalized_time_remaining_fp, ); let result = U256::from(result_fp).to_string(); @@ -217,7 +217,7 @@ impl HyperdriveState { pub fn get_max_short( &self, budget: &str, - open_share_price: &str, + open_vault_share_price: &str, checkpoint_exposure: &str, maybe_conservative_price: Option<&str>, maybe_max_iterations: Option, @@ -225,9 +225,9 @@ impl HyperdriveState { let budget_fp = FixedPoint::from(U256::from_dec_str(budget).map_err(|_| { PyErr::new::("Failed to convert budget string to U256") })?); - let open_share_price_fp = - FixedPoint::from(U256::from_dec_str(open_share_price).map_err(|_| { - PyErr::new::("Failed to convert open_share_price string to U256") + let open_vault_share_price_fp = + FixedPoint::from(U256::from_dec_str(open_vault_share_price).map_err(|_| { + PyErr::new::("Failed to convert open_vault_share_price string to U256") })?); let checkpoint_exposure_i = I256::from_dec_str(checkpoint_exposure).map_err(|_| { PyErr::new::("Failed to convert checkpoint_exposure string to I256") @@ -246,7 +246,7 @@ impl HyperdriveState { }; let result_fp = self.state.get_max_short( budget_fp, - open_share_price_fp, + open_vault_share_price_fp, checkpoint_exposure_i, maybe_conservative_price_fp, maybe_max_iterations, diff --git a/crates/hyperdrivepy/src/hyperdrive_utils.rs b/crates/hyperdrivepy/src/hyperdrive_utils.rs index 1aebe58..8998069 100644 --- a/crates/hyperdrivepy/src/hyperdrive_utils.rs +++ b/crates/hyperdrivepy/src/hyperdrive_utils.rs @@ -3,7 +3,7 @@ use fixed_point::FixedPoint; use pyo3::prelude::*; use pyo3::PyErr; -use pyo3::{exceptions::PyValueError, ffi::PyOS_InitInterrupts}; +use pyo3::exceptions::PyValueError; use hyperdrive_math::{ calculate_initial_bond_reserves as rs_calculate_initial_bond_reserves, @@ -14,7 +14,7 @@ use hyperdrive_math::{ #[pyfunction] pub fn calculate_initial_bond_reserves( effective_share_reserves: &str, - initial_share_price: &str, + initial_vault_share_price: &str, apr: &str, position_duration: &str, time_stretch: &str, @@ -25,9 +25,9 @@ pub fn calculate_initial_bond_reserves( "Failed to convert effective_share_reserves string to U256", ) })?); - let initial_share_price_fp = - FixedPoint::from(U256::from_dec_str(initial_share_price).map_err(|_| { - PyErr::new::("Failed to convert initial_share_price string to U256") + let initial_vault_share_price_fp = + FixedPoint::from(U256::from_dec_str(initial_vault_share_price).map_err(|_| { + PyErr::new::("Failed to convert initial_vault_share_price string to U256") })?); let apr_fp = FixedPoint::from( U256::from_dec_str(apr) @@ -42,7 +42,7 @@ pub fn calculate_initial_bond_reserves( })?); let result_fp = rs_calculate_initial_bond_reserves( effective_share_reserves_fp, - initial_share_price_fp, + initial_vault_share_price_fp, apr_fp, position_duration_fp, time_stretch_fp, diff --git a/crates/hyperdrivepy/src/lib.rs b/crates/hyperdrivepy/src/lib.rs index d9ec54d..7bbef52 100644 --- a/crates/hyperdrivepy/src/lib.rs +++ b/crates/hyperdrivepy/src/lib.rs @@ -14,10 +14,9 @@ pub use hyperdrive_utils::{ }; pub use pool_config::PyPoolConfig; pub use pool_info::PyPoolInfo; -pub use utils::*; /// Get the share reserves after subtracting the adjustment used for -/// A pyO3 wrapper for the hyperdrie_math crate. +/// A pyO3 wrapper for the hyperdrive_math crate. #[pymodule] #[pyo3(name = "hyperdrivepy")] fn hyperdrivepy(_py: Python<'_>, m: &PyModule) -> PyResult<()> { diff --git a/crates/hyperdrivepy/src/pool_config.rs b/crates/hyperdrivepy/src/pool_config.rs index 3005b75..c5e1aa5 100644 --- a/crates/hyperdrivepy/src/pool_config.rs +++ b/crates/hyperdrivepy/src/pool_config.rs @@ -20,7 +20,7 @@ impl FromPyObject<'_> for PyPoolConfig { let base_token = extract_address_from_attr(ob, "baseToken")?; let linker_factory = extract_address_from_attr(ob, "linkerFactory")?; let linker_code_hash = extract_bytes32_from_attr(ob, "linkerCodeHash")?; - let initial_share_price = extract_u256_from_attr(ob, "initialSharePrice")?; + let initial_vault_share_price = extract_u256_from_attr(ob, "initialVaultSharePrice")?; let minimum_share_reserves = extract_u256_from_attr(ob, "minimumShareReserves")?; let minimum_transaction_amount = extract_u256_from_attr(ob, "minimumTransactionAmount")?; let position_duration = extract_u256_from_attr(ob, "positionDuration")?; @@ -34,7 +34,7 @@ impl FromPyObject<'_> for PyPoolConfig { base_token, linker_factory, linker_code_hash, - initial_share_price, + initial_vault_share_price: initial_vault_share_price, minimum_share_reserves, minimum_transaction_amount, position_duration, diff --git a/crates/hyperdrivepy/src/pool_info.rs b/crates/hyperdrivepy/src/pool_info.rs index 179fe60..97cc3cb 100644 --- a/crates/hyperdrivepy/src/pool_info.rs +++ b/crates/hyperdrivepy/src/pool_info.rs @@ -20,7 +20,7 @@ impl FromPyObject<'_> for PyPoolInfo { let zombie_share_reserves = extract_u256_from_attr(ob, "zombieShareReserves")?; let bond_reserves = extract_u256_from_attr(ob, "bondReserves")?; let lp_total_supply = extract_u256_from_attr(ob, "lpTotalSupply")?; - let share_price = extract_u256_from_attr(ob, "sharePrice")?; + let vault_share_price = extract_u256_from_attr(ob, "vaultSharePrice")?; let longs_outstanding = extract_u256_from_attr(ob, "longsOutstanding")?; let long_average_maturity_time = extract_u256_from_attr(ob, "longAverageMaturityTime")?; let shorts_outstanding = extract_u256_from_attr(ob, "shortsOutstanding")?; @@ -38,7 +38,7 @@ impl FromPyObject<'_> for PyPoolInfo { zombie_share_reserves, bond_reserves, lp_total_supply, - share_price, + vault_share_price, longs_outstanding, long_average_maturity_time, shorts_outstanding, diff --git a/requirements-dev.txt b/requirements-dev.txt index 44576eb..9debde8 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,4 +1,4 @@ -black +black==24.* build cibuildwheel jinja2 diff --git a/system_tests/wrapper_tests.py b/system_tests/wrapper_tests.py index 0679164..29cdf58 100644 --- a/system_tests/wrapper_tests.py +++ b/system_tests/wrapper_tests.py @@ -1,13 +1,14 @@ """Tests for hyperdrive_math.rs wrappers""" + import hyperdrivepy import pytest -from hyperdrivepy.pypechain_types.IERC4626HyperdriveTypes import Fees, PoolConfig, PoolInfo +from hyperdrivepy.pypechain_types import Fees, PoolConfig, PoolInfo POOL_CONFIG = PoolConfig( baseToken="0x1234567890abcdef1234567890abcdef12345678", linkerFactory="0x1234567890abcdef1234567890abcdef12345678", linkerCodeHash=bytes(32), - initialSharePrice=1 * 10**18, # 1e18 + initialVaultSharePrice=1 * 10**18, # 1e18 minimumShareReserves=1 * 10**17, # 0.1e18 minimumTransactionAmount=1 * 10**16, # 0.001e18 positionDuration=60 * 60 * 24 * 365, # 1 year @@ -26,7 +27,7 @@ zombieShareReserves=0, bondReserves=2_000_000 * 10**18, lpTotalSupply=3_000_000 * 10**18, - sharePrice=1 * 10**18, + vaultSharePrice=1 * 10**18, longsOutstanding=0, longAverageMaturityTime=0, shortsOutstanding=0, @@ -123,7 +124,7 @@ def test_calculate_initial_bond_reserves(): ) bonds = hyperdrivepy.calculate_initial_bond_reserves( effective_share_reserves, - str(POOL_CONFIG.initialSharePrice), + str(POOL_CONFIG.initialVaultSharePrice), hyperdrivepy.get_spot_rate(POOL_CONFIG, POOL_INFO), str(POOL_CONFIG.positionDuration), str(POOL_CONFIG.timeStretch), @@ -180,16 +181,16 @@ def test_calculate_open_short(): """Test for calculate_open_short.""" short_amount = str(50 * 10**18) spot_price = hyperdrivepy.get_spot_price(POOL_CONFIG, POOL_INFO) - open_share_price = str(9 * 10**17) + open_vault_share_price = str(9 * 10**17) base_required = hyperdrivepy.calculate_open_short( - POOL_CONFIG, POOL_INFO, short_amount, spot_price, open_share_price + POOL_CONFIG, POOL_INFO, short_amount, spot_price, open_vault_share_price ) assert int(base_required) > 0 - base_required_default_share_price = hyperdrivepy.calculate_open_short( + base_required_default_vault_share_price = hyperdrivepy.calculate_open_short( POOL_CONFIG, POOL_INFO, short_amount, spot_price, None ) - assert int(base_required_default_share_price) > 0 - assert base_required_default_share_price == hyperdrivepy.calculate_open_short( + assert int(base_required_default_vault_share_price) > 0 + assert base_required_default_vault_share_price == hyperdrivepy.calculate_open_short( POOL_CONFIG, POOL_INFO, short_amount, spot_price, "0" ) @@ -197,11 +198,11 @@ def test_calculate_open_short(): def test_calculate_close_short(): """Test for calculate_close_short.""" short_amount = str(50 * 10**18) - open_share_price = str(8 * 10**17) - close_share_price = str(9 * 10**17) + open_vault_share_price = str(8 * 10**17) + close_vault_share_price = str(9 * 10**17) normalized_time_remaining = str(9 * 10**17) shares_received = hyperdrivepy.calculate_close_short( - POOL_CONFIG, POOL_INFO, short_amount, open_share_price, close_share_price, normalized_time_remaining + POOL_CONFIG, POOL_INFO, short_amount, open_vault_share_price, close_vault_share_price, normalized_time_remaining ) assert int(shares_received) > 0 @@ -237,7 +238,7 @@ def test_max_short(): """Test get_max_short.""" # test using the state directly budget = str(int(10 * 10**18)) # 10k base - open_share_price = str(int(1 * 10**18)) # 1 base + open_vault_share_price = str(int(1 * 10**18)) # 1 base checkpoint_exposure = str(0) conservative_price = None max_iterations = 20 @@ -245,7 +246,7 @@ def test_max_short(): POOL_CONFIG, POOL_INFO, budget, - open_share_price, + open_vault_share_price, checkpoint_exposure, conservative_price, max_iterations, @@ -255,7 +256,7 @@ def test_max_short(): def test_max_short_fail_conversion(): """Test get_max_short.""" - open_share_price = str(int(1 * 10**18)) # 1 base + open_vault_share_price = str(int(1 * 10**18)) # 1 base checkpoint_exposure = str(0) conservative_price = None max_iterations = 20 @@ -266,7 +267,7 @@ def test_max_short_fail_conversion(): POOL_CONFIG, POOL_INFO, budget, - open_share_price, + open_vault_share_price, checkpoint_exposure, conservative_price, max_iterations, @@ -277,19 +278,19 @@ def test_max_short_fail_conversion(): POOL_CONFIG, POOL_INFO, budget, - open_share_price, + open_vault_share_price, checkpoint_exposure, conservative_price, max_iterations, ) budget = "10000000000000000000000" # 10k base - open_share_price = "asdf" - with pytest.raises(ValueError, match="Failed to convert open_share_price string to U256"): + open_vault_share_price = "asdf" + with pytest.raises(ValueError, match="Failed to convert open_vault_share_price string to U256"): hyperdrivepy.get_max_short( POOL_CONFIG, POOL_INFO, budget, - open_share_price, + open_vault_share_price, checkpoint_exposure, conservative_price, max_iterations,