syncclient

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

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() *Client

func (*Client) NetworkAddressesTokenPrice

func (c *Client) NetworkAddressesTokenPrice(network string, addresses []string) (Response[TokenPrice], error)

NetworkAddressesTokenPrice retrieves the token price for a specific network and addresses. It makes a GET request to the "simple/networks/{network}/token_price/{addresses}" endpoint of the API.

Parameters:

  • network: The ID of the network for which to retrieve the token price.
  • addresses: A slice of addresses for which to retrieve the token price.

Returns:

  • A TokenPrice struct, representing the token price for the given addresses in the network.
  • An error if the GET request or the JSON unmarshalling fails.

func (*Client) NetworkDexPools

func (c *Client) NetworkDexPools(network string, dex string, page int) (Response[[]Pool], error)

NetworkDexPools retrieves the pools for a specific network and dex. It makes a GET request to the "networks/{network}/dexes/{dex}/pools/" endpoint of the API.

Parameters:

  • network: The ID of the network for which to retrieve the pools.
  • dex: The ID of the dex for which to retrieve the pools.
  • page: The page number for pagination. Each page returns a certain number of pools.

Returns:

  • A slice of Pool structs, each representing a pool in the dex of the network.
  • An error if the GET request or the JSON unmarshalling fails.

func (*Client) NetworkDexes

func (c *Client) NetworkDexes(network string, page int) (Response[[]Dex], error)

NetworkDexes retrieves the Dexes for a specific network. It makes a GET request to the "networks/{network}/dexes.go/" endpoint of the API.

Parameters:

  • network: The ID of the network for which to retrieve the Dexes.
  • page: The page number for pagination. Each page returns a certain number of Dexes.

Returns:

  • A slice of Dex structs, each representing a Dex in the network.
  • An error if the GET request or the JSON unmarshalling fails.

func (*Client) NetworkNewPools

func (c *Client) NetworkNewPools(network string, page int) (Response[[]Pool], error)

NetworkNewPools retrieves the new pools for a specific network. It makes a GET request to the "networks/{network}/new_pools/" endpoint of the API.

Parameters:

  • network: The ID of the network for which to retrieve the new pools.
  • page: The page number for pagination. Each page returns a certain number of new pools.

Returns:

  • A slice of Pool structs, each representing a new pool in the network.
  • An error if the GET request or the JSON unmarshalling fails.

func (*Client) NetworkPoolAddress

func (c *Client) NetworkPoolAddress(network string, address string) (Response[Pool], error)

NetworkPoolAddress retrieves the pool for a specific network and address. It makes a GET request to the "networks/{network}/pools/{address}" endpoint of the API.

Parameters:

  • network: The ID of the network for which to retrieve the pool.
  • address: The address of the pool to be retrieved.

Returns:

  • A Pool struct, representing the pool for the given address in the network.
  • An error if the GET request or the JSON unmarshalling fails.

func (*Client) NetworkPoolMultiAddress

func (c *Client) NetworkPoolMultiAddress(network string, address []string) (Response[[]Pool], error)

NetworkPoolMultiAddress retrieves the pools for a specific network and multiple addresses. It makes a GET request to the "networks/{network}/pools/multi/{addresses}" endpoint of the API.

Parameters:

  • network: The ID of the network for which to retrieve the pools.
  • address: A slice of addresses for which to retrieve the pools.

Returns:

  • A slice of Pool structs, each representing a pool for the given addresses in the network.
  • An error if the GET request or the JSON unmarshalling fails.

func (*Client) NetworkPoolOHLCV

func (c *Client) NetworkPoolOHLCV(args NetworkPoolOHLCVArgs) (Response[OHLCVS], error)

NetworkPoolOHLCV retrieves the OHLCV (Open, High, Low, Close, Volume) DataTypes for a specific pool in a network. It makes a GET request to the "networks/{network}/pools/{poolAddress}/ohlcv/{timeframe}" endpoint of the API.

Parameters:

  • args: A struct of NetworkPoolOHLCVArgs which includes:
  • Network: The ID of the network for which to retrieve the OHLCV DataTypes.
  • PoolAddress: The address of the pool for which to retrieve the OHLCV DataTypes.
  • Timeframe: The timeframe for the OHLCV DataTypes ("minute", "hour", "day").
  • Aggregate: The aggregate level for the OHLCV DataTypes 1, 5, 15 for minute, 1, 4, 12 for hour, 1 for day (default 1).
  • BeforeTimestamp: The Unix timestamp before which to retrieve the OHLCV DataTypes (default now).
  • Limit: The number of OHLCVs to return (default 100).
  • Currency: The currency for the OHLCV DataTypes ("usd", "token") (default "usd").
  • Token: The token for the OHLCV DataTypes ("base", "quote") (default "base").

Returns:

  • An OHLCVS struct, representing the OHLCV DataTypes for the given pool in the network.
  • An error if the GET request or the JSON unmarshalling fails.

func (*Client) NetworkPoolTokenInfo

func (c *Client) NetworkPoolTokenInfo(network string, poolAddress string) (Response[[]TokenInfo], error)

NetworkPoolTokenInfo retrieves the token information for a specific network and pool. It makes a GET request to the "networks/{network}/pools/{poolAddress}/info" endpoint of the API.

Parameters:

  • network: The ID of the network for which to retrieve the token information.
  • poolAddress: The address of the pool for which to retrieve the token information.

Returns:

  • A slice of TokenInfo structs, each representing the token information for the given pool in the network.
  • An error if the GET request or the JSON unmarshalling fails.

func (*Client) NetworkPoolTrades

func (c *Client) NetworkPoolTrades(network string, poolAddress string, tradeVolumeInUsdGreaterThan int) (Response[[]Trade], error)

NetworkPoolTrades retrieves the trades for a specific pool in a network. It makes a GET request to the "networks/{network}/pools/{poolAddress}/trades" endpoint of the API.

Parameters:

  • network: The ID of the network for which to retrieve the trades.
  • poolAddress: The address of the pool for which to retrieve the trades.
  • tradeVolumeInUsdGreaterThan: The minimum trade volume in USD for the trades to be retrieved.

Returns:

  • A slice of Trade structs, each representing a trade in the pool.
  • An error if the GET request or the JSON unmarshalling fails.

func (*Client) NetworkPools

func (c *Client) NetworkPools(network string, page int) (Response[[]Pool], error)

NetworkPools retrieves the pools for a specific network. It makes a GET request to the "networks/{network}/pools/" endpoint of the API.

Parameters:

  • network: The ID of the network for which to retrieve the pools.
  • page: The page number for pagination. Each page returns a certain number of pools.

Returns:

  • A slice of Pool structs, each representing a pool in the network.
  • An error if the GET request or the JSON unmarshalling fails.

func (*Client) NetworkToken

func (c *Client) NetworkToken(network string, address string) (Response[Token], error)

NetworkToken retrieves the token for a specific network and address. It makes a GET request to the "networks/{network}/tokens/{address}/" endpoint of the API.

Parameters:

  • network: The ID of the network for which to retrieve the token.
  • address: The address of the token to be retrieved.

Returns:

  • A Token struct, representing the token for the given address in the network.
  • An error if the GET request or the JSON unmarshalling fails.

func (*Client) NetworkTokenInfo

func (c *Client) NetworkTokenInfo(network string, address string) (Response[TokenInfo], error)

NetworkTokenInfo retrieves the token information for a specific network and address. It makes a GET request to the "networks/{network}/tokens/{address}/info" endpoint of the API.

Parameters:

  • network: The ID of the network for which to retrieve the token information.
  • address: The address of the token for which to retrieve the information.

Returns:

  • A TokenInfo struct, representing the token information for the given address in the network.
  • An error if the GET request or the JSON unmarshalling fails.

func (*Client) NetworkTokenPools

func (c *Client) NetworkTokenPools(network string, tokenAddress string, page int) (Response[[]Pool], error)

NetworkTokenPools retrieves the pools for a specific network and token. It makes a GET request to the "networks/{network}/tokens/{tokenAddress}/pools/" endpoint of the API.

Parameters:

  • network: The ID of the network for which to retrieve the pools.
  • tokenAddress: The address of the token for which to retrieve the pools.
  • page: The page number for pagination. Each page returns a certain number of pools.

Returns:

  • A slice of Pool structs, each representing a pool in the network for the given token.
  • An error if the GET request or the JSON unmarshalling fails.

func (*Client) NetworkTokensMultiAddress

func (c *Client) NetworkTokensMultiAddress(network string, addresses []string) (Response[[]Token], error)

NetworkTokensMultiAddress retrieves the tokens for a specific network and multiple addresses. It makes a GET request to the "networks/{network}/tokens/multi/{addresses}" endpoint of the API.

Parameters:

  • network: The ID of the network for which to retrieve the tokens.
  • addresses: A slice of addresses for which to retrieve the tokens.

Returns:

  • A slice of Token structs, each representing a token for the given addresses in the network.
  • An error if the GET request or the JSON unmarshalling fails.

func (*Client) NetworkTrendingPools

func (c *Client) NetworkTrendingPools(network string, page int) (Response[[]Pool], error)

NetworkTrendingPools retrieves the trending pools for a specific Network. It makes a GET request to the "networks/{Network}/trending_pools/" endpoint of the API.

Parameters:

  • Network: The ID of the Network for which to retrieve the trending pools.
  • page: The page number for pagination. Each page returns a certain number of trending pools.

Returns:

  • A slice of Pool structs, each representing a trending Pool in the Network.
  • An error if the GET request or the JSON unmarshalling fails.

func (*Client) Networks

func (c *Client) Networks(page int) (Response[[]Network], error)

Networks retrieves the list of networks. It makes a GET request to the "networks/" endpoint of the API.

Parameters:

  • page: The page number for pagination. Each page returns a certain number of networks.

Returns:

  • A slice of Network structs, each representing a network.
  • An error if the GET request or the JSON unmarshalling fails.

func (*Client) TokenInfoRecentlyUpdated

func (c *Client) TokenInfoRecentlyUpdated() (Response[[]TokenInfo], error)

TokenInfoRecentlyUpdated retrieves the recently updated token information. It makes a GET request to the "tokens/info_recently_updated" endpoint of the API.

Returns:

  • A slice of TokenInfo structs, each representing a recently updated token.
  • An error if the GET request or the JSON unmarshalling fails.

func (*Client) TrendingPools

func (c *Client) TrendingPools(page int) (Response[[]Pool], error)

TrendingPools retrieves the trending pools across all networks. It makes a GET request to the "networks/trending_pools/" endpoint of the API.

Parameters:

  • page: The page number for pagination. Each page returns a certain number of trending pools.

Returns:

  • A slice of Pool structs, each representing a trending Pool across all networks.
  • An error if the GET request or the JSON unmarshalling fails.

type DataTypes added in v0.2.0

type DataTypes interface {
	[]Network | []Dex | []Pool | []Trade | []Token | Pool | TokenPrice | Token | []TokenInfo | TokenInfo | OHLCVS
}

type Dex

type Dex struct {
	Id         string `json:"id"`
	Type       string `json:"type"`
	Attributes struct {
		Name string `json:"name"`
	} `json:"attributes"`
}
type Links struct {
	First string `json:"first"`
	Prev  string `json:"prev"`
	Next  string `json:"next"`
	Last  string `json:"last"`
}

type Meta added in v0.2.0

type Meta struct {
	Base struct {
		Address         string `json:"address"`
		Name            string `json:"name"`
		Symbol          string `json:"symbol"`
		CoingeckoCoinId string `json:"coingecko_coin_id"`
	} `json:"base"`
	Quote struct {
		Address         string `json:"address"`
		Name            string `json:"name"`
		Symbol          string `json:"symbol"`
		CoingeckoCoinId string `json:"coingecko_coin_id"`
	} `json:"quote"`
}

type Network

type Network struct {
	Id         string `json:"id"`
	Type       string `json:"type"`
	Attributes struct {
		Name                     string `json:"name"`
		CoingeckoAssetPlatformId string `json:"coingecko_asset_platform_id"`
	} `json:"attributes"`
}

type NetworkPoolOHLCVArgs

type NetworkPoolOHLCVArgs struct {
	Network     string
	PoolAddress string
	Timeframe   string
	// Optional parameters
	Aggregate       int
	BeforeTimestamp int64
	Limit           int
	Currency        string
	Token           string
}

type OHLCVS

type OHLCVS struct {
	Id         string `json:"id"`
	Type       string `json:"type"`
	Attributes struct {
		OHLCVList [][]float64 `json:"ohlcv_list"`
	} `json:"attributes"`
}

type Pool

type Pool struct {
	Id         string `json:"id"`
	Type       string `json:"type"`
	Attributes struct {
		BaseTokenPriceUsd             string      `json:"base_token_price_usd"`
		BaseTokenPriceNativeCurrency  string      `json:"base_token_price_native_currency"`
		QuoteTokenPriceUsd            string      `json:"quote_token_price_usd"`
		QuoteTokenPriceNativeCurrency string      `json:"quote_token_price_native_currency"`
		BaseTokenPriceQuoteToken      string      `json:"base_token_price_quote_token"`
		QuoteTokenPriceBaseToken      string      `json:"quote_token_price_base_token"`
		Address                       string      `json:"address"`
		Name                          string      `json:"name"`
		PoolCreatedAt                 time.Time   `json:"pool_created_at"`
		FdvUsd                        string      `json:"fdv_usd"`
		MarketCapUsd                  interface{} `json:"market_cap_usd"`
		PriceChangePercentage         struct {
			M5  string `json:"m5"`
			H1  string `json:"h1"`
			H6  string `json:"h6"`
			H24 string `json:"h24"`
		} `json:"price_change_percentage"`
		Transactions struct {
			M5 struct {
				Buys    int `json:"buys"`
				Sells   int `json:"sells"`
				Buyers  int `json:"buyers"`
				Sellers int `json:"sellers"`
			} `json:"m5"`
			M15 struct {
				Buys    int `json:"buys"`
				Sells   int `json:"sells"`
				Buyers  int `json:"buyers"`
				Sellers int `json:"sellers"`
			} `json:"m15"`
			M30 struct {
				Buys    int `json:"buys"`
				Sells   int `json:"sells"`
				Buyers  int `json:"buyers"`
				Sellers int `json:"sellers"`
			} `json:"m30"`
			H1 struct {
				Buys    int `json:"buys"`
				Sells   int `json:"sells"`
				Buyers  int `json:"buyers"`
				Sellers int `json:"sellers"`
			} `json:"h1"`
			H24 struct {
				Buys    int `json:"buys"`
				Sells   int `json:"sells"`
				Buyers  int `json:"buyers"`
				Sellers int `json:"sellers"`
			} `json:"h24"`
		} `json:"transactions"`
		VolumeUsd struct {
			M5  string `json:"m5"`
			H1  string `json:"h1"`
			H6  string `json:"h6"`
			H24 string `json:"h24"`
		} `json:"volume_usd"`
		ReserveInUsd string `json:"reserve_in_usd"`
	} `json:"attributes"`
	Relationships struct {
		BaseToken struct {
			Data struct {
				Id   string `json:"id"`
				Type string `json:"type"`
			} `json:"data"`
		} `json:"base_token"`
		QuoteToken struct {
			Data struct {
				Id   string `json:"id"`
				Type string `json:"type"`
			} `json:"data"`
		} `json:"quote_token"`
		Network struct {
			Data struct {
				Id   string `json:"id"`
				Type string `json:"type"`
			} `json:"data"`
		} `json:"network"`
		Dex struct {
			Data struct {
				Id   string `json:"id"`
				Type string `json:"type"`
			} `json:"data"`
		} `json:"dex"`
	} `json:"relationships"`
}

type Response added in v0.2.0

type Response[T DataTypes] struct {
	Data  T     `json:"data"`
	Links Links `json:"links"`
	Meta  Meta  `json:"meta"`
}

type Token

type Token struct {
	Id         string `json:"id"`
	Type       string `json:"type"`
	Attributes struct {
		Address           string `json:"address"`
		Name              string `json:"name"`
		Symbol            string `json:"symbol"`
		ImageUrl          string `json:"image_url"`
		CoingeckoCoinId   string `json:"coingecko_coin_id"`
		Decimals          int    `json:"decimals"`
		TotalSupply       string `json:"total_supply"`
		PriceUsd          string `json:"price_usd"`
		FdvUsd            string `json:"fdv_usd"`
		TotalReserveInUsd string `json:"total_reserve_in_usd"`
		VolumeUsd         struct {
			H24 string `json:"h24"`
		} `json:"volume_usd"`
		MarketCapUsd string `json:"market_cap_usd"`
	} `json:"attributes"`
	Relationships struct {
		TopPools struct {
			Data []struct {
				Id   string `json:"id"`
				Type string `json:"type"`
			} `json:"data"`
		} `json:"top_pools"`
	} `json:"relationships"`
}

type TokenInfo

type TokenInfo struct {
	Id         string `json:"id"`
	Type       string `json:"type"`
	Attributes struct {
		Address         string      `json:"address"`
		Name            string      `json:"name"`
		Symbol          string      `json:"symbol"`
		ImageUrl        string      `json:"image_url"`
		CoingeckoCoinId string      `json:"coingecko_coin_id"`
		Websites        []string    `json:"websites"`
		Description     string      `json:"description"`
		GtScore         float64     `json:"gt_score"`
		DiscordUrl      interface{} `json:"discord_url"`
		TelegramHandle  interface{} `json:"telegram_handle"`
		TwitterHandle   interface{} `json:"twitter_handle"`
	} `json:"attributes"`
}

type TokenPrice

type TokenPrice struct {
	Id         string `json:"id"`
	Type       string `json:"type"`
	Attributes struct {
		TokenPrices map[string]string `json:"token_prices"`
	} `json:"attributes"`
}

type Trade

type Trade struct {
	Id         string `json:"id"`
	Type       string `json:"type"`
	Attributes struct {
		BlockNumber              int       `json:"block_number"`
		TxHash                   string    `json:"tx_hash"`
		TxFromAddress            string    `json:"tx_from_address"`
		FromTokenAmount          string    `json:"from_token_amount"`
		ToTokenAmount            string    `json:"to_token_amount"`
		PriceFromInCurrencyToken string    `json:"price_from_in_currency_token"`
		PriceToInCurrencyToken   string    `json:"price_to_in_currency_token"`
		PriceFromInUsd           string    `json:"price_from_in_usd"`
		PriceToInUsd             string    `json:"price_to_in_usd"`
		BlockTimestamp           time.Time `json:"block_timestamp"`
		Kind                     string    `json:"kind"`
		VolumeInUsd              string    `json:"volume_in_usd"`
		FromTokenAddress         string    `json:"from_token_address"`
		ToTokenAddress           string    `json:"to_token_address"`
	} `json:"attributes"`
}

Jump to

Keyboard shortcuts

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