prediction-market-agent-tooling 0.25.0__py3-none-any.whl → 0.27.0__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/config.py +12 -29
- prediction_market_agent_tooling/deploy/agent.py +2 -4
- prediction_market_agent_tooling/markets/agent_market.py +8 -0
- prediction_market_agent_tooling/markets/markets.py +2 -3
- prediction_market_agent_tooling/markets/omen/data_models.py +9 -0
- prediction_market_agent_tooling/markets/omen/omen.py +52 -53
- prediction_market_agent_tooling/markets/omen/omen_contracts.py +29 -31
- prediction_market_agent_tooling/markets/omen/omen_resolving.py +15 -15
- prediction_market_agent_tooling/monitor/markets/omen.py +3 -5
- prediction_market_agent_tooling/monitor/markets/polymarket.py +2 -3
- prediction_market_agent_tooling/tools/contract.py +16 -16
- {prediction_market_agent_tooling-0.25.0.dist-info → prediction_market_agent_tooling-0.27.0.dist-info}/METADATA +1 -1
- {prediction_market_agent_tooling-0.25.0.dist-info → prediction_market_agent_tooling-0.27.0.dist-info}/RECORD +16 -16
- {prediction_market_agent_tooling-0.25.0.dist-info → prediction_market_agent_tooling-0.27.0.dist-info}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.25.0.dist-info → prediction_market_agent_tooling-0.27.0.dist-info}/WHEEL +0 -0
- {prediction_market_agent_tooling-0.25.0.dist-info → prediction_market_agent_tooling-0.27.0.dist-info}/entry_points.txt +0 -0
@@ -2,7 +2,6 @@ import typing as t
|
|
2
2
|
|
3
3
|
from gnosis.eth import EthereumClient
|
4
4
|
from gnosis.safe import Safe
|
5
|
-
from pydantic import BaseModel
|
6
5
|
from pydantic.types import SecretStr
|
7
6
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
8
7
|
|
@@ -58,6 +57,15 @@ class APIKeys(BaseSettings):
|
|
58
57
|
"BET_FROM_PRIVATE_KEY missing in the environment.",
|
59
58
|
)
|
60
59
|
|
60
|
+
@property
|
61
|
+
def bet_from_address(self) -> ChecksumAddress:
|
62
|
+
"""If the SAFE is available, we always route transactions via SAFE. Otherwise we use the EOA."""
|
63
|
+
return (
|
64
|
+
self.SAFE_ADDRESS
|
65
|
+
if self.SAFE_ADDRESS
|
66
|
+
else private_key_to_public_key(self.bet_from_private_key)
|
67
|
+
)
|
68
|
+
|
61
69
|
@property
|
62
70
|
def openai_api_key(self) -> SecretStr:
|
63
71
|
return check_not_none(
|
@@ -110,35 +118,10 @@ class APIKeys(BaseSettings):
|
|
110
118
|
if APIKeys.model_fields[k].annotation in SECRET_TYPES and v is not None
|
111
119
|
}
|
112
120
|
|
113
|
-
|
114
|
-
class PrivateCredentials(BaseModel):
|
115
|
-
private_key: PrivateKey
|
116
|
-
safe_address: ChecksumAddress | None
|
117
|
-
|
118
|
-
@property
|
119
|
-
def public_key(self) -> ChecksumAddress:
|
120
|
-
"""If the SAFE is available, we always route transactions via SAFE. Otherwise we use the EOA."""
|
121
|
-
return (
|
122
|
-
self.safe_address
|
123
|
-
if self.safe_address is not None
|
124
|
-
else private_key_to_public_key(self.private_key)
|
125
|
-
)
|
126
|
-
|
127
|
-
@property
|
128
|
-
def has_safe_address(self) -> bool:
|
129
|
-
return self.safe_address is not None
|
130
|
-
|
131
|
-
@staticmethod
|
132
|
-
def from_api_keys(api_keys: APIKeys) -> "PrivateCredentials":
|
133
|
-
return PrivateCredentials(
|
134
|
-
private_key=api_keys.bet_from_private_key,
|
135
|
-
safe_address=api_keys.SAFE_ADDRESS,
|
136
|
-
)
|
137
|
-
|
138
121
|
def check_if_is_safe_owner(self, ethereum_client: EthereumClient) -> bool:
|
139
|
-
if not self.
|
122
|
+
if not self.SAFE_ADDRESS:
|
140
123
|
raise ValueError("Cannot check ownership if safe_address is not defined.")
|
141
124
|
|
142
|
-
s = Safe(self.
|
143
|
-
public_key_from_signer = private_key_to_public_key(self.
|
125
|
+
s = Safe(self.SAFE_ADDRESS, ethereum_client) # type: ignore[abstract]
|
126
|
+
public_key_from_signer = private_key_to_public_key(self.bet_from_private_key)
|
144
127
|
return s.retrieve_is_owner(public_key_from_signer)
|
@@ -8,7 +8,7 @@ from datetime import datetime, timedelta
|
|
8
8
|
from pydantic import BaseModel, BeforeValidator
|
9
9
|
from typing_extensions import Annotated
|
10
10
|
|
11
|
-
from prediction_market_agent_tooling.config import APIKeys
|
11
|
+
from prediction_market_agent_tooling.config import APIKeys
|
12
12
|
from prediction_market_agent_tooling.deploy.constants import (
|
13
13
|
MARKET_TYPE_KEY,
|
14
14
|
REPOSITORY_KEY,
|
@@ -260,11 +260,9 @@ class DeployableTraderAgent(DeployableAgent):
|
|
260
260
|
"""
|
261
261
|
Executes actions that occur before bets are placed.
|
262
262
|
"""
|
263
|
-
private_credentials = PrivateCredentials.from_api_keys(APIKeys())
|
264
|
-
|
265
263
|
if market_type == MarketType.OMEN:
|
266
264
|
# Omen is specific, because the user (agent) needs to manually withdraw winnings from the market.
|
267
|
-
redeem_from_all_user_positions(
|
265
|
+
redeem_from_all_user_positions(APIKeys())
|
268
266
|
|
269
267
|
def process_bets(self, market_type: MarketType) -> None:
|
270
268
|
"""
|
@@ -2,10 +2,12 @@ import typing as t
|
|
2
2
|
from datetime import datetime
|
3
3
|
from enum import Enum
|
4
4
|
|
5
|
+
from eth_typing import ChecksumAddress
|
5
6
|
from pydantic import BaseModel, field_validator
|
6
7
|
|
7
8
|
from prediction_market_agent_tooling.gtypes import Probability
|
8
9
|
from prediction_market_agent_tooling.markets.data_models import (
|
10
|
+
Bet,
|
9
11
|
BetAmount,
|
10
12
|
Currency,
|
11
13
|
Position,
|
@@ -139,6 +141,12 @@ class AgentMarket(BaseModel):
|
|
139
141
|
def get_binary_market(id: str) -> "AgentMarket":
|
140
142
|
raise NotImplementedError("Subclasses must implement this method")
|
141
143
|
|
144
|
+
@staticmethod
|
145
|
+
def get_bets_made_since(
|
146
|
+
better_address: ChecksumAddress, start_time: datetime
|
147
|
+
) -> list[Bet]:
|
148
|
+
raise NotImplementedError("Subclasses must implement this method")
|
149
|
+
|
142
150
|
def is_resolved(self) -> bool:
|
143
151
|
return self.resolution is not None
|
144
152
|
|
@@ -2,7 +2,7 @@ import typing as t
|
|
2
2
|
from datetime import datetime, timedelta
|
3
3
|
from enum import Enum
|
4
4
|
|
5
|
-
from prediction_market_agent_tooling.config import APIKeys
|
5
|
+
from prediction_market_agent_tooling.config import APIKeys
|
6
6
|
from prediction_market_agent_tooling.markets.agent_market import (
|
7
7
|
AgentMarket,
|
8
8
|
FilterBy,
|
@@ -68,7 +68,6 @@ def have_bet_on_market_since(
|
|
68
68
|
keys: APIKeys, market: AgentMarket, since: timedelta
|
69
69
|
) -> bool:
|
70
70
|
start_time = utcnow() - since
|
71
|
-
credentials = PrivateCredentials.from_api_keys(keys)
|
72
71
|
recently_betted_questions = (
|
73
72
|
set(
|
74
73
|
get_manifold_market(b.contractId).question
|
@@ -85,7 +84,7 @@ def have_bet_on_market_since(
|
|
85
84
|
set(
|
86
85
|
b.title
|
87
86
|
for b in OmenSubgraphHandler().get_bets(
|
88
|
-
better_address=
|
87
|
+
better_address=keys.bet_from_address,
|
89
88
|
start_time=start_time,
|
90
89
|
)
|
91
90
|
)
|
@@ -15,6 +15,7 @@ from prediction_market_agent_tooling.gtypes import (
|
|
15
15
|
xDai,
|
16
16
|
)
|
17
17
|
from prediction_market_agent_tooling.markets.data_models import (
|
18
|
+
Bet,
|
18
19
|
BetAmount,
|
19
20
|
Currency,
|
20
21
|
ProfitAmount,
|
@@ -379,6 +380,14 @@ class OmenBet(BaseModel):
|
|
379
380
|
currency=Currency.xDai,
|
380
381
|
)
|
381
382
|
|
383
|
+
def to_bet(self) -> Bet:
|
384
|
+
return Bet(
|
385
|
+
amount=BetAmount(amount=self.collateralAmountUSD, currency=Currency.xDai),
|
386
|
+
outcome=self.boolean_outcome,
|
387
|
+
created_time=self.creation_datetime,
|
388
|
+
market_question=self.title,
|
389
|
+
)
|
390
|
+
|
382
391
|
def to_generic_resolved_bet(self) -> ResolvedBet:
|
383
392
|
if not self.fpmm.is_resolved_with_valid_answer:
|
384
393
|
raise ValueError(
|
@@ -5,7 +5,7 @@ from datetime import datetime
|
|
5
5
|
from web3 import Web3
|
6
6
|
from web3.constants import HASH_ZERO
|
7
7
|
|
8
|
-
from prediction_market_agent_tooling.config import APIKeys
|
8
|
+
from prediction_market_agent_tooling.config import APIKeys
|
9
9
|
from prediction_market_agent_tooling.gtypes import (
|
10
10
|
ChecksumAddress,
|
11
11
|
HexAddress,
|
@@ -24,6 +24,7 @@ from prediction_market_agent_tooling.markets.agent_market import (
|
|
24
24
|
SortBy,
|
25
25
|
)
|
26
26
|
from prediction_market_agent_tooling.markets.data_models import (
|
27
|
+
Bet,
|
27
28
|
BetAmount,
|
28
29
|
Currency,
|
29
30
|
Position,
|
@@ -135,10 +136,8 @@ class OmenAgentMarket(AgentMarket):
|
|
135
136
|
if amount.currency != self.currency:
|
136
137
|
raise ValueError(f"Omen bets are made in xDai. Got {amount.currency}.")
|
137
138
|
amount_xdai = xDai(amount.amount)
|
138
|
-
keys = APIKeys()
|
139
|
-
private_credentials = PrivateCredentials.from_api_keys(keys)
|
140
139
|
binary_omen_buy_outcome_tx(
|
141
|
-
|
140
|
+
api_keys=APIKeys(),
|
142
141
|
amount=amount_xdai,
|
143
142
|
market=self,
|
144
143
|
binary_outcome=outcome,
|
@@ -149,10 +148,8 @@ class OmenAgentMarket(AgentMarket):
|
|
149
148
|
def sell_tokens(
|
150
149
|
self, outcome: bool, amount: TokenAmount, auto_withdraw: bool = True
|
151
150
|
) -> None:
|
152
|
-
keys = APIKeys()
|
153
|
-
private_credentials = PrivateCredentials.from_api_keys(keys)
|
154
151
|
binary_omen_sell_outcome_tx(
|
155
|
-
|
152
|
+
api_keys=APIKeys(),
|
156
153
|
amount=xDai(amount.amount),
|
157
154
|
market=self,
|
158
155
|
binary_outcome=outcome,
|
@@ -205,9 +202,9 @@ class OmenAgentMarket(AgentMarket):
|
|
205
202
|
|
206
203
|
def redeem_positions(
|
207
204
|
self,
|
208
|
-
|
205
|
+
api_keys: APIKeys,
|
209
206
|
) -> None:
|
210
|
-
for_public_key =
|
207
|
+
for_public_key = api_keys.bet_from_address
|
211
208
|
market_is_redeemable = self.market_redeemable_by(user=for_public_key)
|
212
209
|
if not market_is_redeemable:
|
213
210
|
logger.debug(
|
@@ -215,9 +212,7 @@ class OmenAgentMarket(AgentMarket):
|
|
215
212
|
)
|
216
213
|
return None
|
217
214
|
|
218
|
-
omen_redeem_full_position_tx(
|
219
|
-
private_credentials=private_credentials, market=self
|
220
|
-
)
|
215
|
+
omen_redeem_full_position_tx(api_keys=api_keys, market=self)
|
221
216
|
|
222
217
|
@staticmethod
|
223
218
|
def from_data_model(model: OmenMarket) -> "OmenAgentMarket":
|
@@ -265,6 +260,16 @@ class OmenAgentMarket(AgentMarket):
|
|
265
260
|
)
|
266
261
|
)
|
267
262
|
|
263
|
+
@staticmethod
|
264
|
+
def get_bets_made_since(
|
265
|
+
better_address: ChecksumAddress, start_time: datetime
|
266
|
+
) -> list[Bet]:
|
267
|
+
bets = OmenSubgraphHandler().get_bets(
|
268
|
+
better_address=better_address, start_time=start_time
|
269
|
+
)
|
270
|
+
bets.sort(key=lambda x: x.creation_datetime)
|
271
|
+
return [b.to_bet() for b in bets]
|
272
|
+
|
268
273
|
def get_contract(
|
269
274
|
self,
|
270
275
|
) -> OmenFixedProductMarketMakerContract:
|
@@ -356,7 +361,7 @@ def pick_binary_market(
|
|
356
361
|
|
357
362
|
|
358
363
|
def omen_buy_outcome_tx(
|
359
|
-
|
364
|
+
api_keys: APIKeys,
|
360
365
|
amount: xDai,
|
361
366
|
market: OmenAgentMarket,
|
362
367
|
outcome: str,
|
@@ -367,7 +372,7 @@ def omen_buy_outcome_tx(
|
|
367
372
|
Bets the given amount of xDai for the given outcome in the given market.
|
368
373
|
"""
|
369
374
|
amount_wei = xdai_to_wei(amount)
|
370
|
-
from_address_checksummed =
|
375
|
+
from_address_checksummed = api_keys.bet_from_address
|
371
376
|
|
372
377
|
market_contract: OmenFixedProductMarketMakerContract = market.get_contract()
|
373
378
|
|
@@ -384,7 +389,7 @@ def omen_buy_outcome_tx(
|
|
384
389
|
expected_shares = remove_fraction(expected_shares, 0.01)
|
385
390
|
# Approve the market maker to withdraw our collateral token.
|
386
391
|
collateral_token_contract.approve(
|
387
|
-
|
392
|
+
api_keys=api_keys,
|
388
393
|
for_address=market_contract.address,
|
389
394
|
amount_wei=amount_wei,
|
390
395
|
web3=web3,
|
@@ -396,11 +401,11 @@ def omen_buy_outcome_tx(
|
|
396
401
|
)
|
397
402
|
if auto_deposit and collateral_token_balance < amount_wei:
|
398
403
|
collateral_token_contract.deposit(
|
399
|
-
|
404
|
+
api_keys=api_keys, amount_wei=amount_wei, web3=web3
|
400
405
|
)
|
401
406
|
# Buy shares using the deposited xDai in the collateral token.
|
402
407
|
market_contract.buy(
|
403
|
-
|
408
|
+
api_keys=api_keys,
|
404
409
|
amount_wei=amount_wei,
|
405
410
|
outcome_index=outcome_index,
|
406
411
|
min_outcome_tokens_to_buy=expected_shares,
|
@@ -409,7 +414,7 @@ def omen_buy_outcome_tx(
|
|
409
414
|
|
410
415
|
|
411
416
|
def binary_omen_buy_outcome_tx(
|
412
|
-
|
417
|
+
api_keys: APIKeys,
|
413
418
|
amount: xDai,
|
414
419
|
market: OmenAgentMarket,
|
415
420
|
binary_outcome: bool,
|
@@ -417,7 +422,7 @@ def binary_omen_buy_outcome_tx(
|
|
417
422
|
web3: Web3 | None = None,
|
418
423
|
) -> None:
|
419
424
|
omen_buy_outcome_tx(
|
420
|
-
|
425
|
+
api_keys=api_keys,
|
421
426
|
amount=amount,
|
422
427
|
market=market,
|
423
428
|
outcome=OMEN_TRUE_OUTCOME if binary_outcome else OMEN_FALSE_OUTCOME,
|
@@ -427,7 +432,7 @@ def binary_omen_buy_outcome_tx(
|
|
427
432
|
|
428
433
|
|
429
434
|
def omen_sell_outcome_tx(
|
430
|
-
|
435
|
+
api_keys: APIKeys,
|
431
436
|
amount: xDai, # The xDai value of shares to sell.
|
432
437
|
market: OmenAgentMarket,
|
433
438
|
outcome: str,
|
@@ -468,14 +473,14 @@ def omen_sell_outcome_tx(
|
|
468
473
|
|
469
474
|
# Approve the market maker to move our (all) conditional tokens.
|
470
475
|
conditional_token_contract.setApprovalForAll(
|
471
|
-
|
476
|
+
api_keys=api_keys,
|
472
477
|
for_address=market_contract.address,
|
473
478
|
approve=True,
|
474
479
|
web3=web3,
|
475
480
|
)
|
476
481
|
# Sell the shares.
|
477
482
|
market_contract.sell(
|
478
|
-
|
483
|
+
api_keys,
|
479
484
|
amount_wei,
|
480
485
|
outcome_index,
|
481
486
|
max_outcome_tokens_to_sell,
|
@@ -483,13 +488,11 @@ def omen_sell_outcome_tx(
|
|
483
488
|
)
|
484
489
|
if auto_withdraw:
|
485
490
|
# Optionally, withdraw from the collateral token back to the `from_address` wallet.
|
486
|
-
collateral_token.withdraw(
|
487
|
-
private_credentials=private_credentials, amount_wei=amount_wei, web3=web3
|
488
|
-
)
|
491
|
+
collateral_token.withdraw(api_keys=api_keys, amount_wei=amount_wei, web3=web3)
|
489
492
|
|
490
493
|
|
491
494
|
def binary_omen_sell_outcome_tx(
|
492
|
-
|
495
|
+
api_keys: APIKeys,
|
493
496
|
amount: xDai,
|
494
497
|
market: OmenAgentMarket,
|
495
498
|
binary_outcome: bool,
|
@@ -497,7 +500,7 @@ def binary_omen_sell_outcome_tx(
|
|
497
500
|
web3: Web3 | None = None,
|
498
501
|
) -> None:
|
499
502
|
omen_sell_outcome_tx(
|
500
|
-
|
503
|
+
api_keys=api_keys,
|
501
504
|
amount=amount,
|
502
505
|
market=market,
|
503
506
|
outcome=OMEN_TRUE_OUTCOME if binary_outcome else OMEN_FALSE_OUTCOME,
|
@@ -507,7 +510,7 @@ def binary_omen_sell_outcome_tx(
|
|
507
510
|
|
508
511
|
|
509
512
|
def omen_create_market_tx(
|
510
|
-
|
513
|
+
api_keys: APIKeys,
|
511
514
|
initial_funds: xDai,
|
512
515
|
question: str,
|
513
516
|
closing_time: datetime,
|
@@ -521,7 +524,7 @@ def omen_create_market_tx(
|
|
521
524
|
"""
|
522
525
|
Based on omen-exchange TypeScript code: https://github.com/protofire/omen-exchange/blob/b0b9a3e71b415d6becf21fe428e1c4fc0dad2e80/app/src/services/cpk/cpk.ts#L308
|
523
526
|
"""
|
524
|
-
from_address =
|
527
|
+
from_address = api_keys.bet_from_address
|
525
528
|
initial_funds_wei = xdai_to_wei(initial_funds)
|
526
529
|
|
527
530
|
realitio_contract = OmenRealitioContract()
|
@@ -544,7 +547,7 @@ def omen_create_market_tx(
|
|
544
547
|
|
545
548
|
# Approve the market maker to withdraw our collateral token.
|
546
549
|
collateral_token_contract.approve(
|
547
|
-
|
550
|
+
api_keys=api_keys,
|
548
551
|
for_address=factory_contract.address,
|
549
552
|
amount_wei=initial_funds_wei,
|
550
553
|
web3=web3,
|
@@ -560,13 +563,11 @@ def omen_create_market_tx(
|
|
560
563
|
and initial_funds_wei > 0
|
561
564
|
and collateral_token_balance < initial_funds_wei
|
562
565
|
):
|
563
|
-
collateral_token_contract.deposit(
|
564
|
-
private_credentials, initial_funds_wei, web3=web3
|
565
|
-
)
|
566
|
+
collateral_token_contract.deposit(api_keys, initial_funds_wei, web3=web3)
|
566
567
|
|
567
568
|
# Create the question on Realitio.
|
568
569
|
question_id = realitio_contract.askQuestion(
|
569
|
-
|
570
|
+
api_keys=api_keys,
|
570
571
|
question=question,
|
571
572
|
category=category,
|
572
573
|
outcomes=outcomes,
|
@@ -585,7 +586,7 @@ def omen_create_market_tx(
|
|
585
586
|
)
|
586
587
|
if not conditional_token_contract.does_condition_exists(condition_id, web3=web3):
|
587
588
|
conditional_token_contract.prepareCondition(
|
588
|
-
|
589
|
+
api_keys=api_keys,
|
589
590
|
question_id=question_id,
|
590
591
|
oracle_address=oracle_contract.address,
|
591
592
|
outcomes_slot_count=len(outcomes),
|
@@ -594,7 +595,7 @@ def omen_create_market_tx(
|
|
594
595
|
|
595
596
|
# Create the market.
|
596
597
|
create_market_receipt_tx = factory_contract.create2FixedProductMarketMaker(
|
597
|
-
|
598
|
+
api_keys=api_keys,
|
598
599
|
condition_id=condition_id,
|
599
600
|
fee=fee,
|
600
601
|
initial_funds_wei=initial_funds_wei,
|
@@ -613,13 +614,13 @@ def omen_create_market_tx(
|
|
613
614
|
|
614
615
|
|
615
616
|
def omen_fund_market_tx(
|
616
|
-
|
617
|
+
api_keys: APIKeys,
|
617
618
|
market: OmenAgentMarket,
|
618
619
|
funds: Wei,
|
619
620
|
auto_deposit: bool,
|
620
621
|
web3: Web3 | None = None,
|
621
622
|
) -> None:
|
622
|
-
from_address =
|
623
|
+
from_address = api_keys.bet_from_address
|
623
624
|
market_contract = market.get_contract()
|
624
625
|
collateral_token_contract = OmenCollateralTokenContract()
|
625
626
|
|
@@ -630,16 +631,16 @@ def omen_fund_market_tx(
|
|
630
631
|
and collateral_token_contract.balanceOf(for_address=from_address, web3=web3)
|
631
632
|
< funds
|
632
633
|
):
|
633
|
-
collateral_token_contract.deposit(
|
634
|
+
collateral_token_contract.deposit(api_keys, funds, web3=web3)
|
634
635
|
|
635
636
|
collateral_token_contract.approve(
|
636
|
-
|
637
|
+
api_keys=api_keys,
|
637
638
|
for_address=market_contract.address,
|
638
639
|
amount_wei=funds,
|
639
640
|
web3=web3,
|
640
641
|
)
|
641
642
|
|
642
|
-
market_contract.addFunding(
|
643
|
+
market_contract.addFunding(api_keys, funds, web3=web3)
|
643
644
|
|
644
645
|
|
645
646
|
def build_parent_collection_id() -> HexStr:
|
@@ -647,7 +648,7 @@ def build_parent_collection_id() -> HexStr:
|
|
647
648
|
|
648
649
|
|
649
650
|
def omen_redeem_full_position_tx(
|
650
|
-
|
651
|
+
api_keys: APIKeys,
|
651
652
|
market: OmenAgentMarket,
|
652
653
|
web3: Web3 | None = None,
|
653
654
|
) -> None:
|
@@ -656,7 +657,7 @@ def omen_redeem_full_position_tx(
|
|
656
657
|
to be redeemed before sending the transaction.
|
657
658
|
"""
|
658
659
|
|
659
|
-
from_address =
|
660
|
+
from_address = api_keys.bet_from_address
|
660
661
|
|
661
662
|
market_contract: OmenFixedProductMarketMakerContract = market.get_contract()
|
662
663
|
conditional_token_contract = OmenConditionalTokenContract()
|
@@ -686,7 +687,7 @@ def omen_redeem_full_position_tx(
|
|
686
687
|
return
|
687
688
|
|
688
689
|
conditional_token_contract.redeemPositions(
|
689
|
-
|
690
|
+
api_keys=api_keys,
|
690
691
|
collateral_token_address=market.collateral_token_contract_address_checksummed,
|
691
692
|
condition_id=market.condition.id,
|
692
693
|
parent_collection_id=parent_collection_id,
|
@@ -727,7 +728,7 @@ def get_conditional_tokens_balance_for_market(
|
|
727
728
|
|
728
729
|
|
729
730
|
def omen_remove_fund_market_tx(
|
730
|
-
|
731
|
+
api_keys: APIKeys,
|
731
732
|
market: OmenAgentMarket,
|
732
733
|
shares: Wei | None,
|
733
734
|
web3: Web3 | None = None,
|
@@ -740,7 +741,7 @@ def omen_remove_fund_market_tx(
|
|
740
741
|
After we remove funding, using the `mergePositions` we get `min(shares per index)` of wxDai back, but the remaining shares can be converted back only after the market is resolved.
|
741
742
|
That can be done using the `redeem_from_all_user_positions` function below.
|
742
743
|
"""
|
743
|
-
from_address =
|
744
|
+
from_address = api_keys.bet_from_address
|
744
745
|
market_contract = market.get_contract()
|
745
746
|
original_balances = get_balances(from_address, web3=web3)
|
746
747
|
|
@@ -755,9 +756,7 @@ def omen_remove_fund_market_tx(
|
|
755
756
|
)
|
756
757
|
shares = total_shares
|
757
758
|
|
758
|
-
market_contract.removeFunding(
|
759
|
-
private_credentials=private_credentials, remove_funding=shares, web3=web3
|
760
|
-
)
|
759
|
+
market_contract.removeFunding(api_keys=api_keys, remove_funding=shares, web3=web3)
|
761
760
|
|
762
761
|
conditional_tokens = OmenConditionalTokenContract()
|
763
762
|
parent_collection_id = build_parent_collection_id()
|
@@ -770,7 +769,7 @@ def omen_remove_fund_market_tx(
|
|
770
769
|
amount_to_merge = min(amount_per_index_set.values())
|
771
770
|
|
772
771
|
result = conditional_tokens.mergePositions(
|
773
|
-
|
772
|
+
api_keys=api_keys,
|
774
773
|
collateral_token_address=market.collateral_token_contract_address_checksummed,
|
775
774
|
parent_collection_id=parent_collection_id,
|
776
775
|
conditionId=market.condition.id,
|
@@ -788,13 +787,13 @@ def omen_remove_fund_market_tx(
|
|
788
787
|
|
789
788
|
|
790
789
|
def redeem_from_all_user_positions(
|
791
|
-
|
790
|
+
api_keys: APIKeys,
|
792
791
|
web3: Web3 | None = None,
|
793
792
|
) -> None:
|
794
793
|
"""
|
795
794
|
Redeems from all user positions where the user didn't redeem yet.
|
796
795
|
"""
|
797
|
-
public_key =
|
796
|
+
public_key = api_keys.bet_from_address
|
798
797
|
|
799
798
|
conditional_token_contract = OmenConditionalTokenContract()
|
800
799
|
user_positions = OmenSubgraphHandler().get_user_positions(
|
@@ -818,7 +817,7 @@ def redeem_from_all_user_positions(
|
|
818
817
|
|
819
818
|
original_balances = get_balances(public_key, web3)
|
820
819
|
conditional_token_contract.redeemPositions(
|
821
|
-
|
820
|
+
api_keys=api_keys,
|
822
821
|
collateral_token_address=user_position.position.collateral_token_contract_address_checksummed,
|
823
822
|
condition_id=condition_id,
|
824
823
|
parent_collection_id=build_parent_collection_id(),
|
@@ -6,7 +6,7 @@ from enum import Enum
|
|
6
6
|
|
7
7
|
from web3 import Web3
|
8
8
|
|
9
|
-
from prediction_market_agent_tooling.config import
|
9
|
+
from prediction_market_agent_tooling.config import APIKeys
|
10
10
|
from prediction_market_agent_tooling.gtypes import (
|
11
11
|
ABI,
|
12
12
|
ChecksumAddress,
|
@@ -51,7 +51,7 @@ class OmenOracleContract(ContractOnGnosisChain):
|
|
51
51
|
|
52
52
|
def resolve(
|
53
53
|
self,
|
54
|
-
|
54
|
+
api_keys: APIKeys,
|
55
55
|
question_id: HexBytes,
|
56
56
|
template_id: int,
|
57
57
|
question_raw: str,
|
@@ -59,7 +59,7 @@ class OmenOracleContract(ContractOnGnosisChain):
|
|
59
59
|
web3: Web3 | None = None,
|
60
60
|
) -> TxReceipt:
|
61
61
|
return self.send(
|
62
|
-
|
62
|
+
api_keys=api_keys,
|
63
63
|
function_name="resolve",
|
64
64
|
function_params=dict(
|
65
65
|
questionId=question_id,
|
@@ -138,7 +138,7 @@ class OmenConditionalTokenContract(ContractOnGnosisChain):
|
|
138
138
|
|
139
139
|
def mergePositions(
|
140
140
|
self,
|
141
|
-
|
141
|
+
api_keys: APIKeys,
|
142
142
|
collateral_token_address: ChecksumAddress,
|
143
143
|
parent_collection_id: HexStr,
|
144
144
|
conditionId: HexBytes,
|
@@ -147,7 +147,7 @@ class OmenConditionalTokenContract(ContractOnGnosisChain):
|
|
147
147
|
web3: Web3 | None = None,
|
148
148
|
) -> TxReceipt:
|
149
149
|
return self.send(
|
150
|
-
|
150
|
+
api_keys=api_keys,
|
151
151
|
function_name="mergePositions",
|
152
152
|
function_params=[
|
153
153
|
collateral_token_address,
|
@@ -161,7 +161,7 @@ class OmenConditionalTokenContract(ContractOnGnosisChain):
|
|
161
161
|
|
162
162
|
def redeemPositions(
|
163
163
|
self,
|
164
|
-
|
164
|
+
api_keys: APIKeys,
|
165
165
|
collateral_token_address: HexAddress,
|
166
166
|
condition_id: HexBytes,
|
167
167
|
parent_collection_id: HexStr,
|
@@ -169,7 +169,7 @@ class OmenConditionalTokenContract(ContractOnGnosisChain):
|
|
169
169
|
web3: Web3 | None = None,
|
170
170
|
) -> TxReceipt:
|
171
171
|
return self.send(
|
172
|
-
|
172
|
+
api_keys=api_keys,
|
173
173
|
function_name="redeemPositions",
|
174
174
|
function_params=[
|
175
175
|
collateral_token_address,
|
@@ -209,14 +209,14 @@ class OmenConditionalTokenContract(ContractOnGnosisChain):
|
|
209
209
|
|
210
210
|
def setApprovalForAll(
|
211
211
|
self,
|
212
|
-
|
212
|
+
api_keys: APIKeys,
|
213
213
|
for_address: ChecksumAddress,
|
214
214
|
approve: bool,
|
215
215
|
tx_params: t.Optional[TxParams] = None,
|
216
216
|
web3: Web3 | None = None,
|
217
217
|
) -> TxReceipt:
|
218
218
|
return self.send(
|
219
|
-
|
219
|
+
api_keys=api_keys,
|
220
220
|
function_name="setApprovalForAll",
|
221
221
|
function_params=[
|
222
222
|
for_address,
|
@@ -228,7 +228,7 @@ class OmenConditionalTokenContract(ContractOnGnosisChain):
|
|
228
228
|
|
229
229
|
def prepareCondition(
|
230
230
|
self,
|
231
|
-
|
231
|
+
api_keys: APIKeys,
|
232
232
|
oracle_address: ChecksumAddress,
|
233
233
|
question_id: HexBytes,
|
234
234
|
outcomes_slot_count: int,
|
@@ -236,7 +236,7 @@ class OmenConditionalTokenContract(ContractOnGnosisChain):
|
|
236
236
|
web3: Web3 | None = None,
|
237
237
|
) -> TxReceipt:
|
238
238
|
return self.send(
|
239
|
-
|
239
|
+
api_keys=api_keys,
|
240
240
|
function_name="prepareCondition",
|
241
241
|
function_params=[
|
242
242
|
oracle_address,
|
@@ -291,7 +291,7 @@ class OmenFixedProductMarketMakerContract(ContractOnGnosisChain):
|
|
291
291
|
|
292
292
|
def buy(
|
293
293
|
self,
|
294
|
-
|
294
|
+
api_keys: APIKeys,
|
295
295
|
amount_wei: Wei,
|
296
296
|
outcome_index: int,
|
297
297
|
min_outcome_tokens_to_buy: OmenOutcomeToken,
|
@@ -299,7 +299,7 @@ class OmenFixedProductMarketMakerContract(ContractOnGnosisChain):
|
|
299
299
|
web3: Web3 | None = None,
|
300
300
|
) -> TxReceipt:
|
301
301
|
return self.send(
|
302
|
-
|
302
|
+
api_keys=api_keys,
|
303
303
|
function_name="buy",
|
304
304
|
function_params=[
|
305
305
|
amount_wei,
|
@@ -312,7 +312,7 @@ class OmenFixedProductMarketMakerContract(ContractOnGnosisChain):
|
|
312
312
|
|
313
313
|
def sell(
|
314
314
|
self,
|
315
|
-
|
315
|
+
api_keys: APIKeys,
|
316
316
|
amount_wei: Wei,
|
317
317
|
outcome_index: int,
|
318
318
|
max_outcome_tokens_to_sell: OmenOutcomeToken,
|
@@ -320,7 +320,7 @@ class OmenFixedProductMarketMakerContract(ContractOnGnosisChain):
|
|
320
320
|
web3: Web3 | None = None,
|
321
321
|
) -> TxReceipt:
|
322
322
|
return self.send(
|
323
|
-
|
323
|
+
api_keys=api_keys,
|
324
324
|
function_name="sell",
|
325
325
|
function_params=[
|
326
326
|
amount_wei,
|
@@ -333,7 +333,7 @@ class OmenFixedProductMarketMakerContract(ContractOnGnosisChain):
|
|
333
333
|
|
334
334
|
def addFunding(
|
335
335
|
self,
|
336
|
-
|
336
|
+
api_keys: APIKeys,
|
337
337
|
add_funding: Wei,
|
338
338
|
tx_params: t.Optional[TxParams] = None,
|
339
339
|
web3: Web3 | None = None,
|
@@ -344,7 +344,7 @@ class OmenFixedProductMarketMakerContract(ContractOnGnosisChain):
|
|
344
344
|
# `addFunding` with `distribution_hint` can be used only during the market creation, so forcing empty here.
|
345
345
|
distribution_hint: list[int] = []
|
346
346
|
return self.send(
|
347
|
-
|
347
|
+
api_keys=api_keys,
|
348
348
|
function_name="addFunding",
|
349
349
|
function_params=[add_funding, distribution_hint],
|
350
350
|
tx_params=tx_params,
|
@@ -353,7 +353,7 @@ class OmenFixedProductMarketMakerContract(ContractOnGnosisChain):
|
|
353
353
|
|
354
354
|
def removeFunding(
|
355
355
|
self,
|
356
|
-
|
356
|
+
api_keys: APIKeys,
|
357
357
|
remove_funding: Wei,
|
358
358
|
tx_params: t.Optional[TxParams] = None,
|
359
359
|
web3: Web3 | None = None,
|
@@ -362,7 +362,7 @@ class OmenFixedProductMarketMakerContract(ContractOnGnosisChain):
|
|
362
362
|
Remove funding is done in shares.
|
363
363
|
"""
|
364
364
|
return self.send(
|
365
|
-
|
365
|
+
api_keys=api_keys,
|
366
366
|
function_name="removeFunding",
|
367
367
|
function_params=[remove_funding],
|
368
368
|
tx_params=tx_params,
|
@@ -407,7 +407,7 @@ class OmenFixedProductMarketMakerFactoryContract(ContractOnGnosisChain):
|
|
407
407
|
|
408
408
|
def create2FixedProductMarketMaker(
|
409
409
|
self,
|
410
|
-
|
410
|
+
api_keys: APIKeys,
|
411
411
|
condition_id: HexBytes,
|
412
412
|
initial_funds_wei: Wei,
|
413
413
|
fee: float = OMEN_DEFAULT_MARKET_FEE,
|
@@ -418,7 +418,7 @@ class OmenFixedProductMarketMakerFactoryContract(ContractOnGnosisChain):
|
|
418
418
|
xdai_type(fee)
|
419
419
|
) # We need to convert this to the wei units, but in reality it's % fee as stated in the `OMEN_DEFAULT_MARKET_FEE` variable.
|
420
420
|
return self.send(
|
421
|
-
|
421
|
+
api_keys=api_keys,
|
422
422
|
function_name="create2FixedProductMarketMaker",
|
423
423
|
function_params=dict(
|
424
424
|
saltNonce=random.randint(
|
@@ -491,7 +491,7 @@ class OmenRealitioContract(ContractOnGnosisChain):
|
|
491
491
|
|
492
492
|
def askQuestion(
|
493
493
|
self,
|
494
|
-
|
494
|
+
api_keys: APIKeys,
|
495
495
|
question: str,
|
496
496
|
category: str,
|
497
497
|
outcomes: list[str],
|
@@ -518,7 +518,7 @@ class OmenRealitioContract(ContractOnGnosisChain):
|
|
518
518
|
]
|
519
519
|
)
|
520
520
|
receipt_tx = self.send(
|
521
|
-
|
521
|
+
api_keys=api_keys,
|
522
522
|
function_name="askQuestion",
|
523
523
|
function_params=dict(
|
524
524
|
template_id=template_id,
|
@@ -540,7 +540,7 @@ class OmenRealitioContract(ContractOnGnosisChain):
|
|
540
540
|
|
541
541
|
def submitAnswer(
|
542
542
|
self,
|
543
|
-
|
543
|
+
api_keys: APIKeys,
|
544
544
|
question_id: HexBytes,
|
545
545
|
answer: str,
|
546
546
|
outcomes: list[str],
|
@@ -558,7 +558,7 @@ class OmenRealitioContract(ContractOnGnosisChain):
|
|
558
558
|
outcomes = [o.lower() for o in outcomes]
|
559
559
|
|
560
560
|
return self.send_with_value(
|
561
|
-
|
561
|
+
api_keys=api_keys,
|
562
562
|
function_name="submitAnswer",
|
563
563
|
function_params=dict(
|
564
564
|
question_id=question_id,
|
@@ -573,7 +573,7 @@ class OmenRealitioContract(ContractOnGnosisChain):
|
|
573
573
|
|
574
574
|
def claimWinnings(
|
575
575
|
self,
|
576
|
-
|
576
|
+
api_keys: APIKeys,
|
577
577
|
question_id: HexBytes,
|
578
578
|
history_hashes: list[HexBytes],
|
579
579
|
addresses: list[ChecksumAddress],
|
@@ -583,7 +583,7 @@ class OmenRealitioContract(ContractOnGnosisChain):
|
|
583
583
|
web3: Web3 | None = None,
|
584
584
|
) -> TxReceipt:
|
585
585
|
return self.send(
|
586
|
-
|
586
|
+
api_keys=api_keys,
|
587
587
|
function_name="claimWinnings",
|
588
588
|
function_params=dict(
|
589
589
|
question_id=question_id,
|
@@ -606,9 +606,7 @@ class OmenRealitioContract(ContractOnGnosisChain):
|
|
606
606
|
|
607
607
|
def withdraw(
|
608
608
|
self,
|
609
|
-
|
609
|
+
api_keys: APIKeys,
|
610
610
|
web3: Web3 | None = None,
|
611
611
|
) -> TxReceipt:
|
612
|
-
return self.send(
|
613
|
-
private_credentials=private_credentials, function_name="withdraw", web3=web3
|
614
|
-
)
|
612
|
+
return self.send(api_keys=api_keys, function_name="withdraw", web3=web3)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from web3 import Web3
|
2
2
|
|
3
|
-
from prediction_market_agent_tooling.config import
|
3
|
+
from prediction_market_agent_tooling.config import APIKeys
|
4
4
|
from prediction_market_agent_tooling.gtypes import (
|
5
5
|
ChecksumAddress,
|
6
6
|
HexAddress,
|
@@ -35,7 +35,7 @@ from prediction_market_agent_tooling.tools.web3_utils import ZERO_BYTES, xdai_to
|
|
35
35
|
|
36
36
|
|
37
37
|
def claim_bonds_on_realitio_questions(
|
38
|
-
|
38
|
+
api_keys: APIKeys,
|
39
39
|
questions: list[RealityQuestion],
|
40
40
|
auto_withdraw: bool,
|
41
41
|
web3: Web3 | None = None,
|
@@ -47,7 +47,7 @@ def claim_bonds_on_realitio_questions(
|
|
47
47
|
f"[{idx+1} / {len(questions)}] Claiming bond for {question.questionId=} {question.url=}"
|
48
48
|
)
|
49
49
|
claim_bonds_on_realitio_question(
|
50
|
-
|
50
|
+
api_keys, question, auto_withdraw=auto_withdraw, web3=web3
|
51
51
|
)
|
52
52
|
claimed_questions.append(question.questionId)
|
53
53
|
|
@@ -55,12 +55,12 @@ def claim_bonds_on_realitio_questions(
|
|
55
55
|
|
56
56
|
|
57
57
|
def claim_bonds_on_realitio_question(
|
58
|
-
|
58
|
+
api_keys: APIKeys,
|
59
59
|
question: RealityQuestion,
|
60
60
|
auto_withdraw: bool,
|
61
61
|
web3: Web3 | None = None,
|
62
62
|
) -> None:
|
63
|
-
public_key =
|
63
|
+
public_key = api_keys.bet_from_address
|
64
64
|
realitio_contract = OmenRealitioContract()
|
65
65
|
|
66
66
|
# Get all answers for the question.
|
@@ -105,7 +105,7 @@ def claim_bonds_on_realitio_question(
|
|
105
105
|
answers.append(answer.answer)
|
106
106
|
|
107
107
|
realitio_contract.claimWinnings(
|
108
|
-
|
108
|
+
api_keys=api_keys,
|
109
109
|
question_id=question.questionId,
|
110
110
|
history_hashes=history_hashes,
|
111
111
|
addresses=addresses,
|
@@ -118,11 +118,11 @@ def claim_bonds_on_realitio_question(
|
|
118
118
|
# Keeping balance on Realitio is not useful, so it's recommended to just withdraw it.
|
119
119
|
if current_balance > 0 and auto_withdraw:
|
120
120
|
logger.info(f"Withdrawing remaining balance {current_balance=}")
|
121
|
-
realitio_contract.withdraw(
|
121
|
+
realitio_contract.withdraw(api_keys, web3=web3)
|
122
122
|
|
123
123
|
|
124
124
|
def finalize_markets(
|
125
|
-
|
125
|
+
api_keys: APIKeys,
|
126
126
|
markets_with_resolutions: list[tuple[OmenMarket, Resolution | None]],
|
127
127
|
web3: Web3 | None = None,
|
128
128
|
) -> list[HexAddress]:
|
@@ -139,7 +139,7 @@ def finalize_markets(
|
|
139
139
|
elif resolution in (Resolution.YES, Resolution.NO):
|
140
140
|
logger.info(f"Found resolution {resolution.value=} for {market.url=}")
|
141
141
|
omen_submit_answer_market_tx(
|
142
|
-
|
142
|
+
api_keys,
|
143
143
|
market,
|
144
144
|
resolution,
|
145
145
|
OMEN_DEFAULT_REALITIO_BOND_VALUE,
|
@@ -155,7 +155,7 @@ def finalize_markets(
|
|
155
155
|
|
156
156
|
|
157
157
|
def resolve_markets(
|
158
|
-
|
158
|
+
api_keys: APIKeys,
|
159
159
|
markets: list[OmenMarket],
|
160
160
|
web3: Web3 | None = None,
|
161
161
|
) -> list[HexAddress]:
|
@@ -165,14 +165,14 @@ def resolve_markets(
|
|
165
165
|
logger.info(
|
166
166
|
f"[{idx+1} / {len(markets)}] Resolving {market.url=} {market.question_title=}"
|
167
167
|
)
|
168
|
-
omen_resolve_market_tx(
|
168
|
+
omen_resolve_market_tx(api_keys, market, web3=web3)
|
169
169
|
resolved_markets.append(market.id)
|
170
170
|
|
171
171
|
return resolved_markets
|
172
172
|
|
173
173
|
|
174
174
|
def omen_submit_answer_market_tx(
|
175
|
-
|
175
|
+
api_keys: APIKeys,
|
176
176
|
market: OmenMarket,
|
177
177
|
resolution: Resolution,
|
178
178
|
bond: xDai,
|
@@ -184,7 +184,7 @@ def omen_submit_answer_market_tx(
|
|
184
184
|
"""
|
185
185
|
realitio_contract = OmenRealitioContract()
|
186
186
|
realitio_contract.submitAnswer(
|
187
|
-
|
187
|
+
api_keys=api_keys,
|
188
188
|
question_id=market.question.id,
|
189
189
|
answer=resolution.value,
|
190
190
|
outcomes=market.question.outcomes,
|
@@ -194,7 +194,7 @@ def omen_submit_answer_market_tx(
|
|
194
194
|
|
195
195
|
|
196
196
|
def omen_resolve_market_tx(
|
197
|
-
|
197
|
+
api_keys: APIKeys,
|
198
198
|
market: OmenMarket,
|
199
199
|
web3: Web3 | None = None,
|
200
200
|
) -> None:
|
@@ -203,7 +203,7 @@ def omen_resolve_market_tx(
|
|
203
203
|
"""
|
204
204
|
oracle_contract = OmenOracleContract()
|
205
205
|
oracle_contract.resolve(
|
206
|
-
|
206
|
+
api_keys=api_keys,
|
207
207
|
question_id=market.question.id,
|
208
208
|
template_id=market.question.templateId,
|
209
209
|
question_raw=market.question.question_raw,
|
@@ -2,7 +2,7 @@ import typing as t
|
|
2
2
|
|
3
3
|
from google.cloud.functions_v2.types.functions import Function
|
4
4
|
|
5
|
-
from prediction_market_agent_tooling.config import APIKeys
|
5
|
+
from prediction_market_agent_tooling.config import APIKeys
|
6
6
|
from prediction_market_agent_tooling.deploy.constants import MARKET_TYPE_KEY
|
7
7
|
from prediction_market_agent_tooling.gtypes import ChecksumAddress, DatetimeWithTimezone
|
8
8
|
from prediction_market_agent_tooling.markets.data_models import ResolvedBet
|
@@ -49,8 +49,7 @@ class DeployedOmenAgent(DeployedAgent):
|
|
49
49
|
and api_keys.BET_FROM_PRIVATE_KEY
|
50
50
|
!= APIKeys().BET_FROM_PRIVATE_KEY # Check that it didn't get if from the default env.
|
51
51
|
):
|
52
|
-
|
53
|
-
env_vars["omen_public_key"] = private_credentials.public_key
|
52
|
+
env_vars["omen_public_key"] = api_keys.bet_from_address
|
54
53
|
return super().from_env_vars_without_prefix(
|
55
54
|
env_vars=env_vars, extra_vars=extra_vars
|
56
55
|
)
|
@@ -61,11 +60,10 @@ class DeployedOmenAgent(DeployedAgent):
|
|
61
60
|
start_time: DatetimeWithTimezone,
|
62
61
|
api_keys: APIKeys,
|
63
62
|
) -> "DeployedOmenAgent":
|
64
|
-
private_credentials = PrivateCredentials.from_api_keys(api_keys)
|
65
63
|
return DeployedOmenAgent(
|
66
64
|
name=name,
|
67
65
|
start_time=start_time,
|
68
|
-
omen_public_key=
|
66
|
+
omen_public_key=api_keys.bet_from_address,
|
69
67
|
)
|
70
68
|
|
71
69
|
@classmethod
|
@@ -2,7 +2,7 @@ import typing as t
|
|
2
2
|
|
3
3
|
from google.cloud.functions_v2.types.functions import Function
|
4
4
|
|
5
|
-
from prediction_market_agent_tooling.config import APIKeys
|
5
|
+
from prediction_market_agent_tooling.config import APIKeys
|
6
6
|
from prediction_market_agent_tooling.deploy.constants import MARKET_TYPE_KEY
|
7
7
|
from prediction_market_agent_tooling.gtypes import ChecksumAddress, DatetimeWithTimezone
|
8
8
|
from prediction_market_agent_tooling.markets.data_models import ResolvedBet
|
@@ -28,11 +28,10 @@ class DeployedPolymarketAgent(DeployedAgent):
|
|
28
28
|
start_time: DatetimeWithTimezone,
|
29
29
|
api_keys: APIKeys,
|
30
30
|
) -> "DeployedPolymarketAgent":
|
31
|
-
private_credentials = PrivateCredentials.from_api_keys(api_keys)
|
32
31
|
return DeployedPolymarketAgent(
|
33
32
|
name=name,
|
34
33
|
start_time=start_time,
|
35
|
-
polymarket_public_key=
|
34
|
+
polymarket_public_key=api_keys.bet_from_address,
|
36
35
|
)
|
37
36
|
|
38
37
|
@classmethod
|
@@ -6,7 +6,7 @@ from contextlib import contextmanager
|
|
6
6
|
from pydantic import BaseModel, field_validator
|
7
7
|
from web3 import Web3
|
8
8
|
|
9
|
-
from prediction_market_agent_tooling.config import
|
9
|
+
from prediction_market_agent_tooling.config import APIKeys
|
10
10
|
from prediction_market_agent_tooling.gtypes import (
|
11
11
|
ABI,
|
12
12
|
ChainID,
|
@@ -86,7 +86,7 @@ class ContractBaseClass(BaseModel):
|
|
86
86
|
|
87
87
|
def send(
|
88
88
|
self,
|
89
|
-
|
89
|
+
api_keys: APIKeys,
|
90
90
|
function_name: str,
|
91
91
|
function_params: t.Optional[list[t.Any] | dict[str, t.Any]] = None,
|
92
92
|
tx_params: t.Optional[TxParams] = None,
|
@@ -97,13 +97,13 @@ class ContractBaseClass(BaseModel):
|
|
97
97
|
Used for changing a state (writing) to the contract.
|
98
98
|
"""
|
99
99
|
|
100
|
-
if
|
100
|
+
if api_keys.SAFE_ADDRESS:
|
101
101
|
return send_function_on_contract_tx_using_safe(
|
102
102
|
web3=web3 or self.get_web3(),
|
103
103
|
contract_address=self.address,
|
104
104
|
contract_abi=self.abi,
|
105
|
-
from_private_key=
|
106
|
-
safe_address=
|
105
|
+
from_private_key=api_keys.bet_from_private_key,
|
106
|
+
safe_address=api_keys.SAFE_ADDRESS,
|
107
107
|
function_name=function_name,
|
108
108
|
function_params=function_params,
|
109
109
|
tx_params=tx_params,
|
@@ -113,7 +113,7 @@ class ContractBaseClass(BaseModel):
|
|
113
113
|
web3=web3 or self.get_web3(),
|
114
114
|
contract_address=self.address,
|
115
115
|
contract_abi=self.abi,
|
116
|
-
from_private_key=
|
116
|
+
from_private_key=api_keys.bet_from_private_key,
|
117
117
|
function_name=function_name,
|
118
118
|
function_params=function_params,
|
119
119
|
tx_params=tx_params,
|
@@ -122,7 +122,7 @@ class ContractBaseClass(BaseModel):
|
|
122
122
|
|
123
123
|
def send_with_value(
|
124
124
|
self,
|
125
|
-
|
125
|
+
api_keys: APIKeys,
|
126
126
|
function_name: str,
|
127
127
|
amount_wei: Wei,
|
128
128
|
function_params: t.Optional[list[t.Any] | dict[str, t.Any]] = None,
|
@@ -134,7 +134,7 @@ class ContractBaseClass(BaseModel):
|
|
134
134
|
Used for changing a state (writing) to the contract, including sending chain's native currency.
|
135
135
|
"""
|
136
136
|
return self.send(
|
137
|
-
|
137
|
+
api_keys=api_keys,
|
138
138
|
function_name=function_name,
|
139
139
|
function_params=function_params,
|
140
140
|
tx_params={"value": amount_wei, **(tx_params or {})},
|
@@ -158,14 +158,14 @@ class ContractERC20BaseClass(ContractBaseClass):
|
|
158
158
|
|
159
159
|
def approve(
|
160
160
|
self,
|
161
|
-
|
161
|
+
api_keys: APIKeys,
|
162
162
|
for_address: ChecksumAddress,
|
163
163
|
amount_wei: Wei,
|
164
164
|
tx_params: t.Optional[TxParams] = None,
|
165
165
|
web3: Web3 | None = None,
|
166
166
|
) -> TxReceipt:
|
167
167
|
return self.send(
|
168
|
-
|
168
|
+
api_keys=api_keys,
|
169
169
|
function_name="approve",
|
170
170
|
function_params=[
|
171
171
|
for_address,
|
@@ -177,13 +177,13 @@ class ContractERC20BaseClass(ContractBaseClass):
|
|
177
177
|
|
178
178
|
def deposit(
|
179
179
|
self,
|
180
|
-
|
180
|
+
api_keys: APIKeys,
|
181
181
|
amount_wei: Wei,
|
182
182
|
tx_params: t.Optional[TxParams] = None,
|
183
183
|
web3: Web3 | None = None,
|
184
184
|
) -> TxReceipt:
|
185
185
|
return self.send_with_value(
|
186
|
-
|
186
|
+
api_keys=api_keys,
|
187
187
|
function_name="deposit",
|
188
188
|
amount_wei=amount_wei,
|
189
189
|
tx_params=tx_params,
|
@@ -192,7 +192,7 @@ class ContractERC20BaseClass(ContractBaseClass):
|
|
192
192
|
|
193
193
|
def transferFrom(
|
194
194
|
self,
|
195
|
-
|
195
|
+
api_keys: APIKeys,
|
196
196
|
sender: ChecksumAddress,
|
197
197
|
recipient: ChecksumAddress,
|
198
198
|
amount_wei: Wei,
|
@@ -200,7 +200,7 @@ class ContractERC20BaseClass(ContractBaseClass):
|
|
200
200
|
web3: Web3 | None = None,
|
201
201
|
) -> TxReceipt:
|
202
202
|
return self.send(
|
203
|
-
|
203
|
+
api_keys=api_keys,
|
204
204
|
function_name="transferFrom",
|
205
205
|
function_params=[sender, recipient, amount_wei],
|
206
206
|
tx_params=tx_params,
|
@@ -209,13 +209,13 @@ class ContractERC20BaseClass(ContractBaseClass):
|
|
209
209
|
|
210
210
|
def withdraw(
|
211
211
|
self,
|
212
|
-
|
212
|
+
api_keys: APIKeys,
|
213
213
|
amount_wei: Wei,
|
214
214
|
tx_params: t.Optional[TxParams] = None,
|
215
215
|
web3: Web3 | None = None,
|
216
216
|
) -> TxReceipt:
|
217
217
|
return self.send(
|
218
|
-
|
218
|
+
api_keys=api_keys,
|
219
219
|
function_name="withdraw",
|
220
220
|
function_params=[amount_wei],
|
221
221
|
tx_params=tx_params,
|
@@ -11,8 +11,8 @@ prediction_market_agent_tooling/benchmark/__init__.py,sha256=47DEQpj8HBSa-_TImW-
|
|
11
11
|
prediction_market_agent_tooling/benchmark/agents.py,sha256=HPIFJvackW110ch3UkktbxhU48gMRVo4gQse84Klhdc,4000
|
12
12
|
prediction_market_agent_tooling/benchmark/benchmark.py,sha256=xiHKzZx5GHSsDerFHMZ9j_LXAXnSaITSvv67iPe3MEU,21095
|
13
13
|
prediction_market_agent_tooling/benchmark/utils.py,sha256=iS1BzyXcCMfMm1Rx--1QCH0pHvBTblTndcDQFbTUJ2s,2897
|
14
|
-
prediction_market_agent_tooling/config.py,sha256=
|
15
|
-
prediction_market_agent_tooling/deploy/agent.py,sha256=
|
14
|
+
prediction_market_agent_tooling/config.py,sha256=yELIlzAm2yBwZzGRvHtHBZZV3NZy5CllJfo3chMQMo0,4297
|
15
|
+
prediction_market_agent_tooling/deploy/agent.py,sha256=P4MaueaXpNakAWXhB0EYsWLNRXSeRisaN55IVDb8AR8,10187
|
16
16
|
prediction_market_agent_tooling/deploy/agent_example.py,sha256=tqXVA2HSFK3pdZ49tMmta8aKdJFT8JN8WeJ1akjrpBk,909
|
17
17
|
prediction_market_agent_tooling/deploy/constants.py,sha256=M5ty8URipYMGe_G-RzxRydK3AFL6CyvmqCraJUrLBnE,82
|
18
18
|
prediction_market_agent_tooling/deploy/gcp/deploy.py,sha256=CYUgnfy-9XVk04kkxA_5yp0GE9Mw5caYqlFUZQ2j3ks,3739
|
@@ -20,7 +20,7 @@ prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py,sha256=qYIHRxQLa
|
|
20
20
|
prediction_market_agent_tooling/deploy/gcp/utils.py,sha256=oyW0jgrUT2Tr49c7GlpcMsYNQjoCSOcWis3q-MmVAhU,6089
|
21
21
|
prediction_market_agent_tooling/gtypes.py,sha256=xGSJXw12hzp8LwvQ956l01GiZMWd07MZTYqo8CXVeLY,2417
|
22
22
|
prediction_market_agent_tooling/loggers.py,sha256=0znHrzxSbeBaDiB920EZC6a2TiF0tw80Sa_yoLwvo_w,2289
|
23
|
-
prediction_market_agent_tooling/markets/agent_market.py,sha256=
|
23
|
+
prediction_market_agent_tooling/markets/agent_market.py,sha256=b2gsqEXADJir_LxcNUmzEfxGCcJ_V5mWPGM2SZfIA6M,6250
|
24
24
|
prediction_market_agent_tooling/markets/categorize.py,sha256=yTd-lDMPW4ESDSzmxeLLBuzLX0FggOF7Vbswh7295o0,941
|
25
25
|
prediction_market_agent_tooling/markets/data_models.py,sha256=uODY3aoFp8YYeLAUcrzMk1yU8pIKsTLobB9xIEGTmKs,1170
|
26
26
|
prediction_market_agent_tooling/markets/manifold/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -28,12 +28,12 @@ prediction_market_agent_tooling/markets/manifold/api.py,sha256=m6qOzDiyQfxj62Eo_
|
|
28
28
|
prediction_market_agent_tooling/markets/manifold/data_models.py,sha256=2DZIxwtDp-PH0UWTGiktMFIGAAQoVutI07UsxjNyTyE,5296
|
29
29
|
prediction_market_agent_tooling/markets/manifold/manifold.py,sha256=DJZ88r5BGtAugUw5SIyDfzK1S70titba_fwT7OYXuAY,3896
|
30
30
|
prediction_market_agent_tooling/markets/manifold/utils.py,sha256=cPPFWXm3vCYH1jy7_ctJZuQH9ZDaPL4_AgAYzGWkoow,513
|
31
|
-
prediction_market_agent_tooling/markets/markets.py,sha256=
|
31
|
+
prediction_market_agent_tooling/markets/markets.py,sha256=w05Oo7yCA2axpCw69Q9y4i9Gcdpht0u5bZGbWqld3rU,2964
|
32
32
|
prediction_market_agent_tooling/markets/omen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
33
|
-
prediction_market_agent_tooling/markets/omen/data_models.py,sha256=
|
34
|
-
prediction_market_agent_tooling/markets/omen/omen.py,sha256=
|
35
|
-
prediction_market_agent_tooling/markets/omen/omen_contracts.py,sha256=
|
36
|
-
prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256
|
33
|
+
prediction_market_agent_tooling/markets/omen/data_models.py,sha256=f7RO1Zvytii-M2koGuLQiPERjTq_DsDjrT01mar_sX4,14398
|
34
|
+
prediction_market_agent_tooling/markets/omen/omen.py,sha256=YcM9AbBUOJ1xoZTI9UlHZTSNR4T1cTwyl3lZlXy2qbs,31209
|
35
|
+
prediction_market_agent_tooling/markets/omen/omen_contracts.py,sha256=eDS8vN4Klv_-Y1wwfIeLDt3twhl9U_AJjPQov0JScb0,19888
|
36
|
+
prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256=-qssaOJweI_QktR7bQiYjn-V6T_bBTQOH9qQjG35D48,8809
|
37
37
|
prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=QZWwkqvOqQ-b15jidwTNsn1K64x3FY_Un-l6A6g3Twg,22299
|
38
38
|
prediction_market_agent_tooling/markets/polymarket/api.py,sha256=p1JkqL9kF8C04qbmqFzF0hgtzD5kN3yup2hYOjxazQ4,4188
|
39
39
|
prediction_market_agent_tooling/markets/polymarket/data_models.py,sha256=srTl8-0FM76AGLRDWzjLpf46ikWloaBCgkn0XqZoKCI,4248
|
@@ -42,8 +42,8 @@ prediction_market_agent_tooling/markets/polymarket/polymarket.py,sha256=zqGfiUOH
|
|
42
42
|
prediction_market_agent_tooling/markets/polymarket/utils.py,sha256=Gwd2kOK_DrsjtyqgO6ob8oK7tjsB1Yo-Hf7IS5UGnio,1960
|
43
43
|
prediction_market_agent_tooling/monitor/langfuse/langfuse_wrapper.py,sha256=b6T69YB1x8kSUvW9uRFuSWPLOrXzapZG7m5O5SU0QTQ,895
|
44
44
|
prediction_market_agent_tooling/monitor/markets/manifold.py,sha256=GdYpgRX1GahDi-75Mr53jgtEg6nWcs_rHDUkg4o_7dQ,3352
|
45
|
-
prediction_market_agent_tooling/monitor/markets/omen.py,sha256=
|
46
|
-
prediction_market_agent_tooling/monitor/markets/polymarket.py,sha256=
|
45
|
+
prediction_market_agent_tooling/monitor/markets/omen.py,sha256=jOLPnIbDU9syjnYtHfOb2xa6-Ize3vbplgh-8WWkuT4,3323
|
46
|
+
prediction_market_agent_tooling/monitor/markets/polymarket.py,sha256=I9z9aO1wncyGI3a09ihrw17JkeBKjAuMmC0I9pl_9o4,1781
|
47
47
|
prediction_market_agent_tooling/monitor/monitor.py,sha256=elvCqCASCd3fOnM7f2kajb_Oy3RMUmGh88jzpworrEU,13387
|
48
48
|
prediction_market_agent_tooling/monitor/monitor_app.py,sha256=rDxgdDJqSK0ARx0TJFMkS76npkHZJz0__Rp0xTpiRok,4611
|
49
49
|
prediction_market_agent_tooling/monitor/monitor_settings.py,sha256=Xiozs3AsufuJ04JOe1vjUri-IAMWHjjmc2ugGGiHNH4,947
|
@@ -54,7 +54,7 @@ prediction_market_agent_tooling/tools/betting_strategies/market_moving.py,sha256
|
|
54
54
|
prediction_market_agent_tooling/tools/betting_strategies/minimum_bet_to_win.py,sha256=-FUSuQQgjcWSSnoFxnlAyTeilY6raJABJVM2QKkFqAY,438
|
55
55
|
prediction_market_agent_tooling/tools/betting_strategies/stretch_bet_between.py,sha256=THMXwFlskvzbjnX_OiYtDSzI8XVFyULWfP2525_9UGc,429
|
56
56
|
prediction_market_agent_tooling/tools/cache.py,sha256=tGHHd9HCiE_hCCtPtloHZQdDfBuiow9YsqJNYi2Tx_0,499
|
57
|
-
prediction_market_agent_tooling/tools/contract.py,sha256=
|
57
|
+
prediction_market_agent_tooling/tools/contract.py,sha256=fWYQAJhLLBasEJCiJqZEiXOgJ3dO9Mknppdsd1gHchc,6999
|
58
58
|
prediction_market_agent_tooling/tools/costs.py,sha256=EaAJ7v9laD4VEV3d8B44M4u3_oEO_H16jRVCdoZ93Uw,954
|
59
59
|
prediction_market_agent_tooling/tools/gnosis_rpc.py,sha256=_MYSoyOR2MgAJkop1ERf8RhLum-M8S6OjaAsaqUW41w,203
|
60
60
|
prediction_market_agent_tooling/tools/google.py,sha256=SfVDxb3oEOUK8mpd0l3mTX9ybrdrTPNM6HjfJ7kfNjA,1794
|
@@ -65,8 +65,8 @@ prediction_market_agent_tooling/tools/safe.py,sha256=h0xOO0eNtitClf0fPkn-0oTc6A_
|
|
65
65
|
prediction_market_agent_tooling/tools/singleton.py,sha256=CiIELUiI-OeS7U7eeHEt0rnVhtQGzwoUdAgn_7u_GBM,729
|
66
66
|
prediction_market_agent_tooling/tools/utils.py,sha256=zkmwPi3YisgZDPCeNwaRbL8sInOYOkvFgFY4Q8PbEo4,5077
|
67
67
|
prediction_market_agent_tooling/tools/web3_utils.py,sha256=cboATXNmEdn5RmPbVblHOwOdUMKBYrUK3GiI6i6Vzxo,9855
|
68
|
-
prediction_market_agent_tooling-0.
|
69
|
-
prediction_market_agent_tooling-0.
|
70
|
-
prediction_market_agent_tooling-0.
|
71
|
-
prediction_market_agent_tooling-0.
|
72
|
-
prediction_market_agent_tooling-0.
|
68
|
+
prediction_market_agent_tooling-0.27.0.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
|
69
|
+
prediction_market_agent_tooling-0.27.0.dist-info/METADATA,sha256=EOgPmMy7tmfMsgdKgxB_zVCFZN8YQO5n49IazPE9gJA,5465
|
70
|
+
prediction_market_agent_tooling-0.27.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
71
|
+
prediction_market_agent_tooling-0.27.0.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
|
72
|
+
prediction_market_agent_tooling-0.27.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|