Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1 from EnsoFinance/add-subgraph
Browse files Browse the repository at this point in the history
add subgraph basic documentation
  • Loading branch information
milonite authored Nov 30, 2021
2 parents 3ef9e61 + 80c818c commit bbd7122
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 773 deletions.
200 changes: 55 additions & 145 deletions docs/developer-tools/subgraph/entities.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,152 +5,62 @@ sidebar_position: 3
custom_edit_url: https://github.com/EnsoFinance/enso-docs/blob/main/docs/developer-tools/subgraph/entities.mdx
---

##### All of the GraphQL entities of the Enso Subgraph
##### The main GraphQL entities of the Enso Subgraph

---

## Media
## Factory

The `Factory` entity represents the global data that refers to data points about the Enso protocol as a whole

| Field Name | Type | Description |
| -------------------- | -------= | ---------------------------------------------------------- |
| id | ID | The address on the Enso Factory Contract |
| strategiesCount | Int | Total number of strategies on the Enso platform |
| managersCount | Int | Total number of managers on the Enso platform |
| allManagers |\[String\]| Array of all the manager addresses |
| allStrategies |\[String\]| Array of all the strategy addresses |

## Strategies

The `Strategy` entity represents the Enso Strategies.

| Field Name | Type | Description |
| --------------- | ----------------------- | ---------------------------------------------------------------------------- |
| id | ID | Ethereum Address |
| manager | \[Manager\] | Strategy Manager |
| name | String | Strategy name |
| symbol | String | Strategy token symbol |
| totalSupply | BigInt | Strategy token total supply |
| state | \[StrategyState\] | Strategy state, contains data editable by the manager |
| startTime | BigInt | Timestamp, starting date of the strategy |
| nav | BigDecimal | Strategy state, contains data editable by the manager |
| tvl | BigDecimal | Strategy state, contains data editable by the manager |
| tvl24hChange | BigDecimal | TVL change in the last 24h |
| items | \[StrategyItemHolding\] | Strategy items |
| tokenHolders | \[StrategyTokenHolding\]| Strategy token holders |
| strategyDaysData| \[StrategyDayData\] | Day data collection of the strategy |
| rebalances | \[Rebalance\] | All the rebalances occured in the strategy |
| restructures | \[Restructure\] | All the restructures occured in the strategy |

## Managers

The `Manager` entity represents the manager of one or more Enso strategy.

| Field Name | Type | Description |
| --------------- | ----------------------- | ---------------------------------------------------------------------------- |
| id | ID | Ethereum Address |
| strategies | \[Strategy\] | Manager's strategies |
| strategiesCount | Int | Number of strategies managed |
| startTime | BigInt | Timestamp of the manager first action on the Enso platform |
| tvl | BigDecimal | Total TVL managed |
| tvl24hChange | BigDecimal | TVL change in the last 24h |
| holdersCount | Int | Aggregate number of holder for all manager strategies |
| nav | \[StrategyState\] | Strategy state, contains data editable by the manager |
| tvl | \[StrategyState\] | Strategy state, contains data editable by the manager |
| items | \[StrategyItemHolding\] | Strategy items |
| tokenHolders | \[StrategyTokenHolding\]| Strategy token holders |
| strategyDaysData| \[StrategyDayData\] | Day data collection of the strategy |
| rebalances | \[Rebalance\] | All the rebalances occured in the strategy |
| restructures | \[Restructure\] | All the restructures occured in the strategy |

The `Media` entity represents the core data for NFTs minted on Enso (zNFTs)

| Field Name | Type | Description |
| -------------------- | ------- | ---------------------------------------------------------- |
| id | ID | The tokenId on the Enso Media Contract |
| owner | User | The current owner of the Media |
| creator | User | The creator of the Media |
| prevowner | User | The previous owner of the Enso Media's Market |
| approved | User | The approved user of the Media |
| contentHash | Bytes | The sha256 hash of the media's content |
| metadataHash | Bytes | The sha256 hash of the media's metadata |
| contentURI | String | The uri of the content |
| metadataURI | String | The uri of the metadata |
| ownerBidShare | BigInt | The bid share for the current owner of the Media |
| creatorBidShare | BigInt | The bid share for the creator of the Media |
| prevOwnerBidShare | BigInt | The bid share for the previous owner of the Media's market |
| createdAtTimestamp | BigInt | The timestamp of the block the Media was minted in |
| createdAtBlockNumber | BigInt | The number of the block the Media was minted in |
| burnedAtTimestamp | BigInt | The timestamp of the block the Media was burned in |
| burnedAtBlockNumber | BigInt | The number of the block the Media was burned in |
| currentAsk | Ask | The current Ask of the Media |
| currentBids | \[Bid\] | The current Bids on the Media |
| inactiveAsks | \[Ask\] | The InactiveAsks of the Media |
| inactiveBids | \[Bid\] | The InactiveBids of the Media |

## Users

The `User` entity represents ethereum accounts that interact with the Enso Protocol.

| Field Name | Type | Description |
| --------------- | --------- | ---------------------------------------------------------------------------- |
| id | ID | Ethereum Address |
| authorizedUsers | \[User\] | Users that have been granted `ApprovalForAll` Media of the User's Collection |
| collection | \[Media\] | The Media the User owns |
| creations | \[Media\] | The Media the User created |
| currentBids | \[Bid\] | The active Bids made by the User |

## Ask

The `Ask` entity represents an onchain Ask for a Enso NFT.

| Field Name | Type | Description |
| -------------------- | -------- | ------------------------------------------------- |
| id | ID | <tokenId\>-<ownerAddress\> |
| media | Media | The Media associated with the Ask |
| currency | Currency | The Currency of the Ask |
| amount | BigInt | The amount of Currency of the Ask |
| owner | User | The owner of the Ask |
| createdAtTimestamp | BigInt | The timestamp of the block the Ask was created in |
| createdAtBlockNumber | BigInt | The number of the block the Ask created in |

## InactiveAsk

The `InactiveAsk` entity represents an Ask that is no longer valid on the Enso Protocol. InactiveAsks have either been `removed` or `finalized`.

| Field Name | Type | Description |
| -------------------- | --------------- | --------------------------------------------------------- |
| id | ID | <tokenId\>-<ownerAddress\> |
| media | Media | The Media associated with the InactiveAsk |
| type | MarketEventType | The why this Ask is Inactive |
| currency | Currency | The Currency of the InactiveAsk |
| amount | BigInt | The amount of Currency of the InactiveAsk |
| owner | User | The owner of the InactiveAsk |
| createdAtTimestamp | BigInt | The timestamp of the block the InactiveAsk was created in |
| createdAtBlockNumber | BigInt | The number of the block the InactiveAsk created in |

## Bid

The `Bid` entity represents an onchain Bid for a Enso NFT.

| Field Name | Type | Description |
| -------------------- | -------- | ------------------------------------------------- |
| id | ID | <tokenId\>-<bidderAddress\> |
| media | Media | The Media associated with the Bid |
| currency | Currency | The Currency of the Bid |
| amount | BigInt | The amount of Currency of the Bid |
| sellOnShare | BigInt | he sellOnShare of the Bid |
| bidder | User | The bidder of the Bid |
| recipient | User | The recipient of the Bid |
| createdAtTimestamp | BigInt | The timestamp of the block the Bid was created in |
| createdAtBlockNumber | BigInt | The number of the block the Bid created in |

## InactiveBid

The `InactiveAsk` entity represents a Bid that is no longer valid on the Enso Protocol. InactiveBids have either been `removed` or `finalized`.

| Field Name | Type | Description |
| -------------------- | --------------- | --------------------------------------------------------- |
| id | ID | <tokenId\>-<bidderAddress\> |
| media | Media | The Media associated with the InactiveBid |
| type | MarketEventType | The why this Bid is Inactive |
| currency | Currency | The Currency of the InactiveBid |
| amount | BigInt | The amount of Currency of the InactiveBid |
| sellOnShare | BigInt | he sellOnShare of the InactiveBid |
| bidder | User | The bidder of the InactiveBid |
| recipient | User | The recipient of the InactiveBid |
| createdAtTimestamp | BigInt | The timestamp of the block the InactiveBid was created in |
| createdAtBlockNumber | BigInt | The number of the block the InactiveBid created in |

## Currency

The `Currency` entity represents ERC-20 tokens that have been used as Asks or Bids on the Enso Protocol.

| Field Name | Type | Description |
| ------------ | ------- | ----------------------------------------------------- |
| id | ID | The address of the Currency |
| name | String | The name of the Currency |
| symbol | String | The symbol of the Currency |
| decimals | Int | The decimals of the Currency |
| liquidity | BigInt | Total Bid Liquidity of the Currency on all Enso Media |
| activeBids | \[Bid\] | The active Bids denominated in the Currency |
| activeAsks | User | The active Asks denominated in the Currency |
| inactiveBids | User | The InactiveBids denominated in the Currency |
| inactiveAsks | BigInt | The InactiveAsks denominated in the Currency |

## Transfer

The `Transfer` entity represents transfers of ownership of a Enso NFT.

| Field Name | Type | Description |
| -------------------- | ------ | ------------------------------------------------------ |
| id | ID | <tokenId\>-<transactionHash\>-<logIndex\> |
| media | String | The Media associated with the Transfer |
| from | String | The User transferring the Media |
| to | Int | The User receiving the Media |
| createdAtTimestamp | BigInt | The timestamp of the block the Transfer was created in |
| createdAtBlockNumber | BigInt | The number of the block the Transfer was created in |

## URIUpdate

The `URIUpdate` entity represents updates to the `content` or `metadata` uris of Enso NFTs.

| Field Name | Type | Description |
| -------------------- | ------------- | ------------------------------------------------------- |
| id | ID | <tokenId\>-<transactionHash\>-<logIndex\> |
| type | URIUpdateType | The Type of URIUpdate |
| from | String | The previous uri |
| to | Int | The new uri |
| media | String | The Media associated with the URIUpdate |
| owner | User | The owner of the Media |
| updater | User | The updaterr of the Media's URI |
| createdAtTimestamp | BigInt | The timestamp of the block the URIUpdate was created in |
| createdAtBlockNumber | BigInt | The number of the block the URIUpdate was created in |
17 changes: 12 additions & 5 deletions docs/developer-tools/subgraph/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@ custom_edit_url: https://github.com/EnsoFinance/enso-docs/blob/main/docs/develop

---

The Enso Subgraph, is an open implementation of [The Graph Protocol](https://thegraph.com/explorer/subgraph/EnsoFinance/enso-v1).
It syncs with the blockchain and indexes pertinent on-chain data about Enso's smart contracts. It also provides an easy to use GraphQL interface for developers to easily query synced data from the Ethereum blockchain.
Enso uses a subgraphs for indexing and organizing data from the Enso smart contracts.
The Enso Subgraph is hosted on The Graph hosted service and can be used to query Enso data.
It syncs with the blockchain and indexes pertinent on-chain data about Enso's smart contracts.
It also provides an easy to use GraphQL interface for developers to easily query synced data from the Ethereum blockchain.

The source code for the Enso Subgraph is available [here](https://github.com/EnsoFinance/Enso-v1-subgraph).
The source code for the Enso Subgraph is available [here](https://github.com/enso/enso-subgraph).

### Implementations

- [Eth Mainnet Subgraph](https://thegraph.com/explorer/subgraph/EnsoFinance/enso-v1)
- [Rinkeby Subgraph](https://thegraph.com/explorer/subgraph/EnsoFinance/enso-v1-rinkeby)
- [Eth Mainnet Subgraph](https://thegraph.com/explorer/subgraph/enso/enso-v1)
- [Kovan Subgraph](https://thegraph.com/explorer/subgraph/enso/enso-v1-kovan)

### Endpoints

- [Eth Mainnet Subgraph](https://api.thegraph.com/subgraphs/name/enso/enso-v1)
- [Kovan Subgraph](https://api.thegraph.com/subgraphs/name/enso/enso-v1)

### Enso Documentation

Expand Down
Loading

0 comments on commit bbd7122

Please sign in to comment.