prediction-market-agent-tooling 0.39.3__py3-none-any.whl → 0.39.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- prediction_market_agent_tooling/markets/data_models.py +2 -1
- prediction_market_agent_tooling/markets/manifold/data_models.py +1 -1
- prediction_market_agent_tooling/markets/omen/omen_contracts.py +6 -2
- prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +40 -1
- {prediction_market_agent_tooling-0.39.3.dist-info → prediction_market_agent_tooling-0.39.5.dist-info}/METADATA +1 -1
- {prediction_market_agent_tooling-0.39.3.dist-info → prediction_market_agent_tooling-0.39.5.dist-info}/RECORD +9 -9
- {prediction_market_agent_tooling-0.39.3.dist-info → prediction_market_agent_tooling-0.39.5.dist-info}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.39.3.dist-info → prediction_market_agent_tooling-0.39.5.dist-info}/WHEEL +0 -0
- {prediction_market_agent_tooling-0.39.3.dist-info → prediction_market_agent_tooling-0.39.5.dist-info}/entry_points.txt +0 -0
@@ -2,7 +2,7 @@ from datetime import datetime
|
|
2
2
|
from enum import Enum
|
3
3
|
from typing import TypeAlias
|
4
4
|
|
5
|
-
from pydantic import BaseModel
|
5
|
+
from pydantic import BaseModel, computed_field
|
6
6
|
|
7
7
|
from prediction_market_agent_tooling.gtypes import OutcomeStr
|
8
8
|
|
@@ -41,6 +41,7 @@ class ResolvedBet(Bet):
|
|
41
41
|
resolved_time: datetime
|
42
42
|
profit: ProfitAmount
|
43
43
|
|
44
|
+
@computed_field # type: ignore[misc]
|
44
45
|
@property
|
45
46
|
def is_correct(self) -> bool:
|
46
47
|
return self.outcome == self.market_outcome
|
@@ -150,7 +150,7 @@ class ManifoldBet(BaseModel):
|
|
150
150
|
id: str
|
151
151
|
fees: ManifoldBetFees
|
152
152
|
isCancelled: t.Optional[bool] = None
|
153
|
-
loanAmount: Mana
|
153
|
+
loanAmount: Mana | None
|
154
154
|
orderAmount: t.Optional[Mana] = None
|
155
155
|
fills: t.Optional[list[ManifoldBetFills]] = None
|
156
156
|
createdTime: datetime
|
@@ -627,9 +627,13 @@ class OmenThumbnailMapping(ContractOnGnosisChain):
|
|
627
627
|
)
|
628
628
|
)
|
629
629
|
address: ChecksumAddress = Web3.to_checksum_address(
|
630
|
-
"
|
630
|
+
"0xe0cf08311F03850497B0ed6A2cf067f1750C3eFc"
|
631
631
|
)
|
632
632
|
|
633
|
+
@staticmethod
|
634
|
+
def construct_ipfs_url(ipfs_hash: IPFSCIDVersion0) -> str:
|
635
|
+
return f"https://ipfs.io/ipfs/{ipfs_hash}"
|
636
|
+
|
633
637
|
def get(
|
634
638
|
self,
|
635
639
|
market_address: ChecksumAddress,
|
@@ -646,7 +650,7 @@ class OmenThumbnailMapping(ContractOnGnosisChain):
|
|
646
650
|
web3: Web3 | None = None,
|
647
651
|
) -> str | None:
|
648
652
|
hash_ = self.get(market_address, web3)
|
649
|
-
return
|
653
|
+
return self.construct_ipfs_url(hash_) if hash_ is not None else None
|
650
654
|
|
651
655
|
def set(
|
652
656
|
self,
|
@@ -2,8 +2,11 @@ import sys
|
|
2
2
|
import typing as t
|
3
3
|
from datetime import datetime
|
4
4
|
|
5
|
+
import requests
|
5
6
|
import tenacity
|
6
7
|
from eth_typing import ChecksumAddress
|
8
|
+
from PIL import Image
|
9
|
+
from PIL.Image import Image as ImageType
|
7
10
|
from subgrounds import FieldPath, Subgrounds
|
8
11
|
|
9
12
|
from prediction_market_agent_tooling.config import APIKeys
|
@@ -20,9 +23,15 @@ from prediction_market_agent_tooling.markets.omen.data_models import (
|
|
20
23
|
RealityAnswer,
|
21
24
|
RealityQuestion,
|
22
25
|
)
|
26
|
+
from prediction_market_agent_tooling.markets.omen.omen_contracts import (
|
27
|
+
OmenThumbnailMapping,
|
28
|
+
)
|
23
29
|
from prediction_market_agent_tooling.tools.singleton import SingletonMeta
|
24
30
|
from prediction_market_agent_tooling.tools.utils import to_int_timestamp, utcnow
|
25
|
-
from prediction_market_agent_tooling.tools.web3_utils import
|
31
|
+
from prediction_market_agent_tooling.tools.web3_utils import (
|
32
|
+
ZERO_BYTES,
|
33
|
+
byte32_to_ipfscidv0,
|
34
|
+
)
|
26
35
|
|
27
36
|
|
28
37
|
class OmenSubgraphHandler(metaclass=SingletonMeta):
|
@@ -36,6 +45,11 @@ class OmenSubgraphHandler(metaclass=SingletonMeta):
|
|
36
45
|
|
37
46
|
REALITYETH_GRAPH_URL = "https://gateway-arbitrum.network.thegraph.com/api/{graph_api_key}/subgraphs/id/E7ymrCnNcQdAAgLbdFWzGE5mvr5Mb5T9VfT43FqA7bNh"
|
38
47
|
|
48
|
+
# TODO: Switch to arbitrum subgraph once it's published.
|
49
|
+
OMEN_IMAGE_MAPPING_GRAPH_URL = (
|
50
|
+
"https://api.studio.thegraph.com/query/63564/omen-thumbnailmapping/v0.0.3"
|
51
|
+
)
|
52
|
+
|
39
53
|
INVALID_ANSWER = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
|
40
54
|
|
41
55
|
def __init__(self) -> None:
|
@@ -66,6 +80,11 @@ class OmenSubgraphHandler(metaclass=SingletonMeta):
|
|
66
80
|
graph_api_key=keys.graph_api_key.get_secret_value()
|
67
81
|
)
|
68
82
|
)
|
83
|
+
self.omen_image_mapping_subgraph = self.sg.load_subgraph(
|
84
|
+
self.OMEN_IMAGE_MAPPING_GRAPH_URL.format(
|
85
|
+
graph_api_key=keys.graph_api_key.get_secret_value()
|
86
|
+
)
|
87
|
+
)
|
69
88
|
|
70
89
|
def _get_fields_for_bets(self, bets_field: FieldPath) -> list[FieldPath]:
|
71
90
|
markets = bets_field.fpmm
|
@@ -609,3 +628,23 @@ class OmenSubgraphHandler(metaclass=SingletonMeta):
|
|
609
628
|
f"Incorrect number of markets fetched {len(markets)}, expected 1."
|
610
629
|
)
|
611
630
|
return markets[0]
|
631
|
+
|
632
|
+
def get_market_image_url(self, market_id: HexAddress) -> str | None:
|
633
|
+
image = self.omen_image_mapping_subgraph.Query.omenThumbnailMapping(
|
634
|
+
id=market_id.lower()
|
635
|
+
)
|
636
|
+
fields = [image.id, image.image_hash]
|
637
|
+
result = self.sg.query_json(fields)
|
638
|
+
items = self._parse_items_from_json(result)
|
639
|
+
if not items:
|
640
|
+
return None
|
641
|
+
parsed = byte32_to_ipfscidv0(HexBytes(items[0]["image_hash"]))
|
642
|
+
return OmenThumbnailMapping.construct_ipfs_url(parsed)
|
643
|
+
|
644
|
+
def get_market_image(self, market_id: HexAddress) -> ImageType | None:
|
645
|
+
image_url = self.get_market_image_url(market_id)
|
646
|
+
return (
|
647
|
+
Image.open(requests.get(image_url, stream=True).raw)
|
648
|
+
if image_url is not None
|
649
|
+
else None
|
650
|
+
)
|
@@ -23,19 +23,19 @@ prediction_market_agent_tooling/gtypes.py,sha256=lbV2nsPyhMIRI9olx0_6A06jwTWKYBP
|
|
23
23
|
prediction_market_agent_tooling/loggers.py,sha256=ua9rynYmsbOJZjxPIFxRBooomeN08zuLSJ7lxZMDS7w,3133
|
24
24
|
prediction_market_agent_tooling/markets/agent_market.py,sha256=ZpBpNLqY2QXTAdmkCr8-L3yjN70H_y-KiCptx3OFQgM,8099
|
25
25
|
prediction_market_agent_tooling/markets/categorize.py,sha256=yTd-lDMPW4ESDSzmxeLLBuzLX0FggOF7Vbswh7295o0,941
|
26
|
-
prediction_market_agent_tooling/markets/data_models.py,sha256=
|
26
|
+
prediction_market_agent_tooling/markets/data_models.py,sha256=IYI8fne-OA18ZP1lcXySEo9rcJHYv3wZrUvJziSaHew,1476
|
27
27
|
prediction_market_agent_tooling/markets/manifold/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
28
28
|
prediction_market_agent_tooling/markets/manifold/api.py,sha256=m6qOzDiyQfxj62Eo_SzzQLkX4ijpi8KtQKGd4CpKAsk,7307
|
29
|
-
prediction_market_agent_tooling/markets/manifold/data_models.py,sha256=
|
29
|
+
prediction_market_agent_tooling/markets/manifold/data_models.py,sha256=xoCqxk9cO6MZ_px_SEGYZ8hHyhGh-X6QDC8dDhyF3rk,5302
|
30
30
|
prediction_market_agent_tooling/markets/manifold/manifold.py,sha256=EwRL06E2Y_ZAzr8efwS5yD6p6rnykrcBhqmNDUGZ8Aw,4075
|
31
31
|
prediction_market_agent_tooling/markets/manifold/utils.py,sha256=cPPFWXm3vCYH1jy7_ctJZuQH9ZDaPL4_AgAYzGWkoow,513
|
32
32
|
prediction_market_agent_tooling/markets/markets.py,sha256=w05Oo7yCA2axpCw69Q9y4i9Gcdpht0u5bZGbWqld3rU,2964
|
33
33
|
prediction_market_agent_tooling/markets/omen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
34
34
|
prediction_market_agent_tooling/markets/omen/data_models.py,sha256=EXtjmcujx68Xu50BVkYXvLuf_Asx5o65RvFS3ZS6HGs,14405
|
35
35
|
prediction_market_agent_tooling/markets/omen/omen.py,sha256=dMun3MvkvEVrBmN2NwCCb1Uq3kd9nePe1FhFBgHHcj0,36868
|
36
|
-
prediction_market_agent_tooling/markets/omen/omen_contracts.py,sha256
|
36
|
+
prediction_market_agent_tooling/markets/omen/omen_contracts.py,sha256=JGXCO9MIVr-DGyoH2sxReAw7ZDTC_ev0UxDpq1QBv5Q,21854
|
37
37
|
prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256=g77QsQ5WnSI2rzBlX87L_EhWMwobkyXyfRhHQmpAdzo,9012
|
38
|
-
prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=
|
38
|
+
prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=cwimJjzWw7GNXYj_79ztgJawlwJQzf4Q9BPAtqByRFY,25248
|
39
39
|
prediction_market_agent_tooling/markets/polymarket/api.py,sha256=HXmA1akA0qDj0m3e-GEvWG8x75pm6BX4H7YJPQcST7I,4767
|
40
40
|
prediction_market_agent_tooling/markets/polymarket/data_models.py,sha256=9CJzakyEcsn6DQBK2nOXjOMzTZBLAmK_KqevXvW17DI,4292
|
41
41
|
prediction_market_agent_tooling/markets/polymarket/data_models_web.py,sha256=f8SRQy0Rn-gIHSEMrJJAI8H3J7l8lzOLj3aCMe0vJv8,11324
|
@@ -69,8 +69,8 @@ prediction_market_agent_tooling/tools/singleton.py,sha256=CiIELUiI-OeS7U7eeHEt0r
|
|
69
69
|
prediction_market_agent_tooling/tools/streamlit_user_login.py,sha256=NXEqfjT9Lc9QtliwSGRASIz1opjQ7Btme43H4qJbzgE,3010
|
70
70
|
prediction_market_agent_tooling/tools/utils.py,sha256=-G22UEbCRm59bm1RWFdeF55hRsaxgwZVAHvK32-Ye1g,6190
|
71
71
|
prediction_market_agent_tooling/tools/web3_utils.py,sha256=nKRHmdLnWSKd3wpo-cysXGvhhrJ2Yf69sN2FFQfSt6s,10578
|
72
|
-
prediction_market_agent_tooling-0.39.
|
73
|
-
prediction_market_agent_tooling-0.39.
|
74
|
-
prediction_market_agent_tooling-0.39.
|
75
|
-
prediction_market_agent_tooling-0.39.
|
76
|
-
prediction_market_agent_tooling-0.39.
|
72
|
+
prediction_market_agent_tooling-0.39.5.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
|
73
|
+
prediction_market_agent_tooling-0.39.5.dist-info/METADATA,sha256=pJlbhUhEMtWTxji9oFxWVINfG5NQlwypKHU0ZYg7G5s,7634
|
74
|
+
prediction_market_agent_tooling-0.39.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
75
|
+
prediction_market_agent_tooling-0.39.5.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
|
76
|
+
prediction_market_agent_tooling-0.39.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|