fragment DataSource on DataSourceDefinition {
  sourceType {
    ... on DataSourceDefinitionExternal {
      sourceType {
        ... on DataSourceSpecConfiguration {
          signers {
            signer {
              ... on PubKey {
                key
              }
              ... on ETHAddress {
                address
              }
            }
          }
        }
      }
    }
    ... on DataSourceDefinitionInternal {
      sourceType {
        ... on DataSourceSpecConfigurationTime {
          conditions {
            operator
            value
          }
        }
      }
    }
  }
}

query MarketInfo($marketId: ID!) {
  market(id: $marketId) {
    id
    decimalPlaces
    positionDecimalPlaces
    state
    tradingMode
    lpPriceRange
    proposal {
      id
      rationale {
        title
        description
      }
    }
    marketTimestamps {
      open
      close
    }
    openingAuction {
      durationSecs
      volume
    }
    accountsConnection {
      edges {
        node {
          type
          asset {
            id
          }
          balance
        }
      }
    }
    fees {
      factors {
        makerFee
        infrastructureFee
        liquidityFee
      }
    }
    priceMonitoringSettings {
      parameters {
        triggers {
          horizonSecs
          probability
          auctionExtensionSecs
        }
      }
    }
    riskFactors {
      market
      short
      long
    }
    liquidityMonitoringParameters {
      triggeringRatio
      targetStakeParameters {
        timeWindow
        scalingFactor
      }
    }
    tradableInstrument {
      instrument {
        id
        name
        code
        metadata {
          tags
        }
        product {
          ... on Future {
            quoteName
            settlementAsset {
              id
              symbol
              name
              decimals
            }
            dataSourceSpecForSettlementData {
              id
              data {
                ...DataSource
              }
            }
            dataSourceSpecForTradingTermination {
              id
              data {
                ...DataSource
              }
            }
            dataSourceSpecBinding {
              settlementDataProperty
              tradingTerminationProperty
            }
          }
        }
      }
      riskModel {
        ... on LogNormalRiskModel {
          tau
          riskAversionParameter
          params {
            r
            sigma
            mu
          }
        }
        ... on SimpleRiskModel {
          params {
            factorLong
            factorShort
          }
        }
      }
      marginCalculator {
        scalingFactors {
          searchLevel
          initialMargin
          collateralRelease
        }
      }
    }
  }
}
