types

package
v0.0.0-...-5d7b32d Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// eth
	EthV2RouterAddress     string = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"
	EthV3RouterAddress     string = "0xE592427A0AEce92De3Edee1F18E0157C05861564"
	EthV2FactoryAddress    string = "0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f"
	EthV3FactoryAddress    string = "0x1F98431c8aD98523631AE4a59f267346ea31F984"
	EthV2TokenCheckAddress string = ""
	EthV3TokenCheckAddress string = ""

	// binance-smart-chain
	BscV2RouterAddress     string = "0x10ED43C718714eb63d5aA57B78B54704E256024E"
	BscV3RouterAddress     string = "0x1b81D678ffb9C0263b24A97847620C99d213eB14"
	BscV2FactoryAddress    string = "0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f"
	BscV3FactoryAddress    string = "0x1F98431c8aD98523631AE4a59f267346ea31F984"
	BscV2TokenCheckAddress string = "0xd439e0e20f22a4a482ccd93e45af35b0e46faaf2"
	BscV3TokenCheckAddress string = "0xff81b9848845ee11672bb476e3dfab4c379a771e"
)

Variables

View Source
var (
	// contract ABIs
	EthV2RouterABI  string = readFileToString("./eth/abi/ETH_V2_Router_ABI.json")
	EthV3RouterABI  string = readFileToString("./eth/abi/ETH_V3_Router_ABI.json")
	EthV2FactoryABI string = readFileToString("./eth/abi/ETH_V2_Factory_ABI.json")
	EthV3FactoryABI string = readFileToString("./eth/abi/ETH_V3_Factory_ABI.json")
	EthV2PoolABI    string = readFileToString("./eth/abi/ETH_V2_Pool_ABI.json")
	EthV3PoolABI    string = readFileToString("./eth/abi/ETH_V3_Pool_ABI.json")
	BsbV2RouterABI  string = readFileToString("./eth/abi/BSC_V2_Router_ABI.json")
	BscV3RouterABI  string = readFileToString("./eth/abi/BSC_V3_Router_ABI.json")
	BscV2FactoryABI string = readFileToString("./eth/abi/BSC_V2_Factory_ABI.json")
	BscV3FactoryABI string = readFileToString("./eth/abi/BSC_V3_Factory_ABI.json")
	BscV2PoolABI    string = readFileToString("./eth/abi/BSC_V2_Pool_ABI.json")
	BscV3PoolABI    string = readFileToString("./eth/abi/BSC_V3_Pool_ABI.json")
	Erc20ABI        string = readFileToString("./eth/abi/ERC20_ABI.json")
	TokenCheckV2ABI string = readFileToString("./eth/abi/TokenCheck_V2_ABI.json")
)

Functions

func ValidatePairSortBy

func ValidatePairSortBy(sortBy PairSortBy) bool

func ValidateSortOrder

func ValidateSortOrder(order SortOrder) bool

func ValidateTokenSortBy

func ValidateTokenSortBy(sortBy TokenSortBy) bool

Types

type BlockNumber

type BlockNumber struct {
	Number string `json:"blockNumber"`
}

type BlockTimestamp

type BlockTimestamp struct {
	bun.BaseModel `bun:"table:block_timestamps,alias:block_timestamps" json:"-"`
	Block         int64 `json:"block" bun:",pk,notnull,unique"`
	Timestamp     int64 `json:"timestamp" bun:",notnull,default:0"`
}

type Chain

type Chain struct {
	ChainID       int    `json:"chain_id"`
	Name          string `json:"name"`
	ShortName     string `json:"short_name"`
	ExplorerURL   string `json:"explorer_url"`
	RouterV2      string `json:"router_v2"`
	FactoryV2     string `json:"factory_v2"`
	RouterV3      string `json:"router_v3"`
	FactoryV3     string `json:"factory_v3"`
	BlockDuration int64  `json:"block_duration"`
	Http          string `json:"-"`
}

type Creator

type Creator struct {
	Hash    string `json:"hash"`
	Creator string `json:"creator"`
}

type FindPairsRequest

type FindPairsRequest struct {
	ChainID *int64       `json:"chain_id"`
	Filter  *PairFilter  `json:"filter,omitempty"`
	Options *PairOptions `json:"options,omitempty"`
}

func (*FindPairsRequest) Validate

func (r *FindPairsRequest) Validate() error

type FindPairsResponse

type FindPairsResponse struct {
	ID     string     `json:"id"`
	Method string     `json:"method"`
	Result []*Pair    `json:"result,omitempty"`
	Error  *JRPCError `json:"error,omitempty"`
}

type FindTokensRequest

type FindTokensRequest struct {
	ChainID *int64        `json:"chain_id"`
	Filter  *TokenFilter  `json:"filter,omitempty"`
	Options *TokenOptions `json:"options,omitempty"`
}

func (*FindTokensRequest) Validate

func (r *FindTokensRequest) Validate() error

type FindTokensResponse

type FindTokensResponse struct {
	ID     string     `json:"id"`
	Method string     `json:"method"`
	Result []*Token   `json:"result,omitempty"`
	Error  *JRPCError `json:"error,omitempty"`
}

type GetBlockAtTimestampRequest

type GetBlockAtTimestampRequest struct {
	ChainID   *int64 `json:"chain_id"`
	Timestamp *int64 `json:"timestamp"`
}

func (*GetBlockAtTimestampRequest) Validate

func (r *GetBlockAtTimestampRequest) Validate() error

type GetBlockAtTimestampResponse

type GetBlockAtTimestampResponse struct {
	ID     string          `json:"id"`
	Method string          `json:"method"`
	Result *BlockTimestamp `json:"result,omitempty"`
	Error  *JRPCError      `json:"error,omitempty"`
}

type GetBlockNumberRequest

type GetBlockNumberRequest struct{}

type GetBlockNumberResponse

type GetBlockNumberResponse struct {
	ID     string          `json:"id"`
	Method string          `json:"method"`
	Result map[int64]int64 `json:"result,omitempty"`
	Error  *JRPCError      `json:"error,omitempty"`
}

type GetBlockTimestampsRequest

type GetBlockTimestampsRequest struct {
	ChainID   *int64 `json:"chain_id"`
	FromBlock *int64 `json:"from_block"`
	ToBlock   *int64 `json:"to_block"`
}

func (*GetBlockTimestampsRequest) Validate

func (r *GetBlockTimestampsRequest) Validate() error

type GetBlockTimestampsResponse

type GetBlockTimestampsResponse struct {
	ID     string            `json:"id"`
	Method string            `json:"method"`
	Result []*BlockTimestamp `json:"result,omitempty"`
	Error  *JRPCError        `json:"error,omitempty"`
}

type GetChainsRequest

type GetChainsRequest struct{}

type GetChainsResponse

type GetChainsResponse struct {
	ID     string     `json:"id"`
	Method string     `json:"method"`
	Result []Chain    `json:"result,omitempty"`
	Error  *JRPCError `json:"error,omitempty"`
}

type GetHeightsRequest

type GetHeightsRequest struct {
	ChainID *int64 `json:"chain_id"`
}

func (*GetHeightsRequest) Validate

func (r *GetHeightsRequest) Validate() error

type GetHeightsResponse

type GetHeightsResponse struct {
	ID     string     `json:"id"`
	Method string     `json:"method"`
	Result *Heights   `json:"result,omitempty"`
	Error  *JRPCError `json:"error,omitempty"`
}

type GetPairCountRequest

type GetPairCountRequest struct {
	ChainID *int64 `json:"chain_id"`
}

func (*GetPairCountRequest) Validate

func (r *GetPairCountRequest) Validate() error

type GetPairCountResponse

type GetPairCountResponse struct {
	ID     string     `json:"id"`
	Method string     `json:"method"`
	Result int64      `json:"result,omitempty"`
	Error  *JRPCError `json:"error,omitempty"`
}

type GetTokenCountRequest

type GetTokenCountRequest struct {
	ChainID *int64 `json:"chain_id"`
}

func (*GetTokenCountRequest) Validate

func (r *GetTokenCountRequest) Validate() error

type GetTokenCountResponse

type GetTokenCountResponse struct {
	ID     string     `json:"id"`
	Method string     `json:"method"`
	Result int64      `json:"result,omitempty"`
	Error  *JRPCError `json:"error,omitempty"`
}

type Heights

type Heights struct {
	Blocks int64
	Tokens int64
	Pairs  int64
}

type JRPCError

type JRPCError struct {
	Code    int64  `json:"code"`
	Message string `json:"message"`
}

type OHLC

type OHLC struct {
	TS uint32  `json:"ts"`  // timestamp
	US float32 `json:"usd"` // usd price
	O  float32 `json:"o"`   // open price
	H  float32 `json:"h"`   // high price
	L  float32 `json:"l"`   // low price
	C  float32 `json:"c"`   // close price
	BV float32 `json:"bv"`  // buy volume usd
	SV float32 `json:"sv"`  // sell volume usd
	NB uint32  `json:"nb"`  // number of buy
	NS uint32  `json:"ns"`  // number of sells
}

type Pair

type Pair struct {
	bun.BaseModel `bun:"table:pairs,alias:pairs" json:"-"`
	Token0Address string `json:"token0_address" bun:",type:varchar(42),notnull"`
	Token1Address string `json:"token1_address" bun:",type:varchar(42),notnull"`
	Fee           int64  `json:"fee" bun:",notnull,default:0"`
	TickSpacing   int64  `json:"tick_spacing" bun:",notnull,default:0"`
	PoolAddress   string `json:"pool_address" bun:",notnull,type:varchar(42),unique"`
	PoolType      uint8  `json:"pool_type" bun:",notnull,default:0"`
	CreatedAt     int64  `json:"created_at"`
	Hash          string `json:"hash" bun:",pk,type:varchar(66)"`
	ChainID       int16  `json:"chain_id"`
}

func (*Pair) Lower

func (p *Pair) Lower()

type PairFilter

type PairFilter struct {
	Token0Address *string `json:"token0_address,omitempty"`
	Token1Address *string `json:"token1_address,omitempty"`
	PoolAddress   *string `json:"pool_address,omitempty"`
	FromBlock     *int64  `json:"from_block,omitempty"`
	ToBlock       *int64  `json:"to_block,omitempty"`
	Fee           *int64  `json:"fee,omitempty"`
	TickSpacing   *int64  `json:"tick_spacing,omitempty"`
	Hash          *string `json:"hash,omitempty"`
	PoolType      *uint8  `json:"pool_type,omitempty"`
	Fuzzy         bool    `json:"fuzzy"`
}

type PairOptions

type PairOptions struct {
	Offset    int64      `json:"offset"`
	Limit     int64      `json:"limit"`
	SortBy    PairSortBy `json:"sort_by"`
	SortOrder SortOrder  `json:"sort_order"`
}

type PairSortBy

type PairSortBy string
const (
	PairSortByToken0Address PairSortBy = "token0_address"
	PairSortByToken1Address PairSortBy = "token1_address"
	PairSortByPoolAddress   PairSortBy = "pool_address"
	PairSortByFee           PairSortBy = "fee"
	PairSortByTickSpacing   PairSortBy = "tick_spacing"
	PairSortByHash          PairSortBy = "hash"
	PairSortByPoolType      PairSortBy = "pool_type"
	PairSortByCreatedAt     PairSortBy = "created_at"
)

type SortOrder

type SortOrder string
const (
	SortASC  SortOrder = "asc"
	SortDESC SortOrder = "desc"
)

type Token

type Token struct {
	bun.BaseModel `bun:"table:tokens,alias:tokens" json:"-"`
	Address       string `json:"address" bun:",pk,type:varchar(42),unique"`
	Name          string `json:"name"`
	Symbol        string `json:"symbol"`
	Decimals      uint8  `json:"decimals"`
	Creator       string `json:"creator" bun:",type:varchar(42),default:'0x0000000000000000000000000000000000000000'"`
	CreatedAt     int64  `json:"created_at"`
	CreationHash  string `json:"creation_hash" bun:",type:varchar(66),default:'0x0000000000000000000000000000000000000000000000000000000000000000'"`
	ChainID       int16  `json:"chain_id"`
}

func (*Token) Lower

func (p *Token) Lower()

type TokenFilter

type TokenFilter struct {
	Address   *string `json:"address,omitempty"`
	Creator   *string `json:"creator,omitempty"`
	FromBlock *int64  `json:"from_block,omitempty"`
	ToBlock   *int64  `json:"to_block,omitempty"`
	Name      *string `json:"name,omitempty"`
	Symbol    *string `json:"symbol,omitempty"`
	Decimals  *uint8  `json:"decimals,omitempty"`
	Fuzzy     bool    `json:"fuzzy"`
}

type TokenOptions

type TokenOptions struct {
	Offset    int64       `json:"offset"`
	Limit     int64       `json:"limit"`
	SortBy    TokenSortBy `json:"sort_by"`
	SortOrder SortOrder   `json:"sort_order"`
}

type TokenSortBy

type TokenSortBy string
const (
	TokenSortByAddress   TokenSortBy = "address"
	TokenSortByCreator   TokenSortBy = "creator"
	TokenSortByName      TokenSortBy = "name"
	TokenSortBySymbol    TokenSortBy = "symbol"
	TokenSortByDecimals  TokenSortBy = "decimals"
	TokenSortByCreatedAt TokenSortBy = "created_at"
	TokenSortByHash      TokenSortBy = "creation_hash"
)

Jump to

Keyboard shortcuts

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