Skip to content

Commit

Permalink
Merge pull request #264 from valory-xyz/feat/new-staking
Browse files Browse the repository at this point in the history
Feat/ new staking support
  • Loading branch information
Adamantios authored Jun 19, 2024
2 parents 0d747da + b021f88 commit fd6c3a1
Show file tree
Hide file tree
Showing 23 changed files with 1,952 additions and 52 deletions.
17 changes: 10 additions & 7 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@
"contract/valory/realitio_proxy/0.1.0": "bafybeidx37xzjjmapwacedgzhum6grfzhp5vhouz4zu3pvpgdy5pgb2fr4",
"contract/valory/conditional_tokens/0.1.0": "bafybeibnzmqmeph4cj5vfh3s622mo2o5627vjjwc6bptrhj4dk65mzgvhe",
"contract/valory/agent_registry/0.1.0": "bafybeifsb2krg4qnr4nxdrhcdgpncfr5ra2nahebvn2f2yff7ebwe7ooae",
"contract/valory/service_staking_token/0.1.0": "bafybeigzpmgizwxiptscj6bieumby5sjs54w3ps6f3kdnlyxpiwwxy5iem",
"contract/valory/service_staking_token/0.1.0": "bafybeieyfto5xwmvxiu52qxxudp2zaa22idrvw3jr6bytbok6bg3nylgqi",
"contract/valory/transfer_nft_condition/0.1.0": "bafybeihnict3irtvnyxtkwyg6wphe44wz3dogijiha45xrkcrh5ktq2lsi",
"contract/valory/mech_activity/0.1.0": "bafybeiec6nnvfs6captlncrtjfygpp275vkfajvj4frrnab7thsca6337e",
"contract/valory/staking_token/0.1.0": "bafybeig4fl35dn7d5gnprux2nwsqbirm7zkiujz3xvrwcjuktz6hkq4as4",
"contract/valory/relayer/0.1.0": "bafybeiaabvxim4blp5fxb6qjlzjivtvkme3fk24h5jte7w6vr6rsx72j6u",
"skill/valory/market_manager_abci/0.1.0": "bafybeicbvxvjkoksbknujaid5hx7krjlgm6barcjcwo33tdccanrcp674a",
"skill/valory/decision_maker_abci/0.1.0": "bafybeibsnlnzufdach74o3zvgggbb3rfgrow47r3q6ey7wioil43ik6jaa",
"skill/valory/trader_abci/0.1.0": "bafybeihulcjfowlm3cpxwqo2tufada52xleleidy7zlccmhxyphqxj76um",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeiavfiyvyafvvt6t6qx7okcitnmf26tjo2woc27dycpuuw4qsgd5zq",
"skill/valory/staking_abci/0.1.0": "bafybeigo7bicej5t2rbki37cmcwkzgwpcnopokn7ijhylmkihsbqw47xr4",
"skill/valory/check_stop_trading_abci/0.1.0": "bafybeickfeuqlpmryegnfvfu2duk2v4ycowwloohu3xxrafd5md6xl5swi",
"agent/valory/trader/0.1.0": "bafybeicsu6mq2wlgphwspjf345iuji3pqosedrog7fcd7dfnkxgnl5g5by",
"service/valory/trader/0.1.0": "bafybeigioak6bvdcpc7fyxybkqf7tx5hpthppnqfuphwoaudlh3hpryoqi"
"skill/valory/trader_abci/0.1.0": "bafybeigbklah5i4icvpzxgujupgbaz33lxin5vd5vbquni4co7a6o7irvi",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeigjzerfu6zuv6zdlygxr5iqdaimhnmgqlbd46jsecnq4gjqhngu5a",
"skill/valory/staking_abci/0.1.0": "bafybeidubhfvlf6x627t4wetc6ran5sb4pttjphyhv6vefp2a4kcuca2be",
"skill/valory/check_stop_trading_abci/0.1.0": "bafybeie6vnp4oovs3k6qnqjcjcjiok6u2uu4dkyd5gqibu77zxpcmztbnq",
"agent/valory/trader/0.1.0": "bafybeidi4tswlb7ndecgb4ji2bzu2a6zvznp45aloiyass33cd4txxmma4",
"service/valory/trader/0.1.0": "bafybeiftyafjmnf4xbwr7r5bkadpt4p7fkz4mq64hx2ap6sptzd3gbgrke",
"service/valory/trader_omen_gnosis/0.1.0": "bafybeicihxhw2djlsuoy2eji3g2tmasipfqe3rwsfvzbd2j3tvphqvp7aa"
},
"third_party": {
"protocol/open_aea/signing/1.0.0": "bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi",
Expand Down
14 changes: 9 additions & 5 deletions packages/valory/agents/trader/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ contracts:
- valory/realitio:0.1.0:bafybeignaxfk7fjlfa4lioflwsfru2z5xln5cyvyew3if5oas2sgm5wuii
- valory/realitio_proxy:0.1.0:bafybeidx37xzjjmapwacedgzhum6grfzhp5vhouz4zu3pvpgdy5pgb2fr4
- valory/agent_registry:0.1.0:bafybeifsb2krg4qnr4nxdrhcdgpncfr5ra2nahebvn2f2yff7ebwe7ooae
- valory/service_staking_token:0.1.0:bafybeigzpmgizwxiptscj6bieumby5sjs54w3ps6f3kdnlyxpiwwxy5iem
- valory/service_staking_token:0.1.0:bafybeieyfto5xwmvxiu52qxxudp2zaa22idrvw3jr6bytbok6bg3nylgqi
- valory/transfer_nft_condition:0.1.0:bafybeihnict3irtvnyxtkwyg6wphe44wz3dogijiha45xrkcrh5ktq2lsi
- valory/erc20:0.1.0:bafybeia7a7mfjeok4ywpmejz74msofagagcentsudqxfojadmxlur5qolu
- valory/staking_token:0.1.0:bafybeig4fl35dn7d5gnprux2nwsqbirm7zkiujz3xvrwcjuktz6hkq4as4
- valory/mech_activity:0.1.0:bafybeiec6nnvfs6captlncrtjfygpp275vkfajvj4frrnab7thsca6337e
protocols:
- open_aea/signing:1.0.0:bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi
- valory/abci:0.1.0:bafybeiaqmp7kocbfdboksayeqhkbrynvlfzsx4uy4x6nohywnmaig4an7u
Expand All @@ -45,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:bafybeiavfiyvyafvvt6t6qx7okcitnmf26tjo2woc27dycpuuw4qsgd5zq
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeigjzerfu6zuv6zdlygxr5iqdaimhnmgqlbd46jsecnq4gjqhngu5a
- valory/market_manager_abci:0.1.0:bafybeicbvxvjkoksbknujaid5hx7krjlgm6barcjcwo33tdccanrcp674a
- valory/decision_maker_abci:0.1.0:bafybeibsnlnzufdach74o3zvgggbb3rfgrow47r3q6ey7wioil43ik6jaa
- valory/trader_abci:0.1.0:bafybeihulcjfowlm3cpxwqo2tufada52xleleidy7zlccmhxyphqxj76um
- valory/staking_abci:0.1.0:bafybeigo7bicej5t2rbki37cmcwkzgwpcnopokn7ijhylmkihsbqw47xr4
- valory/check_stop_trading_abci:0.1.0:bafybeickfeuqlpmryegnfvfu2duk2v4ycowwloohu3xxrafd5md6xl5swi
- valory/trader_abci:0.1.0:bafybeigbklah5i4icvpzxgujupgbaz33lxin5vd5vbquni4co7a6o7irvi
- valory/staking_abci:0.1.0:bafybeidubhfvlf6x627t4wetc6ran5sb4pttjphyhv6vefp2a4kcuca2be
- valory/check_stop_trading_abci:0.1.0:bafybeie6vnp4oovs3k6qnqjcjcjiok6u2uu4dkyd5gqibu77zxpcmztbnq
- valory/mech_interact_abci:0.1.0:bafybeih2cck5xu6yaibomwtm5zbcp6llghr3ighdnk56fzwu3ihu5xx35e
customs:
- valory/mike_strat:0.1.0:bafybeihjiol7f4ch4piwfikurdtfwzsh6qydkbsztpbwbwb2yrqdqf726m
Expand Down Expand Up @@ -179,6 +181,7 @@ models:
mech_contract_address: ${str:0x77af31De935740567Cf4fF1986D04B2c964A786a}
mech_request_price: ${int:null}
mech_chain_id: ${str:gnosis}
mech_activity_checker_contract: ${str:0x0000000000000000000000000000000000000000}
mech_wrapped_native_token_address: ${str:0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d}
sample_bets_closing_days: ${int:10}
trading_strategy: ${str:kelly_criterion_no_conf}
Expand Down Expand Up @@ -356,4 +359,5 @@ public_id: valory/http_server:0.22.0:bafybeicblltx7ha3ulthg7bzfccuqqyjmihhrvfezt
type: connection
config:
host: ${str:0.0.0.0}
port: ${int:8716}
target_skill_id: valory/trader_abci:0.1.0
20 changes: 20 additions & 0 deletions packages/valory/contracts/mech_activity/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2024 Valory AG
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ------------------------------------------------------------------------------

"""This module contains the support resources for the mech activity checker contract."""
111 changes: 111 additions & 0 deletions packages/valory/contracts/mech_activity/build/MechActivity.json

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions packages/valory/contracts/mech_activity/contract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2024 Valory AG
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ------------------------------------------------------------------------------

"""This module contains the class to connect to the `MechActivityContract` contract."""

from enum import Enum

from aea.common import JSONLike
from aea.configurations.base import PublicId
from aea.contracts.base import Contract
from aea.crypto.base import LedgerApi


class MechActivityContract(Contract):
"""The Service Staking contract."""

contract_id = PublicId.from_str("valory/mech_activity:0.1.0")

@classmethod
def liveness_ratio(
cls,
ledger_api: LedgerApi,
contract_address: str,
) -> JSONLike:
"""Retrieve the liveness ratio."""
contract = cls.get_instance(ledger_api, contract_address)
liveness_ratio = contract.functions.livenessRatio().call()
return dict(data=liveness_ratio)
23 changes: 23 additions & 0 deletions packages/valory/contracts/mech_activity/contract.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: mech_activity
author: valory
version: 0.1.0
type: contract
description: Mech activity checker contract
license: Apache-2.0
aea_version: '>=1.0.0, <2.0.0'
fingerprint:
__init__.py: bafybeid4hg5rx75ltdjmekmxdddwqzbvblygmvlhws5samjxfirnkp666i
build/MechActivity.json: bafybeiagrufcoljrlo2zklc7kxwh7eyrf67usos2bqnf7hss47hgm6low4
contract.py: bafybeihgiwyy5gj5tpyz6wnjlfsywssanrbuzskqctt557f3galofewqse
fingerprint_ignore_patterns: []
contracts: []
class_name: MechActivityContract
contract_interface_paths:
ethereum: build/MechActivity.json
dependencies:
open-aea-ledger-ethereum:
version: ==1.52.0
open-aea-test-autonomy:
version: ==0.14.12
web3:
version: <7,>=6.0.0
10 changes: 1 addition & 9 deletions packages/valory/contracts/service_staking_token/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@
from aea.crypto.base import LedgerApi


class StakingState(Enum):
"""Staking state enumeration for the staking."""

UNSTAKED = 0
STAKED = 1
EVICTED = 2


class ServiceStakingTokenContract(Contract):
"""The Service Staking contract."""

Expand All @@ -50,7 +42,7 @@ def get_service_staking_state(
"""Check whether the service is staked."""
contract_instance = cls.get_instance(ledger_api, contract_address)
res = contract_instance.functions.getServiceStakingState(service_id).call()
return dict(data=StakingState(res))
return dict(data=res)

@classmethod
def build_stake_tx(
Expand Down
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:
__init__.py: bafybeid3wfzglolebuo6jrrsopswzu4lk77bm76mvw3euizlsjtnt3wmgu
build/ServiceStakingToken.json: bafybeib6frfpqtr4dfyxuylehqmic2iawofydx7u24t7j5zbrsc4m4ijoi
contract.py: bafybeihtnccnhtqyiwqomythtuey6vdbsj5swufxl5pcu3ptepmiaolxy4
contract.py: bafybeiboxlbmmhnsreimqyrnn3yamzueiucno6v75xjfrvfvbx4pqrnlsy
fingerprint_ignore_patterns: []
contracts: []
class_name: ServiceStakingTokenContract
Expand Down
20 changes: 20 additions & 0 deletions packages/valory/contracts/staking_token/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2024 Valory AG
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ------------------------------------------------------------------------------

"""This module contains the support resources for the staking contract."""
Loading

0 comments on commit fd6c3a1

Please sign in to comment.