Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

new info_utility field in csv Bencharming files #378

Open
wants to merge 62 commits into
base: feat/benchmarking-convergence
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
d841608
feat/add sell outcome token feature
annasambrook Nov 7, 2024
501b33d
fix error in reported message
annasambrook Nov 12, 2024
65cb73a
add return amount and sell outcome token round
annasambrook Nov 13, 2024
b7e7a51
chore: generators
annasambrook Nov 13, 2024
a50ecad
Merge remote-tracking branch 'refs/remotes/origin/main' into feat/sell
annasambrook Nov 13, 2024
1284dfb
chore: generators
annasambrook Nov 13, 2024
7cf0997
make requested changes
annasambrook Nov 15, 2024
4188687
Merge remote-tracking branch 'refs/remotes/origin/hotfix/staking-kpi-…
annasambrook Nov 22, 2024
104de4f
make suggested changes
annasambrook Nov 22, 2024
e35ce11
chore: generators
annasambrook Nov 22, 2024
1711625
fix: change copyright date
annasambrook Nov 22, 2024
502897e
chore: generators
annasambrook Nov 22, 2024
32fb70d
Merge branch 'refs/heads/hotfix/staking-kpi-reachability' into feat/sell
annasambrook Dec 5, 2024
445998e
add: previous_vote and sell logic
annasambrook Dec 5, 2024
fe78d74
add: initial fsm changes to include sell outcome token round
annasambrook Dec 5, 2024
3fd007f
chore: generators
annasambrook Dec 5, 2024
5e0524c
fix: copyright date
annasambrook Dec 6, 2024
6f47bf1
Merge branch 'hotfix/staking-kpi-reachability' into feat/sell
Adamantios Dec 6, 2024
b65ba87
chore: ignore bandit's false positive error
Adamantios Dec 6, 2024
e9ba6ee
chore: run generators
Adamantios Dec 6, 2024
a3aae14
feat: update the bets so that we store investments per vote
Adamantios Dec 6, 2024
89cd038
chore: create an action to enforce a merge rule for `main`
Adamantios Dec 6, 2024
cf12051
Merge pull request #367 from valory-xyz/feat/bets-structure
Adamantios Dec 9, 2024
3dc7f7e
Merge remote-tracking branch 'origin/feat/sell' into feat/sell
annasambrook Dec 9, 2024
2709c8c
fix: approval tx status
annasambrook Dec 9, 2024
f919d2e
fix: build approval tx
annasambrook Dec 9, 2024
0a5fc2c
fix: make return amount property
annasambrook Dec 9, 2024
d0e3497
fix: build approval tx token
annasambrook Dec 9, 2024
2f0afa2
fix: remove is wxdai check
annasambrook Dec 9, 2024
87d1205
chore: generators
annasambrook Dec 9, 2024
79191b9
Merge branch 'refs/heads/hotfix/staking-kpi-reachability' into feat/sell
annasambrook Dec 9, 2024
2e90b9e
chore: generators
annasambrook Dec 9, 2024
cdfa138
chore: generators
annasambrook Dec 9, 2024
d234b5e
Update packages/valory/skills/decision_maker_abci/behaviours/bet_plac…
annasambrook Dec 9, 2024
235881b
Update packages/valory/skills/decision_maker_abci/behaviours/bet_plac…
annasambrook Dec 9, 2024
f09d85a
add: mech calls limit for benchmarking
keshav1998 Dec 10, 2024
5c6c190
add: sampling logic for benchmarking
keshav1998 Dec 10, 2024
55078b0
add: bet transaction update for benchmarking
keshav1998 Dec 10, 2024
5799490
update: queue transition for benchmarking round
keshav1998 Dec 10, 2024
de962fd
add: counting for mocked mech calls
keshav1998 Dec 10, 2024
4ce25ca
add: check if mech calls reached in benchmarking
keshav1998 Dec 10, 2024
0bb5edd
update: blacklisting behaviour for benchmarking
keshav1998 Dec 10, 2024
2181e9d
add: call count update
keshav1998 Dec 10, 2024
3d23e49
chore: generate hashes
keshav1998 Dec 10, 2024
7231b22
revert: benchmarking changes for blacklisting
keshav1998 Dec 10, 2024
0cd8841
update: bet to benchmarking done if no mock
keshav1998 Dec 10, 2024
f5b2d1e
add: benchmarking done queue status
keshav1998 Dec 10, 2024
8d048d9
add: reprocessed bets to be considered
keshav1998 Dec 10, 2024
44db605
chorde: update generators
keshav1998 Dec 10, 2024
1288b27
add: mech calls reset for benchmarking
keshav1998 Dec 12, 2024
8c6a22b
chore: run generators
keshav1998 Dec 12, 2024
3b3b120
fixing nr_mech_calls default value in service params
cyberosa Dec 12, 2024
f7c4c2c
fix: handle queue status conversion
keshav1998 Dec 12, 2024
2e042be
chore: run generators
keshav1998 Dec 12, 2024
415ae41
new info_utility field in csv Bencharming files
cyberosa Jan 2, 2025
cff43cc
updating skill.yaml files with the new parameter
cyberosa Jan 3, 2025
f810570
updating packages
cyberosa Jan 3, 2025
3e31737
merge with benchmarking convergence branch
cyberosa Jan 3, 2025
6ae14e1
Fixing copyright year
cyberosa Jan 3, 2025
02c5fb5
updating header year to 2025
cyberosa Jan 3, 2025
20a5168
header with 2025 year and linter checks fixed
cyberosa Jan 3, 2025
4211121
extra # and missing docstring
cyberosa Jan 3, 2025
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
14 changes: 14 additions & 0 deletions .github/workflows/merge_rules.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: 'Check Branch'

on:
pull_request:

jobs:
check_branch:
runs-on: ubuntu-latest
steps:
- name: Check branch
if: github.base_ref == 'main' && github.head_ref != 'develop'
run: |
echo "ERROR: You can only merge to main from develop."
exit 1
16 changes: 8 additions & 8 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"custom/jhehemann/kelly_criterion/0.1.0": "bafybeif55cu7cf6znyma7kxus4wxa2doarhau2xmndo57iegshxorivwmq",
"custom/w1kke/always_blue/0.1.0": "bafybeieshu32h3es2fslduuhr7nimuvh2vuibyeqdunzrcggaeohekg3jm",
"custom/valory/kelly_criterion_no_conf/0.1.0": "bafybeibxfp27rzrfnp7sxq62vwv32pdvrijxi7vzg7ihukkaka3bwzrgae",
"contract/valory/market_maker/0.1.0": "bafybeihrz4q5ia7jnflsv2myg6kkung2dfiogqrevuy7xlmqws7tr27rdi",
"contract/valory/market_maker/0.1.0": "bafybeibevdc5trbi2qgt2tvwbsr2h5xvonfhcjwfmozftzvef575fdvbjq",
"contract/valory/realitio/0.1.0": "bafybeietgux6kkhdquspy35qera7gjwwqwrremmoeatjzwwokjb2lzsata",
"contract/valory/realitio_proxy/0.1.0": "bafybeidx37xzjjmapwacedgzhum6grfzhp5vhouz4zu3pvpgdy5pgb2fr4",
"contract/valory/conditional_tokens/0.1.0": "bafybeibnzmqmeph4cj5vfh3s622mo2o5627vjjwc6bptrhj4dk65mzgvhe",
Expand All @@ -15,15 +15,15 @@
"contract/valory/mech_activity/0.1.0": "bafybeibmqmle5fnal3gxlpdmcos2kogzra4q3pr3o5nh7shplxuilji3t4",
"contract/valory/staking_token/0.1.0": "bafybeiep4r6qyilbfgzdvx6t7zvpgaioxqktmxm7puwtnbpb2ftlib43gy",
"contract/valory/relayer/0.1.0": "bafybeicawmds6czx7db2lcktvexwrp245jpekgulndtos5s5zdid3ilvq4",
"skill/valory/market_manager_abci/0.1.0": "bafybeiaru2d32wpmcgqs64eepxud4idgubc3vmsbdwbia7gygipql2mmqi",
"skill/valory/decision_maker_abci/0.1.0": "bafybeie5xp55kt3cjghhmk4v6mdcagfgk4vkneaxdttnxmtdcbfrxwc26a",
"skill/valory/trader_abci/0.1.0": "bafybeid3sehixzitg2xnsgr76h64rsyp2tngzycygyj26nkkg5gzsqzwfi",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeicztsvr3hnmzlg6irafx3phqfftmnk4zrfph4krsnpinekkjdlon4",
"skill/valory/market_manager_abci/0.1.0": "bafybeiaf37mqv45yptqqd6e7fxv5cjrrxrh4pjpe3bs6zkiou53e5lpoia",
"skill/valory/decision_maker_abci/0.1.0": "bafybeieqpqlpr4f2ulpnecw6qizaq2vucmkqnggmdj5n5wi5bzmuipbj4a",
"skill/valory/trader_abci/0.1.0": "bafybeictflzdal74ri34qxmnyorbykygdgpisaj3px6cuu3d52soigmvoa",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeigsdvhghcfwrwttekotansxa3ps6jrul5xpt2bkrdmiu6y5osfnxi",
"skill/valory/staking_abci/0.1.0": "bafybeicupccurmrg7qesivonlyt3nryarsmk5qf5yh6auno64wn45bybvq",
"skill/valory/check_stop_trading_abci/0.1.0": "bafybeieduekpd4zbvjztyxyooppqnmjvup6jfp74uo6hhupvtvzzscdzkq",
"agent/valory/trader/0.1.0": "bafybeiczpkr2drsdppith4foyeby6zf5uxugjfjfhl7yocvr3mcdkjzjpa",
"service/valory/trader/0.1.0": "bafybeiaa3a3e2mg2eowfryszytitwuvs6icxezv5pjtubwnizp2u4s7mte",
"service/valory/trader_pearl/0.1.0": "bafybeiboqxm3lhlqils5tohg7bqlc7pqfpv7hkhj3xixtj6ybdpeemm4f4"
"agent/valory/trader/0.1.0": "bafybeihe6dn75yxe2f6dbtaj72j6glxwtviv7i7copg3sde2fin4xblnk4",
"service/valory/trader/0.1.0": "bafybeib72thsyyalobemgnc6vfunxqdvqlf744bphyfzvyixqheiie3wom",
"service/valory/trader_pearl/0.1.0": "bafybeidbc6ob2mpecv5o2tgdlx6snyh2iew7o3igginbxmhdq3remt4zca"
},
"third_party": {
"protocol/open_aea/signing/1.0.0": "bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi",
Expand Down
12 changes: 7 additions & 5 deletions packages/valory/agents/trader/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contracts:
- valory/gnosis_safe:0.1.0:bafybeih3ropivth4wn7zbzudisx3qezbht5jyndd4w7az7fq634lpozoge
- valory/gnosis_safe_proxy_factory:0.1.0:bafybeieg57u3z7cdlmdamad5e6lk7kmsli2zurzkg3sl4y7lhekcu4y3au
- valory/service_registry:0.1.0:bafybeiaop64kwdoetxtedoehabmsalojmms7ihuoqcdwxtwb2hk5i6bzye
- valory/market_maker:0.1.0:bafybeihrz4q5ia7jnflsv2myg6kkung2dfiogqrevuy7xlmqws7tr27rdi
- valory/market_maker:0.1.0:bafybeibevdc5trbi2qgt2tvwbsr2h5xvonfhcjwfmozftzvef575fdvbjq
- valory/multisend:0.1.0:bafybeig5byt5urg2d2bsecufxe5ql7f4mezg3mekfleeh32nmuusx66p4y
- valory/mech:0.1.0:bafybeiejfjfoxqggghcme43sx53q5gruefrws3k2jam2opkxl5uzffoarm
- valory/conditional_tokens:0.1.0:bafybeibnzmqmeph4cj5vfh3s622mo2o5627vjjwc6bptrhj4dk65mzgvhe
Expand All @@ -45,10 +45,10 @@ skills:
- valory/reset_pause_abci:0.1.0:bafybeigrdlxed3xlsnxtjhnsbl3cojruihxcqx4jxhgivkd5i2fkjncgba
- valory/termination_abci:0.1.0:bafybeib5l7jhew5ic6iq24dd23nidcoimzqkrk556gqywhoziatj33zvwm
- valory/transaction_settlement_abci:0.1.0:bafybeic7q7recyka272udwcupblwbkc3jkodgp74fvcdxb7urametg5dae
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeicztsvr3hnmzlg6irafx3phqfftmnk4zrfph4krsnpinekkjdlon4
- valory/market_manager_abci:0.1.0:bafybeiaru2d32wpmcgqs64eepxud4idgubc3vmsbdwbia7gygipql2mmqi
- valory/decision_maker_abci:0.1.0:bafybeie5xp55kt3cjghhmk4v6mdcagfgk4vkneaxdttnxmtdcbfrxwc26a
- valory/trader_abci:0.1.0:bafybeid3sehixzitg2xnsgr76h64rsyp2tngzycygyj26nkkg5gzsqzwfi
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeigsdvhghcfwrwttekotansxa3ps6jrul5xpt2bkrdmiu6y5osfnxi
- valory/market_manager_abci:0.1.0:bafybeiaf37mqv45yptqqd6e7fxv5cjrrxrh4pjpe3bs6zkiou53e5lpoia
- valory/decision_maker_abci:0.1.0:bafybeieqpqlpr4f2ulpnecw6qizaq2vucmkqnggmdj5n5wi5bzmuipbj4a
- valory/trader_abci:0.1.0:bafybeictflzdal74ri34qxmnyorbykygdgpisaj3px6cuu3d52soigmvoa
- valory/staking_abci:0.1.0:bafybeicupccurmrg7qesivonlyt3nryarsmk5qf5yh6auno64wn45bybvq
- valory/check_stop_trading_abci:0.1.0:bafybeieduekpd4zbvjztyxyooppqnmjvup6jfp74uo6hhupvtvzzscdzkq
- valory/mech_interact_abci:0.1.0:bafybeid6m3i5ofq7vuogqapdnoshhq7mswmudhvfcr2craw25fdwtoe3lm
Expand Down Expand Up @@ -264,10 +264,12 @@ models:
p_yes_field_part: ${str:p_yes_}
p_no_field_part: ${str:p_no_}
confidence_field_part: ${str:confidence_}
info_utility_field_part: ${str:info_utility_}
part_prefix_mode: ${bool:true}
bet_amount_field: ${str:collateral_amount}
results_filename: ${str:benchmarking_results.csv}
randomness: ${str:benchmarking_randomness}
nr_mech_calls: ${int:60}
acc_info_fields:
args:
tool: ${str:tool}
Expand Down
53 changes: 52 additions & 1 deletion packages/valory/contracts/market_maker/contract.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2023 Valory AG
# 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.
Expand Down Expand Up @@ -133,3 +133,54 @@ def get_buy_data(
outcomeIndex=outcome_index,
minOutcomeTokensToBuy=min_outcome_tokens_to_buy,
)

@classmethod
def calc_sell_amount(
cls,
ledger_api: EthereumApi,
contract_address: str,
return_amount: int,
outcome_index: int,
) -> JSONLike:
"""
Calculate the buy amount.

:param ledger_api: the ledger API object
:param contract_address: the contract address
:param return_amount: the amount the user will have returned
:param outcome_index: the index of the answer's outcome that the user wants to sell for
:return: the outcomeTokenSellAmount
"""
outcome_token_sell_amount = cls._method_call(
ledger_api,
contract_address,
"calcSellAmount",
returnAmount=return_amount,
outcomeIndex=outcome_index,
)
return dict(outcomeTokenSellAmount=outcome_token_sell_amount)

def get_sell_data(
cls,
ledger_api: LedgerApi,
contract_address: str,
return_amount: int,
outcome_index: int,
max_outcome_tokens_to_sell: int,
) -> Dict[str, bytes]:
"""Gets the encoded arguments for a sell tx, which should only be called via the multisig.

:param ledger_api: the ledger API object
:param contract_address: the contract address
:param return_amount: the amount the user have returned
:param outcome_index: the index of the answer's outcome that the user wants to sell tokens for
:param max_outcome_tokens_to_sell: the output of the `calcSellAmount` contract method
"""
return cls._encode_abi(
ledger_api,
contract_address,
"sell",
returnAmount=return_amount,
outcomeIndex=outcome_index,
maxOutcomeTokenSellAmount=max_outcome_tokens_to_sell,
)
2 changes: 1 addition & 1 deletion packages/valory/contracts/market_maker/contract.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fingerprint:
README.md: bafybeiegnihrovfkk5big52pl4bo6evt5toqvvmft2jgnq6ofdbhfp7xwa
__init__.py: bafybeicoucixii3fv5xlpk3zfewm4ys4okidcng54bhtjxvwup7g2jcjza
build/FixedProductMarketMaker.json: bafybeigim7n3f67r5czfc5wp2m7cxzxwvnhxops3n5j2zlawenan7qrrtu
contract.py: bafybeicfiicuke4ly5hpcxtyvnob5bgzrqsopuxalruxp2m3w4koxmhrqa
contract.py: bafybeifcopgnnts3dbfh636vvdsgporlkt2olwr2iwuwaom5vjcrtbe5wi
fingerprint_ignore_patterns: []
contracts: []
class_name: FixedProductMarketMakerContract
Expand Down
4 changes: 3 additions & 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:bafybeiczpkr2drsdppith4foyeby6zf5uxugjfjfhl7yocvr3mcdkjzjpa
agent: valory/trader:0.1.0:bafybeihe6dn75yxe2f6dbtaj72j6glxwtviv7i7copg3sde2fin4xblnk4
number_of_agents: 4
deployment:
agent:
Expand Down Expand Up @@ -167,10 +167,12 @@ type: skill
p_yes_field_part: ${BENCHMARKING_MODE_P_YES_FIELD_PART:str:p_yes_}
p_no_field_part: ${BENCHMARKING_MODE_P_NO_FIELD_PART:str:p_no_}
confidence_field_part: ${BENCHMARKING_MODE_CONFIDENCE_FIELD_PART:str:confidence_}
info_utility_field_part: ${BENCHMARKING_MODE_INFO_UTILITY_FIELD_PART:str:info_utility_}
part_prefix_mode: ${BENCHMARKING_MODE_PART_PREFIX_MODE:bool:true}
bet_amount_field: ${BENCHMARKING_MODE_BET_AMOUNT_FIELD:str:collateral_amount}
results_filename: ${BENCHMARKING_MODE_RESULTS_FILENAME:str:benchmarking_results.csv}
randomness: ${BENCHMARKING_MODE_RANDOMNESS:str:benchmarking_randomness}
nr_mech_calls: ${BENCHMARKING_MECH_CALLS:int:60}
acc_info_fields: &id005
args:
tool: ${ACC_INFO_FIELDS_TOOL:str:tool}
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:bafybeiczpkr2drsdppith4foyeby6zf5uxugjfjfhl7yocvr3mcdkjzjpa
agent: valory/trader:0.1.0:bafybeihe6dn75yxe2f6dbtaj72j6glxwtviv7i7copg3sde2fin4xblnk4
number_of_agents: 1
deployment:
agent:
Expand Down
45 changes: 40 additions & 5 deletions packages/valory/skills/decision_maker_abci/behaviours/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2023-2024 Valory AG
# Copyright 2023-2025 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 @@ -29,6 +29,7 @@
from aea.configurations.data_types import PublicId
from aea.protocols.base import Message
from aea.protocols.dialogue.base import Dialogue
from hexbytes import HexBytes

from packages.valory.contracts.erc20.contract import ERC20
from packages.valory.contracts.gnosis_safe.contract import (
Expand Down Expand Up @@ -68,6 +69,7 @@
from packages.valory.skills.market_manager_abci.bets import (
Bet,
CONFIDENCE_FIELD,
INFO_UTILITY_FIELD,
P_NO_FIELD,
P_YES_FIELD,
PredictionResponse,
Expand Down Expand Up @@ -354,12 +356,14 @@ def check_balance(self) -> WaitableConditionType:
def update_bet_transaction_information(self) -> None:
"""Get whether the bet's invested amount should be updated."""
sampled_bet = self.sampled_bet
# Update the bet's invested amount, the new bet amount is added to previously invested amount
sampled_bet.invested_amount += self.synchronized_data.bet_amount

# Update the bet's invested amount
updated = sampled_bet.update_investments(self.synchronized_data.bet_amount)
if not updated:
self.context.logger.error("Could not update the investments!")

# Update bet transaction timestamp
sampled_bet.processed_timestamp = self.synced_timestamp
# update no of bets made
sampled_bet.n_bets += 1
# Update Queue number for priority logic
sampled_bet.queue_status = sampled_bet.queue_status.next_status()

Expand Down Expand Up @@ -683,6 +687,7 @@ def _write_benchmark_results(
P_YES_FIELD,
P_NO_FIELD,
CONFIDENCE_FIELD,
INFO_UTILITY_FIELD,
self.benchmarking_mode.bet_amount_field,
L0_START_FIELD,
L1_START_FIELD,
Expand All @@ -701,6 +706,7 @@ def _write_benchmark_results(
prediction_response.p_yes,
prediction_response.p_no,
prediction_response.confidence,
prediction_response.info_utility,
bet_amount,
liquidity_info.l0_start,
liquidity_info.l1_start,
Expand All @@ -719,6 +725,35 @@ def finish_behaviour(self, payload: BaseTxPayload) -> Generator:

self.set_done()

def build_approval_tx(
self, amount: int, spender: str, token: str
) -> WaitableConditionType:
"""Build an ERC20 approve transaction."""
response_msg = yield from self.get_contract_api_response(
performative=ContractApiMessage.Performative.GET_STATE, # type: ignore
contract_address=self.collateral_token,
contract_id=str(ERC20.contract_id),
contract_callable="build_approval_tx",
spender=spender,
amount=amount,
)

if response_msg.performative != ContractApiMessage.Performative.STATE:
self.context.logger.info(f"Could not build approval tx: {response_msg}")
return False

approval_data = response_msg.state.body.get("data")
if approval_data is None:
self.context.logger.info(f"Could not build approval tx: {response_msg}")
return False

batch = MultisendBatch(
to=token,
data=HexBytes(approval_data),
)
self.multisend_batches.append(batch)
return True


class BaseSubscriptionBehaviour(DecisionMakerBaseBehaviour, ABC):
"""Base class for subscription behaviours."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,30 +99,12 @@ def _build_exchange_tx(self) -> WaitableConditionType:

def _build_approval_tx(self) -> WaitableConditionType:
"""Build an ERC20 approve transaction."""
response_msg = yield from self.get_contract_api_response(
performative=ContractApiMessage.Performative.GET_STATE, # type: ignore
contract_address=self.collateral_token,
contract_id=str(ERC20.contract_id),
contract_callable="build_approval_tx",
spender=self.market_maker_contract_address,
amount=self.investment_amount,
status = yield from self.build_approval_tx(
self.investment_amount,
self.market_maker_contract_address,
self.collateral_token,
)

if response_msg.performative != ContractApiMessage.Performative.STATE:
self.context.logger.info(f"Could not build approval tx: {response_msg}")
return False

approval_data = response_msg.state.body.get("data")
if approval_data is None:
self.context.logger.info(f"Could not build approval tx: {response_msg}")
return False

batch = MultisendBatch(
to=self.collateral_token,
data=HexBytes(approval_data),
)
self.multisend_batches.append(batch)
return True
return status

def _calc_buy_amount(self) -> WaitableConditionType:
"""Calculate the buy amount of the conditional token."""
Expand Down Expand Up @@ -209,6 +191,7 @@ def async_act(self) -> Generator:
if self.benchmarking_mode.enabled:
# simulate the bet placement
with self.context.benchmark_tool.measure(self.behaviour_id).local():
self.update_bet_transaction_information()
payload = BetPlacementPayload(
agent, None, None, True, self.wallet_balance
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2023-2024 Valory AG
# Copyright 2023-2025 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 @@ -126,6 +126,9 @@ def _next_dataset_row(self) -> Optional[Dict[str, str]]:
else:
# no more bets available for this market
msg = f"No more mock responses for the market with id: {sampled_bet_id}"
self.sampled_bet.queue_status = (
self.sampled_bet.queue_status.mark_benchmarking_done()
)
self.context.logger.info(msg)
self.shared_state.last_benchmarking_has_run = True
self._rows_exceeded = True
Expand Down Expand Up @@ -157,6 +160,7 @@ def _parse_dataset_row(self, row: Dict[str, str]) -> str:
P_YES_FIELD: mode.p_yes_field_part,
P_NO_FIELD: mode.p_no_field_part,
CONFIDENCE_FIELD: mode.confidence_field_part,
INFO_UTILITY_FIELD: mode.info_utility_field_part,
}.items():
if mode.part_prefix_mode:
fields[prediction_attribute] = row[field_part + mech_tool]
Expand All @@ -171,8 +175,6 @@ def _parse_dataset_row(self, row: Dict[str, str]) -> str:
float(fields[P_YES_FIELD]),
)

# set the info utility to zero as it does not matter for the benchmark
fields[INFO_UTILITY_FIELD] = "0"
return json.dumps(fields)

def _mock_response(self) -> None:
Expand Down Expand Up @@ -514,6 +516,9 @@ def _is_profitable(
else:
self._write_benchmark_results(prediction_response)

self.context.logger.info("Increasing Mech call count by 1")
self.shared_state.benchmarking_mech_calls += 1

return is_profitable, bet_amount

def _update_selected_bet(
Expand All @@ -531,8 +536,6 @@ def _update_selected_bet(
self.context.logger.info(
f"with the timestamp:{datetime.fromtimestamp(active_sampled_bet.processed_timestamp)}"
)
if prediction_response is not None:
active_sampled_bet.n_bets += 1

self.store_bets()

Expand Down Expand Up @@ -569,6 +572,8 @@ def async_act(self) -> Generator:
prediction_response,
bet_amount,
)
self.context.logger.info("Increasing Mech call count by 1")
self.shared_state.benchmarking_mech_calls += 1

if prediction_response is not None:
self.policy.tool_responded(
Expand Down
Loading
Loading