indexer

package
v0.0.0-...-ba036dd Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string
const (
	Swap     Action = "swap"
	Provide  Action = "provide"
	Withdraw Action = "withdraw"
)

type AssetRepo

type AssetRepo interface {
	VerifiedTokens(chainId string) ([]Token, error)
}

type DbRepo

type DbRepo interface {
	SyncedHeight() (uint64, error)

	Pair(addr string) (*Pair, error)
	Pairs(db.LastIdLimitCondition) ([]Pair, error)

	Token(addr string) (*Token, error)
	Tokens(db.LastIdLimitCondition) ([]Token, error)
	TokenAddresses(db.LastIdLimitCondition) ([]string, error)

	Pool(addr string, height uint64) (*PoolInfo, error)
	Pools(height uint64) ([]PoolInfo, error)

	LatestPools() ([]PoolInfo, error)

	ParsedTxs(height uint64) ([]ParsedTx, error)

	SaveLatestPools(pools []PoolInfo, height uint64) error
	SaveTokens([]Token) error
}

type Indexer

type Indexer interface {
	UpdateVerifiedTokens() error
	UpdateTokens() error
	UpdateLatestPools() error
}

func NewDexIndexer

func NewDexIndexer(repo Repo, chainId string) Indexer

type NodeRepo

type NodeRepo interface {
	LatestHeightFromNode() (uint64, error)
	TokenFromNode(addr string) (*Token, error)
	PoolFromNode(addr string, height uint64) (*PoolInfo, error)
}

type Pair

type Pair struct {
	ID      string `json:"id"`
	Address string `json:"address"`
	Asset0  string `json:"asset0"`
	Asset1  string `json:"asset1"`
	Lp      string `json:"lp"`
}

type ParsedTx

type ParsedTx struct {
	ID                uint64
	ChainId           string  `json:"chainId"`
	Height            uint64  `json:"height"`
	Timestamp         float64 `json:"timestamp"` // timestamp of a block in second
	Hash              string  `json:"hash"`
	Sender            string  `json:"sender"`
	Type              Action  `json:"type"`
	Address           string  `json:"address"`
	Asset0            string  `json:"asset0"`
	Asset0Amount      string  `json:"asset0Amount"`
	Asset1            string  `json:"asset1"`
	Asset1Amount      string  `json:"asset1Amount"`
	Lp                string  `json:"lp"`
	LpAmount          string  `json:"lpAmount"`
	CommissionAmount  string  `json:"commissionAmount"`
	Commission0Amount string  `json:"commission0Amount"`
	Commission1Amount string  `json:"commission1Amount"`
}

type PoolInfo

type PoolInfo struct {
	Height       uint64 `json:"height"`
	ChainId      string `json:"chainId"`
	Address      string `json:"address"`
	Asset0       string `json:"asset0"`
	Asset0Amount string `json:"asset0Amount"`
	Asset1       string `json:"asset1"`
	Asset1Amount string `json:"asset1Amount"`
	Lp           string `json:"lp"`
	LpAmount     string `json:"lpAmount"`
}

func (*PoolInfo) Equal

func (lhs *PoolInfo) Equal(rhs comparable) bool

Equal implements comparable

type Repo

type Repo interface {
	AssetRepo
	NodeRepo
	DbRepo
}

type Token

type Token struct {
	ID       uint   `json:"id"`
	Address  string `json:"address"`
	ChainId  string `json:"chainId"`
	Protocol string `json:"protocol"`
	Symbol   string `json:"symbol"`
	Name     string `json:"name"`
	Decimals uint8  `json:"decimals"`
	Icon     string `json:"icon"`
	Verified bool   `json:"verified"`
}

func (*Token) Equal

func (lhs *Token) Equal(rhs comparable) bool

Equal implements comparable

type Updatable

type Updatable interface {
	Token | PoolInfo
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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