prediction-market-agent-tooling 0.69.4.dev1072__py3-none-any.whl → 0.69.5__py3-none-any.whl

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.
@@ -163,13 +163,6 @@ class SeerMarketWithQuestions(SeerMarket):
163
163
  questions: list[SeerMarketQuestions]
164
164
 
165
165
 
166
- class RedeemParams(BaseModel):
167
- model_config = ConfigDict(populate_by_name=True)
168
- market: ChecksumAddress
169
- outcome_indices: list[int] = Field(alias="outcomeIndexes")
170
- amounts: list[OutcomeWei]
171
-
172
-
173
166
  class ExactInputSingleParams(BaseModel):
174
167
  # from https://gnosisscan.io/address/0xffb643e73f280b97809a8b41f7232ab401a04ee1#code
175
168
  model_config = ConfigDict(populate_by_name=True)
@@ -49,7 +49,6 @@ from prediction_market_agent_tooling.markets.omen.omen_contracts import (
49
49
  SeerAgentResultMappingContract,
50
50
  )
51
51
  from prediction_market_agent_tooling.markets.seer.data_models import (
52
- RedeemParams,
53
52
  SeerMarket,
54
53
  SeerMarketWithQuestions,
55
54
  )
@@ -83,6 +82,7 @@ from prediction_market_agent_tooling.tools.cow.cow_order import (
83
82
  OrderStatusError,
84
83
  get_orders_by_owner,
85
84
  get_trades_by_order_uid,
85
+ handle_allowance,
86
86
  swap_tokens_waiting,
87
87
  wait_for_order_completion,
88
88
  )
@@ -279,6 +279,7 @@ class SeerAgentMarket(AgentMarket):
279
279
  """
280
280
  We filter the markets using previous trades by the user so that we don't have to process all Seer markets.
281
281
  """
282
+
282
283
  trades_by_user = get_seer_transactions(
283
284
  api_keys.bet_from_address, RPCConfig().CHAIN_ID
284
285
  )
@@ -299,10 +300,12 @@ class SeerAgentMarket(AgentMarket):
299
300
  return filtered_markets
300
301
 
301
302
  @staticmethod
302
- def redeem_winnings(api_keys: APIKeys) -> None:
303
- web3 = RPCConfig().get_web3()
303
+ def redeem_winnings(api_keys: APIKeys, web3: Web3 | None = None) -> None:
304
+ web3 = web3 or RPCConfig().get_web3()
304
305
  subgraph = SeerSubgraphHandler()
305
306
 
307
+ # ToDo - Find open positions by user directly
308
+
306
309
  closed_markets = subgraph.get_markets(
307
310
  filter_by=FilterBy.RESOLVED, sort_by=SortBy.NEWEST
308
311
  )
@@ -311,8 +314,8 @@ class SeerAgentMarket(AgentMarket):
311
314
  )
312
315
 
313
316
  market_balances = {
314
- market.id: market.get_outcome_token_balances(
315
- api_keys.bet_from_address, web3
317
+ market.id: list(
318
+ market.get_outcome_token_balances(api_keys.bet_from_address, web3)
316
319
  )
317
320
  for market in filtered_markets
318
321
  }
@@ -329,17 +332,15 @@ class SeerAgentMarket(AgentMarket):
329
332
  try:
330
333
  # GnosisRouter needs approval to use our outcome tokens
331
334
  for i, token in enumerate(market.wrapped_tokens):
332
- ContractERC20OnGnosisChain(
333
- address=Web3.to_checksum_address(token)
334
- ).approve(
335
- api_keys,
335
+ handle_allowance(
336
+ api_keys=api_keys,
337
+ sell_token=Web3.to_checksum_address(token),
338
+ amount_to_check_wei=market_balances[market.id][i].as_wei,
336
339
  for_address=gnosis_router.address,
337
- amount_wei=market_balances[market.id][i].as_wei,
338
340
  web3=web3,
339
341
  )
340
342
 
341
343
  # We can only ask for redeem of outcome tokens on correct outcomes
342
- # TODO: Implement more complex use-cases: https://github.com/gnosis/prediction-market-agent-tooling/issues/850
343
344
  amounts_to_redeem = [
344
345
  (amount if numerator > 0 else OutcomeWei(0))
345
346
  for amount, numerator in zip(
@@ -347,13 +348,13 @@ class SeerAgentMarket(AgentMarket):
347
348
  )
348
349
  ]
349
350
 
350
- # Redeem!
351
- params = RedeemParams(
351
+ gnosis_router.redeem_to_base(
352
+ api_keys,
352
353
  market=Web3.to_checksum_address(market.id),
353
- outcome_indices=list(range(len(market.payout_numerators))),
354
+ outcome_indexes=list(range(len(market.payout_numerators))),
354
355
  amounts=amounts_to_redeem,
356
+ web3=web3,
355
357
  )
356
- gnosis_router.redeem_to_base(api_keys, params=params, web3=web3)
357
358
  logger.info(f"Redeemed market {market.url}.")
358
359
  except Exception:
359
360
  logger.exception(
@@ -8,13 +8,13 @@ from prediction_market_agent_tooling.gtypes import (
8
8
  ABI,
9
9
  ChecksumAddress,
10
10
  OutcomeStr,
11
+ OutcomeWei,
11
12
  TxReceipt,
12
13
  Wei,
13
14
  xDai,
14
15
  )
15
16
  from prediction_market_agent_tooling.markets.seer.data_models import (
16
17
  ExactInputSingleParams,
17
- RedeemParams,
18
18
  )
19
19
  from prediction_market_agent_tooling.markets.seer.subgraph_data_models import (
20
20
  CreateCategoricalMarketsParams,
@@ -102,12 +102,18 @@ class GnosisRouter(ContractOnGnosisChain):
102
102
  def redeem_to_base(
103
103
  self,
104
104
  api_keys: APIKeys,
105
- params: RedeemParams,
105
+ market: ChecksumAddress,
106
+ outcome_indexes: list[int],
107
+ amounts: list[OutcomeWei],
106
108
  web3: Web3 | None = None,
107
109
  ) -> TxReceipt:
108
- params_dict = params.model_dump(by_alias=True)
109
110
  # We explicity set amounts since OutcomeWei gets serialized as dict
110
- params_dict["amounts"] = [amount.value for amount in params.amounts]
111
+ params_dict = {
112
+ "market": market,
113
+ "outcomeIndexes": outcome_indexes,
114
+ "amounts": [amount.value for amount in amounts],
115
+ }
116
+
111
117
  receipt_tx = self.send(
112
118
  api_keys=api_keys,
113
119
  function_name="redeemToBase",
@@ -116,6 +122,22 @@ class GnosisRouter(ContractOnGnosisChain):
116
122
  )
117
123
  return receipt_tx
118
124
 
125
+ def split_from_base(
126
+ self,
127
+ api_keys: APIKeys,
128
+ market_id: ChecksumAddress,
129
+ amount_wei: Wei,
130
+ web3: Web3 | None = None,
131
+ ) -> TxReceipt:
132
+ """Splits using xDAI and receives outcome tokens"""
133
+ return self.send_with_value(
134
+ api_keys=api_keys,
135
+ function_name="splitFromBase",
136
+ amount_wei=amount_wei,
137
+ function_params=[market_id],
138
+ web3=web3,
139
+ )
140
+
119
141
  def split_position(
120
142
  self,
121
143
  api_keys: APIKeys,
@@ -434,6 +434,25 @@ class ContractWrapped1155BaseClass(ContractERC20BaseClass):
434
434
  )
435
435
  )
436
436
 
437
+ def factory(self, web3: Web3 | None = None) -> ChecksumAddress:
438
+ return Web3.to_checksum_address(self.call("factory", web3=web3))
439
+
440
+ def mint(
441
+ self,
442
+ api_keys: APIKeys,
443
+ to_address: ChecksumAddress,
444
+ amount: Wei,
445
+ tx_params: t.Optional[TxParams] = None,
446
+ web3: Web3 | None = None,
447
+ ) -> TxReceipt:
448
+ return self.send(
449
+ api_keys=api_keys,
450
+ function_name="mint",
451
+ function_params=[to_address, amount],
452
+ tx_params=tx_params,
453
+ web3=web3,
454
+ )
455
+
437
456
 
438
457
  class OwnableContract(ContractBaseClass):
439
458
  abi: ABI = abi_field_validator(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.69.4.dev1072
3
+ Version: 0.69.5
4
4
  Summary: Tools to benchmark, deploy and monitor prediction market agents.
5
5
  Author: Gnosis
6
6
  Requires-Python: >=3.10,<3.13
@@ -72,12 +72,12 @@ prediction_market_agent_tooling/markets/polymarket/polymarket.py,sha256=-zAx64Mc
72
72
  prediction_market_agent_tooling/markets/polymarket/polymarket_contracts.py,sha256=x8yvAUPl55nbJALsQAAHJtstahhpH8WcEOj8or_QloQ,1165
73
73
  prediction_market_agent_tooling/markets/polymarket/polymarket_subgraph_handler.py,sha256=2b1hVAp3tCPkmp_FFAZwy6baW7CrPhpUSGk7TlrvgtU,1631
74
74
  prediction_market_agent_tooling/markets/polymarket/utils.py,sha256=A_diygWKYyp4WHbxAlAVAuC0S0ZqbEKE80wxL6mxHKQ,1275
75
- prediction_market_agent_tooling/markets/seer/data_models.py,sha256=Y8tIyOyTHfcIYu0b6YfMDxXcDnW87o3Fam4NEHBITmw,7833
75
+ prediction_market_agent_tooling/markets/seer/data_models.py,sha256=nnuclpajQCkb_s52cCf_rwGWdgjMutaIPyfUq7CqX4M,7626
76
76
  prediction_market_agent_tooling/markets/seer/exceptions.py,sha256=cEObdjluivD94tgOLzmimR7wgQEOt6SRakrYdhsRQtk,112
77
77
  prediction_market_agent_tooling/markets/seer/price_manager.py,sha256=Sz8NkbDd5CYruKe6KZ9GU--Jf8FDSkniE-PVrbqGiPM,9952
78
- prediction_market_agent_tooling/markets/seer/seer.py,sha256=OBQWj8IXU-6NNztvQqH0STNP_56f9G7DLc8jrgDogjY,31238
78
+ prediction_market_agent_tooling/markets/seer/seer.py,sha256=1coDkaHX66s_lWHjzhLEgoaNGeOo87Sxd83e0YGgNDA,31153
79
79
  prediction_market_agent_tooling/markets/seer/seer_api.py,sha256=4iiTWskxWm__oGgUUd1GhV_ItPSrAr0OfnYQ7lKndnQ,1143
80
- prediction_market_agent_tooling/markets/seer/seer_contracts.py,sha256=p2cW1Tk7Zj5Rq1oJ1Cil42MNJjKg2EPIxCOm9621PKY,5595
80
+ prediction_market_agent_tooling/markets/seer/seer_contracts.py,sha256=LEmZg6PO5GnxI2izxkUYtfU7W58MQJrp8CRoMnF-HSc,6170
81
81
  prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py,sha256=nmeSofxwtdB6osrP0ASmDWhL684U52Qp4bqJRbRFkCE,18794
82
82
  prediction_market_agent_tooling/markets/seer/subgraph_data_models.py,sha256=96v41jdNNxBqTCp5g8SLMSrIgeeITVx5IsBjVgm-qdo,2920
83
83
  prediction_market_agent_tooling/markets/seer/swap_pool_handler.py,sha256=k_sCEJZLroVDjOVkZ084VKJGNODLGjBGezhsWEZvlH4,3528
@@ -90,7 +90,7 @@ prediction_market_agent_tooling/tools/betting_strategies/utils.py,sha256=MpS3FOM
90
90
  prediction_market_agent_tooling/tools/caches/db_cache.py,sha256=rZIGhgijquwwPtp_qncSAPR1SDF2XxIVZL1ir0fgzWw,12127
91
91
  prediction_market_agent_tooling/tools/caches/inmemory_cache.py,sha256=ZW5iI5rmjqeAebu5T7ftRnlkxiL02IC-MxCfDB80x7w,1506
92
92
  prediction_market_agent_tooling/tools/caches/serializers.py,sha256=vFDx4fsPxclXp2q0sv27j4al_M_Tj9aR2JJP-xNHQXA,2151
93
- prediction_market_agent_tooling/tools/contract.py,sha256=8k4wF4p19JI3YjVob3o6t4J6sdyPjoSP8jCiAiEVEtM,32305
93
+ prediction_market_agent_tooling/tools/contract.py,sha256=ZuypmdAB82LYpVZE_qvlax13ikwg7D6OV-YafiQYxoE,32870
94
94
  prediction_market_agent_tooling/tools/costs.py,sha256=EaAJ7v9laD4VEV3d8B44M4u3_oEO_H16jRVCdoZ93Uw,954
95
95
  prediction_market_agent_tooling/tools/cow/cow_order.py,sha256=kdvhWVTb31oHVspQFowDNEIoDtx8hwGTlKsWYGRh3oQ,14050
96
96
  prediction_market_agent_tooling/tools/cow/models.py,sha256=2hTW-Ye6SamBBAO32nVo4f3vjAOOySw8ehECReRcA3o,756
@@ -132,8 +132,8 @@ prediction_market_agent_tooling/tools/tokens/usd.py,sha256=DPO-4HBTy1-TZHKL_9CnH
132
132
  prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
133
133
  prediction_market_agent_tooling/tools/utils.py,sha256=ruq6P5TFs8CBHxeBLj1Plpx7kuNFPpDgMsJGQgDiRNs,8785
134
134
  prediction_market_agent_tooling/tools/web3_utils.py,sha256=CDbaidlLeQ4VHzSg150L7QNfHfGveljSePGuDVFEYqc,13963
135
- prediction_market_agent_tooling-0.69.4.dev1072.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
136
- prediction_market_agent_tooling-0.69.4.dev1072.dist-info/METADATA,sha256=WzwC0O9_CJf22VVwHY20fP_QA26TFt1ICzmevaVYLUw,8813
137
- prediction_market_agent_tooling-0.69.4.dev1072.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
138
- prediction_market_agent_tooling-0.69.4.dev1072.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
139
- prediction_market_agent_tooling-0.69.4.dev1072.dist-info/RECORD,,
135
+ prediction_market_agent_tooling-0.69.5.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
136
+ prediction_market_agent_tooling-0.69.5.dist-info/METADATA,sha256=Uaa9YSg_wOcxC5vKVW3qxMF6rRj5NJTDXC6buuKqJuU,8805
137
+ prediction_market_agent_tooling-0.69.5.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
138
+ prediction_market_agent_tooling-0.69.5.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
139
+ prediction_market_agent_tooling-0.69.5.dist-info/RECORD,,