dex

package
v0.16.2 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: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WarnThinLiquidity   = "THIN_LIQUIDITY"
	WarnPriceImpactHigh = "PRICE_IMPACT_HIGH"
)
View Source
const (
	ViaDevice = "device"
	ViaServer = "server"
)
View Source
const DefaultTimeout = 5 * time.Second
View Source
const ThinLiquidityRatio = 0.05

Variables

This section is empty.

Functions

func FormatUSD added in v0.16.2

func FormatUSD(v float64) string

func IsRouteUnsafe added in v0.16.2

func IsRouteUnsafe(r *Route) bool

func RawToHuman added in v0.16.2

func RawToHuman(raw string, decimals int) float64

func ReasonFor added in v0.16.2

func ReasonFor(c *Candidate, channel string) string

Types

type Candidate added in v0.16.2

type Candidate struct {
	Channel      string
	Via          string
	FromChain    string
	FromToken    string
	FromAddress  string
	ToChain      string
	ToToken      string
	ToAddress    string
	ToDecimals   int
	LiquidityUsd float64
	SourceIssuer string
}

func (*Candidate) CrossChain added in v0.16.2

func (c *Candidate) CrossChain() bool

type Engine added in v0.16.2

type Engine struct {
	Logf func(format string, args ...interface{})
}

func (*Engine) Quote added in v0.16.2

func (e *Engine) Quote(ctx context.Context, req *Request, cands []*Candidate, quote QuoteFn) *Response

type QuoteFn added in v0.16.2

type QuoteFn func(ctx context.Context, cand *Candidate, in *dexmodel.DexQuoteIn) (*dexmodel.DexQuoteOut, error)

type RateLimit

type RateLimit struct {
	QPS   float64
	Burst int
}

func (RateLimit) Apply

func (r RateLimit) Apply(req *httpc.Request)

type Request added in v0.16.2

type Request struct {
	FromAmount    string
	SlippageBps   int
	Timeout       time.Duration
	FromAmountUsd float64
	ToPriceUsd    float64
}

type Response added in v0.16.2

type Response struct {
	Routes        []*Route `json:"routes"`
	Reason        string   `json:"reason,omitempty"`
	ReasonMessage string   `json:"reasonMessage,omitempty"`
}

type Route added in v0.16.2

type Route struct {
	Rank            int       `json:"rank"`
	Recommended     bool      `json:"recommended"`
	CrossChain      bool      `json:"crossChain"`
	FromChain       string    `json:"fromChain"`
	FromToken       string    `json:"fromToken"`
	ToChain         string    `json:"toChain"`
	ToToken         string    `json:"toToken"`
	ToDecimals      int       `json:"toDecimals"`
	SourceIssuer    string    `json:"sourceIssuer,omitempty"`
	ToAmount        string    `json:"toAmount"`
	ToAmountUsd     float64   `json:"toAmountUsd"`
	ExpectedFillUsd float64   `json:"expectedFillUsd,omitempty"`
	Channel         string    `json:"channel"`
	FeeUsd          float64   `json:"feeUsd,omitempty"`
	PriceImpactPct  float64   `json:"priceImpactPct,omitempty"`
	LiquidityUsd    float64   `json:"liquidityUsd,omitempty"`
	EstSeconds      int64     `json:"estSeconds,omitempty"`
	Warnings        []Warning `json:"warnings,omitempty"`
	Reason          string    `json:"reason,omitempty"`
}

type Warning added in v0.16.2

type Warning = dexmodel.DexWarning

Directories

Path Synopsis
Package pancakeswap wraps the PancakeSwap V3 subgraph on BNB Chain.
Package pancakeswap wraps the PancakeSwap V3 subgraph on BNB Chain.
Package uniswap wraps the Uniswap V3 subgraph on Ethereum mainnet.
Package uniswap wraps the Uniswap V3 subgraph on Ethereum mainnet.

Jump to

Keyboard shortcuts

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