Skip to content

Commit

Permalink
Revert "Sp/vault post only orders (#2198)" (#2296)
Browse files Browse the repository at this point in the history
  • Loading branch information
tqin7 committed Sep 19, 2024
1 parent 728d53a commit cee80fc
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 52 deletions.
8 changes: 0 additions & 8 deletions protocol/x/vault/keeper/orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,20 +314,12 @@ func (k Keeper) GetVaultClobOrders(
maxSubticks,
)

// If the side would increase the vault's inventory, make the order post-only.
timeInForceType := clobtypes.Order_TIME_IN_FORCE_UNSPECIFIED
if (side == clobtypes.Order_SIDE_SELL && inventory.Sign() <= 0) ||
(side == clobtypes.Order_SIDE_BUY && inventory.Sign() >= 0) {
timeInForceType = clobtypes.Order_TIME_IN_FORCE_POST_ONLY
}

return &clobtypes.Order{
OrderId: *orderId,
Side: side,
Quantums: orderSize.Uint64(), // Validated to be a uint64 above.
Subticks: subticksRounded,
GoodTilOneof: goodTilBlockTime,
TimeInForce: timeInForceType,
}
}

Expand Down
44 changes: 0 additions & 44 deletions protocol/x/vault/keeper/orders_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@ func TestGetVaultClobOrders(t *testing.T) {
/* --- Expectations --- */
expectedOrderSubticks []uint64
expectedOrderQuantums []uint64
expectedTimeInForce []clobtypes.Order_TimeInForce
expectedErr error
}{
"Success - Vault Clob 0, 2 layers, leverage 0, doesn't cross oracle price": {
Expand Down Expand Up @@ -569,14 +568,6 @@ func TestGetVaultClobOrders(t *testing.T) {
20_000_000_000,
20_000_000_000,
},
// post-only if increases inventory
// vault is flat, all orders should be post-only
expectedTimeInForce: []clobtypes.Order_TimeInForce{
clobtypes.Order_TIME_IN_FORCE_POST_ONLY,
clobtypes.Order_TIME_IN_FORCE_POST_ONLY,
clobtypes.Order_TIME_IN_FORCE_POST_ONLY,
clobtypes.Order_TIME_IN_FORCE_POST_ONLY,
},
},
"Success - Vault Clob 1, 3 layers, leverage -0.6, doesn't cross oracle price": {
vaultQuotingParams: vaulttypes.QuotingParams{
Expand Down Expand Up @@ -657,16 +648,6 @@ func TestGetVaultClobOrders(t *testing.T) {
41_666_000,
41_666_000,
},
// post-only if increases inventory
// vault is short, sell orders should be post-only
expectedTimeInForce: []clobtypes.Order_TimeInForce{
clobtypes.Order_TIME_IN_FORCE_POST_ONLY,
clobtypes.Order_TIME_IN_FORCE_UNSPECIFIED,
clobtypes.Order_TIME_IN_FORCE_POST_ONLY,
clobtypes.Order_TIME_IN_FORCE_UNSPECIFIED,
clobtypes.Order_TIME_IN_FORCE_POST_ONLY,
clobtypes.Order_TIME_IN_FORCE_UNSPECIFIED,
},
},
"Success - Vault Clob 1, 3 layers, leverage -3, crosses oracle price": {
vaultQuotingParams: vaulttypes.QuotingParams{
Expand Down Expand Up @@ -747,16 +728,6 @@ func TestGetVaultClobOrders(t *testing.T) {
33_333_000,
33_333_000,
},
// post-only if increases inventory
// vault is short, sell orders should be post-only
expectedTimeInForce: []clobtypes.Order_TimeInForce{
clobtypes.Order_TIME_IN_FORCE_POST_ONLY,
clobtypes.Order_TIME_IN_FORCE_UNSPECIFIED,
clobtypes.Order_TIME_IN_FORCE_POST_ONLY,
clobtypes.Order_TIME_IN_FORCE_UNSPECIFIED,
clobtypes.Order_TIME_IN_FORCE_POST_ONLY,
clobtypes.Order_TIME_IN_FORCE_UNSPECIFIED,
},
},
"Success - Vault Clob 1, 2 layers, leverage 3, crosses oracle price": {
vaultQuotingParams: vaulttypes.QuotingParams{
Expand Down Expand Up @@ -825,14 +796,6 @@ func TestGetVaultClobOrders(t *testing.T) {
333_333_000,
333_333_000,
},
// post-only if increases inventory
// vault is long, buy orders should be post-only
expectedTimeInForce: []clobtypes.Order_TimeInForce{
clobtypes.Order_TIME_IN_FORCE_UNSPECIFIED,
clobtypes.Order_TIME_IN_FORCE_POST_ONLY,
clobtypes.Order_TIME_IN_FORCE_UNSPECIFIED,
clobtypes.Order_TIME_IN_FORCE_POST_ONLY,
},
},
"Success - Get orders from Vault for Clob Pair 1, No Orders due to Zero Order Size": {
vaultQuotingParams: vaulttypes.QuotingParams{
Expand All @@ -857,7 +820,6 @@ func TestGetVaultClobOrders(t *testing.T) {
// round down to nearest multiple of step_base_quantums=1_000.
// order size is 0.
expectedOrderQuantums: []uint64{},
expectedTimeInForce: []clobtypes.Order_TimeInForce{},
},
"Success - Clob Pair doesn't exist, Empty orders": {
vaultQuotingParams: vaulttypes.DefaultQuotingParams(),
Expand All @@ -868,7 +830,6 @@ func TestGetVaultClobOrders(t *testing.T) {
perpetual: constants.EthUsd_NoMarginRequirement,
expectedOrderSubticks: []uint64{},
expectedOrderQuantums: []uint64{},
expectedTimeInForce: []clobtypes.Order_TimeInForce{},
},
"Success - Clob Pair in status final settlement, Empty orders": {
vaultQuotingParams: vaulttypes.DefaultQuotingParams(),
Expand All @@ -890,7 +851,6 @@ func TestGetVaultClobOrders(t *testing.T) {
perpetual: constants.EthUsd_NoMarginRequirement,
expectedOrderSubticks: []uint64{},
expectedOrderQuantums: []uint64{},
expectedTimeInForce: []clobtypes.Order_TimeInForce{},
},
"Error - Vault equity is zero": {
vaultQuotingParams: vaulttypes.DefaultQuotingParams(),
Expand Down Expand Up @@ -1019,7 +979,6 @@ func TestGetVaultClobOrders(t *testing.T) {
side clobtypes.Order_Side,
quantums uint64,
subticks uint64,
timeInForce clobtypes.Order_TimeInForce,
) *clobtypes.Order {
return &clobtypes.Order{
OrderId: clobtypes.OrderId{
Expand All @@ -1034,7 +993,6 @@ func TestGetVaultClobOrders(t *testing.T) {
GoodTilOneof: &clobtypes.Order_GoodTilBlockTime{
GoodTilBlockTime: uint32(ctx.BlockTime().Unix()) + tc.vaultQuotingParams.OrderExpirationSeconds,
},
TimeInForce: timeInForce,
}
}
expectedOrders := make([]*clobtypes.Order, 0)
Expand All @@ -1047,15 +1005,13 @@ func TestGetVaultClobOrders(t *testing.T) {
clobtypes.Order_SIDE_SELL,
tc.expectedOrderQuantums[i],
tc.expectedOrderSubticks[i],
tc.expectedTimeInForce[i],
),
// bid.
buildVaultClobOrder(
uint8(i/2),
clobtypes.Order_SIDE_BUY,
tc.expectedOrderQuantums[i+1],
tc.expectedOrderSubticks[i+1],
tc.expectedTimeInForce[i+1],
),
)
}
Expand Down

0 comments on commit cee80fc

Please sign in to comment.