Test errors with `calculate_targeted_long`
Closed this issue · 2 comments
dpaiton commented
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.
wakamex commented
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