domain

package
v21.1.0 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: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInternalServerError will throw if any the Internal Server Error happen
	ErrInternalServerError = errors.New("internal Server Error")
	// ErrNotFound will throw if the requested item is not exists
	ErrNotFound = errors.New("your requested Item is not found")
	// ErrConflict will throw if the current action already exists
	ErrConflict = errors.New("your Item already exist")
	// ErrBadParamInput will throw if the given request-body or params is not valid
	ErrBadParamInput = errors.New("given Param is not valid")
)
View Source
var DefaultTakerFee = osmomath.MustNewDecFromStr("0.001000000000000000")

Functions

This section is empty.

Types

type ConcentratedCurrentTickAndBucketMismatchError

type ConcentratedCurrentTickAndBucketMismatchError struct {
	CurrentTick int64
	LowerTick   int64
	UpperTick   int64
}

func (ConcentratedCurrentTickAndBucketMismatchError) Error

type ConcentratedCurrentTickNotWithinBucketError

type ConcentratedCurrentTickNotWithinBucketError struct {
	PoolId             uint64
	CurrentBucketIndex int64
	TotalBuckets       int64
}

func (ConcentratedCurrentTickNotWithinBucketError) Error

type ConcentratedNoLiquidityError

type ConcentratedNoLiquidityError struct {
	PoolId uint64
}

func (ConcentratedNoLiquidityError) Error

type ConcentratedNotEnoughLiquidityToCompleteSwapError

type ConcentratedNotEnoughLiquidityToCompleteSwapError struct {
	PoolId   uint64
	AmountIn string
}

func (ConcentratedNotEnoughLiquidityToCompleteSwapError) Error

type ConcentratedPoolNoTickModelError

type ConcentratedPoolNoTickModelError struct {
	PoolId uint64
}

func (ConcentratedPoolNoTickModelError) Error

type ConcentratedTickModelNotSetError

type ConcentratedTickModelNotSetError struct {
	PoolId uint64
}

func (ConcentratedTickModelNotSetError) Error

type ConcentratedZeroCurrentSqrtPriceError

type ConcentratedZeroCurrentSqrtPriceError struct {
	PoolId uint64
}

func (ConcentratedZeroCurrentSqrtPriceError) Error

type DenomPair

type DenomPair struct {
	Denom0 string
	Denom1 string
}

DenomPair encapsulates a pair of denoms. The order of the denoms ius that Denom0 precedes Denom1 lexicographically.

type FailedToCastPoolModelError

type FailedToCastPoolModelError struct {
	ExpectedModel string
	ActualModel   string
}

func (FailedToCastPoolModelError) Error

type InvalidPoolTypeError

type InvalidPoolTypeError struct {
	PoolType int32
}

InvalidPoolTypeError is an error type for invalid pool type.

func (InvalidPoolTypeError) Error

func (e InvalidPoolTypeError) Error() string

type LiquidityDepthsWithRange

type LiquidityDepthsWithRange = clqueryproto.LiquidityDepthWithRange

type PoolI

type PoolI interface {
	// GetId returns the ID of the pool.
	GetId() uint64
	// GetType returns the type of the pool (Balancer, Stableswap, Concentrated, etc.)
	GetType() poolmanagertypes.PoolType

	GetTotalValueLockedUOSMO() osmomath.Int

	GetPoolDenoms() []string

	GetUnderlyingPool() poolmanagertypes.PoolI

	GetSQSPoolModel() SQSPool

	// GetTickModel returns the tick model for the pool
	// If this is a concentrated pool. Errors otherwise
	// Also errors if this is a concentrated pool but
	// the tick model is not set
	GetTickModel() (*TickModel, error)

	// SetTickModel sets the tick model for the pool
	// If this is not a concentrated pool, errors
	SetTickModel(*TickModel) error

	// Validate validates the pool
	// Returns nil if the pool is valid
	// Returns error if the pool is invalid
	Validate(minUOSMOTVL osmomath.Int) error
}

PoolI represents a generalized Pool interface.

func NewPool

func NewPool(model poolmanagertypes.PoolI, spreadFactor osmomath.Dec, balances sdk.Coins) PoolI

type PoolNotFoundError

type PoolNotFoundError struct {
	PoolID uint64
}

func (PoolNotFoundError) Error

func (e PoolNotFoundError) Error() string

type PoolWrapper

type PoolWrapper struct {
	ChainModel poolmanagertypes.PoolI `json:"underlying_pool"`
	SQSModel   SQSPool                `json:"sqs_model"`
	TickModel  *TickModel             `json:"tick_model,omitempty"`
}

func (*PoolWrapper) GetId

func (p *PoolWrapper) GetId() uint64

GetId implements PoolI.

func (*PoolWrapper) GetPoolDenoms

func (p *PoolWrapper) GetPoolDenoms() []string

GetPoolDenoms implements PoolI.

func (*PoolWrapper) GetSQSPoolModel

func (p *PoolWrapper) GetSQSPoolModel() SQSPool

GetSQSPoolModel implements PoolI.

func (*PoolWrapper) GetTickModel

func (p *PoolWrapper) GetTickModel() (*TickModel, error)

GetTickModel implements PoolI.

func (*PoolWrapper) GetTotalValueLockedUOSMO

func (p *PoolWrapper) GetTotalValueLockedUOSMO() osmomath.Int

GetTotalValueLockedUOSMO implements PoolI.

func (*PoolWrapper) GetType

func (p *PoolWrapper) GetType() poolmanagertypes.PoolType

GetType implements PoolI.

func (*PoolWrapper) GetUnderlyingPool

func (p *PoolWrapper) GetUnderlyingPool() poolmanagertypes.PoolI

GetUnderlyingPool implements PoolI.

func (*PoolWrapper) SetTickModel

func (p *PoolWrapper) SetTickModel(tickModel *TickModel) error

SetTickModel implements PoolI.

func (*PoolWrapper) Validate

func (p *PoolWrapper) Validate(minUOSMOTVL osmomath.Int) error

type Quote

type Quote interface {
	GetAmountIn() sdk.Coin
	GetAmountOut() osmomath.Int
	GetRoute() []SplitRoute
	GetEffectiveSpreadFactor() osmomath.Dec

	// PrepareResult mutates the quote to prepare
	// it with the data formatted for output to the client.
	PrepareResult() ([]SplitRoute, osmomath.Dec)

	String() string
}

type RoutablePool

type RoutablePool interface {
	GetId() uint64

	GetType() poolmanagertypes.PoolType

	GetPoolDenoms() []string

	GetTokenOutDenom() string

	CalculateTokenOutByTokenIn(tokenIn sdk.Coin) (sdk.Coin, error)
	ChargeTakerFeeExactIn(tokenIn sdk.Coin) (tokenInAfterFee sdk.Coin)

	// SetTokenOutDenom sets the token out denom on the routable pool.
	SetTokenOutDenom(tokenOutDenom string)

	GetTakerFee() osmomath.Dec

	GetSpreadFactor() osmomath.Dec

	String() string
}

type RoutableResultPool

type RoutableResultPool interface {
	RoutablePool
	GetBalances() sdk.Coins
}

type Route

type Route interface {
	GetPools() []RoutablePool
	// AddPool adds pool to route.
	AddPool(pool PoolI, tokenOut string, takerFee osmomath.Dec)
	// CalculateTokenOutByTokenIn calculates the token out amount given the token in amount.
	// Returns error if the calculation fails.
	CalculateTokenOutByTokenIn(tokenIn sdk.Coin) (sdk.Coin, error)

	GetTokenOutDenom() string

	// PrepareResultPools strips away unnecessary fields
	// from each pool in the route,
	// leaving only the data needed by client
	// Note that it mutates the route.
	// Returns the resulting pools.
	PrepareResultPools() []RoutablePool

	String() string
}

type RouterConfig

type RouterConfig struct {
	PreferredPoolIDs   []uint64 `mapstructure:"preferred_pool_ids"`
	MaxPoolsPerRoute   int      `mapstructure:"max_pools_per_route"`
	MaxRoutes          int      `mapstructure:"max_routes"`
	MaxSplitRoutes     int      `mapstructure:"max_split_routes"`
	MaxSplitIterations int      `mapstructure:"max_split_iterations"`
	// Denominated in OSMO (not uosmo)
	MinOSMOLiquidity          int  `mapstructure:"min_osmo_liquidity"`
	RouteUpdateHeightInterval int  `mapstructure:"route_update_height_interval"`
	RouteCacheEnabled         bool `mapstructure:"route_cache_enabled"`
	// The number of seconds to cache routes for before expiry.
	RouteCacheExpirySeconds uint64 `mapstructure:"route_cache_expiry_seconds"`
}

type SQSPool

type SQSPool struct {
	TotalValueLockedUSDC  osmomath.Int `json:"total_value_locked_uosmo"`
	TotalValueLockedError string       `json:"total_value_locked_error,omitempty"`
	// Only CL and Cosmwasm pools need balances appended
	Balances     sdk.Coins    `json:"balances"`
	PoolDenoms   []string     `json:"pool_denoms"`
	SpreadFactor osmomath.Dec `json:"spread_factor"`
}

type SplitRoute

type SplitRoute interface {
	Route
	GetAmountIn() osmomath.Int
	GetAmountOut() osmomath.Int
}

type StaleHeightError

type StaleHeightError struct {
	StoredHeight            uint64
	TimeSinceLastUpdate     int
	MaxAllowedTimeDeltaSecs int
}

func (StaleHeightError) Error

func (e StaleHeightError) Error() string

type TakerFeeForPair

type TakerFeeForPair struct {
	Denom0   string
	Denom1   string
	TakerFee osmomath.Dec
}

TakerFeeForPair represents the taker fee for a pair of tokens

type TakerFeeMap

type TakerFeeMap map[DenomPair]osmomath.Dec

TakerFeeMap is a map of DenomPair to taker fee. It sorts the denoms lexicographically before looking up the taker fee.

func (TakerFeeMap) GetTakerFee

func (tfm TakerFeeMap) GetTakerFee(denom0, denom1 string) osmomath.Dec

GetTakerFee returns the taker fee for the given denoms. It sorts the denoms lexicographically before looking up the taker fee. Returns error if the taker fee is not found.

func (TakerFeeMap) Has

func (tfm TakerFeeMap) Has(denom0, denom1 string) bool

Has returns true if the taker fee for the given denoms is found. It sorts the denoms lexicographically before looking up the taker fee.

func (TakerFeeMap) MarshalJSON

func (tfm TakerFeeMap) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (TakerFeeMap) SetTakerFee

func (tfm TakerFeeMap) SetTakerFee(denom0, denom1 string, takerFee osmomath.Dec)

SetTakerFee sets the taker fee for the given denoms. It sorts the denoms lexicographically before setting the taker fee.

func (TakerFeeMap) UnmarshalJSON

func (tfm TakerFeeMap) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type TakerFeeNotFoundForDenomPairError

type TakerFeeNotFoundForDenomPairError struct {
	Denom0 string
	Denom1 string
}

func (TakerFeeNotFoundForDenomPairError) Error

type TickModel

type TickModel struct {
	Ticks            []LiquidityDepthsWithRange `json:"ticks,omitempty"`
	CurrentTickIndex int64                      `json:"current_tick_index,omitempty"`
	HasNoLiquidity   bool                       `json:"has_no_liquidity,omitempty"`
}

type Token

type Token struct {
	// ChainDenom is the denom used in the chain state.
	ChainDenom string `json:"chain_denom"`
	// HumanDenom is the human readable denom.
	HumanDenom string `json:"human_denom"`
	// Precision is the precision of the token.
	Precision int `json:"precision"`
}

Token represents the token's domain model

type TokensUsecase

type TokensUsecase interface {
	GetDenomPrecisions(ctx context.Context) (map[string]int, error)
}

Tokens represent the token's usecases

type TransmuterInsufficientBalanceError

type TransmuterInsufficientBalanceError struct {
	Denom         string
	BalanceAmount string
	Amount        string
}

func (TransmuterInsufficientBalanceError) Error

Directories

Path Synopsis
This package encapsulates the JSON library used by the sidecar query server.
This package encapsulates the JSON library used by the sidecar query server.
Encapsulates the Model-View-Controller abstraction domain.
Encapsulates the Model-View-Controller abstraction domain.

Jump to

Keyboard shortcuts

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