Documentation ¶
Index ¶
- Constants
- func DefaultTestBalance() int64
- func DefaultTestLockedBalance() int64
- func DefaultTestPendingBalance() int64
- type Account
- type AccountBSONUpdate
- type AccountRecord
- type AddressAssociation
- type AddressAssociationRecord
- type AddressAssociationWebsocketPayload
- type AssetCode
- type AssociationTransaction
- type AssociationTransactionResponse
- type Chain
- type DepositTransaction
- type EngineResponse
- type GenerateAddressResponse
- type Image
- type KeyValue
- type Matches
- func (m *Matches) AppendMatch(mo *Order, t *Trade)
- func (m *Matches) Length() int
- func (m *Matches) NthMatch(i int) *Matches
- func (m *Matches) PairCode() (string, error)
- func (m *Matches) String() string
- func (m *Matches) Taker() common.Address
- func (m *Matches) TakerOrderHash() common.Hash
- func (m *Matches) TradeAmounts() []*big.Int
- func (m *Matches) Validate() error
- type NativeCurrency
- type NewOrderPayload
- func (p *NewOrderPayload) ComputeHash() common.Hash
- func (p *NewOrderPayload) EncodedSide() *big.Int
- func (p NewOrderPayload) MarshalJSON() ([]byte, error)
- func (p *NewOrderPayload) ToOrder() (o *Order, err error)
- func (p *NewOrderPayload) UnmarshalJSON(b []byte) error
- func (p NewOrderPayload) Validate() error
- func (p *NewOrderPayload) VerifySignature() (bool, error)
- type OHLCVParams
- type OperatorMessage
- type Order
- func (o *Order) BaseTokenSymbol() string
- func (o *Order) BuyAmount(pairMultiplier *big.Int) *big.Int
- func (o *Order) BuyToken() common.Address
- func (o *Order) BuyTokenSymbol() string
- func (o *Order) ComputeHash() common.Hash
- func (o *Order) EncodedSide() *big.Int
- func (o *Order) GetBSON() (interface{}, error)
- func (o *Order) MarshalJSON() ([]byte, error)
- func (o *Order) Pair() (*Pair, error)
- func (o *Order) PairCode() (string, error)
- func (o *Order) Process(p *Pair) error
- func (o *Order) QuoteAmount(p *Pair) *big.Int
- func (o *Order) QuoteTokenSymbol() string
- func (o *Order) RemainingAmount() *big.Int
- func (o *Order) RemainingSellAmount(p *Pair) *big.Int
- func (o *Order) RequiredSellAmount(p *Pair) *big.Int
- func (o *Order) SellAmount(p *Pair) *big.Int
- func (o *Order) SellToken() common.Address
- func (o *Order) SellTokenSymbol() string
- func (o *Order) SetBSON(raw bson.Raw) error
- func (o *Order) Sign(w *Wallet) error
- func (o *Order) String() string
- func (o *Order) TotalRequiredSellAmount(p *Pair) *big.Int
- func (o *Order) UnmarshalJSON(b []byte) error
- func (o *Order) Validate() error
- func (o *Order) VerifySignature() (bool, error)
- type OrderBSONUpdate
- type OrderBook
- type OrderCancel
- func (oc *OrderCancel) ComputeHash() common.Hash
- func (oc *OrderCancel) GetSenderAddress() (common.Address, error)
- func (oc *OrderCancel) MarshalJSON() ([]byte, error)
- func (oc *OrderCancel) Sign(w *Wallet) error
- func (oc *OrderCancel) String() string
- func (oc *OrderCancel) UnmarshalJSON(b []byte) error
- func (oc *OrderCancel) VerifySignature(o *Order) (bool, error)
- type OrderData
- func (o *OrderData) AddressCode() string
- func (o *OrderData) ConvertedVolume(p *Pair, exchangeRate float64) float64
- func (o *OrderData) GetBSON() (interface{}, error)
- func (o *OrderData) MarshalJSON() ([]byte, error)
- func (o *OrderData) SetBSON(raw bson.Raw) error
- func (o *OrderData) UnmarshalJSON(b []byte) error
- type OrderMatchedPayload
- type OrderPendingPayload
- type OrderRecord
- type OrderSuccessPayload
- type Pair
- func (p *Pair) AddressCode() string
- func (p *Pair) BaseTokenMultiplier() *big.Int
- func (p *Pair) Code() string
- func (p *Pair) DecimalsMultiplier() *big.Int
- func (p *Pair) GetBSON() (interface{}, error)
- func (p *Pair) GetKVPrefix() string
- func (p *Pair) GetOrderBookKeys() (sell, buy string)
- func (p *Pair) MarshalJSON() ([]byte, error)
- func (p *Pair) MinQuoteAmount() *big.Int
- func (p *Pair) Name() string
- func (p *Pair) PairMultiplier() *big.Int
- func (p *Pair) ParseAmount(a *big.Int) float64
- func (p *Pair) ParsePricePoint(pp *big.Int) float64
- func (p *Pair) PricepointMultiplier() *big.Int
- func (p *Pair) QuoteTokenMultiplier() *big.Int
- func (p *Pair) SetBSON(raw bson.Raw) error
- func (p *Pair) UnmarshalJSON(b []byte) error
- func (p Pair) Validate() error
- func (p Pair) ValidateAddresses() error
- type PairAPIData
- type PairAddresses
- type PairAddressesRecord
- type PairData
- type PairID
- type PairRecord
- type Params
- type PendingTradeBatch
- type PriceBoardData
- type RawOrderBook
- type Signature
- type SignatureRecord
- type SimplifiedPairAPIData
- type SubscriptionEvent
- type SubscriptionPayload
- type Tick
- func (t *Tick) AddressCode() string
- func (t *Tick) AveragePrice() *big.Int
- func (t *Tick) ConvertedVolume(p *Pair, exchangeRate float64) float64
- func (t *Tick) GetBSON() (interface{}, error)
- func (t *Tick) MarshalJSON() ([]byte, error)
- func (t *Tick) SetBSON(raw bson.Raw) error
- func (t *Tick) UnmarshalJSON(b []byte) error
- type Token
- type TokenBalance
- type TokenBalanceRecord
- type TokenRecord
- type Trade
- func (t *Trade) ComputeHash() common.Hash
- func (t *Trade) GetBSON() (interface{}, error)
- func (t *Trade) MarshalJSON() ([]byte, error)
- func (t *Trade) Pair() (*Pair, error)
- func (t *Trade) QuoteAmount(p *Pair) *big.Int
- func (t *Trade) SetBSON(raw bson.Raw) error
- func (t *Trade) UnmarshalJSON(b []byte) error
- func (t *Trade) Validate() error
- type TradeBSONUpdate
- type TradeRecord
- type Wallet
- func (w *Wallet) GetAddress() string
- func (w *Wallet) GetBSON() (interface{}, error)
- func (w *Wallet) GetPrivateKey() string
- func (w *Wallet) SetBSON(raw bson.Raw) error
- func (w *Wallet) SignHash(h common.Hash) (*Signature, error)
- func (w *Wallet) SignOrder(o *Order) error
- func (w *Wallet) Validate() error
- type WalletRecord
- type WebsocketEvent
- type WebsocketMessage
Constants ¶
const ( AssetCodeETH AssetCode = "ETH" AssetCodeBTC AssetCode = "BTC" CreateOffer = "CreateOffer" CreateAccount = "CreateAccount" RemoveSigner = "RemoveSigner" )
const ( PENDING = "PENDING" SUCCESS = "SUCCESS" FAILED = "FAILED" )
const ( BUY = "BUY" SELL = "SELL" MarketOrder = "MO" LimitOrder = "LO" StopOrder = "SO" )
const ( SUBSCRIBE SubscriptionEvent = "SUBSCRIBE" UNSUBSCRIBE SubscriptionEvent = "UNSUBSCRIBE" Fetch SubscriptionEvent = "fetch" UPDATE SubscriptionEvent = "UPDATE" ERROR SubscriptionEvent = "ERROR" SUCCESS_EVENT SubscriptionEvent = "SUCCESS" INIT SubscriptionEvent = "INIT" CANCEL SubscriptionEvent = "CANCEL" ORDER_ADDED = "ORDER_ADDED" ORDER_FILLED = "ORDER_FILLED" ORDER_PARTIALLY_FILLED = "ORDER_PARTIALLY_FILLED" ORDER_CANCELLED = "ORDER_CANCELLED" UPDATE_STATUS = "UPDATE" ERROR_STATUS = "ERROR" FILLED = "FILLED" CANCELLED = "CANCELLED" TRADES_CANCELLED = "TRADES_CANCELLED" TRADE_ERROR = "TRADE_ERROR" TRADE_TX_PENDING = "TRADE_TX_PENDING" TRADE_TX_SUCCESS = "TRADE_TX_SUCCESS" TRADE_TX_ERROR = "TRADE_TX_ERROR" TRADE_INVALID = "TRADE_INVALID" // channel TradeChannel = "trades" OrderbookChannel = "orderbook" OrderChannel = "orders" OHLCVChannel = "ohlcv" )
Enum members for SubscriptionEvent
Variables ¶
This section is empty.
Functions ¶
func DefaultTestBalance ¶
func DefaultTestBalance() int64
DefaultTestBalance returns the default balance Only for testing/mock purpose
func DefaultTestLockedBalance ¶
func DefaultTestLockedBalance() int64
DefaultTestBalance returns the default locked balance Only for testing/mock purpose
func DefaultTestPendingBalance ¶
func DefaultTestPendingBalance() int64
DefaultTestBalance returns the default pending balance Only for testing/mock purpose
Types ¶
type Account ¶
type Account struct { ID bson.ObjectId `json:"-" bson:"_id"` Address common.Address `json:"address" bson:"address"` TokenBalances map[common.Address]*TokenBalance `json:"tokenBalances" bson:"tokenBalances"` IsBlocked bool `json:"isBlocked" bson:"isBlocked"` CreatedAt time.Time `json:"createdAt" bson:"createdAt"` UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` }
Account corresponds to a single Ethereum address. It contains a list of token balances for that address
func (*Account) MarshalJSON ¶
MarshalJSON implements the json.Marshal interface
func (*Account) UnmarshalJSON ¶
type AccountBSONUpdate ¶
type AccountBSONUpdate struct {
*Account
}
func (*AccountBSONUpdate) GetBSON ¶
func (a *AccountBSONUpdate) GetBSON() (interface{}, error)
type AccountRecord ¶
type AccountRecord struct { ID bson.ObjectId `json:"id" bson:"_id"` Address string `json:"address" bson:"address"` TokenBalances map[string]TokenBalanceRecord `json:"tokenBalances" bson:"tokenBalances"` IsBlocked bool `json:"isBlocked" bson:"isBlocked"` CreatedAt time.Time `json:"createdAt" bson:"createdAt"` UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` }
AccountRecord corresponds to what is stored in the DB. big.Ints are encoded as strings
type AddressAssociation ¶
type AddressAssociation struct { // Chain is the name of the payment origin chain Chain Chain `json:"chain"` // BIP-44 AddressIndex uint64 `json:"addressIndex"` Address common.Address `json:"address"` AssociatedAddress common.Address `json:"associatedAddress"` TomochainPublicKey common.Address `json:"tomochainPublicKey"` CreatedAt time.Time `json:"createdAt"` }
type AddressAssociationRecord ¶
type AddressAssociationRecord struct { ID bson.ObjectId `json:"id" bson:"_id"` AddressIndex uint64 `json:"addressIndex" bson:"addressIndex"` Chain Chain `json:"chain" bson:"chain"` Address string `json:"address" bson:"address"` Status string `json:"status" bson:"status"` AssociatedAddress string `json:"associatedAddress" bson:"associatedAddress"` // this is the last transaction envelopes, should move to seperated collection // We also have it from blockchain transactions TxEnvelopes []string `json:"txEnvelopes" bson:"txEnvelopes"` PairName string `json:"pairName" bson:"pairName"` BaseTokenAddress string `json:"baseTokenAddress" bson:"baseTokenAddress"` QuoteTokenAddress string `json:"quoteTokenAddress" bson:"quoteTokenAddress"` CreatedAt time.Time `json:"createdAt" bson:"createdAt"` UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` }
AddressAssociationRecord is the object that will be saved in the database
func (*AddressAssociationRecord) GetJSON ¶
func (aar *AddressAssociationRecord) GetJSON() (*AddressAssociation, error)
type AddressAssociationWebsocketPayload ¶
type AddressAssociationWebsocketPayload struct { Chain Chain `json:"chain"` AssociatedAddress common.Address `json:"associatedAddress"` PairAddresses *PairAddresses `json:"pairAddresses"` }
type AssociationTransaction ¶
type AssociationTransaction struct { Source string `json:"source"` Signature []byte `json:"signature"` Hash []byte `json:"hash"` TransactionType string `json:"transactionType"` Params []string `json:"params"` }
func (*AssociationTransaction) ComputeHash ¶
func (o *AssociationTransaction) ComputeHash() []byte
ComputeHash calculates the orderRequest hash
func (*AssociationTransaction) GetJSON ¶
func (o *AssociationTransaction) GetJSON() *AssociationTransactionResponse
type DepositTransaction ¶
type DepositTransaction struct { Chain Chain TransactionID string AssetCode AssetCode PairName string // CRITICAL REQUIREMENT: Amount in the base unit of currency. // For 10 satoshi this should be equal 0.0000001 // For 1 BTC this should be equal 1.0000000 // For 1 Finney this should be equal 0.0010000 // For 1 ETH this should be equal 1.0000000 // Currently, the length of Amount string shouldn't be longer than 17 characters. Amount string AssociatedAddress string }
type EngineResponse ¶
type EngineResponse struct { Status string `json:"fillStatus,omitempty"` Order *Order `json:"order,omitempty"` Matches *Matches `json:"matches,omitempty"` RecoveredOrders *[]*Order `json:"recoveredOrders,omitempty"` InvalidatedOrders *[]*Order `json:"invalidatedOrders,omitempty"` CancelledTrades *[]*Trade `json:"cancelledTrades,omitempty"` }
func (*EngineResponse) AppendMatch ¶
func (r *EngineResponse) AppendMatch(mo *Order, t *Trade)
func (*EngineResponse) AppendMatches ¶
func (r *EngineResponse) AppendMatches(mo []*Order, t []*Trade)
type GenerateAddressResponse ¶
type Image ¶
type Image struct { URL string `json:"url" bson:"url"` Meta map[string]interface{} `json:"meta" bson:"meta"` }
Image is a sub document used to store data related to images
type KeyValue ¶
type KeyValue struct { Key string `json:"key" bson"key"` Value interface{} `json:"value" bson "value"` }
type Matches ¶
type Matches struct { MakerOrders []*Order `json:"makerOrders"` TakerOrder *Order `json:"takerOrder"` Trades []*Trade `json:"trades"` }
func NewMatches ¶
func (*Matches) AppendMatch ¶
func (*Matches) TakerOrderHash ¶
func (*Matches) TradeAmounts ¶
type NativeCurrency ¶
type NativeCurrency struct { Address common.Address `json:"address" bson:"address"` Symbol string `json:"symbol" bson:"symbol"` Decimals int `json:"decimals" bson:"decimals"` }
func GetNativeCurrency ¶
func GetNativeCurrency() NativeCurrency
type NewOrderPayload ¶
type NewOrderPayload struct { PairName string `json:"pairName"` ExchangeAddress common.Address `json:"exchangeAddress"` UserAddress common.Address `json:"userAddress"` BaseToken common.Address `json:"baseToken"` QuoteToken common.Address `json:"quoteToken"` Side string `json:"side"` Amount *big.Int `json:"amount"` PricePoint *big.Int `json:"pricepoint"` TakeFee *big.Int `json:"takeFee"` MakeFee *big.Int `json:"makeFee"` Nonce *big.Int `json:"nonce" bson:"nonce"` Signature *Signature `json:"signature"` Hash common.Hash `json:"hash"` }
NewOrderPayload is the struct in which the order request sent by the user is populated
func (*NewOrderPayload) ComputeHash ¶
func (p *NewOrderPayload) ComputeHash() common.Hash
ComputeHash calculates the orderRequest hash
func (*NewOrderPayload) EncodedSide ¶
func (p *NewOrderPayload) EncodedSide() *big.Int
func (NewOrderPayload) MarshalJSON ¶
func (p NewOrderPayload) MarshalJSON() ([]byte, error)
func (*NewOrderPayload) ToOrder ¶
func (p *NewOrderPayload) ToOrder() (o *Order, err error)
ToOrder converts the NewOrderPayload to Order
func (*NewOrderPayload) UnmarshalJSON ¶
func (p *NewOrderPayload) UnmarshalJSON(b []byte) error
func (NewOrderPayload) Validate ¶
func (p NewOrderPayload) Validate() error
Validate validates the NewOrderPayload fields.
func (*NewOrderPayload) VerifySignature ¶
func (p *NewOrderPayload) VerifySignature() (bool, error)
VerifySignature checks that the orderRequest signature corresponds to the address in the userAddress field
type OHLCVParams ¶
type OHLCVParams struct { Pair []PairAddresses `json:"pair"` From int64 `json:"from"` To int64 `json:"to"` Duration int64 `json:"duration"` Units string `json:"units"` }
type OperatorMessage ¶
func (*OperatorMessage) String ¶
func (m *OperatorMessage) String() string
type Order ¶
type Order struct { ID bson.ObjectId `json:"id" bson:"_id"` UserAddress common.Address `json:"userAddress" bson:"userAddress"` ExchangeAddress common.Address `json:"exchangeAddress" bson:"exchangeAddress"` BaseToken common.Address `json:"baseToken" bson:"baseToken"` QuoteToken common.Address `json:"quoteToken" bson:"quoteToken"` Status string `json:"status" bson:"status"` Side string `json:"side" bson:"side"` Type string `json:"type" bson:"type"` Hash common.Hash `json:"hash" bson:"hash"` Signature *Signature `json:"signature,omitempty" bson:"signature"` PricePoint *big.Int `json:"pricepoint" bson:"pricepoint"` Amount *big.Int `json:"amount" bson:"amount"` FilledAmount *big.Int `json:"filledAmount" bson:"filledAmount"` Nonce *big.Int `json:"nonce" bson:"nonce"` MakeFee *big.Int `json:"makeFee" bson:"makeFee"` TakeFee *big.Int `json:"takeFee" bson:"takeFee"` PairName string `json:"pairName" bson:"pairName"` CreatedAt time.Time `json:"createdAt" bson:"createdAt"` UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` }
Order contains the data related to an order sent by the user
func (*Order) BaseTokenSymbol ¶
func (*Order) BuyTokenSymbol ¶
func (*Order) ComputeHash ¶
ComputeHash calculates the orderRequest hash
func (*Order) MarshalJSON ¶
MarshalJSON implements the json.Marshal interface
func (*Order) QuoteTokenSymbol ¶
func (*Order) RemainingAmount ¶
func (*Order) SellAmount ¶
SellAmount If order is a "BUY", then sellToken = quoteToken
func (*Order) SellTokenSymbol ¶
func (*Order) Sign ¶
Sign first calculates the order hash, then computes a signature of this hash with the given wallet
func (*Order) UnmarshalJSON ¶
UnmarshalJSON : write custom logic to unmarshal bytes to Order
func (*Order) Validate ¶
TODO: Verify userAddress, baseToken, quoteToken, etc. conditions are working
func (*Order) VerifySignature ¶
VerifySignature checks that the orderRequest signature corresponds to the address in the userAddress field
type OrderBSONUpdate ¶
type OrderBSONUpdate struct {
*Order
}
func (OrderBSONUpdate) GetBSON ¶
func (o OrderBSONUpdate) GetBSON() (interface{}, error)
type OrderCancel ¶
type OrderCancel struct { OrderHash common.Hash `json:"orderHash"` Hash common.Hash `json:"hash"` Signature *Signature `json:"signature"` }
OrderCancel is a group of params used for canceling an order previously sent to the matching engine. The OrderId and OrderHash must correspond to the same order. To be valid and be able to be processed by the matching engine, the OrderCancel must include a signature by the Maker of the order corresponding to the OrderHash.
func NewOrderCancel ¶
func NewOrderCancel() *OrderCancel
NewOrderCancel returns a new empty OrderCancel object
func (*OrderCancel) ComputeHash ¶
func (oc *OrderCancel) ComputeHash() common.Hash
ComputeHash computes the hash of an order cancel message
func (*OrderCancel) GetSenderAddress ¶
func (oc *OrderCancel) GetSenderAddress() (common.Address, error)
func (*OrderCancel) MarshalJSON ¶
func (oc *OrderCancel) MarshalJSON() ([]byte, error)
MarshalJSON returns the json encoded byte array representing the OrderCancel struct
func (*OrderCancel) Sign ¶
func (oc *OrderCancel) Sign(w *Wallet) error
Sign first computes the order cancel hash, then signs and sets the signature
func (*OrderCancel) String ¶
func (oc *OrderCancel) String() string
func (*OrderCancel) UnmarshalJSON ¶
func (oc *OrderCancel) UnmarshalJSON(b []byte) error
UnmarshalJSON creates an OrderCancel object from a json byte string
func (*OrderCancel) VerifySignature ¶
func (oc *OrderCancel) VerifySignature(o *Order) (bool, error)
VerifySignature returns a true value if the OrderCancel object signature corresponds to the Maker of the given order
type OrderData ¶
type OrderData struct { Pair PairID `json:"id,omitempty" bson:"_id"` OrderVolume *big.Int `json:"orderVolume,omitempty" bson:"orderVolume"` OrderCount *big.Int `json:"orderCount,omitempty" bson:"orderCount"` BestPrice *big.Int `json:"bestPrice,omitempty" bson:"bestPrice"` }
func (*OrderData) AddressCode ¶
func (*OrderData) ConvertedVolume ¶
func (*OrderData) MarshalJSON ¶
func (*OrderData) UnmarshalJSON ¶
UnmarshalJSON creates a trade object from a json byte string
type OrderMatchedPayload ¶
type OrderMatchedPayload struct {
Matches *Matches `json:"matches"`
}
type OrderPendingPayload ¶
type OrderPendingPayload struct {
Matches *Matches `json:"matches"`
}
type OrderRecord ¶
type OrderRecord struct { ID bson.ObjectId `json:"id" bson:"_id"` UserAddress string `json:"userAddress" bson:"userAddress"` ExchangeAddress string `json:"exchangeAddress" bson:"exchangeAddress"` BaseToken string `json:"baseToken" bson:"baseToken"` QuoteToken string `json:"quoteToken" bson:"quoteToken"` Status string `json:"status" bson:"status"` Side string `json:"side" bson:"side"` Type string `json:"type" bson:"type"` Hash string `json:"hash" bson:"hash"` PricePoint string `json:"pricepoint" bson:"pricepoint"` Amount string `json:"amount" bson:"amount"` FilledAmount string `json:"filledAmount" bson:"filledAmount"` Nonce string `json:"nonce" bson:"nonce"` MakeFee string `json:"makeFee" bson:"makeFee"` TakeFee string `json:"takeFee" bson:"takeFee"` Signature *SignatureRecord `json:"signature,omitempty" bson:"signature"` PairName string `json:"pairName" bson:"pairName"` CreatedAt time.Time `json:"createdAt" bson:"createdAt"` UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` }
OrderRecord is the object that will be saved in the database
type OrderSuccessPayload ¶
type OrderSuccessPayload struct {
Matches *Matches `json:"matches"`
}
type Pair ¶
type Pair struct { ID bson.ObjectId `json:"-" bson:"_id"` BaseTokenSymbol string `json:"baseTokenSymbol,omitempty" bson:"baseTokenSymbol"` BaseTokenAddress common.Address `json:"baseTokenAddress,omitempty" bson:"baseTokenAddress"` BaseTokenDecimals int `json:"baseTokenDecimals,omitempty" bson:"baseTokenDecimals"` QuoteTokenSymbol string `json:"quoteTokenSymbol,omitempty" bson:"quoteTokenSymbol"` QuoteTokenAddress common.Address `json:"quoteTokenAddress,omitempty" bson:"quoteTokenAddress"` QuoteTokenDecimals int `json:"quoteTokenDecimals,omitempty" bson:"quoteTokenDecimals"` Listed bool `json:"listed,omitempty" bson:"listed"` Active bool `json:"active,omitempty" bson:"active"` Rank int `json:"rank,omitempty" bson:"rank"` MakeFee *big.Int `json:"makeFee,omitempty" bson:"makeFee"` TakeFee *big.Int `json:"takeFee,omitempty" bson:"takeFee"` CreatedAt time.Time `json:"-" bson:"createdAt"` UpdatedAt time.Time `json:"-" bson:"updatedAt"` }
Pair struct is used to model the pair data in the system and DB
func (*Pair) AddressCode ¶
func (*Pair) BaseTokenMultiplier ¶
func (*Pair) DecimalsMultiplier ¶
func (*Pair) GetKVPrefix ¶
func (*Pair) GetOrderBookKeys ¶
GetOrderBookKeys returns the orderbook price point keys for corresponding pair It is used to fetch the orderbook of a pair
func (*Pair) MarshalJSON ¶
func (*Pair) MinQuoteAmount ¶
func (*Pair) PairMultiplier ¶
func (*Pair) PricepointMultiplier ¶
func (*Pair) QuoteTokenMultiplier ¶
func (*Pair) UnmarshalJSON ¶
func (Pair) Validate ¶
Validate function is used to verify if an instance of struct satisfies all the conditions for a valid instance
func (Pair) ValidateAddresses ¶
type PairAPIData ¶
type PairAPIData struct { Pair PairID `json:"pair" bson:"_id"` Open float64 `json:"open" bson:"open"` High float64 `json:"high" bson:"high"` Low float64 `json:"low" bson:"low"` Close float64 `json:"close" bson:"close"` Volume float64 `json:"volume" bson:"volume"` Timestamp int `json:"timestamp" bson:"timestamp"` OrderVolume float64 `json:"orderVolume" bson:"orderVolume"` OrderCount int `json:"orderCount" bson:"orderCount"` TradeCount int `json:"tradeCount" bson:"tradeCount"` AverageOrderAmount float64 `json:"averageOrderAmount" bson:"averageOrderAmount"` AverageTradeAmount float64 `json:"averageTradeAmount" bson:"averageTradeAmount"` AskPrice float64 `json:"askPrice" bson:"askPrice"` BidPrice float64 `json:"bidPrice" bson:"bidPrice"` Price float64 `json:"price" bson:"price"` Rank int `json:"rank" bson:"rank"` }
type PairAddresses ¶
type PairAddressesRecord ¶
type PairData ¶
type PairData struct { Pair PairID `json:"pair,omitempty" bson:"_id"` Close *big.Int `json:"close,omitempty" bson:"close"` Count *big.Int `json:"count,omitempty" bson:"count"` High *big.Int `json:"high,omitempty" bson:"high"` Low *big.Int `json:"low,omitempty" bson:"low"` Open *big.Int `json:"open,omitempty" bson:"open"` Volume *big.Int `json:"volume,omitempty" bson:"volume"` Timestamp int64 `json:"timestamp,omitempty" bson:"timestamp"` OrderVolume *big.Int `json:"orderVolume,omitempty" bson:"orderVolume"` OrderCount *big.Int `json:"orderCount,omitempty" bson:"orderCount"` AverageOrderAmount *big.Int `json:"averageOrderAmount" bson:"averageOrderAmount"` AverageTradeAmount *big.Int `json:"averageTradeAmount" bson:"averageTradeAmount"` AskPrice *big.Int `json:"askPrice,omitempty" bson:"askPrice"` BidPrice *big.Int `json:"bidPrice,omitempty" bson:"bidPrice"` Price *big.Int `json:"price,omitempty" bson:"price"` Rank int `json"rank,omitempty" bson:"rank"` }
func (*PairData) AddressCode ¶
func (*PairData) MarshalJSON ¶
func (*PairData) ToAPIData ¶
func (p *PairData) ToAPIData(pair *Pair) *PairAPIData
func (*PairData) ToSimplifiedAPIData ¶
func (p *PairData) ToSimplifiedAPIData(pair *Pair) *SimplifiedPairAPIData
ToAPIData converts detailed data into public PairAPIData that contains
type PairID ¶
type PairID struct { PairName string `json:"pairName" bson:"pairName"` BaseToken common.Address `json:"baseToken" bson:"baseToken"` QuoteToken common.Address `json:"quoteToken" bson:"quoteToken"` }
PairID is the subdocument for aggregate grouping for OHLCV data
type PairRecord ¶
type PairRecord struct { ID bson.ObjectId `json:"id" bson:"_id"` BaseTokenSymbol string `json:"baseTokenSymbol" bson:"baseTokenSymbol"` BaseTokenAddress string `json:"baseTokenAddress" bson:"baseTokenAddress"` BaseTokenDecimals int `json:"baseTokenDecimals" bson:"baseTokenDecimals"` QuoteTokenSymbol string `json:"quoteTokenSymbol" bson:"quoteTokenSymbol"` QuoteTokenAddress string `json:"quoteTokenAddress" bson:"quoteTokenAddress"` QuoteTokenDecimals int `json:"quoteTokenDecimals" bson:"quoteTokenDecimals"` Active bool `json:"active" bson:"active"` Listed bool `json:"listed" bson:"listed"` MakeFee string `json:"makeFee" bson:"makeFee"` TakeFee string `json:"takeFee" bson:"takeFee"` Rank int `json:"rank" bson:"rank"` CreatedAt time.Time `json:"createdAt" bson:"createdAt"` UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` }
type Params ¶
type Params struct { From int64 `json:"from"` To int64 `json:"to"` Duration int64 `json:"duration"` Units string `json:"units"` PairID string `json:"pair"` }
Params is a sub document used to pass parameters in Subscription messages
type PendingTradeBatch ¶
type PendingTradeBatch struct {
Matches *Matches
}
type PriceBoardData ¶
type PriceBoardData struct { Ticks []*Tick `json:"ticks" bson:"ticks"` PriceUSD string `json:"usd" bson:"usd"` LastTradePrice string `json:"last_trade_price" bson:"last_trade_price"` }
Pair struct is used to model the pair data in the system and DB
type RawOrderBook ¶
type Signature ¶
Signature struct
func NewSignature ¶
NewSignature function decodes []byte to Signature type
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) GetRecord ¶
func (s *Signature) GetRecord() *SignatureRecord
func (*Signature) MarshalSignature ¶
MarshalSignature marshals the signature struct to []byte
type SignatureRecord ¶
type SimplifiedPairAPIData ¶
type SimplifiedPairAPIData struct { PairName string `json:"pairName"` LastPrice float64 `json:"lastPrice"` TradeCount int `json:"tradeCount"` OrderCount int `json:"orderCount"` Volume float64 `json:"volume"` OrderVolume float64 `json:"orderVolume"` AverageOrderAmount float64 `json:"averageOrderAmount"` AverageTradeAmount float64 `json:"averageTradeAmount"` }
PairAPIData is a similar structure to PairData that contains human-readable data for a certain pair
type SubscriptionEvent ¶
type SubscriptionEvent string
SubscriptionEvent is an enum signifies whether the incoming message is of type Subscribe or unsubscribe
type SubscriptionPayload ¶
type Tick ¶
type Tick struct { Pair PairID `json:"id,omitempty" bson:"_id"` Close *big.Int `json:"close,omitempty" bson:"close"` Count *big.Int `json:"count,omitempty" bson:"count"` High *big.Int `json:"high,omitempty" bson:"high"` Low *big.Int `json:"low,omitempty" bson:"low"` Open *big.Int `json:"open,omitempty" bson:"open"` Volume *big.Int `json:"volume,omitempty" bson:"volume"` Timestamp int64 `json:"timestamp,omitempty" bson:"timestamp"` }
Tick is the format in which mongo aggregate pipeline returns data when queried for OHLCV data
func (*Tick) AddressCode ¶
func (*Tick) AveragePrice ¶
func (*Tick) ConvertedVolume ¶
RoundedVolume returns the value exchanged during this tick in the currency for which the 'exchangeRate' param was provided.
func (*Tick) MarshalJSON ¶
MarshalJSON returns the json encoded byte array representing the trade struct
func (*Tick) UnmarshalJSON ¶
UnmarshalJSON creates a trade object from a json byte string
type Token ¶
type Token struct { ID bson.ObjectId `json:"-" bson:"_id"` Name string `json:"name" bson:"name"` Symbol string `json:"symbol" bson:"symbol"` Address common.Address `json:"address" bson:"address"` Image Image `json:"image" bson:"image"` ContractAddress common.Address `json:"contractAddress" bson:"contractAddress"` Decimals int `json:"decimals" bson:"decimals"` Active bool `json:"active" bson:"active"` Listed bool `json:"listed" bson:"listed"` Quote bool `json:"quote" bson:"quote"` MakeFee *big.Int `json:"makeFee,omitempty" bson:"makeFee,omitempty"` TakeFee *big.Int `json:"takeFee,omitempty" bson:"makeFee,omitempty"` USD string `json:"usd,omitempty" bson:"usd,omitempty"` CreatedAt time.Time `json:"createdAt" bson:"createdAt"` UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` }
Token struct is used to model the token data in the system and DB
func (*Token) MarshalJSON ¶
func (*Token) UnmarshalJSON ¶
type TokenBalance ¶
type TokenBalance struct { Address common.Address `json:"address" bson:"address"` Symbol string `json:"symbol" bson:"symbol"` Balance *big.Int `json:"balance" bson:"balance"` PendingBalance *big.Int `json:"pendingBalance" bson:"pendingBalance"` LockedBalance *big.Int `json:"lockedBalance" bson:"lockedBalance"` }
TokenBalance holds the Balance and the Locked balance values for a single Ethereum token Balance and Locked Balance are stored as big.Int as they represent uint256 values
type TokenBalanceRecord ¶
type TokenBalanceRecord struct { Address string `json:"address" bson:"address"` Symbol string `json:"symbol" bson:"symbol"` Balance string `json:"balance" bson:"balance"` PendingBalance string `json:"pendingBalance" base:"pendingBalance"` LockedBalance string `json:"lockedBalance" bson:"lockedBalance"` }
TokenBalanceRecord corresponds to a TokenBalance struct that is stored in the DB. big.Ints are encoded as strings
type TokenRecord ¶
type TokenRecord struct { ID bson.ObjectId `json:"-" 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"` Decimals int `json:"decimals" bson:"decimals"` Active bool `json:"active" bson:"active"` Quote bool `json:"quote" bson:"quote"` MakeFee string `json:"makeFee,omitempty" bson:"makeFee,omitempty"` TakeFee string `json:"takeFee,omitempty" bson:"takeFee,omitempty"` USD string `json:"usd,omitempty" bson:"usd,omitempty"` CreatedAt time.Time `json:"createdAt" bson:"createdAt"` UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` }
TokenRecord is the struct which is stored in db
type Trade ¶
type Trade struct { ID bson.ObjectId `json:"id,omitempty" bson:"_id"` Taker common.Address `json:"taker" bson:"taker"` Maker common.Address `json:"maker" bson:"maker"` BaseToken common.Address `json:"baseToken" bson:"baseToken"` QuoteToken common.Address `json:"quoteToken" bson:"quoteToken"` MakerOrderHash common.Hash `json:"makerOrderHash" bson:"makerOrderHash"` TakerOrderHash common.Hash `json:"takerOrderHash" bson:"takerOrderHash"` Hash common.Hash `json:"hash" bson:"hash"` TxHash common.Hash `json:"txHash" bson:"txHash"` PairName string `json:"pairName" bson:"pairName"` CreatedAt time.Time `json:"createdAt" bson:"createdAt"` UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` PricePoint *big.Int `json:"pricepoint" bson:"pricepoint"` Status string `json:"status" bson:"status"` Amount *big.Int `json:"amount" bson:"amount"` }
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
func NewTrade ¶
NewTrade returns a new unsigned trade corresponding to an Order, amount and taker address
func (*Trade) ComputeHash ¶
ComputeHash returns hashes the trade The OrderHash, Amount, Taker and TradeNonce attributes must be set before attempting to compute the trade hash
func (*Trade) MarshalJSON ¶
MarshalJSON returns the json encoded byte array representing the trade struct
func (*Trade) UnmarshalJSON ¶
UnmarshalJSON creates a trade object from a json byte string
type TradeBSONUpdate ¶
type TradeBSONUpdate struct {
*Trade
}
func (TradeBSONUpdate) GetBSON ¶
func (t TradeBSONUpdate) GetBSON() (interface{}, error)
type TradeRecord ¶
type TradeRecord struct { ID bson.ObjectId `json:"id" bson:"_id"` Taker string `json:"taker" bson:"taker"` Maker string `json:"maker" bson:"maker"` BaseToken string `json:"baseToken" bson:"baseToken"` QuoteToken string `json:"quoteToken" bson:"quoteToken"` MakerOrderHash string `json:"makerOrderHash" bson:"makerOrderHash"` TakerOrderHash string `json:"takerOrderHash" bson:"takerOrderHash"` Hash string `json:"hash" bson:"hash"` TxHash string `json:"txHash" bson:"txHash"` PairName string `json:"pairName" bson:"pairName"` CreatedAt time.Time `json:"createdAt" bson:"createdAt"` UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` PricePoint string `json:"pricepoint" bson:"pricepoint"` Amount string `json:"amount" bson:"amount"` Status string `json:"status" bson:"status"` }
type Wallet ¶
type Wallet struct { ID bson.ObjectId Address common.Address PrivateKey *ecdsa.PrivateKey Admin bool Operator bool }
Wallet holds both the address and the private key of an ethereum account
func NewWallet ¶
func NewWallet() *Wallet
NewWallet returns a new wallet object corresponding to a random private key
func NewWalletFromPrivateKey ¶
NewWalletFromPrivateKey returns a new wallet object corresponding to a given private key
func (*Wallet) GetAddress ¶
GetAddress returns the wallet address
func (*Wallet) GetPrivateKey ¶
GetPrivateKey returns the wallet private key
type WalletRecord ¶
type WebsocketEvent ¶
type WebsocketEvent struct { Type SubscriptionEvent `json:"type"` Hash string `json:"hash,omitempty"` Payload interface{} `json:"payload"` }
func (*WebsocketEvent) String ¶
func (ev *WebsocketEvent) String() string
type WebsocketMessage ¶
type WebsocketMessage struct { Channel string `json:"channel"` Event WebsocketEvent `json:"event"` }
func NewOrderAddedWebsocketMessage ¶
func NewOrderAddedWebsocketMessage(o *Order, p *Pair, filled int64) *WebsocketMessage
func NewOrderCancelWebsocketMessage ¶
func NewOrderCancelWebsocketMessage(oc *OrderCancel) *WebsocketMessage
func NewOrderWebsocketMessage ¶
func NewOrderWebsocketMessage(o *Order) *WebsocketMessage
func (*WebsocketMessage) String ¶
func (ev *WebsocketMessage) String() string