From 674cace1492f324255575af1d4dd1f65317d14d6 Mon Sep 17 00:00:00 2001 From: Unique Divine <51418232+Unique-Divine@users.noreply.github.com> Date: Sun, 3 Dec 2023 12:41:45 -0600 Subject: [PATCH] feat(perp): MsgShiftPegMultiplier, MsgShiftSwapInvariant (#1680) * chore(deps): Bump cosmossdk.io/math from 1.1.2 to 1.2.0 Bumps [cosmossdk.io/math](https://github.com/cosmos/cosmos-sdk) from 1.1.2 to 1.2.0. - [Release notes](https://github.com/cosmos/cosmos-sdk/releases) - [Changelog](https://github.com/cosmos/cosmos-sdk/blob/main/CHANGELOG.md) - [Commits](https://github.com/cosmos/cosmos-sdk/compare/math/v1.1.2...log/v1.2.0) --- updated-dependencies: - dependency-name: cosmossdk.io/math dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * feat(perp): msg server methods for shift peg and shift swap invariant * (wasmbinding): remove pegshitft and depth shift * test(perp): msg tests * change log * Update x/perp/v2/types/msgs.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * PR comments changes * add events for logging purposes * refactor: consistent error name usage PR comment * refactor: more PR comments * Address Gimeno PR comments + more tests * fix strange address name conflicts * test: fix all tests * test: more calls of EnsureNibiruPrefix * Updated changelog - dependabot * test: fix no error cases in tests --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Unique-Divine --- CHANGELOG.md | 1 + app/genesis.go | 1 + app/ibc_test.go | 1 + app/keepers.go | 22 +- proto/nibiru/perp/v2/event.proto | 26 + proto/nibiru/perp/v2/tx.proto | 58 +- wasmbinding/bindings/msg.go | 12 - wasmbinding/exec_perp.go | 33 - wasmbinding/exec_perp_test.go | 31 - wasmbinding/exec_test.go | 68 -- wasmbinding/message_plugin.go | 16 - wasmbinding/wasmbin_test.go | 4 + x/common/constants.go | 4 +- x/common/testutil/const.go | 6 + x/common/testutil/testapp/testapp.go | 23 +- x/devgas/v1/ante/ante_test.go | 1 + x/inflation/keeper/inflation_test.go | 12 +- x/oracle/keeper/hooks_test.go | 4 + x/perp/v2/integration/action/dnr.go | 29 +- x/perp/v2/integration/action/market.go | 31 +- x/perp/v2/integration/action/position.go | 24 +- x/perp/v2/keeper/admin.go | 87 ++ x/perp/v2/keeper/admin_test.go | 171 +++- x/perp/v2/keeper/amm.go | 94 +- x/perp/v2/keeper/amm_test.go | 65 +- x/perp/v2/keeper/clearing_house_test.go | 23 +- x/perp/v2/keeper/fixture_test.go | 1 + x/perp/v2/keeper/msg_server.go | 41 +- x/perp/v2/keeper/msg_server_test.go | 12 +- x/perp/v2/module/genesis_test.go | 2 +- x/perp/v2/types/amm.go | 2 +- x/perp/v2/types/amm_test.go | 2 +- x/perp/v2/types/codec.go | 4 + x/perp/v2/types/codec_test.go | 2 + x/perp/v2/types/errors.go | 8 +- x/perp/v2/types/event.pb.go | 683 +++++++++++-- x/perp/v2/types/msgs.go | 80 +- x/perp/v2/types/msgs_test.go | 54 + x/perp/v2/types/tx.pb.go | 1150 +++++++++++++++++++--- x/spot/genesis_test.go | 1 + x/spot/keeper/balances_test.go | 1 + x/sudo/keeper/keeper.go | 4 +- 42 files changed, 2303 insertions(+), 591 deletions(-) create mode 100644 x/common/testutil/const.go create mode 100644 x/perp/v2/keeper/fixture_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index ae6f5463e..19ca82776 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,6 +74,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#1617](https://github.com/NibiruChain/nibiru/pull/1617) - fix(app)!: non-nil snapshot manager is not guaranteed in testapp * [#1645](https://github.com/NibiruChain/nibiru/pull/1645) - fix(tokenfactory)!: token supply in bank keeper must be correct after MsgBurn. * [#1646](https://github.com/NibiruChain/nibiru/pull/1646) - feat(wasmbinding)!: whitelisted stargate queries for QueryRequest::Stargate: auth, bank, gov, tokenfactory, epochs, inflation, oracle, sudo, devgas +* [#1680](https://github.com/NibiruChain/nibiru/pull/1680) - feat(perp): MsgShiftPegMultiplier, MsgShiftSwapInvariant. ### Improvements diff --git a/app/genesis.go b/app/genesis.go index ead2fc081..0710a5b9a 100644 --- a/app/genesis.go +++ b/app/genesis.go @@ -78,6 +78,7 @@ func NewDefaultGenesisState(cdc codec.JSONCodec) GenesisState { gen := ModuleBasics.DefaultGenesis(cdc) authGenesis := new(authtypes.GenesisState) + authtypes.DefaultGenesisState() cdc.MustUnmarshalJSON(gen[authtypes.ModuleName], authGenesis) return gen diff --git a/app/ibc_test.go b/app/ibc_test.go index e5b8147d8..9e7d9aee2 100644 --- a/app/ibc_test.go +++ b/app/ibc_test.go @@ -16,6 +16,7 @@ import ( // init changes the value of 'DefaultTestingAppInit' to use custom initialization. func init() { ibctesting.DefaultTestingAppInit = SetupNibiruTestingApp + testapp.EnsureNibiruPrefix() } /* diff --git a/app/keepers.go b/app/keepers.go index 6452aa3b0..a60a8914e 100644 --- a/app/keepers.go +++ b/app/keepers.go @@ -238,13 +238,14 @@ func (app *NibiruApp) InitKeepers( tkeys := app.tkeys memKeys := app.memKeys + govModuleAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String() app.paramsKeeper = initParamsKeeper( appCodec, legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey], ) // set the BaseApp's parameter store - app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[consensusparamtypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String()) + app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[consensusparamtypes.StoreKey], govModuleAddr) bApp.SetParamStore(&app.ConsensusParamsKeeper) /* Add capabilityKeeper and ScopeToModule for the ibc module @@ -274,21 +275,21 @@ func (app *NibiruApp) InitKeepers( authtypes.ProtoBaseAccount, maccPerms, sdk.GetConfig().GetBech32AccountAddrPrefix(), - authtypes.NewModuleAddress(govtypes.ModuleName).String(), + govModuleAddr, ) app.BankKeeper = bankkeeper.NewBaseKeeper( appCodec, keys[banktypes.StoreKey], app.AccountKeeper, BlockedAddresses(), - authtypes.NewModuleAddress(govtypes.ModuleName).String(), + govModuleAddr, ) app.stakingKeeper = stakingkeeper.NewKeeper( appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), + govModuleAddr, ) app.DistrKeeper = distrkeeper.NewKeeper( appCodec, @@ -297,7 +298,7 @@ func (app *NibiruApp) InitKeepers( app.BankKeeper, app.stakingKeeper, authtypes.FeeCollectorName, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), + govModuleAddr, ) invCheckPeriod := cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)) @@ -307,7 +308,7 @@ func (app *NibiruApp) InitKeepers( invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), + govModuleAddr, ) app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper) @@ -326,7 +327,7 @@ func (app *NibiruApp) InitKeepers( appCodec, homePath, app.BaseApp, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), + govModuleAddr, ) // register the staking hooks @@ -336,7 +337,7 @@ func (app *NibiruApp) InitKeepers( legacyAmino, keys[slashingtypes.StoreKey], app.stakingKeeper, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), + govModuleAddr, ) app.stakingKeeper.SetHooks( @@ -442,12 +443,11 @@ func (app *NibiruApp) InitKeepers( wasmDir, wasmConfig, supportedFeatures, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), + govModuleAddr, GetWasmOpts(*app, appOpts)..., ) // DevGas uses WasmKeeper - govModuleAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String() app.DevGasKeeper = devgaskeeper.NewKeeper( keys[devgastypes.StoreKey], appCodec, @@ -553,7 +553,7 @@ func (app *NibiruApp) InitKeepers( app.stakingKeeper, app.MsgServiceRouter(), govConfig, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), + govModuleAddr, ) govKeeper.SetLegacyRouter(govRouter) diff --git a/proto/nibiru/perp/v2/event.proto b/proto/nibiru/perp/v2/event.proto index f8a6b7a04..c3854dd85 100644 --- a/proto/nibiru/perp/v2/event.proto +++ b/proto/nibiru/perp/v2/event.proto @@ -234,3 +234,29 @@ message MarketUpdatedEvent { // the final state of the market nibiru.perp.v2.Market final_market = 1 [ (gogoproto.nullable) = false ]; } + +// EventShiftPegMultiplier: ABCI event emitted from MsgShiftPegMultiplier +message EventShiftPegMultiplier { + string old_peg_multiplier = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string new_peg_multiplier = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + cosmos.base.v1beta1.Coin cost_paid = 3 [ (gogoproto.nullable) = false ]; +} + +// EventShiftSwapInvariant: ABCI event emitted from MsgShiftSwapInvariant +message EventShiftSwapInvariant { + string old_swap_invariant = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + string new_swap_invariant = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + cosmos.base.v1beta1.Coin cost_paid = 3 [ (gogoproto.nullable) = false ]; +} diff --git a/proto/nibiru/perp/v2/tx.proto b/proto/nibiru/perp/v2/tx.proto index 433b78eb5..7dba213c7 100644 --- a/proto/nibiru/perp/v2/tx.proto +++ b/proto/nibiru/perp/v2/tx.proto @@ -29,12 +29,26 @@ service Msg { rpc DonateToEcosystemFund(MsgDonateToEcosystemFund) returns (MsgDonateToEcosystemFundResponse) {} + // ChangeCollateralDenom: Updates the collateral denom. A denom is valid if it + // is possible to make an sdk.Coin using it. [Admin] Only callable by sudoers. rpc ChangeCollateralDenom(MsgChangeCollateralDenom) returns (MsgChangeCollateralDenomResponse) {} - rpc AllocateEpochRebates(MsgAllocateEpochRebates) returns (MsgAllocateEpochRebatesResponse) {} + rpc AllocateEpochRebates(MsgAllocateEpochRebates) + returns (MsgAllocateEpochRebatesResponse) {} - rpc WithdrawEpochRebates(MsgWithdrawEpochRebates) returns (MsgWithdrawEpochRebatesResponse) {} + rpc WithdrawEpochRebates(MsgWithdrawEpochRebates) + returns (MsgWithdrawEpochRebatesResponse) {} + + // ShiftPegMultiplier: gRPC tx msg for changing a market's peg multiplier. + // [Admin] Only callable by sudoers. + rpc ShiftPegMultiplier(MsgShiftPegMultiplier) + returns (MsgShiftPegMultiplierResponse) {} + + // ShiftSwapInvariant: gRPC tx msg for changing a market's swap invariant. + // [Admin] Only callable by sudoers. + rpc ShiftSwapInvariant(MsgShiftSwapInvariant) + returns (MsgShiftSwapInvariantResponse) {} } // -------------------------- Settle Position -------------------------- @@ -376,4 +390,42 @@ message MsgWithdrawEpochRebatesResponse { (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; -} \ No newline at end of file +} + +// -------------------------- ShiftPegMultiplier -------------------------- + +// ShiftPegMultiplier: gRPC tx msg for changing the peg multiplier. +// Admin-only. +message MsgShiftPegMultiplier { + string sender = 1; + string pair = 2 [ + (gogoproto.customtype) = + "github.com/NibiruChain/nibiru/x/common/asset.Pair", + (gogoproto.nullable) = false + ]; + string new_peg_mult = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +message MsgShiftPegMultiplierResponse {} + +// -------------------------- ShiftSwapInvariant -------------------------- + +// ShiftSwapInvariant: gRPC tx msg for changing the swap invariant. +// Admin-only. +message MsgShiftSwapInvariant { + string sender = 1; + string pair = 2 [ + (gogoproto.customtype) = + "github.com/NibiruChain/nibiru/x/common/asset.Pair", + (gogoproto.nullable) = false + ]; + string new_swap_invariant = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} + +message MsgShiftSwapInvariantResponse {} diff --git a/wasmbinding/bindings/msg.go b/wasmbinding/bindings/msg.go index 8085a6be0..bce9b362e 100644 --- a/wasmbinding/bindings/msg.go +++ b/wasmbinding/bindings/msg.go @@ -20,8 +20,6 @@ type NibiruMsg struct { RemoveMargin *RemoveMargin `json:"remove_margin,omitempty"` DonateToInsuranceFund *DonateToInsuranceFund `json:"donate_to_insurance_fund,omitempty"` // TODO InsuranceFundWithdraw *InsuranceFundWithdraw `json:"insurance_fund_withdraw,omitempty"` - PegShift *PegShift `json:"peg_shift,omitempty"` - DepthShift *DepthShift `json:"depth_shift,omitempty"` SetMarketEnabled *SetMarketEnabled `json:"set_market_enabled,omitempty"` CreateMarket *CreateMarket `json:"create_market,omitempty"` @@ -62,16 +60,6 @@ type RemoveMargin struct { Margin sdk.Coin `json:"margin"` } -type PegShift struct { - Pair string `json:"pair"` - PegMult sdk.Dec `json:"peg_mult"` -} - -type DepthShift struct { - Pair string `json:"pair"` - DepthMult sdk.Dec `json:"depth_mult"` -} - type DonateToInsuranceFund struct { Sender string `json:"sender"` Donation sdk.Coin `json:"donation"` diff --git a/wasmbinding/exec_perp.go b/wasmbinding/exec_perp.go index e3abaf869..992718e9e 100644 --- a/wasmbinding/exec_perp.go +++ b/wasmbinding/exec_perp.go @@ -137,39 +137,6 @@ func (exec *ExecutorPerp) RemoveMargin( return exec.MsgServer().RemoveMargin(goCtx, sdkMsg) } -func (exec *ExecutorPerp) PegShift( - cwMsg *bindings.PegShift, contractAddr sdk.AccAddress, ctx sdk.Context, -) (err error) { - if cwMsg == nil { - return wasmvmtypes.InvalidRequest{Err: "null msg"} - } - - pair, err := asset.TryNewPair(cwMsg.Pair) - if err != nil { - return err - } - - return exec.PerpV2.EditPriceMultiplier( - ctx, - // contractAddr, - pair, - cwMsg.PegMult, - ) -} - -func (exec *ExecutorPerp) DepthShift(cwMsg *bindings.DepthShift, ctx sdk.Context) (err error) { - if cwMsg == nil { - return wasmvmtypes.InvalidRequest{Err: "null msg"} - } - - pair, err := asset.TryNewPair(cwMsg.Pair) - if err != nil { - return err - } - - return exec.PerpV2.EditSwapInvariant(ctx, pair, cwMsg.DepthMult) -} - func (exec *ExecutorPerp) InsuranceFundWithdraw( cwMsg *bindings.InsuranceFundWithdraw, ctx sdk.Context, ) (err error) { diff --git a/wasmbinding/exec_perp_test.go b/wasmbinding/exec_perp_test.go index 20a2159ad..b5db53479 100644 --- a/wasmbinding/exec_perp_test.go +++ b/wasmbinding/exec_perp_test.go @@ -91,7 +91,6 @@ func (s *TestSuitePerpExecutor) TestOpenAddRemoveClose() { s.DoRemoveIncorrectMarginTest(pair, incorrectMargin), s.DoRemoveMarginTest(pair, margin), s.DoClosePositionTest(pair), - s.DoPegShiftTest(pair), s.DoInsuranceFundWithdrawTest(sdk.NewInt(69), s.contractDeployer), s.DoCreateMarketTest(asset.MustNewPair("ufoo:ubar")), s.DoCreateMarketTestWithParams(asset.MustNewPair("ufoo2:ubar")), @@ -212,27 +211,6 @@ func (s *TestSuitePerpExecutor) DoClosePositionTest(pair asset.Pair) error { return err } -func (s *TestSuitePerpExecutor) DoPegShiftTest(pair asset.Pair) error { - contractAddr := s.contractPerp - cwMsg := &bindings.PegShift{ - Pair: pair.String(), - PegMult: sdk.NewDec(420), - } - - err := s.exec.PegShift(cwMsg, contractAddr, s.ctx) - return err -} - -func (s *TestSuitePerpExecutor) DoDepthShiftTest(pair asset.Pair) error { - cwMsg := &bindings.DepthShift{ - Pair: pair.String(), - DepthMult: sdk.NewDec(420), - } - - err := s.exec.DepthShift(cwMsg, s.ctx) - return err -} - func (s *TestSuitePerpExecutor) DoInsuranceFundWithdrawTest( amt sdkmath.Int, to sdk.AccAddress, ) error { @@ -302,13 +280,6 @@ func (s *TestSuitePerpExecutor) TestSadPaths_Nil() { _, err = s.exec.ClosePosition(nil, nil, s.ctx) s.Error(err) - err = s.exec.PegShift( - nil, sdk.AccAddress([]byte("contract")), s.ctx) - s.Error(err) - - err = s.exec.DepthShift(nil, s.ctx) - s.Error(err) - err = s.exec.InsuranceFundWithdraw(nil, s.ctx) s.Error(err) } @@ -348,8 +319,6 @@ func (s *TestSuitePerpExecutor) TestSadPaths_InvalidPair() { s.DoAddMarginTest(pair, margin), s.DoRemoveMarginTest(pair, margin), s.DoClosePositionTest(pair), - s.DoPegShiftTest(pair), - s.DoDepthShiftTest(pair), s.DoSetMarketEnabledTest(pair, true), s.DoSetMarketEnabledTest(pair, false), s.DoCreateMarketTest(pair), diff --git a/wasmbinding/exec_test.go b/wasmbinding/exec_test.go index a02fd36a9..d5b5fd9a5 100644 --- a/wasmbinding/exec_test.go +++ b/wasmbinding/exec_test.go @@ -362,40 +362,6 @@ func (s *TestSuiteExecutor) TestOracleParams() { s.Require().Equal(theValidatorFeeRatio, params.ValidatorFeeRatio) } -func (s *TestSuiteExecutor) TestPegShift() { - pair := asset.MustNewPair(s.happyFields.Pair) - execMsg := bindings.NibiruMsg{ - PegShift: &bindings.PegShift{ - Pair: pair.String(), - PegMult: sdk.NewDec(420), - }, - } - - s.T().Log("Executing with permission should succeed") - contract := s.contractShifter - s.keeper.SetSudoContracts( - []string{contract.String()}, s.ctx, - ) - contractRespBz, err := s.ExecuteAgainstContract(contract, execMsg) - s.NoErrorf(err, "contractRespBz: %s", contractRespBz) - - s.T().Log("Executing without permission should fail") - s.keeper.SetSudoContracts( - []string{}, s.ctx, - ) - contractRespBz, err = s.ExecuteAgainstContract(contract, execMsg) - s.Errorf(err, "contractRespBz: %s", contractRespBz) - - s.T().Log("Executing the wrong contract should fail") - contract = s.contractPerp - s.keeper.SetSudoContracts( - []string{contract.String()}, s.ctx, - ) - contractRespBz, err = s.ExecuteAgainstContract(contract, execMsg) - s.Errorf(err, "contractRespBz: %s", contractRespBz) - s.Contains(err.Error(), "Error parsing into type") -} - func (s *TestSuiteExecutor) TestNoOp() { contract := s.contractShifter execMsg := bindings.NibiruMsg{ @@ -405,40 +371,6 @@ func (s *TestSuiteExecutor) TestNoOp() { s.NoErrorf(err, "contractRespBz: %s", contractRespBz) } -func (s *TestSuiteExecutor) TestDepthShift() { - pair := asset.MustNewPair(s.happyFields.Pair) - execMsg := bindings.NibiruMsg{ - DepthShift: &bindings.DepthShift{ - Pair: pair.String(), - DepthMult: sdk.NewDec(2), - }, - } - - s.T().Log("Executing with permission should succeed") - contract := s.contractShifter - s.keeper.SetSudoContracts( - []string{contract.String()}, s.ctx, - ) - contractRespBz, err := s.ExecuteAgainstContract(contract, execMsg) - s.NoErrorf(err, "contractRespBz: %s", contractRespBz) - - s.T().Log("Executing without permission should fail") - s.keeper.SetSudoContracts( - []string{}, s.ctx, - ) - contractRespBz, err = s.ExecuteAgainstContract(contract, execMsg) - s.Errorf(err, "contractRespBz: %s", contractRespBz) - - s.T().Log("Executing the wrong contract should fail") - contract = s.contractPerp - s.keeper.SetSudoContracts( - []string{contract.String()}, s.ctx, - ) - contractRespBz, err = s.ExecuteAgainstContract(contract, execMsg) - s.Errorf(err, "contractRespBz: %s", contractRespBz) - s.Contains(err.Error(), "Error parsing into type") -} - func (s *TestSuiteExecutor) TestInsuranceFundWithdraw() { admin := s.contractDeployer.String() amtToWithdraw := sdk.NewInt(69) diff --git a/wasmbinding/message_plugin.go b/wasmbinding/message_plugin.go index 2b2c726bf..a05b249c7 100644 --- a/wasmbinding/message_plugin.go +++ b/wasmbinding/message_plugin.go @@ -80,22 +80,6 @@ func (messenger *CustomMessenger) DispatchMsg( _, err = messenger.Perp.RemoveMargin(cwMsg, contractAddr, ctx) return events, data, err - // Perp module | shifter - case contractExecuteMsg.ExecuteMsg.PegShift != nil: - if err := messenger.Sudo.CheckPermissions(contractAddr, ctx); err != nil { - return events, data, err - } - cwMsg := contractExecuteMsg.ExecuteMsg.PegShift - err = messenger.Perp.PegShift(cwMsg, contractAddr, ctx) - return events, data, err - case contractExecuteMsg.ExecuteMsg.DepthShift != nil: - if err := messenger.Sudo.CheckPermissions(contractAddr, ctx); err != nil { - return events, data, err - } - cwMsg := contractExecuteMsg.ExecuteMsg.DepthShift - err = messenger.Perp.DepthShift(cwMsg, ctx) - return events, data, err - // Perp module | controller case contractExecuteMsg.ExecuteMsg.CreateMarket != nil: if err := messenger.Sudo.CheckPermissions(contractAddr, ctx); err != nil { diff --git a/wasmbinding/wasmbin_test.go b/wasmbinding/wasmbin_test.go index 76729ede7..3b4c50532 100644 --- a/wasmbinding/wasmbin_test.go +++ b/wasmbinding/wasmbin_test.go @@ -18,6 +18,10 @@ import ( "github.com/NibiruChain/nibiru/x/common/testutil/testapp" ) +func init() { + testapp.EnsureNibiruPrefix() +} + // TestSetupContracts acts as an integration test by storing and instantiating // each production smart contract is expected to interact with x/wasm/binding. func TestSetupContracts(t *testing.T) { diff --git a/x/common/constants.go b/x/common/constants.go index ae5fe5522..031803825 100644 --- a/x/common/constants.go +++ b/x/common/constants.go @@ -7,9 +7,9 @@ const ( // TO_MICRO: multiplier for converting between units and micro-units. TO_MICRO = int64(1_000_000) - NibiruTeam = "nibi1l8dxzwz9d4peazcqjclnkj2mhvtj7mpnkqx85mg0ndrlhwrnh7gskkzg0v" + NIBIRU_TEAM = "nibi1l8dxzwz9d4peazcqjclnkj2mhvtj7mpnkqx85mg0ndrlhwrnh7gskkzg0v" ) func NibiruTeamAddr() sdk.AccAddress { - return sdk.MustAccAddressFromBech32(NibiruTeam) + return sdk.MustAccAddressFromBech32(NIBIRU_TEAM) } diff --git a/x/common/testutil/const.go b/x/common/testutil/const.go new file mode 100644 index 000000000..7366624ce --- /dev/null +++ b/x/common/testutil/const.go @@ -0,0 +1,6 @@ +package testutil + +const ( + ADDR_GUARD_CREAM = "nibi1zaavvzxez0elundtn32qnk9lkm8kmcsz44g7xl" + ADDR_SUDO_ROOT = "nibi1qqx5reauy4glpskmppy88pz25qp2py5yxvpxdt" +) diff --git a/x/common/testutil/testapp/testapp.go b/x/common/testutil/testapp/testapp.go index 4682a29a6..6826da359 100644 --- a/x/common/testutil/testapp/testapp.go +++ b/x/common/testutil/testapp/testapp.go @@ -15,14 +15,20 @@ import ( "github.com/NibiruChain/nibiru/app" "github.com/NibiruChain/nibiru/x/common/asset" "github.com/NibiruChain/nibiru/x/common/denoms" + "github.com/NibiruChain/nibiru/x/common/testutil" epochstypes "github.com/NibiruChain/nibiru/x/epochs/types" inflationtypes "github.com/NibiruChain/nibiru/x/inflation/types" "github.com/NibiruChain/nibiru/x/perp/v2/types" + sudotypes "github.com/NibiruChain/nibiru/x/sudo/types" ) // NewNibiruTestAppAndContext creates an 'app.NibiruApp' instance with an // in-memory 'tmdb.MemDB' and fresh 'sdk.Context'. func NewNibiruTestAppAndContext() (*app.NibiruApp, sdk.Context) { + // Prevent "invalid Bech32 prefix; expected nibi, got ...." error + EnsureNibiruPrefix() + + // Set up base app encoding := app.MakeEncodingConfig() var appGenesis app.GenesisState = app.NewDefaultGenesisState(encoding.Marshaler) genModEpochs := epochstypes.DefaultGenesisFromTime(time.Now().UTC()) @@ -32,14 +38,16 @@ func NewNibiruTestAppAndContext() (*app.NibiruApp, sdk.Context) { app := NewNibiruTestApp(appGenesis) ctx := NewContext(app) + // Set defaults for certain modules. app.OracleKeeper.SetPrice(ctx, asset.Registry.Pair(denoms.BTC, denoms.NUSD), sdk.NewDec(20000)) app.OracleKeeper.SetPrice(ctx, "xxx:yyy", sdk.NewDec(20000)) - app.PerpKeeperV2.Collateral.Set(ctx, types.TestingCollateralDenomNUSD) + app.SudoKeeper.Sudoers.Set(ctx, DefaultSudoers()) return app, ctx } +// NewContext: Returns a fresh sdk.Context corresponding to the given NibiruApp. func NewContext(nibiru *app.NibiruApp) sdk.Context { return nibiru.NewContext(false, tmproto.Header{ Height: 1, @@ -47,6 +55,19 @@ func NewContext(nibiru *app.NibiruApp) sdk.Context { }) } +// DefaultSudoers: State for the x/sudo module for the default test app. +func DefaultSudoers() sudotypes.Sudoers { + addr := DefaultSudoRoot().String() + return sudotypes.Sudoers{ + Root: addr, + Contracts: []string{addr}, + } +} + +func DefaultSudoRoot() sdk.AccAddress { + return sdk.MustAccAddressFromBech32(testutil.ADDR_SUDO_ROOT) +} + // NewNibiruTestAppAndZeroTimeCtx: Runs NewNibiruTestAppAndZeroTimeCtx with the // block time set to time zero. func NewNibiruTestAppAndContextAtTime(startTime time.Time) (*app.NibiruApp, sdk.Context) { diff --git a/x/devgas/v1/ante/ante_test.go b/x/devgas/v1/ante/ante_test.go index 9b9b00d43..6e4a0d332 100644 --- a/x/devgas/v1/ante/ante_test.go +++ b/x/devgas/v1/ante/ante_test.go @@ -25,6 +25,7 @@ type AnteTestSuite struct { } func TestAnteSuite(t *testing.T) { + testapp.EnsureNibiruPrefix() suite.Run(t, new(AnteTestSuite)) } diff --git a/x/inflation/keeper/inflation_test.go b/x/inflation/keeper/inflation_test.go index 0394dfc5e..4012fa74d 100644 --- a/x/inflation/keeper/inflation_test.go +++ b/x/inflation/keeper/inflation_test.go @@ -72,13 +72,11 @@ func TestMintAndAllocateInflation(t *testing.T) { t.Run(fmt.Sprintf("Case %s", tc.name), func(t *testing.T) { nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - if tc.rootAccount != "" { - t.Logf("setting root account to %s", tc.rootAccount) - nibiruApp.SudoKeeper.Sudoers.Set(ctx, sudotypes.Sudoers{ - Root: sdk.MustAccAddressFromBech32(tc.rootAccount).String(), - Contracts: []string{}, - }) - } + t.Logf("setting root account to %s", tc.rootAccount) + nibiruApp.SudoKeeper.Sudoers.Set(ctx, sudotypes.Sudoers{ + Root: tc.rootAccount, + Contracts: []string{}, + }) staking, strategic, community, err := nibiruApp.InflationKeeper.MintAndAllocateInflation(ctx, tc.coinsToMint, types.DefaultParams()) require.NoError(t, err) diff --git a/x/oracle/keeper/hooks_test.go b/x/oracle/keeper/hooks_test.go index 61cc84fd4..516c0dc38 100644 --- a/x/oracle/keeper/hooks_test.go +++ b/x/oracle/keeper/hooks_test.go @@ -14,6 +14,10 @@ import ( perptypes "github.com/NibiruChain/nibiru/x/perp/v2/types" ) +func init() { + testapp.EnsureNibiruPrefix() +} + func TestHooks_AfterEpochEnd(t *testing.T) { tests := []struct { name string diff --git a/x/perp/v2/integration/action/dnr.go b/x/perp/v2/integration/action/dnr.go index 9c5b69a54..96f17b929 100644 --- a/x/perp/v2/integration/action/dnr.go +++ b/x/perp/v2/integration/action/dnr.go @@ -12,6 +12,7 @@ import ( "github.com/NibiruChain/nibiru/app" "github.com/NibiruChain/nibiru/x/common/asset" "github.com/NibiruChain/nibiru/x/common/testutil/action" + perpkeeper "github.com/NibiruChain/nibiru/x/perp/v2/keeper" "github.com/NibiruChain/nibiru/x/perp/v2/types" ) @@ -216,16 +217,20 @@ func (s *setCustomDiscountAction) Do(app *app.NibiruApp, ctx sdk.Context) (outCt } type fundDnREpoch struct { - amt sdk.Coins + funds sdk.Coins } func (f fundDnREpoch) Do(app *app.NibiruApp, ctx sdk.Context) (outCtx sdk.Context, err error, isMandatory bool) { tmpAcc := testutil.AccAddress() - ctx, err, _ = action.FundAccount(tmpAcc, f.amt).Do(app, ctx) + ctx, err, _ = action.FundAccount(tmpAcc, f.funds).Do(app, ctx) if err != nil { return ctx, err, true } - _, err = app.PerpKeeperV2.AllocateEpochRebates(ctx, tmpAcc, f.amt) + _, err = perpkeeper.NewMsgServerImpl(app.PerpKeeperV2).AllocateEpochRebates( + ctx, &types.MsgAllocateEpochRebates{ + Sender: tmpAcc.String(), + Rebates: f.funds, + }) if err != nil { return ctx, err, true } @@ -261,10 +266,15 @@ type dnrRebateIsAction struct { } func (d dnrRebateIsAction) Do(app *app.NibiruApp, ctx sdk.Context) (outCtx sdk.Context, err error, isMandatory bool) { - withdrawn, err := app.PerpKeeperV2.WithdrawEpochRebates(ctx, d.epoch, d.user) + resp, err := perpkeeper.NewMsgServerImpl(app.PerpKeeperV2).WithdrawEpochRebates( + ctx, &types.MsgWithdrawEpochRebates{ + Sender: d.user.String(), + Epochs: []uint64{d.epoch}, + }) if err != nil { return ctx, err, true } + withdrawn := resp.WithdrawnRebates if !withdrawn.IsEqual(d.expectedRewards) { return ctx, fmt.Errorf("expected %s, got %s", d.expectedRewards, withdrawn), true } @@ -291,9 +301,16 @@ type dnrRebateFailsAction struct { epoch uint64 } -func (d dnrRebateFailsAction) Do(app *app.NibiruApp, ctx sdk.Context) (outCtx sdk.Context, err error, isMandatory bool) { - withdrawn, err := app.PerpKeeperV2.WithdrawEpochRebates(ctx, d.epoch, d.user) +func (d dnrRebateFailsAction) Do( + app *app.NibiruApp, ctx sdk.Context, +) (outCtx sdk.Context, err error, isMandatory bool) { + resp, err := perpkeeper.NewMsgServerImpl(app.PerpKeeperV2).WithdrawEpochRebates( + ctx, &types.MsgWithdrawEpochRebates{ + Sender: d.user.String(), + Epochs: []uint64{d.epoch}, + }) if err == nil { + withdrawn := resp.WithdrawnRebates return ctx, fmt.Errorf("expected withdrawal error but got instead: %s rewards", withdrawn.String()), true } return ctx, nil, true diff --git a/x/perp/v2/integration/action/market.go b/x/perp/v2/integration/action/market.go index 805252b07..150286f74 100644 --- a/x/perp/v2/integration/action/market.go +++ b/x/perp/v2/integration/action/market.go @@ -9,6 +9,7 @@ import ( "github.com/NibiruChain/nibiru/x/common" "github.com/NibiruChain/nibiru/x/common/asset" "github.com/NibiruChain/nibiru/x/common/testutil/action" + "github.com/NibiruChain/nibiru/x/common/testutil/testapp" "github.com/NibiruChain/nibiru/app" "github.com/NibiruChain/nibiru/x/perp/v2/keeper" @@ -134,35 +135,39 @@ func WithEnabled(enabled bool) MarketModifier { } } -type editPriceMultiplier struct { +type shiftPegMultiplier struct { pair asset.Pair newValue sdk.Dec } -func (e editPriceMultiplier) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error, bool) { - err := app.PerpKeeperV2.EditPriceMultiplier(ctx, e.pair, e.newValue) +func (e shiftPegMultiplier) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error, bool) { + err := app.PerpKeeperV2.Admin.ShiftPegMultiplier( + ctx, e.pair, e.newValue, testapp.DefaultSudoRoot(), + ) return ctx, err, true } -func EditPriceMultiplier(pair asset.Pair, newValue sdk.Dec) action.Action { - return editPriceMultiplier{ +func ShiftPegMultiplier(pair asset.Pair, newValue sdk.Dec) action.Action { + return shiftPegMultiplier{ pair: pair, newValue: newValue, } } -type editSwapInvariant struct { +type shiftSwapInvariant struct { pair asset.Pair - newValue sdk.Dec + newValue sdkmath.Int } -func (e editSwapInvariant) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error, bool) { - err := app.PerpKeeperV2.EditSwapInvariant(ctx, e.pair, e.newValue) +func (e shiftSwapInvariant) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error, bool) { + err := app.PerpKeeperV2.Admin.ShiftSwapInvariant( + ctx, e.pair, e.newValue, testapp.DefaultSudoRoot(), + ) return ctx, err, true } -func EditSwapInvariant(pair asset.Pair, newValue sdk.Dec) action.Action { - return editSwapInvariant{ +func ShiftSwapInvariant(pair asset.Pair, newValue sdkmath.Int) action.Action { + return shiftSwapInvariant{ pair: pair, newValue: newValue, } @@ -202,7 +207,7 @@ func (c setCollateral) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, err if err != nil { return ctx, err, true } - sudoers.Root = common.NibiruTeam + sudoers.Root = common.NIBIRU_TEAM app.SudoKeeper.Sudoers.Set(ctx, sudoers) senderAddr, err := sdk.AccAddressFromBech32(c.Sender) @@ -216,6 +221,6 @@ func (c setCollateral) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, err func SetCollateral(denom string) action.Action { return setCollateral{ Denom: denom, - Sender: common.NibiruTeam, + Sender: common.NIBIRU_TEAM, } } diff --git a/x/perp/v2/integration/action/position.go b/x/perp/v2/integration/action/position.go index a50405404..f73c6ad60 100644 --- a/x/perp/v2/integration/action/position.go +++ b/x/perp/v2/integration/action/position.go @@ -13,6 +13,7 @@ import ( "github.com/NibiruChain/nibiru/x/common/denoms" "github.com/NibiruChain/nibiru/x/common/testutil" "github.com/NibiruChain/nibiru/x/common/testutil/action" + perpkeeper "github.com/NibiruChain/nibiru/x/perp/v2/keeper" "github.com/NibiruChain/nibiru/x/perp/v2/types" ) @@ -343,7 +344,14 @@ type partialClose struct { } func (p partialClose) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error, bool) { - _, err := app.PerpKeeperV2.PartialClose(ctx, p.pair, p.trader, p.amount) + txMsg := &types.MsgPartialClose{ + Sender: p.trader.String(), + Pair: p.pair, + Size_: p.amount, + } + goCtx := sdk.WrapSDKContext(ctx) + _, err := perpkeeper.NewMsgServerImpl(app.PerpKeeperV2).PartialClose( + goCtx, txMsg) if err != nil { return ctx, err, true } @@ -368,7 +376,15 @@ type partialCloseFails struct { } func (p partialCloseFails) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error, bool) { - _, err := app.PerpKeeperV2.PartialClose(ctx, p.pair, p.trader, p.amount) + txMsg := &types.MsgPartialClose{ + Sender: p.trader.String(), + Pair: p.pair, + Size_: p.amount, + } + goCtx := sdk.WrapSDKContext(ctx) + _, err := perpkeeper.NewMsgServerImpl(app.PerpKeeperV2).PartialClose( + goCtx, txMsg, + ) if !errors.Is(err, p.expectedErr) { return ctx, fmt.Errorf("expected error %s, got %s", p.expectedErr, err), false @@ -377,11 +393,11 @@ func (p partialCloseFails) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, return ctx, nil, false } -func PartialCloseFails(trader sdk.AccAddress, pair asset.Pair, amount sdk.Dec, expecedErr error) action.Action { +func PartialCloseFails(trader sdk.AccAddress, pair asset.Pair, amount sdk.Dec, expectedErr error) action.Action { return partialCloseFails{ trader: trader, pair: pair, amount: amount, - expectedErr: expecedErr, + expectedErr: expectedErr, } } diff --git a/x/perp/v2/keeper/admin.go b/x/perp/v2/keeper/admin.go index 34ec601f3..78270101a 100644 --- a/x/perp/v2/keeper/admin.go +++ b/x/perp/v2/keeper/admin.go @@ -174,3 +174,90 @@ func (k admin) UnsafeChangeCollateralDenom( k.Collateral.Set(ctx, denom) return nil } + +// ShiftPegMultiplier: Edit the peg multiplier of an amm pool after making sure +// there's enough money in the perp fund to pay for the repeg. These funds get +// send to the vault to pay for trader's new net margin. +func (k admin) ShiftPegMultiplier( + ctx sdk.Context, + pair asset.Pair, + newPriceMultiplier sdk.Dec, + sender sdk.AccAddress, +) error { + if err := k.SudoKeeper.CheckPermissions(sender, ctx); err != nil { + return err + } + + amm, err := k.GetAMM(ctx, pair) + if err != nil { + return err + } + oldPriceMult := amm.PriceMultiplier + + if newPriceMultiplier.Equal(oldPriceMult) { + // same price multiplier, no-op + return nil + } + + // Compute cost of re-pegging the pool + cost, err := amm.CalcRepegCost(newPriceMultiplier) + if err != nil { + return err + } + + costPaid, err := k.handleMarketUpdateCost(ctx, pair, cost) + if err != nil { + return err + } + + // Do the re-peg + amm.PriceMultiplier = newPriceMultiplier + k.SaveAMM(ctx, amm) + + return ctx.EventManager().EmitTypedEvent(&types.EventShiftPegMultiplier{ + OldPegMultiplier: oldPriceMult, + NewPegMultiplier: newPriceMultiplier, + CostPaid: costPaid, + }) +} + +// ShiftSwapInvariant: Edit the swap invariant (liquidity depth) of an amm pool, +// ensuring that there's enough money in the perp fund to pay for the operation. +// These funds get send to the vault to pay for trader's new net margin. +func (k admin) ShiftSwapInvariant( + ctx sdk.Context, + pair asset.Pair, + newSwapInvariant sdkmath.Int, + sender sdk.AccAddress, +) error { + if err := k.SudoKeeper.CheckPermissions(sender, ctx); err != nil { + return err + } + amm, err := k.GetAMM(ctx, pair) + if err != nil { + return err + } + + cost, err := amm.CalcUpdateSwapInvariantCost(newSwapInvariant.ToLegacyDec()) + if err != nil { + return err + } + + costPaid, err := k.handleMarketUpdateCost(ctx, pair, cost) + if err != nil { + return err + } + + err = amm.UpdateSwapInvariant(newSwapInvariant.ToLegacyDec()) + if err != nil { + return err + } + + k.SaveAMM(ctx, amm) + + return ctx.EventManager().EmitTypedEvent(&types.EventShiftSwapInvariant{ + OldSwapInvariant: amm.BaseReserve.Mul(amm.QuoteReserve).RoundInt(), + NewSwapInvariant: newSwapInvariant, + CostPaid: costPaid, + }) +} diff --git a/x/perp/v2/keeper/admin_test.go b/x/perp/v2/keeper/admin_test.go index 8b08ced29..6bcf3eaf8 100644 --- a/x/perp/v2/keeper/admin_test.go +++ b/x/perp/v2/keeper/admin_test.go @@ -1,21 +1,24 @@ package keeper_test import ( + "fmt" "testing" "time" sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" "github.com/NibiruChain/nibiru/app" "github.com/NibiruChain/nibiru/x/common/asset" "github.com/NibiruChain/nibiru/x/common/denoms" "github.com/NibiruChain/nibiru/x/common/testutil" + "github.com/NibiruChain/nibiru/x/common/testutil/genesis" "github.com/NibiruChain/nibiru/x/common/testutil/mock" "github.com/NibiruChain/nibiru/x/common/testutil/testapp" "github.com/NibiruChain/nibiru/x/perp/v2/keeper" - "github.com/NibiruChain/nibiru/x/perp/v2/types" + perptypes "github.com/NibiruChain/nibiru/x/perp/v2/types" sudotypes "github.com/NibiruChain/nibiru/x/sudo/types" tftypes "github.com/NibiruChain/nibiru/x/tokenfactory/types" @@ -28,9 +31,9 @@ func TestAdmin_WithdrawFromInsuranceFund(t *testing.T) { expectBalance := func( want sdkmath.Int, t *testing.T, nibiru *app.NibiruApp, ctx sdk.Context, ) { - insuranceFund := nibiru.AccountKeeper.GetModuleAddress(types.PerpEFModuleAccount) + insuranceFund := nibiru.AccountKeeper.GetModuleAddress(perptypes.PerpEFModuleAccount) balances := nibiru.BankKeeper.GetAllBalances(ctx, insuranceFund) - got := balances.AmountOf(types.TestingCollateralDenomNUSD) + got := balances.AmountOf(perptypes.TestingCollateralDenomNUSD) require.EqualValues(t, want.String(), got.String()) } @@ -38,14 +41,14 @@ func TestAdmin_WithdrawFromInsuranceFund(t *testing.T) { testapp.EnsureNibiruPrefix() nibiru, ctx = testapp.NewNibiruTestAppAndContext() expectBalance(sdk.ZeroInt(), t, nibiru, ctx) - nibiru.PerpKeeperV2.Collateral.Set(ctx, types.TestingCollateralDenomNUSD) + nibiru.PerpKeeperV2.Collateral.Set(ctx, perptypes.TestingCollateralDenomNUSD) return nibiru, ctx } fundModule := func(t *testing.T, amount sdkmath.Int, ctx sdk.Context, nibiru *app.NibiruApp) { - coins := sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, amount)) + coins := sdk.NewCoins(sdk.NewCoin(perptypes.TestingCollateralDenomNUSD, amount)) err := testapp.FundModuleAccount( - nibiru.BankKeeper, ctx, types.PerpEFModuleAccount, + nibiru.BankKeeper, ctx, perptypes.PerpEFModuleAccount, coins, ) require.NoError(t, err) @@ -67,7 +70,7 @@ func TestAdmin_WithdrawFromInsuranceFund(t *testing.T) { require.EqualValues(t, amountToFund.String(), - nibiru.BankKeeper.GetBalance(ctx, admin, types.TestingCollateralDenomNUSD).Amount.String(), + nibiru.BankKeeper.GetBalance(ctx, admin, perptypes.TestingCollateralDenomNUSD).Amount.String(), ) expectBalance(sdk.ZeroInt(), t, nibiru, ctx) }, @@ -98,7 +101,7 @@ func TestCreateMarket(t *testing.T) { admin := app.PerpKeeperV2.Admin // Error because of invalid market - market := types.DefaultMarket(pair).WithMaintenanceMarginRatio(sdk.NewDec(2)) + market := perptypes.DefaultMarket(pair).WithMaintenanceMarginRatio(sdk.NewDec(2)) err := admin.CreateMarket(ctx, keeper.ArgsCreateMarket{ Pair: pair, PriceMultiplier: amm.PriceMultiplier, @@ -205,7 +208,7 @@ func TestCloseMarket(t *testing.T) { SetBlockNumber(1), SetBlockTime(startTime), - FundAccount(alice, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), + FundAccount(alice, sdk.NewCoins(sdk.NewCoin(perptypes.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( CloseMarket(pairBtcUsdc), @@ -214,11 +217,11 @@ func TestCloseMarket(t *testing.T) { MarketOrderFails( alice, pairBtcUsdc, - types.Direction_LONG, + perptypes.Direction_LONG, sdk.NewInt(10_000), sdk.OneDec(), sdk.ZeroDec(), - types.ErrMarketNotEnabled, + perptypes.ErrMarketNotEnabled, ), ), TC("cannot close position on disabled market").When( @@ -230,11 +233,11 @@ func TestCloseMarket(t *testing.T) { ), SetBlockNumber(1), SetBlockTime(startTime), - FundAccount(alice, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(10_200)))), + FundAccount(alice, sdk.NewCoins(sdk.NewCoin(perptypes.TestingCollateralDenomNUSD, sdk.NewInt(10_200)))), MarketOrder( alice, pairBtcUsdc, - types.Direction_LONG, + perptypes.Direction_LONG, sdk.NewInt(10_000), sdk.OneDec(), sdk.ZeroDec(), @@ -244,7 +247,7 @@ func TestCloseMarket(t *testing.T) { CloseMarketShouldFail(pairBtcUsdc), CloseMarketShouldFail("random:pair"), ).Then( - ClosePositionFails(alice, pairBtcUsdc, types.ErrMarketNotEnabled), + ClosePositionFails(alice, pairBtcUsdc, perptypes.ErrMarketNotEnabled), ), TC("cannot partial close position on disabled market").When( CreateCustomMarket( @@ -255,11 +258,11 @@ func TestCloseMarket(t *testing.T) { ), SetBlockNumber(1), SetBlockTime(startTime), - FundAccount(alice, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(10_200)))), + FundAccount(alice, sdk.NewCoins(sdk.NewCoin(perptypes.TestingCollateralDenomNUSD, sdk.NewInt(10_200)))), MarketOrder( alice, pairBtcUsdc, - types.Direction_LONG, + perptypes.Direction_LONG, sdk.NewInt(10_000), sdk.OneDec(), sdk.ZeroDec(), @@ -268,7 +271,7 @@ func TestCloseMarket(t *testing.T) { CloseMarket(pairBtcUsdc), AMMShouldBeEqual(pairBtcUsdc, AMM_SettlementPriceShoulBeEqual(sdk.MustNewDecFromStr("1.1"))), ).Then( - PartialCloseFails(alice, pairBtcUsdc, sdk.NewDec(5_000), types.ErrMarketNotEnabled), + PartialCloseFails(alice, pairBtcUsdc, sdk.NewDec(5_000), perptypes.ErrMarketNotEnabled), ), } @@ -320,7 +323,7 @@ func TestAdmin_ChangeCollateralDenom(t *testing.T) { { name: "sad: invalid denom", - newDenom: "", sender: adminSender, wantErr: types.ErrInvalidCollateral.Error(), + newDenom: "", sender: adminSender, wantErr: perptypes.ErrInvalidCollateral.Error(), }, { name: "sad: sender not in sudoers", @@ -345,3 +348,135 @@ func TestAdmin_ChangeCollateralDenom(t *testing.T) { }) } } + +type TestSuiteAdmin struct { + suite.Suite + + nibiru *app.NibiruApp + ctx sdk.Context + addrAdmin sdk.AccAddress + perpKeeper keeper.Keeper + perpMsgServer perptypes.MsgServer +} + +var _ suite.SetupTestSuite = (*TestSuiteAdmin)(nil) + +func TestSuite_Admin_RunAll(t *testing.T) { + suite.Run(t, new(TestSuiteAdmin)) +} + +// SetupTest: Runs before every test in the suite. +func (s *TestSuiteAdmin) SetupTest() { + s.addrAdmin = testutil.AccAddress() + genesisState := genesis.NewTestGenesisState(app.MakeEncodingConfig()) + genesisState = genesis.AddPerpV2Genesis(genesisState) + nibiru := testapp.NewNibiruTestApp(genesisState) + ctx := testapp.NewContext(nibiru) + nibiru.SudoKeeper.Sudoers.Set(ctx, sudotypes.Sudoers{ + Root: "mock-root", // unused + Contracts: []string{s.addrAdmin.String()}, + }) + s.nibiru = nibiru + s.ctx = ctx + s.perpKeeper = s.nibiru.PerpKeeperV2 + s.perpMsgServer = keeper.NewMsgServerImpl(s.perpKeeper) + s.nibiru.PerpKeeperV2.Collateral.Set(s.ctx, perptypes.TestingCollateralDenomNUSD) + + sender := s.addrAdmin + coins := sdk.NewCoins( + sdk.NewCoin(denoms.NIBI, sdk.NewInt(1_000_000)), + sdk.NewCoin(perptypes.TestingCollateralDenomNUSD, sdk.NewInt(420_000*69)), + sdk.NewCoin(denoms.USDT, sdk.NewInt(420_000*69)), + ) + s.NoError(testapp.FundAccount(nibiru.BankKeeper, ctx, sender, coins)) +} + +// HandleMsg: Convenience Executes a tx msg from the MsgServer +func (s *TestSuiteAdmin) HandleMsg(txMsg sdk.Msg) (err error) { + ctx := s.ctx + switch msg := txMsg.(type) { + case *perptypes.MsgShiftPegMultiplier: + _, err = s.perpMsgServer.ShiftPegMultiplier(ctx, msg) + case *perptypes.MsgShiftSwapInvariant: + _, err = s.perpMsgServer.ShiftSwapInvariant(ctx, msg) + case *perptypes.MsgChangeCollateralDenom: + _, err = s.perpMsgServer.ChangeCollateralDenom(ctx, msg) + default: + return fmt.Errorf("unexpected message of type %T encountered", msg) + } + return err +} + +// TestCheckPermissions: Verify that all of the expected admin functions fail +// when called without sudo permissions. +func (s *TestSuiteAdmin) TestCheckPermissions() { + // Sender should not be equal to the admin. + senderAddr := testutil.AccAddress() + if senderAddr.Equals(s.addrAdmin) { + senderAddr = testutil.AccAddress() + } + sender := senderAddr.String() + + for _, testCaseMsg := range []sdk.Msg{ + &perptypes.MsgShiftPegMultiplier{ + Sender: sender, Pair: asset.Pair("valid:pair"), NewPegMult: sdk.NewDec(420), + }, + &perptypes.MsgShiftSwapInvariant{ + Sender: sender, Pair: asset.Pair("valid:pair"), NewSwapInvariant: sdk.NewInt(420), + }, + &perptypes.MsgChangeCollateralDenom{ + Sender: sender, NewDenom: "newdenom", + }, + } { + s.Run(fmt.Sprintf("%T", testCaseMsg), func() { + err := s.HandleMsg(testCaseMsg) + s.ErrorContains(err, sudotypes.ErrUnauthorized.Error()) + }) + } +} + +func (s *TestSuiteAdmin) DoShiftPegTest(pair asset.Pair) error { + _, err := s.perpMsgServer.ShiftPegMultiplier( + sdk.WrapSDKContext(s.ctx), &perptypes.MsgShiftPegMultiplier{ + Sender: s.addrAdmin.String(), + Pair: pair, + NewPegMult: sdk.NewDec(420), + }, + ) + return err +} + +func (s *TestSuiteAdmin) DoShiftSwapInvariantTest(pair asset.Pair) error { + _, err := s.perpMsgServer.ShiftSwapInvariant( + sdk.WrapSDKContext(s.ctx), &perptypes.MsgShiftSwapInvariant{ + Sender: s.addrAdmin.String(), + Pair: pair, + NewSwapInvariant: sdk.NewInt(420), + }, + ) + return err +} + +// TestAdmin_DoHappy: Happy path test cases +func (s *TestSuiteAdmin) TestAdmin_DoHappy() { + pair := asset.Registry.Pair(denoms.ATOM, denoms.NUSD) + + for _, err := range []error{ + s.DoShiftPegTest(pair), + s.DoShiftSwapInvariantTest(pair), + } { + s.NoError(err) + } +} + +// TestAdmin_SadPathsInvalidPair: Test scenarios that fail due to the use of a +// market that doesn't exist. +func (s *TestSuiteAdmin) TestAdmin_SadPathsInvalidPair() { + pair := asset.Pair("ftt:ust:doge") + for _, err := range []error{ + s.DoShiftPegTest(pair), + s.DoShiftSwapInvariantTest(pair), + } { + s.Error(err) + } +} diff --git a/x/perp/v2/keeper/amm.go b/x/perp/v2/keeper/amm.go index 722e6d349..7fc741f6b 100644 --- a/x/perp/v2/keeper/amm.go +++ b/x/perp/v2/keeper/amm.go @@ -11,77 +11,12 @@ import ( types "github.com/NibiruChain/nibiru/x/perp/v2/types" ) -// EditPriceMultiplier edits the peg multiplier of an amm pool after making -// sure there's enough money in the perp EF fund to pay for the repeg. These -// funds get send to the vault to pay for trader's new net margin. -func (k Keeper) EditPriceMultiplier( - ctx sdk.Context, - pair asset.Pair, - newPriceMultiplier sdk.Dec, -) (err error) { - amm, err := k.GetAMM(ctx, pair) - if err != nil { - return err - } - - if newPriceMultiplier.Equal(amm.PriceMultiplier) { - // same price multiplier, no-op - return nil - } - - // Compute cost of re-pegging the pool - cost, err := amm.CalcRepegCost(newPriceMultiplier) - if err != nil { - return err - } - - err = k.handleMarketUpdateCost(ctx, pair, cost) - if err != nil { - return err - } - - // Do the re-peg - amm.PriceMultiplier = newPriceMultiplier - k.SaveAMM(ctx, amm) - - return nil -} - -// EditSwapInvariant edits the swap invariant of an amm pool after making -// sure there's enough money in the perp EF fund to pay for the repeg. These -// funds get send to the vault to pay for trader's new net margin. -func (k Keeper) EditSwapInvariant(ctx sdk.Context, pair asset.Pair, newSwapInvariant sdk.Dec) (err error) { - // Get the pool - amm, err := k.GetAMM(ctx, pair) - if err != nil { - return err - } - - // Compute cost of re-pegging the pool - cost, err := amm.CalcUpdateSwapInvariantCost(newSwapInvariant) - if err != nil { - return err - } - - err = k.handleMarketUpdateCost(ctx, pair, cost) - if err != nil { - return err - } - - err = amm.UpdateSwapInvariant(newSwapInvariant) - if err != nil { - return err - } - - k.SaveAMM(ctx, amm) - - return nil -} - -func (k Keeper) handleMarketUpdateCost(ctx sdk.Context, pair asset.Pair, costAmt sdkmath.Int) (err error) { +func (k Keeper) handleMarketUpdateCost( + ctx sdk.Context, pair asset.Pair, costAmt sdkmath.Int, +) (costPaid sdk.Coin, err error) { collateral, err := k.Collateral.Get(ctx) if err != nil { - return err + return costPaid, err } if costAmt.IsPositive() { @@ -96,11 +31,13 @@ func (k Keeper) handleMarketUpdateCost(ctx sdk.Context, pair asset.Pair, costAmt cost, ) if err != nil { - return types.ErrNotEnoughFundToPayAction.Wrapf( - "not enough fund in perp ef to pay for repeg, need %s got %s", + return costPaid, types.ErrNotEnoughFundToPayAction.Wrapf( + "need %s, got %s", cost.String(), k.BankKeeper.GetBalance(ctx, k.AccountKeeper.GetModuleAddress(types.PerpEFModuleAccount), collateral).String(), ) + } else { + costPaid = cost[0] } } else if costAmt.IsNegative() { // Negative cost, send from margin vault to perp ef. @@ -113,13 +50,18 @@ func (k Keeper) handleMarketUpdateCost(ctx sdk.Context, pair asset.Pair, costAmt ), ) if err != nil { // nolint:staticcheck - // if there's no money in margin to pay for the repeg, we still repeg. It's surprising if it's - // happening on mainnet, but it's not a problem. - // It means there's bad debt in the system, and it's preventing to pay for the repeg down. But the bad debt - // end up being paid up by the perp EF anyway. + costPaid = sdk.NewInt64Coin(collateral, 0) + // Explanation: If there's no money in the vault to pay for the + // operation, the execution should still be successful. It's + // surprising if it's happening on mainnet, but it's not a problem. + // It means there's bad debt in the system, and it's preventing to + // pay for the repeg down. But the bad debt end up being paid up by + // the perp EF anyway. + } else { + costPaid = sdk.NewCoin(collateral, costAmt.Abs()) } } - return nil + return costPaid, nil } // GetMarket returns the market that is enabled. It is the last version of the market. diff --git a/x/perp/v2/keeper/amm_test.go b/x/perp/v2/keeper/amm_test.go index b2ff2513a..e593a5a86 100644 --- a/x/perp/v2/keeper/amm_test.go +++ b/x/perp/v2/keeper/amm_test.go @@ -21,7 +21,7 @@ import ( types "github.com/NibiruChain/nibiru/x/perp/v2/types" ) -func TestEditPriceMultipler(t *testing.T) { +func TestShiftPegMultiplier(t *testing.T) { pair := asset.Registry.Pair(denoms.BTC, denoms.NUSD) tests := TestCases{ @@ -32,7 +32,7 @@ func TestEditPriceMultipler(t *testing.T) { FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( - EditPriceMultiplier(pair, sdk.OneDec()), + ShiftPegMultiplier(pair, sdk.OneDec()), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)), @@ -55,7 +55,7 @@ func TestEditPriceMultipler(t *testing.T) { FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( - EditPriceMultiplier(pair, sdk.NewDec(10)), + ShiftPegMultiplier(pair, sdk.NewDec(10)), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)), @@ -75,7 +75,7 @@ func TestEditPriceMultipler(t *testing.T) { FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( - EditPriceMultiplier(pair, sdk.NewDec(10)), + ShiftPegMultiplier(pair, sdk.NewDec(10)), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1004500)), @@ -95,7 +95,7 @@ func TestEditPriceMultipler(t *testing.T) { FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( - EditPriceMultiplier(pair, sdk.MustNewDecFromStr("0.25")), + ShiftPegMultiplier(pair, sdk.MustNewDecFromStr("0.25")), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(999626)), @@ -115,7 +115,7 @@ func TestEditPriceMultipler(t *testing.T) { FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( - EditPriceMultiplier(pair, sdk.NewDec(10)), + ShiftPegMultiplier(pair, sdk.NewDec(10)), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(995500)), @@ -135,7 +135,7 @@ func TestEditPriceMultipler(t *testing.T) { FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( - EditPriceMultiplier(pair, sdk.MustNewDecFromStr("0.25")), + ShiftPegMultiplier(pair, sdk.MustNewDecFromStr("0.25")), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1000376)), @@ -152,7 +152,9 @@ func TestEditPriceMultipler(t *testing.T) { NewTestSuite(t).WithTestCases(tests...).Run() } -func TestEditPriceMultiplerFail(t *testing.T) { +// TestShiftPegMultiplier_Fail: Test scenarios for the `ShiftPegMultiplier` +// function that should error. +func TestShiftPegMultiplier_Fail(t *testing.T) { pair := asset.Registry.Pair(denoms.BTC, denoms.NUSD) app, ctx := testapp.NewNibiruTestAppAndContext() @@ -184,12 +186,14 @@ func TestEditPriceMultiplerFail(t *testing.T) { }) require.NoError(t, err) + adminAddr := testapp.DefaultSudoRoot() // Error because of invalid pair - err = app.PerpKeeperV2.Admin.EditPriceMultiplier(ctx, asset.MustNewPair("luna:usdt"), sdk.NewDec(-1)) + err = app.PerpKeeperV2.Admin.ShiftPegMultiplier( + ctx, asset.MustNewPair("luna:usdt"), sdk.NewDec(-1), adminAddr) require.ErrorContains(t, err, "market luna:usdt not found") // Error because of invalid price multiplier - err = app.PerpKeeperV2.Admin.EditPriceMultiplier(ctx, pair, sdk.NewDec(-1)) + err = app.PerpKeeperV2.Admin.ShiftPegMultiplier(ctx, pair, sdk.NewDec(-1), adminAddr) require.ErrorIs(t, err, types.ErrNonPositivePegMultiplier) // Add market activity @@ -211,15 +215,17 @@ func TestEditPriceMultiplerFail(t *testing.T) { require.NoError(t, err) // Error because no money in perp ef fund - err = app.PerpKeeperV2.Admin.EditPriceMultiplier(ctx, pair, sdk.NewDec(3)) - require.ErrorContains(t, err, "not enough fund in perp ef to pay for repeg") + err = app.PerpKeeperV2.Admin.ShiftPegMultiplier(ctx, pair, sdk.NewDec(3), adminAddr) + require.ErrorContains(t, err, types.ErrNotEnoughFundToPayAction.Error()) // Works because it goes in the other way - err = app.PerpKeeperV2.Admin.EditPriceMultiplier(ctx, pair, sdk.NewDec(1)) + err = app.PerpKeeperV2.Admin.ShiftPegMultiplier(ctx, pair, sdk.NewDec(1), adminAddr) require.NoError(t, err) } -func TestEditSwapInvariantFail(t *testing.T) { +// TestShiftSwapInvariant_Fail: Test scenarios for the `ShiftSwapInvariant` +// function that should error +func TestShiftSwapInvariant_Fail(t *testing.T) { pair := asset.Registry.Pair(denoms.BTC, denoms.NUSD) app, ctx := testapp.NewNibiruTestAppAndContext() account := testutil.AccAddress() @@ -250,13 +256,14 @@ func TestEditSwapInvariantFail(t *testing.T) { }) require.NoError(t, err) + adminAddr := testapp.DefaultSudoRoot() // Error because of invalid price multiplier - err = app.PerpKeeperV2.Admin.EditSwapInvariant(ctx, asset.MustNewPair("luna:usdt"), sdk.NewDec(-1)) + err = app.PerpKeeperV2.Admin.ShiftSwapInvariant(ctx, asset.MustNewPair("luna:usdt"), sdk.NewInt(-1), adminAddr) require.ErrorContains(t, err, "market luna:usdt not found") // Error because of invalid price multiplier - err = app.PerpKeeperV2.Admin.EditSwapInvariant(ctx, pair, sdk.NewDec(-1)) - require.ErrorIs(t, err, types.ErrNegativeSwapInvariant) + err = app.PerpKeeperV2.Admin.ShiftSwapInvariant(ctx, pair, sdk.NewInt(-1), adminAddr) + require.ErrorIs(t, err, types.ErrNonPositiveSwapInvariant) // Add market activity err = app.BankKeeper.MintCoins(ctx, "inflation", sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(102)))) @@ -277,19 +284,19 @@ func TestEditSwapInvariantFail(t *testing.T) { require.NoError(t, err) // Error because no money in perp ef fund - err = app.PerpKeeperV2.Admin.EditSwapInvariant(ctx, pair, sdk.NewDec(2_000_000)) - require.ErrorContains(t, err, "not enough fund in perp ef to pay for repeg") + err = app.PerpKeeperV2.Admin.ShiftSwapInvariant(ctx, pair, sdk.NewInt(2_000_000), adminAddr) + require.ErrorContains(t, err, types.ErrNotEnoughFundToPayAction.Error()) // Fail at validate - err = app.PerpKeeperV2.Admin.EditSwapInvariant(ctx, pair, sdk.NewDec(0)) - require.ErrorContains(t, err, "swap multiplier must be > 0") + err = app.PerpKeeperV2.Admin.ShiftSwapInvariant(ctx, pair, sdk.NewInt(0), adminAddr) + require.ErrorContains(t, err, types.ErrNonPositiveSwapInvariant.Error()) // Works because it goes in the other way - err = app.PerpKeeperV2.Admin.EditSwapInvariant(ctx, pair, sdk.NewDec(500_000)) + err = app.PerpKeeperV2.Admin.ShiftSwapInvariant(ctx, pair, sdk.NewInt(500_000), adminAddr) require.NoError(t, err) } -func TestEditSwapInvariant(t *testing.T) { +func TestShiftSwapInvariant(t *testing.T) { pair := asset.Registry.Pair(denoms.BTC, denoms.NUSD) tests := TestCases{ @@ -304,7 +311,7 @@ func TestEditSwapInvariant(t *testing.T) { FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( - EditSwapInvariant(pair, sdk.NewDec(1e12)), + ShiftSwapInvariant(pair, sdk.NewInt(1e12)), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)), @@ -328,7 +335,7 @@ func TestEditSwapInvariant(t *testing.T) { FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( - EditSwapInvariant(pair, sdk.NewDec(1e18)), + ShiftSwapInvariant(pair, sdk.NewInt(1e18)), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)), @@ -348,7 +355,7 @@ func TestEditSwapInvariant(t *testing.T) { FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( - EditSwapInvariant(pair, sdk.NewDec(1e14)), + ShiftSwapInvariant(pair, sdk.NewInt(1e14)), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1008101)), @@ -368,7 +375,7 @@ func TestEditSwapInvariant(t *testing.T) { FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( - EditSwapInvariant(pair, sdk.NewDec(1e6)), + ShiftSwapInvariant(pair, sdk.NewInt(1e6)), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(999991)), @@ -388,7 +395,7 @@ func TestEditSwapInvariant(t *testing.T) { FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( - EditSwapInvariant(pair, sdk.NewDec(1e14)), + ShiftSwapInvariant(pair, sdk.NewInt(1e14)), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1010102)), @@ -408,7 +415,7 @@ func TestEditSwapInvariant(t *testing.T) { FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( - EditSwapInvariant(pair, sdk.NewDec(1e6)), + ShiftSwapInvariant(pair, sdk.NewInt(1e6)), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(999989)), diff --git a/x/perp/v2/keeper/clearing_house_test.go b/x/perp/v2/keeper/clearing_house_test.go index 270b1dba2..b9cee6504 100644 --- a/x/perp/v2/keeper/clearing_house_test.go +++ b/x/perp/v2/keeper/clearing_house_test.go @@ -48,7 +48,7 @@ func TestMarketOrder(t *testing.T) { MarketOrder(alice, pairBtcNusd, types.Direction_SHORT, sdk.NewInt(10_000), sdk.OneDec(), sdk.ZeroDec()), MarketOrder(bob, pairBtcNusd, types.Direction_LONG, sdk.NewInt(10_000), sdk.OneDec(), sdk.ZeroDec()), - EditSwapInvariant(pairBtcNusd, sdk.OneDec()), + ShiftSwapInvariant(pairBtcNusd, sdk.NewInt(1)), ). When( PartialCloseFails(alice, pairBtcNusd, sdk.NewDec(5_000), types.ErrBaseReserveAtZero), @@ -264,7 +264,7 @@ func TestMarketOrder(t *testing.T) { FundAccount(alice, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(10_000)))), MarketOrder(alice, pairBtcNusd, types.Direction_LONG, sdk.NewInt(9_000), sdk.NewDec(10), sdk.ZeroDec()), FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), - EditSwapInvariant(pairBtcNusd, sdk.OneDec()), + ShiftSwapInvariant(pairBtcNusd, sdk.NewInt(1)), ). When( ClosePosition(alice, pairBtcNusd), @@ -1956,7 +1956,7 @@ func TestUpdateSwapInvariant(t *testing.T) { pairBtcNusd := asset.Registry.Pair(denoms.BTC, denoms.NUSD) startBlockTime := time.Now() - startingSwapInvariant := sdk.NewDec(1_000_000_000_000).Mul(sdk.NewDec(1_000_000_000_000)) + startingSwapInvariant := sdk.NewInt(1e12).Mul(sdk.NewInt(1e12)) tc := TestCases{ TC("only long position - no change to swap invariant"). @@ -1999,7 +1999,7 @@ func TestUpdateSwapInvariant(t *testing.T) { ). When( MarketOrder(alice, pairBtcNusd, types.Direction_LONG, sdk.NewInt(10_000_000_000), sdk.OneDec(), sdk.ZeroDec()), - EditSwapInvariant(pairBtcNusd, startingSwapInvariant.MulInt64(100)), + ShiftSwapInvariant(pairBtcNusd, startingSwapInvariant.MulRaw(100)), AMMShouldBeEqual( pairBtcNusd, AMM_SwapInvariantShouldBeEqual(sdk.MustNewDecFromStr("99999999999999999999999999.999999000000000000"))), @@ -2019,7 +2019,7 @@ func TestUpdateSwapInvariant(t *testing.T) { ). When( MarketOrder(alice, pairBtcNusd, types.Direction_SHORT, sdk.NewInt(10_000_000_000), sdk.OneDec(), sdk.ZeroDec()), - EditSwapInvariant(pairBtcNusd, startingSwapInvariant.MulInt64(100)), + ShiftSwapInvariant(pairBtcNusd, startingSwapInvariant.MulRaw(100)), AMMShouldBeEqual( pairBtcNusd, AMM_SwapInvariantShouldBeEqual(sdk.MustNewDecFromStr("99999999999999999999999999.999999000000000000"))), @@ -2040,7 +2040,9 @@ func TestUpdateSwapInvariant(t *testing.T) { ). When( MarketOrder(alice, pairBtcNusd, types.Direction_LONG, sdk.NewInt(10_000_000_000), sdk.OneDec(), sdk.ZeroDec()), - EditSwapInvariant(pairBtcNusd, startingSwapInvariant.Mul(sdk.MustNewDecFromStr("0.1"))), + ShiftSwapInvariant( + pairBtcNusd, + startingSwapInvariant.QuoRaw(10)), AMMShouldBeEqual( pairBtcNusd, AMM_SwapInvariantShouldBeEqual(sdk.MustNewDecFromStr("99999999999999999873578.871987715651277660"))), @@ -2060,7 +2062,8 @@ func TestUpdateSwapInvariant(t *testing.T) { ). When( MarketOrder(alice, pairBtcNusd, types.Direction_SHORT, sdk.NewInt(10_000_000_000), sdk.OneDec(), sdk.ZeroDec()), - EditSwapInvariant(pairBtcNusd, startingSwapInvariant.Mul(sdk.MustNewDecFromStr("0.1"))), + ShiftSwapInvariant(pairBtcNusd, + startingSwapInvariant.QuoRaw(10)), AMMShouldBeEqual( pairBtcNusd, AMM_SwapInvariantShouldBeEqual(sdk.MustNewDecFromStr("99999999999999999873578.871987801032774485"))), @@ -2083,7 +2086,8 @@ func TestUpdateSwapInvariant(t *testing.T) { MarketOrder(alice, pairBtcNusd, types.Direction_LONG, sdk.NewInt(10_000_000_000), sdk.OneDec(), sdk.ZeroDec()), MarketOrder(bob, pairBtcNusd, types.Direction_SHORT, sdk.NewInt(10_000_000_000), sdk.OneDec(), sdk.NewDec(10_000_000_000_000)), - EditSwapInvariant(pairBtcNusd, startingSwapInvariant.MulInt64(100)), + ShiftSwapInvariant(pairBtcNusd, + startingSwapInvariant.MulRaw(100)), AMMShouldBeEqual( pairBtcNusd, AMM_BiasShouldBeEqual(sdk.ZeroDec()), @@ -2114,7 +2118,8 @@ func TestUpdateSwapInvariant(t *testing.T) { MarketOrder(alice, pairBtcNusd, types.Direction_LONG, sdk.NewInt(10_000_000_000), sdk.OneDec(), sdk.ZeroDec()), MarketOrder(bob, pairBtcNusd, types.Direction_SHORT, sdk.NewInt(10_000_000_000), sdk.OneDec(), sdk.NewDec(10_000_000_000_000)), - EditSwapInvariant(pairBtcNusd, startingSwapInvariant.Mul(sdk.MustNewDecFromStr("0.1"))), + ShiftSwapInvariant(pairBtcNusd, + startingSwapInvariant.QuoRaw(10)), AMMShouldBeEqual( pairBtcNusd, AMM_BiasShouldBeEqual(sdk.ZeroDec()), diff --git a/x/perp/v2/keeper/fixture_test.go b/x/perp/v2/keeper/fixture_test.go new file mode 100644 index 000000000..942926490 --- /dev/null +++ b/x/perp/v2/keeper/fixture_test.go @@ -0,0 +1 @@ +package keeper_test diff --git a/x/perp/v2/keeper/msg_server.go b/x/perp/v2/keeper/msg_server.go index 3274c3752..03ad6830b 100644 --- a/x/perp/v2/keeper/msg_server.go +++ b/x/perp/v2/keeper/msg_server.go @@ -157,15 +157,15 @@ func (m msgServer) ChangeCollateralDenom( return &types.MsgChangeCollateralDenomResponse{}, err } -func (m msgServer) AllocateEpochRebates(ctx context.Context, msg *types.MsgAllocateEpochRebates) (*types.MsgAllocateEpochRebatesResponse, error) { +func (m msgServer) AllocateEpochRebates( + ctx context.Context, msg *types.MsgAllocateEpochRebates, +) (*types.MsgAllocateEpochRebatesResponse, error) { if msg == nil { return nil, common.ErrNilMsg() } - sender, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { - return nil, err - } + // Sender is checked in `msg.ValidateBasic` before reaching this fn call. + sender, _ := sdk.AccAddressFromBech32(msg.Sender) total, err := m.k.AllocateEpochRebates(sdk.UnwrapSDKContext(ctx), sender, msg.Rebates) if err != nil { return nil, err @@ -178,11 +178,8 @@ func (m msgServer) WithdrawEpochRebates(ctx context.Context, msg *types.MsgWithd if msg == nil { return nil, common.ErrNilMsg() } - - sender, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { - return nil, err - } + // Sender is checked in `msg.ValidateBasic` before reaching this fn call. + sender, _ := sdk.AccAddressFromBech32(msg.Sender) sdkCtx := sdk.UnwrapSDKContext(ctx) totalWithdrawn := sdk.NewCoins() for _, epoch := range msg.Epochs { @@ -196,3 +193,27 @@ func (m msgServer) WithdrawEpochRebates(ctx context.Context, msg *types.MsgWithd WithdrawnRebates: totalWithdrawn, }, nil } + +// ShiftPegMultiplier: gRPC tx msg for changing a market's peg multiplier. +// [Admin] Only callable by sudoers. +func (m msgServer) ShiftPegMultiplier( + goCtx context.Context, msg *types.MsgShiftPegMultiplier, +) (*types.MsgShiftPegMultiplierResponse, error) { + // Sender is checked in `msg.ValidateBasic` before reaching this fn call. + sender, _ := sdk.AccAddressFromBech32(msg.Sender) + ctx := sdk.UnwrapSDKContext(goCtx) + err := m.k.Admin.ShiftPegMultiplier(ctx, msg.Pair, msg.NewPegMult, sender) + return &types.MsgShiftPegMultiplierResponse{}, err +} + +// ShiftSwapInvariant: gRPC tx msg for changing a market's swap invariant. +// [Admin] Only callable by sudoers. +func (m msgServer) ShiftSwapInvariant( + goCtx context.Context, msg *types.MsgShiftSwapInvariant, +) (*types.MsgShiftSwapInvariantResponse, error) { + // Sender is checked in `msg.ValidateBasic` before reaching this fn call. + sender, _ := sdk.AccAddressFromBech32(msg.Sender) + ctx := sdk.UnwrapSDKContext(goCtx) + err := m.k.Admin.ShiftSwapInvariant(ctx, msg.Pair, msg.NewSwapInvariant, sender) + return &types.MsgShiftSwapInvariantResponse{}, err +} diff --git a/x/perp/v2/keeper/msg_server_test.go b/x/perp/v2/keeper/msg_server_test.go index c13baad28..0d357178a 100644 --- a/x/perp/v2/keeper/msg_server_test.go +++ b/x/perp/v2/keeper/msg_server_test.go @@ -17,7 +17,7 @@ import ( "github.com/NibiruChain/nibiru/x/common/testutil/testapp" . "github.com/NibiruChain/nibiru/x/perp/v2/integration/action" . "github.com/NibiruChain/nibiru/x/perp/v2/integration/assertion" - "github.com/NibiruChain/nibiru/x/perp/v2/keeper" + perpkeeper "github.com/NibiruChain/nibiru/x/perp/v2/keeper" "github.com/NibiruChain/nibiru/x/perp/v2/types" sudoerTypes "github.com/NibiruChain/nibiru/x/sudo/types" ) @@ -324,7 +324,7 @@ func TestFailMsgServer(t *testing.T) { sender := testutil.AccAddress().String() - msgServer := keeper.NewMsgServerImpl(app.PerpKeeperV2) + msgServer := perpkeeper.NewMsgServerImpl(app.PerpKeeperV2) _, err := msgServer.MarketOrder(ctx, &types.MsgMarketOrder{ Sender: sender, @@ -372,7 +372,7 @@ func TestMsgChangeCollateralDenom(t *testing.T) { sender := testutil.AccAddress().String() - msgServer := keeper.NewMsgServerImpl(app.PerpKeeperV2) + msgServer := perpkeeper.NewMsgServerImpl(app.PerpKeeperV2) _, err := msgServer.ChangeCollateralDenom(ctx, nil) require.ErrorContains(t, err, "nil msg") @@ -447,13 +447,13 @@ func TestAllocateEpochRebates(t *testing.T) { sender := testutil.AccAddress().String() - msgServer := keeper.NewMsgServerImpl(app.PerpKeeperV2) + msgServer := perpkeeper.NewMsgServerImpl(app.PerpKeeperV2) _, err := msgServer.AllocateEpochRebates(ctx, nil) require.ErrorContains(t, err, "nil msg") _, err = msgServer.AllocateEpochRebates(ctx, &types.MsgAllocateEpochRebates{}) - require.ErrorContains(t, err, "empty address string is not allowed") + require.NoError(t, err) _, err = msgServer.AllocateEpochRebates(ctx, &types.MsgAllocateEpochRebates{ Sender: sender, @@ -484,7 +484,7 @@ func TestAllocateEpochRebates(t *testing.T) { require.ErrorContains(t, err, "nil msg") _, err = msgServer.WithdrawEpochRebates(ctx, &types.MsgWithdrawEpochRebates{}) - require.ErrorContains(t, err, "empty address string is not allowed") + require.NoError(t, err) _, err = msgServer.WithdrawEpochRebates(ctx, &types.MsgWithdrawEpochRebates{ Sender: sender, diff --git a/x/perp/v2/module/genesis_test.go b/x/perp/v2/module/genesis_test.go index 8998d1f2d..7844f8885 100644 --- a/x/perp/v2/module/genesis_test.go +++ b/x/perp/v2/module/genesis_test.go @@ -84,7 +84,7 @@ func RunTestGenesis(t *testing.T, tc TestCase) { pair := asset.Registry.Pair(denoms.BTC, denoms.NUSD) // Initialize sudo state - nibiruTeam := common.NibiruTeam + nibiruTeam := common.NIBIRU_TEAM sudoers := PerpSudoers() sudoersRoot := sdk.MustAccAddressFromBech32(nibiruTeam) sudoers.Root = sudoersRoot.String() diff --git a/x/perp/v2/types/amm.go b/x/perp/v2/types/amm.go index fcb7feab0..57f93a410 100644 --- a/x/perp/v2/types/amm.go +++ b/x/perp/v2/types/amm.go @@ -387,7 +387,7 @@ func (amm AMM) CalcUpdateSwapInvariantCost(newSwapInvariant sdk.Dec) (sdkmath.In } if !newSwapInvariant.IsPositive() { - return sdkmath.Int{}, ErrNegativeSwapInvariant + return sdkmath.Int{}, ErrNonPositiveSwapInvariant } marketValueBefore, err := amm.GetMarketValue() diff --git a/x/perp/v2/types/amm_test.go b/x/perp/v2/types/amm_test.go index ab4e13a5f..8c40d643a 100644 --- a/x/perp/v2/types/amm_test.go +++ b/x/perp/v2/types/amm_test.go @@ -589,7 +589,7 @@ func TestCalcUpdateSwapInvariantCost(t *testing.T) { TotalShort: sdk.ZeroDec(), }, newSwapInvariant: sdk.NewDec(-1), - expectedErr: types.ErrNegativeSwapInvariant, + expectedErr: types.ErrNonPositiveSwapInvariant, }, } diff --git a/x/perp/v2/types/codec.go b/x/perp/v2/types/codec.go index b35212a01..739ef814e 100644 --- a/x/perp/v2/types/codec.go +++ b/x/perp/v2/types/codec.go @@ -16,6 +16,8 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgDonateToEcosystemFund{}, "perpv2/donate_to_ef", nil) cdc.RegisterConcrete(&MsgMultiLiquidate{}, "perpv2/multi_liquidate", nil) cdc.RegisterConcrete(&MsgChangeCollateralDenom{}, "perpv2/change_collateral_denom", nil) + cdc.RegisterConcrete(&MsgShiftPegMultiplier{}, "perpv2/shift_peg_multiplier", nil) + cdc.RegisterConcrete(&MsgShiftSwapInvariant{}, "perpv2/shift_swap_invariant", nil) } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { @@ -29,6 +31,8 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgPartialClose{}, &MsgMultiLiquidate{}, &MsgChangeCollateralDenom{}, + &MsgShiftPegMultiplier{}, + &MsgShiftSwapInvariant{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/perp/v2/types/codec_test.go b/x/perp/v2/types/codec_test.go index e17a2d56c..afae79b86 100644 --- a/x/perp/v2/types/codec_test.go +++ b/x/perp/v2/types/codec_test.go @@ -25,6 +25,8 @@ func TestCodec(t *testing.T) { &MsgPartialClose{}, &MsgDonateToEcosystemFund{}, &MsgMultiLiquidate{}, + &MsgShiftPegMultiplier{}, + &MsgShiftSwapInvariant{}, } for _, msg := range msgs { diff --git a/x/perp/v2/types/errors.go b/x/perp/v2/types/errors.go index 4c49842fc..a38500e85 100644 --- a/x/perp/v2/types/errors.go +++ b/x/perp/v2/types/errors.go @@ -2,10 +2,6 @@ package types import sdkerrors "cosmossdk.io/errors" -// highestErrorCode = 33 -// NOTE: Please increment this when you add an error to make it easier for -// other developers to know which "code" value should be used next. - var ( ErrPairNotSupported = sdkerrors.Register(ModuleName, 1, "pair not supported") ErrQuoteReserveAtZero = sdkerrors.Register(ModuleName, 2, "quote reserve after at zero") @@ -42,8 +38,8 @@ var ( ErrLiquidityDepthOverflow = sdkerrors.Register(ModuleName, 24, "liquidty depth overflow") ErrMarketNotEnabled = sdkerrors.Register(ModuleName, 25, "market is not enabled, you can only fully close your position") ErrNonPositivePegMultiplier = sdkerrors.Register(ModuleName, 26, "peg multiplier must be > 0") - ErrNegativeSwapInvariant = sdkerrors.Register(ModuleName, 27, "swap multiplier must be > 0") - ErrNilSwapInvariant = sdkerrors.Register(ModuleName, 28, "swap multiplier must be not nil") + ErrNonPositiveSwapInvariant = sdkerrors.Register(ModuleName, 27, "swap invariant must be > 0") + ErrNilSwapInvariant = sdkerrors.Register(ModuleName, 28, "swap invariant must not be nil") ErrNotEnoughFundToPayAction = sdkerrors.Register(ModuleName, 29, "not enough fund in perp EF to pay for action") ErrSettlementPositionMarketEnabled = sdkerrors.Register(ModuleName, 32, "market is enabled, you can only settle position on disabled market") diff --git a/x/perp/v2/types/event.pb.go b/x/perp/v2/types/event.pb.go index 598fae243..4db1fe795 100644 --- a/x/perp/v2/types/event.pb.go +++ b/x/perp/v2/types/event.pb.go @@ -523,6 +523,100 @@ func (m *MarketUpdatedEvent) GetFinalMarket() Market { return Market{} } +// EventShiftPegMultiplier: ABCI event emitted from MsgShiftPegMultiplier +type EventShiftPegMultiplier struct { + OldPegMultiplier github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=old_peg_multiplier,json=oldPegMultiplier,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"old_peg_multiplier"` + NewPegMultiplier github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=new_peg_multiplier,json=newPegMultiplier,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"new_peg_multiplier"` + CostPaid types.Coin `protobuf:"bytes,3,opt,name=cost_paid,json=costPaid,proto3" json:"cost_paid"` +} + +func (m *EventShiftPegMultiplier) Reset() { *m = EventShiftPegMultiplier{} } +func (m *EventShiftPegMultiplier) String() string { return proto.CompactTextString(m) } +func (*EventShiftPegMultiplier) ProtoMessage() {} +func (*EventShiftPegMultiplier) Descriptor() ([]byte, []int) { + return fileDescriptor_a5313bbc89fa31dd, []int{7} +} +func (m *EventShiftPegMultiplier) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventShiftPegMultiplier) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventShiftPegMultiplier.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *EventShiftPegMultiplier) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventShiftPegMultiplier.Merge(m, src) +} +func (m *EventShiftPegMultiplier) XXX_Size() int { + return m.Size() +} +func (m *EventShiftPegMultiplier) XXX_DiscardUnknown() { + xxx_messageInfo_EventShiftPegMultiplier.DiscardUnknown(m) +} + +var xxx_messageInfo_EventShiftPegMultiplier proto.InternalMessageInfo + +func (m *EventShiftPegMultiplier) GetCostPaid() types.Coin { + if m != nil { + return m.CostPaid + } + return types.Coin{} +} + +// EventShiftSwapInvariant: ABCI event emitted from MsgShiftSwapInvariant +type EventShiftSwapInvariant struct { + OldSwapInvariant github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=old_swap_invariant,json=oldSwapInvariant,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"old_swap_invariant"` + NewSwapInvariant github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=new_swap_invariant,json=newSwapInvariant,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"new_swap_invariant"` + CostPaid types.Coin `protobuf:"bytes,3,opt,name=cost_paid,json=costPaid,proto3" json:"cost_paid"` +} + +func (m *EventShiftSwapInvariant) Reset() { *m = EventShiftSwapInvariant{} } +func (m *EventShiftSwapInvariant) String() string { return proto.CompactTextString(m) } +func (*EventShiftSwapInvariant) ProtoMessage() {} +func (*EventShiftSwapInvariant) Descriptor() ([]byte, []int) { + return fileDescriptor_a5313bbc89fa31dd, []int{8} +} +func (m *EventShiftSwapInvariant) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventShiftSwapInvariant) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventShiftSwapInvariant.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *EventShiftSwapInvariant) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventShiftSwapInvariant.Merge(m, src) +} +func (m *EventShiftSwapInvariant) XXX_Size() int { + return m.Size() +} +func (m *EventShiftSwapInvariant) XXX_DiscardUnknown() { + xxx_messageInfo_EventShiftSwapInvariant.DiscardUnknown(m) +} + +var xxx_messageInfo_EventShiftSwapInvariant proto.InternalMessageInfo + +func (m *EventShiftSwapInvariant) GetCostPaid() types.Coin { + if m != nil { + return m.CostPaid + } + return types.Coin{} +} + func init() { proto.RegisterEnum("nibiru.perp.v2.LiquidationFailedEvent_LiquidationFailedReason", LiquidationFailedEvent_LiquidationFailedReason_name, LiquidationFailedEvent_LiquidationFailedReason_value) proto.RegisterType((*PositionChangedEvent)(nil), "nibiru.perp.v2.PositionChangedEvent") @@ -532,82 +626,91 @@ func init() { proto.RegisterType((*LiquidationFailedEvent)(nil), "nibiru.perp.v2.LiquidationFailedEvent") proto.RegisterType((*AmmUpdatedEvent)(nil), "nibiru.perp.v2.AmmUpdatedEvent") proto.RegisterType((*MarketUpdatedEvent)(nil), "nibiru.perp.v2.MarketUpdatedEvent") + proto.RegisterType((*EventShiftPegMultiplier)(nil), "nibiru.perp.v2.EventShiftPegMultiplier") + proto.RegisterType((*EventShiftSwapInvariant)(nil), "nibiru.perp.v2.EventShiftSwapInvariant") } func init() { proto.RegisterFile("nibiru/perp/v2/event.proto", fileDescriptor_a5313bbc89fa31dd) } var fileDescriptor_a5313bbc89fa31dd = []byte{ - // 1109 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x96, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xc0, 0xe3, 0xb8, 0xa4, 0xcd, 0xf8, 0x6f, 0x06, 0x93, 0x6e, 0x43, 0xe5, 0x84, 0x55, 0x41, - 0xb9, 0x64, 0x57, 0x09, 0x12, 0x52, 0x7b, 0x00, 0x39, 0x89, 0x43, 0x2c, 0x25, 0x8e, 0xd9, 0x38, - 0xa5, 0x05, 0xa1, 0x65, 0x76, 0x77, 0xec, 0x8c, 0xe2, 0x9d, 0x59, 0x76, 0xc6, 0x69, 0x92, 0x2f, - 0x00, 0x47, 0x6e, 0x7c, 0x07, 0x3e, 0x49, 0x8f, 0x3d, 0x22, 0x0e, 0x01, 0x25, 0xe2, 0xc0, 0x0d, - 0x71, 0xe5, 0x82, 0x76, 0x66, 0x36, 0xfe, 0x93, 0xb6, 0xa1, 0x16, 0x1c, 0x38, 0xd9, 0xfb, 0xde, - 0xbc, 0xdf, 0xfb, 0xb3, 0xef, 0xbd, 0x59, 0xb0, 0x40, 0x89, 0x47, 0xe2, 0xbe, 0x1d, 0xe1, 0x38, - 0xb2, 0x8f, 0xd7, 0x6c, 0x7c, 0x8c, 0xa9, 0xb0, 0xa2, 0x98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xc8, 0xab, 0xfc, 0x43, - 0xa9, 0xd3, 0x25, 0x98, 0x1f, 0x2f, 0x81, 0xb2, 0xd4, 0x55, 0xc8, 0x49, 0x0b, 0x2d, 0xfa, 0xf4, - 0xf9, 0x45, 0x35, 0xf3, 0xe2, 0xa2, 0x9a, 0xf9, 0xf5, 0xa2, 0x9a, 0xf9, 0xfe, 0xb2, 0x3a, 0xf5, - 0xe2, 0xb2, 0x3a, 0xf5, 0xd3, 0x65, 0x75, 0xea, 0x8b, 0x95, 0x9b, 0x3a, 0x35, 0xfd, 0x5e, 0x96, - 0x31, 0x7b, 0x33, 0xf2, 0x7b, 0xf8, 0xc3, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xc9, 0xe7, 0x3a, - 0x1d, 0xce, 0x0b, 0x00, 0x00, + // 1230 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x97, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xc7, 0xe3, 0xb8, 0xa4, 0xcd, 0xc4, 0xb1, 0x9d, 0xc1, 0x24, 0xdb, 0x52, 0x39, 0x61, 0x55, + 0x50, 0x2e, 0xdd, 0x55, 0x83, 0x84, 0xd4, 0x0a, 0x81, 0x92, 0xd4, 0x21, 0x96, 0x1a, 0xd7, 0xac, + 0x9d, 0xd2, 0xf2, 0x43, 0xcb, 0x78, 0xf7, 0xd9, 0x19, 0x65, 0x77, 0x66, 0xd9, 0x19, 0xc7, 0x4d, + 0xff, 0x01, 0x38, 0x22, 0x71, 0xe0, 0x7f, 0xe0, 0x2f, 0xe9, 0xb1, 0x47, 0xc4, 0xa1, 0xa0, 0x56, + 0x1c, 0xb8, 0x21, 0xae, 0x5c, 0xd0, 0xce, 0xce, 0xc6, 0x3f, 0xd2, 0x36, 0xc4, 0xc0, 0x81, 0x53, + 0xb2, 0xef, 0xcd, 0x7c, 0xde, 0x9b, 0xef, 0xbe, 0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0x57, 0x67, 0x7e, 0x7c, 0x5e, 0x9d, + 0xf9, 0xf4, 0xfa, 0x59, 0x53, 0x2d, 0xfb, 0x6d, 0xa5, 0x92, 0xeb, 0xcc, 0xa9, 0xdf, 0x4e, 0xef, + 0xfe, 0x15, 0x00, 0x00, 0xff, 0xff, 0x50, 0x37, 0x90, 0x96, 0xfa, 0x0d, 0x00, 0x00, } func (m *PositionChangedEvent) Marshal() (dAtA []byte, err error) { @@ -1063,6 +1166,112 @@ func (m *MarketUpdatedEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *EventShiftPegMultiplier) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EventShiftPegMultiplier) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventShiftPegMultiplier) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.CostPaid.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.NewPegMultiplier.Size() + i -= size + if _, err := m.NewPegMultiplier.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintEvent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.OldPegMultiplier.Size() + i -= size + if _, err := m.OldPegMultiplier.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintEvent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *EventShiftSwapInvariant) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EventShiftSwapInvariant) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventShiftSwapInvariant) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.CostPaid.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.NewSwapInvariant.Size() + i -= size + if _, err := m.NewSwapInvariant.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintEvent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.OldSwapInvariant.Size() + i -= size + if _, err := m.OldSwapInvariant.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintEvent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintEvent(dAtA []byte, offset int, v uint64) int { offset -= sovEvent(v) base := offset @@ -1213,6 +1422,36 @@ func (m *MarketUpdatedEvent) Size() (n int) { return n } +func (m *EventShiftPegMultiplier) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.OldPegMultiplier.Size() + n += 1 + l + sovEvent(uint64(l)) + l = m.NewPegMultiplier.Size() + n += 1 + l + sovEvent(uint64(l)) + l = m.CostPaid.Size() + n += 1 + l + sovEvent(uint64(l)) + return n +} + +func (m *EventShiftSwapInvariant) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.OldSwapInvariant.Size() + n += 1 + l + sovEvent(uint64(l)) + l = m.NewSwapInvariant.Size() + n += 1 + l + sovEvent(uint64(l)) + l = m.CostPaid.Size() + n += 1 + l + sovEvent(uint64(l)) + return n +} + func sovEvent(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2577,6 +2816,308 @@ func (m *MarketUpdatedEvent) Unmarshal(dAtA []byte) error { } return nil } +func (m *EventShiftPegMultiplier) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EventShiftPegMultiplier: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventShiftPegMultiplier: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OldPegMultiplier", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OldPegMultiplier.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewPegMultiplier", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NewPegMultiplier.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CostPaid", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.CostPaid.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventShiftSwapInvariant) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EventShiftSwapInvariant: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventShiftSwapInvariant: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OldSwapInvariant", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OldSwapInvariant.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewSwapInvariant", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NewSwapInvariant.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CostPaid", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.CostPaid.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipEvent(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/perp/v2/types/msgs.go b/x/perp/v2/types/msgs.go index d67370e3c..b3ccc223f 100644 --- a/x/perp/v2/types/msgs.go +++ b/x/perp/v2/types/msgs.go @@ -19,9 +19,11 @@ var ( _ sdk.Msg = &MsgPartialClose{} _ sdk.Msg = &MsgAllocateEpochRebates{} _ sdk.Msg = &MsgWithdrawEpochRebates{} + _ sdk.Msg = &MsgShiftPegMultiplier{} + _ sdk.Msg = &MsgShiftSwapInvariant{} ) -// MsgRemoveMargin +// ------------------------ MsgRemoveMargin ------------------------ func (m MsgRemoveMargin) Route() string { return "perp" } func (m MsgRemoveMargin) Type() string { return "remove_margin_msg" } @@ -55,7 +57,7 @@ func (m MsgRemoveMargin) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{signer} } -// MsgAddMargin +// ------------------------ MsgAddMargin ------------------------ func (m MsgAddMargin) Route() string { return "perp" } func (m MsgAddMargin) Type() string { return "add_margin_msg" } @@ -89,7 +91,7 @@ func (m MsgAddMargin) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{signer} } -// MsgMarketOrder +// ------------------------ MsgMarketOrder ------------------------ func (m MsgMarketOrder) Route() string { return "perp" } func (m MsgMarketOrder) Type() string { return "market_order_msg" } @@ -129,7 +131,7 @@ func (m *MsgMarketOrder) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{signer} } -// MsgMultiLiquidate +// ------------------------ MsgMultiLiquidate ------------------------ func (m MsgMultiLiquidate) Route() string { return "perp" } func (m MsgMultiLiquidate) Type() string { return "multi_liquidate_msg" } @@ -165,7 +167,7 @@ func (m *MsgMultiLiquidate) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{addr} } -// MsgClosePosition +// ------------------------ MsgClosePosition ------------------------ func (m MsgClosePosition) Route() string { return "perp" } func (m MsgClosePosition) Type() string { return "close_position_msg" } @@ -192,7 +194,7 @@ func (m MsgClosePosition) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{signer} } -// MsgSettlePosition +// ------------------------ MsgSettlePosition ------------------------ func (m MsgSettlePosition) Route() string { return "perp" } func (m MsgSettlePosition) Type() string { return "settle_position_msg" } @@ -220,7 +222,7 @@ func (m MsgSettlePosition) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{signer} } -// MsgDonateToEcosystemFund +// ------------------------ MsgDonateToEcosystemFund ------------------------ func (m MsgDonateToEcosystemFund) Route() string { return "perp" } func (m MsgDonateToEcosystemFund) Type() string { return "donate_to_ef_msg" } @@ -247,7 +249,7 @@ func (m MsgDonateToEcosystemFund) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{signer} } -// MsgPartialClose +// ------------------------ MsgPartialClose ------------------------ func (m MsgPartialClose) Route() string { return "perp" } func (m MsgPartialClose) Type() string { return "partial_close_msg" } @@ -277,10 +279,10 @@ func (m MsgPartialClose) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{signer} } -// MsgChangeCollateralDenom +// ------------------------ MsgChangeCollateralDenom ------------------------ func (m MsgChangeCollateralDenom) Route() string { return "perp" } -func (m MsgChangeCollateralDenom) Type() string { return "partial_close_msg" } +func (m MsgChangeCollateralDenom) Type() string { return "change_collateral_denom_msg" } func (m MsgChangeCollateralDenom) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(m.Sender); err != nil { @@ -304,6 +306,8 @@ func (m MsgChangeCollateralDenom) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{signer} } +// ------------------------ MsgAllocateEpochRebates ------------------------ + func (m MsgAllocateEpochRebates) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(m.Sender); err != nil { return sdkerrors.Wrapf(errors.ErrInvalidAddress, "invalid sender address (%s)", err) @@ -326,6 +330,8 @@ func (m MsgAllocateEpochRebates) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } +// ------------------------ MsgWithdrawEpochRebates ------------------------ + func (m MsgWithdrawEpochRebates) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(m.Sender); err != nil { return sdkerrors.Wrapf(errors.ErrInvalidAddress, "invalid sender address (%s)", err) @@ -347,3 +353,57 @@ func (m MsgWithdrawEpochRebates) GetSigners() []sdk.AccAddress { func (m MsgWithdrawEpochRebates) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } + +// ------------------------ MsgShiftPegMultiplier ------------------------ + +func (m MsgShiftPegMultiplier) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Sender); err != nil { + return sdkerrors.Wrapf(errors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + if err := m.Pair.Validate(); err != nil { + return err + } + if !m.NewPegMult.IsPositive() { + return fmt.Errorf("%w: got value %s", ErrNonPositivePegMultiplier, m.NewPegMult) + } + return nil +} + +func (m MsgShiftPegMultiplier) GetSigners() []sdk.AccAddress { + signer, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{signer} +} + +func (m MsgShiftPegMultiplier) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +// ------------------------ MsgShiftSwapInvariant ------------------------ + +func (m MsgShiftSwapInvariant) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Sender); err != nil { + return sdkerrors.Wrapf(errors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + if err := m.Pair.Validate(); err != nil { + return err + } + if !m.NewSwapInvariant.IsPositive() { + return fmt.Errorf("%w: got value %s", ErrNonPositiveSwapInvariant, m.NewSwapInvariant) + } + return nil +} + +func (m MsgShiftSwapInvariant) GetSigners() []sdk.AccAddress { + signer, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{signer} +} + +func (m MsgShiftSwapInvariant) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} diff --git a/x/perp/v2/types/msgs_test.go b/x/perp/v2/types/msgs_test.go index 083e5b137..ae92f4a67 100644 --- a/x/perp/v2/types/msgs_test.go +++ b/x/perp/v2/types/msgs_test.go @@ -371,6 +371,48 @@ func TestMsgValidateBasic(t *testing.T) { true, "invalid liquidation at index 0: invalid base asset", }, + // MsgShiftPegMultiplier + { + name: "MsgShiftPegMultiplier: Invalid pair", + msg: &MsgShiftPegMultiplier{ + Sender: validSender, + Pair: asset.Pair("not_a_pair"), + NewPegMult: sdk.NewDec(420), + }, + expectErr: true, + expectedError: asset.ErrInvalidTokenPair.Error(), + }, + { + name: "MsgShiftPegMultiplier: nonpositive peg multiplier", + msg: &MsgShiftPegMultiplier{ + Sender: validSender, + Pair: asset.Pair("valid:pair"), + NewPegMult: sdk.NewDec(-420), + }, + expectErr: true, + expectedError: ErrNonPositivePegMultiplier.Error(), + }, + // MsgDonateToEcosystemFund test cases + { + name: "MsgShiftSwapInvariant: Invalid pair", + msg: &MsgShiftSwapInvariant{ + Sender: validSender, + Pair: asset.Pair("not_a_pair"), + NewSwapInvariant: sdk.NewInt(420), + }, + expectErr: true, + expectedError: asset.ErrInvalidTokenPair.Error(), + }, + { + name: "MsgShiftSwapInvariant: nonpositive swap invariant", + msg: &MsgShiftSwapInvariant{ + Sender: validSender, + Pair: asset.Pair("valid:pair"), + NewSwapInvariant: sdk.NewInt(-420), + }, + expectErr: true, + expectedError: ErrNonPositiveSwapInvariant.Error(), + }, } for _, tc := range testCases { @@ -399,6 +441,8 @@ func TestMsg_GetSigners(t *testing.T) { &MsgPartialClose{Sender: validSender}, &MsgDonateToEcosystemFund{Sender: validSender}, &MsgMultiLiquidate{Sender: validSender}, + &MsgShiftPegMultiplier{Sender: validSender}, + &MsgShiftSwapInvariant{Sender: validSender}, } msgInvalidSenderList := []sdk.Msg{ &MsgAddMargin{Sender: invalidSender}, @@ -409,6 +453,8 @@ func TestMsg_GetSigners(t *testing.T) { &MsgPartialClose{Sender: invalidSender}, &MsgDonateToEcosystemFund{Sender: invalidSender}, &MsgMultiLiquidate{Sender: invalidSender}, + &MsgShiftPegMultiplier{Sender: invalidSender}, + &MsgShiftSwapInvariant{Sender: invalidSender}, } for _, msg := range msgValidSenderList { @@ -545,6 +591,14 @@ func TestMsg_GetSignBytes(t *testing.T) { name: "MsgMultiLiquidate", msg: &MsgMultiLiquidate{}, }, + { + name: "MsgShiftPegMultiplier", + msg: &MsgShiftPegMultiplier{}, + }, + { + name: "MsgShiftSwapInvariant", + msg: &MsgShiftSwapInvariant{}, + }, } for _, tc := range testCases { diff --git a/x/perp/v2/types/tx.pb.go b/x/perp/v2/types/tx.pb.go index 54ba4245b..a20200646 100644 --- a/x/perp/v2/types/tx.pb.go +++ b/x/perp/v2/types/tx.pb.go @@ -1199,6 +1199,174 @@ func (m *MsgWithdrawEpochRebatesResponse) GetWithdrawnRebates() github_com_cosmo return nil } +// ShiftPegMultiplier: gRPC tx msg for changing the peg multiplier. +// Admin-only. +type MsgShiftPegMultiplier struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Pair github_com_NibiruChain_nibiru_x_common_asset.Pair `protobuf:"bytes,2,opt,name=pair,proto3,customtype=github.com/NibiruChain/nibiru/x/common/asset.Pair" json:"pair"` + NewPegMult github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=new_peg_mult,json=newPegMult,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"new_peg_mult"` +} + +func (m *MsgShiftPegMultiplier) Reset() { *m = MsgShiftPegMultiplier{} } +func (m *MsgShiftPegMultiplier) String() string { return proto.CompactTextString(m) } +func (*MsgShiftPegMultiplier) ProtoMessage() {} +func (*MsgShiftPegMultiplier) Descriptor() ([]byte, []int) { + return fileDescriptor_b95cda40bf0a0f91, []int{21} +} +func (m *MsgShiftPegMultiplier) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgShiftPegMultiplier) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgShiftPegMultiplier.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgShiftPegMultiplier) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgShiftPegMultiplier.Merge(m, src) +} +func (m *MsgShiftPegMultiplier) XXX_Size() int { + return m.Size() +} +func (m *MsgShiftPegMultiplier) XXX_DiscardUnknown() { + xxx_messageInfo_MsgShiftPegMultiplier.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgShiftPegMultiplier proto.InternalMessageInfo + +func (m *MsgShiftPegMultiplier) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +type MsgShiftPegMultiplierResponse struct { +} + +func (m *MsgShiftPegMultiplierResponse) Reset() { *m = MsgShiftPegMultiplierResponse{} } +func (m *MsgShiftPegMultiplierResponse) String() string { return proto.CompactTextString(m) } +func (*MsgShiftPegMultiplierResponse) ProtoMessage() {} +func (*MsgShiftPegMultiplierResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b95cda40bf0a0f91, []int{22} +} +func (m *MsgShiftPegMultiplierResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgShiftPegMultiplierResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgShiftPegMultiplierResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgShiftPegMultiplierResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgShiftPegMultiplierResponse.Merge(m, src) +} +func (m *MsgShiftPegMultiplierResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgShiftPegMultiplierResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgShiftPegMultiplierResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgShiftPegMultiplierResponse proto.InternalMessageInfo + +// ShiftSwapInvariant: gRPC tx msg for changing the swap invariant. +// Admin-only. +type MsgShiftSwapInvariant struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Pair github_com_NibiruChain_nibiru_x_common_asset.Pair `protobuf:"bytes,2,opt,name=pair,proto3,customtype=github.com/NibiruChain/nibiru/x/common/asset.Pair" json:"pair"` + NewSwapInvariant github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=new_swap_invariant,json=newSwapInvariant,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"new_swap_invariant"` +} + +func (m *MsgShiftSwapInvariant) Reset() { *m = MsgShiftSwapInvariant{} } +func (m *MsgShiftSwapInvariant) String() string { return proto.CompactTextString(m) } +func (*MsgShiftSwapInvariant) ProtoMessage() {} +func (*MsgShiftSwapInvariant) Descriptor() ([]byte, []int) { + return fileDescriptor_b95cda40bf0a0f91, []int{23} +} +func (m *MsgShiftSwapInvariant) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgShiftSwapInvariant) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgShiftSwapInvariant.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgShiftSwapInvariant) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgShiftSwapInvariant.Merge(m, src) +} +func (m *MsgShiftSwapInvariant) XXX_Size() int { + return m.Size() +} +func (m *MsgShiftSwapInvariant) XXX_DiscardUnknown() { + xxx_messageInfo_MsgShiftSwapInvariant.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgShiftSwapInvariant proto.InternalMessageInfo + +func (m *MsgShiftSwapInvariant) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +type MsgShiftSwapInvariantResponse struct { +} + +func (m *MsgShiftSwapInvariantResponse) Reset() { *m = MsgShiftSwapInvariantResponse{} } +func (m *MsgShiftSwapInvariantResponse) String() string { return proto.CompactTextString(m) } +func (*MsgShiftSwapInvariantResponse) ProtoMessage() {} +func (*MsgShiftSwapInvariantResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b95cda40bf0a0f91, []int{24} +} +func (m *MsgShiftSwapInvariantResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgShiftSwapInvariantResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgShiftSwapInvariantResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgShiftSwapInvariantResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgShiftSwapInvariantResponse.Merge(m, src) +} +func (m *MsgShiftSwapInvariantResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgShiftSwapInvariantResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgShiftSwapInvariantResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgShiftSwapInvariantResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgSettlePosition)(nil), "nibiru.perp.v2.MsgSettlePosition") proto.RegisterType((*MsgRemoveMargin)(nil), "nibiru.perp.v2.MsgRemoveMargin") @@ -1223,103 +1391,115 @@ func init() { proto.RegisterType((*MsgAllocateEpochRebatesResponse)(nil), "nibiru.perp.v2.MsgAllocateEpochRebatesResponse") proto.RegisterType((*MsgWithdrawEpochRebates)(nil), "nibiru.perp.v2.MsgWithdrawEpochRebates") proto.RegisterType((*MsgWithdrawEpochRebatesResponse)(nil), "nibiru.perp.v2.MsgWithdrawEpochRebatesResponse") + proto.RegisterType((*MsgShiftPegMultiplier)(nil), "nibiru.perp.v2.MsgShiftPegMultiplier") + proto.RegisterType((*MsgShiftPegMultiplierResponse)(nil), "nibiru.perp.v2.MsgShiftPegMultiplierResponse") + proto.RegisterType((*MsgShiftSwapInvariant)(nil), "nibiru.perp.v2.MsgShiftSwapInvariant") + proto.RegisterType((*MsgShiftSwapInvariantResponse)(nil), "nibiru.perp.v2.MsgShiftSwapInvariantResponse") } func init() { proto.RegisterFile("nibiru/perp/v2/tx.proto", fileDescriptor_b95cda40bf0a0f91) } var fileDescriptor_b95cda40bf0a0f91 = []byte{ - // 1447 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x59, 0xcf, 0x6f, 0x1b, 0xc5, - 0x17, 0xf7, 0xc6, 0x6e, 0xea, 0xbc, 0xa4, 0x4e, 0xb2, 0x4d, 0x13, 0xd7, 0xdf, 0xca, 0xc9, 0x77, - 0x85, 0x4a, 0x38, 0x64, 0xb7, 0x0d, 0x48, 0x08, 0x24, 0x40, 0xf9, 0xd1, 0xa2, 0xa2, 0xba, 0x4d, - 0xb7, 0x55, 0x8b, 0x0a, 0x68, 0x3b, 0xb1, 0x27, 0x9b, 0x51, 0xd7, 0x33, 0xee, 0xce, 0xac, 0x93, - 0x94, 0x1b, 0x7f, 0x01, 0x07, 0x0e, 0x48, 0x48, 0xdc, 0xb8, 0x70, 0x40, 0xe2, 0x00, 0x5c, 0xf8, - 0x03, 0x7a, 0xec, 0x11, 0x71, 0x28, 0xd0, 0x5c, 0xb8, 0x52, 0xf1, 0x07, 0xa0, 0xd9, 0x5f, 0x5e, - 0xbb, 0x13, 0xc7, 0x09, 0x69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 0xa7, 0x9a, 0xca, 0xa7, 0x4a, 0x51, 0xe9, 0xb3, 0xdf, 0x6c, 0x33, 0x72, 0xcb, 0xef, - 0x3e, 0x7a, 0x5a, 0xd5, 0x1e, 0x3f, 0xad, 0x6a, 0xbf, 0x3e, 0xad, 0x6a, 0x9f, 0xee, 0x56, 0x73, - 0x8f, 0x77, 0xab, 0xb9, 0x9f, 0x76, 0xab, 0xb9, 0xbb, 0x0b, 0xfb, 0x9d, 0x18, 0xd3, 0x7f, 0x3a, - 0xc8, 0x21, 0xb6, 0x3e, 0x1c, 0x7e, 0xf8, 0x7f, 0xf5, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x70, - 0xcc, 0xc4, 0x19, 0x93, 0x18, 0x00, 0x00, + // 1570 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x59, 0xcd, 0x6f, 0x5b, 0xc5, + 0x16, 0xf7, 0x8d, 0xdd, 0x34, 0x39, 0x49, 0xf3, 0x71, 0x9b, 0x26, 0xae, 0x5f, 0x9f, 0x93, 0x77, + 0xf5, 0x5e, 0x5f, 0x58, 0xc4, 0x6e, 0x03, 0x12, 0x02, 0x09, 0x50, 0x3e, 0x5a, 0x54, 0x54, 0xb7, + 0xee, 0x4d, 0xd5, 0xa2, 0x52, 0x74, 0x3b, 0xb1, 0x27, 0x37, 0xa3, 0x5e, 0xcf, 0xb8, 0x77, 0xe6, + 0xda, 0x49, 0xd9, 0xf1, 0x17, 0xb0, 0x60, 0x81, 0x84, 0xc4, 0x8e, 0x0d, 0x0b, 0x24, 0x16, 0xc0, + 0x06, 0xf6, 0x5d, 0x76, 0x89, 0x10, 0x2a, 0xa8, 0xd9, 0xb0, 0xa5, 0xe2, 0x0f, 0x40, 0x73, 0xbf, + 0x7c, 0xaf, 0x3b, 0x4e, 0x1c, 0x93, 0x46, 0x02, 0xb1, 0x4a, 0xe6, 0xce, 0x99,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x5e, 0x83, 0x91, 0xba, + 0x5c, 0xd0, 0xb9, 0xdd, 0xec, 0x73, 0x38, 0x9d, 0x93, 0x16, 0x3e, 0x7b, 0x32, 0x3f, 0xb9, 0x8b, + 0x1a, 0xce, 0xeb, 0x46, 0xb4, 0xd0, 0x30, 0x63, 0x0c, 0xc3, 0x80, 0x85, 0x5e, 0x36, 0x44, 0x09, + 0x68, 0x5c, 0x0f, 0xea, 0xa9, 0x1f, 0xc8, 0x35, 0xe6, 0x38, 0x48, 0x60, 0x17, 0x39, 0xeb, 0x98, + 0xb2, 0x46, 0x4f, 0x3b, 0xff, 0x05, 0xa3, 0x14, 0xb7, 0xad, 0xba, 0x14, 0x0a, 0x4f, 0xea, 0x23, + 0x14, 0xb7, 0xfd, 0x45, 0xa1, 0x52, 0x25, 0x60, 0xac, 0xf4, 0x93, 0xe0, 0x52, 0xbf, 0xe2, 0x38, + 0xac, 0x86, 0x04, 0xbe, 0xd4, 0x64, 0xb5, 0x6d, 0x13, 0x6f, 0x22, 0x81, 0x79, 0x4f, 0xa5, 0x18, + 0x4e, 0xba, 0x81, 0x48, 0x78, 0x23, 0xdb, 0xc7, 0x37, 0x17, 0xa4, 0x6f, 0xbe, 0xf8, 0x79, 0x7e, + 0xb1, 0x8f, 0xe8, 0xc9, 0x05, 0xdc, 0x8c, 0xb0, 0x8d, 0xcf, 0x34, 0x98, 0xef, 0x61, 0x5a, 0xbc, + 0x69, 0x3f, 0x80, 0xd3, 0x82, 0x09, 0xe4, 0x58, 0x58, 0xce, 0x5a, 0x91, 0x59, 0xda, 0xd1, 0x9b, + 0x35, 0xed, 0xeb, 0x49, 0x1a, 0x61, 0x5c, 0xf1, 0x5d, 0x77, 0x9b, 0x88, 0xed, 0xba, 0x8b, 0xda, + 0x7d, 0xb9, 0x6e, 0x16, 0x86, 0x7d, 0x4b, 0x03, 0xcf, 0xe5, 0xcc, 0x70, 0x64, 0x7c, 0x1a, 0x70, + 0x55, 0x61, 0xc5, 0x5c, 0x77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+ 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1342,9 +1522,17 @@ type MsgClient interface { PartialClose(ctx context.Context, in *MsgPartialClose, opts ...grpc.CallOption) (*MsgPartialCloseResponse, error) SettlePosition(ctx context.Context, in *MsgSettlePosition, opts ...grpc.CallOption) (*MsgClosePositionResponse, error) DonateToEcosystemFund(ctx context.Context, in *MsgDonateToEcosystemFund, opts ...grpc.CallOption) (*MsgDonateToEcosystemFundResponse, error) + // ChangeCollateralDenom: Updates the collateral denom. A denom is valid if it + // is possible to make an sdk.Coin using it. [Admin] Only callable by sudoers. ChangeCollateralDenom(ctx context.Context, in *MsgChangeCollateralDenom, opts ...grpc.CallOption) (*MsgChangeCollateralDenomResponse, error) AllocateEpochRebates(ctx context.Context, in *MsgAllocateEpochRebates, opts ...grpc.CallOption) (*MsgAllocateEpochRebatesResponse, error) WithdrawEpochRebates(ctx context.Context, in *MsgWithdrawEpochRebates, opts ...grpc.CallOption) (*MsgWithdrawEpochRebatesResponse, error) + // ShiftPegMultiplier: gRPC tx msg for changing a market's peg multiplier. + // [Admin] Only callable by sudoers. + ShiftPegMultiplier(ctx context.Context, in *MsgShiftPegMultiplier, opts ...grpc.CallOption) (*MsgShiftPegMultiplierResponse, error) + // ShiftSwapInvariant: gRPC tx msg for changing a market's swap invariant. + // [Admin] Only callable by sudoers. + ShiftSwapInvariant(ctx context.Context, in *MsgShiftSwapInvariant, opts ...grpc.CallOption) (*MsgShiftSwapInvariantResponse, error) } type msgClient struct { @@ -1454,6 +1642,24 @@ func (c *msgClient) WithdrawEpochRebates(ctx context.Context, in *MsgWithdrawEpo return out, nil } +func (c *msgClient) ShiftPegMultiplier(ctx context.Context, in *MsgShiftPegMultiplier, opts ...grpc.CallOption) (*MsgShiftPegMultiplierResponse, error) { + out := new(MsgShiftPegMultiplierResponse) + err := c.cc.Invoke(ctx, "/nibiru.perp.v2.Msg/ShiftPegMultiplier", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) ShiftSwapInvariant(ctx context.Context, in *MsgShiftSwapInvariant, opts ...grpc.CallOption) (*MsgShiftSwapInvariantResponse, error) { + out := new(MsgShiftSwapInvariantResponse) + err := c.cc.Invoke(ctx, "/nibiru.perp.v2.Msg/ShiftSwapInvariant", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { RemoveMargin(context.Context, *MsgRemoveMargin) (*MsgRemoveMarginResponse, error) @@ -1464,9 +1670,17 @@ type MsgServer interface { PartialClose(context.Context, *MsgPartialClose) (*MsgPartialCloseResponse, error) SettlePosition(context.Context, *MsgSettlePosition) (*MsgClosePositionResponse, error) DonateToEcosystemFund(context.Context, *MsgDonateToEcosystemFund) (*MsgDonateToEcosystemFundResponse, error) + // ChangeCollateralDenom: Updates the collateral denom. A denom is valid if it + // is possible to make an sdk.Coin using it. [Admin] Only callable by sudoers. ChangeCollateralDenom(context.Context, *MsgChangeCollateralDenom) (*MsgChangeCollateralDenomResponse, error) AllocateEpochRebates(context.Context, *MsgAllocateEpochRebates) (*MsgAllocateEpochRebatesResponse, error) WithdrawEpochRebates(context.Context, *MsgWithdrawEpochRebates) (*MsgWithdrawEpochRebatesResponse, error) + // ShiftPegMultiplier: gRPC tx msg for changing a market's peg multiplier. + // [Admin] Only callable by sudoers. + ShiftPegMultiplier(context.Context, *MsgShiftPegMultiplier) (*MsgShiftPegMultiplierResponse, error) + // ShiftSwapInvariant: gRPC tx msg for changing a market's swap invariant. + // [Admin] Only callable by sudoers. + ShiftSwapInvariant(context.Context, *MsgShiftSwapInvariant) (*MsgShiftSwapInvariantResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -1506,6 +1720,12 @@ func (*UnimplementedMsgServer) AllocateEpochRebates(ctx context.Context, req *Ms func (*UnimplementedMsgServer) WithdrawEpochRebates(ctx context.Context, req *MsgWithdrawEpochRebates) (*MsgWithdrawEpochRebatesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method WithdrawEpochRebates not implemented") } +func (*UnimplementedMsgServer) ShiftPegMultiplier(ctx context.Context, req *MsgShiftPegMultiplier) (*MsgShiftPegMultiplierResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ShiftPegMultiplier not implemented") +} +func (*UnimplementedMsgServer) ShiftSwapInvariant(ctx context.Context, req *MsgShiftSwapInvariant) (*MsgShiftSwapInvariantResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ShiftSwapInvariant not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -1709,6 +1929,42 @@ func _Msg_WithdrawEpochRebates_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Msg_ShiftPegMultiplier_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgShiftPegMultiplier) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ShiftPegMultiplier(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/nibiru.perp.v2.Msg/ShiftPegMultiplier", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ShiftPegMultiplier(ctx, req.(*MsgShiftPegMultiplier)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_ShiftSwapInvariant_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgShiftSwapInvariant) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ShiftSwapInvariant(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/nibiru.perp.v2.Msg/ShiftSwapInvariant", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ShiftSwapInvariant(ctx, req.(*MsgShiftSwapInvariant)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "nibiru.perp.v2.Msg", HandlerType: (*MsgServer)(nil), @@ -1757,6 +2013,14 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "WithdrawEpochRebates", Handler: _Msg_WithdrawEpochRebates_Handler, }, + { + MethodName: "ShiftPegMultiplier", + Handler: _Msg_ShiftPegMultiplier_Handler, + }, + { + MethodName: "ShiftSwapInvariant", + Handler: _Msg_ShiftSwapInvariant_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "nibiru/perp/v2/tx.proto", @@ -2914,76 +3178,222 @@ func (m *MsgWithdrawEpochRebatesResponse) MarshalToSizedBuffer(dAtA []byte) (int return len(dAtA) - i, nil } -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *MsgShiftPegMultiplier) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *MsgSettlePosition) Size() (n int) { - if m == nil { - return 0 - } + +func (m *MsgShiftPegMultiplier) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgShiftPegMultiplier) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + { + size := m.NewPegMult.Size() + i -= size + if _, err := m.NewPegMult.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) } - l = m.Pair.Size() - n += 1 + l + sovTx(uint64(l)) - if m.Version != 0 { - n += 1 + sovTx(uint64(m.Version)) + i-- + dAtA[i] = 0x1a + { + size := m.Pair.Size() + i -= size + if _, err := m.Pair.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) } - return n + i-- + dAtA[i] = 0x12 + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (m *MsgRemoveMargin) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) +func (m *MsgShiftPegMultiplierResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - l = m.Pair.Size() - n += 1 + l + sovTx(uint64(l)) - l = m.Margin.Size() - n += 1 + l + sovTx(uint64(l)) - return n + return dAtA[:n], nil } -func (m *MsgRemoveMarginResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *MsgShiftPegMultiplierResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgShiftPegMultiplierResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = m.MarginOut.Size() - n += 1 + l + sovTx(uint64(l)) - l = m.FundingPayment.Size() - n += 1 + l + sovTx(uint64(l)) - if m.Position != nil { - l = m.Position.Size() - n += 1 + l + sovTx(uint64(l)) - } - return n + return len(dAtA) - i, nil } -func (m *MsgAddMargin) Size() (n int) { - if m == nil { - return 0 +func (m *MsgShiftSwapInvariant) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } + return dAtA[:n], nil +} + +func (m *MsgShiftSwapInvariant) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgShiftSwapInvariant) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Sender) + { + size := m.NewSwapInvariant.Size() + i -= size + if _, err := m.NewSwapInvariant.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.Pair.Size() + i -= size + if _, err := m.Pair.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgShiftSwapInvariantResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgShiftSwapInvariantResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgShiftSwapInvariantResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgSettlePosition) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Pair.Size() + n += 1 + l + sovTx(uint64(l)) + if m.Version != 0 { + n += 1 + sovTx(uint64(m.Version)) + } + return n +} + +func (m *MsgRemoveMargin) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Pair.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.Margin.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgRemoveMarginResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.MarginOut.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.FundingPayment.Size() + n += 1 + l + sovTx(uint64(l)) + if m.Position != nil { + l = m.Position.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgAddMargin) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -3328,6 +3738,58 @@ func (m *MsgWithdrawEpochRebatesResponse) Size() (n int) { return n } +func (m *MsgShiftPegMultiplier) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Pair.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.NewPegMult.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgShiftPegMultiplierResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgShiftSwapInvariant) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Pair.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.NewSwapInvariant.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgShiftSwapInvariantResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -6634,6 +7096,406 @@ func (m *MsgWithdrawEpochRebatesResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgShiftPegMultiplier) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgShiftPegMultiplier: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgShiftPegMultiplier: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pair", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Pair.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewPegMult", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NewPegMult.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgShiftPegMultiplierResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgShiftPegMultiplierResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgShiftPegMultiplierResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgShiftSwapInvariant) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgShiftSwapInvariant: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgShiftSwapInvariant: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pair", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Pair.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewSwapInvariant", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NewSwapInvariant.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgShiftSwapInvariantResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgShiftSwapInvariantResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgShiftSwapInvariantResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/spot/genesis_test.go b/x/spot/genesis_test.go index 1cd5207e8..837d4de0a 100644 --- a/x/spot/genesis_test.go +++ b/x/spot/genesis_test.go @@ -13,6 +13,7 @@ import ( ) func TestGenesis(t *testing.T) { + testapp.EnsureNibiruPrefix() genesisState := types.GenesisState{ Params: types.DefaultParams(), Pools: []types.Pool{ diff --git a/x/spot/keeper/balances_test.go b/x/spot/keeper/balances_test.go index c7df38110..053da1e86 100644 --- a/x/spot/keeper/balances_test.go +++ b/x/spot/keeper/balances_test.go @@ -52,6 +52,7 @@ func TestCheckBalances(t *testing.T) { for _, tc := range tests { tc := tc t.Run(tc.name, func(t *testing.T) { + testapp.EnsureNibiruPrefix() app, ctx := testapp.NewNibiruTestAppAndContext() // fund user account diff --git a/x/sudo/keeper/keeper.go b/x/sudo/keeper/keeper.go index f28a9169d..7dc623058 100644 --- a/x/sudo/keeper/keeper.go +++ b/x/sudo/keeper/keeper.go @@ -141,8 +141,8 @@ func (k Keeper) CheckPermissions( hasPermission := set.New(contracts...).Has(contract.String()) || contract.String() == state.Root if !hasPermission { return fmt.Errorf( - "insufficient permissions on smart contract: %s. The sudo contracts are: %s", - contract, contracts, + "%w: insufficient permissions on smart contract: %s. The sudo contracts are: %s", + sudotypes.ErrUnauthorized, contract, contracts, ) } return nil