Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AMM rewards should be sent to the owner's key #11235

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
- [11127](https://github.com/vegaprotocol/vega/issues/11127) - Price monitoring engine should record all observations with the same weight
- [10995](https://github.com/vegaprotocol/vega/issues/10995) - Liquidation range defined by its own parameter.
- [11167](https://github.com/vegaprotocol/vega/issues/11167) - Add realised return reward metric.
- [11165] (https://github.com/vegaprotocol/vega/issues/11165) - Include negative returns in relative returns reward metric.
- [11165](https://github.com/vegaprotocol/vega/issues/11165) - Include negative returns in relative returns reward metric.
- [11151](https://github.com/vegaprotocol/vega/issues/11151) - Remove name field from the spot markets.
- [11170](https://github.com/vegaprotocol/vega/issues/11170) - Add transfer interval support.
- [11143](https://github.com/vegaprotocol/vega/issues/11143) - Add support for new asset proposal in batch governance proposal.
Expand All @@ -40,6 +40,7 @@
- [11143](https://github.com/vegaprotocol/vega/issues/11143) - Add support for new asset proposal in batch governance proposal
- [11182](https://github.com/vegaprotocol/vega/issues/11182) - Remove reduce only restriction on spot markets stop orders.
- [11153](https://github.com/vegaprotocol/vega/issues/11153) - Add check on start-up that bridge `RPC-endpoints` are functional.
- [11211](https://github.com/vegaprotocol/vega/issues/11211) - Liquidation engine includes `vAMM` shapes as available volume.

### 🐛 Fixes

Expand Down Expand Up @@ -82,6 +83,8 @@
- [11193](https://github.com/vegaprotocol/vega/issues/11193) - Fix loading of liquidation strategy from proto with missing data.
- [11200](https://github.com/vegaprotocol/vega/issues/11200) - Make sure a party can afford the trades before they are submitted to the book.
- [11205](https://github.com/vegaprotocol/vega/issues/11205) - Evaluate transfer interval correctly.
- [10374](https://github.com/vegaprotocol/vega/issues/10374) - Add transfer ID to recurring governance transfer ledger entries.

## 0.75.0

### 🚨 Breaking changes
Expand Down Expand Up @@ -166,6 +169,7 @@

- [10702](https://github.com/vegaprotocol/vega/pull/10700) - Use second precision in `GetMarginIncrease()` so that perpetual product uses second precision everywhere.
- [10698](https://github.com/vegaprotocol/vega/issues/10698) - Prevent `L2` from making too many `RPC` calls.
- [971](https://github.com/vegaprotocol/core-test-coverage/issues/971) - Add `AMM` support to the integration test framework.

## 0.74.2

Expand Down Expand Up @@ -200,6 +204,9 @@
- [10611](https://github.com/vegaprotocol/vega/issues/10611) - Added internal config price to update `perps`.
- [10615](https://github.com/vegaprotocol/vega/issues/10615) - Fix oracle scaling function in internal composite price.
- [10621](https://github.com/vegaprotocol/vega/issues/10621) - Fix market activity tracker storing incorrect data for previous `epochMakerFeesPaid`.
- [10643](https://github.com/vegaprotocol/vega/issues/10643) - Games `API` not showing quantum values and added filter for team and party.

## 0.74.0

### 🚨 Breaking changes

Expand Down
1 change: 1 addition & 0 deletions cmd/data-node/commands/start/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ func (l *NodeCommand) createGRPCServer(config api.Config) *api.GRPCServer {
l.gamesService,
l.marginModesService,
l.timeWeightedNotionalPositionService,
l.ammPoolsService,
)
return grpcServer
}
7 changes: 7 additions & 0 deletions cmd/data-node/commands/start/sqlsubscribers.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ type SQLSubscribers struct {
gamesStore *sqlstore.Games
marginModesStore *sqlstore.MarginModes
timeWeightedNotionalPositionStore *sqlstore.TimeWeightedNotionalPosition
ammPoolsStore *sqlstore.AMMPools

// Services
candleService *candlesv2.Svc
Expand Down Expand Up @@ -138,6 +139,7 @@ type SQLSubscribers struct {
gamesService *service.Games
marginModesService *service.MarginModes
timeWeightedNotionalPositionService *service.TimeWeightedNotionalPosition
ammPoolsService *service.AMMPools

// Subscribers
accountSub *sqlsubscribers.Account
Expand Down Expand Up @@ -190,6 +192,7 @@ type SQLSubscribers struct {
transactionResultsSub *sqlsubscribers.TransactionResults
marginModesSub *sqlsubscribers.MarginModes
timeWeightedNotionalPositionSub *sqlsubscribers.TimeWeightedNotionalPosition
ammPoolsSub *sqlsubscribers.AMMPools
}

func (s *SQLSubscribers) GetSQLSubscribers() []broker.SQLBrokerSubscriber {
Expand Down Expand Up @@ -246,6 +249,7 @@ func (s *SQLSubscribers) GetSQLSubscribers() []broker.SQLBrokerSubscriber {
s.transactionResultsSub,
s.marginModesSub,
s.timeWeightedNotionalPositionSub,
s.ammPoolsSub,
}
}

Expand Down Expand Up @@ -307,6 +311,7 @@ func (s *SQLSubscribers) CreateAllStores(ctx context.Context, Log *logging.Logge
s.gamesStore = sqlstore.NewGames(transactionalConnectionSource)
s.marginModesStore = sqlstore.NewMarginModes(transactionalConnectionSource)
s.timeWeightedNotionalPositionStore = sqlstore.NewTimeWeightedNotionalPosition(transactionalConnectionSource)
s.ammPoolsStore = sqlstore.NewAMMPools(transactionalConnectionSource)
}

func (s *SQLSubscribers) SetupServices(ctx context.Context, log *logging.Logger, candlesConfig candlesv2.Config) error {
Expand Down Expand Up @@ -363,6 +368,7 @@ func (s *SQLSubscribers) SetupServices(ctx context.Context, log *logging.Logger,
s.gamesService = service.NewGames(s.gamesStore)
s.marginModesService = service.NewMarginModes(s.marginModesStore)
s.timeWeightedNotionalPositionService = service.NewTimeWeightedNotionalPosition(s.timeWeightedNotionalPositionStore)
s.ammPoolsService = service.NewAMMPools(s.ammPoolsStore)

s.transactionResultsSub = sqlsubscribers.NewTransactionResults(log)
s.transactionResultsService = service.NewTransactionResults(s.transactionResultsSub)
Expand Down Expand Up @@ -432,4 +438,5 @@ func (s *SQLSubscribers) SetupSQLSubscribers() {
s.vestingSummarySub = sqlsubscribers.NewVestingBalancesSummary(s.partyVestingBalancesStore, s.partyLockedBalancesStore)
s.marginModesSub = sqlsubscribers.NewMarginModes(s.marginModesService)
s.timeWeightedNotionalPositionSub = sqlsubscribers.NewTimeWeightedNotionalPosition(s.timeWeightedNotionalPositionService)
s.ammPoolsSub = sqlsubscribers.NewAMMPools(s.ammPoolsService)
}
129 changes: 129 additions & 0 deletions commands/amend_amm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// Copyright (C) 2023 Gobalsky Labs Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package commands

import (
"math/big"

"code.vegaprotocol.io/vega/libs/num"
commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1"
)

func CheckAmendAMM(cmd *commandspb.AmendAMM) error {
return checkAmendAMM(cmd).ErrorOrNil()
}

func checkAmendAMM(cmd *commandspb.AmendAMM) Errors {
errs := NewErrors()

if cmd == nil {
return errs.FinalAddForProperty("amend_amm", ErrIsRequired)
}

if len(cmd.MarketId) <= 0 {
errs.AddForProperty("amend_amm.market_id", ErrIsRequired)
} else if !IsVegaID(cmd.MarketId) {
errs.AddForProperty("amend_amm.market_id", ErrShouldBeAValidVegaID)
}

if len(cmd.SlippageTolerance) <= 0 {
errs.AddForProperty("amend_amm.slippage_tolerance", ErrIsRequired)
} else if slippageTolerance, err := num.DecimalFromString(cmd.SlippageTolerance); err != nil {
errs.AddForProperty("amend_amm.slippage_tolerance", ErrIsNotValidNumber)
} else if slippageTolerance.LessThanOrEqual(num.DecimalZero()) || slippageTolerance.GreaterThan(num.DecimalOne()) {
errs.AddForProperty("amend_amm.slippage_tolerance", ErrMustBeBetween01)
}

var hasUpdate bool

if cmd.CommitmentAmount != nil {
hasUpdate = true
if amount, _ := big.NewInt(0).SetString(*cmd.CommitmentAmount, 10); amount == nil {
errs.FinalAddForProperty("amend_amm.commitment_amount", ErrIsNotValidNumber)
} else if amount.Cmp(big.NewInt(0)) <= 0 {
errs.AddForProperty("amend_amm.commitment_amount", ErrMustBePositive)
}
}

if cmd.ProposedFee != nil {
hasUpdate = true
if proposedFee, err := num.DecimalFromString(*cmd.ProposedFee); err != nil {
errs.AddForProperty("amend_amm.proposed_fee", ErrIsNotValid)
} else if proposedFee.LessThanOrEqual(num.DecimalZero()) {
errs.AddForProperty("amend_amm.proposed_fee", ErrMustBePositive)
}
}

if cmd.ConcentratedLiquidityParameters != nil {
if cmd.ConcentratedLiquidityParameters.Base != nil {
hasUpdate = true
if amount, _ := big.NewInt(0).SetString(*cmd.ConcentratedLiquidityParameters.Base, 10); amount == nil {
errs.FinalAddForProperty("amend_amm.concentrated_liquidity_parameters.base", ErrIsNotValidNumber)
} else if amount.Cmp(big.NewInt(0)) <= 0 {
errs.AddForProperty("amend_amm.concentrated_liquidity_parameters.base", ErrMustBePositive)
}
}
if cmd.ConcentratedLiquidityParameters.LowerBound != nil {
hasUpdate = true
if amount, _ := big.NewInt(0).SetString(*cmd.ConcentratedLiquidityParameters.LowerBound, 10); amount == nil {
errs.FinalAddForProperty("amend_amm.concentrated_liquidity_parameters.lower_bound", ErrIsNotValidNumber)
} else if amount.Cmp(big.NewInt(0)) <= 0 {
errs.AddForProperty("amend_amm.concentrated_liquidity_parameters.lower_bound", ErrMustBePositive)
}
}
if cmd.ConcentratedLiquidityParameters.UpperBound != nil {
hasUpdate = true
if amount, _ := big.NewInt(0).SetString(*cmd.ConcentratedLiquidityParameters.UpperBound, 10); amount == nil {
errs.FinalAddForProperty("amend_amm.concentrated_liquidity_parameters.upper_bound", ErrIsNotValidNumber)
} else if amount.Cmp(big.NewInt(0)) <= 0 {
errs.AddForProperty("amend_amm.concentrated_liquidity_parameters.upper_bound", ErrMustBePositive)
}
}

if cmd.ConcentratedLiquidityParameters.LeverageAtUpperBound != nil {
hasUpdate = true
if leverage, err := num.DecimalFromString(*cmd.ConcentratedLiquidityParameters.LeverageAtUpperBound); err != nil {
errs.AddForProperty("amend_amm.concentrated_liquidity_parameters.leverage_at_upper_bound", ErrIsNotValidNumber)
} else if leverage.LessThan(num.DecimalZero()) {
errs.AddForProperty("amend_amm.concentrated_liquidity_parameters.leverage_at_upper_bound", ErrMustBePositive)
}
}

if cmd.ConcentratedLiquidityParameters.LeverageAtLowerBound != nil {
hasUpdate = true
if leverage, err := num.DecimalFromString(*cmd.ConcentratedLiquidityParameters.LeverageAtLowerBound); err != nil {
errs.AddForProperty("amend_amm.concentrated_liquidity_parameters.leverage_at_lower_bound", ErrIsNotValidNumber)
} else if leverage.LessThan(num.DecimalZero()) {
errs.AddForProperty("amend_amm.concentrated_liquidity_parameters.leverage_at_lower_bound", ErrMustBePositive)
}
}

if len(cmd.SlippageTolerance) <= 0 {
errs.AddForProperty("submit_amm.slippage_tolerance", ErrIsRequired)
} else if slippageTolerance, err := num.DecimalFromString(cmd.SlippageTolerance); err != nil {
errs.AddForProperty("submit_amm.slippage_tolerance", ErrIsNotValidNumber)
} else if slippageTolerance.LessThan(num.DecimalZero()) {
errs.AddForProperty("submit_amm.slippage_tolerance", ErrMustBePositive)
}
}

// no update, but also no error, invalid
if !hasUpdate && errs.Empty() {
errs.FinalAdd(ErrNoUpdatesProvided)
}

return errs
}
Loading
Loading