Documentation ¶
Index ¶
- Constants
- Variables
- func ErrAllOrderFailedToExecute() sdk.EnvelopedErr
- func ErrCancelOrderBiggerThanLimit(limit int) sdk.EnvelopedErr
- func ErrCheckTokenPairUnderDexDelistFailed() sdk.EnvelopedErr
- func ErrInvalidAddress(address string) sdk.EnvelopedErr
- func ErrInvalidSizeParam(size uint) sdk.EnvelopedErr
- func ErrIsProductLocked(product string) sdk.EnvelopedErr
- func ErrMsgQuantityLessThan(minQuantity string) sdk.EnvelopedErr
- func ErrNoOrdersIsCanceled() sdk.EnvelopedErr
- func ErrNotOrderOwner(orderID string) sdk.EnvelopedErr
- func ErrOrderIDsHasDuplicatedID() sdk.EnvelopedErr
- func ErrOrderIDsIsEmpty() sdk.EnvelopedErr
- func ErrOrderIsNotExist(order string) sdk.EnvelopedErr
- func ErrOrderIsNotExistOrClosed(orderID string) sdk.EnvelopedErr
- func ErrOrderItemCountsBiggerThanLimit(limit int) sdk.EnvelopedErr
- func ErrOrderItemCountsIsEmpty() sdk.EnvelopedErr
- func ErrOrderItemPriceOrQuantityIsNotPositive() sdk.EnvelopedErr
- func ErrOrderItemProductCountsIsEmpty() sdk.EnvelopedErr
- func ErrOrderItemProductFormat() sdk.EnvelopedErr
- func ErrOrderItemProductSymbolIsEqual() sdk.EnvelopedErr
- func ErrOrderItemSideIsNotBuyAndSell() sdk.EnvelopedErr
- func ErrOrderStatusIsNotOpen() sdk.EnvelopedErr
- func ErrPriceOverAccuracy(price sdk.Dec, priceDigit int64) sdk.EnvelopedErr
- func ErrQuantityOverAccuracy(quantity sdk.Dec, quantityDigit int64) sdk.EnvelopedErr
- func ErrSendCoinsFailed(coins string, to string) sdk.EnvelopedErr
- func ErrTokenPairNotExist(product string) sdk.EnvelopedErr
- func ErrTradingPairIsDelisting(product string) sdk.EnvelopedErr
- func ErrUnknownOrderQueryType() sdk.EnvelopedErr
- func ErrUserInputOrderIDIsEmpty() sdk.EnvelopedErr
- func FormatOrderID(blockHeight, orderNum int64) string
- func FormatOrderIDPrefix(blockHeight int64) string
- func FormatOrderIDsKey(product string, price sdk.Dec, side string) string
- func GetBlockHeightFromOrderID(orderID string) int64
- func GetDepthBookKey(key string) []byte
- func GetExpireBlockHeightKey(blockHeight int64) []byte
- func GetKey(it sdk.Iterator) string
- func GetOrderIDsKey(key string) []byte
- func GetOrderKey(key string) []byte
- func GetOrderNumPerBlockKey(blockHeight int64) []byte
- func GetPriceKey(key string) []byte
- func ParamKeyTable() params.KeyTable
- func RegisterCodec(cdc *codec.Codec)
- type BlockMatchResult
- type Deal
- type DepthBook
- type DepthBookItem
- type MatchResult
- type MsgCancelOrder
- type MsgCancelOrders
- func (msg MsgCancelOrders) CalculateGas(gasUnit uint64) uint64
- func (msg MsgCancelOrders) GetSignBytes() []byte
- func (msg MsgCancelOrders) GetSigners() []sdk.AccAddress
- func (msg MsgCancelOrders) Route() string
- func (msg MsgCancelOrders) Type() string
- func (msg MsgCancelOrders) ValidateBasic() sdk.Error
- type MsgNewOrder
- type MsgNewOrders
- type Order
- func (order *Order) Cancel()
- func (order *Order) Expire()
- func (order *Order) Fill(price, fillAmount sdk.Dec)
- func (order *Order) GetExtraInfoWithKey(key string) string
- func (order *Order) NeedLockCoins() sdk.SysCoins
- func (order *Order) NeedUnlockCoins() sdk.SysCoins
- func (order *Order) RecordOrderCancelFee(fee sdk.SysCoins)
- func (order *Order) RecordOrderDealFee(fee sdk.SysCoins)
- func (order *Order) RecordOrderNewFee(fee sdk.SysCoins)
- func (order *Order) RecordOrderReceiveFee(fee sdk.SysCoins)
- func (order *Order) String() string
- func (order *Order) Unlock()
- type OrderItem
- type OrderResult
- type OrderStatus
- type Params
- type ProductLock
- type ProductLockMap
Constants ¶
const ( FeeTypeOrderNew = "new" FeeTypeOrderCancel = "cancel" FeeTypeOrderExpire = "expire" FeeTypeOrderDeal = "deal" FeeTypeOrderReceive = "receive" TestTokenPair = common.TestToken + "_" + sdk.DefaultBondDenom BuyOrder = "BUY" SellOrder = "SELL" )
nolint
const ( CodeInvalidAddress uint32 = 63000 CodeSizeIsInvalid uint32 = 63001 CodeTokenPairNotExist uint32 = 63002 CodeSendCoinsFailed uint32 = 63003 CodeTradingPairIsDelisting uint32 = 63004 CodePriceOverAccuracy uint32 = 63005 CodeQuantityOverAccuracy uint32 = 63006 CodeMsgQuantityLessThan uint32 = 63007 CodeOrderIsNotExist uint32 = 63008 CodeCheckTokenPairUnderDexDelistFailed uint32 = 63009 CodeIsProductLocked uint32 = 63010 CodeNoOrdersIsCanceled uint32 = 63011 CodeOrderStatusIsNotOpen uint32 = 63012 CodeOrderIsNotExistOrClosed uint32 = 63013 CodeUnknownOrderQueryType uint32 = 63014 CodeOrderItemCountsBiggerThanLimit uint32 = 63015 CodeOrderItemCountsIsEmpty uint32 = 63016 CodeOrderItemProductCountsIsEmpty uint32 = 63017 CodeOrderItemProductSymbolError uint32 = 63018 CodeOrderItemProductSymbolIsEqual uint32 = 63019 CodeOrderItemSideIsNotBuyAndSell uint32 = 63020 CodeOrderItemPriceOrQuantityIsNotPositive uint32 = 63021 CodeOrderIDsIsEmpty uint32 = 63022 CodeCancelOrderBiggerThanLimit uint32 = 63023 CodeOrderIDsHasDuplicatedID uint32 = 63024 CodeUserInputOrderIDIsEmpty uint32 = 63025 CodeNotOrderOwner uint32 = 63026 CodeProductIsEmpty uint32 = 63027 CodeAllOrderFailedToExecute uint32 = 63028 )
const uint32
const ( // ModuleName is the name of the order module ModuleName = "order" DefaultParamspace = ModuleName DefaultCodespace = ModuleName // QuerierRoute is the querier route for the order module QuerierRoute = ModuleName // RouterKey is the msg router key for the order module RouterKey = ModuleName // QueryOrderDetail query endpoints supported by the governance Querier QueryOrderDetail = "detail" QueryDepthBook = "depthbook" QueryParameters = "params" QueryStore = "store" QueryDepthBookV2 = "depthbookV2" OrderStoreKey = ModuleName )
nolint
const ( OrderItemLimit = 200 MultiCancelOrderItemLimit = 200 )
nolint
const ( OrderStatusOpen = 0 OrderStatusFilled = 1 OrderStatusCancelled = 2 OrderStatusExpired = 3 OrderStatusPartialFilledCancelled = 4 OrderStatusPartialFilledExpired = 5 )
nolint
const ( OrderExtraInfoKeyNewFee = "newFee" OrderExtraInfoKeyCancelFee = "cancelFee" OrderExtraInfoKeyExpireFee = "expireFee" OrderExtraInfoKeyDealFee = "dealFee" OrderExtraInfoKeyReceiveFee = "receiveFee" )
nolint
const ( // System param DefaultOrderExpireBlocks = 259200 // order will be expired after 86400 blocks. DefaultMaxDealsPerBlock = 1000 // deals limit per block // Fee param DefaultFeeAmountPerBlock = "0" // omt DefaultFeeDenomPerBlock = common.NativeToken DefaultFeeRateTrade = "0.001" // percentage DefaultNewOrderMsgGasUnit = 40000 DefaultCancelOrderMsgGasUnit = 30000 )
nolint
const DefaultTestFeeAmountPerBlock = "0.000001" // omt
Variables ¶
var ( // iterator keys OrderKey = []byte{0x11} DepthBookKey = []byte{0x12} OrderIDsKey = []byte{0x13} PriceKey = []byte{0x14} ExpireBlockHeightKey = []byte{0x15} OrderNumPerBlockKey = []byte{0x16} // none iterator keys RecentlyClosedOrderIDsKey = []byte{0x17} LastExpiredBlockHeightKey = []byte{0x18} OpenOrderNumKey = []byte{0x19} StoreOrderNumKey = []byte{0x20} )
nolint
var ( KeyOrderExpireBlocks = []byte("OrderExpireBlocks") KeyMaxDealsPerBlock = []byte("MaxDealsPerBlock") KeyFeePerBlock = []byte("FeePerBlock") KeyTradeFeeRate = []byte("TradeFeeRate") KeyNewOrderMsgGasUnit = []byte("NewOrderMsgGasUnit") KeyCancelOrderMsgGasUnit = []byte("CancelOrderMsgGasUnit") DefaultFeePerBlock = sdk.NewDecCoinFromDec(DefaultFeeDenomPerBlock, sdk.MustNewDecFromStr(DefaultFeeAmountPerBlock)) )
nolint : Parameter keys
var DefaultTestFeePerBlock = sdk.NewDecCoinFromDec(DefaultFeeDenomPerBlock, sdk.MustNewDecFromStr(DefaultTestFeeAmountPerBlock))
var ModuleCdc *codec.Codec
ModuleCdc generic sealed codec to be used throughout this module
Functions ¶
func ErrAllOrderFailedToExecute ¶
func ErrAllOrderFailedToExecute() sdk.EnvelopedErr
func ErrCancelOrderBiggerThanLimit ¶
func ErrCancelOrderBiggerThanLimit(limit int) sdk.EnvelopedErr
func ErrCheckTokenPairUnderDexDelistFailed ¶
func ErrCheckTokenPairUnderDexDelistFailed() sdk.EnvelopedErr
func ErrInvalidAddress ¶
func ErrInvalidAddress(address string) sdk.EnvelopedErr
func ErrIsProductLocked ¶
func ErrIsProductLocked(product string) sdk.EnvelopedErr
func ErrMsgQuantityLessThan ¶
func ErrMsgQuantityLessThan(minQuantity string) sdk.EnvelopedErr
func ErrNoOrdersIsCanceled ¶
func ErrNoOrdersIsCanceled() sdk.EnvelopedErr
func ErrNotOrderOwner ¶
func ErrNotOrderOwner(orderID string) sdk.EnvelopedErr
func ErrOrderIDsHasDuplicatedID ¶
func ErrOrderIDsHasDuplicatedID() sdk.EnvelopedErr
func ErrOrderIDsIsEmpty ¶
func ErrOrderIDsIsEmpty() sdk.EnvelopedErr
func ErrOrderIsNotExist ¶
func ErrOrderIsNotExist(order string) sdk.EnvelopedErr
func ErrOrderIsNotExistOrClosed ¶
func ErrOrderIsNotExistOrClosed(orderID string) sdk.EnvelopedErr
func ErrOrderItemCountsBiggerThanLimit ¶
func ErrOrderItemCountsBiggerThanLimit(limit int) sdk.EnvelopedErr
func ErrOrderItemCountsIsEmpty ¶
func ErrOrderItemCountsIsEmpty() sdk.EnvelopedErr
func ErrOrderItemPriceOrQuantityIsNotPositive ¶
func ErrOrderItemPriceOrQuantityIsNotPositive() sdk.EnvelopedErr
func ErrOrderItemProductCountsIsEmpty ¶
func ErrOrderItemProductCountsIsEmpty() sdk.EnvelopedErr
func ErrOrderItemProductFormat ¶
func ErrOrderItemProductFormat() sdk.EnvelopedErr
func ErrOrderItemProductSymbolIsEqual ¶
func ErrOrderItemProductSymbolIsEqual() sdk.EnvelopedErr
func ErrOrderItemSideIsNotBuyAndSell ¶
func ErrOrderItemSideIsNotBuyAndSell() sdk.EnvelopedErr
func ErrOrderStatusIsNotOpen ¶
func ErrOrderStatusIsNotOpen() sdk.EnvelopedErr
func ErrPriceOverAccuracy ¶
func ErrPriceOverAccuracy(price sdk.Dec, priceDigit int64) sdk.EnvelopedErr
func ErrQuantityOverAccuracy ¶
func ErrQuantityOverAccuracy(quantity sdk.Dec, quantityDigit int64) sdk.EnvelopedErr
func ErrSendCoinsFailed ¶
func ErrSendCoinsFailed(coins string, to string) sdk.EnvelopedErr
func ErrTokenPairNotExist ¶
func ErrTokenPairNotExist(product string) sdk.EnvelopedErr
func ErrTradingPairIsDelisting ¶
func ErrTradingPairIsDelisting(product string) sdk.EnvelopedErr
func ErrUnknownOrderQueryType ¶
func ErrUnknownOrderQueryType() sdk.EnvelopedErr
func ErrUserInputOrderIDIsEmpty ¶
func ErrUserInputOrderIDIsEmpty() sdk.EnvelopedErr
func FormatOrderIDsKey ¶
nolint
func RegisterCodec ¶
RegisterCodec registers concrete types on the Amino codec
Types ¶
type BlockMatchResult ¶
type BlockMatchResult struct { BlockHeight int64 `json:"block_height"` ResultMap map[string]MatchResult `json:"result_map"` TimeStamp int64 `json:"timestamp"` }
nolint
type Deal ¶
type Deal struct { OrderID string `json:"order_id"` Side string `json:"side"` Quantity sdk.Dec `json:"quantity"` Fee string `json:"fee"` FeeReceiver string `json:"fee_receiver"` }
nolint
type DepthBook ¶
type DepthBook struct {
Items []DepthBookItem
}
nolint
func (*DepthBook) InsertOrder ¶
InsertOrder : Items in depth book are sorted by price desc insert a new order into depth book
func (*DepthBook) RemoveIfEmpty ¶
RemoveIfEmpty : remove the filled or empty item
func (*DepthBook) RemoveOrder ¶
RemoveOrder : remove an order from depth book when order cancelled/expired
type DepthBookItem ¶
type DepthBookItem struct { Price sdk.Dec `json:"price"` BuyQuantity sdk.Dec `json:"buy_quantity"` SellQuantity sdk.Dec `json:"sell_quantity"` }
nolint
type MatchResult ¶
type MatchResult struct { BlockHeight int64 `json:"block_height"` Price sdk.Dec `json:"price"` Quantity sdk.Dec `json:"quantity"` Deals []Deal `json:"deals"` }
nolint
type MsgCancelOrder ¶
type MsgCancelOrder struct { Sender sdk.AccAddress `json:"sender"` OrderID string `json:"order_id"` }
nolint
type MsgCancelOrders ¶
type MsgCancelOrders struct { Sender sdk.AccAddress `json:"sender"` // order maker address OrderIDs []string `json:"order_ids"` }
nolint
func NewMsgCancelOrder ¶
func NewMsgCancelOrder(sender sdk.AccAddress, orderID string) MsgCancelOrders
NewMsgCancelOrder is a constructor function for MsgCancelOrder
func NewMsgCancelOrders ¶
func NewMsgCancelOrders(sender sdk.AccAddress, orderIDItems []string) MsgCancelOrders
NewMsgCancelOrders is a constructor function for MsgCancelOrder
func (MsgCancelOrders) CalculateGas ¶
func (msg MsgCancelOrders) CalculateGas(gasUnit uint64) uint64
Calculate customize gas
func (MsgCancelOrders) GetSignBytes ¶
func (msg MsgCancelOrders) GetSignBytes() []byte
GetSignBytes encodes the message for signing
func (MsgCancelOrders) GetSigners ¶
func (msg MsgCancelOrders) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
type MsgNewOrder ¶
type MsgNewOrder struct { Sender sdk.AccAddress `json:"sender"` // order maker address Product string `json:"product"` // product for trading pair in full name of the tokens Side string `json:"side"` // BUY/SELL Price sdk.Dec `json:"price"` // price of the order Quantity sdk.Dec `json:"quantity"` // quantity of the order }
nolint
type MsgNewOrders ¶
type MsgNewOrders struct { Sender sdk.AccAddress `json:"sender"` // order maker address OrderItems []OrderItem `json:"order_items"` }
********************MsgNewOrders************* nolint
func NewMsgNewOrder ¶
func NewMsgNewOrder(sender sdk.AccAddress, product string, side string, price string, quantity string) MsgNewOrders
NewMsgNewOrder is a constructor function for MsgNewOrder
func NewMsgNewOrders ¶
func NewMsgNewOrders(sender sdk.AccAddress, orderItems []OrderItem) MsgNewOrders
NewMsgNewOrders is a constructor function for MsgNewOrder
func (MsgNewOrders) CalculateGas ¶
func (msg MsgNewOrders) CalculateGas(gasUnit uint64) uint64
Calculate customize gas
func (MsgNewOrders) GetSignBytes ¶
func (msg MsgNewOrders) GetSignBytes() []byte
GetSignBytes : encodes the message for signing
func (MsgNewOrders) GetSigners ¶
func (msg MsgNewOrders) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgNewOrders) ValidateBasic ¶
func (msg MsgNewOrders) ValidateBasic() sdk.Error
ValidateBasic : Implements Msg.
type Order ¶
type Order struct { TxHash string `json:"txhash"` // txHash of the place order tx OrderID string `json:"order_id"` // order id Sender sdk.AccAddress `json:"sender"` // order maker address Product string `json:"product"` // product for trading pair Side string `json:"side"` // BUY/SELL Price sdk.Dec `json:"price"` // price of the order Quantity sdk.Dec `json:"quantity"` // quantity of the order Status int64 `json:"status"` // order status, see OrderStatusXXX FilledAvgPrice sdk.Dec `json:"filled_avg_price"` // filled average price RemainQuantity sdk.Dec `json:"remain_quantity"` // Remaining quantity of the order RemainLocked sdk.Dec `json:"remain_locked"` // Remaining locked quantity of token Timestamp int64 `json:"timestamp"` // created timestamp OrderExpireBlocks int64 `json:"order_expire_blocks"` FeePerBlock sdk.SysCoin `json:"fee_per_block"` ExtraInfo string `json:"extra_info"` // extra info of order in json format }
nolint
func NewOrder ¶
func NewOrder(txHash string, sender sdk.AccAddress, product, side string, price, quantity sdk.Dec, timestamp int64, orderExpireBlocks int64, feePerBlock sdk.SysCoin) *Order
nolint
func (*Order) GetExtraInfoWithKey ¶
nolint
func (*Order) NeedLockCoins ¶
NeedLockCoins : when place a new order, we should lock the coins of sender
func (*Order) NeedUnlockCoins ¶
NeedUnlockCoins : when order be cancelled/expired, we should unlock the coins of sender
func (*Order) RecordOrderCancelFee ¶
nolint
func (*Order) RecordOrderDealFee ¶
RecordOrderDealFee : An order may have several deals
func (*Order) RecordOrderReceiveFee ¶
nolint
type OrderItem ¶
type OrderItem struct { Product string `json:"product"` // product for trading pair in full name of the tokens Side string `json:"side"` // BUY/SELL Price sdk.Dec `json:"price"` // price of the order Quantity sdk.Dec `json:"quantity"` // quantity of the order }
nolint
type OrderResult ¶
type OrderResult struct { Error error `json:"error"` Message string `json:"msg"` // order return error message OrderID string `json:"orderid"` // order return orderid }
nolint
type OrderStatus ¶
type OrderStatus int
nolint
const ( Open OrderStatus = iota Filled Cancelled Expired PartialFilledCancelled PartialFilledExpired )
nolint
func (OrderStatus) String ¶
func (p OrderStatus) String() string
type Params ¶
type Params struct { OrderExpireBlocks int64 `json:"order_expire_blocks"` MaxDealsPerBlock int64 `json:"max_deals_per_block"` FeePerBlock sdk.SysCoin `json:"fee_per_block"` TradeFeeRate sdk.Dec `json:"trade_fee_rate"` NewOrderMsgGasUnit uint64 `json:"new_order_msg_gas_unit"` CancelOrderMsgGasUnit uint64 `json:"cancel_order_msg_gas_unit"` }
nolint : order parameters
func DefaultTestParams ¶
func DefaultTestParams() Params
func (*Params) ParamSetPairs ¶
func (p *Params) ParamSetPairs() params.ParamSetPairs
ParamSetPairs implements the ParamSet interface and returns all the key/value pairs pairs of auth module's parameters. nolint
type ProductLock ¶
type ProductLock struct { BlockHeight int64 Price sdk.Dec Quantity sdk.Dec BuyExecuted sdk.Dec SellExecuted sdk.Dec }
nolint