diff --git a/mypy.ini b/mypy.ini index 67a9420d..b1c51378 100644 --- a/mypy.ini +++ b/mypy.ini @@ -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 diff --git a/pyproject.toml b/pyproject.toml index e6dd9e3c..338b288b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/scripts/bet_omen.py b/scripts/bet_omen.py new file mode 100644 index 00000000..5779746f --- /dev/null +++ b/scripts/bet_omen.py @@ -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()