delvtech/hyperdrive-rs

Fix `calculate_max_long` and `calculate_max_short` for accuracy

Closed this issue · 11 comments

A lot has changed in Hyperdrive over the last few months. We should make sure that the math used in these functions is actually correct and fix any discrepancies that we find. This should address any of the lingering known issues in the SDK.

While doing this it would be good to verify that delvtech/hyperdrive#797 and #42 are resolved. This is also related to delvtech/hyperdrive#894.

crash on calc max short with a high fixed rate of 100%

failing test here: #19

I noticed our fuzz ranges seem too narrow. should we do all of them up to 100% fixed rate? also in some cases fixed rate is not fuzzed.

crash trying to open long over 70% of the calculated max long after adding liquidity delvtech/agent0@7434b96

Related to max short crash report from @slundqui #42

Crash Report

Description

Calling calc_max_short in the rust SDK breaks with an arithmetic operation overflow error

Expected Behavior

calc_max_short doesn't crash

Actual Behavior

calc_max_short crashes with an error

Steps to Reproduce

  1. Deploy a hyperdrive pool with a position duration of a week, target fixed rate of 5%, initial liquidity of 100,000,000 base. This results in a time_stretch of 0.00087344336337973.
  2. Call calc_max_short with a budget of 100,000 base.

Playing around with parameters, it seems that calc_max_short doesn't crash when the position duration is > 29 days, but does crash when position duration <= 28 days.

Additionally, with a position duration of a week, adjusting the budget to be 1e9 base doesn't crash, but setting a budget of 100,000 base does crash.

Getting another error in calc_max_short:

pyo3_runtime.PanicException: max short exceeded budget

Here are the parameters when calling get_max_short:

pool_config = PoolConfig(baseToken='0x5FbDB2315678afecb367f032d93F642f64180aa3',
           linkerFactory='0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9',
           linkerCodeHash=b'uK(\x17\x1a\xf2\xb7q\xa3\x126\xd9\x1d;\xfd\x93'
                          b"2\xda\xa1\xde9\x80\x94D1L\r\xfd6\xfb'\xeb",
           initialSharePrice=1000000000000000000,
           minimumShareReserves=10000000000000000000,
           minimumTransactionAmount=1000000000000000,
           positionDuration=604800,
           checkpointDuration=3600,
           timeStretch=873443363379730,
           governance='0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
           feeCollector='0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
           fees=Fees(curve=10000000000000000,
                     flat=500000000000000,
                     governanceLP=10000000000000000,
                     governanceZombie=100000000000000000))

pool_info = PoolInfo(shareReserves=100000166168989209376245204,
         shareAdjustment=-72597894831832927,
         zombieBaseProceeds=0,
         zombieShareReserves=0,
         bondReserves=299612105618339733502453961,
         lpTotalSupply=100000107244738255324956936,
         sharePrice=1000165648843736100,
         longsOutstanding=61284946301931302384,
         longAverageMaturityTime=1706232591357648602037963923,
         shortsOutstanding=12309486122233927680,
         shortAverageMaturityTime=1706241600000000000000000002,
         withdrawalSharesReadyToWithdraw=0,
         withdrawalSharesProceeds=0,
         lpSharePrice=1000165648867533483,
         longExposure=61284946301931302384)

budget = 130080851117999367591

open_share_price = 1000165648843736100

checkpoint_exposure = 0

maybe_conservative_price = None

maybe_max_iterations = None

copied from @slundqui's issue:

absolute_max_long is failing due to target_share_reserves < effective_share_reserves with arithmetic operation overflow here:
https://github.com/delvtech/hyperdrive/blob/1576e4c4368dd9c21b2df60274f223271e793d46/crates/hyperdrive-math/src/long/max.rs#L214

This is the pool state that caused this issue:

pool_config = {
   base_token='0x610178dA211FEF7D417bC0e6FeD39F05609AD788',
   vault_shares_token='0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e',
   linker_factory='0x5FbDB2315678afecb367f032d93F642f64180aa3',
   linker_code_hash=b'\x91\xa6<\xce\xc3\xbbXQ\xa0\x88\xc4G\xd5\xd3@`4AP\xbe+q\xac`\xc1\x97\x82\x7f\xd1HIL',
   initial_vault_share_price=FixedPoint("1.0"), minimum_share_reserves=FixedPoint("0.206282109669978528"),
   minimum_transaction_amount=FixedPoint("2.4934863032025728"),
   position_duration=30801600,
   checkpoint_duration=82800,
   time_stretch=FixedPoint("0.168128366020933774"),
   governance='0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
   fee_collector='0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
   sweep_collector='0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
   fees={
      curve=FixedPoint("0.063774932363567072"),
      flat=FixedPoint("0.180852177854770176"),
      governance_lp=FixedPoint("0.19281944111115744"),
      governance_zombie=FixedPoint("0.052803595874591256")
   }
}

pool_info = {
   share_reserves=FixedPoint("26176.625462115783671808"),
   share_adjustment=FixedPoint("0.0"),
   zombie_base_proceeds=FixedPoint("0.0"),
   zombie_share_reserves=FixedPoint("0.0"),
   bond_reserves=FixedPoint("73185.723713861986104902"),
   lp_total_supply=FixedPoint("26176.41918000611369328"),
   vault_share_price=FixedPoint("1.000001457064193671"),
   longs_outstanding=FixedPoint("0.0"),
   long_average_maturity_time=FixedPoint("0.0"),
   shorts_outstanding=FixedPoint("0.0"),
   short_average_maturity_time=FixedPoint("0.0"),
   withdrawal_shares_ready_to_withdraw=FixedPoint("0.0"),
   withdrawal_shares_proceeds=FixedPoint("0.0"),
   lp_share_price=FixedPoint("1.00000145706419367"),
   long_exposure=FixedPoint("0.0")
}

That is a really high flat fee. We should consider bumping that down in the fuzzed range.

copying over crash report from delvtech/hyperdrive#686

Crash Report

Description

calc_max_short fails after opening max short

Expected Behavior

I expected it not to crash. I guess return 0?

Actual Behavior

it crashed.

Steps to Reproduce

see attached agent0 script: interactive_econ_this_causes_max_short_error.zip

  1. run calc_max_short
  2. open a short of that size
  3. run calc_max_short
    *** crash here ***

Possible Solution

check if we're at the max before beginning optimization steps? or catch error then check?

Log and stack trace

spot_price=FixedPoint("0.966183574879227054")
 budget: 100,000,000, max_long: 192,698, max_short: 109,485,978
 wallet=HyperdriveWallet(address=HexBytes('0x7ed0be4a227257ee29044dbc2f69bf93da52439d'), balance=Quantity(amount=FixedPoint("100000000.0"), unit=<TokenType.BASE: 'base'>), lp_tokens=FixedPoint("0.0"), withdraw_shares=FixedPoint("0.0"), longs={}, shorts={})
randnum=1
day 0: OpenShort(trader='0x7ED0BE4A227257ee29044dbC2F69Bf93Da52439D', asset_id=904625697166532776746648320380374280103671755200316906558262375063523923712, maturity_time=1702598400, base_amount=FixedPoint("488735.244665681407618051"), share_price=FixedPoint("1.000000173611118645"), bond_amount=FixedPoint("2498616.965861401359408817"))
 spot_price=FixedPoint("0.676414979823208904")
thread '<unnamed>' panicked at [/home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/primitive-types-0.12.2/src/lib.rs:38:1](https://file+.vscode-resource.vscode-cdn.net/home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/primitive-types-0.12.2/src/lib.rs:38:1):
arithmetic operation overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---------------------------------------------------------------------------
PanicException                            Traceback (most recent call last)
[/code/elfpy/lib/agent0/examples/interactive_econ_this_causes_max_short_error.py](https://file+.vscode-resource.vscode-cdn.net/code/elfpy/lib/agent0/examples/interactive_econ_this_causes_max_short_error.py) in line 17
     [63](file:///code/elfpy/lib/agent0/examples/interactive_econ_this_causes_max_short_error.py?line=62) max_long_shares = interactive_hyperdrive.hyperdrive_interface.calc_shares_in_given_bonds_out_down(max_long_bonds)
     [64](file:///code/elfpy/lib/agent0/examples/interactive_econ_this_causes_max_short_error.py?line=63) max_long_base = max_long_shares * share_price
---> [65](file:///code/elfpy/lib/agent0/examples/interactive_econ_this_causes_max_short_error.py?line=64) max_short_bonds = interactive_hyperdrive.hyperdrive_interface.calc_max_short(budget=current_base)
     [66](file:///code/elfpy/lib/agent0/examples/interactive_econ_this_causes_max_short_error.py?line=65) max_short_shares = interactive_hyperdrive.hyperdrive_interface.calc_shares_out_given_bonds_in_down(max_short_bonds)
     [67](file:///code/elfpy/lib/agent0/examples/interactive_econ_this_causes_max_short_error.py?line=66) print(f" budget: {int(current_base):{FLOAT_FMT}}, max_long: {int(max_long_bonds):{FLOAT_FMT}}, max_short: {int(max_short_bonds):{FLOAT_FMT}}")

File [/code/elfpy/lib/ethpy/ethpy/hyperdrive/api/api.py:1067](https://file+.vscode-resource.vscode-cdn.net/code/elfpy/lib/ethpy/ethpy/hyperdrive/api/api.py:1067), in HyperdriveInterface.calc_max_short(self, budget, pool_state)
   [1065](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/api.py?line=1064) if pool_state is None:
   [1066](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/api.py?line=1065)     pool_state = self.current_pool_state
-> [1067](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/api.py?line=1066) return _calc_max_short(pool_state, budget)

File [/code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py:255](https://file+.vscode-resource.vscode-cdn.net/code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py:255), in _calc_max_short(pool_state, budget)
    [251](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=250) def _calc_max_short(pool_state: PoolState, budget: FixedPoint) -> FixedPoint:
    [252](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=251)     """See API for documentation."""
    [253](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=252)     return FixedPoint(
    [254](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=253)         scaled_value=int(
--> [255](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=254)             hyperdrivepy.get_max_short(
    [256](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=255)                 pool_config=fixedpoint_to_pool_config(pool_state.pool_config),
    [257](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=256)                 pool_info=fixedpoint_to_pool_info(pool_state.pool_info),
    [258](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=257)                 budget=str(budget.scaled_value),
    [259](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=258)                 open_share_price=str(pool_state.pool_info.share_price.scaled_value),
    [260](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=259)                 checkpoint_exposure=str(pool_state.checkpoint.exposure.scaled_value),
    [261](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=260)                 maybe_conservative_price=None,
    [262](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=261)                 maybe_max_iterations=None,
    [263](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=262)             )
    [264](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=263)         )
    [265](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=264)     )

File [~/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py:287](https://file+.vscode-resource.vscode-cdn.net/code/elfpy/~/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py:287), in get_max_short(pool_config, pool_info, budget, open_share_price, checkpoint_exposure, maybe_conservative_price, maybe_max_iterations)
    [252](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=251) def get_max_short(
    [253](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=252)     pool_config: types.PoolConfigType,
    [254](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=253)     pool_info: types.PoolInfoType,
   (...)
    [259](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=258)     maybe_max_iterations: int | None,
    [260](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=259) ) -> str:
    [261](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=260)     """Get the max amount of bonds that can be shorted for the given budget.
    [262](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=261) 
    [263](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=262)     Arguments
   (...)
    [285](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=284)         The maximum short the pool and user's wallet can handle.
    [286](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=285)     """
--> [287](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=286)     return _get_interface(pool_config, pool_info).get_max_short(
    [288](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=287)         budget,
    [289](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=288)         open_share_price,
    [290](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=289)         checkpoint_exposure,
    [291](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=290)         maybe_conservative_price,
    [292](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=291)         maybe_max_iterations,
    [293](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=292)     )

PanicException: arithmetic operation overflow

Environment

  • Hyperdrive Version: 0.3.0
  • Agent0 Version: 0.10.0 (35a69e7d4358cbd301b903b3c9eec485943e5167)
  • Infra Version: not used in interactive agent0
  • Cloud Environment: none, run locally
  • Additional Information: I love this template very much

copying over crash report from delvtech/hyperdrive#687

Crash Report

Description

calc_max_long errors when fixed rate is 182.5%
seemed like a reasonable experiment, since that gives me the same price for a 7 day term as a 365 day term at 3.5% fixed rate
it seems to happen after crossing a fixed rate of ~100%
should be impacted by curve fee, since that affects your max spot price
in the next hyperdrive version it will be impacted by flat fee, because we just added that (#657)
might be impacted by other factors like the pool's term? I stumbled on it w/ a 7 day term, and didn't check other cases

Expected Behavior

I expected it not to crash. maybe return 0 if it's not possible to open a long, perhaps explaining why.

Actual Behavior

it crashed.

Steps to Reproduce

see attached agent0 script: interactive_econ_this_causes_max_long_error.zip

  1. initialize 7 day pool with 182.5% starting rate (default fees of 10% curve, 0.05% flat, and 15% governance)
  2. run calc_max_long
    *** crash here ***

Possible Solution

return error specifying what is going on, especially if it's hitting an edge case due to the rate being so high.

Log

spot_price=FixedPoint("0.966183574879227054")
thread '<unnamed>' panicked at [/home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/primitive-types-0.12.2/src/lib.rs:38:1](https://file+.vscode-resource.vscode-cdn.net/home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/primitive-types-0.12.2/src/lib.rs:38:1):
arithmetic operation overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Stack Trace

---------------------------------------------------------------------------
PanicException                            Traceback (most recent call last)
[/code/elfpy/lib/agent0/examples/interactive_econ_this_causes_max_long_error.py](https://file+.vscode-resource.vscode-cdn.net/code/elfpy/lib/agent0/examples/interactive_econ_this_causes_max_long_error.py) in line 13
     [59](file:///code/elfpy/lib/agent0/examples/interactive_econ_this_causes_max_long_error.py?line=58) spot_price = interactive_hyperdrive.hyperdrive_interface.calc_spot_price()
     [60](file:///code/elfpy/lib/agent0/examples/interactive_econ_this_causes_max_long_error.py?line=59) print(f" {spot_price=}")
---> [61](file:///code/elfpy/lib/agent0/examples/interactive_econ_this_causes_max_long_error.py?line=60) max_long_bonds = interactive_hyperdrive.hyperdrive_interface.calc_max_long(budget=current_base)
     [62](file:///code/elfpy/lib/agent0/examples/interactive_econ_this_causes_max_long_error.py?line=61) max_long_shares = interactive_hyperdrive.hyperdrive_interface.calc_shares_in_given_bonds_out_down(max_long_bonds)
     [63](file:///code/elfpy/lib/agent0/examples/interactive_econ_this_causes_max_long_error.py?line=62) max_long_base = max_long_shares * share_price

File [/code/elfpy/lib/ethpy/ethpy/hyperdrive/api/api.py:1044](https://file+.vscode-resource.vscode-cdn.net/code/elfpy/lib/ethpy/ethpy/hyperdrive/api/api.py:1044), in HyperdriveInterface.calc_max_long(self, budget, pool_state)
   [1042](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/api.py?line=1041) if pool_state is None:
   [1043](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/api.py?line=1042)     pool_state = self.current_pool_state
-> [1044](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/api.py?line=1043) return _calc_max_long(pool_state, budget)

File [/code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py:240](https://file+.vscode-resource.vscode-cdn.net/code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py:240), in _calc_max_long(pool_state, budget)
    [236](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=235) def _calc_max_long(pool_state: PoolState, budget: FixedPoint) -> FixedPoint:
    [237](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=236)     """See API for documentation."""
    [238](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=237)     return FixedPoint(
    [239](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=238)         scaled_value=int(
--> [240](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=239)             hyperdrivepy.get_max_long(
    [241](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=240)                 fixedpoint_to_pool_config(pool_state.pool_config),
    [242](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=241)                 fixedpoint_to_pool_info(pool_state.pool_info),
    [243](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=242)                 str(budget.scaled_value),
    [244](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=243)                 checkpoint_exposure=str(pool_state.checkpoint.exposure.scaled_value),
    [245](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=244)                 maybe_max_iterations=None,
    [246](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=245)             )
    [247](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=246)         )
    [248](file:///code/elfpy/lib/ethpy/ethpy/hyperdrive/api/_mock_contract.py?line=247)     )

File [~/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py:249](https://file+.vscode-resource.vscode-cdn.net/code/elfpy/~/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py:249), in get_max_long(pool_config, pool_info, budget, checkpoint_exposure, maybe_max_iterations)
    [220](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=219) def get_max_long(
    [221](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=220)     pool_config: types.PoolConfigType,
    [222](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=221)     pool_info: types.PoolInfoType,
   (...)
    [225](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=224)     maybe_max_iterations: int | None,
    [226](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=225) ) -> str:
    [227](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=226)     """Get the max amount of bonds that can be purchased for the given budget.
    [228](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=227) 
    [229](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=228)     Arguments
   (...)
    [247](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=246)         The maximum long the pool and user's wallet can support.
    [248](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=247)     """
--> [249](file:///home/mihai/.pyenv/versions/3.10.11/envs/elf-env/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py?line=248)     return _get_interface(pool_config, pool_info).get_max_long(budget, checkpoint_exposure, maybe_max_iterations)

PanicException: arithmetic operation overflow

Environment

  • Hyperdrive Version: 0.3.0
  • Agent0 Version: 0.10.0 (35a69e7d4358cbd301b903b3c9eec485943e5167)
  • Infra Version: not used in interactive agent0
  • Cloud Environment: none, run locally
  • Additional Information: I love this template very much

long::max::fuzz_calculate_max_long is failing (#88) after the fee rounding update in Hyperdrive v1.0.6.

long::max::fuzz_calculate_max_long is failing (#88) after the fee rounding update in Hyperdrive v1.0.6.

resolved by #101

@wakamex we have made a lot of changes to calculate_max_* and underlying functions since these issues were originally posted, including writing several new tests.

Can you attempt to replicate your original failures on the latest hyperdrive v1.0.7 and hyperdrive-rs v0.15.4 when they are released (should be later today)?