> ## 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 は予測市場データ用に 3 つの Cube を提供しており、主に Polygon で利用できます。これらの Cube は、予測市場のライフサイクル全体（作成・取引・決済）をカバーします。

<Note>
  Prediction Market Cube は **EVM** Chain Group で利用できます。主に `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 }
      }
    }
  }
}
```

### 特定の Condition に紐づく取引

```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 }
        }
      }
    }
  }
}
```

### 特定の Holder の決済

```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="/jp/graphql/schema/cubes">
    Prediction Market Cube のフィールド構造の詳細。
  </Card>

  <Card title="チェーングループ" icon="layer-group" href="/jp/graphql/schema/chain-groups">
    Prediction Cube は EVM のみで、主に Polygon 上で利用します。
  </Card>
</CardGroup>
