diff --git a/pyproject.toml b/pyproject.toml index 79d44a049f..85b8c8a8e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -152,9 +152,10 @@ unfixable = [] # We ignore the following rules: # D203: 1 blank line required before class docstring (incompatible with D211: no blank lines before class docstring) # D213: multi-line-summary-second-line (incompatible with D212: multi-line summary should start at the first line) +# D413: blank-line-after-last-section (not part of Numpy style guide) # D415: First line should end with a period, question mark, or exclamation point (in period-only D400) # D416: section-name-ends-in-colon (numpy style guide doesn't use colons after sections, i.e. Parameters) -ignore = ["D203", "D213", "D415", "D416"] +ignore = ["D203", "D213", "D413", "D415", "D416"] # Default is: pycodestyle (E) and Pyflakes (F) # We add flake8-builtins (A), pydocstyle (D), isort (I), pep8-naming (N), and pylint (PL). diff --git a/src/agent0/core/hyperdrive/agent/hyperdrive_wallet.py b/src/agent0/core/hyperdrive/agent/hyperdrive_wallet.py index 931246c060..376b5edb1a 100644 --- a/src/agent0/core/hyperdrive/agent/hyperdrive_wallet.py +++ b/src/agent0/core/hyperdrive/agent/hyperdrive_wallet.py @@ -62,6 +62,8 @@ class Short: """The amount of bonds that the position is short.""" maturity_time: int """The maturity time of the short.""" + open_vault_share_price: FixedPoint = FixedPoint(0) + """The vault share price at the time of opening the short.""" @dataclass(kw_only=True) diff --git a/src/agent0/core/hyperdrive/exec/execute_agent_trades.py b/src/agent0/core/hyperdrive/exec/execute_agent_trades.py index 5006994e61..8e1ba101a2 100644 --- a/src/agent0/core/hyperdrive/exec/execute_agent_trades.py +++ b/src/agent0/core/hyperdrive/exec/execute_agent_trades.py @@ -272,7 +272,9 @@ async def async_match_contract_call_to_trade( ), shorts={ trade_result.maturity_time_seconds: Short( - balance=trade_result.bond_amount, maturity_time=trade_result.maturity_time_seconds + open_vault_share_price=trade_result.vault_share_price, + balance=trade_result.bond_amount, + maturity_time=trade_result.maturity_time_seconds, ) }, ) @@ -290,7 +292,8 @@ async def async_match_contract_call_to_trade( ), shorts={ trade.maturity_time: Short( - balance=-trade_result.bond_amount, maturity_time=trade_result.maturity_time_seconds + balance=-trade_result.bond_amount, + maturity_time=trade_result.maturity_time_seconds, ) }, ) diff --git a/src/agent0/ethpy/hyperdrive/transactions.py b/src/agent0/ethpy/hyperdrive/transactions.py index 97c40c7812..3310531686 100644 --- a/src/agent0/ethpy/hyperdrive/transactions.py +++ b/src/agent0/ethpy/hyperdrive/transactions.py @@ -163,6 +163,14 @@ def parse_logs(tx_receipt: TxReceipt, hyperdrive_contract: Contract, fn_name: st if value in log_args and hasattr(trade_result, camel_to_snake(value)): setattr(trade_result, camel_to_snake(value), FixedPoint(scaled_value=log_args[value])) + # special handling for vault_share_price since it's not emitted, but calculated as base_amount / vault_share_amount + if all(x in log_args for x in ["baseAmount", "vaultShareAmount"]): + setattr( + trade_result, + "vault_share_price", + FixedPoint(scaled_value=log_args["baseAmount"]) / FixedPoint(scaled_value=log_args["vaultShareAmount"]), + ) + return trade_result