mirror of
https://github.com/lux-apps/papers.git
synced 2026-10-30 18:15:21 +00:00
Restructured from flat .tex/.pdf files into per-paper subdirectories. Added Antje Worring as co-author on all papers. Synced PDFs to pdfs/ for download site.
114 lines
2.1 KiB
TeX
114 lines
2.1 KiB
TeX
\section{Query Language Design}
|
|
|
|
|
|
\subsection{GraphQL Schema}
|
|
|
|
G-Chain exposes a unified GraphQL schema across all chains:
|
|
|
|
\begin{lstlisting}[language=GraphQL, basicstyle=\small\ttfamily]
|
|
type Query {
|
|
# Chain queries
|
|
chain(id: ChainID!): Chain
|
|
chains(filter: ChainFilter): [Chain!]!
|
|
|
|
# Cross-chain queries
|
|
asset(id: AssetID!, chain: ChainID!): Asset
|
|
crossChainTransfers(
|
|
from: ChainID!,
|
|
to: ChainID!,
|
|
after: Timestamp
|
|
): [Transfer!]!
|
|
|
|
# Address queries
|
|
address(id: Address!, chain: ChainID!): AddressInfo
|
|
addressBalances(
|
|
address: Address!,
|
|
chains: [ChainID!]
|
|
): [Balance!]!
|
|
|
|
# Advanced queries
|
|
pathBetween(
|
|
from: NodeID!,
|
|
to: NodeID!,
|
|
maxDepth: Int = 6
|
|
): [Path!]!
|
|
|
|
aggregateBy(
|
|
nodes: NodeFilter!,
|
|
groupBy: [String!]!,
|
|
aggregations: [Aggregation!]!
|
|
): [AggregateResult!]!
|
|
}
|
|
|
|
type Chain {
|
|
id: ChainID!
|
|
name: String!
|
|
blockHeight: BigInt!
|
|
totalTransactions: BigInt!
|
|
activeAddresses: BigInt!
|
|
tvl: BigInt!
|
|
}
|
|
|
|
type Asset {
|
|
id: AssetID!
|
|
chain: ChainID!
|
|
symbol: String!
|
|
decimals: Int!
|
|
totalSupply: BigInt!
|
|
holders: BigInt!
|
|
transfers: [Transfer!]!
|
|
}
|
|
\end{lstlisting}
|
|
|
|
\subsection{Example Queries}
|
|
|
|
\subsubsection{Cross-Chain Portfolio}
|
|
|
|
\begin{lstlisting}[language=GraphQL, basicstyle=\small\ttfamily]
|
|
query CrossChainPortfolio($address: Address!) {
|
|
addressBalances(address: $address, chains: [C, X, M, Z]) {
|
|
chain
|
|
asset { symbol, decimals }
|
|
balance
|
|
valueUSD
|
|
}
|
|
|
|
crossChainTransfers(
|
|
filter: {
|
|
or: [
|
|
{ from: $address },
|
|
{ to: $address }
|
|
]
|
|
}
|
|
) {
|
|
sourceChain
|
|
destChain
|
|
asset { symbol }
|
|
amount
|
|
timestamp
|
|
}
|
|
}
|
|
\end{lstlisting}
|
|
|
|
\subsubsection{DEX Analytics}
|
|
|
|
\begin{lstlisting}[language=GraphQL, basicstyle=\small\ttfamily]
|
|
query DEXAnalytics {
|
|
aggregateBy(
|
|
nodes: { type: "Swap", chain: X }
|
|
groupBy: ["pair"]
|
|
aggregations: [
|
|
{ field: "volume", op: SUM },
|
|
{ field: "fee", op: SUM },
|
|
{ field: "timestamp", op: COUNT }
|
|
]
|
|
) {
|
|
pair
|
|
totalVolume
|
|
totalFees
|
|
swapCount
|
|
}
|
|
}
|
|
\end{lstlisting}
|
|
|