Documentation
¶
Overview ¶
Package defillama is the library behind the defillama command line: the HTTP client, request shaping, and the typed data models for the DeFi Llama API.
The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (429 and 5xx) that any public API throws under load.
Index ¶
- Constants
- type Chain
- type Client
- func (c *Client) Get(ctx context.Context, url string) ([]byte, error)
- func (c *Client) GetProtocol(ctx context.Context, slug string) (*Protocol, error)
- func (c *Client) ListChains(ctx context.Context, limit int) ([]*Chain, error)
- func (c *Client) ListProtocols(ctx context.Context, category, chain string, limit int) ([]*Protocol, error)
- func (c *Client) ListStablecoins(ctx context.Context, limit int) ([]*Stablecoin, error)
- func (c *Client) ListYields(ctx context.Context, minAPY float64, chain, project string, ...) ([]*YieldPool, error)
- type Config
- type Domain
- type Protocol
- type Stablecoin
- type YieldPool
Constants ¶
const BaseURL = "https://" + Host
BaseURL is the root every main request is built from.
const DefaultUserAgent = "defillama-cli/0.1 (tamnd87@gmail.com)"
DefaultUserAgent identifies the client to DeFi Llama.
const Host = "api.llama.fi"
Host is the primary API host.
const StablecoinsURL = "https://stablecoins.llama.fi"
StablecoinsURL is the stablecoins subdomain.
const YieldsURL = "https://yields.llama.fi"
YieldsURL is the yields subdomain.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chain ¶
type Chain struct {
Name string `json:"name"`
Symbol string `json:"symbol"`
TVL float64 `json:"tvl"`
}
Chain is a blockchain network.
type Client ¶
type Client struct {
HTTP *http.Client
UserAgent string
Rate time.Duration
Retries int
// contains filtered or unexported fields
}
Client talks to the DeFi Llama API over HTTP.
func NewClientFromConfig ¶
NewClientFromConfig returns a Client configured from cfg.
func (*Client) GetProtocol ¶
GetProtocol fetches a single protocol by slug.
func (*Client) ListChains ¶
ListChains fetches all chains sorted by TVL.
func (*Client) ListProtocols ¶
func (c *Client) ListProtocols(ctx context.Context, category, chain string, limit int) ([]*Protocol, error)
ListProtocols fetches all protocols and applies optional filters.
func (*Client) ListStablecoins ¶
ListStablecoins fetches all stablecoins sorted by circulating USD.
type Config ¶
type Config struct {
BaseURL string
StablecoinsURL string
YieldsURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds the client configuration.
type Domain ¶
type Domain struct{}
Domain is the DeFi Llama driver. It carries no state; the per-run client is built by the factory Register hands kit.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity a host reuses for help and version.
type Protocol ¶
type Protocol struct {
Name string `json:"name"`
Symbol string `json:"symbol"`
Chain string `json:"chain"`
Category string `json:"category"`
TVL float64 `json:"tvl"`
Change1D float64 `json:"change_1d"`
Change7D float64 `json:"change_7d"`
URL string `json:"url"`
}
Protocol is a DeFi protocol with TVL data.