Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Balance ¶
type Balance struct { ID bson.ObjectId `json:"id" bson:"_id"` Address string `json:"address" bson:"address"` Tokens map[string]TokenBalance `json:"tokens" bson:"tokens"` CreatedAt time.Time `json:"createdAt" bson:"createdAt"` UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` }
Balance holds both the address and the private key of an ethereum account
func NewBalance ¶
NewBalance returns a new wallet object corresponding to a random private key
type Order ¶
type Order struct { ID bson.ObjectId `json:"id" bson:"_id" redis:"_id"` BuyToken string `json:"buyToken" bson:"buyToken" redis:"buyToken"` SellToken string `json:"sellToken" bson:"sellToken" redis:"sellToken"` BuyTokenAddress string `json:"buyTokenAddress" bson:"buyTokenAddress" redis:"buyTokenAddress"` SellTokenAddress string `json:"sellTokenAddress" bson:"sellTokenAddress" redis:"sellTokenAddress"` FilledAmount int64 `json:"filledAmount" bson:"filledAmount" redis:"filledAmount"` Amount int64 `json:"amount" bson:"amount" redis:"amount"` Price int64 `json:"price" bson:"price" redis:"price"` Fee int64 `json:"fee" bson:"fee" redis:"fee"` Type OrderType `json:"type" bson:"type" redis:"type"` AmountBuy int64 `json:"amountBuy" bson:"amountBuy" redis:"amountBuy"` AmountSell int64 `json:"amountSell" bson:"amountSell" redis:"amountSell"` ExchangeAddress string `json:"exchangeAddress" bson:"exchangeAddress" redis:"exchangeAddress"` Status OrderStatus `json:"status" bson:"status" redis:"status"` Signature *Signature `json:"signature,omitempty" bson:"signature" redis:"signature"` PairID bson.ObjectId `json:"pairID" bson:"pairID" redis:"pairID"` PairName string `json:"pairName" bson:"pairName" redis:"pairName"` Hash string `json:"hash" bson:"hash" redis:"hash"` UserAddress string `json:"userAddress" bson:"userAddress" redis:"userAddress"` OrderBook *OrderSubDoc `json:"orderBook" bson:"orderBook"` CreatedAt time.Time `json:"createdAt" bson:"createdAt" redis:"createdAt"` UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt" redis:"updatedAt"` }
func (*Order) GetKVPrefix ¶
func (*Order) GetOBMatchKey ¶
type OrderRequest ¶
type OrderRequest struct { Type int `json:"type" bson:"type"` Amount float64 `json:"amount"` Price float64 `json:"price"` Fee float64 `json:"fee"` // Signature string `json:"signature"` PairID string `json:"pairID"` PairName string `json:"pairName"` UserAddress string `json:"userAddress"` }
func (*OrderRequest) ToOrder ¶
func (m *OrderRequest) ToOrder() (order *Order, err error)
ToOrder converts the OrderRequest to Order
func (OrderRequest) Validate ¶
func (m OrderRequest) Validate() error
Validate validates the OrderRequest fields.
type OrderStatus ¶
type OrderStatus int
const ( NEW OrderStatus = iota OPEN MATCHED SUBMITTED PARTIAL_FILLED FILLED CANCELLED PENDING INVALID_ORDER ERROR )
func (*OrderStatus) MarshalJSON ¶
func (orderStatus *OrderStatus) MarshalJSON() ([]byte, error)
func (*OrderStatus) UnmarshalJSON ¶
func (orderStatus *OrderStatus) UnmarshalJSON(data []byte) error
type OrderSubDoc ¶
type OrderType ¶
type OrderType int
const ( BUY OrderType SELL )
func (*OrderType) MarshalJSON ¶
func (*OrderType) UnmarshalJSON ¶
type Pair ¶
type Pair struct { ID bson.ObjectId `json:"id" bson:"_id"` Name string `json:"name" bson:"name"` BuyToken bson.ObjectId `json:"buyToken" bson:"buyToken"` BuyTokenSymbol string `json:"buyTokenSymbol" bson:"buyTokenSymbol"` BuyTokenAddress string `json:"buyTokenAddress" bson:"buyTokenAddress"` SellToken bson.ObjectId `json:"sellToken" bson:"sellToken"` SellTokenAddress string `json:"sellTokenAddress" bson:"sellTokenAddress"` SellTokenSymbol string `json:"sellTokenSymbol" bson:"sellTokenSymbol"` MakerFee float64 `json:"makerFee" bson:"makerFee"` TakerFee float64 `json:"takerFee" bson:"takerFee"` CreatedAt time.Time `json:"createdAt" bson:"createdAt"` UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` }
func (*Pair) GetOrderBookKeys ¶
type Signature ¶
asdfasdf
func NewSignature ¶
func Sign ¶
Sign calculates the EDCSA signature corresponding of a hashed message from a given private key
func SignHash ¶
SignHash also calculates the EDCSA signature of a message but adds an "Ethereum Signed Message" prefix https://github.com/ethereum/EIPs/issues/191
func (*Signature) MarshalSignature ¶
type Token ¶
type Token struct { ID bson.ObjectId `json:"id" bson:"_id"` Name string `json:"name" bson:"name"` Symbol string `json:"symbol" bson:"symbol"` Image Image `json:"image" bson:"image"` ContractAddress string `json:"contractAddress" bson:"contractAddress"` Decimal int `json:"decimal" bson:"decimal"` Active bool `json:"active" bson:"active"` CreatedAt time.Time `json:"createdAt" bson:"createdAt"` UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` }
type TokenBalance ¶
type Trade ¶
type Trade struct { ID bson.ObjectId `json:"id,omitempty" bson:"_id"` OrderHash string `json:"orderHash" bson:"orderHash"` Amount int64 `json:"amount" bson:"amount"` Price int64 `json:"price" bson:"price"` Type OrderType `json:"type" bson:"type"` TradeNonce int64 `json:"tradeNonce" bson:"tradeNonce"` Taker string `json:"taker" bson:"taker"` Maker string `json:"maker" bson:"maker"` TakerOrderID bson.ObjectId `json:"takerOrderId" bson:"takerOrderId"` MakerOrderID bson.ObjectId `json:"makerOrderId" bson:"makerOrderId"` Signature *Signature `json:"signature" bson:"signature"` Hash string `json:"hash" bson:"hash"` PairName string `json:"pairName" bson:"pairName"` CreatedAt time.Time `json:"createdAt" bson:"createdAt" redis:"createdAt"` UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt" redis:"updatedAt"` }
Trade struct holds arguments corresponding to a "Taker Order" To be valid an accept by the matching engine (and ultimately the exchange smart-contract), the trade signature must be made from the trader Maker account
type UserAddress ¶
type UserAddress struct { ID bson.ObjectId `json:"id" bson:"_id"` Address string `json:"address" bson:"address"` IsBlocked bool `json:"isBlocked" bson:"isBlocked"` CreatedAt time.Time `json:"createdAt" bson:"createdAt"` UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` }
Address holds both the address and the private key of an ethereum account
func (UserAddress) Validate ¶
func (ua UserAddress) Validate() error