Initial commit: add .gitignore and README
This commit is contained in:
146
examples/subgraphs/cross-protocol-analytics.graphql
Normal file
146
examples/subgraphs/cross-protocol-analytics.graphql
Normal file
@@ -0,0 +1,146 @@
|
||||
# Cross-Protocol Analytics: Query data across multiple protocols
|
||||
#
|
||||
# This is a conceptual example showing how you might query multiple subgraphs
|
||||
# to analyze cross-protocol strategies and positions.
|
||||
#
|
||||
# In production, you would:
|
||||
# 1. Query multiple subgraphs (Uniswap, Aave, etc.)
|
||||
# 2. Combine the data
|
||||
# 3. Calculate metrics like:
|
||||
# - Total TVL across protocols
|
||||
# - Cross-protocol arbitrage opportunities
|
||||
# - User positions across protocols
|
||||
# - Protocol interaction patterns
|
||||
|
||||
# Example: Query user's Aave position and Uniswap LP positions
|
||||
# (This would require querying two separate subgraphs and combining results)
|
||||
|
||||
# Query 1: Get user's Aave positions
|
||||
# (Use Aave subgraph - see aave-positions.graphql)
|
||||
|
||||
# Query 2: Get user's Uniswap v3 positions
|
||||
query GetUserUniswapPositions($userAddress: String!) {
|
||||
positions(
|
||||
where: { owner: $userAddress }
|
||||
first: 100
|
||||
) {
|
||||
id
|
||||
owner
|
||||
pool {
|
||||
id
|
||||
token0 {
|
||||
symbol
|
||||
}
|
||||
token1 {
|
||||
symbol
|
||||
}
|
||||
feeTier
|
||||
}
|
||||
liquidity
|
||||
depositedToken0
|
||||
depositedToken1
|
||||
withdrawnToken0
|
||||
withdrawnToken1
|
||||
collectedFeesToken0
|
||||
collectedFeesToken1
|
||||
transaction {
|
||||
timestamp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Query 3: Get protocol volumes (for analytics)
|
||||
query GetProtocolVolumes {
|
||||
# Uniswap volume (example)
|
||||
uniswapDayDatas(
|
||||
orderBy: date
|
||||
orderDirection: desc
|
||||
first: 30
|
||||
) {
|
||||
date
|
||||
dailyVolumeUSD
|
||||
totalVolumeUSD
|
||||
tvlUSD
|
||||
}
|
||||
|
||||
# Aave volume (example - would need Aave subgraph)
|
||||
# aaveDayDatas {
|
||||
# date
|
||||
# dailyDepositsUSD
|
||||
# dailyBorrowsUSD
|
||||
# totalValueLockedUSD
|
||||
# }
|
||||
}
|
||||
|
||||
# Query 4: Get token prices across protocols
|
||||
query GetTokenPrices($tokenAddress: String!) {
|
||||
# Uniswap price
|
||||
token(id: $tokenAddress) {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
decimals
|
||||
derivedETH
|
||||
poolCount
|
||||
totalValueLocked
|
||||
totalValueLockedUSD
|
||||
volume
|
||||
volumeUSD
|
||||
feesUSD
|
||||
txCount
|
||||
pools {
|
||||
id
|
||||
token0 {
|
||||
symbol
|
||||
}
|
||||
token1 {
|
||||
symbol
|
||||
}
|
||||
token0Price
|
||||
token1Price
|
||||
totalValueLockedUSD
|
||||
}
|
||||
}
|
||||
|
||||
# Aave reserve price (would need Aave subgraph)
|
||||
# reserve(id: $tokenAddress) {
|
||||
# id
|
||||
# symbol
|
||||
# price {
|
||||
# priceInUsd
|
||||
# }
|
||||
# }
|
||||
}
|
||||
|
||||
# Query 5: Get arbitrage opportunities
|
||||
# (Conceptual - would require real-time price comparison)
|
||||
query GetArbitrageOpportunities {
|
||||
# Get pools with significant price differences
|
||||
# This is a simplified example - real arbitrage detection is more complex
|
||||
pools(
|
||||
where: {
|
||||
# Filter by high volume and liquidity
|
||||
totalValueLockedUSD_gt: "1000000"
|
||||
volumeUSD_gt: "100000"
|
||||
}
|
||||
orderBy: volumeUSD
|
||||
orderDirection: desc
|
||||
first: 50
|
||||
) {
|
||||
id
|
||||
token0 {
|
||||
symbol
|
||||
}
|
||||
token1 {
|
||||
symbol
|
||||
}
|
||||
token0Price
|
||||
token1Price
|
||||
feeTier
|
||||
volumeUSD
|
||||
tvlUSD
|
||||
# Compare with prices from other DEXes/AMMs
|
||||
# (would require additional queries)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user