unigraphclient

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 8 Imported by: 0

README

go-uniswap-subgraph-client

A Go library for querying Uniswap v3 subgraphs.

Installation

$ go get github.com/emersonmacro/go-uniswap-subgraph-client

Basic Usage

import (
  "context"
  "fmt"

  unigraphclient "github.com/emersonmacro/go-uniswap-subgraph-client"
)

poolId := "0xc2e9f25be6257c210d7adf0d4cd6e3e881ba25f8"
endpoint := unigraphclient.Endpoints[unigraphclient.Ethereum]

client := unigraphclient.NewClient(endpoint, nil)

requestOpts := &unigraphclient.RequestOptions{
  IncludeFields: []string{"*"},
}
response, err := client.GetPoolById(context.Background(), poolId, requestOpts)

fmt.Println(response.Pool.ID) // 0xc2e9f25be6257c210d7adf0d4cd6e3e881ba25f8
fmt.Println(response.Pool.Token0.Symbol) // DAI
fmt.Println(response.Pool.Token1.Symbol) // WETH
fmt.Println(response.Pool.VolumeUSD) // 12790614690.20250028366283473022774

All Uniswap v3 models are supported. Each model can by queried by ID (Get<Model>ById) or as a list (List<Model>). This is the full list of models:

Factory
Pool
Token
Bundle
Tick
Position
PositionSnapshot
Transaction
Mint
Burn
Swap
Collect
Flash
UniswapDayData
PoolDayData
PoolHourData
TickHourData
TickDayData
TokenDayData
TokenHourData

See the test directory for more usage examples.

Known Issues

  • Derived fields are currently not supported
  • where clauses are currently not supported
  • All response fields are returned as strings, regardless of their underlying type. See the converter package for some utility functions for converting to *big.Int or *big.Float

Client Options

type ClientOptions struct {
  HttpClient *http.Client // option to pass in your own http client (http.DefaultClient by default)
  CloseReq   bool // option to close the request immediately
}

func NewClient(url string, opts *ClientOptions) *Client

Request Options

There are two ways to specify the fields you want to be included in the query. IncludeFields can be used to "opt in" to the fields you want, and "*" is a valid option to include all fields. Alternatively, you can include all fields and then exclude certain fields ("opt out") with ExcludeFields.

You can query data at a particular block with the Block option. For List* queries, pagination is supported with the First and Skip options, and sorting is supported with the OrderBy and OrderDir options.

type RequestOptions struct {
  IncludeFields []string // fields to include in the query. '*' is a valid option meaning 'include all fields'. if any fields are listed in IncludeFields besides '*', ExcludeFields must be empty.
  ExcludeFields []string // fields to exclude from the query. only valid when '*' is in IncludeFields.
  Block         int      // query for data at a specific block number.
  First         int      // number of results to retrieve. `100` is the default. only valid for List queries.
  Skip          int      // number of results to skip. `0` is the default. only valid for List queries.
  OrderBy       string   // field to order by. `id` is the default. only valid for List queries.
  OrderDir      string   // order direction. `asc` for ascending and `desc` for descending are the only valid options. `asc` is the default. only valid for List queries.
}

Endpoints

When creating a new client, you can specify any subgraph endpoint that supports a Uniswap v3 schema:

client := unigraphclient.NewClient("https://<my graphql host>", nil)

For convenience, you can also use one of the provided endpoints, which are the same as the endpoints used in the Uniswap Info site:

// e.g.:
endpoint := unigraphclient.Endpoints[unigraphclient.Ethereum] // https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3
// or
endpoint := unigraphclient.Endpoints[unigraphclient.Arbitrum] // https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-arbitrum-one
// or
endpoint := unigraphclient.Endpoints[unigraphclient.Optimism] // https://api.thegraph.com/subgraphs/name/ianlapham/optimism-post-regenesis
// or
endpoint := unigraphclient.Endpoints[unigraphclient.Polygon] // https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-v3-polygon
// or
endpoint := unigraphclient.Endpoints[unigraphclient.Base] // https://api.studio.thegraph.com/query/48211/uniswap-v3-base/version/latest
// or
endpoint := unigraphclient.Endpoints[unigraphclient.Celo] // https://api.thegraph.com/subgraphs/name/jesse-sawa/uniswap-celo
// or
endpoint := unigraphclient.Endpoints[unigraphclient.Avalanche] //https://api.thegraph.com/subgraphs/name/lynnshaoyu/uniswap-v3-avax
// or
endpoint := unigraphclient.Endpoints[unigraphclient.Bnb] // https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-v3-bsc

client := unigraphclient.NewClient(endpoint, nil)

Converter utility functions

func StringToBigInt(s string) (*big.Int, error)
func StringToBigFloat(s string) (*big.Float, error)
func ModelToJsonBytes(model any) ([]byte, error)
func ModelToJsonString(model any) (string, error)

Resources

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BundleFields modelFields = modelFields{
	// contains filtered or unexported fields
}
View Source
var BurnFields modelFields = modelFields{
	// contains filtered or unexported fields
}
View Source
var CollectFields modelFields = modelFields{
	// contains filtered or unexported fields
}
View Source
var Endpoints map[Endpoint]string = map[Endpoint]string{
	Ethereum:  "https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3",
	Arbitrum:  "https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-arbitrum-one",
	Optimism:  "https://api.thegraph.com/subgraphs/name/ianlapham/optimism-post-regenesis",
	Polygon:   "https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-v3-polygon",
	Celo:      "https://api.thegraph.com/subgraphs/name/jesse-sawa/uniswap-celo",
	Bnb:       "https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-v3-bsc",
	Base:      "https://api.studio.thegraph.com/query/48211/uniswap-v3-base/version/latest",
	Avalanche: "https://api.thegraph.com/subgraphs/name/lynnshaoyu/uniswap-v3-avax",
}

endpoints map (values from https://github.com/Uniswap/v3-info/blob/master/src/apollo/client.ts)

View Source
var FactoryFields modelFields = modelFields{
	// contains filtered or unexported fields
}
View Source
var FlashFields modelFields = modelFields{
	// contains filtered or unexported fields
}
View Source
var MintFields modelFields = modelFields{
	// contains filtered or unexported fields
}
View Source
var PoolDayDataFields modelFields = modelFields{
	// contains filtered or unexported fields
}
View Source
var PoolFields modelFields = modelFields{
	// contains filtered or unexported fields
}
View Source
var PoolHourDataFields modelFields = modelFields{
	// contains filtered or unexported fields
}
View Source
var PositionFields modelFields = modelFields{
	// contains filtered or unexported fields
}
View Source
var PositionSnapshotFields modelFields = modelFields{
	// contains filtered or unexported fields
}
View Source
var SwapFields modelFields = modelFields{
	// contains filtered or unexported fields
}
View Source
var TickDayDataFields modelFields = modelFields{
	// contains filtered or unexported fields
}
View Source
var TickFields modelFields = modelFields{
	// contains filtered or unexported fields
}
View Source
var TickHourDataFields modelFields = modelFields{
	// contains filtered or unexported fields
}
View Source
var TokenDayDataFields modelFields = modelFields{
	// contains filtered or unexported fields
}
View Source
var TokenFields modelFields = modelFields{
	// contains filtered or unexported fields
}
View Source
var TokenHourDataFields modelFields = modelFields{
	// contains filtered or unexported fields
}
View Source
var TransactionFields modelFields = modelFields{
	// contains filtered or unexported fields
}
View Source
var UniswapDayDataFields modelFields = modelFields{
	// contains filtered or unexported fields
}

Functions

This section is empty.

Types

type Bundle

type Bundle struct {
	ID          string `json:"id"`
	EthPriceUSD string `json:"ethPriceUSD"`
}

type BundleResponse

type BundleResponse struct {
	Bundle Bundle
}

type Burn

type Burn struct {
	ID          string      `json:"id"`
	Transaction Transaction `json:"transaction"`
	Pool        Pool        `json:"pool"`
	Token0      Token       `json:"token0"`
	Token1      Token       `json:"token1"`
	Timestamp   string      `json:"timestamp"`
	Owner       string      `json:"owner"`
	Origin      string      `json:"origin"`
	Amount      string      `json:"amount"`
	Amount0     string      `json:"amount0"`
	Amount1     string      `json:"amount1"`
	AmountUSD   string      `json:"amountUSD"`
	TickLower   string      `json:"tickLower"`
	TickUpper   string      `json:"tickUpper"`
	LogIndex    string      `json:"logIndex"`
}

type BurnResponse

type BurnResponse struct {
	Burn Burn
}

type Client

type Client struct {
	GqlClient *graphql.Client
	// contains filtered or unexported fields
}

main uniswap subgraph client

func NewClient

func NewClient(url string, opts *ClientOptions) *Client

func (*Client) GetBundleById

func (c *Client) GetBundleById(ctx context.Context, id string, opts *RequestOptions) (*BundleResponse, error)

func (*Client) GetBurnById

func (c *Client) GetBurnById(ctx context.Context, id string, opts *RequestOptions) (*BurnResponse, error)

func (*Client) GetCollectById

func (c *Client) GetCollectById(ctx context.Context, id string, opts *RequestOptions) (*CollectResponse, error)

func (*Client) GetFactoryById

func (c *Client) GetFactoryById(ctx context.Context, id string, opts *RequestOptions) (*FactoryResponse, error)

func (*Client) GetFlashById

func (c *Client) GetFlashById(ctx context.Context, id string, opts *RequestOptions) (*FlashResponse, error)

func (*Client) GetMintById

func (c *Client) GetMintById(ctx context.Context, id string, opts *RequestOptions) (*MintResponse, error)

func (*Client) GetPoolById

func (c *Client) GetPoolById(ctx context.Context, id string, opts *RequestOptions) (*PoolResponse, error)

func (*Client) GetPoolDayDataById

func (c *Client) GetPoolDayDataById(ctx context.Context, id string, opts *RequestOptions) (*PoolDayDataResponse, error)

func (*Client) GetPoolHourDataById

func (c *Client) GetPoolHourDataById(ctx context.Context, id string, opts *RequestOptions) (*PoolHourDataResponse, error)

func (*Client) GetPositionById

func (c *Client) GetPositionById(ctx context.Context, id string, opts *RequestOptions) (*PositionResponse, error)

func (*Client) GetSwapById

func (c *Client) GetSwapById(ctx context.Context, id string, opts *RequestOptions) (*SwapResponse, error)

func (*Client) GetTickById

func (c *Client) GetTickById(ctx context.Context, id string, opts *RequestOptions) (*TickResponse, error)

func (*Client) GetTickDayDataById

func (c *Client) GetTickDayDataById(ctx context.Context, id string, opts *RequestOptions) (*TickDayDataResponse, error)

func (*Client) GetTickHourDataById

func (c *Client) GetTickHourDataById(ctx context.Context, id string, opts *RequestOptions) (*TickHourDataResponse, error)

func (*Client) GetTokenById

func (c *Client) GetTokenById(ctx context.Context, id string, opts *RequestOptions) (*TokenResponse, error)

func (*Client) GetTokenDayDataById

func (c *Client) GetTokenDayDataById(ctx context.Context, id string, opts *RequestOptions) (*TokenDayDataResponse, error)

func (*Client) GetTokenHourDataById

func (c *Client) GetTokenHourDataById(ctx context.Context, id string, opts *RequestOptions) (*TokenHourDataResponse, error)

func (*Client) GetTransactionById

func (c *Client) GetTransactionById(ctx context.Context, id string, opts *RequestOptions) (*TransactionResponse, error)

func (*Client) GetUniswapDayDataById

func (c *Client) GetUniswapDayDataById(ctx context.Context, id string, opts *RequestOptions) (*UniswapDayDataResponse, error)

func (*Client) ListBundles

func (c *Client) ListBundles(ctx context.Context, opts *RequestOptions) (*ListBundlesResponse, error)

func (*Client) ListBurns

func (c *Client) ListBurns(ctx context.Context, opts *RequestOptions) (*ListBurnsResponse, error)

func (*Client) ListCollects

func (c *Client) ListCollects(ctx context.Context, opts *RequestOptions) (*ListCollectsResponse, error)

func (*Client) ListFactories

func (c *Client) ListFactories(ctx context.Context, opts *RequestOptions) (*ListFactoriesResponse, error)

func (*Client) ListFlashes

func (c *Client) ListFlashes(ctx context.Context, opts *RequestOptions) (*ListFlashesResponse, error)

func (*Client) ListMints

func (c *Client) ListMints(ctx context.Context, opts *RequestOptions) (*ListMintsResponse, error)

func (*Client) ListPoolDayDatas

func (c *Client) ListPoolDayDatas(ctx context.Context, opts *RequestOptions) (*ListPoolDayDatasResponse, error)

func (*Client) ListPoolHourDatas

func (c *Client) ListPoolHourDatas(ctx context.Context, opts *RequestOptions) (*ListPoolHourDatasResponse, error)

func (*Client) ListPools

func (c *Client) ListPools(ctx context.Context, opts *RequestOptions) (*ListPoolsResponse, error)

func (*Client) ListPositions

func (c *Client) ListPositions(ctx context.Context, opts *RequestOptions) (*ListPositionsResponse, error)

func (*Client) ListSwaps

func (c *Client) ListSwaps(ctx context.Context, opts *RequestOptions) (*ListSwapsResponse, error)

func (*Client) ListTickDayDatas

func (c *Client) ListTickDayDatas(ctx context.Context, opts *RequestOptions) (*ListTickDayDatasResponse, error)

func (*Client) ListTickHourDatas

func (c *Client) ListTickHourDatas(ctx context.Context, opts *RequestOptions) (*ListTickHourDatasResponse, error)

func (*Client) ListTicks

func (c *Client) ListTicks(ctx context.Context, opts *RequestOptions) (*ListTicksResponse, error)

func (*Client) ListTokenDayDatas

func (c *Client) ListTokenDayDatas(ctx context.Context, opts *RequestOptions) (*ListTokenDayDatasResponse, error)

func (*Client) ListTokenHourDatas

func (c *Client) ListTokenHourDatas(ctx context.Context, opts *RequestOptions) (*ListTokenHourDatasResponse, error)

func (*Client) ListTokens

func (c *Client) ListTokens(ctx context.Context, opts *RequestOptions) (*ListTokensResponse, error)

func (*Client) ListTransactions

func (c *Client) ListTransactions(ctx context.Context, opts *RequestOptions) (*ListTransactionsResponse, error)

func (*Client) ListUniswapDayDatas

func (c *Client) ListUniswapDayDatas(ctx context.Context, opts *RequestOptions) (*ListUniswapDayDatasResponse, error)

type ClientOptions

type ClientOptions struct {
	HttpClient *http.Client
	CloseReq   bool
}

options when creating a new Client

type Collect

type Collect struct {
	ID          string      `json:"id"`
	Transaction Transaction `json:"transaction"`
	Timestamp   string      `json:"timestamp"`
	Pool        Pool        `json:"pool"`
	Owner       string      `json:"owner"`
	Amount0     string      `json:"amount0"`
	Amount1     string      `json:"amount1"`
	AmountUSD   string      `json:"amountUSD"`
	TickLower   string      `json:"tickLower"`
	TickUpper   string      `json:"tickUpper"`
	LogIndex    string      `json:"logIndex"`
}

type CollectResponse

type CollectResponse struct {
	Collect Collect
}

type Endpoint

type Endpoint int

endpoints enum

const (
	Ethereum Endpoint = iota
	Arbitrum
	Optimism
	Polygon
	Celo
	Bnb
	Base
	Avalanche
)

type Factory

type Factory struct {
	ID                           string `json:"id"`
	PoolCount                    string `json:"poolCount"`
	TxCount                      string `json:"txCount"`
	TotalVolumeUSD               string `json:"totalVolumeUSD"`
	TotalVolumeETH               string `json:"totalVolumeETH"`
	TotalFeesUSD                 string `json:"totalFeesUSD"`
	TotalFeesETH                 string `json:"totalFeesETH"`
	UntrackedVolumeUSD           string `json:"untrackedVolumeUSD"`
	TotalValueLockedUSD          string `json:"totalValueLockedUSD"`
	TotalValueLockedETH          string `json:"totalValueLockedETH"`
	TotalValueLockedUSDUntracked string `json:"totalValueLockedUSDUntracked"`
	TotalValueLockedETHUntracked string `json:"totalValueLockedETHUntracked"`
	Owner                        string `json:"owner"`
}

type FactoryResponse

type FactoryResponse struct {
	Factory Factory
}

type Flash

type Flash struct {
	ID          string      `json:"id"`
	Transaction Transaction `json:"transaction"`
	Timestamp   string      `json:"timestamp"`
	Pool        Pool        `json:"pool"`
	Sender      string      `json:"sender"`
	Recipient   string      `json:"recipient"`
	Amount0     string      `json:"amount0"`
	Amount1     string      `json:"amount1"`
	AmountUSD   string      `json:"amountUSD"`
	Amount0Paid string      `json:"amount0Paid"`
	Amount1Paid string      `json:"amount1Paid"`
	LogIndex    string      `json:"logIndex"`
}

type FlashResponse

type FlashResponse struct {
	Flash Flash
}

type ListBundlesResponse

type ListBundlesResponse struct {
	Bundles []Bundle
}

type ListBurnsResponse

type ListBurnsResponse struct {
	Burns []Burn
}

type ListCollectsResponse

type ListCollectsResponse struct {
	Collects []Collect
}

type ListFactoriesResponse

type ListFactoriesResponse struct {
	Factories []Factory
}

type ListFlashesResponse

type ListFlashesResponse struct {
	Flashes []Flash
}

type ListMintsResponse

type ListMintsResponse struct {
	Mints []Mint
}

type ListPoolDayDatasResponse

type ListPoolDayDatasResponse struct {
	PoolDayDatas []PoolDayData
}

type ListPoolHourDatasResponse

type ListPoolHourDatasResponse struct {
	PoolHourDatas []PoolHourData
}

type ListPoolsResponse

type ListPoolsResponse struct {
	Pools []Pool
}

type ListPositionSnapshotsResponse

type ListPositionSnapshotsResponse struct {
	PositionSnapshots []PositionSnapshot
}

type ListPositionsResponse

type ListPositionsResponse struct {
	Positions []Position
}

type ListSwapsResponse

type ListSwapsResponse struct {
	Swaps []Swap
}

type ListTickDayDatasResponse

type ListTickDayDatasResponse struct {
	TickDayDatas []TickDayData
}

type ListTickHourDatasResponse

type ListTickHourDatasResponse struct {
	TickHourDatas []TickHourData
}

type ListTicksResponse

type ListTicksResponse struct {
	Ticks []Tick
}

type ListTokenDayDatasResponse

type ListTokenDayDatasResponse struct {
	TokenDayDatas []TokenDayData
}

type ListTokenHourDatasResponse

type ListTokenHourDatasResponse struct {
	TokenHourDatas []TokenHourData
}

type ListTokensResponse

type ListTokensResponse struct {
	Tokens []Token
}

type ListTransactionsResponse

type ListTransactionsResponse struct {
	Transactions []Transaction
}

type ListUniswapDayDatasResponse

type ListUniswapDayDatasResponse struct {
	UniswapDayDatas []UniswapDayData
}

type Mint

type Mint struct {
	ID          string      `json:"id"`
	Transaction Transaction `json:"transaction"`
	Timestamp   string      `json:"timestamp"`
	Pool        Pool        `json:"pool"`
	Token0      Token       `json:"token0"`
	Token1      Token       `json:"token1"`
	Owner       string      `json:"owner"`
	Sender      string      `json:"sender"`
	Origin      string      `json:"origin"`
	Amount      string      `json:"amount"`
	Amount0     string      `json:"amount0"`
	Amount1     string      `json:"amount1"`
	AmountUSD   string      `json:"amountUSD"`
	TickLower   string      `json:"tickLower"`
	TickUpper   string      `json:"tickUpper"`
	LogIndex    string      `json:"logIndex"`
}

type MintResponse

type MintResponse struct {
	Mint Mint
}

type Pool

type Pool struct {
	ID                           string `json:"id"`
	CreatedAtTimestamp           string `json:"createdAtTimestamp"`
	CreatedAtBlockNumber         string `json:"createdAtBlockNumber"`
	Token0                       Token  `json:"token0"`
	Token1                       Token  `json:"token1"`
	FeeTier                      string `json:"feeTier"`
	Liquidity                    string `json:"liquidity"`
	SqrtPrice                    string `json:"sqrtPrice"`
	FeeGrowthGlobal0X128         string `json:"feeGrowthGlobal0X128"`
	FeeGrowthGlobal1X128         string `json:"feeGrowthGlobal1X128"`
	Token0Price                  string `json:"token0Price"`
	Token1Price                  string `json:"token1Price"`
	Tick                         string `json:"tick"`
	ObservationIndex             string `json:"observationIndex"`
	VolumeToken0                 string `json:"volumeToken0"`
	VolumeToken1                 string `json:"volumeToken1"`
	VolumeUSD                    string `json:"volumeUSD"`
	UntrackedVolumeUSD           string `json:"untrackedVolumeUSD"`
	FeesUSD                      string `json:"feesUSD"`
	TxCount                      string `json:"txCount"`
	CollectedFeesToken0          string `json:"collectedFeesToken0"`
	CollectedFeesToken1          string `json:"collectedFeesToken1"`
	CollectedFeesUSD             string `json:"collectedFeesUSD"`
	TotalValueLockedToken0       string `json:"totalValueLockedToken0"`
	TotalValueLockedToken1       string `json:"totalValueLockedToken1"`
	TotalValueLockedETH          string `json:"totalValueLockedETH"`
	TotalValueLockedUSD          string `json:"totalValueLockedUSD"`
	TotalValueLockedUSDUntracked string `json:"totalValueLockedUSDUntracked"`
	LiquidityProviderCount       string `json:"liquidityProviderCount"`
}

type PoolDayData

type PoolDayData struct {
	ID                   string `json:"id"`
	Date                 string `json:"date"`
	Pool                 Pool   `json:"pool"`
	Liquidity            string `json:"liquidity"`
	SqrtPrice            string `json:"sqrtPrice"`
	Token0Price          string `json:"token0Price"`
	Token1Price          string `json:"token1Price"`
	Tick                 string `json:"tick"`
	FeeGrowthGlobal0X128 string `json:"feeGrowthGlobal0X128"`
	FeeGrowthGlobal1X128 string `json:"feeGrowthGlobal1X128"`
	TvlUSD               string `json:"tvlUSD"`
	VolumeToken0         string `json:"volumeToken0"`
	VolumeToken1         string `json:"volumeToken1"`
	VolumeUSD            string `json:"volumeUSD"`
	FeesUSD              string `json:"feesUSD"`
	TxCount              string `json:"txCount"`
	Open                 string `json:"open"`
	High                 string `json:"high"`
	Low                  string `json:"low"`
	Close                string `json:"close"`
}

type PoolDayDataResponse

type PoolDayDataResponse struct {
	PoolDayData PoolDayData
}

type PoolHourData

type PoolHourData struct {
	ID                   string `json:"id"`
	PeriodStartUnix      string `json:"periodStartUnix"`
	Pool                 Pool   `json:"pool"`
	Liquidity            string `json:"liquidity"`
	SqrtPrice            string `json:"sqrtPrice"`
	Token0Price          string `json:"token0Price"`
	Token1Price          string `json:"token1Price"`
	Tick                 string `json:"tick"`
	FeeGrowthGlobal0X128 string `json:"feeGrowthGlobal0X128"`
	FeeGrowthGlobal1X128 string `json:"feeGrowthGlobal1X128"`
	TvlUSD               string `json:"tvlUSD"`
	VolumeToken0         string `json:"volumeToken0"`
	VolumeToken1         string `json:"volumeToken1"`
	VolumeUSD            string `json:"volumeUSD"`
	FeesUSD              string `json:"feesUSD"`
	TxCount              string `json:"txCount"`
	Open                 string `json:"open"`
	High                 string `json:"high"`
	Low                  string `json:"low"`
	Close                string `json:"close"`
}

type PoolHourDataResponse

type PoolHourDataResponse struct {
	PoolHourData PoolHourData
}

type PoolResponse

type PoolResponse struct {
	Pool Pool
}

type Position

type Position struct {
	ID                       string      `json:"id"`
	Owner                    string      `json:"owner"`
	Pool                     Pool        `json:"pool"`
	Token0                   Token       `json:"token0"`
	Token1                   Token       `json:"token1"`
	TickLower                Tick        `json:"tickLower"`
	TickUpper                Tick        `json:"tickUpper"`
	Liquidity                string      `json:"liquidity"`
	DepositedToken0          string      `json:"depositedToken0"`
	DepositedToken1          string      `json:"depositedToken1"`
	WithdrawnToken0          string      `json:"withdrawnToken0"`
	WithdrawnToken1          string      `json:"withdrawnToken1"`
	CollectedFeesToken0      string      `json:"collectedFeesToken0"`
	CollectedFeesToken1      string      `json:"collectedFeesToken1"`
	Transaction              Transaction `json:"transaction"`
	FeeGrowthInside0LastX128 string      `json:"feeGrowthInside0LastX128"`
	FeeGrowthInside1LastX128 string      `json:"feeGrowthInside1LastX128"`
}

type PositionResponse

type PositionResponse struct {
	Position Position
}

type PositionSnapshot

type PositionSnapshot struct {
	ID                       string      `json:"id"`
	Owner                    string      `json:"owner"`
	Pool                     Pool        `json:"pool"`
	Position                 Position    `json:"position"`
	BlockNumber              string      `json:"blockNumber"`
	Timestamp                string      `json:"timestamp"`
	Liquidity                string      `json:"liquidity"`
	DepositedToken0          string      `json:"depositedToken0"`
	DepositedToken1          string      `json:"depositedToken1"`
	WithdrawnToken0          string      `json:"withdrawnToken0"`
	WithdrawnToken1          string      `json:"withdrawnToken1"`
	CollectedFeesToken0      string      `json:"collectedFeesToken0"`
	CollectedFeesToken1      string      `json:"collectedFeesToken1"`
	Transaction              Transaction `json:"transaction"`
	FeeGrowthInside0LastX128 string      `json:"feeGrowthInside0LastX128"`
	FeeGrowthInside1LastX128 string      `json:"feeGrowthInside1LastX128"`
}

type PositionSnapshotResponse

type PositionSnapshotResponse struct {
	PositionSnapshot PositionSnapshot
}

type QueryType

type QueryType int

query type enum

const (
	ById QueryType = iota
	List
)

type RequestOptions

type RequestOptions struct {
	IncludeFields []string // fields to include in the query. '*' is a valid option meaning 'include all fields'. if any fields are listed in IncludeFields besides '*', ExcludeFields must be empty.
	ExcludeFields []string // fields to exclude from the query. only valid when '*' is in IncludeFields.
	Block         int      // query for data at a specific block number.
	First         int      // number of results to retrieve. `100` is the default. only valid for List queries.
	Skip          int      // number of results to skip. `0` is the default. only valid for List queries.
	OrderBy       string   // field to order by. `id` is the default. only valid for List queries.
	OrderDir      string   // order direction. `asc` for ascending and `desc` for descending are the only valid options. `asc` is the default. only valid for List queries.
}

options when creating a new Request

type Swap

type Swap struct {
	ID           string      `json:"id"`
	Transaction  Transaction `json:"transaction"`
	Timestamp    string      `json:"timestamp"`
	Pool         Pool        `json:"pool"`
	Token0       Token       `json:"token0"`
	Token1       Token       `json:"token1"`
	Sender       string      `json:"sender"`
	Recipient    string      `json:"recipient"`
	Origin       string      `json:"origin"`
	Amount0      string      `json:"amount0"`
	Amount1      string      `json:"amount1"`
	AmountUSD    string      `json:"amountUSD"`
	SqrtPriceX96 string      `json:"sqrtPriceX96"`
	Tick         string      `json:"tick"`
	LogIndex     string      `json:"logIndex"`
}

type SwapResponse

type SwapResponse struct {
	Swap Swap
}

type Tick

type Tick struct {
	ID                     string `json:"id"`
	PoolAddress            string `json:"poolAddress"`
	TickIdx                string `json:"tickIdx"`
	Pool                   Pool   `json:"pool"`
	LiquidityGross         string `json:"liquidityGross"`
	LiquidityNet           string `json:"liquidityNet"`
	Price0                 string `json:"price0"`
	Price1                 string `json:"price1"`
	VolumeToken0           string `json:"volumeToken0"`
	VolumeToken1           string `json:"volumeToken1"`
	VolumeUSD              string `json:"volumeUSD"`
	UntrackedVolumeUSD     string `json:"untrackedVolumeUSD"`
	FeesUSD                string `json:"feesUSD"`
	CollectedFeesToken0    string `json:"collectedFeesToken0"`
	CollectedFeesToken1    string `json:"collectedFeesToken1"`
	CollectedFeesUSD       string `json:"collectedFeesUSD"`
	CreatedAtTimestamp     string `json:"createdAtTimestamp"`
	CreatedAtBlockNumber   string `json:"createdAtBlockNumber"`
	LiquidityProviderCount string `json:"liquidityProviderCount"`
	FeeGrowthOutside0X128  string `json:"feeGrowthOutside0X128"`
	FeeGrowthOutside1X128  string `json:"feeGrowthOutside1X128"`
}

type TickDayData

type TickDayData struct {
	ID                    string `json:"id"`
	Date                  string `json:"date"`
	Pool                  Pool   `json:"pool"`
	Tick                  Tick   `json:"tick"`
	LiquidityGross        string `json:"liquidityGross"`
	LiquidityNet          string `json:"liquidityNet"`
	VolumeToken0          string `json:"volumeToken0"`
	VolumeToken1          string `json:"volumeToken1"`
	VolumeUSD             string `json:"volumeUSD"`
	FeesUSD               string `json:"feesUSD"`
	FeeGrowthOutside0X128 string `json:"feeGrowthOutside0X128"`
	FeeGrowthOutside1X128 string `json:"feeGrowthOutside1X128"`
}

type TickDayDataResponse

type TickDayDataResponse struct {
	TickDayData TickDayData
}

type TickHourData

type TickHourData struct {
	ID              string `json:"id"`
	PeriodStartUnix string `json:"periodStartUnix"`
	Pool            Pool   `json:"pool"`
	Tick            Tick   `json:"tick"`
	LiquidityGross  string `json:"liquidityGross"`
	LiquidityNet    string `json:"liquidityNet"`
	VolumeToken0    string `json:"volumeToken0"`
	VolumeToken1    string `json:"volumeToken1"`
	VolumeUSD       string `json:"volumeUSD"`
	FeesUSD         string `json:"feesUSD"`
}

type TickHourDataResponse

type TickHourDataResponse struct {
	TickHourData TickHourData
}

type TickResponse

type TickResponse struct {
	Tick Tick
}

type Token

type Token struct {
	ID                           string `json:"id"`
	Symbol                       string `json:"symbol"`
	Name                         string `json:"name"`
	Decimals                     string `json:"decimals"`
	TotalSupply                  string `json:"totalSupply"`
	Volume                       string `json:"volume"`
	VolumeUSD                    string `json:"volumeUSD"`
	UntrackedVolumeUSD           string `json:"untrackedVolumeUSD"`
	FeesUSD                      string `json:"feesUSD"`
	TxCount                      string `json:"txCount"`
	PoolCount                    string `json:"poolCount"`
	TotalValueLocked             string `json:"totalValueLocked"`
	TotalValueLockedUSD          string `json:"totalValueLockedUSD"`
	TotalValueLockedUSDUntracked string `json:"totalValueLockedUSDUntracked"`
	DerivedETH                   string `json:"derivedETH"`
}

type TokenDayData

type TokenDayData struct {
	ID                  string `json:"id"`
	Date                string `json:"date"`
	Token               Token  `json:"token"`
	Volume              string `json:"volume"`
	VolumeUSD           string `json:"volumeUSD"`
	UntrackedVolumeUSD  string `json:"untrackedVolumeUSD"`
	TotalValueLocked    string `json:"totalValueLocked"`
	TotalValueLockedUSD string `json:"totalValueLockedUSD"`
	PriceUSD            string `json:"priceUSD"`
	FeesUSD             string `json:"feesUSD"`
	Open                string `json:"open"`
	High                string `json:"high"`
	Low                 string `json:"low"`
	Close               string `json:"close"`
}

type TokenDayDataResponse

type TokenDayDataResponse struct {
	TokenDayData TokenDayData
}

type TokenHourData

type TokenHourData struct {
	ID                  string `json:"id"`
	PeriodStartUnix     string `json:"periodStartUnix"`
	Token               Token  `json:"token"`
	Volume              string `json:"volume"`
	VolumeUSD           string `json:"volumeUSD"`
	UntrackedVolumeUSD  string `json:"untrackedVolumeUSD"`
	TotalValueLocked    string `json:"totalValueLocked"`
	TotalValueLockedUSD string `json:"totalValueLockedUSD"`
	PriceUSD            string `json:"priceUSD"`
	FeesUSD             string `json:"feesUSD"`
	Open                string `json:"open"`
	High                string `json:"high"`
	Low                 string `json:"low"`
	Close               string `json:"close"`
}

type TokenHourDataResponse

type TokenHourDataResponse struct {
	TokenHourData TokenHourData
}

type TokenResponse

type TokenResponse struct {
	Token Token
}

type Transaction

type Transaction struct {
	ID          string `json:"id"`
	BlockNumber string `json:"blockNumber"`
	Timestamp   string `json:"timestamp"`
	GasUsed     string `json:"gasUsed"`
	GasPrice    string `json:"gasPrice"`
}

type TransactionResponse

type TransactionResponse struct {
	Transaction Transaction
}

type UniswapDayData

type UniswapDayData struct {
	ID                 string `json:"id"`
	Date               string `json:"date"`
	VolumeETH          string `json:"volumeETH"`
	VolumeUSD          string `json:"volumeUSD"`
	VolumeUSDUntracked string `json:"volumeUSDUntracked"`
	FeesUSD            string `json:"feesUSD"`
	TxCount            string `json:"txCount"`
	TvlUSD             string `json:"tvlUSD"`
}

type UniswapDayDataResponse

type UniswapDayDataResponse struct {
	UniswapDayData UniswapDayData
}

Directories

Path Synopsis
Package graphql provides a low level GraphQL client.
Package graphql provides a low level GraphQL client.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL