prediction-market-agent-tooling 0.65.7__py3-none-any.whl → 0.65.10__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/swapr_router.abi.json +634 -0
  2. prediction_market_agent_tooling/benchmark/benchmark.py +1 -1
  3. prediction_market_agent_tooling/deploy/agent.py +3 -10
  4. prediction_market_agent_tooling/markets/agent_market.py +4 -0
  5. prediction_market_agent_tooling/markets/manifold/data_models.py +5 -3
  6. prediction_market_agent_tooling/markets/manifold/manifold.py +17 -1
  7. prediction_market_agent_tooling/markets/manifold/utils.py +8 -2
  8. prediction_market_agent_tooling/markets/markets.py +1 -47
  9. prediction_market_agent_tooling/markets/omen/omen.py +9 -0
  10. prediction_market_agent_tooling/markets/omen/omen_resolving.py +23 -9
  11. prediction_market_agent_tooling/markets/seer/data_models.py +19 -0
  12. prediction_market_agent_tooling/markets/seer/seer.py +96 -17
  13. prediction_market_agent_tooling/markets/seer/seer_contracts.py +40 -1
  14. prediction_market_agent_tooling/markets/seer/swap_pool_handler.py +96 -0
  15. prediction_market_agent_tooling/tools/cow/cow_order.py +151 -25
  16. prediction_market_agent_tooling/tools/cow/models.py +16 -0
  17. prediction_market_agent_tooling/tools/utils.py +10 -0
  18. prediction_market_agent_tooling/tools/web3_utils.py +10 -4
  19. {prediction_market_agent_tooling-0.65.7.dist-info → prediction_market_agent_tooling-0.65.10.dist-info}/METADATA +1 -1
  20. {prediction_market_agent_tooling-0.65.7.dist-info → prediction_market_agent_tooling-0.65.10.dist-info}/RECORD +23 -20
  21. {prediction_market_agent_tooling-0.65.7.dist-info → prediction_market_agent_tooling-0.65.10.dist-info}/LICENSE +0 -0
  22. {prediction_market_agent_tooling-0.65.7.dist-info → prediction_market_agent_tooling-0.65.10.dist-info}/WHEEL +0 -0
  23. {prediction_market_agent_tooling-0.65.7.dist-info → prediction_market_agent_tooling-0.65.10.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,634 @@
1
+ [
2
+ {
3
+ "inputs": [
4
+ {
5
+ "internalType": "address",
6
+ "name": "_factory",
7
+ "type": "address"
8
+ },
9
+ {
10
+ "internalType": "address",
11
+ "name": "_WNativeToken",
12
+ "type": "address"
13
+ },
14
+ {
15
+ "internalType": "address",
16
+ "name": "_poolDeployer",
17
+ "type": "address"
18
+ }
19
+ ],
20
+ "stateMutability": "nonpayable",
21
+ "type": "constructor"
22
+ },
23
+ {
24
+ "inputs": [],
25
+ "name": "WNativeToken",
26
+ "outputs": [
27
+ {
28
+ "internalType": "address",
29
+ "name": "",
30
+ "type": "address"
31
+ }
32
+ ],
33
+ "stateMutability": "view",
34
+ "type": "function"
35
+ },
36
+ {
37
+ "inputs": [
38
+ {
39
+ "internalType": "int256",
40
+ "name": "amount0Delta",
41
+ "type": "int256"
42
+ },
43
+ {
44
+ "internalType": "int256",
45
+ "name": "amount1Delta",
46
+ "type": "int256"
47
+ },
48
+ {
49
+ "internalType": "bytes",
50
+ "name": "_data",
51
+ "type": "bytes"
52
+ }
53
+ ],
54
+ "name": "algebraSwapCallback",
55
+ "outputs": [],
56
+ "stateMutability": "nonpayable",
57
+ "type": "function"
58
+ },
59
+ {
60
+ "inputs": [
61
+ {
62
+ "components": [
63
+ {
64
+ "internalType": "bytes",
65
+ "name": "path",
66
+ "type": "bytes"
67
+ },
68
+ {
69
+ "internalType": "address",
70
+ "name": "recipient",
71
+ "type": "address"
72
+ },
73
+ {
74
+ "internalType": "uint256",
75
+ "name": "deadline",
76
+ "type": "uint256"
77
+ },
78
+ {
79
+ "internalType": "uint256",
80
+ "name": "amountIn",
81
+ "type": "uint256"
82
+ },
83
+ {
84
+ "internalType": "uint256",
85
+ "name": "amountOutMinimum",
86
+ "type": "uint256"
87
+ }
88
+ ],
89
+ "internalType": "struct ISwapRouter.ExactInputParams",
90
+ "name": "params",
91
+ "type": "tuple"
92
+ }
93
+ ],
94
+ "name": "exactInput",
95
+ "outputs": [
96
+ {
97
+ "internalType": "uint256",
98
+ "name": "amountOut",
99
+ "type": "uint256"
100
+ }
101
+ ],
102
+ "stateMutability": "payable",
103
+ "type": "function"
104
+ },
105
+ {
106
+ "inputs": [
107
+ {
108
+ "components": [
109
+ {
110
+ "internalType": "address",
111
+ "name": "tokenIn",
112
+ "type": "address"
113
+ },
114
+ {
115
+ "internalType": "address",
116
+ "name": "tokenOut",
117
+ "type": "address"
118
+ },
119
+ {
120
+ "internalType": "address",
121
+ "name": "recipient",
122
+ "type": "address"
123
+ },
124
+ {
125
+ "internalType": "uint256",
126
+ "name": "deadline",
127
+ "type": "uint256"
128
+ },
129
+ {
130
+ "internalType": "uint256",
131
+ "name": "amountIn",
132
+ "type": "uint256"
133
+ },
134
+ {
135
+ "internalType": "uint256",
136
+ "name": "amountOutMinimum",
137
+ "type": "uint256"
138
+ },
139
+ {
140
+ "internalType": "uint160",
141
+ "name": "limitSqrtPrice",
142
+ "type": "uint160"
143
+ }
144
+ ],
145
+ "internalType": "struct ISwapRouter.ExactInputSingleParams",
146
+ "name": "params",
147
+ "type": "tuple"
148
+ }
149
+ ],
150
+ "name": "exactInputSingle",
151
+ "outputs": [
152
+ {
153
+ "internalType": "uint256",
154
+ "name": "amountOut",
155
+ "type": "uint256"
156
+ }
157
+ ],
158
+ "stateMutability": "payable",
159
+ "type": "function"
160
+ },
161
+ {
162
+ "inputs": [
163
+ {
164
+ "components": [
165
+ {
166
+ "internalType": "address",
167
+ "name": "tokenIn",
168
+ "type": "address"
169
+ },
170
+ {
171
+ "internalType": "address",
172
+ "name": "tokenOut",
173
+ "type": "address"
174
+ },
175
+ {
176
+ "internalType": "address",
177
+ "name": "recipient",
178
+ "type": "address"
179
+ },
180
+ {
181
+ "internalType": "uint256",
182
+ "name": "deadline",
183
+ "type": "uint256"
184
+ },
185
+ {
186
+ "internalType": "uint256",
187
+ "name": "amountIn",
188
+ "type": "uint256"
189
+ },
190
+ {
191
+ "internalType": "uint256",
192
+ "name": "amountOutMinimum",
193
+ "type": "uint256"
194
+ },
195
+ {
196
+ "internalType": "uint160",
197
+ "name": "limitSqrtPrice",
198
+ "type": "uint160"
199
+ }
200
+ ],
201
+ "internalType": "struct ISwapRouter.ExactInputSingleParams",
202
+ "name": "params",
203
+ "type": "tuple"
204
+ }
205
+ ],
206
+ "name": "exactInputSingleSupportingFeeOnTransferTokens",
207
+ "outputs": [
208
+ {
209
+ "internalType": "uint256",
210
+ "name": "amountOut",
211
+ "type": "uint256"
212
+ }
213
+ ],
214
+ "stateMutability": "nonpayable",
215
+ "type": "function"
216
+ },
217
+ {
218
+ "inputs": [
219
+ {
220
+ "components": [
221
+ {
222
+ "internalType": "bytes",
223
+ "name": "path",
224
+ "type": "bytes"
225
+ },
226
+ {
227
+ "internalType": "address",
228
+ "name": "recipient",
229
+ "type": "address"
230
+ },
231
+ {
232
+ "internalType": "uint256",
233
+ "name": "deadline",
234
+ "type": "uint256"
235
+ },
236
+ {
237
+ "internalType": "uint256",
238
+ "name": "amountOut",
239
+ "type": "uint256"
240
+ },
241
+ {
242
+ "internalType": "uint256",
243
+ "name": "amountInMaximum",
244
+ "type": "uint256"
245
+ }
246
+ ],
247
+ "internalType": "struct ISwapRouter.ExactOutputParams",
248
+ "name": "params",
249
+ "type": "tuple"
250
+ }
251
+ ],
252
+ "name": "exactOutput",
253
+ "outputs": [
254
+ {
255
+ "internalType": "uint256",
256
+ "name": "amountIn",
257
+ "type": "uint256"
258
+ }
259
+ ],
260
+ "stateMutability": "payable",
261
+ "type": "function"
262
+ },
263
+ {
264
+ "inputs": [
265
+ {
266
+ "components": [
267
+ {
268
+ "internalType": "address",
269
+ "name": "tokenIn",
270
+ "type": "address"
271
+ },
272
+ {
273
+ "internalType": "address",
274
+ "name": "tokenOut",
275
+ "type": "address"
276
+ },
277
+ {
278
+ "internalType": "uint24",
279
+ "name": "fee",
280
+ "type": "uint24"
281
+ },
282
+ {
283
+ "internalType": "address",
284
+ "name": "recipient",
285
+ "type": "address"
286
+ },
287
+ {
288
+ "internalType": "uint256",
289
+ "name": "deadline",
290
+ "type": "uint256"
291
+ },
292
+ {
293
+ "internalType": "uint256",
294
+ "name": "amountOut",
295
+ "type": "uint256"
296
+ },
297
+ {
298
+ "internalType": "uint256",
299
+ "name": "amountInMaximum",
300
+ "type": "uint256"
301
+ },
302
+ {
303
+ "internalType": "uint160",
304
+ "name": "limitSqrtPrice",
305
+ "type": "uint160"
306
+ }
307
+ ],
308
+ "internalType": "struct ISwapRouter.ExactOutputSingleParams",
309
+ "name": "params",
310
+ "type": "tuple"
311
+ }
312
+ ],
313
+ "name": "exactOutputSingle",
314
+ "outputs": [
315
+ {
316
+ "internalType": "uint256",
317
+ "name": "amountIn",
318
+ "type": "uint256"
319
+ }
320
+ ],
321
+ "stateMutability": "payable",
322
+ "type": "function"
323
+ },
324
+ {
325
+ "inputs": [],
326
+ "name": "factory",
327
+ "outputs": [
328
+ {
329
+ "internalType": "address",
330
+ "name": "",
331
+ "type": "address"
332
+ }
333
+ ],
334
+ "stateMutability": "view",
335
+ "type": "function"
336
+ },
337
+ {
338
+ "inputs": [
339
+ {
340
+ "internalType": "bytes[]",
341
+ "name": "data",
342
+ "type": "bytes[]"
343
+ }
344
+ ],
345
+ "name": "multicall",
346
+ "outputs": [
347
+ {
348
+ "internalType": "bytes[]",
349
+ "name": "results",
350
+ "type": "bytes[]"
351
+ }
352
+ ],
353
+ "stateMutability": "payable",
354
+ "type": "function"
355
+ },
356
+ {
357
+ "inputs": [],
358
+ "name": "poolDeployer",
359
+ "outputs": [
360
+ {
361
+ "internalType": "address",
362
+ "name": "",
363
+ "type": "address"
364
+ }
365
+ ],
366
+ "stateMutability": "view",
367
+ "type": "function"
368
+ },
369
+ {
370
+ "inputs": [],
371
+ "name": "refundNativeToken",
372
+ "outputs": [],
373
+ "stateMutability": "payable",
374
+ "type": "function"
375
+ },
376
+ {
377
+ "inputs": [
378
+ {
379
+ "internalType": "address",
380
+ "name": "token",
381
+ "type": "address"
382
+ },
383
+ {
384
+ "internalType": "uint256",
385
+ "name": "value",
386
+ "type": "uint256"
387
+ },
388
+ {
389
+ "internalType": "uint256",
390
+ "name": "deadline",
391
+ "type": "uint256"
392
+ },
393
+ {
394
+ "internalType": "uint8",
395
+ "name": "v",
396
+ "type": "uint8"
397
+ },
398
+ {
399
+ "internalType": "bytes32",
400
+ "name": "r",
401
+ "type": "bytes32"
402
+ },
403
+ {
404
+ "internalType": "bytes32",
405
+ "name": "s",
406
+ "type": "bytes32"
407
+ }
408
+ ],
409
+ "name": "selfPermit",
410
+ "outputs": [],
411
+ "stateMutability": "payable",
412
+ "type": "function"
413
+ },
414
+ {
415
+ "inputs": [
416
+ {
417
+ "internalType": "address",
418
+ "name": "token",
419
+ "type": "address"
420
+ },
421
+ {
422
+ "internalType": "uint256",
423
+ "name": "nonce",
424
+ "type": "uint256"
425
+ },
426
+ {
427
+ "internalType": "uint256",
428
+ "name": "expiry",
429
+ "type": "uint256"
430
+ },
431
+ {
432
+ "internalType": "uint8",
433
+ "name": "v",
434
+ "type": "uint8"
435
+ },
436
+ {
437
+ "internalType": "bytes32",
438
+ "name": "r",
439
+ "type": "bytes32"
440
+ },
441
+ {
442
+ "internalType": "bytes32",
443
+ "name": "s",
444
+ "type": "bytes32"
445
+ }
446
+ ],
447
+ "name": "selfPermitAllowed",
448
+ "outputs": [],
449
+ "stateMutability": "payable",
450
+ "type": "function"
451
+ },
452
+ {
453
+ "inputs": [
454
+ {
455
+ "internalType": "address",
456
+ "name": "token",
457
+ "type": "address"
458
+ },
459
+ {
460
+ "internalType": "uint256",
461
+ "name": "nonce",
462
+ "type": "uint256"
463
+ },
464
+ {
465
+ "internalType": "uint256",
466
+ "name": "expiry",
467
+ "type": "uint256"
468
+ },
469
+ {
470
+ "internalType": "uint8",
471
+ "name": "v",
472
+ "type": "uint8"
473
+ },
474
+ {
475
+ "internalType": "bytes32",
476
+ "name": "r",
477
+ "type": "bytes32"
478
+ },
479
+ {
480
+ "internalType": "bytes32",
481
+ "name": "s",
482
+ "type": "bytes32"
483
+ }
484
+ ],
485
+ "name": "selfPermitAllowedIfNecessary",
486
+ "outputs": [],
487
+ "stateMutability": "payable",
488
+ "type": "function"
489
+ },
490
+ {
491
+ "inputs": [
492
+ {
493
+ "internalType": "address",
494
+ "name": "token",
495
+ "type": "address"
496
+ },
497
+ {
498
+ "internalType": "uint256",
499
+ "name": "value",
500
+ "type": "uint256"
501
+ },
502
+ {
503
+ "internalType": "uint256",
504
+ "name": "deadline",
505
+ "type": "uint256"
506
+ },
507
+ {
508
+ "internalType": "uint8",
509
+ "name": "v",
510
+ "type": "uint8"
511
+ },
512
+ {
513
+ "internalType": "bytes32",
514
+ "name": "r",
515
+ "type": "bytes32"
516
+ },
517
+ {
518
+ "internalType": "bytes32",
519
+ "name": "s",
520
+ "type": "bytes32"
521
+ }
522
+ ],
523
+ "name": "selfPermitIfNecessary",
524
+ "outputs": [],
525
+ "stateMutability": "payable",
526
+ "type": "function"
527
+ },
528
+ {
529
+ "inputs": [
530
+ {
531
+ "internalType": "address",
532
+ "name": "token",
533
+ "type": "address"
534
+ },
535
+ {
536
+ "internalType": "uint256",
537
+ "name": "amountMinimum",
538
+ "type": "uint256"
539
+ },
540
+ {
541
+ "internalType": "address",
542
+ "name": "recipient",
543
+ "type": "address"
544
+ }
545
+ ],
546
+ "name": "sweepToken",
547
+ "outputs": [],
548
+ "stateMutability": "payable",
549
+ "type": "function"
550
+ },
551
+ {
552
+ "inputs": [
553
+ {
554
+ "internalType": "address",
555
+ "name": "token",
556
+ "type": "address"
557
+ },
558
+ {
559
+ "internalType": "uint256",
560
+ "name": "amountMinimum",
561
+ "type": "uint256"
562
+ },
563
+ {
564
+ "internalType": "address",
565
+ "name": "recipient",
566
+ "type": "address"
567
+ },
568
+ {
569
+ "internalType": "uint256",
570
+ "name": "feeBips",
571
+ "type": "uint256"
572
+ },
573
+ {
574
+ "internalType": "address",
575
+ "name": "feeRecipient",
576
+ "type": "address"
577
+ }
578
+ ],
579
+ "name": "sweepTokenWithFee",
580
+ "outputs": [],
581
+ "stateMutability": "payable",
582
+ "type": "function"
583
+ },
584
+ {
585
+ "inputs": [
586
+ {
587
+ "internalType": "uint256",
588
+ "name": "amountMinimum",
589
+ "type": "uint256"
590
+ },
591
+ {
592
+ "internalType": "address",
593
+ "name": "recipient",
594
+ "type": "address"
595
+ }
596
+ ],
597
+ "name": "unwrapWNativeToken",
598
+ "outputs": [],
599
+ "stateMutability": "payable",
600
+ "type": "function"
601
+ },
602
+ {
603
+ "inputs": [
604
+ {
605
+ "internalType": "uint256",
606
+ "name": "amountMinimum",
607
+ "type": "uint256"
608
+ },
609
+ {
610
+ "internalType": "address",
611
+ "name": "recipient",
612
+ "type": "address"
613
+ },
614
+ {
615
+ "internalType": "uint256",
616
+ "name": "feeBips",
617
+ "type": "uint256"
618
+ },
619
+ {
620
+ "internalType": "address",
621
+ "name": "feeRecipient",
622
+ "type": "address"
623
+ }
624
+ ],
625
+ "name": "unwrapWNativeTokenWithFee",
626
+ "outputs": [],
627
+ "stateMutability": "payable",
628
+ "type": "function"
629
+ },
630
+ {
631
+ "stateMutability": "payable",
632
+ "type": "receive"
633
+ }
634
+ ]
@@ -456,4 +456,4 @@ class Benchmarker:
456
456
  md += "\n\n"
457
457
  md += "### Markets\n\n"
458
458
  md += pd.DataFrame(self.get_markets_summary()).to_markdown(index=False)
459
- return md
459
+ return str(md)
@@ -33,10 +33,7 @@ from prediction_market_agent_tooling.markets.data_models import (
33
33
  ProbabilisticAnswer,
34
34
  Trade,
35
35
  )
36
- from prediction_market_agent_tooling.markets.markets import (
37
- MarketType,
38
- have_bet_on_market_since,
39
- )
36
+ from prediction_market_agent_tooling.markets.markets import MarketType
40
37
  from prediction_market_agent_tooling.markets.omen.omen import (
41
38
  send_keeping_token_to_eoa_xdai,
42
39
  )
@@ -219,7 +216,6 @@ class DeployablePredictionAgent(DeployableAgent):
219
216
  def initialize_langfuse(self) -> None:
220
217
  super().initialize_langfuse()
221
218
  # Auto-observe all the methods where it makes sense, so that subclassses don't need to do it manually.
222
- self.have_bet_on_market_since = observe()(self.have_bet_on_market_since) # type: ignore[method-assign]
223
219
  self.verify_market = observe()(self.verify_market) # type: ignore[method-assign]
224
220
  self.answer_binary_market = observe()(self.answer_binary_market) # type: ignore[method-assign]
225
221
  self.answer_categorical_market = observe()(self.answer_categorical_market) # type: ignore[method-assign]
@@ -265,16 +261,13 @@ class DeployablePredictionAgent(DeployableAgent):
265
261
  f"{api_keys=} doesn't have enough operational balance."
266
262
  )
267
263
 
268
- def have_bet_on_market_since(self, market: AgentMarket, since: timedelta) -> bool:
269
- return have_bet_on_market_since(keys=APIKeys(), market=market, since=since)
270
-
271
264
  def verify_market(self, market_type: MarketType, market: AgentMarket) -> bool:
272
265
  """
273
266
  Subclasses can implement their own logic instead of this one, or on top of this one.
274
267
  By default, it allows only markets where user didn't bet recently and it's a reasonable question.
275
268
  """
276
- if self.have_bet_on_market_since(
277
- market, since=self.same_market_trade_interval.get(market=market)
269
+ if market.have_bet_on_market_since(
270
+ keys=APIKeys(), since=self.same_market_trade_interval.get(market=market)
278
271
  ):
279
272
  logger.info(
280
273
  f"Market already bet on within {self.same_market_trade_interval}."
@@ -1,4 +1,5 @@
1
1
  import typing as t
2
+ from datetime import timedelta
2
3
  from enum import Enum
3
4
  from math import prod
4
5
 
@@ -115,6 +116,9 @@ class AgentMarket(BaseModel):
115
116
  )
116
117
  return outcome_token_pool
117
118
 
119
+ def have_bet_on_market_since(self, keys: APIKeys, since: timedelta) -> bool:
120
+ raise NotImplementedError("Subclasses must implement this method")
121
+
118
122
  def get_outcome_token_pool_by_outcome(self, outcome: OutcomeStr) -> OutcomeToken:
119
123
  if self.outcome_token_pool is None or not self.outcome_token_pool:
120
124
  return OutcomeToken(0)