prediction-market-agent-tooling 0.39.3__tar.gz → 0.40.0__tar.gz
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-0.39.3 → prediction_market_agent_tooling-0.40.0}/PKG-INFO +1 -1
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/config.py +5 -5
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/deploy/agent.py +8 -2
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/data_models.py +2 -1
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/manifold/data_models.py +1 -1
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/omen/omen.py +37 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/omen/omen_contracts.py +6 -2
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +40 -1
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/pyproject.toml +1 -1
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/README.md +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/abis/erc20.abi.json +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/abis/omen_dxdao.abi.json +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/abis/omen_fpmm.abi.json +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/abis/omen_fpmm_conditionaltokens.abi.json +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/abis/omen_fpmm_factory.abi.json +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/abis/omen_kleros.abi.json +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/abis/omen_oracle.abi.json +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/abis/omen_realitio.abi.json +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/abis/omen_thumbnailmapping.abi.json +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/abis/wxdai.abi.json +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/benchmark/__init__.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/benchmark/agents.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/benchmark/benchmark.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/benchmark/utils.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/deploy/agent_example.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/deploy/constants.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/deploy/gcp/deploy.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/deploy/gcp/utils.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/gtypes.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/loggers.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/agent_market.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/categorize.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/manifold/__init__.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/manifold/api.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/manifold/manifold.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/manifold/utils.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/markets.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/omen/__init__.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/omen/data_models.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/omen/omen_resolving.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/polymarket/api.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/polymarket/data_models.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/polymarket/data_models_web.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/polymarket/polymarket.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/markets/polymarket/utils.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/monitor/langfuse/langfuse_wrapper.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/monitor/markets/manifold.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/monitor/markets/omen.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/monitor/markets/polymarket.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/monitor/monitor.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/monitor/monitor_app.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/monitor/monitor_settings.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/py.typed +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/balances.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/betting_strategies/kelly_criterion.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/betting_strategies/market_moving.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/betting_strategies/minimum_bet_to_win.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/betting_strategies/stretch_bet_between.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/cache.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/contract.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/costs.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/gnosis_rpc.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/google.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/hexbytes_custom.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/image_gen/image_gen.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/image_gen/market_thumbnail_gen.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/is_predictable.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/parallelism.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/safe.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/singleton.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/streamlit_user_login.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/utils.py +0 -0
- {prediction_market_agent_tooling-0.39.3 → prediction_market_agent_tooling-0.40.0}/prediction_market_agent_tooling/tools/web3_utils.py +0 -0
@@ -58,14 +58,14 @@ class APIKeys(BaseSettings):
|
|
58
58
|
"BET_FROM_PRIVATE_KEY missing in the environment.",
|
59
59
|
)
|
60
60
|
|
61
|
+
@property
|
62
|
+
def public_key(self) -> ChecksumAddress:
|
63
|
+
return private_key_to_public_key(self.bet_from_private_key)
|
64
|
+
|
61
65
|
@property
|
62
66
|
def bet_from_address(self) -> ChecksumAddress:
|
63
67
|
"""If the SAFE is available, we always route transactions via SAFE. Otherwise we use the EOA."""
|
64
|
-
return
|
65
|
-
self.SAFE_ADDRESS
|
66
|
-
if self.SAFE_ADDRESS
|
67
|
-
else private_key_to_public_key(self.bet_from_private_key)
|
68
|
-
)
|
68
|
+
return self.SAFE_ADDRESS if self.SAFE_ADDRESS else self.public_key
|
69
69
|
|
70
70
|
@property
|
71
71
|
def openai_api_key(self) -> SecretStr:
|
@@ -22,7 +22,7 @@ from prediction_market_agent_tooling.deploy.gcp.utils import (
|
|
22
22
|
gcp_function_is_active,
|
23
23
|
gcp_resolve_api_keys_secrets,
|
24
24
|
)
|
25
|
-
from prediction_market_agent_tooling.gtypes import Probability
|
25
|
+
from prediction_market_agent_tooling.gtypes import Probability, xdai_type
|
26
26
|
from prediction_market_agent_tooling.loggers import logger
|
27
27
|
from prediction_market_agent_tooling.markets.agent_market import (
|
28
28
|
AgentMarket,
|
@@ -36,6 +36,7 @@ from prediction_market_agent_tooling.markets.markets import (
|
|
36
36
|
)
|
37
37
|
from prediction_market_agent_tooling.markets.omen.omen import (
|
38
38
|
redeem_from_all_user_positions,
|
39
|
+
withdraw_wxdai_to_xdai_to_keep_balance,
|
39
40
|
)
|
40
41
|
from prediction_market_agent_tooling.monitor.langfuse.langfuse_wrapper import (
|
41
42
|
LangfuseWrapper,
|
@@ -260,9 +261,14 @@ class DeployableTraderAgent(DeployableAgent):
|
|
260
261
|
"""
|
261
262
|
Executes actions that occur before bets are placed.
|
262
263
|
"""
|
264
|
+
api_keys = APIKeys()
|
263
265
|
if market_type == MarketType.OMEN:
|
264
266
|
# Omen is specific, because the user (agent) needs to manually withdraw winnings from the market.
|
265
|
-
redeem_from_all_user_positions(
|
267
|
+
redeem_from_all_user_positions(api_keys)
|
268
|
+
# Exchange wxdai back to xdai if the balance is getting low, so we can keep paying for fees.
|
269
|
+
withdraw_wxdai_to_xdai_to_keep_balance(
|
270
|
+
api_keys, min_required_balance=xdai_type(1), withdraw_multiplier=2
|
271
|
+
)
|
266
272
|
|
267
273
|
def process_bets(self, market_type: MarketType) -> None:
|
268
274
|
"""
|
@@ -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
|
@@ -1000,3 +1000,40 @@ def get_binary_market_p_yes_history(market: OmenAgentMarket) -> list[Probability
|
|
1000
1000
|
)
|
1001
1001
|
|
1002
1002
|
return history
|
1003
|
+
|
1004
|
+
|
1005
|
+
def withdraw_wxdai_to_xdai_to_keep_balance(
|
1006
|
+
api_keys: APIKeys,
|
1007
|
+
min_required_balance: xDai,
|
1008
|
+
withdraw_multiplier: float = 1.0,
|
1009
|
+
web3: Web3 | None = None,
|
1010
|
+
) -> None:
|
1011
|
+
"""
|
1012
|
+
Keeps xDai balance above the minimum required balance by withdrawing wxDai to xDai.
|
1013
|
+
Optionally, the amount to withdraw can be multiplied by the `withdraw_multiplier`, which can be useful to keep a buffer.
|
1014
|
+
"""
|
1015
|
+
# xDai needs to be in our wallet where we pay transaction fees, so do not check for Safe's balance.
|
1016
|
+
current_balances = get_balances(api_keys.public_key, web3)
|
1017
|
+
|
1018
|
+
if current_balances.xdai >= min_required_balance:
|
1019
|
+
logger.info(
|
1020
|
+
f"Current xDai balance {current_balances.xdai} is more or equal than the required minimum balance {min_required_balance}."
|
1021
|
+
)
|
1022
|
+
return
|
1023
|
+
|
1024
|
+
need_to_withdraw = xDai(
|
1025
|
+
(min_required_balance - current_balances.xdai) * withdraw_multiplier
|
1026
|
+
)
|
1027
|
+
|
1028
|
+
if current_balances.wxdai < need_to_withdraw:
|
1029
|
+
raise ValueError(
|
1030
|
+
f"Current wxDai balance {current_balances.wxdai} is less than the required minimum wxDai to withdraw {need_to_withdraw}."
|
1031
|
+
)
|
1032
|
+
|
1033
|
+
collateral_token_contract = OmenCollateralTokenContract()
|
1034
|
+
collateral_token_contract.withdraw(
|
1035
|
+
api_keys=api_keys, amount_wei=xdai_to_wei(need_to_withdraw), web3=web3
|
1036
|
+
)
|
1037
|
+
logger.info(
|
1038
|
+
f"Withdrew {need_to_withdraw} wxDai to keep the balance above the minimum required balance {min_required_balance}."
|
1039
|
+
)
|
@@ -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
|
+
)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|