# Protocol Level Entities

## Introduction

These queries can be used to get Superform-specific protocol data across the various modules.

## Core Concepts

### SuperRegistry

SuperRegistry maintains a single source of truth for the various deployments of the contracts in the protocol within the chain. It keeps looking for various events which set or update contract addresses and maintains that in a single entity. To get the protocol deployments, use the ID `"protocolDeployedAddress"` with a query like this-

```graphql
{
  superRegistry (id:"protocolDeployedAddress"){
    chainID
    superRouterAddress
    superformFactoryAddress
    superRBACAddress
    superPositionsAddress
    payMasterAddress
    coreStateRegistryAddress
    paymentAdminAddress
    paymentHelperAddress
    payloadHelperAddress
    twoStepsRegistryProcessor
    coreRegistryUpdaterAddress
    coreRegistryProcessorAddress
    superTransmuterAddress
    timelockStateRegistryAddress
    broadcastRegistryAddress
    broadcastRegistryProcessorAddress
    permit2Address
    
    stateRegistries(first:5){
      chainId
      address
    }
    bridgeValidatorAddress(first:5){
      bridgeValidatorId
      bridgeValidatorAddress
    }
    bridgeAddress(first:5){
      bridgeId
      bridgeAddress
    }
    ambAddress(first:5){
      ambId
      ambAddress
    }
    quorumsRequired(first:5){
      srcChainId
      quorumRequired
    }
    routers(first:5){
      superFormRouterId
      stateSyncerAddress
      routerAddress
    }
  }
}
```

The fields can be explained as follows-

1. `chainID-` Chain ID on which the SuperRegistry is deployed
2. `stateRegistryAddress-` This maintains the latest Address of the State registry Smart Contract
3. `superformFactoryAddress-` This maintains the latest Address of the Superform Factory Smart Contract which helps in deployment of forms and Superforms.
4. `superPositionsAddress-` This maintains the latest Address of the SuperPositions Smart Contract which mints and maintains the SuperPositions
5. `superRBACAddress-` This maintains the latest Address of the SuperRBAC Smart Contract which help in the Role Based Access of the Protocol
6. `superRouterAddress-` This maintains the latest Address of the SuperRouter Smart Contract which routes the deposits and withdrawals for both same chain and cross chain transactions
7. `payMasterAddress-` This maintains the latest Address of the PayMaster Smart Contract which helps in paying for gases for the users
8. `coreStateRegistryAddress-` This maintains the latest Address of the Core State Registry Smart Contract.
9. `paymentAdminAddress-`  This maintains the latest Address of the Payment Admin Smart Contract which helps the PayMaster Smart Contract.
10. `paymentHelperAddress-`  This maintains the latest Address of the Payment Helper Smart Contract which helps the PayMaster Smart Contract.
11. `payloadHelperAddress-` This maintains the latest address of Payload Helper Smart Contract which helps in decoding various payloads on destination chain.
12. `twoStepsRegistryProcessor-` This maintains the latest Address of the Two Steps Registry Smart Contract.
13. `coreRegistryUpdaterAddress-` This maintains the latest Address of the Core Registry Updater Smart Contract.
14. `permit2Address-` This maintains the latest Address of the Permit2 Smart Contract.
15. `coreRegistryProcessorAddress-` This maintains the latest Address of the Core Registry Processor Smart Contract.
16. `coreRegistryProcessorUpdater-` This maintains the latest Address of the Core Registry Updater Smart Contract.
17. `superTransmuterAddress-` This maintains the latest Address of the SuperTransmuter Smart Contract.
18. `timelockStateRegistryAddress-` This maintains the latest Address of the Timelock State Registry Smart Contract.
19. `broadcastRegistryAddress-` This maintains the latest Address of the Broadcasting Registry Smart Contract.
20. `broadcastRegistryProcessorAddress-` This maintains the latest Address of the Broadcast Registry Processor Smart Contract.
21. `quorumsRequired-` This is a list quorums required for messages of different source chains. The fields of quorumsRequired are-
    1. `srcChainId-` Chain ID of the chain from where messages are coming
    2. `quorumRequired-` Quorum Required for the chain mentioned by it
22. `routers-` This is a list of SuperFormRouters deployed in the protocol. Each `router` has the following fields-
    1. `superFormRouterId-` ID of the SuperFormRouter
    2. `address-` Address of the contract on the specific chain
23. `bridgeValidatorAddress-` This is a list of Bridge Validator Smart Contracts. Each `bridgeValidator` has the following fields-
    1. `Id-` ID of the specific Bridge Validator
    2. `stateSyncerAddress-` Address of the stateSyncer contract
    3. `routerAddress-` Address of the SuperFormRouter contract
24. `bridgeAddress-` This is a list of Bridge Smart Contracts Available for the chain. Each `bridge` has the following fields-
    1. `Id-` ID of the specific Bridge
    2. `address-` Address of the contract for the Bridge On The Chain
25. `ambAddress-` This is a list of AMB Smart Contracts Deployed on the chain. Each `AMB` has the following fields-
    1. `ambId-` ID of the specific Bridge
    2. `ambAddress-` Address of the contract for the AMB On The Chain

Also apart from querying SuperRegistry in the specified manner, each `quorumsRequired`, `routers`, `bridgeValidatorAddress`, `bridgeAddress` and `ambAddress` can be queried individually in a manner like this-

```graphql
{
  quorumsRequired(first:5){
    srcChainId
    quorumRequired
  }
  bridgeAddresses (first:5) {
    bridgeId
    bridgeAddress
  }
  ambAddress (ambId: 1){
    ambId
    ambAddress
  }
  routers(first:5){
    superFormRouterId
    stateSyncerAddress
    routerAddress
  }
}
```

### Protocol Metrics

Protocol Metrics keeps a track of some of the critical protocol wide metrices. Various flows keep updating the fields within ProtocolMetrics and they can be queried using ID `"protocolUniversalMetrics"` and a query like this-

```graphql
{
  protocolMetrics (id:"protocolUniversalMetrics"){
    totalSuperformsCreated
    totalBeaconFormsCreated
    totalxChainTransactions
    totalSingleChainTransactions
  }
}
```

The fields within ProtocolMetrics are as follows-

1. `totalSuperformsCreated-` This is the total number of superforms that have been created in the chain
2. `totalBeaconFormsCreated-` This is the total number of forms that have been created in the chain
3. `totalxChainTransactions-` Total number of Cross Chain Transactions (deposits/ withdrawals) that been created from the specified chain
4. `totalSingleChainTransactions-` Total number of Same Chain Transactions (deposits/ withdrawals) that been completed in the specified chain
