> ## Documentation Index
> Fetch the complete documentation index at: https://docs.goldsky.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Indexing Polymarket with Goldsky

<Note>
  On **April 28, 2026**, Polymarket migrated to a v2 set of contracts and is no longer using subgraphs going forward. Existing public subgraph endpoints will return incomplete or incorrect data. **Turbo Pipelines** with the v2 Polymarket datasets are the recommended way to access on-chain Polymarket data.
</Note>

## Overview

Goldsky provides high-performance data infrastructure for Polymarket, making it easy to extract, transform, and load on-chain data to power both application and analytics use cases via [Turbo Pipelines](/turbo-pipelines/introduction) (real-time data replication pipelines).

Polymarket is the world's largest prediction market platform, enabling users to trade on the outcome of real-world events. Built on Polygon, Polymarket processes millions of trades and provides deep liquidity for markets spanning politics, sports, economics, and more.

## Benefits

Goldsky's Polymarket integration enables:

* **Real-time market monitoring** - Track order fills, matched orders, and position changes as they happen
* **Analytics and insights** - Build dashboards showing open interest, trading volume, and market trends
* **User position tracking** - Monitor individual user balances and positions with PnL data
* **Trading activity analysis** - Analyze granular order flow and market maker activity
* **Custom alerts** - Set up webhooks for specific market events or trading patterns

## Getting started

To use Goldsky, you'll need to create an account, install the CLI, and log in.

<Accordion title="Install Goldsky's CLI and log in">
  1. Install the Goldsky CLI:

     **For macOS/Linux:**

     ```shell theme={null}
     curl https://goldsky.com | sh
     ```

     **For Windows:**

     ```shell theme={null}
     npm install -g @goldskycom/cli
     ```

     <Note>Windows users need to have Node.js and npm installed first. Download from [nodejs.org](https://nodejs.org) if not already installed.</Note>
  2. Go to your [Project Settings](https://app.goldsky.com/dashboard/settings) page and create an API key.
  3. Back in your Goldsky CLI, log into your Project by running the command `goldsky login` and paste your API key.
  4. Now that you are logged in, run `goldsky` to get started:
     ```shell theme={null}
     goldsky
     ```
</Accordion>

### Turbo Pipelines

Turbo pipelines allow users to replicate data into their own infrastructure (any of the [supported sinks](/turbo-pipelines/sinks)) in real time. For a complete overview of how to deploy Turbo pipelines, including a video walkthrough, check the [Quickstart guide](/turbo-pipelines/quickstart).

### Working with Polymarket datasets

Goldsky provides real-time streaming of Polymarket datasets, including all historical data.

The following datasets are currently available:

| Dataset                          | Description                                                                                                                                                                                                                                                                                                                           |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Order Filled (*recommended*)** | Emitted when a single Polymarket order is partially or completely filled. For example: a 50¢ YES buy for 100 YES matched against a 50¢ YES sell for 100 YES will emit 2 Order Filled events, from the perspective of the YES buy and of the YES sell. This is useful for granular tracking of trading activity and history.           |
| **Orders Matched**               | Emitted when a Polymarket taker order is matched against a set of Polymarket maker (limit) orders. For example: a 50¢ YES buy for 200 YES matched against 2 50¢ YES sells for 100 YES each will emit a single Orders Matched event. Orders Matched gives a more high-level view of trading activity as it only tracks taker activity. |
| **User Balances**                | Keeps track of all user outcome token positions.                                                                                                                                                                                                                                                                                      |
| **User Positions**               | Keeps track of outcome token positions along with PnL-specific data including average price and realized PnL.                                                                                                                                                                                                                         |

These datasets can be used as sources in your Turbo pipelines to stream Polymarket data to any of the supported sinks.

#### Dataset schemas

<AccordionGroup>
  <Accordion title="polymarket.order_filled">
    | Column             | Type   | Description                                |
    | ------------------ | ------ | ------------------------------------------ |
    | `id`               | string | Unique event identifier                    |
    | `block_number`     | long   | Block number of the event                  |
    | `block_timestamp`  | long   | Unix timestamp of the block                |
    | `transaction_hash` | string | Transaction hash                           |
    | `address`          | string | Contract address that emitted the event    |
    | `user_id`          | string | Address of the user whose order was filled |
    | `asset`            | string | Token ID of the outcome token              |
    | `amount_usdc`      | double | USDC value of the fill                     |
    | `amount_shares`    | double | Number of outcome token shares filled      |
    | `price`            | double | Fill price (between 0 and 1)               |
    | `tx_type`          | string | Transaction type (e.g. `TRADE`)            |
    | `side`             | string | Order side (`BUY` or `SELL`)               |
    | `order_hash`       | string | Hash of the order                          |
    | `counterparty_id`  | string | Address of the counterparty                |
    | `order_type`       | string | Whether this order was `maker` or `taker`  |
    | `fee`              | double | Fee paid for this fill                     |
    | `builder`          | string | Builder address if applicable              |
  </Accordion>

  <Accordion title="polymarket.orders_matched">
    | Column             | Type   | Description                                  |
    | ------------------ | ------ | -------------------------------------------- |
    | `id`               | string | Unique event identifier                      |
    | `block_number`     | long   | Block number of the event                    |
    | `block_timestamp`  | long   | Unix timestamp of the block                  |
    | `transaction_hash` | string | Transaction hash                             |
    | `address`          | string | Contract address that emitted the event      |
    | `user_id`          | string | Address of the taker                         |
    | `asset`            | string | Token ID of the outcome token                |
    | `amount_usdc`      | double | Total USDC value of the matched trade        |
    | `amount_shares`    | double | Total number of outcome token shares matched |
    | `price`            | double | Effective price (between 0 and 1)            |
    | `tx_type`          | string | Transaction type (e.g. `TRADE`)              |
    | `side`             | string | Taker order side (`BUY` or `SELL`)           |
    | `order_hash`       | string | Hash of the taker order                      |
  </Accordion>

  <Accordion title="polymarket.user_balances">
    | Column             | Type    | Description                       |
    | ------------------ | ------- | --------------------------------- |
    | `id`               | string  | Unique balance record identifier  |
    | `owner_address`    | string  | Address of the token holder       |
    | `contract_address` | string  | ERC-1155 contract address         |
    | `token_id`         | string  | Outcome token ID                  |
    | `token_type`       | string  | Token standard (e.g. `ERC_1155`)  |
    | `block_number`     | long    | Block number of the last update   |
    | `block_timestamp`  | long    | Unix timestamp of the last update |
    | `balance`          | decimal | Current token balance             |
  </Accordion>

  <Accordion title="polymarket.user_positions">
    | Column         | Type    | Description                                              |
    | -------------- | ------- | -------------------------------------------------------- |
    | `vid`          | long    | Internal version ID                                      |
    | `block_range`  | string  | Block range for which this record is valid               |
    | `id`           | string  | Unique position identifier (`{user_address}-{token_id}`) |
    | `user`         | string  | Address of the user                                      |
    | `token_id`     | decimal | Outcome token ID                                         |
    | `amount`       | decimal | Current position size                                    |
    | `avg_price`    | decimal | Average entry price                                      |
    | `realized_pnl` | decimal | Realized profit and loss                                 |
    | `total_bought` | decimal | Total amount bought                                      |
    | `_gs_chain`    | string  | Chain identifier (e.g. `matic`)                          |
    | `_gs_gid`      | string  | Goldsky internal graph ID                                |
  </Accordion>
</AccordionGroup>

#### Deploying Polymarket pipelines

Turbo pipelines are defined using YAML configuration files and deployed via the Goldsky CLI. Here's the workflow:

1. **Create a pipeline configuration file** - Define your sources, transforms, and sinks in a YAML file
2. **Validate your configuration** - Run `goldsky turbo validate polymarket-pipeline.yaml` to check for errors
3. **Deploy the pipeline** - Run `goldsky turbo apply polymarket-pipeline.yaml` to deploy
4. **Monitor your pipeline** - Use `goldsky turbo logs polymarket-pipeline.yaml` to view logs and `goldsky turbo inspect polymarket-pipeline.yaml` to see live data

For a complete walkthrough, see the [Turbo Pipelines Quickstart](/turbo-pipelines/quickstart).

<Note>
  Remember to first create a [Secret](/mirror/manage-secrets) in order for Turbo Pipelines to be able to write the data into the database of your choice. For webhook sinks, you can include authentication headers directly in the configuration.
</Note>

#### Example pipeline configuration

Here's an example configuration file for streaming Polymarket order fills to a webhook endpoint, using the v2 dataset and a block number range to backfill a specific period:

```yaml polymarket-orders-webhook.yaml theme={null}
name: polymarket-orders-webhook
resource_size: s

sources:
  order_filled:
    type: dataset
    dataset_name: polymarket.order_filled
    version: 2.0.0
    start_at: earliest
    filter: block_number >= 42598795 AND block_number <= 42835303

transforms:
  high_value_orders:
    type: sql
    primary_key: id
    sql: |
      SELECT 
        id,
        block_number,
        block_timestamp,
        transaction_hash,
        user_id,
        asset,
        side,
        price,
        amount_usdc,
        amount_shares
      FROM order_filled
      WHERE amount_usdc > 1000

sinks:
  webhook_alerts:
    type: webhook
    from: high_value_orders
    url: https://api.example.com/polymarket/orders
    one_row_per_request: true
    headers:
      Authorization: Bearer YOUR_API_TOKEN
      Content-Type: application/json
```

This pipeline:

1. Streams Order Filled events from the v2 Polymarket dataset for a specific block range
2. Filters for high-value orders (amount\_usdc > 1000)
3. Sends each order individually to your webhook endpoint with authentication

Deploy the pipeline by running:

```bash theme={null}
goldsky turbo apply polymarket-orders-webhook.yaml
```

<Note>
  Fast scan is supported on the v2 Polymarket datasets, so you can backfill a specific period using a `block_number` range filter as shown above. Filtering by timestamp is not supported for fast scan — use `block_number` instead.
</Note>

***Note***:

The datasets output large amounts of data. E.g. user positions may be up to 1.2B entities to backfill, and up to 150M entities monthly to maintain.

For insights on costs for datasets, please refer to our [pricing calculator](https://goldsky.com/pricing#pricing-calculator).

## Getting support

Can't find what you're looking for? Reach out to us at [support@goldsky.com](mailto:support@goldsky.com) for help.
