Versions in this module Expand all Collapse all v1 v1.0.0 Mar 14, 2024 Changes in this version + var ErrAllOnSameChain = errors.New("all pools must be on the same chain") + var ErrDuplicatePools = errors.New("duplicate pools") + var ErrFeeTooHigh = errors.New("Fee too high") + var ErrInputCurrencyMismatch = errors.New("input currency mismatch") + var ErrInputNotInvolved = errors.New("input token not involved in route") + var ErrInvalidAmountForRoute = errors.New("invalid amount for route") + var ErrInvalidMaxHops = errors.New("invalid max hops") + var ErrInvalidMaxSize = errors.New("invalid max size") + var ErrInvalidRecursion = errors.New("invalid recursion") + var ErrInvalidSlippageTolerance = errors.New("invalid slippage tolerance") + var ErrInvalidSqrtRatioX96 = errors.New("Invalid sqrtRatioX96") + var ErrInvalidTickSpacing = errors.New("invalid tick spacing") + var ErrMaxSizeExceeded = errors.New("max size exceeded") + var ErrNoPools = errors.New("no pools") + var ErrOutputCurrencyMismatch = errors.New("output currency mismatch") + var ErrOutputNotInvolved = errors.New("output token not involved in route") + var ErrPathNotContinuous = errors.New("path not continuous") + var ErrRouteNoPools = errors.New("route must have at least one pool") + var ErrSorted = errors.New("ticks must be sorted") + var ErrSqrtPriceLimitX96TooHigh = errors.New("SqrtPriceLimitX96 too high") + var ErrSqrtPriceLimitX96TooLow = errors.New("SqrtPriceLimitX96 too low") + var ErrTickLower = errors.New("tick lower error") + var ErrTickOrder = errors.New("tick order error") + var ErrTickUpper = errors.New("tick upper error") + var ErrTokenNotInvolved = errors.New("Token not involved in pool") + var ErrTradeHasMultipleRoutes = errors.New("trade has multiple routes") + var ErrZeroNet = errors.New("tick net delta must be zero") + var ErrZeroTickSpacing = errors.New("tick spacing must be greater than 0") + func GetAddress(tokenA, tokenB *entities.Token, fee constants.FeeAmount, ...) (common.Address, error) + func IsAtOrAboveLargest(ticks []Tick, tick int) bool + func IsBelowSmallest(ticks []Tick, tick int) bool + func NearestUsableTick(tick int, tickSpacing int) int + func NextInitializedTickWithinOneWord(ticks []Tick, tick int, lte bool, tickSpacing int) (int, bool) + func Round(x float64) float64 + func ValidateList(ticks []Tick, tickSpacing int) error + type BestTradeOptions struct + MaxHops int + MaxNumResults int + type Pool struct + Fee constants.FeeAmount + Liquidity *big.Int + SqrtRatioX96 *big.Int + TickCurrent int + TickDataProvider TickDataProvider + Token0 *entities.Token + Token1 *entities.Token + func NewPool(tokenA, tokenB *entities.Token, fee constants.FeeAmount, sqrtRatioX96 *big.Int, ...) (*Pool, error) + func (p *Pool) ChainID() uint + func (p *Pool) GetInputAmount(outputAmount *entities.CurrencyAmount, sqrtPriceLimitX96 *big.Int) (*entities.CurrencyAmount, *Pool, error) + func (p *Pool) GetOutputAmount(inputAmount *entities.CurrencyAmount, sqrtPriceLimitX96 *big.Int) (*entities.CurrencyAmount, *Pool, error) + func (p *Pool) InvolvesToken(token *entities.Token) bool + func (p *Pool) PriceOf(token *entities.Token) (*entities.Price, error) + func (p *Pool) Token0Price() *entities.Price + func (p *Pool) Token1Price() *entities.Price + type Position struct + Liquidity *big.Int + Pool *Pool + TickLower int + TickUpper int + func FromAmount0(pool *Pool, tickLower, tickUpper int, amount0 *big.Int, useFullPrecision bool) (*Position, error) + func FromAmount1(pool *Pool, tickLower, tickUpper int, amount1 *big.Int) (*Position, error) + func FromAmounts(pool *Pool, tickLower, tickUpper int, amount0, amount1 *big.Int, ...) (*Position, error) + func NewPosition(pool *Pool, liquidity *big.Int, tickLower int, tickUpper int) (*Position, error) + func (p *Position) Amount0() (*entities.CurrencyAmount, error) + func (p *Position) Amount1() (*entities.CurrencyAmount, error) + func (p *Position) BurnAmountsWithSlippage(slippageTolerance *entities.Percent) (amount0, amount1 *big.Int, err error) + func (p *Position) MintAmounts() (amount0, amount1 *big.Int, err error) + func (p *Position) MintAmountsWithSlippage(slippageTolerance *entities.Percent) (amount0, amount1 *big.Int, err error) + func (p *Position) Token0PriceLower() (*entities.Price, error) + func (p *Position) Token0PriceUpper() (*entities.Price, error) + type Route struct + Input entities.Currency + Output entities.Currency + Pools []*Pool + TokenPath []*entities.Token + func NewRoute(pools []*Pool, input, output entities.Currency) (*Route, error) + func (r *Route) ChainID() uint + func (r *Route) MidPrice() (*entities.Price, error) + type StepComputations struct + type Swap struct + InputAmount *entities.CurrencyAmount + OutputAmount *entities.CurrencyAmount + Route *Route + type Tick struct + Index int + LiquidityGross *big.Int + LiquidityNet *big.Int + func GetTick(ticks []Tick, index int) Tick + func NextInitializedTick(ticks []Tick, tick int, lte bool) Tick + type TickDataProvider interface + GetTick func(tick int) Tick + NextInitializedTickWithinOneWord func(tick int, lte bool, tickSpacing int) (int, bool) + type TickListDataProvider struct + func NewTickListDataProvider(ticks []Tick, tickSpacing int) (*TickListDataProvider, error) + func (p *TickListDataProvider) GetTick(tick int) Tick + func (p *TickListDataProvider) NextInitializedTickWithinOneWord(tick int, lte bool, tickSpacing int) (int, bool) + type Trade struct + Swaps []*Swap + TradeType entities.TradeType + func BestTradeExactIn(pools []*Pool, currencyAmountIn *entities.CurrencyAmount, ...) ([]*Trade, error) + func BestTradeExactOut(pools []*Pool, currencyIn entities.Currency, ...) ([]*Trade, error) + func CreateUncheckedTrade(route *Route, inputAmount, outputAmount *entities.CurrencyAmount, ...) (*Trade, error) + func CreateUncheckedTradeWithMultipleRoutes(routes []*Swap, tradeType entities.TradeType) (*Trade, error) + func ExactIn(route *Route, amountIn *entities.CurrencyAmount) (*Trade, error) + func ExactOut(route *Route, amountOut *entities.CurrencyAmount) (*Trade, error) + func FromRoute(route *Route, amount *entities.CurrencyAmount, tradeType entities.TradeType) (*Trade, error) + func FromRoutes(wrappedRoutes []*WrappedRoute, tradeType entities.TradeType) (*Trade, error) + func (t *Trade) ExecutionPrice() *entities.Price + func (t *Trade) InputAmount() *entities.CurrencyAmount + func (t *Trade) MaximumAmountIn(slippageTolerance *entities.Percent, amountIn *entities.CurrencyAmount) (*entities.CurrencyAmount, error) + func (t *Trade) MinimumAmountOut(slippageTolerance *entities.Percent, amountOut *entities.CurrencyAmount) (*entities.CurrencyAmount, error) + func (t *Trade) OutputAmount() *entities.CurrencyAmount + func (t *Trade) PriceImpact() (*entities.Percent, error) + func (t *Trade) Route() (*Route, error) + func (t *Trade) WorstExecutionPrice(slippageTolerance *entities.Percent) (*entities.Price, error) + type WrappedRoute struct + Amount *entities.CurrencyAmount + Route *Route