Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix staking state #331

Merged
merged 7 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
"contract/valory/staking_token/0.1.0": "bafybeig4fl35dn7d5gnprux2nwsqbirm7zkiujz3xvrwcjuktz6hkq4as4",
"contract/valory/relayer/0.1.0": "bafybeihzgjyvhtorugjw3yldznqsbwo3aqpxowm7k2nrvj6qtwpsc7jl7u",
"skill/valory/market_manager_abci/0.1.0": "bafybeicfdptiseyvorks2ji2nycjqxf4ef43jr5ygdswon6hgkckzgqjfe",
"skill/valory/decision_maker_abci/0.1.0": "bafybeib5l7pn5ax4jigare7xl3ryxtfyshytz3pl6bs52yj2u724ge3cgy",
"skill/valory/trader_abci/0.1.0": "bafybeiesex4en2n2lna2diof64met5mdymszbdm3hy24sphfx2egj66pha",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeicfinufanscmqdsdcluftvkgpsf7phvewwxejxjfmafjdmcq3c3dq",
"skill/valory/staking_abci/0.1.0": "bafybeiegy5iny4x3jk2kjuykebxksoqhfl7irdcldbcwzrsvpopxooys2q",
"skill/valory/check_stop_trading_abci/0.1.0": "bafybeif6w4uc3pzrbuuhyktgehvwsq2gxv6udeivhlhijlguhmctxokdqa",
"agent/valory/trader/0.1.0": "bafybeibx4yko4dq7fkukqmzj26drmvmrjazkqbufhduebnryeuxxcwlcwa",
"service/valory/trader/0.1.0": "bafybeihzlc56shuqbd77wle6p6lfi3dkf3a66ikjk4rau7t7ka6acbjgd4",
"service/valory/trader_pearl/0.1.0": "bafybeiaaar26oxdz543earn72dbyuzxc7soojy7xnr6w3ukze3gemeejn4"
"skill/valory/decision_maker_abci/0.1.0": "bafybeiesadxojzaadkmrbdagyllrngeswpeezbqrdfzw4qnuekb36x6r5e",
"skill/valory/trader_abci/0.1.0": "bafybeidg725kbuaenxvv3u6zasexfh3cpjqyblg7d4ekukdjvryz75lqfu",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeic6nyxwqqkw7mrpj3xpzpoli3re2zy2mjsqkfb7renhtzvrcxawgq",
"skill/valory/staking_abci/0.1.0": "bafybeicdubaxhjmrqlewtveukjlth55zhenj723az3gv24di43n5julmra",
"skill/valory/check_stop_trading_abci/0.1.0": "bafybeieuljdaepxnrboddow2g3d4gqjw2bvljgzodw6bwd63wtppej35gm",
"agent/valory/trader/0.1.0": "bafybeih6yyk2mtxxy3mcneseejtc424k46pvgg2hdyc4owpiiw252ijtqe",
"service/valory/trader/0.1.0": "bafybeiarh6porpap6aogru22th23lmgw5af5hkyhd6jnzeacoggrpjtrry",
"service/valory/trader_pearl/0.1.0": "bafybeicgeauldjv66l6hddsgrdhhai32eizwy36cduzlz4w2oxknublwoi"
},
"third_party": {
"protocol/open_aea/signing/1.0.0": "bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi",
Expand Down
10 changes: 5 additions & 5 deletions packages/valory/agents/trader/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ skills:
- valory/reset_pause_abci:0.1.0:bafybeiameewywqigpupy3u2iwnkfczeiiucue74x2l5lbge74rmw6bgaie
- valory/termination_abci:0.1.0:bafybeif2zim2de356eo3sipkmoev5emwadpqqzk3huwqarywh4tmqt3vzq
- valory/transaction_settlement_abci:0.1.0:bafybeic3tccdjypuge2lewtlgprwkbb53lhgsgn7oiwzyrcrrptrbeyote
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeicfinufanscmqdsdcluftvkgpsf7phvewwxejxjfmafjdmcq3c3dq
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeic6nyxwqqkw7mrpj3xpzpoli3re2zy2mjsqkfb7renhtzvrcxawgq
- valory/market_manager_abci:0.1.0:bafybeicfdptiseyvorks2ji2nycjqxf4ef43jr5ygdswon6hgkckzgqjfe
- valory/decision_maker_abci:0.1.0:bafybeib5l7pn5ax4jigare7xl3ryxtfyshytz3pl6bs52yj2u724ge3cgy
- valory/trader_abci:0.1.0:bafybeiesex4en2n2lna2diof64met5mdymszbdm3hy24sphfx2egj66pha
- valory/staking_abci:0.1.0:bafybeiegy5iny4x3jk2kjuykebxksoqhfl7irdcldbcwzrsvpopxooys2q
- valory/check_stop_trading_abci:0.1.0:bafybeif6w4uc3pzrbuuhyktgehvwsq2gxv6udeivhlhijlguhmctxokdqa
- valory/decision_maker_abci:0.1.0:bafybeiesadxojzaadkmrbdagyllrngeswpeezbqrdfzw4qnuekb36x6r5e
- valory/trader_abci:0.1.0:bafybeidg725kbuaenxvv3u6zasexfh3cpjqyblg7d4ekukdjvryz75lqfu
- valory/staking_abci:0.1.0:bafybeicdubaxhjmrqlewtveukjlth55zhenj723az3gv24di43n5julmra
- valory/check_stop_trading_abci:0.1.0:bafybeieuljdaepxnrboddow2g3d4gqjw2bvljgzodw6bwd63wtppej35gm
- valory/mech_interact_abci:0.1.0:bafybeih2cck5xu6yaibomwtm5zbcp6llghr3ighdnk56fzwu3ihu5xx35e
customs:
- valory/mike_strat:0.1.0:bafybeihjiol7f4ch4piwfikurdtfwzsh6qydkbsztpbwbwb2yrqdqf726m
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/services/trader/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license: Apache-2.0
fingerprint:
README.md: bafybeigtuothskwyvrhfosps2bu6suauycolj67dpuxqvnicdrdu7yhtvq
fingerprint_ignore_patterns: []
agent: valory/trader:0.1.0:bafybeibx4yko4dq7fkukqmzj26drmvmrjazkqbufhduebnryeuxxcwlcwa
agent: valory/trader:0.1.0:bafybeih6yyk2mtxxy3mcneseejtc424k46pvgg2hdyc4owpiiw252ijtqe
number_of_agents: 4
deployment:
agent:
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/services/trader_pearl/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license: Apache-2.0
fingerprint:
README.md: bafybeibg7bdqpioh4lmvknw3ygnllfku32oca4eq5pqtvdrdsgw6buko7e
fingerprint_ignore_patterns: []
agent: valory/trader:0.1.0:bafybeibx4yko4dq7fkukqmzj26drmvmrjazkqbufhduebnryeuxxcwlcwa
agent: valory/trader:0.1.0:bafybeih6yyk2mtxxy3mcneseejtc424k46pvgg2hdyc4owpiiw252ijtqe
number_of_agents: 1
deployment:
agent:
Expand Down
9 changes: 7 additions & 2 deletions packages/valory/skills/check_stop_trading_abci/behaviours.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"""This module contains the behaviours for the check stop trading skill."""

import math
from typing import Generator, Set, Type, cast
from typing import Any, Generator, Set, Type, cast

from packages.valory.contracts.mech.contract import Mech as MechContract
from packages.valory.skills.abstract_round_abci.base import get_name
Expand Down Expand Up @@ -54,6 +54,11 @@ class CheckStopTradingBehaviour(StakingInteractBaseBehaviour):

matching_round = CheckStopTradingRound

def __init__(self, **kwargs: Any) -> None:
"""Initialize the behaviour."""
super().__init__(**kwargs)
self._mech_request_count: int = 0

@property
def mech_request_count(self) -> int:
"""Get the liveness period."""
Expand Down Expand Up @@ -95,7 +100,7 @@ def is_staking_kpi_met(self) -> Generator[None, None, bool]:

yield from self.wait_for_condition_with_sleep(self._get_mech_request_count)
mech_request_count = self.mech_request_count
self.context.logger.debug(f"{self.mech_request_count=}")
self.context.logger.debug(f"{mech_request_count=}")

yield from self.wait_for_condition_with_sleep(self._get_service_info)
mech_request_count_on_last_checkpoint = self.service_info[2][1]
Expand Down
5 changes: 5 additions & 0 deletions packages/valory/skills/check_stop_trading_abci/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

from typing import Any

from aea.exceptions import enforce

from packages.valory.skills.abstract_round_abci.models import (
BenchmarkTool as BaseBenchmarkTool,
)
Expand All @@ -44,6 +46,9 @@ class CheckStopTradingParams(StakingParams):

def __init__(self, *args: Any, **kwargs: Any) -> None:
"""Initialize the parameters' object."""
mech_address = kwargs.get("mech_contract_address", None)
enforce(mech_address is not None, "Mech contract address not specified!")
self.mech_contract_address = mech_address
self.disable_trading: bool = self._ensure("disable_trading", kwargs, bool)
self.stop_trading_if_staking_kpi_met: bool = self._ensure(
"stop_trading_if_staking_kpi_met", kwargs, bool
Expand Down
6 changes: 3 additions & 3 deletions packages/valory/skills/check_stop_trading_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ aea_version: '>=1.0.0, <2.0.0'
fingerprint:
README.md: bafybeif2pq7fg5upl6vmfgfzpiwsh4nbk4zaeyz6upyucqi5tasrxgq4ee
__init__.py: bafybeifc23rlw2hzhplp3wfceixnmwq5ztnixhh7jp4dd5av3crwp3x22a
behaviours.py: bafybeid63rkrrta3hjp7cnlyws2xyqfaotur77caimyb47m5p3nroo62eu
behaviours.py: bafybeifdfqkczchnbfzzb4q2gwe3qqrn5ci2tk4mq65bunivjkw4scuzse
dialogues.py: bafybeictrrnwcijiejczy23dfvbx5kujgef3dulzqhs3etl2juvz5spm2e
fsm_specification.yaml: bafybeihhau35a5xclncjpxh5lg7qiw34xs4d5qlez7dnjpkf45d3gc57ai
handlers.py: bafybeiard64fwxib3rtyp67ymhf222uongcyqhfhdyttpsyqkmyh5ajipu
models.py: bafybeif4vl5pcmrens4lydvkjhq4unwurznirmnnbarnlroke7pleevouy
models.py: bafybeigwdhgianx5rizlb7ebmm6pdtkixh4uehbvu5c24ysvyvojs74dfq
payloads.py: bafybeidh5bqywun4chrbsci2xbcrnnzuys5sswxwbxq3yl2ksawi3xsi5q
rounds.py: bafybeigqkzikghmzjj2ceqrnvmiiagtris3livgvn6r5z5ossk73xcfqfy
tests/__init__.py: bafybeihv2cjk4va5bc5ncqtppqg2xmmxcro34bma36trtvk32gtmhdycxu
Expand All @@ -27,7 +27,7 @@ contracts:
protocols: []
skills:
- valory/abstract_round_abci:0.1.0:bafybeiar2yhzxacfe3qqamqhaihtlcimquwedffctw55sowx6rac3cm3ui
- valory/staking_abci:0.1.0:bafybeiegy5iny4x3jk2kjuykebxksoqhfl7irdcldbcwzrsvpopxooys2q
- valory/staking_abci:0.1.0:bafybeicdubaxhjmrqlewtveukjlth55zhenj723az3gv24di43n5julmra
behaviours:
main:
args: {}
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/skills/decision_maker_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fingerprint:
states/handle_failed_tx.py: bafybeihewm2vernvhktuorljdupjqcg2p5vs6wvsira2d62wkoyo5xlzjm
states/order_subscription.py: bafybeidrcef2op3nhq4tjgri3ct5hfhmc22xw2ep6dk4ro6tg7ob6cmioa
states/randomness.py: bafybeiceoo4nx3t4dofpwczw3v5mclramwmzpwjs6hv7l56arodrjx4l5u
states/redeem.py: bafybeigzlvsyg72qncpb3cogh2jquvrwlau3i6cpkikdcnfojppdoiipf4
states/redeem.py: bafybeihccmeci65ixskds23kmdk23b34ueirfypszvhv5qbkcmprgocznq
states/sampling.py: bafybeihriyyskmlupjiwytx2pdpftms7plkjku5bip64c3ztx7oi3n43ci
states/tool_selection.py: bafybeiak5ihuie4nxh3sguiea6pcdgyxr4k4xyzvq6o2uj5xpf7urocawy
tests/__init__.py: bafybeiakpi3k3kc7wrjj7hrluvjcj36lu2gezpmrctwiz5yg2fe7ggnf3i
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def end_block(self) -> Optional[Tuple[BaseSynchronizedData, Enum]]:
mech_tools_update = most_voted_payload.mech_tools
updated_data = synced_data.update(
self.synchronized_data_class,
**{get_name(SynchronizedData.available_mech_tools): mech_tools_update},
**{self.mech_tools_name: mech_tools_update},
)
return updated_data, event

Expand Down
1 change: 1 addition & 0 deletions packages/valory/skills/staking_abci/behaviours.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class StakingInteractBaseBehaviour(BaseBehaviour, ABC):
def __init__(self, **kwargs: Any) -> None:
"""Initialize the behaviour."""
super().__init__(**kwargs)
self._service_staking_state: StakingState = StakingState.UNSTAKED

@property
def params(self) -> StakingParams:
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/skills/staking_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ aea_version: '>=1.0.0, <2.0.0'
fingerprint:
README.md: bafybeifrpl36fddmgvniwvghqtxdzc44ry6l2zvqy37vu3y2xvwyd23ugy
__init__.py: bafybeiageyes36ujnvvodqd5vlnihgz44rupysrk2ebbhskjkueetj6dai
behaviours.py: bafybeidke7jrikywzysz35m4s74yzm7hy6klvjwmedynziu5igrsqqwh2m
behaviours.py: bafybeib5rcg26usohcbf2suahk5jticruzzdl2hdakchwsf6bptksi32oy
dialogues.py: bafybeiebofyykseqp3fmif36cqmmyf3k7d2zbocpl6t6wnlpv4szghrxbm
fsm_specification.yaml: bafybeicuoejmaks3ndwhbflp64kkfdkrdyn74a2fplarg4l3gxlonfmeoq
handlers.py: bafybeichsi2y5zvzffupj2vhgagocwvnm7cbzr6jmavp656mfrzsdvkfnu
Expand Down
6 changes: 4 additions & 2 deletions packages/valory/skills/trader_abci/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ class RandomnessApi(ApiSpecs):


class TraderParams(
DecisionMakerParams, # It also contains MechInteractParams
# also contains the `StakingParams`. Must be before `MechInteractParams` because of the mech's contract address
CheckStopTradingParams,
# also contains the `MechInteractParams`
DecisionMakerParams,
TerminationParams,
TxSettlementMultiplexerParams,
CheckStopTradingParams, # It also contains StakingParams
):
"""A model to represent the trader params."""

Expand Down
10 changes: 5 additions & 5 deletions packages/valory/skills/trader_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fingerprint:
dialogues.py: bafybeiebofyykseqp3fmif36cqmmyf3k7d2zbocpl6t6wnlpv4szghrxbm
fsm_specification.yaml: bafybeibgm4crhqny63ax36447cglnycvlwnwuwse62bob64zbya4vjfgnm
handlers.py: bafybeibbxybbi66em63ad33cllymypr3za3f5xvor3m2krhuxoyxnqjnxu
models.py: bafybeidrtcycxhuig776kjhnuonwlvjmn4kb2n3uvxdrpmc3hwn65qsolm
models.py: bafybeih2vkf4ln7n7ar27iemho7w7sdr4clmhbnhbcznmsri6mc2skkky4
tests/__init__.py: bafybeiadatapyjh3e7ucg2ehz77oms3ihrbutwb2cs2tkjehy54utwvuyi
tests/tests_handlers.py: bafybeifxvd63qblqpsmyvj7k4dbqubab2pshao5zd2zs2srs7rt32zvciu
fingerprint_ignore_patterns: []
Expand All @@ -27,10 +27,10 @@ skills:
- valory/transaction_settlement_abci:0.1.0:bafybeic3tccdjypuge2lewtlgprwkbb53lhgsgn7oiwzyrcrrptrbeyote
- valory/termination_abci:0.1.0:bafybeif2zim2de356eo3sipkmoev5emwadpqqzk3huwqarywh4tmqt3vzq
- valory/market_manager_abci:0.1.0:bafybeicfdptiseyvorks2ji2nycjqxf4ef43jr5ygdswon6hgkckzgqjfe
- valory/decision_maker_abci:0.1.0:bafybeib5l7pn5ax4jigare7xl3ryxtfyshytz3pl6bs52yj2u724ge3cgy
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeicfinufanscmqdsdcluftvkgpsf7phvewwxejxjfmafjdmcq3c3dq
- valory/staking_abci:0.1.0:bafybeiegy5iny4x3jk2kjuykebxksoqhfl7irdcldbcwzrsvpopxooys2q
- valory/check_stop_trading_abci:0.1.0:bafybeif6w4uc3pzrbuuhyktgehvwsq2gxv6udeivhlhijlguhmctxokdqa
- valory/decision_maker_abci:0.1.0:bafybeiesadxojzaadkmrbdagyllrngeswpeezbqrdfzw4qnuekb36x6r5e
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeic6nyxwqqkw7mrpj3xpzpoli3re2zy2mjsqkfb7renhtzvrcxawgq
- valory/staking_abci:0.1.0:bafybeicdubaxhjmrqlewtveukjlth55zhenj723az3gv24di43n5julmra
- valory/check_stop_trading_abci:0.1.0:bafybeieuljdaepxnrboddow2g3d4gqjw2bvljgzodw6bwd63wtppej35gm
- valory/mech_interact_abci:0.1.0:bafybeih2cck5xu6yaibomwtm5zbcp6llghr3ighdnk56fzwu3ihu5xx35e
behaviours:
main:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ protocols:
- valory/ledger_api:1.0.0:bafybeihdk6psr4guxmbcrc26jr2cbgzpd5aljkqvpwo64bvaz7tdti2oni
skills:
- valory/abstract_round_abci:0.1.0:bafybeiar2yhzxacfe3qqamqhaihtlcimquwedffctw55sowx6rac3cm3ui
- valory/decision_maker_abci:0.1.0:bafybeib5l7pn5ax4jigare7xl3ryxtfyshytz3pl6bs52yj2u724ge3cgy
- valory/staking_abci:0.1.0:bafybeiegy5iny4x3jk2kjuykebxksoqhfl7irdcldbcwzrsvpopxooys2q
- valory/decision_maker_abci:0.1.0:bafybeiesadxojzaadkmrbdagyllrngeswpeezbqrdfzw4qnuekb36x6r5e
- valory/staking_abci:0.1.0:bafybeicdubaxhjmrqlewtveukjlth55zhenj723az3gv24di43n5julmra
- valory/mech_interact_abci:0.1.0:bafybeih2cck5xu6yaibomwtm5zbcp6llghr3ighdnk56fzwu3ihu5xx35e
behaviours:
main:
Expand Down
Loading