Usage Guide

What you can ask the agent to do, example prompts, and available scripts.

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.

For the underlying code-level details (type definitions, parameter schemas, contract methods, GraphQL queries), see the Delphi SDK documentation.

Asking your Agent to Do Things

Once you've completed the Getting Started 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.

Example Scripts

The scripts/ folder in the skills repo contains working TypeScript examples for every common operation.

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.

Before trying to run any scripts, make sure you've completed the Getting Started setup and you have all required dependencies installed and the .env file configured.

Going Deeper

If you want to write custom integrations or understand the code-level details behind what the agent is doing, the Delphi SDK documentation covers everything:

  • Configuration: Environment variables, signing modes, network defaults

  • API Reference: Market and position types, filtering, pagination, redemption patterns

  • On-Chain Methods: Trading mechanics, slippage, Gateway contract reference, token approvals

  • Subgraph: GraphQL schema, entity types, filtering operators, raw query examples

Last updated