Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test errors with calculate_targeted_long #69

Closed
dpaiton opened this issue May 3, 2024 · 2 comments
Closed

Test errors with calculate_targeted_long #69

dpaiton opened this issue May 3, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@dpaiton
Copy link
Contributor

dpaiton commented May 3, 2024

this is a tolerance issue for when fuzz tests put in crazy numbers.

---- long::targeted::tests::test_calculate_targeted_long_with_budget stdout ----
thread 'long::targeted::tests::test_calculate_targeted_long_with_budget' panicked at crates/hyperdrive-math/src/long/targeted.rs:507:17:
target_rate was 0.022437506175906878, realized rate is 0.022437606229255172. abs_error=0.000000100053348294 was not <= 0.000000100000000000.
@dpaiton dpaiton added the bug Something isn't working label May 3, 2024
@wakamex
Copy link
Contributor

wakamex commented May 3, 2024

here's a log from a crash in bots_on_testnet

random_steth30 (0x8817b7e94dc29503839f6515bc2652aBd80b2127) BASE=508 ETH=0.04967
===POOL INFO===
PoolInfoFP(share_reserves=FixedPoint("346643.960988065950165133"), share_adjustment=FixedPoint("7882.266532349756602536"), zombie_base_proceeds=FixedPoint("0.0"), zombie_share_reserves=FixedPoint("0.0"), bond_reserves=FixedPoint("29223865.18427352698382377"), lp_total_supply=FixedPoint("292689.997757872582173643"), vault_share_price=FixedPoint("1.00158206576483243"), longs_outstanding=FixedPoint("681775.196930321061294182"), long_average_maturity_time=FixedPoint("1716249179.401359641739904204"), shorts_outstanding=FixedPoint("627128.24131681"), short_average_maturity_time=FixedPoint("1716315144.100679191880729482"), withdrawal_shares_ready_to_withdraw=FixedPoint("0.000000000000000701"), withdrawal_shares_proceeds=FixedPoint("0.000000000000000701"), lp_share_price=FixedPoint("1.001191756023741379"), long_exposure=FixedPoint("305565.268200216168602777"))
Traceback (most recent call last):
  File "/code/agent0/scripts/bots_on_testnet.py", line 208, in <module>
    event_list = agent.execute_policy_action()
  File "/code/agent0/src/agent0/core/hyperdrive/interactive/i_hyperdrive_agent.py", line 200, in execute_policy_action
    return self._pool._execute_policy_action(self.agent)
  File "/code/agent0/src/agent0/core/hyperdrive/interactive/i_hyperdrive.py", line 359, in _execute_policy_action
    trade_results: list[TradeResult] = asyncio.run(
  File "/code/agent0/.venv/lib/python3.10/site-packages/nest_asyncio.py", line 30, in run
    return loop.run_until_complete(task)
  File "/code/agent0/.venv/lib/python3.10/site-packages/nest_asyncio.py", line 98, in run_until_complete
    return f.result()
  File "/usr/lib/python3.10/asyncio/futures.py", line 201, in result
    raise self._exception.with_traceback(self._exception_tb)
  File "/usr/lib/python3.10/asyncio/tasks.py", line 232, in __step
    result = coro.send(None)
  File "/code/agent0/src/agent0/core/hyperdrive/interactive/exec/execute_agent_trades.py", line 80, in async_execute_agent_trades
    trades: list[Trade[HyperdriveMarketAction]] = agent.get_trades(interface=interface.get_read_interface())
  File "/code/agent0/src/agent0/core/hyperdrive/agent/hyperdrive_agent.py", line 126, in get_trades
    actions, self.done_trading = self.policy.action(interface, self.wallet)
  File "/code/agent0/src/agent0/core/hyperdrive/policies/lpandarb.py", line 599, in action
    arb_fixed_rate_down(
  File "/code/agent0/src/agent0/core/hyperdrive/policies/lpandarb.py", line 88, in arb_fixed_rate_down
    base_needed = interface.calc_targeted_long(budget=wallet.balance.amount, target_rate=variable_rate, pool_state=pool_state)
  File "/code/agent0/src/agent0/ethpy/hyperdrive/interface/read_interface.py", line 801, 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 128, in _calc_targeted_long
    hyperdrivepy.calculate_targeted_long(
  File "/code/agent0/.venv/lib/python3.10/site-packages/hyperdrivepy/hyperdrive_state.py", line 393, in calculate_targeted_long
    return _get_interface(pool_config, pool_info).calculate_targeted_long_with_budget(
ValueError: Calculate_targeted_long_with_budget returned the error: We overshot the zero-crossing during Newton's method.

Location:
    /home/runner/work/hyperdrive-bindings/hyperdrive-bindings/hyperdrive/crates/hyperdrive-math/src/long/targeted.rs:121:28

@dpaiton
Copy link
Contributor Author

dpaiton commented May 15, 2024

Should be fixed by #95

I'm going to close the issue; we should open a new one if new problems arrise.

@dpaiton dpaiton closed this as completed May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants