Skip to content

Commit a46b320

Browse files
committed
Merge branch 'ethereum-heartbeat' of github.com:vegaprotocol/specs into ethereum-heartbeat
2 parents 577b6cb + e209e4c commit a46b320

23 files changed

+1504
-1211
lines changed

protocol/0001-MKTF-market_framework.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Data:
3232
- **Position Decimal Places**: number of decimal places for orders and positions, i.e. if this is 2 then the smallest increment that can be traded is 0.01, for example 0.01 BTC in a `BTSUSD` market.
3333
- If this is negative e.g. -3 this means that the smallest order and position is of size 1000.
3434
- Accepted values are `-6,...,-1,0,1,2,...,6`.
35+
- **Liquidation strategy**: A field specifying the liquidation strategy for the market. Please refer to [0012-POSR-position_resolution](./0012-POSR-position_resolution.md#managing-networks-position) for supported strategies.
3536

3637
Note: it is agreed that initially the integer representation of the full precision of both order and positions can be required to fit into an int64, so this means that the largest position/order size possible reduces by a factor of ten for every extra decimal place used. This also means that, for instance, it would not be possible to create a `BTCUSD` market that allows order/position sizes equivalent to 1 sat.
3738

protocol/0004-AMND-amends.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44

55
- Only LIMIT or PEGGED orders can be amended. Any attempt to amend a MARKET order is rejected (<a name="0004-AMND-001" href="#0004-AMND-001">0004-AMND-001</a>). For product spot: (<a name="0004-AMND-030" href="#0004-AMND-030">0004-AMND-030</a>)
66
- Price change amends remove the order from the book and insert the order at the back of the queue at the new price level (<a name="0004-AMND-002" href="#0004-AMND-002">0004-AMND-002</a>). For product spot: (<a name="0004-AMND-031" href="#0004-AMND-031">0004-AMND-031</a>)
7-
- Reducing the quantity leaves the order in its current spot but reduces the remaining amount accordingly (<a name="0004-AMND-003" href="#0004-AMND-003">0004-AMND-003</a>). For product spot: (<a name="0004-AMND-032" href="#0004-AMND-032">0004-AMND-032</a>)
8-
- Quantity after amendment must be a multiple of the smallest increment possible given the `Position Decimal Places` (PDP) specified in the [Market Framework](./0001-MKTF-market_framework.md), i.e. is PDP = 2 then quantity must be a whole multiple of 0.01. (<a name="0004-AMND-004" href="#0004-AMND-004">0004-AMND-004</a>). For product spot: (<a name="0004-AMND-055" href="#0004-AMND-055">0004-AMND-055</a>)
9-
- Increasing the quantity causes the order to be removed from the book and inserted at the back of the price level queue with the updated quantity (<a name="0004-AMND-005" href="#0004-AMND-005">0004-AMND-005</a>). For product spot: (<a name="0004-AMND-033" href="#0004-AMND-033">0004-AMND-033</a>)
7+
- Reducing the quantity by specifying a `sizeDelta` leaves the order in its current spot but reduces the remaining amount accordingly (<a name="0004-AMND-003" href="#0004-AMND-003">0004-AMND-003</a>). For product spot: (<a name="0004-AMND-032" href="#0004-AMND-032">0004-AMND-032</a>)
8+
- Quantity after amendment using a `sizeDelta` must be a multiple of the smallest increment possible given the `Position Decimal Places` (PDP) specified in the [Market Framework](./0001-MKTF-market_framework.md), i.e. is PDP = 2 then quantity must be a whole multiple of 0.01. (<a name="0004-AMND-004" href="#0004-AMND-004">0004-AMND-004</a>). For product spot: (<a name="0004-AMND-055" href="#0004-AMND-055">0004-AMND-055</a>)
9+
- Increasing the quantity by specifying a `sizeDelta` causes the order to be removed from the book and inserted at the back of the price level queue with the updated quantity (<a name="0004-AMND-005" href="#0004-AMND-005">0004-AMND-005</a>). For product spot: (<a name="0004-AMND-033" href="#0004-AMND-033">0004-AMND-033</a>)
10+
- Size change amends specifying a `size` greater than the current size remove and reinsert the order at the back of the price level and increase the remaining amount accordingly (<a name="0004-AMND-056" href="#0004-AMND-056">0004-AMND-056</a>).
11+
- Size change amends specifying a `size` lower than the current size leave the order in its current spot and reduce the remaining amount of the order accordingly (<a name="0004-AMND-057" href="#0004-AMND-057">0004-AMND-057</a>).
12+
- Size change amends which would result in the remaining part of the order being reduced below zero should instead cancel the order (<a name="0004-AMND-058" href="#0004-AMND-058">0004-AMND-058</a>).
13+
- A transaction specifying both a `sizeDelta` and `size` field should be rejected as invalid (<a name="0004-AMND-059" href="#0004-AMND-059">0004-AMND-059</a>).
1014
- Changing the `TIF` can only occur between `GTC` and `GTT`. Any attempt to amend to another `TIF` flag is rejected. A `GTT` must have an `expiresAt` value but a `GTC` must not have one. (<a name="0004-AMND-006" href="#0004-AMND-006">0004-AMND-006</a>). For product spot: (<a name="0004-AMND-034" href="#0004-AMND-034">0004-AMND-034</a>)
1115
- Any attempt to amend to or from the `TIF` values `GFA` and `GFN` will result in a rejected amend. (<a name="0004-AMND-007" href="#0004-AMND-007">0004-AMND-007</a>). For product spot: (<a name="0004-AMND-035" href="#0004-AMND-035">0004-AMND-035</a>)
1216
- All updates to an existing order update the `UpdatedAt` time stamp field in the order (<a name="0004-AMND-008" href="#0004-AMND-008">0004-AMND-008</a>). For product spot: (<a name="0004-AMND-036" href="#0004-AMND-036">0004-AMND-036</a>)
@@ -42,7 +46,7 @@ The amend order can alter the quantity, price and expiry time/`TIF` type. For pe
4246

4347
## Guide-level explanation
4448

45-
The amend order message is a custom message containing the `orderID` of the original order and optional fields that can be altered. Prices can be changed with a new absolute value, quantity can be reduced or increased from their current remaining size. Expiry time can be set to a new value and the `TIF` type can be toggled between `GTC` and `GTT`. Changing the `TIF` field will impact the value in the `ExpiryTime` field as it will either be blanked or set to a new valid value.
49+
The amend order message is a custom message containing the `orderID` of the original order and optional fields that can be altered. Prices can be changed with a new absolute value, sizes can be changed by either specifying a size delta or a new absolute value. If a user attempts to amend the size of an order by specifying both a size delta and anew absolute value the order should be rejected. Expiry time can be set to a new value and the `TIF` type can be toggled between `GTC` and `GTT`. Changing the `TIF` field will impact the value in the `ExpiryTime` field as it will either be blanked or set to a new valid value.
4650

4751
Some examples:
4852
A LIMIT order sitting on the bid side of the order book:
@@ -58,6 +62,15 @@ amendOrder{
5862
}
5963
```
6064

65+
or
66+
67+
```json
68+
amendOrder{
69+
orderID: "V0000000001-0000000001"
70+
size: 300
71+
}
72+
```
73+
6174
This will be the resulting order book:
6275

6376
`Bids: 300@1000 GTC (OrderID V0000000001-0000000001)`
@@ -86,7 +99,9 @@ The fields which can be altered are:
8699
- `Price`
87100
- Amending the price causes the order to be removed from the book and re-inserted at the new price level. This can result in the order being filled if the price is moved to a level that would cross.
88101
- `SizeDelta`
89-
- A size change is specified as a delta to the current amount. This will be applied to both the `Size` and `Remaining` part of the order. In the case that the remaining amount it reduced to zero or less, the order is cancelled. This must be a multiple of the smallest value allowed by the `Position Decimal Places` (PDP) specified in the [Market Framework](./0001-MKTF-market_framework.md), i.e. is PDP = 2 then `SizeDelta` must be a whole multiple of 0.01. (NB: `SizeDelta` may use an int64 where the int value 1 is the smallest multiple allowable given the configured dp). In case PDP is negative this again applies e.g. if PDP = -1 then `SizeDelta` must be a whole multiple of 10.
102+
- Amending the size by specifying a `sizeDelta` will be applied to both the `Size` and `Remaining` part of the order. In the case that the remaining amount it reduced to zero or less, the order is cancelled. This must be a multiple of the smallest value allowed by the `Position Decimal Places` (PDP) specified in the [Market Framework](./0001-MKTF-market_framework.md), i.e. is PDP = 2 then `SizeDelta` must be a whole multiple of 0.01. (NB: `SizeDelta` may use an int64 where the int value 1 is the smallest multiple allowable given the configured dp). In case PDP is negative this again applies e.g. if PDP = -1 then `SizeDelta` must be a whole multiple of 10.
103+
- `Size`
104+
- Amending the size by specifying a new `size` causes the the `Size` and `Remaining` part of the order to be amended by the difference between the original and amended size. In the case that the remaining amount it reduced to zero or less, the order is cancelled. This must be a multiple of the smallest value allowed by the `Position Decimal Places` (PDP) specified in the [Market Framework](./0001-MKTF-market_framework.md), i.e. is PDP = 2 then `Size` must be a whole multiple of 0.01. (NB: `Size` may use an int64 where the int value 1 is the smallest multiple allowable given the configured dp). In case PDP is negative this again applies e.g. if PDP = -1 then `Size` must be a whole multiple of 10.
90105
- `TimeInForce`
91106
- The `TIF` enumeration can only be toggled between `GTT` and `GTC`. Amending to `GTT` requires an `expiryTime` value to be set. Amending to `GTC` removes the `expiryTime` value.
92107
- `ExpiryTime`
@@ -110,10 +125,11 @@ message amendOrder {
110125
enum TIF 4;
111126
int64 expiryTime 5;
112127
PeggedOrder *peggedOrder 6;
128+
int64 size 7;
113129
}
114130
```
115131

116-
An example of using a negative size is shown below:
132+
An example of reducing the size is shown below:
117133

118134
`Bids: 100@1000 GTC (OrderID V0000000001-0000000001)`
119135

@@ -124,6 +140,13 @@ amendOrder{ orderID:"V0000000001-0000000001",
124140
sizeDelta: -50 }
125141
```
126142

143+
or
144+
145+
```json
146+
amendOrder{ orderID:"V0000000001-0000000001",
147+
size: 50 }
148+
```
149+
127150
The resulting order book will be:
128151

129152
`Bids: 50@1000 GTC (OrderID V0000000001-0000000001)`

protocol/0010-MARG-margin_orchestration.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ This specification outlines:
3434

3535
### **Background - how margin levels are calculated**
3636

37-
The [margin calculator](./0019-MCAL-margin_calculator.md) will calculate the margin levels when instructed to do so. It will return four margin levels for each trader:
37+
The [margin calculator](./0019-MCAL-margin_calculator.md) will calculate the margin levels when instructed to do so. It will return five margin levels for each trader:
3838

3939
1. maintenance margin
40+
1. order margin
4041
1. collateral search level
4142
1. initial margin
4243
1. collateral release level

0 commit comments

Comments
 (0)