Skip to content

Commit

Permalink
Merge branch 'main' into fix/release
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/packages.json
#	packages/valory/agents/trader/aea-config.yaml
#	packages/valory/services/trader/service.yaml
#	packages/valory/skills/trader_abci/skill.yaml
#	packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml
  • Loading branch information
Adamantios committed Feb 28, 2024
2 parents 58bb241 + 605f06d commit ba769ea
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 29 deletions.
10 changes: 5 additions & 5 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"contract/valory/service_staking_token/0.1.0": "bafybeicv4nfbogieioufevoo2dcpxbafw7vmcfythabvhcrja2qgarbqf4",
"contract/valory/transfer_nft_condition/0.1.0": "bafybeibqsfqao3puhodmvtriyyvbiqtgotdb4z5hul7tvitfacr47fv2pe",
"skill/valory/market_manager_abci/0.1.0": "bafybeigcboyrmlmuwtzuvkxi4uiklromiyuaund4xgtfjbxwsuemndidna",
"skill/valory/decision_maker_abci/0.1.0": "bafybeiailugc3i2ujbzwoylfoltdanz7xbgnscykrur2u4tt2sgui46t4m",
"skill/valory/trader_abci/0.1.0": "bafybeiels2i3j2xifeeny64li2znpueximf3p4ctf3wrd4sosdfubx66ra",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeifbbhgebvszz3eekvrdyvgwr7w5luaeepjbswirnaeauziyfuxt4q",
"skill/valory/decision_maker_abci/0.1.0": "bafybeick4cueks2xwktifcrnkwr3f7ta6a57swbsn46tujmjsiqb4uuh74",
"skill/valory/trader_abci/0.1.0": "bafybeigs6tqnvxuyczfj6jjwsazggb6cs2gjaxyw35hewwokoz5i5e6ywe",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeif6uqfiwizn4xd5k67rdslb56l2vrtvc53jirvn7xz32aht6cttzm",
"skill/valory/staking_abci/0.1.0": "bafybeiafgwdxmnyme675pcdagrgtu34riizw5aig65hvku355sd7rharj4",
"agent/valory/trader/0.1.0": "bafybeibs6nvz6hirhfnk3el42hfxvktkiwiozyypkanad5vfp75jckcfte",
"service/valory/trader/0.1.0": "bafybeib7avkcssrovsgdharv7ufiazwwiufzn6egqh5jyb4av3nya5zhwe"
"agent/valory/trader/0.1.0": "bafybeibopc2kl2hnkri4pkhu3ljnz2a6igr2emvvnpenzbm223c5qoftay",
"service/valory/trader/0.1.0": "bafybeifme7v6jnpkffle3kz44tpgodpxq4vtsgjutix6msgdhky53kufae"
},
"third_party": {
"protocol/open_aea/signing/1.0.0": "bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi",
Expand Down
6 changes: 3 additions & 3 deletions packages/valory/agents/trader/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ skills:
- valory/reset_pause_abci:0.1.0:bafybeienpu6guwbkdzscnovmhizuzlkpalycltzxnwovisbd2coyjim7li
- valory/termination_abci:0.1.0:bafybeicklx5s3mjl4pgkcz36bw2vuuqj6w73qyh455vkoncyanxqlns6ze
- valory/transaction_settlement_abci:0.1.0:bafybeihcfbjnty6j4aluaajgfdrc4ctg76ebb3gfub5pwqtooait7x76r4
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeifbbhgebvszz3eekvrdyvgwr7w5luaeepjbswirnaeauziyfuxt4q
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeif6uqfiwizn4xd5k67rdslb56l2vrtvc53jirvn7xz32aht6cttzm
- valory/market_manager_abci:0.1.0:bafybeigcboyrmlmuwtzuvkxi4uiklromiyuaund4xgtfjbxwsuemndidna
- valory/decision_maker_abci:0.1.0:bafybeiailugc3i2ujbzwoylfoltdanz7xbgnscykrur2u4tt2sgui46t4m
- valory/trader_abci:0.1.0:bafybeiels2i3j2xifeeny64li2znpueximf3p4ctf3wrd4sosdfubx66ra
- valory/decision_maker_abci:0.1.0:bafybeick4cueks2xwktifcrnkwr3f7ta6a57swbsn46tujmjsiqb4uuh74
- valory/trader_abci:0.1.0:bafybeigs6tqnvxuyczfj6jjwsazggb6cs2gjaxyw35hewwokoz5i5e6ywe
- valory/staking_abci:0.1.0:bafybeiafgwdxmnyme675pcdagrgtu34riizw5aig65hvku355sd7rharj4
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:bafybeibs6nvz6hirhfnk3el42hfxvktkiwiozyypkanad5vfp75jckcfte
agent: valory/trader:0.1.0:bafybeibopc2kl2hnkri4pkhu3ljnz2a6igr2emvvnpenzbm223c5qoftay
number_of_agents: 4
deployment: {}
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
from packages.valory.skills.market_manager_abci.bets import BetStatus


TX_COST_APPROX = int(1e15)


class BlacklistingBehaviour(DecisionMakerBaseBehaviour):
"""A behaviour in which the agents blacklist the sampled bet."""

Expand All @@ -49,12 +52,18 @@ def _blacklist(self) -> None:
sampled_bet.status = BetStatus.BLACKLISTED
blacklist_expiration = self.synced_time + self.params.blacklisting_duration
sampled_bet.blacklist_expiration = blacklist_expiration
tool_idx = self.synchronized_data.mech_tool_idx
if self.synchronized_data.is_mech_price_set:
# impose a penalty equivalent to the mech's price on the tool responsible for blacklisting the market
tool_idx = self.synchronized_data.mech_tool_idx
penalty = -self.wei_to_native(self.synchronized_data.mech_price)
penalty *= self.params.tool_punishment_multiplier
self.policy.add_reward(tool_idx, penalty)
penalty_wei = self.synchronized_data.mech_price
else:
# if the price has not been set or a nevermined subscription is used, penalize using a small amount,
# approximating the cost of a transaction
penalty_wei = -TX_COST_APPROX

penalty = -self.wei_to_native(penalty_wei)
penalty *= self.params.tool_punishment_multiplier
self.policy.add_reward(tool_idx, penalty)

def setup(self) -> None:
"""Setup the behaviour"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ def _get_price(self) -> WaitableConditionType:
"""Get the price of the mech request."""
if self.params.use_nevermined:
# when we use nevermined, we don't need to pay for the mech request
self.price = 0
return True
result = yield from self._mech_contract_interact(
"get_price", "price", get_name(DecisionRequestBehaviour.price)
Expand Down
16 changes: 10 additions & 6 deletions packages/valory/skills/decision_maker_abci/behaviours/reedem.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2023 Valory AG
# Copyright 2023-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.
Expand Down Expand Up @@ -202,9 +202,9 @@ def redeeming_progress(self) -> RedeemingProgress:
return self.shared_state.redeeming_progress

@redeeming_progress.setter
def redeeming_progress(self, payouts: RedeemingProgress) -> None:
def redeeming_progress(self, progress: RedeemingProgress) -> None:
"""Set the redeeming check progress in the shared state."""
self.shared_state.redeeming_progress = payouts
self.shared_state.redeeming_progress = progress

@property
def latest_block_number(self) -> int:
Expand Down Expand Up @@ -487,7 +487,7 @@ def _check_already_redeemed_via_events(self) -> WaitableConditionType:
def _check_already_redeemed_via_subgraph(self) -> WaitableConditionType:
"""Check whether the condition ids have already been redeemed via subgraph."""
safe_address = self.synchronized_data.safe_contract_address.lower()
from_timestamp, to_timestamp = 0.0, time.time() # from begging to now
from_timestamp, to_timestamp = 0.0, time.time() # from beginning to now

# get the trades
trades = yield from self.fetch_trades(
Expand All @@ -496,7 +496,7 @@ def _check_already_redeemed_via_subgraph(self) -> WaitableConditionType:
if trades is None:
return False

# get the user positions
# get the user's positions
user_positions = yield from self.fetch_user_positions(safe_address)
if user_positions is None:
return False
Expand Down Expand Up @@ -535,7 +535,11 @@ def _clean_redeem_info(self) -> WaitableConditionType:
payouts_amount = sum(payouts.values())
if payouts_amount > 0:
self.redeemed_condition_ids |= set(payouts.keys())
self.payout_so_far += payouts_amount
if self.params.use_subgraph_for_redeeming:
self.payout_so_far = payouts_amount
else:
self.payout_so_far += payouts_amount

# filter the trades again if new payouts have been found
self._filter_trades()
wxdai_amount = self.wei_to_native(self.payout_so_far)
Expand Down
5 changes: 4 additions & 1 deletion packages/valory/skills/decision_maker_abci/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,12 @@ def select_tool(self, randomness: RandomnessType) -> Optional[int]:

return self.best_tool

def tool_used(self, index: int) -> None:
"""Increase the times used for the tool corresponding to the given index."""
self.counts[index] += 1

def add_reward(self, index: int, reward: float = 0) -> None:
"""Add a reward for the tool corresponding to the given index."""
self.counts[index] += 1
self.rewards[index] += reward

def serialize(self) -> str:
Expand Down
8 changes: 4 additions & 4 deletions packages/valory/skills/decision_maker_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ fingerprint:
behaviours/__init__.py: bafybeih6ddz2ocvm6x6ytvlbcz6oi4snb5ee5xh5h65nq4w2qf7fd7zfky
behaviours/base.py: bafybeigoxverx6e75jdzj54hsfyzgunofuy5nll5lbn52gxeyzo7jw6vyy
behaviours/bet_placement.py: bafybeib7jgq7iyfoyj3ur3xkj6knh7t7vr32kc743ztyjskkdevyh6l75q
behaviours/blacklisting.py: bafybeic7o2jzmhbamdcebbdjeie3dkm7y2wq7xutpeshqmrt2hdq65vlai
behaviours/blacklisting.py: bafybeid2kwsrq3ityeqsixalpaxwwiduo3lvqs5uzqhw5yfccqz5hqm6im
behaviours/claim_subscription.py: bafybeihv5dg74deifzk46ppdwcvz6lgamgl6m7qr6sgqv2zie35j2576ca
behaviours/decision_receive.py: bafybeig4gmlad7epkaao6nsfqya3zqhllt4hwiijtarcczmokxekxehrcu
behaviours/decision_request.py: bafybeico22ps3u7olsny5c2efki4x2tub726s4mpnqnsx7oyzv4yd5fa4y
behaviours/decision_request.py: bafybeiesxnu3outdldwrd2rhbokryvik5uzp6wr6dqhwypy66txev322um
behaviours/handle_failed_tx.py: bafybeidxpc6u575ymct5tdwutvzov6zqfdoio5irgldn3fw7q3lg36mmxm
behaviours/order_subscription.py: bafybeifygejified3yoza3gy4g7ina6m4lmz4pp2abtwfuwrmiwznnvrua
behaviours/randomness.py: bafybeidmr33teizrs4uxlo5tdz766ds6os4pe5lttstm7jpmhgmjz5ti3q
behaviours/reedem.py: bafybeibenzbek5qdtk3gobjxfmsm6tg6i3d4yltozymy23izpgbcpal5ye
behaviours/reedem.py: bafybeihwe4azke5zbdu4rhhsx3bmjgnkagwkuowyowvkure2do2rg4ainy
behaviours/round_behaviour.py: bafybeidrks62unrnoyp3jnbz2nozgnittfntyknymuuja7jwcsjuap4fve
behaviours/sampling.py: bafybeibtkli72qsvotkrsepkgpiumtr5sershtkpb427oygnszs3dpgxry
behaviours/tool_selection.py: bafybeicxw4je76uc7znx4u2hq2b2aaxcf7blwfla7lhdhkqnf3kkupsczq
Expand All @@ -32,7 +32,7 @@ fingerprint:
io_/loader.py: bafybeih3sdsx5dhe4kzhtoafexjgkutsujwqy3zcdrlrkhtdks45bc7exa
models.py: bafybeihzxf3dhx73lk7d56ir7zhmz2x6u5x6aga6f7rfms37zkvaqhfelm
payloads.py: bafybeibmjrckgsflqulviynadl6bx3keuabvhfolkiib7cmjhfsov2vuty
policy.py: bafybeihca4gc5gdj3wmvtzulqq3cr4zm6ouyt7aoscfedutzr4so4bksna
policy.py: bafybeidbsu5zn456jpku65jajwlxyg5kn2ltlkctkculkj2i2tfmmwm4jq
redeem_info.py: bafybeifiiix4gihfo4avraxt34sfw35v6dqq45do2drrssei2shbps63mm
rounds.py: bafybeih6bo7nnc7hvg67svio3f6cwob55qp4bgxjcejsmj6el3zhltz7bq
states/__init__.py: bafybeid23llnyp6j257dluxmrnztugo5llsrog7kua53hllyktz4dqhqoy
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 @@ -25,8 +25,8 @@ skills:
- valory/transaction_settlement_abci:0.1.0:bafybeihcfbjnty6j4aluaajgfdrc4ctg76ebb3gfub5pwqtooait7x76r4
- valory/termination_abci:0.1.0:bafybeicklx5s3mjl4pgkcz36bw2vuuqj6w73qyh455vkoncyanxqlns6ze
- valory/market_manager_abci:0.1.0:bafybeigcboyrmlmuwtzuvkxi4uiklromiyuaund4xgtfjbxwsuemndidna
- valory/decision_maker_abci:0.1.0:bafybeiailugc3i2ujbzwoylfoltdanz7xbgnscykrur2u4tt2sgui46t4m
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeifbbhgebvszz3eekvrdyvgwr7w5luaeepjbswirnaeauziyfuxt4q
- valory/decision_maker_abci:0.1.0:bafybeick4cueks2xwktifcrnkwr3f7ta6a57swbsn46tujmjsiqb4uuh74
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeif6uqfiwizn4xd5k67rdslb56l2vrtvc53jirvn7xz32aht6cttzm
- valory/staking_abci:0.1.0:bafybeiafgwdxmnyme675pcdagrgtu34riizw5aig65hvku355sd7rharj4
behaviours:
main:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ def end_block(self) -> Optional[Tuple[BaseSynchronizedData, Enum]]:
synced_data = SynchronizedData(self.synchronized_data.db)
event = submitter_to_event.get(synced_data.tx_submitter, Event.UNRECOGNIZED)

# if a mech request was just performed, increase the utilized tool's counter
if event == Event.DECISION_REQUESTING_DONE:
policy = synced_data.policy
policy.tool_used(synced_data.mech_tool_idx)
policy_update = policy.serialize()
self.synchronized_data.update(policy=policy_update)

# if a bet was just placed, edit the utilized tools mapping
if event == Event.BET_PLACEMENT_DONE:
utilized_tools = synced_data.utilized_tools
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ fingerprint:
fsm_specification.yaml: bafybeib7nmznbbug6icxyahy34r6ory7ujkwnlakv3bgmnlecysr46l5v4
handlers.py: bafybeiafbqr7ojfcbwohvee7x4zzswad3ymfrrbjlfz7uuuttmn3qdfs6q
models.py: bafybeigtmxoecoow663hgqnyinxarlrttyyt5ghpbdamdv4tc4kikcfx3a
rounds.py: bafybeictmmkmkxsbij4zhcsth6avb477tzhqaycpjkx2igtec2czszx6hu
rounds.py: bafybeifzdrrx73azctfpdbhiha7ie7pu6mxzmfjfjzq5umdlfyt6j4g2tq
fingerprint_ignore_patterns: []
connections: []
contracts: []
protocols:
- valory/ledger_api:1.0.0:bafybeihdk6psr4guxmbcrc26jr2cbgzpd5aljkqvpwo64bvaz7tdti2oni
skills:
- valory/abstract_round_abci:0.1.0:bafybeifrsatxr4syaccaxnirpvm2zetttlmrp3vr3fmqm7vc7lazy4i2bm
- valory/decision_maker_abci:0.1.0:bafybeiailugc3i2ujbzwoylfoltdanz7xbgnscykrur2u4tt2sgui46t4m
- valory/decision_maker_abci:0.1.0:bafybeick4cueks2xwktifcrnkwr3f7ta6a57swbsn46tujmjsiqb4uuh74
- valory/staking_abci:0.1.0:bafybeiafgwdxmnyme675pcdagrgtu34riizw5aig65hvku355sd7rharj4
behaviours:
main:
Expand Down

0 comments on commit ba769ea

Please sign in to comment.