# Usage Guide

## Using Natural Language

Agentic Trading is designed to be used through natural language: you tell your agent what you want to do, and it handles the SDK calls, contract interactions, and error handling for you. This page covers what you can do and how to do it.

{% hint style="info" %}
For the underlying code-level details (type definitions, parameter schemas, contract methods, GraphQL queries), see the [Delphi SDK documentation.](/tech/delphi-sdk.md)
{% endhint %}

### Asking your Agent to Do Things

Once you've completed the [Getting Started](/tech/agentic-trading/get-started.md) setup, open your agent and start with natural language. Here are the core capabilities:

#### Browse & Research Markets

* *"Show me the open prediction markets"*
* *"List crypto markets"*
* *"What's the current price and probability on \[market name]?"*
* *"Get me the details for market \[id]"*

The agent can list markets, filter by status or category, and fetch live on-chain prices and implied probabilities for any market.

#### Trade

* *"Buy 10 shares of outcome 0 on \[market address]"*
* *"How much would it cost to buy 5 shares of outcome 1?"*
* *"Sell all my shares in \[market address]"*
* *"Quote a sell for 20 shares of outcome 0"*

The agent handles the full trade flow automatically: quoting the cost, ensuring token approval, applying slippage protection, and executing the transaction. You can also ask for a quote first without committing.

#### Manage Positions

* *"What are my current positions?"*
* *"Show me my active positions that haven't been redeemed"*
* *"Redeem my winnings from \[market address]"*
* *"Redeem all my settled positions"*

The agent can list your holdings, filter out zero-share positions, and handle both single and batch redemptions.

#### Query Trade History

* *"Show me recent trades for \[market address]"*
* *"What buys happened in the last 24 hours?"*
* *"Has \[market address] been settled? Who won?"*

The agent queries the Goldsky subgraph for historical on-chain events including buys, sells, redemptions, liquidations, and winner submissions.

#### Manage Token Approvals

* *"Check my token allowance for \[market address]"*
* *"Approve unlimited USDC spending for \[market address]"*

In most cases you won't need to manage approvals manually, since the agent handles this automatically before trades. But you can check or set approvals explicitly if needed.

{% hint style="warning" %}
Agents cannot create markets. Markets *must* be created through the Delphi UI.&#x20;

**Markets created outside the UI will not appear in the interface.**
{% endhint %}

### Example Scripts

The `scripts/` folder in the skills repo contains working TypeScript examples for every common operation.&#x20;

These serve two purposes: **\[1]** agents can reference or run them directly, and **\[2]** you can use them to test your setup or run operations outside of an agent conversation.

| Script                          | Purpose                              | Usage                                                                                   |
| ------------------------------- | ------------------------------------ | --------------------------------------------------------------------------------------- |
| `scripts/list-markets.ts`       | List and filter markets              | `npx tsx scripts/list-markets.ts [status] [category] [limit]`                           |
| `scripts/get-market.ts`         | Get details for a specific market    | `npx tsx scripts/get-market.ts <market-id>`                                             |
| `scripts/quote-buy.ts`          | Get buy quote (read-only)            | `npx tsx scripts/quote-buy.ts <market-address> <outcome-idx> <shares>`                  |
| `scripts/quote-sell.ts`         | Get sell quote (read-only)           | `npx tsx scripts/quote-sell.ts <market-address> <outcome-idx> <shares>`                 |
| `scripts/buy-shares.ts`         | Buy shares (on-chain)                | `npx tsx scripts/buy-shares.ts <market-address> <outcome-idx> <shares> [slippage-pct]`  |
| `scripts/sell-shares.ts`        | Sell shares (on-chain)               | `npx tsx scripts/sell-shares.ts <market-address> <outcome-idx> <shares> [slippage-pct]` |
| `scripts/list-positions.ts`     | List wallet positions                | `npx tsx scripts/list-positions.ts [wallet-address]`                                    |
| `scripts/redeem.ts`             | Redeem winnings from settled markets | `npx tsx scripts/redeem.ts <market-address>`                                            |
| `scripts/token-approval.ts`     | Check or set token approval          | `npx tsx scripts/token-approval.ts <market-address> [amount]`                           |
| `scripts/list-recent-trades.ts` | List recent trades via subgraph      | `npx tsx scripts/list-recent-trades.ts <market-proxy-address> [limit]`                  |

All scripts use the shared client setup from `scripts/client.ts` which handles environment variable configuration automatically. You can also run them via npm scripts: `npm run list-markets`, `npm run buy-shares`, etc.

{% hint style="info" %}
Before trying to run any scripts, make sure you've completed the [Getting Started setup](/tech/agentic-trading/get-started.md) and you have all required dependencies installed *and* the `.env` file configured.
{% endhint %}

### Going Deeper

If you want to write custom integrations or understand the code-level details behind what the agent is doing, the [Delphi SDK](/tech/delphi-sdk.md) documentation covers everything:

* [Configuration](/tech/delphi-sdk/configuration.md): Environment variables, signing modes, network defaults
* [API Reference](/tech/delphi-sdk/api.md): Market and position types, filtering, pagination, redemption patterns
* [On-Chain Methods](/tech/delphi-sdk/methods.md): Trading mechanics, slippage, Gateway contract reference, token approvals
* [Subgraph](/tech/delphi-sdk/subgraph.md): GraphQL schema, entity types, filtering operators, raw query examples


---

# 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.gensyn.ai/tech/agentic-trading/usage-guide.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.
