mirror of
https://github.com/cerc-io/watcher-ts
synced 2024-11-19 12:26:19 +00:00
Uniswap queries/mapping analysis (#91)
* List down view method in uniswap core contracts. * List queries used in uniswap subgraph frontend. * Analyse uniswap subgraph entities with mappings. * Generate schema graphql file for uniswap subgraph. * Schema graphql for queries used in subgraph frontend. Co-authored-by: nikugogoi <95nikass@gmail.com>
This commit is contained in:
parent
a654b79df3
commit
69f4cf3513
198
packages/uniswap/README.md
Normal file
198
packages/uniswap/README.md
Normal file
@ -0,0 +1,198 @@
|
||||
# Uniswap
|
||||
|
||||
## Scripts
|
||||
|
||||
* **generate:schema**
|
||||
|
||||
Generate schema for uniswap subgraph in graphql format. The `get-graphql-schema` tool is used to generate the schema (https://github.com/prisma-labs/get-graphql-schema). The uniswap subgraph graphql endpoint is provided in the script to generate the schema.
|
||||
|
||||
* **lint:schema**
|
||||
|
||||
Lint schema graphql files.
|
||||
```bash
|
||||
$ yarn lint:schema frontend-schema.graphql
|
||||
```
|
||||
|
||||
## View Methods in Uniswap V3 Core
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-core/blob/main/contracts/NoDelegateCall.sol
|
||||
- checkNotDelegateCall (private)
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-core/blob/main/contracts/UniswapV3Pool.sol#L158
|
||||
- _blockTimestamp (internal)
|
||||
- balance0 (private)
|
||||
- balance1 (private)
|
||||
- snapshotCumulativesInside (external)
|
||||
- observe (external)
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-core/blob/main/contracts/libraries/Oracle.sol
|
||||
- binarySearch (private)
|
||||
- getSurroundingObservations (private)
|
||||
- observeSingle (internal)
|
||||
- observe (internal)
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-core/blob/main/contracts/libraries/Position.sol
|
||||
- get (internal)
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-core/blob/main/contracts/libraries/Tick.sol
|
||||
- getFeeGrowthInside (internal)
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-core/blob/main/contracts/libraries/TickBitmap.sol
|
||||
- nextInitializedTickWithinOneWord (internal)
|
||||
|
||||
## Queries in Uniswap subgraph frontend
|
||||
Actual queries are listed in [queries](./queries.md) file.
|
||||
|
||||
- uniswap-v3 endpoint (https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-v3-alt)
|
||||
* PoolDayData
|
||||
- poolDayDatas (https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/pools/chartData.ts)
|
||||
|
||||
* Pool
|
||||
- pools
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/pools/poolData.ts
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/pools/topPools.ts
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/search/index.ts
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/tokens/poolsForToken.ts
|
||||
- pool
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/pools/tickData.ts
|
||||
|
||||
* Tick
|
||||
- tick (https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/pools/tickData.ts)
|
||||
|
||||
* Mint
|
||||
- mints
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/pools/transactions.ts
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/tokens/transactions.ts
|
||||
|
||||
* UniswapDayData
|
||||
- uniswapDayDatas (https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/protocol/chart.ts)
|
||||
|
||||
* Factory
|
||||
- factories (https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/protocol/overview.ts)
|
||||
|
||||
* Transaction
|
||||
- transactions (https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/protocol/transactions.ts)
|
||||
|
||||
* Token
|
||||
- tokens
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/search/index.ts
|
||||
* (queried by block) https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/tokens/tokenData.ts
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/tokens/topTokens.ts
|
||||
- token queried by block (https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/tokens/priceData.ts)
|
||||
|
||||
* TokenDayData
|
||||
- tokenDayDatas (https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/tokens/chartData.ts)
|
||||
|
||||
* Bundle
|
||||
- bundle queried by block (https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/tokens/priceData.ts)
|
||||
- bundles (https://github.com/Uniswap/uniswap-v3-info/blob/master/src/hooks/useEthPrices.ts)
|
||||
|
||||
* TokenHourData
|
||||
- tokenHourDatas (https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/tokens/priceData.ts)
|
||||
|
||||
* Swap
|
||||
- swaps (https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/tokens/transactions.ts)
|
||||
|
||||
* Burn
|
||||
- burns (https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/tokens/transactions.ts)
|
||||
|
||||
- ethereum-blocks endpoint (https://api.thegraph.com/subgraphs/name/blocklytics/ethereum-blocks)
|
||||
|
||||
t${timestamp}:blocks (https://github.com/Uniswap/uniswap-v3-info/blob/master/src/hooks/useBlocksFromTimestamps.ts)
|
||||
|
||||
- Checking subgraph health (https://thegraph.com/docs/deploy-a-subgraph#checking-subgraph-health)
|
||||
|
||||
https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/application/index.ts#L5
|
||||
|
||||
## Mapping Event handlers in Uniswap subgraph
|
||||
|
||||
* handlePoolCreated (Factory contract - PoolCreated event)
|
||||
- Data from event
|
||||
- Entities
|
||||
* Factory
|
||||
* Bundle
|
||||
* Pool
|
||||
* Token
|
||||
- Contract calls
|
||||
* ERC20 (symbol, name, totalSupply, decimals)
|
||||
* ERC20SymbolBytes (symbol)
|
||||
* ERC20NameBytes (name)
|
||||
- Create new Template contract (Pool)
|
||||
|
||||
* NonfungiblePositionManager contract
|
||||
- Handlers (Similar code)
|
||||
* handleIncreaseLiquidity (IncreaseLiquidity event)
|
||||
* handleDecreaseLiquidity (DecreaseLiquidity event)
|
||||
* handleCollect (Collect event)
|
||||
* handleTransfer (Transfer event)
|
||||
- Data from event
|
||||
- Entities
|
||||
* Position
|
||||
* Transaction
|
||||
* Token
|
||||
- Contract calls
|
||||
* NonfungiblePositionManager (positions)
|
||||
* Factory (getPool)
|
||||
|
||||
* handleInitialize (Pool contract - Initialize event)
|
||||
- Data from event
|
||||
- Entities
|
||||
* Pool
|
||||
* Token
|
||||
* Bundle
|
||||
* PoolDayData
|
||||
* PoolHourData
|
||||
|
||||
* handleSwap (Pool contract - Swap event)
|
||||
- Data from event
|
||||
- Entities
|
||||
* Bundle
|
||||
* Factory
|
||||
* Pool
|
||||
* Token
|
||||
* Transaction
|
||||
* Swap
|
||||
* UniswapDayData
|
||||
* PoolDayData
|
||||
* PoolHourData
|
||||
* TokenDayData
|
||||
* TokenHourData
|
||||
- Contract calls
|
||||
* Pool (feeGrowthGlobal0X128, feeGrowthGlobal1X128)
|
||||
|
||||
* handleMint (Pool contract - Mint event)
|
||||
- Data from event
|
||||
- Entities
|
||||
* Bundle
|
||||
* Pool
|
||||
* Factory
|
||||
* Token
|
||||
* Transaction
|
||||
* Mint
|
||||
* Tick
|
||||
* UniswapDayData
|
||||
* PoolDayData
|
||||
* PoolHourData
|
||||
* TokenDayData
|
||||
* TokenHourData
|
||||
|
||||
* handleBurn (Pool contract - Burn event)
|
||||
- Data from event
|
||||
- Entities
|
||||
* Bundle
|
||||
* Pool
|
||||
* Factory
|
||||
* Token
|
||||
* Burn
|
||||
* Tick
|
||||
* UniswapDayData
|
||||
* PoolDayData
|
||||
* PoolHourData
|
||||
* TokenDayData
|
||||
* TokenHourData
|
||||
- Extra methods
|
||||
* store.remove (remove Tick entity)
|
||||
|
||||
## References
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-core
|
383
packages/uniswap/frontend-schema.graphql
Normal file
383
packages/uniswap/frontend-schema.graphql
Normal file
@ -0,0 +1,383 @@
|
||||
# lint-disable fields-have-descriptions, arguments-have-descriptions, types-have-descriptions, enum-values-all-caps, enum-values-have-descriptions, input-object-values-have-descriptions, input-object-values-are-camel-cased, relay-page-info-spec
|
||||
scalar BigDecimal
|
||||
|
||||
scalar BigInt
|
||||
|
||||
scalar Bytes
|
||||
|
||||
input Block_height {
|
||||
hash: Bytes
|
||||
number: Int
|
||||
}
|
||||
|
||||
type Pool {
|
||||
feeTier: BigInt!
|
||||
id: ID!
|
||||
liquidity: BigInt!
|
||||
sqrtPrice: BigInt!
|
||||
tick: BigInt
|
||||
token0: Token!
|
||||
token0Price: BigDecimal!
|
||||
token1: Token!
|
||||
token1Price: BigDecimal!
|
||||
totalValueLockedToken0: BigDecimal!
|
||||
totalValueLockedToken1: BigDecimal!
|
||||
totalValueLockedUSD: BigDecimal!
|
||||
txCount: BigInt!
|
||||
volumeUSD: BigDecimal!
|
||||
}
|
||||
|
||||
type PoolDayData {
|
||||
date: Int!
|
||||
id: ID!
|
||||
tvlUSD: BigDecimal!
|
||||
volumeUSD: BigDecimal!
|
||||
}
|
||||
|
||||
type Tick {
|
||||
id: ID!
|
||||
liquidityGross: BigInt!
|
||||
liquidityNet: BigInt!
|
||||
price0: BigDecimal!
|
||||
price1: BigDecimal!
|
||||
tickIdx: BigInt!
|
||||
}
|
||||
|
||||
type Mint {
|
||||
amount0: BigDecimal!
|
||||
amount1: BigDecimal!
|
||||
amountUSD: BigDecimal
|
||||
id: ID!
|
||||
origin: Bytes!
|
||||
owner: Bytes!
|
||||
pool: Pool!
|
||||
sender: Bytes
|
||||
timestamp: BigInt!
|
||||
transaction: Transaction!
|
||||
}
|
||||
|
||||
type Swap {
|
||||
amount0: BigDecimal!
|
||||
amount1: BigDecimal!
|
||||
amountUSD: BigDecimal!
|
||||
id: ID!
|
||||
origin: Bytes!
|
||||
pool: Pool!
|
||||
timestamp: BigInt!
|
||||
transaction: Transaction!
|
||||
}
|
||||
|
||||
type Burn {
|
||||
amount0: BigDecimal!
|
||||
amount1: BigDecimal!
|
||||
amountUSD: BigDecimal
|
||||
id: ID!
|
||||
origin: Bytes!
|
||||
owner: Bytes
|
||||
pool: Pool!
|
||||
timestamp: BigInt!
|
||||
transaction: Transaction!
|
||||
}
|
||||
|
||||
type UniswapDayData {
|
||||
date: Int!
|
||||
id: ID!
|
||||
tvlUSD: BigDecimal!
|
||||
volumeUSD: BigDecimal!
|
||||
}
|
||||
|
||||
type Factory {
|
||||
id: ID!
|
||||
totalFeesUSD: BigDecimal!
|
||||
totalValueLockedUSD: BigDecimal!
|
||||
totalVolumeUSD: BigDecimal!
|
||||
txCount: BigInt!
|
||||
}
|
||||
|
||||
type Transaction {
|
||||
burns(skip: Int = 0, first: Int = 100, orderBy: Burn_orderBy, orderDirection: OrderDirection, where: Burn_filter): [Burn]!
|
||||
id: ID!
|
||||
mints(skip: Int = 0, first: Int = 100, orderBy: Mint_orderBy, orderDirection: OrderDirection, where: Mint_filter): [Mint]!
|
||||
swaps(skip: Int = 0, first: Int = 100, orderBy: Swap_orderBy, orderDirection: OrderDirection, where: Swap_filter): [Swap]!
|
||||
timestamp: BigInt!
|
||||
}
|
||||
|
||||
type Token {
|
||||
derivedETH: BigDecimal!
|
||||
feesUSD: BigDecimal!
|
||||
id: ID!
|
||||
name: String!
|
||||
symbol: String!
|
||||
totalValueLocked: BigDecimal!
|
||||
totalValueLockedUSD: BigDecimal!
|
||||
txCount: BigInt!
|
||||
volume: BigDecimal!
|
||||
volumeUSD: BigDecimal!
|
||||
}
|
||||
|
||||
type TokenDayData {
|
||||
date: Int!
|
||||
id: ID!
|
||||
totalValueLockedUSD: BigDecimal!
|
||||
volumeUSD: BigDecimal!
|
||||
}
|
||||
|
||||
type Bundle {
|
||||
ethPriceUSD: BigDecimal!
|
||||
id: ID!
|
||||
}
|
||||
|
||||
type TokenHourData {
|
||||
close: BigDecimal!
|
||||
high: BigDecimal!
|
||||
id: ID!
|
||||
low: BigDecimal!
|
||||
open: BigDecimal!
|
||||
periodStartUnix: Int!
|
||||
}
|
||||
|
||||
enum OrderDirection {
|
||||
asc
|
||||
desc
|
||||
}
|
||||
|
||||
input PoolDayData_filter {
|
||||
date_gt: Int
|
||||
pool: String
|
||||
}
|
||||
|
||||
enum PoolDayData_orderBy {
|
||||
date
|
||||
}
|
||||
|
||||
input Pool_filter {
|
||||
id: ID
|
||||
id_in: [ID!]
|
||||
token0: String
|
||||
token0_in: [String!]
|
||||
token1: String
|
||||
token1_in: [String!]
|
||||
}
|
||||
|
||||
enum Pool_orderBy {
|
||||
totalValueLockedUSD
|
||||
}
|
||||
|
||||
input Tick_filter {
|
||||
poolAddress: String
|
||||
tickIdx_gte: BigInt
|
||||
tickIdx_lte: BigInt
|
||||
}
|
||||
|
||||
input Mint_filter {
|
||||
pool: String
|
||||
token0: String
|
||||
token1: String
|
||||
}
|
||||
|
||||
enum Mint_orderBy {
|
||||
timestamp
|
||||
}
|
||||
|
||||
input Swap_filter {
|
||||
pool: String
|
||||
token0: String
|
||||
token1: String
|
||||
}
|
||||
|
||||
enum Swap_orderBy {
|
||||
timestamp
|
||||
}
|
||||
|
||||
input Burn_filter {
|
||||
pool: String
|
||||
token0: String
|
||||
token1: String
|
||||
}
|
||||
|
||||
enum Burn_orderBy {
|
||||
timestamp
|
||||
}
|
||||
|
||||
enum UniswapDayData_orderBy {
|
||||
date
|
||||
}
|
||||
|
||||
input UniswapDayData_filter {
|
||||
date_gt: Int
|
||||
}
|
||||
|
||||
enum Transaction_orderBy {
|
||||
timestamp
|
||||
}
|
||||
|
||||
input Token_filter {
|
||||
id: ID
|
||||
id_in: [ID!]
|
||||
name_contains: String
|
||||
symbol_contains: String
|
||||
}
|
||||
|
||||
enum Token_orderBy {
|
||||
totalValueLockedUSD
|
||||
}
|
||||
|
||||
input TokenDayData_filter {
|
||||
date_gt: Int
|
||||
token: String
|
||||
}
|
||||
|
||||
enum TokenDayData_orderBy {
|
||||
date
|
||||
}
|
||||
|
||||
input TokenHourData_filter {
|
||||
periodStartUnix_gt: Int
|
||||
token: String
|
||||
}
|
||||
|
||||
enum TokenHourData_orderBy {
|
||||
periodStartUnix
|
||||
}
|
||||
|
||||
type Query {
|
||||
bundle(
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
The block at which the query should be executed. Can either be an `{ number:
|
||||
Int }` containing the block number or a `{ hash: Bytes }` value containing a
|
||||
block hash. Defaults to the latest block when omitted.
|
||||
"""
|
||||
block: Block_height
|
||||
): Bundle
|
||||
|
||||
bundles(
|
||||
first: Int = 100
|
||||
|
||||
"""
|
||||
The block at which the query should be executed. Can either be an `{ number:
|
||||
Int }` containing the block number or a `{ hash: Bytes }` value containing a
|
||||
block hash. Defaults to the latest block when omitted.
|
||||
"""
|
||||
block: Block_height
|
||||
): [Bundle!]!
|
||||
|
||||
burns(
|
||||
first: Int = 100
|
||||
orderBy: Burn_orderBy
|
||||
orderDirection: OrderDirection
|
||||
where: Burn_filter
|
||||
): [Burn!]!
|
||||
|
||||
factories(
|
||||
first: Int = 100
|
||||
|
||||
"""
|
||||
The block at which the query should be executed. Can either be an `{ number:
|
||||
Int }` containing the block number or a `{ hash: Bytes }` value containing a
|
||||
block hash. Defaults to the latest block when omitted.
|
||||
"""
|
||||
block: Block_height
|
||||
): [Factory!]!
|
||||
|
||||
mints(
|
||||
first: Int = 100
|
||||
orderBy: Mint_orderBy
|
||||
orderDirection: OrderDirection
|
||||
where: Mint_filter
|
||||
): [Mint!]!
|
||||
|
||||
pool(
|
||||
id: ID!
|
||||
): Pool
|
||||
|
||||
poolDayDatas(
|
||||
skip: Int = 0
|
||||
first: Int = 100
|
||||
orderBy: PoolDayData_orderBy
|
||||
orderDirection: OrderDirection
|
||||
where: PoolDayData_filter
|
||||
): [PoolDayData!]!
|
||||
|
||||
pools(
|
||||
first: Int = 100
|
||||
orderBy: Pool_orderBy
|
||||
orderDirection: OrderDirection
|
||||
where: Pool_filter
|
||||
|
||||
"""
|
||||
The block at which the query should be executed. Can either be an `{ number:
|
||||
Int }` containing the block number or a `{ hash: Bytes }` value containing a
|
||||
block hash. Defaults to the latest block when omitted.
|
||||
"""
|
||||
block: Block_height
|
||||
): [Pool!]!
|
||||
|
||||
swaps(
|
||||
first: Int = 100
|
||||
orderBy: Swap_orderBy
|
||||
orderDirection: OrderDirection
|
||||
where: Swap_filter
|
||||
): [Swap!]!
|
||||
|
||||
ticks(
|
||||
skip: Int = 0
|
||||
first: Int = 100
|
||||
where: Tick_filter
|
||||
|
||||
"""
|
||||
The block at which the query should be executed. Can either be an `{ number:
|
||||
Int }` containing the block number or a `{ hash: Bytes }` value containing a
|
||||
block hash. Defaults to the latest block when omitted.
|
||||
"""
|
||||
block: Block_height
|
||||
): [Tick!]!
|
||||
|
||||
token(
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
The block at which the query should be executed. Can either be an `{ number:
|
||||
Int }` containing the block number or a `{ hash: Bytes }` value containing a
|
||||
block hash. Defaults to the latest block when omitted.
|
||||
"""
|
||||
block: Block_height
|
||||
): Token
|
||||
|
||||
tokenDayDatas(
|
||||
skip: Int = 0
|
||||
first: Int = 100
|
||||
orderBy: TokenDayData_orderBy
|
||||
orderDirection: OrderDirection
|
||||
where: TokenDayData_filter
|
||||
): [TokenDayData!]!
|
||||
|
||||
tokenHourDatas(
|
||||
skip: Int = 0
|
||||
first: Int = 100
|
||||
orderBy: TokenHourData_orderBy
|
||||
orderDirection: OrderDirection
|
||||
where: TokenHourData_filter
|
||||
): [TokenHourData!]!
|
||||
|
||||
tokens(
|
||||
orderBy: Token_orderBy
|
||||
orderDirection: OrderDirection
|
||||
where: Token_filter
|
||||
): [Token!]!
|
||||
|
||||
transactions(
|
||||
first: Int = 100
|
||||
orderBy: Transaction_orderBy
|
||||
orderDirection: OrderDirection
|
||||
): [Transaction!]!
|
||||
|
||||
uniswapDayDatas(
|
||||
skip: Int = 0
|
||||
first: Int = 100
|
||||
orderBy: UniswapDayData_orderBy
|
||||
orderDirection: OrderDirection
|
||||
where: UniswapDayData_filter
|
||||
): [UniswapDayData!]!
|
||||
}
|
14
packages/uniswap/package.json
Normal file
14
packages/uniswap/package.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "@vulcanize/uniswap",
|
||||
"version": "0.1.0",
|
||||
"main": "index.js",
|
||||
"license": "UNLICENSED",
|
||||
"scripts": {
|
||||
"generate:schema": "get-graphql-schema https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-v3-alt > schema.graphql",
|
||||
"lint:schema": "graphql-schema-linter"
|
||||
},
|
||||
"devDependencies": {
|
||||
"get-graphql-schema": "^2.1.2",
|
||||
"graphql-schema-linter": "^2.0.1"
|
||||
}
|
||||
}
|
595
packages/uniswap/queries.md
Normal file
595
packages/uniswap/queries.md
Normal file
@ -0,0 +1,595 @@
|
||||
## Queries
|
||||
|
||||
- uniswap-v3 endpoint (https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-v3-alt)
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/pools/chartData.ts
|
||||
```
|
||||
query poolDayDatas($startTime: Int!, $skip: Int!, $address: Bytes!) {
|
||||
poolDayDatas(
|
||||
first: 1000
|
||||
skip: $skip
|
||||
where: { pool: $address, date_gt: $startTime }
|
||||
orderBy: date
|
||||
orderDirection: asc
|
||||
) {
|
||||
date
|
||||
volumeUSD
|
||||
tvlUSD
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/pools/poolData.ts
|
||||
```
|
||||
query pools {
|
||||
pools(where: {id_in: $poolString}, block: {number: $block}, orderBy: totalValueLockedUSD, orderDirection: desc) {
|
||||
id
|
||||
feeTier
|
||||
liquidity
|
||||
sqrtPrice
|
||||
tick
|
||||
token0 {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
decimals
|
||||
derivedETH
|
||||
}
|
||||
token1 {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
decimals
|
||||
derivedETH
|
||||
}
|
||||
token0Price
|
||||
token1Price
|
||||
volumeUSD
|
||||
txCount
|
||||
totalValueLockedToken0
|
||||
totalValueLockedToken1
|
||||
totalValueLockedUSD
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/pools/tickData.ts
|
||||
```
|
||||
query surroundingTicks(
|
||||
$poolAddress: String!
|
||||
$tickIdxLowerBound: BigInt!
|
||||
$tickIdxUpperBound: BigInt!
|
||||
$skip: Int!
|
||||
) {
|
||||
ticks(
|
||||
first: 1000
|
||||
skip: $skip
|
||||
where: { poolAddress: $poolAddress, tickIdx_lte: $tickIdxUpperBound, tickIdx_gte: $tickIdxLowerBound }
|
||||
) {
|
||||
tickIdx
|
||||
liquidityGross
|
||||
liquidityNet
|
||||
price0
|
||||
price1
|
||||
}
|
||||
}
|
||||
|
||||
query pool($poolAddress: String!) {
|
||||
pool(id: $poolAddress) {
|
||||
tick
|
||||
token0 {
|
||||
symbol
|
||||
id
|
||||
decimals
|
||||
}
|
||||
token1 {
|
||||
symbol
|
||||
id
|
||||
decimals
|
||||
}
|
||||
feeTier
|
||||
sqrtPrice
|
||||
liquidity
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/pools/topPools.ts
|
||||
```
|
||||
query topPools {
|
||||
pools(first: 50, orderBy: totalValueLockedUSD, orderDirection: desc) {
|
||||
id
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/pools/transactions.ts
|
||||
```
|
||||
query transactions($address: Bytes!) {
|
||||
mints(first: 100, orderBy: timestamp, orderDirection: desc, where: { pool: $address }) {
|
||||
timestamp
|
||||
transaction {
|
||||
id
|
||||
}
|
||||
pool {
|
||||
token0 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
token1 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
}
|
||||
owner
|
||||
sender
|
||||
origin
|
||||
amount0
|
||||
amount1
|
||||
amountUSD
|
||||
}
|
||||
swaps(first: 100, orderBy: timestamp, orderDirection: desc, where: { pool: $address }) {
|
||||
timestamp
|
||||
transaction {
|
||||
id
|
||||
}
|
||||
pool {
|
||||
token0 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
token1 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
}
|
||||
origin
|
||||
amount0
|
||||
amount1
|
||||
amountUSD
|
||||
}
|
||||
burns(first: 100, orderBy: timestamp, orderDirection: desc, where: { pool: $address }) {
|
||||
timestamp
|
||||
transaction {
|
||||
id
|
||||
}
|
||||
pool {
|
||||
token0 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
token1 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
}
|
||||
owner
|
||||
amount0
|
||||
amount1
|
||||
amountUSD
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/protocol/chart.ts
|
||||
```
|
||||
query uniswapDayDatas($startTime: Int!, $skip: Int!) {
|
||||
uniswapDayDatas(first: 1000, skip: $skip, where: { date_gt: $startTime }, orderBy: date, orderDirection: asc) {
|
||||
id
|
||||
date
|
||||
volumeUSD
|
||||
tvlUSD
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/protocol/overview.ts
|
||||
```
|
||||
query uniswapFactories {
|
||||
factories(
|
||||
block: { number: $block }
|
||||
first: 1) {
|
||||
txCount
|
||||
totalVolumeUSD
|
||||
totalFeesUSD
|
||||
totalValueLockedUSD
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/protocol/transactions.ts
|
||||
```
|
||||
query transactions {
|
||||
transactions(first: 500, orderBy: timestamp, orderDirection: desc) {
|
||||
id
|
||||
timestamp
|
||||
mints {
|
||||
pool {
|
||||
token0 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
token1 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
}
|
||||
owner
|
||||
sender
|
||||
origin
|
||||
amount0
|
||||
amount1
|
||||
amountUSD
|
||||
}
|
||||
swaps {
|
||||
pool {
|
||||
token0 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
token1 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
}
|
||||
origin
|
||||
amount0
|
||||
amount1
|
||||
amountUSD
|
||||
}
|
||||
burns {
|
||||
pool {
|
||||
token0 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
token1 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
}
|
||||
owner
|
||||
origin
|
||||
amount0
|
||||
amount1
|
||||
amountUSD
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/search/index.ts
|
||||
```
|
||||
query tokens($value: String, $id: String) {
|
||||
asSymbol: tokens(where: { symbol_contains: $value }, orderBy: totalValueLockedUSD, orderDirection: desc) {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
totalValueLockedUSD
|
||||
}
|
||||
asName: tokens(where: { name_contains: $value }, orderBy: totalValueLockedUSD, orderDirection: desc) {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
totalValueLockedUSD
|
||||
}
|
||||
asAddress: tokens(where: { id: $id }, orderBy: totalValueLockedUSD, orderDirection: desc) {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
totalValueLockedUSD
|
||||
}
|
||||
}
|
||||
|
||||
query pools($tokens: [Bytes]!, $id: String) {
|
||||
as0: pools(where: { token0_in: $tokens }) {
|
||||
id
|
||||
feeTier
|
||||
token0 {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
}
|
||||
token1 {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
}
|
||||
}
|
||||
as1: pools(where: { token1_in: $tokens }) {
|
||||
id
|
||||
feeTier
|
||||
token0 {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
}
|
||||
token1 {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
}
|
||||
}
|
||||
asAddress: pools(where: { id: $id }) {
|
||||
id
|
||||
feeTier
|
||||
token0 {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
}
|
||||
token1 {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/tokens/chartData.ts
|
||||
```
|
||||
query tokenDayDatas($startTime: Int!, $skip: Int!, $address: Bytes!) {
|
||||
tokenDayDatas(
|
||||
first: 1000
|
||||
skip: $skip
|
||||
where: { token: $address, date_gt: $startTime }
|
||||
orderBy: date
|
||||
orderDirection: asc
|
||||
) {
|
||||
date
|
||||
volumeUSD
|
||||
totalValueLockedUSD
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/tokens/poolsForToken.ts
|
||||
```
|
||||
query topPools($address: Bytes!) {
|
||||
asToken0: pools(first: 200, orderBy: totalValueLockedUSD, orderDirection: desc, where: { token0: $address }) {
|
||||
id
|
||||
}
|
||||
asToken1: pools(first: 200, orderBy: totalValueLockedUSD, orderDirection: desc, where: { token1: $address }) {
|
||||
id
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/tokens/priceData.ts
|
||||
```
|
||||
query blocks {
|
||||
tBlockTimestamp:token(id:$tokenAddress, block: { number: $blockNumber }) {
|
||||
derivedETH
|
||||
},
|
||||
bBlockTimestamp: bundle(id:"1", block: { number: $blockNumber }) {
|
||||
ethPriceUSD
|
||||
}
|
||||
}
|
||||
|
||||
query tokenHourDatas($startTime: Int!, $skip: Int!, $address: Bytes!) {
|
||||
tokenHourDatas(
|
||||
first: 100
|
||||
skip: $skip
|
||||
where: { token: $address, periodStartUnix_gt: $startTime }
|
||||
orderBy: periodStartUnix
|
||||
orderDirection: asc
|
||||
) {
|
||||
periodStartUnix
|
||||
high
|
||||
low
|
||||
open
|
||||
close
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/tokens/tokenData.ts
|
||||
```
|
||||
query tokens {
|
||||
tokens(where: {id_in: $tokenString}, block: {number: $block}), orderBy: totalValueLockedUSD, orderDirection: desc) {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
derivedETH
|
||||
volumeUSD
|
||||
volume
|
||||
txCount
|
||||
totalValueLocked
|
||||
feesUSD
|
||||
totalValueLockedUSD
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/tokens/topTokens.ts
|
||||
```
|
||||
query topPools {
|
||||
tokens(first: 50, orderBy: totalValueLockedUSD, orderDirection: desc) {
|
||||
id
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/tokens/transactions.ts
|
||||
```
|
||||
query transactions($address: Bytes!) {
|
||||
mintsAs0: mints(first: 500, orderBy: timestamp, orderDirection: desc, where: { token0: $address }) {
|
||||
timestamp
|
||||
transaction {
|
||||
id
|
||||
}
|
||||
pool {
|
||||
token0 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
token1 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
}
|
||||
owner
|
||||
sender
|
||||
origin
|
||||
amount0
|
||||
amount1
|
||||
amountUSD
|
||||
}
|
||||
mintsAs1: mints(first: 500, orderBy: timestamp, orderDirection: desc, where: { token0: $address }) {
|
||||
timestamp
|
||||
transaction {
|
||||
id
|
||||
}
|
||||
pool {
|
||||
token0 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
token1 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
}
|
||||
owner
|
||||
sender
|
||||
origin
|
||||
amount0
|
||||
amount1
|
||||
amountUSD
|
||||
}
|
||||
swapsAs0: swaps(first: 500, orderBy: timestamp, orderDirection: desc, where: { token0: $address }) {
|
||||
timestamp
|
||||
transaction {
|
||||
id
|
||||
}
|
||||
pool {
|
||||
token0 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
token1 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
}
|
||||
origin
|
||||
amount0
|
||||
amount1
|
||||
amountUSD
|
||||
}
|
||||
swapsAs1: swaps(first: 500, orderBy: timestamp, orderDirection: desc, where: { token1: $address }) {
|
||||
timestamp
|
||||
transaction {
|
||||
id
|
||||
}
|
||||
pool {
|
||||
token0 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
token1 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
}
|
||||
origin
|
||||
amount0
|
||||
amount1
|
||||
amountUSD
|
||||
}
|
||||
burnsAs0: burns(first: 500, orderBy: timestamp, orderDirection: desc, where: { token0: $address }) {
|
||||
timestamp
|
||||
transaction {
|
||||
id
|
||||
}
|
||||
pool {
|
||||
token0 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
token1 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
}
|
||||
owner
|
||||
amount0
|
||||
amount1
|
||||
amountUSD
|
||||
}
|
||||
burnsAs1: burns(first: 500, orderBy: timestamp, orderDirection: desc, where: { token1: $address }) {
|
||||
timestamp
|
||||
transaction {
|
||||
id
|
||||
}
|
||||
pool {
|
||||
token0 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
token1 {
|
||||
id
|
||||
symbol
|
||||
}
|
||||
}
|
||||
owner
|
||||
amount0
|
||||
amount1
|
||||
amountUSD
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* https://github.com/Uniswap/uniswap-v3-info/blob/master/src/hooks/useEthPrices.ts
|
||||
```
|
||||
query prices($block24: Int!, $block48: Int!, $blockWeek: Int!) {
|
||||
current: bundles(first: 1) {
|
||||
ethPriceUSD
|
||||
}
|
||||
oneDay: bundles(first: 1, block: { number: $block24 }) {
|
||||
ethPriceUSD
|
||||
}
|
||||
twoDay: bundles(first: 1, block: { number: $block48 }) {
|
||||
ethPriceUSD
|
||||
}
|
||||
oneWeek: bundles(first: 1, block: { number: $blockWeek }) {
|
||||
ethPriceUSD
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- ethereum-blocks endpoint (https://api.thegraph.com/subgraphs/name/blocklytics/ethereum-blocks)
|
||||
|
||||
https://github.com/Uniswap/uniswap-v3-info/blob/master/src/hooks/useBlocksFromTimestamps.ts
|
||||
```
|
||||
query blocks {
|
||||
tTimestamp1:blocks(first: 1, orderBy: timestamp, orderDirection: desc, where: { timestamp_gt: $timestamp1, timestamp_lt: $timestamp1Plus600 }) {
|
||||
number
|
||||
}
|
||||
|
||||
tTimestamp2:blocks(first: 1, orderBy: timestamp, orderDirection: desc, where: { timestamp_gt: $timestamp2, timestamp_lt: $timestamp2Plus600 }) {
|
||||
number
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- Checking subgraph health (https://thegraph.com/docs/deploy-a-subgraph#checking-subgraph-health)
|
||||
|
||||
https://github.com/Uniswap/uniswap-v3-info/blob/master/src/data/application/index.ts
|
||||
```
|
||||
query health {
|
||||
indexingStatusForCurrentVersion(subgraphName: "uniswap/uniswap-v2") {
|
||||
synced
|
||||
health
|
||||
chains {
|
||||
chainHeadBlock {
|
||||
number
|
||||
}
|
||||
latestBlock {
|
||||
number
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
3995
packages/uniswap/schema.graphql
Normal file
3995
packages/uniswap/schema.graphql
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user