usecase

package
v21.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilCurrentRoute     = errors.New("currentRoute cannot be nil")
	ErrNilRouterRepository = errors.New("router repository is not set")
	ErrNilPoolsRepository  = errors.New("pools repository is not set")
)

Functions

func NewRouterUsecase

func NewRouterUsecase(timeout time.Duration, routerRepository mvc.RouterRepository, poolsUsecase mvc.PoolsUsecase, config domain.RouterConfig, logger log.Logger) mvc.RouterUsecase

NewRouterUsecase will create a new pools use case object

Types

type CurrentTokenOutDenomNotInPoolError

type CurrentTokenOutDenomNotInPoolError struct {
	RouteIndex           int
	PoolId               uint64
	CurrentTokenOutDenom string
}

func (CurrentTokenOutDenomNotInPoolError) Error

type NoPoolsInRouteError

type NoPoolsInRouteError struct {
	RouteIndex int
}

func (NoPoolsInRouteError) Error

func (e NoPoolsInRouteError) Error() string

type Pool

type Pool struct {
	ID       int
	TokenIn  string
	TokenOut string
}

Pool represents a pool in the decentralized exchange.

type PreviousTokenOutDenomNotInPoolError

type PreviousTokenOutDenomNotInPoolError struct {
	RouteIndex            int
	PoolId                uint64
	PreviousTokenOutDenom string
}

func (PreviousTokenOutDenomNotInPoolError) Error

type RoutePoolWithTokenInDenomError

type RoutePoolWithTokenInDenomError struct {
	RouteIndex   int
	TokenInDenom string
}

func (RoutePoolWithTokenInDenomError) Error

type RoutePoolWithTokenOutDenomError

type RoutePoolWithTokenOutDenomError struct {
	RouteIndex    int
	TokenOutDenom string
}

func (RoutePoolWithTokenOutDenomError) Error

type RouteWithOutAmount

type RouteWithOutAmount struct {
	route.RouteImpl
	OutAmount osmomath.Int "json:\"out_amount\""
	InAmount  osmomath.Int "json:\"in_amount\""
}

func (RouteWithOutAmount) GetAmountIn

func (r RouteWithOutAmount) GetAmountIn() osmomath.Int

GetAmountIn implements domain.SplitRoute.

func (RouteWithOutAmount) GetAmountOut

func (r RouteWithOutAmount) GetAmountOut() math.Int

GetAmountOut implements domain.SplitRoute.

type Router

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

func NewRouter

func NewRouter(preferredPoolIDs []uint64, maxHops, maxRoutes, maxSplitRoutes, maxSplitIterations int, minOSMOTVL int, logger log.Logger) *Router

NewRouter returns a new Router. It initialized the routable pools where the given preferredPoolIDs take precedence. The rest of the pools are sorted by TVL. Each pool has a flag indicating whether there was an error in estimating its on-chain TVL. If that is the case, the pool is to be sorted towards the end. However, the preferredPoolIDs overwrites this rule and prioritizes the preferred pools.

func WithPoolsUsecase

func WithPoolsUsecase(router *Router, poolsUsecase mvc.PoolsUsecase) *Router

WithPoolsUsecase instruments router by setting a pools usecase on it and returns the router.

func WithRouterRepository

func WithRouterRepository(router *Router, routerRepository mvc.RouterRepository) *Router

WithRouterRepository instruments router by setting a router repository on it and returns the router.

func WithSortedPools

func WithSortedPools(router *Router, allPools []domain.PoolI) *Router

func (Router) GetCandidateRoutes

func (r Router) GetCandidateRoutes(tokenInDenom, tokenOutDenom string) (route.CandidateRoutes, error)

GetCandidateRoutes returns candidate routes from tokenInDenom to tokenOutDenom using BFS.

func (Router) GetLogger

func (r Router) GetLogger() log.Logger

GetLogger returns the logger.

func (Router) GetMaxHops

func (r Router) GetMaxHops() int

GetMaxHops returns the maximum number of hops configured.

func (Router) GetMaxRoutes

func (r Router) GetMaxRoutes() int

GetMaxRoutes returns the maximum number of routes configured.

func (Router) GetMaxSplitIterations

func (r Router) GetMaxSplitIterations() int

GetMaxSplitIterations returns the maximum number of iterations when searching for split routes.

func (Router) GetSortedPools

func (r Router) GetSortedPools() []domain.PoolI

func (*Router) GetSplitQuote

func (r *Router) GetSplitQuote(routes []route.RouteImpl, tokenIn sdk.Coin) (domain.Quote, error)

type SortedPoolsAndPoolsInRouteLengthMismatchError

type SortedPoolsAndPoolsInRouteLengthMismatchError struct {
	SortedPoolsLen int
	PoolsInRoute   int
}

func (SortedPoolsAndPoolsInRouteLengthMismatchError) Error

type SortedPoolsAndPoolsUsedLengthMismatchError

type SortedPoolsAndPoolsUsedLengthMismatchError struct {
	SortedPoolsLen int
	PoolsUsedLen   int
}

func (SortedPoolsAndPoolsUsedLengthMismatchError) Error

type Split

type Split struct {
	Routes          []domain.SplitRoute
	CurrentTotalOut osmomath.Int
}

type TokenOutDenomMatchesTokenInDenomError

type TokenOutDenomMatchesTokenInDenomError struct {
	Denom string
}

func (TokenOutDenomMatchesTokenInDenomError) Error

type TokenOutMismatchBetweenRoutesError

type TokenOutMismatchBetweenRoutesError struct {
	TokenOutDenomRouteA string
	TokenOutDenomRouteB string
}

func (TokenOutMismatchBetweenRoutesError) Error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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