lifi

package
v0.14.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: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChainMapper = map[string]string{
	"eth": "ETH",
	"arb": "ARB",
	"bas": "BASE",
	"hpl": "HYPE",
	"hyp": "HYPEEVM",
	"mon": "MON",
	"bsc": "BNB",
	"opt": "OP",
	"pol": "POLYGON",
	"ava": "AVAXC",
	"lna": "LINEA",
	"btc": "BTC",
	"sol": "SOL",
	"sui": "SUI",
}
View Source
var ChainMapperReverse = func() map[string]string {
	m := make(map[string]string, len(ChainMapper))
	for k, v := range ChainMapper {
		m[v] = k
	}
	return m
}()

Functions

This section is empty.

Types

type ChainsRes

type ChainsRes struct {
	Chains []struct {
		ID        int    `json:"id"`
		Key       string `json:"key"`
		Name      string `json:"name"`
		ChainType string `json:"chainType"`
		Coin      string `json:"coin"`
	} `json:"chains"`
}

type Client

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

func NewClient

func NewClient() *Client

func (*Client) Chains

func (c *Client) Chains(ctx context.Context) ([]string, error)

func (*Client) Quote

func (*Client) Status

func (*Client) Tokens

func (c *Client) Tokens(ctx context.Context) error

type Error

type Error struct {
	Message string `json:"message"`
	Code    int    `json:"code"`
}

type QuoteReq

type QuoteReq struct {
	FromChain   string
	ToChain     string
	FromToken   string
	ToToken     string
	FromAmount  string
	FromAddress string
	ToAddress   string
	Slippage    string
	Fee         string
	// FromAmountForGas — fraction of FromAmount (smallest unit) routed
	// through LiFi's GasZip integration so the destination chain
	// receives some native gas. Empty disables refuel.
	FromAmountForGas string
}

type QuoteRes

type QuoteRes struct {
	Error
	ID            string `json:"id"`
	Type          string `json:"type"`
	Tool          string `json:"tool"`
	TransactionId string `json:"transactionId"`
	ToolDetails   struct {
		Key     string `json:"key"`
		Name    string `json:"name"`
		LogoURI string `json:"logoURI"`
	} `json:"toolDetails"`
	Action struct {
		FromChainID int     `json:"fromChainId"`
		ToChainID   int     `json:"toChainId"`
		FromAmount  string  `json:"fromAmount"`
		Slippage    float64 `json:"slippage"`
		FromToken   struct {
			Address  string `json:"address"`
			Symbol   string `json:"symbol"`
			Decimals int    `json:"decimals"`
		} `json:"fromToken"`
		ToToken struct {
			Address  string `json:"address"`
			Symbol   string `json:"symbol"`
			Decimals int    `json:"decimals"`
		} `json:"toToken"`
	} `json:"action"`
	Estimate struct {
		FromAmount        string `json:"fromAmount"`
		ToAmount          string `json:"toAmount"`
		ToAmountMin       string `json:"toAmountMin"`
		FromAmountUSD     string `json:"fromAmountUSD"`
		ToAmountUSD       string `json:"toAmountUSD"`
		ExecutionDuration int64  `json:"executionDuration"`
		GasCosts          []struct {
			Type      string `json:"type"`
			Estimate  string `json:"estimate"`
			Amount    string `json:"amount"`
			AmountUSD string `json:"amountUSD"`
		} `json:"gasCosts"`
		FeeCosts []struct {
			Name      string `json:"name"`
			Amount    string `json:"amount"`
			AmountUSD string `json:"amountUSD"`
		} `json:"feeCosts"`
		ApprovalAddress string `json:"approvalAddress"`
	} `json:"estimate"`
	TransactionRequest struct {
		To       string `json:"to"`
		Data     string `json:"data"`
		Value    string `json:"value"`
		From     string `json:"from,omitempty"`
		ChainID  int    `json:"chainId,omitempty"`
		GasPrice string `json:"gasPrice,omitempty"`
		GasLimit string `json:"gasLimit,omitempty"`
	} `json:"transactionRequest"`
}

type StatusRes

type StatusRes struct {
	Status       string `json:"status"`
	Substatus    string `json:"substatus"`
	SubstatusMsg string `json:"substatusMessage"`

	Sending struct {
		TxHash  string `json:"txHash"`
		ChainID int    `json:"chainId"`
		Amount  string `json:"amount"`
	} `json:"sending"`

	Receiving struct {
		TxHash  string `json:"txHash"`
		ChainID int    `json:"chainId"`
		Amount  string `json:"amount"`
	} `json:"receiving"`
}

type Token

type Token struct {
	Address  string `json:"address"`
	Symbol   string `json:"symbol"`
	Decimals int    `json:"decimals"`
	ChainID  int    `json:"chainId"`
	Name     string `json:"name"`
	PriceUSD string `json:"priceUSD"`
	LogoURI  string `json:"logoURI"`
}

type TokensRes

type TokensRes struct {
	Tokens map[string][]Token `json:"tokens"`
}

Jump to

Keyboard shortcuts

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