Uniswap Governance is governed over GovernorAlpha - a set of proposals and votes. This subgraph aggregates the proposals in an easy to consume way.
Subgraph quickstart docs: https://thegraph.com/docs/define-a-subgraph
(H/t) Compound Governance subgraph: https://github.com/protofire/compound-governance-subgraph
-
Follow these steps to setup
graph-cli
: https://thegraph.com/docs/define-a-subgraph -
Define the events to listen to inside
subgraph.yaml
, see example here -
Define the GraphQL Schema inside
schema.graphql
, note this is the crux of the abstraction here. See example here -
Run
yarn codegen
to generate the corresponding Contracts (defined insubgraph.yaml
) and Entities (defined inschema.graphql
) into the/generated
folder -
Implement
mapping.ts
which maps the Contract events to the corresponding Entities - this acts as a bridge between the two set of generated types.
-
Goto https://thegraph.com/, login and click on "Add Subgraph"
-
Follow https://thegraph.com/docs/deploy-a-subgraph#create-the-subgraph and input the corresponding info
-
Retrieve access token from the created empty subgraph page
-
Authenticate to this specific subgraph:
graph auth https://api.thegraph.com/deploy/ <ACCESS_TOKEN>
-
Build:
yarn build
-
Deploy:
yarn deploy