pancakeswap

package
v0.16.1 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: 4 Imported by: 0

Documentation

Overview

Package pancakeswap wraps the PancakeSwap V3 subgraph on BNB Chain. Same role as the uniswap client but for BSC sources — fills priceUsd / liquidity / primaryPoolAddr on each AssetSource issued on BNB. PancakeSwap V3's subgraph forks Uniswap V3's so the GraphQL schema lines up; only derivedETH → derivedBNB differs.

As of 2026 PancakeSwap publishes the V3 BSC subgraph at

https://api.studio.thegraph.com/query/45376/pancakeswap-v3-bsc/version/latest

— open access, no key. The Graph gateway also serves it behind a key; either URL is valid (pass via NewClient).

Index

Constants

View Source
const DefaultSubgraphURL = "https://api.studio.thegraph.com/query/45376/pancakeswap-v3-bsc/version/latest"

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

func (*Client) GetTokenInfo

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

GetTokenInfo mirrors uniswap.GetTokenInfo on BSC. Address must be lowercased hex. Returns (nil, nil) when the token isn't indexed.

type Pool

type Pool struct {
	ID                  string `json:"id"`
	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"`
}

type TokenInfo

type TokenInfo struct {
	ID                  string  `json:"id"`
	Symbol              string  `json:"symbol"`
	Decimals            string  `json:"decimals"`
	DerivedBNB          string  `json:"derivedBNB"`          // string-encoded decimal
	TotalValueLockedUSD string  `json:"totalValueLockedUSD"` // string-encoded decimal
	VolumeUSD           string  `json:"volumeUSD"`
	WhitelistPools      []*Pool `json:"whitelistPools,omitempty"`
}

TokenInfo mirrors Uniswap's TokenInfo shape — PancakeSwap V3's subgraph schema is forked from Uniswap V3 so field semantics are identical (derivedBNB instead of derivedETH for the chain-native quote, but the rest line up).

Jump to

Keyboard shortcuts

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