heap

package
v0.0.0-...-23a414b Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 3 Imported by: 0

Documentation

Index

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.

Jump to

Keyboard shortcuts

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