models

package
v0.0.0-...-5f38ebe Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const TestUser1 = "0xe36ea790bc9d7ab70c55260c66d52b1eca985f84"
View Source
const TestUser2 = "0xe834ec434daba538cd1b9fe1582052b880bd7e63"

Variables

View Source
var DB *gorm.DB
View Source
var KeyGenerator *utils.AddressGenerator

Functions

func ConfigKeyGenerator

func ConfigKeyGenerator(masterKey string)

func Connect

func Connect(url string) *gorm.DB

func GetBaseTokenDecimals

func GetBaseTokenDecimals(marketID string) int

func GetBaseTokenSymbol

func GetBaseTokenSymbol(marketID string) string

func InitTestDBPG

func InitTestDBPG()

func MockMarketDao

func MockMarketDao()

func MockTradeDao

func MockTradeDao()

func UpdateLaunchLogToPending

func UpdateLaunchLogToPending(launchLog *LaunchLog) (err error)

Types

type AssociationRow

type AssociationRow struct {
	ID                 uint64
	BaseAddress        string
	QuoteAddress       string
	Status             string
	BlockNumber        int
	CurrentBlockNumber int
	TxtReciver         pq.StringArray
}

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
var BalanceDaoPG 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
var LaunchLogDaoPG ILaunchLogDao

type IMarketDao

type IMarketDao interface {
	FindAllMarkets() []*Market
	FindPublishedMarkets() []*Market
	FindMarketByID(marketID string) *Market
	InsertMarket(market *Market) error
	UpdateMarket(market *Market) error
}
var MarketDao IMarketDao
var MarketDaoPG 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
var OrderDaoPG IOrderDao

type ITokenDao

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

type ITradeDao

type ITradeDao interface {
	FindTradesByMarket(marketID 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
var TradeDaoPG 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
var TransactionDaoPG ITransactionDao

type LaunchLog

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

	From     string              `db:"t_from" gorm:"column:t_from"`
	To       string              `db:"t_to"   gorm:"column: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"`
}

func (LaunchLog) TableName

func (LaunchLog) TableName() string

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) FindPublishedMarkets

func (m *MMarketDao) FindPublishedMarkets() []*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" gorm:"primary_key"`
	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

func (Market) TableName

func (Market) TableName() string

type Order

type Order struct {
	ID              string          `json:"id" db:"id" primaryKey:"true" gorm:"primary_key"`
	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

func (Order) TableName

func (Order) TableName() string

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" gorm:"primary_key"`
	Name     string `json:"name"     db:"name"`
	Decimals int    `json:"decimals" db:"decimals"`
	Address  string `json:"address"  db:"address"`
}

func (Token) TableName

func (Token) TableName() string

type Trade

type Trade struct {
	ID              int64           `json:"id"               db:"id" primaryKey:"true" autoIncrement:"true" gorm:"primary_key"`
	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"`
}

func (Trade) TableName

func (Trade) TableName() string

type Transaction

type Transaction struct {
	ID              int64           `json:"id"              db:"id" primaryKey:"true"  autoIncrement:"true" gorm:"primary_key"`
	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"`
}

func (Transaction) TableName

func (Transaction) TableName() string

Jump to

Keyboard shortcuts

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