Documentation ¶
Index ¶
- Constants
- Variables
- type AccountService
- func (s *AccountService) AddFavoriteToken(owner, token common.Address) error
- func (s *AccountService) Create(a *types.Account) error
- func (s *AccountService) DeleteFavoriteToken(owner, token common.Address) error
- func (s *AccountService) FindOrCreate(addr common.Address) (*types.Account, error)
- func (s *AccountService) GetAll() ([]types.Account, error)
- func (s *AccountService) GetByAddress(a common.Address) (*types.Account, error)
- func (s *AccountService) GetByID(id bson.ObjectId) (*types.Account, error)
- func (s *AccountService) GetFavoriteTokens(owner common.Address) (map[common.Address]bool, error)
- func (s *AccountService) GetTokenBalance(owner common.Address, token common.Address) (*types.TokenBalance, error)
- func (s *AccountService) GetTokenBalanceProvidor(owner common.Address, tokenAddress common.Address) (*types.TokenBalance, error)
- func (s *AccountService) GetTokenBalances(owner common.Address) (map[common.Address]*types.TokenBalance, error)
- func (s *AccountService) GetTokenBalancesProvidor(owner common.Address) (map[common.Address]*types.TokenBalance, error)
- func (s *AccountService) Transfer(token common.Address, fromAddress common.Address, toAddress common.Address, ...) error
- type LendingMarketsService
- type LendingOhlcvService
- func (s *LendingOhlcvService) Get24hTick(term uint64, lendingToken common.Address) *types.LendingTick
- func (s *LendingOhlcvService) GetAllTokenPairData() ([]*types.LendingTick, error)
- func (s *LendingOhlcvService) GetLendingVolumeByCoinbase(addr common.Address, years, months, days int) (*big.Int, *big.Int, error)
- func (s *LendingOhlcvService) GetOHLCV(term uint64, lendingToken common.Address, duration int64, unit string, ...) ([]*types.LendingTick, error)
- func (s *LendingOhlcvService) GetTokenPairData(term uint64, lendingToken common.Address) *types.LendingTick
- func (s *LendingOhlcvService) Init()
- func (s *LendingOhlcvService) NotifyTrade(trade *types.LendingTrade)
- func (s *LendingOhlcvService) Subscribe(conn *ws.Client, p *types.SubscriptionPayload)
- func (s *LendingOhlcvService) Unsubscribe(conn *ws.Client)
- func (s *LendingOhlcvService) UnsubscribeChannel(conn *ws.Client, p *types.SubscriptionPayload)
- type LendingOrderBookService
- func (s *LendingOrderBookService) GetLendingOrderBook(term uint64, lendingToken common.Address) (*types.LendingOrderBook, error)
- func (s *LendingOrderBookService) GetLendingOrderBookInDb(term uint64, lendingToken common.Address) (*types.LendingOrderBook, error)
- func (s *LendingOrderBookService) SubscribeLendingOrderBook(c *ws.Client, term uint64, lendingToken common.Address)
- func (s *LendingOrderBookService) UnsubscribeLendingOrderBook(c *ws.Client)
- func (s *LendingOrderBookService) UnsubscribeLendingOrderBookChannel(c *ws.Client, term uint64, lendingToken common.Address)
- type LendingOrderService
- func (s *LendingOrderService) CancelLendingOrder(o *types.LendingOrder) error
- func (s *LendingOrderService) EstimateCollateral(collateralToken common.Address, lendingToken common.Address, ...) (*big.Float, *big.Float, error)
- func (s *LendingOrderService) GetByHash(hash common.Hash) (*types.LendingOrder, error)
- func (s *LendingOrderService) GetLendingNonceByUserAddress(addr common.Address) (uint64, error)
- func (s *LendingOrderService) GetLendingOrders(lendingSpec types.LendingSpec, sort []string, offset int, size int) (*types.LendingRes, error)
- func (s *LendingOrderService) GetRecall(recallSpec types.RecallSpec, sort []string, offset int, size int) (*types.LendingRes, error)
- func (s *LendingOrderService) GetRepay(repaySpec types.RepaySpec, sort []string, offset int, size int) (*types.LendingRes, error)
- func (s *LendingOrderService) GetTopup(topupSpec types.TopupSpec, sort []string, offset int, size int) (*types.LendingRes, error)
- func (s *LendingOrderService) HandleDocumentType(ev types.LendingOrderChangeEvent, docType string) error
- func (s *LendingOrderService) HandleLendingOrderResponse(res *types.EngineResponse) error
- func (s *LendingOrderService) HandleLendingOrdersCreateCancel(msg *rabbitmq.Message) error
- func (s *LendingOrderService) NewLendingOrder(o *types.LendingOrder) error
- func (s *LendingOrderService) RepayLendingOrder(o *types.LendingOrder) error
- func (s *LendingOrderService) TopupLendingOrder(o *types.LendingOrder) error
- func (s *LendingOrderService) WatchChanges()
- type LendingPairService
- type LendingPriceBoardService
- func (s *LendingPriceBoardService) GetLendingPriceBoardData(term uint64, lendingToken common.Address) *types.LendingTick
- func (s *LendingPriceBoardService) Subscribe(c *ws.Client, term uint64, lendingToken common.Address)
- func (s *LendingPriceBoardService) Unsubscribe(c *ws.Client)
- func (s *LendingPriceBoardService) UnsubscribeChannel(c *ws.Client, term uint64, lendingToken common.Address)
- type LendingTradeService
- func (s *LendingTradeService) GetLendingTradeByOrderBook(tern uint64, lendingToken common.Address, from, to int64, n int) ([]*types.LendingTrade, error)
- func (s *LendingTradeService) GetLendingTradeByTime(dateFrom, dateTo int64, pageOffset int, pageSize int) ([]*types.LendingTrade, error)
- func (s *LendingTradeService) GetLendingTrades(lendingtradeSpec *types.LendingTradeSpec, sortedBy []string, pageOffset int, ...) (*types.LendingTradeRes, error)
- func (s *LendingTradeService) GetLendingTradesUserHistory(a common.Address, lendingtradeSpec *types.LendingTradeSpec, sortedBy []string, ...) (*types.LendingTradeRes, error)
- func (s *LendingTradeService) HandleDocumentType(ev types.LendingTradeChangeEvent) error
- func (s *LendingTradeService) HandleLendingTradeResponse(res *types.EngineResponse) error
- func (s *LendingTradeService) HandleOperationInsert(trade *types.LendingTrade) error
- func (s *LendingTradeService) HandleOperationUpdate(trade *types.LendingTrade) error
- func (s *LendingTradeService) HandleTradeSuccess(m *types.LendingMatches)
- func (s *LendingTradeService) RegisterNotify(fn func(*types.LendingTrade))
- func (s *LendingTradeService) Subscribe(c *ws.Client, term uint64, lendingToken common.Address)
- func (s *LendingTradeService) Unsubscribe(c *ws.Client)
- func (s *LendingTradeService) UnsubscribeChannel(c *ws.Client, term uint64, lendingToken common.Address)
- func (s *LendingTradeService) WatchChanges()
- type MarketsService
- type NotificationService
- func (s *NotificationService) Create(n *types.Notification) ([]*types.Notification, error)
- func (s *NotificationService) GetAll() ([]types.Notification, error)
- func (s *NotificationService) GetByID(id bson.ObjectId) (*types.Notification, error)
- func (s *NotificationService) GetByUserAddress(addr common.Address, limit int, offset int) ([]*types.Notification, error)
- func (s *NotificationService) GetSortDecByUserAddress(addr common.Address, limit int, offset int) ([]*types.Notification, error)
- func (s *NotificationService) MarkAllRead(addr common.Address) error
- func (s *NotificationService) MarkRead(id bson.ObjectId) error
- func (s *NotificationService) MarkUnRead(id bson.ObjectId) error
- func (s *NotificationService) Update(n *types.Notification) (*types.Notification, error)
- type OHLCVService
- func (s *OHLCVService) Get24hTick(baseToken, quoteToken common.Address) *types.Tick
- func (s *OHLCVService) GetAllTokenPairData() ([]*types.PairData, error)
- func (s *OHLCVService) GetAllTokenPairDataByCoinbase(addr common.Address) ([]*types.PairData, error)
- func (s *OHLCVService) GetFiatPriceChart() (map[string][]*types.FiatPriceItem, error)
- func (s *OHLCVService) GetLastPriceCurrentByTime(symbol string, createAt time.Time) (*big.Float, error)
- func (s *OHLCVService) GetOHLCV(pairs []types.PairAddresses, duration int64, unit string, ...) ([]*types.Tick, error)
- func (s *OHLCVService) GetPairPrice(pairName string, timestamp int64) (int64, error)
- func (s *OHLCVService) GetTokenPairData(baseToken common.Address, quoteToken common.Address) *types.PairData
- func (s *OHLCVService) GetTokenPriceByUsdt(token common.Address) (*big.Int, error)
- func (s *OHLCVService) GetVolumeByCoinbase(addr common.Address, years, months, days int) (*big.Int, *big.Int, error)
- func (s *OHLCVService) GetVolumeByUsdt(token common.Address, volume *big.Int) *big.Int
- func (s *OHLCVService) Init()
- func (s *OHLCVService) NotifyTrade(trade *types.Trade)
- func (s *OHLCVService) Subscribe(conn *ws.Client, p *types.SubscriptionPayload)
- func (s *OHLCVService) Unsubscribe(conn *ws.Client)
- func (s *OHLCVService) UnsubscribeChannel(conn *ws.Client, p *types.SubscriptionPayload)
- type OrderBookService
- func (s *OrderBookService) GetDbOrderBook(bt, qt common.Address) (*types.OrderBook, error)
- func (s *OrderBookService) GetOrderBook(bt, qt common.Address) (*types.OrderBook, error)
- func (s *OrderBookService) GetRawOrderBook(bt, qt common.Address) (*types.RawOrderBook, error)
- func (s *OrderBookService) SubscribeOrderBook(c *ws.Client, bt, qt common.Address)
- func (s *OrderBookService) SubscribeRawOrderBook(c *ws.Client, bt, qt common.Address)
- func (s *OrderBookService) UnsubscribeOrderBook(c *ws.Client)
- func (s *OrderBookService) UnsubscribeOrderBookChannel(c *ws.Client, bt, qt common.Address)
- func (s *OrderBookService) UnsubscribeRawOrderBook(c *ws.Client)
- func (s *OrderBookService) UnsubscribeRawOrderBookChannel(c *ws.Client, bt, qt common.Address)
- type OrderService
- func (s *OrderService) CancelAllOrder(a common.Address) error
- func (s *OrderService) CancelOrder(oc *types.OrderCancel) error
- func (s *OrderService) GetBestAsk(baseToken, quouteToken common.Address) (*types.PriceVolume, error)
- func (s *OrderService) GetBestBid(baseToken, quouteToken common.Address) (*types.PriceVolume, error)
- func (s *OrderService) GetByHash(hash common.Hash) (*types.Order, error)
- func (s *OrderService) GetByHashes(hashes []common.Hash) ([]*types.Order, error)
- func (s *OrderService) GetByID(id bson.ObjectId) (*types.Order, error)
- func (s *OrderService) GetByUserAddress(a, bt, qt common.Address, from, to int64, limit ...int) ([]*types.Order, error)
- func (s *OrderService) GetCurrentByUserAddress(addr common.Address, limit ...int) ([]*types.Order, error)
- func (s *OrderService) GetHistoryByUserAddress(addr, bt, qt common.Address, from, to int64, limit ...int) ([]*types.Order, error)
- func (s *OrderService) GetOrderBookPricePoint(baseToken, quoteToken common.Address, pricepoint *big.Int, side string) (*big.Int, error)
- func (s *OrderService) GetOrderCountByUserAddress(addr common.Address) (int, error)
- func (s *OrderService) GetOrderNonceByUserAddress(addr common.Address) (interface{}, error)
- func (s *OrderService) GetOrders(orderSpec types.OrderSpec, sort []string, offset int, size int) (*types.OrderRes, error)
- func (s *OrderService) GetOrdersLockedBalanceByUserAddress(addr common.Address) (map[string]*big.Int, error)
- func (s *OrderService) HandleDocumentType(ev types.OrderChangeEvent) error
- func (s *OrderService) HandleEngineResponse(res *types.EngineResponse) error
- func (s *OrderService) LoadCache()
- func (s *OrderService) NewOrder(o *types.Order) error
- func (s *OrderService) WatchChanges()
- type PairCache
- type PairService
- func (s *PairService) Create(pair *types.Pair) error
- func (s *PairService) CreatePairs(addr common.Address) ([]*types.Pair, error)
- func (s *PairService) GetAll() ([]types.Pair, error)
- func (s *PairService) GetAllByCoinbase(addr common.Address) ([]types.Pair, error)
- func (s *PairService) GetAllTokenPairData() ([]*types.PairData, error)
- func (s *PairService) GetAllTokenPairDataByCoinbase(addr common.Address) ([]*types.PairData, error)
- func (s *PairService) GetByID(id bson.ObjectId) (*types.Pair, error)
- func (s *PairService) GetByTokenAddress(bt, qt common.Address) (*types.Pair, error)
- func (s *PairService) GetTokenPairData(bt, qt common.Address) (*types.PairData, error)
- type PriceBoardService
- func (s *PriceBoardService) GetPriceBoardData(pairs []types.PairAddresses, duration int64, unit string, ...) ([]*types.Tick, error)
- func (s *PriceBoardService) Subscribe(c *ws.Client, bt, qt common.Address)
- func (s *PriceBoardService) Unsubscribe(c *ws.Client)
- func (s *PriceBoardService) UnsubscribeChannel(c *ws.Client, bt, qt common.Address)
- type PriceUsdt
- type RelayerService
- func (s *RelayerService) GetAll() ([]types.Relayer, error)
- func (s *RelayerService) GetByAddress(addr common.Address) (*types.Relayer, error)
- func (s *RelayerService) GetRelayerAddress(r *http.Request) common.Address
- func (s *RelayerService) UpdateNameByAddress(addr common.Address, name string, url string) error
- func (s *RelayerService) UpdateRelayer(coinbase common.Address) error
- func (s *RelayerService) UpdateRelayers() error
- type TokenCache
- type TokenService
- func (s *TokenService) Create(token *types.Token) error
- func (s *TokenService) GetAll() ([]types.Token, error)
- func (s *TokenService) GetAllByCoinbase(addr common.Address) ([]types.Token, error)
- func (s *TokenService) GetBaseTokens() ([]types.Token, error)
- func (s *TokenService) GetByAddress(addr common.Address) (*types.Token, error)
- func (s *TokenService) GetByID(id bson.ObjectId) (*types.Token, error)
- func (s *TokenService) GetQuoteTokens() ([]types.Token, error)
- type TradeService
- func (s *TradeService) GetAllTradesByPairAddress(bt, qt common.Address) ([]*types.Trade, error)
- func (s *TradeService) GetByHash(h common.Hash) (*types.Trade, error)
- func (s *TradeService) GetByMakerOrderHash(h common.Hash) ([]*types.Trade, error)
- func (s *TradeService) GetByOrderHashes(hashes []common.Hash) ([]*types.Trade, error)
- func (s *TradeService) GetByPairName(p string) ([]*types.Trade, error)
- func (s *TradeService) GetByTakerOrderHash(h common.Hash) ([]*types.Trade, error)
- func (s *TradeService) GetByUserAddress(a common.Address) ([]*types.Trade, error)
- func (s *TradeService) GetSortedTrades(bt, qt common.Address, from, to int64, n int) ([]*types.Trade, error)
- func (s *TradeService) GetSortedTradesByUserAddress(a, bt, qt common.Address, from, to int64, limit ...int) ([]*types.Trade, error)
- func (s *TradeService) GetTrades(tradeSpec *types.TradeSpec, sortedBy []string, pageOffset int, pageSize int) (*types.TradeRes, error)
- func (s *TradeService) GetTradesUserHistory(a common.Address, tradeSpec *types.TradeSpec, sortedBy []string, ...) (*types.TradeRes, error)
- func (s *TradeService) HandleDocumentType(ev types.TradeChangeEvent) error
- func (s *TradeService) HandleOperationInsert(trade *types.Trade) error
- func (s *TradeService) HandleOperationUpdate(trade *types.Trade) error
- func (s *TradeService) HandleTradeResponse(res *types.EngineResponse) error
- func (s *TradeService) HandleTradeSuccess(m *types.Matches)
- func (s *TradeService) Subscribe(c *ws.Client, bt, qt common.Address)
- func (s *TradeService) Unsubscribe(c *ws.Client)
- func (s *TradeService) UnsubscribeChannel(c *ws.Client, bt, qt common.Address)
- func (s *TradeService) WatchChanges()
- type TxService
- func (s *TxService) GetCustomTxSendOptions(w *types.Wallet) *bind.TransactOpts
- func (s *TxService) GetTxCallOptions() *bind.CallOpts
- func (s *TxService) GetTxDefaultSendOptions() (*bind.TransactOpts, error)
- func (s *TxService) GetTxSendOptions() (*bind.TransactOpts, error)
- func (s *TxService) SetTxSender(w *types.Wallet)
- type ValidatorService
- type WalletService
- func (s *WalletService) CreateAdminWallet(a common.Address) (*types.Wallet, error)
- func (s *WalletService) GetAll() ([]types.Wallet, error)
- func (s *WalletService) GetByAddress(a common.Address) (*types.Wallet, error)
- func (s *WalletService) GetDefaultAdminWallet() (*types.Wallet, error)
- func (s *WalletService) GetOperatorAddresses() ([]common.Address, error)
- func (s *WalletService) GetOperatorWallets() ([]*types.Wallet, error)
Constants ¶
const ( LENDING_EVENT = "ORDER" REPAY_EVENT = "REPAY" TOPUP_EVENT = "TOPUP" RECALL_EVENT = "RECALL" )
const (
// LendingCachePath OHL cache file name
LendingCachePath = "lending.cache"
)
Variables ¶
var ErrAccountExists = errors.New("Account already Exists")
var ErrAccountNotFound = errors.New("Account not found")
var ErrBaseTokenNotFound = errors.New("BaseToken not found")
var ErrNoContractCode = errors.New("Contract not found at given address")
var ErrPairExists = errors.New("Pairs already exists")
var ErrPairNotFound = errors.New("Pair not found")
var ErrQuoteTokenInvalid = errors.New("Quote Token Invalid (not a quote)")
var ErrQuoteTokenNotFound = errors.New("QuoteToken not found")
var ErrTokenExists = errors.New("Token already exists")
Functions ¶
This section is empty.
Types ¶
type AccountService ¶
type AccountService struct { AccountDao interfaces.AccountDao TokenDao interfaces.TokenDao PairDao interfaces.PairDao OrderDao interfaces.OrderDao LendingDao interfaces.LendingOrderDao Provider interfaces.EthereumProvider OHLCVService interfaces.OHLCVService }
func NewAccountService ¶
func NewAccountService( accountDao interfaces.AccountDao, tokenDao interfaces.TokenDao, pairDao interfaces.PairDao, orderDao interfaces.OrderDao, lendingDao interfaces.LendingOrderDao, provider interfaces.EthereumProvider, ohlcvService interfaces.OHLCVService, ) *AccountService
NewAccountService returns a new instance of accountService
func (*AccountService) AddFavoriteToken ¶
func (s *AccountService) AddFavoriteToken(owner, token common.Address) error
AddFavoriteToken add favorite token
func (*AccountService) DeleteFavoriteToken ¶
func (s *AccountService) DeleteFavoriteToken(owner, token common.Address) error
DeleteFavoriteToken delete favorite token
func (*AccountService) FindOrCreate ¶
FindOrCreate find or create if not found [Deprecated]
func (*AccountService) GetAll ¶
func (s *AccountService) GetAll() ([]types.Account, error)
GetAll get all account [Deprecated]
func (*AccountService) GetByAddress ¶
GetByAddress get account from address
func (*AccountService) GetFavoriteTokens ¶
GetFavoriteTokens get favorite token
func (*AccountService) GetTokenBalance ¶
func (s *AccountService) GetTokenBalance(owner common.Address, token common.Address) (*types.TokenBalance, error)
GetTokenBalance database [Deprecated]
func (*AccountService) GetTokenBalanceProvidor ¶
func (s *AccountService) GetTokenBalanceProvidor(owner common.Address, tokenAddress common.Address) (*types.TokenBalance, error)
GetTokenBalanceProvidor get balance from chain
func (*AccountService) GetTokenBalances ¶
func (s *AccountService) GetTokenBalances(owner common.Address) (map[common.Address]*types.TokenBalance, error)
GetTokenBalances Deprecated
func (*AccountService) GetTokenBalancesProvidor ¶
func (s *AccountService) GetTokenBalancesProvidor(owner common.Address) (map[common.Address]*types.TokenBalance, error)
GetTokenBalancesProvidor get balances from chain
type LendingMarketsService ¶ added in v1.2.0
type LendingMarketsService struct { LendingPairDao interfaces.LendingPairDao LendingOhlcvService interfaces.LendingOhlcvService }
LendingMarketsService struct with daos required, responsible for communicating with daos. LendingMarketsService functions are responsible for interacting with daos and implements business logics.
func NewLendingMarketsService ¶ added in v1.2.0
func NewLendingMarketsService( lendingPairDao interfaces.LendingPairDao, lendingOhlcvService interfaces.LendingOhlcvService, ) *LendingMarketsService
NewLendingMarketsService returns a new instance of TradeService
func (*LendingMarketsService) Subscribe ¶ added in v1.2.0
func (s *LendingMarketsService) Subscribe(c *ws.Client)
Subscribe market
func (*LendingMarketsService) Unsubscribe ¶ added in v1.2.0
func (s *LendingMarketsService) Unsubscribe(c *ws.Client)
Unsubscribe unsubscribe lending market socket
func (*LendingMarketsService) UnsubscribeChannel ¶ added in v1.2.0
func (s *LendingMarketsService) UnsubscribeChannel(c *ws.Client)
UnsubscribeChannel UnsubscribeChannel lending market socket
type LendingOhlcvService ¶ added in v1.2.0
type LendingOhlcvService struct {
// contains filtered or unexported fields
}
LendingOhlcvService ohlcv lending struct
func NewLendingOhlcvService ¶ added in v1.2.0
func NewLendingOhlcvService(lendingTradeService interfaces.LendingTradeService, ohlcv interfaces.OHLCVService, lendingPairDao interfaces.LendingPairDao) *LendingOhlcvService
NewLendingOhlcvService init new ohlcv service
func (*LendingOhlcvService) Get24hTick ¶ added in v1.2.0
func (s *LendingOhlcvService) Get24hTick(term uint64, lendingToken common.Address) *types.LendingTick
Get24hTick get 24h tick of token
func (*LendingOhlcvService) GetAllTokenPairData ¶ added in v1.2.0
func (s *LendingOhlcvService) GetAllTokenPairData() ([]*types.LendingTick, error)
GetAllTokenPairData get tick of all tokens
func (*LendingOhlcvService) GetLendingVolumeByCoinbase ¶ added in v1.2.1
func (s *LendingOhlcvService) GetLendingVolumeByCoinbase(addr common.Address, years, months, days int) (*big.Int, *big.Int, error)
GetLendingVolumeByCoinbase get total volume lending
func (*LendingOhlcvService) GetOHLCV ¶ added in v1.2.0
func (s *LendingOhlcvService) GetOHLCV(term uint64, lendingToken common.Address, duration int64, unit string, timeInterval ...int64) ([]*types.LendingTick, error)
GetOHLCV fetches OHLCV data using pairName: can be "" for fetching data for all pairs duration: in integer unit: sec,min,hour,day,week,month,yr timeInterval: 0-2 entries (0 argument: latest data,1st argument: from timestamp, 2nd argument: to timestamp)
func (*LendingOhlcvService) GetTokenPairData ¶ added in v1.2.0
func (s *LendingOhlcvService) GetTokenPairData(term uint64, lendingToken common.Address) *types.LendingTick
GetTokenPairData get tick of pair
func (*LendingOhlcvService) Init ¶ added in v1.2.0
func (s *LendingOhlcvService) Init()
Init init cache ensure add current time frame before trade notify come
func (*LendingOhlcvService) NotifyTrade ¶ added in v1.2.0
func (s *LendingOhlcvService) NotifyTrade(trade *types.LendingTrade)
NotifyTrade trigger if trade comming
func (*LendingOhlcvService) Subscribe ¶ added in v1.2.0
func (s *LendingOhlcvService) Subscribe(conn *ws.Client, p *types.SubscriptionPayload)
Subscribe handles all the subscription messages for ticks corresponding to a pair It calls the corresponding channel's subscription method and sends trade history back on the connection
func (*LendingOhlcvService) Unsubscribe ¶ added in v1.2.0
func (s *LendingOhlcvService) Unsubscribe(conn *ws.Client)
Unsubscribe handles all the unsubscription messages for ticks corresponding to a pair
func (*LendingOhlcvService) UnsubscribeChannel ¶ added in v1.2.0
func (s *LendingOhlcvService) UnsubscribeChannel(conn *ws.Client, p *types.SubscriptionPayload)
UnsubscribeChannel handles all the unsubscription messages for ticks corresponding to a pair
type LendingOrderBookService ¶ added in v1.2.0
type LendingOrderBookService struct {
// contains filtered or unexported fields
}
LendingOrderBookService struct with daos required, responsible for communicating with daos. PairService functions are responsible for interacting with daos and implements business logics.
func NewLendingOrderBookService ¶ added in v1.2.0
func NewLendingOrderBookService( lendingOrderDao interfaces.LendingOrderDao, ) *LendingOrderBookService
NewLendingOrderBookService returns a new instance of balance service
func (*LendingOrderBookService) GetLendingOrderBook ¶ added in v1.2.0
func (s *LendingOrderBookService) GetLendingOrderBook(term uint64, lendingToken common.Address) (*types.LendingOrderBook, error)
GetLendingOrderBook fetches orderbook from engine and returns it as an map[string]interface
func (*LendingOrderBookService) GetLendingOrderBookInDb ¶ added in v1.2.0
func (s *LendingOrderBookService) GetLendingOrderBookInDb(term uint64, lendingToken common.Address) (*types.LendingOrderBook, error)
func (*LendingOrderBookService) SubscribeLendingOrderBook ¶ added in v1.2.0
func (s *LendingOrderBookService) SubscribeLendingOrderBook(c *ws.Client, term uint64, lendingToken common.Address)
SubscribeLendingOrderBook is responsible for handling incoming orderbook subscription messages It makes an entry of connection in pairSocket corresponding to pair,unit and duration
func (*LendingOrderBookService) UnsubscribeLendingOrderBook ¶ added in v1.2.0
func (s *LendingOrderBookService) UnsubscribeLendingOrderBook(c *ws.Client)
UnsubscribeLendingOrderBook is responsible for handling incoming orderbook unsubscription messages
func (*LendingOrderBookService) UnsubscribeLendingOrderBookChannel ¶ added in v1.2.0
func (s *LendingOrderBookService) UnsubscribeLendingOrderBookChannel(c *ws.Client, term uint64, lendingToken common.Address)
UnsubscribeLendingOrderBookChannel is responsible for handling incoming orderbook unsubscription messages
type LendingOrderService ¶ added in v1.2.0
type LendingOrderService struct {
// contains filtered or unexported fields
}
LendingOrderService struct
func NewLendingOrderService ¶ added in v1.2.0
func NewLendingOrderService( lendingDao interfaces.LendingOrderDao, topupDao interfaces.LendingOrderDao, repayDao interfaces.LendingOrderDao, recallDao interfaces.LendingOrderDao, collateralTokenDao interfaces.TokenDao, lendingTokenDao interfaces.TokenDao, notificationDao interfaces.NotificationDao, lendingTradeDao interfaces.LendingTradeDao, validator interfaces.ValidatorService, engine interfaces.Engine, broker *rabbitmq.Connection, ) *LendingOrderService
NewLendingOrderService returns a new instance of lending order service
func (*LendingOrderService) CancelLendingOrder ¶ added in v1.2.0
func (s *LendingOrderService) CancelLendingOrder(o *types.LendingOrder) error
CancelLendingOrder handles the cancellation order requests. Only Orders which are OPEN or NEW i.e. Not yet filled/partially filled can be cancelled
func (*LendingOrderService) EstimateCollateral ¶ added in v1.2.0
func (s *LendingOrderService) EstimateCollateral(collateralToken common.Address, lendingToken common.Address, lendingAmount *big.Float) (*big.Float, *big.Float, error)
EstimateCollateral estimate collateral amount to make lending
func (*LendingOrderService) GetByHash ¶ added in v1.2.0
func (s *LendingOrderService) GetByHash(hash common.Hash) (*types.LendingOrder, error)
GetByHash get lending by hash
func (*LendingOrderService) GetLendingNonceByUserAddress ¶ added in v1.2.0
func (s *LendingOrderService) GetLendingNonceByUserAddress(addr common.Address) (uint64, error)
GetLendingNonceByUserAddress return nonce of user order
func (*LendingOrderService) GetLendingOrders ¶ added in v1.2.0
func (s *LendingOrderService) GetLendingOrders(lendingSpec types.LendingSpec, sort []string, offset int, size int) (*types.LendingRes, error)
GetLendingOrders filter lending
func (*LendingOrderService) GetRecall ¶ added in v1.2.0
func (s *LendingOrderService) GetRecall(recallSpec types.RecallSpec, sort []string, offset int, size int) (*types.LendingRes, error)
GetRecall filter recall
func (*LendingOrderService) GetRepay ¶ added in v1.2.0
func (s *LendingOrderService) GetRepay(repaySpec types.RepaySpec, sort []string, offset int, size int) (*types.LendingRes, error)
GetRepay filter repay
func (*LendingOrderService) GetTopup ¶ added in v1.2.0
func (s *LendingOrderService) GetTopup(topupSpec types.TopupSpec, sort []string, offset int, size int) (*types.LendingRes, error)
GetTopup filter topup
func (*LendingOrderService) HandleDocumentType ¶ added in v1.2.0
func (s *LendingOrderService) HandleDocumentType(ev types.LendingOrderChangeEvent, docType string) error
HandleDocumentType handle order frome changing db
func (*LendingOrderService) HandleLendingOrderResponse ¶ added in v1.2.0
func (s *LendingOrderService) HandleLendingOrderResponse(res *types.EngineResponse) error
HandleLendingOrderResponse listens to messages incoming from the engine and handles websocket responses and database updates accordingly
func (*LendingOrderService) HandleLendingOrdersCreateCancel ¶ added in v1.2.0
func (s *LendingOrderService) HandleLendingOrdersCreateCancel(msg *rabbitmq.Message) error
HandleLendingOrdersCreateCancel handle lending order api
func (*LendingOrderService) NewLendingOrder ¶ added in v1.2.0
func (s *LendingOrderService) NewLendingOrder(o *types.LendingOrder) error
NewLendingOrder validates if the passed order is valid or not based on user's available funds and order data. If valid: LendingOrder is inserted in DB with order status as new and order is publiched on rabbitmq queue for matching engine to process the order
func (*LendingOrderService) RepayLendingOrder ¶ added in v1.2.0
func (s *LendingOrderService) RepayLendingOrder(o *types.LendingOrder) error
RepayLendingOrder repay
func (*LendingOrderService) TopupLendingOrder ¶ added in v1.2.0
func (s *LendingOrderService) TopupLendingOrder(o *types.LendingOrder) error
TopupLendingOrder topup
func (*LendingOrderService) WatchChanges ¶ added in v1.2.0
func (s *LendingOrderService) WatchChanges()
WatchChanges watch database
type LendingPairService ¶ added in v1.2.0
type LendingPairService struct {
// contains filtered or unexported fields
}
LendingPairService struct with daos required, responsible for communicating with daos. LendingPairService functions are responsible for interacting with daos and implements business logics.
func NewLendingPairService ¶ added in v1.2.0
func NewLendingPairService( lendingPairDao interfaces.LendingPairDao, ) *LendingPairService
NewLendingPairService returns a new instance of balance service
func (*LendingPairService) GetAll ¶ added in v1.2.0
func (s *LendingPairService) GetAll() ([]types.LendingPair, error)
GetAll is reponsible for fetching all the pairs in the DB
func (*LendingPairService) GetAllByCoinbase ¶ added in v1.2.0
func (s *LendingPairService) GetAllByCoinbase(addr common.Address) ([]types.LendingPair, error)
func (*LendingPairService) GetByLendingID ¶ added in v1.2.0
func (s *LendingPairService) GetByLendingID(term uint64, lendingAddress common.Address) (*types.LendingPair, error)
GetByLendingID get pair by ID
type LendingPriceBoardService ¶ added in v1.2.0
type LendingPriceBoardService struct {
// contains filtered or unexported fields
}
func NewLendingPriceBoardService ¶ added in v1.2.0
func NewLendingPriceBoardService( lendingPairService interfaces.LendingPairService, lendingOhlcvService interfaces.LendingOhlcvService, ) *LendingPriceBoardService
NewLendingPriceBoardService returns a new instance of LendingPriceBoardService
func (*LendingPriceBoardService) GetLendingPriceBoardData ¶ added in v1.2.0
func (s *LendingPriceBoardService) GetLendingPriceBoardData(term uint64, lendingToken common.Address) *types.LendingTick
GetLendingPriceBoardData get data of 24h change tokens
func (*LendingPriceBoardService) Unsubscribe ¶ added in v1.2.0
func (s *LendingPriceBoardService) Unsubscribe(c *ws.Client)
Unsubscribe unsubscribe registered socket
func (*LendingPriceBoardService) UnsubscribeChannel ¶ added in v1.2.0
type LendingTradeService ¶ added in v1.2.0
type LendingTradeService struct {
// contains filtered or unexported fields
}
LendingTradeService struct with daos required, responsible for communicating with daos. LendingTradeService functions are responsible for interacting with daos and implements business logics.
func NewLendingTradeService ¶ added in v1.2.0
func NewLendingTradeService( lendingdao interfaces.LendingOrderDao, lendingTradeDao interfaces.LendingTradeDao, notificationDao interfaces.NotificationDao, broker *rabbitmq.Connection, ) *LendingTradeService
NewLendingTradeService returns a new instance of LendingTradeService
func (*LendingTradeService) GetLendingTradeByOrderBook ¶ added in v1.2.0
func (s *LendingTradeService) GetLendingTradeByOrderBook(tern uint64, lendingToken common.Address, from, to int64, n int) ([]*types.LendingTrade, error)
GetLendingTradeByOrderBook get sorted lending trade from term and lending tokens
func (*LendingTradeService) GetLendingTradeByTime ¶ added in v1.2.0
func (s *LendingTradeService) GetLendingTradeByTime(dateFrom, dateTo int64, pageOffset int, pageSize int) ([]*types.LendingTrade, error)
GetLendingTradeByTime get lending trade by range time
func (*LendingTradeService) GetLendingTrades ¶ added in v1.2.0
func (s *LendingTradeService) GetLendingTrades(lendingtradeSpec *types.LendingTradeSpec, sortedBy []string, pageOffset int, pageSize int) (*types.LendingTradeRes, error)
GetLendingTrades get lending trade
func (*LendingTradeService) GetLendingTradesUserHistory ¶ added in v1.2.0
func (s *LendingTradeService) GetLendingTradesUserHistory(a common.Address, lendingtradeSpec *types.LendingTradeSpec, sortedBy []string, pageOffset int, pageSize int) (*types.LendingTradeRes, error)
GetLendingTradesUserHistory get lending trade by history
func (*LendingTradeService) HandleDocumentType ¶ added in v1.2.0
func (s *LendingTradeService) HandleDocumentType(ev types.LendingTradeChangeEvent) error
HandleDocumentType handle trade insert/update db trigger
func (*LendingTradeService) HandleLendingTradeResponse ¶ added in v1.2.0
func (s *LendingTradeService) HandleLendingTradeResponse(res *types.EngineResponse) error
HandleLendingTradeResponse listens to messages incoming from the engine and handles websocket responses and database updates accordingly
func (*LendingTradeService) HandleOperationInsert ¶ added in v1.2.0
func (s *LendingTradeService) HandleOperationInsert(trade *types.LendingTrade) error
HandleOperationInsert sent WS messages to client when a trade is created with status "PENDING""
func (*LendingTradeService) HandleOperationUpdate ¶ added in v1.2.0
func (s *LendingTradeService) HandleOperationUpdate(trade *types.LendingTrade) error
HandleOperationUpdate sent WS messages to client when a trade is updated with status "SUCCESS" or "ERROR"
func (*LendingTradeService) HandleTradeSuccess ¶ added in v1.2.0
func (s *LendingTradeService) HandleTradeSuccess(m *types.LendingMatches)
HandleTradeSuccess handle order match success
func (*LendingTradeService) RegisterNotify ¶ added in v1.2.0
func (s *LendingTradeService) RegisterNotify(fn func(*types.LendingTrade))
RegisterNotify register a only trade notify function
func (*LendingTradeService) Unsubscribe ¶ added in v1.2.0
func (s *LendingTradeService) Unsubscribe(c *ws.Client)
Unsubscribe unsubscribe lending channel
func (*LendingTradeService) UnsubscribeChannel ¶ added in v1.2.0
func (s *LendingTradeService) UnsubscribeChannel(c *ws.Client, term uint64, lendingToken common.Address)
UnsubscribeChannel unsubscribe lending channel
func (*LendingTradeService) WatchChanges ¶ added in v1.2.0
func (s *LendingTradeService) WatchChanges()
WatchChanges watch changing trade database
type MarketsService ¶
type MarketsService struct { PairDao interfaces.PairDao OrderDao interfaces.OrderDao TradeDao interfaces.TradeDao OHLCVService interfaces.OHLCVService PairService interfaces.PairService }
MarketsService struct with daos required, responsible for communicating with daos. MarketsService functions are responsible for interacting with daos and implements business logics.
func NewMarketsService ¶
func NewMarketsService( pairDao interfaces.PairDao, orderdao interfaces.OrderDao, tradeDao interfaces.TradeDao, ohlcvService interfaces.OHLCVService, pairService interfaces.PairService, ) *MarketsService
NewMarketsService returns a new instance of TradeService
func (*MarketsService) GetPairData ¶
func (s *MarketsService) GetPairData() ([]*types.PairData, error)
func (*MarketsService) Subscribe ¶
func (s *MarketsService) Subscribe(c *ws.Client)
Subscribe market
func (*MarketsService) UnsubscribeChannel ¶
func (s *MarketsService) UnsubscribeChannel(c *ws.Client)
UnsubscribeChannel
type NotificationService ¶
type NotificationService struct {
NotificationDao interfaces.NotificationDao
}
NotificationService struct with daos required, responsible for communicating with dao NotificationService functions are responsible for interacting with dao and implements business logic.
func NewNotificationService ¶
func NewNotificationService( notificationDao interfaces.NotificationDao, ) *NotificationService
NewNotificationService returns a new instance of NewNotificationService
func (*NotificationService) Create ¶
func (s *NotificationService) Create(n *types.Notification) ([]*types.Notification, error)
Create inserts a new notification into the database
func (*NotificationService) GetAll ¶
func (s *NotificationService) GetAll() ([]types.Notification, error)
GetAll fetches all the notifications from db
func (*NotificationService) GetByID ¶
func (s *NotificationService) GetByID(id bson.ObjectId) (*types.Notification, error)
GetByID fetches the detailed document of a notification using its mongo ID
func (*NotificationService) GetByUserAddress ¶
func (s *NotificationService) GetByUserAddress(addr common.Address, limit int, offset int) ([]*types.Notification, error)
GetByUserAddress fetches all the notifications related to user address
func (*NotificationService) GetSortDecByUserAddress ¶
func (s *NotificationService) GetSortDecByUserAddress(addr common.Address, limit int, offset int) ([]*types.Notification, error)
GetSortDecByUserAddress function fetches list of orders from order collection based on user address, result sorted by created date. Returns array of notification type struct
func (*NotificationService) MarkAllRead ¶
func (s *NotificationService) MarkAllRead(addr common.Address) error
MarkAllRead update all UNREAD status to READ status
func (*NotificationService) MarkRead ¶
func (s *NotificationService) MarkRead(id bson.ObjectId) error
MarkRead update UNREAD status to READ status
func (*NotificationService) MarkUnRead ¶
func (s *NotificationService) MarkUnRead(id bson.ObjectId) error
MarkUnRead update READ status to UNREAD status
func (*NotificationService) Update ¶
func (s *NotificationService) Update(n *types.Notification) (*types.Notification, error)
Update updates the detailed document of a notification using its mongo ID
type OHLCVService ¶
type OHLCVService struct {
// contains filtered or unexported fields
}
func NewOHLCVService ¶
func NewOHLCVService(TradeDao interfaces.TradeDao, pairDao interfaces.PairDao, tokenDao interfaces.TokenDao) *OHLCVService
NewOHLCVService init new ohlcv service
func (*OHLCVService) Get24hTick ¶ added in v1.2.0
func (s *OHLCVService) Get24hTick(baseToken, quoteToken common.Address) *types.Tick
Get24hTick get 24h tick of token
func (*OHLCVService) GetAllTokenPairData ¶ added in v1.2.0
func (s *OHLCVService) GetAllTokenPairData() ([]*types.PairData, error)
GetAllTokenPairData get tick of all tokens
func (*OHLCVService) GetAllTokenPairDataByCoinbase ¶ added in v1.2.0
func (*OHLCVService) GetFiatPriceChart ¶ added in v1.2.0
func (s *OHLCVService) GetFiatPriceChart() (map[string][]*types.FiatPriceItem, error)
GetFiatPriceChart get fiat chart
func (*OHLCVService) GetLastPriceCurrentByTime ¶ added in v1.2.0
func (s *OHLCVService) GetLastPriceCurrentByTime(symbol string, createAt time.Time) (*big.Float, error)
GetLastPriceCurrentByTime get last trade price
func (*OHLCVService) GetOHLCV ¶
func (s *OHLCVService) GetOHLCV(pairs []types.PairAddresses, duration int64, unit string, timeInterval ...int64) ([]*types.Tick, error)
GetOHLCV fetches OHLCV data using pairName: can be "" for fetching data for all pairs duration: in integer unit: sec,min,hour,day,week,month,yr timeInterval: 0-2 entries (0 argument: latest data,1st argument: from timestamp, 2nd argument: to timestamp)
func (*OHLCVService) GetPairPrice ¶ added in v1.2.0
func (s *OHLCVService) GetPairPrice(pairName string, timestamp int64) (int64, error)
GetPairPrice get lastest price by time
func (*OHLCVService) GetTokenPairData ¶ added in v1.2.0
func (s *OHLCVService) GetTokenPairData(baseToken common.Address, quoteToken common.Address) *types.PairData
GetTokenPairData get tick of pair tokens
func (*OHLCVService) GetTokenPriceByUsdt ¶ added in v1.2.2
func (*OHLCVService) GetVolumeByCoinbase ¶ added in v1.2.0
func (s *OHLCVService) GetVolumeByCoinbase(addr common.Address, years, months, days int) (*big.Int, *big.Int, error)
GetVolumeByCoinbase get total volume exchange
func (*OHLCVService) GetVolumeByUsdt ¶ added in v1.2.1
GetVolumeByUsdt convert to USDT volume
func (*OHLCVService) Init ¶ added in v1.2.0
func (s *OHLCVService) Init()
Init init cache ensure add current time frame before trade notify come
func (*OHLCVService) NotifyTrade ¶ added in v1.2.0
func (s *OHLCVService) NotifyTrade(trade *types.Trade)
NotifyTrade trigger if trade comming
func (*OHLCVService) Subscribe ¶
func (s *OHLCVService) Subscribe(conn *ws.Client, p *types.SubscriptionPayload)
Subscribe handles all the subscription messages for ticks corresponding to a pair It calls the corresponding channel's subscription method and sends trade history back on the connection
func (*OHLCVService) Unsubscribe ¶
func (s *OHLCVService) Unsubscribe(conn *ws.Client)
Unsubscribe handles all the unsubscription messages for ticks corresponding to a pair
func (*OHLCVService) UnsubscribeChannel ¶
func (s *OHLCVService) UnsubscribeChannel(conn *ws.Client, p *types.SubscriptionPayload)
UnsubscribeChannel handles all the unsubscription messages for ticks corresponding to a pair
type OrderBookService ¶
type OrderBookService struct {
// contains filtered or unexported fields
}
PairService struct with daos required, responsible for communicating with daos. PairService functions are responsible for interacting with daos and implements business logics.
func NewOrderBookService ¶
func NewOrderBookService( pairDao interfaces.PairDao, tokenDao interfaces.TokenDao, orderDao interfaces.OrderDao, eng interfaces.Engine, ) *OrderBookService
NewPairService returns a new instance of balance service
func (*OrderBookService) GetDbOrderBook ¶ added in v1.2.0
func (*OrderBookService) GetOrderBook ¶
GetOrderBook fetches orderbook from engine and returns it as an map[string]interface
func (*OrderBookService) GetRawOrderBook ¶
func (s *OrderBookService) GetRawOrderBook(bt, qt common.Address) (*types.RawOrderBook, error)
GetRawOrderBook fetches complete orderbook from engine
func (*OrderBookService) SubscribeOrderBook ¶
func (s *OrderBookService) SubscribeOrderBook(c *ws.Client, bt, qt common.Address)
SubscribeOrderBook is responsible for handling incoming orderbook subscription messages It makes an entry of connection in pairSocket corresponding to pair,unit and duration
func (*OrderBookService) SubscribeRawOrderBook ¶
func (s *OrderBookService) SubscribeRawOrderBook(c *ws.Client, bt, qt common.Address)
SubscribeRawOrderBook is responsible for handling incoming orderbook subscription messages It makes an entry of connection in pairSocket corresponding to pair,unit and duration
func (*OrderBookService) UnsubscribeOrderBook ¶
func (s *OrderBookService) UnsubscribeOrderBook(c *ws.Client)
UnsubscribeOrderBook is responsible for handling incoming orderbook unsubscription messages
func (*OrderBookService) UnsubscribeOrderBookChannel ¶
func (s *OrderBookService) UnsubscribeOrderBookChannel(c *ws.Client, bt, qt common.Address)
func (*OrderBookService) UnsubscribeRawOrderBook ¶
func (s *OrderBookService) UnsubscribeRawOrderBook(c *ws.Client)
UnsubscribeRawOrderBook is responsible for handling incoming orderbook unsubscription messages
func (*OrderBookService) UnsubscribeRawOrderBookChannel ¶
func (s *OrderBookService) UnsubscribeRawOrderBookChannel(c *ws.Client, bt, qt common.Address)
type OrderService ¶
type OrderService struct {
// contains filtered or unexported fields
}
OrderService
func NewOrderService ¶
func NewOrderService( orderDao interfaces.OrderDao, tokenDao interfaces.TokenDao, pairDao interfaces.PairDao, accountDao interfaces.AccountDao, tradeDao interfaces.TradeDao, notificationDao interfaces.NotificationDao, engine interfaces.Engine, validator interfaces.ValidatorService, broker *rabbitmq.Connection, ) *OrderService
NewOrderService returns a new instance of orderservice
func (*OrderService) CancelAllOrder ¶
func (s *OrderService) CancelAllOrder(a common.Address) error
CancelOrder handles the cancellation order requests. Only Orders which are OPEN or NEW i.e. Not yet filled/partially filled can be cancelled
func (*OrderService) CancelOrder ¶
func (s *OrderService) CancelOrder(oc *types.OrderCancel) error
CancelOrder handles the cancellation order requests. Only Orders which are OPEN or NEW i.e. Not yet filled/partially filled can be cancelled
func (*OrderService) GetBestAsk ¶ added in v1.2.1
func (s *OrderService) GetBestAsk(baseToken, quouteToken common.Address) (*types.PriceVolume, error)
GetBestAsk get best sell price
func (*OrderService) GetBestBid ¶ added in v1.2.1
func (s *OrderService) GetBestBid(baseToken, quouteToken common.Address) (*types.PriceVolume, error)
GetBestBid get best buy price
func (*OrderService) GetByHashes ¶
func (*OrderService) GetByUserAddress ¶
func (s *OrderService) GetByUserAddress(a, bt, qt common.Address, from, to int64, limit ...int) ([]*types.Order, error)
GetByUserAddress fetches all the orders placed by passed user address
func (*OrderService) GetCurrentByUserAddress ¶
func (s *OrderService) GetCurrentByUserAddress(addr common.Address, limit ...int) ([]*types.Order, error)
GetCurrentByUserAddress function fetches list of open/partial orders from order collection based on user address. Returns array of Order type struct
func (*OrderService) GetHistoryByUserAddress ¶
func (s *OrderService) GetHistoryByUserAddress(addr, bt, qt common.Address, from, to int64, limit ...int) ([]*types.Order, error)
GetHistoryByUserAddress function fetches list of orders which are not in open/partial order status from order collection based on user address. Returns array of Order type struct
func (*OrderService) GetOrderBookPricePoint ¶ added in v1.2.0
func (s *OrderService) GetOrderBookPricePoint(baseToken, quoteToken common.Address, pricepoint *big.Int, side string) (*big.Int, error)
GetOrderBookPricePoint return amount remain for pricepoint
func (*OrderService) GetOrderCountByUserAddress ¶
func (s *OrderService) GetOrderCountByUserAddress(addr common.Address) (int, error)
GetOrderCountByUserAddress get the total number of orders created by a user
func (*OrderService) GetOrderNonceByUserAddress ¶ added in v0.5.0
func (s *OrderService) GetOrderNonceByUserAddress(addr common.Address) (interface{}, error)
GetOrderNonceByUserAddress return nonce of user order
func (*OrderService) GetOrders ¶
func (s *OrderService) GetOrders(orderSpec types.OrderSpec, sort []string, offset int, size int) (*types.OrderRes, error)
GetOrders filter orders
func (*OrderService) GetOrdersLockedBalanceByUserAddress ¶
func (s *OrderService) GetOrdersLockedBalanceByUserAddress(addr common.Address) (map[string]*big.Int, error)
GetOrdersLockedBalanceByUserAddress get the total number of orders amount created by a user
func (*OrderService) HandleDocumentType ¶
func (s *OrderService) HandleDocumentType(ev types.OrderChangeEvent) error
HandleDocumentType handle order frome changing db
func (*OrderService) HandleEngineResponse ¶
func (s *OrderService) HandleEngineResponse(res *types.EngineResponse) error
HandleEngineResponse listens to messages incoming from the engine and handles websocket responses and database updates accordingly
func (*OrderService) LoadCache ¶ added in v1.2.0
func (s *OrderService) LoadCache()
LoadCache init order data for caching
func (*OrderService) NewOrder ¶
func (s *OrderService) NewOrder(o *types.Order) error
NewOrder validates if the passed order is valid or not based on user's available funds and order data. If valid: Order is inserted in DB with order status as new and order is publiched on rabbitmq queue for matching engine to process the order
func (*OrderService) WatchChanges ¶
func (s *OrderService) WatchChanges()
WatchChanges wath change record
type PairCache ¶ added in v1.2.0
type PairCache struct {
// contains filtered or unexported fields
}
type PairService ¶
type PairService struct {
// contains filtered or unexported fields
}
PairService struct with daos required, responsible for communicating with daos. PairService functions are responsible for interacting with daos and implements business logics.
func NewPairService ¶
func NewPairService( pairDao interfaces.PairDao, tokenDao interfaces.TokenDao, tradeDao interfaces.TradeDao, orderDao interfaces.OrderDao, ohlcv interfaces.OHLCVService, eng interfaces.Engine, provider interfaces.EthereumProvider, ) *PairService
NewPairService returns a new instance of balance service
func (*PairService) Create ¶
func (s *PairService) Create(pair *types.Pair) error
Create function is responsible for inserting new pair in DB. It checks for existence of tokens in DB first
func (*PairService) CreatePairs ¶
func (*PairService) GetAll ¶
func (s *PairService) GetAll() ([]types.Pair, error)
GetAll is reponsible for fetching all the pairs in the DB
func (*PairService) GetAllByCoinbase ¶ added in v1.2.0
GetAllByCoinbase get all pair by coinbase
func (*PairService) GetAllTokenPairData ¶
func (s *PairService) GetAllTokenPairData() ([]*types.PairData, error)
GetAllTokenPairData get tick of all tokens
func (*PairService) GetAllTokenPairDataByCoinbase ¶ added in v1.2.3
GetAllTokenPairDataByCoinbase get all token pair data
func (*PairService) GetByTokenAddress ¶
GetByTokenAddress fetches details of a pair using contract address of its constituting tokens
func (*PairService) GetTokenPairData ¶
GetTokenPairData get tick of a token pair
type PriceBoardService ¶
type PriceBoardService struct { TokenDao interfaces.TokenDao TradeDao interfaces.TradeDao OHLCVService interfaces.OHLCVService }
TradeService struct with daos required, responsible for communicating with daos. TradeService functions are responsible for interacting with daos and implements business logics.
func NewPriceBoardService ¶
func NewPriceBoardService( tokenDao interfaces.TokenDao, tradeDao interfaces.TradeDao, ohlcvService interfaces.OHLCVService, ) *PriceBoardService
NewPriceBoardService returns a new instance of TradeService
func (*PriceBoardService) GetPriceBoardData ¶
func (s *PriceBoardService) GetPriceBoardData(pairs []types.PairAddresses, duration int64, unit string, timeInterval ...int64) ([]*types.Tick, error)
GetPriceBoardData get data of 24h change tokens
func (*PriceBoardService) Subscribe ¶
func (s *PriceBoardService) Subscribe(c *ws.Client, bt, qt common.Address)
Subscribe
func (*PriceBoardService) Unsubscribe ¶
func (s *PriceBoardService) Unsubscribe(c *ws.Client)
Unsubscribe unsubscribe registered socket
func (*PriceBoardService) UnsubscribeChannel ¶
func (s *PriceBoardService) UnsubscribeChannel(c *ws.Client, bt, qt common.Address)
UnsubscribeChannel
type PriceUsdt ¶ added in v1.2.0
type PriceUsdt struct {
// contains filtered or unexported fields
}
type RelayerService ¶
type RelayerService struct {
// contains filtered or unexported fields
}
RelayerService struct
func NewRelayerService ¶
func NewRelayerService( relaye interfaces.Relayer, tokenDao interfaces.TokenDao, colateralTokenDao interfaces.TokenDao, lendingTokenDao interfaces.TokenDao, pairDao interfaces.PairDao, lendingPairDao interfaces.LendingPairDao, relayerDao interfaces.RelayerDao, ) *RelayerService
NewRelayerService returns a new instance of orderservice
func (*RelayerService) GetAll ¶ added in v1.2.2
func (s *RelayerService) GetAll() ([]types.Relayer, error)
func (*RelayerService) GetByAddress ¶ added in v1.2.0
func (*RelayerService) GetRelayerAddress ¶ added in v1.2.0
func (s *RelayerService) GetRelayerAddress(r *http.Request) common.Address
func (*RelayerService) UpdateNameByAddress ¶ added in v1.2.0
func (*RelayerService) UpdateRelayer ¶
func (s *RelayerService) UpdateRelayer(coinbase common.Address) error
UpdateRelayer get the total number of orders amount created by a user
func (*RelayerService) UpdateRelayers ¶ added in v1.2.0
func (s *RelayerService) UpdateRelayers() error
type TokenCache ¶ added in v1.2.0
type TokenCache struct {
// contains filtered or unexported fields
}
type TokenService ¶
type TokenService struct {
// contains filtered or unexported fields
}
TokenService struct with daos required, responsible for communicating with daos. TokenService functions are responsible for interacting with daos and implements business logics.
func NewTokenService ¶
func NewTokenService(tokenDao interfaces.TokenDao) *TokenService
NewTokenService returns a new instance of TokenService
func (*TokenService) Create ¶
func (s *TokenService) Create(token *types.Token) error
Create inserts a new token into the database
func (*TokenService) GetAll ¶
func (s *TokenService) GetAll() ([]types.Token, error)
GetAll fetches all the tokens from db
func (*TokenService) GetAllByCoinbase ¶ added in v1.2.0
func (*TokenService) GetBaseTokens ¶
func (s *TokenService) GetBaseTokens() ([]types.Token, error)
GetBase fetches all the quote tokens from db
func (*TokenService) GetByAddress ¶
GetByAddress fetches the detailed document of a token using its contract address
func (*TokenService) GetQuoteTokens ¶
func (s *TokenService) GetQuoteTokens() ([]types.Token, error)
GetQuote fetches all the quote tokens from db
type TradeService ¶
type TradeService struct { OrderDao interfaces.OrderDao // contains filtered or unexported fields }
TradeService struct with daos required, responsible for communicating with daos. TradeService functions are responsible for interacting with daos and implements business logics.
func NewTradeService ¶
func NewTradeService( orderdao interfaces.OrderDao, tradeDao interfaces.TradeDao, ohlcvService *OHLCVService, notificationDao interfaces.NotificationDao, broker *rabbitmq.Connection, ) *TradeService
NewTradeService returns a new instance of TradeService
func (*TradeService) GetAllTradesByPairAddress ¶
GetByPairAddress fetches all the trades corresponding to a pair using pair's token address
func (*TradeService) GetByMakerOrderHash ¶
func (*TradeService) GetByOrderHashes ¶
func (*TradeService) GetByPairName ¶
func (s *TradeService) GetByPairName(p string) ([]*types.Trade, error)
GetByPairName fetches all the trades corresponding to a pair using pair's name
func (*TradeService) GetByTakerOrderHash ¶
func (*TradeService) GetByUserAddress ¶
GetByUserAddress fetches all the trades corresponding to a user address
func (*TradeService) GetSortedTrades ¶
func (*TradeService) GetSortedTradesByUserAddress ¶
func (*TradeService) GetTrades ¶
func (s *TradeService) GetTrades(tradeSpec *types.TradeSpec, sortedBy []string, pageOffset int, pageSize int) (*types.TradeRes, error)
GetTrades filter trade
func (*TradeService) GetTradesUserHistory ¶
func (s *TradeService) GetTradesUserHistory(a common.Address, tradeSpec *types.TradeSpec, sortedBy []string, pageOffset int, pageSize int) (*types.TradeRes, error)
GetTradesUserHistory get trade by history
func (*TradeService) HandleDocumentType ¶
func (s *TradeService) HandleDocumentType(ev types.TradeChangeEvent) error
HandleDocumentType handle trade insert/update db trigger
func (*TradeService) HandleOperationInsert ¶
func (s *TradeService) HandleOperationInsert(trade *types.Trade) error
HandleOperationInsert sent WS messages to client when a trade is created with status "PENDING""
func (*TradeService) HandleOperationUpdate ¶
func (s *TradeService) HandleOperationUpdate(trade *types.Trade) error
HandleOperationUpdate sent WS messages to client when a trade is updated with status "SUCCESS" or "ERROR"
func (*TradeService) HandleTradeResponse ¶
func (s *TradeService) HandleTradeResponse(res *types.EngineResponse) error
HandleTradeResponse listens to messages incoming from the engine and handles websocket responses and database updates accordingly
func (*TradeService) HandleTradeSuccess ¶
func (s *TradeService) HandleTradeSuccess(m *types.Matches)
HandleTradeSuccess handle order match success
func (*TradeService) Subscribe ¶
func (s *TradeService) Subscribe(c *ws.Client, bt, qt common.Address)
Subscribe
func (*TradeService) UnsubscribeChannel ¶
func (s *TradeService) UnsubscribeChannel(c *ws.Client, bt, qt common.Address)
Unsubscribe
func (*TradeService) WatchChanges ¶
func (s *TradeService) WatchChanges()
type TxService ¶
type TxService struct { WalletDao interfaces.WalletDao Wallet *types.Wallet }
WalletService struct with daos required, responsible for communicating with daos
func NewTxService ¶
func NewTxService(dao interfaces.WalletDao, w *types.Wallet) *TxService
func (*TxService) GetCustomTxSendOptions ¶
func (s *TxService) GetCustomTxSendOptions(w *types.Wallet) *bind.TransactOpts
func (*TxService) GetTxCallOptions ¶
func (*TxService) GetTxDefaultSendOptions ¶
func (s *TxService) GetTxDefaultSendOptions() (*bind.TransactOpts, error)
func (*TxService) GetTxSendOptions ¶
func (s *TxService) GetTxSendOptions() (*bind.TransactOpts, error)
func (*TxService) SetTxSender ¶
type ValidatorService ¶
type ValidatorService struct {
// contains filtered or unexported fields
}
func NewValidatorService ¶
func NewValidatorService( ethereumProvider interfaces.EthereumProvider, accountDao interfaces.AccountDao, orderDao interfaces.OrderDao, lendingDao interfaces.LendingOrderDao, pairDao interfaces.PairDao, tokenDao interfaces.TokenDao, ) *ValidatorService
func (*ValidatorService) ValidateAvailablExchangeBalance ¶ added in v1.2.2
func (s *ValidatorService) ValidateAvailablExchangeBalance(o *types.Order) error
ValidateAvailablExchangeBalance get balance
func (*ValidatorService) ValidateAvailablLendingBalance ¶ added in v1.2.2
func (s *ValidatorService) ValidateAvailablLendingBalance(o *types.LendingOrder) error
ValidateAvailablLendingBalance validate avalable lending order
type WalletService ¶
type WalletService struct {
WalletDao interfaces.WalletDao
}
WalletService struct with daos required, responsible for communicating with daos
func NewWalletService ¶
func NewWalletService(walletDao interfaces.WalletDao) *WalletService
func (*WalletService) CreateAdminWallet ¶
func (*WalletService) GetByAddress ¶
func (*WalletService) GetDefaultAdminWallet ¶
func (s *WalletService) GetDefaultAdminWallet() (*types.Wallet, error)
func (*WalletService) GetOperatorAddresses ¶
func (s *WalletService) GetOperatorAddresses() ([]common.Address, error)
func (*WalletService) GetOperatorWallets ¶
func (s *WalletService) GetOperatorWallets() ([]*types.Wallet, error)