Skip to content

Commit

Permalink
chore: fix fund before swap transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoreira-valory committed Aug 28, 2024
1 parent 5319963 commit 6c3cb7c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions operate/services/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ def _deploy_service_onchain_from_safe( # pylint: disable=too-many-statements,to
)

on_chain_hash = self._get_on_chain_hash(chain_config=chain_config)
current_agent_bond = staking_params["min_staking_deposit"] # TODO fixme, read from service registry token utility contract
is_first_mint = (
self._get_on_chain_state(service=service, chain_id=chain_id)
== OnChainState.NON_EXISTENT
Expand All @@ -486,6 +487,7 @@ def _deploy_service_onchain_from_safe( # pylint: disable=too-many-statements,to
and (
on_chain_hash != service.hash
or current_agent_id != staking_params["agent_ids"][0]
or current_agent_bond != staking_params["min_staking_deposit"]
)
)
current_staking_program = self._get_current_staking_program(
Expand Down Expand Up @@ -845,6 +847,16 @@ def _terminate_service_on_chain_from_safe( # pylint: disable=too-many-locals

if counter_current_safe_owners == counter_instances:
self.logger.info("Swapping Safe owners")

self.fund_service(
hash=hash,
rpc=ledger_config.rpc,
agent_topup=chain_data.user_params.fund_requirements.agent,
agent_fund_threshold=chain_data.user_params.fund_requirements.agent,
safe_topup=0,
safe_fund_treshold=0,
)

sftxb.swap( # noqa: E800
service_id=chain_data.token, # noqa: E800
multisig=chain_data.multisig, # TODO this can be read from the registry
Expand Down

0 comments on commit 6c3cb7c

Please sign in to comment.