prediction-market-agent-tooling 0.63.7__py3-none-any.whl → 0.63.9__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/abis/seer_gnosis_router.abi.json +348 -0
- prediction_market_agent_tooling/markets/seer/data_models.py +30 -0
- prediction_market_agent_tooling/markets/seer/seer.py +65 -2
- prediction_market_agent_tooling/markets/seer/seer_contracts.py +31 -0
- prediction_market_agent_tooling/tools/cow/cow_order.py +23 -0
- prediction_market_agent_tooling/tools/utils.py +7 -3
- {prediction_market_agent_tooling-0.63.7.dist-info → prediction_market_agent_tooling-0.63.9.dist-info}/METADATA +1 -1
- {prediction_market_agent_tooling-0.63.7.dist-info → prediction_market_agent_tooling-0.63.9.dist-info}/RECORD +11 -10
- {prediction_market_agent_tooling-0.63.7.dist-info → prediction_market_agent_tooling-0.63.9.dist-info}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.63.7.dist-info → prediction_market_agent_tooling-0.63.9.dist-info}/WHEEL +0 -0
- {prediction_market_agent_tooling-0.63.7.dist-info → prediction_market_agent_tooling-0.63.9.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,348 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"inputs": [
|
4
|
+
{
|
5
|
+
"internalType": "contract IConditionalTokens",
|
6
|
+
"name": "_conditionalTokens",
|
7
|
+
"type": "address"
|
8
|
+
},
|
9
|
+
{
|
10
|
+
"internalType": "contract IWrapped1155Factory",
|
11
|
+
"name": "_wrapped1155Factory",
|
12
|
+
"type": "address"
|
13
|
+
}
|
14
|
+
],
|
15
|
+
"stateMutability": "nonpayable",
|
16
|
+
"type": "constructor"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"inputs": [],
|
20
|
+
"name": "conditionalTokens",
|
21
|
+
"outputs": [
|
22
|
+
{
|
23
|
+
"internalType": "contract IConditionalTokens",
|
24
|
+
"name": "",
|
25
|
+
"type": "address"
|
26
|
+
}
|
27
|
+
],
|
28
|
+
"stateMutability": "view",
|
29
|
+
"type": "function"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"inputs": [
|
33
|
+
{
|
34
|
+
"internalType": "contract IERC20",
|
35
|
+
"name": "collateralToken",
|
36
|
+
"type": "address"
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"internalType": "bytes32",
|
40
|
+
"name": "parentCollectionId",
|
41
|
+
"type": "bytes32"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"internalType": "bytes32",
|
45
|
+
"name": "conditionId",
|
46
|
+
"type": "bytes32"
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"internalType": "uint256",
|
50
|
+
"name": "indexSet",
|
51
|
+
"type": "uint256"
|
52
|
+
}
|
53
|
+
],
|
54
|
+
"name": "getTokenId",
|
55
|
+
"outputs": [
|
56
|
+
{
|
57
|
+
"internalType": "uint256",
|
58
|
+
"name": "",
|
59
|
+
"type": "uint256"
|
60
|
+
}
|
61
|
+
],
|
62
|
+
"stateMutability": "view",
|
63
|
+
"type": "function"
|
64
|
+
},
|
65
|
+
{
|
66
|
+
"inputs": [
|
67
|
+
{
|
68
|
+
"internalType": "bytes32",
|
69
|
+
"name": "conditionId",
|
70
|
+
"type": "bytes32"
|
71
|
+
}
|
72
|
+
],
|
73
|
+
"name": "getWinningOutcomes",
|
74
|
+
"outputs": [
|
75
|
+
{
|
76
|
+
"internalType": "bool[]",
|
77
|
+
"name": "",
|
78
|
+
"type": "bool[]"
|
79
|
+
}
|
80
|
+
],
|
81
|
+
"stateMutability": "view",
|
82
|
+
"type": "function"
|
83
|
+
},
|
84
|
+
{
|
85
|
+
"inputs": [
|
86
|
+
{
|
87
|
+
"internalType": "contract IERC20",
|
88
|
+
"name": "collateralToken",
|
89
|
+
"type": "address"
|
90
|
+
},
|
91
|
+
{
|
92
|
+
"internalType": "contract Market",
|
93
|
+
"name": "market",
|
94
|
+
"type": "address"
|
95
|
+
},
|
96
|
+
{
|
97
|
+
"internalType": "uint256",
|
98
|
+
"name": "amount",
|
99
|
+
"type": "uint256"
|
100
|
+
}
|
101
|
+
],
|
102
|
+
"name": "mergePositions",
|
103
|
+
"outputs": [],
|
104
|
+
"stateMutability": "nonpayable",
|
105
|
+
"type": "function"
|
106
|
+
},
|
107
|
+
{
|
108
|
+
"inputs": [
|
109
|
+
{
|
110
|
+
"internalType": "contract Market",
|
111
|
+
"name": "market",
|
112
|
+
"type": "address"
|
113
|
+
},
|
114
|
+
{
|
115
|
+
"internalType": "uint256",
|
116
|
+
"name": "amount",
|
117
|
+
"type": "uint256"
|
118
|
+
}
|
119
|
+
],
|
120
|
+
"name": "mergeToBase",
|
121
|
+
"outputs": [],
|
122
|
+
"stateMutability": "nonpayable",
|
123
|
+
"type": "function"
|
124
|
+
},
|
125
|
+
{
|
126
|
+
"inputs": [
|
127
|
+
{
|
128
|
+
"internalType": "address",
|
129
|
+
"name": "",
|
130
|
+
"type": "address"
|
131
|
+
},
|
132
|
+
{
|
133
|
+
"internalType": "address",
|
134
|
+
"name": "",
|
135
|
+
"type": "address"
|
136
|
+
},
|
137
|
+
{
|
138
|
+
"internalType": "uint256[]",
|
139
|
+
"name": "",
|
140
|
+
"type": "uint256[]"
|
141
|
+
},
|
142
|
+
{
|
143
|
+
"internalType": "uint256[]",
|
144
|
+
"name": "",
|
145
|
+
"type": "uint256[]"
|
146
|
+
},
|
147
|
+
{
|
148
|
+
"internalType": "bytes",
|
149
|
+
"name": "",
|
150
|
+
"type": "bytes"
|
151
|
+
}
|
152
|
+
],
|
153
|
+
"name": "onERC1155BatchReceived",
|
154
|
+
"outputs": [
|
155
|
+
{
|
156
|
+
"internalType": "bytes4",
|
157
|
+
"name": "",
|
158
|
+
"type": "bytes4"
|
159
|
+
}
|
160
|
+
],
|
161
|
+
"stateMutability": "nonpayable",
|
162
|
+
"type": "function"
|
163
|
+
},
|
164
|
+
{
|
165
|
+
"inputs": [
|
166
|
+
{
|
167
|
+
"internalType": "address",
|
168
|
+
"name": "",
|
169
|
+
"type": "address"
|
170
|
+
},
|
171
|
+
{
|
172
|
+
"internalType": "address",
|
173
|
+
"name": "",
|
174
|
+
"type": "address"
|
175
|
+
},
|
176
|
+
{
|
177
|
+
"internalType": "uint256",
|
178
|
+
"name": "",
|
179
|
+
"type": "uint256"
|
180
|
+
},
|
181
|
+
{
|
182
|
+
"internalType": "uint256",
|
183
|
+
"name": "",
|
184
|
+
"type": "uint256"
|
185
|
+
},
|
186
|
+
{
|
187
|
+
"internalType": "bytes",
|
188
|
+
"name": "",
|
189
|
+
"type": "bytes"
|
190
|
+
}
|
191
|
+
],
|
192
|
+
"name": "onERC1155Received",
|
193
|
+
"outputs": [
|
194
|
+
{
|
195
|
+
"internalType": "bytes4",
|
196
|
+
"name": "",
|
197
|
+
"type": "bytes4"
|
198
|
+
}
|
199
|
+
],
|
200
|
+
"stateMutability": "nonpayable",
|
201
|
+
"type": "function"
|
202
|
+
},
|
203
|
+
{
|
204
|
+
"inputs": [
|
205
|
+
{
|
206
|
+
"internalType": "contract IERC20",
|
207
|
+
"name": "collateralToken",
|
208
|
+
"type": "address"
|
209
|
+
},
|
210
|
+
{
|
211
|
+
"internalType": "contract Market",
|
212
|
+
"name": "market",
|
213
|
+
"type": "address"
|
214
|
+
},
|
215
|
+
{
|
216
|
+
"internalType": "uint256[]",
|
217
|
+
"name": "outcomeIndexes",
|
218
|
+
"type": "uint256[]"
|
219
|
+
},
|
220
|
+
{
|
221
|
+
"internalType": "uint256[]",
|
222
|
+
"name": "amounts",
|
223
|
+
"type": "uint256[]"
|
224
|
+
}
|
225
|
+
],
|
226
|
+
"name": "redeemPositions",
|
227
|
+
"outputs": [],
|
228
|
+
"stateMutability": "nonpayable",
|
229
|
+
"type": "function"
|
230
|
+
},
|
231
|
+
{
|
232
|
+
"inputs": [
|
233
|
+
{
|
234
|
+
"internalType": "contract Market",
|
235
|
+
"name": "market",
|
236
|
+
"type": "address"
|
237
|
+
},
|
238
|
+
{
|
239
|
+
"internalType": "uint256[]",
|
240
|
+
"name": "outcomeIndexes",
|
241
|
+
"type": "uint256[]"
|
242
|
+
},
|
243
|
+
{
|
244
|
+
"internalType": "uint256[]",
|
245
|
+
"name": "amounts",
|
246
|
+
"type": "uint256[]"
|
247
|
+
}
|
248
|
+
],
|
249
|
+
"name": "redeemToBase",
|
250
|
+
"outputs": [],
|
251
|
+
"stateMutability": "nonpayable",
|
252
|
+
"type": "function"
|
253
|
+
},
|
254
|
+
{
|
255
|
+
"inputs": [],
|
256
|
+
"name": "sDAI",
|
257
|
+
"outputs": [
|
258
|
+
{
|
259
|
+
"internalType": "contract IERC20",
|
260
|
+
"name": "",
|
261
|
+
"type": "address"
|
262
|
+
}
|
263
|
+
],
|
264
|
+
"stateMutability": "view",
|
265
|
+
"type": "function"
|
266
|
+
},
|
267
|
+
{
|
268
|
+
"inputs": [],
|
269
|
+
"name": "savingsXDaiAdapter",
|
270
|
+
"outputs": [
|
271
|
+
{
|
272
|
+
"internalType": "contract ISavingsXDaiAdapter",
|
273
|
+
"name": "",
|
274
|
+
"type": "address"
|
275
|
+
}
|
276
|
+
],
|
277
|
+
"stateMutability": "view",
|
278
|
+
"type": "function"
|
279
|
+
},
|
280
|
+
{
|
281
|
+
"inputs": [
|
282
|
+
{
|
283
|
+
"internalType": "contract Market",
|
284
|
+
"name": "market",
|
285
|
+
"type": "address"
|
286
|
+
}
|
287
|
+
],
|
288
|
+
"name": "splitFromBase",
|
289
|
+
"outputs": [],
|
290
|
+
"stateMutability": "payable",
|
291
|
+
"type": "function"
|
292
|
+
},
|
293
|
+
{
|
294
|
+
"inputs": [
|
295
|
+
{
|
296
|
+
"internalType": "contract IERC20",
|
297
|
+
"name": "collateralToken",
|
298
|
+
"type": "address"
|
299
|
+
},
|
300
|
+
{
|
301
|
+
"internalType": "contract Market",
|
302
|
+
"name": "market",
|
303
|
+
"type": "address"
|
304
|
+
},
|
305
|
+
{
|
306
|
+
"internalType": "uint256",
|
307
|
+
"name": "amount",
|
308
|
+
"type": "uint256"
|
309
|
+
}
|
310
|
+
],
|
311
|
+
"name": "splitPosition",
|
312
|
+
"outputs": [],
|
313
|
+
"stateMutability": "nonpayable",
|
314
|
+
"type": "function"
|
315
|
+
},
|
316
|
+
{
|
317
|
+
"inputs": [
|
318
|
+
{
|
319
|
+
"internalType": "bytes4",
|
320
|
+
"name": "interfaceId",
|
321
|
+
"type": "bytes4"
|
322
|
+
}
|
323
|
+
],
|
324
|
+
"name": "supportsInterface",
|
325
|
+
"outputs": [
|
326
|
+
{
|
327
|
+
"internalType": "bool",
|
328
|
+
"name": "",
|
329
|
+
"type": "bool"
|
330
|
+
}
|
331
|
+
],
|
332
|
+
"stateMutability": "view",
|
333
|
+
"type": "function"
|
334
|
+
},
|
335
|
+
{
|
336
|
+
"inputs": [],
|
337
|
+
"name": "wrapped1155Factory",
|
338
|
+
"outputs": [
|
339
|
+
{
|
340
|
+
"internalType": "contract IWrapped1155Factory",
|
341
|
+
"name": "",
|
342
|
+
"type": "address"
|
343
|
+
}
|
344
|
+
],
|
345
|
+
"stateMutability": "view",
|
346
|
+
"type": "function"
|
347
|
+
}
|
348
|
+
]
|
@@ -13,12 +13,14 @@ from prediction_market_agent_tooling.gtypes import (
|
|
13
13
|
HexAddress,
|
14
14
|
HexBytes,
|
15
15
|
OutcomeStr,
|
16
|
+
OutcomeWei,
|
16
17
|
Web3Wei,
|
17
18
|
)
|
18
19
|
from prediction_market_agent_tooling.markets.data_models import Resolution
|
19
20
|
from prediction_market_agent_tooling.markets.seer.subgraph_data_models import (
|
20
21
|
SeerParentMarket,
|
21
22
|
)
|
23
|
+
from prediction_market_agent_tooling.tools.contract import ContractERC20OnGnosisChain
|
22
24
|
from prediction_market_agent_tooling.tools.datetime_utc import DatetimeUTC
|
23
25
|
|
24
26
|
|
@@ -149,6 +151,27 @@ class SeerMarket(BaseModel):
|
|
149
151
|
return Resolution.YES
|
150
152
|
return Resolution.NO
|
151
153
|
|
154
|
+
def is_redeemable(self, owner: ChecksumAddress, web3: Web3 | None = None) -> bool:
|
155
|
+
token_balances = self.get_outcome_token_balances(owner, web3)
|
156
|
+
if not self.payout_reported:
|
157
|
+
return False
|
158
|
+
return any(
|
159
|
+
payout and balance > 0
|
160
|
+
for payout, balance in zip(self.payout_numerators, token_balances)
|
161
|
+
)
|
162
|
+
|
163
|
+
def get_outcome_token_balances(
|
164
|
+
self, owner: ChecksumAddress, web3: Web3 | None = None
|
165
|
+
) -> list[OutcomeWei]:
|
166
|
+
return [
|
167
|
+
OutcomeWei.from_wei(
|
168
|
+
ContractERC20OnGnosisChain(
|
169
|
+
address=Web3.to_checksum_address(token)
|
170
|
+
).balanceOf(owner, web3=web3)
|
171
|
+
)
|
172
|
+
for token in self.wrapped_tokens
|
173
|
+
]
|
174
|
+
|
152
175
|
@property
|
153
176
|
def is_binary(self) -> bool:
|
154
177
|
# 3 because Seer has also third, `Invalid` outcome.
|
@@ -186,3 +209,10 @@ class SeerMarket(BaseModel):
|
|
186
209
|
def url(self) -> str:
|
187
210
|
chain_id = RPCConfig().chain_id
|
188
211
|
return urljoin(SEER_BASE_URL, f"markets/{chain_id}/{self.id.hex()}")
|
212
|
+
|
213
|
+
|
214
|
+
class RedeemParams(BaseModel):
|
215
|
+
model_config = ConfigDict(populate_by_name=True)
|
216
|
+
market: ChecksumAddress
|
217
|
+
outcome_indices: list[int] = Field(alias="outcomeIndexes")
|
218
|
+
amounts: list[OutcomeWei]
|
@@ -28,11 +28,13 @@ from prediction_market_agent_tooling.markets.data_models import ExistingPosition
|
|
28
28
|
from prediction_market_agent_tooling.markets.market_fees import MarketFees
|
29
29
|
from prediction_market_agent_tooling.markets.omen.omen import OmenAgentMarket
|
30
30
|
from prediction_market_agent_tooling.markets.seer.data_models import (
|
31
|
+
RedeemParams,
|
31
32
|
SeerMarket,
|
32
33
|
SeerOutcomeEnum,
|
33
34
|
)
|
34
35
|
from prediction_market_agent_tooling.markets.seer.price_manager import PriceManager
|
35
36
|
from prediction_market_agent_tooling.markets.seer.seer_contracts import (
|
37
|
+
GnosisRouter,
|
36
38
|
SeerMarketFactory,
|
37
39
|
)
|
38
40
|
from prediction_market_agent_tooling.markets.seer.seer_subgraph_handler import (
|
@@ -48,6 +50,7 @@ from prediction_market_agent_tooling.tools.contract import (
|
|
48
50
|
)
|
49
51
|
from prediction_market_agent_tooling.tools.cow.cow_order import (
|
50
52
|
get_buy_token_amount_else_raise,
|
53
|
+
get_trades_by_owner,
|
51
54
|
swap_tokens_waiting,
|
52
55
|
)
|
53
56
|
from prediction_market_agent_tooling.tools.datetime_utc import DatetimeUTC
|
@@ -202,10 +205,70 @@ class SeerAgentMarket(AgentMarket):
|
|
202
205
|
def get_user_id(api_keys: APIKeys) -> str:
|
203
206
|
return OmenAgentMarket.get_user_id(api_keys)
|
204
207
|
|
208
|
+
@staticmethod
|
209
|
+
def _filter_markets_contained_in_trades(
|
210
|
+
api_keys: APIKeys,
|
211
|
+
markets: list[SeerMarket],
|
212
|
+
) -> list[SeerMarket]:
|
213
|
+
"""
|
214
|
+
We filter the markets using previous trades by the user so that we don't have to process all Seer markets.
|
215
|
+
"""
|
216
|
+
trades_by_user = get_trades_by_owner(api_keys.bet_from_address)
|
217
|
+
|
218
|
+
traded_tokens = {t.buyToken for t in trades_by_user}.union(
|
219
|
+
[t.sellToken for t in trades_by_user]
|
220
|
+
)
|
221
|
+
filtered_markets = []
|
222
|
+
for market in markets:
|
223
|
+
if any(
|
224
|
+
[
|
225
|
+
Web3.to_checksum_address(wrapped_token) in traded_tokens
|
226
|
+
for wrapped_token in market.wrapped_tokens
|
227
|
+
]
|
228
|
+
):
|
229
|
+
filtered_markets.append(market)
|
230
|
+
|
231
|
+
return filtered_markets
|
232
|
+
|
205
233
|
@staticmethod
|
206
234
|
def redeem_winnings(api_keys: APIKeys) -> None:
|
207
|
-
|
208
|
-
|
235
|
+
web3 = RPCConfig().get_web3()
|
236
|
+
subgraph = SeerSubgraphHandler()
|
237
|
+
|
238
|
+
closed_markets = subgraph.get_binary_markets(
|
239
|
+
filter_by=FilterBy.RESOLVED, sort_by=SortBy.NEWEST
|
240
|
+
)
|
241
|
+
filtered_markets = SeerAgentMarket._filter_markets_contained_in_trades(
|
242
|
+
api_keys, closed_markets
|
243
|
+
)
|
244
|
+
|
245
|
+
market_balances = {
|
246
|
+
market.id: market.get_outcome_token_balances(
|
247
|
+
api_keys.bet_from_address, web3
|
248
|
+
)
|
249
|
+
for market in filtered_markets
|
250
|
+
}
|
251
|
+
|
252
|
+
markets_to_redeem = [
|
253
|
+
market
|
254
|
+
for market in filtered_markets
|
255
|
+
if market.is_redeemable(owner=api_keys.bet_from_address, web3=web3)
|
256
|
+
]
|
257
|
+
|
258
|
+
gnosis_router = GnosisRouter()
|
259
|
+
for market in markets_to_redeem:
|
260
|
+
try:
|
261
|
+
params = RedeemParams(
|
262
|
+
market=Web3.to_checksum_address(market.id),
|
263
|
+
outcome_indices=list(range(len(market.payout_numerators))),
|
264
|
+
amounts=market_balances[market.id],
|
265
|
+
)
|
266
|
+
gnosis_router.redeem_to_base(api_keys, params=params, web3=web3)
|
267
|
+
logger.info(f"Redeemed market {market.id.hex()}")
|
268
|
+
except Exception as e:
|
269
|
+
logger.error(f"Failed to redeem market {market.id.hex()}, {e}")
|
270
|
+
|
271
|
+
# GnosisRouter withdraws sDai into wxDAI/xDai on its own, so no auto-withdraw needed by us.
|
209
272
|
|
210
273
|
@staticmethod
|
211
274
|
def verify_operational_balance(api_keys: APIKeys) -> bool:
|
@@ -11,6 +11,7 @@ from prediction_market_agent_tooling.gtypes import (
|
|
11
11
|
TxReceipt,
|
12
12
|
xDai,
|
13
13
|
)
|
14
|
+
from prediction_market_agent_tooling.markets.seer.data_models import RedeemParams
|
14
15
|
from prediction_market_agent_tooling.markets.seer.subgraph_data_models import (
|
15
16
|
CreateCategoricalMarketsParams,
|
16
17
|
)
|
@@ -79,3 +80,33 @@ class SeerMarketFactory(ContractOnGnosisChain):
|
|
79
80
|
web3=web3,
|
80
81
|
)
|
81
82
|
return receipt_tx
|
83
|
+
|
84
|
+
|
85
|
+
class GnosisRouter(ContractOnGnosisChain):
|
86
|
+
# https://gnosisscan.io/address/0x83183da839ce8228e31ae41222ead9edbb5cdcf1#code.
|
87
|
+
abi: ABI = abi_field_validator(
|
88
|
+
os.path.join(
|
89
|
+
os.path.dirname(os.path.realpath(__file__)),
|
90
|
+
"../../abis/seer_gnosis_router.abi.json",
|
91
|
+
)
|
92
|
+
)
|
93
|
+
address: ChecksumAddress = Web3.to_checksum_address(
|
94
|
+
"0xeC9048b59b3467415b1a38F63416407eA0c70fB8"
|
95
|
+
)
|
96
|
+
|
97
|
+
def redeem_to_base(
|
98
|
+
self,
|
99
|
+
api_keys: APIKeys,
|
100
|
+
params: RedeemParams,
|
101
|
+
web3: Web3 | None = None,
|
102
|
+
) -> TxReceipt:
|
103
|
+
params_dict = params.model_dump(by_alias=True)
|
104
|
+
# We explicity set amounts since OutcomeWei gets serialized as dict
|
105
|
+
params_dict["amounts"] = [amount.value for amount in params.amounts]
|
106
|
+
receipt_tx = self.send(
|
107
|
+
api_keys=api_keys,
|
108
|
+
function_name="redeemToBase",
|
109
|
+
function_params=params_dict,
|
110
|
+
web3=web3,
|
111
|
+
)
|
112
|
+
return receipt_tx
|
@@ -23,6 +23,7 @@ from cowdao_cowpy.order_book.generated.model import (
|
|
23
23
|
OrderStatus,
|
24
24
|
TokenAmount,
|
25
25
|
)
|
26
|
+
from cowdao_cowpy.subgraph.client import BaseModel
|
26
27
|
from eth_account.signers.local import LocalAccount
|
27
28
|
from tenacity import retry_if_not_exception_type, stop_after_attempt, wait_fixed
|
28
29
|
from web3 import Web3
|
@@ -34,6 +35,11 @@ from prediction_market_agent_tooling.tools.contract import ContractERC20OnGnosis
|
|
34
35
|
from prediction_market_agent_tooling.tools.utils import utcnow
|
35
36
|
|
36
37
|
|
38
|
+
class MinimalisticToken(BaseModel):
|
39
|
+
sellToken: ChecksumAddress
|
40
|
+
buyToken: ChecksumAddress
|
41
|
+
|
42
|
+
|
37
43
|
class OrderStatusError(Exception):
|
38
44
|
pass
|
39
45
|
|
@@ -221,3 +227,20 @@ async def swap_tokens_waiting_async(
|
|
221
227
|
)
|
222
228
|
|
223
229
|
await asyncio.sleep(3.14)
|
230
|
+
|
231
|
+
|
232
|
+
@tenacity.retry(
|
233
|
+
stop=stop_after_attempt(3),
|
234
|
+
wait=wait_fixed(1),
|
235
|
+
after=lambda x: logger.debug(f"get_trades_by_owner failed, {x.attempt_number=}."),
|
236
|
+
)
|
237
|
+
def get_trades_by_owner(
|
238
|
+
owner: ChecksumAddress,
|
239
|
+
) -> list[MinimalisticToken]:
|
240
|
+
# Using this until cowpy gets fixed (https://github.com/cowdao-grants/cow-py/issues/35)
|
241
|
+
response = httpx.get(
|
242
|
+
f"https://api.cow.fi/xdai/api/v1/trades",
|
243
|
+
params={"owner": owner},
|
244
|
+
)
|
245
|
+
response.raise_for_status()
|
246
|
+
return [MinimalisticToken.model_validate(i) for i in response.json()]
|
@@ -194,15 +194,19 @@ def calculate_sell_amount_in_collateral(
|
|
194
194
|
fees: MarketFees,
|
195
195
|
) -> CollateralToken:
|
196
196
|
"""
|
197
|
-
Computes the amount of collateral that needs to be sold to get `shares`
|
198
|
-
amount of shares. Returns None if the amount can't be computed.
|
197
|
+
Computes the amount of collateral that needs to be sold to get `shares` amount of shares.
|
199
198
|
|
200
199
|
Taken from https://github.com/protofire/omen-exchange/blob/29d0ab16bdafa5cc0d37933c1c7608a055400c73/app/src/util/tools/fpmm/trading/index.ts#L99
|
201
200
|
Simplified for binary markets.
|
202
201
|
"""
|
202
|
+
if shares_to_sell == 0:
|
203
|
+
return CollateralToken(0)
|
204
|
+
|
203
205
|
for v in [shares_to_sell, holdings, other_holdings]:
|
204
206
|
if v <= 0:
|
205
|
-
raise ValueError(
|
207
|
+
raise ValueError(
|
208
|
+
f"All share args must be greater than 0, got {[shares_to_sell, holdings, other_holdings]=}"
|
209
|
+
)
|
206
210
|
|
207
211
|
def f(r: float) -> float:
|
208
212
|
R = OutcomeToken((r + fees.absolute) / (1 - fees.bet_proportion))
|
@@ -15,6 +15,7 @@ prediction_market_agent_tooling/abis/omen_thumbnailmapping.abi.json,sha256=u1-3B
|
|
15
15
|
prediction_market_agent_tooling/abis/ownable.abi.json,sha256=DeTy_7VmsMhFl7jwI8MIlmjy2jORauYxrGm7wC_Alxw,1528
|
16
16
|
prediction_market_agent_tooling/abis/ownable_erc721.abi.json,sha256=9sxm588MAQmqCV_S0D3eYC7l9grbeALsd0Da_AHxdEI,8506
|
17
17
|
prediction_market_agent_tooling/abis/proxy.abi.json,sha256=h24GXZ6Q0bSZlwh7zOv0EiDvbqUz_PHtWfKHTyPJ1w4,644
|
18
|
+
prediction_market_agent_tooling/abis/seer_gnosis_router.abi.json,sha256=DyADzOXhy9MDS31ReVrG7ibpWbw1jVy19nExZ80xfRY,6839
|
18
19
|
prediction_market_agent_tooling/abis/seer_market_factory.abi.json,sha256=g7RVxZVUWlTXIgTV2W6kO4twQM909Qv58zAr7Dk4XIc,13553
|
19
20
|
prediction_market_agent_tooling/benchmark/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
20
21
|
prediction_market_agent_tooling/benchmark/agents.py,sha256=B1-uWdyeN4GGKMWGK_-CcAFJg1m9Y_XuaeIHPB29QR8,3971
|
@@ -61,10 +62,10 @@ prediction_market_agent_tooling/markets/polymarket/data_models.py,sha256=utGN-Lh
|
|
61
62
|
prediction_market_agent_tooling/markets/polymarket/data_models_web.py,sha256=LVEsNw2nUx5poiU1m803NNqG5-fs8-MODQRyGLqy4mE,12585
|
62
63
|
prediction_market_agent_tooling/markets/polymarket/polymarket.py,sha256=6rc9qulPl90MxXKB55XiiWKLhjfAyG_eUzAlqpq1UIE,3339
|
63
64
|
prediction_market_agent_tooling/markets/polymarket/utils.py,sha256=8kTeVjXPcXC6DkDvWYsZQLY7x8DS6CEp_yznSEazsNU,2037
|
64
|
-
prediction_market_agent_tooling/markets/seer/data_models.py,sha256=
|
65
|
+
prediction_market_agent_tooling/markets/seer/data_models.py,sha256=TcsDgbk2id1JJ_XT9bnvO4M75dTvOtbzQX67918OQ8E,7442
|
65
66
|
prediction_market_agent_tooling/markets/seer/price_manager.py,sha256=EuOe6zCmEEWXz1loXaQQOYC7ZNQ0cDJn0rZadK1dBlc,5460
|
66
|
-
prediction_market_agent_tooling/markets/seer/seer.py,sha256=
|
67
|
-
prediction_market_agent_tooling/markets/seer/seer_contracts.py,sha256=
|
67
|
+
prediction_market_agent_tooling/markets/seer/seer.py,sha256=1LTCf_9hQ4LQ_0G0f0Y1HVNT0_lUgUKuVMOYWMLWsN4,18265
|
68
|
+
prediction_market_agent_tooling/markets/seer/seer_contracts.py,sha256=kH9nPXsx6UM5er42g2f3fLvy36sY5JM2f_beXeuNgUc,3790
|
68
69
|
prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py,sha256=KKRI493VNNAY9tR1AjzNraeH76MvDsBV6GsiLZas0_Y,9859
|
69
70
|
prediction_market_agent_tooling/markets/seer/subgraph_data_models.py,sha256=0izxS8Mtzonfdl9UqvFVXrdj0hVzieroekXhogfZKCw,1817
|
70
71
|
prediction_market_agent_tooling/monitor/financial_metrics/financial_metrics.py,sha256=fjIgjDIx5MhH5mwf7S0cspLOOSU3elYLhGYoIiM26mU,2746
|
@@ -88,7 +89,7 @@ prediction_market_agent_tooling/tools/caches/inmemory_cache.py,sha256=ZW5iI5rmjq
|
|
88
89
|
prediction_market_agent_tooling/tools/caches/serializers.py,sha256=vFDx4fsPxclXp2q0sv27j4al_M_Tj9aR2JJP-xNHQXA,2151
|
89
90
|
prediction_market_agent_tooling/tools/contract.py,sha256=1ZFp_VoqTjM8cqOfAhco2Ht0DTqakjhZpuZUrAXr28Q,21332
|
90
91
|
prediction_market_agent_tooling/tools/costs.py,sha256=EaAJ7v9laD4VEV3d8B44M4u3_oEO_H16jRVCdoZ93Uw,954
|
91
|
-
prediction_market_agent_tooling/tools/cow/cow_order.py,sha256=
|
92
|
+
prediction_market_agent_tooling/tools/cow/cow_order.py,sha256=EC3xzYaY5cEh2cMBBzmNim6WYY1bRKYJNh_4wMccwU0,7671
|
92
93
|
prediction_market_agent_tooling/tools/custom_exceptions.py,sha256=Fh8z1fbwONvP4-j7AmV_PuEcoqb6-QXa9PJ9m7guMcM,93
|
93
94
|
prediction_market_agent_tooling/tools/datetime_utc.py,sha256=8_WackjtjC8zHXrhQFTGQ6e6Fz_6llWoKR4CSFvIv9I,2766
|
94
95
|
prediction_market_agent_tooling/tools/db/db_manager.py,sha256=GtzHH1NLl8HwqC8Z7s6eTlIQXuV0blxfaV2PeQrBnfQ,3013
|
@@ -119,10 +120,10 @@ prediction_market_agent_tooling/tools/tokens/main_token.py,sha256=1rbwpdCusPgQIV
|
|
119
120
|
prediction_market_agent_tooling/tools/tokens/token_utils.py,sha256=fhs-FH9m9IbzGa-30R3ZleSKLeKfLEDoJ7F5Om285Vk,1369
|
120
121
|
prediction_market_agent_tooling/tools/tokens/usd.py,sha256=yuW8iPPtcpP4eLH2nORMDAfztcq0Nv2ascSrCquF1f8,3115
|
121
122
|
prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
|
122
|
-
prediction_market_agent_tooling/tools/utils.py,sha256=
|
123
|
+
prediction_market_agent_tooling/tools/utils.py,sha256=AC2a68jwASMWuQi-w8twl8b_M52YwrEJ81abmuEaqMY,6661
|
123
124
|
prediction_market_agent_tooling/tools/web3_utils.py,sha256=zRq-eeBGWt8uUGN9G_WfjmJ0eVvO8aWE9S0Pz_Y6AOA,12342
|
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.
|
125
|
+
prediction_market_agent_tooling-0.63.9.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
|
126
|
+
prediction_market_agent_tooling-0.63.9.dist-info/METADATA,sha256=8GI888jIBmKnNzupIIL7Pem4RTVhl8-QO4J8-drwdJ4,8689
|
127
|
+
prediction_market_agent_tooling-0.63.9.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
128
|
+
prediction_market_agent_tooling-0.63.9.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
|
129
|
+
prediction_market_agent_tooling-0.63.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|