prediction-market-agent-tooling 0.57.16.dev311__py3-none-any.whl → 0.57.17__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.
@@ -0,0 +1,609 @@
1
+ [
2
+ {
3
+ "inputs": [
4
+ {
5
+ "internalType": "address",
6
+ "name": "_market",
7
+ "type": "address"
8
+ },
9
+ {
10
+ "internalType": "address",
11
+ "name": "_arbitrator",
12
+ "type": "address"
13
+ },
14
+ {
15
+ "internalType": "contract IRealityETH_v3_0",
16
+ "name": "_realitio",
17
+ "type": "address"
18
+ },
19
+ {
20
+ "internalType": "contract IWrapped1155Factory",
21
+ "name": "_wrapped1155Factory",
22
+ "type": "address"
23
+ },
24
+ {
25
+ "internalType": "contract IConditionalTokens",
26
+ "name": "_conditionalTokens",
27
+ "type": "address"
28
+ },
29
+ {
30
+ "internalType": "address",
31
+ "name": "_collateralToken",
32
+ "type": "address"
33
+ },
34
+ {
35
+ "internalType": "contract RealityProxy",
36
+ "name": "_realityProxy",
37
+ "type": "address"
38
+ },
39
+ {
40
+ "internalType": "uint32",
41
+ "name": "_questionTimeout",
42
+ "type": "uint32"
43
+ }
44
+ ],
45
+ "stateMutability": "nonpayable",
46
+ "type": "constructor"
47
+ },
48
+ {
49
+ "inputs": [],
50
+ "name": "ERC1167FailedCreateClone",
51
+ "type": "error"
52
+ },
53
+ {
54
+ "anonymous": false,
55
+ "inputs": [
56
+ {
57
+ "indexed": true,
58
+ "internalType": "address",
59
+ "name": "market",
60
+ "type": "address"
61
+ },
62
+ {
63
+ "indexed": false,
64
+ "internalType": "string",
65
+ "name": "marketName",
66
+ "type": "string"
67
+ },
68
+ {
69
+ "indexed": false,
70
+ "internalType": "address",
71
+ "name": "parentMarket",
72
+ "type": "address"
73
+ },
74
+ {
75
+ "indexed": false,
76
+ "internalType": "bytes32",
77
+ "name": "conditionId",
78
+ "type": "bytes32"
79
+ },
80
+ {
81
+ "indexed": false,
82
+ "internalType": "bytes32",
83
+ "name": "questionId",
84
+ "type": "bytes32"
85
+ },
86
+ {
87
+ "indexed": false,
88
+ "internalType": "bytes32[]",
89
+ "name": "questionsIds",
90
+ "type": "bytes32[]"
91
+ }
92
+ ],
93
+ "name": "NewMarket",
94
+ "type": "event"
95
+ },
96
+ {
97
+ "inputs": [],
98
+ "name": "allMarkets",
99
+ "outputs": [
100
+ {
101
+ "internalType": "address[]",
102
+ "name": "",
103
+ "type": "address[]"
104
+ }
105
+ ],
106
+ "stateMutability": "view",
107
+ "type": "function"
108
+ },
109
+ {
110
+ "inputs": [],
111
+ "name": "arbitrator",
112
+ "outputs": [
113
+ {
114
+ "internalType": "address",
115
+ "name": "",
116
+ "type": "address"
117
+ }
118
+ ],
119
+ "stateMutability": "view",
120
+ "type": "function"
121
+ },
122
+ {
123
+ "inputs": [],
124
+ "name": "collateralToken",
125
+ "outputs": [
126
+ {
127
+ "internalType": "address",
128
+ "name": "",
129
+ "type": "address"
130
+ }
131
+ ],
132
+ "stateMutability": "view",
133
+ "type": "function"
134
+ },
135
+ {
136
+ "inputs": [],
137
+ "name": "conditionalTokens",
138
+ "outputs": [
139
+ {
140
+ "internalType": "contract IConditionalTokens",
141
+ "name": "",
142
+ "type": "address"
143
+ }
144
+ ],
145
+ "stateMutability": "view",
146
+ "type": "function"
147
+ },
148
+ {
149
+ "inputs": [
150
+ {
151
+ "components": [
152
+ {
153
+ "internalType": "string",
154
+ "name": "marketName",
155
+ "type": "string"
156
+ },
157
+ {
158
+ "internalType": "string[]",
159
+ "name": "outcomes",
160
+ "type": "string[]"
161
+ },
162
+ {
163
+ "internalType": "string",
164
+ "name": "questionStart",
165
+ "type": "string"
166
+ },
167
+ {
168
+ "internalType": "string",
169
+ "name": "questionEnd",
170
+ "type": "string"
171
+ },
172
+ {
173
+ "internalType": "string",
174
+ "name": "outcomeType",
175
+ "type": "string"
176
+ },
177
+ {
178
+ "internalType": "uint256",
179
+ "name": "parentOutcome",
180
+ "type": "uint256"
181
+ },
182
+ {
183
+ "internalType": "address",
184
+ "name": "parentMarket",
185
+ "type": "address"
186
+ },
187
+ {
188
+ "internalType": "string",
189
+ "name": "category",
190
+ "type": "string"
191
+ },
192
+ {
193
+ "internalType": "string",
194
+ "name": "lang",
195
+ "type": "string"
196
+ },
197
+ {
198
+ "internalType": "uint256",
199
+ "name": "lowerBound",
200
+ "type": "uint256"
201
+ },
202
+ {
203
+ "internalType": "uint256",
204
+ "name": "upperBound",
205
+ "type": "uint256"
206
+ },
207
+ {
208
+ "internalType": "uint256",
209
+ "name": "minBond",
210
+ "type": "uint256"
211
+ },
212
+ {
213
+ "internalType": "uint32",
214
+ "name": "openingTime",
215
+ "type": "uint32"
216
+ },
217
+ {
218
+ "internalType": "string[]",
219
+ "name": "tokenNames",
220
+ "type": "string[]"
221
+ }
222
+ ],
223
+ "internalType": "struct MarketFactory.CreateMarketParams",
224
+ "name": "params",
225
+ "type": "tuple"
226
+ }
227
+ ],
228
+ "name": "createCategoricalMarket",
229
+ "outputs": [
230
+ {
231
+ "internalType": "address",
232
+ "name": "",
233
+ "type": "address"
234
+ }
235
+ ],
236
+ "stateMutability": "nonpayable",
237
+ "type": "function"
238
+ },
239
+ {
240
+ "inputs": [
241
+ {
242
+ "components": [
243
+ {
244
+ "internalType": "string",
245
+ "name": "marketName",
246
+ "type": "string"
247
+ },
248
+ {
249
+ "internalType": "string[]",
250
+ "name": "outcomes",
251
+ "type": "string[]"
252
+ },
253
+ {
254
+ "internalType": "string",
255
+ "name": "questionStart",
256
+ "type": "string"
257
+ },
258
+ {
259
+ "internalType": "string",
260
+ "name": "questionEnd",
261
+ "type": "string"
262
+ },
263
+ {
264
+ "internalType": "string",
265
+ "name": "outcomeType",
266
+ "type": "string"
267
+ },
268
+ {
269
+ "internalType": "uint256",
270
+ "name": "parentOutcome",
271
+ "type": "uint256"
272
+ },
273
+ {
274
+ "internalType": "address",
275
+ "name": "parentMarket",
276
+ "type": "address"
277
+ },
278
+ {
279
+ "internalType": "string",
280
+ "name": "category",
281
+ "type": "string"
282
+ },
283
+ {
284
+ "internalType": "string",
285
+ "name": "lang",
286
+ "type": "string"
287
+ },
288
+ {
289
+ "internalType": "uint256",
290
+ "name": "lowerBound",
291
+ "type": "uint256"
292
+ },
293
+ {
294
+ "internalType": "uint256",
295
+ "name": "upperBound",
296
+ "type": "uint256"
297
+ },
298
+ {
299
+ "internalType": "uint256",
300
+ "name": "minBond",
301
+ "type": "uint256"
302
+ },
303
+ {
304
+ "internalType": "uint32",
305
+ "name": "openingTime",
306
+ "type": "uint32"
307
+ },
308
+ {
309
+ "internalType": "string[]",
310
+ "name": "tokenNames",
311
+ "type": "string[]"
312
+ }
313
+ ],
314
+ "internalType": "struct MarketFactory.CreateMarketParams",
315
+ "name": "params",
316
+ "type": "tuple"
317
+ }
318
+ ],
319
+ "name": "createMultiCategoricalMarket",
320
+ "outputs": [
321
+ {
322
+ "internalType": "address",
323
+ "name": "",
324
+ "type": "address"
325
+ }
326
+ ],
327
+ "stateMutability": "nonpayable",
328
+ "type": "function"
329
+ },
330
+ {
331
+ "inputs": [
332
+ {
333
+ "components": [
334
+ {
335
+ "internalType": "string",
336
+ "name": "marketName",
337
+ "type": "string"
338
+ },
339
+ {
340
+ "internalType": "string[]",
341
+ "name": "outcomes",
342
+ "type": "string[]"
343
+ },
344
+ {
345
+ "internalType": "string",
346
+ "name": "questionStart",
347
+ "type": "string"
348
+ },
349
+ {
350
+ "internalType": "string",
351
+ "name": "questionEnd",
352
+ "type": "string"
353
+ },
354
+ {
355
+ "internalType": "string",
356
+ "name": "outcomeType",
357
+ "type": "string"
358
+ },
359
+ {
360
+ "internalType": "uint256",
361
+ "name": "parentOutcome",
362
+ "type": "uint256"
363
+ },
364
+ {
365
+ "internalType": "address",
366
+ "name": "parentMarket",
367
+ "type": "address"
368
+ },
369
+ {
370
+ "internalType": "string",
371
+ "name": "category",
372
+ "type": "string"
373
+ },
374
+ {
375
+ "internalType": "string",
376
+ "name": "lang",
377
+ "type": "string"
378
+ },
379
+ {
380
+ "internalType": "uint256",
381
+ "name": "lowerBound",
382
+ "type": "uint256"
383
+ },
384
+ {
385
+ "internalType": "uint256",
386
+ "name": "upperBound",
387
+ "type": "uint256"
388
+ },
389
+ {
390
+ "internalType": "uint256",
391
+ "name": "minBond",
392
+ "type": "uint256"
393
+ },
394
+ {
395
+ "internalType": "uint32",
396
+ "name": "openingTime",
397
+ "type": "uint32"
398
+ },
399
+ {
400
+ "internalType": "string[]",
401
+ "name": "tokenNames",
402
+ "type": "string[]"
403
+ }
404
+ ],
405
+ "internalType": "struct MarketFactory.CreateMarketParams",
406
+ "name": "params",
407
+ "type": "tuple"
408
+ }
409
+ ],
410
+ "name": "createMultiScalarMarket",
411
+ "outputs": [
412
+ {
413
+ "internalType": "address",
414
+ "name": "",
415
+ "type": "address"
416
+ }
417
+ ],
418
+ "stateMutability": "nonpayable",
419
+ "type": "function"
420
+ },
421
+ {
422
+ "inputs": [
423
+ {
424
+ "components": [
425
+ {
426
+ "internalType": "string",
427
+ "name": "marketName",
428
+ "type": "string"
429
+ },
430
+ {
431
+ "internalType": "string[]",
432
+ "name": "outcomes",
433
+ "type": "string[]"
434
+ },
435
+ {
436
+ "internalType": "string",
437
+ "name": "questionStart",
438
+ "type": "string"
439
+ },
440
+ {
441
+ "internalType": "string",
442
+ "name": "questionEnd",
443
+ "type": "string"
444
+ },
445
+ {
446
+ "internalType": "string",
447
+ "name": "outcomeType",
448
+ "type": "string"
449
+ },
450
+ {
451
+ "internalType": "uint256",
452
+ "name": "parentOutcome",
453
+ "type": "uint256"
454
+ },
455
+ {
456
+ "internalType": "address",
457
+ "name": "parentMarket",
458
+ "type": "address"
459
+ },
460
+ {
461
+ "internalType": "string",
462
+ "name": "category",
463
+ "type": "string"
464
+ },
465
+ {
466
+ "internalType": "string",
467
+ "name": "lang",
468
+ "type": "string"
469
+ },
470
+ {
471
+ "internalType": "uint256",
472
+ "name": "lowerBound",
473
+ "type": "uint256"
474
+ },
475
+ {
476
+ "internalType": "uint256",
477
+ "name": "upperBound",
478
+ "type": "uint256"
479
+ },
480
+ {
481
+ "internalType": "uint256",
482
+ "name": "minBond",
483
+ "type": "uint256"
484
+ },
485
+ {
486
+ "internalType": "uint32",
487
+ "name": "openingTime",
488
+ "type": "uint32"
489
+ },
490
+ {
491
+ "internalType": "string[]",
492
+ "name": "tokenNames",
493
+ "type": "string[]"
494
+ }
495
+ ],
496
+ "internalType": "struct MarketFactory.CreateMarketParams",
497
+ "name": "params",
498
+ "type": "tuple"
499
+ }
500
+ ],
501
+ "name": "createScalarMarket",
502
+ "outputs": [
503
+ {
504
+ "internalType": "address",
505
+ "name": "",
506
+ "type": "address"
507
+ }
508
+ ],
509
+ "stateMutability": "nonpayable",
510
+ "type": "function"
511
+ },
512
+ {
513
+ "inputs": [],
514
+ "name": "market",
515
+ "outputs": [
516
+ {
517
+ "internalType": "address",
518
+ "name": "",
519
+ "type": "address"
520
+ }
521
+ ],
522
+ "stateMutability": "view",
523
+ "type": "function"
524
+ },
525
+ {
526
+ "inputs": [],
527
+ "name": "marketCount",
528
+ "outputs": [
529
+ {
530
+ "internalType": "uint256",
531
+ "name": "",
532
+ "type": "uint256"
533
+ }
534
+ ],
535
+ "stateMutability": "view",
536
+ "type": "function"
537
+ },
538
+ {
539
+ "inputs": [
540
+ {
541
+ "internalType": "uint256",
542
+ "name": "",
543
+ "type": "uint256"
544
+ }
545
+ ],
546
+ "name": "markets",
547
+ "outputs": [
548
+ {
549
+ "internalType": "address",
550
+ "name": "",
551
+ "type": "address"
552
+ }
553
+ ],
554
+ "stateMutability": "view",
555
+ "type": "function"
556
+ },
557
+ {
558
+ "inputs": [],
559
+ "name": "questionTimeout",
560
+ "outputs": [
561
+ {
562
+ "internalType": "uint32",
563
+ "name": "",
564
+ "type": "uint32"
565
+ }
566
+ ],
567
+ "stateMutability": "view",
568
+ "type": "function"
569
+ },
570
+ {
571
+ "inputs": [],
572
+ "name": "realitio",
573
+ "outputs": [
574
+ {
575
+ "internalType": "contract IRealityETH_v3_0",
576
+ "name": "",
577
+ "type": "address"
578
+ }
579
+ ],
580
+ "stateMutability": "view",
581
+ "type": "function"
582
+ },
583
+ {
584
+ "inputs": [],
585
+ "name": "realityProxy",
586
+ "outputs": [
587
+ {
588
+ "internalType": "contract RealityProxy",
589
+ "name": "",
590
+ "type": "address"
591
+ }
592
+ ],
593
+ "stateMutability": "view",
594
+ "type": "function"
595
+ },
596
+ {
597
+ "inputs": [],
598
+ "name": "wrapped1155Factory",
599
+ "outputs": [
600
+ {
601
+ "internalType": "contract IWrapped1155Factory",
602
+ "name": "",
603
+ "type": "address"
604
+ }
605
+ ],
606
+ "stateMutability": "view",
607
+ "type": "function"
608
+ }
609
+ ]
@@ -61,7 +61,7 @@ def patch_logger() -> None:
61
61
  format_logging = GCP_LOG_LOGGING_FORMAT
62
62
  datefmt_logging = GCP_LOG_FORMAT_LOGGING_DATEFMT
63
63
  print_logging = print_using_loguru_info
64
- handlers = [NoNewLineStreamHandler()]
64
+ handlers: list[logging.Handler] | None = [NoNewLineStreamHandler()]
65
65
 
66
66
  elif config.LOG_FORMAT == LogFormat.DEFAULT:
67
67
  format_loguru, format_logging, datefmt_logging = None, None, None
@@ -80,6 +80,14 @@ def patch_logger() -> None:
80
80
  handlers=handlers,
81
81
  )
82
82
 
83
+ # Configure all existing loggers
84
+ for logger_name in logging.root.manager.loggerDict:
85
+ existing_logger = logging.getLogger(logger_name)
86
+ existing_logger.setLevel(config.LOG_LEVEL.value)
87
+ if handlers is not None:
88
+ existing_logger.handlers = handlers
89
+ existing_logger.propagate = False
90
+
83
91
  # Change loguru.
84
92
  if format_loguru is not None:
85
93
  logger.remove()
@@ -50,7 +50,7 @@ def claim_bonds_on_realitio_questions(
50
50
  except Exception as e:
51
51
  if not skip_failed:
52
52
  raise e
53
- logger.error(
53
+ logger.warning(
54
54
  f"Failed to claim bond for {question.url=}, {question.questionId=}: {e}"
55
55
  )
56
56
 
@@ -203,7 +203,7 @@ def omen_submit_answer_market_tx(
203
203
  web3: Web3 | None = None,
204
204
  ) -> None:
205
205
  """
206
- After the answer is submitted, there is 24h waiting period where the answer can be challenged by others.
206
+ After the answer is submitted, there is waiting period where the answer can be challenged by others.
207
207
  And after the period is over, you need to resolve the market using `omen_resolve_market_tx`.
208
208
  """
209
209
  realitio_contract = OmenRealitioContract()
@@ -224,7 +224,7 @@ def omen_submit_invalid_answer_market_tx(
224
224
  web3: Web3 | None = None,
225
225
  ) -> None:
226
226
  """
227
- After the answer is submitted, there is 24h waiting period where the answer can be challenged by others.
227
+ After the answer is submitted, there is waiting period where the answer can be challenged by others.
228
228
  And after the period is over, you need to resolve the market using `omen_resolve_market_tx`.
229
229
  """
230
230
  realitio_contract = OmenRealitioContract()
@@ -1,6 +1,33 @@
1
+ import typing as t
2
+
3
+ from eth_typing import HexAddress
1
4
  from pydantic import BaseModel, ConfigDict, Field
5
+ from web3.constants import ADDRESS_ZERO
6
+
7
+ from prediction_market_agent_tooling.gtypes import HexBytes, Wei
8
+
9
+
10
+ class CreateCategoricalMarketsParams(BaseModel):
11
+ model_config = ConfigDict(populate_by_name=True)
2
12
 
3
- from prediction_market_agent_tooling.gtypes import HexBytes
13
+ market_name: str = Field(..., alias="marketName")
14
+ outcomes: list[str]
15
+ # Only relevant for scalar markets
16
+ question_start: str = Field(alias="questionStart", default="")
17
+ question_end: str = Field(alias="questionEnd", default="")
18
+ outcome_type: str = Field(alias="outcomeType", default="")
19
+
20
+ # Not needed for non-conditional markets.
21
+ parent_outcome: int = Field(alias="parentOutcome", default=0)
22
+ parent_market: HexAddress = Field(alias="parentMarket", default=ADDRESS_ZERO)
23
+
24
+ category: str
25
+ lang: str
26
+ lower_bound: int = Field(alias="lowerBound", default=0)
27
+ upper_bound: int = Field(alias="upperBound", default=0)
28
+ min_bond: Wei = Field(..., alias="minBond")
29
+ opening_time: int = Field(..., alias="openingTime")
30
+ token_names: list[str] = Field(..., alias="tokenNames")
4
31
 
5
32
 
6
33
  class SeerParentMarket(BaseModel):
@@ -13,8 +40,11 @@ class SeerMarket(BaseModel):
13
40
  id: HexBytes
14
41
  title: str = Field(alias="marketName")
15
42
  outcomes: list[str]
16
- parent_market: SeerParentMarket | None = Field(alias="parentMarket")
17
43
  wrapped_tokens: list[HexBytes] = Field(alias="wrappedTokens")
44
+ parent_outcome: int = Field(alias="parentOutcome")
45
+ parent_market: t.Optional[SeerParentMarket] = Field(
46
+ alias="parentMarket", default=None
47
+ )
18
48
 
19
49
 
20
50
  class SeerToken(BaseModel):
@@ -29,3 +59,12 @@ class SeerPool(BaseModel):
29
59
  liquidity: int
30
60
  token0: SeerToken
31
61
  token1: SeerToken
62
+
63
+
64
+ class NewMarketEvent(BaseModel):
65
+ market: HexAddress
66
+ marketName: str
67
+ parentMarket: HexAddress
68
+ conditionId: HexBytes
69
+ questionId: HexBytes
70
+ questionsIds: list[HexBytes]
@@ -0,0 +1,92 @@
1
+ from eth_typing import ChecksumAddress
2
+ from web3 import Web3
3
+ from web3.types import TxReceipt
4
+
5
+ from prediction_market_agent_tooling.config import APIKeys
6
+ from prediction_market_agent_tooling.gtypes import xDai
7
+ from prediction_market_agent_tooling.markets.seer.data_models import NewMarketEvent
8
+ from prediction_market_agent_tooling.markets.seer.seer_contracts import (
9
+ SeerMarketFactory,
10
+ )
11
+ from prediction_market_agent_tooling.tools.contract import (
12
+ auto_deposit_collateral_token,
13
+ init_collateral_token_contract,
14
+ to_gnosis_chain_contract,
15
+ )
16
+ from prediction_market_agent_tooling.tools.datetime_utc import DatetimeUTC
17
+ from prediction_market_agent_tooling.tools.web3_utils import xdai_to_wei
18
+
19
+
20
+ def seer_create_market_tx(
21
+ api_keys: APIKeys,
22
+ initial_funds: xDai,
23
+ question: str,
24
+ opening_time: DatetimeUTC,
25
+ language: str,
26
+ outcomes: list[str],
27
+ auto_deposit: bool,
28
+ category: str,
29
+ min_bond_xdai: xDai,
30
+ web3: Web3 | None = None,
31
+ ) -> ChecksumAddress:
32
+ web3 = web3 or SeerMarketFactory.get_web3() # Default to Gnosis web3.
33
+ initial_funds_wei = xdai_to_wei(initial_funds)
34
+
35
+ factory_contract = SeerMarketFactory()
36
+ collateral_token_address = factory_contract.collateral_token(web3=web3)
37
+ collateral_token_contract = to_gnosis_chain_contract(
38
+ init_collateral_token_contract(collateral_token_address, web3)
39
+ )
40
+
41
+ if auto_deposit:
42
+ auto_deposit_collateral_token(
43
+ collateral_token_contract=collateral_token_contract,
44
+ api_keys=api_keys,
45
+ amount_wei=initial_funds_wei,
46
+ web3=web3,
47
+ )
48
+
49
+ # In case of ERC4626, obtained (for example) sDai out of xDai could be lower than the `amount_wei`, so we need to handle it.
50
+ initial_funds_in_shares = collateral_token_contract.get_in_shares(
51
+ amount=initial_funds_wei, web3=web3
52
+ )
53
+
54
+ # Approve the market maker to withdraw our collateral token.
55
+ collateral_token_contract.approve(
56
+ api_keys=api_keys,
57
+ for_address=factory_contract.address,
58
+ amount_wei=initial_funds_in_shares,
59
+ web3=web3,
60
+ )
61
+
62
+ # Create the market.
63
+ params = factory_contract.build_market_params(
64
+ market_question=question,
65
+ outcomes=outcomes,
66
+ opening_time=opening_time,
67
+ language=language,
68
+ category=category,
69
+ min_bond_xdai=min_bond_xdai,
70
+ )
71
+ tx_receipt = factory_contract.create_categorical_market(
72
+ api_keys=api_keys, params=params, web3=web3
73
+ )
74
+
75
+ # ToDo - Add liquidity to market on Swapr (https://github.com/gnosis/prediction-market-agent-tooling/issues/497)
76
+ market_address = extract_market_address_from_tx(
77
+ factory_contract=factory_contract, tx_receipt=tx_receipt, web3=web3
78
+ )
79
+ return market_address
80
+
81
+
82
+ def extract_market_address_from_tx(
83
+ factory_contract: SeerMarketFactory, tx_receipt: TxReceipt, web3: Web3
84
+ ) -> ChecksumAddress:
85
+ """We extract the newly created market from the NewMarket event emitted in the transaction."""
86
+ event_logs = (
87
+ factory_contract.get_web3_contract(web3=web3)
88
+ .events.NewMarket()
89
+ .process_receipt(tx_receipt)
90
+ )
91
+ new_market_event = NewMarketEvent(**event_logs[0]["args"])
92
+ return Web3.to_checksum_address(new_market_event.market)
@@ -0,0 +1,76 @@
1
+ import os
2
+
3
+ from web3 import Web3
4
+ from web3.types import TxReceipt
5
+
6
+ from prediction_market_agent_tooling.config import APIKeys
7
+ from prediction_market_agent_tooling.gtypes import ABI, ChecksumAddress, xDai
8
+ from prediction_market_agent_tooling.markets.seer.data_models import (
9
+ CreateCategoricalMarketsParams,
10
+ )
11
+ from prediction_market_agent_tooling.tools.contract import (
12
+ ContractOnGnosisChain,
13
+ abi_field_validator,
14
+ )
15
+ from prediction_market_agent_tooling.tools.datetime_utc import DatetimeUTC
16
+ from prediction_market_agent_tooling.tools.web3_utils import xdai_to_wei
17
+
18
+
19
+ class SeerMarketFactory(ContractOnGnosisChain):
20
+ # https://gnosisscan.io/address/0x83183da839ce8228e31ae41222ead9edbb5cdcf1#code.
21
+ abi: ABI = abi_field_validator(
22
+ os.path.join(
23
+ os.path.dirname(os.path.realpath(__file__)),
24
+ "../../abis/seer_market_factory.abi.json",
25
+ )
26
+ )
27
+ address: ChecksumAddress = Web3.to_checksum_address(
28
+ "0x83183da839ce8228e31ae41222ead9edbb5cdcf1"
29
+ )
30
+
31
+ @staticmethod
32
+ def build_market_params(
33
+ market_question: str,
34
+ outcomes: list[str],
35
+ opening_time: DatetimeUTC,
36
+ min_bond_xdai: xDai,
37
+ language: str = "en_US",
38
+ category: str = "misc",
39
+ ) -> CreateCategoricalMarketsParams:
40
+ return CreateCategoricalMarketsParams(
41
+ market_name=market_question,
42
+ token_names=[
43
+ o.upper() for o in outcomes
44
+ ], # Following usual token names on Seer (YES,NO).
45
+ min_bond=xdai_to_wei(min_bond_xdai),
46
+ opening_time=int(opening_time.timestamp()),
47
+ outcomes=outcomes,
48
+ lang=language,
49
+ category=category,
50
+ )
51
+
52
+ def market_count(self, web3: Web3 | None = None) -> int:
53
+ count: int = self.call("marketCount", web3=web3)
54
+ return count
55
+
56
+ def market_at_index(self, index: int, web3: Web3 | None = None) -> ChecksumAddress:
57
+ market_address: str = self.call("markets", function_params=[index], web3=web3)
58
+ return Web3.to_checksum_address(market_address)
59
+
60
+ def collateral_token(self, web3: Web3 | None = None) -> ChecksumAddress:
61
+ collateral_token_address: str = self.call("collateralToken", web3=web3)
62
+ return Web3.to_checksum_address(collateral_token_address)
63
+
64
+ def create_categorical_market(
65
+ self,
66
+ api_keys: APIKeys,
67
+ params: CreateCategoricalMarketsParams,
68
+ web3: Web3 | None = None,
69
+ ) -> TxReceipt:
70
+ receipt_tx = self.send(
71
+ api_keys=api_keys,
72
+ function_name="createCategoricalMarket",
73
+ function_params=[params.model_dump(by_alias=True)],
74
+ web3=web3,
75
+ )
76
+ return receipt_tx
@@ -46,6 +46,7 @@ class SeerSubgraphHandler(BaseSubgraphHandler):
46
46
  markets_field.factory,
47
47
  markets_field.creator,
48
48
  markets_field.marketName,
49
+ markets_field.parentOutcome,
49
50
  markets_field.outcomes,
50
51
  markets_field.parentMarket.id,
51
52
  markets_field.finalizeTs,
@@ -126,7 +127,7 @@ class SeerSubgraphHandler(BaseSubgraphHandler):
126
127
  ]
127
128
  return fields
128
129
 
129
- def get_pools_for_market(self, market: SeerMarket) -> list[SeerPool]:
130
+ def get_swapr_pools_for_market(self, market: SeerMarket) -> list[SeerPool]:
130
131
  # We iterate through the wrapped tokens and put them in a where clause so that we hit the subgraph endpoint just once.
131
132
  wheres = []
132
133
  for wrapped_token in market.wrapped_tokens:
@@ -378,7 +378,7 @@ def monitor_market_outcome_bias(
378
378
 
379
379
  if len(df) > 0:
380
380
  st.altair_chart(
381
- alt.layer(open_chart, resolved_chart).interactive(), # type: ignore # Doesn't expect `LayerChart`, but `Chart`, yet it works.
381
+ alt.layer(open_chart, resolved_chart).interactive(),
382
382
  use_container_width=True,
383
383
  )
384
384
 
@@ -1,5 +1,5 @@
1
1
  import typing as t
2
- from datetime import date, datetime, timedelta
2
+ from datetime import datetime, timedelta
3
3
 
4
4
  import streamlit as st
5
5
 
@@ -105,13 +105,9 @@ def monitor_app(
105
105
  start_time: DatetimeUTC | None = (
106
106
  DatetimeUTC.from_datetime(
107
107
  datetime.combine(
108
- t.cast(
109
- # This will be always a date for us, so casting.
110
- date,
111
- st.date_input(
112
- "Start time",
113
- value=utcnow() - timedelta(weeks=settings.PAST_N_WEEKS),
114
- ),
108
+ st.date_input(
109
+ "Start time",
110
+ value=utcnow() - timedelta(weeks=settings.PAST_N_WEEKS),
115
111
  ),
116
112
  datetime.min.time(),
117
113
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.57.16.dev311
3
+ Version: 0.57.17
4
4
  Summary: Tools to benchmark, deploy and monitor prediction market agents.
5
5
  Author: Gnosis
6
6
  Requires-Python: >=3.10,<3.13
@@ -16,6 +16,7 @@ prediction_market_agent_tooling/abis/omen_thumbnailmapping.abi.json,sha256=u1-3B
16
16
  prediction_market_agent_tooling/abis/ownable.abi.json,sha256=DeTy_7VmsMhFl7jwI8MIlmjy2jORauYxrGm7wC_Alxw,1528
17
17
  prediction_market_agent_tooling/abis/ownable_erc721.abi.json,sha256=9sxm588MAQmqCV_S0D3eYC7l9grbeALsd0Da_AHxdEI,8506
18
18
  prediction_market_agent_tooling/abis/proxy.abi.json,sha256=h24GXZ6Q0bSZlwh7zOv0EiDvbqUz_PHtWfKHTyPJ1w4,644
19
+ prediction_market_agent_tooling/abis/seer_market_factory.abi.json,sha256=g7RVxZVUWlTXIgTV2W6kO4twQM909Qv58zAr7Dk4XIc,13553
19
20
  prediction_market_agent_tooling/abis/simpletreasury.abi.json,sha256=7-l7rntLkcFKkoN8hXywO0-h-mUZxOZlyQg1Jk7yTB0,2877
20
21
  prediction_market_agent_tooling/benchmark/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
22
  prediction_market_agent_tooling/benchmark/agents.py,sha256=B1-uWdyeN4GGKMWGK_-CcAFJg1m9Y_XuaeIHPB29QR8,3971
@@ -34,7 +35,7 @@ prediction_market_agent_tooling/gtypes.py,sha256=G9KOKqYcxoKLv5Tfto4g5zq46FeIKxG
34
35
  prediction_market_agent_tooling/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
36
  prediction_market_agent_tooling/jobs/jobs_models.py,sha256=GOtsNm7URhzZM5fPY64r8m8Gz-sSsUhG1qmDoC7wGL8,2231
36
37
  prediction_market_agent_tooling/jobs/omen/omen_jobs.py,sha256=N0_jGDyXQeVXXlYg4oA_pOfqIjscHsLQbr0pBwFGoRo,5178
37
- prediction_market_agent_tooling/loggers.py,sha256=Am6HHXRNO545BO3l7Ue9Wb2TkYE1OK8KKhGbI3XypVU,3751
38
+ prediction_market_agent_tooling/loggers.py,sha256=MvCkQSJL2_0yErNatqr81sJlc4aOgPzDp9VNrIhKUcc,4140
38
39
  prediction_market_agent_tooling/markets/agent_market.py,sha256=W2ME57-CSAhrt8qm8-b5r7yLq-Sk7R_BZMaApvjhrUE,12901
39
40
  prediction_market_agent_tooling/markets/base_subgraph_handler.py,sha256=7RaYO_4qAmQ6ZGM8oPK2-CkiJfKmV9MxM-rJlduaecU,1971
40
41
  prediction_market_agent_tooling/markets/categorize.py,sha256=jsoHWvZk9pU6n17oWSCcCxNNYVwlb_NXsZxKRI7vmsk,1301
@@ -53,22 +54,24 @@ prediction_market_agent_tooling/markets/omen/__init__.py,sha256=47DEQpj8HBSa-_TI
53
54
  prediction_market_agent_tooling/markets/omen/data_models.py,sha256=uT8ILKrg2g4jGodPxtolPErk25buNzMYndb01ZL2dYE,28421
54
55
  prediction_market_agent_tooling/markets/omen/omen.py,sha256=w6uf_hDpVS2_9LnfmC3ZX9KZSMtXeuUvyOr1fs9nGZU,51880
55
56
  prediction_market_agent_tooling/markets/omen/omen_contracts.py,sha256=baXJwk-jSI3-FV-k239oCNOA4oKz6LT47juX8AKpW3A,28297
56
- prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256=TTi-HP_fUHKH5YTlWSBdszQFb5q3pfzXnXr1FsFu3bM,9703
57
+ prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256=E1BVDvQd1qYtCxmfC94kJtGkmQqpGPHL3zTkcs5wW6M,9697
57
58
  prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=mZ0CgKfHj0gLFq9plNpBhNqMuclb8V3qNagWfLYcpUc,38806
58
59
  prediction_market_agent_tooling/markets/polymarket/api.py,sha256=UZ4_TG8ceb9Y-qgsOKs8Qiv8zDt957QkT8IX2c83yqo,4800
59
60
  prediction_market_agent_tooling/markets/polymarket/data_models.py,sha256=Fd5PI5y3mJM8VHExBhWFWEnuuIKxQmIAXgBuoPDvNjw,4341
60
61
  prediction_market_agent_tooling/markets/polymarket/data_models_web.py,sha256=VZhVccTApygSKMmy6Au2G02JCJOKJnR_oVeKlaesuSg,12548
61
62
  prediction_market_agent_tooling/markets/polymarket/polymarket.py,sha256=NRoZK71PtH8kkangMqme7twcAXhRJSSabbmOir-UnAI,3418
62
63
  prediction_market_agent_tooling/markets/polymarket/utils.py,sha256=DImFxeMg8lTfsEDZ8FavndW38TfUsCkawcVGnucsuGo,2029
63
- prediction_market_agent_tooling/markets/seer/data_models.py,sha256=afbwmwGJXUw-F7SE3OgL4ClpXp5yHs5v1Ae7xlFgJdQ,712
64
- prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py,sha256=gVzmLhN9YQdmeYVNAwdZ4_t_bND09ioIJOmXnb8UOvo,5481
64
+ prediction_market_agent_tooling/markets/seer/data_models.py,sha256=DmxkAfusRbupqBDjohSFhsYyW7WjKZ1sQKpm8xeAMi4,2017
65
+ prediction_market_agent_tooling/markets/seer/seer.py,sha256=sPjhWdC3ri3xavD_7dnGAUFyZvPrrUOJoVXNhE8fvqM,3277
66
+ prediction_market_agent_tooling/markets/seer/seer_contracts.py,sha256=E7CYAKZiK6cg3dyj1kJuIPKSYYUft98F64shF5S0g4s,2730
67
+ prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py,sha256=KraQe4GgbdMcYnvpEJqcSHXQqgyDiC7IjkIOHAfma9s,5528
65
68
  prediction_market_agent_tooling/monitor/financial_metrics/financial_metrics.py,sha256=fjIgjDIx5MhH5mwf7S0cspLOOSU3elYLhGYoIiM26mU,2746
66
69
  prediction_market_agent_tooling/monitor/markets/manifold.py,sha256=TS4ERwTfQnot8dhekNyVNhJYf5ysYsjF-9v5_kM3aVI,3334
67
70
  prediction_market_agent_tooling/monitor/markets/metaculus.py,sha256=LOnyWWBFdg10-cTWdb76nOsNjDloO8OfMT85GBzRCFI,1455
68
71
  prediction_market_agent_tooling/monitor/markets/omen.py,sha256=EqiJYTvDbSu7fBpbrBmCuf3fc6GHr4MxWrBGa69MIyc,3305
69
72
  prediction_market_agent_tooling/monitor/markets/polymarket.py,sha256=wak8o4BYaGbLpshQD12OrsqNABdanyID6ql95lEG2io,1870
70
- prediction_market_agent_tooling/monitor/monitor.py,sha256=4kMev1iGHQiEFslEqt5bWiXAyM_Qxb4rdMVKx2H9e1U,14235
71
- prediction_market_agent_tooling/monitor/monitor_app.py,sha256=zNHSwH_KEiv8aOwvfo1JrNuSFMefpzXPWtellhnJpTI,4775
73
+ prediction_market_agent_tooling/monitor/monitor.py,sha256=4jw_1aDUoWi9kTET8usy_k5hwhANR8m522aAjHWmvMI,14161
74
+ prediction_market_agent_tooling/monitor/monitor_app.py,sha256=-_6w_ZvQ-Ad5qaeuo7NKTXUOOZ_6OrR8jMe25BGOY4k,4615
72
75
  prediction_market_agent_tooling/monitor/monitor_settings.py,sha256=Xiozs3AsufuJ04JOe1vjUri-IAMWHjjmc2ugGGiHNH4,947
73
76
  prediction_market_agent_tooling/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
77
  prediction_market_agent_tooling/tools/balances.py,sha256=PhLUKHKJR5Fx9j2EcaUzuQRnnZJM10cw70SxVdsELlI,962
@@ -109,8 +112,8 @@ prediction_market_agent_tooling/tools/tavily/tavily_search.py,sha256=Kw2mXNkMTYT
109
112
  prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
110
113
  prediction_market_agent_tooling/tools/utils.py,sha256=jLG4nbEoIzzJiZ4RgMx4Q969Zdl0p0s63p8uET_0Fuw,6440
111
114
  prediction_market_agent_tooling/tools/web3_utils.py,sha256=wqUDCed3iNrn1Wao1iwGN6tzIrhpzrTRj319wlveJEo,12275
112
- prediction_market_agent_tooling-0.57.16.dev311.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
113
- prediction_market_agent_tooling-0.57.16.dev311.dist-info/METADATA,sha256=T67P5-zqlNFVIA4QDcQbnKhFcVi1CM6L5YHZJMu_jvY,8459
114
- prediction_market_agent_tooling-0.57.16.dev311.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
115
- prediction_market_agent_tooling-0.57.16.dev311.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
116
- prediction_market_agent_tooling-0.57.16.dev311.dist-info/RECORD,,
115
+ prediction_market_agent_tooling-0.57.17.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
116
+ prediction_market_agent_tooling-0.57.17.dist-info/METADATA,sha256=4gih1dpxZvldnv0oRnp5g0e8-dhNYHxjXzKHRdIIRd8,8452
117
+ prediction_market_agent_tooling-0.57.17.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
118
+ prediction_market_agent_tooling-0.57.17.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
119
+ prediction_market_agent_tooling-0.57.17.dist-info/RECORD,,