Aqua Subgraph is the main provider for Aqua Interface data.
$ npm install
$ npm run codegenYou can explore Aqua's xDai subgraph at The Graph Explorer.
If you wish to deploy a local explorer, run:
$ npm run explore-localThis snippet requires Docker. After deployment, a local version of the graph, with a web front-end, is available at http://localhost:8000/subgraphs/name/adamazad/aqua
The subgraph listens for events from three fixed contracts; they are deployed once:
AquaFactorySaleLauncherTemplateLauncherParticipantListLauncher
These contracted deployed from the contracts above
FixedPriceSalefromSaleLauncherFixedPriceSaleTemplatefromTemplateLauncherParticipantListfromParticipantListLauncher
The following entities are available in the subgraph. Rest is available in schema.graphql
Stores and tracks information about the AquaFactory contract.
Stores all sale templates added to TemplateLauncher, including the contract address, ID, and name. A template is essentially a sale mechanism.
Every time a new Sale Template is created - cloned - from the list of SaleTemplates, the launched version with additional data is also stored. The launched sale template also stores IPFS metadata hash for sale.
Sales can have a white-labeled list of addresses. This entity tracks the contract, the contract managers, and the list of participants.
Stores all information about the FixedPriceSales. This includes total commitments, withdrawals, sale status, and other sale information.
Each address participating in a FixedPriceSale has a unique ID. The ID is in the following format:
<saleAddress>/users/<userAddress>
A commitment is a pledge that the investor wishes to buy a certain amount of tokens in a FixedPriceSale should the sale reach the threshold. Each commitment has a status - SUBMITTED, RELEASED, and/or CLAIMED. Commitments ID are formatted in
<saleAddress>/commitments/<userAddress>/<commitmentIndex>
Tracks sale withdrawals. This entity is available when a sale has successfully concluded — reached the minimum raise threshold. Unlike FixedPriceSaleCommitment, FixedPriceSaleWithdrawal is aggregated per withdrawal event.
<saleAddress>/withdrawals/<userAddress>
Stores information about ERC20 tokens that have been used as bidding or auctioning tokens in sales. These include symbol, decimals name and address.
How to get the factory information?
The AquaFactory tracks all information
aquaFactory (id: "AquaFactory") {
id
saleCount
address
feeManager
feeTo
templateManager
templateLauncher
saleFee
feeNumerator
templateFee
}How to get list of registered sale templates (mechanisms)?
The SaleTemplate stores such information
saleTemplates {
id
address
name
verified
}How to get the total number of sales?
The AquaFactory tracks the number of sales using saleCount
aquaFactory (id: "AquaFactory") {
saleCount
}How to access the IPFS hash from a sale?
The IPFS hash is stored on the LaunchedSaleTemplate entity. Reference it in your sales query
fixedPriceSales {
launchedSaleTemplate {
metadataContentHash
}
}Each network deployment requires setting up a JSON configuration file in config/<NetworkName>.json.
subgraph.yaml is built from subgraph.template.yaml using configuration defined in previous section. To do so, run
$ npm run prepare-<NetworkName>xDAI and Rinkeby networks are supported.
Read documentations for installing The Graph CLI, then run
$ npm run deployABIs for main contracts are not included in the repo. Instead, they are extracted from the smart contract package @dxdao/aqua-sc). To build the ABIs, run:
$ npm run build-abisNote that it requires jq tool.
Tests require Docker installed. To run tests, run
$ yarn testsThis projects comes with a set of predefined scripts in package.json
| Script | Description |
|---|---|
test |
Runs Jest tests. |
docker-up |
Runs Docker services defined in docker-compose.yaml. |
docker-clean |
reset docker kill & rm. Use if subgraph is not working with explore-local. |
prepare-subgraph |
Builds subgraph.yaml for either mainnet or rinkeby. |
prepare-rinkeby |
Builds subgraph.yaml for the Rinkeby testnet (deprecated). |
prepare-xdai |
Builds subgraph.yaml for the xDai network (deprecated). |
codegen |
Generates AssemblyScript types for smart contract ABIs and the subgraph schema. |
build |
Runs graph build to compile a subgraph to WebAssembly. |
deploy-xdai |
Deploys the subgraph build to The Graph on the xDai network. |
deploy-rinkeby |
Deploys the subgraph build to The Graph on the Rinkeby testnet. |
typechain |
Creates typed-contracts classes. |
build-abis |
Extracts contract ABIs from artifacts in artifacts directory. |
deploy-local |
Deploys the graph build to local graph-node. |
create-local |
Creates the graph build in local graph-node. |
remove-local |
Removes the graph build from local graph-node. |
explore-local |
Starts local graph explorer. |