This project serves the circulating supply of OHM to CoinGecko, so that it can be displayed accurately on the token page.
This is a very simple app, architected in the following way:
- treasury-subgraph API endpoint. See: treasury-subgraph
- Firestore database
- Serverless function (in GCP)
- Hosting in Firebase, so that the URL endpoint is static
- A custom domain under olympusdao.finance is also manually mapped to the production URL endpoint
When the function's trigger URL is hit, the following are performed:
-
Check if there is a value in the cache (Firestore) and returns it, if so.
- Values are currently cached for 1 hour, in order to reduce queries to the GraphQL endpoint (which incur a charge).
-
If there is no valid cached value, an API query is performed. If successful, the cache is updated and the value is returned.
-
If no value is returned by the API query, HTTP status 500 is returned by the function.
A GCP service account is required for deployment. The name of the file should correspond to the name specified in the Pulumi config file (e.g. Pulumi.prod.yaml). The role of the service account should be set to "Owner" for the project.
TODO: determine if a more restrictive role can be used.
A key then needs to be created for the service account and saved to a JSON file. This can then be referenced in the Pulumi config file. The JSON file should NOT be committed to the repo.
Deployment is handled by Pulumi, with hosting on GCP.
To deploy:
- Copy the
.env.samplefile and fill in any variables - Obtain the JSON credentials file for the project's service account and save as
gcp_credentials.json. Firebase requires a service account for deployment, hence the need to jump through this hoop. - Run
pulumi stack selectand select/create the required stack - Run
pulumi refreshto grab the current state from GCP - Run
pulumi upto deploy.
If the GCP project is shared between stacks, you may need to import the default Firestore database: pulumi import gcp:firestore/database:Database default "(default)"
- To force the deployed function to ignore the cache, append
?cache=falseto the URL