0.1.5 • Published 2 years ago
gurram-swap v0.1.5
Gurram swap []
Typescript library for interacting with the uniswap V3 subgraphs.
Gurram swap is a library for querying the uniswap v3 subgraph.
- It supports the Ethereum mainnet as wells as L2 networks like Polygon and Optimism.
- injects summaries for positions (liquidity in fiat, uncollected fees etc).
- uses bignumber.js to represent big numbers. Handles two's complement where necessary.
Installation
npm install gurram-swap --save
Usage example
// Use the provided clients
import { clients, EthereumNetworkName } from "gurram-swap";
const client = await clients[EthereumNetworkName.Mainnet];
// OR create a new instance
const network = EthereumNetworkName.Polygon;
const client = new Unigraph(network);
// get first 100 pools
const results = await graph.getPairs({ pageSize: 100});
// get summaries for positions
const positions = await graph.getPositions({ address: "0xaddress", summaries: true});
// Custom graphql query
const query = `
query {
pools(first: 5){
id
token0{
symbol
}
token1{
symbol
}
}
}
`;
const pools = await underTest.rawQuery<Pool[]>({ query, mapper: "Pool" });
Known issues
- Position summary is in alpha. When liquidity is added or removed, position summary will be incorrect.
- Q128.128 resolution of
feeGrowthX
is probably innacurate in some cases.
Release History
0.1.4
- Fix for rawQuery variables parameter
0.1.3
- Unigraph.rawQuery
0.1.0
- The first proper release
Meta
Abhijith Reddy – @archerabi
Distributed under the MIT license. See LICENSE
for more information.