Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/airstack-xyz/airstack-subgraph
Standardized subgraph and schemas to access the data across projects and blockchains.
https://github.com/airstack-xyz/airstack-subgraph
Last synced: about 21 hours ago
JSON representation
Standardized subgraph and schemas to access the data across projects and blockchains.
- Host: GitHub
- URL: https://github.com/airstack-xyz/airstack-subgraph
- Owner: Airstack-xyz
- Created: 2022-08-07T17:07:44.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-12-21T13:31:29.000Z (almost 2 years ago)
- Last Synced: 2023-03-10T18:33:36.018Z (over 1 year ago)
- Language: TypeScript
- Size: 317 KB
- Stars: 5
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## What are Airstack Schema?
Airstack schemas are standardized schemas to access data across projects and blockchains.
These schemas are for eight initial verticals, and it is intended that any dapp/protocol within those verticals could be indexed consistently by utilizing the Airstack schemas for Subgraph.
The 8 verticals defined for Airstack schemas are:
1. NFT Marketplaces (E.g. OpenSea, Looksrare)
2. NFT Projects (E.g. ENS, POAP, Nouns, Moonbirds, Apes)
3. Swaps (e.g. Quickswap, Uniswap, Sushiswap)
4. Defi (e.g. Aave or Compound)
5. Bridges (e.g. Hop)
6. Games (e.g. Sandbox)
7. DAOs
8. Social (e.g. Farcaster and Lens)
9. Catch all for Other Dapps (we anticipate that this will soon be broken out into additional verticals, e.g. Music, Publishing, Social)## Getting Started
### 1. Prerequisite:
You already have a subgraph for Dapp/Protocol. And you intend to integrate Airstack schemas into the project.
### 2. Install Airstack package:
```npm
npm install @airstack/subgraph-generator
```### 3. Identify the vertical for the Dapp/Protocol:
Currently, we support eight verticals. Identify your project's vertical
Use the following command to add Airstack Schemas and ABIs in your project's `subgraph.yaml`
```npm
npx @airstack/subgraph-generator --yaml --graphql --dataSourceNames <"name1, name2, ..."> --templates <"name1, name2">
````npx airstack `
will add the required Airstack entities and the ABI files in your **subgraph.yaml** file`--yaml `
provide the location of your project's **subgraph.yaml** file. This is an optional parameter.`--graphql `
provide the location of your project's **schema.graphql** file. This is an optional parameter.`--dataSourceNames ` provide the **dataSource** name where Airstack entities will be added. This is an optional parameter. By default, the entities will be added in all the **dataSource** provided in the **subgraph.yaml**.
`--templates ` provide the **teamplate** name where Airstack entities will be added. This is an optional parameter. By default, the entities will be added in all the **teamplate** provided in the **subgraph.yaml**.
Examples:
a. NFT Marketplace
```
npx @airstack/subgraph-generator nft-marketplace
```b. DEX
```
npx @airstack/subgraph-generator dex --yaml "./subgraph.yaml" --dataSourceNames "Factory, Pair"
```Following are the vertical Ids
NFT Marketplace: `nft-marketplace`
NFT: `nft`Swap:`dex`
Bridges: `bridge`
DAO: `TBD`
Defi: `TBD`
Games: `TBD`Integration of the Airstack schemas is done. Now, move to the vertical-specific section for further integration.
### 3. Code integration
#### a. NFT Marketplace
Track actions for NFT Marketplace.
Call the following functions from your subgraph mapping. An example implementation is [Here](https://github.com/Airstack-xyz).1. NFT sale transactions
```ts
function trackNFTSaleTransactions(
chainID: string,
txHash: string,
txIndex: BigInt,
NftSales: Sale[],
protocolType: string,
protocolActionType: string,
timestamp: BigInt,
blockHeight: BigInt,
blockHash: string
): void;
```
**chainID**: ID of the chain on which contract of the subgraph is deployed
**txHash**: Transaction hash of the NFT transaction
**txIndex**: Transaction Index of the NFT transaction
**NFTSales**: Array of the Sale objects containing details of NFT sales
**ProtocolType**: Protocol type
**ProtocolActionType**: Protocol Action Type
**Timestamp**: Timestamp of the block in which transaction happened
**blockHeight**: Block height
**blockHash**: Block hashSupported protocol types are :-
GENERIC
EXCHANGE
LENDING
YIELD
BRIDGE
DAO
NFT_MARKET_PLACE
STAKING
P2E #play to earn
LAUNCHPADSupported protocol action types are :-
ALL ##to track all action stats of a dapp
### NFT Marketplace/Tokens ###
BUY
SELL
MINT
BURN # TODO check this later
### NFT (ex: Poap) ###
ATTEND
### P2E (NFT + Utility) ###
EARN
### DEX ###
SWAP
ADD_LIQUIDITY
REMOVE_LIQUIDITY
ADD_TO_FARM
REMOVE_FROM_FARM
CLAIM_FARM_REWARD
### Lending ###
LEND
BORROW
FLASH_LOAN
### Staking / Delegating ###
STAKE
RESTAKE
UNSTAKE
DELEGATE
CLAIM_REWARDS#### b. NFT Marketplace
Track actions for NFT Marketplaces.
Call the following function from your subgraph mapping. An example implementation is [Here](https://github.com/Airstack-xyz/Subgraphs)1. Creation of NFT object
```ts
NFT(
Collection Address : Address,
Standard: string, //ERC1155 or ERC721
tokenId: BigInt,
amount: BigInt
)
```
2. Creation of NFT Sale object
```ts
Sale(
buyer: Address,
seller: Address,
nft: NFT,
paymentAmount: BigInt,
paymentToken: Address,
protocolFees: BigInt,
protocolFeesBeneficiary: Address,
royaltyFees: BigInt,
royaltyFeesBeneficiary: Address
)
```3. Use the trackNFTSaleTransactions function to process the data and store in Airstack schema
```ts
trackNFTSaleTransactions(
chainID: string,
txHash: string,
txIndex: BigInt,
NftSales: Sale[],
protocolType: string,
protocolActionType: string,
timestamp: BigInt,
blockHeight: BigInt,
blockHash: string
): void;
```### 4. Development status of each vertical
⌛ = Prioritized
💬 = In discussion
🔨 = In progress implementation
✅ = Completed| Vertical | Status |
| --------------- | :----: |
| NFT Marketplace | 🔨 |
| DEX | 🔨 |
| Bridges | 💬 |
| DAO | ⌛ |
| Defi | ⌛ |
| Games | ⌛ |