Skip to content

Commit

Permalink
fix: indexer endpoints and some outdated api docs details
Browse files Browse the repository at this point in the history
  • Loading branch information
razgraf committed Jul 11, 2024
1 parent 0ff9d32 commit cad7529
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 52 deletions.
2 changes: 1 addition & 1 deletion docs/api/01-overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@ similar campaigns from their own dashboards. Read more on the dedicated page abo

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%3A%2F%2Fapi.thegraph.com%2Fsubgraphs%2Fname%2Fsablier-labs%2Fsablier-v2-experimental)'s
[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.
11 changes: 7 additions & 4 deletions docs/api/indexers/01-endpoints.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ creating, withdrawing, or transferring streams.
| ---------------- | ----------------------------------------------------------------------- |
| All-Networks[^1] | [https://indexer.bigdevenergy.link/[...]/v1/graphql][endpoint-protocol] |

Use [Hasura's online explorer](https://cloud.hasura.io/public/graphiql?) to view the entities and query API.
The endpoint is meant to be plugged into a query client. Use
[Hasura's online explorer](https://cloud.hasura.io/public/graphiql?) to view the entities and query API.

### Code

Expand All @@ -51,7 +52,8 @@ streams as defined in the attached Merkle tree.
| ------------ | --------------------------------------------------------------------- |
| All-Networks | [https://indexer.bigdevenergy.link/[...]/v1/graphql][endpoint-merkle] |

Use [Hasura's online explorer](https://cloud.hasura.io/public/graphiql?) to view the entities and query API.
The endpoint is meant to be plugged into a query client. Use
[Hasura's online explorer](https://cloud.hasura.io/public/graphiql?) to view the entities and query API.

[endpoint-merkle]: https://indexer.bigdevenergy.link/508d217/v1/graphql

Expand All @@ -66,5 +68,6 @@ Use [Hasura's online explorer](https://cloud.hasura.io/public/graphiql?) to view

[^1]:
All-Networks = most of the networks supported by Sablier, e.g., Mainnet, Optimism, Polygon, Sepolia. The full list
can be found
[here](https://github.com/sablier-labs/v2-subgraphs/blob/main/apps/protocol-envio/src/constants/chains/index.ts).
can be found [here](https://github.com/sablier-labs/v2-subgraphs/tree/main/packages/constants/src). To add a new
chain to our Envio indexer, create a new list of contracts (`/addresses`) and import that configuration into our
bundles (see `/bundles`).
39 changes: 24 additions & 15 deletions docs/api/indexers/02-differences.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -73,31 +73,37 @@ the start of each method. It should only come into play within the create handle
### Versioning and Lockup Flavors

While for The Graph's subgraphs we track flavor-first (see `subgraph.template.yaml` for the configuration of
`SablierV2LockupLinear` and `SablierV2LockupDynamic`), for Envio's indexers we'll have a version-first approach.
`SablierV2LockupLinear` and `..Dynamic` or `..Tranched`), for Envio's indexers we'll have a version-first approach.

Therefore, `LockupLinear` and `LockupDynamic` will be bundled under the same `Lockup<Version>` contract tracker (see
`./config.template.mustache`). Different versions of the protocol will be tracked separately, which is why we have
`Lockup_V20` (v2.0) and `Lockup_V21` (v2.1) in our configuration. Later on, inside the handler logic, we'll separate
contracts by flavor.
Therefore, `LockupLinear`,`LockupDynamic` and `LockupTranched` will be bundled under the same `Lockup<Version>` contract
tracker (see `./config.template.mustache`). Different versions of the protocol will be tracked separately, which is why
we have `Lockup_V20` (v2.0) and `Lockup_V21` (v2.1) in our configuration. Later on, inside the handler logic, we'll
separate contracts by flavor.

```tree title="Envio: Contract configuration tree (version-first)"
└── contracts/
├── LockupV20/
│ ├── event: CreateLockupDynamicStream
│ └── event: CreateLockupLinearStream
└── LockupV21/
├── event: CreateLockupDynamicStream
└── event: CreateLockupLinearStream
│ ├── event: CreateLockupLinearStream
│ └── event: CreateLockupTrnchedStream
├── LockupV21/
│ ├── event: CreateLockupDynamicStream
│ ├── event: CreateLockupLinearStream
│ └── event: CreateLockupTranchedStream
└── LockupV22/
```

```tree title="The Graph: Contract configuration tree (flavor-first)"
└── contracts/
├── LockupDynamic/
│ ├── event: CreateLockupDynamicStreamV20
│ └── event: CreateLockupDynamicStreamV21
└── LockupLinear/
├── event: CreateLockupLinearStreamV20
└── event: CreateLockupLinearStreamV21
│ └── event: CreateLockupDynamicStreamV22
├── LockupLinear/
│ ├── event: CreateLockupLinearStreamV20
│ └── event: CreateLockupLinearStreamV21
│ └── event: CreateLockupLinearStreamV22
└── LockupTranched/
```

## Contract Calls
Expand All @@ -113,15 +119,18 @@ Due to the cross-chain indexing aspect, entities in Envio will need to have a ch
they're unique across the board. At the same time, there are some minor features missing, which will cause some
differences listed below.

- For Envio indexers, some entities will have different identifiers (from what The Graph's subgraph have):
- For Envio indexers, entities will have fully specified identifiers (meaning chainId included)
1. `protocol-envio`: the `Action`, `Asset`, `Batch`, `Batcher`, `Contract` have a `-chainId` appended to the ID
2. `merkle-envio`: the `Action`, `Asset` and `Factory` have a `-chainId` appended to the ID

While we've tried to refactor our The Graph entities to share similar identifiers, please double check in cases when you
use both query resolves (The Graph and Envio) at the same time.

:::tip

To avoid writing separate systems when assigning variables to queries, you can use slightly different filters. For
example, given the different `id`s of an `Asset` (`address` in The Graph and `address-chainId` in Envio) you can query
for certain assets with:
example, given a different `id` for an entity like `Asset` (`address` in The Graph and `address-chainId` in Envio) you
can query for certain assets with:

1. `asset(id: $assetId)` for The Graph
2. `Asset(where: {id: {_iregex: $assetId}})`
Expand Down
2 changes: 1 addition & 1 deletion docs/api/indexers/_category_.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"collapsed": false,
"label": "Indexers",
"label": "Indexers - Envio",
"position": 2
}
8 changes: 4 additions & 4 deletions docs/api/indexers/protocol/03-flow.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ To offer a backwards compatible subgraph (between Sablier Core/ Sablier Peripher
the ABIs of the two versions. This will cause the configuration file to contain similar events between different
versions of Lockup contract.

Different from how we handle this for [subgraphs](/api/subgraphs/protocol/flow), `LockupLinear` and `LockupDynamic` will
be bundled under the same `Lockup<Version>` contract tracker `config.yaml`. Versions of the protocol will be tracked
separately, which is why we have `Lockup_V20` (v2.0) and `Lockup_V21` (v2.1) in our configuration. Later on, inside the
handler logic, we'll separate contracts by flavor.
Different from how we handle this for [subgraphs](/api/subgraphs/protocol/flow), `Lockup Linear`, `Lockup Dynamic` and
`Lockup Tranched` will be bundled under the same `Lockup<Version>` contract tracker `config.yaml`. Versions of the
protocol will be tracked separately, which is why we have `Lockup_V20` (v2.0) and `Lockup_V21` (v2.1) in our
configuration. Later on, inside the handler logic, we'll separate contracts by flavor.
15 changes: 4 additions & 11 deletions docs/api/subgraphs/01-endpoints.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,11 @@ import LinkPreview from "@site/src/components/LinkPreview";
This subgraph tracks events mainly emitted by the [`@sablier/v2-core`](/contracts/v2/reference/overview#core) contracts.
It deals with core protocol actions like creating, withdrawing or transferring streams.

:::warning
:::important

Since The Graph is [sunsetting](https://thegraph.com/blog/sunsetting-hosted-service/) their Hosted Service we've
transitioned our subgraphs to either the Studio or The Decentralized Network (see
[supported networks](https://thegraph.com/docs/en/developing/supported-networks/)). For a while you may still be able to
access the Hosted Service endpoints using

```
api.thegraph.com/subgraphs/name/sablier-labs/sablier-v2-<CHAIN>
```

... where `CHAIN` corresponds to the chain names used below.
[supported networks](https://thegraph.com/docs/en/developing/supported-networks/) and our endpoints below).

:::

Expand Down Expand Up @@ -294,10 +287,10 @@ NFTs as defined in the attached Merkle tree.
### Code

<LinkPreview
href="https://github.com/sablier-labs/v2-subgraphs/tree/main/apps/protocol"
href="https://github.com/sablier-labs/v2-subgraphs/tree/main/apps/merkle"
icon="github"
subtitle="Github - sablier-labs/v2-subgraphs"
title="Sablier V2 protocol subgraph (The Graph)"
title="Sablier V2 merkle subgraph (The Graph)"
/>

## Sablier V1
Expand Down
2 changes: 1 addition & 1 deletion docs/api/subgraphs/_category_.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"collapsed": false,
"label": "Subgraphs",
"label": "Subgraphs - The Graph",
"position": 1
}
15 changes: 8 additions & 7 deletions docs/api/subgraphs/protocol/01-entities.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ responsible of defining the following Sablier entities:

### Primary

| Entity | Description |
| -------- | ------------------------------------------------------------------------------------------ |
| Contract | Instances of `SablierV2LockupLinear` or `SablierV2LockupDynamic` |
| Action | Emitted events transformed into historical entries (e.g. Create, Withdraw) |
| Stream | Primary entity tracking the up to date state of a stream |
| Asset | The ERC20 asset that is being streamed |
| Segment | The function segment used to build the custom curve in cases of LockupDynamic streams care |
| Entity | Description |
| -------- | -------------------------------------------------------------------------------------- |
| Contract | Instances of `SablierV2LockupLinear` or `..Dynamic` or `..Tranched` |
| Action | Emitted events transformed into historical entries (e.g. Create, Withdraw) |
| Stream | Primary entity tracking the up to date state of a stream |
| Asset | The ERC20 asset that is being streamed |
| Segment | The function segment used to build the custom curve in cases of Lockup Dynamic streams |
| Tranche | The tranche/step used to build shapes powered by Lockup Tranched streams |

### Secondary

Expand Down
32 changes: 24 additions & 8 deletions docs/api/subgraphs/protocol/02-structure.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ title: "Structure"
We'll break down the [schema](https://github.com/sablier-labs/v2-subgraphs/blob/main/apps/core/schema.graphql) into
primary and secondary entities.

| Type | Entities |
| --------- | ---------------------------------------- |
| Primary | Contract, Action, Stream, Asset, Segment |
| Secondary | Batch, Batcher, Watcher |
| Type | Entities |
| --------- | ------------------------------------------------- |
| Primary | Contract, Action, Stream, Asset, Segment, Tranche |
| Secondary | Batch, Batcher, Watcher |

## Contract

Expand Down Expand Up @@ -125,9 +125,10 @@ you don't need to worry about `proxenders` and `proxy` if you're not looking to

:::

[In V2.0] While not mandatory for the core functionality, Sablier made use of [PRBProxy](https://github.com/paulrberg/prb-proxy)
in its [periphery](https://github.com/sablier-labs/v2-periphery. The official client interfaces provided support for functionality
exposed through both EOAs and this proxy integration, at the same time.
[In V2.0] While not mandatory for the core functionality, Sablier made use of
[PRBProxy](https://github.com/paulrberg/prb-proxy) in its [periphery](https://github.com/sablier-labs/v2-periphery. The
official client interfaces provided support for functionality exposed through both EOAs and this proxy integration, at
the same time.

For streams created within this "extended" ecosystem, a few attributes and entities will change meaning as such:

Expand Down Expand Up @@ -169,12 +170,27 @@ implementation. For examples, see the asset "helper" files inside this subgraph'

## Segment

The custom emission curve used by LockupDynamic streams will be defined as a sequence of
The custom emission curve used by Lockup Dynamic streams will be defined as a sequence of
[segments](/concepts/protocol/segments). This entity will store data regarding those segments, which will be later used
to reconstruct the shape of the curve client side.

---

## Tranche

The custom emission curve used by Lockup Tranched streams will be defined as a sequence of
[tranches](/concepts/protocol/tranches). This entity will store data regarding those tranches, which will be later used
to reconstruct the shape of the curve client side.

:::tip

Tranches can also be represented as a set of two segments (one horizontal, one vertical) so client apps may benefit from
artificially creating segments from tranches.

:::

---

## Batch and Batcher

The v2-periphery, while not explicitly tracked by the subgraph will offer some extra functionality to proxy-sourced
Expand Down

0 comments on commit cad7529

Please sign in to comment.