Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

496 seer market creation on pmat #606

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

gabrielfior
Copy link
Contributor

No description provided.

@gabrielfior gabrielfior linked an issue Feb 4, 2025 that may be closed by this pull request
@gabrielfior gabrielfior requested a review from kongzii February 4, 2025 20:41
Copy link

coderabbitai bot commented Feb 4, 2025

Walkthrough

This pull request extends the Seer module by refining the data models and contract interactions for categorical market creation. It introduces a new Pydantic model for market creation parameters, updates the SeerMarket class with additional fields and type adjustments, and adds a new contract class with methods to create and count markets. Furthermore, the subgraph handler has been modified for clarity, a new CLI script has been added to facilitate market creation, and related integration tests have been updated and added.

Changes

File(s) Change Summary
prediction_market_agent_tooling/markets/seer/data_models.py - Added new class CreateCategoricalMarketsParams for categorical market creation.
- Updated SeerMarket: added new field parent_outcome (alias parentOutcome) and changed parent_market type to optional.
prediction_market_agent_tooling/markets/seer/seer_contracts.py - Added new class SeerMarketFactory with methods to build market parameters, count markets, and create categorical markets.
prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py - Renamed method get_pools_for_market to get_swapr_pools_for_market.
- Added field markets_field.parentOutcome in _get_fields_for_markets to extend retrieved market data.
scripts/create_market_seer.py - Introduced a new CLI script using Typer to facilitate market creation on the Omen platform, processing parameters and logging confirmations.
tests_integration/markets/seer/test_seer_subgraph_handler.py - Updated test to call the renamed method get_swapr_pools_for_market instead of the old name.
tests_integration_with_local_chain/markets/seer/test_seer_contracts.py - Added integration tests for Seer contracts to verify market creation via the updated SeerMarketFactory.
prediction_market_agent_tooling/markets/seer/seer.py - Added new function seer_create_market_tx for creating a market on the Seer platform.
prediction_market_agent_tooling/monitor/monitor.py - Removed a comment related to type-checking in the monitor_market_outcome_bias function.
prediction_market_agent_tooling/monitor/monitor_app.py - Simplified the handling of the start_time variable in the monitor_app function.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant CLI as Create Market CLI Script
    participant MF as SeerMarketFactory
    participant BC as Blockchain/Gnosis Contract

    U->>CLI: Provide market parameters
    CLI->>CLI: Process parameters and instantiate APIKeys
    CLI->>MF: Call create_categorical_market(api_keys, params)
    MF->>BC: Send transaction to create market
    BC-->>MF: Return transaction receipt
    MF-->>CLI: Return confirmation of market creation
    CLI-->>U: Log confirmation message
Loading

Possibly related PRs

  • Force DatetimeUTC everywhere #456: The changes in the main PR, which introduce a new class and modify fields in the SeerMarket class, are related to the retrieved PR as both involve the use of the DatetimeUTC type for datetime handling, ensuring consistency across the codebase.

Suggested reviewers

  • kongzii

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (4)
tests_integration_with_local_chain/markets/seer/test_seer_contracts.py (1)

12-22: Consider parameterizing the market creation parameters.

The hardcoded values in build_params limit test coverage. Consider parameterizing these values to test different scenarios.

-def build_params() -> CreateCategoricalMarketsParams:
+def build_params(
+    token_names: list[str] = ["YES", "NO"],
+    min_bond: int = int(1e18),
+    outcomes: list[str] = ["Yes", "No"],
+    market_name: str = "test test test"
+) -> CreateCategoricalMarketsParams:
     opening_time = int(
         (datetime.datetime.utcnow() + datetime.timedelta(days=1)).timestamp()
     )
     return CreateCategoricalMarketsParams(
-        token_names=["YES", "NO"],
-        min_bond=str(int(1e18)),
+        token_names=token_names,
+        min_bond=str(min_bond),
         openingTime=opening_time,
-        outcomes=["Yes", "No"],
-        market_name="test test test",
+        outcomes=outcomes,
+        market_name=market_name,
     )
prediction_market_agent_tooling/markets/seer/data_models.py (1)

46-49: Consider adding validation for parent_outcome.

The parent_outcome field might benefit from value validation to ensure it's non-negative.

-    parent_outcome: int = Field(alias="parentOutcome")
+    parent_outcome: int = Field(alias="parentOutcome", ge=0)
scripts/create_market_seer.py (2)

21-21: Address the TODO comment to adapt the script for Seer.

The script currently uses Omen-specific functionality and needs to be adapted for Seer.

Would you like me to help implement the Seer-specific changes? This would involve:

  1. Updating imports to use Seer-specific modules
  2. Modifying the market creation parameters
  3. Updating the documentation

41-42: Update script name in documentation.

The example command shows incorrect script name.

-    python scripts/create_market_omen.py \
+    python scripts/create_market_seer.py \
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 939fa84 and 116a8df.

⛔ Files ignored due to path filters (5)
  • poetry.lock is excluded by !**/*.lock, !**/*.lock
  • prediction_market_agent_tooling/abis/seer_market_factory.abi.json is excluded by !**/*.json
  • prediction_market_agent_tooling/abis/seer_realitio_3_0.abi.json is excluded by !**/*.json
  • prediction_market_agent_tooling/abis/seer_wrapper_1155_factory.abi.json is excluded by !**/*.json
  • pyproject.toml is excluded by !**/*.toml
📒 Files selected for processing (6)
  • prediction_market_agent_tooling/markets/seer/data_models.py (2 hunks)
  • prediction_market_agent_tooling/markets/seer/seer_contracts.py (1 hunks)
  • prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py (2 hunks)
  • scripts/create_market_seer.py (1 hunks)
  • tests_integration/markets/seer/test_seer_subgraph_handler.py (1 hunks)
  • tests_integration_with_local_chain/markets/seer/test_seer_contracts.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
tests_integration_with_local_chain/markets/seer/test_seer_contracts.py

29-29: Local variable tx_receipt is assigned to but never used

Remove assignment to unused variable tx_receipt

(F841)

scripts/create_market_seer.py

26-26: Do not perform function call typer.Option in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


34-34: Do not perform function call typer.Option in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: pytest - Python 3.12.x - Integration with Local Chain
  • GitHub Check: pytest - Python 3.12.x - Unit Tests
  • GitHub Check: pytest - Python 3.11.x - Integration with Local Chain
  • GitHub Check: pytest - Python 3.11.x - Unit Tests
  • GitHub Check: pytest - Python 3.10.x - Integration with Local Chain
  • GitHub Check: pytest - Python 3.10.x - Unit Tests
  • GitHub Check: mypy
🔇 Additional comments (7)
prediction_market_agent_tooling/markets/seer/data_models.py (1)

10-33: LGTM! Well-structured data model with proper type hints.

The class is well-designed with:

  • Clear field aliases for JSON serialization
  • Proper type hints and optional fields
  • Sensible default values
tests_integration/markets/seer/test_seer_subgraph_handler.py (1)

51-62: LGTM! Test updated to use renamed method.

The test correctly uses the renamed method get_swapr_pools_for_market and maintains the same validation logic.

prediction_market_agent_tooling/markets/seer/seer_contracts.py (3)

24-24: Reminder: Address the TODO comment.

Please ensure that tests are added to verify that the same functionality is supported as in the parent class.

Do you want me to generate the unit testing code or open a new issue to track this task?


39-39: Reminder: Address the TODO comment.

Please specify which functions need to be added to this class.

Do you want me to help identify the missing functions from the contract ABI or open a new issue to track this task?


53-53: Reminder: Address the TODO comment.

Please specify which functions need to be added to this class.

Do you want me to help identify the missing functions from the contract ABI or open a new issue to track this task?

prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py (2)

49-49: LGTM!

The addition of parentOutcome field enhances the market data model by including parent outcome information.


130-130: LGTM!

The method rename from get_pools_for_market to get_swapr_pools_for_market improves clarity by being more specific about the type of pools being fetched.

Comment on lines 25 to 34
def test_create_market(local_web3: Web3, test_keys: APIKeys) -> None:
factory = MarketFactory()
num_initial_markets = factory.market_count(web3=local_web3)
params = build_params()
tx_receipt = factory.create_categorical_market(
api_keys=test_keys, params=params, web3=local_web3
)

num_final_markets = factory.market_count(web3=local_web3)
assert num_initial_markets + 1 == num_final_markets
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove unused variable and add error handling.

The test should handle potential transaction failures and verify the transaction receipt.

 def test_create_market(local_web3: Web3, test_keys: APIKeys) -> None:
     factory = MarketFactory()
     num_initial_markets = factory.market_count(web3=local_web3)
     params = build_params()
-    tx_receipt = factory.create_categorical_market(
+    factory.create_categorical_market(
         api_keys=test_keys, params=params, web3=local_web3
     )

     num_final_markets = factory.market_count(web3=local_web3)
     assert num_initial_markets + 1 == num_final_markets
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def test_create_market(local_web3: Web3, test_keys: APIKeys) -> None:
factory = MarketFactory()
num_initial_markets = factory.market_count(web3=local_web3)
params = build_params()
tx_receipt = factory.create_categorical_market(
api_keys=test_keys, params=params, web3=local_web3
)
num_final_markets = factory.market_count(web3=local_web3)
assert num_initial_markets + 1 == num_final_markets
def test_create_market(local_web3: Web3, test_keys: APIKeys) -> None:
factory = MarketFactory()
num_initial_markets = factory.market_count(web3=local_web3)
params = build_params()
factory.create_categorical_market(
api_keys=test_keys, params=params, web3=local_web3
)
num_final_markets = factory.market_count(web3=local_web3)
assert num_initial_markets + 1 == num_final_markets
🧰 Tools
🪛 Ruff (0.8.2)

29-29: Local variable tx_receipt is assigned to but never used

Remove assignment to unused variable tx_receipt

(F841)

Comment on lines 24 to 36
def main(
question: str = typer.Option(),
closing_time: datetime = typer.Option(),
category: str = typer.Option(),
initial_funds: str = typer.Option(),
from_private_key: str = typer.Option(),
safe_address: str = typer.Option(None),
cl_token: CollateralTokenChoice = CollateralTokenChoice.sdai,
fee_perc: float = typer.Option(OMEN_DEFAULT_MARKET_FEE_PERC),
language: str = typer.Option("en"),
outcomes: list[str] = typer.Option(OMEN_BINARY_MARKET_OUTCOMES),
auto_deposit: bool = typer.Option(False),
) -> None:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix function calls in argument defaults.

Using function calls in argument defaults can lead to unexpected behavior.

 def main(
-    question: str = typer.Option(),
-    closing_time: datetime = typer.Option(),
-    category: str = typer.Option(),
-    initial_funds: str = typer.Option(),
-    from_private_key: str = typer.Option(),
-    safe_address: str = typer.Option(None),
+    question: str = None,
+    closing_time: datetime = None,
+    category: str = None,
+    initial_funds: str = None,
+    from_private_key: str = None,
+    safe_address: str = None,
     cl_token: CollateralTokenChoice = CollateralTokenChoice.sdai,
-    fee_perc: float = typer.Option(OMEN_DEFAULT_MARKET_FEE_PERC),
+    fee_perc: float = OMEN_DEFAULT_MARKET_FEE_PERC,
     language: str = typer.Option("en"),
-    outcomes: list[str] = typer.Option(OMEN_BINARY_MARKET_OUTCOMES),
+    outcomes: list[str] = None,
-    auto_deposit: bool = typer.Option(False),
+    auto_deposit: bool = False,
 ) -> None:

Then, add the options inside the function:

def main(
    # ... parameters as shown above ...
) -> None:
    question = typer.Option(question)
    closing_time = typer.Option(closing_time)
    category = typer.Option(category)
    initial_funds = typer.Option(initial_funds)
    from_private_key = typer.Option(from_private_key)
    safe_address = typer.Option(safe_address)
    fee_perc = typer.Option(fee_perc)
    outcomes = typer.Option(outcomes or OMEN_BINARY_MARKET_OUTCOMES)
    auto_deposit = typer.Option(auto_deposit)
🧰 Tools
🪛 Ruff (0.8.2)

26-26: Do not perform function call typer.Option in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


34-34: Do not perform function call typer.Option in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)

)
return receipt_tx

# ToDo - Also return event NewMarket, emitted by this contract
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Implement event handling for NewMarket event.

The TODO comment indicates that the NewMarket event emitted by the contract should be handled. This event likely contains important information about the created market.

Consider updating the create_categorical_market method to parse and return the event data:

 def create_categorical_market(
     self,
     api_keys: APIKeys,
     params: CreateCategoricalMarketsParams,
     web3: Web3 | None = None,
 ) -> TxReceipt:
     receipt_tx = self.send(
         api_keys=api_keys,
         function_name="createCategoricalMarket",
         function_params=[params.model_dump(by_alias=True)],
         web3=web3,
     )
+    # Parse NewMarket event from receipt
+    new_market_event = self.get_event_from_receipt(receipt_tx, "NewMarket")
+    if not new_market_event:
+        raise ValueError("NewMarket event not found in transaction receipt")
     return receipt_tx
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# ToDo - Also return event NewMarket, emitted by this contract
def create_categorical_market(
self,
api_keys: APIKeys,
params: CreateCategoricalMarketsParams,
web3: Web3 | None = None,
) -> TxReceipt:
receipt_tx = self.send(
api_keys=api_keys,
function_name="createCategoricalMarket",
function_params=[params.model_dump(by_alias=True)],
web3=web3,
)
# Parse NewMarket event from receipt
new_market_event = self.get_event_from_receipt(receipt_tx, "NewMarket")
if not new_market_event:
raise ValueError("NewMarket event not found in transaction receipt")
return receipt_tx

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (4)
prediction_market_agent_tooling/markets/seer/seer.py (3)

18-29: Add a docstring for the new function.

It's helpful to document the purpose, parameters, and return value for future reference and ease of understanding.


47-50: Handle the scenario where shares could be zero.

If get_in_shares returns 0, depositing an insufficient amount of collateral might lead to errors when the market is created. Consider adding logic to handle or warn about this situation.


72-72: Address the TODO for liquidity provisioning.

The comment references adding liquidity on Swapr. Let me know if you'd like a helper function or script to facilitate this integration.

prediction_market_agent_tooling/markets/seer/data_models.py (1)

10-33: Add validations for numeric fields.

Consider enforcing non-negative constraints on fields like lower_bound, upper_bound, and opening_time (e.g., future-only markets). This can make your model more robust against invalid inputs.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 116a8df and 513f95e.

📒 Files selected for processing (7)
  • prediction_market_agent_tooling/markets/seer/data_models.py (2 hunks)
  • prediction_market_agent_tooling/markets/seer/seer.py (1 hunks)
  • prediction_market_agent_tooling/markets/seer/seer_contracts.py (1 hunks)
  • prediction_market_agent_tooling/monitor/monitor.py (1 hunks)
  • prediction_market_agent_tooling/monitor/monitor_app.py (2 hunks)
  • scripts/create_market_seer.py (1 hunks)
  • tests_integration_with_local_chain/markets/seer/test_seer_contracts.py (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • prediction_market_agent_tooling/monitor/monitor.py
🧰 Additional context used
🪛 Ruff (0.8.2)
scripts/create_market_seer.py

18-18: Do not perform function call typer.Option in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


23-23: Do not perform function call typer.Option in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


23-23: Do not perform function call xdai_type in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


25-25: Do not perform function call typer.Option in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)

prediction_market_agent_tooling/markets/seer/seer_contracts.py

41-41: Do not perform function call xdai_type in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)

tests_integration_with_local_chain/markets/seer/test_seer_contracts.py

27-27: Local variable tx_receipt is assigned to but never used

Remove assignment to unused variable tx_receipt

(F841)

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: pytest - Python 3.12.x - Integration with Local Chain
  • GitHub Check: pytest - Python 3.12.x - Unit Tests
  • GitHub Check: pytest - Python 3.11.x - Integration with Local Chain
  • GitHub Check: pytest - Python 3.11.x - Unit Tests
  • GitHub Check: pytest - Python 3.10.x - Integration with Local Chain
  • GitHub Check: pytest - Python 3.10.x - Unit Tests
🔇 Additional comments (8)
prediction_market_agent_tooling/markets/seer/seer.py (1)

39-46: Consider verifying deposit success.

After calling auto_deposit_collateral_token, you might want to check the updated balance or validate the transaction's success to gracefully handle any deposit failures.

tests_integration_with_local_chain/markets/seer/test_seer_contracts.py (1)

27-29: Remove or utilize the unused tx_receipt variable.

This local variable isn’t used and triggers a linting warning. You could verify tx_receipt.status to ensure the transaction succeeded or omit storing it if it isn't needed.

🧰 Tools
🪛 Ruff (0.8.2)

27-27: Local variable tx_receipt is assigned to but never used

Remove assignment to unused variable tx_receipt

(F841)

prediction_market_agent_tooling/markets/seer/data_models.py (1)

46-49: Ensure consistent parent/child outcome relationships.

When setting parent_outcome and parent_market, consider validating that the given outcome index is valid for the specified market to prevent mismatched or invalid hierarchical references.

scripts/create_market_seer.py (2)

17-26: Fix function calls in argument defaults.

Using function calls in argument defaults can lead to unexpected behavior.

Apply this diff to fix the issue:

 def main(
-    question: str = typer.Option(),
-    opening_time: datetime = typer.Option(),
-    category: str = typer.Option(),
-    initial_funds: str = typer.Option(),
-    from_private_key: str = typer.Option(),
-    safe_address: str = typer.Option(None),
-    min_bond_xdai: xDai = typer.Option(xdai_type(10)),
-    language: str = typer.Option("en"),
-    outcomes: list[str] = typer.Option(OMEN_BINARY_MARKET_OUTCOMES),
-    auto_deposit: bool = typer.Option(False),
+    question: str = None,
+    opening_time: datetime = None,
+    category: str = None,
+    initial_funds: str = None,
+    from_private_key: str = None,
+    safe_address: str = None,
+    min_bond_xdai: xDai = None,
+    language: str = "en",
+    outcomes: list[str] = None,
+    auto_deposit: bool = False,

Then, add the options inside the function:

def main(
    # ... parameters as shown above ...
) -> None:
    question = typer.Option(question)
    opening_time = typer.Option(opening_time)
    category = typer.Option(category)
    initial_funds = typer.Option(initial_funds)
    from_private_key = typer.Option(from_private_key)
    safe_address = typer.Option(safe_address)
    min_bond_xdai = typer.Option(min_bond_xdai or xdai_type(10))
    outcomes = typer.Option(outcomes or OMEN_BINARY_MARKET_OUTCOMES)
    auto_deposit = typer.Option(auto_deposit)
🧰 Tools
🪛 Ruff (0.8.2)

18-18: Do not perform function call typer.Option in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


23-23: Do not perform function call typer.Option in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


23-23: Do not perform function call xdai_type in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


25-25: Do not perform function call typer.Option in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)


40-58: LGTM! The implementation looks good.

The function correctly:

  • Converts safe address to checksum format
  • Creates API keys with proper validation
  • Calls seer_create_market_tx with all required parameters
  • Logs the created market
prediction_market_agent_tooling/markets/seer/seer_contracts.py (2)

83-83: Implement event handling for NewMarket event.

The TODO comment indicates that the NewMarket event emitted by the contract should be handled.

Would you like me to help implement the event handling code to parse and return the event data from the transaction receipt?


24-68: LGTM! The implementation looks good.

The class correctly:

  • Loads ABI from JSON file
  • Sets contract address
  • Implements utility methods for market operations
🧰 Tools
🪛 Ruff (0.8.2)

41-41: Do not perform function call xdai_type in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)

prediction_market_agent_tooling/monitor/monitor_app.py (1)

108-110: LGTM! The changes look good.

The code correctly:

  • Simplifies start_time handling by directly using st.date_input result
  • Maintains proper date/time combination logic

market_question: str,
outcomes: list[str],
opening_time: DatetimeUTC,
min_bond_xdai: xDai = xdai_type(10),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Fix function call in argument defaults.

Using function calls in argument defaults can lead to unexpected behavior.

Apply this diff to fix the issue:

-    min_bond_xdai: xDai = xdai_type(10),
+    min_bond_xdai: xDai | None = None,

Then, add the default inside the function:

def build_market_params(
    # ... parameters as shown above ...
) -> CreateCategoricalMarketsParams:
    min_bond_xdai = min_bond_xdai or xdai_type(10)
    return CreateCategoricalMarketsParams(
        # ... rest of the implementation ...
    )
🧰 Tools
🪛 Ruff (0.8.2)

41-41: Do not perform function call xdai_type in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)

@gabrielfior gabrielfior marked this pull request as draft February 4, 2025 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Seer market creation on PMAT
1 participant