Skip to content

Commit

Permalink
Merge pull request #139 from valory-xyz/feat/add-methods-trader
Browse files Browse the repository at this point in the history
feat: add staking contract utils
  • Loading branch information
Adamantios authored Nov 16, 2023
2 parents 6a2db66 + ec8ee6c commit 3ff1ab6
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitleaksignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ cd8a3159e660a5eb6838657db4d7537912e657bf:packages/valory/skills/market_manager_a
ce811dab0e95cdd63ea00e1ed8207801f464d773:packages/valory/contracts/service_staking_token/contract.yaml:generic-api-key:10
61e62bd62dcaae666f1bf25981d068e360d32322:packages/valory/skills/staking_abci/skill.yaml:generic-api-key:78
b520b0c67a9ae55ba501e1e9a99abfc0738e8d49:packages/valory/skills/staking_abci/skill.yaml:generic-api-key:78
61e62bd62dcaae666f1bf25981d068e360d32322:packages/valory/skills/staking_abci/skill.yaml:generic-api-key:78
12 changes: 6 additions & 6 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
"dev": {
"skill/valory/market_manager_abci/0.1.0": "bafybeibrjre5yka3sbvb6lsefgc5yutovb6h4ffzrpecplfkjwtl5i36te",
"skill/valory/decision_maker_abci/0.1.0": "bafybeiejunyhbfzk3tqn22xmyvpyn75xyjsbeg7grjrywhecak3phbwwem",
"skill/valory/trader_abci/0.1.0": "bafybeid3uohgff4mv6qdaed477c2bvrlo72nq7lzfyfkfki2snyhdgntxu",
"skill/valory/trader_abci/0.1.0": "bafybeihjre2rppuyuxesevdmpgjvnvsvsgsevfzqi3f7l6yi6thq7xvl5a",
"contract/valory/market_maker/0.1.0": "bafybeif4mm2s3gxtvp227yypkcnna5ftec7vajcftvtbdmqddh7nprah5m",
"agent/valory/trader/0.1.0": "bafybeig7ccohw2wommcnhunepnjageyssxx335pgvvpn4g6bnoyfhhl36m",
"service/valory/trader/0.1.0": "bafybeidd3vf3jnidjkce6zfzoabrfmh5dc2qnnyb2arexqedxis3olmnqu",
"agent/valory/trader/0.1.0": "bafybeiccr6adm3ijuyp7so7js4qqnvkdrljylbjc4svc65xt75la6jykpm",
"service/valory/trader/0.1.0": "bafybeifeil57odcx6c22zmmfz4krqwci5gc6tttagiylwthfi34fwdahbq",
"contract/valory/erc20/0.1.0": "bafybeieqj7dea4tcv6z2yqkgtmhd23vbiycsr5trhwxdvlbwulpl6vhmam",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeibixthabcfuz3ttgjiy2sfdurrefb2gzkaqxcznmngxtr37kbqmvu",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeibtbginmn7tq2tluo7jyxpnlgqfwtpia5a2delxhjmsdejazvpsku",
"contract/valory/mech/0.1.0": "bafybeihvc6btuk3nvernzcx4qpezvuhiw2wwnagqj5nkeljvszghv7mq64",
"contract/valory/realitio/0.1.0": "bafybeiamgkwwqhray4fs2hlipwxkq7mosmi7ev7jut4vneetaaycc4ruji",
"contract/valory/realitio_proxy/0.1.0": "bafybeidx37xzjjmapwacedgzhum6grfzhp5vhouz4zu3pvpgdy5pgb2fr4",
"contract/valory/conditional_tokens/0.1.0": "bafybeifov35k2ifwagzyfvl7km6je6tmyvcqgrccldob3zmbx2af2wzque",
"contract/valory/agent_registry/0.1.0": "bafybeifwdtwxdc2jdlhzdyxctqdmoz6zroxf5o4nhuok5l4luvnofqavty",
"contract/valory/service_staking_token/0.1.0": "bafybeideljvdcgahtaufdwyopgclcpbtx53z3ki3rx56jlauneoqy2d2vy",
"skill/valory/staking_abci/0.1.0": "bafybeichs6yhjv24mgccqt6hlcqakpfcxit6gvowziz7pb2w6hxfc5wyem"
"contract/valory/service_staking_token/0.1.0": "bafybeia7ukqmozdwa3nrsb4kvcae7iya2625gb4hhhes6ivvmnf24w6fyi",
"skill/valory/staking_abci/0.1.0": "bafybeifdxywwwtwgfmtufkvvjvepil6qwetbldftf5eab5v2r3b3zh574q"
},
"third_party": {
"protocol/open_aea/signing/1.0.0": "bafybeie7xyems76v5b4wc2lmaidcujizpxfzjnnwdeokmhje53g7ym25ii",
Expand Down
8 changes: 4 additions & 4 deletions packages/valory/agents/trader/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ contracts:
- valory/realitio:0.1.0:bafybeiamgkwwqhray4fs2hlipwxkq7mosmi7ev7jut4vneetaaycc4ruji
- valory/realitio_proxy:0.1.0:bafybeidx37xzjjmapwacedgzhum6grfzhp5vhouz4zu3pvpgdy5pgb2fr4
- valory/agent_registry:0.1.0:bafybeifwdtwxdc2jdlhzdyxctqdmoz6zroxf5o4nhuok5l4luvnofqavty
- valory/service_staking_token:0.1.0:bafybeideljvdcgahtaufdwyopgclcpbtx53z3ki3rx56jlauneoqy2d2vy
- valory/service_staking_token:0.1.0:bafybeia7ukqmozdwa3nrsb4kvcae7iya2625gb4hhhes6ivvmnf24w6fyi
protocols:
- open_aea/signing:1.0.0:bafybeie7xyems76v5b4wc2lmaidcujizpxfzjnnwdeokmhje53g7ym25ii
- valory/abci:0.1.0:bafybeihmzlmmb4pdo3zkhg6ehuyaa4lhw7bfpclln2o2z7v3o6fcep26iu
Expand All @@ -43,11 +43,11 @@ skills:
- valory/reset_pause_abci:0.1.0:bafybeicpxn2khtaesuf4cq6ypwdmdmonlqroj2q2i6cxvpizc2y4cw66pe
- valory/termination_abci:0.1.0:bafybeieqm46zuccaagnko3qlw6p3nvoohdrfgvpmw467r5lyil2dqrzjsy
- valory/transaction_settlement_abci:0.1.0:bafybeia6cdxdlqrcwk2maw25fo7dafzd2p3rs7syropvufophk2pitzbwy
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeibixthabcfuz3ttgjiy2sfdurrefb2gzkaqxcznmngxtr37kbqmvu
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeibtbginmn7tq2tluo7jyxpnlgqfwtpia5a2delxhjmsdejazvpsku
- valory/market_manager_abci:0.1.0:bafybeibrjre5yka3sbvb6lsefgc5yutovb6h4ffzrpecplfkjwtl5i36te
- valory/decision_maker_abci:0.1.0:bafybeiejunyhbfzk3tqn22xmyvpyn75xyjsbeg7grjrywhecak3phbwwem
- valory/trader_abci:0.1.0:bafybeid3uohgff4mv6qdaed477c2bvrlo72nq7lzfyfkfki2snyhdgntxu
- valory/staking_abci:0.1.0:bafybeichs6yhjv24mgccqt6hlcqakpfcxit6gvowziz7pb2w6hxfc5wyem
- valory/trader_abci:0.1.0:bafybeihjre2rppuyuxesevdmpgjvnvsvsgsevfzqi3f7l6yi6thq7xvl5a
- valory/staking_abci:0.1.0:bafybeifdxywwwtwgfmtufkvvjvepil6qwetbldftf5eab5v2r3b3zh574q
default_ledger: ethereum
required_ledgers:
- ethereum
Expand Down
23 changes: 23 additions & 0 deletions packages/valory/contracts/service_staking_token/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,26 @@ def get_next_checkpoint_ts(
contract = cls.get_instance(ledger_api, contract_address)
ts = contract.functions.getNextRewardCheckpointTimestamp().call()
return dict(data=ts)

@classmethod
def get_liveness_period(
cls,
ledger_api: LedgerApi,
contract_address: str,
) -> JSONLike:
"""Retrieve the liveness period."""
contract = cls.get_instance(ledger_api, contract_address)
liveness_period = contract.functions.livenessPeriod().call()
return dict(data=liveness_period)

@classmethod
def get_service_info(
cls,
ledger_api: LedgerApi,
contract_address: str,
service_id: int,
) -> JSONLike:
"""Retrieve the service info for a service."""
contract = cls.get_instance(ledger_api, contract_address)
info = contract.functions.mapServiceInfo(service_id).call()
return dict(data=info)
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: bafybeie2xbccvzmjuptqfqumctv6gtyyeoxe7fkx3t7fgbto7wbdugbqxm
contract.py: bafybeiddcci5w72vnvclr7muyijn2mrowmx73mx66fkpttqm2a5nnso2me
contract.py: bafybeihhdg5mvd3jwc7q445ntdahaiyjpt2ne6ipkiaymycbrw5iwzuble
fingerprint_ignore_patterns: []
contracts: []
class_name: ServiceStakingTokenContract
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:bafybeig7ccohw2wommcnhunepnjageyssxx335pgvvpn4g6bnoyfhhl36m
agent: valory/trader:0.1.0:bafybeiccr6adm3ijuyp7so7js4qqnvkdrljylbjc4svc65xt75la6jykpm
number_of_agents: 4
deployment: {}
---
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 @@ -19,7 +19,7 @@ fingerprint_ignore_patterns: []
connections: []
contracts:
- valory/gnosis_safe:0.1.0:bafybeibt7arvjzz4ah24omst74f4sfjpzrdef76yti6ml7dopsauhdzeci
- valory/service_staking_token:0.1.0:bafybeideljvdcgahtaufdwyopgclcpbtx53z3ki3rx56jlauneoqy2d2vy
- valory/service_staking_token:0.1.0:bafybeia7ukqmozdwa3nrsb4kvcae7iya2625gb4hhhes6ivvmnf24w6fyi
protocols:
- valory/contract_api:1.0.0:bafybeialhbjvwiwcnqq3ysxcyemobcbie7xza66gaofcvla5njezkvhcka
skills:
Expand Down
4 changes: 2 additions & 2 deletions packages/valory/skills/trader_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ skills:
- valory/termination_abci:0.1.0:bafybeieqm46zuccaagnko3qlw6p3nvoohdrfgvpmw467r5lyil2dqrzjsy
- valory/market_manager_abci:0.1.0:bafybeibrjre5yka3sbvb6lsefgc5yutovb6h4ffzrpecplfkjwtl5i36te
- valory/decision_maker_abci:0.1.0:bafybeiejunyhbfzk3tqn22xmyvpyn75xyjsbeg7grjrywhecak3phbwwem
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeibixthabcfuz3ttgjiy2sfdurrefb2gzkaqxcznmngxtr37kbqmvu
- valory/staking_abci:0.1.0:bafybeichs6yhjv24mgccqt6hlcqakpfcxit6gvowziz7pb2w6hxfc5wyem
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeibtbginmn7tq2tluo7jyxpnlgqfwtpia5a2delxhjmsdejazvpsku
- valory/staking_abci:0.1.0:bafybeifdxywwwtwgfmtufkvvjvepil6qwetbldftf5eab5v2r3b3zh574q
behaviours:
main:
args: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protocols: []
skills:
- valory/abstract_round_abci:0.1.0:bafybeid7neqpxxe4ualp23gxgrtpf6r5u3myr2mmc4uvwameyqshfdoydq
- valory/decision_maker_abci:0.1.0:bafybeiejunyhbfzk3tqn22xmyvpyn75xyjsbeg7grjrywhecak3phbwwem
- valory/staking_abci:0.1.0:bafybeichs6yhjv24mgccqt6hlcqakpfcxit6gvowziz7pb2w6hxfc5wyem
- valory/staking_abci:0.1.0:bafybeifdxywwwtwgfmtufkvvjvepil6qwetbldftf5eab5v2r3b3zh574q
behaviours:
main:
args: {}
Expand Down

0 comments on commit 3ff1ab6

Please sign in to comment.