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

# 預測市場

> PredictionTrades、PredictionManagements 與 PredictionSettlements Cubes 的查詢範例

## 概述

ChainStream GraphQL 提供三個用於預測市場資料的 Cube，主要覆蓋 Polygon。這些 Cube 覆蓋預測市場從建立、交易到結算的完整生命週期。

<Note>
  預測市場 Cube 位於 **EVM** 鏈組中，通常與 `network: polygon` 一起使用。
</Note>

***

## PredictionTrades

### 近期預測市場交易

```graphql theme={null}
query {
  EVM(network: polygon) {
    PredictionTrades(
      limit: {count: 20}
      orderBy: {descending: Block_Time}
    ) {
      Block { Time }
      Transaction { Hash }
      Trade {
        Buyer
        Seller
        Amount
        Price
        Fee
      }
      Prediction {
        Condition { Id Outcomes }
        Question { Id }
        Outcome
        Marketplace { ProtocolName }
      }
    }
  }
}
```

### 指定條件的交易

```graphql theme={null}
query {
  EVM(network: polygon) {
    PredictionTrades(
      conditionId: {is: "CONDITION_ID"}
      limit: {count: 50}
      orderBy: {descending: Block_Time}
    ) {
      Block { Time }
      Trade { Buyer Seller Amount Price }
      Prediction { Outcome OutcomeToken { SmartContract } }
    }
  }
}
```

### 按交易平臺的成交量

```graphql theme={null}
query {
  EVM(network: polygon) {
    PredictionTrades(
      marketplace: {is: "Polymarket"}
      limit: {count: 100}
      orderBy: {descending: Block_Time}
    ) {
      Block { Time }
      Trade { Amount Price }
      Prediction {
        Question { Id }
        Marketplace { ProtocolName }
      }
      count
      sum(of: Trade_Amount)
    }
  }
}
```

***

## PredictionManagements

### 市場建立與結算事件

```graphql theme={null}
query {
  EVM(network: polygon) {
    PredictionManagements(
      limit: {count: 20}
      orderBy: {descending: Block_Time}
    ) {
      Block { Time }
      Transaction { Hash }
      Management {
        EventType
        Description
        Group
        Prediction {
          Condition { Id }
          Question { Id }
          Marketplace { ProtocolName }
        }
      }
    }
  }
}
```

### 按事件型別篩選

```graphql theme={null}
query {
  EVM(network: polygon) {
    PredictionManagements(
      eventType: {is: "ConditionResolution"}
      limit: {count: 20}
      orderBy: {descending: Block_Time}
    ) {
      Block { Time }
      Management {
        EventType
        Description
        Prediction { Condition { Id Outcomes } }
      }
    }
  }
}
```

***

## PredictionSettlements

### 近期結算

```graphql theme={null}
query {
  EVM(network: polygon) {
    PredictionSettlements(
      limit: {count: 20}
      orderBy: {descending: Block_Time}
    ) {
      Block { Time }
      Transaction { Hash }
      Settlement {
        EventType
        Holder
        OutcomeTokenIds
        Amounts
        Prediction {
          Condition { Id }
          CollateralToken { SmartContract Symbol }
          Marketplace { ProtocolName }
        }
      }
    }
  }
}
```

### 指定持有人的結算

```graphql theme={null}
query {
  EVM(network: polygon) {
    PredictionSettlements(
      holder: {is: "0xHOLDER_ADDRESS"}
      limit: {count: 50}
      orderBy: {descending: Block_Time}
    ) {
      Block { Time }
      Settlement {
        EventType
        Amounts
        Prediction { Condition { Id } }
      }
    }
  }
}
```

***

## 相關文件

<CardGroup cols={2}>
  <Card title="資料 Cube" icon="cubes" href="/zh-Hant/graphql/schema/cubes">
    預測市場 Cube 的詳細欄位結構。
  </Card>

  <Card title="鏈組" icon="layer-group" href="/zh-Hant/graphql/schema/chain-groups">
    預測類 Cube 僅支援 EVM，主要在 Polygon 上。
  </Card>
</CardGroup>
