Skip to content

Commit

Permalink
[CLOB-858] Add liquidation tests with different block limits (#772)
Browse files Browse the repository at this point in the history
* [CLOB-858] Add liquidation tests with different block limits

* long tests

* comments
  • Loading branch information
jayy04 authored Nov 9, 2023
1 parent 238427b commit eaf1b04
Show file tree
Hide file tree
Showing 3 changed files with 674 additions and 0 deletions.
28 changes: 28 additions & 0 deletions protocol/testutil/constants/orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,13 @@ var (
Subticks: 10,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 15},
}
Order_Carl_Num0_Id1_Clob0_Buy01BTC_Price49500_GTB10 = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Carl_Num0, ClientId: 1, ClobPairId: 0},
Side: clobtypes.Order_SIDE_BUY,
Quantums: 10_000_000,
Subticks: 49_500_000_000,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 10},
}
Order_Carl_Num0_Id0_Clob0_Buy1BTC_Price49500_GTB10 = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Carl_Num0, ClientId: 0, ClobPairId: 0},
Side: clobtypes.Order_SIDE_BUY,
Expand All @@ -624,6 +631,13 @@ var (
Subticks: 50_000_000_000,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 10},
}
Order_Carl_Num0_Id2_Clob0_Buy1BTC_Price50500_GTB10 = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Carl_Num0, ClientId: 2, ClobPairId: 0},
Side: clobtypes.Order_SIDE_BUY,
Quantums: 100_000_000,
Subticks: 50_500_000_000,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 10},
}
Order_Carl_Num0_Id1_Clob0_Buy1BTC_Price49999 = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Carl_Num0, ClientId: 1, ClobPairId: 0},
Side: clobtypes.Order_SIDE_BUY,
Expand Down Expand Up @@ -771,6 +785,13 @@ var (
Subticks: 50_000_000_000,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 10},
}
Order_Dave_Num0_Id2_Clob0_Sell1BTC_Price49500_GTB10 = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Dave_Num0, ClientId: 2, ClobPairId: 0},
Side: clobtypes.Order_SIDE_SELL,
Quantums: 100_000_000,
Subticks: 49_500_000_000,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 10},
}
Order_Dave_Num0_Id0_Clob0_Sell1BTC_Price49999_GTB10 = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Dave_Num0, ClientId: 0, ClobPairId: 0},
Side: clobtypes.Order_SIDE_SELL,
Expand All @@ -792,6 +813,13 @@ var (
Subticks: 50_498_000_000,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 10},
}
Order_Dave_Num0_Id1_Clob0_Sell01BTC_Price50500_GTB10 = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Dave_Num0, ClientId: 1, ClobPairId: 0},
Side: clobtypes.Order_SIDE_SELL,
Quantums: 10_000_000,
Subticks: 50_500_000_000,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 10},
}
Order_Dave_Num0_Id0_Clob0_Sell1BTC_Price50500_GTB10 = clobtypes.Order{
OrderId: clobtypes.OrderId{SubaccountId: Dave_Num0, ClientId: 0, ClobPairId: 0},
Side: clobtypes.Order_SIDE_SELL,
Expand Down
30 changes: 30 additions & 0 deletions protocol/testutil/constants/subaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,21 @@ var (
},
},
}
Carl_Num1_1BTC_Short_50499USD = satypes.Subaccount{
Id: &Carl_Num1,
AssetPositions: []*satypes.AssetPosition{
{
AssetId: 0,
Quantums: dtypes.NewInt(50_499_000_000), // $50,499
},
},
PerpetualPositions: []*satypes.PerpetualPosition{
{
PerpetualId: 0,
Quantums: dtypes.NewInt(-100_000_000), // -1 BTC
},
},
}
Dave_Num0_01BTC_Long_50000USD = satypes.Subaccount{
Id: &Dave_Num0,
AssetPositions: []*satypes.AssetPosition{
Expand Down Expand Up @@ -502,6 +517,21 @@ var (
},
},
}
Dave_Num1_1BTC_Long_49501USD_Short = satypes.Subaccount{
Id: &Dave_Num1,
AssetPositions: []*satypes.AssetPosition{
{
AssetId: 0,
Quantums: dtypes.NewInt(-49_501_000_000), // -$49,501
},
},
PerpetualPositions: []*satypes.PerpetualPosition{
{
PerpetualId: 0,
Quantums: dtypes.NewInt(100_000_000), // 1 BTC
},
},
}
Dave_Num1_1ETH_Long_50000USD = satypes.Subaccount{
Id: &Dave_Num1,
AssetPositions: []*satypes.AssetPosition{
Expand Down
Loading

0 comments on commit eaf1b04

Please sign in to comment.