Documentation ¶
Index ¶
- type LiquidationPriority
- type LiquidationPriorityHeap
- func (h *LiquidationPriorityHeap) AddSubaccount(subaccountId types.SubaccountId, priority *big.Float)
- func (h LiquidationPriorityHeap) Len() int
- func (h LiquidationPriorityHeap) Less(i, j int) bool
- func (h *LiquidationPriorityHeap) Pop() interface{}
- func (h *LiquidationPriorityHeap) PopLowestPriority() *LiquidationPriority
- func (h *LiquidationPriorityHeap) Push(x interface{})
- func (h LiquidationPriorityHeap) Swap(i, j int)
- func (h *LiquidationPriorityHeap) UpdatePriority(item *LiquidationPriority, newPriority *big.Float) bool
- type SubaccountToDeleverage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LiquidationPriority ¶
type LiquidationPriority struct { SubaccountId types.SubaccountId Priority *big.Float Index int // The index of the item in the heap }
LiquidationPriority represents an item in our priority queue
type LiquidationPriorityHeap ¶
type LiquidationPriorityHeap []*LiquidationPriority
LiquidationPriorityHeap is a min-heap of LiquidationPriority items
func NewLiquidationPriorityHeap ¶
func NewLiquidationPriorityHeap() *LiquidationPriorityHeap
NewLiquidationPriorityHeap creates and initializes a new LiquidationPriorityHeap
func (*LiquidationPriorityHeap) AddSubaccount ¶
func (h *LiquidationPriorityHeap) AddSubaccount(subaccountId types.SubaccountId, priority *big.Float)
AddSubaccount adds a new subaccount to the heap
func (LiquidationPriorityHeap) Len ¶
func (h LiquidationPriorityHeap) Len() int
Len returns the number of elements in the heap
func (LiquidationPriorityHeap) Less ¶
func (h LiquidationPriorityHeap) Less(i, j int) bool
Less defines the ordering of items in the heap
func (*LiquidationPriorityHeap) Pop ¶
func (h *LiquidationPriorityHeap) Pop() interface{}
Pop removes and returns the minimum element (according to Less) from the heap
func (*LiquidationPriorityHeap) PopLowestPriority ¶
func (h *LiquidationPriorityHeap) PopLowestPriority() *LiquidationPriority
PopLowestPriority removes and returns the subaccount with the lowest priority
func (*LiquidationPriorityHeap) Push ¶
func (h *LiquidationPriorityHeap) Push(x interface{})
Push adds an element to the heap
func (LiquidationPriorityHeap) Swap ¶
func (h LiquidationPriorityHeap) Swap(i, j int)
Swap swaps the elements with indexes i and j
func (*LiquidationPriorityHeap) UpdatePriority ¶
func (h *LiquidationPriorityHeap) UpdatePriority(item *LiquidationPriority, newPriority *big.Float) bool
UpdatePriority updates the priority of a subaccount in the heap
type SubaccountToDeleverage ¶
type SubaccountToDeleverage struct { SubaccountId satypes.SubaccountId PerpetualId uint32 }
subaccountToDeleverage is a struct containing a subaccount ID and perpetual ID to deleverage. This struct is used as a return type for the LiquidateSubaccountsAgainstOrderbook and GetSubaccountsWithOpenPositionsInFinalSettlementMarkets called in PrepareCheckState.