Documentation ¶
Index ¶
- func AlwaysSuccessfulCollatCheckFn(subaccountMatchedOrders map[satypes.SubaccountId][]clobtypes.PendingOpenOrder) (success bool, successPerUpdate map[satypes.SubaccountId]satypes.UpdateResult)
- func CreateCollatCheckFunction(t *testing.T, collateralCheckCounter *int, ...) (collatCheckFn clobtypes.AddOrderToOrderbookCollateralizationCheckFn)
- func CreateSimpleCollatCheckFunction(t *testing.T, collateralCheckCounter *int, ...) (collatCheckFn clobtypes.AddOrderToOrderbookCollateralizationCheckFn)
- func HasMessage(offchainUpdates *types.OffchainUpdates, orderId types.OrderId, ...) bool
- func MessageCountOfType(offchainUpdates *types.OffchainUpdates, ...) int
- func OrderSideHumanReadable(isBuy bool) string
- func RequireCancelOrderMessage(t *testing.T, ctx sdk.Context, message *msgsender.Message, ...)
- func RequireCancelOrderOffchainUpdate(t *testing.T, ctx sdk.Context, offchainUpdate *types.OffchainUpdates, ...)
- type CollateralizationCheck
- type FakeMemClobKeeper
- func (f *FakeMemClobKeeper) AddOrderToOrderbookCollatCheck(ctx sdk.Context, clobPairId types.ClobPairId, ...) (success bool, successPerUpdate map[satypes.SubaccountId]satypes.UpdateResult)
- func (f *FakeMemClobKeeper) AddPreexistingStatefulOrder(ctx sdk.Context, order *types.Order, memclob types.MemClob) (orderSizeOptimisticallyFilledFromMatchingQuantums satypes.BaseQuantums, ...)
- func (f *FakeMemClobKeeper) CanDeleverageSubaccount(ctx sdk.Context, msg satypes.SubaccountId, perpetualId uint32) (bool, bool, error)
- func (f *FakeMemClobKeeper) CancelShortTermOrder(ctx sdk.Context, msgCancelOrder *types.MsgCancelOrder) error
- func (f *FakeMemClobKeeper) CommitState()
- func (f *FakeMemClobKeeper) DoesLongTermOrderExistInState(ctx sdk.Context, order types.Order) bool
- func (f *FakeMemClobKeeper) GetIndexerEventManager() indexer_manager.IndexerEventManager
- func (f *FakeMemClobKeeper) GetLongTermOrderPlacement(ctx sdk.Context, orderId types.OrderId) (val types.LongTermOrderPlacement, found bool)
- func (f *FakeMemClobKeeper) GetOrderFillAmount(ctx sdk.Context, orderId types.OrderId) (exists bool, fillAmount satypes.BaseQuantums, prunableBlockHeight uint32)
- func (f *FakeMemClobKeeper) GetStatePosition(ctx sdk.Context, subaccountId satypes.SubaccountId, ...) (positionSizeQuantums *big.Int)
- func (f *FakeMemClobKeeper) GetStatefulOrdersTimeSlice(ctx sdk.Context, goodTilBlockTime time.Time) (orderIds []types.OrderId)
- func (f *FakeMemClobKeeper) IsLiquidatable(ctx sdk.Context, subaccountId satypes.SubaccountId) (isLiquidatable bool, err error)
- func (f *FakeMemClobKeeper) Logger(ctx sdk.Context) log.Logger
- func (f *FakeMemClobKeeper) MustAddOrderToStatefulOrdersTimeSlice(ctx sdk.Context, goodTilBlockTime time.Time, orderId types.OrderId)
- func (f *FakeMemClobKeeper) OffsetSubaccountPerpetualPosition(ctx sdk.Context, liquidatedSubaccountId satypes.SubaccountId, ...) (fills []types.MatchPerpetualDeleveraging_Fill, deltaQuantumsRemaining *big.Int)
- func (f *FakeMemClobKeeper) PlaceShortTermOrder(ctx sdk.Context, msg *types.MsgPlaceOrder) (orderSizeOptimisticallyFilledFromMatchingQuantums satypes.BaseQuantums, ...)
- func (f *FakeMemClobKeeper) ProcessSingleMatch(ctx sdk.Context, matchWithOrders *types.MatchWithOrders) (success bool, takerUpdateResult satypes.UpdateResult, ...)
- func (f *FakeMemClobKeeper) ReplayPlaceOrder(ctx sdk.Context, msg *types.MsgPlaceOrder) (orderSizeOptimisticallyFilledFromMatchingQuantums satypes.BaseQuantums, ...)
- func (f *FakeMemClobKeeper) ResetState()
- func (f *FakeMemClobKeeper) SetLongTermOrderPlacement(ctx sdk.Context, order types.Order, blockHeight uint32)
- func (f *FakeMemClobKeeper) SetOrderFillAmount(ctx sdk.Context, orderId types.OrderId, fillAmount satypes.BaseQuantums)
- func (f *FakeMemClobKeeper) ValidateSubaccountEquityTierLimitForNewOrder(ctx sdk.Context, order types.Order) error
- func (f *FakeMemClobKeeper) WithCollatCheckFn(fn types.AddOrderToOrderbookCollateralizationCheckFn) *FakeMemClobKeeper
- func (f *FakeMemClobKeeper) WithCollatCheckFnForProcessSingleMatch() *FakeMemClobKeeper
- func (f *FakeMemClobKeeper) WithIndexerEventManager(indexerEventManager indexer_manager.IndexerEventManager) *FakeMemClobKeeper
- func (f *FakeMemClobKeeper) WithStatePositionFn(fn types.GetStatePositionFn) *FakeMemClobKeeper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlwaysSuccessfulCollatCheckFn ¶
func AlwaysSuccessfulCollatCheckFn( subaccountMatchedOrders map[satypes.SubaccountId][]clobtypes.PendingOpenOrder, ) (success bool, successPerUpdate map[satypes.SubaccountId]satypes.UpdateResult)
AlwaysSuccessfulCollatCheckFn is a collateralization check function that always returns success.
func CreateCollatCheckFunction ¶
func CreateCollatCheckFunction( t *testing.T, collateralCheckCounter *int, expectedCollatCheckParams map[int]map[satypes.SubaccountId][]clobtypes.PendingOpenOrder, collatCheckFailures map[int]map[satypes.SubaccountId]satypes.UpdateResult, ) ( collatCheckFn clobtypes.AddOrderToOrderbookCollateralizationCheckFn, )
CreateCollatCheckFunction creates a collateralization check function that can be used when calling the `PlaceOrder` function on the memclob. It asserts that the passed in parameters to the collateralization check function are correct, and returns the specified collateralization check results. Note that this function takes a pointer parameter representing the number of collateralization checks, and increments it after each performed collateralization check such that the caller can assert the expected number of collateralization checks are performed.
func CreateSimpleCollatCheckFunction ¶
func CreateSimpleCollatCheckFunction( t *testing.T, collateralCheckCounter *int, expectedCollatCheck map[int]CollateralizationCheck, ) ( collatCheckFn clobtypes.AddOrderToOrderbookCollateralizationCheckFn, )
CreateSimpleCollatCheckFunction creates a collateralization check function that can be used when calling the `PlaceOrder` function on the memclob. It asserts that the passed in parameters to the collateralization check function are correct, and returns the specified collateralization check results. Note that this function takes a pointer parameter representing the number of collateralization checks, and increments it after each performed collateralization check such that the caller can assert the expected number of collateralization checks are performed.
func HasMessage ¶
func HasMessage( offchainUpdates *types.OffchainUpdates, orderId types.OrderId, messageType types.OffchainUpdateMessageType, ) bool
HasMessage checks if OffchainUpdates contains an message for the given OrderId & OffchainUpdateMessageType. Useful for when we want to verify an update message was added for a specific scenario.
func MessageCountOfType ¶
func MessageCountOfType( offchainUpdates *types.OffchainUpdates, messageType types.OffchainUpdateMessageType, ) int
MessageCountOfType counts the number of messages in OffchainUpdates of a given type (Place/Remove/Update). Useful for when we want to verify we've added the correct number of messages.
func OrderSideHumanReadable ¶
OrderSideHumanReadable is a testing observability function that translates the boolean side of an order to a human readable string. For example, passing in `true` represents a buy order, so this function will return `"BUY"`, whereas passing in `false` will return `"SELL"`.
Types ¶
type CollateralizationCheck ¶
type CollateralizationCheck struct { CollatCheck map[satypes.SubaccountId][]clobtypes.PendingOpenOrder Result map[satypes.SubaccountId]satypes.UpdateResult }
CollateralizationCheck is a testing utility struct used to represent a collateralization check.
type FakeMemClobKeeper ¶
type FakeMemClobKeeper struct {
// contains filtered or unexported fields
}
TODO(DEC-1629): Remove FakeMemClobKeeper struct.
func NewFakeMemClobKeeper ¶
func NewFakeMemClobKeeper() *FakeMemClobKeeper
func (*FakeMemClobKeeper) AddOrderToOrderbookCollatCheck ¶
func (f *FakeMemClobKeeper) AddOrderToOrderbookCollatCheck( ctx sdk.Context, clobPairId types.ClobPairId, subaccountOpenOrders map[satypes.SubaccountId][]types.PendingOpenOrder, ) ( success bool, successPerUpdate map[satypes.SubaccountId]satypes.UpdateResult, )
func (*FakeMemClobKeeper) AddPreexistingStatefulOrder ¶
func (f *FakeMemClobKeeper) AddPreexistingStatefulOrder( ctx sdk.Context, order *types.Order, memclob types.MemClob, ) ( orderSizeOptimisticallyFilledFromMatchingQuantums satypes.BaseQuantums, orderStatus types.OrderStatus, offchainUpdates *types.OffchainUpdates, err error, )
func (*FakeMemClobKeeper) CanDeleverageSubaccount ¶
func (f *FakeMemClobKeeper) CanDeleverageSubaccount( ctx sdk.Context, msg satypes.SubaccountId, perpetualId uint32, ) ( bool, bool, error, )
func (*FakeMemClobKeeper) CancelShortTermOrder ¶
func (f *FakeMemClobKeeper) CancelShortTermOrder( ctx sdk.Context, msgCancelOrder *types.MsgCancelOrder, ) error
func (*FakeMemClobKeeper) CommitState ¶
func (f *FakeMemClobKeeper) CommitState()
Commit simulates `checkState.Commit()`.
func (*FakeMemClobKeeper) DoesLongTermOrderExistInState ¶
func (*FakeMemClobKeeper) GetIndexerEventManager ¶
func (f *FakeMemClobKeeper) GetIndexerEventManager() indexer_manager.IndexerEventManager
func (*FakeMemClobKeeper) GetLongTermOrderPlacement ¶
func (f *FakeMemClobKeeper) GetLongTermOrderPlacement( ctx sdk.Context, orderId types.OrderId, ) (val types.LongTermOrderPlacement, found bool)
func (*FakeMemClobKeeper) GetOrderFillAmount ¶
func (f *FakeMemClobKeeper) GetOrderFillAmount( ctx sdk.Context, orderId types.OrderId, ) ( exists bool, fillAmount satypes.BaseQuantums, prunableBlockHeight uint32, )
func (*FakeMemClobKeeper) GetStatePosition ¶
func (f *FakeMemClobKeeper) GetStatePosition( ctx sdk.Context, subaccountId satypes.SubaccountId, clobPairId types.ClobPairId, ) ( positionSizeQuantums *big.Int, )
func (*FakeMemClobKeeper) GetStatefulOrdersTimeSlice ¶
func (*FakeMemClobKeeper) IsLiquidatable ¶
func (f *FakeMemClobKeeper) IsLiquidatable( ctx sdk.Context, subaccountId satypes.SubaccountId, ) ( isLiquidatable bool, err error, )
func (*FakeMemClobKeeper) MustAddOrderToStatefulOrdersTimeSlice ¶
func (*FakeMemClobKeeper) OffsetSubaccountPerpetualPosition ¶
func (f *FakeMemClobKeeper) OffsetSubaccountPerpetualPosition( ctx sdk.Context, liquidatedSubaccountId satypes.SubaccountId, perpetualId uint32, deltaQuantumsTotal *big.Int, isFinalSettlement bool, ) ( fills []types.MatchPerpetualDeleveraging_Fill, deltaQuantumsRemaining *big.Int, )
func (*FakeMemClobKeeper) PlaceShortTermOrder ¶
func (f *FakeMemClobKeeper) PlaceShortTermOrder( ctx sdk.Context, msg *types.MsgPlaceOrder, ) ( orderSizeOptimisticallyFilledFromMatchingQuantums satypes.BaseQuantums, orderStatus types.OrderStatus, err error, )
func (*FakeMemClobKeeper) ProcessSingleMatch ¶
func (f *FakeMemClobKeeper) ProcessSingleMatch( ctx sdk.Context, matchWithOrders *types.MatchWithOrders, ) ( success bool, takerUpdateResult satypes.UpdateResult, makerUpdateResult satypes.UpdateResult, offchainUpdates *types.OffchainUpdates, err error, )
func (*FakeMemClobKeeper) ReplayPlaceOrder ¶
func (f *FakeMemClobKeeper) ReplayPlaceOrder( ctx sdk.Context, msg *types.MsgPlaceOrder, ) ( orderSizeOptimisticallyFilledFromMatchingQuantums satypes.BaseQuantums, orderStatus types.OrderStatus, offchainUpdates *types.OffchainUpdates, err error, )
func (*FakeMemClobKeeper) ResetState ¶
func (f *FakeMemClobKeeper) ResetState()
Commit simulates the `checkState` being reset and uncommitted.
func (*FakeMemClobKeeper) SetLongTermOrderPlacement ¶
func (*FakeMemClobKeeper) SetOrderFillAmount ¶
func (f *FakeMemClobKeeper) SetOrderFillAmount( ctx sdk.Context, orderId types.OrderId, fillAmount satypes.BaseQuantums, )
func (*FakeMemClobKeeper) ValidateSubaccountEquityTierLimitForNewOrder ¶
func (*FakeMemClobKeeper) WithCollatCheckFn ¶
func (f *FakeMemClobKeeper) WithCollatCheckFn( fn types.AddOrderToOrderbookCollateralizationCheckFn, ) *FakeMemClobKeeper
func (*FakeMemClobKeeper) WithCollatCheckFnForProcessSingleMatch ¶
func (f *FakeMemClobKeeper) WithCollatCheckFnForProcessSingleMatch() *FakeMemClobKeeper
func (*FakeMemClobKeeper) WithIndexerEventManager ¶
func (f *FakeMemClobKeeper) WithIndexerEventManager( indexerEventManager indexer_manager.IndexerEventManager, ) *FakeMemClobKeeper
func (*FakeMemClobKeeper) WithStatePositionFn ¶
func (f *FakeMemClobKeeper) WithStatePositionFn(fn types.GetStatePositionFn) *FakeMemClobKeeper