uniswap

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package uniswap wraps the Uniswap V3 subgraph on Ethereum mainnet. Used by the EVM source resolver to fill priceUsd / liquidity / primaryPoolAddr on each AssetSource issued on ETH. The subgraph is GraphQL-only; this client speaks the minimum subset of the schema we actually consume (Token + whitelistPools).

SubgraphURL is injectable so callers can swap between The Graph's hosted service and the decentralized network without changing call sites. As of 2026 the canonical mainnet V3 subgraph is published at

https://gateway.thegraph.com/api/<API_KEY>/subgraphs/id/5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV

— the gateway requires an API key. For local/CI dev a no-key fallback is the community mirror at

https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3

which still serves traffic but isn't guaranteed past 2026.

Index

Constants

View Source
const DefaultSubgraphURL = "https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3"

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(subgraphURL string) *Client

NewClient builds a subgraph-query client. Pass "" to use the public hosted-service URL (no API key). When/if that mirror disappears, callers move to The Graph gateway URL with a key baked in.

func (*Client) GetTokenInfo

func (c *Client) GetTokenInfo(ctx context.Context, contractAddr string) (*TokenInfo, error)

GetTokenInfo loads the Token row + whitelisted pools for one contract. Address must be lowercased (subgraph IDs are case-sensitive lowercased hex). Returns (nil, nil) when the token isn't indexed — trade routing should fall through to LiFi/1inch in that case.

type Pool

type Pool struct {
	ID                  string `json:"id"` // pool contract address
	FeeTier             string `json:"feeTier"`
	Liquidity           string `json:"liquidity"`
	TotalValueLockedUSD string `json:"totalValueLockedUSD"`
	Token0              struct {
		Symbol string `json:"symbol"`
		ID     string `json:"id"`
	} `json:"token0"`
	Token1 struct {
		Symbol string `json:"symbol"`
		ID     string `json:"id"`
	} `json:"token1"`
}

Pool is one Uniswap V3 pool the token participates in. FeeTier is expressed in hundredths-of-bps (500 = 0.05%, 3000 = 0.3%, 10000 = 1%). TotalValueLockedUSD is the per-pool TVL — pick the deepest pool as the trade-routing primary.

type TokenInfo

type TokenInfo struct {
	ID                  string  `json:"id"` // token contract address (lowercased)
	Symbol              string  `json:"symbol"`
	Decimals            string  `json:"decimals"`            // string in GraphQL (it's actually BigInt upstream)
	DerivedETH          string  `json:"derivedETH"`          // string-encoded decimal
	TotalValueLockedUSD string  `json:"totalValueLockedUSD"` // string-encoded decimal
	VolumeUSD           string  `json:"volumeUSD"`           // 24h volume across pools
	WhitelistPools      []*Pool `json:"whitelistPools,omitempty"`
}

TokenInfo is the subset of Uniswap V3 subgraph's Token type we care about. derivedETH is the on-chain price in ETH; multiply by the current ETH/USD spot to get a USD figure. totalValueLockedUSD is the sum across every whitelisted pool — useful as a "is this trade-able?" filter on the catalog.

Jump to

Keyboard shortcuts

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