prediction-market-agent-tooling 0.25.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.25.0 → prediction_market_agent_tooling-0.27.0}/PKG-INFO +1 -1
  2. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/config.py +12 -29
  3. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/deploy/agent.py +2 -4
  4. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/agent_market.py +8 -0
  5. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/markets.py +2 -3
  6. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/omen/data_models.py +9 -0
  7. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/omen/omen.py +52 -53
  8. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/omen/omen_contracts.py +29 -31
  9. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/omen/omen_resolving.py +15 -15
  10. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/monitor/markets/omen.py +3 -5
  11. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/monitor/markets/polymarket.py +2 -3
  12. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/contract.py +16 -16
  13. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/pyproject.toml +1 -1
  14. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/LICENSE +0 -0
  15. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/README.md +0 -0
  16. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/abis/erc20.abi.json +0 -0
  17. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/abis/omen_dxdao.abi.json +0 -0
  18. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/abis/omen_fpmm.abi.json +0 -0
  19. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/abis/omen_fpmm_conditionaltokens.abi.json +0 -0
  20. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/abis/omen_fpmm_factory.abi.json +0 -0
  21. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/abis/omen_kleros.abi.json +0 -0
  22. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/abis/omen_oracle.abi.json +0 -0
  23. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/abis/omen_realitio.abi.json +0 -0
  24. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/abis/wxdai.abi.json +0 -0
  25. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/benchmark/__init__.py +0 -0
  26. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/benchmark/agents.py +0 -0
  27. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/benchmark/benchmark.py +0 -0
  28. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/benchmark/utils.py +0 -0
  29. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/deploy/agent_example.py +0 -0
  30. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/deploy/constants.py +0 -0
  31. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/deploy/gcp/deploy.py +0 -0
  32. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py +0 -0
  33. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/deploy/gcp/utils.py +0 -0
  34. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/gtypes.py +0 -0
  35. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/loggers.py +0 -0
  36. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/categorize.py +0 -0
  37. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/data_models.py +0 -0
  38. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/manifold/__init__.py +0 -0
  39. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/manifold/api.py +0 -0
  40. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/manifold/data_models.py +0 -0
  41. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/manifold/manifold.py +0 -0
  42. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/manifold/utils.py +0 -0
  43. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/omen/__init__.py +0 -0
  44. {prediction_market_agent_tooling-0.25.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.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/polymarket/api.py +0 -0
  46. {prediction_market_agent_tooling-0.25.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.25.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.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/polymarket/polymarket.py +0 -0
  49. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/markets/polymarket/utils.py +0 -0
  50. {prediction_market_agent_tooling-0.25.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.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/monitor/markets/manifold.py +0 -0
  52. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/monitor/monitor.py +0 -0
  53. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/monitor/monitor_app.py +0 -0
  54. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/monitor/monitor_settings.py +0 -0
  55. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/py.typed +0 -0
  56. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/balances.py +0 -0
  57. {prediction_market_agent_tooling-0.25.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.25.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.25.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.25.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.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/cache.py +0 -0
  62. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/costs.py +0 -0
  63. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/gnosis_rpc.py +0 -0
  64. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/google.py +0 -0
  65. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/hexbytes_custom.py +0 -0
  66. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/is_predictable.py +0 -0
  67. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/parallelism.py +0 -0
  68. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/safe.py +0 -0
  69. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/singleton.py +0 -0
  70. {prediction_market_agent_tooling-0.25.0 → prediction_market_agent_tooling-0.27.0}/prediction_market_agent_tooling/tools/utils.py +0 -0
  71. {prediction_market_agent_tooling-0.25.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.25.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,10 +2,12 @@ import typing as t
2
2
  from datetime import datetime
3
3
  from enum import Enum
4
4
 
5
+ from eth_typing import ChecksumAddress
5
6
  from pydantic import BaseModel, field_validator
6
7
 
7
8
  from prediction_market_agent_tooling.gtypes import Probability
8
9
  from prediction_market_agent_tooling.markets.data_models import (
10
+ Bet,
9
11
  BetAmount,
10
12
  Currency,
11
13
  Position,
@@ -139,6 +141,12 @@ class AgentMarket(BaseModel):
139
141
  def get_binary_market(id: str) -> "AgentMarket":
140
142
  raise NotImplementedError("Subclasses must implement this method")
141
143
 
144
+ @staticmethod
145
+ def get_bets_made_since(
146
+ better_address: ChecksumAddress, start_time: datetime
147
+ ) -> list[Bet]:
148
+ raise NotImplementedError("Subclasses must implement this method")
149
+
142
150
  def is_resolved(self) -> bool:
143
151
  return self.resolution is not None
144
152
 
@@ -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
  )
@@ -15,6 +15,7 @@ from prediction_market_agent_tooling.gtypes import (
15
15
  xDai,
16
16
  )
17
17
  from prediction_market_agent_tooling.markets.data_models import (
18
+ Bet,
18
19
  BetAmount,
19
20
  Currency,
20
21
  ProfitAmount,
@@ -379,6 +380,14 @@ class OmenBet(BaseModel):
379
380
  currency=Currency.xDai,
380
381
  )
381
382
 
383
+ def to_bet(self) -> Bet:
384
+ return Bet(
385
+ amount=BetAmount(amount=self.collateralAmountUSD, currency=Currency.xDai),
386
+ outcome=self.boolean_outcome,
387
+ created_time=self.creation_datetime,
388
+ market_question=self.title,
389
+ )
390
+
382
391
  def to_generic_resolved_bet(self) -> ResolvedBet:
383
392
  if not self.fpmm.is_resolved_with_valid_answer:
384
393
  raise ValueError(
@@ -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,
@@ -24,6 +24,7 @@ from prediction_market_agent_tooling.markets.agent_market import (
24
24
  SortBy,
25
25
  )
26
26
  from prediction_market_agent_tooling.markets.data_models import (
27
+ Bet,
27
28
  BetAmount,
28
29
  Currency,
29
30
  Position,
@@ -135,10 +136,8 @@ class OmenAgentMarket(AgentMarket):
135
136
  if amount.currency != self.currency:
136
137
  raise ValueError(f"Omen bets are made in xDai. Got {amount.currency}.")
137
138
  amount_xdai = xDai(amount.amount)
138
- keys = APIKeys()
139
- private_credentials = PrivateCredentials.from_api_keys(keys)
140
139
  binary_omen_buy_outcome_tx(
141
- private_credentials=private_credentials,
140
+ api_keys=APIKeys(),
142
141
  amount=amount_xdai,
143
142
  market=self,
144
143
  binary_outcome=outcome,
@@ -149,10 +148,8 @@ class OmenAgentMarket(AgentMarket):
149
148
  def sell_tokens(
150
149
  self, outcome: bool, amount: TokenAmount, auto_withdraw: bool = True
151
150
  ) -> None:
152
- keys = APIKeys()
153
- private_credentials = PrivateCredentials.from_api_keys(keys)
154
151
  binary_omen_sell_outcome_tx(
155
- private_credentials=private_credentials,
152
+ api_keys=APIKeys(),
156
153
  amount=xDai(amount.amount),
157
154
  market=self,
158
155
  binary_outcome=outcome,
@@ -205,9 +202,9 @@ class OmenAgentMarket(AgentMarket):
205
202
 
206
203
  def redeem_positions(
207
204
  self,
208
- private_credentials: PrivateCredentials,
205
+ api_keys: APIKeys,
209
206
  ) -> None:
210
- for_public_key = private_credentials.public_key
207
+ for_public_key = api_keys.bet_from_address
211
208
  market_is_redeemable = self.market_redeemable_by(user=for_public_key)
212
209
  if not market_is_redeemable:
213
210
  logger.debug(
@@ -215,9 +212,7 @@ class OmenAgentMarket(AgentMarket):
215
212
  )
216
213
  return None
217
214
 
218
- omen_redeem_full_position_tx(
219
- private_credentials=private_credentials, market=self
220
- )
215
+ omen_redeem_full_position_tx(api_keys=api_keys, market=self)
221
216
 
222
217
  @staticmethod
223
218
  def from_data_model(model: OmenMarket) -> "OmenAgentMarket":
@@ -265,6 +260,16 @@ class OmenAgentMarket(AgentMarket):
265
260
  )
266
261
  )
267
262
 
263
+ @staticmethod
264
+ def get_bets_made_since(
265
+ better_address: ChecksumAddress, start_time: datetime
266
+ ) -> list[Bet]:
267
+ bets = OmenSubgraphHandler().get_bets(
268
+ better_address=better_address, start_time=start_time
269
+ )
270
+ bets.sort(key=lambda x: x.creation_datetime)
271
+ return [b.to_bet() for b in bets]
272
+
268
273
  def get_contract(
269
274
  self,
270
275
  ) -> OmenFixedProductMarketMakerContract:
@@ -356,7 +361,7 @@ def pick_binary_market(
356
361
 
357
362
 
358
363
  def omen_buy_outcome_tx(
359
- private_credentials: PrivateCredentials,
364
+ api_keys: APIKeys,
360
365
  amount: xDai,
361
366
  market: OmenAgentMarket,
362
367
  outcome: str,
@@ -367,7 +372,7 @@ def omen_buy_outcome_tx(
367
372
  Bets the given amount of xDai for the given outcome in the given market.
368
373
  """
369
374
  amount_wei = xdai_to_wei(amount)
370
- from_address_checksummed = private_credentials.public_key
375
+ from_address_checksummed = api_keys.bet_from_address
371
376
 
372
377
  market_contract: OmenFixedProductMarketMakerContract = market.get_contract()
373
378
 
@@ -384,7 +389,7 @@ def omen_buy_outcome_tx(
384
389
  expected_shares = remove_fraction(expected_shares, 0.01)
385
390
  # Approve the market maker to withdraw our collateral token.
386
391
  collateral_token_contract.approve(
387
- private_credentials=private_credentials,
392
+ api_keys=api_keys,
388
393
  for_address=market_contract.address,
389
394
  amount_wei=amount_wei,
390
395
  web3=web3,
@@ -396,11 +401,11 @@ def omen_buy_outcome_tx(
396
401
  )
397
402
  if auto_deposit and collateral_token_balance < amount_wei:
398
403
  collateral_token_contract.deposit(
399
- private_credentials=private_credentials, amount_wei=amount_wei, web3=web3
404
+ api_keys=api_keys, amount_wei=amount_wei, web3=web3
400
405
  )
401
406
  # Buy shares using the deposited xDai in the collateral token.
402
407
  market_contract.buy(
403
- private_credentials=private_credentials,
408
+ api_keys=api_keys,
404
409
  amount_wei=amount_wei,
405
410
  outcome_index=outcome_index,
406
411
  min_outcome_tokens_to_buy=expected_shares,
@@ -409,7 +414,7 @@ def omen_buy_outcome_tx(
409
414
 
410
415
 
411
416
  def binary_omen_buy_outcome_tx(
412
- private_credentials: PrivateCredentials,
417
+ api_keys: APIKeys,
413
418
  amount: xDai,
414
419
  market: OmenAgentMarket,
415
420
  binary_outcome: bool,
@@ -417,7 +422,7 @@ def binary_omen_buy_outcome_tx(
417
422
  web3: Web3 | None = None,
418
423
  ) -> None:
419
424
  omen_buy_outcome_tx(
420
- private_credentials=private_credentials,
425
+ api_keys=api_keys,
421
426
  amount=amount,
422
427
  market=market,
423
428
  outcome=OMEN_TRUE_OUTCOME if binary_outcome else OMEN_FALSE_OUTCOME,
@@ -427,7 +432,7 @@ def binary_omen_buy_outcome_tx(
427
432
 
428
433
 
429
434
  def omen_sell_outcome_tx(
430
- private_credentials: PrivateCredentials,
435
+ api_keys: APIKeys,
431
436
  amount: xDai, # The xDai value of shares to sell.
432
437
  market: OmenAgentMarket,
433
438
  outcome: str,
@@ -468,14 +473,14 @@ def omen_sell_outcome_tx(
468
473
 
469
474
  # Approve the market maker to move our (all) conditional tokens.
470
475
  conditional_token_contract.setApprovalForAll(
471
- private_credentials=private_credentials,
476
+ api_keys=api_keys,
472
477
  for_address=market_contract.address,
473
478
  approve=True,
474
479
  web3=web3,
475
480
  )
476
481
  # Sell the shares.
477
482
  market_contract.sell(
478
- private_credentials,
483
+ api_keys,
479
484
  amount_wei,
480
485
  outcome_index,
481
486
  max_outcome_tokens_to_sell,
@@ -483,13 +488,11 @@ def omen_sell_outcome_tx(
483
488
  )
484
489
  if auto_withdraw:
485
490
  # Optionally, withdraw from the collateral token back to the `from_address` wallet.
486
- collateral_token.withdraw(
487
- private_credentials=private_credentials, amount_wei=amount_wei, web3=web3
488
- )
491
+ collateral_token.withdraw(api_keys=api_keys, amount_wei=amount_wei, web3=web3)
489
492
 
490
493
 
491
494
  def binary_omen_sell_outcome_tx(
492
- private_credentials: PrivateCredentials,
495
+ api_keys: APIKeys,
493
496
  amount: xDai,
494
497
  market: OmenAgentMarket,
495
498
  binary_outcome: bool,
@@ -497,7 +500,7 @@ def binary_omen_sell_outcome_tx(
497
500
  web3: Web3 | None = None,
498
501
  ) -> None:
499
502
  omen_sell_outcome_tx(
500
- private_credentials=private_credentials,
503
+ api_keys=api_keys,
501
504
  amount=amount,
502
505
  market=market,
503
506
  outcome=OMEN_TRUE_OUTCOME if binary_outcome else OMEN_FALSE_OUTCOME,
@@ -507,7 +510,7 @@ def binary_omen_sell_outcome_tx(
507
510
 
508
511
 
509
512
  def omen_create_market_tx(
510
- private_credentials: PrivateCredentials,
513
+ api_keys: APIKeys,
511
514
  initial_funds: xDai,
512
515
  question: str,
513
516
  closing_time: datetime,
@@ -521,7 +524,7 @@ def omen_create_market_tx(
521
524
  """
522
525
  Based on omen-exchange TypeScript code: https://github.com/protofire/omen-exchange/blob/b0b9a3e71b415d6becf21fe428e1c4fc0dad2e80/app/src/services/cpk/cpk.ts#L308
523
526
  """
524
- from_address = private_credentials.public_key
527
+ from_address = api_keys.bet_from_address
525
528
  initial_funds_wei = xdai_to_wei(initial_funds)
526
529
 
527
530
  realitio_contract = OmenRealitioContract()
@@ -544,7 +547,7 @@ def omen_create_market_tx(
544
547
 
545
548
  # Approve the market maker to withdraw our collateral token.
546
549
  collateral_token_contract.approve(
547
- private_credentials=private_credentials,
550
+ api_keys=api_keys,
548
551
  for_address=factory_contract.address,
549
552
  amount_wei=initial_funds_wei,
550
553
  web3=web3,
@@ -560,13 +563,11 @@ def omen_create_market_tx(
560
563
  and initial_funds_wei > 0
561
564
  and collateral_token_balance < initial_funds_wei
562
565
  ):
563
- collateral_token_contract.deposit(
564
- private_credentials, initial_funds_wei, web3=web3
565
- )
566
+ collateral_token_contract.deposit(api_keys, initial_funds_wei, web3=web3)
566
567
 
567
568
  # Create the question on Realitio.
568
569
  question_id = realitio_contract.askQuestion(
569
- private_credentials=private_credentials,
570
+ api_keys=api_keys,
570
571
  question=question,
571
572
  category=category,
572
573
  outcomes=outcomes,
@@ -585,7 +586,7 @@ def omen_create_market_tx(
585
586
  )
586
587
  if not conditional_token_contract.does_condition_exists(condition_id, web3=web3):
587
588
  conditional_token_contract.prepareCondition(
588
- private_credentials=private_credentials,
589
+ api_keys=api_keys,
589
590
  question_id=question_id,
590
591
  oracle_address=oracle_contract.address,
591
592
  outcomes_slot_count=len(outcomes),
@@ -594,7 +595,7 @@ def omen_create_market_tx(
594
595
 
595
596
  # Create the market.
596
597
  create_market_receipt_tx = factory_contract.create2FixedProductMarketMaker(
597
- private_credentials=private_credentials,
598
+ api_keys=api_keys,
598
599
  condition_id=condition_id,
599
600
  fee=fee,
600
601
  initial_funds_wei=initial_funds_wei,
@@ -613,13 +614,13 @@ def omen_create_market_tx(
613
614
 
614
615
 
615
616
  def omen_fund_market_tx(
616
- private_credentials: PrivateCredentials,
617
+ api_keys: APIKeys,
617
618
  market: OmenAgentMarket,
618
619
  funds: Wei,
619
620
  auto_deposit: bool,
620
621
  web3: Web3 | None = None,
621
622
  ) -> None:
622
- from_address = private_credentials.public_key
623
+ from_address = api_keys.bet_from_address
623
624
  market_contract = market.get_contract()
624
625
  collateral_token_contract = OmenCollateralTokenContract()
625
626
 
@@ -630,16 +631,16 @@ def omen_fund_market_tx(
630
631
  and collateral_token_contract.balanceOf(for_address=from_address, web3=web3)
631
632
  < funds
632
633
  ):
633
- collateral_token_contract.deposit(private_credentials, funds, web3=web3)
634
+ collateral_token_contract.deposit(api_keys, funds, web3=web3)
634
635
 
635
636
  collateral_token_contract.approve(
636
- private_credentials=private_credentials,
637
+ api_keys=api_keys,
637
638
  for_address=market_contract.address,
638
639
  amount_wei=funds,
639
640
  web3=web3,
640
641
  )
641
642
 
642
- market_contract.addFunding(private_credentials, funds, web3=web3)
643
+ market_contract.addFunding(api_keys, funds, web3=web3)
643
644
 
644
645
 
645
646
  def build_parent_collection_id() -> HexStr:
@@ -647,7 +648,7 @@ def build_parent_collection_id() -> HexStr:
647
648
 
648
649
 
649
650
  def omen_redeem_full_position_tx(
650
- private_credentials: PrivateCredentials,
651
+ api_keys: APIKeys,
651
652
  market: OmenAgentMarket,
652
653
  web3: Web3 | None = None,
653
654
  ) -> None:
@@ -656,7 +657,7 @@ def omen_redeem_full_position_tx(
656
657
  to be redeemed before sending the transaction.
657
658
  """
658
659
 
659
- from_address = private_credentials.public_key
660
+ from_address = api_keys.bet_from_address
660
661
 
661
662
  market_contract: OmenFixedProductMarketMakerContract = market.get_contract()
662
663
  conditional_token_contract = OmenConditionalTokenContract()
@@ -686,7 +687,7 @@ def omen_redeem_full_position_tx(
686
687
  return
687
688
 
688
689
  conditional_token_contract.redeemPositions(
689
- private_credentials=private_credentials,
690
+ api_keys=api_keys,
690
691
  collateral_token_address=market.collateral_token_contract_address_checksummed,
691
692
  condition_id=market.condition.id,
692
693
  parent_collection_id=parent_collection_id,
@@ -727,7 +728,7 @@ def get_conditional_tokens_balance_for_market(
727
728
 
728
729
 
729
730
  def omen_remove_fund_market_tx(
730
- private_credentials: PrivateCredentials,
731
+ api_keys: APIKeys,
731
732
  market: OmenAgentMarket,
732
733
  shares: Wei | None,
733
734
  web3: Web3 | None = None,
@@ -740,7 +741,7 @@ def omen_remove_fund_market_tx(
740
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.
741
742
  That can be done using the `redeem_from_all_user_positions` function below.
742
743
  """
743
- from_address = private_credentials.public_key
744
+ from_address = api_keys.bet_from_address
744
745
  market_contract = market.get_contract()
745
746
  original_balances = get_balances(from_address, web3=web3)
746
747
 
@@ -755,9 +756,7 @@ def omen_remove_fund_market_tx(
755
756
  )
756
757
  shares = total_shares
757
758
 
758
- market_contract.removeFunding(
759
- private_credentials=private_credentials, remove_funding=shares, web3=web3
760
- )
759
+ market_contract.removeFunding(api_keys=api_keys, remove_funding=shares, web3=web3)
761
760
 
762
761
  conditional_tokens = OmenConditionalTokenContract()
763
762
  parent_collection_id = build_parent_collection_id()
@@ -770,7 +769,7 @@ def omen_remove_fund_market_tx(
770
769
  amount_to_merge = min(amount_per_index_set.values())
771
770
 
772
771
  result = conditional_tokens.mergePositions(
773
- private_credentials=private_credentials,
772
+ api_keys=api_keys,
774
773
  collateral_token_address=market.collateral_token_contract_address_checksummed,
775
774
  parent_collection_id=parent_collection_id,
776
775
  conditionId=market.condition.id,
@@ -788,13 +787,13 @@ def omen_remove_fund_market_tx(
788
787
 
789
788
 
790
789
  def redeem_from_all_user_positions(
791
- private_credentials: PrivateCredentials,
790
+ api_keys: APIKeys,
792
791
  web3: Web3 | None = None,
793
792
  ) -> None:
794
793
  """
795
794
  Redeems from all user positions where the user didn't redeem yet.
796
795
  """
797
- public_key = private_credentials.public_key
796
+ public_key = api_keys.bet_from_address
798
797
 
799
798
  conditional_token_contract = OmenConditionalTokenContract()
800
799
  user_positions = OmenSubgraphHandler().get_user_positions(
@@ -818,7 +817,7 @@ def redeem_from_all_user_positions(
818
817
 
819
818
  original_balances = get_balances(public_key, web3)
820
819
  conditional_token_contract.redeemPositions(
821
- private_credentials=private_credentials,
820
+ api_keys=api_keys,
822
821
  collateral_token_address=user_position.position.collateral_token_contract_address_checksummed,
823
822
  condition_id=condition_id,
824
823
  parent_collection_id=build_parent_collection_id(),