Skip to content

Commit

Permalink
feat: fixes for amm agent
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel1302 committed Jul 12, 2024
1 parent ae7311f commit 91649c9
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions vega_sim/scenario/common/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from vega_sim.null_service import VegaService, VegaServiceNull
from vega_python_protos.protos.vega import markets as markets_protos
from vega_python_protos.protos.vega import vega as vega_protos
from vega_python_protos.protos.vega.events.v1 import events as vega_protos_events
from vega_sim.scenario.common.utils.ideal_mm_models import GLFT_approx, a_s_mm_model
from vega_sim.service import PeggedOrder

Expand Down Expand Up @@ -3894,6 +3895,7 @@ def __init__(
np.random.RandomState() if random_state is None else random_state
)
self.amm_created = False
self._public_key = None

def initialise(
self,
Expand All @@ -3903,6 +3905,11 @@ def initialise(
):
super().initialise(vega, create_key, mint_key)

if self._public_key is None:
self._public_key = self.vega.wallet.public_key(
name=self.key_name, wallet_name=self.wallet_name
)

self.market_id = self.vega.find_market_id(name=self.market_name)
self.asset_id = self.vega.market_to_asset[self.market_id]

Expand Down Expand Up @@ -3945,15 +3952,14 @@ def _check(self) -> bool:
# If check passed once, return True without querying API
if self.amm_created:
return True
if (
len(
self.vega.list_amms(
market_id=self.market_id,
party_id=self._public_key,
)
)
> 0
):

amms = [amm for amm in self.vega.list_amms(
market_id=self.market_id,
party_id=self._public_key,
status=vega_protos_events.AMM.Status.Value("STATUS_ACTIVE"),
)]

if len(amms) > 0:
self.amm_created = True
return True
return False
Expand Down

0 comments on commit 91649c9

Please sign in to comment.