models

package
v0.0.0-...-fed0080 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OP_OR = "or"
)

Variables

View Source
var DB *sqlx.DB

Functions

func ConnectDatabase

func ConnectDatabase(driver, url string) *sqlx.DB

func GetBaseTokenDecimals

func GetBaseTokenDecimals(marketID string) int

func GetBaseTokenSymbol

func GetBaseTokenSymbol(marketID string) string

func InitTestDB

func InitTestDB()

func MockMarketDao

func MockMarketDao()

func MockTradeDao

func MockTradeDao()

func ToSnake

func ToSnake(camel string) string

func UpdateLaunchLogToPending

func UpdateLaunchLogToPending(launchLog *LaunchLog) (err error)

Types

type ECSignature

type ECSignature struct {
	Config string `json:"config"`
	R      string `json:"r"`
	S      string `json:"s"`
}

type IBalanceDao

type IBalanceDao interface {
	GetByAccountAndSymbol(account, tokenSymbol string, decimals int) decimal.Decimal
}

IBalanceDao is an interface about how to fetch balance data from storage

var BalanceDao IBalanceDao

type ILaunchLogDao

type ILaunchLogDao interface {
	FindLaunchLogByID(int) *LaunchLog
	FindByHash(hash string) *LaunchLog
	FindPendingLogWithMaxNonce() int64
	FindAllCreated() []*LaunchLog
	UpdateLaunchLog(*LaunchLog) error
	InsertLaunchLog(*LaunchLog) error
	UpdateLaunchLogsStatusByItemID(string, int64) error
}
var LaunchLogDao ILaunchLogDao

type IMarketDao

type IMarketDao interface {
	FindAllMarkets() []*Market
	FindMarketByID(marketID string) *Market
	InsertMarket(market *Market) error
	UpdateMarket(market *Market) error
}
var MarketDao IMarketDao

type IOrderDao

type IOrderDao interface {
	FindMarketPendingOrders(marketID string) []*Order
	FindByAccount(trader, marketID, status string, offset, limit int) (int64, []*Order)
	FindByID(id string) *Order
	InsertOrder(order *Order) error
	UpdateOrder(order *Order) error
	Count() int
}
var OrderDao IOrderDao

type ITokenDao

type ITokenDao interface {
	GetAllTokens() []*Token
	InsertToken(*Token) error
	FindTokenBySymbol(string) *Token
}
var TokenDao ITokenDao

type ITradeDao

type ITradeDao interface {
	FindTradesByMarket(pair string, startTime time.Time, endTime time.Time) []*Trade
	FindAllTrades(marketID string) (int64, []*Trade)
	FindTradesByHash(hash string) []*Trade
	FindTradeByID(id int64) *Trade
	FindAccountMarketTrades(account, marketID, status string, limit, offset int) (int64, []*Trade)

	InsertTrade(trade *Trade) error
	UpdateTrade(trade *Trade) error
	Count() int
	FindTradeByTransactionID(transactionID int64) []*Trade
}
var TradeDao ITradeDao

type ITransactionDao

type ITransactionDao interface {
	FindTransactionByHash(transactionHash string) *Transaction
	InsertTransaction(transaction *Transaction) error
	UpdateTransaction(transaction *Transaction) error
	UpdateTransactionStatus(status, hash string) error
	Count() int
	FindTransactionByID(id int64) *Transaction
}
var TransactionDao ITransactionDao

type LaunchLog

type LaunchLog struct {
	ID       int64          `db:"id" auto:"true" primaryKey:"true" autoIncrement:"true"`
	ItemType string         `db:"item_type"`
	ItemID   int64          `db:"item_id"`
	Status   string         `db:"status"`
	Hash     sql.NullString `db:"transaction_hash"`

	BlockNumber sql.NullInt64 `db:"block_number"`

	From     string              `db:"t_from"`
	To       string              `db:"t_to"`
	Value    decimal.Decimal     `db:"value"`
	GasLimit int64               `db:"gas_limit"`
	GasUsed  sql.NullInt64       `db:"gas_used"`
	GasPrice decimal.NullDecimal `db:"gas_price"`
	Nonce    sql.NullInt64       `db:"nonce"`
	Data     string              `db:"data"`

	ExecutedAt time.Time `db:"executed_at"`
	CreatedAt  time.Time `db:"created_at"`
	UpdatedAt  time.Time `db:"updated_at"`
}

type MCache

type MCache struct {
	mock.Mock
}

func (*MCache) Get

func (m *MCache) Get(key string) (string, error)

func (*MCache) Pop

func (m *MCache) Pop() ([]byte, error)

func (*MCache) Push

func (m *MCache) Push(key []byte) error

func (*MCache) Set

func (m *MCache) Set(key string, value string, expire time.Duration) error

type MErc20

type MErc20 struct {
	mock.Mock
}

func (*MErc20) Allowance

func (m *MErc20) Allowance(contract, owner, spender string) (decimal.Decimal, error)

func (*MErc20) BalanceOf

func (m *MErc20) BalanceOf(contract, owner string) (decimal.Decimal, error)

type MLockedBalanceDao

type MLockedBalanceDao struct {
	mock.Mock
}

func (*MLockedBalanceDao) GetByAccountAndSymbol

func (m *MLockedBalanceDao) GetByAccountAndSymbol(account, tokenSymbol string, decimals int) decimal.Decimal

type MMarketDao

type MMarketDao struct {
	mock.Mock
}

func (*MMarketDao) FindAllMarkets

func (m *MMarketDao) FindAllMarkets() []*Market

func (*MMarketDao) FindMarketByID

func (m *MMarketDao) FindMarketByID(marketID string) *Market

func (*MMarketDao) InsertMarket

func (m *MMarketDao) InsertMarket(market *Market) error

func (*MMarketDao) UpdateMarket

func (m *MMarketDao) UpdateMarket(market *Market) error

type MTradeDao

type MTradeDao struct {
	mock.Mock
}

func (*MTradeDao) Count

func (m *MTradeDao) Count() int

func (*MTradeDao) FindAccountMarketTrades

func (m *MTradeDao) FindAccountMarketTrades(account, marketID, status string, limit, offset int) (int64, []*Trade)

func (*MTradeDao) FindAllTrades

func (m *MTradeDao) FindAllTrades(marketID string) (int64, []*Trade)

func (*MTradeDao) FindTradeByID

func (m *MTradeDao) FindTradeByID(id int64) *Trade

func (*MTradeDao) FindTradeByTransactionID

func (m *MTradeDao) FindTradeByTransactionID(transactionID int64) []*Trade

func (*MTradeDao) FindTradesByHash

func (m *MTradeDao) FindTradesByHash(hash string) []*Trade

func (*MTradeDao) FindTradesByMarket

func (m *MTradeDao) FindTradesByMarket(pair string, startTime time.Time, endTime time.Time) []*Trade

func (*MTradeDao) InsertTrade

func (m *MTradeDao) InsertTrade(trade *Trade) error

func (*MTradeDao) UpdateTrade

func (m *MTradeDao) UpdateTrade(trade *Trade) error

type Market

type Market struct {
	ID                string `json:"id"                db:"id" primaryKey:"true"`
	BaseTokenSymbol   string `json:"baseTokenSymbol"   db:"base_token_symbol"`
	BaseTokenName     string `json:"BaseTokenName"     db:"base_token_name"`
	BaseTokenAddress  string `json:"baseTokenAddress"  db:"base_token_address"`
	BaseTokenDecimals int    `json:"baseTokenDecimals" db:"base_token_decimals"`

	QuoteTokenSymbol   string `json:"quoteTokenSymbol"   db:"quote_token_symbol"`
	QuoteTokenName     string `json:"QuoteTokenName"     db:"quote_token_name"`
	QuoteTokenAddress  string `json:"quoteTokenAddress"  db:"quote_token_address"`
	QuoteTokenDecimals int    `json:"quoteTokenDecimals" db:"quote_token_decimals"`

	MinOrderSize      decimal.Decimal `json:"minOrderSize"      db:"min_order_size"`
	PricePrecision    int             `json:"pricePrecision"    db:"price_precision"`
	PriceDecimals     int             `json:"priceDecimals"     db:"price_decimals"`
	AmountDecimals    int             `json:"amountDecimals"    db:"amount_decimals"`
	MakerFeeRate      decimal.Decimal `json:"makerFeeRate"      db:"maker_fee_rate"`
	TakerFeeRate      decimal.Decimal `json:"takerFeeRate"      db:"taker_fee_rate"`
	GasUsedEstimation int             `json:"gasUsedEstimation" db:"gas_used_estimation"`
	IsPublished       bool            `json:"isPublished"       db:"is_published"`
}

func MarketHotDai

func MarketHotDai() *Market

default models

type Op

type Op interface {
	GetSqlAndValues(index int) (string, []interface{})
}

type OpEq

type OpEq struct {
	Field string
	Value interface{}
}

func (*OpEq) GetSqlAndValues

func (op *OpEq) GetSqlAndValues(index int) (string, []interface{})

type OpGt

type OpGt struct {
	Field string
	Value interface{}
}

func (*OpGt) GetSqlAndValues

func (op *OpGt) GetSqlAndValues(index int) (string, []interface{})

type OpList

type OpList struct {
	// contains filtered or unexported fields
}

func (*OpList) GetSqlAndValues

func (opList *OpList) GetSqlAndValues(index int) (string, []interface{})

type OpLt

type OpLt struct {
	Field string
	Value interface{}
}

func (*OpLt) GetSqlAndValues

func (op *OpLt) GetSqlAndValues(index int) (string, []interface{})

type Order

type Order struct {
	ID              string          `json:"id" db:"id" primaryKey:"true"`
	TraderAddress   string          `json:"traderAddress" db:"trader_address"`
	MarketID        string          `json:"marketID" db:"market_id"`
	Side            string          `json:"side" db:"side"`
	Price           decimal.Decimal `json:"price" db:"price"`
	Amount          decimal.Decimal `json:"amount" db:"amount"`
	Status          string          `json:"status" db:"status"`
	Type            string          `json:"type" db:"type"`
	Version         string          `json:"version" db:"version"`
	AvailableAmount decimal.Decimal `json:"availableAmount" db:"available_amount"`
	ConfirmedAmount decimal.Decimal `json:"confirmedAmount" db:"confirmed_amount"`
	CanceledAmount  decimal.Decimal `json:"canceledAmount" db:"canceled_amount"`
	PendingAmount   decimal.Decimal `json:"pendingAmount" db:"pending_amount"`
	MakerFeeRate    decimal.Decimal `json:"makerFeeRate" db:"maker_fee_rate"`
	TakerFeeRate    decimal.Decimal `json:"takerFeeRate" db:"taker_fee_rate"`
	MakerRebateRate decimal.Decimal `json:"makerRebateRate" db:"maker_rebate_rate"`
	GasFeeAmount    decimal.Decimal `json:"gasFeeAmount" db:"gas_fee_amount"`
	JSON            string          `json:"json" db:"json"`
	CreatedAt       time.Time       `json:"createdAt" db:"created_at"`
	UpdatedAt       time.Time       `json:"updatedAt" db:"updated_at"`
}

func (*Order) AutoSetStatusByAmounts

func (o *Order) AutoSetStatusByAmounts()

func (Order) GetOrderJson

func (o Order) GetOrderJson() *OrderJSON

type OrderByDirection

type OrderByDirection uint
const (
	OrderByAsc OrderByDirection = iota
	OrderByDesc
)

type OrderJSON

type OrderJSON struct {
	Trader                  string          `json:"trader"`
	Relayer                 string          `json:"relayer"`
	BaseCurrencyHugeAmount  decimal.Decimal `json:"baseTokenAmount"`
	QuoteCurrencyHugeAmount decimal.Decimal `json:"quoteTokenAmount"`
	BaseCurrency            string          `json:"baseToken"`
	QuoteCurrency           string          `json:"quoteToken"`
	GasTokenHugeAmount      decimal.Decimal `json:"gasTokenAmount"`
	Signature               string          `json:"signature"`
	Data                    string          `json:"data"`
}

type Token

type Token struct {
	Symbol   string `json:"symbol"   db:"symbol"`
	Name     string `json:"name"     db:"name"`
	Decimals int    `json:"decimals" db:"decimals"`
	Address  string `json:"address"  db:"address"`
}

type Trade

type Trade struct {
	ID              int64           `json:"id"               db:"id" primaryKey:"true" autoIncrement:"true"`
	TransactionID   int64           `json:"transactionID"    db:"transaction_id"`
	TransactionHash string          `json:"transactionHash"  db:"transaction_hash"`
	Status          string          `json:"status"           db:"status"`
	MarketID        string          `json:"marketID"         db:"market_id"`
	Maker           string          `json:"maker"            db:"maker"`
	Taker           string          `json:"taker"            db:"taker"`
	TakerSide       string          `json:"takerSide"        db:"taker_side"`
	MakerOrderID    string          `json:"makerOrderID"     db:"maker_order_id"`
	TakerOrderID    string          `json:"takerOrderID"     db:"taker_order_id"`
	Sequence        int             `json:"sequence"         db:"sequence"`
	Amount          decimal.Decimal `json:"amount"           db:"amount"`
	Price           decimal.Decimal `json:"price"            db:"price"`
	ExecutedAt      time.Time       `json:"executedAt"       db:"executed_at"`
	CreatedAt       time.Time       `json:"createdAt"        db:"created_at"`
	UpdatedAt       time.Time       `json:"updatedAt"        db:"updated_at"`
}

type Transaction

type Transaction struct {
	ID              int64           `json:"id"              db:"id" primaryKey:"true"  autoIncrement:"true"`
	MarketID        string          `json:"marketID"        db:"market_id"`
	TransactionHash *sql.NullString `json:"transactionHash" db:"transaction_hash"`
	Status          string          `json:"status"          db:"status"`
	ExecutedAt      time.Time       `json:"executedAt"      db:"executed_at"`
	UpdatedAt       time.Time       `json:"updatedAt"       db:"updated_at"`
	CreatedAt       time.Time       `json:"createdAt"       db:"created_at"`
}

Jump to

Keyboard shortcuts

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