Skip to content

bug: crash in calc_targeted_long after max short #1670

@wakamex

Description

@wakamex

this script was working, so this is a recent change. I tried previous versions, but they result in a different error.

reproduced in this script on a branch: https://github.com/delvtech/agent0/blob/af73b4dcb2380dd39e3de2a864258fbef8fa43ce/fail_calc_targeted_long.py

steps are:

uv pip install -e .
python fail_calc_targeted_long.py

output:

Warning: failed to convert bytecode for stethtarget3deployer to HexBytes: Non-hexadecimal digit found
Warning: failed to convert bytecode for erc4626target0deployer to HexBytes: Non-hexadecimal digit found
Warning: failed to convert bytecode for erc4626target3deployer to HexBytes: Non-hexadecimal digit found
Warning: failed to convert bytecode for stethtarget0deployer to HexBytes: Non-hexadecimal digit found
Warning: failed to convert bytecode for erc4626target4deployer to HexBytes: Non-hexadecimal digit found
Warning: failed to convert bytecode for erc4626target1deployer to HexBytes: Non-hexadecimal digit found
Warning: failed to convert bytecode for stethtarget2deployer to HexBytes: Non-hexadecimal digit found
Warning: failed to convert bytecode for stethtarget1deployer to HexBytes: Non-hexadecimal digit found
Warning: failed to convert bytecode for erc4626target2deployer to HexBytes: Non-hexadecimal digit found
Warning: failed to convert bytecode for stethtarget4deployer to HexBytes: Non-hexadecimal digit found
=== TIME_STRETCH_APR=0.1 DELTA=1e+18 ===

24-08-29 15:40:14: INFO: interface.py:88::interface::initialize_engine:
Database agent0_db does not exist, creating

24-08-29 15:40:14: WARNING: interface.py:93::interface::initialize_engine:
No postgres connection, retrying

24-08-29 15:40:15: INFO: interface.py:88::interface::initialize_engine:
Database agent0_db does not exist, creating
max long  rate = 0.00000%
max short rate = 401.67863%
=== POOL INFO ===
 bond_reserves = 113485.98289020474650654
 long_average_maturity_time = 0.0
 long_exposure = 0.0
 longs_outstanding = 0.0
 lp_share_price = 1.000000190258751902
 lp_total_supply = 99999.999
 share_adjustment = 72640.8983086062206679
 share_reserves = 72640.899816826822935958
 short_average_maturity_time = 1756494000.0
 shorts_outstanding = 33580.99475073790377984
 vault_share_price = 1.000000190258751902
 withdrawal_shares_proceeds = 0.0
 withdrawal_shares_ready_to_withdraw = 0.0
 zombie_base_proceeds = 0.0
 zombie_share_reserves = 0.0
trying to calculate targeted long, target=401.00000%, current rate=401.67863%
Traceback (most recent call last):
  File "/code/experiments/fail_calc_targeted_long.py", line 92, in <module>
    calc_shorts(chain=chain, interface=interface)
  File "/code/experiments/fail_calc_targeted_long.py", line 62, in calc_shorts
    trade_size = interface.calc_targeted_long(budget=FixedPoint(1e18), target_rate=FixedPoint(short_target))
  File "/code/agent0/src/agent0/ethpy/hyperdrive/interface/read_interface.py", line 1354, in calc_targeted_long
    return _calc_targeted_long(pool_state, budget, target_rate, max_iterations, allowable_error)
  File "/code/agent0/src/agent0/ethpy/hyperdrive/interface/_mock_contract.py", line 199, in _calc_targeted_long
    hyperdrivepy.calculate_targeted_long(
  File "/code/experiments/.venv/lib64/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py", line 514, in calculate_targeted_long
    return _get_interface(pool_config, pool_info).calculate_targeted_long_with_budget(
ValueError: calculate_targeted_long_with_budget: MinimumTransactionAmount: Input amount too low

Location:
    crates/hyperdrive-math/src/long/open.rs:34:24

using agent0 v0.21.7:

Traceback (most recent call last):
  File "/code/agent0/fail_calc_targeted_long.py", line 4, in <module>
    from agent0.core.hyperdrive.interactive import LocalChain, LocalHyperdrive
  File "/code/agent0/.venv/lib64/python3.10/site-packages/agent0/__init__.py", line 12, in <module>
    from agent0.core.hyperdrive.interactive import Chain, Hyperdrive, LocalChain, LocalHyperdrive
  File "/code/agent0/.venv/lib64/python3.10/site-packages/agent0/core/hyperdrive/interactive/__init__.py", line 3, in <module>
    from .chain import Chain
  File "/code/agent0/.venv/lib64/python3.10/site-packages/agent0/core/hyperdrive/interactive/chain.py", line 22, in <module>
    from agent0.chainsync.dashboard.usernames import build_user_mapping
  File "/code/agent0/.venv/lib64/python3.10/site-packages/agent0/chainsync/dashboard/__init__.py", line 3, in <module>
    from .build_dashboard_dfs import build_pool_dashboard, build_wallet_dashboard
  File "/code/agent0/.venv/lib64/python3.10/site-packages/agent0/chainsync/dashboard/build_dashboard_dfs.py", line 9, in <module>
    from agent0.chainsync.db.hyperdrive import (
  File "/code/agent0/.venv/lib64/python3.10/site-packages/agent0/chainsync/db/hyperdrive/__init__.py", line 3, in <module>
    from .chain_to_db import checkpoint_events_to_db, data_chain_to_db, init_data_chain_to_db, trade_events_to_db
  File "/code/agent0/.venv/lib64/python3.10/site-packages/agent0/chainsync/db/hyperdrive/chain_to_db.py", line 13, in <module>
    from agent0.ethpy.hyperdrive import HyperdriveReadInterface
  File "/code/agent0/.venv/lib64/python3.10/site-packages/agent0/ethpy/hyperdrive/__init__.py", line 3, in <module>
    from .addresses import (
  File "/code/agent0/.venv/lib64/python3.10/site-packages/agent0/ethpy/hyperdrive/addresses.py", line 13, in <module>
    from agent0.hypertypes import HyperdriveRegistryContract, IHyperdriveContract, MockERC4626Contract
  File "/code/agent0/.venv/lib64/python3.10/site-packages/agent0/hypertypes/__init__.py", line 4, in <module>
    from .types import *
  File "/code/agent0/.venv/lib64/python3.10/site-packages/agent0/hypertypes/types/__init__.py", line 10, in <module>
    from .IHyperdriveContract import *
  File "/code/agent0/.venv/lib64/python3.10/site-packages/agent0/hypertypes/types/IHyperdriveContract.py", line 47, in <module>
    from web3.exceptions import FallbackNotFound
ImportError: cannot import name 'FallbackNotFound' from 'web3.exceptions' (/code/agent0/.venv/lib64/python3.10/site-packages/web3/exceptions.py)

Metadata

Metadata

Assignees

Labels

bugA bug that is preventing execution

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions