domain

package
v23.0.12-iavl-v1 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// sqs_sync_check_error
	//
	// counter that is increased if node sync check fails when processing the first block
	//
	// Has the following labels:
	// * err - the error returned
	// * height - the height of the block being processed
	SQSNodeSyncCheckErrorMetricName = "sqs_sync_check_error"

	// sqs_process_block_error
	//
	// counter that is increased if ingest process block fails with error.
	//
	// Has the following labels:
	// * msg - the error returned
	// * height - the height of the block being processed
	SQSProcessBlockErrorMetricName = "sqs_process_block_error"

	// sqs_process_block_panic
	//
	// counter that is increased if ingest process block fails with panic.
	//
	// Has the following labels:
	// * msg - the error returned
	// * height - the height of the block being processed
	SQSProcessBlockPanicMetricName = "sqs_process_block_panic"

	// sqs_process_block_duration
	//
	// histogram that measures the duration of processing a block
	//
	// Has the following labels:
	// * height - the height of the block being processed
	SQSProcessBlockDurationMetricName = "sqs_process_block_duration"

	// sqs_grpc_connection_error
	//
	// counter that is increased if grpc connection fails
	//
	// Has the following labels:
	// * err - the error returned
	// * height - the height of the block being processed
	SQSGRPCConnectionErrorMetricName = "sqs_grpc_connection_error"
)
View Source
var (
	ErrNodeIsSyncing = errors.New("node is syncing, skipping block processing")
)

Functions

func GetDenomPrecisions

func GetDenomPrecisions(ctx context.Context) (map[string]int, error)

GetDenomPrecisions implements domain.TokensUsecase.

Types

type AssetList

type AssetList struct {
	ChainName string `json:"chain_name"`
	Assets    []struct {
		Description string `json:"description"`
		DenomUnits  []struct {
			Denom    string `json:"denom"`
			Exponent int    `json:"exponent"`
		} `json:"denom_units"`
		Base     string        `json:"base"`
		Name     string        `json:"name"`
		Display  string        `json:"display"`
		Symbol   string        `json:"symbol"`
		Traces   []interface{} `json:"traces"`
		LogoURIs struct {
			PNG string `json:"png"`
			SVG string `json:"svg"`
		} `json:"logo_URIs"`
		CoingeckoID string   `json:"coingecko_id"`
		Keywords    []string `json:"keywords"`
	} `json:"assets"`
}

Struct to represent the JSON structure

type AssetListGetter

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

func NewAssetListGetter

func NewAssetListGetter() AssetListGetter

type AssetListGetterImpl

type AssetListGetterImpl struct{}

func (*AssetListGetterImpl) GetDenomPrecisions

func (*AssetListGetterImpl) GetDenomPrecisions(ctx context.Context) (map[string]int, error)

GetDenomPrecisions implements AssetListGetter.

type BankKeeper

type BankKeeper interface {
	GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
}

BankKeeper is an interface for getting bank balances.

type BlockPoolUpdateTracker added in v23.0.9

type BlockPoolUpdateTracker interface {
	// TrackConcentrated tracks the concentrated pool.
	TrackConcentrated(pool poolmanagertypes.PoolI)

	// TrackConcentratedPoolIDTickChange tracks the concentrated pool ID tick change.
	// Due to internal implementation, it is non-trivial to apply tick changes.
	// As a result, we track the pool ID tick change and read the pool with all of its ticks
	// if at least one tick change was applied within the block.
	TrackConcentratedPoolIDTickChange(poolID uint64)

	// TrackCFMM tracks the CFMM pool.
	TrackCFMM(pool poolmanagertypes.PoolI)

	// TrackCosmWasm tracks the CosmWasm pool.
	TrackCosmWasm(pool poolmanagertypes.PoolI)

	// GetConcentratedPools returns the tracked concentrated pools.
	GetConcentratedPools() []poolmanagertypes.PoolI

	// GetConcentratedPoolIDTickChange returns the tracked concentrated pool ID tick change.
	GetConcentratedPoolIDTickChange() map[uint64]struct{}

	// GetCFMMPools returns the tracked CFMM pools.
	GetCFMMPools() []poolmanagertypes.PoolI

	// GetCosmWasmPools returns the tracked CosmWasm pools.
	GetCosmWasmPools() []poolmanagertypes.PoolI

	// Reset clears the internal state.
	Reset()
}

BlockPoolUpdateTracker is an interface for tracking the pools that were updated in a block. It persists the pools using "Track" methods in its internal state. It tracks the latest pool update, discarding the previous updates. Only on Reset, the internal state is cleared.

type BlockPools added in v23.0.9

type BlockPools struct {
	// ConcentratedPools are the concentrated pools to be ingested.
	ConcentratedPools []poolmanagertypes.PoolI
	// ConcentratedPoolIDTickChange is the map of pool ID to tick change for concentrated pools.
	// We use these pool IDs to append concentrated pools with all ticks at the end of the block.
	ConcentratedPoolIDTickChange map[uint64]struct{}
	// CosmWasmPools are the CosmWasm pools to be ingested.
	CosmWasmPools []poolmanagertypes.PoolI
	// CFMMPools are the CFMM pools to be ingested.
	CFMMPools []poolmanagertypes.PoolI
}

BlockPools contains the pools to be ingested in a block.

type ConcentratedKeeper

type ConcentratedKeeper interface {
	PoolKeeper
	GetTickLiquidityForFullRange(ctx sdk.Context, poolId uint64) ([]queryproto.LiquidityDepthWithRange, int64, error)
	GetConcentratedPoolById(ctx sdk.Context, poolId uint64) (concentratedtypes.ConcentratedPoolExtension, error)
}

ConcentratedKeeper is an interface for the concentrated keeper.

type CosmWasmPoolKeeper

type CosmWasmPoolKeeper interface {
	GetPoolsWithWasmKeeper(ctx sdk.Context) ([]poolmanagertypes.PoolI, error)
}

CosmWasmPoolKeeper is an interface for getting CosmWasm pools from a keeper.

type Ingester added in v23.0.9

type Ingester interface {
	// ProcessAllBlockData processes the block and ingests data into a sink.
	// Returns error if the ingester fails to ingest data.
	ProcessAllBlockData(ctx sdk.Context) error

	// ProcessChangedBlockData processes only the pools that were changed in the block.
	ProcessChangedBlockData(ctx sdk.Context, changedPools BlockPools) error
}

Ingester is an interface that defines the methods for the ingester. Ingester ingests data into a sink.

type NodeStatusChecker added in v23.0.9

type NodeStatusChecker interface {
	// IsNodeSyncing checks if the node is syncing.
	// Returns true if the node is syncing, false otherwise.
	// Returns error if the node syncing status cannot be determined.
	IsNodeSyncing(ctx sdk.Context) (bool, error)
}

NodeStatusChecker is an interface for checking the node status.

type PoolKeeper

type PoolKeeper interface {
	GetPools(ctx sdk.Context) ([]poolmanagertypes.PoolI, error)
}

PoolKeeper is an interface for getting pools from a keeper.

type PoolManagerKeeper

type PoolManagerKeeper interface {
	RouteCalculateSpotPrice(
		ctx sdk.Context,
		poolId uint64,
		quoteAssetDenom string,
		baseAssetDenom string,
	) (price osmomath.BigDec, err error)

	SwapExactAmountIn(
		ctx sdk.Context,
		sender sdk.AccAddress,
		poolId uint64,
		tokenIn sdk.Coin,
		tokenOutDenom string,
		tokenOutMinAmount osmomath.Int,
	) (tokenOutAmount osmomath.Int, err error)

	RouteGetPoolDenoms(
		ctx sdk.Context,
		poolId uint64,
	) (denoms []string, err error)

	GetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string) (osmomath.Dec, error)

	MultihopEstimateInGivenExactAmountOut(
		ctx sdk.Context,
		route []poolmanagertypes.SwapAmountOutRoute,
		tokenOut sdk.Coin,
	) (tokenInAmount osmomath.Int, err error)
}

PoolManagerKeeper is an interface for the pool manager keeper.

type PoolsTransformer

type PoolsTransformer interface {
	// Transform processes the pool state, returning pools instrumented with all the necessary chain data.
	// Additionally, returns the taker fee map for every pool denom pair.
	// Returns error if the transformer fails to process pool data.
	Transform(ctx sdk.Context, blockPools BlockPools) ([]sqsdomain.PoolI, sqsdomain.TakerFeeMap, error)
}

PoolsTransformer is an interface that defines the methods for the pool transformer

type ProtorevKeeper

type ProtorevKeeper interface {
	GetPoolForDenomPair(ctx sdk.Context, baseDenom, denomToMatch string) (uint64, error)
}

ProtorevKeeper is an interface for getting the pool for a denom pair.

type SQSGRPClient

type SQSGRPClient interface {
	// PushData pushes the height, pools and taker fee data to SQS via GRPC.
	// Returns error if the GRPC client fails to push data.
	// On status.Unavailable, it closes the connection and attempts to re-establish it during the next GRPC call.
	// Note: while there are built-in mechanisms to handle retry such as exponential backoff, they are no suitable for our context.
	// In our context, we would rather continue attempting to repush the data in the next block instead of blocking the system.
	PushData(ctx context.Context, height uint64, pools []sqsdomain.PoolI, takerFeesMap sqsdomain.TakerFeeMap) error
}

SQSGRPClient is an interface that defines the methods for the graceful SQS GRPC client. It handles graceful connection management. So that, if a GRPC ingest method returns status.Unavailable, the GRPC client will reset the connection and attempt to recreate it before retrying the ingest method.

type SQSIngestKeepers

type SQSIngestKeepers struct {
	GammKeeper         PoolKeeper
	CosmWasmPoolKeeper CosmWasmPoolKeeper
	BankKeeper         BankKeeper
	ProtorevKeeper     ProtorevKeeper
	PoolManagerKeeper  PoolManagerKeeper
	ConcentratedKeeper ConcentratedKeeper
}

Chain keepers required for sqs ingest.

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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