# SquidGain Queries
## Context
- GH: https://github.com/timbotro/squid-gain
- Global Squid API Address: https://app.gc.subsquid.io/beta/squidgain/1/graphql
## Running Globally
> :information_source: Navigate to the API address above for the GraphiQL playground, or connect directly via your other favourite GraphQL interface.
## Running Locally
1. Install pkgs: `npm i`
2. Run the db: `make up`
3. Migrate the db: `make codegen && make typegen && make build && make migrate`
4. Run the processor: `bash scripts/docker-run.sh`
5. Run GraphQL server: `make serve`
6. Navigate to : `http://localhost:4350/graphql`
## Queries
### Overall Stats
```
query MyQuery {
overviewHistories(orderBy: timestamp_DESC) {
totalVolumeDay
totalLiquidity
timestamp
}
}
```
This is day aggregated stats for all all Native Asset pairs.
### Pool volume by day
```
query MyQuery {
poolVolumeDays(where: {pool: {AND: {currency0_contains: "KUSD", currency1_contains: "KSM"}}}) {
timestamp
pool {
currency0
currency1
}
volumeDayUSD
}
}
```
This will return the daily volumes for the KUSD/KSM pool
### Historic Prices
```
query MyQuery {
currPrices(where: {currency: {currencyName_containsInsensitive: "KSM", currencyName_not_contains: "LKSM"}}) {
usdPrice
timestamp
currency {
currencyName
decimals
}
}
}
```
This will return on-chain prices of a particular token based on the pool depths at the timestamp. Updated hourly.
### Currencies
```
query MyQuery {
currencies {
currencyName
decimals
id
priceHistory(limit: 1, orderBy: timestamp_DESC, where: {currency: {}}) {
usdPrice
}
}
}
```
Currencies that are being displayed and their associated decimals and most recent price snapshot
### Token Liquidities
```
query MyQuery {
currLiquidities(orderBy: timestamp_DESC) {
liquidity
liquidityUSD
timestamp
currency {
currencyName
}
}
}
```
This will return the liquities for each currency on the platform
### Pool Liquidities
```
query MyQuery {
poolLiquidities(orderBy: timestamp_DESC) {
usdTotalLiquidity
token1Liquidity
token0Liquidity
timestamp
pool {
currency0
currency1
}
}
}
```
This will return the liquidities for a pool and the associated USD value for that time.
### Complex Queries
```
query MyQuery {
currencies {
id
currencyName
decimals
liquidityHistory(limit: 1, orderBy: timestamp_DESC) {
liquidityUSD
}
priceHistory(limit: 1, orderBy: timestamp_DESC) {
usdPrice
}
volumeDayHistory(limit: 1, orderBy: timestamp_DESC) {
volumeDayUSD
}
}
}
```
Many of the entities are derived from one another, so you can chain nested queries like the above. This will return each registered currency with the most uptodate price, volume and liquidity.