Skip to content

Commit

Permalink
Merge pull request #11475 from vegaprotocol/release/v0.77.1
Browse files Browse the repository at this point in the history
Release/v0.77.1
  • Loading branch information
jeremyletang authored Jul 18, 2024
2 parents a72ff4b + 3112aa0 commit a5d58f3
Show file tree
Hide file tree
Showing 30 changed files with 260 additions and 112 deletions.
1 change: 1 addition & 0 deletions .spelling
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ clef
codegen
collateralised
cometbft
CometBFT
config
cyclomatic
dApp
Expand Down
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
- [](https://github.com/vegaprotocol/vega/issues/xxx)


## 0.77.1

### 🛠 Improvements

- [11466](https://github.com/vegaprotocol/vega/issues/11466) - Update CometBFT to version `0.38.10`.

### 🐛 Fixes

- [11453](https://github.com/vegaprotocol/vega/issues/11453) - Fix margin for fully collateralised markets.
- [11462](https://github.com/vegaprotocol/vega/issues/11462) - Update the time weighted notional when publishing live game scores.


## 0.77.0

### 🛠 Improvements
Expand Down Expand Up @@ -72,7 +84,6 @@
- [11457](https://github.com/vegaprotocol/vega/issues/11457) - Fix cursor column ordering for game scores.
- [11454](https://github.com/vegaprotocol/vega/issues/11454) - Ensure ended transfers proper handling.


## 0.76.1

### 🐛 Fixes
Expand Down
7 changes: 5 additions & 2 deletions core/execution/common/market_activity_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1186,8 +1186,11 @@ func (mat *MarketActivityTracker) getTWNotionalPosition(asset, party string, mar

for _, mkt := range mkts {
if tracker, ok := mat.getMarketTracker(asset, mkt); ok {
if twNotional, ok := tracker.twNotional[party]; ok {
total.AddSum(twNotional.currentEpochTWNotional)
if len(tracker.epochTimeWeightedNotional) <= 0 {
continue
}
if twNotional, ok := tracker.epochTimeWeightedNotional[len(tracker.epochTimeWeightedNotional)-1][party]; ok {
total.AddSum(twNotional)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ func TestAverageNotional(t *testing.T) {
// (( 116 * 5000000 ) + ( 600 * 5000000 )) / 10000000 = 358
tracker.processNotionalEndOfEpoch(time.Unix(0, 0), time.Unix(60, 0))
require.Equal(t, "358", tracker.twNotional["p1"].currentEpochTWNotional.String())
require.Equal(t, "358", tracker.epochTimeWeightedNotional[len(tracker.epochTimeWeightedNotional)-1]["p1"].String())

// epoch 2
// (( 358 * 0 ) + ( 600 * 10000000 )) / 10000000 = 600
Expand All @@ -330,12 +331,14 @@ func TestAverageNotional(t *testing.T) {
// (( 600 * 5000000 ) + ( 300 * 5000000 )) / 10000000 = 450
tracker.processNotionalEndOfEpoch(time.Unix(60, 0), time.Unix(120, 0))
require.Equal(t, "450", tracker.twNotional["p1"].currentEpochTWNotional.String())
require.Equal(t, "450", tracker.epochTimeWeightedNotional[len(tracker.epochTimeWeightedNotional)-1]["p1"].String())

// epoch 3
// no position changes over the epoch
// (( 450 * 0 ) + ( 300 * 10000000 )) / 10000000 = 300
tracker.processNotionalEndOfEpoch(time.Unix(120, 0), time.Unix(180, 0))
require.Equal(t, "300", tracker.twNotional["p1"].currentEpochTWNotional.String())
require.Equal(t, "300", tracker.epochTimeWeightedNotional[len(tracker.epochTimeWeightedNotional)-1]["p1"].String())
}

func TestCalculateMetricForIndividualsAvePosition(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Feature: When binary settlement is enabled, the market ignored oracle data that
| ETH/DEC22 | ETH | USD | simple-risk-model-1 | default-margin-calculator | 1 | fees-config-1 | price-monitoring-1 | ethDec22Oracle | 0.25 | 0 | default-futures | 1500 | false | true |
| ETH/DEC23 | ETH | USD | lognormal-risk-model-1 | default-margin-calculator | 1 | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.25 | 0 | default-futures | 1500 | true | true |

@NoPerp @Capped @CBin
@NoPerp @Capped @CBin @CappedBug
Scenario: 0016-PFUT-020: Pass in settlement prices that are neither 0 nor max price, then settle at valid prices.
Given the initial insurance pool balance is "10000" for all the markets
And the parties deposit on asset's general account the following amount:
Expand Down Expand Up @@ -157,16 +157,16 @@ Feature: When binary settlement is enabled, the market ignored oracle data that
And the market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC22"
And the parties should have the following account balances:
| party | asset | market id | margin | general |
| party1 | USD | ETH/DEC21 | 5000 | 5500 |
| party2 | USD | ETH/DEC21 | 2500 | 7000 |
| party1 | USD | ETH/DEC21 | 5500 | 5000 |
| party2 | USD | ETH/DEC21 | 2000 | 7500 |
| party3 | USD | ETH/DEC22 | 3200 | 7300 |
| party4 | USD | ETH/DEC22 | 2310 | 7190 |
| aux1 | USD | ETH/DEC21 | 3098 | 96908 |
| aux2 | USD | ETH/DEC21 | 402 | 99570 |
| aux5 | USD | ETH/DEC22 | 1122 | 98884 |
| aux6 | USD | ETH/DEC22 | 726 | 99246 |
| party5 | USD | ETH/DEC23 | 5000 | 5500 |
| party6 | USD | ETH/DEC23 | 2500 | 7000 |
| party5 | USD | ETH/DEC23 | 5500 | 5000 |
| party6 | USD | ETH/DEC23 | 2000 | 7500 |
| aux3 | USD | ETH/DEC23 | 3098 | 96908 |
| aux4 | USD | ETH/DEC23 | 402 | 99570 |

Expand Down
28 changes: 14 additions & 14 deletions core/integration/features/capped-futures/0016-PFUT-021.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Feature: When `max_price` is specified and the market is ran in a fully-collater
| id | quote name | asset | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | max price cap | fully collateralised | binary |
| ETH/DEC21 | ETH | USD | lognormal-risk-model-1 | default-capped-margin-calculator | 1 | fees-config-1 | price-monitoring-1 | ethDec21Oracle | 0.25 | 0 | default-futures | 1500 | true | false |

@SLABug @NoPerp @Capped @CMargin
@SLABug @NoPerp @Capped @CMargin @CappedBug
Scenario: 0016-PFUT-021: parties with open positions settling it at a price of `max_price`
Given the initial insurance pool balance is "10000" for all the markets
And the parties deposit on asset's general account the following amount:
Expand Down Expand Up @@ -97,8 +97,8 @@ Feature: When `max_price` is specified and the market is ran in a fully-collater
# aux2's short position and potential margins are calculated separately as 2 * (1500-1301) + 1 * (1500 - 1100) = 398 + 400 = 798
And the parties should have the following account balances:
| party | asset | market id | margin | general |
| party1 | USD | ETH/DEC21 | 5000 | 5500 |
| party2 | USD | ETH/DEC21 | 2500 | 7000 |
| party1 | USD | ETH/DEC21 | 5500 | 5000 |
| party2 | USD | ETH/DEC21 | 2000 | 7500 |
| aux1 | USD | ETH/DEC21 | 3098 | 96908 |
| aux2 | USD | ETH/DEC21 | 402 | 99570 |
# The market is fully collateralised, switching to isolated margin is not supported
Expand Down Expand Up @@ -126,18 +126,18 @@ Feature: When `max_price` is specified and the market is ran in a fully-collater
# aux2: short position of size 2, traded price at 1500, then margin: postion size * (max price - average entry price) = 3*(1100+1500*2)/3
And the parties should have the following account balances:
| party | asset | market id | margin | general |
| party1 | USD | ETH/DEC21 | 5000 | 7495 |
| party2 | USD | ETH/DEC21 | 2500 | 5005 |
| aux1 | USD | ETH/DEC21 | 3098 | 97307 |
| aux2 | USD | ETH/DEC21 | 402 | 99186 |
| party1 | USD | ETH/DEC21 | 7495 | 5000 |
| party2 | USD | ETH/DEC21 | 5 | 7500 |
| aux1 | USD | ETH/DEC21 | 3497 | 96908 |
| aux2 | USD | ETH/DEC21 | 3 | 99585 |
| aux3 | USD | ETH/DEC21 | 2998 | 96927 |

And the parties should have the following margin levels:
| party | market id | maintenance | search | initial | release | margin mode |
| party1 | ETH/DEC21 | 5000 | 5000 | 5000 | 5000 | cross margin |
| party2 | ETH/DEC21 | 2500 | 2500 | 2500 | 2500 | cross margin |
| aux2 | ETH/DEC21 | 402 | 402 | 402 | 402 | cross margin |
| aux1 | ETH/DEC21 | 3098 | 3098 | 3098 | 3098 | cross margin |
| party1 | ETH/DEC21 | 7495 | 7495 | 7495 | 7495 | cross margin |
| party2 | ETH/DEC21 | 5 | 5 | 5 | 5 | cross margin |
| aux2 | ETH/DEC21 | 3 | 3 | 3 | 3 | cross margin |
| aux1 | ETH/DEC21 | 3497 | 3497 | 3497 | 3497 | cross margin |

#0016-PFUT-024: trade at max_price, no closeout for parties with short position
When the parties place the following orders:
Expand All @@ -148,10 +148,10 @@ Feature: When `max_price` is specified and the market is ran in a fully-collater
And the network moves ahead "2" blocks

# aux5: short position of size 2, traded price at 1500, then margin: postion size * (max price - average entry price) = 0
And the parties should have the following account balances:
Then the parties should have the following account balances:
| party | asset | market id | margin | general |
| aux1 | USD | ETH/DEC21 | 3098 | 97307 |
| aux2 | USD | ETH/DEC21 | 402 | 99186 |
| aux1 | USD | ETH/DEC21 | 3497 | 96908 |
| aux2 | USD | ETH/DEC21 | 3 | 99585 |
| aux4 | USD | ETH/DEC21 | 2998 | 97017 |
| aux5 | USD | ETH/DEC21 | 2 | 99923 |

Expand Down
28 changes: 14 additions & 14 deletions core/integration/features/capped-futures/0016-PFUT-022-max.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Feature: When max_price is specified and the market is ran in a fully-collateral
| id | quote name | asset | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | max price cap | fully collateralised | binary |
| ETH/DEC21 | ETH | USD | lognormal-risk-model-1 | default-capped-margin-calculator | 1 | fees-config-1 | price-monitoring-1 | ethDec21Oracle | 0.25 | 0 | default-futures | 1500 | true | false |

@NoPerp @Capped @CSettle
@NoPerp @Capped @CSettle @CappedBug
Scenario: 0016-PFUT-022: Same as the settlement at price 0 test, only with a settlement at max price.
Given the initial insurance pool balance is "10000" for all the markets
And the parties deposit on asset's general account the following amount:
Expand Down Expand Up @@ -97,8 +97,8 @@ Feature: When max_price is specified and the market is ran in a fully-collateral
# aux2's short position and potential margins are calculated separately as 2 * (1500-1301) + 1 * (1500 - 1100) = 398 + 400 = 798
And the parties should have the following account balances:
| party | asset | market id | margin | general |
| party1 | USD | ETH/DEC21 | 5000 | 5500 |
| party2 | USD | ETH/DEC21 | 2500 | 7000 |
| party1 | USD | ETH/DEC21 | 5500 | 5000 |
| party2 | USD | ETH/DEC21 | 2000 | 7500 |
| aux1 | USD | ETH/DEC21 | 3098 | 96908 |
| aux2 | USD | ETH/DEC21 | 402 | 99570 |
# The market is fully collateralised, switching to isolated margin is not supported
Expand Down Expand Up @@ -126,18 +126,18 @@ Feature: When max_price is specified and the market is ran in a fully-collateral
# aux2: short position of size 2, traded price at 1500, then margin: postion size * (max price - average entry price) = 3*(1100+1500*2)/3
And the parties should have the following account balances:
| party | asset | market id | margin | general |
| party1 | USD | ETH/DEC21 | 5000 | 7495 |
| party2 | USD | ETH/DEC21 | 2500 | 5005 |
| aux1 | USD | ETH/DEC21 | 3098 | 97307 |
| aux2 | USD | ETH/DEC21 | 402 | 99186 |
| party1 | USD | ETH/DEC21 | 7495 | 5000 |
| party2 | USD | ETH/DEC21 | 5 | 7500 |
| aux1 | USD | ETH/DEC21 | 3497 | 96908 |
| aux2 | USD | ETH/DEC21 | 3 | 99585 |
| aux3 | USD | ETH/DEC21 | 2998 | 96927 |

And the parties should have the following margin levels:
| party | market id | maintenance | search | initial | release | margin mode |
| party1 | ETH/DEC21 | 5000 | 5000 | 5000 | 5000 | cross margin |
| party2 | ETH/DEC21 | 2500 | 2500 | 2500 | 2500 | cross margin |
| aux2 | ETH/DEC21 | 402 | 402 | 402 | 402 | cross margin |
| aux1 | ETH/DEC21 | 3098 | 3098 | 3098 | 3098 | cross margin |
| party1 | ETH/DEC21 | 7495 | 7495 | 7495 | 7495 | cross margin |
| party2 | ETH/DEC21 | 5 | 5 | 5 | 5 | cross margin |
| aux2 | ETH/DEC21 | 3 | 3 | 3 | 3 | cross margin |
| aux1 | ETH/DEC21 | 3497 | 3497 | 3497 | 3497 | cross margin |
#trade at max_price
When the parties place the following orders:
| party | market id | side | volume | price | resulting trades | type | tif | reference |
Expand Down Expand Up @@ -178,12 +178,12 @@ Feature: When max_price is specified and the market is ran in a fully-collateral
| market | aux3 | ACCOUNT_TYPE_SETTLEMENT | ACCOUNT_TYPE_MARGIN | ETH/DEC21 | 2 | USD | TRANSFER_TYPE_WIN |
| market | aux4 | ACCOUNT_TYPE_SETTLEMENT | ACCOUNT_TYPE_MARGIN | ETH/DEC21 | 2 | USD | TRANSFER_TYPE_WIN |
| market | party1 | ACCOUNT_TYPE_SETTLEMENT | ACCOUNT_TYPE_MARGIN | ETH/DEC21 | 5 | USD | TRANSFER_TYPE_WIN |
| aux1 | aux1 | ACCOUNT_TYPE_MARGIN | ACCOUNT_TYPE_GENERAL | ETH/DEC21 | 3099 | USD | TRANSFER_TYPE_CLEAR_ACCOUNT |
| aux2 | aux2 | ACCOUNT_TYPE_MARGIN | ACCOUNT_TYPE_GENERAL | ETH/DEC21 | 399 | USD | TRANSFER_TYPE_CLEAR_ACCOUNT |
| aux1 | aux1 | ACCOUNT_TYPE_MARGIN | ACCOUNT_TYPE_GENERAL | ETH/DEC21 | 3498 | USD | TRANSFER_TYPE_CLEAR_ACCOUNT |
| aux2 | aux2 | ACCOUNT_TYPE_MARGIN | ACCOUNT_TYPE_GENERAL | ETH/DEC21 | 0 | USD | TRANSFER_TYPE_CLEAR_ACCOUNT |
| aux3 | aux3 | ACCOUNT_TYPE_MARGIN | ACCOUNT_TYPE_GENERAL | ETH/DEC21 | 3000 | USD | TRANSFER_TYPE_CLEAR_ACCOUNT |
| aux4 | aux4 | ACCOUNT_TYPE_MARGIN | ACCOUNT_TYPE_GENERAL | ETH/DEC21 | 3000 | USD | TRANSFER_TYPE_CLEAR_ACCOUNT |
| aux5 | aux5 | ACCOUNT_TYPE_MARGIN | ACCOUNT_TYPE_GENERAL | ETH/DEC21 | 0 | USD | TRANSFER_TYPE_CLEAR_ACCOUNT |
| party1 | party1 | ACCOUNT_TYPE_MARGIN | ACCOUNT_TYPE_GENERAL | ETH/DEC21 | 5005 | USD | TRANSFER_TYPE_CLEAR_ACCOUNT |
| party1 | party1 | ACCOUNT_TYPE_MARGIN | ACCOUNT_TYPE_GENERAL | ETH/DEC21 | 7500 | USD | TRANSFER_TYPE_CLEAR_ACCOUNT |
| party-lp | party-lp | ACCOUNT_TYPE_BOND | ACCOUNT_TYPE_GENERAL | ETH/DEC21 | 30000 | USD | TRANSFER_TYPE_CLEAR_ACCOUNT |
And the parties should have the following account balances:
| party | asset | market id | margin | general |
Expand Down
Loading

0 comments on commit a5d58f3

Please sign in to comment.