keepers

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: BSD-2-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryMarket            = "market-info"
	QueryMarkets           = "market-list"
	QueryOrdersInMarket    = "orders-in-market"
	QueryOrder             = "order-info"
	QueryUserOrders        = "user-order-list"
	QueryWaitCancelMarkets = "wait-cancel-markets"
	QueryParameters        = "parameters"
)

Variables

View Source
var (
	MarketIdentifierPrefix = []byte{0x15}
	DelistKey              = []byte{0x40}
	DelistRevKey           = []byte{0x42}
)
View Source
var (
	OrderBookKeyPrefix     = []byte{0x11}
	BidListKeyPrefix       = []byte{0x12}
	AskListKeyPrefix       = []byte{0x13}
	OrderQueueKeyPrefix    = []byte{0x14}
	NewlyAddedKeyPrefix    = []byte{0x66}
	NewlyAddedKeyEnd       = []byte{0x67}
	LastOrderCleanUpDayKey = []byte{0x20}
)

nolint

Functions

func NewQuerier

func NewQuerier(mk Keeper) sdk.Querier

creates a querier for asset REST endpoints

Types

type DelistKeeper

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

func NewDelistKeeper

func NewDelistKeeper(key sdk.StoreKey) *DelistKeeper

func (*DelistKeeper) AddDelistRequest

func (keeper *DelistKeeper) AddDelistRequest(ctx sdk.Context, time int64, symbol string)

func (*DelistKeeper) GetDelistSymbolsBeforeTime

func (keeper *DelistKeeper) GetDelistSymbolsBeforeTime(ctx sdk.Context, time int64) []string

include the specific time

func (*DelistKeeper) HasDelistRequest

func (keeper *DelistKeeper) HasDelistRequest(ctx sdk.Context, symbol string) bool

func (*DelistKeeper) RemoveDelistRequestsBeforeTime

func (keeper *DelistKeeper) RemoveDelistRequestsBeforeTime(ctx sdk.Context, time int64)

type GlobalMarketInfoKeeper

type GlobalMarketInfoKeeper interface {
	SetMarket(ctx sdk.Context, info types.MarketInfo) sdk.Error
	RemoveMarket(ctx sdk.Context, symbol string) sdk.Error
	GetAllMarketInfos(ctx sdk.Context) []types.MarketInfo
	MarketCountOfStock(ctx sdk.Context, stock string) int64
	GetMarketInfo(ctx sdk.Context, symbol string) (types.MarketInfo, error)
}

func NewGlobalMarketInfoKeeper

func NewGlobalMarketInfoKeeper(key sdk.StoreKey, cdcVal *codec.Codec) GlobalMarketInfoKeeper

type GlobalOrderKeeper

type GlobalOrderKeeper interface {
	GetAllOrders(ctx sdk.Context) []*types.Order
	QueryOrder(ctx sdk.Context, orderID string) *types.Order
	GetOrdersFromUser(ctx sdk.Context, user string) []string
}

Global order keep can lookup a order, given its ID or the prefix of its ID, i.e. the sender's address

func NewGlobalOrderKeeper

func NewGlobalOrderKeeper(key sdk.StoreKey, codec *codec.Codec) GlobalOrderKeeper

type Keeper

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

func (Keeper) DeductInt64CetFee

func (k Keeper) DeductInt64CetFee(ctx sdk.Context, addr sdk.AccAddress, amt int64) sdk.Error

func (Keeper) FreezeCoins

func (k Keeper) FreezeCoins(ctx sdk.Context, acc sdk.AccAddress, amt sdk.Coins) sdk.Error

func (Keeper) GetAllMarketInfos

func (k Keeper) GetAllMarketInfos(ctx sdk.Context) []types.MarketInfo

func (Keeper) GetAllOrders

func (k Keeper) GetAllOrders(ctx sdk.Context) []*types.Order

func (Keeper) GetAssetKeeper

func (k Keeper) GetAssetKeeper() types.ExpectedAssetStatusKeeper

func (Keeper) GetBankxKeeper

func (k Keeper) GetBankxKeeper() types.ExpectedBankxKeeper

func (Keeper) GetMarketFeeMin

func (k Keeper) GetMarketFeeMin(ctx sdk.Context) int64

func (Keeper) GetMarketInfo

func (k Keeper) GetMarketInfo(ctx sdk.Context, symbol string) (types.MarketInfo, error)

func (Keeper) GetMarketKey

func (k Keeper) GetMarketKey() sdk.StoreKey

func (*Keeper) GetMarketLastExePrice

func (k *Keeper) GetMarketLastExePrice(ctx sdk.Context, symbol string) (sdk.Dec, error)

func (Keeper) GetMarketVolume

func (k Keeper) GetMarketVolume(ctx sdk.Context, stock, money string, stockVolume, moneyVolume sdk.Dec) sdk.Dec

func (Keeper) GetMarketsWithNewlyAddedOrder

func (k Keeper) GetMarketsWithNewlyAddedOrder(ctx sdk.Context) []string

func (Keeper) GetMsgProducer

func (k Keeper) GetMsgProducer() msgqueue.MsgSender

func (Keeper) GetOrderCleanTime

func (k Keeper) GetOrderCleanTime(ctx sdk.Context) int64

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)

GetParams gets the asset module's parameters.

func (Keeper) GetRebateRatio

func (k Keeper) GetRebateRatio(ctx sdk.Context) int64

func (Keeper) GetRebateRatioBase

func (k Keeper) GetRebateRatioBase(ctx sdk.Context) int64

func (Keeper) GetRefereeAddr

func (k Keeper) GetRefereeAddr(ctx sdk.Context, accAddr sdk.AccAddress) sdk.AccAddress

func (Keeper) GetToken

func (k Keeper) GetToken(ctx sdk.Context, symbol string) asset.Token

func (Keeper) HasCoins

func (k Keeper) HasCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) bool

func (Keeper) IsForbiddenByTokenIssuer

func (k Keeper) IsForbiddenByTokenIssuer(ctx sdk.Context, denom string, addr sdk.AccAddress) bool

func (*Keeper) IsMarketExist

func (k *Keeper) IsMarketExist(ctx sdk.Context, symbol string) bool

func (Keeper) IsSubScribed

func (k Keeper) IsSubScribed(topic string) bool

func (Keeper) IsTokenExists

func (k Keeper) IsTokenExists(ctx sdk.Context, symbol string) bool

func (Keeper) IsTokenForbidden

func (k Keeper) IsTokenForbidden(ctx sdk.Context, symbol string) bool

func (Keeper) IsTokenIssuer

func (k Keeper) IsTokenIssuer(ctx sdk.Context, denom string, addr sdk.AccAddress) bool

func (Keeper) MarketCountOfStock

func (k Keeper) MarketCountOfStock(ctx sdk.Context, stock string) int64

func (Keeper) MarketOwner

func (k Keeper) MarketOwner(ctx sdk.Context, info types.MarketInfo) sdk.AccAddress

func (Keeper) QuerySeqWithAddr

func (k Keeper) QuerySeqWithAddr(ctx sdk.Context, addr sdk.AccAddress) (uint64, sdk.Error)

func (Keeper) RemoveMarket

func (k Keeper) RemoveMarket(ctx sdk.Context, symbol string) sdk.Error

func (Keeper) SendCoins

func (k Keeper) SendCoins(ctx sdk.Context, from sdk.AccAddress, to sdk.AccAddress, amt sdk.Coins) sdk.Error

func (Keeper) SetMarket

func (k Keeper) SetMarket(ctx sdk.Context, info types.MarketInfo) sdk.Error

func (Keeper) SetOrder

func (k Keeper) SetOrder(ctx sdk.Context, order *types.Order) sdk.Error

SetOrder implements token Keeper.

func (Keeper) SetOrderCleanTime

func (k Keeper) SetOrderCleanTime(ctx sdk.Context, t int64)

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, params types.Params)

SetParams sets the asset module's parameters.

func (Keeper) SubtractCoins

func (k Keeper) SubtractCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) sdk.Error

func (Keeper) SubtractFeeAndCollectFee

func (k Keeper) SubtractFeeAndCollectFee(ctx sdk.Context, addr sdk.AccAddress, amt int64) sdk.Error

func (Keeper) UnFreezeCoins

func (k Keeper) UnFreezeCoins(ctx sdk.Context, acc sdk.AccAddress, amt sdk.Coins) sdk.Error

type MarketInfoList

type MarketInfoList []QueryMarketInfo

type OrderCleanUpDayKeeper

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

This keeper records at which day the last GTE-order-clean-up action was performed

func NewOrderCleanUpDayKeeper

func NewOrderCleanUpDayKeeper(key sdk.StoreKey) *OrderCleanUpDayKeeper

func (*OrderCleanUpDayKeeper) GetUnixTime

func (keeper *OrderCleanUpDayKeeper) GetUnixTime(ctx sdk.Context) int64

func (*OrderCleanUpDayKeeper) SetUnixTime

func (keeper *OrderCleanUpDayKeeper) SetUnixTime(ctx sdk.Context, unixTime int64)

type OrderKeeper

type OrderKeeper interface {
	Add(ctx sdk.Context, order *types.Order) sdk.Error
	Update(ctx sdk.Context, order *types.Order) sdk.Error
	Remove(ctx sdk.Context, order *types.Order) sdk.Error
	GetOlderThan(ctx sdk.Context, height int64) []*types.Order
	GetOrdersAtHeight(ctx sdk.Context, height int64) []*types.Order
	GetMatchingCandidates(ctx sdk.Context) []*types.Order
	GetSymbol() string
}

OrderKeeper manages the order book of one market

func NewOrderKeeper

func NewOrderKeeper(key sdk.StoreKey, symbol string, codec *codec.Codec) OrderKeeper

type PersistentGlobalOrderKeeper

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

func (*PersistentGlobalOrderKeeper) GetAllOrders

func (keeper *PersistentGlobalOrderKeeper) GetAllOrders(ctx sdk.Context) []*types.Order

Get all the orders out. It is an expensive operation. Only use it for dumping state.

func (*PersistentGlobalOrderKeeper) GetOrdersFromUser

func (keeper *PersistentGlobalOrderKeeper) GetOrdersFromUser(ctx sdk.Context, user string) []string

func (*PersistentGlobalOrderKeeper) QueryOrder

func (keeper *PersistentGlobalOrderKeeper) QueryOrder(ctx sdk.Context, orderID string) *types.Order

type PersistentMarketInfoKeeper

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

func (PersistentMarketInfoKeeper) GetAllMarketInfos

func (k PersistentMarketInfoKeeper) GetAllMarketInfos(ctx sdk.Context) []types.MarketInfo

func (PersistentMarketInfoKeeper) GetMarketInfo

func (k PersistentMarketInfoKeeper) GetMarketInfo(ctx sdk.Context, symbol string) (info types.MarketInfo, err error)

func (PersistentMarketInfoKeeper) MarketCountOfStock

func (k PersistentMarketInfoKeeper) MarketCountOfStock(ctx sdk.Context, stock string) (count int64)

func (PersistentMarketInfoKeeper) RemoveMarket

func (k PersistentMarketInfoKeeper) RemoveMarket(ctx sdk.Context, symbol string) sdk.Error

func (PersistentMarketInfoKeeper) SetMarket

SetMarket implements token Keeper.

type PersistentOrderKeeper

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

PersistentOrderKeeper implements OrderKeeper interface with a KVStore

func (*PersistentOrderKeeper) Add

func (keeper *PersistentOrderKeeper) Add(ctx sdk.Context, order *types.Order) sdk.Error

func (*PersistentOrderKeeper) GetMatchingCandidates

func (keeper *PersistentOrderKeeper) GetMatchingCandidates(ctx sdk.Context) []*types.Order

Return the bid orders and ask orders which have proper prices and have possibilities for deal

func (*PersistentOrderKeeper) GetOlderThan

func (keeper *PersistentOrderKeeper) GetOlderThan(ctx sdk.Context, height int64) []*types.Order

using the order queue, find orders which are older than a particular height

func (*PersistentOrderKeeper) GetOrdersAtHeight

func (keeper *PersistentOrderKeeper) GetOrdersAtHeight(ctx sdk.Context, height int64) []*types.Order

using the order queue, find orders which locate at a particular height

func (*PersistentOrderKeeper) GetSymbol

func (keeper *PersistentOrderKeeper) GetSymbol() string

func (*PersistentOrderKeeper) Remove

func (keeper *PersistentOrderKeeper) Remove(ctx sdk.Context, order *types.Order) sdk.Error

func (*PersistentOrderKeeper) Update

func (keeper *PersistentOrderKeeper) Update(ctx sdk.Context, order *types.Order) sdk.Error

type QueryCancelMarkets

type QueryCancelMarkets struct {
	Time int64
}

type QueryMarketInfo

type QueryMarketInfo struct {
	Creator           sdk.AccAddress `json:"creator"`
	Stock             string         `json:"stock"`
	Money             string         `json:"money"`
	PricePrecision    string         `json:"price_precision"`
	LastExecutedPrice sdk.Dec        `json:"last_executed_price"`
	OrderPrecision    string         `json:"order_precision"`
}

type QueryMarketInfoAndParams

type QueryMarketInfoAndParams interface {
	GetParams(ctx sdk.Context) types.Params
	GetMarketVolume(ctx sdk.Context, stock, money string, stockVolume, moneyVolume sdk.Dec) sdk.Dec
}

type QueryMarketParam

type QueryMarketParam struct {
	TradingPair string
}

func NewQueryMarketParam

func NewQueryMarketParam(symbol string) QueryMarketParam

type QueryOrderParam

type QueryOrderParam struct {
	OrderID string
}

func NewQueryOrderParam

func NewQueryOrderParam(orderID string) QueryOrderParam

type QueryUserOrderList

type QueryUserOrderList struct {
	User string
}

type ResOrder added in v0.2.10

type ResOrder struct {
	OrderID          string         `json:"order_id"`
	Sender           sdk.AccAddress `json:"sender"`
	Sequence         uint64         `json:"sequence"`
	Identify         byte           `json:"identify"`
	TradingPair      string         `json:"trading_pair"`
	OrderType        byte           `json:"order_type"`
	Price            sdk.Dec        `json:"price"`
	Quantity         int64          `json:"quantity"`
	Side             byte           `json:"side"`
	TimeInForce      int64          `json:"time_in_force"`
	Height           int64          `json:"height"`
	FrozenCommission int64          `json:"frozen_commission"` // DEX2
	ExistBlocks      int64          `json:"exist_blocks"`
	FrozenFeatureFee int64          `json:"frozen_feature_fee"`   // DEX2
	FrozenFee        int64          `json:"frozen_fee,omitempty"` // DEX2: -> frozen_commission

	// These fields will change when order was filled/canceled.
	LeftStock int64 `json:"left_stock"`
	Freeze    int64 `json:"freeze"`
	DealStock int64 `json:"deal_stock"`
	DealMoney int64 `json:"deal_money"`
}

Jump to

Keyboard shortcuts

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