exchange

package
v0.0.0-...-f42d900 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddOutstandingLimitOrdersToOrderbook

func AddOutstandingLimitOrdersToOrderbook(
	ctx sdk.Context, keeper *keeper.Keeper,
	limitBuys []*types.Order,
	limitSells []*types.Order,
)

func CancelOrders

func CancelOrders(
	ctx sdk.Context, keeper *keeper.Keeper, contract types.ContractAddress, pair types.Pair,
	cancels []*types.Cancellation,
)

func MatchByValueFOKMarketOrder

func MatchByValueFOKMarketOrder(
	ctx sdk.Context,
	marketOrder *types.Order,
	orderBookEntries *types.CachedSortedOrderBookEntries,
	direction types.PositionDirection,
	totalExecuted *sdk.Dec,
	totalPrice *sdk.Dec,
	minPrice *sdk.Dec,
	maxPrice *sdk.Dec,
	settlements []*types.SettlementEntry,
	allTakerSettlements []*types.SettlementEntry,
	blockOrders *cache.BlockOrders,
) ([]*types.SettlementEntry, []*types.SettlementEntry)

func MatchFOKMarketOrder

func MatchFOKMarketOrder(
	ctx sdk.Context,
	marketOrder *types.Order,
	orderBookEntries *types.CachedSortedOrderBookEntries,
	direction types.PositionDirection,
	totalExecuted *sdk.Dec,
	totalPrice *sdk.Dec,
	minPrice *sdk.Dec,
	maxPrice *sdk.Dec,
	settlements []*types.SettlementEntry,
	allTakerSettlements []*types.SettlementEntry,
	blockOrders *cache.BlockOrders,
) ([]*types.SettlementEntry, []*types.SettlementEntry)

func MatchMarketOrder

func MatchMarketOrder(
	ctx sdk.Context,
	marketOrder *types.Order,
	orderBookEntries *types.CachedSortedOrderBookEntries,
	direction types.PositionDirection,
	totalExecuted *sdk.Dec,
	totalPrice *sdk.Dec,
	minPrice *sdk.Dec,
	maxPrice *sdk.Dec,
	settlements []*types.SettlementEntry,
	allTakerSettlements []*types.SettlementEntry,
	blockOrders *cache.BlockOrders,
) ([]*types.SettlementEntry, []*types.SettlementEntry)

func MergeByNominalTakerSettlements

func MergeByNominalTakerSettlements(settlements []*types.SettlementEntry) []*types.SettlementEntry

func Settle

func Settle(
	ctx sdk.Context,
	takerOrder *types.Order,
	quantityTaken sdk.Dec,
	orderbook *types.CachedSortedOrderBookEntries,
	worstPrice sdk.Dec,
	makerPrice sdk.Dec,
) ([]*types.SettlementEntry, []*types.SettlementEntry)

this function helps to settle market orders

func SettleFromBook

func SettleFromBook(
	ctx sdk.Context,
	orderbook *types.OrderBook,
	executedQuantity sdk.Dec,
	longPrice sdk.Dec,
	shortPrice sdk.Dec,
) []*types.SettlementEntry

func UpdateOrderData

func UpdateOrderData(
	takerOrder *types.Order,
	quantityTaken sdk.Dec,
	blockOrders *cache.BlockOrders,
)

this function update the order data in the memState to be noted that the order status will only reflect for market orders that are settled

Types

type ExecutionOutcome

type ExecutionOutcome struct {
	TotalNotional sdk.Dec
	TotalQuantity sdk.Dec
	Settlements   []*types.SettlementEntry
	MinPrice      sdk.Dec
	MaxPrice      sdk.Dec
}

func MatchLimitOrders

func MatchLimitOrders(
	ctx sdk.Context,
	orderbook *types.OrderBook,
) ExecutionOutcome

func MatchMarketOrders

func MatchMarketOrders(
	ctx sdk.Context,
	marketOrders []*types.Order,
	orderBookEntries *types.CachedSortedOrderBookEntries,
	direction types.PositionDirection,
	blockOrders *cache.BlockOrders,
) ExecutionOutcome

func (*ExecutionOutcome) Merge

Jump to

Keyboard shortcuts

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