Skip to content

Commit

Permalink
Merge pull request #186 from sablier-labs/docs/flow-protocol
Browse files Browse the repository at this point in the history
feat: revamps structure and adds Flow docs
  • Loading branch information
smol-ninja authored Dec 12, 2024
2 parents 1c7d804 + 422f649 commit 3f551df
Show file tree
Hide file tree
Showing 280 changed files with 9,342 additions and 3,316 deletions.
12 changes: 8 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[submodule "repos/v2-core"]
[submodule "repos/lockup/v2-core"]
branch = "release"
path = "repos/v2-core"
path = "repos/lockup/v2-core"
url = "https://github.com/sablier-labs/v2-core"
[submodule "repos/v2-periphery"]
[submodule "repos/lockup/v2-periphery"]
branch = "release"
path = "repos/v2-periphery"
path = "repos/lockup/v2-periphery"
url = "https://github.com/sablier-labs/v2-periphery"
[submodule "repos/flow"]
branch = "release"
path = "repos/flow"
url = "https://github.com/sablier-labs/flow"
Binary file modified bun.lockb
Binary file not shown.
155 changes: 109 additions & 46 deletions docs/api/01-overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,81 +8,144 @@ import LinkPreview from "@site/src/components/LinkPreview";

# The Sablier APIs

Sablier relies on specific dependencies to source data or manage off-chain flows. All of these are either public or
fully open-source, so feel free to roam around and suggest improvements or optimizations where needed.
Sablier relies on specific dependencies to source data and enable off-chain features. All of these are either public or
open-source, so feel free to roam around and suggest improvements or optimizations.open-source, so feel free to roam
around and suggest improvements or optimizations.

## Subgraphs and Indexers (GraphQL)
Below, we will cover:

As an alternative to reading data from the contracts or listening to onchain events, we use a set of subgraphs and
indexers. These act as a middleware between the chain and our interfaces and allow for caching, formatting and querying
data.
1. The [solutions](#solutions) we use to index and query data
2. The [interface-to-protocol](#products) links between these solutions
3. The raw entities emitted by the contracts

### The Graph's Subgraphs
## Solutions

[The Graph](https://thegraph.com/) has been the vendor of choice for the EVM space for the past few years. We've been
integrating The Graph since 2019 with Sablier V1. For Sablier V2, we designed a special set of feature-oriented
subgraphs used not only by us (in the official apps) but by 3rd party services (e.g. snapshot) and integrators alike.
![Banner Sablier APIs](/banner/docs-banner-apis.webp)

As an alternative to reading data from the contracts or listening to onchain events, we use a collection of subgraphs
and indexers. These service act as a middleware between the chain and our interfaces and allow for caching, formatting
and querying data. For more advanced features like Merkle tree generation (used in Airdrops), we've written own SDKs and
open-sourced some of them.

:::note Playground

To preview the GraphQL APIs for subgraphs and indexers, you can plug them into
[Hasura's](https://cloud.hasura.io/public/graphiql) online explorer.
[Here](https://cloud.hasura.io/public/graphiql?endpoint=https://api.studio.thegraph.com/query/57079/sablier-v2/version/latest)'s
an example setup of a Mainnet subgraph for Sablier Lockup.

:::

## Subgraphs

### The Graph

[The Graph](https://thegraph.com/) has been the vendor of choice in the EVM space for the past few years. We've been
using The Graph since we launched Sablier Legacy in 2019. For our current apps, we created a special set of
feature-oriented subgraphs used internally and by third-party services (e.g., Snapshot) and integrators.

These subgraphs are hosted on The Graph Network, as well as on the The Graph Hosted Service. They can be used to query
Sablier data from the official [endpoints](/api/subgraphs/endpoints). Every network has its own subgraph endpoints.
Sablier data from the official [endpoints](/api/lockup/endpoints). EAch network has its own subgraph endpoints.

Read more on the dedicated pages about our `protocol` and `merkle` [subgraphs](/api/subgraphs/endpoints) or check out
the [official vendor docs](https://thegraph.com/docs/en/quick-start/).
- [Lockup endpoints](/api/lockup/endpoints)
- [Lockup subgraph](https://github.com/sablier-labs/subgraphs/apps/lockup) (Vesting)
- [Flow endpoints](/api/flow/endpoints)
- [Flow subgraph](https://github.com/sablier-labs/subgraphs/apps/flow) (Payments)
- [Airdrops endpoints](/api/airdrops/endpoints)
- [Airdrops subgraph](https://github.com/sablier-labs/subgraphs/apps/merkle) (Airdrops, Airstreams)
- [The Graph docs](https://thegraph.com/docs/en/quick-start/)

<LinkPreview
href="https://github.com/sablier-labs/v2-subgraphs"
href="https://github.com/sablier-labs/subgraphs"
icon="github"
subtitle="@sablier/v2-subgraphs"
title="Github - apps/protocol, apps/merkle"
subtitle="@sablier/subgraphs"
title="Sablier Subgraphs on Github"
/>

### Envio's Indexers
#### Endpoints / Slugs

Every subgraph deployment will have a `slug` generated by The Graph. The slug is derived from the subgraph name and can
be found in the Studio Development Query URL. We use the following naming convention for subgraphs:

| Subgraph | Example | Product or Concept |
| ------------------- | ----------------------------------- | ---------------------------------------------------- |
| `sablier-v2-*` | `sablier-v2`, `sablier-v2-optimism` | [Lockup](/concepts/lockup/overview) (Vesting) |
| `sablier-v2-flow-*` | `sablier-v2-flow-arbitrum` | [Flow](/concepts/flow/overview) (Payments) |
| `sablier-v2-ms-*` | `sablier-v2-ms-base` | [Airstreams](/concepts/lockup/airstreams) (Airdrops) |
| `sablier-*` | `sablier-optimism` | [V1](/api/legacy) (Legacy) |

There is a `v2` in the subgraph name due to historical reasons. Sablier used to be versioned as `v1` and `v2`, and the
subgraphs were named accordingly. However, we have since dropped this versioning scheme.

### Envio

[Envio](https://envio.dev/) offers a suite of fast and flexible tools to access onchain data. Their HyperIndex service
provides for a similar GraphQL driven API to access cached data and serve it into our client interfaces.
provides a similar GraphQL-driven API to access cached data and serve it into our client interfaces.

We designed a set of indexers that mimic the features and entities exposed by subgraphs and take advantage of the speed
and optimized environment configured through HyperIndex. Read more on the dedicated page about our `protocol-envio` and
`merkle-envio` [indexers](/api/indexers/endpoints).
We created indexers that mimic the features and entities exposed by subgraphs and take advantage of the speed and
optimized environment configured through HyperIndex.

All networks share the same indexer endpoint (for one indexer type), as Envio promotes a cross-chain indexing
architecture.

:::tip

Before diving into integrating Envio's indexer as a data source for your application, please read the
[main differences](/api/indexers/differences) between subgraphs and indexers (generally as well as applied to the
Sablier deployments).

:::
- [Caveats](/api/caveats) between subgraphs and indexers
- [Lockup endpoints](/api/lockup/endpoints)
- [Lockup indexer](https://github.com/sablier-labs/subgraphs/apps/lockup-envio) (Vesting)
- [Flow endpoints](/api/lockup/endpoints)
- [Flow indexer](https://github.com/sablier-labs/subgraphs/apps/flow-envio) (Payments)
- [Airdrops endpoints](/api/airdrops/endpoints)
- [Airdrops indexer](https://github.com/sablier-labs/subgraphs/apps/merkle-envio) (Airdrops, Airstreams)
- [The Graph docs](https://thegraph.com/docs/en/quick-start/)

<LinkPreview
href="https://github.com/sablier-labs/v2-subgraphs"
href="https://github.com/sablier-labs/subgraphs"
icon="github"
subtitle="@sablier/v2-subgraphs"
title="Github - apps/protocol-envio, apps/merkle-envio"
subtitle="@sablier/subgraphs"
title="Sablier Indexers on Github"
/>

## Merkle API (Rust)
## Sablier SDKs

### Merkle API

To support the Merkle distribution (see [Airdrops](/apps/features/airdrops)) system, we developed a backend service
called `@sablier/merkle-api`. This API deals with the validation, creation, and management of Merkle trees, which are
used to define eligibility and claiming rules for Sablier's Airstream campaigns.

To support our Merkle distribution (a.k.a. [Airstreams](/apps/features/airstreams)) system we developed a backend
service called `@sablier/v2-merkle-api`. This backend deals with the validation, creation and management of Merkle
trees, used to define eligibility and claiming rules for Sablier's Airstream campaigns.
The service is open-source and can be used by integrators as a plug-n-play solution to support (and even deploy) similar
campaigns. Read more on the dedicated page about the `merkle-api` service [here](/api/airdrops/merkle-api/overview).

This service is open-source and can be used by integrators as a plug-n-play solution to support (and even deploy)
similar campaigns from their own dashboards. Read more on the dedicated page about the `merkle-api`
[backend](/api/merkle-api/intro).
- [Endpoints](/api/airdrops/endpoints)

<LinkPreview
href="https://github.com/sablier-labs/v2-merkle-api"
href="https://github.com/sablier-labs/merkle-api"
icon="github"
subtitle="@sablier/v2-merkle-api"
title="Github - Rust based API to generate Merkle distribution"
subtitle="@sablier/merkle-api - Rust-based service for Merkle distributions"
title="Sablier Merkle API on Github"
/>

## Explorer
## Products

To preview the GraphQL APIs for subgraphs and indexers you can plug them into
[Hasura's](https://cloud.hasura.io/public/graphiql) online explorer.
[Here](https://cloud.hasura.io/public/graphiql?endpoint=https://api.studio.thegraph.com/query/57079/sablier-v2/version/latest)'s
an example setup for the `sablier-v2` mainnet subgraph inside Hasura's explorer.
### Lockup

The [vesting](/apps/features/vesting) side of the application is powered by:

- The `@sablier/subgraphs/apps/lockup` subgraph
- The `@sablier/subgraphs/apps/lockup-envio` indexer

### Airdrops (Airstreams)

The [airdrops](/apps/features/airdrops) side of the application is powered by:

- The `@sablier/subgraphs/apps/merkle` subgraph
- The `@sablier/subgraphs/apps/merkle-envio` indexer
- The `@sablier/merkle-api` rust service for airdrops

These will work for both Airstreams and Instant Airdrops 🔜.

### Flow

The [payments](/apps/features/payments) side of the application is powered by:

- The `@sablier/subgraphs/apps/flow` subgraph
- The `@sablier/subgraphs/apps/flow-envio` indexer
Loading

0 comments on commit 3f551df

Please sign in to comment.