Skip to content

Commit

Permalink
Merge pull request #11605 from vegaprotocol/governance-check-amm-els
Browse files Browse the repository at this point in the history
fix: count sub-key ELS for the parent key when voting
  • Loading branch information
EVODelavega authored Aug 22, 2024
2 parents 880103f + efc92c3 commit db4e035
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
- [11579](https://github.com/vegaprotocol/vega/issues/11579) - Spot calculate fee on amend, use order price if no amended price is provided.
- [11585](https://github.com/vegaprotocol/vega/issues/11585) - Initialise rebate stats service in API.
- [11592](https://github.com/vegaprotocol/vega/issues/11592) - Fix the order of calls at end of epoch between rebate engine and market tracker.
- [959](https://github.com/vegaprotocol/core-test-coverage/issues/959) - Include `ELS` for `AMM` sub keys to the parent key `ELS`.

## 0.77.5

Expand Down
1 change: 1 addition & 0 deletions core/execution/common/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ type CommonMarket interface {
GetMarketData() types.MarketData
StartOpeningAuction(context.Context) error
GetEquityShares() *EquityShares
GetEquitySharesForParty(partyID string) num.Decimal
IntoType() types.Market
OnEpochEvent(ctx context.Context, epoch types.Epoch)
OnEpochRestore(ctx context.Context, epoch types.Epoch)
Expand Down
2 changes: 1 addition & 1 deletion core/execution/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ func (e *Engine) GetMarket(market string, settled bool) (types.Market, bool) {
// party in the given market. If the market doesn't exist, it returns false.
func (e *Engine) GetEquityLikeShareForMarketAndParty(market, party string) (num.Decimal, bool) {
if mkt, ok := e.allMarkets[market]; ok {
return mkt.GetEquityShares().SharesFromParty(party), true
return mkt.GetEquitySharesForParty(party), true
}
return num.DecimalZero(), false
}
Expand Down
8 changes: 8 additions & 0 deletions core/execution/future/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,14 @@ func (m *Market) GetEquityShares() *common.EquityShares {
return m.equityShares
}

func (m *Market) GetEquitySharesForParty(partyID string) num.Decimal {
primary := m.equityShares.SharesFromParty(partyID)
if sub, err := m.amm.GetAMMParty(partyID); err == nil {
return primary.Add(m.equityShares.SharesFromParty(sub))
}
return primary
}

func (m *Market) ResetParentIDAndInsurancePoolFraction() {
m.mkt.ParentMarketID = ""
m.mkt.InsurancePoolFraction = num.DecimalZero()
Expand Down
9 changes: 9 additions & 0 deletions core/execution/spot/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,15 @@ func (m *Market) GetEquityShares() *common.EquityShares {
return m.equityShares
}

func (m *Market) GetEquitySharesForParty(partyID string) num.Decimal {
primary := m.equityShares.SharesFromParty(partyID)
// AMM for spot has not been implemented yet
// if sub, err := m.amm.GetAMMParty(partyID); err == nil {
// return primary.Add(m.equityShares.SharesFromParty(sub))
// }
return primary
}

func (m *Market) SetNextMTM(tm time.Time) {
m.nextMTM = tm
}
Expand Down

0 comments on commit db4e035

Please sign in to comment.