prediction-market-agent-tooling 0.63.1__py3-none-any.whl → 0.63.2__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/seer/price_manager.py +3 -1
- prediction_market_agent_tooling/markets/seer/seer.py +32 -3
- prediction_market_agent_tooling/tools/cow/cow_order.py +2 -2
- prediction_market_agent_tooling/tools/tokens/usd.py +2 -2
- {prediction_market_agent_tooling-0.63.1.dist-info → prediction_market_agent_tooling-0.63.2.dist-info}/METADATA +1 -1
- {prediction_market_agent_tooling-0.63.1.dist-info → prediction_market_agent_tooling-0.63.2.dist-info}/RECORD +9 -9
- {prediction_market_agent_tooling-0.63.1.dist-info → prediction_market_agent_tooling-0.63.2.dist-info}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.63.1.dist-info → prediction_market_agent_tooling-0.63.2.dist-info}/WHEEL +0 -0
- {prediction_market_agent_tooling-0.63.1.dist-info → prediction_market_agent_tooling-0.63.2.dist-info}/entry_points.txt +0 -0
@@ -1,3 +1,4 @@
|
|
1
|
+
from cachetools import TTLCache, cached
|
1
2
|
from web3 import Web3
|
2
3
|
|
3
4
|
from prediction_market_agent_tooling.gtypes import (
|
@@ -65,6 +66,7 @@ class PriceManager:
|
|
65
66
|
else:
|
66
67
|
return None
|
67
68
|
|
69
|
+
@cached(TTLCache(maxsize=100, ttl=5 * 60))
|
68
70
|
def get_price_for_token(
|
69
71
|
self,
|
70
72
|
token: ChecksumAddress,
|
@@ -78,7 +80,7 @@ class PriceManager:
|
|
78
80
|
|
79
81
|
try:
|
80
82
|
buy_token_amount = get_buy_token_amount_else_raise(
|
81
|
-
|
83
|
+
sell_amount=collateral_exchange_amount.as_wei,
|
82
84
|
sell_token=self.seer_market.collateral_token_contract_address_checksummed,
|
83
85
|
buy_token=token,
|
84
86
|
)
|
@@ -46,7 +46,10 @@ from prediction_market_agent_tooling.tools.contract import (
|
|
46
46
|
init_collateral_token_contract,
|
47
47
|
to_gnosis_chain_contract,
|
48
48
|
)
|
49
|
-
from prediction_market_agent_tooling.tools.cow.cow_order import
|
49
|
+
from prediction_market_agent_tooling.tools.cow.cow_order import (
|
50
|
+
get_buy_token_amount_else_raise,
|
51
|
+
swap_tokens_waiting,
|
52
|
+
)
|
50
53
|
from prediction_market_agent_tooling.tools.datetime_utc import DatetimeUTC
|
51
54
|
from prediction_market_agent_tooling.tools.tokens.auto_deposit import (
|
52
55
|
auto_deposit_collateral_token,
|
@@ -122,6 +125,23 @@ class SeerAgentMarket(AgentMarket):
|
|
122
125
|
amount_outcome_tokens = bet_amount_in_tokens / price
|
123
126
|
return OutcomeToken(amount_outcome_tokens)
|
124
127
|
|
128
|
+
def get_sell_value_of_outcome_token(
|
129
|
+
self, outcome: str, amount: OutcomeToken
|
130
|
+
) -> CollateralToken:
|
131
|
+
if amount == amount.zero():
|
132
|
+
return CollateralToken.zero()
|
133
|
+
|
134
|
+
outcome_index = self.get_outcome_index(outcome=outcome)
|
135
|
+
wrapped_outcome_token = self.wrapped_tokens[outcome_index]
|
136
|
+
|
137
|
+
# We calculate how much collateral we would get back if we sold `amount` of outcome token.
|
138
|
+
value_outcome_token_in_collateral = get_buy_token_amount_else_raise(
|
139
|
+
sell_amount=amount.as_outcome_wei.as_wei,
|
140
|
+
sell_token=wrapped_outcome_token,
|
141
|
+
buy_token=self.collateral_token_contract_address_checksummed,
|
142
|
+
)
|
143
|
+
return value_outcome_token_in_collateral.as_token
|
144
|
+
|
125
145
|
def get_outcome_str_from_bool(self, outcome: bool) -> OutcomeStr:
|
126
146
|
outcome_translated = SeerOutcomeEnum.from_bool(outcome)
|
127
147
|
idx = self.seer_outcomes[outcome_translated]
|
@@ -134,9 +154,9 @@ class SeerAgentMarket(AgentMarket):
|
|
134
154
|
def get_tiny_bet_amount(self) -> CollateralToken:
|
135
155
|
return self.get_in_token(SEER_TINY_BET_AMOUNT)
|
136
156
|
|
137
|
-
def
|
157
|
+
def get_position_else_raise(
|
138
158
|
self, user_id: str, web3: Web3 | None = None
|
139
|
-
) -> ExistingPosition
|
159
|
+
) -> ExistingPosition:
|
140
160
|
"""
|
141
161
|
Fetches position from the user in a given market.
|
142
162
|
We ignore the INVALID balances since we are only interested in binary outcomes.
|
@@ -169,6 +189,15 @@ class SeerAgentMarket(AgentMarket):
|
|
169
189
|
amounts_ot=amounts_ot,
|
170
190
|
)
|
171
191
|
|
192
|
+
def get_position(
|
193
|
+
self, user_id: str, web3: Web3 | None = None
|
194
|
+
) -> ExistingPosition | None:
|
195
|
+
try:
|
196
|
+
return self.get_position_else_raise(user_id=user_id, web3=web3)
|
197
|
+
except Exception as e:
|
198
|
+
logger.warning(f"Could not get position for user {user_id}, exception {e}")
|
199
|
+
return None
|
200
|
+
|
172
201
|
@staticmethod
|
173
202
|
def get_user_id(api_keys: APIKeys) -> str:
|
174
203
|
return OmenAgentMarket.get_user_id(api_keys)
|
@@ -127,14 +127,14 @@ def get_quote(
|
|
127
127
|
|
128
128
|
|
129
129
|
def get_buy_token_amount_else_raise(
|
130
|
-
|
130
|
+
sell_amount: Wei,
|
131
131
|
sell_token: ChecksumAddress,
|
132
132
|
buy_token: ChecksumAddress,
|
133
133
|
chain: Chain = Chain.GNOSIS,
|
134
134
|
env: Envs = "prod",
|
135
135
|
) -> Wei:
|
136
136
|
order_quote = get_quote(
|
137
|
-
amount_wei=
|
137
|
+
amount_wei=sell_amount,
|
138
138
|
sell_token=sell_token,
|
139
139
|
buy_token=buy_token,
|
140
140
|
chain=chain,
|
@@ -50,7 +50,7 @@ def get_single_token_to_usd_rate(token_address: ChecksumAddress) -> USD:
|
|
50
50
|
.as_token.value
|
51
51
|
)
|
52
52
|
in_wei = get_buy_token_amount_else_raise(
|
53
|
-
|
53
|
+
sell_amount=CollateralToken(1).as_wei,
|
54
54
|
sell_token=token_address,
|
55
55
|
buy_token=WRAPPED_XDAI_CONTRACT_ADDRESS,
|
56
56
|
)
|
@@ -72,7 +72,7 @@ def get_single_usd_to_token_rate(token_address: ChecksumAddress) -> CollateralTo
|
|
72
72
|
.as_token.value
|
73
73
|
)
|
74
74
|
in_wei = get_buy_token_amount_else_raise(
|
75
|
-
|
75
|
+
sell_amount=CollateralToken(1).as_wei,
|
76
76
|
sell_token=WRAPPED_XDAI_CONTRACT_ADDRESS,
|
77
77
|
buy_token=token_address,
|
78
78
|
)
|
@@ -62,8 +62,8 @@ 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=
|
66
|
-
prediction_market_agent_tooling/markets/seer/seer.py,sha256=
|
65
|
+
prediction_market_agent_tooling/markets/seer/price_manager.py,sha256=PtGD9cm8JlxVTkSD-QgZuh_gWfG7WATakh8-t0szomk,4924
|
66
|
+
prediction_market_agent_tooling/markets/seer/seer.py,sha256=_FzFGTkaOHQ2WTkUa_ba-Tc9zqw4KTmbCTrH4EmvOsU,16035
|
67
67
|
prediction_market_agent_tooling/markets/seer/seer_contracts.py,sha256=yufEojZxLa_SQv9xhsG23wLGsyHOWD8Azm7-7E5Zn_8,2714
|
68
68
|
prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py,sha256=KKRI493VNNAY9tR1AjzNraeH76MvDsBV6GsiLZas0_Y,9859
|
69
69
|
prediction_market_agent_tooling/markets/seer/subgraph_data_models.py,sha256=0izxS8Mtzonfdl9UqvFVXrdj0hVzieroekXhogfZKCw,1817
|
@@ -88,7 +88,7 @@ prediction_market_agent_tooling/tools/caches/inmemory_cache.py,sha256=ZW5iI5rmjq
|
|
88
88
|
prediction_market_agent_tooling/tools/caches/serializers.py,sha256=vFDx4fsPxclXp2q0sv27j4al_M_Tj9aR2JJP-xNHQXA,2151
|
89
89
|
prediction_market_agent_tooling/tools/contract.py,sha256=1ZFp_VoqTjM8cqOfAhco2Ht0DTqakjhZpuZUrAXr28Q,21332
|
90
90
|
prediction_market_agent_tooling/tools/costs.py,sha256=EaAJ7v9laD4VEV3d8B44M4u3_oEO_H16jRVCdoZ93Uw,954
|
91
|
-
prediction_market_agent_tooling/tools/cow/cow_order.py,sha256=
|
91
|
+
prediction_market_agent_tooling/tools/cow/cow_order.py,sha256=Kk-J3N3wTbmgdYs_XGp3nXbSi3-A17lQ61j60D_lPGg,6961
|
92
92
|
prediction_market_agent_tooling/tools/custom_exceptions.py,sha256=Fh8z1fbwONvP4-j7AmV_PuEcoqb6-QXa9PJ9m7guMcM,93
|
93
93
|
prediction_market_agent_tooling/tools/datetime_utc.py,sha256=8_WackjtjC8zHXrhQFTGQ6e6Fz_6llWoKR4CSFvIv9I,2766
|
94
94
|
prediction_market_agent_tooling/tools/db/db_manager.py,sha256=GtzHH1NLl8HwqC8Z7s6eTlIQXuV0blxfaV2PeQrBnfQ,3013
|
@@ -117,12 +117,12 @@ prediction_market_agent_tooling/tools/tokens/auto_deposit.py,sha256=MWIRHYCN-7o2
|
|
117
117
|
prediction_market_agent_tooling/tools/tokens/auto_withdraw.py,sha256=22g0SIVmLlgITpdt3kPhJOw0sU4OPeBuYk_7xCrQr9U,2491
|
118
118
|
prediction_market_agent_tooling/tools/tokens/main_token.py,sha256=1rbwpdCusPgQIVFuo3m00nBZ_b2lCAoFVm67i-YDcEw,812
|
119
119
|
prediction_market_agent_tooling/tools/tokens/token_utils.py,sha256=fhs-FH9m9IbzGa-30R3ZleSKLeKfLEDoJ7F5Om285Vk,1369
|
120
|
-
prediction_market_agent_tooling/tools/tokens/usd.py,sha256=
|
120
|
+
prediction_market_agent_tooling/tools/tokens/usd.py,sha256=yuW8iPPtcpP4eLH2nORMDAfztcq0Nv2ascSrCquF1f8,3115
|
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.
|
125
|
-
prediction_market_agent_tooling-0.63.
|
126
|
-
prediction_market_agent_tooling-0.63.
|
127
|
-
prediction_market_agent_tooling-0.63.
|
128
|
-
prediction_market_agent_tooling-0.63.
|
124
|
+
prediction_market_agent_tooling-0.63.2.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
|
125
|
+
prediction_market_agent_tooling-0.63.2.dist-info/METADATA,sha256=8842h65SdEztkGfvqLpAOdd1DdOrrJ7eFtSQtBcQYcA,8689
|
126
|
+
prediction_market_agent_tooling-0.63.2.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
127
|
+
prediction_market_agent_tooling-0.63.2.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
|
128
|
+
prediction_market_agent_tooling-0.63.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|