prediction-market-agent-tooling 0.63.0.dev501__py3-none-any.whl → 0.63.0.dev506__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.
@@ -41,8 +41,9 @@ def store_trades(
41
41
  # tx_hashes must be list of bytes32 (see Solidity contract).
42
42
  # For regular tx hashes that's fine, but for other types of IDs we take the first 32 bytes (orderDigest).
43
43
  tx_hashes = [
44
- HexBytes(HexStr(i.id[:32])) for i in traded_market.trades if i.id is not None
44
+ HexBytes(HexStr(trade.id))[:32] for trade in traded_market.trades if trade.id
45
45
  ]
46
+
46
47
  prediction = ContractPrediction(
47
48
  publisher=keys.bet_from_address,
48
49
  ipfs_hash=ipfs_hash_decoded,
@@ -42,7 +42,7 @@ class PriceManager:
42
42
 
43
43
  def current_p_yes(self) -> Probability | None:
44
44
  # Inspired by https://github.com/seer-pm/demo/blob/ca682153a6b4d4dd3dcc4ad8bdcbe32202fc8fe7/web/src/hooks/useMarketOdds.ts#L15
45
- price_data = {}
45
+ price_data: dict[int, CollateralToken | None] = {}
46
46
  for idx, wrapped_token in enumerate(self.seer_market.wrapped_tokens):
47
47
  price = self.get_price_for_token(
48
48
  token=Web3.to_checksum_address(wrapped_token),
@@ -55,31 +55,29 @@ class PriceManager:
55
55
 
56
56
  # We only return a probability if we have both price_yes and price_no, since we could place bets
57
57
  # in both sides hence we need current probabilities for both outcomes.
58
- if price_yes and price_no:
59
- # If other outcome`s price is None, we set it to 0.
60
- total_price = sum(
61
- price if price is not None else 0.0 for price in price_data.values()
62
- )
63
- normalized_price_yes = price_yes / total_price
58
+ if price_yes is not None and price_no is not None:
59
+ normalized_price_yes = price_yes / (price_yes + price_no)
64
60
  self._log_track_price_normalization_diff(
65
- old_price=price_yes, normalized_price=normalized_price_yes
61
+ old_price=price_yes.value, normalized_price=normalized_price_yes
66
62
  )
67
63
  return Probability(normalized_price_yes)
68
64
  else:
69
65
  return None
70
66
 
71
67
  def get_price_for_token(
72
- self, token: ChecksumAddress, collateral_exchange_amount: Wei | None = None
73
- ) -> float | None:
68
+ self,
69
+ token: ChecksumAddress,
70
+ collateral_exchange_amount: CollateralToken | None = None,
71
+ ) -> CollateralToken | None:
74
72
  collateral_exchange_amount = (
75
73
  collateral_exchange_amount
76
74
  if collateral_exchange_amount is not None
77
- else CollateralToken(1).as_wei
75
+ else CollateralToken(1)
78
76
  )
79
77
 
80
78
  try:
81
79
  quote = get_quote(
82
- amount_wei=collateral_exchange_amount,
80
+ amount_wei=collateral_exchange_amount.as_wei,
83
81
  sell_token=self.seer_market.collateral_token_contract_address_checksummed,
84
82
  buy_token=token,
85
83
  )
@@ -90,9 +88,8 @@ class PriceManager:
90
88
  )
91
89
  return self.get_token_price_from_pools(token=token)
92
90
 
93
- collateral_exchange_amount = check_not_none(collateral_exchange_amount)
94
91
  price = collateral_exchange_amount / float(quote.quote.buyAmount.root)
95
- return Wei(str(price)).value
92
+ return price
96
93
 
97
94
  @staticmethod
98
95
  def _pool_token0_matches_token(token: ChecksumAddress, pool: SeerPool) -> bool:
@@ -101,7 +98,7 @@ class PriceManager:
101
98
  def get_token_price_from_pools(
102
99
  self,
103
100
  token: ChecksumAddress,
104
- ) -> float | None:
101
+ ) -> CollateralToken | None:
105
102
  pool = SeerSubgraphHandler().get_pool_by_token(
106
103
  token_address=token,
107
104
  collateral_address=self.seer_market.collateral_token_contract_address_checksummed,
@@ -114,9 +111,9 @@ class PriceManager:
114
111
  # The mapping below is odd but surprisingly the Algebra subgraph delivers the token1Price
115
112
  # for the token0 and the token0Price for the token1 pool.
116
113
  # For example, in a outcomeYES (token0)/sDAI pool (token1), token1Price is the price of outcomeYES in units of sDAI.
117
- price_in_collateral_units = (
114
+ price = (
118
115
  pool.token1Price
119
116
  if self._pool_token0_matches_token(token=token, pool=pool)
120
117
  else pool.token0Price
121
118
  )
122
- return price_in_collateral_units
119
+ return price
@@ -113,14 +113,14 @@ class SeerAgentMarket(AgentMarket):
113
113
  bet_amount_in_tokens = self.get_in_token(bet_amount)
114
114
 
115
115
  p = PriceManager.build(market_id=HexBytes(HexStr(self.id)))
116
- price_in_collateral_units = p.get_price_for_token(
117
- token=outcome_token, collateral_exchange_amount=bet_amount_in_tokens.as_wei
116
+ price = p.get_price_for_token(
117
+ token=outcome_token, collateral_exchange_amount=bet_amount_in_tokens
118
118
  )
119
- if not price_in_collateral_units:
119
+ if not price:
120
120
  logger.info(f"Could not get price for token {outcome_token}")
121
121
  return None
122
122
 
123
- amount_outcome_tokens = bet_amount_in_tokens.value / price_in_collateral_units
123
+ amount_outcome_tokens = bet_amount_in_tokens / price
124
124
  return OutcomeToken(amount_outcome_tokens)
125
125
 
126
126
  def get_outcome_str_from_bool(self, outcome: bool) -> OutcomeStr:
@@ -1,7 +1,13 @@
1
1
  from pydantic import BaseModel, ConfigDict, Field
2
2
  from web3.constants import ADDRESS_ZERO
3
3
 
4
- from prediction_market_agent_tooling.gtypes import HexAddress, HexBytes, OutcomeStr, Wei
4
+ from prediction_market_agent_tooling.gtypes import (
5
+ CollateralToken,
6
+ HexAddress,
7
+ HexBytes,
8
+ OutcomeStr,
9
+ Wei,
10
+ )
5
11
 
6
12
 
7
13
  class SeerToken(BaseModel):
@@ -16,8 +22,8 @@ class SeerPool(BaseModel):
16
22
  liquidity: int
17
23
  token0: SeerToken
18
24
  token1: SeerToken
19
- token0Price: float
20
- token1Price: float
25
+ token0Price: CollateralToken
26
+ token1Price: CollateralToken
21
27
  sqrtPrice: int
22
28
 
23
29
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.63.0.dev501
3
+ Version: 0.63.0.dev506
4
4
  Summary: Tools to benchmark, deploy and monitor prediction market agents.
5
5
  Author: Gnosis
6
6
  Requires-Python: >=3.10,<3.13
@@ -36,7 +36,7 @@ prediction_market_agent_tooling/jobs/omen/omen_jobs.py,sha256=Pf6QxPXGyie-2l_wZU
36
36
  prediction_market_agent_tooling/loggers.py,sha256=MvCkQSJL2_0yErNatqr81sJlc4aOgPzDp9VNrIhKUcc,4140
37
37
  prediction_market_agent_tooling/markets/agent_market.py,sha256=1NomilM0GCXcRq_1N_cr2AbSK5ONTowFeRbrhc7V5zE,14929
38
38
  prediction_market_agent_tooling/markets/base_subgraph_handler.py,sha256=7RaYO_4qAmQ6ZGM8oPK2-CkiJfKmV9MxM-rJlduaecU,1971
39
- prediction_market_agent_tooling/markets/blockchain_utils.py,sha256=rm-nh-FuIMuH3AuneRNfkwOfHc7Cs7DnPAcHtuTFcuw,2363
39
+ prediction_market_agent_tooling/markets/blockchain_utils.py,sha256=QDHYPfSHOj-oB8j5Kaw0HQ4cunfmfTuwuRTfJn7NNYU,2364
40
40
  prediction_market_agent_tooling/markets/categorize.py,sha256=jsoHWvZk9pU6n17oWSCcCxNNYVwlb_NXsZxKRI7vmsk,1301
41
41
  prediction_market_agent_tooling/markets/data_models.py,sha256=_R9Hr5zwGLpZLPXq0Jo2wZRNRQyOnSi3WVQJZ81syuk,4541
42
42
  prediction_market_agent_tooling/markets/manifold/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -62,11 +62,11 @@ prediction_market_agent_tooling/markets/polymarket/data_models_web.py,sha256=LVE
62
62
  prediction_market_agent_tooling/markets/polymarket/polymarket.py,sha256=6rc9qulPl90MxXKB55XiiWKLhjfAyG_eUzAlqpq1UIE,3339
63
63
  prediction_market_agent_tooling/markets/polymarket/utils.py,sha256=8kTeVjXPcXC6DkDvWYsZQLY7x8DS6CEp_yznSEazsNU,2037
64
64
  prediction_market_agent_tooling/markets/seer/data_models.py,sha256=FwTOq9X2iJ7r3ijtE0evl8pMSbFPm4lUwuc9m7YsMVA,6373
65
- prediction_market_agent_tooling/markets/seer/price_manager.py,sha256=gA-WurjKC4e5B-YWqaSFqSLnI0jFpLhPD-kA31j7Pm0,4976
66
- prediction_market_agent_tooling/markets/seer/seer.py,sha256=-F9WBBS1nq_RTBxNYFdpWT_aI_6hdXgyWs1s8mne_aE,15236
65
+ prediction_market_agent_tooling/markets/seer/price_manager.py,sha256=i31iHTZCxAbKoyU9x7k52DyfmMf-W1xc0Yu3Lxi3rEE,4771
66
+ prediction_market_agent_tooling/markets/seer/seer.py,sha256=PWsNsuIHIHkURH1HUasYru9F4NXnUdLXW34bG-JepoM,15163
67
67
  prediction_market_agent_tooling/markets/seer/seer_contracts.py,sha256=KXLPhxQuVEvXLKzKhiJCkINNB5xEO3fS2HsKqxQCcbs,2715
68
68
  prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py,sha256=KKRI493VNNAY9tR1AjzNraeH76MvDsBV6GsiLZas0_Y,9859
69
- prediction_market_agent_tooling/markets/seer/subgraph_data_models.py,sha256=knlBD6yQkbqbfan8l3_mIHRT3gprbWYBXAsoerDi-zg,1663
69
+ prediction_market_agent_tooling/markets/seer/subgraph_data_models.py,sha256=F5H2wcpVyEVg8OQqtE_HGfKgAjnGnWCch_iO_PvzIBc,1725
70
70
  prediction_market_agent_tooling/monitor/financial_metrics/financial_metrics.py,sha256=fjIgjDIx5MhH5mwf7S0cspLOOSU3elYLhGYoIiM26mU,2746
71
71
  prediction_market_agent_tooling/monitor/markets/manifold.py,sha256=TS4ERwTfQnot8dhekNyVNhJYf5ysYsjF-9v5_kM3aVI,3334
72
72
  prediction_market_agent_tooling/monitor/markets/metaculus.py,sha256=LOnyWWBFdg10-cTWdb76nOsNjDloO8OfMT85GBzRCFI,1455
@@ -121,8 +121,8 @@ prediction_market_agent_tooling/tools/tokens/usd.py,sha256=Qq8ofVCCMX-eo8mDlHv4g
121
121
  prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
122
122
  prediction_market_agent_tooling/tools/utils.py,sha256=1xsyBBJfiEdSoMlceB2F8o2sCb6Z8-qNz11pEJFrdyE,6566
123
123
  prediction_market_agent_tooling/tools/web3_utils.py,sha256=eYCc1iWAVtqDKUPTwnMUHuYolPdwh_OTiM3-AdRgDp4,12198
124
- prediction_market_agent_tooling-0.63.0.dev501.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
125
- prediction_market_agent_tooling-0.63.0.dev501.dist-info/METADATA,sha256=Yt4LRyUOlUnlmiMa9q_Hlh6RAl9VynJ1Vu4BQJYqkq8,8696
126
- prediction_market_agent_tooling-0.63.0.dev501.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
127
- prediction_market_agent_tooling-0.63.0.dev501.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
128
- prediction_market_agent_tooling-0.63.0.dev501.dist-info/RECORD,,
124
+ prediction_market_agent_tooling-0.63.0.dev506.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
125
+ prediction_market_agent_tooling-0.63.0.dev506.dist-info/METADATA,sha256=iZ8yYRmYwjhX24cy1IRPDrg9UUBcKZM6UuHnNioMYdU,8696
126
+ prediction_market_agent_tooling-0.63.0.dev506.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
127
+ prediction_market_agent_tooling-0.63.0.dev506.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
128
+ prediction_market_agent_tooling-0.63.0.dev506.dist-info/RECORD,,