liquidation

package
v0.75.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultStrat

func GetDefaultStrat() *types.LiquidationStrategy

GetDefaultStrat is exporeted, expected to be used to update existing proposals on protocol upgrade once that's happened, this code can be removed.

func GetLegacyStrat

func GetLegacyStrat() *types.LiquidationStrategy

GetLegacyStrat is exported, same as defaul. This can be used for protocol upgrade it most closely resebles the old behaviour (network attempts to close out fully, in one go) this can be removed once protocol upgrade has completed.

Types

type Book

type Book interface {
	GetVolumeAtPrice(price *num.Uint, side types.Side) uint64
}

type Engine

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

func (*Engine) ClearDistressedParties

func (e *Engine) ClearDistressedParties(ctx context.Context, idgen IDGen, closed []events.Margin, mp, mmp *num.Uint) ([]events.MarketPosition, []string, []*types.Trade)

ClearDistressedParties transfers the open positions to the network, returns the market position events and party ID's for the market to remove the parties from things like positions engine and collateral.

func (*Engine) GetNetworkPosition

func (e *Engine) GetNetworkPosition() events.MarketPosition

func (*Engine) GetNextCloseoutTS

func (e *Engine) GetNextCloseoutTS() int64

func (*Engine) GetState

func (e *Engine) GetState(key string) ([]byte, []types.StateProvider, error)

GetState must be thread-safe as it may be called from multiple goroutines concurrently!

func (*Engine) Keys

func (e *Engine) Keys() []string

func (*Engine) LoadState

func (e *Engine) LoadState(ctx context.Context, pl *types.Payload) ([]types.StateProvider, error)

func (*Engine) Namespace

func (e *Engine) Namespace() types.SnapshotNamespace

func (*Engine) OnTick

func (e *Engine) OnTick(ctx context.Context, now time.Time) (*types.Order, error)

func (*Engine) StopSnapshots

func (e *Engine) StopSnapshots()

func (*Engine) Stopped

func (e *Engine) Stopped() bool

func (*Engine) Update

func (e *Engine) Update(cfg *types.LiquidationStrategy)

func (*Engine) UpdateMarkPrice

func (e *Engine) UpdateMarkPrice(mp *num.Uint)

func (*Engine) UpdateNetworkPosition

func (e *Engine) UpdateNetworkPosition(trades []*types.Trade)

type IDGen

type IDGen interface {
	NextID() string
}

type MarketLiquidity

type MarketLiquidity interface {
	ValidOrdersPriceRange() (*num.Uint, *num.Uint, error)
}

type Pos

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

func (*Pos) AverageEntryPrice

func (p *Pos) AverageEntryPrice() *num.Uint

func (*Pos) Buy

func (p *Pos) Buy() int64

func (*Pos) BuySumProduct

func (p *Pos) BuySumProduct() *num.Uint

func (*Pos) Party

func (p *Pos) Party() string

func (*Pos) Price

func (p *Pos) Price() *num.Uint

func (*Pos) Sell

func (p *Pos) Sell() int64

func (*Pos) SellSumProduct

func (p *Pos) SellSumProduct() *num.Uint

func (*Pos) Size

func (p *Pos) Size() int64

func (*Pos) VWBuy

func (p *Pos) VWBuy() *num.Uint

func (*Pos) VWSell

func (p *Pos) VWSell() *num.Uint

type Positions

type Positions interface {
	RegisterOrder(ctx context.Context, order *types.Order) *positions.MarketPosition
	Update(ctx context.Context, trade *types.Trade, passiveOrder, aggressiveOrder *types.Order) []events.MarketPosition
}

type PriceMonitor added in v0.74.7

type PriceMonitor interface {
	GetValidPriceRange() (num.WrappedDecimal, num.WrappedDecimal)
}

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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