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:
- NFT Marketplaces (E.g. OpenSea, Looksrare)
- NFT Projects (E.g. ENS, POAP, Nouns, Moonbirds, Apes)
- Swaps (e.g. Quickswap, Uniswap, Sushiswap)
- Defi (e.g. Aave or Compound)
- Bridges (e.g. Hop)
- Games (e.g. Sandbox)
- DAOs
- Social (e.g. Farcaster and Lens)
- Catch all for Other Dapps (we anticipate that this will soon be broken out into additional verticals, e.g. Music, Publishing, Social)
You already have a subgraph for Dapp/Protocol. And you intend to integrate Airstack schemas into the project.
npm install @airstack/subgraph-generator
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
npx @airstack/subgraph-generator <vertical> --yaml <subgraph.yaml file path> --graphql <schema.graphql file path> --dataSourceNames <"name1, name2, ..."> --templates <"name1, name2">
npx airstack <vertical>
will add the required Airstack entities and the ABI files in your subgraph.yaml file
--yaml <subgraph.yaml file path>
provide the location of your project's subgraph.yaml file. This is an optional parameter.
--graphql <subgraph.graphql file path>
provide the location of your project's schema.graphql file. This is an optional parameter.
--dataSourceNames <name1, name2, ...>
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 <name1, name2, ...>
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.
Track actions for NFT Marketplace. Call the following functions from your subgraph mapping. An example implementation is Here.
-
NFT sale transactions
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 hash
Supported protocol types are :- GENERIC EXCHANGE LENDING YIELD BRIDGE DAO NFT_MARKET_PLACE STAKING P2E #play to earn LAUNCHPAD
Supported protocol action types are :- ALL ##to track all action stats of a dapp
BUY SELL MINT BURN # TODO check this later
ATTEND
EARN
SWAP ADD_LIQUIDITY REMOVE_LIQUIDITY ADD_TO_FARM REMOVE_FROM_FARM CLAIM_FARM_REWARD
LEND BORROW FLASH_LOAN
STAKE RESTAKE UNSTAKE DELEGATE CLAIM_REWARDS
Track actions for NFT Marketplaces. Call the following function from your subgraph mapping. An example implementation is Here
-
Creation of NFT object
NFT( Collection Address : Address, Standard: string, //ERC1155 or ERC721 tokenId: BigInt, amount: BigInt )
-
Creation of NFT Sale object
Sale( buyer: Address, seller: Address, nft: NFT, paymentAmount: BigInt, paymentToken: Address, protocolFees: BigInt, protocolFeesBeneficiary: Address, royaltyFees: BigInt, royaltyFeesBeneficiary: Address )
-
Use the trackNFTSaleTransactions function to process the data and store in Airstack schema
trackNFTSaleTransactions( chainID: string, txHash: string, txIndex: BigInt, NftSales: Sale[], protocolType: string, protocolActionType: string, timestamp: BigInt, blockHeight: BigInt, blockHash: string ): void;
⌛ = Prioritized
💬 = In discussion
🔨 = In progress implementation
✅ = Completed
Vertical | Status |
---|---|
NFT Marketplace | 🔨 |
DEX | 🔨 |
Bridges | 💬 |
DAO | ⌛ |
Defi | ⌛ |
Games | ⌛ |