> ## 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>
  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="Data Cubes" icon="cubes" href="/ko/graphql/schema/cubes">
    Prediction Market Cube의 필드 구조 상세.
  </Card>

  <Card title="Chain Groups" icon="layer-group" href="/ko/graphql/schema/chain-groups">
    Prediction Cube는 EVM 전용이며, 주로 Polygon에서 사용합니다.
  </Card>
</CardGroup>
