Skip to content

Commit

Permalink
Add script for betting on omen
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzii committed Feb 11, 2024
1 parent f0b069b commit 51c1fd4
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[mypy]
python_version = 3.9
files = prediction_market_agent_tooling/, tests/, examples/
files = prediction_market_agent_tooling/, tests/, examples/, scripts/
plugins = pydantic.mypy
warn_redundant_casts = True
warn_unused_ignores = True
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ description = "Tools to benchmark, deploy and monitor prediction market agents."
authors = ["Gnosis"]
readme = "README.md"

[tool.poetry.scripts]
buy_omen = "scripts.bet_omen:buy"
sell_omen = "scripts.bet_omen:sell"

[tool.poetry.dependencies]
python = ">=3.9,<3.12"
typer = "^0.9.0"
Expand Down
86 changes: 86 additions & 0 deletions scripts/bet_omen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import typer
from prediction_market_agent_tooling.tools.web3_utils import verify_address
from prediction_market_agent_tooling.markets.omen import (
omen_buy_outcome_tx,
get_market,
omen_sell_outcome_tx,
)
from prediction_market_agent_tooling.gtypes import (
PrivateKey,
xdai_type,
)
from eth_typing import HexStr

app = typer.Typer()


@app.command()
def buy(
amount: str = typer.Option(),
from_address: str = typer.Option(),
from_private_key: str = typer.Option(),
market_id: str = typer.Option(),
outcome: str = typer.Option(),
auto_deposit: bool = typer.Option(False),
) -> None:
"""
Helper script to place a bet on Omen, usage:
```bash
python scripts/bet_omen.py buy \
--amount 0.01 \
--from-address your-address \
--from-private-key your-private-key \
--market-id some-market-id \
--outcome one-of-the-outcomes
```
Market ID can be found easily in the URL: https://aiomen.eth.limo/#/0x86376012a5185f484ec33429cadfa00a8052d9d4
"""
market = get_market(market_id)
omen_buy_outcome_tx(
amount=xdai_type(amount),
from_address=verify_address(from_address),
from_private_key=PrivateKey(from_private_key),
market=market,
outcome=outcome,
auto_deposit=auto_deposit,
)


@app.command()
def sell(
amount: str = typer.Option(),
from_address: str = typer.Option(),
from_private_key: str = typer.Option(),
market_id: str = typer.Option(),
outcome: str = typer.Option(),
auto_withdraw: bool = typer.Option(False),
) -> None:
"""
Helper script to sell outcome of an existing bet on Omen, usage:
```bash
python scripts/bet_omen.py sell \
--amount 0.01 \
--from-address your-address \
--from-private-key your-private-key \
--market-id some-market-id \
--outcome one-of-the-outcomes
```
Market ID can be found easily in the URL: https://aiomen.eth.limo/#/0x86376012a5185f484ec33429cadfa00a8052d9d4
"""
market = get_market(market_id)
omen_sell_outcome_tx(
amount=xdai_type(amount),
from_address=verify_address(from_address),
from_private_key=PrivateKey(from_private_key),
market=market,
outcome=outcome,
auto_withdraw=auto_withdraw,
)


if __name__ == "__main__":
app()

0 comments on commit 51c1fd4

Please sign in to comment.