Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding whale for aero, and funding one agent with as much base as pos…
Browse files Browse the repository at this point in the history
…sible in the case where whale doesn't have enough base
slundqui committed Oct 31, 2024
1 parent 8947bff commit dde12a6
Showing 3 changed files with 20 additions and 17 deletions.
3 changes: 3 additions & 0 deletions scripts/fork_fuzz_bots.py
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
# with the value as the whale address.
# Note that if a token is missing in this mapping, we will try to
# call `mint` on the trading token to fund.
# TODO we need a better method to ensure this list of whales doesn't get stale
MAINNET_WHALE_ADDRESSES = {
# stETH
"0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84": "0x7F39C581F595B53C5CB19BD0B3F8DA6C935E2CA0",
@@ -71,6 +72,8 @@
"0xe66E3A37C3274Ac24FE8590f7D84A2427194DC17": "0x5E564c1905fFF9724621542f58d61BE0405C4879",
# snARS
"0xC1F4C75e8925A67BE4F35D6b1c044B5ea8849a58": "0x54423d0A5c4e3a6Eb8Bd12FDD54c1e6b42D52Ebe",
# LP Token for Areo USD pool
"0x6cDcb1C4A4D1C3C6d054b27AC5B77e89eAFb971d": "0xD22B2890A6812414B544598fC77AC04382008754",
}

# We build an outer lookup based on chain id
10 changes: 8 additions & 2 deletions src/agent0/core/hyperdrive/interactive/hyperdrive_agent.py
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
from __future__ import annotations

import asyncio
import logging
import threading
from functools import partial
from typing import TYPE_CHECKING, Literal, Type, overload
@@ -273,10 +274,15 @@ def add_funds(
else:
base_scaled_value = base.scaled_value

# If whale doesn't have enough balance, give it as much as possible
if whale_balance < base_scaled_value:
raise ValueError(
f"Whale does not have enough base to transfer. {whale_balance=}, {base_scaled_value=}."
logging.warning(
"Whale %s doesn't have enough base to transfer %s, only supplying %s base.",
whale_account_addr,
base_scaled_value,
whale_balance,
)
base_scaled_value = whale_balance

# RPC anvil call to impersonate account
response = self.chain._web3.provider.make_request(
24 changes: 9 additions & 15 deletions src/agent0/hyperfuzz/system_fuzz/run_fuzz_bots.py
Original file line number Diff line number Diff line change
@@ -489,21 +489,15 @@ def run_fuzz_bots(
logging.info("Refunding agents...")
if run_async:
raise NotImplementedError("Running async not implemented")
try:
_ = [
agent.add_funds(
base=base_budget_per_bot,
eth=eth_budget_per_bot,
pool=hyperdrive_pool,
whale_accounts=whale_accounts,
)
for agent in agents
]
except ValueError as e:
# Look for the case when the whale doesn't have enough base to transfer, and
# ignore when refunding.
if "Whale does not have enough base to transfer." not in e.args[0]:
raise e
_ = [
agent.add_funds(
base=base_budget_per_bot,
eth=eth_budget_per_bot,
pool=hyperdrive_pool,
whale_accounts=whale_accounts,
)
for agent in agents
]

if random_advance_time:
# We only allow random advance time if the chain connected to the pool is a

0 comments on commit dde12a6

Please sign in to comment.