Skip to content

Commit

Permalink
feat: add staking contract utils
Browse files Browse the repository at this point in the history
  • Loading branch information
0xArdi committed Nov 16, 2023
1 parent 2f30fdd commit 07d3eb7
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
"skill/valory/decision_maker_abci/0.1.0": "bafybeiguvfiaytb7i3p5sluubvehvzcu4wdzch4avdyxhj6332mkohv674",
"skill/valory/trader_abci/0.1.0": "bafybeigjkkphi7y2nlq7nc4unookfvyn5vwfqus27g2qtldctuan6fiipa",
"contract/valory/market_maker/0.1.0": "bafybeif4mm2s3gxtvp227yypkcnna5ftec7vajcftvtbdmqddh7nprah5m",
"agent/valory/trader/0.1.0": "bafybeiege455u6bfg42amizcfmxgz5hzdkuwzx3rt5q6oogf3gqaqmfyfi",
"service/valory/trader/0.1.0": "bafybeieh2ttygh6rkfuxvqhvpyahar2dstwlqe64xwrb4q4f2ukcnrcgaq",
"agent/valory/trader/0.1.0": "bafybeide5rc6gsg2pe2gzqopt2eypqmjm5z3wvkql6fyfexupm424cvbzi",
"service/valory/trader/0.1.0": "bafybeickxpbvulbpnca6me7s3jroynhcam4mjfydhdkgr2apcbputooohm",
"contract/valory/erc20/0.1.0": "bafybeieqj7dea4tcv6z2yqkgtmhd23vbiycsr5trhwxdvlbwulpl6vhmam",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeidkeozxuznavfqotsuaahmaajciz7lpro5wxe5y6um2w5k2ag6ohe",
"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": "bafybeibifxmoeaiptovouispl5jdgm4lduzcfgsx723zlw45cfpllecuwy"
"contract/valory/service_staking_token/0.1.0": "bafybeifzynpmjjkvsxraujft4sirmsh56vgqvtf2zt5l4fzrcdicgus4s4"
},
"third_party": {
"protocol/open_aea/signing/1.0.0": "bafybeie7xyems76v5b4wc2lmaidcujizpxfzjnnwdeokmhje53g7ym25ii",
Expand Down
2 changes: 1 addition & 1 deletion 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:bafybeibifxmoeaiptovouispl5jdgm4lduzcfgsx723zlw45cfpllecuwy
- valory/service_staking_token:0.1.0:bafybeifzynpmjjkvsxraujft4sirmsh56vgqvtf2zt5l4fzrcdicgus4s4
protocols:
- open_aea/signing:1.0.0:bafybeie7xyems76v5b4wc2lmaidcujizpxfzjnnwdeokmhje53g7ym25ii
- valory/abci:0.1.0:bafybeihmzlmmb4pdo3zkhg6ehuyaa4lhw7bfpclln2o2z7v3o6fcep26iu
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 @@ -112,3 +112,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: bafybeihyuap3ndb7ov7fkqr5ybsazikph47oeallykzbs6wdbyvvwruerq
contract.py: bafybeiamj36g4p35m4k5q3umqiujzz3zcflrmjwwnfn4k6ijqrdlgrpfem
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:bafybeiege455u6bfg42amizcfmxgz5hzdkuwzx3rt5q6oogf3gqaqmfyfi
agent: valory/trader:0.1.0:bafybeide5rc6gsg2pe2gzqopt2eypqmjm5z3wvkql6fyfexupm424cvbzi
number_of_agents: 4
deployment: {}
---
Expand Down

0 comments on commit 07d3eb7

Please sign in to comment.