Markets Module
prediction_market_agent_tooling.markets
agent_market
ProcessedMarket
Bases: BaseModel
answer
instance-attribute
answer: CategoricalProbabilisticAnswer
ProcessedTradedMarket
Bases: ProcessedMarket
trades
instance-attribute
trades: list[PlacedTrade]
answer
instance-attribute
answer: CategoricalProbabilisticAnswer
SortBy
Bases: str, Enum
CLOSING_SOONEST
class-attribute
instance-attribute
CLOSING_SOONEST = 'closing-soonest'
NEWEST
class-attribute
instance-attribute
NEWEST = 'newest'
HIGHEST_LIQUIDITY
class-attribute
instance-attribute
HIGHEST_LIQUIDITY = 'highest_liquidity'
LOWEST_LIQUIDITY
class-attribute
instance-attribute
LOWEST_LIQUIDITY = 'lowest_liquidity'
NONE
class-attribute
instance-attribute
NONE = 'none'
FilterBy
Bases: str, Enum
OPEN
class-attribute
instance-attribute
OPEN = 'open'
RESOLVED
class-attribute
instance-attribute
RESOLVED = 'resolved'
NONE
class-attribute
instance-attribute
NONE = 'none'
AgentMarket
Bases: BaseModel
Common market class that can be created from vendor specific markets. Contains everything that is needed for an agent to make a prediction.
base_url
class-attribute
base_url: str
id
instance-attribute
id: str
question
instance-attribute
question: str
description
instance-attribute
description: str | None
outcomes
instance-attribute
outcomes: Sequence[OutcomeStr]
outcome_token_pool
instance-attribute
outcome_token_pool: dict[OutcomeStr, OutcomeToken] | None
resolution
instance-attribute
resolution: Resolution | None
created_time
instance-attribute
created_time: DatetimeUTC | None
close_time
instance-attribute
close_time: DatetimeUTC | None
probabilities
instance-attribute
probabilities: dict[OutcomeStr, Probability]
url
instance-attribute
url: str
volume
instance-attribute
volume: CollateralToken | None
fees
instance-attribute
fees: MarketFees
is_binary
property
is_binary: bool
p_yes
property
p_yes: Probability
p_no
property
p_no: Probability
probable_resolution
property
probable_resolution: Resolution
validate_probabilities
validate_probabilities(
probs: dict[OutcomeStr, Probability],
info: FieldValidationInfo,
) -> dict[OutcomeStr, Probability]
Source code in prediction_market_agent_tooling/markets/agent_market.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
validate_outcome_token_pool
validate_outcome_token_pool(
outcome_token_pool: dict[str, OutcomeToken] | None,
info: FieldValidationInfo,
) -> dict[str, OutcomeToken] | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
have_bet_on_market_since
have_bet_on_market_since(
keys: APIKeys, since: timedelta
) -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
119 120 | |
get_outcome_token_pool_by_outcome
get_outcome_token_pool_by_outcome(
outcome: OutcomeStr,
) -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
122 123 124 125 126 127 128 | |
handle_legacy_fee
handle_legacy_fee(data: dict[str, Any]) -> dict[str, t.Any]
Source code in prediction_market_agent_tooling/markets/agent_market.py
130 131 132 133 134 135 136 | |
market_outcome_for_probability_key
market_outcome_for_probability_key(
probability_key: OutcomeStr,
) -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/agent_market.py
138 139 140 141 142 143 144 145 146 | |
probability_for_market_outcome
probability_for_market_outcome(
market_outcome: OutcomeStr,
) -> Probability
Source code in prediction_market_agent_tooling/markets/agent_market.py
148 149 150 151 152 153 154 | |
get_last_trade_p_yes
get_last_trade_p_yes() -> Probability | None
Get the last trade price for the YES outcome. This can be different from the current p_yes, for example if market is closed and it's probabilities are fixed to 0 and 1. Could be None if no trades were made.
Source code in prediction_market_agent_tooling/markets/agent_market.py
195 196 197 198 199 200 | |
get_last_trade_p_no
get_last_trade_p_no() -> Probability | None
Get the last trade price for the NO outcome. This can be different from the current p_yes, for example if market is closed and it's probabilities are fixed to 0 and 1. Could be None if no trades were made.
Source code in prediction_market_agent_tooling/markets/agent_market.py
202 203 204 205 206 207 | |
get_last_trade_yes_outcome_price
get_last_trade_yes_outcome_price() -> (
CollateralToken | None
)
Source code in prediction_market_agent_tooling/markets/agent_market.py
209 210 211 212 213 214 | |
get_last_trade_yes_outcome_price_usd
get_last_trade_yes_outcome_price_usd() -> USD | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
216 217 218 219 | |
get_last_trade_no_outcome_price
get_last_trade_no_outcome_price() -> CollateralToken | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
221 222 223 224 225 226 | |
get_last_trade_no_outcome_price_usd
get_last_trade_no_outcome_price_usd() -> USD | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
228 229 230 231 | |
get_liquidatable_amount
get_liquidatable_amount() -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
233 234 235 | |
get_token_in_usd
get_token_in_usd(x: CollateralToken) -> USD
Token of this market can have whatever worth (e.g. sDai and ETH markets will have different worth of 1 token). Use this to convert it to USD.
Source code in prediction_market_agent_tooling/markets/agent_market.py
237 238 239 240 241 | |
get_usd_in_token
get_usd_in_token(x: USD) -> CollateralToken
Markets on a single platform can have different tokens as collateral (sDai, wxDai, GNO, ...). Use this to convert USD to the token of this market.
Source code in prediction_market_agent_tooling/markets/agent_market.py
243 244 245 246 247 | |
get_sell_value_of_outcome_token
get_sell_value_of_outcome_token(
outcome: OutcomeStr, amount: OutcomeToken
) -> CollateralToken
When you hold OutcomeToken(s), it's easy to calculate how much you get at the end if you win (1 OutcomeToken will equal to 1 Token). But use this to figure out, how much are these outcome tokens worth right now (for how much you can sell them).
Source code in prediction_market_agent_tooling/markets/agent_market.py
249 250 251 252 253 254 255 256 | |
get_in_usd
get_in_usd(x: USD | CollateralToken) -> USD
Source code in prediction_market_agent_tooling/markets/agent_market.py
258 259 260 261 | |
get_in_token
get_in_token(x: USD | CollateralToken) -> CollateralToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
263 264 265 266 | |
get_tiny_bet_amount
get_tiny_bet_amount() -> CollateralToken
Tiny bet amount that the platform still allows us to do.
Source code in prediction_market_agent_tooling/markets/agent_market.py
268 269 270 271 272 | |
liquidate_existing_positions
liquidate_existing_positions(outcome: OutcomeStr) -> None
Source code in prediction_market_agent_tooling/markets/agent_market.py
274 275 | |
place_bet
place_bet(outcome: OutcomeStr, amount: USD) -> str
Source code in prediction_market_agent_tooling/markets/agent_market.py
277 278 | |
buy_tokens
buy_tokens(outcome: OutcomeStr, amount: USD) -> str
Source code in prediction_market_agent_tooling/markets/agent_market.py
280 281 | |
get_buy_token_amount
get_buy_token_amount(
bet_amount: USD | CollateralToken, outcome: OutcomeStr
) -> OutcomeToken | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
283 284 285 286 | |
sell_tokens
sell_tokens(
outcome: OutcomeStr, amount: USD | OutcomeToken
) -> str
Source code in prediction_market_agent_tooling/markets/agent_market.py
288 289 | |
compute_fpmm_probabilities
staticmethod
compute_fpmm_probabilities(
balances: list[OutcomeWei],
) -> list[Probability]
Compute the implied probabilities in a Fixed Product Market Maker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
balances
|
List[float]
|
Balances of outcome tokens. |
required |
Returns:
| Type | Description |
|---|---|
list[Probability]
|
List[float]: Implied probabilities for each outcome. |
Source code in prediction_market_agent_tooling/markets/agent_market.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
build_probability_map_from_p_yes
staticmethod
build_probability_map_from_p_yes(
p_yes: Probability,
) -> dict[OutcomeStr, Probability]
Source code in prediction_market_agent_tooling/markets/agent_market.py
321 322 323 324 325 326 327 328 | |
build_probability_map
staticmethod
build_probability_map(
outcome_token_amounts: list[OutcomeWei],
outcomes: list[OutcomeStr],
) -> dict[OutcomeStr, Probability]
Source code in prediction_market_agent_tooling/markets/agent_market.py
330 331 332 333 334 335 | |
get_markets
staticmethod
get_markets(
limit: int,
sort_by: SortBy,
filter_by: FilterBy = FilterBy.OPEN,
created_after: Optional[DatetimeUTC] = None,
excluded_questions: set[str] | None = None,
fetch_categorical_markets: bool = False,
) -> t.Sequence[AgentMarket]
Source code in prediction_market_agent_tooling/markets/agent_market.py
337 338 339 340 341 342 343 344 345 346 | |
get_binary_market
staticmethod
get_binary_market(id: str) -> AgentMarket
Source code in prediction_market_agent_tooling/markets/agent_market.py
348 349 350 | |
redeem_winnings
staticmethod
redeem_winnings(api_keys: APIKeys) -> None
On some markets (like Omen), it's needed to manually claim the winner bets. If it's not needed, just implement with pass.
Source code in prediction_market_agent_tooling/markets/agent_market.py
352 353 354 355 356 357 | |
get_trade_balance
classmethod
get_trade_balance(api_keys: APIKeys) -> USD
Return balance that can be used to trade on the given market.
Source code in prediction_market_agent_tooling/markets/agent_market.py
359 360 361 362 363 364 | |
verify_operational_balance
staticmethod
verify_operational_balance(api_keys: APIKeys) -> bool
Return True if the user has enough of operational balance. If not needed, just return True.
For example: Omen needs at least some xDai in the wallet to execute transactions.
Source code in prediction_market_agent_tooling/markets/agent_market.py
366 367 368 369 370 371 372 | |
store_prediction
store_prediction(
processed_market: ProcessedMarket | None,
keys: APIKeys,
agent_name: str,
) -> None
If market allows to upload predictions somewhere, implement it in this method.
Source code in prediction_market_agent_tooling/markets/agent_market.py
374 375 376 377 378 379 380 381 382 383 | |
store_trades
store_trades(
traded_market: ProcessedTradedMarket | None,
keys: APIKeys,
agent_name: str,
web3: Web3 | None = None,
) -> None
If market allows to upload trades somewhere, implement it in this method.
Source code in prediction_market_agent_tooling/markets/agent_market.py
385 386 387 388 389 390 391 392 393 394 395 | |
get_bets_made_since
staticmethod
get_bets_made_since(
better_address: ChecksumAddress, start_time: DatetimeUTC
) -> list[Bet]
Source code in prediction_market_agent_tooling/markets/agent_market.py
397 398 399 400 401 | |
get_resolved_bets_made_since
staticmethod
get_resolved_bets_made_since(
better_address: ChecksumAddress,
start_time: DatetimeUTC,
end_time: DatetimeUTC | None,
) -> list[ResolvedBet]
Source code in prediction_market_agent_tooling/markets/agent_market.py
403 404 405 406 407 408 409 | |
is_closed
is_closed() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
411 412 | |
is_resolved
is_resolved() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
414 415 | |
get_liquidity
get_liquidity() -> CollateralToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
417 418 | |
has_liquidity
has_liquidity() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
420 421 | |
has_successful_resolution
has_successful_resolution() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
423 424 425 426 427 428 | |
has_unsuccessful_resolution
has_unsuccessful_resolution() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
430 431 | |
get_outcome_str_from_bool
staticmethod
get_outcome_str_from_bool(outcome: bool) -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/agent_market.py
433 434 435 | |
get_outcome_str
get_outcome_str(outcome_index: int) -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/agent_market.py
437 438 439 440 441 442 443 | |
get_outcome_index
get_outcome_index(outcome: OutcomeStr) -> int
Source code in prediction_market_agent_tooling/markets/agent_market.py
445 446 447 448 449 450 | |
get_token_balance
get_token_balance(
user_id: str, outcome: OutcomeStr
) -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
452 453 | |
get_position
get_position(user_id: str) -> ExistingPosition | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
455 456 | |
get_positions
classmethod
get_positions(
user_id: str,
liquid_only: bool = False,
larger_than: OutcomeToken = OutcomeToken(0),
) -> t.Sequence[ExistingPosition]
Get all non-zero positions a user has in any market.
If liquid_only is True, only return positions that can be sold.
If larger_than is not None, only return positions with a larger number
of tokens than this amount.
Source code in prediction_market_agent_tooling/markets/agent_market.py
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 | |
can_be_traded
can_be_traded() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
475 476 477 478 | |
get_user_url
classmethod
get_user_url(keys: APIKeys) -> str
Source code in prediction_market_agent_tooling/markets/agent_market.py
480 481 482 | |
has_token_pool
has_token_pool() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
484 485 | |
get_pool_tokens
get_pool_tokens(outcome: OutcomeStr) -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
487 488 489 490 491 | |
get_user_balance
staticmethod
get_user_balance(user_id: str) -> float
Source code in prediction_market_agent_tooling/markets/agent_market.py
493 494 495 | |
get_user_id
staticmethod
get_user_id(api_keys: APIKeys) -> str
Source code in prediction_market_agent_tooling/markets/agent_market.py
497 498 499 | |
get_most_recent_trade_datetime
get_most_recent_trade_datetime(
user_id: str,
) -> DatetimeUTC | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
501 502 | |
base_subgraph_handler
T
module-attribute
T = TypeVar('T', bound=BaseModel)
BaseSubgraphHandler
BaseSubgraphHandler(timeout: int = 30)
Source code in prediction_market_agent_tooling/markets/base_subgraph_handler.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
sg
instance-attribute
sg = Subgrounds(timeout=timeout)
keys
instance-attribute
keys = APIKeys()
do_query
do_query(
fields: list[FieldPath], pydantic_model: Type[T]
) -> list[T]
Source code in prediction_market_agent_tooling/markets/base_subgraph_handler.py
47 48 49 50 51 | |
blockchain_utils
UINT16_MAX
module-attribute
UINT16_MAX = 2 ** 16 - 1
store_trades
store_trades(
market_id: str,
traded_market: ProcessedTradedMarket | None,
keys: APIKeys,
agent_name: str,
web3: Web3 | None = None,
) -> None
Source code in prediction_market_agent_tooling/markets/blockchain_utils.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
categorize
infer_category
infer_category(
question: str,
categories: set[str],
model: str = "gpt-3.5-turbo-0125",
) -> str
Source code in prediction_market_agent_tooling/markets/categorize.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
data_models
Decision
module-attribute
Decision = Annotated[
bool, BeforeValidator(to_boolean_outcome)
]
Resolution
Bases: BaseModel
outcome
instance-attribute
outcome: OutcomeStr | None
invalid
instance-attribute
invalid: bool
from_answer
staticmethod
from_answer(answer: OutcomeStr) -> Resolution
Source code in prediction_market_agent_tooling/markets/data_models.py
25 26 27 | |
find_outcome_matching_market
find_outcome_matching_market(
market_outcomes: Sequence[OutcomeStr],
) -> OutcomeStr | None
Finds a matching outcome in the provided market outcomes.
Performs case-insensitive matching between this resolution's outcome and the provided market outcomes.
Source code in prediction_market_agent_tooling/markets/data_models.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
Bet
Bases: BaseModel
id
instance-attribute
id: str
amount
instance-attribute
amount: CollateralToken
outcome
instance-attribute
outcome: OutcomeStr
created_time
instance-attribute
created_time: DatetimeUTC
market_question
instance-attribute
market_question: str
market_id
instance-attribute
market_id: str
ResolvedBet
Bases: Bet
market_outcome
instance-attribute
market_outcome: OutcomeStr
resolved_time
instance-attribute
resolved_time: DatetimeUTC
profit
instance-attribute
profit: CollateralToken
is_correct
property
is_correct: bool
id
instance-attribute
id: str
amount
instance-attribute
amount: CollateralToken
outcome
instance-attribute
outcome: OutcomeStr
created_time
instance-attribute
created_time: DatetimeUTC
market_question
instance-attribute
market_question: str
market_id
instance-attribute
market_id: str
ProbabilisticAnswer
Bases: BaseModel
p_yes
instance-attribute
p_yes: Probability
confidence
instance-attribute
confidence: float
reasoning
class-attribute
instance-attribute
reasoning: str | None = None
logprobs
class-attribute
instance-attribute
logprobs: list[FieldLogprobs] | None = None
p_no
property
p_no: Probability
probable_resolution
property
probable_resolution: Resolution
CategoricalProbabilisticAnswer
Bases: BaseModel
probabilities
instance-attribute
probabilities: dict[OutcomeStr, Probability]
confidence
instance-attribute
confidence: float
reasoning
class-attribute
instance-attribute
reasoning: str | None = None
probable_resolution
property
probable_resolution: Resolution
to_probabilistic_answer
to_probabilistic_answer() -> ProbabilisticAnswer
Source code in prediction_market_agent_tooling/markets/data_models.py
135 136 137 138 139 140 | |
from_probabilistic_answer
staticmethod
from_probabilistic_answer(
answer: ProbabilisticAnswer,
) -> CategoricalProbabilisticAnswer
Source code in prediction_market_agent_tooling/markets/data_models.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
probability_for_market_outcome
probability_for_market_outcome(
market_outcome: OutcomeStr,
) -> Probability
Source code in prediction_market_agent_tooling/markets/data_models.py
157 158 159 160 161 162 163 | |
get_yes_probability
get_yes_probability() -> Probability | None
Source code in prediction_market_agent_tooling/markets/data_models.py
165 166 167 168 169 170 171 172 173 | |
Position
Bases: BaseModel
market_id
instance-attribute
market_id: str
amounts_current
instance-attribute
amounts_current: dict[OutcomeStr, USD]
total_amount_current
property
total_amount_current: USD
ExistingPosition
Bases: Position
amounts_potential
instance-attribute
amounts_potential: dict[OutcomeStr, USD]
amounts_ot
instance-attribute
amounts_ot: dict[OutcomeStr, OutcomeToken]
total_amount_potential
property
total_amount_potential: USD
total_amount_ot
property
total_amount_ot: OutcomeToken
market_id
instance-attribute
market_id: str
amounts_current
instance-attribute
amounts_current: dict[OutcomeStr, USD]
total_amount_current
property
total_amount_current: USD
TradeType
Bases: str, Enum
SELL
class-attribute
instance-attribute
SELL = 'sell'
BUY
class-attribute
instance-attribute
BUY = 'buy'
Trade
Bases: BaseModel
trade_type
instance-attribute
trade_type: TradeType
outcome
instance-attribute
outcome: OutcomeStr
amount
instance-attribute
amount: USD
PlacedTrade
Bases: Trade
id
class-attribute
instance-attribute
id: str | None = None
trade_type
instance-attribute
trade_type: TradeType
outcome
instance-attribute
outcome: OutcomeStr
amount
instance-attribute
amount: USD
from_trade
staticmethod
from_trade(trade: Trade, id: str) -> PlacedTrade
Source code in prediction_market_agent_tooling/markets/data_models.py
222 223 224 225 226 227 228 229 | |
SimulatedBetDetail
Bases: BaseModel
strategy
instance-attribute
strategy: str
url
instance-attribute
url: str
probabilities
instance-attribute
probabilities: dict[OutcomeStr, Probability]
agent_prob_multi
instance-attribute
agent_prob_multi: dict[OutcomeStr, Probability]
agent_conf
instance-attribute
agent_conf: float
org_bet
instance-attribute
org_bet: CollateralToken
sim_bet
instance-attribute
sim_bet: CollateralToken
org_dir
instance-attribute
org_dir: OutcomeStr
sim_dir
instance-attribute
sim_dir: OutcomeStr
org_profit
instance-attribute
org_profit: CollateralToken
sim_profit
instance-attribute
sim_profit: CollateralToken
timestamp
instance-attribute
timestamp: DatetimeUTC
SharpeOutput
Bases: BaseModel
annualized_volatility
instance-attribute
annualized_volatility: float
mean_daily_return
instance-attribute
mean_daily_return: float
annualized_sharpe_ratio
instance-attribute
annualized_sharpe_ratio: float
SimulatedLifetimeDetail
Bases: BaseModel
p_yes_mse
instance-attribute
p_yes_mse: float
total_bet_amount
instance-attribute
total_bet_amount: CollateralToken
total_bet_profit
instance-attribute
total_bet_profit: CollateralToken
total_simulated_amount
instance-attribute
total_simulated_amount: CollateralToken
total_simulated_profit
instance-attribute
total_simulated_profit: CollateralToken
roi
instance-attribute
roi: float
simulated_roi
instance-attribute
simulated_roi: float
maximize
instance-attribute
maximize: float
to_boolean_outcome
to_boolean_outcome(value: str | bool) -> bool
Source code in prediction_market_agent_tooling/markets/data_models.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
manifold
api
MANIFOLD_API_BASE_URL
module-attribute
MANIFOLD_API_BASE_URL = 'https://api.manifold.markets'
MARKETS_LIMIT
module-attribute
MARKETS_LIMIT = 1000
get_manifold_binary_markets
get_manifold_binary_markets(
limit: int,
term: str = "",
topic_slug: Optional[str] = None,
sort: Literal[
"liquidity", "score", "newest", "close-date"
]
| None = "liquidity",
filter_: Literal[
"open",
"closed",
"resolved",
"closing-this-month",
"closing-next-month",
]
| None = "open",
created_after: Optional[DatetimeUTC] = None,
excluded_questions: set[str] | None = None,
) -> list[ManifoldMarket]
Source code in prediction_market_agent_tooling/markets/manifold/api.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
get_one_manifold_binary_market
get_one_manifold_binary_market() -> ManifoldMarket
Source code in prediction_market_agent_tooling/markets/manifold/api.py
98 99 | |
place_bet
place_bet(
amount: Mana,
market_id: str,
outcome: OutcomeStr,
manifold_api_key: SecretStr,
) -> ManifoldBet
Source code in prediction_market_agent_tooling/markets/manifold/api.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
get_authenticated_user
get_authenticated_user(api_key: str) -> ManifoldUser
Source code in prediction_market_agent_tooling/markets/manifold/api.py
136 137 138 139 140 141 142 143 144 145 | |
get_manifold_market
get_manifold_market(market_id: str) -> FullManifoldMarket
Source code in prediction_market_agent_tooling/markets/manifold/api.py
148 149 150 151 152 153 154 155 | |
get_manifold_bets
get_manifold_bets(
user_id: str,
start_time: DatetimeUTC,
end_time: Optional[DatetimeUTC],
) -> list[ManifoldBet]
Source code in prediction_market_agent_tooling/markets/manifold/api.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
get_resolved_manifold_bets
get_resolved_manifold_bets(
user_id: str,
start_time: DatetimeUTC,
end_time: Optional[DatetimeUTC],
) -> tuple[list[ManifoldBet], list[ManifoldMarket]]
Source code in prediction_market_agent_tooling/markets/manifold/api.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
manifold_to_generic_resolved_bet
manifold_to_generic_resolved_bet(
bet: ManifoldBet, market: ManifoldMarket
) -> ResolvedBet
Source code in prediction_market_agent_tooling/markets/manifold/api.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
get_market_positions
get_market_positions(
market_id: str, user_id: str
) -> list[ManifoldContractMetric]
Source code in prediction_market_agent_tooling/markets/manifold/api.py
221 222 223 224 225 226 | |
find_resolution_on_manifold
find_resolution_on_manifold(
question: str, n: int = 100
) -> Resolution | None
Source code in prediction_market_agent_tooling/markets/manifold/api.py
229 230 231 232 233 234 235 236 237 | |
data_models
MANIFOLD_BASE_URL
module-attribute
MANIFOLD_BASE_URL = 'https://manifold.markets'
ManifoldPool
Bases: BaseModel
NO
instance-attribute
NO: OutcomeToken
YES
instance-attribute
YES: OutcomeToken
size_for_outcome
size_for_outcome(outcome: str) -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/manifold/data_models.py
37 38 39 40 41 | |
ManifoldAnswersMode
Bases: str, Enum
ANYONE
class-attribute
instance-attribute
ANYONE = 'ANYONE'
ONLY_CREATOR
class-attribute
instance-attribute
ONLY_CREATOR = 'ONLY_CREATOR'
DISABLED
class-attribute
instance-attribute
DISABLED = 'DISABLED'
ManifoldAnswer
Bases: BaseModel
createdTime
instance-attribute
createdTime: DatetimeUTC
avatarUrl
instance-attribute
avatarUrl: str
id
instance-attribute
id: str
username
instance-attribute
username: str
number
instance-attribute
number: int
name
instance-attribute
name: str
contractId
instance-attribute
contractId: str
text
instance-attribute
text: str
userId
instance-attribute
userId: str
probability
instance-attribute
probability: float
ManifoldMarket
Bases: BaseModel
https://docs.manifold.markets/api#get-v0markets
id
instance-attribute
id: str
question
instance-attribute
question: str
creatorId
instance-attribute
creatorId: str
closeTime
instance-attribute
closeTime: DatetimeUTC
createdTime
instance-attribute
createdTime: DatetimeUTC
creatorAvatarUrl
class-attribute
instance-attribute
creatorAvatarUrl: Optional[str] = None
creatorName
instance-attribute
creatorName: str
creatorUsername
instance-attribute
creatorUsername: str
isResolved
instance-attribute
isResolved: bool
resolution
class-attribute
instance-attribute
resolution: Optional[Resolution] = None
resolutionTime
class-attribute
instance-attribute
resolutionTime: Optional[DatetimeUTC] = None
lastBetTime
class-attribute
instance-attribute
lastBetTime: Optional[DatetimeUTC] = None
lastCommentTime
class-attribute
instance-attribute
lastCommentTime: Optional[DatetimeUTC] = None
lastUpdatedTime
instance-attribute
lastUpdatedTime: DatetimeUTC
mechanism
instance-attribute
mechanism: str
outcomeType
instance-attribute
outcomeType: str
p
class-attribute
instance-attribute
p: Optional[float] = None
pool
instance-attribute
pool: ManifoldPool
probability
instance-attribute
probability: Probability
slug
instance-attribute
slug: str
totalLiquidity
class-attribute
instance-attribute
totalLiquidity: Optional[CollateralToken] = None
uniqueBettorCount
instance-attribute
uniqueBettorCount: int
url
instance-attribute
url: str
volume
instance-attribute
volume: CollateralToken
volume24Hours
instance-attribute
volume24Hours: CollateralToken
outcomes
property
outcomes: Sequence[OutcomeStr]
get_resolved_outcome
get_resolved_outcome() -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/manifold/data_models.py
98 99 100 101 102 | |
is_resolved_non_cancelled
is_resolved_non_cancelled() -> bool
Source code in prediction_market_agent_tooling/markets/manifold/data_models.py
104 105 106 107 108 109 110 111 | |
validate_resolution
validate_resolution(v: Any) -> Resolution
Source code in prediction_market_agent_tooling/markets/manifold/data_models.py
113 114 115 | |
FullManifoldMarket
Bases: ManifoldMarket
answers
class-attribute
instance-attribute
answers: list[ManifoldAnswer] | None = None
shouldAnswersSumToOne
class-attribute
instance-attribute
shouldAnswersSumToOne: bool | None = None
addAnswersMode
class-attribute
instance-attribute
addAnswersMode: ManifoldAnswersMode | None = None
options
class-attribute
instance-attribute
options: dict[str, int | str] | None = None
totalBounty
class-attribute
instance-attribute
totalBounty: float | None = None
bountyLeft
class-attribute
instance-attribute
bountyLeft: float | None = None
description
instance-attribute
description: str | dict[str, Any]
textDescription
instance-attribute
textDescription: str
coverImageUrl
class-attribute
instance-attribute
coverImageUrl: str | None = None
groupSlugs
class-attribute
instance-attribute
groupSlugs: list[str] | None = None
id
instance-attribute
id: str
question
instance-attribute
question: str
creatorId
instance-attribute
creatorId: str
closeTime
instance-attribute
closeTime: DatetimeUTC
createdTime
instance-attribute
createdTime: DatetimeUTC
creatorAvatarUrl
class-attribute
instance-attribute
creatorAvatarUrl: Optional[str] = None
creatorName
instance-attribute
creatorName: str
creatorUsername
instance-attribute
creatorUsername: str
isResolved
instance-attribute
isResolved: bool
resolution
class-attribute
instance-attribute
resolution: Optional[Resolution] = None
resolutionTime
class-attribute
instance-attribute
resolutionTime: Optional[DatetimeUTC] = None
lastBetTime
class-attribute
instance-attribute
lastBetTime: Optional[DatetimeUTC] = None
lastCommentTime
class-attribute
instance-attribute
lastCommentTime: Optional[DatetimeUTC] = None
lastUpdatedTime
instance-attribute
lastUpdatedTime: DatetimeUTC
mechanism
instance-attribute
mechanism: str
outcomeType
instance-attribute
outcomeType: str
p
class-attribute
instance-attribute
p: Optional[float] = None
pool
instance-attribute
pool: ManifoldPool
probability
instance-attribute
probability: Probability
slug
instance-attribute
slug: str
totalLiquidity
class-attribute
instance-attribute
totalLiquidity: Optional[CollateralToken] = None
uniqueBettorCount
instance-attribute
uniqueBettorCount: int
url
instance-attribute
url: str
volume
instance-attribute
volume: CollateralToken
volume24Hours
instance-attribute
volume24Hours: CollateralToken
outcomes
property
outcomes: Sequence[OutcomeStr]
get_resolved_outcome
get_resolved_outcome() -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/manifold/data_models.py
98 99 100 101 102 | |
is_resolved_non_cancelled
is_resolved_non_cancelled() -> bool
Source code in prediction_market_agent_tooling/markets/manifold/data_models.py
104 105 106 107 108 109 110 111 | |
validate_resolution
validate_resolution(v: Any) -> Resolution
Source code in prediction_market_agent_tooling/markets/manifold/data_models.py
113 114 115 | |
ProfitCached
Bases: BaseModel
daily
instance-attribute
daily: Mana
weekly
instance-attribute
weekly: Mana
monthly
instance-attribute
monthly: Mana
allTime
instance-attribute
allTime: Mana
ManifoldUser
Bases: BaseModel
https://docs.manifold.markets/api#get-v0userusername
id
instance-attribute
id: str
createdTime
instance-attribute
createdTime: DatetimeUTC
name
instance-attribute
name: str
username
instance-attribute
username: str
url
instance-attribute
url: str
avatarUrl
class-attribute
instance-attribute
avatarUrl: Optional[str] = None
bio
class-attribute
instance-attribute
bio: Optional[str] = None
bannerUrl
class-attribute
instance-attribute
bannerUrl: Optional[str] = None
website
class-attribute
instance-attribute
website: Optional[str] = None
twitterHandle
class-attribute
instance-attribute
twitterHandle: Optional[str] = None
discordHandle
class-attribute
instance-attribute
discordHandle: Optional[str] = None
isBot
class-attribute
instance-attribute
isBot: Optional[bool] = None
isAdmin
class-attribute
instance-attribute
isAdmin: Optional[bool] = None
isTrustworthy
class-attribute
instance-attribute
isTrustworthy: Optional[bool] = None
isBannedFromPosting
class-attribute
instance-attribute
isBannedFromPosting: Optional[bool] = None
userDeleted
class-attribute
instance-attribute
userDeleted: Optional[bool] = None
balance
instance-attribute
balance: Mana
totalDeposits
instance-attribute
totalDeposits: Mana
lastBetTime
class-attribute
instance-attribute
lastBetTime: Optional[DatetimeUTC] = None
currentBettingStreak
class-attribute
instance-attribute
currentBettingStreak: Optional[int] = None
profitCached
instance-attribute
profitCached: ProfitCached
ManifoldBetFills
Bases: BaseModel
amount
instance-attribute
amount: Mana
matchedBetId
instance-attribute
matchedBetId: Optional[str]
shares
instance-attribute
shares: float
timestamp
instance-attribute
timestamp: int
ManifoldBetFees
Bases: BaseModel
platformFee
instance-attribute
platformFee: float
liquidityFee
instance-attribute
liquidityFee: float
creatorFee
instance-attribute
creatorFee: float
get_total
get_total() -> float
Source code in prediction_market_agent_tooling/markets/manifold/data_models.py
182 183 | |
ManifoldBet
Bases: BaseModel
https://docs.manifold.markets/api#get-v0bets
shares
instance-attribute
shares: CollateralToken
probBefore
instance-attribute
probBefore: Probability
isFilled
class-attribute
instance-attribute
isFilled: Optional[bool] = None
probAfter
instance-attribute
probAfter: Probability
userId
instance-attribute
userId: str
amount
instance-attribute
amount: CollateralToken
contractId
instance-attribute
contractId: str
id
instance-attribute
id: str
fees
instance-attribute
fees: ManifoldBetFees
isCancelled
class-attribute
instance-attribute
isCancelled: Optional[bool] = None
loanAmount
instance-attribute
loanAmount: CollateralToken | None
orderAmount
class-attribute
instance-attribute
orderAmount: Optional[CollateralToken] = None
fills
class-attribute
instance-attribute
fills: Optional[list[ManifoldBetFills]] = None
createdTime
instance-attribute
createdTime: DatetimeUTC
outcome
instance-attribute
outcome: Resolution
validate_resolution
validate_resolution(v: Any) -> Resolution
Source code in prediction_market_agent_tooling/markets/manifold/data_models.py
207 208 209 | |
get_resolved_outcome
get_resolved_outcome() -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/manifold/data_models.py
211 212 213 214 215 | |
get_profit
get_profit(market_outcome: OutcomeStr) -> CollateralToken
Source code in prediction_market_agent_tooling/markets/manifold/data_models.py
217 218 219 220 221 222 223 | |
ManifoldContractMetric
Bases: BaseModel
https://docs.manifold.markets/api#get-v0marketmarketidpositions
contractId
instance-attribute
contractId: str
hasNoShares
instance-attribute
hasNoShares: bool
hasShares
instance-attribute
hasShares: bool
hasYesShares
instance-attribute
hasYesShares: bool
invested
instance-attribute
invested: float
loan
instance-attribute
loan: float
maxSharesOutcome
instance-attribute
maxSharesOutcome: Optional[str]
payout
instance-attribute
payout: float
profit
instance-attribute
profit: float
profitPercent
instance-attribute
profitPercent: float
totalShares
instance-attribute
totalShares: dict[str, float]
userId
instance-attribute
userId: str
userUsername
instance-attribute
userUsername: str
userName
instance-attribute
userName: str
userAvatarUrl
instance-attribute
userAvatarUrl: str
lastBetTime
instance-attribute
lastBetTime: DatetimeUTC
mana_to_usd
mana_to_usd(mana: Mana) -> USD
Source code in prediction_market_agent_tooling/markets/manifold/data_models.py
23 24 25 | |
usd_to_mana
usd_to_mana(usd: USD) -> Mana
Source code in prediction_market_agent_tooling/markets/manifold/data_models.py
28 29 30 | |
manifold
ManifoldAgentMarket
Bases: AgentMarket
Manifold's market class that can be used by agents to make predictions.
base_url
class-attribute
base_url: str = MANIFOLD_BASE_URL
fees
class-attribute
instance-attribute
fees: MarketFees = MarketFees(
bet_proportion=0, absolute=0.25
)
current_p_yes
instance-attribute
current_p_yes: Probability
id
instance-attribute
id: str
question
instance-attribute
question: str
description
instance-attribute
description: str | None
outcomes
instance-attribute
outcomes: Sequence[OutcomeStr]
outcome_token_pool
instance-attribute
outcome_token_pool: dict[OutcomeStr, OutcomeToken] | None
resolution
instance-attribute
resolution: Resolution | None
created_time
instance-attribute
created_time: DatetimeUTC | None
close_time
instance-attribute
close_time: DatetimeUTC | None
probabilities
instance-attribute
probabilities: dict[OutcomeStr, Probability]
url
instance-attribute
url: str
volume
instance-attribute
volume: CollateralToken | None
is_binary
property
is_binary: bool
p_yes
property
p_yes: Probability
p_no
property
p_no: Probability
probable_resolution
property
probable_resolution: Resolution
get_last_trade_p_yes
get_last_trade_p_yes() -> Probability
On Manifold, probablities aren't updated after the closure, so we can just use the current probability
Source code in prediction_market_agent_tooling/markets/manifold/manifold.py
49 50 51 | |
get_tiny_bet_amount
get_tiny_bet_amount() -> CollateralToken
Source code in prediction_market_agent_tooling/markets/manifold/manifold.py
53 54 | |
have_bet_on_market_since
have_bet_on_market_since(
keys: APIKeys, since: timedelta
) -> bool
Source code in prediction_market_agent_tooling/markets/manifold/manifold.py
56 57 58 59 60 61 62 63 64 65 66 67 68 | |
place_bet
place_bet(outcome: OutcomeStr, amount: USD) -> str
Source code in prediction_market_agent_tooling/markets/manifold/manifold.py
70 71 72 73 74 75 76 77 78 | |
from_data_model
staticmethod
from_data_model(
model: FullManifoldMarket,
) -> ManifoldAgentMarket
Source code in prediction_market_agent_tooling/markets/manifold/manifold.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
get_markets
staticmethod
get_markets(
limit: int,
sort_by: SortBy,
filter_by: FilterBy = FilterBy.OPEN,
created_after: Optional[DatetimeUTC] = None,
excluded_questions: set[str] | None = None,
fetch_categorical_markets: bool = False,
) -> t.Sequence[ManifoldAgentMarket]
Source code in prediction_market_agent_tooling/markets/manifold/manifold.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
redeem_winnings
staticmethod
redeem_winnings(api_keys: APIKeys) -> None
Source code in prediction_market_agent_tooling/markets/manifold/manifold.py
146 147 148 149 | |
get_user_url
classmethod
get_user_url(keys: APIKeys) -> str
Source code in prediction_market_agent_tooling/markets/manifold/manifold.py
151 152 153 | |
get_user_id
staticmethod
get_user_id(api_keys: APIKeys) -> str
Source code in prediction_market_agent_tooling/markets/manifold/manifold.py
155 156 157 | |
validate_probabilities
validate_probabilities(
probs: dict[OutcomeStr, Probability],
info: FieldValidationInfo,
) -> dict[OutcomeStr, Probability]
Source code in prediction_market_agent_tooling/markets/agent_market.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
validate_outcome_token_pool
validate_outcome_token_pool(
outcome_token_pool: dict[str, OutcomeToken] | None,
info: FieldValidationInfo,
) -> dict[str, OutcomeToken] | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
get_outcome_token_pool_by_outcome
get_outcome_token_pool_by_outcome(
outcome: OutcomeStr,
) -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
122 123 124 125 126 127 128 | |
handle_legacy_fee
handle_legacy_fee(data: dict[str, Any]) -> dict[str, t.Any]
Source code in prediction_market_agent_tooling/markets/agent_market.py
130 131 132 133 134 135 136 | |
market_outcome_for_probability_key
market_outcome_for_probability_key(
probability_key: OutcomeStr,
) -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/agent_market.py
138 139 140 141 142 143 144 145 146 | |
probability_for_market_outcome
probability_for_market_outcome(
market_outcome: OutcomeStr,
) -> Probability
Source code in prediction_market_agent_tooling/markets/agent_market.py
148 149 150 151 152 153 154 | |
get_last_trade_p_no
get_last_trade_p_no() -> Probability | None
Get the last trade price for the NO outcome. This can be different from the current p_yes, for example if market is closed and it's probabilities are fixed to 0 and 1. Could be None if no trades were made.
Source code in prediction_market_agent_tooling/markets/agent_market.py
202 203 204 205 206 207 | |
get_last_trade_yes_outcome_price
get_last_trade_yes_outcome_price() -> (
CollateralToken | None
)
Source code in prediction_market_agent_tooling/markets/agent_market.py
209 210 211 212 213 214 | |
get_last_trade_yes_outcome_price_usd
get_last_trade_yes_outcome_price_usd() -> USD | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
216 217 218 219 | |
get_last_trade_no_outcome_price
get_last_trade_no_outcome_price() -> CollateralToken | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
221 222 223 224 225 226 | |
get_last_trade_no_outcome_price_usd
get_last_trade_no_outcome_price_usd() -> USD | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
228 229 230 231 | |
get_liquidatable_amount
get_liquidatable_amount() -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
233 234 235 | |
get_token_in_usd
get_token_in_usd(x: CollateralToken) -> USD
Token of this market can have whatever worth (e.g. sDai and ETH markets will have different worth of 1 token). Use this to convert it to USD.
Source code in prediction_market_agent_tooling/markets/agent_market.py
237 238 239 240 241 | |
get_usd_in_token
get_usd_in_token(x: USD) -> CollateralToken
Markets on a single platform can have different tokens as collateral (sDai, wxDai, GNO, ...). Use this to convert USD to the token of this market.
Source code in prediction_market_agent_tooling/markets/agent_market.py
243 244 245 246 247 | |
get_sell_value_of_outcome_token
get_sell_value_of_outcome_token(
outcome: OutcomeStr, amount: OutcomeToken
) -> CollateralToken
When you hold OutcomeToken(s), it's easy to calculate how much you get at the end if you win (1 OutcomeToken will equal to 1 Token). But use this to figure out, how much are these outcome tokens worth right now (for how much you can sell them).
Source code in prediction_market_agent_tooling/markets/agent_market.py
249 250 251 252 253 254 255 256 | |
get_in_usd
get_in_usd(x: USD | CollateralToken) -> USD
Source code in prediction_market_agent_tooling/markets/agent_market.py
258 259 260 261 | |
get_in_token
get_in_token(x: USD | CollateralToken) -> CollateralToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
263 264 265 266 | |
liquidate_existing_positions
liquidate_existing_positions(outcome: OutcomeStr) -> None
Source code in prediction_market_agent_tooling/markets/agent_market.py
274 275 | |
buy_tokens
buy_tokens(outcome: OutcomeStr, amount: USD) -> str
Source code in prediction_market_agent_tooling/markets/agent_market.py
280 281 | |
get_buy_token_amount
get_buy_token_amount(
bet_amount: USD | CollateralToken, outcome: OutcomeStr
) -> OutcomeToken | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
283 284 285 286 | |
sell_tokens
sell_tokens(
outcome: OutcomeStr, amount: USD | OutcomeToken
) -> str
Source code in prediction_market_agent_tooling/markets/agent_market.py
288 289 | |
compute_fpmm_probabilities
staticmethod
compute_fpmm_probabilities(
balances: list[OutcomeWei],
) -> list[Probability]
Compute the implied probabilities in a Fixed Product Market Maker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
balances
|
List[float]
|
Balances of outcome tokens. |
required |
Returns:
| Type | Description |
|---|---|
list[Probability]
|
List[float]: Implied probabilities for each outcome. |
Source code in prediction_market_agent_tooling/markets/agent_market.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
build_probability_map_from_p_yes
staticmethod
build_probability_map_from_p_yes(
p_yes: Probability,
) -> dict[OutcomeStr, Probability]
Source code in prediction_market_agent_tooling/markets/agent_market.py
321 322 323 324 325 326 327 328 | |
build_probability_map
staticmethod
build_probability_map(
outcome_token_amounts: list[OutcomeWei],
outcomes: list[OutcomeStr],
) -> dict[OutcomeStr, Probability]
Source code in prediction_market_agent_tooling/markets/agent_market.py
330 331 332 333 334 335 | |
get_binary_market
staticmethod
get_binary_market(id: str) -> AgentMarket
Source code in prediction_market_agent_tooling/markets/agent_market.py
348 349 350 | |
get_trade_balance
classmethod
get_trade_balance(api_keys: APIKeys) -> USD
Return balance that can be used to trade on the given market.
Source code in prediction_market_agent_tooling/markets/agent_market.py
359 360 361 362 363 364 | |
verify_operational_balance
staticmethod
verify_operational_balance(api_keys: APIKeys) -> bool
Return True if the user has enough of operational balance. If not needed, just return True.
For example: Omen needs at least some xDai in the wallet to execute transactions.
Source code in prediction_market_agent_tooling/markets/agent_market.py
366 367 368 369 370 371 372 | |
store_prediction
store_prediction(
processed_market: ProcessedMarket | None,
keys: APIKeys,
agent_name: str,
) -> None
If market allows to upload predictions somewhere, implement it in this method.
Source code in prediction_market_agent_tooling/markets/agent_market.py
374 375 376 377 378 379 380 381 382 383 | |
store_trades
store_trades(
traded_market: ProcessedTradedMarket | None,
keys: APIKeys,
agent_name: str,
web3: Web3 | None = None,
) -> None
If market allows to upload trades somewhere, implement it in this method.
Source code in prediction_market_agent_tooling/markets/agent_market.py
385 386 387 388 389 390 391 392 393 394 395 | |
get_bets_made_since
staticmethod
get_bets_made_since(
better_address: ChecksumAddress, start_time: DatetimeUTC
) -> list[Bet]
Source code in prediction_market_agent_tooling/markets/agent_market.py
397 398 399 400 401 | |
get_resolved_bets_made_since
staticmethod
get_resolved_bets_made_since(
better_address: ChecksumAddress,
start_time: DatetimeUTC,
end_time: DatetimeUTC | None,
) -> list[ResolvedBet]
Source code in prediction_market_agent_tooling/markets/agent_market.py
403 404 405 406 407 408 409 | |
is_closed
is_closed() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
411 412 | |
is_resolved
is_resolved() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
414 415 | |
get_liquidity
get_liquidity() -> CollateralToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
417 418 | |
has_liquidity
has_liquidity() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
420 421 | |
has_successful_resolution
has_successful_resolution() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
423 424 425 426 427 428 | |
has_unsuccessful_resolution
has_unsuccessful_resolution() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
430 431 | |
get_outcome_str_from_bool
staticmethod
get_outcome_str_from_bool(outcome: bool) -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/agent_market.py
433 434 435 | |
get_outcome_str
get_outcome_str(outcome_index: int) -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/agent_market.py
437 438 439 440 441 442 443 | |
get_outcome_index
get_outcome_index(outcome: OutcomeStr) -> int
Source code in prediction_market_agent_tooling/markets/agent_market.py
445 446 447 448 449 450 | |
get_token_balance
get_token_balance(
user_id: str, outcome: OutcomeStr
) -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
452 453 | |
get_position
get_position(user_id: str) -> ExistingPosition | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
455 456 | |
get_positions
classmethod
get_positions(
user_id: str,
liquid_only: bool = False,
larger_than: OutcomeToken = OutcomeToken(0),
) -> t.Sequence[ExistingPosition]
Get all non-zero positions a user has in any market.
If liquid_only is True, only return positions that can be sold.
If larger_than is not None, only return positions with a larger number
of tokens than this amount.
Source code in prediction_market_agent_tooling/markets/agent_market.py
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 | |
can_be_traded
can_be_traded() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
475 476 477 478 | |
has_token_pool
has_token_pool() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
484 485 | |
get_pool_tokens
get_pool_tokens(outcome: OutcomeStr) -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
487 488 489 490 491 | |
get_user_balance
staticmethod
get_user_balance(user_id: str) -> float
Source code in prediction_market_agent_tooling/markets/agent_market.py
493 494 495 | |
get_most_recent_trade_datetime
get_most_recent_trade_datetime(
user_id: str,
) -> DatetimeUTC | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
501 502 | |
utils
MANIFOLD_CANCEL_OUTCOME
module-attribute
MANIFOLD_CANCEL_OUTCOME = 'CANCEL'
validate_manifold_resolution
validate_manifold_resolution(v: Any) -> Resolution
Source code in prediction_market_agent_tooling/markets/manifold/utils.py
9 10 11 12 13 14 15 16 | |
market_fees
MarketFees
Bases: BaseModel
bet_proportion
class-attribute
instance-attribute
bet_proportion: float = Field(..., ge=0.0, lt=1.0)
absolute
instance-attribute
absolute: float
get_zero_fees
staticmethod
get_zero_fees(
bet_proportion: float = 0.0, absolute: float = 0.0
) -> MarketFees
Source code in prediction_market_agent_tooling/markets/market_fees.py
12 13 14 15 16 17 18 19 20 | |
total_fee_absolute_value
total_fee_absolute_value(bet_amount: float) -> float
Returns the total fee in absolute terms, including both proportional and fixed fees.
Source code in prediction_market_agent_tooling/markets/market_fees.py
22 23 24 25 26 | |
total_fee_relative_value
total_fee_relative_value(bet_amount: float) -> float
Returns the total fee relative to the bet amount, including both proportional and fixed fees.
Source code in prediction_market_agent_tooling/markets/market_fees.py
28 29 30 31 32 33 34 35 | |
get_after_fees
get_after_fees(
bet_amount: CollateralToken,
) -> CollateralToken
Source code in prediction_market_agent_tooling/markets/market_fees.py
37 38 39 40 | |
markets
MARKET_TYPE_TO_AGENT_MARKET
module-attribute
MARKET_TYPE_TO_AGENT_MARKET: dict[
MarketType, type[AgentMarket]
] = {
MANIFOLD: ManifoldAgentMarket,
OMEN: OmenAgentMarket,
POLYMARKET: PolymarketAgentMarket,
METACULUS: MetaculusAgentMarket,
SEER: SeerAgentMarket,
}
JOB_MARKET_TYPE_TO_JOB_AGENT_MARKET
module-attribute
JOB_MARKET_TYPE_TO_JOB_AGENT_MARKET: dict[
MarketType, type[JobAgentMarket]
] = {OMEN: OmenJobAgentMarket}
MarketType
Bases: str, Enum
OMEN
class-attribute
instance-attribute
OMEN = 'omen'
MANIFOLD
class-attribute
instance-attribute
MANIFOLD = 'manifold'
POLYMARKET
class-attribute
instance-attribute
POLYMARKET = 'polymarket'
METACULUS
class-attribute
instance-attribute
METACULUS = 'metaculus'
SEER
class-attribute
instance-attribute
SEER = 'seer'
market_class
property
market_class: type[AgentMarket]
job_class
property
job_class: type[JobAgentMarket]
is_blockchain_market
property
is_blockchain_market: bool
get_binary_markets
get_binary_markets(
limit: int,
market_type: MarketType,
filter_by: FilterBy = FilterBy.OPEN,
sort_by: SortBy = SortBy.NONE,
excluded_questions: set[str] | None = None,
created_after: DatetimeUTC | None = None,
) -> t.Sequence[AgentMarket]
Source code in prediction_market_agent_tooling/markets/markets.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
metaculus
api
METACULUS_API_BASE_URL
module-attribute
METACULUS_API_BASE_URL = 'https://www.metaculus.com/api2'
get_auth_headers
get_auth_headers() -> dict[str, str]
Source code in prediction_market_agent_tooling/markets/metaculus/api.py
16 17 | |
post_question_comment
post_question_comment(
question_id: str, comment_text: str
) -> None
Post a comment on the question page as the bot user.
Source code in prediction_market_agent_tooling/markets/metaculus/api.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
make_prediction
make_prediction(
question_id: str, p_yes: Probability
) -> None
Make a prediction for a question.
Source code in prediction_market_agent_tooling/markets/metaculus/api.py
38 39 40 41 42 43 44 45 46 47 48 | |
get_question
get_question(question_id: str) -> MetaculusQuestion
Get all details about a specific question.
Source code in prediction_market_agent_tooling/markets/metaculus/api.py
51 52 53 54 55 56 57 58 59 | |
get_questions
get_questions(
limit: int,
order_by: str | None = None,
offset: int = 0,
tournament_id: int | None = None,
created_after: DatetimeUTC | None = None,
status: str | None = None,
) -> list[MetaculusQuestion]
List detailed metaculus questions (i.e. markets)
Source code in prediction_market_agent_tooling/markets/metaculus/api.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
data_models
QuestionType
Bases: str, Enum
binary
class-attribute
instance-attribute
binary = 'binary'
AggregationItem
Bases: BaseModel
start_time
instance-attribute
start_time: DatetimeUTC
end_time
instance-attribute
end_time: DatetimeUTC | None
forecast_values
instance-attribute
forecast_values: list[float] | None
forecaster_count
instance-attribute
forecaster_count: int
interval_lower_bounds
instance-attribute
interval_lower_bounds: list[float] | None
centers
instance-attribute
centers: list[float] | None
interval_upper_bounds
instance-attribute
interval_upper_bounds: list[float] | None
means
instance-attribute
means: list[float] | None
histogram
instance-attribute
histogram: list[list[float]] | None
Aggregation
Bases: BaseModel
history
instance-attribute
history: list[AggregationItem]
latest
instance-attribute
latest: AggregationItem | None
score_data
instance-attribute
score_data: dict[str, Any]
Aggregations
Bases: BaseModel
recency_weighted
instance-attribute
recency_weighted: Aggregation
unweighted
instance-attribute
unweighted: Aggregation
single_aggregation
instance-attribute
single_aggregation: Aggregation
metaculus_prediction
instance-attribute
metaculus_prediction: Aggregation
MyForecast
Bases: BaseModel
start_time
instance-attribute
start_time: DatetimeUTC
end_time
instance-attribute
end_time: DatetimeUTC | None
forecast_values
instance-attribute
forecast_values: list[float] | None
interval_lower_bounds
instance-attribute
interval_lower_bounds: list[float] | None
centers
instance-attribute
centers: list[float] | None
interval_upper_bounds
instance-attribute
interval_upper_bounds: list[float] | None
MyAggregation
Bases: BaseModel
history
instance-attribute
history: list[MyForecast]
latest
instance-attribute
latest: MyForecast | None
score_data
instance-attribute
score_data: dict[str, Any]
Question
Bases: BaseModel
aggregations
instance-attribute
aggregations: Aggregations
my_forecasts
instance-attribute
my_forecasts: MyAggregation
type
instance-attribute
type: QuestionType
possibilities
instance-attribute
possibilities: dict[str, str] | None
description
instance-attribute
description: str
fine_print
instance-attribute
fine_print: str
resolution_criteria
instance-attribute
resolution_criteria: str
MetaculusQuestion
Bases: BaseModel
id
instance-attribute
id: int
author_id
instance-attribute
author_id: int
author_username
instance-attribute
author_username: str
title
instance-attribute
title: str
created_at
instance-attribute
created_at: DatetimeUTC
published_at
instance-attribute
published_at: DatetimeUTC | None
scheduled_close_time
instance-attribute
scheduled_close_time: DatetimeUTC
scheduled_resolve_time
instance-attribute
scheduled_resolve_time: DatetimeUTC
user_permission
instance-attribute
user_permission: str
comment_count
instance-attribute
comment_count: int
question
instance-attribute
question: Question
page_url
property
page_url: str
p_yes
property
p_yes: Probability
MetaculusQuestions
Bases: BaseModel
next
instance-attribute
next: str | None
previous
instance-attribute
previous: str | None
results
instance-attribute
results: list[MetaculusQuestion]
metaculus
MetaculusAgentMarket
Bases: AgentMarket
Metaculus' market class that can be used by agents to make predictions.
have_predicted
instance-attribute
have_predicted: bool
base_url
class-attribute
base_url: str = METACULUS_API_BASE_URL
description
instance-attribute
description: str
fine_print
instance-attribute
fine_print: str
resolution_criteria
instance-attribute
resolution_criteria: str
fees
class-attribute
instance-attribute
fees: MarketFees = get_zero_fees()
id
instance-attribute
id: str
question
instance-attribute
question: str
outcomes
instance-attribute
outcomes: Sequence[OutcomeStr]
outcome_token_pool
instance-attribute
outcome_token_pool: dict[OutcomeStr, OutcomeToken] | None
resolution
instance-attribute
resolution: Resolution | None
created_time
instance-attribute
created_time: DatetimeUTC | None
close_time
instance-attribute
close_time: DatetimeUTC | None
probabilities
instance-attribute
probabilities: dict[OutcomeStr, Probability]
url
instance-attribute
url: str
volume
instance-attribute
volume: CollateralToken | None
is_binary
property
is_binary: bool
p_yes
property
p_yes: Probability
p_no
property
p_no: Probability
probable_resolution
property
probable_resolution: Resolution
validate_probabilities
validate_probabilities(
probs: dict[OutcomeStr, Probability],
info: FieldValidationInfo,
) -> dict[OutcomeStr, Probability]
Source code in prediction_market_agent_tooling/markets/metaculus/metaculus.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
from_data_model
staticmethod
from_data_model(
model: MetaculusQuestion,
) -> MetaculusAgentMarket
Source code in prediction_market_agent_tooling/markets/metaculus/metaculus.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
get_markets
staticmethod
get_markets(
limit: int,
sort_by: SortBy = SortBy.NONE,
filter_by: FilterBy = FilterBy.OPEN,
created_after: Optional[DatetimeUTC] = None,
excluded_questions: set[str] | None = None,
tournament_id: int | None = None,
) -> t.Sequence[MetaculusAgentMarket]
Source code in prediction_market_agent_tooling/markets/metaculus/metaculus.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
store_prediction
store_prediction(
processed_market: ProcessedMarket | None,
keys: APIKeys,
agent_name: str,
) -> None
Source code in prediction_market_agent_tooling/markets/metaculus/metaculus.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
get_user_id
staticmethod
get_user_id(api_keys: APIKeys) -> str
Source code in prediction_market_agent_tooling/markets/metaculus/metaculus.py
147 148 149 | |
verify_operational_balance
staticmethod
verify_operational_balance(api_keys: APIKeys) -> bool
Source code in prediction_market_agent_tooling/markets/metaculus/metaculus.py
151 152 153 154 | |
redeem_winnings
staticmethod
redeem_winnings(api_keys: APIKeys) -> None
Source code in prediction_market_agent_tooling/markets/metaculus/metaculus.py
156 157 158 159 | |
validate_outcome_token_pool
validate_outcome_token_pool(
outcome_token_pool: dict[str, OutcomeToken] | None,
info: FieldValidationInfo,
) -> dict[str, OutcomeToken] | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
have_bet_on_market_since
have_bet_on_market_since(
keys: APIKeys, since: timedelta
) -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
119 120 | |
get_outcome_token_pool_by_outcome
get_outcome_token_pool_by_outcome(
outcome: OutcomeStr,
) -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
122 123 124 125 126 127 128 | |
handle_legacy_fee
handle_legacy_fee(data: dict[str, Any]) -> dict[str, t.Any]
Source code in prediction_market_agent_tooling/markets/agent_market.py
130 131 132 133 134 135 136 | |
market_outcome_for_probability_key
market_outcome_for_probability_key(
probability_key: OutcomeStr,
) -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/agent_market.py
138 139 140 141 142 143 144 145 146 | |
probability_for_market_outcome
probability_for_market_outcome(
market_outcome: OutcomeStr,
) -> Probability
Source code in prediction_market_agent_tooling/markets/agent_market.py
148 149 150 151 152 153 154 | |
get_last_trade_p_yes
get_last_trade_p_yes() -> Probability | None
Get the last trade price for the YES outcome. This can be different from the current p_yes, for example if market is closed and it's probabilities are fixed to 0 and 1. Could be None if no trades were made.
Source code in prediction_market_agent_tooling/markets/agent_market.py
195 196 197 198 199 200 | |
get_last_trade_p_no
get_last_trade_p_no() -> Probability | None
Get the last trade price for the NO outcome. This can be different from the current p_yes, for example if market is closed and it's probabilities are fixed to 0 and 1. Could be None if no trades were made.
Source code in prediction_market_agent_tooling/markets/agent_market.py
202 203 204 205 206 207 | |
get_last_trade_yes_outcome_price
get_last_trade_yes_outcome_price() -> (
CollateralToken | None
)
Source code in prediction_market_agent_tooling/markets/agent_market.py
209 210 211 212 213 214 | |
get_last_trade_yes_outcome_price_usd
get_last_trade_yes_outcome_price_usd() -> USD | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
216 217 218 219 | |
get_last_trade_no_outcome_price
get_last_trade_no_outcome_price() -> CollateralToken | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
221 222 223 224 225 226 | |
get_last_trade_no_outcome_price_usd
get_last_trade_no_outcome_price_usd() -> USD | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
228 229 230 231 | |
get_liquidatable_amount
get_liquidatable_amount() -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
233 234 235 | |
get_token_in_usd
get_token_in_usd(x: CollateralToken) -> USD
Token of this market can have whatever worth (e.g. sDai and ETH markets will have different worth of 1 token). Use this to convert it to USD.
Source code in prediction_market_agent_tooling/markets/agent_market.py
237 238 239 240 241 | |
get_usd_in_token
get_usd_in_token(x: USD) -> CollateralToken
Markets on a single platform can have different tokens as collateral (sDai, wxDai, GNO, ...). Use this to convert USD to the token of this market.
Source code in prediction_market_agent_tooling/markets/agent_market.py
243 244 245 246 247 | |
get_sell_value_of_outcome_token
get_sell_value_of_outcome_token(
outcome: OutcomeStr, amount: OutcomeToken
) -> CollateralToken
When you hold OutcomeToken(s), it's easy to calculate how much you get at the end if you win (1 OutcomeToken will equal to 1 Token). But use this to figure out, how much are these outcome tokens worth right now (for how much you can sell them).
Source code in prediction_market_agent_tooling/markets/agent_market.py
249 250 251 252 253 254 255 256 | |
get_in_usd
get_in_usd(x: USD | CollateralToken) -> USD
Source code in prediction_market_agent_tooling/markets/agent_market.py
258 259 260 261 | |
get_in_token
get_in_token(x: USD | CollateralToken) -> CollateralToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
263 264 265 266 | |
get_tiny_bet_amount
get_tiny_bet_amount() -> CollateralToken
Tiny bet amount that the platform still allows us to do.
Source code in prediction_market_agent_tooling/markets/agent_market.py
268 269 270 271 272 | |
liquidate_existing_positions
liquidate_existing_positions(outcome: OutcomeStr) -> None
Source code in prediction_market_agent_tooling/markets/agent_market.py
274 275 | |
place_bet
place_bet(outcome: OutcomeStr, amount: USD) -> str
Source code in prediction_market_agent_tooling/markets/agent_market.py
277 278 | |
buy_tokens
buy_tokens(outcome: OutcomeStr, amount: USD) -> str
Source code in prediction_market_agent_tooling/markets/agent_market.py
280 281 | |
get_buy_token_amount
get_buy_token_amount(
bet_amount: USD | CollateralToken, outcome: OutcomeStr
) -> OutcomeToken | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
283 284 285 286 | |
sell_tokens
sell_tokens(
outcome: OutcomeStr, amount: USD | OutcomeToken
) -> str
Source code in prediction_market_agent_tooling/markets/agent_market.py
288 289 | |
compute_fpmm_probabilities
staticmethod
compute_fpmm_probabilities(
balances: list[OutcomeWei],
) -> list[Probability]
Compute the implied probabilities in a Fixed Product Market Maker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
balances
|
List[float]
|
Balances of outcome tokens. |
required |
Returns:
| Type | Description |
|---|---|
list[Probability]
|
List[float]: Implied probabilities for each outcome. |
Source code in prediction_market_agent_tooling/markets/agent_market.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
build_probability_map_from_p_yes
staticmethod
build_probability_map_from_p_yes(
p_yes: Probability,
) -> dict[OutcomeStr, Probability]
Source code in prediction_market_agent_tooling/markets/agent_market.py
321 322 323 324 325 326 327 328 | |
build_probability_map
staticmethod
build_probability_map(
outcome_token_amounts: list[OutcomeWei],
outcomes: list[OutcomeStr],
) -> dict[OutcomeStr, Probability]
Source code in prediction_market_agent_tooling/markets/agent_market.py
330 331 332 333 334 335 | |
get_binary_market
staticmethod
get_binary_market(id: str) -> AgentMarket
Source code in prediction_market_agent_tooling/markets/agent_market.py
348 349 350 | |
get_trade_balance
classmethod
get_trade_balance(api_keys: APIKeys) -> USD
Return balance that can be used to trade on the given market.
Source code in prediction_market_agent_tooling/markets/agent_market.py
359 360 361 362 363 364 | |
store_trades
store_trades(
traded_market: ProcessedTradedMarket | None,
keys: APIKeys,
agent_name: str,
web3: Web3 | None = None,
) -> None
If market allows to upload trades somewhere, implement it in this method.
Source code in prediction_market_agent_tooling/markets/agent_market.py
385 386 387 388 389 390 391 392 393 394 395 | |
get_bets_made_since
staticmethod
get_bets_made_since(
better_address: ChecksumAddress, start_time: DatetimeUTC
) -> list[Bet]
Source code in prediction_market_agent_tooling/markets/agent_market.py
397 398 399 400 401 | |
get_resolved_bets_made_since
staticmethod
get_resolved_bets_made_since(
better_address: ChecksumAddress,
start_time: DatetimeUTC,
end_time: DatetimeUTC | None,
) -> list[ResolvedBet]
Source code in prediction_market_agent_tooling/markets/agent_market.py
403 404 405 406 407 408 409 | |
is_closed
is_closed() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
411 412 | |
is_resolved
is_resolved() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
414 415 | |
get_liquidity
get_liquidity() -> CollateralToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
417 418 | |
has_liquidity
has_liquidity() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
420 421 | |
has_successful_resolution
has_successful_resolution() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
423 424 425 426 427 428 | |
has_unsuccessful_resolution
has_unsuccessful_resolution() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
430 431 | |
get_outcome_str_from_bool
staticmethod
get_outcome_str_from_bool(outcome: bool) -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/agent_market.py
433 434 435 | |
get_outcome_str
get_outcome_str(outcome_index: int) -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/agent_market.py
437 438 439 440 441 442 443 | |
get_outcome_index
get_outcome_index(outcome: OutcomeStr) -> int
Source code in prediction_market_agent_tooling/markets/agent_market.py
445 446 447 448 449 450 | |
get_token_balance
get_token_balance(
user_id: str, outcome: OutcomeStr
) -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
452 453 | |
get_position
get_position(user_id: str) -> ExistingPosition | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
455 456 | |
get_positions
classmethod
get_positions(
user_id: str,
liquid_only: bool = False,
larger_than: OutcomeToken = OutcomeToken(0),
) -> t.Sequence[ExistingPosition]
Get all non-zero positions a user has in any market.
If liquid_only is True, only return positions that can be sold.
If larger_than is not None, only return positions with a larger number
of tokens than this amount.
Source code in prediction_market_agent_tooling/markets/agent_market.py
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 | |
can_be_traded
can_be_traded() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
475 476 477 478 | |
get_user_url
classmethod
get_user_url(keys: APIKeys) -> str
Source code in prediction_market_agent_tooling/markets/agent_market.py
480 481 482 | |
has_token_pool
has_token_pool() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
484 485 | |
get_pool_tokens
get_pool_tokens(outcome: OutcomeStr) -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
487 488 489 490 491 | |
get_user_balance
staticmethod
get_user_balance(user_id: str) -> float
Source code in prediction_market_agent_tooling/markets/agent_market.py
493 494 495 | |
get_most_recent_trade_datetime
get_most_recent_trade_datetime(
user_id: str,
) -> DatetimeUTC | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
501 502 | |
omen
cow_contracts
CowGPv2SettlementContract
Bases: ContractOnGnosisChain
abi
class-attribute
instance-attribute
abi: ABI = abi_field_validator(
join(
dirname(realpath(__file__)),
"../../abis/gvp2_settlement.abi.json",
)
)
CHAIN_ID
class-attribute
instance-attribute
CHAIN_ID = chain_id
address
instance-attribute
address: ChecksumAddress
setPreSignature
setPreSignature(
api_keys: APIKeys,
orderId: HexBytes,
signed: bool,
web3: Web3 | None = None,
) -> None
Source code in prediction_market_agent_tooling/markets/omen/cow_contracts.py
22 23 24 25 26 27 28 29 30 31 32 33 34 | |
merge_contract_abis
classmethod
merge_contract_abis(
contracts: list[ContractBaseClass],
) -> ABI
Source code in prediction_market_agent_tooling/tools/contract.py
77 78 79 80 81 82 | |
get_web3_contract
get_web3_contract(web3: Web3 | None = None) -> Web3Contract
Source code in prediction_market_agent_tooling/tools/contract.py
84 85 86 | |
call
call(
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
web3: Web3 | None = None,
) -> t.Any
Used for reading from the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
send
send(
api_keys: APIKeys,
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
send_with_value
send_with_value(
api_keys: APIKeys,
function_name: str,
amount_wei: Wei,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract, including sending chain's native currency.
Source code in prediction_market_agent_tooling/tools/contract.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_transaction_count
classmethod
get_transaction_count(
for_address: ChecksumAddress,
) -> Nonce
Source code in prediction_market_agent_tooling/tools/contract.py
164 165 166 | |
get_web3
classmethod
get_web3() -> Web3
Source code in prediction_market_agent_tooling/tools/contract.py
168 169 170 | |
data_models
OMEN_TRUE_OUTCOME
module-attribute
OMEN_TRUE_OUTCOME = OutcomeStr('Yes')
OMEN_FALSE_OUTCOME
module-attribute
OMEN_FALSE_OUTCOME = OutcomeStr('No')
OMEN_BINARY_MARKET_OUTCOMES
module-attribute
OMEN_BINARY_MARKET_OUTCOMES: Sequence[OutcomeStr] = [
OMEN_TRUE_OUTCOME,
OMEN_FALSE_OUTCOME,
]
INVALID_ANSWER
module-attribute
INVALID_ANSWER = 115792089237316195423570985008687907853269984665640564039457584007913129639935
INVALID_ANSWER_HEX_BYTES
module-attribute
INVALID_ANSWER_HEX_BYTES = HexBytes(INVALID_ANSWER)
INVALID_ANSWER_STR
module-attribute
INVALID_ANSWER_STR = HexStr(hex())
OMEN_BASE_URL
module-attribute
OMEN_BASE_URL = 'https://aiomen.eth.limo'
PRESAGIO_BASE_URL
module-attribute
PRESAGIO_BASE_URL = 'https://presagio.pages.dev'
TEST_CATEGORY
module-attribute
TEST_CATEGORY = 'test'
Condition
Bases: BaseModel
id
instance-attribute
id: HexBytes
outcomeSlotCount
instance-attribute
outcomeSlotCount: int
index_sets
property
index_sets: List[int]
Question
Bases: BaseModel
id
instance-attribute
id: HexBytes
title
instance-attribute
title: str
data
instance-attribute
data: str
templateId
instance-attribute
templateId: int
outcomes
instance-attribute
outcomes: Sequence[OutcomeStr]
isPendingArbitration
instance-attribute
isPendingArbitration: bool
openingTimestamp
instance-attribute
openingTimestamp: int
answerFinalizedTimestamp
class-attribute
instance-attribute
answerFinalizedTimestamp: Optional[DatetimeUTC] = None
currentAnswer
class-attribute
instance-attribute
currentAnswer: Optional[str] = None
question_id
property
question_id: HexBytes
question_raw
property
question_raw: str
n_outcomes
property
n_outcomes: int
opening_datetime
property
opening_datetime: DatetimeUTC
has_answer
property
has_answer: bool
outcome_index
property
outcome_index: int | None
is_binary
property
is_binary: bool
has_valid_answer
property
has_valid_answer: bool
boolean_outcome
property
boolean_outcome: bool
OmenPosition
Bases: BaseModel
id
instance-attribute
id: HexBytes
conditionIds
instance-attribute
conditionIds: list[HexBytes]
collateralTokenAddress
instance-attribute
collateralTokenAddress: HexAddress
indexSets
instance-attribute
indexSets: list[int]
condition_id
property
condition_id: HexBytes
index_set
property
index_set: int
collateral_token_contract_address_checksummed
property
collateral_token_contract_address_checksummed: (
ChecksumAddress
)
get_collateral_token_contract
get_collateral_token_contract(
web3: Web3 | None = None,
) -> ContractERC20OnGnosisChain
Source code in prediction_market_agent_tooling/markets/omen/data_models.py
179 180 181 182 183 184 185 186 187 | |
OmenUserPosition
Bases: BaseModel
id
instance-attribute
id: HexBytes
position
instance-attribute
position: OmenPosition
balance
instance-attribute
balance: OutcomeWei
wrappedBalance
instance-attribute
wrappedBalance: OutcomeWei
totalBalance
instance-attribute
totalBalance: OutcomeWei
redeemable
property
redeemable: bool
OmenMarket
Bases: BaseModel
https://presagio.pages.dev
An Omen market goes through the following stages:
- creation - can add liquidty immediately, and trade immediately if there is liquidity
- closing - market is closed, and a question is simultaneously opened for answers on Reality
- finalizing - the question is finalized on reality (including any disputes)
- resolving - a manual step required by calling the Omen oracle contract
- redeeming - a user withdraws collateral tokens from the market
id
instance-attribute
id: HexAddress
title
instance-attribute
title: str
creator
instance-attribute
creator: HexAddress
category
instance-attribute
category: str
collateralVolume
instance-attribute
collateralVolume: Wei
liquidityParameter
instance-attribute
liquidityParameter: Wei
usdVolume
instance-attribute
usdVolume: USD
collateralToken
instance-attribute
collateralToken: HexAddress
outcomes
instance-attribute
outcomes: Sequence[OutcomeStr]
outcomeTokenAmounts
instance-attribute
outcomeTokenAmounts: list[OutcomeWei]
outcomeTokenMarginalPrices
instance-attribute
outcomeTokenMarginalPrices: Optional[list[CollateralToken]]
fee
instance-attribute
fee: Optional[Wei]
resolutionTimestamp
class-attribute
instance-attribute
resolutionTimestamp: Optional[int] = None
answerFinalizedTimestamp
class-attribute
instance-attribute
answerFinalizedTimestamp: Optional[int] = None
currentAnswer
class-attribute
instance-attribute
currentAnswer: Optional[HexBytes] = None
creationTimestamp
instance-attribute
creationTimestamp: int
condition
instance-attribute
condition: Condition
question
instance-attribute
question: Question
openingTimestamp
property
openingTimestamp: int
opening_datetime
property
opening_datetime: DatetimeUTC
close_time
property
close_time: DatetimeUTC
answer_index
property
answer_index: Optional[int]
has_valid_answer
property
has_valid_answer: bool
is_open
property
is_open: bool
is_resolved
property
is_resolved: bool
is_resolved_with_valid_answer
property
is_resolved_with_valid_answer: bool
question_title
property
question_title: str
creation_datetime
property
creation_datetime: DatetimeUTC
finalized_datetime
property
finalized_datetime: DatetimeUTC | None
has_bonded_outcome
property
has_bonded_outcome: bool
market_maker_contract_address
property
market_maker_contract_address: HexAddress
market_maker_contract_address_checksummed
property
market_maker_contract_address_checksummed: ChecksumAddress
collateral_token_contract_address
property
collateral_token_contract_address: HexAddress
collateral_token_contract_address_checksummed
property
collateral_token_contract_address_checksummed: (
ChecksumAddress
)
outcomeTokenProbabilities
property
outcomeTokenProbabilities: Optional[list[Probability]]
yes_index
property
yes_index: int
no_index
property
no_index: int
current_p_no
property
current_p_no: Probability
current_p_yes
property
current_p_yes: Probability
Calculate the probability of the outcomes from the relative token amounts.
Note, not all markets reliably have outcomeTokenMarginalPrices, hence we use the relative proportion of outcomeTokenAmounts to calculate the probabilities.
The higher the proportion of available outcome tokens for a given outcome, the the lower the price of that token, and therefore the lower the probability of that outcome.
is_binary
property
is_binary: bool
url
property
url: str
outcome_from_answer
outcome_from_answer(answer: HexBytes) -> OutcomeStr | None
Source code in prediction_market_agent_tooling/markets/omen/data_models.py
402 403 404 405 | |
get_resolution_enum_from_answer
get_resolution_enum_from_answer(
answer: HexBytes,
) -> Resolution
Source code in prediction_market_agent_tooling/markets/omen/data_models.py
407 408 409 410 411 | |
get_resolution_enum
get_resolution_enum() -> t.Optional[Resolution]
Source code in prediction_market_agent_tooling/markets/omen/data_models.py
413 414 415 416 417 418 419 420 | |
from_created_market
staticmethod
from_created_market(model: CreatedMarket) -> OmenMarket
OmenMarket is meant to be retrieved from subgraph, however in tests against local chain it's very handy to create it out of CreatedMarket,
which is collection of events that are emitted during the market creation in omen_create_market_tx function.
Source code in prediction_market_agent_tooling/markets/omen/data_models.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | |
OmenBetCreator
Bases: BaseModel
id
instance-attribute
id: HexAddress
OmenBet
Bases: BaseModel
id
instance-attribute
id: HexAddress
title
instance-attribute
title: str
collateralToken
instance-attribute
collateralToken: HexAddress
outcomeTokenMarginalPrice
instance-attribute
outcomeTokenMarginalPrice: CollateralToken
oldOutcomeTokenMarginalPrice
instance-attribute
oldOutcomeTokenMarginalPrice: CollateralToken
type
instance-attribute
type: str
creator
instance-attribute
creator: OmenBetCreator
creationTimestamp
instance-attribute
creationTimestamp: int
collateralAmount
instance-attribute
collateralAmount: Wei
feeAmount
instance-attribute
feeAmount: Wei
outcomeIndex
instance-attribute
outcomeIndex: int
outcomeTokensTraded
instance-attribute
outcomeTokensTraded: OutcomeWei
transactionHash
instance-attribute
transactionHash: HexBytes
fpmm
instance-attribute
fpmm: OmenMarket
collateral_amount_token
property
collateral_amount_token: CollateralToken
collateral_token_checksummed
property
collateral_token_checksummed: ChecksumAddress
creation_datetime
property
creation_datetime: DatetimeUTC
old_probability
property
old_probability: Probability
probability
property
probability: Probability
get_collateral_amount_usd
get_collateral_amount_usd() -> USD
Source code in prediction_market_agent_tooling/markets/omen/data_models.py
559 560 561 562 | |
get_profit
get_profit() -> CollateralToken
Source code in prediction_market_agent_tooling/markets/omen/data_models.py
564 565 566 567 568 569 570 571 572 573 574 575 | |
to_bet
to_bet() -> Bet
Source code in prediction_market_agent_tooling/markets/omen/data_models.py
577 578 579 580 581 582 583 584 585 586 | |
to_generic_resolved_bet
to_generic_resolved_bet() -> ResolvedBet
Source code in prediction_market_agent_tooling/markets/omen/data_models.py
588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 | |
FixedProductMarketMakersData
Bases: BaseModel
fixedProductMarketMakers
instance-attribute
fixedProductMarketMakers: list[OmenMarket]
FixedProductMarketMakersResponse
Bases: BaseModel
data
instance-attribute
data: FixedProductMarketMakersData
RealityQuestion
Bases: BaseModel
id
instance-attribute
id: str
user
instance-attribute
user: HexAddress
historyHash
instance-attribute
historyHash: HexBytes | None
updatedTimestamp
instance-attribute
updatedTimestamp: int
contentHash
instance-attribute
contentHash: HexBytes
questionId
instance-attribute
questionId: HexBytes
answerFinalizedTimestamp
instance-attribute
answerFinalizedTimestamp: int | None
currentScheduledFinalizationTimestamp
instance-attribute
currentScheduledFinalizationTimestamp: int
updated_datetime
property
updated_datetime: DatetimeUTC
answer_finalized_datetime
property
answer_finalized_datetime: DatetimeUTC | None
current_scheduled_finalization_datetime
property
current_scheduled_finalization_datetime: DatetimeUTC
url
property
url: str
RealityAnswer
Bases: BaseModel
id
instance-attribute
id: str
timestamp
instance-attribute
timestamp: int
answer
instance-attribute
answer: HexBytes
lastBond
instance-attribute
lastBond: Wei
bondAggregate
instance-attribute
bondAggregate: Wei
question
instance-attribute
question: RealityQuestion
createdBlock
instance-attribute
createdBlock: int
timestamp_datetime
property
timestamp_datetime: DatetimeUTC
RealityResponse
Bases: BaseModel
This is similar to RealityAnswer, but contains additional fields, most importantly historyHash.
id
instance-attribute
id: str
timestamp
instance-attribute
timestamp: int
answer
instance-attribute
answer: HexBytes
isUnrevealed
instance-attribute
isUnrevealed: bool
isCommitment
instance-attribute
isCommitment: bool
bond
instance-attribute
bond: xDaiWei
user
instance-attribute
user: HexAddress
historyHash
instance-attribute
historyHash: HexBytes
question
instance-attribute
question: RealityQuestion
createdBlock
instance-attribute
createdBlock: int
revealedBlock
instance-attribute
revealedBlock: int | None
bond_xdai
property
bond_xdai: xDai
user_checksummed
property
user_checksummed: ChecksumAddress
RealityAnswers
Bases: BaseModel
answers
instance-attribute
answers: list[RealityAnswer]
RealityAnswersResponse
Bases: BaseModel
data
instance-attribute
data: RealityAnswers
ParsedQuestion
Bases: BaseModel
question
instance-attribute
question: str
outcomes
instance-attribute
outcomes: Sequence[OutcomeStr]
language
instance-attribute
language: str
category
instance-attribute
category: str
RealitioLogNewQuestionEvent
Bases: BaseModel
question_id
instance-attribute
question_id: HexBytes
user
instance-attribute
user: HexAddress
template_id
instance-attribute
template_id: int
question
instance-attribute
question: str
content_hash
instance-attribute
content_hash: HexBytes
arbitrator
instance-attribute
arbitrator: HexAddress
timeout
instance-attribute
timeout: int
opening_ts
instance-attribute
opening_ts: int
nonce
instance-attribute
nonce: int
created
instance-attribute
created: int
user_checksummed
property
user_checksummed: ChecksumAddress
parsed_question
property
parsed_question: ParsedQuestion
OmenFixedProductMarketMakerCreationEvent
Bases: BaseModel
creator
instance-attribute
creator: HexAddress
fixedProductMarketMaker
instance-attribute
fixedProductMarketMaker: HexAddress
conditionalTokens
instance-attribute
conditionalTokens: HexAddress
collateralToken
instance-attribute
collateralToken: HexAddress
conditionIds
instance-attribute
conditionIds: list[HexBytes]
fee
instance-attribute
fee: int
creator_checksummed
property
creator_checksummed: ChecksumAddress
fixed_product_market_maker_checksummed
property
fixed_product_market_maker_checksummed: ChecksumAddress
conditional_tokens_checksummed
property
conditional_tokens_checksummed: ChecksumAddress
collateral_token_checksummed
property
collateral_token_checksummed: ChecksumAddress
ConditionPreparationEvent
Bases: BaseModel
conditionId
instance-attribute
conditionId: HexBytes
oracle
instance-attribute
oracle: HexAddress
questionId
instance-attribute
questionId: HexBytes
outcomeSlotCount
instance-attribute
outcomeSlotCount: int
FPMMFundingAddedEvent
Bases: BaseModel
funder
instance-attribute
funder: HexAddress
amountsAdded
instance-attribute
amountsAdded: list[Wei]
sharesMinted
instance-attribute
sharesMinted: Wei
outcome_token_amounts
property
outcome_token_amounts: list[OutcomeWei]
CreatedMarket
Bases: BaseModel
market_creation_timestamp
instance-attribute
market_creation_timestamp: int
market_event
instance-attribute
market_event: OmenFixedProductMarketMakerCreationEvent
funding_event
instance-attribute
funding_event: FPMMFundingAddedEvent
condition_id
instance-attribute
condition_id: HexBytes
question_event
instance-attribute
question_event: RealitioLogNewQuestionEvent
condition_event
instance-attribute
condition_event: ConditionPreparationEvent | None
initial_funds
instance-attribute
initial_funds: Wei
fee
instance-attribute
fee: Wei
distribution_hint
instance-attribute
distribution_hint: list[OutcomeWei] | None
url
property
url: str
ContractPrediction
Bases: BaseModel
model_config
class-attribute
instance-attribute
model_config = ConfigDict(populate_by_name=True)
publisher
class-attribute
instance-attribute
publisher: str = Field(..., alias='publisherAddress')
ipfs_hash
class-attribute
instance-attribute
ipfs_hash: HexBytes = Field(..., alias='ipfsHash')
tx_hashes
class-attribute
instance-attribute
tx_hashes: list[HexBytes] = Field(..., alias='txHashes')
estimated_probability_bps
class-attribute
instance-attribute
estimated_probability_bps: int = Field(
..., alias="estimatedProbabilityBps"
)
estimated_probability
property
estimated_probability: Probability
boolean_outcome
property
boolean_outcome: bool
publisher_checksummed
property
publisher_checksummed: ChecksumAddress
from_tuple
staticmethod
from_tuple(values: tuple[Any, ...]) -> ContractPrediction
Source code in prediction_market_agent_tooling/markets/omen/data_models.py
847 848 849 850 851 852 853 854 | |
IPFSAgentResult
Bases: BaseModel
reasoning
instance-attribute
reasoning: str
agent_name
instance-attribute
agent_name: str
model_config
class-attribute
instance-attribute
model_config = ConfigDict(extra='forbid')
PayoutRedemptionEvent
Bases: BaseModel
redeemer
instance-attribute
redeemer: HexAddress
collateralToken
instance-attribute
collateralToken: HexAddress
parentCollectionId
instance-attribute
parentCollectionId: HexBytes
conditionId
instance-attribute
conditionId: HexBytes
indexSets
instance-attribute
indexSets: list[int]
payout
instance-attribute
payout: Wei
construct_presagio_url
construct_presagio_url(market_id: HexAddress) -> str
Source code in prediction_market_agent_tooling/markets/omen/data_models.py
54 55 | |
get_boolean_outcome
get_boolean_outcome(outcome_str: str) -> bool
Source code in prediction_market_agent_tooling/markets/omen/data_models.py
58 59 60 61 62 63 | |
get_bet_outcome
get_bet_outcome(binary_outcome: bool) -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/omen/data_models.py
66 67 | |
calculate_liquidity_parameter
calculate_liquidity_parameter(
outcome_token_amounts: list[OutcomeWei],
) -> Wei
Converted to Python from https://github.com/protofire/omen-subgraph/blob/f92bbfb6fa31ed9cd5985c416a26a2f640837d8b/src/utils/fpmm.ts#L171.
Source code in prediction_market_agent_tooling/markets/omen/data_models.py
477 478 479 480 481 482 483 484 485 486 487 488 | |
calculate_marginal_prices
calculate_marginal_prices(
outcome_token_amounts: list[OutcomeWei],
) -> list[CollateralToken] | None
Converted to Python from https://github.com/protofire/omen-subgraph/blob/f92bbfb6fa31ed9cd5985c416a26a2f640837d8b/src/utils/fpmm.ts#L197.
Source code in prediction_market_agent_tooling/markets/omen/data_models.py
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | |
format_realitio_question
format_realitio_question(
question: str,
outcomes: Sequence[str],
category: str,
language: str,
template_id: int,
) -> str
If you add a new template id here, also add to the parsing function below.
Source code in prediction_market_agent_tooling/markets/omen/data_models.py
699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 | |
parse_realitio_question
parse_realitio_question(
question_raw: str, template_id: int
) -> ParsedQuestion
If you add a new template id here, also add to the encoding function above.
Source code in prediction_market_agent_tooling/markets/omen/data_models.py
724 725 726 727 728 729 730 731 732 733 | |
omen
OMEN_DEFAULT_REALITIO_BOND_VALUE
module-attribute
OMEN_DEFAULT_REALITIO_BOND_VALUE = xDai(0.01)
OMEN_TINY_BET_AMOUNT
module-attribute
OMEN_TINY_BET_AMOUNT = USD(0.01)
OmenAgentMarket
Bases: AgentMarket
Omen's market class that can be used by agents to make predictions.
base_url
class-attribute
base_url: str = PRESAGIO_BASE_URL
creator
instance-attribute
creator: HexAddress
collateral_token_contract_address_checksummed
instance-attribute
collateral_token_contract_address_checksummed: (
ChecksumAddress
)
market_maker_contract_address_checksummed
instance-attribute
market_maker_contract_address_checksummed: ChecksumAddress
condition
instance-attribute
condition: Condition
finalized_time
instance-attribute
finalized_time: DatetimeUTC | None
created_time
instance-attribute
created_time: DatetimeUTC
close_time
instance-attribute
close_time: DatetimeUTC
description
class-attribute
instance-attribute
description: str | None = None
yes_index
property
yes_index: int
no_index
property
no_index: int
id
instance-attribute
id: str
question
instance-attribute
question: str
outcomes
instance-attribute
outcomes: Sequence[OutcomeStr]
outcome_token_pool
instance-attribute
outcome_token_pool: dict[OutcomeStr, OutcomeToken] | None
resolution
instance-attribute
resolution: Resolution | None
probabilities
instance-attribute
probabilities: dict[OutcomeStr, Probability]
url
instance-attribute
url: str
volume
instance-attribute
volume: CollateralToken | None
fees
instance-attribute
fees: MarketFees
is_binary
property
is_binary: bool
p_yes
property
p_yes: Probability
p_no
property
p_no: Probability
probable_resolution
property
probable_resolution: Resolution
get_p_yes_history_cached
get_p_yes_history_cached() -> list[Probability]
Source code in prediction_market_agent_tooling/markets/omen/omen.py
124 125 126 127 | |
get_last_trade_p_yes
get_last_trade_p_yes() -> Probability | None
On Omen, probablities converge after the resolution, so we need to get market's predicted probability from the trade history.
Source code in prediction_market_agent_tooling/markets/omen/omen.py
129 130 131 132 133 134 135 | |
get_last_trade_p_no
get_last_trade_p_no() -> Probability | None
On Omen, probablities converge after the resolution, so we need to get market's predicted probability from the trade history.
Source code in prediction_market_agent_tooling/markets/omen/omen.py
137 138 139 140 141 142 143 144 | |
get_liquidity_in_wei
get_liquidity_in_wei(web3: Web3 | None = None) -> Wei
Source code in prediction_market_agent_tooling/markets/omen/omen.py
146 147 | |
get_liquidity
get_liquidity(web3: Web3 | None = None) -> CollateralToken
Source code in prediction_market_agent_tooling/markets/omen/omen.py
149 150 | |
get_tiny_bet_amount
get_tiny_bet_amount() -> CollateralToken
Source code in prediction_market_agent_tooling/markets/omen/omen.py
152 153 | |
get_token_in_usd
get_token_in_usd(x: CollateralToken) -> USD
Source code in prediction_market_agent_tooling/markets/omen/omen.py
155 156 | |
get_usd_in_token
get_usd_in_token(x: USD) -> CollateralToken
Source code in prediction_market_agent_tooling/markets/omen/omen.py
158 159 | |
have_bet_on_market_since
have_bet_on_market_since(
keys: APIKeys, since: timedelta
) -> bool
Source code in prediction_market_agent_tooling/markets/omen/omen.py
161 162 163 164 165 166 167 | |
liquidate_existing_positions
liquidate_existing_positions(
bet_outcome: OutcomeStr,
web3: Web3 | None = None,
api_keys: APIKeys | None = None,
larger_than: OutcomeToken | None = None,
) -> None
Liquidates all previously existing positions.
Source code in prediction_market_agent_tooling/markets/omen/omen.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
place_bet
place_bet(
outcome: OutcomeStr,
amount: USD,
auto_deposit: bool = True,
web3: Web3 | None = None,
api_keys: APIKeys | None = None,
) -> str
Source code in prediction_market_agent_tooling/markets/omen/omen.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
buy_tokens
buy_tokens(
outcome: OutcomeStr,
amount: USD,
web3: Web3 | None = None,
api_keys: APIKeys | None = None,
) -> str
Source code in prediction_market_agent_tooling/markets/omen/omen.py
221 222 223 224 225 226 227 228 229 230 231 232 233 | |
get_sell_value_of_outcome_token
get_sell_value_of_outcome_token(
outcome: OutcomeStr,
amount: OutcomeToken,
web3: Web3 | None = None,
) -> CollateralToken
Market can have as collateral token GNO for example. When you place bet, you buy shares with GNO. For example, you get 10 shares for 1 GNO. When selling, you need to provide the amount in GNO, which is cumbersome because you know how much shares you have, but you don't have the price of the shares in GNO. Use this to convert how much collateral token (GNO in our example) to sell, to get the amount of shares you want to sell.
Source code in prediction_market_agent_tooling/markets/omen/omen.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
sell_tokens
sell_tokens(
outcome: OutcomeStr,
amount: USD | OutcomeToken,
auto_withdraw: bool = True,
api_keys: APIKeys | None = None,
web3: Web3 | None = None,
) -> str
Source code in prediction_market_agent_tooling/markets/omen/omen.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
was_any_bet_outcome_correct
was_any_bet_outcome_correct(
resolved_omen_bets: List[OmenBet],
) -> bool | None
Source code in prediction_market_agent_tooling/markets/omen/omen.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
market_redeemable_by
market_redeemable_by(user: ChecksumAddress) -> bool
Will return true if given user placed a bet on this market and that bet has a balance. If the user never placed a bet on this market, this correctly return False.
Source code in prediction_market_agent_tooling/markets/omen/omen.py
309 310 311 312 313 314 315 316 317 318 319 320 321 | |
redeem_positions
redeem_positions(api_keys: APIKeys) -> None
Source code in prediction_market_agent_tooling/markets/omen/omen.py
323 324 325 326 327 328 329 330 331 332 333 334 335 | |
from_created_market
staticmethod
from_created_market(
model: CreatedMarket,
) -> OmenAgentMarket
Source code in prediction_market_agent_tooling/markets/omen/omen.py
337 338 339 | |
from_data_model
staticmethod
from_data_model(model: OmenMarket) -> OmenAgentMarket
Source code in prediction_market_agent_tooling/markets/omen/omen.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | |
get_markets
staticmethod
get_markets(
limit: int,
sort_by: SortBy,
filter_by: FilterBy = FilterBy.OPEN,
created_after: Optional[DatetimeUTC] = None,
excluded_questions: set[str] | None = None,
fetch_categorical_markets: bool = False,
) -> t.Sequence[OmenAgentMarket]
Source code in prediction_market_agent_tooling/markets/omen/omen.py
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | |
get_binary_market
staticmethod
get_binary_market(id: str) -> OmenAgentMarket
Source code in prediction_market_agent_tooling/markets/omen/omen.py
394 395 396 397 398 399 400 | |
redeem_winnings
staticmethod
redeem_winnings(api_keys: APIKeys) -> None
Source code in prediction_market_agent_tooling/markets/omen/omen.py
402 403 404 | |
get_trade_balance
staticmethod
get_trade_balance(
api_keys: APIKeys, web3: Web3 | None = None
) -> USD
Source code in prediction_market_agent_tooling/markets/omen/omen.py
406 407 408 409 410 411 412 413 414 415 416 417 | |
verify_operational_balance
staticmethod
verify_operational_balance(api_keys: APIKeys) -> bool
Source code in prediction_market_agent_tooling/markets/omen/omen.py
419 420 421 422 423 424 | |
store_prediction
store_prediction(
processed_market: ProcessedMarket | None,
keys: APIKeys,
agent_name: str,
) -> None
On Omen, we have to store predictions along with trades, see store_trades.
Source code in prediction_market_agent_tooling/markets/omen/omen.py
426 427 428 429 | |
store_trades
store_trades(
traded_market: ProcessedTradedMarket | None,
keys: APIKeys,
agent_name: str,
web3: Web3 | None = None,
) -> None
Source code in prediction_market_agent_tooling/markets/omen/omen.py
431 432 433 434 435 436 437 438 439 440 441 442 443 | |
get_bets_made_since
staticmethod
get_bets_made_since(
better_address: ChecksumAddress, start_time: DatetimeUTC
) -> list[Bet]
Source code in prediction_market_agent_tooling/markets/omen/omen.py
445 446 447 448 449 450 451 452 453 | |
get_resolved_bets_made_since
staticmethod
get_resolved_bets_made_since(
better_address: ChecksumAddress,
start_time: DatetimeUTC,
end_time: DatetimeUTC | None,
market_resolved_before: DatetimeUTC | None = None,
market_resolved_after: DatetimeUTC | None = None,
) -> list[ResolvedBet]
Source code in prediction_market_agent_tooling/markets/omen/omen.py
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 | |
get_contract
get_contract() -> OmenFixedProductMarketMakerContract
Source code in prediction_market_agent_tooling/markets/omen/omen.py
475 476 477 478 479 480 | |
get_index_set
get_index_set(outcome: OutcomeStr) -> int
Source code in prediction_market_agent_tooling/markets/omen/omen.py
482 483 | |
index_set_to_outcome_index
index_set_to_outcome_index(index_set: int) -> int
Source code in prediction_market_agent_tooling/markets/omen/omen.py
485 486 | |
index_set_to_outcome_str
index_set_to_outcome_str(index_set: int) -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/omen/omen.py
488 489 490 491 | |
get_outcome_str_from_bool
staticmethod
get_outcome_str_from_bool(outcome: bool) -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/omen/omen.py
493 494 495 496 497 | |
get_token_balance
get_token_balance(
user_id: str,
outcome: OutcomeStr,
web3: Web3 | None = None,
) -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/omen/omen.py
499 500 501 502 503 504 505 506 | |
get_position
get_position(user_id: str) -> ExistingPosition | None
Source code in prediction_market_agent_tooling/markets/omen/omen.py
508 509 510 511 512 513 514 515 516 517 518 | |
get_positions
classmethod
get_positions(
user_id: str,
liquid_only: bool = False,
larger_than: OutcomeToken = OutcomeToken(0),
) -> t.Sequence[ExistingPosition]
Source code in prediction_market_agent_tooling/markets/omen/omen.py
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 | |
get_user_url
classmethod
get_user_url(keys: APIKeys) -> str
Source code in prediction_market_agent_tooling/markets/omen/omen.py
608 609 610 | |
get_buy_token_amount
get_buy_token_amount(
bet_amount: USD | CollateralToken, outcome: OutcomeStr
) -> OutcomeToken
Note: this is only valid if the market instance's token pool is up-to-date with the smart contract.
Source code in prediction_market_agent_tooling/markets/omen/omen.py
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 | |
get_user_balance
staticmethod
get_user_balance(user_id: str) -> float
Source code in prediction_market_agent_tooling/markets/omen/omen.py
642 643 644 | |
get_user_id
staticmethod
get_user_id(api_keys: APIKeys) -> str
Source code in prediction_market_agent_tooling/markets/omen/omen.py
646 647 648 | |
get_most_recent_trade_datetime
get_most_recent_trade_datetime(
user_id: str,
) -> DatetimeUTC | None
Source code in prediction_market_agent_tooling/markets/omen/omen.py
650 651 652 653 654 655 656 657 658 659 660 661 662 | |
validate_probabilities
validate_probabilities(
probs: dict[OutcomeStr, Probability],
info: FieldValidationInfo,
) -> dict[OutcomeStr, Probability]
Source code in prediction_market_agent_tooling/markets/agent_market.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
validate_outcome_token_pool
validate_outcome_token_pool(
outcome_token_pool: dict[str, OutcomeToken] | None,
info: FieldValidationInfo,
) -> dict[str, OutcomeToken] | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
get_outcome_token_pool_by_outcome
get_outcome_token_pool_by_outcome(
outcome: OutcomeStr,
) -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
122 123 124 125 126 127 128 | |
handle_legacy_fee
handle_legacy_fee(data: dict[str, Any]) -> dict[str, t.Any]
Source code in prediction_market_agent_tooling/markets/agent_market.py
130 131 132 133 134 135 136 | |
market_outcome_for_probability_key
market_outcome_for_probability_key(
probability_key: OutcomeStr,
) -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/agent_market.py
138 139 140 141 142 143 144 145 146 | |
probability_for_market_outcome
probability_for_market_outcome(
market_outcome: OutcomeStr,
) -> Probability
Source code in prediction_market_agent_tooling/markets/agent_market.py
148 149 150 151 152 153 154 | |
get_last_trade_yes_outcome_price
get_last_trade_yes_outcome_price() -> (
CollateralToken | None
)
Source code in prediction_market_agent_tooling/markets/agent_market.py
209 210 211 212 213 214 | |
get_last_trade_yes_outcome_price_usd
get_last_trade_yes_outcome_price_usd() -> USD | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
216 217 218 219 | |
get_last_trade_no_outcome_price
get_last_trade_no_outcome_price() -> CollateralToken | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
221 222 223 224 225 226 | |
get_last_trade_no_outcome_price_usd
get_last_trade_no_outcome_price_usd() -> USD | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
228 229 230 231 | |
get_liquidatable_amount
get_liquidatable_amount() -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
233 234 235 | |
get_in_usd
get_in_usd(x: USD | CollateralToken) -> USD
Source code in prediction_market_agent_tooling/markets/agent_market.py
258 259 260 261 | |
get_in_token
get_in_token(x: USD | CollateralToken) -> CollateralToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
263 264 265 266 | |
compute_fpmm_probabilities
staticmethod
compute_fpmm_probabilities(
balances: list[OutcomeWei],
) -> list[Probability]
Compute the implied probabilities in a Fixed Product Market Maker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
balances
|
List[float]
|
Balances of outcome tokens. |
required |
Returns:
| Type | Description |
|---|---|
list[Probability]
|
List[float]: Implied probabilities for each outcome. |
Source code in prediction_market_agent_tooling/markets/agent_market.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
build_probability_map_from_p_yes
staticmethod
build_probability_map_from_p_yes(
p_yes: Probability,
) -> dict[OutcomeStr, Probability]
Source code in prediction_market_agent_tooling/markets/agent_market.py
321 322 323 324 325 326 327 328 | |
build_probability_map
staticmethod
build_probability_map(
outcome_token_amounts: list[OutcomeWei],
outcomes: list[OutcomeStr],
) -> dict[OutcomeStr, Probability]
Source code in prediction_market_agent_tooling/markets/agent_market.py
330 331 332 333 334 335 | |
is_closed
is_closed() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
411 412 | |
is_resolved
is_resolved() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
414 415 | |
has_liquidity
has_liquidity() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
420 421 | |
has_successful_resolution
has_successful_resolution() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
423 424 425 426 427 428 | |
has_unsuccessful_resolution
has_unsuccessful_resolution() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
430 431 | |
get_outcome_str
get_outcome_str(outcome_index: int) -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/agent_market.py
437 438 439 440 441 442 443 | |
get_outcome_index
get_outcome_index(outcome: OutcomeStr) -> int
Source code in prediction_market_agent_tooling/markets/agent_market.py
445 446 447 448 449 450 | |
can_be_traded
can_be_traded() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
475 476 477 478 | |
has_token_pool
has_token_pool() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
484 485 | |
get_pool_tokens
get_pool_tokens(outcome: OutcomeStr) -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
487 488 489 490 491 | |
get_omen_user_url
get_omen_user_url(address: ChecksumAddress) -> str
Source code in prediction_market_agent_tooling/markets/omen/omen.py
665 666 | |
omen_buy_outcome_tx
omen_buy_outcome_tx(
api_keys: APIKeys,
amount: USD | CollateralToken,
market: OmenAgentMarket,
outcome: OutcomeStr,
auto_deposit: bool,
web3: Web3 | None = None,
slippage: float = 0.01,
) -> str
Bets the given amount for the given outcome in the given market.
Source code in prediction_market_agent_tooling/markets/omen/omen.py
669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 | |
binary_omen_buy_outcome_tx
binary_omen_buy_outcome_tx(
api_keys: APIKeys,
amount: USD | CollateralToken,
market: OmenAgentMarket,
outcome: OutcomeStr,
auto_deposit: bool,
web3: Web3 | None = None,
) -> str
Source code in prediction_market_agent_tooling/markets/omen/omen.py
730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 | |
omen_sell_outcome_tx
omen_sell_outcome_tx(
api_keys: APIKeys,
amount: OutcomeToken | CollateralToken | USD,
market: OmenAgentMarket,
outcome: OutcomeStr,
auto_withdraw: bool,
web3: Web3 | None = None,
slippage: float = 0.01,
) -> str
Sells the given xDai value of shares corresponding to the given outcome in the given market.
The number of shares sold will depend on the share price at the time of the transaction.
Source code in prediction_market_agent_tooling/markets/omen/omen.py
748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 | |
binary_omen_sell_outcome_tx
binary_omen_sell_outcome_tx(
api_keys: APIKeys,
amount: OutcomeToken | CollateralToken | USD,
market: OmenAgentMarket,
outcome: OutcomeStr,
auto_withdraw: bool,
web3: Web3 | None = None,
) -> str
Source code in prediction_market_agent_tooling/markets/omen/omen.py
824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 | |
omen_create_market_tx
omen_create_market_tx(
api_keys: APIKeys,
initial_funds: USD | CollateralToken,
question: str,
closing_time: DatetimeUTC,
category: str,
language: str,
outcomes: Sequence[str],
auto_deposit: bool,
finalization_timeout: timedelta = REALITY_DEFAULT_FINALIZATION_TIMEOUT,
fee_perc: float = OMEN_DEFAULT_MARKET_FEE_PERC,
distribution_hint: list[OutcomeWei] | None = None,
collateral_token_address: ChecksumAddress = WrappedxDaiContract().address,
arbitrator: Arbitrator = Arbitrator.KLEROS_31_JURORS_WITH_APPEAL,
web3: Web3 | None = None,
) -> CreatedMarket
Based on omen-exchange TypeScript code: https://github.com/protofire/omen-exchange/blob/b0b9a3e71b415d6becf21fe428e1c4fc0dad2e80/app/src/services/cpk/cpk.ts#L308
Source code in prediction_market_agent_tooling/markets/omen/omen.py
842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 | |
omen_fund_market_tx
omen_fund_market_tx(
api_keys: APIKeys,
market: OmenAgentMarket,
funds: USD | CollateralToken,
auto_deposit: bool,
web3: Web3 | None = None,
) -> None
Source code in prediction_market_agent_tooling/markets/omen/omen.py
971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 | |
omen_redeem_full_position_tx
omen_redeem_full_position_tx(
api_keys: APIKeys,
market: OmenAgentMarket,
auto_withdraw: bool = True,
web3: Web3 | None = None,
) -> None
Redeems position from a given Omen market. Note that we check if there is a balance to be redeemed before sending the transaction.
Source code in prediction_market_agent_tooling/markets/omen/omen.py
998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 | |
get_conditional_tokens_balance_for_market
get_conditional_tokens_balance_for_market(
market: OmenAgentMarket,
from_address: ChecksumAddress,
web3: Web3 | None = None,
) -> dict[int, OutcomeWei]
We derive the withdrawable balance from the ConditionalTokens contract through CollectionId -> PositionId (which also serves as tokenId) -> TokenBalances.
Source code in prediction_market_agent_tooling/markets/omen/omen.py
1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 | |
omen_remove_fund_market_tx
omen_remove_fund_market_tx(
api_keys: APIKeys,
market: OmenAgentMarket,
shares: Wei | None,
web3: Web3 | None = None,
auto_withdraw: bool = True,
) -> None
Removes funding from a given OmenMarket (moving the funds from the OmenMarket to the
ConditionalTokens contract), and finally calls the mergePositions method which transfers collateralToken from the ConditionalTokens contract to the address corresponding to from_private_key.
Warning: Liquidity removal works on the principle of getting market's shares, not the collateral token itself.
After we remove funding, using the mergePositions we get min(shares per index) of collateral token back, but the remaining shares can be converted back only after the market is resolved.
That can be done using the redeem_from_all_user_positions function below.
Source code in prediction_market_agent_tooling/markets/omen/omen.py
1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 | |
redeem_from_all_user_positions
redeem_from_all_user_positions(
api_keys: APIKeys,
web3: Web3 | None = None,
auto_withdraw: bool = True,
) -> None
Redeems from all user positions where the user didn't redeem yet.
Source code in prediction_market_agent_tooling/markets/omen/omen.py
1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 | |
get_binary_market_p_yes_history
get_binary_market_p_yes_history(
market: OmenAgentMarket,
) -> list[Probability]
Source code in prediction_market_agent_tooling/markets/omen/omen.py
1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 | |
send_keeping_token_to_eoa_xdai
send_keeping_token_to_eoa_xdai(
api_keys: APIKeys,
min_required_balance: xDai,
multiplier: float = 1.0,
web3: Web3 | None = None,
) -> None
Keeps xDai balance above the minimum required balance by transfering keeping token to xDai.
Optionally, the amount to transfer can be multiplied by the multiplier, which can be useful to keep a buffer.
Source code in prediction_market_agent_tooling/markets/omen/omen.py
1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 | |
get_buy_outcome_token_amount
get_buy_outcome_token_amount(
investment_amount: CollateralToken,
outcome_index: int,
pool_balances: list[OutcomeToken],
fees: MarketFees,
) -> OutcomeToken
Calculates the amount of outcome tokens received for a given investment
Taken from https://github.com/gnosis/conditional-tokens-market-makers/blob/6814c0247c745680bb13298d4f0dd7f5b574d0db/contracts/FixedProductMarketMaker.sol#L264
Source code in prediction_market_agent_tooling/markets/omen/omen.py
1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 | |
omen_constants
WRAPPED_XDAI_CONTRACT_ADDRESS
module-attribute
WRAPPED_XDAI_CONTRACT_ADDRESS = to_checksum_address(
"0xe91d153e0b41518a2ce8dd3d7944fa863463a97d"
)
SDAI_CONTRACT_ADDRESS
module-attribute
SDAI_CONTRACT_ADDRESS = to_checksum_address(
"0xaf204776c7245bF4147c2612BF6e5972Ee483701"
)
omen_contracts
OMEN_DEFAULT_MARKET_FEE_PERC
module-attribute
OMEN_DEFAULT_MARKET_FEE_PERC = 0.02
REALITY_DEFAULT_FINALIZATION_TIMEOUT
module-attribute
REALITY_DEFAULT_FINALIZATION_TIMEOUT = timedelta(days=3)
COLLATERAL_TOKEN_CHOICE_TO_ADDRESS
module-attribute
COLLATERAL_TOKEN_CHOICE_TO_ADDRESS = {
wxdai: address,
sdai: address,
gno: address,
metri_super_user: address,
}
OmenOracleContract
Bases: ContractOnGnosisChain
abi
class-attribute
instance-attribute
abi: ABI = abi_field_validator(
join(
dirname(realpath(__file__)),
"../../abis/omen_oracle.abi.json",
)
)
address
class-attribute
instance-attribute
address: ChecksumAddress = to_checksum_address(
"0xAB16D643bA051C11962DA645f74632d3130c81E2"
)
CHAIN_ID
class-attribute
instance-attribute
CHAIN_ID = chain_id
realitio
realitio() -> ChecksumAddress
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
68 69 70 | |
conditionalTokens
conditionalTokens() -> ChecksumAddress
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
72 73 74 | |
resolve
resolve(
api_keys: APIKeys,
question_id: HexBytes,
template_id: int,
question_raw: str,
n_outcomes: int,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
merge_contract_abis
classmethod
merge_contract_abis(
contracts: list[ContractBaseClass],
) -> ABI
Source code in prediction_market_agent_tooling/tools/contract.py
77 78 79 80 81 82 | |
get_web3_contract
get_web3_contract(web3: Web3 | None = None) -> Web3Contract
Source code in prediction_market_agent_tooling/tools/contract.py
84 85 86 | |
call
call(
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
web3: Web3 | None = None,
) -> t.Any
Used for reading from the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
send
send(
api_keys: APIKeys,
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
send_with_value
send_with_value(
api_keys: APIKeys,
function_name: str,
amount_wei: Wei,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract, including sending chain's native currency.
Source code in prediction_market_agent_tooling/tools/contract.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_transaction_count
classmethod
get_transaction_count(
for_address: ChecksumAddress,
) -> Nonce
Source code in prediction_market_agent_tooling/tools/contract.py
164 165 166 | |
get_web3
classmethod
get_web3() -> Web3
Source code in prediction_market_agent_tooling/tools/contract.py
168 169 170 | |
OmenConditionalTokenContract
Bases: ContractOnGnosisChain
abi
class-attribute
instance-attribute
abi: ABI = abi_field_validator(
join(
dirname(realpath(__file__)),
"../../abis/omen_fpmm_conditionaltokens.abi.json",
)
)
address
class-attribute
instance-attribute
address: ChecksumAddress = to_checksum_address(
"0xCeAfDD6bc0bEF976fdCd1112955828E00543c0Ce"
)
CHAIN_ID
class-attribute
instance-attribute
CHAIN_ID = chain_id
getConditionId
getConditionId(
question_id: HexBytes,
oracle_address: ChecksumAddress,
outcomes_slot_count: int,
web3: Web3 | None = None,
) -> HexBytes
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
balanceOf
balanceOf(
from_address: ChecksumAddress,
position_id: int,
web3: Web3 | None = None,
) -> OutcomeWei
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
130 131 132 133 134 135 136 | |
getCollectionId
getCollectionId(
parent_collection_id: HexStr,
condition_id: HexBytes,
index_set: int,
web3: Web3 | None = None,
) -> HexBytes
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
getPositionId
getPositionId(
collateral_token_address: ChecksumAddress,
collection_id: HexBytes,
web3: Web3 | None = None,
) -> int
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
154 155 156 157 158 159 160 161 162 163 164 165 | |
mergePositions
mergePositions(
api_keys: APIKeys,
collateral_token_address: ChecksumAddress,
conditionId: HexBytes,
index_sets: List[int],
amount: OutcomeWei,
parent_collection_id: HexStr = build_parent_collection_id(),
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
redeemPositions
redeemPositions(
api_keys: APIKeys,
collateral_token_address: HexAddress,
condition_id: HexBytes,
index_sets: List[int],
parent_collection_id: HexStr = build_parent_collection_id(),
web3: Web3 | None = None,
) -> PayoutRedemptionEvent
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
getOutcomeSlotCount
getOutcomeSlotCount(
condition_id: HexBytes, web3: Web3 | None = None
) -> int
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
218 219 220 221 222 | |
does_condition_exists
does_condition_exists(
condition_id: HexBytes, web3: Web3 | None = None
) -> bool
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
224 225 226 227 | |
is_condition_resolved
is_condition_resolved(
condition_id: HexBytes, web3: Web3 | None = None
) -> bool
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
229 230 231 232 233 234 235 | |
payoutDenominator
payoutDenominator(
condition_id: HexBytes, web3: Web3 | None = None
) -> int
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
237 238 239 240 241 242 243 | |
setApprovalForAll
setApprovalForAll(
api_keys: APIKeys,
for_address: ChecksumAddress,
approve: bool,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
prepareCondition
prepareCondition(
api_keys: APIKeys,
oracle_address: ChecksumAddress,
question_id: HexBytes,
outcomes_slot_count: int,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> ConditionPreparationEvent
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | |
merge_contract_abis
classmethod
merge_contract_abis(
contracts: list[ContractBaseClass],
) -> ABI
Source code in prediction_market_agent_tooling/tools/contract.py
77 78 79 80 81 82 | |
get_web3_contract
get_web3_contract(web3: Web3 | None = None) -> Web3Contract
Source code in prediction_market_agent_tooling/tools/contract.py
84 85 86 | |
call
call(
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
web3: Web3 | None = None,
) -> t.Any
Used for reading from the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
send
send(
api_keys: APIKeys,
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
send_with_value
send_with_value(
api_keys: APIKeys,
function_name: str,
amount_wei: Wei,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract, including sending chain's native currency.
Source code in prediction_market_agent_tooling/tools/contract.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_transaction_count
classmethod
get_transaction_count(
for_address: ChecksumAddress,
) -> Nonce
Source code in prediction_market_agent_tooling/tools/contract.py
164 165 166 | |
get_web3
classmethod
get_web3() -> Web3
Source code in prediction_market_agent_tooling/tools/contract.py
168 169 170 | |
OmenFixedProductMarketMakerContract
Bases: ContractOnGnosisChain
abi
class-attribute
instance-attribute
abi: ABI = abi_field_validator(
join(
dirname(realpath(__file__)),
"../../abis/omen_fpmm.abi.json",
)
)
CHAIN_ID
class-attribute
instance-attribute
CHAIN_ID = chain_id
address
instance-attribute
address: ChecksumAddress
balanceOf
balanceOf(
for_address: ChecksumAddress, web3: Web3 | None = None
) -> Wei
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
306 307 308 | |
calcBuyAmount
calcBuyAmount(
investment_amount: Wei,
outcome_index: int,
web3: Web3 | None = None,
) -> OutcomeWei
Returns amount of shares we will get for the given outcome_index for the given investment amount.
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
310 311 312 313 314 315 316 317 318 319 | |
calcSellAmount
calcSellAmount(
return_amount: Wei,
outcome_index: int,
web3: Web3 | None = None,
) -> OutcomeWei
Returns amount of shares we will sell for the requested wei.
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
321 322 323 324 325 326 327 328 329 330 | |
conditionalTokens
conditionalTokens(
web3: Web3 | None = None,
) -> ChecksumAddress
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
332 333 334 | |
collateralToken
collateralToken(
web3: Web3 | None = None,
) -> ChecksumAddress
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
336 337 338 | |
buy
buy(
api_keys: APIKeys,
amount_wei: Wei,
outcome_index: int,
min_outcome_tokens_to_buy: OutcomeWei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | |
sell
sell(
api_keys: APIKeys,
amount_wei: Wei,
outcome_index: int,
max_outcome_tokens_to_sell: OutcomeWei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 | |
addFunding
addFunding(
api_keys: APIKeys,
add_funding: Wei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Funding is added in Weis (xDai) and then converted to shares.
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 | |
removeFunding
removeFunding(
api_keys: APIKeys,
remove_funding: Wei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Remove funding is done in shares.
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | |
totalSupply
totalSupply(web3: Web3 | None = None) -> Wei
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
420 421 422 423 | |
get_collateral_token_contract
get_collateral_token_contract(
web3: Web3 | None = None,
) -> ContractERC20OnGnosisChain
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
425 426 427 428 429 430 431 | |
merge_contract_abis
classmethod
merge_contract_abis(
contracts: list[ContractBaseClass],
) -> ABI
Source code in prediction_market_agent_tooling/tools/contract.py
77 78 79 80 81 82 | |
get_web3_contract
get_web3_contract(web3: Web3 | None = None) -> Web3Contract
Source code in prediction_market_agent_tooling/tools/contract.py
84 85 86 | |
call
call(
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
web3: Web3 | None = None,
) -> t.Any
Used for reading from the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
send
send(
api_keys: APIKeys,
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
send_with_value
send_with_value(
api_keys: APIKeys,
function_name: str,
amount_wei: Wei,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract, including sending chain's native currency.
Source code in prediction_market_agent_tooling/tools/contract.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_transaction_count
classmethod
get_transaction_count(
for_address: ChecksumAddress,
) -> Nonce
Source code in prediction_market_agent_tooling/tools/contract.py
164 165 166 | |
get_web3
classmethod
get_web3() -> Web3
Source code in prediction_market_agent_tooling/tools/contract.py
168 169 170 | |
MetriSuperGroup
Bases: ContractERC20OnGnosisChain
address
class-attribute
instance-attribute
address: ChecksumAddress = to_checksum_address(
"0x7147A7405fCFe5CFa30c6d5363f9f357a317d082"
)
CHAIN_ID
class-attribute
instance-attribute
CHAIN_ID = chain_id
abi
class-attribute
instance-attribute
abi: ABI = abi_field_validator(
join(
dirname(realpath(__file__)),
"../abis/erc20.abi.json",
)
)
merge_contract_abis
classmethod
merge_contract_abis(
contracts: list[ContractBaseClass],
) -> ABI
Source code in prediction_market_agent_tooling/tools/contract.py
77 78 79 80 81 82 | |
get_web3_contract
get_web3_contract(web3: Web3 | None = None) -> Web3Contract
Source code in prediction_market_agent_tooling/tools/contract.py
84 85 86 | |
call
call(
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
web3: Web3 | None = None,
) -> t.Any
Used for reading from the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
send
send(
api_keys: APIKeys,
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
send_with_value
send_with_value(
api_keys: APIKeys,
function_name: str,
amount_wei: Wei,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract, including sending chain's native currency.
Source code in prediction_market_agent_tooling/tools/contract.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_transaction_count
classmethod
get_transaction_count(
for_address: ChecksumAddress,
) -> Nonce
Source code in prediction_market_agent_tooling/tools/contract.py
164 165 166 | |
get_web3
classmethod
get_web3() -> Web3
Source code in prediction_market_agent_tooling/tools/contract.py
168 169 170 | |
symbol
symbol(web3: Web3 | None = None) -> str
Source code in prediction_market_agent_tooling/tools/contract.py
200 201 202 | |
symbol_cached
symbol_cached(web3: Web3 | None = None) -> str
Source code in prediction_market_agent_tooling/tools/contract.py
204 205 206 207 208 209 210 | |
allowance
allowance(
owner: ChecksumAddress,
for_address: ChecksumAddress,
web3: Web3 | None = None,
) -> Wei
Source code in prediction_market_agent_tooling/tools/contract.py
212 213 214 215 216 217 218 219 220 221 | |
approve
approve(
api_keys: APIKeys,
for_address: ChecksumAddress,
amount_wei: Wei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
transferFrom
transferFrom(
api_keys: APIKeys,
sender: ChecksumAddress,
recipient: ChecksumAddress,
amount_wei: Wei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
balanceOf
balanceOf(
for_address: ChecksumAddress, web3: Web3 | None = None
) -> Wei
Source code in prediction_market_agent_tooling/tools/contract.py
259 260 261 | |
balance_of_in_tokens
balance_of_in_tokens(
for_address: ChecksumAddress, web3: Web3 | None = None
) -> CollateralToken
Source code in prediction_market_agent_tooling/tools/contract.py
263 264 265 266 | |
GNOContract
Bases: ContractERC20OnGnosisChain
address
class-attribute
instance-attribute
address: ChecksumAddress = to_checksum_address(
"0x9c58bacc331c9aa871afd802db6379a98e80cedb"
)
CHAIN_ID
class-attribute
instance-attribute
CHAIN_ID = chain_id
abi
class-attribute
instance-attribute
abi: ABI = abi_field_validator(
join(
dirname(realpath(__file__)),
"../abis/erc20.abi.json",
)
)
merge_contract_abis
classmethod
merge_contract_abis(
contracts: list[ContractBaseClass],
) -> ABI
Source code in prediction_market_agent_tooling/tools/contract.py
77 78 79 80 81 82 | |
get_web3_contract
get_web3_contract(web3: Web3 | None = None) -> Web3Contract
Source code in prediction_market_agent_tooling/tools/contract.py
84 85 86 | |
call
call(
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
web3: Web3 | None = None,
) -> t.Any
Used for reading from the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
send
send(
api_keys: APIKeys,
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
send_with_value
send_with_value(
api_keys: APIKeys,
function_name: str,
amount_wei: Wei,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract, including sending chain's native currency.
Source code in prediction_market_agent_tooling/tools/contract.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_transaction_count
classmethod
get_transaction_count(
for_address: ChecksumAddress,
) -> Nonce
Source code in prediction_market_agent_tooling/tools/contract.py
164 165 166 | |
get_web3
classmethod
get_web3() -> Web3
Source code in prediction_market_agent_tooling/tools/contract.py
168 169 170 | |
symbol
symbol(web3: Web3 | None = None) -> str
Source code in prediction_market_agent_tooling/tools/contract.py
200 201 202 | |
symbol_cached
symbol_cached(web3: Web3 | None = None) -> str
Source code in prediction_market_agent_tooling/tools/contract.py
204 205 206 207 208 209 210 | |
allowance
allowance(
owner: ChecksumAddress,
for_address: ChecksumAddress,
web3: Web3 | None = None,
) -> Wei
Source code in prediction_market_agent_tooling/tools/contract.py
212 213 214 215 216 217 218 219 220 221 | |
approve
approve(
api_keys: APIKeys,
for_address: ChecksumAddress,
amount_wei: Wei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
transferFrom
transferFrom(
api_keys: APIKeys,
sender: ChecksumAddress,
recipient: ChecksumAddress,
amount_wei: Wei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
balanceOf
balanceOf(
for_address: ChecksumAddress, web3: Web3 | None = None
) -> Wei
Source code in prediction_market_agent_tooling/tools/contract.py
259 260 261 | |
balance_of_in_tokens
balance_of_in_tokens(
for_address: ChecksumAddress, web3: Web3 | None = None
) -> CollateralToken
Source code in prediction_market_agent_tooling/tools/contract.py
263 264 265 266 | |
WETHContract
Bases: ContractERC20OnGnosisChain
address
class-attribute
instance-attribute
address: ChecksumAddress = to_checksum_address(
"0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1"
)
CHAIN_ID
class-attribute
instance-attribute
CHAIN_ID = chain_id
abi
class-attribute
instance-attribute
abi: ABI = abi_field_validator(
join(
dirname(realpath(__file__)),
"../abis/erc20.abi.json",
)
)
merge_contract_abis
classmethod
merge_contract_abis(
contracts: list[ContractBaseClass],
) -> ABI
Source code in prediction_market_agent_tooling/tools/contract.py
77 78 79 80 81 82 | |
get_web3_contract
get_web3_contract(web3: Web3 | None = None) -> Web3Contract
Source code in prediction_market_agent_tooling/tools/contract.py
84 85 86 | |
call
call(
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
web3: Web3 | None = None,
) -> t.Any
Used for reading from the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
send
send(
api_keys: APIKeys,
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
send_with_value
send_with_value(
api_keys: APIKeys,
function_name: str,
amount_wei: Wei,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract, including sending chain's native currency.
Source code in prediction_market_agent_tooling/tools/contract.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_transaction_count
classmethod
get_transaction_count(
for_address: ChecksumAddress,
) -> Nonce
Source code in prediction_market_agent_tooling/tools/contract.py
164 165 166 | |
get_web3
classmethod
get_web3() -> Web3
Source code in prediction_market_agent_tooling/tools/contract.py
168 169 170 | |
symbol
symbol(web3: Web3 | None = None) -> str
Source code in prediction_market_agent_tooling/tools/contract.py
200 201 202 | |
symbol_cached
symbol_cached(web3: Web3 | None = None) -> str
Source code in prediction_market_agent_tooling/tools/contract.py
204 205 206 207 208 209 210 | |
allowance
allowance(
owner: ChecksumAddress,
for_address: ChecksumAddress,
web3: Web3 | None = None,
) -> Wei
Source code in prediction_market_agent_tooling/tools/contract.py
212 213 214 215 216 217 218 219 220 221 | |
approve
approve(
api_keys: APIKeys,
for_address: ChecksumAddress,
amount_wei: Wei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
transferFrom
transferFrom(
api_keys: APIKeys,
sender: ChecksumAddress,
recipient: ChecksumAddress,
amount_wei: Wei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
balanceOf
balanceOf(
for_address: ChecksumAddress, web3: Web3 | None = None
) -> Wei
Source code in prediction_market_agent_tooling/tools/contract.py
259 260 261 | |
balance_of_in_tokens
balance_of_in_tokens(
for_address: ChecksumAddress, web3: Web3 | None = None
) -> CollateralToken
Source code in prediction_market_agent_tooling/tools/contract.py
263 264 265 266 | |
EUReContract
Bases: ContractERC20OnGnosisChain
address
class-attribute
instance-attribute
address: ChecksumAddress = to_checksum_address(
"0xcB444e90D8198415266c6a2724b7900fb12FC56E"
)
CHAIN_ID
class-attribute
instance-attribute
CHAIN_ID = chain_id
abi
class-attribute
instance-attribute
abi: ABI = abi_field_validator(
join(
dirname(realpath(__file__)),
"../abis/erc20.abi.json",
)
)
merge_contract_abis
classmethod
merge_contract_abis(
contracts: list[ContractBaseClass],
) -> ABI
Source code in prediction_market_agent_tooling/tools/contract.py
77 78 79 80 81 82 | |
get_web3_contract
get_web3_contract(web3: Web3 | None = None) -> Web3Contract
Source code in prediction_market_agent_tooling/tools/contract.py
84 85 86 | |
call
call(
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
web3: Web3 | None = None,
) -> t.Any
Used for reading from the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
send
send(
api_keys: APIKeys,
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
send_with_value
send_with_value(
api_keys: APIKeys,
function_name: str,
amount_wei: Wei,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract, including sending chain's native currency.
Source code in prediction_market_agent_tooling/tools/contract.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_transaction_count
classmethod
get_transaction_count(
for_address: ChecksumAddress,
) -> Nonce
Source code in prediction_market_agent_tooling/tools/contract.py
164 165 166 | |
get_web3
classmethod
get_web3() -> Web3
Source code in prediction_market_agent_tooling/tools/contract.py
168 169 170 | |
symbol
symbol(web3: Web3 | None = None) -> str
Source code in prediction_market_agent_tooling/tools/contract.py
200 201 202 | |
symbol_cached
symbol_cached(web3: Web3 | None = None) -> str
Source code in prediction_market_agent_tooling/tools/contract.py
204 205 206 207 208 209 210 | |
allowance
allowance(
owner: ChecksumAddress,
for_address: ChecksumAddress,
web3: Web3 | None = None,
) -> Wei
Source code in prediction_market_agent_tooling/tools/contract.py
212 213 214 215 216 217 218 219 220 221 | |
approve
approve(
api_keys: APIKeys,
for_address: ChecksumAddress,
amount_wei: Wei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
transferFrom
transferFrom(
api_keys: APIKeys,
sender: ChecksumAddress,
recipient: ChecksumAddress,
amount_wei: Wei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
balanceOf
balanceOf(
for_address: ChecksumAddress, web3: Web3 | None = None
) -> Wei
Source code in prediction_market_agent_tooling/tools/contract.py
259 260 261 | |
balance_of_in_tokens
balance_of_in_tokens(
for_address: ChecksumAddress, web3: Web3 | None = None
) -> CollateralToken
Source code in prediction_market_agent_tooling/tools/contract.py
263 264 265 266 | |
SAFEContract
Bases: ContractERC20OnGnosisChain
address
class-attribute
instance-attribute
address: ChecksumAddress = to_checksum_address(
"0x4d18815D14fe5c3304e87B3FA18318baa5c23820"
)
CHAIN_ID
class-attribute
instance-attribute
CHAIN_ID = chain_id
abi
class-attribute
instance-attribute
abi: ABI = abi_field_validator(
join(
dirname(realpath(__file__)),
"../abis/erc20.abi.json",
)
)
merge_contract_abis
classmethod
merge_contract_abis(
contracts: list[ContractBaseClass],
) -> ABI
Source code in prediction_market_agent_tooling/tools/contract.py
77 78 79 80 81 82 | |
get_web3_contract
get_web3_contract(web3: Web3 | None = None) -> Web3Contract
Source code in prediction_market_agent_tooling/tools/contract.py
84 85 86 | |
call
call(
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
web3: Web3 | None = None,
) -> t.Any
Used for reading from the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
send
send(
api_keys: APIKeys,
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
send_with_value
send_with_value(
api_keys: APIKeys,
function_name: str,
amount_wei: Wei,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract, including sending chain's native currency.
Source code in prediction_market_agent_tooling/tools/contract.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_transaction_count
classmethod
get_transaction_count(
for_address: ChecksumAddress,
) -> Nonce
Source code in prediction_market_agent_tooling/tools/contract.py
164 165 166 | |
get_web3
classmethod
get_web3() -> Web3
Source code in prediction_market_agent_tooling/tools/contract.py
168 169 170 | |
symbol
symbol(web3: Web3 | None = None) -> str
Source code in prediction_market_agent_tooling/tools/contract.py
200 201 202 | |
symbol_cached
symbol_cached(web3: Web3 | None = None) -> str
Source code in prediction_market_agent_tooling/tools/contract.py
204 205 206 207 208 209 210 | |
allowance
allowance(
owner: ChecksumAddress,
for_address: ChecksumAddress,
web3: Web3 | None = None,
) -> Wei
Source code in prediction_market_agent_tooling/tools/contract.py
212 213 214 215 216 217 218 219 220 221 | |
approve
approve(
api_keys: APIKeys,
for_address: ChecksumAddress,
amount_wei: Wei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
transferFrom
transferFrom(
api_keys: APIKeys,
sender: ChecksumAddress,
recipient: ChecksumAddress,
amount_wei: Wei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
balanceOf
balanceOf(
for_address: ChecksumAddress, web3: Web3 | None = None
) -> Wei
Source code in prediction_market_agent_tooling/tools/contract.py
259 260 261 | |
balance_of_in_tokens
balance_of_in_tokens(
for_address: ChecksumAddress, web3: Web3 | None = None
) -> CollateralToken
Source code in prediction_market_agent_tooling/tools/contract.py
263 264 265 266 | |
COWContract
Bases: ContractERC20OnGnosisChain
address
class-attribute
instance-attribute
address: ChecksumAddress = to_checksum_address(
"0x177127622c4A00F3d409B75571e12cB3c8973d3c"
)
CHAIN_ID
class-attribute
instance-attribute
CHAIN_ID = chain_id
abi
class-attribute
instance-attribute
abi: ABI = abi_field_validator(
join(
dirname(realpath(__file__)),
"../abis/erc20.abi.json",
)
)
merge_contract_abis
classmethod
merge_contract_abis(
contracts: list[ContractBaseClass],
) -> ABI
Source code in prediction_market_agent_tooling/tools/contract.py
77 78 79 80 81 82 | |
get_web3_contract
get_web3_contract(web3: Web3 | None = None) -> Web3Contract
Source code in prediction_market_agent_tooling/tools/contract.py
84 85 86 | |
call
call(
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
web3: Web3 | None = None,
) -> t.Any
Used for reading from the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
send
send(
api_keys: APIKeys,
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
send_with_value
send_with_value(
api_keys: APIKeys,
function_name: str,
amount_wei: Wei,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract, including sending chain's native currency.
Source code in prediction_market_agent_tooling/tools/contract.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_transaction_count
classmethod
get_transaction_count(
for_address: ChecksumAddress,
) -> Nonce
Source code in prediction_market_agent_tooling/tools/contract.py
164 165 166 | |
get_web3
classmethod
get_web3() -> Web3
Source code in prediction_market_agent_tooling/tools/contract.py
168 169 170 | |
symbol
symbol(web3: Web3 | None = None) -> str
Source code in prediction_market_agent_tooling/tools/contract.py
200 201 202 | |
symbol_cached
symbol_cached(web3: Web3 | None = None) -> str
Source code in prediction_market_agent_tooling/tools/contract.py
204 205 206 207 208 209 210 | |
allowance
allowance(
owner: ChecksumAddress,
for_address: ChecksumAddress,
web3: Web3 | None = None,
) -> Wei
Source code in prediction_market_agent_tooling/tools/contract.py
212 213 214 215 216 217 218 219 220 221 | |
approve
approve(
api_keys: APIKeys,
for_address: ChecksumAddress,
amount_wei: Wei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
transferFrom
transferFrom(
api_keys: APIKeys,
sender: ChecksumAddress,
recipient: ChecksumAddress,
amount_wei: Wei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
balanceOf
balanceOf(
for_address: ChecksumAddress, web3: Web3 | None = None
) -> Wei
Source code in prediction_market_agent_tooling/tools/contract.py
259 260 261 | |
balance_of_in_tokens
balance_of_in_tokens(
for_address: ChecksumAddress, web3: Web3 | None = None
) -> CollateralToken
Source code in prediction_market_agent_tooling/tools/contract.py
263 264 265 266 | |
WrappedxDaiContract
Bases: ContractDepositableWrapperERC20OnGnosisChain
address
class-attribute
instance-attribute
address: ChecksumAddress = WRAPPED_XDAI_CONTRACT_ADDRESS
CHAIN_ID
class-attribute
instance-attribute
CHAIN_ID = chain_id
abi
class-attribute
instance-attribute
abi: ABI = abi_field_validator(
join(
dirname(realpath(__file__)),
"../abis/depositablewrapper_erc20.abi.json",
)
)
merge_contract_abis
classmethod
merge_contract_abis(
contracts: list[ContractBaseClass],
) -> ABI
Source code in prediction_market_agent_tooling/tools/contract.py
77 78 79 80 81 82 | |
get_web3_contract
get_web3_contract(web3: Web3 | None = None) -> Web3Contract
Source code in prediction_market_agent_tooling/tools/contract.py
84 85 86 | |
call
call(
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
web3: Web3 | None = None,
) -> t.Any
Used for reading from the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
send
send(
api_keys: APIKeys,
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
send_with_value
send_with_value(
api_keys: APIKeys,
function_name: str,
amount_wei: Wei,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract, including sending chain's native currency.
Source code in prediction_market_agent_tooling/tools/contract.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_transaction_count
classmethod
get_transaction_count(
for_address: ChecksumAddress,
) -> Nonce
Source code in prediction_market_agent_tooling/tools/contract.py
164 165 166 | |
get_web3
classmethod
get_web3() -> Web3
Source code in prediction_market_agent_tooling/tools/contract.py
168 169 170 | |
symbol
symbol(web3: Web3 | None = None) -> str
Source code in prediction_market_agent_tooling/tools/contract.py
200 201 202 | |
symbol_cached
symbol_cached(web3: Web3 | None = None) -> str
Source code in prediction_market_agent_tooling/tools/contract.py
204 205 206 207 208 209 210 | |
allowance
allowance(
owner: ChecksumAddress,
for_address: ChecksumAddress,
web3: Web3 | None = None,
) -> Wei
Source code in prediction_market_agent_tooling/tools/contract.py
212 213 214 215 216 217 218 219 220 221 | |
approve
approve(
api_keys: APIKeys,
for_address: ChecksumAddress,
amount_wei: Wei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
transferFrom
transferFrom(
api_keys: APIKeys,
sender: ChecksumAddress,
recipient: ChecksumAddress,
amount_wei: Wei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
balanceOf
balanceOf(
for_address: ChecksumAddress, web3: Web3 | None = None
) -> Wei
Source code in prediction_market_agent_tooling/tools/contract.py
259 260 261 | |
balance_of_in_tokens
balance_of_in_tokens(
for_address: ChecksumAddress, web3: Web3 | None = None
) -> CollateralToken
Source code in prediction_market_agent_tooling/tools/contract.py
263 264 265 266 | |
deposit
deposit(
api_keys: APIKeys,
amount_wei: Wei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
withdraw
withdraw(
api_keys: APIKeys,
amount_wei: Wei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
sDaiContract
Bases: ContractERC4626OnGnosisChain
address
class-attribute
instance-attribute
address: ChecksumAddress = SDAI_CONTRACT_ADDRESS
CHAIN_ID
class-attribute
instance-attribute
CHAIN_ID = chain_id
abi
class-attribute
instance-attribute
abi: ABI = abi_field_validator(
join(
dirname(realpath(__file__)),
"../abis/erc4626.abi.json",
)
)
merge_contract_abis
classmethod
merge_contract_abis(
contracts: list[ContractBaseClass],
) -> ABI
Source code in prediction_market_agent_tooling/tools/contract.py
77 78 79 80 81 82 | |
get_web3_contract
get_web3_contract(web3: Web3 | None = None) -> Web3Contract
Source code in prediction_market_agent_tooling/tools/contract.py
84 85 86 | |
call
call(
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
web3: Web3 | None = None,
) -> t.Any
Used for reading from the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
send
send(
api_keys: APIKeys,
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
send_with_value
send_with_value(
api_keys: APIKeys,
function_name: str,
amount_wei: Wei,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract, including sending chain's native currency.
Source code in prediction_market_agent_tooling/tools/contract.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_transaction_count
classmethod
get_transaction_count(
for_address: ChecksumAddress,
) -> Nonce
Source code in prediction_market_agent_tooling/tools/contract.py
164 165 166 | |
get_web3
classmethod
get_web3() -> Web3
Source code in prediction_market_agent_tooling/tools/contract.py
168 169 170 | |
symbol
symbol(web3: Web3 | None = None) -> str
Source code in prediction_market_agent_tooling/tools/contract.py
200 201 202 | |
symbol_cached
symbol_cached(web3: Web3 | None = None) -> str
Source code in prediction_market_agent_tooling/tools/contract.py
204 205 206 207 208 209 210 | |
allowance
allowance(
owner: ChecksumAddress,
for_address: ChecksumAddress,
web3: Web3 | None = None,
) -> Wei
Source code in prediction_market_agent_tooling/tools/contract.py
212 213 214 215 216 217 218 219 220 221 | |
approve
approve(
api_keys: APIKeys,
for_address: ChecksumAddress,
amount_wei: Wei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
transferFrom
transferFrom(
api_keys: APIKeys,
sender: ChecksumAddress,
recipient: ChecksumAddress,
amount_wei: Wei,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
balanceOf
balanceOf(
for_address: ChecksumAddress, web3: Web3 | None = None
) -> Wei
Source code in prediction_market_agent_tooling/tools/contract.py
259 260 261 | |
balance_of_in_tokens
balance_of_in_tokens(
for_address: ChecksumAddress, web3: Web3 | None = None
) -> CollateralToken
Source code in prediction_market_agent_tooling/tools/contract.py
263 264 265 266 | |
asset
asset(web3: Web3 | None = None) -> ChecksumAddress
Source code in prediction_market_agent_tooling/tools/contract.py
324 325 326 | |
deposit
deposit(
api_keys: APIKeys,
amount_wei: Wei,
receiver: ChecksumAddress | None = None,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | |
withdraw
withdraw(
api_keys: APIKeys,
assets_wei: Wei,
receiver: ChecksumAddress | None = None,
owner: ChecksumAddress | None = None,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | |
withdraw_in_shares
withdraw_in_shares(
api_keys: APIKeys,
shares_wei: Wei,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
365 366 367 368 369 370 | |
convertToShares
convertToShares(
assets: Wei, web3: Web3 | None = None
) -> Wei
Source code in prediction_market_agent_tooling/tools/contract.py
372 373 374 | |
convertToAssets
convertToAssets(
shares: Wei, web3: Web3 | None = None
) -> Wei
Source code in prediction_market_agent_tooling/tools/contract.py
376 377 378 | |
get_asset_token_contract
get_asset_token_contract(
web3: Web3 | None = None,
) -> (
ContractERC20OnGnosisChain
| ContractDepositableWrapperERC20OnGnosisChain
)
Source code in prediction_market_agent_tooling/tools/contract.py
543 544 545 546 | |
get_asset_token_balance
get_asset_token_balance(
for_address: ChecksumAddress, web3: Web3 | None = None
) -> Wei
Source code in prediction_market_agent_tooling/tools/contract.py
390 391 392 393 394 | |
deposit_asset_token
deposit_asset_token(
asset_value: Wei,
api_keys: APIKeys,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/tools/contract.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |
get_in_shares
get_in_shares(amount: Wei, web3: Web3 | None = None) -> Wei
Source code in prediction_market_agent_tooling/tools/contract.py
411 412 413 | |
OmenFixedProductMarketMakerFactoryContract
Bases: ContractOnGnosisChain
abi
class-attribute
instance-attribute
abi: ABI = abi_field_validator(
join(
dirname(realpath(__file__)),
"../../abis/omen_fpmm_factory.abi.json",
)
)
address
class-attribute
instance-attribute
address: ChecksumAddress = to_checksum_address(
"0x9083A2B699c0a4AD06F63580BDE2635d26a3eeF0"
)
CHAIN_ID
class-attribute
instance-attribute
CHAIN_ID = chain_id
create2FixedProductMarketMaker
create2FixedProductMarketMaker(
api_keys: APIKeys,
condition_id: HexBytes,
initial_funds_wei: Wei,
collateral_token_address: ChecksumAddress,
fee: Wei,
distribution_hint: list[OutcomeWei] | None = None,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> tuple[
OmenFixedProductMarketMakerCreationEvent,
FPMMFundingAddedEvent,
TxReceipt,
]
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 | |
merge_contract_abis
classmethod
merge_contract_abis(
contracts: list[ContractBaseClass],
) -> ABI
Source code in prediction_market_agent_tooling/tools/contract.py
77 78 79 80 81 82 | |
get_web3_contract
get_web3_contract(web3: Web3 | None = None) -> Web3Contract
Source code in prediction_market_agent_tooling/tools/contract.py
84 85 86 | |
call
call(
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
web3: Web3 | None = None,
) -> t.Any
Used for reading from the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
send
send(
api_keys: APIKeys,
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
send_with_value
send_with_value(
api_keys: APIKeys,
function_name: str,
amount_wei: Wei,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract, including sending chain's native currency.
Source code in prediction_market_agent_tooling/tools/contract.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_transaction_count
classmethod
get_transaction_count(
for_address: ChecksumAddress,
) -> Nonce
Source code in prediction_market_agent_tooling/tools/contract.py
164 165 166 | |
get_web3
classmethod
get_web3() -> Web3
Source code in prediction_market_agent_tooling/tools/contract.py
168 169 170 | |
Arbitrator
Bases: str, Enum
KLEROS_511_JURORS_WITHOUT_APPEAL
class-attribute
instance-attribute
KLEROS_511_JURORS_WITHOUT_APPEAL = (
"kleros_511_jurors_without_appeal"
)
KLEROS_31_JURORS_WITH_APPEAL
class-attribute
instance-attribute
KLEROS_31_JURORS_WITH_APPEAL = (
"kleros_31_jurors_with_appeal"
)
DXDAO
class-attribute
instance-attribute
DXDAO = 'dxdao'
is_kleros
property
is_kleros: bool
OmenDxDaoContract
Bases: ContractOnGnosisChain
abi
class-attribute
instance-attribute
abi: ABI = abi_field_validator(
join(
dirname(realpath(__file__)),
"../../abis/omen_dxdao.abi.json",
)
)
address
class-attribute
instance-attribute
address: ChecksumAddress = to_checksum_address(
"0xFe14059344b74043Af518d12931600C0f52dF7c5"
)
CHAIN_ID
class-attribute
instance-attribute
CHAIN_ID = chain_id
merge_contract_abis
classmethod
merge_contract_abis(
contracts: list[ContractBaseClass],
) -> ABI
Source code in prediction_market_agent_tooling/tools/contract.py
77 78 79 80 81 82 | |
get_web3_contract
get_web3_contract(web3: Web3 | None = None) -> Web3Contract
Source code in prediction_market_agent_tooling/tools/contract.py
84 85 86 | |
call
call(
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
web3: Web3 | None = None,
) -> t.Any
Used for reading from the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
send
send(
api_keys: APIKeys,
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
send_with_value
send_with_value(
api_keys: APIKeys,
function_name: str,
amount_wei: Wei,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract, including sending chain's native currency.
Source code in prediction_market_agent_tooling/tools/contract.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_transaction_count
classmethod
get_transaction_count(
for_address: ChecksumAddress,
) -> Nonce
Source code in prediction_market_agent_tooling/tools/contract.py
164 165 166 | |
get_web3
classmethod
get_web3() -> Web3
Source code in prediction_market_agent_tooling/tools/contract.py
168 169 170 | |
OmenKlerosContract
Bases: ContractOnGnosisChain
abi
class-attribute
instance-attribute
abi: ABI = abi_field_validator(
join(
dirname(realpath(__file__)),
"../../abis/omen_kleros.abi.json",
)
)
CHAIN_ID
class-attribute
instance-attribute
CHAIN_ID = chain_id
address
instance-attribute
address: ChecksumAddress
from_arbitrator
staticmethod
from_arbitrator(
arbitrator: Arbitrator,
) -> OmenKlerosContract
See https://docs.kleros.io/developer/deployment-addresses for all available addresses.
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 | |
merge_contract_abis
classmethod
merge_contract_abis(
contracts: list[ContractBaseClass],
) -> ABI
Source code in prediction_market_agent_tooling/tools/contract.py
77 78 79 80 81 82 | |
get_web3_contract
get_web3_contract(web3: Web3 | None = None) -> Web3Contract
Source code in prediction_market_agent_tooling/tools/contract.py
84 85 86 | |
call
call(
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
web3: Web3 | None = None,
) -> t.Any
Used for reading from the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
send
send(
api_keys: APIKeys,
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
send_with_value
send_with_value(
api_keys: APIKeys,
function_name: str,
amount_wei: Wei,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract, including sending chain's native currency.
Source code in prediction_market_agent_tooling/tools/contract.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_transaction_count
classmethod
get_transaction_count(
for_address: ChecksumAddress,
) -> Nonce
Source code in prediction_market_agent_tooling/tools/contract.py
164 165 166 | |
get_web3
classmethod
get_web3() -> Web3
Source code in prediction_market_agent_tooling/tools/contract.py
168 169 170 | |
OmenRealitioContract
Bases: ContractOnGnosisChain
abi
class-attribute
instance-attribute
abi: ABI = abi_field_validator(
join(
dirname(realpath(__file__)),
"../../abis/omen_realitio.abi.json",
)
)
address
class-attribute
instance-attribute
address: ChecksumAddress = to_checksum_address(
"0x79e32aE03fb27B07C89c0c568F80287C01ca2E57"
)
CHAIN_ID
class-attribute
instance-attribute
CHAIN_ID = chain_id
get_arbitrator_contract
staticmethod
get_arbitrator_contract(
arbitrator: Arbitrator,
) -> ContractOnGnosisChain
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
605 606 607 608 609 610 611 612 613 | |
askQuestion
askQuestion(
api_keys: APIKeys,
question: str,
category: str,
outcomes: Sequence[str],
language: str,
arbitrator: Arbitrator,
opening: DatetimeUTC,
timeout: timedelta,
nonce: int | None = None,
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> RealitioLogNewQuestionEvent
After the question is created, you can find it at https://reality.eth.link/app/#!/creator/{from_address}.
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 | |
submitAnswer
submitAnswer(
api_keys: APIKeys,
question_id: HexBytes,
answer: HexBytes,
bond: xDaiWei,
max_previous: xDaiWei | None = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 | |
submit_answer
submit_answer(
api_keys: APIKeys,
question_id: HexBytes,
outcome_index: int,
bond: xDaiWei,
max_previous: xDaiWei | None = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 | |
submit_answer_invalid
submit_answer_invalid(
api_keys: APIKeys,
question_id: HexBytes,
bond: xDaiWei,
max_previous: xDaiWei | None = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 | |
claimWinnings
claimWinnings(
api_keys: APIKeys,
question_id: HexBytes,
history_hashes: list[HexBytes],
addresses: list[ChecksumAddress],
bonds: list[xDaiWei],
answers: list[HexBytes],
tx_params: Optional[TxParams] = None,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 | |
balanceOf
balanceOf(
from_address: ChecksumAddress, web3: Web3 | None = None
) -> xDaiWei
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
760 761 762 763 764 765 766 | |
withdraw
withdraw(
api_keys: APIKeys, web3: Web3 | None = None
) -> TxReceipt
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
768 769 770 771 772 773 | |
getOpeningTS
getOpeningTS(
question_id: HexBytes, web3: Web3 | None = None
) -> int
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
775 776 777 778 779 780 781 782 783 784 785 | |
getFinalizeTS
getFinalizeTS(
question_id: HexBytes, web3: Web3 | None = None
) -> int
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
787 788 789 790 791 792 793 794 795 796 797 | |
isFinalized
isFinalized(
question_id: HexBytes, web3: Web3 | None = None
) -> bool
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
799 800 801 802 803 804 805 806 807 808 809 | |
isPendingArbitration
isPendingArbitration(
question_id: HexBytes, web3: Web3 | None = None
) -> bool
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
811 812 813 814 815 816 817 818 819 820 821 | |
merge_contract_abis
classmethod
merge_contract_abis(
contracts: list[ContractBaseClass],
) -> ABI
Source code in prediction_market_agent_tooling/tools/contract.py
77 78 79 80 81 82 | |
get_web3_contract
get_web3_contract(web3: Web3 | None = None) -> Web3Contract
Source code in prediction_market_agent_tooling/tools/contract.py
84 85 86 | |
call
call(
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
web3: Web3 | None = None,
) -> t.Any
Used for reading from the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
send
send(
api_keys: APIKeys,
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
send_with_value
send_with_value(
api_keys: APIKeys,
function_name: str,
amount_wei: Wei,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract, including sending chain's native currency.
Source code in prediction_market_agent_tooling/tools/contract.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_transaction_count
classmethod
get_transaction_count(
for_address: ChecksumAddress,
) -> Nonce
Source code in prediction_market_agent_tooling/tools/contract.py
164 165 166 | |
get_web3
classmethod
get_web3() -> Web3
Source code in prediction_market_agent_tooling/tools/contract.py
168 169 170 | |
OmenAgentResultMappingContract
Bases: ContractOnGnosisChain
abi
class-attribute
instance-attribute
abi: ABI = abi_field_validator(
join(
dirname(realpath(__file__)),
"../../abis/omen_agentresultmapping.abi.json",
)
)
address
class-attribute
instance-attribute
address: ChecksumAddress = to_checksum_address(
"0x260E1077dEA98e738324A6cEfB0EE9A272eD471a"
)
CHAIN_ID
class-attribute
instance-attribute
CHAIN_ID = chain_id
get_predictions
get_predictions(
market_address: ChecksumAddress,
web3: Web3 | None = None,
) -> list[ContractPrediction]
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
838 839 840 841 842 843 844 845 846 | |
add_prediction
add_prediction(
api_keys: APIKeys,
market_address: ChecksumAddress,
prediction: ContractPrediction,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
848 849 850 851 852 853 854 855 856 857 858 859 860 | |
merge_contract_abis
classmethod
merge_contract_abis(
contracts: list[ContractBaseClass],
) -> ABI
Source code in prediction_market_agent_tooling/tools/contract.py
77 78 79 80 81 82 | |
get_web3_contract
get_web3_contract(web3: Web3 | None = None) -> Web3Contract
Source code in prediction_market_agent_tooling/tools/contract.py
84 85 86 | |
call
call(
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
web3: Web3 | None = None,
) -> t.Any
Used for reading from the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
send
send(
api_keys: APIKeys,
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
send_with_value
send_with_value(
api_keys: APIKeys,
function_name: str,
amount_wei: Wei,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract, including sending chain's native currency.
Source code in prediction_market_agent_tooling/tools/contract.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_transaction_count
classmethod
get_transaction_count(
for_address: ChecksumAddress,
) -> Nonce
Source code in prediction_market_agent_tooling/tools/contract.py
164 165 166 | |
get_web3
classmethod
get_web3() -> Web3
Source code in prediction_market_agent_tooling/tools/contract.py
168 169 170 | |
OmenThumbnailMapping
Bases: ContractOnGnosisChain
abi
class-attribute
instance-attribute
abi: ABI = abi_field_validator(
join(
dirname(realpath(__file__)),
"../../abis/omen_thumbnailmapping.abi.json",
)
)
address
class-attribute
instance-attribute
address: ChecksumAddress = to_checksum_address(
"0xe0cf08311F03850497B0ed6A2cf067f1750C3eFc"
)
CHAIN_ID
class-attribute
instance-attribute
CHAIN_ID = chain_id
construct_ipfs_url
staticmethod
construct_ipfs_url(ipfs_hash: IPFSCIDVersion0) -> str
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
875 876 877 | |
get
get(
market_address: ChecksumAddress,
web3: Web3 | None = None,
) -> IPFSCIDVersion0 | None
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
879 880 881 882 883 884 885 886 887 | |
get_url
get_url(
market_address: ChecksumAddress,
web3: Web3 | None = None,
) -> str | None
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
889 890 891 892 893 894 895 | |
set
set(
api_keys: APIKeys,
market_address: ChecksumAddress,
image_hash: IPFSCIDVersion0,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
897 898 899 900 901 902 903 904 905 906 907 908 909 | |
remove
remove(
api_keys: APIKeys,
market_address: ChecksumAddress,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
911 912 913 914 915 916 917 918 919 920 921 922 | |
merge_contract_abis
classmethod
merge_contract_abis(
contracts: list[ContractBaseClass],
) -> ABI
Source code in prediction_market_agent_tooling/tools/contract.py
77 78 79 80 81 82 | |
get_web3_contract
get_web3_contract(web3: Web3 | None = None) -> Web3Contract
Source code in prediction_market_agent_tooling/tools/contract.py
84 85 86 | |
call
call(
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
web3: Web3 | None = None,
) -> t.Any
Used for reading from the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
send
send(
api_keys: APIKeys,
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
send_with_value
send_with_value(
api_keys: APIKeys,
function_name: str,
amount_wei: Wei,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract, including sending chain's native currency.
Source code in prediction_market_agent_tooling/tools/contract.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_transaction_count
classmethod
get_transaction_count(
for_address: ChecksumAddress,
) -> Nonce
Source code in prediction_market_agent_tooling/tools/contract.py
164 165 166 | |
get_web3
classmethod
get_web3() -> Web3
Source code in prediction_market_agent_tooling/tools/contract.py
168 169 170 | |
CollateralTokenChoice
Bases: str, Enum
wxdai
class-attribute
instance-attribute
wxdai = 'wxdai'
sdai
class-attribute
instance-attribute
sdai = 'sdai'
gno
class-attribute
instance-attribute
gno = 'gno'
metri_super_user
class-attribute
instance-attribute
metri_super_user = 'metri_super_user'
build_parent_collection_id
build_parent_collection_id() -> HexStr
Source code in prediction_market_agent_tooling/markets/omen/omen_contracts.py
98 99 | |
omen_resolving
claim_bonds_on_realitio_questions
claim_bonds_on_realitio_questions(
api_keys: APIKeys,
questions: list[RealityQuestion],
auto_withdraw: bool,
web3: Web3 | None = None,
skip_failed: bool = False,
) -> list[HexBytes]
Source code in prediction_market_agent_tooling/markets/omen/omen_resolving.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
claim_bonds_on_realitio_question
claim_bonds_on_realitio_question(
api_keys: APIKeys,
question: RealityQuestion,
auto_withdraw: bool,
web3: Web3 | None = None,
) -> None
Source code in prediction_market_agent_tooling/markets/omen/omen_resolving.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
finalize_markets
finalize_markets(
api_keys: APIKeys,
markets_with_resolutions: list[
tuple[OmenMarket, Resolution | None]
],
realitio_bond: xDai,
wait_n_days_before_invalid: int = 30,
web3: Web3 | None = None,
) -> list[HexAddress]
Source code in prediction_market_agent_tooling/markets/omen/omen_resolving.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
resolve_markets
resolve_markets(
api_keys: APIKeys,
markets: list[OmenMarket],
web3: Web3 | None = None,
) -> list[HexAddress]
Source code in prediction_market_agent_tooling/markets/omen/omen_resolving.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
omen_submit_answer_market_tx
omen_submit_answer_market_tx(
api_keys: APIKeys,
market: OmenMarket,
resolution: Resolution,
bond: xDai,
web3: Web3 | None = None,
) -> None
After the answer is submitted, there is waiting period where the answer can be challenged by others.
And after the period is over, you need to resolve the market using omen_resolve_market_tx.
Source code in prediction_market_agent_tooling/markets/omen/omen_resolving.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
omen_submit_invalid_answer_market_tx
omen_submit_invalid_answer_market_tx(
api_keys: APIKeys,
market: OmenMarket,
bond: xDai,
web3: Web3 | None = None,
) -> None
After the answer is submitted, there is waiting period where the answer can be challenged by others.
And after the period is over, you need to resolve the market using omen_resolve_market_tx.
Source code in prediction_market_agent_tooling/markets/omen/omen_resolving.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
omen_resolve_market_tx
omen_resolve_market_tx(
api_keys: APIKeys,
market: OmenMarket,
web3: Web3 | None = None,
) -> None
Market can be resolved after the answer if finalized on Reality.
Source code in prediction_market_agent_tooling/markets/omen/omen_resolving.py
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
find_resolution_on_other_markets
find_resolution_on_other_markets(
market: OmenMarket,
) -> Resolution | None
Source code in prediction_market_agent_tooling/markets/omen/omen_resolving.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
omen_subgraph_handler
SAFE_COLLATERAL_TOKENS
module-attribute
SAFE_COLLATERAL_TOKENS = (
WrappedxDaiContract(),
sDaiContract(),
GNOContract(),
WETHContract(),
EUReContract(),
SAFEContract(),
COWContract(),
)
SAFE_COLLATERAL_TOKENS_ADDRESSES
module-attribute
SAFE_COLLATERAL_TOKENS_ADDRESSES = tuple(
address for contract in SAFE_COLLATERAL_TOKENS
)
OmenSubgraphHandler
OmenSubgraphHandler()
Bases: BaseSubgraphHandler
Class responsible for handling interactions with Omen subgraphs (trades, conditionalTokens).
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
OMEN_TRADES_SUBGRAPH
class-attribute
instance-attribute
OMEN_TRADES_SUBGRAPH = "https://gateway-arbitrum.network.thegraph.com/api/{graph_api_key}/subgraphs/id/9fUVQpFwzpdWS9bq5WkAnmKbNNcoBwatMR4yZq81pbbz"
CONDITIONAL_TOKENS_SUBGRAPH
class-attribute
instance-attribute
CONDITIONAL_TOKENS_SUBGRAPH = "https://gateway-arbitrum.network.thegraph.com/api/{graph_api_key}/subgraphs/id/7s9rGBffUTL8kDZuxvvpuc46v44iuDarbrADBFw5uVp2"
REALITYETH_GRAPH_URL
class-attribute
instance-attribute
REALITYETH_GRAPH_URL = "https://gateway-arbitrum.network.thegraph.com/api/{graph_api_key}/subgraphs/id/E7ymrCnNcQdAAgLbdFWzGE5mvr5Mb5T9VfT43FqA7bNh"
OMEN_IMAGE_MAPPING_GRAPH_URL
class-attribute
instance-attribute
OMEN_IMAGE_MAPPING_GRAPH_URL = "https://gateway-arbitrum.network.thegraph.com/api/{graph_api_key}/subgraphs/id/EWN14ciGK53PpUiKSm7kMWQ6G4iz3tDrRLyZ1iXMQEdu"
OMEN_AGENT_RESULT_MAPPING_GRAPH_URL
class-attribute
instance-attribute
OMEN_AGENT_RESULT_MAPPING_GRAPH_URL = "https://gateway-arbitrum.network.thegraph.com/api/{graph_api_key}/subgraphs/id/J6bJEnbqJpAvNyQE8i58M9mKF4zqo33BEJRdnXmqa6Kn"
INVALID_ANSWER
class-attribute
instance-attribute
INVALID_ANSWER = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
trades_subgraph
instance-attribute
trades_subgraph = load_subgraph(
format(graph_api_key=get_secret_value())
)
conditional_tokens_subgraph
instance-attribute
conditional_tokens_subgraph = load_subgraph(
format(graph_api_key=get_secret_value())
)
realityeth_subgraph
instance-attribute
realityeth_subgraph = load_subgraph(
format(graph_api_key=get_secret_value())
)
omen_image_mapping_subgraph
instance-attribute
omen_image_mapping_subgraph = load_subgraph(
format(graph_api_key=get_secret_value())
)
omen_agent_result_mapping_subgraph
instance-attribute
omen_agent_result_mapping_subgraph = load_subgraph(
format(graph_api_key=get_secret_value())
)
sg
instance-attribute
sg = Subgrounds(timeout=timeout)
keys
instance-attribute
keys = APIKeys()
get_omen_markets_simple
get_omen_markets_simple(
limit: Optional[int],
filter_by: FilterBy,
sort_by: SortBy,
include_categorical_markets: bool = False,
created_after: DatetimeUTC | None = None,
excluded_questions: set[str] | None = None,
collateral_token_address_in: tuple[ChecksumAddress, ...]
| None = SAFE_COLLATERAL_TOKENS_ADDRESSES,
category: str | None = None,
creator_in: Sequence[HexAddress] | None = None,
) -> t.List[OmenMarket]
Simplified get_omen_markets method, which allows to fetch markets based on the filter_by and sort_by values.
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | |
get_omen_markets
get_omen_markets(
limit: Optional[int],
creator: HexAddress | None = None,
creator_in: Sequence[HexAddress] | None = None,
created_after: DatetimeUTC | None = None,
question_opened_before: DatetimeUTC | None = None,
question_opened_after: DatetimeUTC | None = None,
question_finalized_before: DatetimeUTC | None = None,
question_finalized_after: DatetimeUTC | None = None,
question_with_answers: bool | None = None,
question_pending_arbitration: bool | None = None,
question_id: HexBytes | None = None,
question_id_in: list[HexBytes] | None = None,
question_current_answer_before: DatetimeUTC
| None = None,
question_excluded_titles: set[str] | None = None,
resolved: bool | None = None,
liquidity_bigger_than: Wei | None = None,
condition_id_in: list[HexBytes] | None = None,
id_in: list[str] | None = None,
sort_by_field: FieldPath | None = None,
sort_direction: str | None = None,
collateral_token_address_in: tuple[ChecksumAddress, ...]
| None = SAFE_COLLATERAL_TOKENS_ADDRESSES,
category: str | None = None,
include_categorical_markets: bool = True,
include_scalar_markets: bool = False,
) -> t.List[OmenMarket]
Complete method to fetch Omen markets with various filters, use get_omen_markets_simple for simplified version that uses FilterBy and SortBy enums.
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | |
get_omen_market_by_market_id
get_omen_market_by_market_id(
market_id: HexAddress, block_number: int | None = None
) -> OmenMarket
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | |
get_positions
get_positions(
condition_id: HexBytes | None = None,
) -> list[OmenPosition]
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 | |
get_user_positions
get_user_positions(
better_address: ChecksumAddress | None = None,
user_position_id_in: list[HexBytes] | None = None,
position_id_in: list[HexBytes] | None = None,
total_balance_bigger_than: OutcomeWei | None = None,
) -> list[OmenUserPosition]
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 | |
get_trades
get_trades(
limit: int | None = None,
better_address: ChecksumAddress | None = None,
start_time: DatetimeUTC | None = None,
end_time: Optional[DatetimeUTC] = None,
market_id: Optional[ChecksumAddress] = None,
filter_by_answer_finalized_not_null: bool = False,
type_: Literal["Buy", "Sell"] | None = None,
market_opening_after: DatetimeUTC | None = None,
market_resolved_before: DatetimeUTC | None = None,
market_resolved_after: DatetimeUTC | None = None,
collateral_amount_more_than: Wei | None = None,
sort_by_field: FieldPath | None = None,
sort_direction: str | None = None,
) -> list[OmenBet]
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 | |
get_bets
get_bets(
better_address: ChecksumAddress | None = None,
start_time: DatetimeUTC | None = None,
end_time: Optional[DatetimeUTC] = None,
market_id: Optional[ChecksumAddress] = None,
filter_by_answer_finalized_not_null: bool = False,
market_opening_after: DatetimeUTC | None = None,
market_resolved_before: DatetimeUTC | None = None,
market_resolved_after: DatetimeUTC | None = None,
collateral_amount_more_than: Wei | None = None,
) -> list[OmenBet]
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 | |
get_resolved_bets
get_resolved_bets(
better_address: ChecksumAddress,
start_time: DatetimeUTC | None = None,
end_time: Optional[DatetimeUTC] = None,
market_id: Optional[ChecksumAddress] = None,
market_resolved_before: DatetimeUTC | None = None,
market_resolved_after: DatetimeUTC | None = None,
) -> list[OmenBet]
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 | |
get_resolved_bets_with_valid_answer
get_resolved_bets_with_valid_answer(
better_address: ChecksumAddress,
start_time: DatetimeUTC | None = None,
end_time: Optional[DatetimeUTC] = None,
market_resolved_before: DatetimeUTC | None = None,
market_resolved_after: DatetimeUTC | None = None,
market_id: Optional[ChecksumAddress] = None,
) -> list[OmenBet]
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 | |
get_reality_question_filters
staticmethod
get_reality_question_filters(
user: HexAddress | None,
claimed: bool | None,
current_answer_before: DatetimeUTC | None,
finalized_before: DatetimeUTC | None,
finalized_after: DatetimeUTC | None,
with_answers: bool | None,
pending_arbitration: bool | None,
question_id: HexBytes | None,
question_id_in: list[HexBytes] | None,
opened_before: Optional[DatetimeUTC],
opened_after: Optional[DatetimeUTC],
excluded_titles: set[str] | None,
) -> dict[str, t.Any]
Be aware, both Omen subgraph and Reality subgraph are indexing questions, but their fields are a bit different.
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 | |
get_omen_question_filters
staticmethod
get_omen_question_filters(
current_answer_before: DatetimeUTC | None,
finalized_before: DatetimeUTC | None,
finalized_after: DatetimeUTC | None,
with_answers: bool | None,
pending_arbitration: bool | None,
question_id: HexBytes | None,
question_id_in: list[HexBytes] | None,
opened_before: Optional[DatetimeUTC],
opened_after: Optional[DatetimeUTC],
excluded_titles: set[str] | None,
) -> dict[str, t.Any]
Be aware, both Omen subgraph and Reality subgraph are indexing questions, but their fields are a bit different.
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 | |
get_questions
get_questions(
limit: int | None,
user: HexAddress | None = None,
claimed: bool | None = None,
current_answer_before: DatetimeUTC | None = None,
finalized_before: DatetimeUTC | None = None,
finalized_after: DatetimeUTC | None = None,
with_answers: bool | None = None,
pending_arbitration: bool | None = None,
question_id_in: list[HexBytes] | None = None,
question_id: HexBytes | None = None,
opened_before: DatetimeUTC | None = None,
opened_after: DatetimeUTC | None = None,
excluded_titles: set[str] | None = None,
) -> list[RealityQuestion]
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 | |
get_answers
get_answers(question_id: HexBytes) -> list[RealityAnswer]
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
861 862 863 864 865 866 867 868 869 870 871 872 873 874 | |
get_responses
get_responses(
limit: int | None,
user: HexAddress | None = None,
question_user: HexAddress | None = None,
question_claimed: bool | None = None,
question_opened_before: Optional[DatetimeUTC] = None,
question_opened_after: Optional[DatetimeUTC] = None,
question_finalized_before: Optional[DatetimeUTC] = None,
question_finalized_after: Optional[DatetimeUTC] = None,
question_with_answers: bool | None = None,
question_pending_arbitration: bool | None = None,
question_id: HexBytes | None = None,
question_id_in: list[HexBytes] | None = None,
question_current_answer_before: DatetimeUTC
| None = None,
question_excluded_titles: set[str] | None = None,
) -> list[RealityResponse]
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 | |
get_markets_from_all_user_positions
get_markets_from_all_user_positions(
user_positions: list[OmenUserPosition],
) -> list[OmenMarket]
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
924 925 926 927 928 929 930 931 932 933 | |
get_market_from_user_position
get_market_from_user_position(
user_position: OmenUserPosition,
) -> OmenMarket
Markets and user positions are uniquely connected via condition_ids
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
935 936 937 938 939 940 941 942 943 944 945 | |
get_market_image_url
get_market_image_url(market_id: HexAddress) -> str | None
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
947 948 949 950 951 952 953 954 955 956 957 | |
get_market_image
get_market_image(market_id: HexAddress) -> ImageType | None
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
959 960 961 962 963 964 965 | |
get_agent_results_for_market
get_agent_results_for_market(
market_id: HexAddress | None = None,
) -> list[ContractPrediction]
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 | |
get_agent_results_for_bet
get_agent_results_for_bet(
bet: OmenBet,
) -> ContractPrediction | None
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 | |
do_query
do_query(
fields: list[FieldPath], pydantic_model: Type[T]
) -> list[T]
Source code in prediction_market_agent_tooling/markets/base_subgraph_handler.py
47 48 49 50 51 | |
get_omen_market_by_market_id_cached
get_omen_market_by_market_id_cached(
market_id: HexAddress, block_number: int
) -> OmenMarket
Source code in prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py
1008 1009 1010 1011 1012 1013 1014 1015 | |
polymarket
api
POLYMARKET_API_BASE_URL
module-attribute
POLYMARKET_API_BASE_URL = 'https://clob.polymarket.com/'
MARKETS_LIMIT
module-attribute
MARKETS_LIMIT = 100
get_polymarkets
get_polymarkets(
limit: int,
with_rewards: bool = False,
next_cursor: str | None = None,
) -> MarketsEndpointResponse
Source code in prediction_market_agent_tooling/markets/polymarket/api.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
get_polymarket_binary_markets
get_polymarket_binary_markets(
limit: int,
closed: bool | None = False,
excluded_questions: set[str] | None = None,
with_rewards: bool = False,
main_markets_only: bool = True,
) -> list[PolymarketMarketWithPrices]
See https://learn.polymarket.com/trading-rewards for information about rewards.
Source code in prediction_market_agent_tooling/markets/polymarket/api.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
get_polymarket_market
get_polymarket_market(
condition_id: str,
) -> PolymarketMarket
Source code in prediction_market_agent_tooling/markets/polymarket/api.py
112 113 114 | |
get_token_price
get_token_price(
token_id: str, side: Literal["buy", "sell"]
) -> PolymarketPriceResponse
Source code in prediction_market_agent_tooling/markets/polymarket/api.py
117 118 119 120 121 122 | |
get_market_tokens_with_prices
get_market_tokens_with_prices(
market: PolymarketMarket,
) -> list[PolymarketTokenWithPrices]
Source code in prediction_market_agent_tooling/markets/polymarket/api.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
data_models
PolymarketRewards
Bases: BaseModel
min_size
instance-attribute
min_size: int
max_spread
instance-attribute
max_spread: float | None
event_start_date
class-attribute
instance-attribute
event_start_date: DatetimeUTC | None = None
event_end_date
class-attribute
instance-attribute
event_end_date: DatetimeUTC | None = None
in_game_multiplier
class-attribute
instance-attribute
in_game_multiplier: int | None = None
reward_epoch
class-attribute
instance-attribute
reward_epoch: int | None = None
PolymarketToken
Bases: BaseModel
token_id
instance-attribute
token_id: str
outcome
instance-attribute
outcome: OutcomeStr
winner
instance-attribute
winner: bool
PolymarketMarket
Bases: BaseModel
enable_order_book
instance-attribute
enable_order_book: bool
active
instance-attribute
active: bool
closed
instance-attribute
closed: bool
archived
instance-attribute
archived: bool
minimum_order_size
instance-attribute
minimum_order_size: str | float
minimum_tick_size
instance-attribute
minimum_tick_size: str | float
condition_id
instance-attribute
condition_id: str
question_id
instance-attribute
question_id: str
question
instance-attribute
question: str
description
instance-attribute
description: str
market_slug
instance-attribute
market_slug: str
end_date_iso
instance-attribute
end_date_iso: DatetimeUTC | None
game_start_time
instance-attribute
game_start_time: DatetimeUTC | None
seconds_delay
instance-attribute
seconds_delay: int
fpmm
instance-attribute
fpmm: str
maker_base_fee
instance-attribute
maker_base_fee: int
taker_base_fee
instance-attribute
taker_base_fee: int
notifications_enabled
instance-attribute
notifications_enabled: bool
neg_risk
instance-attribute
neg_risk: bool
neg_risk_market_id
instance-attribute
neg_risk_market_id: str
neg_risk_request_id
instance-attribute
neg_risk_request_id: str
icon
instance-attribute
icon: str
image
instance-attribute
image: str
rewards
instance-attribute
rewards: PolymarketRewards
tokens
instance-attribute
tokens: tuple[PolymarketToken, ...]
is_50_50_outcome
instance-attribute
is_50_50_outcome: bool
categories
class-attribute
instance-attribute
categories: list[str] | None = None
parent_categories
class-attribute
instance-attribute
parent_categories: list[str] | None = None
accepting_orders
instance-attribute
accepting_orders: bool
id
property
id: str
url
property
url: str
resolution
property
resolution: Resolution | None
fetch_full_market
fetch_full_market() -> PolymarketFullMarket | None
Source code in prediction_market_agent_tooling/markets/polymarket/data_models.py
92 93 | |
fetch_if_its_a_main_market
fetch_if_its_a_main_market() -> bool
Source code in prediction_market_agent_tooling/markets/polymarket/data_models.py
95 96 97 98 99 100 101 102 103 | |
MarketsEndpointResponse
Bases: BaseModel
limit
instance-attribute
limit: int
count
instance-attribute
count: int
next_cursor
instance-attribute
next_cursor: str
data
instance-attribute
data: list[PolymarketMarket]
PolymarketPriceResponse
Bases: BaseModel
price
instance-attribute
price: str
price_dec
property
price_dec: USDC
Prices
Bases: BaseModel
BUY
instance-attribute
BUY: USDC
SELL
instance-attribute
SELL: USDC
PolymarketTokenWithPrices
Bases: PolymarketToken
prices
instance-attribute
prices: Prices
token_id
instance-attribute
token_id: str
outcome
instance-attribute
outcome: OutcomeStr
winner
instance-attribute
winner: bool
PolymarketMarketWithPrices
Bases: PolymarketMarket
tokens
instance-attribute
tokens: tuple[PolymarketTokenWithPrices, ...]
p_yes
property
p_yes: Probability
enable_order_book
instance-attribute
enable_order_book: bool
active
instance-attribute
active: bool
closed
instance-attribute
closed: bool
archived
instance-attribute
archived: bool
minimum_order_size
instance-attribute
minimum_order_size: str | float
minimum_tick_size
instance-attribute
minimum_tick_size: str | float
condition_id
instance-attribute
condition_id: str
question_id
instance-attribute
question_id: str
question
instance-attribute
question: str
description
instance-attribute
description: str
market_slug
instance-attribute
market_slug: str
end_date_iso
instance-attribute
end_date_iso: DatetimeUTC | None
game_start_time
instance-attribute
game_start_time: DatetimeUTC | None
seconds_delay
instance-attribute
seconds_delay: int
fpmm
instance-attribute
fpmm: str
maker_base_fee
instance-attribute
maker_base_fee: int
taker_base_fee
instance-attribute
taker_base_fee: int
notifications_enabled
instance-attribute
notifications_enabled: bool
neg_risk
instance-attribute
neg_risk: bool
neg_risk_market_id
instance-attribute
neg_risk_market_id: str
neg_risk_request_id
instance-attribute
neg_risk_request_id: str
icon
instance-attribute
icon: str
image
instance-attribute
image: str
rewards
instance-attribute
rewards: PolymarketRewards
is_50_50_outcome
instance-attribute
is_50_50_outcome: bool
categories
class-attribute
instance-attribute
categories: list[str] | None = None
parent_categories
class-attribute
instance-attribute
parent_categories: list[str] | None = None
accepting_orders
instance-attribute
accepting_orders: bool
id
property
id: str
url
property
url: str
resolution
property
resolution: Resolution | None
fetch_full_market
fetch_full_market() -> PolymarketFullMarket | None
Source code in prediction_market_agent_tooling/markets/polymarket/data_models.py
92 93 | |
fetch_if_its_a_main_market
fetch_if_its_a_main_market() -> bool
Source code in prediction_market_agent_tooling/markets/polymarket/data_models.py
95 96 97 98 99 100 101 102 103 | |
data_models_web
Autogenerated using datamodel-codegen from a single Polymarket response. Then adjusted, fixed.
Keep in mind that not all fields were used so far, so there might be some bugs.
These models are based on what Polymarket's website returns in the response, and prediction_market_agent_tooling/markets/polymarket/data_models.py are based on what their API returns.
POLYMARKET_BASE_URL
module-attribute
POLYMARKET_BASE_URL = 'https://polymarket.com'
POLYMARKET_TRUE_OUTCOME
module-attribute
POLYMARKET_TRUE_OUTCOME = 'Yes'
POLYMARKET_FALSE_OUTCOME
module-attribute
POLYMARKET_FALSE_OUTCOME = 'No'
ImageOptimized
Bases: BaseModel
imageUrlOptimized
instance-attribute
imageUrlOptimized: str
IconOptimized
Bases: BaseModel
imageUrlOptimized
instance-attribute
imageUrlOptimized: str
Event
Bases: BaseModel
id
instance-attribute
id: str
slug
instance-attribute
slug: str
ticker
instance-attribute
ticker: str
title
instance-attribute
title: str
series
class-attribute
instance-attribute
series: Any | None = None
Event1
Bases: BaseModel
startDate
class-attribute
instance-attribute
startDate: DatetimeUTC | None = None
slug
instance-attribute
slug: str
Market1
Bases: BaseModel
slug
instance-attribute
slug: str
question
instance-attribute
question: str
image
instance-attribute
image: str
volume
class-attribute
instance-attribute
volume: USDC | None = None
outcomes
instance-attribute
outcomes: Sequence[OutcomeStr]
outcomePrices
instance-attribute
outcomePrices: list[USDC]
active
instance-attribute
active: bool
archived
instance-attribute
archived: bool
closed
instance-attribute
closed: bool
orderPriceMinTickSize
instance-attribute
orderPriceMinTickSize: USDC
clobTokenIds
instance-attribute
clobTokenIds: str
events
class-attribute
instance-attribute
events: list[Event1] | None = None
ResolutionData
Bases: BaseModel
id
instance-attribute
id: str
author
instance-attribute
author: str
lastUpdateTimestamp
instance-attribute
lastUpdateTimestamp: int
status
instance-attribute
status: str
wasDisputed
instance-attribute
wasDisputed: bool
price
instance-attribute
price: str
proposedPrice
instance-attribute
proposedPrice: str
reproposedPrice
instance-attribute
reproposedPrice: str
updates
instance-attribute
updates: str
newVersionQ
instance-attribute
newVersionQ: bool
transactionHash
instance-attribute
transactionHash: str
logIndex
instance-attribute
logIndex: str
Market
Bases: BaseModel
id
instance-attribute
id: str
question
instance-attribute
question: str
conditionId
instance-attribute
conditionId: str
slug
instance-attribute
slug: str
twitterCardImage
class-attribute
instance-attribute
twitterCardImage: Any | None = None
resolutionSource
class-attribute
instance-attribute
resolutionSource: str | None = None
endDate
instance-attribute
endDate: DatetimeUTC
category
class-attribute
instance-attribute
category: Any | None = None
ammType
class-attribute
instance-attribute
ammType: Any | None = None
description
instance-attribute
description: str
liquidity
class-attribute
instance-attribute
liquidity: str | None = None
startDate
class-attribute
instance-attribute
startDate: DatetimeUTC | None = None
createdAt
instance-attribute
createdAt: DatetimeUTC
xAxisValue
class-attribute
instance-attribute
xAxisValue: Any | None = None
yAxisValue
class-attribute
instance-attribute
yAxisValue: Any | None = None
denominationToken
class-attribute
instance-attribute
denominationToken: Any | None = None
fee
class-attribute
instance-attribute
fee: str | None = None
lowerBound
class-attribute
instance-attribute
lowerBound: Any | None = None
upperBound
class-attribute
instance-attribute
upperBound: Any | None = None
outcomes
instance-attribute
outcomes: Sequence[OutcomeStr]
image
class-attribute
instance-attribute
image: str | None = None
icon
class-attribute
instance-attribute
icon: str | None = None
imageOptimized
class-attribute
instance-attribute
imageOptimized: Any | None = None
iconOptimized
class-attribute
instance-attribute
iconOptimized: Any | None = None
outcomePrices
instance-attribute
outcomePrices: list[USDC]
volume
class-attribute
instance-attribute
volume: USDC | None = None
active
instance-attribute
active: bool
marketType
class-attribute
instance-attribute
marketType: str | None = None
formatType
class-attribute
instance-attribute
formatType: Any | None = None
lowerBoundDate
class-attribute
instance-attribute
lowerBoundDate: Any | None = None
upperBoundDate
class-attribute
instance-attribute
upperBoundDate: Any | None = None
closed
instance-attribute
closed: bool
marketMakerAddress
instance-attribute
marketMakerAddress: HexAddress
closedTime
class-attribute
instance-attribute
closedTime: DatetimeUTC | None = None
wideFormat
class-attribute
instance-attribute
wideFormat: bool | None = None
new
class-attribute
instance-attribute
new: bool | None = None
sentDiscord
class-attribute
instance-attribute
sentDiscord: Any | None = None
mailchimpTag
class-attribute
instance-attribute
mailchimpTag: Any | None = None
featured
class-attribute
instance-attribute
featured: bool | None = None
submitted_by
class-attribute
instance-attribute
submitted_by: str | None = None
subcategory
class-attribute
instance-attribute
subcategory: Any | None = None
categoryMailchimpTag
class-attribute
instance-attribute
categoryMailchimpTag: Any | None = None
archived
class-attribute
instance-attribute
archived: bool | None = None
resolvedBy
class-attribute
instance-attribute
resolvedBy: str | None = None
restricted
class-attribute
instance-attribute
restricted: bool | None = None
groupItemTitle
class-attribute
instance-attribute
groupItemTitle: str | None = None
groupItemThreshold
class-attribute
instance-attribute
groupItemThreshold: str | None = None
questionID
class-attribute
instance-attribute
questionID: str | None = None
umaEndDate
class-attribute
instance-attribute
umaEndDate: Any | None = None
enableOrderBook
class-attribute
instance-attribute
enableOrderBook: bool | None = None
orderPriceMinTickSize
class-attribute
instance-attribute
orderPriceMinTickSize: float | None = None
orderMinSize
class-attribute
instance-attribute
orderMinSize: int | None = None
umaResolutionStatus
class-attribute
instance-attribute
umaResolutionStatus: Any | None = None
curationOrder
class-attribute
instance-attribute
curationOrder: Any | None = None
volumeNum
class-attribute
instance-attribute
volumeNum: USDC | None = None
liquidityNum
class-attribute
instance-attribute
liquidityNum: float | None = None
endDateIso
class-attribute
instance-attribute
endDateIso: DatetimeUTC | None = None
startDateIso
class-attribute
instance-attribute
startDateIso: DatetimeUTC | None = None
umaEndDateIso
class-attribute
instance-attribute
umaEndDateIso: DatetimeUTC | None = None
commentsEnabled
class-attribute
instance-attribute
commentsEnabled: bool | None = None
disqusThread
class-attribute
instance-attribute
disqusThread: Any | None = None
gameStartTime
class-attribute
instance-attribute
gameStartTime: Any | None = None
secondsDelay
class-attribute
instance-attribute
secondsDelay: int | None = None
clobTokenIds
class-attribute
instance-attribute
clobTokenIds: list[str] | None = None
liquidityAmm
class-attribute
instance-attribute
liquidityAmm: float | None = None
liquidityClob
class-attribute
instance-attribute
liquidityClob: float | None = None
makerBaseFee
class-attribute
instance-attribute
makerBaseFee: int | None = None
takerBaseFee
class-attribute
instance-attribute
takerBaseFee: int | None = None
negRisk
class-attribute
instance-attribute
negRisk: Any | None = None
negRiskRequestID
class-attribute
instance-attribute
negRiskRequestID: Any | None = None
negRiskMarketID
class-attribute
instance-attribute
negRiskMarketID: Any | None = None
events
class-attribute
instance-attribute
events: list[Event] | None = None
markets
class-attribute
instance-attribute
markets: list[Market1] | None = None
lower_bound_date
class-attribute
instance-attribute
lower_bound_date: Any | None = None
upper_bound_date
class-attribute
instance-attribute
upper_bound_date: Any | None = None
market_type
class-attribute
instance-attribute
market_type: str | None = None
resolution_source
class-attribute
instance-attribute
resolution_source: str | None = None
end_date
class-attribute
instance-attribute
end_date: str | None = None
amm_type
class-attribute
instance-attribute
amm_type: Any | None = None
x_axis_value
class-attribute
instance-attribute
x_axis_value: Any | None = None
y_axis_value
class-attribute
instance-attribute
y_axis_value: Any | None = None
denomination_token
class-attribute
instance-attribute
denomination_token: Any | None = None
resolved_by
class-attribute
instance-attribute
resolved_by: str | None = None
upper_bound
class-attribute
instance-attribute
upper_bound: Any | None = None
lower_bound
class-attribute
instance-attribute
lower_bound: Any | None = None
created_at
class-attribute
instance-attribute
created_at: str | None = None
updated_at
class-attribute
instance-attribute
updated_at: Any | None = None
closed_time
class-attribute
instance-attribute
closed_time: Any | None = None
wide_format
class-attribute
instance-attribute
wide_format: bool | None = None
volume_num
class-attribute
instance-attribute
volume_num: USDC | None = None
liquidity_num
class-attribute
instance-attribute
liquidity_num: USDC | None = None
image_raw
class-attribute
instance-attribute
image_raw: str | None = None
resolutionData
instance-attribute
resolutionData: ResolutionData
resolution
property
resolution: Resolution | None
field_validator_closedTime
field_validator_closedTime(
v: str | None = None,
) -> str | None
Source code in prediction_market_agent_tooling/markets/polymarket/data_models_web.py
170 171 172 | |
Category
Bases: BaseModel
id
instance-attribute
id: str
label
instance-attribute
label: str
parentCategory
instance-attribute
parentCategory: str
slug
instance-attribute
slug: str
Bid
Bases: BaseModel
price
instance-attribute
price: str
size
instance-attribute
size: str
Ask
Bases: BaseModel
price
instance-attribute
price: str
size
instance-attribute
size: str
MarketBidsAndAsks
Bases: BaseModel
market
instance-attribute
market: str
asset_id
instance-attribute
asset_id: str
hash
instance-attribute
hash: str
bids
instance-attribute
bids: list[Bid]
asks
instance-attribute
asks: list[Ask]
lastUpdated
instance-attribute
lastUpdated: int
PolymarketFullMarket
Bases: BaseModel
id
instance-attribute
id: str
ticker
instance-attribute
ticker: str
slug
instance-attribute
slug: str
title
instance-attribute
title: str
subtitle
class-attribute
instance-attribute
subtitle: Any | None = None
description
instance-attribute
description: str
commentCount
class-attribute
instance-attribute
commentCount: int | None = None
resolutionSource
class-attribute
instance-attribute
resolutionSource: str | None = None
startDate
class-attribute
instance-attribute
startDate: DatetimeUTC | None = None
endDate
instance-attribute
endDate: DatetimeUTC
image
class-attribute
instance-attribute
image: str | None = None
icon
class-attribute
instance-attribute
icon: str | None = None
featuredImage
class-attribute
instance-attribute
featuredImage: str | None = None
active
instance-attribute
active: bool
closed
instance-attribute
closed: bool
archived
class-attribute
instance-attribute
archived: bool | None = None
new
class-attribute
instance-attribute
new: bool | None = None
featured
class-attribute
instance-attribute
featured: bool | None = None
restricted
class-attribute
instance-attribute
restricted: bool | None = None
liquidity
class-attribute
instance-attribute
liquidity: USDC | None = None
volume
class-attribute
instance-attribute
volume: USDC | None = None
volume24hr
class-attribute
instance-attribute
volume24hr: USDC | None = None
competitive
class-attribute
instance-attribute
competitive: float | None = None
openInterest
class-attribute
instance-attribute
openInterest: int | None = None
sortBy
class-attribute
instance-attribute
sortBy: str | None = None
createdAt
instance-attribute
createdAt: DatetimeUTC
commentsEnabled
class-attribute
instance-attribute
commentsEnabled: bool | None = None
disqusThread
class-attribute
instance-attribute
disqusThread: Any | None = None
updatedAt
instance-attribute
updatedAt: DatetimeUTC
enableOrderBook
class-attribute
instance-attribute
enableOrderBook: bool | None = None
liquidityAmm
class-attribute
instance-attribute
liquidityAmm: float | None = None
liquidityClob
class-attribute
instance-attribute
liquidityClob: float | None = None
imageOptimized
class-attribute
instance-attribute
imageOptimized: ImageOptimized | None = None
iconOptimized
class-attribute
instance-attribute
iconOptimized: IconOptimized | None = None
featuredImageOptimized
class-attribute
instance-attribute
featuredImageOptimized: str | None = None
negRisk
class-attribute
instance-attribute
negRisk: Any | None = None
negRiskMarketID
class-attribute
instance-attribute
negRiskMarketID: Any | None = None
negRiskFeeBips
class-attribute
instance-attribute
negRiskFeeBips: Any | None = None
markets
instance-attribute
markets: list[Market]
categories
class-attribute
instance-attribute
categories: list[Category] | None = None
series
class-attribute
instance-attribute
series: Any | None = None
image_raw
class-attribute
instance-attribute
image_raw: str | None = None
url
property
url: str
is_main_market
property
is_main_market: bool
main_market
property
main_market: Market
fetch_from_url
staticmethod
fetch_from_url(url: str) -> PolymarketFullMarket | None
Get the full market data from the Polymarket website.
Returns None if this market's url returns "Oops...we didn't forecast this", see check_if_its_a_main_market method for more details.
Warning: This is a very slow operation, as it requires fetching the website. Use it only when necessary.
Source code in prediction_market_agent_tooling/markets/polymarket/data_models_web.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | |
PriceSide
Bases: BaseModel
price
instance-attribute
price: USDC
side
instance-attribute
side: Literal['BUY', 'SELL']
State
Bases: BaseModel
data
instance-attribute
data: (
PolymarketFullMarket
| MarketBidsAndAsks
| PriceSide
| dict[str, MarketBidsAndAsks]
| dict[str, PriceSide]
| None
)
dataUpdateCount
instance-attribute
dataUpdateCount: int
dataUpdatedAt
instance-attribute
dataUpdatedAt: int
error
class-attribute
instance-attribute
error: Any | None = None
errorUpdateCount
instance-attribute
errorUpdateCount: int
errorUpdatedAt
instance-attribute
errorUpdatedAt: int
fetchFailureCount
instance-attribute
fetchFailureCount: int
fetchFailureReason
class-attribute
instance-attribute
fetchFailureReason: Any | None = None
fetchMeta
class-attribute
instance-attribute
fetchMeta: Any | None = None
isInvalidated
instance-attribute
isInvalidated: bool
status
instance-attribute
status: str
fetchStatus
instance-attribute
fetchStatus: str
Query
Bases: BaseModel
state
instance-attribute
state: State
queryKey
instance-attribute
queryKey: list[str]
queryHash
instance-attribute
queryHash: str
DehydratedState
Bases: BaseModel
mutations
instance-attribute
mutations: list[Any]
queries
instance-attribute
queries: list[Query]
PageProps
Bases: BaseModel
key
instance-attribute
key: str
dehydratedState
instance-attribute
dehydratedState: DehydratedState
eslug
instance-attribute
eslug: str
mslug
class-attribute
instance-attribute
mslug: str | None = None
isSingleMarket
instance-attribute
isSingleMarket: bool
Props
Bases: BaseModel
pageProps
instance-attribute
pageProps: PageProps
Query1
Bases: BaseModel
slug
instance-attribute
slug: list[str]
PolymarketWebResponse
Bases: BaseModel
props
instance-attribute
props: Props
page
instance-attribute
page: str
query
instance-attribute
query: Query1
buildId
instance-attribute
buildId: str
isFallback
instance-attribute
isFallback: bool
gsp
instance-attribute
gsp: bool
locale
instance-attribute
locale: str
locales
instance-attribute
locales: list[str]
defaultLocale
instance-attribute
defaultLocale: str
scriptLoader
instance-attribute
scriptLoader: list[Any]
construct_polymarket_url
construct_polymarket_url(slug: str) -> str
Note: This works only if it's a single main market, not sub-market of some more general question.
Source code in prediction_market_agent_tooling/markets/polymarket/data_models_web.py
416 417 418 419 420 | |
polymarket
PolymarketAgentMarket
Bases: AgentMarket
Polymarket's market class that can be used by agents to make predictions.
base_url
class-attribute
base_url: str = POLYMARKET_BASE_URL
fees
class-attribute
instance-attribute
fees: MarketFees = get_zero_fees()
id
instance-attribute
id: str
question
instance-attribute
question: str
description
instance-attribute
description: str | None
outcomes
instance-attribute
outcomes: Sequence[OutcomeStr]
outcome_token_pool
instance-attribute
outcome_token_pool: dict[OutcomeStr, OutcomeToken] | None
resolution
instance-attribute
resolution: Resolution | None
created_time
instance-attribute
created_time: DatetimeUTC | None
close_time
instance-attribute
close_time: DatetimeUTC | None
probabilities
instance-attribute
probabilities: dict[OutcomeStr, Probability]
url
instance-attribute
url: str
volume
instance-attribute
volume: CollateralToken | None
is_binary
property
is_binary: bool
p_yes
property
p_yes: Probability
p_no
property
p_no: Probability
probable_resolution
property
probable_resolution: Resolution
from_data_model
staticmethod
from_data_model(
model: PolymarketMarketWithPrices,
) -> PolymarketAgentMarket
Source code in prediction_market_agent_tooling/markets/polymarket/polymarket.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
get_tiny_bet_amount
get_tiny_bet_amount() -> CollateralToken
Source code in prediction_market_agent_tooling/markets/polymarket/polymarket.py
51 52 | |
place_bet
place_bet(outcome: OutcomeStr, amount: USD) -> str
Source code in prediction_market_agent_tooling/markets/polymarket/polymarket.py
54 55 | |
get_markets
staticmethod
get_markets(
limit: int,
sort_by: SortBy = SortBy.NONE,
filter_by: FilterBy = FilterBy.OPEN,
created_after: Optional[DatetimeUTC] = None,
excluded_questions: set[str] | None = None,
fetch_categorical_markets: bool = False,
) -> t.Sequence[PolymarketAgentMarket]
Source code in prediction_market_agent_tooling/markets/polymarket/polymarket.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
validate_probabilities
validate_probabilities(
probs: dict[OutcomeStr, Probability],
info: FieldValidationInfo,
) -> dict[OutcomeStr, Probability]
Source code in prediction_market_agent_tooling/markets/agent_market.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
validate_outcome_token_pool
validate_outcome_token_pool(
outcome_token_pool: dict[str, OutcomeToken] | None,
info: FieldValidationInfo,
) -> dict[str, OutcomeToken] | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
have_bet_on_market_since
have_bet_on_market_since(
keys: APIKeys, since: timedelta
) -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
119 120 | |
get_outcome_token_pool_by_outcome
get_outcome_token_pool_by_outcome(
outcome: OutcomeStr,
) -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
122 123 124 125 126 127 128 | |
handle_legacy_fee
handle_legacy_fee(data: dict[str, Any]) -> dict[str, t.Any]
Source code in prediction_market_agent_tooling/markets/agent_market.py
130 131 132 133 134 135 136 | |
market_outcome_for_probability_key
market_outcome_for_probability_key(
probability_key: OutcomeStr,
) -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/agent_market.py
138 139 140 141 142 143 144 145 146 | |
probability_for_market_outcome
probability_for_market_outcome(
market_outcome: OutcomeStr,
) -> Probability
Source code in prediction_market_agent_tooling/markets/agent_market.py
148 149 150 151 152 153 154 | |
get_last_trade_p_yes
get_last_trade_p_yes() -> Probability | None
Get the last trade price for the YES outcome. This can be different from the current p_yes, for example if market is closed and it's probabilities are fixed to 0 and 1. Could be None if no trades were made.
Source code in prediction_market_agent_tooling/markets/agent_market.py
195 196 197 198 199 200 | |
get_last_trade_p_no
get_last_trade_p_no() -> Probability | None
Get the last trade price for the NO outcome. This can be different from the current p_yes, for example if market is closed and it's probabilities are fixed to 0 and 1. Could be None if no trades were made.
Source code in prediction_market_agent_tooling/markets/agent_market.py
202 203 204 205 206 207 | |
get_last_trade_yes_outcome_price
get_last_trade_yes_outcome_price() -> (
CollateralToken | None
)
Source code in prediction_market_agent_tooling/markets/agent_market.py
209 210 211 212 213 214 | |
get_last_trade_yes_outcome_price_usd
get_last_trade_yes_outcome_price_usd() -> USD | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
216 217 218 219 | |
get_last_trade_no_outcome_price
get_last_trade_no_outcome_price() -> CollateralToken | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
221 222 223 224 225 226 | |
get_last_trade_no_outcome_price_usd
get_last_trade_no_outcome_price_usd() -> USD | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
228 229 230 231 | |
get_liquidatable_amount
get_liquidatable_amount() -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
233 234 235 | |
get_token_in_usd
get_token_in_usd(x: CollateralToken) -> USD
Token of this market can have whatever worth (e.g. sDai and ETH markets will have different worth of 1 token). Use this to convert it to USD.
Source code in prediction_market_agent_tooling/markets/agent_market.py
237 238 239 240 241 | |
get_usd_in_token
get_usd_in_token(x: USD) -> CollateralToken
Markets on a single platform can have different tokens as collateral (sDai, wxDai, GNO, ...). Use this to convert USD to the token of this market.
Source code in prediction_market_agent_tooling/markets/agent_market.py
243 244 245 246 247 | |
get_sell_value_of_outcome_token
get_sell_value_of_outcome_token(
outcome: OutcomeStr, amount: OutcomeToken
) -> CollateralToken
When you hold OutcomeToken(s), it's easy to calculate how much you get at the end if you win (1 OutcomeToken will equal to 1 Token). But use this to figure out, how much are these outcome tokens worth right now (for how much you can sell them).
Source code in prediction_market_agent_tooling/markets/agent_market.py
249 250 251 252 253 254 255 256 | |
get_in_usd
get_in_usd(x: USD | CollateralToken) -> USD
Source code in prediction_market_agent_tooling/markets/agent_market.py
258 259 260 261 | |
get_in_token
get_in_token(x: USD | CollateralToken) -> CollateralToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
263 264 265 266 | |
liquidate_existing_positions
liquidate_existing_positions(outcome: OutcomeStr) -> None
Source code in prediction_market_agent_tooling/markets/agent_market.py
274 275 | |
buy_tokens
buy_tokens(outcome: OutcomeStr, amount: USD) -> str
Source code in prediction_market_agent_tooling/markets/agent_market.py
280 281 | |
get_buy_token_amount
get_buy_token_amount(
bet_amount: USD | CollateralToken, outcome: OutcomeStr
) -> OutcomeToken | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
283 284 285 286 | |
sell_tokens
sell_tokens(
outcome: OutcomeStr, amount: USD | OutcomeToken
) -> str
Source code in prediction_market_agent_tooling/markets/agent_market.py
288 289 | |
compute_fpmm_probabilities
staticmethod
compute_fpmm_probabilities(
balances: list[OutcomeWei],
) -> list[Probability]
Compute the implied probabilities in a Fixed Product Market Maker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
balances
|
List[float]
|
Balances of outcome tokens. |
required |
Returns:
| Type | Description |
|---|---|
list[Probability]
|
List[float]: Implied probabilities for each outcome. |
Source code in prediction_market_agent_tooling/markets/agent_market.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
build_probability_map_from_p_yes
staticmethod
build_probability_map_from_p_yes(
p_yes: Probability,
) -> dict[OutcomeStr, Probability]
Source code in prediction_market_agent_tooling/markets/agent_market.py
321 322 323 324 325 326 327 328 | |
build_probability_map
staticmethod
build_probability_map(
outcome_token_amounts: list[OutcomeWei],
outcomes: list[OutcomeStr],
) -> dict[OutcomeStr, Probability]
Source code in prediction_market_agent_tooling/markets/agent_market.py
330 331 332 333 334 335 | |
get_binary_market
staticmethod
get_binary_market(id: str) -> AgentMarket
Source code in prediction_market_agent_tooling/markets/agent_market.py
348 349 350 | |
redeem_winnings
staticmethod
redeem_winnings(api_keys: APIKeys) -> None
On some markets (like Omen), it's needed to manually claim the winner bets. If it's not needed, just implement with pass.
Source code in prediction_market_agent_tooling/markets/agent_market.py
352 353 354 355 356 357 | |
get_trade_balance
classmethod
get_trade_balance(api_keys: APIKeys) -> USD
Return balance that can be used to trade on the given market.
Source code in prediction_market_agent_tooling/markets/agent_market.py
359 360 361 362 363 364 | |
verify_operational_balance
staticmethod
verify_operational_balance(api_keys: APIKeys) -> bool
Return True if the user has enough of operational balance. If not needed, just return True.
For example: Omen needs at least some xDai in the wallet to execute transactions.
Source code in prediction_market_agent_tooling/markets/agent_market.py
366 367 368 369 370 371 372 | |
store_prediction
store_prediction(
processed_market: ProcessedMarket | None,
keys: APIKeys,
agent_name: str,
) -> None
If market allows to upload predictions somewhere, implement it in this method.
Source code in prediction_market_agent_tooling/markets/agent_market.py
374 375 376 377 378 379 380 381 382 383 | |
store_trades
store_trades(
traded_market: ProcessedTradedMarket | None,
keys: APIKeys,
agent_name: str,
web3: Web3 | None = None,
) -> None
If market allows to upload trades somewhere, implement it in this method.
Source code in prediction_market_agent_tooling/markets/agent_market.py
385 386 387 388 389 390 391 392 393 394 395 | |
get_bets_made_since
staticmethod
get_bets_made_since(
better_address: ChecksumAddress, start_time: DatetimeUTC
) -> list[Bet]
Source code in prediction_market_agent_tooling/markets/agent_market.py
397 398 399 400 401 | |
get_resolved_bets_made_since
staticmethod
get_resolved_bets_made_since(
better_address: ChecksumAddress,
start_time: DatetimeUTC,
end_time: DatetimeUTC | None,
) -> list[ResolvedBet]
Source code in prediction_market_agent_tooling/markets/agent_market.py
403 404 405 406 407 408 409 | |
is_closed
is_closed() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
411 412 | |
is_resolved
is_resolved() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
414 415 | |
get_liquidity
get_liquidity() -> CollateralToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
417 418 | |
has_liquidity
has_liquidity() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
420 421 | |
has_successful_resolution
has_successful_resolution() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
423 424 425 426 427 428 | |
has_unsuccessful_resolution
has_unsuccessful_resolution() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
430 431 | |
get_outcome_str_from_bool
staticmethod
get_outcome_str_from_bool(outcome: bool) -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/agent_market.py
433 434 435 | |
get_outcome_str
get_outcome_str(outcome_index: int) -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/agent_market.py
437 438 439 440 441 442 443 | |
get_outcome_index
get_outcome_index(outcome: OutcomeStr) -> int
Source code in prediction_market_agent_tooling/markets/agent_market.py
445 446 447 448 449 450 | |
get_token_balance
get_token_balance(
user_id: str, outcome: OutcomeStr
) -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
452 453 | |
get_position
get_position(user_id: str) -> ExistingPosition | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
455 456 | |
get_positions
classmethod
get_positions(
user_id: str,
liquid_only: bool = False,
larger_than: OutcomeToken = OutcomeToken(0),
) -> t.Sequence[ExistingPosition]
Get all non-zero positions a user has in any market.
If liquid_only is True, only return positions that can be sold.
If larger_than is not None, only return positions with a larger number
of tokens than this amount.
Source code in prediction_market_agent_tooling/markets/agent_market.py
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 | |
can_be_traded
can_be_traded() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
475 476 477 478 | |
get_user_url
classmethod
get_user_url(keys: APIKeys) -> str
Source code in prediction_market_agent_tooling/markets/agent_market.py
480 481 482 | |
has_token_pool
has_token_pool() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
484 485 | |
get_pool_tokens
get_pool_tokens(outcome: OutcomeStr) -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
487 488 489 490 491 | |
get_user_balance
staticmethod
get_user_balance(user_id: str) -> float
Source code in prediction_market_agent_tooling/markets/agent_market.py
493 494 495 | |
get_user_id
staticmethod
get_user_id(api_keys: APIKeys) -> str
Source code in prediction_market_agent_tooling/markets/agent_market.py
497 498 499 | |
get_most_recent_trade_datetime
get_most_recent_trade_datetime(
user_id: str,
) -> DatetimeUTC | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
501 502 | |
utils
find_resolution_on_polymarket
find_resolution_on_polymarket(
question: str,
) -> Resolution | None
Source code in prediction_market_agent_tooling/markets/polymarket/utils.py
9 10 11 12 13 14 15 16 | |
find_full_polymarket
find_full_polymarket(
question: str,
) -> PolymarketFullMarket | None
Source code in prediction_market_agent_tooling/markets/polymarket/utils.py
19 20 21 22 23 | |
find_url_to_polymarket
find_url_to_polymarket(question: str) -> str | None
Source code in prediction_market_agent_tooling/markets/polymarket/utils.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
seer
data_models
SEER_BASE_URL
module-attribute
SEER_BASE_URL = 'https://app.seer.pm'
CreateCategoricalMarketsParams
Bases: BaseModel
model_config
class-attribute
instance-attribute
model_config = ConfigDict(populate_by_name=True)
market_name
class-attribute
instance-attribute
market_name: str = Field(..., alias='marketName')
outcomes
instance-attribute
outcomes: Sequence[OutcomeStr]
question_start
class-attribute
instance-attribute
question_start: str = Field(
alias="questionStart", default=""
)
question_end
class-attribute
instance-attribute
question_end: str = Field(alias='questionEnd', default='')
outcome_type
class-attribute
instance-attribute
outcome_type: str = Field(alias='outcomeType', default='')
parent_outcome
class-attribute
instance-attribute
parent_outcome: int = Field(
alias="parentOutcome", default=0
)
parent_market
class-attribute
instance-attribute
parent_market: HexAddress = Field(
alias="parentMarket", default=ADDRESS_ZERO
)
category
instance-attribute
category: str
lang
instance-attribute
lang: str
lower_bound
class-attribute
instance-attribute
lower_bound: int = Field(alias='lowerBound', default=0)
upper_bound
class-attribute
instance-attribute
upper_bound: int = Field(alias='upperBound', default=0)
min_bond
class-attribute
instance-attribute
min_bond: Web3Wei = Field(..., alias='minBond')
opening_time
class-attribute
instance-attribute
opening_time: int = Field(..., alias='openingTime')
token_names
class-attribute
instance-attribute
token_names: list[str] = Field(..., alias='tokenNames')
SeerMarket
Bases: BaseModel
model_config
class-attribute
instance-attribute
model_config = ConfigDict(populate_by_name=True)
id
instance-attribute
id: HexBytes
creator
instance-attribute
creator: HexAddress
title
class-attribute
instance-attribute
title: str = Field(alias='marketName')
outcomes
instance-attribute
outcomes: Sequence[OutcomeStr]
wrapped_tokens
class-attribute
instance-attribute
wrapped_tokens: list[HexAddress] = Field(
alias="wrappedTokens"
)
parent_outcome
class-attribute
instance-attribute
parent_outcome: int = Field(alias='parentOutcome')
parent_market
class-attribute
instance-attribute
parent_market: Optional[SeerParentMarket] = Field(
alias="parentMarket", default=None
)
collateral_token
class-attribute
instance-attribute
collateral_token: HexAddress = Field(
alias="collateralToken"
)
condition_id
class-attribute
instance-attribute
condition_id: HexBytes = Field(alias='conditionId')
opening_ts
class-attribute
instance-attribute
opening_ts: int = Field(alias='openingTs')
block_timestamp
class-attribute
instance-attribute
block_timestamp: int = Field(alias='blockTimestamp')
has_answers
class-attribute
instance-attribute
has_answers: bool | None = Field(alias='hasAnswers')
payout_reported
class-attribute
instance-attribute
payout_reported: bool = Field(alias='payoutReported')
payout_numerators
class-attribute
instance-attribute
payout_numerators: list[int] = Field(
alias="payoutNumerators"
)
outcomes_supply
class-attribute
instance-attribute
outcomes_supply: int = Field(alias='outcomesSupply')
has_valid_answer
property
has_valid_answer: bool
is_resolved
property
is_resolved: bool
is_resolved_with_valid_answer
property
is_resolved_with_valid_answer: bool
is_binary
property
is_binary: bool
collateral_token_contract_address_checksummed
property
collateral_token_contract_address_checksummed: (
ChecksumAddress
)
close_time
property
close_time: DatetimeUTC
created_time
property
created_time: DatetimeUTC
url
property
url: str
is_redeemable
is_redeemable(
owner: ChecksumAddress, web3: Web3 | None = None
) -> bool
Source code in prediction_market_agent_tooling/markets/seer/data_models.py
90 91 92 93 94 95 96 97 | |
get_outcome_token_balances
get_outcome_token_balances(
owner: ChecksumAddress, web3: Web3 | None = None
) -> list[OutcomeWei]
Source code in prediction_market_agent_tooling/markets/seer/data_models.py
99 100 101 102 103 104 105 106 107 108 109 | |
RedeemParams
Bases: BaseModel
model_config
class-attribute
instance-attribute
model_config = ConfigDict(populate_by_name=True)
market
instance-attribute
market: ChecksumAddress
outcome_indices
class-attribute
instance-attribute
outcome_indices: list[int] = Field(alias='outcomeIndexes')
amounts
instance-attribute
amounts: list[OutcomeWei]
ExactInputSingleParams
Bases: BaseModel
model_config
class-attribute
instance-attribute
model_config = ConfigDict(populate_by_name=True)
token_in
class-attribute
instance-attribute
token_in: ChecksumAddress = Field(alias='tokenIn')
token_out
class-attribute
instance-attribute
token_out: ChecksumAddress = Field(alias='tokenOut')
recipient
instance-attribute
recipient: ChecksumAddress
deadline
class-attribute
instance-attribute
deadline: int = Field(
default_factory=lambda: int(timestamp())
)
amount_in
class-attribute
instance-attribute
amount_in: Wei = Field(alias='amountIn')
amount_out_minimum
class-attribute
instance-attribute
amount_out_minimum: Wei = Field(alias='amountOutMinimum')
limit_sqrt_price
class-attribute
instance-attribute
limit_sqrt_price: Wei = Field(
alias="limitSqrtPrice", default_factory=lambda: Wei(0)
)
exceptions
PriceCalculationError
Bases: Exception
Raised when there's an error discovering prices for a market.
price_manager
PriceManager
PriceManager(
seer_market: SeerMarket,
seer_subgraph: SeerSubgraphHandler,
)
Source code in prediction_market_agent_tooling/markets/seer/price_manager.py
50 51 52 | |
seer_market
instance-attribute
seer_market = seer_market
seer_subgraph
instance-attribute
seer_subgraph = seer_subgraph
build
staticmethod
build(market_id: HexBytes) -> PriceManager
Source code in prediction_market_agent_tooling/markets/seer/price_manager.py
54 55 56 57 58 | |
get_price_for_token
get_price_for_token(
token: ChecksumAddress,
collateral_exchange_amount: CollateralToken
| None = None,
) -> CollateralToken | None
Source code in prediction_market_agent_tooling/markets/seer/price_manager.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
pool_token0_matches_token
staticmethod
pool_token0_matches_token(
token: ChecksumAddress, pool: SeerPool
) -> bool
Source code in prediction_market_agent_tooling/markets/seer/price_manager.py
97 98 99 | |
get_token_price_from_pools
get_token_price_from_pools(
token: ChecksumAddress,
) -> CollateralToken | None
Source code in prediction_market_agent_tooling/markets/seer/price_manager.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
build_probability_map
build_probability_map() -> dict[OutcomeStr, Probability]
Source code in prediction_market_agent_tooling/markets/seer/price_manager.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
seer
SEER_TINY_BET_AMOUNT
module-attribute
SEER_TINY_BET_AMOUNT = USD(0.1)
SeerAgentMarket
Bases: AgentMarket
wrapped_tokens
instance-attribute
wrapped_tokens: list[ChecksumAddress]
creator
instance-attribute
creator: HexAddress
collateral_token_contract_address_checksummed
instance-attribute
collateral_token_contract_address_checksummed: (
ChecksumAddress
)
condition_id
instance-attribute
condition_id: HexBytes
description
class-attribute
instance-attribute
description: str | None = None
outcomes_supply
instance-attribute
outcomes_supply: int
base_url
class-attribute
base_url: str
id
instance-attribute
id: str
question
instance-attribute
question: str
outcomes
instance-attribute
outcomes: Sequence[OutcomeStr]
outcome_token_pool
instance-attribute
outcome_token_pool: dict[OutcomeStr, OutcomeToken] | None
resolution
instance-attribute
resolution: Resolution | None
created_time
instance-attribute
created_time: DatetimeUTC | None
close_time
instance-attribute
close_time: DatetimeUTC | None
probabilities
instance-attribute
probabilities: dict[OutcomeStr, Probability]
url
instance-attribute
url: str
volume
instance-attribute
volume: CollateralToken | None
fees
instance-attribute
fees: MarketFees
is_binary
property
is_binary: bool
p_yes
property
p_yes: Probability
p_no
property
p_no: Probability
probable_resolution
property
probable_resolution: Resolution
get_collateral_token_contract
get_collateral_token_contract(
web3: Web3 | None = None,
) -> ContractERC20OnGnosisChain
Source code in prediction_market_agent_tooling/markets/seer/seer.py
91 92 93 94 95 96 97 98 99 | |
store_prediction
store_prediction(
processed_market: ProcessedMarket | None,
keys: APIKeys,
agent_name: str,
) -> None
On Seer, we have to store predictions along with trades, see store_trades.
Source code in prediction_market_agent_tooling/markets/seer/seer.py
101 102 103 104 105 106 107 | |
store_trades
store_trades(
traded_market: ProcessedTradedMarket | None,
keys: APIKeys,
agent_name: str,
web3: Web3 | None = None,
) -> None
Source code in prediction_market_agent_tooling/markets/seer/seer.py
109 110 111 112 113 114 115 116 | |
get_token_in_usd
get_token_in_usd(x: CollateralToken) -> USD
Source code in prediction_market_agent_tooling/markets/seer/seer.py
118 119 | |
get_usd_in_token
get_usd_in_token(x: USD) -> CollateralToken
Source code in prediction_market_agent_tooling/markets/seer/seer.py
121 122 | |
get_buy_token_amount
get_buy_token_amount(
bet_amount: USD | CollateralToken,
outcome_str: OutcomeStr,
) -> OutcomeToken | None
Returns number of outcome tokens returned for a given bet expressed in collateral units.
Source code in prediction_market_agent_tooling/markets/seer/seer.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
get_sell_value_of_outcome_token
get_sell_value_of_outcome_token(
outcome: OutcomeStr, amount: OutcomeToken
) -> CollateralToken
Source code in prediction_market_agent_tooling/markets/seer/seer.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
get_trade_balance
staticmethod
get_trade_balance(api_keys: APIKeys) -> USD
Source code in prediction_market_agent_tooling/markets/seer/seer.py
165 166 167 | |
get_tiny_bet_amount
get_tiny_bet_amount() -> CollateralToken
Source code in prediction_market_agent_tooling/markets/seer/seer.py
169 170 | |
get_position_else_raise
get_position_else_raise(
user_id: str, web3: Web3 | None = None
) -> ExistingPosition
Fetches position from the user in a given market. We ignore the INVALID balances since we are only interested in binary outcomes.
Source code in prediction_market_agent_tooling/markets/seer/seer.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
get_position
get_position(
user_id: str, web3: Web3 | None = None
) -> ExistingPosition | None
Source code in prediction_market_agent_tooling/markets/seer/seer.py
207 208 209 210 211 212 213 214 | |
get_user_id
staticmethod
get_user_id(api_keys: APIKeys) -> str
Source code in prediction_market_agent_tooling/markets/seer/seer.py
216 217 218 | |
redeem_winnings
staticmethod
redeem_winnings(api_keys: APIKeys) -> None
Source code in prediction_market_agent_tooling/markets/seer/seer.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | |
have_bet_on_market_since
have_bet_on_market_since(
keys: APIKeys, since: timedelta
) -> bool
Check if the user has placed a bet on this market since a specific time using Cow API.
Source code in prediction_market_agent_tooling/markets/seer/seer.py
285 286 287 288 289 290 291 292 293 294 295 296 297 | |
verify_operational_balance
staticmethod
verify_operational_balance(api_keys: APIKeys) -> bool
Source code in prediction_market_agent_tooling/markets/seer/seer.py
299 300 301 | |
from_data_model_with_subgraph
staticmethod
from_data_model_with_subgraph(
model: SeerMarket,
seer_subgraph: SeerSubgraphHandler,
must_have_prices: bool,
) -> t.Optional[SeerAgentMarket]
Source code in prediction_market_agent_tooling/markets/seer/seer.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
get_markets
staticmethod
get_markets(
limit: int,
sort_by: SortBy,
filter_by: FilterBy = FilterBy.OPEN,
created_after: Optional[DatetimeUTC] = None,
excluded_questions: set[str] | None = None,
fetch_categorical_markets: bool = False,
) -> t.Sequence[SeerAgentMarket]
Source code in prediction_market_agent_tooling/markets/seer/seer.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | |
get_outcome_str_from_idx
get_outcome_str_from_idx(outcome_index: int) -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/seer/seer.py
381 382 | |
get_liquidity_for_outcome
get_liquidity_for_outcome(
outcome: OutcomeStr, web3: Web3 | None = None
) -> CollateralToken
Liquidity per outcome is comprised of the balance of outcomeToken + collateralToken held by the pool itself (see https://github.com/seer-pm/demo/blob/7bfd0a062780ed6567f65714c4fc4f6e6cdf1c4f/web/netlify/functions/utils/fetchPools.ts#L35-L42).
Source code in prediction_market_agent_tooling/markets/seer/seer.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | |
get_liquidity
get_liquidity() -> CollateralToken
Source code in prediction_market_agent_tooling/markets/seer/seer.py
428 429 430 431 432 433 434 435 | |
has_liquidity_for_outcome
has_liquidity_for_outcome(outcome: OutcomeStr) -> bool
Source code in prediction_market_agent_tooling/markets/seer/seer.py
437 438 439 | |
has_liquidity
has_liquidity() -> bool
Source code in prediction_market_agent_tooling/markets/seer/seer.py
441 442 443 444 445 | |
get_wrapped_token_for_outcome
get_wrapped_token_for_outcome(
outcome: OutcomeStr,
) -> ChecksumAddress
Source code in prediction_market_agent_tooling/markets/seer/seer.py
447 448 449 | |
place_bet
place_bet(
outcome: OutcomeStr,
amount: USD,
auto_deposit: bool = True,
web3: Web3 | None = None,
api_keys: APIKeys | None = None,
) -> str
Source code in prediction_market_agent_tooling/markets/seer/seer.py
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 | |
sell_tokens
sell_tokens(
outcome: OutcomeStr,
amount: USD | OutcomeToken,
auto_withdraw: bool = True,
api_keys: APIKeys | None = None,
web3: Web3 | None = None,
) -> str
Sells the given number of shares for the given outcome in the given market.
Source code in prediction_market_agent_tooling/markets/seer/seer.py
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | |
get_token_balance
get_token_balance(
user_id: str,
outcome: OutcomeStr,
web3: Web3 | None = None,
) -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/seer/seer.py
575 576 577 578 579 580 581 582 583 584 585 | |
validate_probabilities
validate_probabilities(
probs: dict[OutcomeStr, Probability],
info: FieldValidationInfo,
) -> dict[OutcomeStr, Probability]
Source code in prediction_market_agent_tooling/markets/agent_market.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
validate_outcome_token_pool
validate_outcome_token_pool(
outcome_token_pool: dict[str, OutcomeToken] | None,
info: FieldValidationInfo,
) -> dict[str, OutcomeToken] | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
get_outcome_token_pool_by_outcome
get_outcome_token_pool_by_outcome(
outcome: OutcomeStr,
) -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
122 123 124 125 126 127 128 | |
handle_legacy_fee
handle_legacy_fee(data: dict[str, Any]) -> dict[str, t.Any]
Source code in prediction_market_agent_tooling/markets/agent_market.py
130 131 132 133 134 135 136 | |
market_outcome_for_probability_key
market_outcome_for_probability_key(
probability_key: OutcomeStr,
) -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/agent_market.py
138 139 140 141 142 143 144 145 146 | |
probability_for_market_outcome
probability_for_market_outcome(
market_outcome: OutcomeStr,
) -> Probability
Source code in prediction_market_agent_tooling/markets/agent_market.py
148 149 150 151 152 153 154 | |
get_last_trade_p_yes
get_last_trade_p_yes() -> Probability | None
Get the last trade price for the YES outcome. This can be different from the current p_yes, for example if market is closed and it's probabilities are fixed to 0 and 1. Could be None if no trades were made.
Source code in prediction_market_agent_tooling/markets/agent_market.py
195 196 197 198 199 200 | |
get_last_trade_p_no
get_last_trade_p_no() -> Probability | None
Get the last trade price for the NO outcome. This can be different from the current p_yes, for example if market is closed and it's probabilities are fixed to 0 and 1. Could be None if no trades were made.
Source code in prediction_market_agent_tooling/markets/agent_market.py
202 203 204 205 206 207 | |
get_last_trade_yes_outcome_price
get_last_trade_yes_outcome_price() -> (
CollateralToken | None
)
Source code in prediction_market_agent_tooling/markets/agent_market.py
209 210 211 212 213 214 | |
get_last_trade_yes_outcome_price_usd
get_last_trade_yes_outcome_price_usd() -> USD | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
216 217 218 219 | |
get_last_trade_no_outcome_price
get_last_trade_no_outcome_price() -> CollateralToken | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
221 222 223 224 225 226 | |
get_last_trade_no_outcome_price_usd
get_last_trade_no_outcome_price_usd() -> USD | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
228 229 230 231 | |
get_liquidatable_amount
get_liquidatable_amount() -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
233 234 235 | |
get_in_usd
get_in_usd(x: USD | CollateralToken) -> USD
Source code in prediction_market_agent_tooling/markets/agent_market.py
258 259 260 261 | |
get_in_token
get_in_token(x: USD | CollateralToken) -> CollateralToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
263 264 265 266 | |
liquidate_existing_positions
liquidate_existing_positions(outcome: OutcomeStr) -> None
Source code in prediction_market_agent_tooling/markets/agent_market.py
274 275 | |
buy_tokens
buy_tokens(outcome: OutcomeStr, amount: USD) -> str
Source code in prediction_market_agent_tooling/markets/agent_market.py
280 281 | |
compute_fpmm_probabilities
staticmethod
compute_fpmm_probabilities(
balances: list[OutcomeWei],
) -> list[Probability]
Compute the implied probabilities in a Fixed Product Market Maker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
balances
|
List[float]
|
Balances of outcome tokens. |
required |
Returns:
| Type | Description |
|---|---|
list[Probability]
|
List[float]: Implied probabilities for each outcome. |
Source code in prediction_market_agent_tooling/markets/agent_market.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
build_probability_map_from_p_yes
staticmethod
build_probability_map_from_p_yes(
p_yes: Probability,
) -> dict[OutcomeStr, Probability]
Source code in prediction_market_agent_tooling/markets/agent_market.py
321 322 323 324 325 326 327 328 | |
build_probability_map
staticmethod
build_probability_map(
outcome_token_amounts: list[OutcomeWei],
outcomes: list[OutcomeStr],
) -> dict[OutcomeStr, Probability]
Source code in prediction_market_agent_tooling/markets/agent_market.py
330 331 332 333 334 335 | |
get_binary_market
staticmethod
get_binary_market(id: str) -> AgentMarket
Source code in prediction_market_agent_tooling/markets/agent_market.py
348 349 350 | |
get_bets_made_since
staticmethod
get_bets_made_since(
better_address: ChecksumAddress, start_time: DatetimeUTC
) -> list[Bet]
Source code in prediction_market_agent_tooling/markets/agent_market.py
397 398 399 400 401 | |
get_resolved_bets_made_since
staticmethod
get_resolved_bets_made_since(
better_address: ChecksumAddress,
start_time: DatetimeUTC,
end_time: DatetimeUTC | None,
) -> list[ResolvedBet]
Source code in prediction_market_agent_tooling/markets/agent_market.py
403 404 405 406 407 408 409 | |
is_closed
is_closed() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
411 412 | |
is_resolved
is_resolved() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
414 415 | |
has_successful_resolution
has_successful_resolution() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
423 424 425 426 427 428 | |
has_unsuccessful_resolution
has_unsuccessful_resolution() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
430 431 | |
get_outcome_str_from_bool
staticmethod
get_outcome_str_from_bool(outcome: bool) -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/agent_market.py
433 434 435 | |
get_outcome_str
get_outcome_str(outcome_index: int) -> OutcomeStr
Source code in prediction_market_agent_tooling/markets/agent_market.py
437 438 439 440 441 442 443 | |
get_outcome_index
get_outcome_index(outcome: OutcomeStr) -> int
Source code in prediction_market_agent_tooling/markets/agent_market.py
445 446 447 448 449 450 | |
get_positions
classmethod
get_positions(
user_id: str,
liquid_only: bool = False,
larger_than: OutcomeToken = OutcomeToken(0),
) -> t.Sequence[ExistingPosition]
Get all non-zero positions a user has in any market.
If liquid_only is True, only return positions that can be sold.
If larger_than is not None, only return positions with a larger number
of tokens than this amount.
Source code in prediction_market_agent_tooling/markets/agent_market.py
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 | |
can_be_traded
can_be_traded() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
475 476 477 478 | |
get_user_url
classmethod
get_user_url(keys: APIKeys) -> str
Source code in prediction_market_agent_tooling/markets/agent_market.py
480 481 482 | |
has_token_pool
has_token_pool() -> bool
Source code in prediction_market_agent_tooling/markets/agent_market.py
484 485 | |
get_pool_tokens
get_pool_tokens(outcome: OutcomeStr) -> OutcomeToken
Source code in prediction_market_agent_tooling/markets/agent_market.py
487 488 489 490 491 | |
get_user_balance
staticmethod
get_user_balance(user_id: str) -> float
Source code in prediction_market_agent_tooling/markets/agent_market.py
493 494 495 | |
get_most_recent_trade_datetime
get_most_recent_trade_datetime(
user_id: str,
) -> DatetimeUTC | None
Source code in prediction_market_agent_tooling/markets/agent_market.py
501 502 | |
seer_create_market_tx
seer_create_market_tx(
api_keys: APIKeys,
initial_funds: USD | CollateralToken,
question: str,
opening_time: DatetimeUTC,
language: str,
outcomes: Sequence[OutcomeStr],
auto_deposit: bool,
category: str,
min_bond: xDai,
web3: Web3 | None = None,
) -> ChecksumAddress
Source code in prediction_market_agent_tooling/markets/seer/seer.py
588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 | |
extract_market_address_from_tx
extract_market_address_from_tx(
factory_contract: SeerMarketFactory,
tx_receipt: TxReceipt,
web3: Web3,
) -> ChecksumAddress
We extract the newly created market from the NewMarket event emitted in the transaction.
Source code in prediction_market_agent_tooling/markets/seer/seer.py
651 652 653 654 655 656 657 658 659 660 661 | |
seer_contracts
SeerMarketFactory
Bases: ContractOnGnosisChain
abi
class-attribute
instance-attribute
abi: ABI = abi_field_validator(
join(
dirname(realpath(__file__)),
"../../abis/seer_market_factory.abi.json",
)
)
address
class-attribute
instance-attribute
address: ChecksumAddress = to_checksum_address(
"0x83183da839ce8228e31ae41222ead9edbb5cdcf1"
)
CHAIN_ID
class-attribute
instance-attribute
CHAIN_ID = chain_id
build_market_params
staticmethod
build_market_params(
market_question: str,
outcomes: Sequence[OutcomeStr],
opening_time: DatetimeUTC,
min_bond: xDai,
language: str = "en_US",
category: str = "misc",
) -> CreateCategoricalMarketsParams
Source code in prediction_market_agent_tooling/markets/seer/seer_contracts.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
market_count
market_count(web3: Web3 | None = None) -> int
Source code in prediction_market_agent_tooling/markets/seer/seer_contracts.py
62 63 64 | |
market_at_index
market_at_index(
index: int, web3: Web3 | None = None
) -> ChecksumAddress
Source code in prediction_market_agent_tooling/markets/seer/seer_contracts.py
66 67 68 | |
collateral_token
collateral_token(
web3: Web3 | None = None,
) -> ChecksumAddress
Source code in prediction_market_agent_tooling/markets/seer/seer_contracts.py
70 71 72 | |
create_categorical_market
create_categorical_market(
api_keys: APIKeys,
params: CreateCategoricalMarketsParams,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/markets/seer/seer_contracts.py
74 75 76 77 78 79 80 81 82 83 84 85 86 | |
merge_contract_abis
classmethod
merge_contract_abis(
contracts: list[ContractBaseClass],
) -> ABI
Source code in prediction_market_agent_tooling/tools/contract.py
77 78 79 80 81 82 | |
get_web3_contract
get_web3_contract(web3: Web3 | None = None) -> Web3Contract
Source code in prediction_market_agent_tooling/tools/contract.py
84 85 86 | |
call
call(
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
web3: Web3 | None = None,
) -> t.Any
Used for reading from the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
send
send(
api_keys: APIKeys,
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
send_with_value
send_with_value(
api_keys: APIKeys,
function_name: str,
amount_wei: Wei,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract, including sending chain's native currency.
Source code in prediction_market_agent_tooling/tools/contract.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_transaction_count
classmethod
get_transaction_count(
for_address: ChecksumAddress,
) -> Nonce
Source code in prediction_market_agent_tooling/tools/contract.py
164 165 166 | |
get_web3
classmethod
get_web3() -> Web3
Source code in prediction_market_agent_tooling/tools/contract.py
168 169 170 | |
GnosisRouter
Bases: ContractOnGnosisChain
abi
class-attribute
instance-attribute
abi: ABI = abi_field_validator(
join(
dirname(realpath(__file__)),
"../../abis/seer_gnosis_router.abi.json",
)
)
address
class-attribute
instance-attribute
address: ChecksumAddress = to_checksum_address(
"0xeC9048b59b3467415b1a38F63416407eA0c70fB8"
)
CHAIN_ID
class-attribute
instance-attribute
CHAIN_ID = chain_id
redeem_to_base
redeem_to_base(
api_keys: APIKeys,
params: RedeemParams,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/markets/seer/seer_contracts.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
merge_contract_abis
classmethod
merge_contract_abis(
contracts: list[ContractBaseClass],
) -> ABI
Source code in prediction_market_agent_tooling/tools/contract.py
77 78 79 80 81 82 | |
get_web3_contract
get_web3_contract(web3: Web3 | None = None) -> Web3Contract
Source code in prediction_market_agent_tooling/tools/contract.py
84 85 86 | |
call
call(
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
web3: Web3 | None = None,
) -> t.Any
Used for reading from the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
send
send(
api_keys: APIKeys,
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
send_with_value
send_with_value(
api_keys: APIKeys,
function_name: str,
amount_wei: Wei,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract, including sending chain's native currency.
Source code in prediction_market_agent_tooling/tools/contract.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_transaction_count
classmethod
get_transaction_count(
for_address: ChecksumAddress,
) -> Nonce
Source code in prediction_market_agent_tooling/tools/contract.py
164 165 166 | |
get_web3
classmethod
get_web3() -> Web3
Source code in prediction_market_agent_tooling/tools/contract.py
168 169 170 | |
SwaprRouterContract
Bases: ContractOnGnosisChain
abi
class-attribute
instance-attribute
abi: ABI = abi_field_validator(
join(
dirname(realpath(__file__)),
"../../abis/swapr_router.abi.json",
)
)
address
class-attribute
instance-attribute
address: ChecksumAddress = to_checksum_address(
"0xffb643e73f280b97809a8b41f7232ab401a04ee1"
)
CHAIN_ID
class-attribute
instance-attribute
CHAIN_ID = chain_id
exact_input_single
exact_input_single(
api_keys: APIKeys,
params: ExactInputSingleParams,
web3: Web3 | None = None,
) -> TxReceipt
Source code in prediction_market_agent_tooling/markets/seer/seer_contracts.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
merge_contract_abis
classmethod
merge_contract_abis(
contracts: list[ContractBaseClass],
) -> ABI
Source code in prediction_market_agent_tooling/tools/contract.py
77 78 79 80 81 82 | |
get_web3_contract
get_web3_contract(web3: Web3 | None = None) -> Web3Contract
Source code in prediction_market_agent_tooling/tools/contract.py
84 85 86 | |
call
call(
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
web3: Web3 | None = None,
) -> t.Any
Used for reading from the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
send
send(
api_keys: APIKeys,
function_name: str,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract.
Source code in prediction_market_agent_tooling/tools/contract.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
send_with_value
send_with_value(
api_keys: APIKeys,
function_name: str,
amount_wei: Wei,
function_params: Optional[
list[Any] | dict[str, Any]
] = None,
tx_params: Optional[TxParams] = None,
timeout: int = 180,
web3: Web3 | None = None,
) -> TxReceipt
Used for changing a state (writing) to the contract, including sending chain's native currency.
Source code in prediction_market_agent_tooling/tools/contract.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_transaction_count
classmethod
get_transaction_count(
for_address: ChecksumAddress,
) -> Nonce
Source code in prediction_market_agent_tooling/tools/contract.py
164 165 166 | |
get_web3
classmethod
get_web3() -> Web3
Source code in prediction_market_agent_tooling/tools/contract.py
168 169 170 | |
seer_subgraph_handler
SeerSubgraphHandler
SeerSubgraphHandler()
Bases: BaseSubgraphHandler
Class responsible for handling interactions with Seer subgraphs.
Source code in prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py
36 37 38 39 40 41 42 43 44 45 46 47 48 | |
SEER_SUBGRAPH
class-attribute
instance-attribute
SEER_SUBGRAPH = "https://gateway-arbitrum.network.thegraph.com/api/{graph_api_key}/subgraphs/id/B4vyRqJaSHD8dRDb3BFRoAzuBK18c1QQcXq94JbxDxWH"
SWAPR_ALGEBRA_SUBGRAPH
class-attribute
instance-attribute
SWAPR_ALGEBRA_SUBGRAPH = "https://gateway-arbitrum.network.thegraph.com/api/{graph_api_key}/subgraphs/id/AAA1vYjxwFHzbt6qKwLHNcDSASyr1J1xVViDH8gTMFMR"
INVALID_ANSWER
class-attribute
instance-attribute
INVALID_ANSWER = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
seer_subgraph
instance-attribute
seer_subgraph = load_subgraph(
format(graph_api_key=get_secret_value())
)
swapr_algebra_subgraph
instance-attribute
swapr_algebra_subgraph = load_subgraph(
format(graph_api_key=get_secret_value())
)
sg
instance-attribute
sg = Subgrounds(timeout=timeout)
keys
instance-attribute
keys = APIKeys()
filter_bicategorical_markets
staticmethod
filter_bicategorical_markets(
markets: list[SeerMarket],
) -> list[SeerMarket]
Source code in prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py
72 73 74 75 | |
get_markets
get_markets(
filter_by: FilterBy,
sort_by: SortBy = SortBy.NONE,
limit: int | None = None,
outcome_supply_gt_if_open: Wei = Wei(0),
include_conditional_markets: bool = True,
include_categorical_markets: bool = True,
) -> list[SeerMarket]
Source code in prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
get_market_by_id
get_market_by_id(market_id: HexBytes) -> SeerMarket
Source code in prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py
192 193 194 195 196 197 198 199 200 | |
get_pool_by_token
get_pool_by_token(
token_address: ChecksumAddress,
collateral_address: ChecksumAddress,
) -> SeerPool | None
Source code in prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |
do_query
do_query(
fields: list[FieldPath], pydantic_model: Type[T]
) -> list[T]
Source code in prediction_market_agent_tooling/markets/base_subgraph_handler.py
47 48 49 50 51 | |
subgraph_data_models
SeerToken
Bases: BaseModel
id
instance-attribute
id: HexBytes
name
instance-attribute
name: str
symbol
instance-attribute
symbol: str
SeerPool
Bases: BaseModel
model_config
class-attribute
instance-attribute
model_config = ConfigDict(populate_by_name=True)
id
instance-attribute
id: HexBytes
liquidity
instance-attribute
liquidity: int
token0
instance-attribute
token0: SeerToken
token1
instance-attribute
token1: SeerToken
token0Price
instance-attribute
token0Price: CollateralToken
token1Price
instance-attribute
token1Price: CollateralToken
sqrtPrice
instance-attribute
sqrtPrice: int
NewMarketEvent
Bases: BaseModel
market
instance-attribute
market: HexAddress
marketName
instance-attribute
marketName: str
parentMarket
instance-attribute
parentMarket: HexAddress
conditionId
instance-attribute
conditionId: HexBytes
questionId
instance-attribute
questionId: HexBytes
questionsIds
instance-attribute
questionsIds: list[HexBytes]
CreateCategoricalMarketsParams
Bases: BaseModel
model_config
class-attribute
instance-attribute
model_config = ConfigDict(populate_by_name=True)
market_name
class-attribute
instance-attribute
market_name: str = Field(..., alias='marketName')
outcomes
instance-attribute
outcomes: list[OutcomeStr]
question_start
class-attribute
instance-attribute
question_start: str = Field(
alias="questionStart", default=""
)
question_end
class-attribute
instance-attribute
question_end: str = Field(alias='questionEnd', default='')
outcome_type
class-attribute
instance-attribute
outcome_type: str = Field(alias='outcomeType', default='')
parent_outcome
class-attribute
instance-attribute
parent_outcome: int = Field(
alias="parentOutcome", default=0
)
parent_market
class-attribute
instance-attribute
parent_market: HexAddress = Field(
alias="parentMarket", default=ADDRESS_ZERO
)
category
instance-attribute
category: str
lang
instance-attribute
lang: str
lower_bound
class-attribute
instance-attribute
lower_bound: int = Field(alias='lowerBound', default=0)
upper_bound
class-attribute
instance-attribute
upper_bound: int = Field(alias='upperBound', default=0)
min_bond
class-attribute
instance-attribute
min_bond: int = Field(..., alias='minBond')
opening_time
class-attribute
instance-attribute
opening_time: int = Field(..., alias='openingTime')
token_names
class-attribute
instance-attribute
token_names: list[str] = Field(..., alias='tokenNames')
SeerParentMarket
Bases: BaseModel
id
instance-attribute
id: HexBytes
swap_pool_handler
SwapPoolHandler
SwapPoolHandler(
api_keys: APIKeys,
market_id: str,
collateral_token_address: ChecksumAddress,
seer_subgraph: SeerSubgraphHandler | None = None,
)
Source code in prediction_market_agent_tooling/markets/seer/swap_pool_handler.py
25 26 27 28 29 30 31 32 33 34 35 | |
api_keys
instance-attribute
api_keys = api_keys
market_id
instance-attribute
market_id = market_id
collateral_token_address
instance-attribute
collateral_token_address = collateral_token_address
seer_subgraph
instance-attribute
seer_subgraph = seer_subgraph or SeerSubgraphHandler()
buy_or_sell_outcome_token
buy_or_sell_outcome_token(
amount_wei: Wei,
token_in: ChecksumAddress,
token_out: ChecksumAddress,
web3: Web3 | None = None,
) -> TxReceipt
Buys/sells outcome_tokens in exchange for collateral tokens
Source code in prediction_market_agent_tooling/markets/seer/swap_pool_handler.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |