Skip to content

Commit 1ed85b3

Browse files
Merge remote-tracking branch 'origin/main' into feat/polymarket-bet-selection-gates
# Conflicts: # packages/packages.json # packages/valory/agents/trader/aea-config.yaml # packages/valory/services/polymarket_trader/service.yaml # packages/valory/services/trader_pearl/service.yaml
2 parents e4d50f6 + 272a236 commit 1ed85b3

6 files changed

Lines changed: 174 additions & 17 deletions

File tree

packages/packages.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
"connection/valory/polymarket_client/0.1.0": "bafybeid4eo37pka4tfhsjs6rb3knrugmokcvihust2dpfrgob56y77xd44",
1111
"skill/valory/market_manager_abci/0.1.0": "bafybeic67hypwetzltnuy3a6y3o2o332lxyvn34buq57gy4n6bfqpbpxjm",
1212
"skill/valory/decision_maker_abci/0.1.0": "bafybeidsonnk4yma356zkil6xxpav6m7twoxuqa2s2in4ehjagw5bjd3se",
13-
"skill/valory/trader_abci/0.1.0": "bafybeibdbcwsvcy3fiest4cxx2iafxg4roy3tkn2g6tkpibukhtdkrci4i",
13+
"skill/valory/trader_abci/0.1.0": "bafybeihiujaz45ny5nfxpkwrac5iflxvj7o7xv4cnhnf3s4pefkfufhpru",
1414
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeigndtkxcmmfrdpnq4drv6hcnodrdjqqb3trcjpmwnn6tdbu43g5uq",
1515
"skill/valory/staking_abci/0.1.0": "bafybeihwyron2bv7ierrgxke7xofwjy7x6wtglg5vopon7i7lfdiivweaq",
1616
"skill/valory/agent_performance_summary_abci/0.1.0": "bafybeigmmvpncem6i6t57nwjqzajrbnf6rnqgp43mlo6jf6uziq6lrhlca",
1717
"skill/valory/check_stop_trading_abci/0.1.0": "bafybeifbiko6p3sqqg2q6qemmcig432s5djcsxm44j35ejittlpyr5f6z4",
1818
"skill/valory/chatui_abci/0.1.0": "bafybeie2kmgihgk3rwpzelaa76ypvchsyg2vy3me4vxlbjttaq4frs3ipa",
19-
"agent/valory/trader/0.1.0": "bafybeietfanr5kozlsg3zqwegg4aawktlfrww6x25skdjebujlcr4hlu3q",
20-
"service/valory/trader_pearl/0.1.0": "bafybeidd4llc32jvbnmm4r6khzqjzfprwk2dndvb3m4o7awjsmoll6q43i",
21-
"service/valory/polymarket_trader/0.1.0": "bafybeidxoe3bpkpoyex5xgmnkchjmpzsaqqi2bpu7tucipgx3mds2c5ydi"
19+
"agent/valory/trader/0.1.0": "bafybeic5vg7qos26dyafhrzvhyvljmqj3t5zsrekhwtdqshuq5jltgky3m",
20+
"service/valory/trader_pearl/0.1.0": "bafybeih3uakz6euj3g6uzi6drautdji6tlitphtwk2q6ig5ccdjohjufx4",
21+
"service/valory/polymarket_trader/0.1.0": "bafybeicrag6gbqlnbvaqtkoyckmf55axxczgdlzf5vayldhkszyobuvnue"
2222
},
2323
"third_party": {
2424
"protocol/valory/acn_data_share/0.1.0": "bafybeieqisfr6lhaaesq37lk7vyaxza2h6nucshksgyo2djqfyf2saqo4i",

packages/valory/agents/trader/aea-config.yaml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ skills:
6969
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeigndtkxcmmfrdpnq4drv6hcnodrdjqqb3trcjpmwnn6tdbu43g5uq
7070
- valory/market_manager_abci:0.1.0:bafybeic67hypwetzltnuy3a6y3o2o332lxyvn34buq57gy4n6bfqpbpxjm
7171
- valory/decision_maker_abci:0.1.0:bafybeidsonnk4yma356zkil6xxpav6m7twoxuqa2s2in4ehjagw5bjd3se
72-
- valory/trader_abci:0.1.0:bafybeibdbcwsvcy3fiest4cxx2iafxg4roy3tkn2g6tkpibukhtdkrci4i
72+
- valory/trader_abci:0.1.0:bafybeihiujaz45ny5nfxpkwrac5iflxvj7o7xv4cnhnf3s4pefkfufhpru
7373
- valory/staking_abci:0.1.0:bafybeihwyron2bv7ierrgxke7xofwjy7x6wtglg5vopon7i7lfdiivweaq
7474
- valory/check_stop_trading_abci:0.1.0:bafybeifbiko6p3sqqg2q6qemmcig432s5djcsxm44j35ejittlpyr5f6z4
7575
- valory/mech_interact_abci:0.1.0:bafybeidnmszufszq3ro4ebgrqzmhqgctrsc6sykeanfsbvotghvt2cgfsy
@@ -270,7 +270,7 @@ models:
270270
genai_api_key: ${GENAI_API_KEY:str:""}
271271
x402_payment_requirements: ${dict:{"threshold":200000,"top_up":250000}}
272272
gnosis_ledger_rpc: ${str:https://rpc.gnosischain.com/}
273-
polygon_ledger_rpc: ${POLYGON_LEDGER_RPC:str:https://1rpc.io/matic}
273+
polygon_ledger_rpc: ${POLYGON_LEDGER_RPC:str:https://polygon.drpc.org}
274274
lifi_quote_to_amount_url: ${str:https://li.quest/v1/quote/toAmount}
275275
use_x402: ${USE_X402:bool:false}
276276
is_agent_performance_summary_enabled: ${IS_AGENT_PERFORMANCE_SUMMARY_ENABLED:bool:true}
@@ -476,7 +476,7 @@ models:
476476
error_index: ${int:0}
477477
error_type: ${str:dict}
478478
retries: ${int:5}
479-
url: ${MECHS_SUBGRAPH_URL:str:https://api.subgraph.autonolas.tech/api/proxy/marketplace-gnosis}
479+
url: ${str:https://api.subgraph.autonolas.tech/api/proxy/marketplace-gnosis}
480480
delivery_rate_cap: ${int:10000000000000000}
481481
polymarket_agents_subgraph:
482482
args:
@@ -546,7 +546,7 @@ config:
546546
poa_chain: ${bool:false}
547547
default_gas_price_strategy: ${str:eip1559}
548548
polygon:
549-
address: ${POLYGON_LEDGER_RPC:str:https://1rpc.io/matic}
549+
address: ${POLYGON_LEDGER_RPC:str:https://polygon.drpc.org}
550550
chain_id: ${int:137}
551551
poa_chain: ${bool:true}
552552
default_gas_price_strategy: ${str:eip1559}
@@ -578,16 +578,17 @@ models:
578578
params:
579579
args:
580580
fund_requirements: ${FUND_REQUIREMENTS:dict:{"gnosis":{"agent":{"0x0000000000000000000000000000000000000000":{"topup":2000000000000000000,"threshold":210000000000000000}},"safe":{"0x0000000000000000000000000000000000000000":{"topup":5000000000000000000,"threshold":1000000000000000000},"0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d":{"topup":0,"threshold":0}}}}}
581-
rpc_urls: ${RPC_URLS:dict:{"gnosis":"https://rpc.gnosischain.com"}}
581+
rpc_urls:
582+
gnosis: ${GNOSIS_LEDGER_RPC:str:https://rpc.gnosischain.com}
583+
polygon: ${POLYGON_LEDGER_RPC:str:https://polygon.drpc.org}
582584
safe_contract_addresses: ${SAFE_CONTRACT_ADDRESSES:dict:{"gnosis":"0x0000000000000000000000000000000000000000"}}
583585
---
584586
public_id: valory/polymarket_client:0.1.0:bafybeicblltx7ha3ulthg7bzfccuqqyjmihhrvfeztlgrlcoxhr7kf6nbq
585587
type: connection
586588
config:
587589
host: https://clob.polymarket.com
588590
chain_id: 137
589-
safe_contract_addresses:
590-
polygon: ${SAFE_CONTRACT_ADDRESS:str:0x}
591+
safe_contract_addresses: ${SAFE_CONTRACT_ADDRESSES:dict:{"polygon":"0x0000000000000000000000000000000000000000"}}
591592
polymarket_builder_program_enabled: ${POLYMARKET_BUILDER_PROGRAM_ENABLED:bool:false}
592593
builder_code: ${POLYMARKET_BUILDER_CODE:str:0x0000000000000000000000000000000000000000000000000000000000000000}
593594
clob_version: ${CLOB_VERSION:str:v2}
@@ -598,5 +599,5 @@ config:
598599
ctf_exchange: ${POLYMARKET_CTF_EXCHANGE:str:0xE111180000d2663C0091e4f400237545B87B996B}
599600
neg_risk_ctf_exchange: ${POLYMARKET_NEG_RISK_CTF_EXCHANGE:str:0xe2222d279d744050d28e00520010520000310F59}
600601
neg_risk_adapter: ${POLYMARKET_NEG_RISK_ADAPTER:str:0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296}
601-
polygon_ledger_rpc: ${POLYGON_LEDGER_RPC:str:https://1rpc.io/matic}
602+
polygon_ledger_rpc: ${POLYGON_LEDGER_RPC:str:https://polygon.drpc.org}
602603
is_running_on_polymarket: ${IS_RUNNING_ON_POLYMARKET:bool:false}

packages/valory/services/polymarket_trader/service.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ license: Apache-2.0
88
fingerprint:
99
README.md: bafybeichoh5tnk4qctaazcjcrxvpwc5yasodleqoeapnfapwrrdh3tm5gu
1010
fingerprint_ignore_patterns: []
11-
agent: valory/trader:0.1.0:bafybeietfanr5kozlsg3zqwegg4aawktlfrww6x25skdjebujlcr4hlu3q
11+
agent: valory/trader:0.1.0:bafybeic5vg7qos26dyafhrzvhyvljmqj3t5zsrekhwtdqshuq5jltgky3m
1212
number_of_agents: 1
1313
deployment:
1414
agent:
@@ -155,7 +155,7 @@ models:
155155
coingecko_pol_in_usd_price_url: ${COINGECKO_POL_IN_USD_PRICE_URL:str:https://api.coingecko.com/api/v3/simple/token_price/polygon-pos?contract_addresses=0x0000000000000000000000000000000000001010&vs_currencies=usd}
156156
genai_api_key: ${GENAI_API_KEY:str:""}
157157
x402_payment_requirements: ${X402_PAYMENT_REQUIREMENTS:dict:{"threshold":200000,"top_up":250000}}
158-
polygon_ledger_rpc: ${POLYGON_LEDGER_RPC:str:https://1rpc.io/matic}
158+
polygon_ledger_rpc: ${POLYGON_LEDGER_RPC:str:https://polygon.drpc.org}
159159
lifi_quote_to_amount_url: ${LIFI_QUOTE_TO_AMOUNT_URL:str:https://li.quest/v1/quote/toAmount}
160160
use_x402: ${USE_X402:bool:false}
161161
is_agent_performance_summary_enabled: ${IS_AGENT_PERFORMANCE_SUMMARY_ENABLED:bool:true}
@@ -340,7 +340,7 @@ type: connection
340340
config:
341341
ledger_apis:
342342
polygon:
343-
address: ${POLYGON_LEDGER_RPC:str:https://1rpc.io/matic}
343+
address: ${POLYGON_LEDGER_RPC:str:https://polygon.drpc.org}
344344
chain_id: ${POLYGON_LEDGER_CHAIN_ID:int:137}
345345
poa_chain: ${POLYGON_LEDGER_IS_POA_CHAIN:bool:true}
346346
default_gas_price_strategy: ${POLYGON_LEDGER_PRICING:str:eip1559}
@@ -389,7 +389,7 @@ models:
389389
args:
390390
fund_requirements: ${FUND_REQUIREMENTS:dict:{"polygon":{"agent":{"0x0000000000000000000000000000000000000000":{"topup":30000000000000000000,"threshold":3200000000000000000}},"safe":{"0x0000000000000000000000000000000000000000":{"topup":40000000000000000000,"threshold":10000000000000000000},"0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB":{"topup":65000000,"threshold":16000000},"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174":{"topup":0,"threshold":0},"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359":{"topup":0,"threshold":0}}}}}
391391
rpc_urls:
392-
polygon: ${POLYGON_LEDGER_RPC:str:https://1rpc.io/matic}
392+
polygon: ${POLYGON_LEDGER_RPC:str:https://polygon.drpc.org}
393393
safe_contract_addresses: ${SAFE_CONTRACT_ADDRESSES:dict:{"polygon":"0x0000000000000000000000000000000000000000"}}
394394
---
395395
public_id: valory/polymarket_client:0.1.0:bafybeicblltx7ha3ulthg7bzfccuqqyjmihhrvfeztlgrlcoxhr7kf6nbq

packages/valory/services/trader_pearl/service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ license: Apache-2.0
88
fingerprint:
99
README.md: bafybeibg7bdqpioh4lmvknw3ygnllfku32oca4eq5pqtvdrdsgw6buko7e
1010
fingerprint_ignore_patterns: []
11-
agent: valory/trader:0.1.0:bafybeietfanr5kozlsg3zqwegg4aawktlfrww6x25skdjebujlcr4hlu3q
11+
agent: valory/trader:0.1.0:bafybeic5vg7qos26dyafhrzvhyvljmqj3t5zsrekhwtdqshuq5jltgky3m
1212
number_of_agents: 1
1313
deployment:
1414
agent:

packages/valory/skills/trader_abci/skill.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ fingerprint:
1515
handlers.py: bafybeidefu2bxiadnxbnlaiz2e4ntrcrraxhrvmvyd7uce3e274lfdodti
1616
models.py: bafybeiai3vxuyl2ydfxocaygnhbno2ef3lw4ag63turmd7fqpaleixc2xy
1717
tests/__init__.py: bafybeiadatapyjh3e7ucg2ehz77oms3ihrbutwb2cs2tkjehy54utwvuyi
18+
tests/test_agent_config_resolution.py: bafybeiflcotz6gq2dgtnzptlyyhu5fryg3c6z7gosoqmln2tlci3v4odqa
1819
tests/test_behaviours.py: bafybeicovtjruufnh2yd5lhfvc6pgcletuyj2s3jaz5sz55wsdo2w22xle
1920
tests/test_composition.py: bafybeie54kpq3hzxnqegeyswbg7upae3bi25p7xucaco36zzkekt7ivleq
2021
tests/test_dialogues.py: bafybeibatogwoj6ieapcbiwonij6vskhogc65vfv53tyauqzeyiwmnd2im
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# -*- coding: utf-8 -*-
2+
# ------------------------------------------------------------------------------
3+
#
4+
# Copyright 2026 Valory AG
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
# ------------------------------------------------------------------------------
19+
20+
"""Regression tests for the agent-level ``aea-config.yaml`` env-var wiring.
21+
22+
These guard against the class of bug introduced by renaming anonymous
23+
``${type:default}`` placeholders to named ``${NAME:type:default}`` ones.
24+
open-aea only applies the auto-derived component-path env var (e.g.
25+
``SKILL_..._ARGS_URL``) for *anonymous* placeholders; a *named* placeholder
26+
resolves solely against a bare env var of that exact name and otherwise
27+
silently falls back to its default. When the chosen name does not match what
28+
the runtime actually exports, the agent boots with the wrong (typically
29+
Omen/gnosis-flavored or ``0x``) default.
30+
31+
The agent-runner path resolves ``aea-config.yaml`` (not ``service.yaml``), so
32+
these mismatches only surface there. We resolve the real ``aea-config.yaml``
33+
with open-aea's own resolver against a representative per-chain environment
34+
and assert the result is internally consistent for both deployment flavors.
35+
"""
36+
37+
import io
38+
import json
39+
from pathlib import Path
40+
from typing import Any, Dict, List
41+
from unittest import mock
42+
43+
import pytest
44+
from aea.helpers.env_vars import apply_env_variables_on_agent_config
45+
from aea.helpers.yaml_utils import yaml_load_all
46+
47+
from packages.valory.skills.funds_manager.models import Params
48+
49+
# packages/valory/skills/trader_abci/tests/ -> packages/valory/
50+
_VALORY_DIR = Path(__file__).resolve().parents[3]
51+
AEA_CONFIG_PATH = _VALORY_DIR / "agents" / "trader" / "aea-config.yaml"
52+
53+
# The path-derived env var the middleware exports for the (anonymous) mechs
54+
# marketplace subgraph url; open-aea derives this name from the config path.
55+
MECHS_SUBGRAPH_PATH_KEY = "SKILL_TRADER_ABCI_MODELS_MECHS_SUBGRAPH_ARGS_URL"
56+
57+
SAFE = "0x318bF3775A8DE43ac803cfeDE45F62e256e3a7EC"
58+
59+
# A minimal, valid per-chain fund requirement (chain key is added per test).
60+
_FUND_REQUIREMENT = {
61+
"agent": {
62+
"0x0000000000000000000000000000000000000000": {
63+
"topup": 100000000000000000,
64+
"threshold": 50000000000000000,
65+
}
66+
},
67+
"safe": {
68+
"0x0000000000000000000000000000000000000000": {
69+
"topup": 5000000000000000000,
70+
"threshold": 2500000000000000000,
71+
}
72+
},
73+
}
74+
75+
76+
def _resolve(env: Dict[str, str]) -> List[Dict[str, Any]]:
77+
"""Resolve the real aea-config.yaml against ``env`` with open-aea's resolver.
78+
79+
:param env: the environment variables to apply during resolution.
80+
:return: the agent config documents with env vars substituted.
81+
"""
82+
docs = list(yaml_load_all(io.StringIO(AEA_CONFIG_PATH.read_text(encoding="utf-8"))))
83+
return apply_env_variables_on_agent_config(docs, env)
84+
85+
86+
def _override(docs: List[Dict[str, Any]], component: str) -> Dict[str, Any]:
87+
"""Return the resolved override doc whose public id contains ``component``.
88+
89+
:param docs: the resolved agent config documents.
90+
:param component: substring to match against each override's public id.
91+
:return: the matching resolved override document.
92+
:raises AssertionError: if no override matches ``component``.
93+
"""
94+
for doc in docs:
95+
if component in str(doc.get("public_id", "")):
96+
return doc
97+
raise AssertionError(f"override for {component!r} not found in aea-config.yaml")
98+
99+
100+
@pytest.mark.parametrize(
101+
"chain, rpc_var, rpc_url",
102+
[
103+
("polygon", "POLYGON_LEDGER_RPC", "https://polygon.example/rpc"),
104+
("gnosis", "GNOSIS_LEDGER_RPC", "https://gnosis.example/rpc"),
105+
],
106+
)
107+
def test_agent_config_resolves_consistently_per_chain(
108+
chain: str, rpc_var: str, rpc_url: str
109+
) -> None:
110+
"""The resolved agent config is chain-consistent for both flavors.
111+
112+
Reproduces the failure modes fixed for the polymarket Safe,
113+
``funds_manager.rpc_urls`` and the mechs marketplace subgraph: each must
114+
resolve to the active chain rather than a stale gnosis/``0x`` default.
115+
116+
:param chain: the active deployment chain (e.g. ``polygon``/``gnosis``).
117+
:param rpc_var: the bare env var name carrying that chain's ledger RPC.
118+
:param rpc_url: the RPC url injected via ``rpc_var`` for the run.
119+
"""
120+
marketplace_url = (
121+
f"https://api.subgraph.autonolas.tech/api/proxy/marketplace-{chain}"
122+
)
123+
env = {
124+
"SAFE_CONTRACT_ADDRESSES": json.dumps({chain: SAFE}),
125+
rpc_var: rpc_url,
126+
MECHS_SUBGRAPH_PATH_KEY: marketplace_url,
127+
}
128+
docs = _resolve(env)
129+
130+
# funds_manager: rpc_urls / safe must cover the active chain with real values.
131+
fm_args = _override(docs, "funds_manager")["models"]["params"]["args"]
132+
assert fm_args["rpc_urls"].get(chain) == rpc_url
133+
assert fm_args["safe_contract_addresses"].get(chain) == SAFE
134+
135+
# The exact invariant that crashed the agent runner: fund_requirements'
136+
# chains must be a subset of rpc_urls and safe_contract_addresses. Drive
137+
# the real validation (Params.__init__ -> _validate_chain_keys).
138+
Params(
139+
name="params",
140+
skill_context=mock.MagicMock(skill_id="valory/funds_manager:0.1.0"),
141+
fund_requirements={chain: _FUND_REQUIREMENT},
142+
rpc_urls=fm_args["rpc_urls"],
143+
safe_contract_addresses=fm_args["safe_contract_addresses"],
144+
)
145+
146+
# polymarket_client Safe must resolve to the provided address, never "0x".
147+
pm_safe = _override(docs, "polymarket_client")["config"]["safe_contract_addresses"]
148+
assert pm_safe.get(chain) == SAFE
149+
150+
# mechs marketplace subgraph must follow the active chain (anonymous
151+
# placeholder -> path-key), not the gnosis default baked into the yaml.
152+
mechs_url = _override(docs, "trader_abci")["models"]["mechs_subgraph"]["args"][
153+
"url"
154+
]
155+
assert mechs_url == marketplace_url

0 commit comments

Comments
 (0)