Skip to content

Commit

Permalink
feat(api): tips and tricks with stream contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
razgraf committed Jan 18, 2025
1 parent 0fda391 commit c157ec5
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
38 changes: 38 additions & 0 deletions docs/api/lockup/01-overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,41 @@ Lockup-native functionality is powered by:

As per our endpoint [naming convention](/api/overview#endpoints--slugs), subgraph deployments of Sablier Lockup will
follow the `sablier-v2-*` structure (e.g. `sablier-v2` for Mainnet, `sablier-v2-base` for Base).

#### Tips and tricks

:::tip

To avoid writing the same entity definitions over and over again, check out
[Fragments](https://graphql.org/learn/queries/#fragments).

```graphql

fragment StreamFragment on Stream {
id
sender
recipient
contract {
id
address
}
}

query getStreams(...){
streams(...){
...StreamFragment
}
}

```

:::

:::note

Since Sablier uses multiple immutable contract versions and deployments (e.g.
[lockup's variants](/guides/lockup/deployments#previous-versions)), if you're going to perform onchain actions on
queried streams (e.g. getting the `streamedAmountOf`) make sure you call those methods on the right contract. For
subgraphs/indexers, we store the source contract under `stream.contract.address`.

:::
16 changes: 15 additions & 1 deletion docs/api/lockup/the-graph/04-queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,19 @@ query getStreams_ByCampaignId($campaignId: String!) {

:::tip

To avoid writing the same entity definitions over and over again, check out Fragments.
To avoid writing the same entity definitions over and over again, check out
[Fragments](https://graphql.org/learn/queries/#fragments).

```graphql

fragment StreamFragment on Stream {
id
sender
recipient
contract {
id
address
}
}

query getStreams(...){
Expand All @@ -180,6 +185,15 @@ query getStreams(...){

:::

:::note

Since Sablier uses multiple immutable contract versions and deployments (e.g.
[lockup's variants](/guides/lockup/deployments#previous-versions)), if you're going to perform onchain actions on these
streams (e.g. getting the `streamedAmountOf` for each one) make sure you call those methods on the right contract. For
subgraphs/indexers, we store the source contract under `stream.contract.address`.

:::

## Actions

### Actions by stream
Expand Down

0 comments on commit c157ec5

Please sign in to comment.