Versions in this module Expand all Collapse all v1 v1.1.0 Jul 26, 2023 Changes in this version + const AccountChannelPrefix + const EventCancelOrder + const EventCloseMarket + const EventConfirmTransaction + const EventNewOrder + const EventOpenMarket + const EventRestartEngine + const HYDRO_ENGINE_EVENTS_QUEUE_KEY + const HYDRO_WATCHER_BLOCK_NUMBER_CACHE_KEY + const HYDRO_WEBSOCKET_MESSAGES_QUEUE_KEY + const MarketChannelPrefix + const ORDER_CANCELED + const ORDER_FULL_FILLED + const ORDER_PARTIAL_FILLED + const ORDER_PENDING + const STATUS_FAILED + const STATUS_PENDING + const STATUS_SUCCESSFUL + const WsTypeLockedBalanceChange + const WsTypeNewMarketTrade + const WsTypeOrderChange + const WsTypeTradeChange + var EXIT = errors.New("EXIT") + var KVStoreEmpty = errors.New("KVStoreEmpty") + func GetAccountChannelID(address string) string + func GetMarketChannelID(marketID string) string + func GetMarketOrderbookSnapshotV2Key(marketID string) string + func TakerOrderShouldBeRemoved(taker *MemoryOrder) bool + type CancelOrderEvent struct + ID string + Price string + Side string + type ConfirmTransactionEvent struct + Hash string + Status string + Timestamp uint64 + type Event struct + MarketID string + Type string + type IKVStore interface + Get func(key string) (string, error) + Set func(key string, value string, expire time.Duration) error + func InitKVStore(config interface{}) (store IKVStore, err error) + type IOrderBook interface + CanMatch func(*MemoryOrder) bool + ChangeOrder func(*MemoryOrder, decimal.Decimal) + ExecuteMatch func(*MemoryOrder, int) *MatchResult + InsertOrder func(*MemoryOrder) + MatchOrder func(*MemoryOrder, int) *MatchResult + RemoveOrder func(*MemoryOrder) + SnapshotV2 func() *SnapshotV2 + UsePlugin func(plugin OrderbookPlugin) + type IQueue interface + Pop func() ([]byte, error) + Push func([]byte) error + func InitQueue(config interface{}) (queue IQueue, err error) + type MatchItem struct + MakerOrder *MemoryOrder + MakerOrderIsDone bool + MatchShouldBeCanceled bool + MatchedAmount decimal.Decimal + type MatchResult struct + MatchItems []*MatchItem + OrderBookActivities []WebSocketMessage + TakerOrder *MemoryOrder + TakerOrderIsDone bool + TakerOrderLeftAmount decimal.Decimal + func (matchResult *MatchResult) BaseTokenTotalMatchedAmtWithoutCanceledMatch() decimal.Decimal + func (matchResult *MatchResult) MakerTradeFeeInQuoteToken() (sum decimal.Decimal) + func (matchResult *MatchResult) QuoteTokenTotalMatchedAmt() decimal.Decimal + func (matchResult *MatchResult) SumOfGasOfMakerOrders() decimal.Decimal + func (matchResult *MatchResult) TakerTradeFeeInQuoteToken() decimal.Decimal + func (matchResult MatchResult) ExistMatchToBeExecuted() bool + type MemoryOrder struct + Amount decimal.Decimal + GasFeeAmount decimal.Decimal + ID string + MakerFeeRate decimal.Decimal + MarketID string + Price decimal.Decimal + Side string + TakerFeeRate decimal.Decimal + Trader string + Type string + func (order *MemoryOrder) BaseTokenSymbol() string + func (order *MemoryOrder) QuoteTokenSymbol() string + type MockKVStore struct + func (m *MockKVStore) Get(key string) (string, error) + func (m *MockKVStore) Set(key string, value string, expire time.Duration) error + type MockQueue struct + Buffers [][]byte + func (m *MockQueue) Pop() ([]byte, error) + func (m *MockQueue) Push(bts []byte) error + func (m *MockQueue) ResetBuffer() + type NewOrderEvent struct + Order string + type Orderbook struct + Sequence uint64 + func NewOrderbook(market string) *Orderbook + func (book *Orderbook) CanMatch(order *MemoryOrder) bool + func (book *Orderbook) ChangeOrder(order *MemoryOrder, changeAmount decimal.Decimal) *OrderbookEvent + func (book *Orderbook) ExecuteMatch(takerOrder *MemoryOrder, marketAmountDecimals int) *MatchResult + func (book *Orderbook) GetOrder(id string, side string, price decimal.Decimal) (*MemoryOrder, bool) + func (book *Orderbook) InsertOrder(order *MemoryOrder) *OrderbookEvent + func (book *Orderbook) MatchOrder(takerOrder *MemoryOrder, marketAmountDecimals int) *MatchResult + func (book *Orderbook) MaxBid() *decimal.Decimal + func (book *Orderbook) MinAsk() *decimal.Decimal + func (book *Orderbook) RemoveOrder(order *MemoryOrder) *OrderbookEvent + func (book *Orderbook) RunPlugins(event *OrderbookEvent) + func (book *Orderbook) SnapshotV2() *SnapshotV2 + func (book *Orderbook) UsePlugin(plugin OrderbookPlugin) + type OrderbookEvent struct + Amount decimal.Decimal + OrderID string + Price decimal.Decimal + Side string + type OrderbookPlugin func(event *OrderbookEvent) + type RedisKVStore struct + func (queue *RedisKVStore) Init(config *RedisKVStoreConfig) error + func (queue RedisKVStore) Get(key string) (string, error) + func (queue RedisKVStore) Set(key, value string, expire time.Duration) error + type RedisKVStoreConfig struct + Client *redis.Client + Ctx context.Context + type RedisQueue struct + func (queue *RedisQueue) Init(config *RedisQueueConfig) error + func (queue *RedisQueue) Pop() ([]byte, error) + func (queue *RedisQueue) Push(data []byte) error + type RedisQueueConfig struct + Client *redis.Client + Ctx context.Context + Name string + type SnapshotV2 struct + Asks [][2]string + Bids [][2]string + Sequence uint64 + type WebSocketMessage struct + ChannelID string + Payload interface{} + func MessagesForUpdateOrder(order *MemoryOrder) []WebSocketMessage + func OrderBookChangeMessage(marketID string, sequence uint64, side string, price, amount decimal.Decimal) WebSocketMessage + type WebsocketLockedBalanceChangePayload struct + Balance decimal.Decimal + Symbol string + Type string + type WebsocketMarketNewMarketTradePayload struct + Trade interface{} + Type string + type WebsocketMarketOrderChangePayload struct + Amount string + Price string + Sequence uint64 + Side string + type WebsocketOrderChangePayload struct + Order interface{} + Type string + type WebsocketTradeChangePayload struct + Trade interface{} + Type string