types

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AssetCodeETH  AssetCode = "ETH"
	AssetCodeBTC  AssetCode = "BTC"
	CreateOffer             = "CreateOffer"
	CreateAccount           = "CreateAccount"
	RemoveSigner            = "RemoveSigner"
)
View Source
const (
	LendingRate = 150
	BORROW      = "BORROW"
	LEND        = "INVEST"
	TypeMarket  = "MO"
	TypeLimit   = "LO"

	LendingStatusOpen          = "OPEN"
	LendingStatusPartialFilled = "PARTIAL_FILLED"
	LendingStatusFilled        = "FILLED"
	LendingStatusRejected      = "REJECTED"
	LendingStatusCancelled     = "CANCELLED"
	LendingStatusRepay         = "REPAY"
	LendingStatusTopup         = "TOPUP"
	LendingStatusRecall        = "RECALL"
)
View Source
const (
	TradeStatusOpen       = "OPEN"
	TradeStatusClosed     = "CLOSED"
	TradeStatusLiquidated = "LIQUIDATED"
)
View Source
const (
	PENDING      = "PENDING"
	SUCCESS      = "SUCCESS"
	FAILED       = "FAILED"
	DefaultLimit = 50
)
View Source
const (
	StatusUnread = "UNREAD"
	StatusRead   = "READ"

	TypeAnnounce = "ANNOUNCE"
	TypeAlert    = "ALERT"
	TypeLog      = "LOG"
)
View Source
const (
	BUY             = "BUY"
	SELL            = "SELL"
	TypeMarketOrder = "MO"
	TypeLimitOrder  = "LO"

	OrderStatusOpen          = "OPEN"
	OrderStatusPartialFilled = "PARTIAL_FILLED"
	OrderStatusFilled        = "FILLED"
	OrderStatusRejected      = "REJECTED"
	OrderStatusCancelled     = "CANCELLED"
)
View Source
const (
	OPERATION_TYPE_INSERT  = "insert"
	OPERATION_TYPE_UPDATE  = "update"
	OPERATION_TYPE_REPLACE = "replace"
	OPERATION_TYPE_DELETE  = "delete"
)
View Source
const (
	TypeStopMarketOrder = "SMO"
	TypeStopLimitOrder  = "SLO"

	StopOrderStatusOpen      = "OPEN"
	StopOrderStatusDone      = "DONE"
	StopOrderStatusCancelled = "CANCELLED"
)
View Source
const (
	TradeStatusPending = "PENDING"
	TradeStatusSuccess = "SUCCESS"
	TradeStatusError   = "ERROR"
)
View Source
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"
	ORDER_REJECTED         = "ORDER_REJECTED"
	ERROR_STATUS           = "ERROR"

	TradeAdded   = "TRADE_ADDED"
	TradeUpdated = "TRADE_UPDATED"
	// channel
	TradeChannel     = "trades"
	OrderbookChannel = "orderbook"
	OrderChannel     = "orders"
	OHLCVChannel     = "ohlcv"

	// Lending
	LENDING_ORDER_ADDED            = "LENDING_ORDER_ADDED"
	LENDING_ORDER_FILLED           = "LENDING_ORDER_FILLED"
	LENDING_ORDER_PARTIALLY_FILLED = "LENDING_ORDER_PARTIALLY_FILLED"
	LENDING_ORDER_CANCELLED        = "LENDING_ORDER_CANCELLED"
	LENDING_ORDER_REJECTED         = "LENDING_ORDER_REJECTED"
	LENDING_ORDER_TOPUPED          = "LENDING_ORDER_TOPUPED"
	LENDING_ORDER_REPAYED          = "LENDING_ORDER_REPAYED"
	LENDING_ORDER_RECALLED         = "LENDING_ORDER_RECALLED"

	LENDING_ORDER_TOPUP_REJECTED  = "LENDING_ORDER_TOPUP_REJECTED"
	LENDING_ORDER_REPAY_REJECTED  = "LENDING_ORDER_REPAY_REJECTED"
	LENDING_ORDER_RECALL_REJECTED = "LENDING_ORDER_RECALL_REJECTED"
)

Enum members for SubscriptionEvent

Variables

This section is empty.

Functions

func DefaultTestAvailableBalance

func DefaultTestAvailableBalance() int64

DefaultTestAvailableBalance returns the default available balance Only for testing/mock purpose

func DefaultTestBalance

func DefaultTestBalance() int64

DefaultTestBalance returns the default balance Only for testing/mock purpose

func DefaultTestInOrderBalance

func DefaultTestInOrderBalance() int64

DefaultTestBalance returns the default locked 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"`
	FavoriteTokens map[common.Address]bool          `json:"favoriteTokens" bson:"favoriteTokens"`
	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) GetBSON

func (a *Account) GetBSON() (interface{}, error)

GetBSON implements bson.Getter

func (*Account) MarshalJSON

func (a *Account) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshal interface

func (*Account) SetBSON

func (a *Account) SetBSON(raw bson.Raw) error

SetBSON implemenets bson.Setter

func (*Account) UnmarshalJSON

func (a *Account) UnmarshalJSON(b []byte) error

func (Account) Validate

func (a Account) Validate() error

Validate enforces the account model

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"`
	FavoriteTokens map[string]bool               `json:"favoriteTokens" bson:"favoriteTokens"`
	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

type AddressAssociationWebsocketPayload

type AddressAssociationWebsocketPayload struct {
	Chain             Chain          `json:"chain"`
	AssociatedAddress common.Address `json:"associatedAddress"`
	PairAddresses     *PairAddresses `json:"pairAddresses"`
}

type AssetCode

type AssetCode string

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

type AssociationTransactionResponse

type AssociationTransactionResponse struct {
	Source          string   `json:"source"`
	Signature       string   `json:"signature"`
	Hash            string   `json:"hash"`
	TransactionType string   `json:"transactionType"`
	Params          []string `json:"params"`
}

type Chain

type Chain string
const (
	ChainEthereum Chain = "ethereum"
	ChainBitcoin  Chain = "bitcoin"
)

func NewChain

func NewChain(str interface{}) Chain

func (*Chain) Bytes

func (s *Chain) Bytes() []byte

func (*Chain) Scan

func (s *Chain) Scan(src interface{}) error

Scan implements database/sql.Scanner interface

func (*Chain) String

func (s *Chain) String() string

type ChartItem

type ChartItem [2]float64

type CoinsIDMarketChart

type CoinsIDMarketChart struct {
	Prices       []*ChartItem `json:"prices"`
	MarketCaps   []*ChartItem `json:"market_caps"`
	TotalVolumes []*ChartItem `json:"total_volumes"`
}

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"`
	Trade             *Trade          `json:"trade,omitenpty"`
	Matches           *Matches        `json:"matches,omitempty"`
	RecoveredOrders   *[]*Order       `json:"recoveredOrders,omitempty"`
	InvalidatedOrders *[]*Order       `json:"invalidatedOrders,omitempty"`
	CancelledTrades   *[]*Trade       `json:"cancelledTrades,omitempty"`
	LendingOrder      *LendingOrder   `json:"lendingOrder,omitempty"`
	LendingTrade      *LendingTrade   `json:"lendingTrade,omitenpty"`
	LendingMatches    *LendingMatches `json:"lendingMatches,omitempty"`
}

EngineResponse engine message

func (*EngineResponse) AppendMatch

func (r *EngineResponse) AppendMatch(mo *Order, t *Trade)

func (*EngineResponse) AppendMatches

func (r *EngineResponse) AppendMatches(mo []*Order, t []*Trade)

type FavoriteTokenRequest

type FavoriteTokenRequest struct {
	Address string `json:"address" bson:"address"`
	Token   string `json:"token" bson:"token"`
}

type FiatPriceItem

type FiatPriceItem struct {
	Symbol       string `json:"-" bson:"symbol"`
	Price        string `json:"price" bson:"price"`
	Timestamp    int64  `json:"timestamp" bson:"timestamp"`
	FiatCurrency string `json:"fiatCurrency" bson:"fiatCurrency"`
	TotalVolume  string `json:"totalVolume" bson:"totalVolume"`
}

func (*FiatPriceItem) GetBSON

func (i *FiatPriceItem) GetBSON() (interface{}, error)

func (*FiatPriceItem) SetBSON

func (i *FiatPriceItem) SetBSON(raw bson.Raw) error

type FiatPriceItemBSONUpdate

type FiatPriceItemBSONUpdate struct {
	*FiatPriceItem
}

type GenerateAddressResponse

type GenerateAddressResponse struct {
	ProtocolVersion int    `json:"protocolVersion"`
	Chain           string `json:"chain"`
	Address         string `json:"address"`
	Signer          string `json:"signer"`
}

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 LendingID added in v1.2.0

type LendingID struct {
	Name         string         `json:"name" bson:"name"`
	Term         uint64         `json:"term" bson:"term"`
	LendingToken common.Address `json:"lendingToken" bson:"lendingToken"`
}

LendingID is the subdocument for aggregate grouping for OHLCV data

type LendingMarketData added in v1.2.0

type LendingMarketData struct {
	PairData []*LendingTick `json:"pairData" bson:"pairData"`
}

LendingMarketData lending pair tick data

type LendingMatches added in v1.2.0

type LendingMatches struct {
	Investing     []*LendingOrder `json:"investing"`
	Borrowing     *LendingOrder   `json:"borrowing"`
	LendingTrades []*LendingTrade `json:"lendingTrades"`
}

LendingMatches matching trade

type LendingOrder added in v1.2.0

type LendingOrder struct {
	ID              bson.ObjectId  `json:"id" bson:"_id"`
	Quantity        *big.Int       `bson:"quantity" json:"quantity"`
	Interest        uint64         `bson:"interest" json:"interest"`
	Term            uint64         `bson:"term" json:"term"`
	Side            string         `bson:"side" json:"side"`
	Type            string         `bson:"type" json:"type"`
	LendingToken    common.Address `bson:"lendingToken" json:"lendingToken"`
	CollateralToken common.Address `bson:"collateralToken" json:"collateralToken"`
	FilledAmount    *big.Int       `bson:"filledAmount" json:"filledAmount"`
	Status          string         `bson:"status" json:"status"`
	UserAddress     common.Address `bson:"userAddress" json:"userAddress"`
	RelayerAddress  common.Address `bson:"relayer" json:"relayerAddress"`
	Signature       *Signature     `bson:"signature" json:"signature"`
	Hash            common.Hash    `bson:"hash" json:"hash"`
	TxHash          common.Hash    `bson:"txHash" json:"txHash"`
	Nonce           *big.Int       `bson:"nonce" json:"nonce"`
	CreatedAt       time.Time      `bson:"createdAt" json:"createdAt"`
	UpdatedAt       time.Time      `bson:"updatedAt" json:"updatedAt"`
	LendingID       uint64         `bson:"lendingId" json:"lendingId"`
	ExtraData       string         `bson:"extraData" json:"extraData"`
	LendingTradeID  uint64         `bson:"tradeId" json:"tradeId"`
	AutoTopUp       uint64         `json:"autoTopUp" json:"autoTopUp"`
	Key             string         `json:"key" bson:"key"`
}

LendingOrder contains the data related to an lending sent by the user

func (*LendingOrder) ComputeHash added in v1.2.0

func (o *LendingOrder) ComputeHash() common.Hash

ComputeHash calculates the orderRequest hash

func (*LendingOrder) GetBSON added in v1.2.0

func (o *LendingOrder) GetBSON() (interface{}, error)

GetBSON return bson

func (*LendingOrder) MarshalJSON added in v1.2.0

func (o *LendingOrder) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshal interface

func (*LendingOrder) PairCode added in v1.2.0

func (o *LendingOrder) PairCode() (string, error)

PairCode get orderbook code

func (*LendingOrder) Process added in v1.2.0

func (o *LendingOrder) Process() error

Process pre-process data

func (*LendingOrder) SetBSON added in v1.2.0

func (o *LendingOrder) SetBSON(raw bson.Raw) error

SetBSON for database

func (*LendingOrder) UnmarshalJSON added in v1.2.0

func (o *LendingOrder) UnmarshalJSON(b []byte) error

UnmarshalJSON : write custom logic to unmarshal bytes to LendingOrder

func (*LendingOrder) Validate added in v1.2.0

func (o *LendingOrder) Validate() error

Validate Verify userAddress, collateralToken, lendingToken, etc. conditions are working

func (*LendingOrder) VerifySignature added in v1.2.0

func (o *LendingOrder) VerifySignature() (bool, error)

VerifySignature checks that the orderRequest signature corresponds to the address in the userAddress field

type LendingOrderBook added in v1.2.0

type LendingOrderBook struct {
	Name   string              `json:"name"`
	Borrow []map[string]string `json:"borrow"`
	Lend   []map[string]string `json:"lend"`
}

LendingOrderBook for lending orderbook

type LendingOrderCancel added in v1.2.0

type LendingOrderCancel struct {
	LendingHash    common.Hash    `json:"lendingHash"`
	Nonce          *big.Int       `json:"nonce"`
	Hash           common.Hash    `json:"hash"`
	LendingID      uint64         `json:"lendingId"`
	Status         string         `json:"status"`
	UserAddress    common.Address `json:"userAddress"`
	RelayerAddress common.Address `json:"relayerAddress"`
	Term           uint64         `json:"term"`
	Interest       uint64         `json:"interest"`
	Signature      *Signature     `json:"signature"`
}

LendingOrderCancel for cancelled lending order

func (*LendingOrderCancel) MarshalJSON added in v1.2.0

func (oc *LendingOrderCancel) MarshalJSON() ([]byte, error)

MarshalJSON returns the json encoded byte array representing the LendingOrderCancel struct

func (*LendingOrderCancel) UnmarshalJSON added in v1.2.0

func (oc *LendingOrderCancel) UnmarshalJSON(b []byte) error

UnmarshalJSON creates an LendingOrderCancel object from a json byte string

type LendingOrderChangeEvent added in v1.2.0

type LendingOrderChangeEvent struct {
	ID                interface{}   `bson:"_id"`
	OperationType     string        `bson:"operationType"`
	FullDocument      *LendingOrder `bson:"fullDocument,omitempty"`
	Ns                evNamespace   `bson:"ns"`
	DocumentKey       M             `bson:"documentKey"`
	UpdateDescription *updateDesc   `bson:"updateDescription,omitempty"`
}

LendingOrderChangeEvent data format for changing data records

type LendingOrderMatchedPayload added in v1.2.0

type LendingOrderMatchedPayload struct {
	LendingMatches *LendingMatches `json:"matches"`
}

type LendingOrderPendingPayload added in v1.2.0

type LendingOrderPendingPayload struct {
	LendingMatches *LendingMatches `json:"matches"`
}

type LendingOrderSuccessPayload added in v1.2.0

type LendingOrderSuccessPayload struct {
	LendingMatches *LendingMatches `json:"matches"`
}

type LendingPair added in v1.2.0

type LendingPair struct {
	ID                   bson.ObjectId  `json:"-" bson:"_id"`
	Term                 uint64         `json:"term,omitempty" bson:"term"`
	LendingTokenSymbol   string         `json:"lendingTokenSymbol,omitempty" bson:"lendingTokenSymbol"`
	LendingTokenAddress  common.Address `json:"lendingTokenAddress,omitempty" bson:"lendingTokenAddress"`
	LendingTokenDecimals int            `json:"lendingTokenDecimals,omitempty" bson:"lendingTokenDecimals"`
	RelayerAddress       common.Address `json:"relayerAddress,omitempty" bson:"relayerAddress"`
	CreatedAt            time.Time      `json:"-" bson:"createdAt"`
	UpdatedAt            time.Time      `json:"-" bson:"updatedAt"`
}

LendingPair struct is used to model the lendingPair data in the system and DB

func (*LendingPair) GetBSON added in v1.2.0

func (p *LendingPair) GetBSON() (interface{}, error)

GetBSON insert record to database

func (*LendingPair) MarshalJSON added in v1.2.0

func (p *LendingPair) MarshalJSON() ([]byte, error)

MarshalJSON marshal json byte

func (*LendingPair) Name added in v1.2.0

func (p *LendingPair) Name() string

Name name of lending pair

func (*LendingPair) SetBSON added in v1.2.0

func (p *LendingPair) SetBSON(raw bson.Raw) error

SetBSON get lending pair object from database

func (*LendingPair) UnmarshalJSON added in v1.2.0

func (p *LendingPair) UnmarshalJSON(b []byte) error

UnmarshalJSON umarshal JSON

type LendingPairRecord added in v1.2.0

type LendingPairRecord struct {
	ID                   bson.ObjectId `json:"id" bson:"_id"`
	Term                 string        `json:"term" bson:"term"`
	LendingTokenSymbol   string        `json:"lendingTokenSymbol" bson:"lendingTokenSymbol"`
	LendingTokenAddress  string        `json:"lendingTokenAddress" bson:"lendingTokenAddress"`
	LendingTokenDecimals int           `json:"lendingTokenDecimals" bson:"lendingTokenDecimals"`
	RelayerAddress       string        `json:"relayerAddress" bson:"relayerAddress"`
	CreatedAt            time.Time     `json:"createdAt" bson:"createdAt"`
	UpdatedAt            time.Time     `json:"updatedAt" bson:"updatedAt"`
}

LendingPairRecord struct for database

type LendingRecord added in v1.2.0

type LendingRecord struct {
	ID              bson.ObjectId    `json:"id" bson:"_id"`
	UserAddress     string           `json:"userAddress" bson:"userAddress"`
	RelayerAddress  string           `json:"relayerAddress" bson:"relayer"`
	CollateralToken string           `json:"collateralToken" bson:"collateralToken"`
	LendingToken    string           `json:"lendingToken" bson:"lendingToken"`
	Term            string           `json:"term" bson:"term"`
	Interest        string           `json:"interest" bson:"interest"`
	Status          string           `json:"status" bson:"status"`
	Side            string           `json:"side" bson:"side"`
	Type            string           `json:"type" bson:"type"`
	Hash            string           `json:"hash" bson:"hash"`
	Quantity        string           `json:"quantity" bson:"quantity"`
	FilledAmount    string           `json:"filledAmount" bson:"filledAmount"`
	Nonce           string           `json:"nonce" bson:"nonce"`
	Signature       *SignatureRecord `json:"signature,omitempty" bson:"signature"`
	CreatedAt       time.Time        `json:"createdAt" bson:"createdAt"`
	UpdatedAt       time.Time        `json:"updatedAt" bson:"updatedAt"`
	LendingID       string           `json:"lendingId,omitempty" bson:"lendingId"`
	NextOrder       string           `json:"nextOrder,omitempty" bson:"nextOrder"`
	PrevOrder       string           `json:"prevOrder,omitempty" bson:"prevOrder"`
	OrderList       string           `json:"orderList,omitempty" bson:"orderList"`
	Key             string           `json:"key" bson:"key"`
}

LendingRecord is the object that will be saved in the database

type LendingRes added in v1.2.0

type LendingRes struct {
	Total        int             `json:"total" bson:"total"`
	LendingItems []*LendingOrder `json:"lendings" bson:"lendings"`
}

LendingRes use for api

type LendingSpec added in v1.2.0

type LendingSpec struct {
	UserAddress     string
	CollateralToken string
	RelayerAddress  common.Address
	LendingToken    string
	Term            string
	Status          string
	Side            string
	Type            string
	DateFrom        int64
	DateTo          int64
	Hash            string
}

LendingSpec contains field for filter

type LendingTick added in v1.2.0

type LendingTick struct {
	LendingID LendingID `json:"lendingID,omitempty" bson:"lendingID"`
	Open      uint64    `json:"open,omitempty" bson:"open"`
	Close     uint64    `json:"close,omitempty" bson:"close"`
	High      uint64    `json:"high,omitempty" bson:"high"`
	Low       uint64    `json:"low,omitempty" bson:"low"`
	Volume    *big.Int  `json:"volume,omitempty" bson:"volume"`
	Count     *big.Int  `json:"count,omitempty" bson:"count"`
	Timestamp int64     `json:"timestamp,omitempty" bson:"timestamp"`
	Duration  int64     `json:"duration" bson:"duration"`
	Unit      string    `json:"unit" bson:"unit"`
}

LendingTick is the format in which mongo aggregate pipeline returns data when queried for OHLCV data

func (*LendingTick) AddressCode added in v1.2.0

func (t *LendingTick) AddressCode() string

AddressCode generate code from pair

func (*LendingTick) MarshalJSON added in v1.2.0

func (t *LendingTick) MarshalJSON() ([]byte, error)

MarshalJSON returns the json encoded byte array representing the trade struct

func (*LendingTick) UnmarshalJSON added in v1.2.0

func (t *LendingTick) UnmarshalJSON(b []byte) error

UnmarshalJSON creates a trade object from a json byte string

type LendingTicks added in v1.2.0

type LendingTicks []*LendingTick

LendingTicks array of lending ticks

type LendingTrade added in v1.2.0

type LendingTrade struct {
	ID                     bson.ObjectId  `json:"id,omitempty" bson:"_id"`
	Borrower               common.Address `bson:"borrower" json:"borrower"`
	Investor               common.Address `bson:"investor" json:"investor"`
	LendingToken           common.Address `bson:"lendingToken" json:"lendingToken"`
	CollateralToken        common.Address `bson:"collateralToken" json:"collateralToken"`
	BorrowingOrderHash     common.Hash    `bson:"borrowingOrderHash" json:"borrowingOrderHash"`
	InvestingOrderHash     common.Hash    `bson:"investingOrderHash" json:"investingOrderHash"`
	BorrowingRelayer       common.Address `bson:"borrowingRelayer" json:"borrowingRelayer"`
	InvestingRelayer       common.Address `bson:"investingRelayer" json:"investingRelayer"`
	Term                   uint64         `bson:"term" json:"term"`
	Interest               uint64         `bson:"interest" json:"interest"`
	CollateralPrice        *big.Int       `bson:"collateralPrice" json:"collateralPrice"`
	LiquidationPrice       *big.Int       `bson:"liquidationPrice" json:"liquidationPrice"`
	CollateralLockedAmount *big.Int       `bson:"collateralLockedAmount" json:"collateralLockedAmount"`
	LiquidationTime        uint64         `bson:"liquidationTime" json:"liquidationTime"`
	DepositRate            *big.Int       `bson:"depositRate" json:"depositRate"`
	Amount                 *big.Int       `bson:"amount" json:"amount"`
	BorrowingFee           *big.Int       `bson:"borrowingFee" json:"borrowingFee"`
	InvestingFee           *big.Int       `bson:"investingFee" json:"investingFee"`
	Status                 string         `bson:"status" json:"status"`
	TakerOrderSide         string         `bson:"takerOrderSide" json:"takerOrderSide"`
	TakerOrderType         string         `bson:"takerOrderType" json:"takerOrderType"`
	MakerOrderType         string         `bson:"makerOrderType" json:"makerOrderType"`
	TradeID                string         `bson:"tradeId" json:"tradeID"`
	Hash                   common.Hash    `bson:"hash" json:"hash"`
	TxHash                 common.Hash    `bson:"txHash" json:"txHash"`
	AutoTopUp              uint64         `json:"autoTopUp" json:"autoTopUp"`
	ExtraData              string         `bson:"extraData" json:"extraData"`
	CreatedAt              time.Time      `bson:"createdAt" json:"createdAt"`
	UpdatedAt              time.Time      `bson:"updatedAt" json:"updatedAt"`
}

LendingTrade lending trade struct

func (*LendingTrade) ComputeHash added in v1.2.0

func (t *LendingTrade) ComputeHash() common.Hash

ComputeHash returns hashes the trade The OrderHash, Amount, Taker and TradeNonce attributes must be set before attempting to compute the trade hash

func (*LendingTrade) GetBSON added in v1.2.0

func (t *LendingTrade) GetBSON() (interface{}, error)

GetBSON for monggo insert

func (*LendingTrade) MarshalJSON added in v1.2.0

func (t *LendingTrade) MarshalJSON() ([]byte, error)

MarshalJSON returns the json encoded byte array representing the trade struct

func (*LendingTrade) SetBSON added in v1.2.0

func (t *LendingTrade) SetBSON(raw bson.Raw) error

SetBSON get monggo record

func (*LendingTrade) UnmarshalJSON added in v1.2.0

func (t *LendingTrade) UnmarshalJSON(b []byte) error

UnmarshalJSON creates a trade object from a json byte string

type LendingTradeBSON added in v1.2.0

type LendingTradeBSON struct {
	ID                     bson.ObjectId `json:"id,omitempty" bson:"_id"`
	Borrower               string        `bson:"borrower" json:"borrower"`
	Investor               string        `bson:"investor" json:"investor"`
	LendingToken           string        `bson:"lendingToken" json:"lendingToken"`
	CollateralToken        string        `bson:"collateralToken" json:"collateralToken"`
	BorrowingOrderHash     string        `bson:"borrowingOrderHash" json:"borrowingOrderHash"`
	InvestingOrderHash     string        `bson:"investingOrderHash" json:"investingOrderHash"`
	BorrowingRelayer       string        `bson:"borrowingRelayer" json:"borrowingRelayer"`
	InvestingRelayer       string        `bson:"investingRelayer" json:"investingRelayer"`
	Term                   string        `bson:"term" json:"term"`
	Interest               string        `bson:"interest" json:"interest"`
	CollateralPrice        string        `bson:"collateralPrice" json:"collateralPrice"`
	LiquidationPrice       string        `bson:"liquidationPrice" json:"liquidationPrice"`
	LiquidationTime        string        `bson:"liquidationTime" json:"liquidationTime"`
	CollateralLockedAmount string        `bson:"collateralLockedAmount" json:"collateralLockedAmount"`
	DepositRate            string        `bson:"depositRate" json:"depositRate"`
	Amount                 string        `bson:"amount" json:"amount"`
	BorrowingFee           string        `bson:"borrowingFee" json:"borrowingFee"`
	InvestingFee           string        `bson:"investingFee" json:"investingFee"`
	Status                 string        `bson:"status" json:"status"`
	TakerOrderSide         string        `bson:"takerOrderSide" json:"takerOrderSide"`
	TakerOrderType         string        `bson:"takerOrderType" json:"takerOrderType"`
	MakerOrderType         string        `bson:"makerOrderType" json:"makerOrderType"`
	TradeID                string        `bson:"tradeId" json:"tradeID"`
	Hash                   string        `bson:"hash" json:"hash"`
	TxHash                 string        `bson:"txHash" json:"txHash"`
	AutoTopUp              uint64        `bson:"autoTopUp" json:"autoTopUp"`
	ExtraData              string        `bson:"extraData" json:"extraData"`
	CreatedAt              time.Time     `bson:"createdAt" json:"createdAt"`
	UpdatedAt              time.Time     `bson:"updatedAt" json:"updatedAt"`
}

LendingTradeBSON lending trade mongo

type LendingTradeChangeEvent added in v1.2.0

type LendingTradeChangeEvent struct {
	ID                interface{}   `bson:"_id"`
	OperationType     string        `bson:"operationType"`
	FullDocument      *LendingTrade `bson:"fullDocument,omitempty"`
	Ns                evNamespace   `bson:"ns"`
	DocumentKey       M             `bson:"documentKey"`
	UpdateDescription *updateDesc   `bson:"updateDescription,omitempty"`
}

LendingTradeChangeEvent event for changing mongo watch

type LendingTradeRes added in v1.2.0

type LendingTradeRes struct {
	Total         int             `json:"total" bson:"total"`
	LendingTrades []*LendingTrade `json:"trades" bson:"trades"`
}

LendingTradeRes response api

type LendingTradeSpec added in v1.2.0

type LendingTradeSpec struct {
	CollateralToken string
	RelayerAddress  common.Address
	LendingToken    string
	Term            string
	Status          string
	DateFrom        int64
	DateTo          int64
}

LendingTradeSpec for query

type M

type M bson.M

type MarketData

type MarketData struct {
	PairData        []*PairData                 `json:"pairData" bson:"pairData"`
	SmallChartsData map[string][]*FiatPriceItem `json:"smallChartsData" bson:"smallChartsData"`
}

type Matches

type Matches struct {
	MakerOrders []*Order `json:"makerOrders"`
	TakerOrder  *Order   `json:"takerOrder"`
	Trades      []*Trade `json:"trades"`
}

func NewMatches

func NewMatches(makerOrders []*Order, takerOrder *Order, trades []*Trade) *Matches

func (*Matches) AppendMatch

func (m *Matches) AppendMatch(mo *Order, t *Trade)

func (*Matches) Length

func (m *Matches) Length() int

func (*Matches) NthMatch

func (m *Matches) NthMatch(i int) *Matches

func (*Matches) PairCode

func (m *Matches) PairCode() (string, error)

func (*Matches) String

func (m *Matches) String() string

func (*Matches) Taker

func (m *Matches) Taker() common.Address

func (*Matches) TakerOrderHash

func (m *Matches) TakerOrderHash() common.Hash

func (*Matches) TradeAmounts

func (m *Matches) TradeAmounts() []*big.Int

func (*Matches) Validate

func (m *Matches) Validate() error

type Message

type Message struct {
	MessageType string `json:"type" bson:"type"`
	Description string `json:"description" bson:"description"`
}

Message struct

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"`
	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 Notification

type Notification struct {
	ID        bson.ObjectId  `json:"_id" bson:"_id"`
	Recipient common.Address `json:"recipient" bson:"recipient"`
	Message   Message        `json:"message" bson:"message"`
	Type      string         `json:"type" bson:"type"`
	Status    string         `json:"status" bson:"status"`
	CreatedAt time.Time      `json:"createdAt" bson:"createdAt"`
	UpdatedAt time.Time      `json:"updatedAt" bson:"updatedAt"`
}

Notification struct

func (*Notification) GetBSON

func (n *Notification) GetBSON() (interface{}, error)

GetBSON get Notification struct

func (*Notification) MarshalJSON

func (n *Notification) MarshalJSON() ([]byte, error)

MarshalJSON returns the json encoded byte array representing the notification struct

func (*Notification) SetBSON

func (n *Notification) SetBSON(raw bson.Raw) error

SetBSON json to Notification

func (*Notification) UnmarshalJSON

func (n *Notification) UnmarshalJSON(b []byte) error

UnmarshalJSON creates a notification object from a json byte string

type NotificationBSONUpdate

type NotificationBSONUpdate struct {
	*Notification
}

NotificationBSONUpdate return BSON structure for NotificationSpec structure

type NotificationRecord

type NotificationRecord struct {
	ID        bson.ObjectId `json:"_id" bson:"_id"`
	Recipient string        `json:"recipient" bson:"recipient"`
	Message   Message       `json:"message" bson:"message"`
	Type      string        `json:"type" bson:"type"`
	Status    string        `json:"status" bson:"status"`
	CreatedAt time.Time     `json:"createdAt" bson:"createdAt"`
	UpdatedAt time.Time     `json:"updatedAt" bson:"updatedAt"`
}

NotificationRecord struct

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"`
}

OHLCVParams struct

type OperatorMessage

type OperatorMessage struct {
	MessageType string
	Matches     *Matches
	ErrorType   string
}

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:"price"`
	Amount          *big.Int       `json:"amount" bson:"quantity"`
	FilledAmount    *big.Int       `json:"filledAmount" bson:"filledAmount"`
	Nonce           *big.Int       `json:"nonce" bson:"nonce"`
	PairName        string         `json:"pairName" bson:"pairName"`
	CreatedAt       time.Time      `json:"createdAt" bson:"createdAt"`
	UpdatedAt       time.Time      `json:"updatedAt" bson:"updatedAt"`
	OrderID         uint64         `json:"orderID,omitempty" bson:"orderID"`
	NextOrder       []byte         `json:"-"`
	PrevOrder       []byte         `json:"-"`
	OrderList       []byte         `json:"-"`
	Key             string         `json:"key" bson:"key"`
}

Order contains the data related to an order sent by the user

func (*Order) BaseTokenSymbol

func (o *Order) BaseTokenSymbol() string

func (*Order) BuyAmount

func (o *Order) BuyAmount(pairMultiplier *big.Int) *big.Int

func (*Order) BuyToken

func (o *Order) BuyToken() common.Address

func (*Order) BuyTokenSymbol

func (o *Order) BuyTokenSymbol() string

func (*Order) ComputeHash

func (o *Order) ComputeHash() common.Hash

ComputeHash calculates the orderRequest hash

func (*Order) EncodedSide

func (o *Order) EncodedSide() *big.Int

TODO handle error case ?

func (*Order) GetBSON

func (o *Order) GetBSON() (interface{}, error)

GetBSON return bson

func (*Order) MarshalJSON

func (o *Order) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshal interface

func (*Order) Pair

func (o *Order) Pair() (*Pair, error)

func (*Order) PairCode

func (o *Order) PairCode() (string, error)

func (*Order) Process

func (o *Order) Process(p *Pair) error

func (*Order) QuoteAmount

func (o *Order) QuoteAmount(p *Pair) *big.Int

func (*Order) QuoteTokenSymbol

func (o *Order) QuoteTokenSymbol() string

func (*Order) RemainingAmount

func (o *Order) RemainingAmount() *big.Int

func (*Order) RemainingSellAmount

func (o *Order) RemainingSellAmount(p *Pair) *big.Int

func (*Order) RequiredSellAmount

func (o *Order) RequiredSellAmount(p *Pair) *big.Int

func (*Order) SellAmount

func (o *Order) SellAmount(p *Pair) *big.Int

SellAmount If order is a "BUY", then sellToken = quoteToken

func (*Order) SellToken

func (o *Order) SellToken() common.Address

TODO handle error case

func (*Order) SellTokenSymbol

func (o *Order) SellTokenSymbol() string

func (*Order) SetBSON

func (o *Order) SetBSON(raw bson.Raw) error

func (*Order) Sign

func (o *Order) Sign(w *Wallet) error

Sign first calculates the order hash, then computes a signature of this hash with the given wallet

func (*Order) String

func (o *Order) String() string

func (*Order) TotalRequiredSellAmount

func (o *Order) TotalRequiredSellAmount(p *Pair) *big.Int

func (*Order) UnmarshalJSON

func (o *Order) UnmarshalJSON(b []byte) error

UnmarshalJSON : write custom logic to unmarshal bytes to Order

func (*Order) Validate

func (o *Order) Validate() error

Validate Verify userAddress, baseToken, quoteToken, etc. conditions are working

func (*Order) VerifySignature

func (o *Order) VerifySignature() (bool, error)

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 OrderBook

type OrderBook struct {
	PairName string              `json:"pairName"`
	Asks     []map[string]string `json:"asks"`
	Bids     []map[string]string `json:"bids"`
}

type OrderCancel

type OrderCancel struct {
	OrderHash       common.Hash    `json:"orderHash"`
	Nonce           *big.Int       `json:"nonce"`
	Hash            common.Hash    `json:"hash"`
	OrderID         uint64         `json:"orderID"`
	Status          string         `json:"status"`
	UserAddress     common.Address `json:"userAddress"`
	ExchangeAddress common.Address `json:"exchangeAddress"`
	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 OrderChangeEvent

type OrderChangeEvent struct {
	ID                interface{} `bson:"_id"`
	OperationType     string      `bson:"operationType"`
	FullDocument      *Order      `bson:"fullDocument,omitempty"`
	Ns                evNamespace `bson:"ns"`
	DocumentKey       M           `bson:"documentKey"`
	UpdateDescription *updateDesc `bson:"updateDescription,omitempty"`
}

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 (o *OrderData) AddressCode() string

func (*OrderData) ConvertedVolume

func (o *OrderData) ConvertedVolume(p *Pair, exchangeRate float64) float64

func (*OrderData) GetBSON

func (o *OrderData) GetBSON() (interface{}, error)

func (*OrderData) MarshalJSON

func (o *OrderData) MarshalJSON() ([]byte, error)

func (*OrderData) SetBSON

func (o *OrderData) SetBSON(raw bson.Raw) error

func (*OrderData) UnmarshalJSON

func (o *OrderData) UnmarshalJSON(b []byte) error

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"`
	Price           string           `json:"price" bson:"price"`
	Quantity        string           `json:"quantity" bson:"quantity"`
	FilledAmount    string           `json:"filledAmount" bson:"filledAmount"`
	Nonce           string           `json:"nonce" bson:"nonce"`
	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"`
	OrderID         string           `json:"orderID,omitempty" bson:"orderID"`
	NextOrder       string           `json:"nextOrder,omitempty" bson:"nextOrder"`
	PrevOrder       string           `json:"prevOrder,omitempty" bson:"prevOrder"`
	OrderList       string           `json:"orderList,omitempty" bson:"orderList"`
	Key             string           `json:"key" bson:"key"`
}

OrderRecord is the object that will be saved in the database

type OrderRes

type OrderRes struct {
	Total  int      `json:"total" bson:"total"`
	Orders []*Order `json:"orders" bson:"orders"`
}

OrderRes use for api

type OrderSpec

type OrderSpec struct {
	UserAddress    string
	RelayerAddress common.Address
	BaseToken      string
	QuoteToken     string
	Status         string
	Side           string
	OrderType      string
	DateFrom       int64
	DateTo         int64
	OrderHash      string
}

OrderSpec contains field for filter

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"`
	RelayerAddress     common.Address `json:"relayerAddress,omitempty" bson:"relayerAddress"`
	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 (p *Pair) AddressCode() string

func (*Pair) BaseTokenMultiplier

func (p *Pair) BaseTokenMultiplier() *big.Int

func (*Pair) Code

func (p *Pair) Code() string

func (*Pair) DecimalsMultiplier

func (p *Pair) DecimalsMultiplier() *big.Int

func (*Pair) EncodedTopic

func (p *Pair) EncodedTopic() string

func (*Pair) GetBSON

func (p *Pair) GetBSON() (interface{}, error)

func (*Pair) GetKVPrefix

func (p *Pair) GetKVPrefix() string

func (*Pair) GetOrderBookKeys

func (p *Pair) GetOrderBookKeys() (sell, buy string)

GetOrderBookKeys returns the orderbook price point keys for corresponding pair It is used to fetch the orderbook of a pair

func (*Pair) MarshalJSON

func (p *Pair) MarshalJSON() ([]byte, error)

func (*Pair) MinQuoteAmount

func (p *Pair) MinQuoteAmount() *big.Int

func (*Pair) Name

func (p *Pair) Name() string

func (*Pair) PairMultiplier

func (p *Pair) PairMultiplier() *big.Int

func (*Pair) ParseAmount

func (p *Pair) ParseAmount(a *big.Int) float64

func (*Pair) ParsePricePoint

func (p *Pair) ParsePricePoint(pp *big.Int) float64

func (*Pair) PricepointMultiplier

func (p *Pair) PricepointMultiplier() *big.Int

func (*Pair) QuoteTokenMultiplier

func (p *Pair) QuoteTokenMultiplier() *big.Int

func (*Pair) SetBSON

func (p *Pair) SetBSON(raw bson.Raw) error

func (*Pair) UnmarshalJSON

func (p *Pair) UnmarshalJSON(b []byte) error

func (Pair) Validate

func (p Pair) Validate() error

Validate function is used to verify if an instance of struct satisfies all the conditions for a valid instance

func (Pair) ValidateAddresses

func (p Pair) ValidateAddresses() error

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 PairAddresses struct {
	Name       string         `json:"name" bson:"name"`
	BaseToken  common.Address `json:"baseToken" bson:"baseToken"`
	QuoteToken common.Address `json:"quoteToken" bson:"quoteToken"`
}

type PairAddressesRecord

type PairAddressesRecord struct {
	Name       string `json:"name" bson:"name"`
	BaseToken  string `json:"baseToken" bson:"baseToken"`
	QuoteToken string `json:"quoteToken" bson:"quoteToken"`
}

type PairData

type PairData struct {
	Pair               PairID     `json:"pair,omitempty" bson:"_id"`
	Open               *big.Int   `json:"open,omitempty" bson:"open"`
	High               *big.Int   `json:"high,omitempty" bson:"high"`
	Low                *big.Int   `json:"low,omitempty" bson:"low"`
	Close              *big.Int   `json:"close,omitempty" bson:"close"`
	CloseBaseUsd       *big.Float `json:"closeBaseUsd,omitempty" bson:"closeBaseUsd"`
	Volume             *big.Int   `json:"volume,omitempty" bson:"volume"`
	BaseVolume         *big.Int   `json:"baseVolume,omitempty" bson:"baseVolume"`
	Change             float32    `json:"change,omitempty" bson:"change"`
	Count              *big.Int   `json:"count,omitempty" bson:"count"`
	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 (p *PairData) AddressCode() string

func (*PairData) MarshalJSON

func (p *PairData) MarshalJSON() ([]byte, error)

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"`
	RelayerAddress     string    `json:"relayerAddress" bson:"relayerAddress"`
	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 PriceVolume added in v1.2.1

type PriceVolume struct {
	Price  *big.Int `json:"price,omitempty"`
	Volume *big.Int `json:"volume,omitempty"`
}

PriceVolume get best order price

type RawLendingOrderBook added in v1.2.0

type RawLendingOrderBook struct {
	PairName string   `json:"pairName"`
	Orders   []*Order `json:"orders"`
}

RawLendingOrderBook for lending orderbook

type RawOrderBook

type RawOrderBook struct {
	PairName string   `json:"pairName"`
	Orders   []*Order `json:"orders"`
}

type RecallSpec added in v1.2.0

type RecallSpec struct {
	UserAddress     string
	CollateralToken string
	LendingToken    string
	Term            string
	Status          string
	DateFrom        int64
	DateTo          int64
	Hash            string
}

RecallSpec filter recall

type Relayer added in v1.2.0

type Relayer struct {
	ID         bson.ObjectId  `json:"-" bson:"_id"`
	RID        int            `json:"rid" bson:"rid"`
	Owner      common.Address `json:"owner" bson:"owner"`
	Deposit    *big.Int       `json:"deposit" bson:"deposit"`
	Address    common.Address `json:"address" bson:"address"`
	Domain     string         `json:"domain" bson:"domain"`
	Name       string         `json:"name" bson:"name"`
	Resign     bool           `json:"resign" bson:"resign"`
	LockTime   int            `json:"lockTime" bson:"lockTime"`
	MakeFee    *big.Int       `json:"makeFee,omitempty" bson:"makeFee,omitempty"`
	TakeFee    *big.Int       `json:"takeFee,omitempty" bson:"makeFee,omitempty"`
	LendingFee *big.Int       `json:"lendingFee,omitempty" bson:"lendingFee,omitempty"`
	CreatedAt  time.Time      `json:"createdAt" bson:"createdAt"`
	UpdatedAt  time.Time      `json:"updatedAt" bson:"updatedAt"`
}

Relayer corresponds to a single Ethereum address. It contains a list of token balances for that address

func (*Relayer) GetBSON added in v1.2.0

func (a *Relayer) GetBSON() (interface{}, error)

GetBSON implements bson.Getter

func (*Relayer) MarshalJSON added in v1.2.0

func (a *Relayer) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshal interface

func (*Relayer) SetBSON added in v1.2.0

func (a *Relayer) SetBSON(raw bson.Raw) error

SetBSON implemenets bson.Setter

func (*Relayer) UnmarshalJSON added in v1.2.0

func (a *Relayer) UnmarshalJSON(b []byte) error

func (Relayer) Validate added in v1.2.0

func (a Relayer) Validate() error

Validate enforces the relayer model

type RelayerBSONUpdate added in v1.2.0

type RelayerBSONUpdate struct {
	*Relayer
}

func (*RelayerBSONUpdate) GetBSON added in v1.2.0

func (a *RelayerBSONUpdate) GetBSON() (interface{}, error)

type RelayerLendingTick added in v1.2.1

type RelayerLendingTick struct {
	RelayerAddress common.Address `json:"relayerAddress,omitempty" bson:"relayerAddress"`
	LendingTick    *LendingTick   `json:"lendingTick,omitempty" bson:"lendingTick"`
}

RelayerLendingTick relayer tick

type RelayerLendingTicks added in v1.2.1

type RelayerLendingTicks []*RelayerLendingTick

RelayerLendingTicks array relayer tick

type RelayerRecord added in v1.2.0

type RelayerRecord struct {
	ID         bson.ObjectId `json:"id" bson:"_id"`
	RID        int           `json:"rid" bson:"rid"`
	Owner      string        `json:"owner" bson:"owner"`
	Deposit    string        `json:"deposit" bson:"deposit"`
	Address    string        `json:"address" bson:"address"`
	Domain     string        `json:"domain" bson:"domain"`
	Name       string        `json:"name" bson:"name"`
	Resign     bool          `json:"resign" bson:"resign"`
	LockTime   int           `json:"lockTime" bson:"lockTime"`
	MakeFee    string        `json:"makeFee,omitempty" bson:"makeFee,omitempty"`
	TakeFee    string        `json:"takeFee,omitempty" bson:"takeFee,omitempty"`
	LendingFee string        `json:"lendingFee,omitempty" bson:"lendingFee,omitempty"`
	CreatedAt  time.Time     `json:"createdAt" bson:"createdAt"`
	UpdatedAt  time.Time     `json:"updatedAt" bson:"updatedAt"`
}

RelayerRecord corresponds to what is stored in the DB. big.Ints are encoded as strings

type RelayerTick added in v1.2.0

type RelayerTick struct {
	RelayerAddress common.Address `json:"relayerAddress,omitempty" bson:"relayerAddress"`
	Tick           *Tick          `json:"tick,omitempty" bson:"tick"`
}

RelayerTick relayer tick

type RelayerTicks added in v1.2.0

type RelayerTicks []*RelayerTick

RelayerTicks array relayer tick

type RepaySpec added in v1.2.0

type RepaySpec struct {
	UserAddress  string
	LendingToken string
	Term         string
	Status       string
	DateFrom     int64
	DateTo       int64
	Hash         string
}

RepaySpec filter repay

type RestResponse

type RestResponse struct {
	Status string           `json:"status"`
	Data   interface{}      `json:"data"`
	Meta   RestResponseMeta `json:"meta"`
}

func (*RestResponse) String

func (r *RestResponse) String() string

type RestResponseMeta

type RestResponseMeta struct {
	Total int `json:"total"`
}

func (*RestResponseMeta) String

func (m *RestResponseMeta) String() string

type Signature

type Signature struct {
	V byte
	R common.Hash
	S common.Hash
}

Signature struct

func NewSignature

func NewSignature(b []byte) (*Signature, error)

NewSignature function decodes []byte to Signature type

func Sign

func Sign(hash common.Hash, privKey *ecdsa.PrivateKey) (*Signature, error)

Sign calculates the EDCSA signature corresponding of a hashed message from a given private key

func SignHash

func SignHash(hash common.Hash, privKey *ecdsa.PrivateKey) (*Signature, error)

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

func (s *Signature) MarshalSignature() ([]byte, error)

MarshalSignature marshals the signature struct to []byte

func (*Signature) Verify

func (s *Signature) Verify(hash common.Hash) (common.Address, error)

Verify returns the address that corresponds to the given signature and signed message

type SignatureRecord

type SignatureRecord struct {
	V byte   `json:"V" bson:"V"`
	R string `json:"R" bson:"R"`
	S string `json:"S" bson:"S"`
}

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 StopOrder

type StopOrder 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"`
	StopPrice       *big.Int       `json:"stopPrice" bson:"stopPrice"`
	LimitPrice      *big.Int       `json:"limitPrice" bson:"limitPrice"`
	Direction       int            `json:"direction" bson:"direction"`
	Amount          *big.Int       `json:"amount" bson:"amount"`
	FilledAmount    *big.Int       `json:"filledAmount" bson:"filledAmount"`
	Nonce           *big.Int       `json:"nonce" bson:"nonce"`
	PairName        string         `json:"pairName" bson:"pairName"`
	CreatedAt       time.Time      `json:"createdAt" bson:"createdAt"`
	UpdatedAt       time.Time      `json:"updatedAt" bson:"updatedAt"`
}

func (*StopOrder) ComputeHash

func (so *StopOrder) ComputeHash() common.Hash

ComputeHash calculates the orderRequest hash

func (*StopOrder) EncodedSide

func (so *StopOrder) EncodedSide() *big.Int

TODO handle error case ?

func (*StopOrder) GetBSON

func (so *StopOrder) GetBSON() (interface{}, error)

func (*StopOrder) MarshalJSON

func (so *StopOrder) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshal interface

func (*StopOrder) PairCode

func (so *StopOrder) PairCode() (string, error)

func (*StopOrder) Process

func (so *StopOrder) Process(p *Pair) error

func (*StopOrder) QuoteAmount

func (so *StopOrder) QuoteAmount(p *Pair) *big.Int

func (*StopOrder) SetBSON

func (so *StopOrder) SetBSON(raw bson.Raw) error

func (*StopOrder) ToOrder

func (so *StopOrder) ToOrder() (*Order, error)

ToOrder converts a stop order to a real order that will be pushed to TomoX

func (*StopOrder) UnmarshalJSON

func (so *StopOrder) UnmarshalJSON(b []byte) error

UnmarshalJSON : write custom logic to unmarshal bytes to StopOrder

func (*StopOrder) Validate

func (so *StopOrder) Validate() error

TODO: Verify userAddress, baseToken, quoteToken, etc. conditions are working

func (*StopOrder) VerifySignature

func (so *StopOrder) VerifySignature() (bool, error)

VerifySignature checks that the orderRequest signature corresponds to the address in the userAddress field

type StopOrderBSONUpdate

type StopOrderBSONUpdate struct {
	*StopOrder
}

func (StopOrderBSONUpdate) GetBSON

func (o StopOrderBSONUpdate) GetBSON() (interface{}, error)

type StopOrderRecord

type StopOrderRecord 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"`
	StopPrice       string           `json:"stopPrice" bson:"stopPrice"`
	LimitPrice      string           `json:"limitPrice" bson:"limitPrice"`
	Direction       int              `json:"direction" bson:"direction"`
	Amount          string           `json:"amount" bson:"amount"`
	FilledAmount    string           `json:"filledAmount" bson:"filledAmount"`
	Nonce           string           `json:"nonce" bson:"nonce"`
	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"`
}

StopOrderRecord is the object that will be saved in the database

type SubscriptionEvent

type SubscriptionEvent string

SubscriptionEvent is an enum signifies whether the incoming message is of type Subscribe or unsubscribe

type SubscriptionPayload

type SubscriptionPayload struct {
	PairName     string         `json:"pairName,omitempty"`
	QuoteToken   common.Address `json:"quoteToken,omitempty"`
	BaseToken    common.Address `json:"baseToken,omitempty"`
	From         int64          `json"from"`
	To           int64          `json:"to"`
	Duration     int64          `json:"duration"`
	Units        string         `json:"units"`
	Term         uint64         `json:"term"`
	LendingToken common.Address `json:"lendingToken,omitempty"`
}

type Tick

type Tick struct {
	Pair          PairID    `json:"id,omitempty" bson:"_id"`
	Open          *big.Int  `json:"open,omitempty" bson:"open"`
	Close         *big.Int  `json:"close,omitempty" bson:"close"`
	High          *big.Int  `json:"high,omitempty" bson:"high"`
	Low           *big.Int  `json:"low,omitempty" bson:"low"`
	Volume        *big.Int  `json:"volume,omitempty" bson:"volume"`
	VolumeByQuote *big.Int  `json:"volumebyquote,omitempty" bson:"volumebyquote"`
	VolumeUsdt    *big.Int  `json:"volumeusdt,omitempty" bson:"volumeusdt"`
	Count         *big.Int  `json:"count,omitempty" bson:"count"`
	Timestamp     int64     `json:"timestamp,omitempty" bson:"timestamp"`
	OpenTime      time.Time `json:"openTime" bson:"openTime"`
	CloseTime     time.Time `json:"closeTime" bson:"closeTime"`
	Duration      int64     `json:"duration" bson:"duration"`
	Unit          string    `json:"unit" bson:"unit"`
}

Tick is the format in which mongo aggregate pipeline returns data when queried for OHLCV data

func (*Tick) AddressCode

func (t *Tick) AddressCode() string

AddressCode generate code from pair

func (*Tick) AveragePrice

func (t *Tick) AveragePrice() *big.Int

AveragePrice get price averge

func (*Tick) GetBSON

func (t *Tick) GetBSON() (interface{}, error)

GetBSON return Tick structure

func (*Tick) MarshalJSON

func (t *Tick) MarshalJSON() ([]byte, error)

MarshalJSON returns the json encoded byte array representing the trade struct

func (*Tick) SetBSON

func (t *Tick) SetBSON(raw bson.Raw) error

SetBSON decode json

func (*Tick) UnmarshalJSON

func (t *Tick) UnmarshalJSON(b []byte) error

UnmarshalJSON creates a trade object from a json byte string

type Ticks added in v1.2.0

type Ticks []*Tick

Ticks tick

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"`
	RelayerAddress  common.Address `json:"relayerAddress" bson:"relayerAddress"`
	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 TokensFrom added in v1.2.3

func TokensFrom(token common.Address, tokens []Token) *Token

TokensFrom get token from list

func (*Token) GetBSON

func (t *Token) GetBSON() (interface{}, error)

GetBSON implements bson.Getter

func (*Token) MarshalJSON

func (t *Token) MarshalJSON() ([]byte, error)

func (*Token) SetBSON

func (t *Token) SetBSON(raw bson.Raw) error

SetBSON implemenets bson.Setter

func (*Token) UnmarshalJSON

func (t *Token) UnmarshalJSON(b []byte) error

func (Token) Validate

func (t Token) Validate() error

Validate function is used to verify if an instance of struct satisfies all the conditions for a valid instance

type TokenBalance

type TokenBalance struct {
	Address          common.Address `json:"address" bson:"address"`
	Symbol           string         `json:"symbol" bson:"symbol"`
	Decimals         int            `json:"decimals" bson:"decimals"`
	Balance          *big.Int       `json:"balance" bson:"balance"`
	AvailableBalance *big.Int       `json:"availableBalance" bson:"availableBalance"`
	InOrderBalance   *big.Int       `json:"inOrderBalance" bson:"inOrderBalance"`
	InUsdBalance     *big.Float     `json:"inUsdBalance" bson:"inUsdBalance"`
}

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

func (*TokenBalance) MarshalJSON

func (t *TokenBalance) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshal interface

func (*TokenBalance) UnmarshalJSON

func (t *TokenBalance) UnmarshalJSON(b []byte) error

type TokenBalanceRecord

type TokenBalanceRecord struct {
	Address          string `json:"address" bson:"address"`
	Symbol           string `json:"symbol" bson:"symbol"`
	Decimals         int    `json:"decimals" bson:"decimals"`
	Balance          string `json:"balance" bson:"balance"`
	AvailableBalance string `json:"availableBalance" base:"availableBalance"`
	InOrderBalance   string `json:"inOrderBalance" bson:"inOrderBalance"`
}

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"`
	RelayerAddress  string        `json:"relayerAddress" bson:"relayerAddress"`
	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 TopupSpec added in v1.2.0

type TopupSpec struct {
	UserAddress     string
	CollateralToken string
	LendingToken    string
	Term            string
	Status          string
	DateFrom        int64
	DateTo          int64
	Hash            string
}

TopupSpec filter topup

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"`
	PricePoint     *big.Int       `json:"pricepoint" bson:"pricepoint"`
	Amount         *big.Int       `json:"amount" bson:"amount"`
	MakeFee        *big.Int       `json:"makeFee" bson:"makeFee"`
	TakeFee        *big.Int       `json:"takeFee" bson:"takeFee"`
	Status         string         `json:"status" bson:"status"`
	CreatedAt      time.Time      `json:"createdAt" bson:"createdAt"`
	UpdatedAt      time.Time      `json:"updatedAt" bson:"updatedAt"`
	TakerOrderSide string         `json:"takerOrderSide" bson:"takerOrderSide"`
	TakerOrderType string         `json:"takerOrderType" bson:"takerOrderType"`
	MakerOrderType string         `json:"makerOrderType" bson:"makerOrderType"`
	MakerExchange  common.Address `json:"makerExchange" bson:"makerExchange"`
	TakerExchange  common.Address `json:"takerExchange" bson:"takerExchange"`
}

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

func NewTrade(mo *Order, to *Order, amount *big.Int, pricepoint *big.Int) *Trade

NewTrade returns a new unsigned trade corresponding to an Order, amount and taker address

func (*Trade) ComputeHash

func (t *Trade) ComputeHash() common.Hash

ComputeHash returns hashes the trade The OrderHash, Amount, Taker and TradeNonce attributes must be set before attempting to compute the trade hash

func (*Trade) GetBSON

func (t *Trade) GetBSON() (interface{}, error)

func (*Trade) MarshalJSON

func (t *Trade) MarshalJSON() ([]byte, error)

MarshalJSON returns the json encoded byte array representing the trade struct

func (*Trade) Pair

func (t *Trade) Pair() (*Pair, error)

func (*Trade) QuoteAmount

func (t *Trade) QuoteAmount(p *Pair) *big.Int

func (*Trade) SetBSON

func (t *Trade) SetBSON(raw bson.Raw) error

func (*Trade) UnmarshalJSON

func (t *Trade) UnmarshalJSON(b []byte) error

UnmarshalJSON creates a trade object from a json byte string

func (*Trade) Validate

func (t *Trade) Validate() error

type TradeBSONUpdate

type TradeBSONUpdate struct {
	*Trade
}

func (TradeBSONUpdate) GetBSON

func (t TradeBSONUpdate) GetBSON() (interface{}, error)

type TradeChangeEvent

type TradeChangeEvent struct {
	ID                interface{} `bson:"_id"`
	OperationType     string      `bson:"operationType"`
	FullDocument      *Trade      `bson:"fullDocument,omitempty"`
	Ns                evNamespace `bson:"ns"`
	DocumentKey       M           `bson:"documentKey"`
	UpdateDescription *updateDesc `bson:"updateDescription,omitempty"`
}

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"`
	Amount         string        `json:"amount" bson:"amount"`
	MakeFee        string        `json:"makeFee" bson:"makeFee"`
	TakeFee        string        `json:"takeFee" bson:"takeFee"`
	PricePoint     string        `json:"pricepoint" bson:"pricepoint"`
	Status         string        `json:"status" bson:"status"`
	CreatedAt      time.Time     `json:"createdAt" bson:"createdAt"`
	UpdatedAt      time.Time     `json:"updatedAt" bson:"updatedAt"`
	TakerOrderSide string        `json:"takerOrderSide" bson:"takerOrderSide"`
	TakerOrderType string        `json:"takerOrderType" bson:"takerOrderType"`
	MakerOrderType string        `json:"makerOrderType" bson:"makerOrderType"`
	MakerExchange  string        `json:"makerExchange" bson:"makerExchange"`
	TakerExchange  string        `json:"takerExchange" bson:"takerExchange"`
}

type TradeRes

type TradeRes struct {
	Total  int      `json:"total" bson:"total"`
	Trades []*Trade `json:"trades" bson:"orders"`
}

TradeRes response api

type TradeSpec

type TradeSpec struct {
	BaseToken      string
	QuoteToken     string
	RelayerAddress common.Address
	DateFrom       int64
	DateTo         int64
}

TradeSpec for query

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

func NewWalletFromPrivateKey(key string) *Wallet

NewWalletFromPrivateKey returns a new wallet object corresponding to a given private key

func (*Wallet) GetAddress

func (w *Wallet) GetAddress() string

GetAddress returns the wallet address

func (*Wallet) GetBSON

func (w *Wallet) GetBSON() (interface{}, error)

func (*Wallet) GetPrivateKey

func (w *Wallet) GetPrivateKey() string

GetPrivateKey returns the wallet private key

func (*Wallet) SetBSON

func (w *Wallet) SetBSON(raw bson.Raw) error

func (*Wallet) SignHash

func (w *Wallet) SignHash(h common.Hash) (*Signature, error)

SignHash signs a hashed message with a wallet private key and returns it as a Signature object

func (*Wallet) SignOrder

func (w *Wallet) SignOrder(o *Order) error

func (*Wallet) Validate

func (w *Wallet) Validate() error

type WalletRecord

type WalletRecord struct {
	ID         bson.ObjectId `json:"id,omitempty" bson:"_id"`
	Address    string        `json:"address" bson:"address"`
	PrivateKey string        `json:"privateKey" bson:"privateKey"`
	Admin      bool          `json:"admin" bson:"admin"`
	Operator   bool          `json:"operator" bson:"operator"`
}

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

Jump to

Keyboard shortcuts

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