prediction-market-agent-tooling 0.26.0__tar.gz → 0.27.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/PKG-INFO +1 -1
  2. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/config.py +12 -29
  3. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/deploy/agent.py +2 -4
  4. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/markets.py +2 -3
  5. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/omen/omen.py +41 -56
  6. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/omen/omen_contracts.py +29 -31
  7. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/omen/omen_resolving.py +15 -15
  8. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/monitor/markets/omen.py +3 -5
  9. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/monitor/markets/polymarket.py +2 -3
  10. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/contract.py +16 -16
  11. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/pyproject.toml +1 -1
  12. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/LICENSE +0 -0
  13. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/README.md +0 -0
  14. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/abis/erc20.abi.json +0 -0
  15. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/abis/omen_dxdao.abi.json +0 -0
  16. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/abis/omen_fpmm.abi.json +0 -0
  17. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/abis/omen_fpmm_conditionaltokens.abi.json +0 -0
  18. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/abis/omen_fpmm_factory.abi.json +0 -0
  19. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/abis/omen_kleros.abi.json +0 -0
  20. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/abis/omen_oracle.abi.json +0 -0
  21. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/abis/omen_realitio.abi.json +0 -0
  22. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/abis/wxdai.abi.json +0 -0
  23. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/benchmark/__init__.py +0 -0
  24. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/benchmark/agents.py +0 -0
  25. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/benchmark/benchmark.py +0 -0
  26. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/benchmark/utils.py +0 -0
  27. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/deploy/agent_example.py +0 -0
  28. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/deploy/constants.py +0 -0
  29. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/deploy/gcp/deploy.py +0 -0
  30. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py +0 -0
  31. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/deploy/gcp/utils.py +0 -0
  32. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/gtypes.py +0 -0
  33. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/loggers.py +0 -0
  34. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/agent_market.py +0 -0
  35. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/categorize.py +0 -0
  36. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/data_models.py +0 -0
  37. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/manifold/__init__.py +0 -0
  38. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/manifold/api.py +0 -0
  39. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/manifold/data_models.py +0 -0
  40. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/manifold/manifold.py +0 -0
  41. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/manifold/utils.py +0 -0
  42. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/omen/__init__.py +0 -0
  43. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/omen/data_models.py +0 -0
  44. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +0 -0
  45. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/polymarket/api.py +0 -0
  46. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/polymarket/data_models.py +0 -0
  47. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/polymarket/data_models_web.py +0 -0
  48. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/polymarket/polymarket.py +0 -0
  49. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/polymarket/utils.py +0 -0
  50. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/monitor/langfuse/langfuse_wrapper.py +0 -0
  51. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/monitor/markets/manifold.py +0 -0
  52. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/monitor/monitor.py +0 -0
  53. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/monitor/monitor_app.py +0 -0
  54. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/monitor/monitor_settings.py +0 -0
  55. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/py.typed +0 -0
  56. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/balances.py +0 -0
  57. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/betting_strategies/kelly_criterion.py +0 -0
  58. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/betting_strategies/market_moving.py +0 -0
  59. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/betting_strategies/minimum_bet_to_win.py +0 -0
  60. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/betting_strategies/stretch_bet_between.py +0 -0
  61. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/cache.py +0 -0
  62. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/costs.py +0 -0
  63. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/gnosis_rpc.py +0 -0
  64. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/google.py +0 -0
  65. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/hexbytes_custom.py +0 -0
  66. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/is_predictable.py +0 -0
  67. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/parallelism.py +0 -0
  68. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/safe.py +0 -0
  69. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/singleton.py +0 -0
  70. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/utils.py +0 -0
  71. {prediction_market_agent_tooling-0.26.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/web3_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.26.0
3
+ Version: 0.27.0
4
4
  Summary: Tools to benchmark, deploy and monitor prediction market agents.
5
5
  Author: Gnosis
6
6
  Requires-Python: >=3.10,<3.12
@@ -2,7 +2,6 @@ import typing as t
2
2
 
3
3
  from gnosis.eth import EthereumClient
4
4
  from gnosis.safe import Safe
5
- from pydantic import BaseModel
6
5
  from pydantic.types import SecretStr
7
6
  from pydantic_settings import BaseSettings, SettingsConfigDict
8
7
 
@@ -58,6 +57,15 @@ class APIKeys(BaseSettings):
58
57
  "BET_FROM_PRIVATE_KEY missing in the environment.",
59
58
  )
60
59
 
60
+ @property
61
+ def bet_from_address(self) -> ChecksumAddress:
62
+ """If the SAFE is available, we always route transactions via SAFE. Otherwise we use the EOA."""
63
+ return (
64
+ self.SAFE_ADDRESS
65
+ if self.SAFE_ADDRESS
66
+ else private_key_to_public_key(self.bet_from_private_key)
67
+ )
68
+
61
69
  @property
62
70
  def openai_api_key(self) -> SecretStr:
63
71
  return check_not_none(
@@ -110,35 +118,10 @@ class APIKeys(BaseSettings):
110
118
  if APIKeys.model_fields[k].annotation in SECRET_TYPES and v is not None
111
119
  }
112
120
 
113
-
114
- class PrivateCredentials(BaseModel):
115
- private_key: PrivateKey
116
- safe_address: ChecksumAddress | None
117
-
118
- @property
119
- def public_key(self) -> ChecksumAddress:
120
- """If the SAFE is available, we always route transactions via SAFE. Otherwise we use the EOA."""
121
- return (
122
- self.safe_address
123
- if self.safe_address is not None
124
- else private_key_to_public_key(self.private_key)
125
- )
126
-
127
- @property
128
- def has_safe_address(self) -> bool:
129
- return self.safe_address is not None
130
-
131
- @staticmethod
132
- def from_api_keys(api_keys: APIKeys) -> "PrivateCredentials":
133
- return PrivateCredentials(
134
- private_key=api_keys.bet_from_private_key,
135
- safe_address=api_keys.SAFE_ADDRESS,
136
- )
137
-
138
121
  def check_if_is_safe_owner(self, ethereum_client: EthereumClient) -> bool:
139
- if not self.safe_address:
122
+ if not self.SAFE_ADDRESS:
140
123
  raise ValueError("Cannot check ownership if safe_address is not defined.")
141
124
 
142
- s = Safe(self.safe_address, ethereum_client) # type: ignore[abstract]
143
- public_key_from_signer = private_key_to_public_key(self.private_key)
125
+ s = Safe(self.SAFE_ADDRESS, ethereum_client) # type: ignore[abstract]
126
+ public_key_from_signer = private_key_to_public_key(self.bet_from_private_key)
144
127
  return s.retrieve_is_owner(public_key_from_signer)
@@ -8,7 +8,7 @@ from datetime import datetime, timedelta
8
8
  from pydantic import BaseModel, BeforeValidator
9
9
  from typing_extensions import Annotated
10
10
 
11
- from prediction_market_agent_tooling.config import APIKeys, PrivateCredentials
11
+ from prediction_market_agent_tooling.config import APIKeys
12
12
  from prediction_market_agent_tooling.deploy.constants import (
13
13
  MARKET_TYPE_KEY,
14
14
  REPOSITORY_KEY,
@@ -260,11 +260,9 @@ class DeployableTraderAgent(DeployableAgent):
260
260
  """
261
261
  Executes actions that occur before bets are placed.
262
262
  """
263
- private_credentials = PrivateCredentials.from_api_keys(APIKeys())
264
-
265
263
  if market_type == MarketType.OMEN:
266
264
  # Omen is specific, because the user (agent) needs to manually withdraw winnings from the market.
267
- redeem_from_all_user_positions(private_credentials)
265
+ redeem_from_all_user_positions(APIKeys())
268
266
 
269
267
  def process_bets(self, market_type: MarketType) -> None:
270
268
  """
@@ -2,7 +2,7 @@ import typing as t
2
2
  from datetime import datetime, timedelta
3
3
  from enum import Enum
4
4
 
5
- from prediction_market_agent_tooling.config import APIKeys, PrivateCredentials
5
+ from prediction_market_agent_tooling.config import APIKeys
6
6
  from prediction_market_agent_tooling.markets.agent_market import (
7
7
  AgentMarket,
8
8
  FilterBy,
@@ -68,7 +68,6 @@ def have_bet_on_market_since(
68
68
  keys: APIKeys, market: AgentMarket, since: timedelta
69
69
  ) -> bool:
70
70
  start_time = utcnow() - since
71
- credentials = PrivateCredentials.from_api_keys(keys)
72
71
  recently_betted_questions = (
73
72
  set(
74
73
  get_manifold_market(b.contractId).question
@@ -85,7 +84,7 @@ def have_bet_on_market_since(
85
84
  set(
86
85
  b.title
87
86
  for b in OmenSubgraphHandler().get_bets(
88
- better_address=credentials.public_key,
87
+ better_address=keys.bet_from_address,
89
88
  start_time=start_time,
90
89
  )
91
90
  )
@@ -5,7 +5,7 @@ from datetime import datetime
5
5
  from web3 import Web3
6
6
  from web3.constants import HASH_ZERO
7
7
 
8
- from prediction_market_agent_tooling.config import APIKeys, PrivateCredentials
8
+ from prediction_market_agent_tooling.config import APIKeys
9
9
  from prediction_market_agent_tooling.gtypes import (
10
10
  ChecksumAddress,
11
11
  HexAddress,
@@ -136,10 +136,8 @@ class OmenAgentMarket(AgentMarket):
136
136
  if amount.currency != self.currency:
137
137
  raise ValueError(f"Omen bets are made in xDai. Got {amount.currency}.")
138
138
  amount_xdai = xDai(amount.amount)
139
- keys = APIKeys()
140
- private_credentials = PrivateCredentials.from_api_keys(keys)
141
139
  binary_omen_buy_outcome_tx(
142
- private_credentials=private_credentials,
140
+ api_keys=APIKeys(),
143
141
  amount=amount_xdai,
144
142
  market=self,
145
143
  binary_outcome=outcome,
@@ -150,10 +148,8 @@ class OmenAgentMarket(AgentMarket):
150
148
  def sell_tokens(
151
149
  self, outcome: bool, amount: TokenAmount, auto_withdraw: bool = True
152
150
  ) -> None:
153
- keys = APIKeys()
154
- private_credentials = PrivateCredentials.from_api_keys(keys)
155
151
  binary_omen_sell_outcome_tx(
156
- private_credentials=private_credentials,
152
+ api_keys=APIKeys(),
157
153
  amount=xDai(amount.amount),
158
154
  market=self,
159
155
  binary_outcome=outcome,
@@ -206,9 +202,9 @@ class OmenAgentMarket(AgentMarket):
206
202
 
207
203
  def redeem_positions(
208
204
  self,
209
- private_credentials: PrivateCredentials,
205
+ api_keys: APIKeys,
210
206
  ) -> None:
211
- for_public_key = private_credentials.public_key
207
+ for_public_key = api_keys.bet_from_address
212
208
  market_is_redeemable = self.market_redeemable_by(user=for_public_key)
213
209
  if not market_is_redeemable:
214
210
  logger.debug(
@@ -216,9 +212,7 @@ class OmenAgentMarket(AgentMarket):
216
212
  )
217
213
  return None
218
214
 
219
- omen_redeem_full_position_tx(
220
- private_credentials=private_credentials, market=self
221
- )
215
+ omen_redeem_full_position_tx(api_keys=api_keys, market=self)
222
216
 
223
217
  @staticmethod
224
218
  def from_data_model(model: OmenMarket) -> "OmenAgentMarket":
@@ -273,9 +267,6 @@ class OmenAgentMarket(AgentMarket):
273
267
  bets = OmenSubgraphHandler().get_bets(
274
268
  better_address=better_address, start_time=start_time
275
269
  )
276
- # get unique titles
277
- seen_titles = {bet.title: bet for bet in bets}
278
- bets = list(seen_titles.values())
279
270
  bets.sort(key=lambda x: x.creation_datetime)
280
271
  return [b.to_bet() for b in bets]
281
272
 
@@ -370,7 +361,7 @@ def pick_binary_market(
370
361
 
371
362
 
372
363
  def omen_buy_outcome_tx(
373
- private_credentials: PrivateCredentials,
364
+ api_keys: APIKeys,
374
365
  amount: xDai,
375
366
  market: OmenAgentMarket,
376
367
  outcome: str,
@@ -381,7 +372,7 @@ def omen_buy_outcome_tx(
381
372
  Bets the given amount of xDai for the given outcome in the given market.
382
373
  """
383
374
  amount_wei = xdai_to_wei(amount)
384
- from_address_checksummed = private_credentials.public_key
375
+ from_address_checksummed = api_keys.bet_from_address
385
376
 
386
377
  market_contract: OmenFixedProductMarketMakerContract = market.get_contract()
387
378
 
@@ -398,7 +389,7 @@ def omen_buy_outcome_tx(
398
389
  expected_shares = remove_fraction(expected_shares, 0.01)
399
390
  # Approve the market maker to withdraw our collateral token.
400
391
  collateral_token_contract.approve(
401
- private_credentials=private_credentials,
392
+ api_keys=api_keys,
402
393
  for_address=market_contract.address,
403
394
  amount_wei=amount_wei,
404
395
  web3=web3,
@@ -410,11 +401,11 @@ def omen_buy_outcome_tx(
410
401
  )
411
402
  if auto_deposit and collateral_token_balance < amount_wei:
412
403
  collateral_token_contract.deposit(
413
- private_credentials=private_credentials, amount_wei=amount_wei, web3=web3
404
+ api_keys=api_keys, amount_wei=amount_wei, web3=web3
414
405
  )
415
406
  # Buy shares using the deposited xDai in the collateral token.
416
407
  market_contract.buy(
417
- private_credentials=private_credentials,
408
+ api_keys=api_keys,
418
409
  amount_wei=amount_wei,
419
410
  outcome_index=outcome_index,
420
411
  min_outcome_tokens_to_buy=expected_shares,
@@ -423,7 +414,7 @@ def omen_buy_outcome_tx(
423
414
 
424
415
 
425
416
  def binary_omen_buy_outcome_tx(
426
- private_credentials: PrivateCredentials,
417
+ api_keys: APIKeys,
427
418
  amount: xDai,
428
419
  market: OmenAgentMarket,
429
420
  binary_outcome: bool,
@@ -431,7 +422,7 @@ def binary_omen_buy_outcome_tx(
431
422
  web3: Web3 | None = None,
432
423
  ) -> None:
433
424
  omen_buy_outcome_tx(
434
- private_credentials=private_credentials,
425
+ api_keys=api_keys,
435
426
  amount=amount,
436
427
  market=market,
437
428
  outcome=OMEN_TRUE_OUTCOME if binary_outcome else OMEN_FALSE_OUTCOME,
@@ -441,7 +432,7 @@ def binary_omen_buy_outcome_tx(
441
432
 
442
433
 
443
434
  def omen_sell_outcome_tx(
444
- private_credentials: PrivateCredentials,
435
+ api_keys: APIKeys,
445
436
  amount: xDai, # The xDai value of shares to sell.
446
437
  market: OmenAgentMarket,
447
438
  outcome: str,
@@ -482,14 +473,14 @@ def omen_sell_outcome_tx(
482
473
 
483
474
  # Approve the market maker to move our (all) conditional tokens.
484
475
  conditional_token_contract.setApprovalForAll(
485
- private_credentials=private_credentials,
476
+ api_keys=api_keys,
486
477
  for_address=market_contract.address,
487
478
  approve=True,
488
479
  web3=web3,
489
480
  )
490
481
  # Sell the shares.
491
482
  market_contract.sell(
492
- private_credentials,
483
+ api_keys,
493
484
  amount_wei,
494
485
  outcome_index,
495
486
  max_outcome_tokens_to_sell,
@@ -497,13 +488,11 @@ def omen_sell_outcome_tx(
497
488
  )
498
489
  if auto_withdraw:
499
490
  # Optionally, withdraw from the collateral token back to the `from_address` wallet.
500
- collateral_token.withdraw(
501
- private_credentials=private_credentials, amount_wei=amount_wei, web3=web3
502
- )
491
+ collateral_token.withdraw(api_keys=api_keys, amount_wei=amount_wei, web3=web3)
503
492
 
504
493
 
505
494
  def binary_omen_sell_outcome_tx(
506
- private_credentials: PrivateCredentials,
495
+ api_keys: APIKeys,
507
496
  amount: xDai,
508
497
  market: OmenAgentMarket,
509
498
  binary_outcome: bool,
@@ -511,7 +500,7 @@ def binary_omen_sell_outcome_tx(
511
500
  web3: Web3 | None = None,
512
501
  ) -> None:
513
502
  omen_sell_outcome_tx(
514
- private_credentials=private_credentials,
503
+ api_keys=api_keys,
515
504
  amount=amount,
516
505
  market=market,
517
506
  outcome=OMEN_TRUE_OUTCOME if binary_outcome else OMEN_FALSE_OUTCOME,
@@ -521,7 +510,7 @@ def binary_omen_sell_outcome_tx(
521
510
 
522
511
 
523
512
  def omen_create_market_tx(
524
- private_credentials: PrivateCredentials,
513
+ api_keys: APIKeys,
525
514
  initial_funds: xDai,
526
515
  question: str,
527
516
  closing_time: datetime,
@@ -535,7 +524,7 @@ def omen_create_market_tx(
535
524
  """
536
525
  Based on omen-exchange TypeScript code: https://github.com/protofire/omen-exchange/blob/b0b9a3e71b415d6becf21fe428e1c4fc0dad2e80/app/src/services/cpk/cpk.ts#L308
537
526
  """
538
- from_address = private_credentials.public_key
527
+ from_address = api_keys.bet_from_address
539
528
  initial_funds_wei = xdai_to_wei(initial_funds)
540
529
 
541
530
  realitio_contract = OmenRealitioContract()
@@ -558,7 +547,7 @@ def omen_create_market_tx(
558
547
 
559
548
  # Approve the market maker to withdraw our collateral token.
560
549
  collateral_token_contract.approve(
561
- private_credentials=private_credentials,
550
+ api_keys=api_keys,
562
551
  for_address=factory_contract.address,
563
552
  amount_wei=initial_funds_wei,
564
553
  web3=web3,
@@ -574,13 +563,11 @@ def omen_create_market_tx(
574
563
  and initial_funds_wei > 0
575
564
  and collateral_token_balance < initial_funds_wei
576
565
  ):
577
- collateral_token_contract.deposit(
578
- private_credentials, initial_funds_wei, web3=web3
579
- )
566
+ collateral_token_contract.deposit(api_keys, initial_funds_wei, web3=web3)
580
567
 
581
568
  # Create the question on Realitio.
582
569
  question_id = realitio_contract.askQuestion(
583
- private_credentials=private_credentials,
570
+ api_keys=api_keys,
584
571
  question=question,
585
572
  category=category,
586
573
  outcomes=outcomes,
@@ -599,7 +586,7 @@ def omen_create_market_tx(
599
586
  )
600
587
  if not conditional_token_contract.does_condition_exists(condition_id, web3=web3):
601
588
  conditional_token_contract.prepareCondition(
602
- private_credentials=private_credentials,
589
+ api_keys=api_keys,
603
590
  question_id=question_id,
604
591
  oracle_address=oracle_contract.address,
605
592
  outcomes_slot_count=len(outcomes),
@@ -608,7 +595,7 @@ def omen_create_market_tx(
608
595
 
609
596
  # Create the market.
610
597
  create_market_receipt_tx = factory_contract.create2FixedProductMarketMaker(
611
- private_credentials=private_credentials,
598
+ api_keys=api_keys,
612
599
  condition_id=condition_id,
613
600
  fee=fee,
614
601
  initial_funds_wei=initial_funds_wei,
@@ -627,13 +614,13 @@ def omen_create_market_tx(
627
614
 
628
615
 
629
616
  def omen_fund_market_tx(
630
- private_credentials: PrivateCredentials,
617
+ api_keys: APIKeys,
631
618
  market: OmenAgentMarket,
632
619
  funds: Wei,
633
620
  auto_deposit: bool,
634
621
  web3: Web3 | None = None,
635
622
  ) -> None:
636
- from_address = private_credentials.public_key
623
+ from_address = api_keys.bet_from_address
637
624
  market_contract = market.get_contract()
638
625
  collateral_token_contract = OmenCollateralTokenContract()
639
626
 
@@ -644,16 +631,16 @@ def omen_fund_market_tx(
644
631
  and collateral_token_contract.balanceOf(for_address=from_address, web3=web3)
645
632
  < funds
646
633
  ):
647
- collateral_token_contract.deposit(private_credentials, funds, web3=web3)
634
+ collateral_token_contract.deposit(api_keys, funds, web3=web3)
648
635
 
649
636
  collateral_token_contract.approve(
650
- private_credentials=private_credentials,
637
+ api_keys=api_keys,
651
638
  for_address=market_contract.address,
652
639
  amount_wei=funds,
653
640
  web3=web3,
654
641
  )
655
642
 
656
- market_contract.addFunding(private_credentials, funds, web3=web3)
643
+ market_contract.addFunding(api_keys, funds, web3=web3)
657
644
 
658
645
 
659
646
  def build_parent_collection_id() -> HexStr:
@@ -661,7 +648,7 @@ def build_parent_collection_id() -> HexStr:
661
648
 
662
649
 
663
650
  def omen_redeem_full_position_tx(
664
- private_credentials: PrivateCredentials,
651
+ api_keys: APIKeys,
665
652
  market: OmenAgentMarket,
666
653
  web3: Web3 | None = None,
667
654
  ) -> None:
@@ -670,7 +657,7 @@ def omen_redeem_full_position_tx(
670
657
  to be redeemed before sending the transaction.
671
658
  """
672
659
 
673
- from_address = private_credentials.public_key
660
+ from_address = api_keys.bet_from_address
674
661
 
675
662
  market_contract: OmenFixedProductMarketMakerContract = market.get_contract()
676
663
  conditional_token_contract = OmenConditionalTokenContract()
@@ -700,7 +687,7 @@ def omen_redeem_full_position_tx(
700
687
  return
701
688
 
702
689
  conditional_token_contract.redeemPositions(
703
- private_credentials=private_credentials,
690
+ api_keys=api_keys,
704
691
  collateral_token_address=market.collateral_token_contract_address_checksummed,
705
692
  condition_id=market.condition.id,
706
693
  parent_collection_id=parent_collection_id,
@@ -741,7 +728,7 @@ def get_conditional_tokens_balance_for_market(
741
728
 
742
729
 
743
730
  def omen_remove_fund_market_tx(
744
- private_credentials: PrivateCredentials,
731
+ api_keys: APIKeys,
745
732
  market: OmenAgentMarket,
746
733
  shares: Wei | None,
747
734
  web3: Web3 | None = None,
@@ -754,7 +741,7 @@ def omen_remove_fund_market_tx(
754
741
  After we remove funding, using the `mergePositions` we get `min(shares per index)` of wxDai back, but the remaining shares can be converted back only after the market is resolved.
755
742
  That can be done using the `redeem_from_all_user_positions` function below.
756
743
  """
757
- from_address = private_credentials.public_key
744
+ from_address = api_keys.bet_from_address
758
745
  market_contract = market.get_contract()
759
746
  original_balances = get_balances(from_address, web3=web3)
760
747
 
@@ -769,9 +756,7 @@ def omen_remove_fund_market_tx(
769
756
  )
770
757
  shares = total_shares
771
758
 
772
- market_contract.removeFunding(
773
- private_credentials=private_credentials, remove_funding=shares, web3=web3
774
- )
759
+ market_contract.removeFunding(api_keys=api_keys, remove_funding=shares, web3=web3)
775
760
 
776
761
  conditional_tokens = OmenConditionalTokenContract()
777
762
  parent_collection_id = build_parent_collection_id()
@@ -784,7 +769,7 @@ def omen_remove_fund_market_tx(
784
769
  amount_to_merge = min(amount_per_index_set.values())
785
770
 
786
771
  result = conditional_tokens.mergePositions(
787
- private_credentials=private_credentials,
772
+ api_keys=api_keys,
788
773
  collateral_token_address=market.collateral_token_contract_address_checksummed,
789
774
  parent_collection_id=parent_collection_id,
790
775
  conditionId=market.condition.id,
@@ -802,13 +787,13 @@ def omen_remove_fund_market_tx(
802
787
 
803
788
 
804
789
  def redeem_from_all_user_positions(
805
- private_credentials: PrivateCredentials,
790
+ api_keys: APIKeys,
806
791
  web3: Web3 | None = None,
807
792
  ) -> None:
808
793
  """
809
794
  Redeems from all user positions where the user didn't redeem yet.
810
795
  """
811
- public_key = private_credentials.public_key
796
+ public_key = api_keys.bet_from_address
812
797
 
813
798
  conditional_token_contract = OmenConditionalTokenContract()
814
799
  user_positions = OmenSubgraphHandler().get_user_positions(
@@ -832,7 +817,7 @@ def redeem_from_all_user_positions(
832
817
 
833
818
  original_balances = get_balances(public_key, web3)
834
819
  conditional_token_contract.redeemPositions(
835
- private_credentials=private_credentials,
820
+ api_keys=api_keys,
836
821
  collateral_token_address=user_position.position.collateral_token_contract_address_checksummed,
837
822
  condition_id=condition_id,
838
823
  parent_collection_id=build_parent_collection_id(),
@@ -6,7 +6,7 @@ from enum import Enum
6
6
 
7
7
  from web3 import Web3
8
8
 
9
- from prediction_market_agent_tooling.config import PrivateCredentials
9
+ from prediction_market_agent_tooling.config import APIKeys
10
10
  from prediction_market_agent_tooling.gtypes import (
11
11
  ABI,
12
12
  ChecksumAddress,
@@ -51,7 +51,7 @@ class OmenOracleContract(ContractOnGnosisChain):
51
51
 
52
52
  def resolve(
53
53
  self,
54
- private_credentials: PrivateCredentials,
54
+ api_keys: APIKeys,
55
55
  question_id: HexBytes,
56
56
  template_id: int,
57
57
  question_raw: str,
@@ -59,7 +59,7 @@ class OmenOracleContract(ContractOnGnosisChain):
59
59
  web3: Web3 | None = None,
60
60
  ) -> TxReceipt:
61
61
  return self.send(
62
- private_credentials=private_credentials,
62
+ api_keys=api_keys,
63
63
  function_name="resolve",
64
64
  function_params=dict(
65
65
  questionId=question_id,
@@ -138,7 +138,7 @@ class OmenConditionalTokenContract(ContractOnGnosisChain):
138
138
 
139
139
  def mergePositions(
140
140
  self,
141
- private_credentials: PrivateCredentials,
141
+ api_keys: APIKeys,
142
142
  collateral_token_address: ChecksumAddress,
143
143
  parent_collection_id: HexStr,
144
144
  conditionId: HexBytes,
@@ -147,7 +147,7 @@ class OmenConditionalTokenContract(ContractOnGnosisChain):
147
147
  web3: Web3 | None = None,
148
148
  ) -> TxReceipt:
149
149
  return self.send(
150
- private_credentials=private_credentials,
150
+ api_keys=api_keys,
151
151
  function_name="mergePositions",
152
152
  function_params=[
153
153
  collateral_token_address,
@@ -161,7 +161,7 @@ class OmenConditionalTokenContract(ContractOnGnosisChain):
161
161
 
162
162
  def redeemPositions(
163
163
  self,
164
- private_credentials: PrivateCredentials,
164
+ api_keys: APIKeys,
165
165
  collateral_token_address: HexAddress,
166
166
  condition_id: HexBytes,
167
167
  parent_collection_id: HexStr,
@@ -169,7 +169,7 @@ class OmenConditionalTokenContract(ContractOnGnosisChain):
169
169
  web3: Web3 | None = None,
170
170
  ) -> TxReceipt:
171
171
  return self.send(
172
- private_credentials=private_credentials,
172
+ api_keys=api_keys,
173
173
  function_name="redeemPositions",
174
174
  function_params=[
175
175
  collateral_token_address,
@@ -209,14 +209,14 @@ class OmenConditionalTokenContract(ContractOnGnosisChain):
209
209
 
210
210
  def setApprovalForAll(
211
211
  self,
212
- private_credentials: PrivateCredentials,
212
+ api_keys: APIKeys,
213
213
  for_address: ChecksumAddress,
214
214
  approve: bool,
215
215
  tx_params: t.Optional[TxParams] = None,
216
216
  web3: Web3 | None = None,
217
217
  ) -> TxReceipt:
218
218
  return self.send(
219
- private_credentials=private_credentials,
219
+ api_keys=api_keys,
220
220
  function_name="setApprovalForAll",
221
221
  function_params=[
222
222
  for_address,
@@ -228,7 +228,7 @@ class OmenConditionalTokenContract(ContractOnGnosisChain):
228
228
 
229
229
  def prepareCondition(
230
230
  self,
231
- private_credentials: PrivateCredentials,
231
+ api_keys: APIKeys,
232
232
  oracle_address: ChecksumAddress,
233
233
  question_id: HexBytes,
234
234
  outcomes_slot_count: int,
@@ -236,7 +236,7 @@ class OmenConditionalTokenContract(ContractOnGnosisChain):
236
236
  web3: Web3 | None = None,
237
237
  ) -> TxReceipt:
238
238
  return self.send(
239
- private_credentials=private_credentials,
239
+ api_keys=api_keys,
240
240
  function_name="prepareCondition",
241
241
  function_params=[
242
242
  oracle_address,
@@ -291,7 +291,7 @@ class OmenFixedProductMarketMakerContract(ContractOnGnosisChain):
291
291
 
292
292
  def buy(
293
293
  self,
294
- private_credentials: PrivateCredentials,
294
+ api_keys: APIKeys,
295
295
  amount_wei: Wei,
296
296
  outcome_index: int,
297
297
  min_outcome_tokens_to_buy: OmenOutcomeToken,
@@ -299,7 +299,7 @@ class OmenFixedProductMarketMakerContract(ContractOnGnosisChain):
299
299
  web3: Web3 | None = None,
300
300
  ) -> TxReceipt:
301
301
  return self.send(
302
- private_credentials=private_credentials,
302
+ api_keys=api_keys,
303
303
  function_name="buy",
304
304
  function_params=[
305
305
  amount_wei,
@@ -312,7 +312,7 @@ class OmenFixedProductMarketMakerContract(ContractOnGnosisChain):
312
312
 
313
313
  def sell(
314
314
  self,
315
- private_credentials: PrivateCredentials,
315
+ api_keys: APIKeys,
316
316
  amount_wei: Wei,
317
317
  outcome_index: int,
318
318
  max_outcome_tokens_to_sell: OmenOutcomeToken,
@@ -320,7 +320,7 @@ class OmenFixedProductMarketMakerContract(ContractOnGnosisChain):
320
320
  web3: Web3 | None = None,
321
321
  ) -> TxReceipt:
322
322
  return self.send(
323
- private_credentials=private_credentials,
323
+ api_keys=api_keys,
324
324
  function_name="sell",
325
325
  function_params=[
326
326
  amount_wei,
@@ -333,7 +333,7 @@ class OmenFixedProductMarketMakerContract(ContractOnGnosisChain):
333
333
 
334
334
  def addFunding(
335
335
  self,
336
- private_credentials: PrivateCredentials,
336
+ api_keys: APIKeys,
337
337
  add_funding: Wei,
338
338
  tx_params: t.Optional[TxParams] = None,
339
339
  web3: Web3 | None = None,
@@ -344,7 +344,7 @@ class OmenFixedProductMarketMakerContract(ContractOnGnosisChain):
344
344
  # `addFunding` with `distribution_hint` can be used only during the market creation, so forcing empty here.
345
345
  distribution_hint: list[int] = []
346
346
  return self.send(
347
- private_credentials=private_credentials,
347
+ api_keys=api_keys,
348
348
  function_name="addFunding",
349
349
  function_params=[add_funding, distribution_hint],
350
350
  tx_params=tx_params,
@@ -353,7 +353,7 @@ class OmenFixedProductMarketMakerContract(ContractOnGnosisChain):
353
353
 
354
354
  def removeFunding(
355
355
  self,
356
- private_credentials: PrivateCredentials,
356
+ api_keys: APIKeys,
357
357
  remove_funding: Wei,
358
358
  tx_params: t.Optional[TxParams] = None,
359
359
  web3: Web3 | None = None,
@@ -362,7 +362,7 @@ class OmenFixedProductMarketMakerContract(ContractOnGnosisChain):
362
362
  Remove funding is done in shares.
363
363
  """
364
364
  return self.send(
365
- private_credentials=private_credentials,
365
+ api_keys=api_keys,
366
366
  function_name="removeFunding",
367
367
  function_params=[remove_funding],
368
368
  tx_params=tx_params,
@@ -407,7 +407,7 @@ class OmenFixedProductMarketMakerFactoryContract(ContractOnGnosisChain):
407
407
 
408
408
  def create2FixedProductMarketMaker(
409
409
  self,
410
- private_credentials: PrivateCredentials,
410
+ api_keys: APIKeys,
411
411
  condition_id: HexBytes,
412
412
  initial_funds_wei: Wei,
413
413
  fee: float = OMEN_DEFAULT_MARKET_FEE,
@@ -418,7 +418,7 @@ class OmenFixedProductMarketMakerFactoryContract(ContractOnGnosisChain):
418
418
  xdai_type(fee)
419
419
  ) # We need to convert this to the wei units, but in reality it's % fee as stated in the `OMEN_DEFAULT_MARKET_FEE` variable.
420
420
  return self.send(
421
- private_credentials=private_credentials,
421
+ api_keys=api_keys,
422
422
  function_name="create2FixedProductMarketMaker",
423
423
  function_params=dict(
424
424
  saltNonce=random.randint(
@@ -491,7 +491,7 @@ class OmenRealitioContract(ContractOnGnosisChain):
491
491
 
492
492
  def askQuestion(
493
493
  self,
494
- private_credentials: PrivateCredentials,
494
+ api_keys: APIKeys,
495
495
  question: str,
496
496
  category: str,
497
497
  outcomes: list[str],
@@ -518,7 +518,7 @@ class OmenRealitioContract(ContractOnGnosisChain):
518
518
  ]
519
519
  )
520
520
  receipt_tx = self.send(
521
- private_credentials=private_credentials,
521
+ api_keys=api_keys,
522
522
  function_name="askQuestion",
523
523
  function_params=dict(
524
524
  template_id=template_id,
@@ -540,7 +540,7 @@ class OmenRealitioContract(ContractOnGnosisChain):
540
540
 
541
541
  def submitAnswer(
542
542
  self,
543
- private_credentials: PrivateCredentials,
543
+ api_keys: APIKeys,
544
544
  question_id: HexBytes,
545
545
  answer: str,
546
546
  outcomes: list[str],
@@ -558,7 +558,7 @@ class OmenRealitioContract(ContractOnGnosisChain):
558
558
  outcomes = [o.lower() for o in outcomes]
559
559
 
560
560
  return self.send_with_value(
561
- private_credentials=private_credentials,
561
+ api_keys=api_keys,
562
562
  function_name="submitAnswer",
563
563
  function_params=dict(
564
564
  question_id=question_id,
@@ -573,7 +573,7 @@ class OmenRealitioContract(ContractOnGnosisChain):
573
573
 
574
574
  def claimWinnings(
575
575
  self,
576
- private_credentials: PrivateCredentials,
576
+ api_keys: APIKeys,
577
577
  question_id: HexBytes,
578
578
  history_hashes: list[HexBytes],
579
579
  addresses: list[ChecksumAddress],
@@ -583,7 +583,7 @@ class OmenRealitioContract(ContractOnGnosisChain):
583
583
  web3: Web3 | None = None,
584
584
  ) -> TxReceipt:
585
585
  return self.send(
586
- private_credentials=private_credentials,
586
+ api_keys=api_keys,
587
587
  function_name="claimWinnings",
588
588
  function_params=dict(
589
589
  question_id=question_id,
@@ -606,9 +606,7 @@ class OmenRealitioContract(ContractOnGnosisChain):
606
606
 
607
607
  def withdraw(
608
608
  self,
609
- private_credentials: PrivateCredentials,
609
+ api_keys: APIKeys,
610
610
  web3: Web3 | None = None,
611
611
  ) -> TxReceipt:
612
- return self.send(
613
- private_credentials=private_credentials, function_name="withdraw", web3=web3
614
- )
612
+ return self.send(api_keys=api_keys, function_name="withdraw", web3=web3)
@@ -1,6 +1,6 @@
1
1
  from web3 import Web3
2
2
 
3
- from prediction_market_agent_tooling.config import PrivateCredentials
3
+ from prediction_market_agent_tooling.config import APIKeys
4
4
  from prediction_market_agent_tooling.gtypes import (
5
5
  ChecksumAddress,
6
6
  HexAddress,
@@ -35,7 +35,7 @@ from prediction_market_agent_tooling.tools.web3_utils import ZERO_BYTES, xdai_to
35
35
 
36
36
 
37
37
  def claim_bonds_on_realitio_questions(
38
- private_credentials: PrivateCredentials,
38
+ api_keys: APIKeys,
39
39
  questions: list[RealityQuestion],
40
40
  auto_withdraw: bool,
41
41
  web3: Web3 | None = None,
@@ -47,7 +47,7 @@ def claim_bonds_on_realitio_questions(
47
47
  f"[{idx+1} / {len(questions)}] Claiming bond for {question.questionId=} {question.url=}"
48
48
  )
49
49
  claim_bonds_on_realitio_question(
50
- private_credentials, question, auto_withdraw=auto_withdraw, web3=web3
50
+ api_keys, question, auto_withdraw=auto_withdraw, web3=web3
51
51
  )
52
52
  claimed_questions.append(question.questionId)
53
53
 
@@ -55,12 +55,12 @@ def claim_bonds_on_realitio_questions(
55
55
 
56
56
 
57
57
  def claim_bonds_on_realitio_question(
58
- private_credentials: PrivateCredentials,
58
+ api_keys: APIKeys,
59
59
  question: RealityQuestion,
60
60
  auto_withdraw: bool,
61
61
  web3: Web3 | None = None,
62
62
  ) -> None:
63
- public_key = private_credentials.public_key
63
+ public_key = api_keys.bet_from_address
64
64
  realitio_contract = OmenRealitioContract()
65
65
 
66
66
  # Get all answers for the question.
@@ -105,7 +105,7 @@ def claim_bonds_on_realitio_question(
105
105
  answers.append(answer.answer)
106
106
 
107
107
  realitio_contract.claimWinnings(
108
- private_credentials=private_credentials,
108
+ api_keys=api_keys,
109
109
  question_id=question.questionId,
110
110
  history_hashes=history_hashes,
111
111
  addresses=addresses,
@@ -118,11 +118,11 @@ def claim_bonds_on_realitio_question(
118
118
  # Keeping balance on Realitio is not useful, so it's recommended to just withdraw it.
119
119
  if current_balance > 0 and auto_withdraw:
120
120
  logger.info(f"Withdrawing remaining balance {current_balance=}")
121
- realitio_contract.withdraw(private_credentials, web3=web3)
121
+ realitio_contract.withdraw(api_keys, web3=web3)
122
122
 
123
123
 
124
124
  def finalize_markets(
125
- private_credentials: PrivateCredentials,
125
+ api_keys: APIKeys,
126
126
  markets_with_resolutions: list[tuple[OmenMarket, Resolution | None]],
127
127
  web3: Web3 | None = None,
128
128
  ) -> list[HexAddress]:
@@ -139,7 +139,7 @@ def finalize_markets(
139
139
  elif resolution in (Resolution.YES, Resolution.NO):
140
140
  logger.info(f"Found resolution {resolution.value=} for {market.url=}")
141
141
  omen_submit_answer_market_tx(
142
- private_credentials,
142
+ api_keys,
143
143
  market,
144
144
  resolution,
145
145
  OMEN_DEFAULT_REALITIO_BOND_VALUE,
@@ -155,7 +155,7 @@ def finalize_markets(
155
155
 
156
156
 
157
157
  def resolve_markets(
158
- private_credentials: PrivateCredentials,
158
+ api_keys: APIKeys,
159
159
  markets: list[OmenMarket],
160
160
  web3: Web3 | None = None,
161
161
  ) -> list[HexAddress]:
@@ -165,14 +165,14 @@ def resolve_markets(
165
165
  logger.info(
166
166
  f"[{idx+1} / {len(markets)}] Resolving {market.url=} {market.question_title=}"
167
167
  )
168
- omen_resolve_market_tx(private_credentials, market, web3=web3)
168
+ omen_resolve_market_tx(api_keys, market, web3=web3)
169
169
  resolved_markets.append(market.id)
170
170
 
171
171
  return resolved_markets
172
172
 
173
173
 
174
174
  def omen_submit_answer_market_tx(
175
- private_credentials: PrivateCredentials,
175
+ api_keys: APIKeys,
176
176
  market: OmenMarket,
177
177
  resolution: Resolution,
178
178
  bond: xDai,
@@ -184,7 +184,7 @@ def omen_submit_answer_market_tx(
184
184
  """
185
185
  realitio_contract = OmenRealitioContract()
186
186
  realitio_contract.submitAnswer(
187
- private_credentials=private_credentials,
187
+ api_keys=api_keys,
188
188
  question_id=market.question.id,
189
189
  answer=resolution.value,
190
190
  outcomes=market.question.outcomes,
@@ -194,7 +194,7 @@ def omen_submit_answer_market_tx(
194
194
 
195
195
 
196
196
  def omen_resolve_market_tx(
197
- private_credentials: PrivateCredentials,
197
+ api_keys: APIKeys,
198
198
  market: OmenMarket,
199
199
  web3: Web3 | None = None,
200
200
  ) -> None:
@@ -203,7 +203,7 @@ def omen_resolve_market_tx(
203
203
  """
204
204
  oracle_contract = OmenOracleContract()
205
205
  oracle_contract.resolve(
206
- private_credentials=private_credentials,
206
+ api_keys=api_keys,
207
207
  question_id=market.question.id,
208
208
  template_id=market.question.templateId,
209
209
  question_raw=market.question.question_raw,
@@ -2,7 +2,7 @@ import typing as t
2
2
 
3
3
  from google.cloud.functions_v2.types.functions import Function
4
4
 
5
- from prediction_market_agent_tooling.config import APIKeys, PrivateCredentials
5
+ from prediction_market_agent_tooling.config import APIKeys
6
6
  from prediction_market_agent_tooling.deploy.constants import MARKET_TYPE_KEY
7
7
  from prediction_market_agent_tooling.gtypes import ChecksumAddress, DatetimeWithTimezone
8
8
  from prediction_market_agent_tooling.markets.data_models import ResolvedBet
@@ -49,8 +49,7 @@ class DeployedOmenAgent(DeployedAgent):
49
49
  and api_keys.BET_FROM_PRIVATE_KEY
50
50
  != APIKeys().BET_FROM_PRIVATE_KEY # Check that it didn't get if from the default env.
51
51
  ):
52
- private_credentials = PrivateCredentials.from_api_keys(api_keys)
53
- env_vars["omen_public_key"] = private_credentials.public_key
52
+ env_vars["omen_public_key"] = api_keys.bet_from_address
54
53
  return super().from_env_vars_without_prefix(
55
54
  env_vars=env_vars, extra_vars=extra_vars
56
55
  )
@@ -61,11 +60,10 @@ class DeployedOmenAgent(DeployedAgent):
61
60
  start_time: DatetimeWithTimezone,
62
61
  api_keys: APIKeys,
63
62
  ) -> "DeployedOmenAgent":
64
- private_credentials = PrivateCredentials.from_api_keys(api_keys)
65
63
  return DeployedOmenAgent(
66
64
  name=name,
67
65
  start_time=start_time,
68
- omen_public_key=private_credentials.public_key,
66
+ omen_public_key=api_keys.bet_from_address,
69
67
  )
70
68
 
71
69
  @classmethod
@@ -2,7 +2,7 @@ import typing as t
2
2
 
3
3
  from google.cloud.functions_v2.types.functions import Function
4
4
 
5
- from prediction_market_agent_tooling.config import APIKeys, PrivateCredentials
5
+ from prediction_market_agent_tooling.config import APIKeys
6
6
  from prediction_market_agent_tooling.deploy.constants import MARKET_TYPE_KEY
7
7
  from prediction_market_agent_tooling.gtypes import ChecksumAddress, DatetimeWithTimezone
8
8
  from prediction_market_agent_tooling.markets.data_models import ResolvedBet
@@ -28,11 +28,10 @@ class DeployedPolymarketAgent(DeployedAgent):
28
28
  start_time: DatetimeWithTimezone,
29
29
  api_keys: APIKeys,
30
30
  ) -> "DeployedPolymarketAgent":
31
- private_credentials = PrivateCredentials.from_api_keys(api_keys)
32
31
  return DeployedPolymarketAgent(
33
32
  name=name,
34
33
  start_time=start_time,
35
- polymarket_public_key=private_credentials.public_key,
34
+ polymarket_public_key=api_keys.bet_from_address,
36
35
  )
37
36
 
38
37
  @classmethod
@@ -6,7 +6,7 @@ from contextlib import contextmanager
6
6
  from pydantic import BaseModel, field_validator
7
7
  from web3 import Web3
8
8
 
9
- from prediction_market_agent_tooling.config import PrivateCredentials
9
+ from prediction_market_agent_tooling.config import APIKeys
10
10
  from prediction_market_agent_tooling.gtypes import (
11
11
  ABI,
12
12
  ChainID,
@@ -86,7 +86,7 @@ class ContractBaseClass(BaseModel):
86
86
 
87
87
  def send(
88
88
  self,
89
- private_credentials: PrivateCredentials,
89
+ api_keys: APIKeys,
90
90
  function_name: str,
91
91
  function_params: t.Optional[list[t.Any] | dict[str, t.Any]] = None,
92
92
  tx_params: t.Optional[TxParams] = None,
@@ -97,13 +97,13 @@ class ContractBaseClass(BaseModel):
97
97
  Used for changing a state (writing) to the contract.
98
98
  """
99
99
 
100
- if private_credentials.safe_address is not None:
100
+ if api_keys.SAFE_ADDRESS:
101
101
  return send_function_on_contract_tx_using_safe(
102
102
  web3=web3 or self.get_web3(),
103
103
  contract_address=self.address,
104
104
  contract_abi=self.abi,
105
- from_private_key=private_credentials.private_key,
106
- safe_address=private_credentials.safe_address,
105
+ from_private_key=api_keys.bet_from_private_key,
106
+ safe_address=api_keys.SAFE_ADDRESS,
107
107
  function_name=function_name,
108
108
  function_params=function_params,
109
109
  tx_params=tx_params,
@@ -113,7 +113,7 @@ class ContractBaseClass(BaseModel):
113
113
  web3=web3 or self.get_web3(),
114
114
  contract_address=self.address,
115
115
  contract_abi=self.abi,
116
- from_private_key=private_credentials.private_key,
116
+ from_private_key=api_keys.bet_from_private_key,
117
117
  function_name=function_name,
118
118
  function_params=function_params,
119
119
  tx_params=tx_params,
@@ -122,7 +122,7 @@ class ContractBaseClass(BaseModel):
122
122
 
123
123
  def send_with_value(
124
124
  self,
125
- private_credentials: PrivateCredentials,
125
+ api_keys: APIKeys,
126
126
  function_name: str,
127
127
  amount_wei: Wei,
128
128
  function_params: t.Optional[list[t.Any] | dict[str, t.Any]] = None,
@@ -134,7 +134,7 @@ class ContractBaseClass(BaseModel):
134
134
  Used for changing a state (writing) to the contract, including sending chain's native currency.
135
135
  """
136
136
  return self.send(
137
- private_credentials=private_credentials,
137
+ api_keys=api_keys,
138
138
  function_name=function_name,
139
139
  function_params=function_params,
140
140
  tx_params={"value": amount_wei, **(tx_params or {})},
@@ -158,14 +158,14 @@ class ContractERC20BaseClass(ContractBaseClass):
158
158
 
159
159
  def approve(
160
160
  self,
161
- private_credentials: PrivateCredentials,
161
+ api_keys: APIKeys,
162
162
  for_address: ChecksumAddress,
163
163
  amount_wei: Wei,
164
164
  tx_params: t.Optional[TxParams] = None,
165
165
  web3: Web3 | None = None,
166
166
  ) -> TxReceipt:
167
167
  return self.send(
168
- private_credentials=private_credentials,
168
+ api_keys=api_keys,
169
169
  function_name="approve",
170
170
  function_params=[
171
171
  for_address,
@@ -177,13 +177,13 @@ class ContractERC20BaseClass(ContractBaseClass):
177
177
 
178
178
  def deposit(
179
179
  self,
180
- private_credentials: PrivateCredentials,
180
+ api_keys: APIKeys,
181
181
  amount_wei: Wei,
182
182
  tx_params: t.Optional[TxParams] = None,
183
183
  web3: Web3 | None = None,
184
184
  ) -> TxReceipt:
185
185
  return self.send_with_value(
186
- private_credentials=private_credentials,
186
+ api_keys=api_keys,
187
187
  function_name="deposit",
188
188
  amount_wei=amount_wei,
189
189
  tx_params=tx_params,
@@ -192,7 +192,7 @@ class ContractERC20BaseClass(ContractBaseClass):
192
192
 
193
193
  def transferFrom(
194
194
  self,
195
- private_credentials: PrivateCredentials,
195
+ api_keys: APIKeys,
196
196
  sender: ChecksumAddress,
197
197
  recipient: ChecksumAddress,
198
198
  amount_wei: Wei,
@@ -200,7 +200,7 @@ class ContractERC20BaseClass(ContractBaseClass):
200
200
  web3: Web3 | None = None,
201
201
  ) -> TxReceipt:
202
202
  return self.send(
203
- private_credentials=private_credentials,
203
+ api_keys=api_keys,
204
204
  function_name="transferFrom",
205
205
  function_params=[sender, recipient, amount_wei],
206
206
  tx_params=tx_params,
@@ -209,13 +209,13 @@ class ContractERC20BaseClass(ContractBaseClass):
209
209
 
210
210
  def withdraw(
211
211
  self,
212
- private_credentials: PrivateCredentials,
212
+ api_keys: APIKeys,
213
213
  amount_wei: Wei,
214
214
  tx_params: t.Optional[TxParams] = None,
215
215
  web3: Web3 | None = None,
216
216
  ) -> TxReceipt:
217
217
  return self.send(
218
- private_credentials=private_credentials,
218
+ api_keys=api_keys,
219
219
  function_name="withdraw",
220
220
  function_params=[amount_wei],
221
221
  tx_params=tx_params,
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "prediction-market-agent-tooling"
3
- version = "0.26.0"
3
+ version = "0.27.0"
4
4
  description = "Tools to benchmark, deploy and monitor prediction market agents."
5
5
  authors = ["Gnosis"]
6
6
  readme = "README.md"