Skip to content

Commit

Permalink
use offline reward calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzii committed Sep 19, 2024
1 parent 7d0c7d8 commit 2a55f4f
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions prediction_market_agent_tooling/jobs/omen/omen_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
ProbabilisticAnswer,
TradeType,
)
from prediction_market_agent_tooling.gtypes import Probability, xdai_type
from prediction_market_agent_tooling.gtypes import Probability
from prediction_market_agent_tooling.jobs.jobs_models import JobAgentMarket
from prediction_market_agent_tooling.markets.omen.omen import (
BetAmount,
OmenAgentMarket,
OmenMarket,
)
Expand All @@ -20,7 +21,6 @@
OmenSubgraphHandler,
SortBy,
)
from prediction_market_agent_tooling.tools.web3_utils import wei_to_xdai, xdai_to_wei


class OmenJobAgentMarket(OmenAgentMarket, JobAgentMarket):
Expand Down Expand Up @@ -82,8 +82,6 @@ def from_omen_agent_market(market: OmenAgentMarket) -> "OmenJobAgentMarket":
def compute_job_reward(
market: OmenAgentMarket, max_bond: float, web3: Web3 | None = None
) -> float:
market_contract = market.get_contract()

# Because jobs are powered by prediction markets, potentional reward depends on job's liquidity and our will to bond (bet) our xDai into our job completion.
required_trades = KellyBettingStrategy(max_bet_amount=max_bond).calculate_trades(
existing_position=None,
Expand All @@ -102,15 +100,14 @@ def compute_job_reward(
trade.amount.currency == Currency.xDai
), "Should work only on real-money markets."

bet_amount = xdai_type(trade.amount.amount)

# TODO: Use after merged https://github.com/gnosis/prediction-market-agent-tooling/pull/415.
outcome_tokens = market_contract.calcBuyAmount(
investment_amount=xdai_to_wei(bet_amount),
outcome_index=market.yes_index if trade.outcome else market.no_index,
web3=web3,
reward = (
market.get_buy_token_amount(
bet_amount=BetAmount(
amount=trade.amount.amount, currency=trade.amount.currency
),
direction=trade.outcome,
).amount
- trade.amount.amount
)

reward = xdai_type(wei_to_xdai(outcome_tokens) - bet_amount)

return reward

0 comments on commit 2a55f4f

Please sign in to comment.