# Contracts API

The contracts are upgradable, following the Open Zeppelin Proxy Upgrade Pattern. Each contract will be explained in brief detail below.

ConsumerHost

Host services for consumers, allowing consumers to use the PAYG faster and better.

EraManager

Produce epochs based on a period to coordinate contracts.

IndexerRegistry

The IndexerRegistry contract store and track all registered Indexers and related status for these Indexers. It also provide the entry for Indexers to register, unregister, and config their metedata.

InflationController

The InflationController contract mint the inflation SQT token to a set address at a set inflation rate. It also provide the manual way to mint SQT Token to admin.

PermissionedExchange

For now, PermissionedExchange contract allows traders trade their SQTs on admin sent orders, later on we may allow others to send their orders. Controllers may set the trade quota for trader, and trader cannot trade over the their quota. It provides a way for indexers to swap their rewards(SQT) to stable token with a fixed exchange rate.

PlanManager

The Plan Manager Contract tracks and maintains all the Plans and PlanTemplates. It is the place Indexer create and publish a Plan for a specific deployment. And also the place Consumer can search and take these Plan.

PurchaseOfferMarket

The Purchase Offer Market Contract tracks all purchase offers for Indexers and Consumers. It allows Consumers to create/cancel purchase offers, and Indexers to accept the purchase offer to make the service agreements. It is the place Consumer publish a purchase offer for a specific deployment. And also the place indexers can search and take these purchase offers.

ProjectRegistry

This contract tracks all query projects and their deployments. At the beginning of the network, we will start with the restrict mode which only allow permissioned account to create and update query project. Indexers are able to start and stop indexing with a specific deployment from this conttact. Also Indexers can update and report their indexing status from this contarct.

RewardsDistributer

The Rewards distributer contract tracks and distriubtes the rewards Era by Era. In each distribution, Indexers can take the commission part of rewards, the remaining rewards are distributed according to the staking amount of indexers and delegators.

RewardsHelper

RewardsPool

The Rewards Pool using the Cobb-Douglas production function for PAYG and Open Agreement.

RewardsStaking

Keep tracing the pending staking and commission rate and last settled era.

ServiceAgreementRegistry

This contract tracks all service Agreements for Indexers and Consumers.

SQToken

Staking

The Staking contract hold and track the changes of all staked SQT Token, It provides entry for the indexers and delegators to stake/unstake, delegate/undelegate to available Indexers and withdraw their SQT Token.

StateChannel

The contact for Pay-as-you-go service for Indexer and Consumer.

Vesting

VSQToken