Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions typescript/.changeset/fresh-memes-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@coinbase/agentkit": patch
---

Added TrueMarkets action provider for retrieving prediction market info
13 changes: 13 additions & 0 deletions typescript/agentkit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,19 @@ const agent = createReactAgent({
</table>
</details>
<details>
<summary><strong>TrueMarkets</strong></summary>
<table width="100%">
<tr>
<td width="200"><code>get_active_markets</code></td>
<td width="768">Retrieves active prediction markets from Truemarkets with pagination and sorting options.</td>
</tr>
<tr>
<td width="200"><code>get_market_details</code></td>
<td width="768">Fetches comprehensive details for a specific Truemarkets prediction market including question, status, prices, and liquidity.</td>
</tr>
</table>
</details>
<details>
<summary><strong>Wallet</strong></summary>
<table width="100%">
<tr>
Expand Down
1 change: 1 addition & 0 deletions typescript/agentkit/src/action-providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export * from "./moonwell";
export * from "./morpho";
export * from "./opensea";
export * from "./spl";
export * from "./truemarkets";
export * from "./twitter";
export * from "./wallet";
export * from "./weth";
Expand Down
46 changes: 46 additions & 0 deletions typescript/agentkit/src/action-providers/truemarkets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# TrueMarkets Action Provider

This directory contains the **TrueMarketsActionProvider** implementation, which provides actions to interact with **Truemarkets** prediction markets on Base.

## Directory Structure

```
truemarkets/
├── truemarketsActionProvider.ts # Main provider with Truemarkets functionality
├── truemarketsActionProvider.test.ts # Test file for Truemarkets provider
├── constants.ts # Constants and ABIs for Truemarkets contracts
├── schemas.ts # Truemarkets action schemas
├── index.ts # Main exports
└── README.md # This file
```

## Actions

- `get_active_markets`: Get active prediction markets from Truemarkets
- Returns a list of markets with their ID, contract address, and market question
- Supports pagination and sorting options

- `get_market_details`: Get detailed information for a specific market
- Takes a market address as input
- Returns comprehensive market information including:
- Market question, source, and status
- Pool addresses and liquidity
- YES/NO token prices
- Pool balances and TVL (Total Value Locked)

## Adding New Actions

To add new Truemarkets actions:

1. Define your action schema in `schemas.ts`
2. Implement the action in `truemarketsActionProvider.ts`
3. Implement tests in `truemarketsActionProvider.test.ts`

## Network Support

The Truemarkets provider currently supports:
- Base Mainnet

## Notes

Truemarkets is a prediction market platform built on Base. For more information, see the [Truemarkets website](https://truemarkets.org/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { parseAbiItem } from "viem";

// Simplified ABIs
export const TruthMarketABI = [
parseAbiItem("function marketQuestion() view returns (string)"),
parseAbiItem("function marketSource() view returns (string)"),
parseAbiItem("function getCurrentStatus() view returns (uint8)"),
parseAbiItem("function endOfTrading() view returns (uint256)"),
parseAbiItem("function getPoolAddresses() view returns (address yesPool, address noPool)"),
parseAbiItem("function paymentToken() view returns (address)"),
parseAbiItem("function additionalInfo() view returns (string)"),
parseAbiItem("function winningPosition() view returns (uint8)"),
];

export const TruthMarketManagerABI = [
parseAbiItem("function numberOfActiveMarkets() view returns (uint256)"),
parseAbiItem("function getActiveMarketAddress(uint256) view returns (address)"),
parseAbiItem("function creatorAddress(address) view returns (address)"),
parseAbiItem("function resolverAddress(address) view returns (address)"),
];

export const UniswapV3PoolABI = [
parseAbiItem("function liquidity() view returns (uint128)"),
parseAbiItem(
"function slot0() view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked)",
),
parseAbiItem("function token0() view returns (address)"),
parseAbiItem("function token1() view returns (address)"),
];

export const TruthMarketManager_ADDRESS = "0x61A98Bef11867c69489B91f340fE545eEfc695d7";
export const USDC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
export const TYD_ADDRESS = "0xb13CF163d916917d9cD6E836905cA5f12a1dEF4B";
export const USDC_DECIMALS = 6;
export const TYD_DECIMALS = 6;
export const YESNO_DECIMALS = 18;

/**
* Market status enum
*/
export const MarketStatus = {
Created: 0,
OpenForResolution: 1,
ResolutionProposed: 2,
DisputeRaised: 3,
SetByCouncil: 4,
ResetByCouncil: 5,
EscalatedDisputeRaised: 6,
Finalized: 7,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./truemarketsActionProvider";
28 changes: 28 additions & 0 deletions typescript/agentkit/src/action-providers/truemarkets/schemas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { z } from "zod";

/**
* Input schema for get active markets action.
*/
export const GetTruthMarketsSchema = z
.object({
limit: z
.number()
.optional()
.describe("Maximum number of markets to return (default: 10)")
.default(10),
offset: z.number().optional().describe("Number of markets to skip (for pagination)").default(0),
sortOrder: z
.enum(["asc", "desc"])
.optional()
.describe("Sort order for the markets (default: desc)")
.default("desc"),
})
.strip()
.describe("Instructions for getting prediction markets on Truemarkets");

/**
* Input schema for get market details action.
*/
export const GetTruthMarketDetailsSchema = z
.string()
.describe("Prediction market address (0x...) or market ID (number) to retrieve details for");
Loading
Loading