prediction-market-agent-tooling 0.68.0.dev999__py3-none-any.whl → 0.68.1__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.
- prediction_market_agent_tooling/chains.py +1 -0
- prediction_market_agent_tooling/config.py +37 -2
- prediction_market_agent_tooling/deploy/agent.py +13 -19
- prediction_market_agent_tooling/deploy/betting_strategy.py +11 -3
- prediction_market_agent_tooling/jobs/jobs_models.py +2 -2
- prediction_market_agent_tooling/jobs/omen/omen_jobs.py +3 -3
- prediction_market_agent_tooling/markets/agent_market.py +16 -9
- prediction_market_agent_tooling/markets/blockchain_utils.py +3 -3
- prediction_market_agent_tooling/markets/omen/data_models.py +3 -18
- prediction_market_agent_tooling/markets/omen/omen.py +26 -11
- prediction_market_agent_tooling/markets/omen/omen_contracts.py +2 -196
- prediction_market_agent_tooling/markets/omen/omen_resolving.py +2 -2
- prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +13 -11
- prediction_market_agent_tooling/markets/polymarket/api.py +35 -1
- prediction_market_agent_tooling/markets/polymarket/clob_manager.py +156 -0
- prediction_market_agent_tooling/markets/polymarket/constants.py +15 -0
- prediction_market_agent_tooling/markets/polymarket/data_models.py +33 -5
- prediction_market_agent_tooling/markets/polymarket/polymarket.py +247 -18
- prediction_market_agent_tooling/markets/polymarket/polymarket_contracts.py +35 -0
- prediction_market_agent_tooling/markets/polymarket/polymarket_subgraph_handler.py +2 -1
- prediction_market_agent_tooling/markets/seer/data_models.py +1 -1
- prediction_market_agent_tooling/markets/seer/price_manager.py +69 -1
- prediction_market_agent_tooling/markets/seer/seer.py +35 -20
- prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py +7 -3
- prediction_market_agent_tooling/markets/seer/subgraph_data_models.py +2 -0
- prediction_market_agent_tooling/tools/contract.py +236 -4
- prediction_market_agent_tooling/tools/cow/cow_order.py +13 -8
- prediction_market_agent_tooling/tools/hexbytes_custom.py +3 -9
- prediction_market_agent_tooling/tools/tokens/auto_deposit.py +1 -1
- prediction_market_agent_tooling/tools/tokens/usd.py +5 -2
- prediction_market_agent_tooling/tools/web3_utils.py +9 -4
- {prediction_market_agent_tooling-0.68.0.dev999.dist-info → prediction_market_agent_tooling-0.68.1.dist-info}/METADATA +8 -7
- {prediction_market_agent_tooling-0.68.0.dev999.dist-info → prediction_market_agent_tooling-0.68.1.dist-info}/RECORD +36 -34
- prediction_market_agent_tooling/markets/polymarket/data_models_web.py +0 -366
- {prediction_market_agent_tooling-0.68.0.dev999.dist-info → prediction_market_agent_tooling-0.68.1.dist-info}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.68.0.dev999.dist-info → prediction_market_agent_tooling-0.68.1.dist-info}/WHEEL +0 -0
- {prediction_market_agent_tooling-0.68.0.dev999.dist-info → prediction_market_agent_tooling-0.68.1.dist-info}/entry_points.txt +0 -0
@@ -24,12 +24,12 @@ prediction_market_agent_tooling/benchmark/__init__.py,sha256=47DEQpj8HBSa-_TImW-
|
|
24
24
|
prediction_market_agent_tooling/benchmark/agents.py,sha256=zC5tUM6pPTWtqSddOOSYV_fxHYmZb5uGAb4Ru87Tah8,4221
|
25
25
|
prediction_market_agent_tooling/benchmark/benchmark.py,sha256=hpIpjjePDFTLhK841sGftFbhu8bDDZr28KO4VTneewM,17837
|
26
26
|
prediction_market_agent_tooling/benchmark/utils.py,sha256=vmVTQLER8I7MM_bHFiavrNM9aQe28PL6WihM6J-E65k,3327
|
27
|
-
prediction_market_agent_tooling/chains.py,sha256=
|
28
|
-
prediction_market_agent_tooling/config.py,sha256
|
27
|
+
prediction_market_agent_tooling/chains.py,sha256=MF600uUR_I0Mf7-Pz5InS6RWMkdrZI2sohP6Vfh0YRw,148
|
28
|
+
prediction_market_agent_tooling/config.py,sha256=juGITh2OxpH_dVe-63W4vcrRYtzldSUTT7UIjcDvAT4,13006
|
29
29
|
prediction_market_agent_tooling/data_download/langfuse_data_downloader.py,sha256=VY23h324VKIVkevj1B1O-zL1eEp9AElmcfn6SwYDUSc,14246
|
30
|
-
prediction_market_agent_tooling/deploy/agent.py,sha256=
|
30
|
+
prediction_market_agent_tooling/deploy/agent.py,sha256=LQUfP25ViMBQTqy9l_u0WsML__PsPMqjt1m1dXvW5zM,30076
|
31
31
|
prediction_market_agent_tooling/deploy/agent_example.py,sha256=yS1fWkHynr9MYGNOM2WsCnRWLPaffY4bOc6bIudrdd4,1377
|
32
|
-
prediction_market_agent_tooling/deploy/betting_strategy.py,sha256=
|
32
|
+
prediction_market_agent_tooling/deploy/betting_strategy.py,sha256=E_0P8MFBtm50OT9BCAy_ZSHW80skDPtSr-vgGZqNjDs,26584
|
33
33
|
prediction_market_agent_tooling/deploy/constants.py,sha256=iobTlZpQD6_2UL9TfoElAnBEbqzIIAKZSsAoMCGhwmA,331
|
34
34
|
prediction_market_agent_tooling/deploy/gcp/deploy.py,sha256=CYUgnfy-9XVk04kkxA_5yp0GE9Mw5caYqlFUZQ2j3ks,3739
|
35
35
|
prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py,sha256=OsPboCFGiZKsvGyntGZHwdqPlLTthITkNF5rJFvGgU8,2582
|
@@ -37,13 +37,13 @@ prediction_market_agent_tooling/deploy/gcp/utils.py,sha256=WI2ycX1X-IlTRoNoG4ggF
|
|
37
37
|
prediction_market_agent_tooling/deploy/trade_interval.py,sha256=Xk9j45alQ_vrasGvsNyuW70XHIQ7wfvjoxNR3F6HYCw,1155
|
38
38
|
prediction_market_agent_tooling/gtypes.py,sha256=bUIZfZIGvIi3aiZNu5rVE9kRevw8sfMa4bcze6QeBg8,6058
|
39
39
|
prediction_market_agent_tooling/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
40
|
-
prediction_market_agent_tooling/jobs/jobs_models.py,sha256=
|
41
|
-
prediction_market_agent_tooling/jobs/omen/omen_jobs.py,sha256=
|
40
|
+
prediction_market_agent_tooling/jobs/jobs_models.py,sha256=4KZ0iaKZx5zEZBBiEo9CHk0OpX3bKjoYA0wmptR0Wyk,2455
|
41
|
+
prediction_market_agent_tooling/jobs/omen/omen_jobs.py,sha256=DqWQTQUsS0KE97mEJNeDxRcqcEktPavqOpkXZ21Mn0M,5126
|
42
42
|
prediction_market_agent_tooling/loggers.py,sha256=o1HyvwtK1DbuC0YWQwJNqzXLLbSC41gNBkEUxiAziEg,5796
|
43
43
|
prediction_market_agent_tooling/logprobs_parser.py,sha256=DBlBQtWX8_URXhzTU3YWIPa76Zx3QDHlx1ARqbgJsVI,5008
|
44
|
-
prediction_market_agent_tooling/markets/agent_market.py,sha256=
|
44
|
+
prediction_market_agent_tooling/markets/agent_market.py,sha256=x4BW--A9gYWwd0qnBtG6D4fktnD695Ej_GYdJ_b5lqM,21501
|
45
45
|
prediction_market_agent_tooling/markets/base_subgraph_handler.py,sha256=7RaYO_4qAmQ6ZGM8oPK2-CkiJfKmV9MxM-rJlduaecU,1971
|
46
|
-
prediction_market_agent_tooling/markets/blockchain_utils.py,sha256=
|
46
|
+
prediction_market_agent_tooling/markets/blockchain_utils.py,sha256=OJp402xDbPXfks-S3iRN2ygAjjJpdasKVt6iYvQlemA,3065
|
47
47
|
prediction_market_agent_tooling/markets/categorize.py,sha256=orLZlPaHgeREU66m1amxfWikeV77idV4sZDPB8NgSD0,1300
|
48
48
|
prediction_market_agent_tooling/markets/data_models.py,sha256=f05tZuflrcfy19dqRL2f_ABVa_lzmzOrW09zxOw6s6Q,10735
|
49
49
|
prediction_market_agent_tooling/markets/manifold/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -58,25 +58,27 @@ prediction_market_agent_tooling/markets/metaculus/data_models.py,sha256=WjPt0MKe
|
|
58
58
|
prediction_market_agent_tooling/markets/metaculus/metaculus.py,sha256=kM0U0k90YfLE82ra53JAoCR9uIc9wm4B8l32hLw5imU,5312
|
59
59
|
prediction_market_agent_tooling/markets/omen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
60
60
|
prediction_market_agent_tooling/markets/omen/cow_contracts.py,sha256=sFaW82u_haL4nze8fjTmnQsOuV0OecunQlAhh1OAw0w,1091
|
61
|
-
prediction_market_agent_tooling/markets/omen/data_models.py,sha256=
|
62
|
-
prediction_market_agent_tooling/markets/omen/omen.py,sha256=
|
61
|
+
prediction_market_agent_tooling/markets/omen/data_models.py,sha256=2dXP27rvx3qkYG0qU8lrkMFQSq41fd-6HlN0SkcpIFM,30969
|
62
|
+
prediction_market_agent_tooling/markets/omen/omen.py,sha256=uigiPTGbx5bYXuXLbYMI16Y1UzLZSULtj_tpVrhD73w,52353
|
63
63
|
prediction_market_agent_tooling/markets/omen/omen_constants.py,sha256=XtRk4vpxwUYkTndfjlcmghA-NOIneV8zdHFdyI7tHhM,487
|
64
|
-
prediction_market_agent_tooling/markets/omen/omen_contracts.py,sha256=
|
65
|
-
prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256=
|
66
|
-
prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=
|
67
|
-
prediction_market_agent_tooling/markets/polymarket/api.py,sha256=
|
68
|
-
prediction_market_agent_tooling/markets/polymarket/
|
69
|
-
prediction_market_agent_tooling/markets/polymarket/
|
70
|
-
prediction_market_agent_tooling/markets/polymarket/
|
71
|
-
prediction_market_agent_tooling/markets/polymarket/
|
64
|
+
prediction_market_agent_tooling/markets/omen/omen_contracts.py,sha256=0tzaL9P9T7whcTdgK1q_XsEKK3kzCAHs-eZEh-nTZEY,24105
|
65
|
+
prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256=vVYdrL-9txufByYf3E7ApkrbVZlAGD-70STrqnhQWhg,11047
|
66
|
+
prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=bT8A1Hl-pOOIe4qz0vx_prO_5unMSG_kHIXE32txedg,40097
|
67
|
+
prediction_market_agent_tooling/markets/polymarket/api.py,sha256=62PtOJyiXywRCvW4vnj5aq8XgQXqGP04GBW7o6XNQ8Y,5755
|
68
|
+
prediction_market_agent_tooling/markets/polymarket/clob_manager.py,sha256=sCCQw5GePrfike0A4EgQRtxaqp91RDjGaVWNx_5QzH4,5367
|
69
|
+
prediction_market_agent_tooling/markets/polymarket/constants.py,sha256=-sEFwEsMSJEgLAIaeJnWFoTBsnjSW_m5iKFiFkfw2NE,457
|
70
|
+
prediction_market_agent_tooling/markets/polymarket/data_models.py,sha256=a0PJVhW3b9IoUXunCIwxHm7W4KURkaNwwQU2y9nZtuU,5836
|
71
|
+
prediction_market_agent_tooling/markets/polymarket/polymarket.py,sha256=-zAx64Mccuwp3E7oBLfdIlf9aRHNFF01GESlbDK2M4A,15746
|
72
|
+
prediction_market_agent_tooling/markets/polymarket/polymarket_contracts.py,sha256=x8yvAUPl55nbJALsQAAHJtstahhpH8WcEOj8or_QloQ,1165
|
73
|
+
prediction_market_agent_tooling/markets/polymarket/polymarket_subgraph_handler.py,sha256=2b1hVAp3tCPkmp_FFAZwy6baW7CrPhpUSGk7TlrvgtU,1631
|
72
74
|
prediction_market_agent_tooling/markets/polymarket/utils.py,sha256=A_diygWKYyp4WHbxAlAVAuC0S0ZqbEKE80wxL6mxHKQ,1275
|
73
|
-
prediction_market_agent_tooling/markets/seer/data_models.py,sha256=
|
75
|
+
prediction_market_agent_tooling/markets/seer/data_models.py,sha256=M6hCKCAHPqKGh8ST0TVvRcCbNfJ-e60jetVS49Zu87w,6687
|
74
76
|
prediction_market_agent_tooling/markets/seer/exceptions.py,sha256=cEObdjluivD94tgOLzmimR7wgQEOt6SRakrYdhsRQtk,112
|
75
|
-
prediction_market_agent_tooling/markets/seer/price_manager.py,sha256=
|
76
|
-
prediction_market_agent_tooling/markets/seer/seer.py,sha256=
|
77
|
+
prediction_market_agent_tooling/markets/seer/price_manager.py,sha256=LCfbnwOlcWn_pb5mNSqu0fYb-FKOgql19OnpItEc8wA,10007
|
78
|
+
prediction_market_agent_tooling/markets/seer/seer.py,sha256=gv3iDH9g9JSjeh2IHTmrH1qG2osINxKpHI4BN76nbb8,29319
|
77
79
|
prediction_market_agent_tooling/markets/seer/seer_contracts.py,sha256=JqfQNFSRWREPw6pQGpJoh-No5ZlKwmTiALJiAYEuvW8,5516
|
78
|
-
prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py,sha256=
|
79
|
-
prediction_market_agent_tooling/markets/seer/subgraph_data_models.py,sha256=
|
80
|
+
prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py,sha256=e-rI0JwJAGtrFmUoDZP5uFbMx3EPmUHAhk2RgQvx3u4,17269
|
81
|
+
prediction_market_agent_tooling/markets/seer/subgraph_data_models.py,sha256=VREm8bR-gPY06ODFJsaiSMinYgN64q5dC6DFckMY6oA,1831
|
80
82
|
prediction_market_agent_tooling/markets/seer/swap_pool_handler.py,sha256=k_sCEJZLroVDjOVkZ084VKJGNODLGjBGezhsWEZvlH4,3528
|
81
83
|
prediction_market_agent_tooling/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
82
84
|
prediction_market_agent_tooling/tools/_generic_value.py,sha256=pD_PI13lpPp1gFoljHwa_Lzlp-u2pu0m-Z7LcxwDM2U,10618
|
@@ -87,16 +89,16 @@ prediction_market_agent_tooling/tools/betting_strategies/utils.py,sha256=MpS3FOM
|
|
87
89
|
prediction_market_agent_tooling/tools/caches/db_cache.py,sha256=rZIGhgijquwwPtp_qncSAPR1SDF2XxIVZL1ir0fgzWw,12127
|
88
90
|
prediction_market_agent_tooling/tools/caches/inmemory_cache.py,sha256=ZW5iI5rmjqeAebu5T7ftRnlkxiL02IC-MxCfDB80x7w,1506
|
89
91
|
prediction_market_agent_tooling/tools/caches/serializers.py,sha256=vFDx4fsPxclXp2q0sv27j4al_M_Tj9aR2JJP-xNHQXA,2151
|
90
|
-
prediction_market_agent_tooling/tools/contract.py,sha256=
|
92
|
+
prediction_market_agent_tooling/tools/contract.py,sha256=Pgu3xaq7rwrilTuZCfK8HGNysQTiAG8fxEc8NrYuBiE,32073
|
91
93
|
prediction_market_agent_tooling/tools/costs.py,sha256=EaAJ7v9laD4VEV3d8B44M4u3_oEO_H16jRVCdoZ93Uw,954
|
92
|
-
prediction_market_agent_tooling/tools/cow/cow_order.py,sha256=
|
94
|
+
prediction_market_agent_tooling/tools/cow/cow_order.py,sha256=q39Kr0mSvnKjyQ4LSmMVjgNxguZiYEc9Gtk-k7sfPUg,14051
|
93
95
|
prediction_market_agent_tooling/tools/cow/models.py,sha256=Z_XUAMj5AGHZE-A92oRG0DuPeXTSyWnZRIwKQ49LaXU,709
|
94
96
|
prediction_market_agent_tooling/tools/cow/semaphore.py,sha256=IJGKRgvXnRSkEt_z1i5-eFIoVMcyhr7HK0JfIz1MXdQ,3738
|
95
97
|
prediction_market_agent_tooling/tools/custom_exceptions.py,sha256=Fh8z1fbwONvP4-j7AmV_PuEcoqb6-QXa9PJ9m7guMcM,93
|
96
98
|
prediction_market_agent_tooling/tools/datetime_utc.py,sha256=8_WackjtjC8zHXrhQFTGQ6e6Fz_6llWoKR4CSFvIv9I,2766
|
97
99
|
prediction_market_agent_tooling/tools/db/db_manager.py,sha256=GtzHH1NLl8HwqC8Z7s6eTlIQXuV0blxfaV2PeQrBnfQ,3013
|
98
100
|
prediction_market_agent_tooling/tools/google_utils.py,sha256=D-6FB2HRtmxaKZJ_Za-qj6VZCp5XU18rF4wLMMrqEUg,2557
|
99
|
-
prediction_market_agent_tooling/tools/hexbytes_custom.py,sha256=
|
101
|
+
prediction_market_agent_tooling/tools/hexbytes_custom.py,sha256=0Y1n8MChjWJmE4w6kgIJPiqbrGULui0m3TQzUBgZDHs,2206
|
100
102
|
prediction_market_agent_tooling/tools/httpx_cached_client.py,sha256=1mqOWC2-Ch2ibT63GAk0npsVR-4bR1T9WN9eU_SEhkE,634
|
101
103
|
prediction_market_agent_tooling/tools/image_gen/image_gen.py,sha256=i7ole0NMprELk-I3qJQLqFNZjiqM1w6s11IqM4Ctaqw,1349
|
102
104
|
prediction_market_agent_tooling/tools/image_gen/market_thumbnail_gen.py,sha256=ihH_ARBuHUIL7DSLYUe2osRrC_iVlzHezfspASOUu0g,1285
|
@@ -120,17 +122,17 @@ prediction_market_agent_tooling/tools/singleton.py,sha256=CHpUJuu89Hwup2fH9CIChU
|
|
120
122
|
prediction_market_agent_tooling/tools/streamlit_user_login.py,sha256=NXEqfjT9Lc9QtliwSGRASIz1opjQ7Btme43H4qJbzgE,3010
|
121
123
|
prediction_market_agent_tooling/tools/tavily/tavily_models.py,sha256=5ldQs1pZe6uJ5eDAuP4OLpzmcqYShlIV67kttNFvGS0,342
|
122
124
|
prediction_market_agent_tooling/tools/tavily/tavily_search.py,sha256=pPs0qZNfJ7G-1ajfz0iaWOBQyiC0TbcShfrW8T39jtg,3859
|
123
|
-
prediction_market_agent_tooling/tools/tokens/auto_deposit.py,sha256
|
125
|
+
prediction_market_agent_tooling/tools/tokens/auto_deposit.py,sha256=ccpDCYueObaaoBS66d3P-xprJg7FFZREdx-6oRbuKm8,9183
|
124
126
|
prediction_market_agent_tooling/tools/tokens/auto_withdraw.py,sha256=HYLSI_MincuyRGSrSJTuf0cHMcdnyQPrXOUW3o2quBk,2811
|
125
127
|
prediction_market_agent_tooling/tools/tokens/main_token.py,sha256=1rbwpdCusPgQIVFuo3m00nBZ_b2lCAoFVm67i-YDcEw,812
|
126
128
|
prediction_market_agent_tooling/tools/tokens/slippage.py,sha256=ByBssRY6fBjLdxPx5bpudYfs-Z4gUa8CyOGuLDd5tQk,639
|
127
129
|
prediction_market_agent_tooling/tools/tokens/token_utils.py,sha256=fhs-FH9m9IbzGa-30R3ZleSKLeKfLEDoJ7F5Om285Vk,1369
|
128
|
-
prediction_market_agent_tooling/tools/tokens/usd.py,sha256=
|
130
|
+
prediction_market_agent_tooling/tools/tokens/usd.py,sha256=DPO-4HBTy1-TZHKL_9CnHQ8p9W7ivPfcRlUkRO0nKJ8,3259
|
129
131
|
prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
|
130
132
|
prediction_market_agent_tooling/tools/utils.py,sha256=mbOGoWKalNIm7M2K51TEPGwU9oVp1Z6SPsFaBgbn6ws,7397
|
131
|
-
prediction_market_agent_tooling/tools/web3_utils.py,sha256=
|
132
|
-
prediction_market_agent_tooling-0.68.
|
133
|
-
prediction_market_agent_tooling-0.68.
|
134
|
-
prediction_market_agent_tooling-0.68.
|
135
|
-
prediction_market_agent_tooling-0.68.
|
136
|
-
prediction_market_agent_tooling-0.68.
|
133
|
+
prediction_market_agent_tooling/tools/web3_utils.py,sha256=ajHZIBM_PNNNUp0ZxJ-AvpSzyVATm7LnZtb2hi6NcOw,12614
|
134
|
+
prediction_market_agent_tooling-0.68.1.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
|
135
|
+
prediction_market_agent_tooling-0.68.1.dist-info/METADATA,sha256=xViLluiOrvDpEF2wBMDodVyGSTS9auN_vTBosi8reos,8805
|
136
|
+
prediction_market_agent_tooling-0.68.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
137
|
+
prediction_market_agent_tooling-0.68.1.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
|
138
|
+
prediction_market_agent_tooling-0.68.1.dist-info/RECORD,,
|
@@ -1,366 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
Autogenerated using `datamodel-codegen` from a single Polymarket response. Then adjusted, fixed.
|
3
|
-
Keep in mind that not all fields were used so far, so there might be some bugs.
|
4
|
-
|
5
|
-
These models are based on what Polymarket's website returns in the response, and `prediction_market_agent_tooling/markets/polymarket/data_models.py` are based on what their API returns.
|
6
|
-
"""
|
7
|
-
|
8
|
-
import typing as t
|
9
|
-
|
10
|
-
from pydantic import BaseModel, field_validator
|
11
|
-
|
12
|
-
from prediction_market_agent_tooling.gtypes import USDC, HexAddress, OutcomeStr
|
13
|
-
from prediction_market_agent_tooling.markets.data_models import Resolution
|
14
|
-
from prediction_market_agent_tooling.tools.utils import DatetimeUTC
|
15
|
-
|
16
|
-
POLYMARKET_BASE_URL = "https://polymarket.com"
|
17
|
-
POLYMARKET_TRUE_OUTCOME = "Yes"
|
18
|
-
POLYMARKET_FALSE_OUTCOME = "No"
|
19
|
-
|
20
|
-
|
21
|
-
class ImageOptimized(BaseModel):
|
22
|
-
imageUrlOptimized: str
|
23
|
-
|
24
|
-
|
25
|
-
class IconOptimized(BaseModel):
|
26
|
-
imageUrlOptimized: str
|
27
|
-
|
28
|
-
|
29
|
-
class Event(BaseModel):
|
30
|
-
id: str
|
31
|
-
slug: str
|
32
|
-
ticker: str
|
33
|
-
title: str
|
34
|
-
series: t.Any | None = None
|
35
|
-
|
36
|
-
|
37
|
-
class Event1(BaseModel):
|
38
|
-
startDate: DatetimeUTC | None = None
|
39
|
-
slug: str
|
40
|
-
|
41
|
-
|
42
|
-
class Market1(BaseModel):
|
43
|
-
slug: str
|
44
|
-
question: str
|
45
|
-
image: str
|
46
|
-
volume: USDC | None = None
|
47
|
-
outcomes: t.Sequence[OutcomeStr]
|
48
|
-
outcomePrices: list[USDC]
|
49
|
-
active: bool
|
50
|
-
archived: bool
|
51
|
-
closed: bool
|
52
|
-
orderPriceMinTickSize: USDC
|
53
|
-
clobTokenIds: str
|
54
|
-
events: list[Event1] | None = None
|
55
|
-
|
56
|
-
|
57
|
-
class ResolutionData(BaseModel):
|
58
|
-
id: str
|
59
|
-
author: str
|
60
|
-
lastUpdateTimestamp: int
|
61
|
-
status: str
|
62
|
-
wasDisputed: bool
|
63
|
-
price: str
|
64
|
-
proposedPrice: str
|
65
|
-
reproposedPrice: str
|
66
|
-
updates: str
|
67
|
-
newVersionQ: bool
|
68
|
-
transactionHash: str
|
69
|
-
logIndex: str
|
70
|
-
|
71
|
-
|
72
|
-
class Market(BaseModel):
|
73
|
-
id: str
|
74
|
-
question: str
|
75
|
-
conditionId: str
|
76
|
-
slug: str
|
77
|
-
twitterCardImage: t.Any | None = None
|
78
|
-
resolutionSource: str | None = None
|
79
|
-
endDate: DatetimeUTC
|
80
|
-
category: t.Any | None = None
|
81
|
-
ammType: t.Any | None = None
|
82
|
-
description: str
|
83
|
-
liquidity: str | None = None
|
84
|
-
startDate: DatetimeUTC | None = None
|
85
|
-
createdAt: DatetimeUTC
|
86
|
-
xAxisValue: t.Any | None = None
|
87
|
-
yAxisValue: t.Any | None = None
|
88
|
-
denominationToken: t.Any | None = None
|
89
|
-
fee: str | None = None
|
90
|
-
lowerBound: t.Any | None = None
|
91
|
-
upperBound: t.Any | None = None
|
92
|
-
outcomes: t.Sequence[OutcomeStr]
|
93
|
-
image: str | None = None
|
94
|
-
icon: str | None = None
|
95
|
-
imageOptimized: t.Any | None = None
|
96
|
-
iconOptimized: t.Any | None = None
|
97
|
-
outcomePrices: list[USDC]
|
98
|
-
volume: USDC | None = None
|
99
|
-
active: bool
|
100
|
-
marketType: str | None = None
|
101
|
-
formatType: t.Any | None = None
|
102
|
-
lowerBoundDate: t.Any | None = None
|
103
|
-
upperBoundDate: t.Any | None = None
|
104
|
-
closed: bool
|
105
|
-
marketMakerAddress: HexAddress
|
106
|
-
closedTime: DatetimeUTC | None = None
|
107
|
-
wideFormat: bool | None = None
|
108
|
-
new: bool | None = None
|
109
|
-
sentDiscord: t.Any | None = None
|
110
|
-
mailchimpTag: t.Any | None = None
|
111
|
-
featured: bool | None = None
|
112
|
-
submitted_by: str | None = None
|
113
|
-
subcategory: t.Any | None = None
|
114
|
-
categoryMailchimpTag: t.Any | None = None
|
115
|
-
archived: bool | None = None
|
116
|
-
resolvedBy: str | None = None
|
117
|
-
restricted: bool | None = None
|
118
|
-
groupItemTitle: str | None = None
|
119
|
-
groupItemThreshold: str | None = None
|
120
|
-
questionID: str | None = None
|
121
|
-
umaEndDate: t.Any | None = None
|
122
|
-
enableOrderBook: bool | None = None
|
123
|
-
orderPriceMinTickSize: float | None = None
|
124
|
-
orderMinSize: int | None = None
|
125
|
-
umaResolutionStatus: t.Any | None = None
|
126
|
-
curationOrder: t.Any | None = None
|
127
|
-
volumeNum: USDC | None = None
|
128
|
-
liquidityNum: float | None = None
|
129
|
-
endDateIso: DatetimeUTC | None = None
|
130
|
-
startDateIso: DatetimeUTC | None = None
|
131
|
-
umaEndDateIso: DatetimeUTC | None = None
|
132
|
-
commentsEnabled: bool | None = None
|
133
|
-
disqusThread: t.Any | None = None
|
134
|
-
gameStartTime: t.Any | None = None
|
135
|
-
secondsDelay: int | None = None
|
136
|
-
clobTokenIds: list[str] | None = None
|
137
|
-
liquidityAmm: float | None = None
|
138
|
-
liquidityClob: float | None = None
|
139
|
-
makerBaseFee: int | None = None
|
140
|
-
takerBaseFee: int | None = None
|
141
|
-
negRisk: t.Any | None = None
|
142
|
-
negRiskRequestID: t.Any | None = None
|
143
|
-
negRiskMarketID: t.Any | None = None
|
144
|
-
events: list[Event] | None = None
|
145
|
-
markets: list[Market1] | None = None
|
146
|
-
lower_bound_date: t.Any | None = None
|
147
|
-
upper_bound_date: t.Any | None = None
|
148
|
-
market_type: str | None = None
|
149
|
-
resolution_source: str | None = None
|
150
|
-
end_date: str | None = None
|
151
|
-
amm_type: t.Any | None = None
|
152
|
-
x_axis_value: t.Any | None = None
|
153
|
-
y_axis_value: t.Any | None = None
|
154
|
-
denomination_token: t.Any | None = None
|
155
|
-
resolved_by: str | None = None
|
156
|
-
upper_bound: t.Any | None = None
|
157
|
-
lower_bound: t.Any | None = None
|
158
|
-
created_at: str | None = None
|
159
|
-
updated_at: t.Any | None = None
|
160
|
-
closed_time: t.Any | None = None
|
161
|
-
wide_format: bool | None = None
|
162
|
-
volume_num: USDC | None = None
|
163
|
-
liquidity_num: USDC | None = None
|
164
|
-
image_raw: str | None = None
|
165
|
-
resolutionData: ResolutionData
|
166
|
-
|
167
|
-
@field_validator("closedTime", mode="before")
|
168
|
-
def field_validator_closedTime(cls, v: str | None = None) -> str | None:
|
169
|
-
return v.replace("+00", "") if v else None
|
170
|
-
|
171
|
-
@property
|
172
|
-
def resolution(self) -> Resolution | None:
|
173
|
-
# If the market is not closed, it doesn't have a resolution.
|
174
|
-
if not self.closed:
|
175
|
-
return None
|
176
|
-
|
177
|
-
outcome_to_outcome_price: dict[str, USDC] = dict(
|
178
|
-
zip(self.outcomes, self.outcomePrices)
|
179
|
-
)
|
180
|
-
|
181
|
-
# On Polymarket, we can find out binary market resolution by checking for the outcome prices.
|
182
|
-
# E.g. if `Yes` price (probability) is 1$ and `No` price (probability) is 0$, it means the resolution is `Yes`.
|
183
|
-
if (
|
184
|
-
outcome_to_outcome_price[POLYMARKET_TRUE_OUTCOME] == 1.0
|
185
|
-
and outcome_to_outcome_price[POLYMARKET_FALSE_OUTCOME] == 0.0
|
186
|
-
):
|
187
|
-
return Resolution(
|
188
|
-
outcome=OutcomeStr(POLYMARKET_TRUE_OUTCOME), invalid=False
|
189
|
-
)
|
190
|
-
|
191
|
-
elif (
|
192
|
-
outcome_to_outcome_price[POLYMARKET_TRUE_OUTCOME] == 0.0
|
193
|
-
and outcome_to_outcome_price[POLYMARKET_FALSE_OUTCOME] == 1.0
|
194
|
-
):
|
195
|
-
return Resolution(
|
196
|
-
outcome=OutcomeStr(POLYMARKET_FALSE_OUTCOME), invalid=False
|
197
|
-
)
|
198
|
-
|
199
|
-
else:
|
200
|
-
raise ValueError(
|
201
|
-
f"Unexpected outcome prices {outcome_to_outcome_price} or outcomes {self.outcomes}, please debug."
|
202
|
-
)
|
203
|
-
|
204
|
-
|
205
|
-
class Category(BaseModel):
|
206
|
-
id: str
|
207
|
-
label: str
|
208
|
-
parentCategory: str
|
209
|
-
slug: str
|
210
|
-
|
211
|
-
|
212
|
-
class Bid(BaseModel):
|
213
|
-
price: str
|
214
|
-
size: str
|
215
|
-
|
216
|
-
|
217
|
-
class Ask(BaseModel):
|
218
|
-
price: str
|
219
|
-
size: str
|
220
|
-
|
221
|
-
|
222
|
-
class MarketBidsAndAsks(BaseModel):
|
223
|
-
market: str
|
224
|
-
asset_id: str
|
225
|
-
hash: str
|
226
|
-
bids: list[Bid]
|
227
|
-
asks: list[Ask]
|
228
|
-
lastUpdated: int
|
229
|
-
|
230
|
-
|
231
|
-
class PolymarketFullMarket(BaseModel):
|
232
|
-
id: str
|
233
|
-
ticker: str
|
234
|
-
slug: str
|
235
|
-
title: str
|
236
|
-
subtitle: t.Any | None = None
|
237
|
-
description: str
|
238
|
-
commentCount: int | None = None
|
239
|
-
resolutionSource: str | None = None
|
240
|
-
startDate: DatetimeUTC | None = None
|
241
|
-
endDate: DatetimeUTC
|
242
|
-
image: str | None = None
|
243
|
-
icon: str | None = None
|
244
|
-
featuredImage: str | None = None
|
245
|
-
active: bool
|
246
|
-
closed: bool
|
247
|
-
archived: bool | None = None
|
248
|
-
new: bool | None = None
|
249
|
-
featured: bool | None = None
|
250
|
-
restricted: bool | None = None
|
251
|
-
liquidity: USDC | None = None
|
252
|
-
volume: USDC | None = None
|
253
|
-
volume24hr: USDC | None = None
|
254
|
-
competitive: float | None = None
|
255
|
-
openInterest: int | None = None
|
256
|
-
sortBy: str | None = None
|
257
|
-
createdAt: DatetimeUTC
|
258
|
-
commentsEnabled: bool | None = None
|
259
|
-
disqusThread: t.Any | None = None
|
260
|
-
updatedAt: DatetimeUTC
|
261
|
-
enableOrderBook: bool | None = None
|
262
|
-
liquidityAmm: float | None = None
|
263
|
-
liquidityClob: float | None = None
|
264
|
-
imageOptimized: ImageOptimized | None = None
|
265
|
-
iconOptimized: IconOptimized | None = None
|
266
|
-
featuredImageOptimized: str | None = None
|
267
|
-
negRisk: t.Any | None = None
|
268
|
-
negRiskMarketID: t.Any | None = None
|
269
|
-
negRiskFeeBips: t.Any | None = None
|
270
|
-
markets: list[Market]
|
271
|
-
categories: list[Category] | None = None
|
272
|
-
series: t.Any | None = None
|
273
|
-
image_raw: str | None = None
|
274
|
-
|
275
|
-
@property
|
276
|
-
def url(self) -> str:
|
277
|
-
return construct_polymarket_url(self.slug)
|
278
|
-
|
279
|
-
@property
|
280
|
-
def is_main_market(self) -> bool:
|
281
|
-
# On Polymarket, there are markets that are actually a group of multiple Yes/No markets, for example https://polymarket.com/event/presidential-election-winner-2024.
|
282
|
-
# But if there is only 1 market in this list, it should mean it's a "main market", e.g. with only one question.
|
283
|
-
return len(self.markets) == 1
|
284
|
-
|
285
|
-
@property
|
286
|
-
def main_market(self) -> Market:
|
287
|
-
if not self.is_main_market:
|
288
|
-
raise ValueError(
|
289
|
-
f"Unexpected number of markets in the Polymarket's response, shouldn't happen if you used `is_main_market` filter, please debug: {self.id=}, {self.title=}"
|
290
|
-
)
|
291
|
-
return self.markets[0]
|
292
|
-
|
293
|
-
|
294
|
-
class PriceSide(BaseModel):
|
295
|
-
price: USDC
|
296
|
-
side: t.Literal["BUY", "SELL"]
|
297
|
-
|
298
|
-
|
299
|
-
class State(BaseModel):
|
300
|
-
data: (
|
301
|
-
PolymarketFullMarket
|
302
|
-
| MarketBidsAndAsks
|
303
|
-
| PriceSide
|
304
|
-
| dict[str, MarketBidsAndAsks]
|
305
|
-
| dict[str, PriceSide]
|
306
|
-
| None
|
307
|
-
# It's none if you go to the website and it says "Oops...we didn't forecast this".
|
308
|
-
)
|
309
|
-
dataUpdateCount: int
|
310
|
-
dataUpdatedAt: int
|
311
|
-
error: t.Any | None = None
|
312
|
-
errorUpdateCount: int
|
313
|
-
errorUpdatedAt: int
|
314
|
-
fetchFailureCount: int
|
315
|
-
fetchFailureReason: t.Any | None = None
|
316
|
-
fetchMeta: t.Any | None = None
|
317
|
-
isInvalidated: bool
|
318
|
-
status: str
|
319
|
-
fetchStatus: str
|
320
|
-
|
321
|
-
|
322
|
-
class Query(BaseModel):
|
323
|
-
state: State
|
324
|
-
queryKey: list[str]
|
325
|
-
queryHash: str
|
326
|
-
|
327
|
-
|
328
|
-
class DehydratedState(BaseModel):
|
329
|
-
mutations: list[t.Any]
|
330
|
-
queries: list[Query]
|
331
|
-
|
332
|
-
|
333
|
-
class PageProps(BaseModel):
|
334
|
-
key: str
|
335
|
-
dehydratedState: DehydratedState
|
336
|
-
eslug: str
|
337
|
-
mslug: str | None = None
|
338
|
-
isSingleMarket: bool
|
339
|
-
|
340
|
-
|
341
|
-
class Props(BaseModel):
|
342
|
-
pageProps: PageProps
|
343
|
-
|
344
|
-
|
345
|
-
class Query1(BaseModel):
|
346
|
-
slug: list[str]
|
347
|
-
|
348
|
-
|
349
|
-
class PolymarketWebResponse(BaseModel):
|
350
|
-
props: Props
|
351
|
-
page: str
|
352
|
-
query: Query1
|
353
|
-
buildId: str
|
354
|
-
isFallback: bool
|
355
|
-
gsp: bool
|
356
|
-
locale: str
|
357
|
-
locales: list[str]
|
358
|
-
defaultLocale: str
|
359
|
-
scriptLoader: list[t.Any]
|
360
|
-
|
361
|
-
|
362
|
-
def construct_polymarket_url(slug: str) -> str:
|
363
|
-
"""
|
364
|
-
Note: This works only if it's a single main market, not sub-market of some more general question.
|
365
|
-
"""
|
366
|
-
return f"{POLYMARKET_BASE_URL}/event/{slug}"
|
File without changes
|
File without changes
|