types

package
v0.0.0-...-a8d0dae Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

nolint

nolint

nolint

Index

Constants

View Source
const (
	DefaultCodespace = ModuleName

	CodeProductIsRequired             uint32 = 62000
	CodeAddressIsRequired             uint32 = 62001
	CodeOrderStatusMustBeOpenOrClosed uint32 = 62002
	CodeAddressAndProductRequired     uint32 = 62003
	CodeGetChainHeightFailed          uint32 = 62004
	CodeGetBlockTxHashesFailed        uint32 = 62005
	CodeOrderSideMustBuyOrSell        uint32 = 62006
	CodeProductDoesNotExist           uint32 = 62007
	CodeBackendPluginNotEnabled       uint32 = 62008
	CodeGoroutinePanic                uint32 = 62009
	CodeBackendModuleUnknownQueryType uint32 = 62010
	CodeGetCandlesFailed              uint32 = 62011
	CodeGetCandlesByMarketFailed      uint32 = 62012
	CodeGetTickerByProductsFailed     uint32 = 62013
	CodeParamNotCorrect               uint32 = 62014
	CodeNoKlinesFunctionFound         uint32 = 62015
	CodeMarketkeeperNotInitialized    uint32 = 62016
	CodeGetInvalidateGranularity      uint32 = 62017
	CodeGetInvalidTickerByProducts    uint32 = 62018
	CodeOrderIdIsRequired             uint32 = 62019
)

const uint32

View Source
const (
	WhitelistFarmPool = "whitelist"
	NormalFarmPool    = "normal"

	SecondsInDay  = 24 * 60 * 60
	DaysInYear    = 365
	BlockInterval = 3
	BlocksPerDay  = SecondsInADay / BlockInterval

	// farm pool status
	FarmPoolCreated  FarmPoolStatus = 1
	FarmPoolProvided FarmPoolStatus = 2
	FarmPoolYielded  FarmPoolStatus = 3
	FarmPoolFinished FarmPoolStatus = 4

	// query key
	QueryFarmPools      = "farmPools"
	QueryFarmDashboard  = "farmDashboard"
	QueryFarmMaxApy     = "farmMaxApy"
	QueryFarmStakedInfo = "farmStakedInfo"
	QueryFarmFirstPool  = "farmFirstPool"

	// farm sort column
	FarmPoolTotalStaked = "total_staked"
	FarmPoolApy         = "farm_apy"
	FarmPoolStartAt     = "start_at"
	FarmPoolFinishAt    = "finish_at"

	// sort direction
	FarmSortAsc = "asc"
)
View Source
const (
	// ModuleName is the name of the backend module
	ModuleName = "backend"
	// QuerierRoute is the querier route for the backend module
	QuerierRoute = ModuleName
	// RouterKey is the msg router key for the backend module
	RouterKey = ""

	// query endpoints supported by the backend querier
	QueryMatchResults  = "matches"
	QueryDealList      = "deals"
	QueryFeeDetails    = "fees"
	QueryOrderList     = "orders"
	QueryOrderByID     = "orderByID"
	QueryAccountOrders = "accountOrders"
	QueryTxList        = "txs"
	QueryCandleList    = "candles"
	QueryTickerList    = "tickers"
	QueryDexFeesList   = "dexFees"

	// v2
	QueryTickerListV2   = "tickerListV2"
	QueryTickerV2       = "tickerV2"
	QueryInstrumentsV2  = "instrumentsV2"
	QueryOrderListV2    = "orderListV2"
	QueryOrderV2        = "orderV2"
	QueryCandleListV2   = "candlesV2"
	QueryMatchResultsV2 = "matchesV2"
	QueryFeeDetailsV2   = "feesV2"
	QueryDealListV2     = "dealsV2"
	QueryTxListV2       = "txsV2"

	Kline1GoRoutineWaitInSecond = 5
	KlinexGoRoutineWaitInSecond = 10

	SecondsInADay = 24 * 60 * 60
)
View Source
const (
	KlineTypeM1      = "kline_m1"
	KlineTypeM3      = "kline_m3"
	KlineTypeM5      = "kline_m5"
	KlineTypeM15     = "kline_m15"
	KlineTypeM30     = "kline_m30"
	KlineTypeM60     = "kline_m60"
	KlineTypeM120    = "kline_m120"
	KlineTypeM240    = "kline_m240"
	KlineTypeM360    = "kline_m360"
	KlineTypeM720    = "kline_m720"
	KlineTypeM1440   = "kline_m1440"
	KlineTypeM4320   = "kline_m4320"
	KlineTypeM10080  = "kline_m10080"
	KlineTypeM44640  = "kline_m44640"
	KlineTypeM525600 = "kline_m525600"
)
View Source
const (
	DefaultPage    = 1
	DefaultPerPage = 50
)

nolint

View Source
const (
	// watchlist sort column
	SwapWatchlistLiquidity = "liquidity"
	SwapWatchlistVolume24h = "volume24h"
	SwapWatchlistFeeApy    = "fee_apy"
	SwapWatchlistLastPrice = "last_price"
	SwapWatchlistChange24h = "change24h"

	// sort direction
	SwapWatchlistSortAsc = "asc"

	// query key
	QuerySwapWatchlist          = "swapWatchlist"
	QuerySwapTokens             = "swapTokens"
	QuerySwapTokenPairs         = "swapTokenPairs"
	QuerySwapLiquidityHistories = "swapLiquidityHistories"

	// swap business type
	SwapBusinessTypeCreate = "create"
	SwapBusinessTypeAdd    = "add"
	SwapBusinessTypeSwap   = "swap"
)
View Source
const (
	TxTypeTransfer    = 1
	TxTypeOrderNew    = 2
	TxTypeOrderCancel = 3

	TxSideBuy  = 1
	TxSideSell = 2
	TxSideFrom = 3
	TxSideTo   = 4

	BuyOrder      = orderTypes.BuyOrder
	SellOrder     = orderTypes.SellOrder
	TestTokenPair = orderTypes.TestTokenPair

	FeeTypeOrderNew     = orderTypes.FeeTypeOrderNew
	FeeTypeOrderCancel  = orderTypes.FeeTypeOrderCancel
	FeeTypeOrderExpire  = orderTypes.FeeTypeOrderExpire
	FeeTypeOrderDeal    = orderTypes.FeeTypeOrderDeal
	FeeTypeOrderReceive = orderTypes.FeeTypeOrderReceive
)
View Source
const WebsocketChanCapacity = 2048

Variables

This section is empty.

Functions

func ErrAddressIsRequired

func ErrAddressIsRequired() sdk.EnvelopedErr

address is required

func ErrBackendModuleUnknownQueryType

func ErrBackendModuleUnknownQueryType() sdk.EnvelopedErr

func ErrBackendPluginNotEnabled

func ErrBackendPluginNotEnabled() sdk.EnvelopedErr

func ErrGetInvalidTickerByProducts

func ErrGetInvalidTickerByProducts(key string) sdk.EnvelopedErr

func ErrGetInvalidateGranularity

func ErrGetInvalidateGranularity(msg string, key string, field string) sdk.EnvelopedErr

func ErrMarketkeeperNotInitialized

func ErrMarketkeeperNotInitialized() sdk.EnvelopedErr

func ErrNoKlinesFunctionFound

func ErrNoKlinesFunctionFound() sdk.EnvelopedErr

func ErrOrderIdIsRequired

func ErrOrderIdIsRequired() sdk.EnvelopedErr

orderId is required

func ErrOrderSideParamMustBuyOrSell

func ErrOrderSideParamMustBuyOrSell(side string) sdk.EnvelopedErr

invalid param side, must be buy or sell

func ErrParamNotCorrect

func ErrParamNotCorrect(size int, granularity int) sdk.EnvelopedErr

func ErrProductDoesNotExist

func ErrProductDoesNotExist(product string) sdk.EnvelopedErr

product does not exist

func ErrProductIsRequired

func ErrProductIsRequired() sdk.EnvelopedErr

product is required

func GetAllKlineMap

func GetAllKlineMap() map[int]string

GetAllKlineMap return map about kline table names

func GetChannelByKlineType

func GetChannelByKlineType(klineType string) string

func GetFreqByKlineType

func GetFreqByKlineType(klineType string) int

func GetKlineTableNameByFreq

func GetKlineTableNameByFreq(freq int) string

GetKlineTableNameByFreq return table name

func MustNewKlineFactory

func MustNewKlineFactory(name string, baseK *BaseKline) (r interface{})

MustNewKlineFactory will panic when err occurred during NewKlineFactory

func NewErrorsMerged

func NewErrorsMerged(args ...error) error

NewErrorsMerged plenty of errors into a single error.

func NewKlineFactory

func NewKlineFactory(name string, baseK *BaseKline) (r interface{}, err error)

NewKlineFactory generate kline type by factory pattern

func NewKlinesFactory

func NewKlinesFactory(name string) (r interface{}, err error)

NewKlinesFactory generate kline type by type of kline

func PrintStackIfPanic

func PrintStackIfPanic()

nolint

func TimeString

func TimeString(ts int64) string

TimeString format time

func ToRestfulData

func ToRestfulData(klines *[]IKline, limit int) [][]string

nolint

Types

type BaseKline

type BaseKline struct {
	Product   string  `gorm:"PRIMARY_KEY;type:varchar(20)" json:"product"`
	Timestamp int64   `gorm:"PRIMARY_KEY;type:bigint;" json:"timestamp"`
	Open      float64 `gorm:"type:DOUBLE" json:"open"`
	Close     float64 `gorm:"type:DOUBLE" json:"close"`
	High      float64 `gorm:"type:DOUBLE" json:"high"`
	Low       float64 `gorm:"type:DOUBLE" json:"low"`
	Volume    float64 `gorm:"type:DOUBLE" json:"volume"`
	// contains filtered or unexported fields
}

BaseKline define the basic data of Kine

func (*BaseKline) FormatResult

func (b *BaseKline) FormatResult() interface{}

func (*BaseKline) GetAnchorTimeTS

func (b *BaseKline) GetAnchorTimeTS(ts int64) int64

GetAnchorTimeTS return time interval

func (*BaseKline) GetBriefInfo

func (b *BaseKline) GetBriefInfo() []string

GetBriefInfo return array of kline data

func (*BaseKline) GetChannelInfo

func (b *BaseKline) GetChannelInfo() (channel, filter string, err error)

func (*BaseKline) GetClose

func (b *BaseKline) GetClose() float64

GetClose return close price

func (*BaseKline) GetFreqInSecond

func (b *BaseKline) GetFreqInSecond() int

GetFreqInSecond return interval time

func (*BaseKline) GetFullChannel

func (b *BaseKline) GetFullChannel() string

func (*BaseKline) GetHigh

func (b *BaseKline) GetHigh() float64

GetHigh return high price

func (*BaseKline) GetLow

func (b *BaseKline) GetLow() float64

GetLow return low price

func (*BaseKline) GetOpen

func (b *BaseKline) GetOpen() float64

GetOpen return open price

func (*BaseKline) GetProduct

func (b *BaseKline) GetProduct() string

GetProduct return product

func (*BaseKline) GetTableName

func (b *BaseKline) GetTableName() string

GetTableName rerurn database table name

func (*BaseKline) GetTimestamp

func (b *BaseKline) GetTimestamp() int64

GetTimestamp return timestamp

func (*BaseKline) GetVolume

func (b *BaseKline) GetVolume() float64

GetVolume return volume of trade quantity

func (*BaseKline) PrettyTimeString

func (b *BaseKline) PrettyTimeString() string

PrettyTimeString convert kline data to string

type ClaimInfo

type ClaimInfo struct {
	Id        uint64 `gorm:"primaryKey`
	PoolName  string `grom:"index;"`
	Address   string `grom:"index;"`
	Claimed   string `gorm:"type:varchar(256)"`
	Timestamp int64  `gorm:"index;"`
}

type Deal

type Deal struct {
	Timestamp   int64   `gorm:"index;" json:"timestamp" v2:"timestamp"`
	BlockHeight int64   `gorm:"PRIMARY_KEY;type:bigint" json:"block_height" v2:"block_height"`
	OrderID     string  `gorm:"PRIMARY_KEY;type:varchar(30)" json:"order_id" v2:"order_id"`
	Sender      string  `gorm:"index;type:varchar(80)" json:"sender" v2:"sender"`
	Product     string  `gorm:"index;type:varchar(20)" json:"product" v2:"product"`
	Side        string  `gorm:"type:varchar(10)" json:"side" v2:"side"`
	Price       float64 `gorm:"type:DOUBLE" json:"price" v2:"price"`
	Quantity    float64 `gorm:"type:DOUBLE" json:"volume" v2:"volume"`
	Fee         string  `gorm:"type:varchar(40)" json:"fee" v2:"fee"`
	FeeReceiver string  `gorm:"index;type:varchar(80)" json:"fee_receiver" v2:"fee_receiver"`
}

type DexFees

type DexFees struct {
	Timestamp       int64  `json:"timestamp"`
	OrderID         string `json:"order_id"`
	Product         string `json:"product"`
	Fee             string `json:"fee"`
	HandlingFeeAddr string `json:"handling_fee_addr"`
}

type DexKeeper

type DexKeeper interface {
	GetTokenPairs(ctx sdk.Context) []*dextypes.TokenPair
	GetTokenPair(ctx sdk.Context, product string) *dextypes.TokenPair
	SetObserverKeeper(keeper dex.StreamKeeper)
}

DexKeeper expected dex keeper

type ErrorsMerged

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

nolint

func (ErrorsMerged) Error

func (em ErrorsMerged) Error() string

nolint

type FakeWSEvent

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

FakeWSEvent won't result in sending out tendermint event

func NewFakeWSEvent

func NewFakeWSEvent(channel, filter string, ts int64) *FakeWSEvent

func (*FakeWSEvent) FormatResult

func (f *FakeWSEvent) FormatResult() interface{}

func (*FakeWSEvent) GetChannelInfo

func (f *FakeWSEvent) GetChannelInfo() (channel, filter string, err error)

func (*FakeWSEvent) GetFullChannel

func (f *FakeWSEvent) GetFullChannel() string

func (*FakeWSEvent) GetTimestamp

func (f *FakeWSEvent) GetTimestamp() int64

type FarmFirstPool

type FarmFirstPool struct {
	FarmApy       sdk.Dec `json:"farm_apy"`
	FarmAmount    sdk.Dec `json:"farm_amount"`
	TotalStaked   sdk.Dec `json:"total_staked"`
	ClaimAt       int64   `json:"claim_at"`
	AccountStaked sdk.Dec `json:"account_staked"`
	EstimatedFarm sdk.Dec `json:"estimated_farm"`
	Balance       sdk.Dec `json:"balance"`
}

type FarmInfo

type FarmInfo struct {
	Symbol    string  `json:"symbol"`
	Claimed   sdk.Dec `json:"claimed"`
	UnClaimed sdk.Dec `json:"unclaimed"`
}

type FarmKeeper

type FarmKeeper interface {
	SetObserverKeeper(k farmtypes.BackendKeeper)
	GetFarmPools(ctx sdk.Context) (pools farmtypes.FarmPools)
	GetWhitelist(ctx sdk.Context) (whitelist farmtypes.PoolNameList)
	GetParams(ctx sdk.Context) (params farmtypes.Params)
	GetPoolLockedValue(ctx sdk.Context, pool farmtypes.FarmPool) sdk.Dec
	CalculateAmountYieldedBetween(ctx sdk.Context, pool farmtypes.FarmPool) (farmtypes.FarmPool, sdk.SysCoins)
	SupplyKeeper() supply.Keeper
	GetFarmPoolNamesForAccount(ctx sdk.Context, accAddr sdk.AccAddress) (poolNames farmtypes.PoolNameList)
	GetFarmPool(ctx sdk.Context, poolName string) (pool farmtypes.FarmPool, found bool)
	GetLockInfo(ctx sdk.Context, addr sdk.AccAddress, poolName string) (info farmtypes.LockInfo, found bool)
	GetEarnings(ctx sdk.Context, poolName string, accAddr sdk.AccAddress) (farmtypes.Earnings, sdk.Error)
}

FarmKeeper expected farm keeper

type FarmPoolResponse

type FarmPoolResponse struct {
	PoolName      string         `json:"pool_name"`
	LockSymbol    string         `json:"lock_symbol"`
	YieldSymbol   string         `json:"yield_symbol"`
	TotalStaked   sdk.Dec        `json:"total_staked"`
	UserStaked    sdk.Dec        `json:"user_staked"`
	StartAt       int64          `json:"start_at"`
	FinishAt      int64          `json:"finish_at"`
	PoolRate      sdk.SysCoins   `json:"pool_rate"`
	FarmApy       sdk.SysCoins   `json:"farm_apy"`
	PoolRatio     sdk.Dec        `json:"pool_ratio"`
	InWhitelist   bool           `json:"in_whitelist"`
	TotalFarmed   sdk.Dec        `json:"total_farmed"`
	FarmedDetails []FarmInfo     `json:"farmed_details"`
	Status        FarmPoolStatus `json:"status"`
}

func (FarmPoolResponse) TotalApy

func (farmPool FarmPoolResponse) TotalApy() sdk.Dec

type FarmPoolStatus

type FarmPoolStatus int

type FarmResponseList

type FarmResponseList []FarmPoolResponse

func (FarmResponseList) Len

func (list FarmResponseList) Len() int

func (FarmResponseList) Less

func (list FarmResponseList) Less(i, j int) bool

func (FarmResponseList) Swap

func (list FarmResponseList) Swap(i, j int)

type FarmResponseListSorter

type FarmResponseListSorter struct {
	FarmPoolList  FarmResponseList
	SortField     string
	SortDirectory string
}

func (*FarmResponseListSorter) Len

func (s *FarmResponseListSorter) Len() int

func (*FarmResponseListSorter) Less

func (s *FarmResponseListSorter) Less(i, j int) bool

func (*FarmResponseListSorter) Swap

func (s *FarmResponseListSorter) Swap(i, j int)

type FarmStakedInfo

type FarmStakedInfo struct {
	PoolName        string  `json:"pool_name"`
	Balance         sdk.Dec `json:"balance"`
	AccountStaked   sdk.Dec `json:"account_staked"`
	PoolTotalStaked sdk.Dec `json:"pool_total_staked"`
	PoolRatio       sdk.Dec `json:"pool_ratio"`
	MinLockAmount   sdk.Dec `json:"min_lock_amount"`
}

type IKline

type IKline interface {
	GetFreqInSecond() int
	GetAnchorTimeTS(ts int64) int64
	GetTableName() string
	GetProduct() string
	GetTimestamp() int64
	GetOpen() float64
	GetClose() float64
	GetHigh() float64
	GetLow() float64
	GetVolume() float64
	PrettyTimeString() string
	GetBriefInfo() []string
}

nolint

func ToIKlinesArray

func ToIKlinesArray(klines interface{}, endTS int64, doPadding bool) []IKline

ToIKlinesArray Convert kline data to array for restful interface

type IKlines

type IKlines []IKline

nolint

func (IKlines) Len

func (klines IKlines) Len() int

nolint

func (IKlines) Less

func (klines IKlines) Less(i, j int) bool

nolint

func (IKlines) Swap

func (klines IKlines) Swap(i, j int)

nolint

type IKlinesDsc

type IKlinesDsc []IKline

nolint

func (IKlinesDsc) Len

func (klines IKlinesDsc) Len() int

nolint

func (IKlinesDsc) Less

func (klines IKlinesDsc) Less(i, j int) bool

nolint

func (IKlinesDsc) Swap

func (c IKlinesDsc) Swap(i, j int)

nolint

type IWebsocket

type IWebsocket interface {
	GetChannelInfo() (channel, filter string, err error)
	GetFullChannel() string
	FormatResult() interface{}
	GetTimestamp() int64
}

type InstrumentV2

type InstrumentV2 struct {
	InstrumentID  string `json:"instrument_id"` // name of token pair
	BaseCurrency  string `json:"base_currency"`
	QuoteCurrency string `json:"quote_currency"`
	MinSize       string `json:"min_size"`
	SizeIncrement string `json:"size_increment"`
	TickSize      string `json:"tick_size"`
}

func ConvertTokenPairToInstrumentV2

func ConvertTokenPairToInstrumentV2(tokenPair *dex.TokenPair) *InstrumentV2

ConvertTokenPairToInstrumentV2 convert TokenPair to InstrumentV2

type KlineM1

type KlineM1 struct {
	*BaseKline
}

KlineM1 define kline data in 1 minute

func NewKlineM1

func NewKlineM1(b *BaseKline) *KlineM1

NewKlineM1 create a instance of KlineM1

func (*KlineM1) GetFreqInSecond

func (k *KlineM1) GetFreqInSecond() int

GetFreqInSecond return 60

func (*KlineM1) GetTableName

func (k *KlineM1) GetTableName() string

GetTableName return kline_m1

type KlineM10080

type KlineM10080 struct {
	*BaseKline
}

KlineM10080 define kline data in 1 week

func NewKlineM10080

func NewKlineM10080(b *BaseKline) *KlineM10080

NewKlineM10080 create a instance of NewKlineM10080

func (*KlineM10080) GetFreqInSecond

func (k *KlineM10080) GetFreqInSecond() int

GetFreqInSecond return 604800

func (*KlineM10080) GetTableName

func (k *KlineM10080) GetTableName() string

GetTableName return kline_m10080

type KlineM120

type KlineM120 struct {
	*BaseKline
}

KlineM120 define kline data in 2 hours

func NewKlineM120

func NewKlineM120(b *BaseKline) *KlineM120

NewKlineM120 create a instance of KlineM120

func (*KlineM120) GetFreqInSecond

func (k *KlineM120) GetFreqInSecond() int

GetFreqInSecond return 7200

func (*KlineM120) GetTableName

func (k *KlineM120) GetTableName() string

GetTableName return kline_m120

type KlineM1440

type KlineM1440 struct {
	*BaseKline
}

KlineM1440 define kline data in 1 day

func NewKlineM1440

func NewKlineM1440(b *BaseKline) *KlineM1440

NewKlineM1440 create a instance of NewKlineM1440

func (*KlineM1440) GetFreqInSecond

func (k *KlineM1440) GetFreqInSecond() int

GetFreqInSecond return 86400

func (*KlineM1440) GetTableName

func (k *KlineM1440) GetTableName() string

GetTableName return kline_m1440

type KlineM15

type KlineM15 struct {
	*BaseKline
}

KlineM15 define kline data in 15 minutes

func NewKlineM15

func NewKlineM15(b *BaseKline) *KlineM15

NewKlineM15 create a instance of KlineM15

func (*KlineM15) GetFreqInSecond

func (k *KlineM15) GetFreqInSecond() int

GetFreqInSecond return 900

func (*KlineM15) GetTableName

func (k *KlineM15) GetTableName() string

GetTableName return kline_m15

type KlineM240

type KlineM240 struct {
	*BaseKline
}

KlineM240 define kline data in 4 hours

func NewKlineM240

func NewKlineM240(b *BaseKline) *KlineM240

NewKlineM240 create a instance of KlineM240

func (*KlineM240) GetFreqInSecond

func (k *KlineM240) GetFreqInSecond() int

GetFreqInSecond return 14400

func (*KlineM240) GetTableName

func (k *KlineM240) GetTableName() string

GetTableName return kline_m240

type KlineM3

type KlineM3 struct {
	*BaseKline
}

KlineM3 define kline data in 3 minutes

func NewKlineM3

func NewKlineM3(b *BaseKline) *KlineM3

NewKlineM3 create a instance of KlineM3

func (*KlineM3) GetFreqInSecond

func (k *KlineM3) GetFreqInSecond() int

GetFreqInSecond return 180

func (*KlineM3) GetTableName

func (k *KlineM3) GetTableName() string

GetTableName return kline_m3

type KlineM30

type KlineM30 struct {
	*BaseKline
}

KlineM30 define kline data in 30 minutes

func NewKlineM30

func NewKlineM30(b *BaseKline) *KlineM30

NewKlineM30 create a instance of KlineM30

func (*KlineM30) GetFreqInSecond

func (k *KlineM30) GetFreqInSecond() int

GetFreqInSecond return 1800

func (*KlineM30) GetTableName

func (k *KlineM30) GetTableName() string

GetTableName return kline_m30

type KlineM360

type KlineM360 struct {
	*BaseKline
}

KlineM360 define kline data in 6 hours

func NewKlineM360

func NewKlineM360(b *BaseKline) *KlineM360

NewKlineM360 create a instance of KlineM360

func (*KlineM360) GetFreqInSecond

func (k *KlineM360) GetFreqInSecond() int

GetFreqInSecond return 21600

func (*KlineM360) GetTableName

func (k *KlineM360) GetTableName() string

GetTableName return kline_m360

type KlineM4320

type KlineM4320 struct {
	*BaseKline
}

KlineM4320 define kline data in 1 day

func NewKlineM4320

func NewKlineM4320(b *BaseKline) *KlineM4320

NewKlineM4320 create a instance of KlineM4320

func (*KlineM4320) GetFreqInSecond

func (k *KlineM4320) GetFreqInSecond() int

GetFreqInSecond return 259200

func (*KlineM4320) GetTableName

func (k *KlineM4320) GetTableName() string

GetTableName return kline_m4320

type KlineM44640

type KlineM44640 struct {
	*BaseKline
}

KlineM44640 define kline data in 1 day

func NewKlineM44640

func NewKlineM44640(b *BaseKline) *KlineM44640

NewKlineM44640 create a instance of KlineM44640

func (*KlineM44640) GetFreqInSecond

func (k *KlineM44640) GetFreqInSecond() int

GetFreqInSecond return 2678400

func (*KlineM44640) GetTableName

func (k *KlineM44640) GetTableName() string

GetTableName return kline_m44640

type KlineM5

type KlineM5 struct {
	*BaseKline
}

KlineM5 define kline data in 5 minutes

func NewKlineM5

func NewKlineM5(b *BaseKline) *KlineM5

NewKlineM5 create a instance of KlineM5

func (*KlineM5) GetFreqInSecond

func (k *KlineM5) GetFreqInSecond() int

GetFreqInSecond return 300

func (*KlineM5) GetTableName

func (k *KlineM5) GetTableName() string

GetTableName return kline_m5

type KlineM525600

type KlineM525600 struct {
	*BaseKline
}

KlineM525600 define kline data in 1 day

func NewKlineM525600

func NewKlineM525600(b *BaseKline) *KlineM525600

NewKlineM525600 create a instance of KlineM525600

func (*KlineM525600) GetFreqInSecond

func (k *KlineM525600) GetFreqInSecond() int

GetFreqInSecond return 31536000

func (*KlineM525600) GetTableName

func (k *KlineM525600) GetTableName() string

GetTableName return kline_m525600

type KlineM60

type KlineM60 struct {
	*BaseKline
}

KlineM60 define kline data in 1 hour

func NewKlineM60

func NewKlineM60(b *BaseKline) *KlineM60

NewKlineM60 create a instance of KlineM60

func (*KlineM60) GetFreqInSecond

func (k *KlineM60) GetFreqInSecond() int

GetFreqInSecond return 3600

func (*KlineM60) GetTableName

func (k *KlineM60) GetTableName() string

GetTableName return kline_m60

type KlineM720

type KlineM720 struct {
	*BaseKline
}

KlineM720 define kline data in 12 hours

func NewKlineM720

func NewKlineM720(b *BaseKline) *KlineM720

NewKlineM720 create a instance of KlineM720

func (*KlineM720) GetFreqInSecond

func (k *KlineM720) GetFreqInSecond() int

GetFreqInSecond return 43200

func (*KlineM720) GetTableName

func (k *KlineM720) GetTableName() string

GetTableName return kline_m720

type MarketKeeper

type MarketKeeper interface {
	GetTickerByProducts(products []string) ([]map[string]string, error)
	GetKlineByProductID(productID uint64, granularity, size int) ([][]string, error)
}

MarketKeeper expected market keeper which would get data from pulsar & redis

type MatchResult

type MatchResult struct {
	Timestamp   int64   `gorm:"index;" json:"timestamp" v2:"timestamp"`
	BlockHeight int64   `gorm:"PRIMARY_KEY;type:bigint" json:"block_height" v2:"block_height"`
	Product     string  `gorm:"PRIMARY_KEY;type:varchar(20)" json:"product" v2:"product"`
	Price       float64 `gorm:"type:DOUBLE" json:"price" v2:"price"`
	Quantity    float64 `gorm:"type:DOUBLE" json:"volume" v2:"volume"`
}

type MergedTickersEvent

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

func NewMergedTickersEvent

func NewMergedTickersEvent(ts int64, freq int, tickers []interface{}) *MergedTickersEvent

func (*MergedTickersEvent) FormatResult

func (m *MergedTickersEvent) FormatResult() interface{}

func (*MergedTickersEvent) GetChannelInfo

func (m *MergedTickersEvent) GetChannelInfo() (channel, filter string, err error)

func (*MergedTickersEvent) GetFullChannel

func (m *MergedTickersEvent) GetFullChannel() string

func (*MergedTickersEvent) GetTimestamp

func (m *MergedTickersEvent) GetTimestamp() int64

type MintKeeper

type MintKeeper interface {
	GetParams(ctx sdk.Context) (params mint.Params)
}

MintKeeper expected mint keeper

type Order

type Order struct {
	TxHash         string `gorm:"type:varchar(80)" json:"txhash" v2:"txhash"`
	OrderID        string `gorm:"PRIMARY_KEY;type:varchar(30)" json:"order_id" v2:"order_id"`
	Sender         string `gorm:"index;type:varchar(80)" json:"sender" v2:"sender"`
	Product        string `gorm:"index;type:varchar(20)" json:"product" v2:"product"`
	Side           string `gorm:"type:varchar(10)" json:"side" v2:"side"`
	Price          string `gorm:"type:varchar(40)" json:"price" v2:"price"`
	Quantity       string `gorm:"type:varchar(40)" json:"quantity" v2:"quantity"`
	Status         int64  `gorm:"index;" json:"status" v2:"status"`
	FilledAvgPrice string `gorm:"type:varchar(40)" json:"filled_avg_price" v2:"filled_avg_price"`
	RemainQuantity string `gorm:"type:varchar(40)" json:"remain_quantity" v2:"remain_quantity"`
	Timestamp      int64  `gorm:"index;" json:"timestamp" v2:"timestamp"`
}

type OrderKeeper

type OrderKeeper interface {
	GetOrder(ctx sdk.Context, orderID string) *order.Order
	GetUpdatedOrderIDs() []string
	GetTxHandlerMsgResult() []bitset.BitSet
	GetBlockOrderNum(ctx sdk.Context, blockHeight int64) int64
	GetBlockMatchResult() *ordertypes.BlockMatchResult
	GetLastPrice(ctx sdk.Context, product string) sdk.Dec
	GetBestBidAndAsk(ctx sdk.Context, product string) (sdk.Dec, sdk.Dec)
}

OrderKeeper expected order keeper

type OrderV2

type OrderV2 struct {
	OrderID        string `json:"order_id"`
	Price          string `json:"price"`
	Size           string `json:"size"`
	OrderType      string `json:"order_type"`
	Notional       string `json:"notional"`
	InstrumentID   string `json:"instrument_id"`
	Side           string `json:"side"`
	Type           string `json:"type"`
	Timestamp      string `json:"timestamp"`
	FilledSize     string `json:"filled_size"`
	FilledNotional string `json:"filled_notional"`
	State          string `json:"state"`
}

func ConvertOrderToOrderV2

func ConvertOrderToOrderV2(order Order) OrderV2

type QueryAccountOrdersParams

type QueryAccountOrdersParams struct {
	Address string
	Start   int64
	End     int64
	Page    int
	PerPage int
}

nolint

func NewQueryAccountOrdersParams

func NewQueryAccountOrdersParams(address string, start int64, end int64, page, perPage int) QueryAccountOrdersParams

NewQueryAccountOrdersParams creates a new instance of QueryAccountOrdersParams

type QueryDealsParams

type QueryDealsParams struct {
	Address string
	Product string
	Start   int64
	End     int64
	Page    int
	PerPage int
	Side    string
}

nolint

func NewQueryDealsParams

func NewQueryDealsParams(addr, product string, start, end int64, page, perPage int, side string) QueryDealsParams

NewQueryDealsParams creates a new instance of QueryDealsParams

type QueryDealsParamsV2

type QueryDealsParamsV2 struct {
	Address string
	Product string
	Side    string
	After   string
	Before  string
	Limit   int
}

type QueryDexFeesParams

type QueryDexFeesParams struct {
	DexHandlingAddr string
	BaseAsset       string
	QuoteAsset      string
	Page            int
	PerPage         int
}

nolint

func NewQueryDexFeesParams

func NewQueryDexFeesParams(dexHandlingAddr, baseAsset, quoteAsset string, page, perPage int) QueryDexFeesParams

NewQueryDexFeesParams creates a new instance of QueryDexFeesParams

type QueryFarmDashboardParams

type QueryFarmDashboardParams struct {
	Address string `json:"address"`
	Page    int    `json:"page"`
	PerPage int    `json:"per_page"`
}

nolint

func NewQueryFarmDashboardParams

func NewQueryFarmDashboardParams(address string, page int, perPage int) QueryFarmDashboardParams

NewQueryFarmDashboardParams creates a new instance of QueryFarmDashboardParams

type QueryFarmFirstPoolParams

type QueryFarmFirstPoolParams struct {
	PoolName    string `json:"pool_name"`
	Address     string `json:"address"`
	StakeAt     int64  `json:"stake_at"`
	ClaimHeight int64  `json:"claim_height"`
}

nolint

func NewQueryFarmFirstPoolParams

func NewQueryFarmFirstPoolParams(poolName string, address string, stakeAt int64, claimHeight int64) QueryFarmFirstPoolParams

NewQueryFarmFirstPoolParams creates a new instance of QueryFarmFirstPoolParams

type QueryFarmPoolsParams

type QueryFarmPoolsParams struct {
	PoolType      string `json:"pool_type"`
	SortColumn    string `json:"sort_column"`
	SortDirection string `json:"sort_direction"`
	Page          int    `json:"page"`
	PerPage       int    `json:"per_page"`
}

nolint

func NewQueryFarmPoolsParams

func NewQueryFarmPoolsParams(poolType string, sortColumn string, sortDirection string, page int, perPage int) QueryFarmPoolsParams

NewQueryFarmPoolsParams creates a new instance of QueryFarmPoolsParams

type QueryFarmStakedInfoParams

type QueryFarmStakedInfoParams struct {
	PoolName string `json:"pool_name"`
	Address  string `json:"address"`
}

nolint

func NewQueryFarmStakedInfoParams

func NewQueryFarmStakedInfoParams(poolName string, address string) QueryFarmStakedInfoParams

NewQueryFarmStakedInfoParams creates a new instance of QueryFarmStakedInfoParams

type QueryFeeDetailsParams

type QueryFeeDetailsParams struct {
	Address string
	Page    int
	PerPage int
}

nolint

func NewQueryFeeDetailsParams

func NewQueryFeeDetailsParams(addr string, page, perPage int) QueryFeeDetailsParams

NewQueryFeeDetailsParams creates a new instance of QueryFeeDetailsParams

type QueryFeeDetailsParamsV2

type QueryFeeDetailsParamsV2 struct {
	Address string
	After   string
	Before  string
	Limit   int
}

type QueryKlinesParams

type QueryKlinesParams struct {
	Product     string
	Granularity int
	Size        int
}

nolint

func NewQueryKlinesParams

func NewQueryKlinesParams(product string, granularity, size int) QueryKlinesParams

NewQueryKlinesParams creates a new instance of QueryKlinesParams

type QueryMatchParams

type QueryMatchParams struct {
	Product string
	Start   int64
	End     int64
	Page    int
	PerPage int
}

nolint

func NewQueryMatchParams

func NewQueryMatchParams(product string, start, end int64, page, perPage int) QueryMatchParams

NewQueryMatchParams creates a new instance of QueryMatchParams

type QueryMatchParamsV2

type QueryMatchParamsV2 struct {
	Product string
	After   string
	Before  string
	Limit   int
}

type QueryOrderListParams

type QueryOrderListParams struct {
	Address    string
	Product    string
	Page       int
	PerPage    int
	Start      int64
	End        int64
	Side       string
	HideNoFill bool
}

nolint

func NewQueryOrderListParams

func NewQueryOrderListParams(addr, product, side string, page, perPage int, start, end int64,
	hideNoFill bool) QueryOrderListParams

NewQueryOrderListParams creates a new instance of QueryOrderListParams

type QueryOrderParamsV2

type QueryOrderParamsV2 struct {
	OrderID string
	Product string
	Side    string
	Address string
	After   string
	Before  string
	Limit   int
	IsOpen  bool
}

type QuerySwapLiquidityInfoParams

type QuerySwapLiquidityInfoParams struct {
	Address       string `json:"address"`
	TokenPairName string `json:"token_pair_name"`
}

nolint

func NewQuerySwapLiquidityInfoParams

func NewQuerySwapLiquidityInfoParams(address string, tokenPairName string) QuerySwapLiquidityInfoParams

NewQuerySwapBuyInfoParams creates a new instance of QuerySwapLiquidityInfoParams

type QuerySwapTokensParams

type QuerySwapTokensParams struct {
	BusinessType  string `json:"business_type"`
	Address       string `json:"address"`
	BaseTokenName string `json:"base_token_name"`
}

nolint

func NewQuerySwapTokensParams

func NewQuerySwapTokensParams(businessType string, address string, baseTokenName string) QuerySwapTokensParams

NewQuerySwapTokensParams creates a new instance of QueryDexFeesParams

type QuerySwapWatchlistParams

type QuerySwapWatchlistParams struct {
	SortColumn    string `json:"sort_column"`
	SortDirection string `json:"sort_direction"`
	Page          int    `json:"page"`
	PerPage       int    `json:"per_page"`
}

nolint

func NewQuerySwapWatchlistParams

func NewQuerySwapWatchlistParams(sortColumn string, sortDirection string, page int, perPage int) QuerySwapWatchlistParams

NewQuerySwapWatchlistParams creates a new instance of QuerySwapWatchlistParams

type QueryTickerParams

type QueryTickerParams struct {
	Product string `json:"product"`
	Count   int    `json:"count"`
	Sort    bool   `json:"sort"`
}

nolint

type QueryTxListParams

type QueryTxListParams struct {
	Address   string
	TxType    int64
	StartTime int64
	EndTime   int64
	Page      int
	PerPage   int
}

nolint

func NewQueryTxListParams

func NewQueryTxListParams(addr string, txType, startTime, endTime int64, page, perPage int) QueryTxListParams

NewQueryTxListParams creates a new instance of QueryTxListParams

type QueryTxListParamsV2

type QueryTxListParamsV2 struct {
	Address string
	TxType  int
	After   string
	Before  string
	Limit   int
}

type SwapInfo

type SwapInfo struct {
	Address          string `grom:"index;"`
	TokenPairName    string `gorm:"index;"`
	BaseTokenAmount  string `gorm:"type:varchar(40)"`
	QuoteTokenAmount string `gorm:"type:varchar(40)"`
	SellAmount       string `gorm:"type:varchar(40)"`
	BuysAmount       string `gorm:"type:varchar(40)"`
	Price            string `gorm:"type:varchar(40)"`
	Timestamp        int64  `gorm:"index;"`
}

type SwapKeeper

type SwapKeeper interface {
	GetSwapTokenPairs(ctx sdk.Context) []ammswap.SwapTokenPair
	GetSwapTokenPair(ctx sdk.Context, tokenPairName string) (ammswap.SwapTokenPair, error)
	GetParams(ctx sdk.Context) (params ammswap.Params)
	GetPoolTokenAmount(ctx sdk.Context, poolTokenName string) sdk.Dec
	SetObserverKeeper(k ammswaptypes.BackendKeeper)
}

SwapKeeper expected swap keeper

type SwapLiquidityInfo

type SwapLiquidityInfo struct {
	BasePooledCoin  sdk.SysCoin `json:"base_pooled_coin"`
	QuotePooledCoin sdk.SysCoin `json:"quote_pooled_coin"`
	PoolTokenCoin   sdk.SysCoin `json:"pool_token_coin"`
	PoolTokenRatio  sdk.Dec     `json:"pool_token_ratio"`
}

type SwapToken

type SwapToken struct {
	Symbol    string  `json:"symbol"`
	Available sdk.Dec `json:"available"`
}

func NewSwapToken

func NewSwapToken(symbol string, available sdk.Dec) SwapToken

type SwapTokens

type SwapTokens []SwapToken

func (SwapTokens) Len

func (swapTokens SwapTokens) Len() int

func (SwapTokens) Less

func (swapTokens SwapTokens) Less(i, j int) bool

func (SwapTokens) Swap

func (swapTokens SwapTokens) Swap(i, j int)

type SwapTokensResponse

type SwapTokensResponse struct {
	NativeToken string     `json:"native_token"`
	Tokens      SwapTokens `json:"tokens"`
}

type SwapVolumePriceInfo

type SwapVolumePriceInfo struct {
	Volume    sdk.Dec
	Price24h  sdk.Dec
	Timestamp int64
}

type SwapWatchlist

type SwapWatchlist struct {
	SwapPair  string  `json:"swap_pair"`
	Liquidity sdk.Dec `json:"liquidity"`
	Volume24h sdk.Dec `json:"volume24h"`
	FeeApy    sdk.Dec `json:"fee_apy"`
	LastPrice sdk.Dec `json:"last_price"`
	Change24h sdk.Dec `json:"change24h"`
}

type SwapWatchlistSorter

type SwapWatchlistSorter struct {
	Watchlist     []SwapWatchlist
	SortField     string
	SortDirectory string
}

func (*SwapWatchlistSorter) Len

func (s *SwapWatchlistSorter) Len() int

func (*SwapWatchlistSorter) Less

func (s *SwapWatchlistSorter) Less(i, j int) bool

func (*SwapWatchlistSorter) Swap

func (s *SwapWatchlistSorter) Swap(i, j int)

type SwapWhitelist

type SwapWhitelist struct {
	Id            uint64 `gorm:"primaryKey`
	TokenPairName string `gorm:"index;type:varchar(128)"`
	Deleted       bool   `gorm:"type:bool"`
	Timestamp     int64  `gorm:""`
}

type Ticker

type Ticker struct {
	Symbol           string  `json:"symbol"`
	Product          string  `json:"product"`
	Timestamp        int64   `json:"timestamp"`
	Open             float64 `json:"open"`  // Open In 24h
	Close            float64 `json:"close"` // Close in 24h
	High             float64 `json:"high"`  // High in 24h
	Low              float64 `json:"low"`   // Low in 24h
	Price            float64 `json:"price"`
	Volume           float64 `json:"volume"`            // Volume in 24h
	Change           float64 `json:"change"`            // (Close - Open)
	ChangePercentage string  `json:"change_percentage"` // Change / Open * 100%
}

func (*Ticker) FormatResult

func (t *Ticker) FormatResult() interface{}

func (*Ticker) GetChannelInfo

func (t *Ticker) GetChannelInfo() (channel, filter string, err error)

func (*Ticker) GetFullChannel

func (t *Ticker) GetFullChannel() string

func (*Ticker) GetTimestamp

func (t *Ticker) GetTimestamp() int64

func (*Ticker) PrettyString

func (t *Ticker) PrettyString() string

PrettyString return string of ticker data

type TickerV2

type TickerV2 struct {
	InstrumentID   string `json:"instrument_id"` // name of token pair
	Last           string `json:"last"`
	BestBid        string `json:"best_bid"`
	BestAsk        string `json:"best_ask"`
	Open24H        string `json:"open_24h"`
	High24H        string `json:"high_24h"`
	Low24H         string `json:"low_24h"`
	BaseVolume24H  string `json:"base_volume_24h"`
	QuoteVolume24H string `json:"quote_volume_24h"`
	Timestamp      string `json:"timestamp"`
}

func DefaultTickerV2

func DefaultTickerV2(instrumentID string) TickerV2

type Tickers

type Tickers []Ticker

func (Tickers) Len

func (tickers Tickers) Len() int

func (Tickers) Less

func (tickers Tickers) Less(i, j int) bool

func (Tickers) Swap

func (c Tickers) Swap(i, j int)

type TokenKeeper

type TokenKeeper interface {
	GetFeeDetailList() []*token.FeeDetail
	GetParams(ctx sdk.Context) (params token.Params)
	GetCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.SysCoins
	GetTokensInfo(ctx sdk.Context) (tokens []token.Token)
}

TokenKeeper expected token keeper

type Transaction

type Transaction struct {
	TxHash    string `gorm:"type:varchar(80)" json:"txhash" v2:"txhash"`
	Type      int64  `gorm:"index;" json:"type" v2:"type"` // 1:Transfer, 2:NewOrder, 3:CancelOrder
	Address   string `gorm:"index;type:varchar(80)" json:"address" v2:"address"`
	Symbol    string `gorm:"type:varchar(20)" json:"symbol" v2:"symbol"`
	Side      int64  `gorm:"" json:"side"` // 1:buy, 2:sell, 3:from, 4:to
	Quantity  string `gorm:"type:varchar(40)" json:"quantity" v2:"quantity"`
	Fee       string `gorm:"type:varchar(40)" json:"fee" v2:"fee"`
	Timestamp int64  `gorm:"index" json:"timestamp" v2:"timestamp"`
}

func GenerateTx

func GenerateTx(tx *auth.StdTx, txHash string, ctx sdk.Context, orderKeeper OrderKeeper, timestamp int64) []*Transaction

GenerateTx return transaction, called at DeliverTx

Jump to

Keyboard shortcuts

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