prediction-market-agent-tooling 0.57.16.dev311__py3-none-any.whl → 0.57.18__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.
Files changed (23) hide show
  1. prediction_market_agent_tooling/abis/seer_market_factory.abi.json +609 -0
  2. prediction_market_agent_tooling/config.py +8 -0
  3. prediction_market_agent_tooling/loggers.py +9 -1
  4. prediction_market_agent_tooling/markets/omen/omen.py +12 -16
  5. prediction_market_agent_tooling/markets/omen/omen_constants.py +8 -0
  6. prediction_market_agent_tooling/markets/omen/omen_contracts.py +16 -4
  7. prediction_market_agent_tooling/markets/omen/omen_resolving.py +3 -3
  8. prediction_market_agent_tooling/markets/seer/data_models.py +41 -2
  9. prediction_market_agent_tooling/markets/seer/seer.py +94 -0
  10. prediction_market_agent_tooling/markets/seer/seer_contracts.py +76 -0
  11. prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py +2 -1
  12. prediction_market_agent_tooling/monitor/monitor.py +1 -1
  13. prediction_market_agent_tooling/monitor/monitor_app.py +4 -8
  14. prediction_market_agent_tooling/tools/contract.py +1 -98
  15. prediction_market_agent_tooling/tools/cow/cow_order.py +133 -0
  16. prediction_market_agent_tooling/tools/tokens/auto_deposit.py +156 -0
  17. prediction_market_agent_tooling/tools/tokens/auto_withdraw.py +62 -0
  18. prediction_market_agent_tooling/tools/tokens/main_token.py +13 -0
  19. {prediction_market_agent_tooling-0.57.16.dev311.dist-info → prediction_market_agent_tooling-0.57.18.dist-info}/METADATA +3 -1
  20. {prediction_market_agent_tooling-0.57.16.dev311.dist-info → prediction_market_agent_tooling-0.57.18.dist-info}/RECORD +23 -15
  21. {prediction_market_agent_tooling-0.57.16.dev311.dist-info → prediction_market_agent_tooling-0.57.18.dist-info}/LICENSE +0 -0
  22. {prediction_market_agent_tooling-0.57.16.dev311.dist-info → prediction_market_agent_tooling-0.57.18.dist-info}/WHEEL +0 -0
  23. {prediction_market_agent_tooling-0.57.16.dev311.dist-info → prediction_market_agent_tooling-0.57.18.dist-info}/entry_points.txt +0 -0
@@ -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
+ ]
@@ -1,11 +1,13 @@
1
1
  import typing as t
2
2
 
3
+ from eth_account.signers.local import LocalAccount
3
4
  from pydantic import Field
4
5
  from pydantic.types import SecretStr
5
6
  from pydantic.v1.types import SecretStr as SecretStrV1
6
7
  from pydantic_settings import BaseSettings, SettingsConfigDict
7
8
  from safe_eth.eth import EthereumClient
8
9
  from safe_eth.safe.safe import SafeV141
10
+ from web3 import Account
9
11
 
10
12
  from prediction_market_agent_tooling.gtypes import (
11
13
  ChainID,
@@ -184,6 +186,12 @@ class APIKeys(BaseSettings):
184
186
  self.SQLALCHEMY_DB_URL, "SQLALCHEMY_DB_URL missing in the environment."
185
187
  )
186
188
 
189
+ def get_account(self) -> LocalAccount:
190
+ acc: LocalAccount = Account.from_key(
191
+ self.bet_from_private_key.get_secret_value()
192
+ )
193
+ return acc
194
+
187
195
  def model_dump_public(self) -> dict[str, t.Any]:
188
196
  return {
189
197
  k: v
@@ -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()
@@ -69,15 +69,18 @@ from prediction_market_agent_tooling.markets.omen.omen_subgraph_handler import (
69
69
  )
70
70
  from prediction_market_agent_tooling.tools.balances import get_balances
71
71
  from prediction_market_agent_tooling.tools.contract import (
72
- ContractDepositableWrapperERC20BaseClass,
73
- ContractERC4626BaseClass,
74
- auto_deposit_collateral_token,
75
72
  init_collateral_token_contract,
76
73
  to_gnosis_chain_contract,
77
74
  )
78
75
  from prediction_market_agent_tooling.tools.custom_exceptions import OutOfFundsError
79
76
  from prediction_market_agent_tooling.tools.hexbytes_custom import HexBytes
80
77
  from prediction_market_agent_tooling.tools.ipfs.ipfs_handler import IPFSHandler
78
+ from prediction_market_agent_tooling.tools.tokens.auto_deposit import (
79
+ auto_deposit_collateral_token,
80
+ )
81
+ from prediction_market_agent_tooling.tools.tokens.auto_withdraw import (
82
+ auto_withdraw_collateral_token,
83
+ )
81
84
  from prediction_market_agent_tooling.tools.utils import (
82
85
  BPS_CONSTANT,
83
86
  DatetimeUTC,
@@ -901,19 +904,12 @@ def omen_sell_outcome_tx(
901
904
  max_outcome_tokens_to_sell,
902
905
  web3=web3,
903
906
  )
904
- if auto_withdraw and (
905
- isinstance(collateral_token_contract, ContractERC4626BaseClass)
906
- or isinstance(
907
- collateral_token_contract, ContractDepositableWrapperERC20BaseClass
908
- )
909
- ):
910
- collateral_token_contract.withdraw(
911
- api_keys,
912
- remove_fraction(
913
- amount_wei,
914
- 0.001, # Allow 0.1% slippage.
915
- ),
916
- web3,
907
+ if auto_withdraw:
908
+ auto_withdraw_collateral_token(
909
+ collateral_token_contract=collateral_token_contract,
910
+ amount_wei=amount_wei,
911
+ api_keys=api_keys,
912
+ web3=web3,
917
913
  )
918
914
 
919
915
  return tx_receipt["transactionHash"].hex()