match

package
v0.0.0-...-a287f25 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const POOL_STORAGE_USE_DURATION = 60
View Source
const PriceExceedsLimit = "price exceeds limit"
View Source
const TriggerPriceNotReach = "trigger price is not reached"

Variables

View Source
var ChannelHWM = 64
View Source
var TradeAmountRelaxFactor = decimal.NewFromFloat(0.99)

Functions

func CheckCloseOnly

func CheckCloseOnly(account *model.AccountStorage, order *model.Order) decimal.Decimal

Types

type MatchItem

type MatchItem struct {
	Order              *orderbook.MemoryOrder // NOTE: mutable! should only be modified where execute match
	OrderCancelAmounts []decimal.Decimal
	OrderCancelReasons []model.CancelReasonType
	OrderTotalCancel   decimal.Decimal

	MatchedAmount decimal.Decimal
}

type OrderCancel

type OrderCancel struct {
	LiquidityPoolAddress string
	PerpetualIndex       int64
	OrderHash            string
	Status               model.OrderStatus
	ToCancel             decimal.Decimal
	Reason               model.CancelReasonType
}

func ComputeOrderAvailable

func ComputeOrderAvailable(poolStorage *model.LiquidityPoolStorage, perpetualIndex int64, account *model.AccountStorage, orders []*model.Order) ([]*OrderCancel, decimal.Decimal)

type OrdersCollateral

type OrdersCollateral struct {
	WalletBalance decimal.Decimal
	OrderMap      map[string]*OrdersPerpMap
}

type OrdersEachPerp

type OrdersEachPerp struct {
	LiquidityPoolAddress string
	PerpetualIndex       int64
	PoolStorage          *model.LiquidityPoolStorage
	Orders               []*model.Order
}

type OrdersPerpMap

type OrdersPerpMap struct {
	LiquidityPoolAddress string
	PerpetualIndex       int64
	Account              *model.AccountStorage
	PoolStorage          *model.LiquidityPoolStorage
	Orders               []*model.Order
}

type Server

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

func New

func New(ctx context.Context, cli chain.ChainClient, dao dao.DAO, wsChan chan interface{}, gm *gasmonitor.GasMonitor) (*Server, error)

func (*Server) CancelOrder

func (s *Server) CancelOrder(poolAddress string, perpetualIndex int64, orderHash string) error

func (*Server) ClosePerpetual

func (s *Server) ClosePerpetual(poolAddress string, perpIndex int64) error

func (*Server) NewOrder

func (s *Server) NewOrder(order *model.Order) string

func (*Server) RollbackOrdersStatus

func (s *Server) RollbackOrdersStatus(txID string, status model.TransactionStatus, transactionHash, blockHash string,
	blockNumber, blockTime uint64, successEvents []*model.TradeSuccessEvent, failedEvents []*model.TradeFailedEvent) error

func (*Server) SetPoolStorageDirty

func (s *Server) SetPoolStorageDirty(txID string)

func (*Server) Start

func (s *Server) Start() error

func (*Server) UpdateOrdersStatus

func (s *Server) UpdateOrdersStatus(txID string, status model.TransactionStatus, transactionHash, blockHash string,
	blockNumber, blockTime uint64, successEvents []*model.TradeSuccessEvent, failedEvents []*model.TradeFailedEvent) error

Jump to

Keyboard shortcuts

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