# Use OpenBook

The `Use OpenBook` tool, part of AgentiPy, allows users to interact with the OpenBook decentralized exchange protocol on Solana. The primary function exposed in this manager is the creation of new trading markets. This operation is routed through an Agentipy proxy service. (Note: The filename is `use_openpook.py`, which is likely a typo for OpenBook).

## Functionality

This tool is implemented in the `OpenBookManager` class. It interacts with an Agentipy proxy service (`agent.base_proxy_url`) to perform actions related to OpenBook. The agent's private key is encrypted and sent to this proxy, and an OpenAI API key (`agent.openai_api_key`) also seems to be part of the payload.

### Key Methods:

* `create_market(agent: SolanaAgentKit, base_mint: str, quote_mint: str, lot_size: Optional[float] = 1, tick_size: Optional[float] = 0.01) -> Optional[Dict[str, Any]]`:
  * Creates a new market on the OpenBook DEX.
  * Parameters:
    * `agent`: The `SolanaAgentKit` instance.
    * `base_mint`: The mint address (string) of the base asset for the market (e.g., the token being traded).
    * `quote_mint`: The mint address (string) of the quote asset (e.g., USDC, SOL).
    * `lot_size`: (Optional) The minimum order quantity for the base asset, also known as base lot size (default is 1).
    * `tick_size`: (Optional) The minimum price increment for the market, also known as quote tick size (default is 0.01).
  * Sends a request to the Agentipy proxy endpoint (`/openbook-create-market`).
  * Returns a dictionary with the transaction details from the proxy or an error. The response likely contains the new market ID and transaction signatures.

##

**Important Considerations:**

* **Proxy Service:** This tool relies on an Agentipy proxy service. The availability, authentication (including the role of the OpenAI API key), and terms of use for this proxy are critical.
* **On-Chain Action & Costs:** Creating an OpenBook market is a complex on-chain operation that involves multiple transactions and will incur significant SOL fees (for rent of accounts like event queue, request queue, order books).
* **Market Parameters:** Correctly setting `lot_size` and `tick_size` is crucial for a functional market and depends on the expected price and trading characteristics of the token pair. Incorrect values can lead to an unusable market.
* **OpenBook Program:** Users should be familiar with the OpenBook DEX program and its requirements for market creation.

## Source Code

You can find the source code for this tool on GitHub: <https://github.com/niceberginc/agentipy/blob/main/agentipy/tools/use_openpook.py> (Note the typo in the filename in the repository).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.agentipy.fun/tools/use-openbook.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
