From b4175f1eacffe99ab0294d35296c7e6fa5fdcc0f Mon Sep 17 00:00:00 2001 From: Jonathan Gimeno Date: Tue, 2 Jan 2024 15:08:04 +0100 Subject: [PATCH] feat(perp): move close market from Wasm Binding to MsgCloseMarket as part of #1642 (#1749) * remove mentions of bindings for closing the market. * create new message for Closing a Market * temp commit * add permissions to call the CloseMarket * make lint * it fails when closing market with other user * update changelog --- CHANGELOG.md | 2 + proto/nibiru/perp/v2/tx.proto | 20 + wasmbinding/bindings/msg.go | 7 - wasmbinding/exec_perp.go | 21 - wasmbinding/exec_perp_test.go | 31 -- wasmbinding/exec_test.go | 44 -- wasmbinding/message_plugin.go | 9 - x/perp/v2/integration/action/settlement.go | 18 +- x/perp/v2/keeper/clearing_house_test.go | 5 +- x/perp/v2/keeper/hooks_test.go | 11 +- x/perp/v2/keeper/msg_server.go | 7 + x/perp/v2/keeper/msg_server_test.go | 5 +- x/perp/v2/keeper/settlement_test.go | 13 +- x/perp/v2/keeper/sudo.go | 13 +- x/perp/v2/keeper/sudo_test.go | 36 +- x/perp/v2/types/msgs.go | 22 + x/perp/v2/types/tx.pb.go | 589 +++++++++++++++++---- 17 files changed, 608 insertions(+), 245 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d526c8e9..7dcee358d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#1718](https://github.com/NibiruChain/nibiru/pull/1718) - fix: fees does not require additional funds * [#1734](https://github.com/NibiruChain/nibiru/pull/1734) - feat(perp): MsgDonateToPerpFund sudo call as part of #1642 * [#1755](https://github.com/NibiruChain/nibiru/pull/1755) - feat(oracle): Add more events on validator's performance +* [#1749](https://github.com/NibiruChain/nibiru/pull/1749) - feat(perp): move close market from Wasm Binding to MsgCloseMarket + ### Non-breaking/Compatible Improvements diff --git a/proto/nibiru/perp/v2/tx.proto b/proto/nibiru/perp/v2/tx.proto index faae01c34..4a8e22893 100644 --- a/proto/nibiru/perp/v2/tx.proto +++ b/proto/nibiru/perp/v2/tx.proto @@ -54,8 +54,13 @@ service Msg { // account. [SUDO] Only callable by sudoers. rpc WithdrawFromPerpFund(MsgWithdrawFromPerpFund) returns (MsgWithdrawFromPerpFundResponse) {} + + // CloseMarket: gRPC tx msg for closing a market. + // [Admin] Only callable by sudoers. + rpc CloseMarket(MsgCloseMarket) returns (MsgCloseMarketResponse) {} } + // -------------------------- Settle Position -------------------------- /* MsgSettlePosition: Msg to remove margin. */ @@ -451,3 +456,18 @@ message MsgWithdrawFromPerpFund { } message MsgWithdrawFromPerpFundResponse {} + +// -------------------------- CloseMarket -------------------------- + +// CloseMarket: gRPC tx msg for closing a market. +// Admin-only. +message MsgCloseMarket { + string sender = 1; + string pair = 2 [ + (gogoproto.customtype) = + "github.com/NibiruChain/nibiru/x/common/asset.Pair", + (gogoproto.nullable) = false + ]; +} + +message MsgCloseMarketResponse {} diff --git a/wasmbinding/bindings/msg.go b/wasmbinding/bindings/msg.go index 40f20cfc8..bbef598d1 100644 --- a/wasmbinding/bindings/msg.go +++ b/wasmbinding/bindings/msg.go @@ -14,8 +14,6 @@ import ( type NibiruMsg struct { // bindings-perp ExecuteMsg enum types // MultiLiquidate *MultiLiquidate `json:"multi_liquidate,omitempty"` // TODO - SetMarketEnabled *SetMarketEnabled `json:"set_market_enabled,omitempty"` - EditOracleParams *EditOracleParams `json:"edit_oracle_params,omitempty"` // Short for "no operation". A wasm binding payload that does nothing. @@ -35,11 +33,6 @@ type EditOracleParams struct { ValidatorFeeRatio *sdk.Dec `json:"validator_fee_ratio,omitempty"` } -type SetMarketEnabled struct { - Pair string `json:"pair"` - Enabled bool `json:"enabled"` -} - type MarketParams struct { Pair string Enabled bool `json:"enabled,omitempty"` diff --git a/wasmbinding/exec_perp.go b/wasmbinding/exec_perp.go index 5f5aca1b0..da485fda1 100644 --- a/wasmbinding/exec_perp.go +++ b/wasmbinding/exec_perp.go @@ -1,11 +1,6 @@ package wasmbinding import ( - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/NibiruChain/nibiru/wasmbinding/bindings" - "github.com/NibiruChain/nibiru/x/common/asset" perpv2keeper "github.com/NibiruChain/nibiru/x/perp/v2/keeper" perpv2types "github.com/NibiruChain/nibiru/x/perp/v2/types" ) @@ -17,19 +12,3 @@ type ExecutorPerp struct { func (exec *ExecutorPerp) MsgServer() perpv2types.MsgServer { return perpv2keeper.NewMsgServerImpl(exec.PerpV2) } - -// TODO: rename to CloseMarket -func (exec *ExecutorPerp) SetMarketEnabled( - cwMsg *bindings.SetMarketEnabled, 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.Sudo().CloseMarket(ctx, pair) -} diff --git a/wasmbinding/exec_perp_test.go b/wasmbinding/exec_perp_test.go index d1f373225..5848cde59 100644 --- a/wasmbinding/exec_perp_test.go +++ b/wasmbinding/exec_perp_test.go @@ -11,7 +11,6 @@ import ( "github.com/NibiruChain/nibiru/app" "github.com/NibiruChain/nibiru/wasmbinding" - "github.com/NibiruChain/nibiru/wasmbinding/bindings" "github.com/NibiruChain/nibiru/wasmbinding/wasmbin" "github.com/NibiruChain/nibiru/x/common/asset" "github.com/NibiruChain/nibiru/x/common/denoms" @@ -130,33 +129,3 @@ func (s *TestSuitePerpExecutor) OnSetupEnd() { s.contractPerp = ContractMap[wasmbin.WasmKeyPerpBinding] s.ratesMap = SetExchangeRates(&s.Suite, s.nibiru, s.ctx) } - -func (s *TestSuitePerpExecutor) DoSetMarketEnabledTest( - pair asset.Pair, enabled bool, -) error { - cwMsg := &bindings.SetMarketEnabled{ - Pair: pair.String(), - Enabled: enabled, - } - err := s.exec.SetMarketEnabled(cwMsg, s.ctx) - if err != nil { - return err - } - - market, err := s.nibiru.PerpKeeperV2.GetMarket(s.ctx, pair) - s.NoError(err) - s.Equal(enabled, market.Enabled) - return err -} - -func (s *TestSuitePerpExecutor) TestSadPaths_InvalidPair() { - sadPair := asset.Pair("ftt:ust:doge") - pair := sadPair - - for _, err := range []error{ - s.DoSetMarketEnabledTest(pair, true), - s.DoSetMarketEnabledTest(pair, false), - } { - s.Error(err) - } -} diff --git a/wasmbinding/exec_test.go b/wasmbinding/exec_test.go index 019a7aa21..cecf66007 100644 --- a/wasmbinding/exec_test.go +++ b/wasmbinding/exec_test.go @@ -16,7 +16,6 @@ import ( "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/testapp" "github.com/NibiruChain/nibiru/x/oracle/types" perpv2types "github.com/NibiruChain/nibiru/x/perp/v2/types" @@ -312,46 +311,3 @@ func (s *TestSuiteExecutor) TestNoOp() { contractRespBz, err := s.ExecuteAgainstContract(contract, execMsg) s.NoErrorf(err, "contractRespBz: %s", contractRespBz) } - -func (s *TestSuiteExecutor) TestSetMarketEnabled() { - // admin := s.contractDeployer.String() - perpv2Genesis := genesis.PerpV2Genesis() - contract := s.contractController - var execMsg bindings.NibiruMsg - - for testIdx, market := range perpv2Genesis.Markets { - execMsg = bindings.NibiruMsg{ - SetMarketEnabled: &bindings.SetMarketEnabled{ - Pair: market.Pair.String(), - Enabled: !market.Enabled, - }, - } - - s.T().Logf("Execute - happy %v: market: %s", testIdx, market.Pair) - s.keeper.SetSudoContracts( - []string{contract.String()}, s.ctx, - ) - contractRespBz, err := s.ExecuteAgainstContract(contract, execMsg) - s.NoErrorf(err, "contractRespBz: %s", contractRespBz) - - marketAfter, err := s.nibiru.PerpKeeperV2.GetMarket(s.ctx, market.Pair) - s.NoError(err) - s.Equal(!market.Enabled, marketAfter.Enabled) - } - - 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") -} diff --git a/wasmbinding/message_plugin.go b/wasmbinding/message_plugin.go index 2bf63e8f0..05e9c1162 100644 --- a/wasmbinding/message_plugin.go +++ b/wasmbinding/message_plugin.go @@ -62,15 +62,6 @@ func (messenger *CustomMessenger) DispatchMsg( } switch { - // Perp module | controller - case contractExecuteMsg.ExecuteMsg.SetMarketEnabled != nil: - if err := messenger.Sudo.CheckPermissions(contractAddr, ctx); err != nil { - return events, data, err - } - cwMsg := contractExecuteMsg.ExecuteMsg.SetMarketEnabled - err = messenger.Perp.SetMarketEnabled(cwMsg, ctx) - return events, data, err - // Oracle module case contractExecuteMsg.ExecuteMsg.EditOracleParams != nil: if err := messenger.Sudo.CheckPermissions(contractAddr, ctx); err != nil { diff --git a/x/perp/v2/integration/action/settlement.go b/x/perp/v2/integration/action/settlement.go index 1719d581a..712ce2a87 100644 --- a/x/perp/v2/integration/action/settlement.go +++ b/x/perp/v2/integration/action/settlement.go @@ -13,11 +13,12 @@ import ( // closeMarket type closeMarket struct { - pair asset.Pair + pair asset.Pair + sender sdk.AccAddress } func (c closeMarket) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) { - err := app.PerpKeeperV2.Sudo().CloseMarket(ctx, c.pair) + err := app.PerpKeeperV2.Sudo().CloseMarket(ctx, c.pair, c.sender) if err != nil { return ctx, err } @@ -25,17 +26,18 @@ func (c closeMarket) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error return ctx, nil } -func CloseMarket(pair asset.Pair) action.Action { - return closeMarket{pair: pair} +func CloseMarket(pair asset.Pair, adminAccount sdk.AccAddress) action.Action { + return closeMarket{pair: pair, sender: adminAccount} } // closeMarketShouldFail type closeMarketShouldFail struct { - pair asset.Pair + pair asset.Pair + sender sdk.AccAddress } func (c closeMarketShouldFail) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) { - err := app.PerpKeeperV2.Sudo().CloseMarket(ctx, c.pair) + err := app.PerpKeeperV2.Sudo().CloseMarket(ctx, c.pair, c.sender) if err == nil { return ctx, err } @@ -43,8 +45,8 @@ func (c closeMarketShouldFail) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Cont return ctx, nil } -func CloseMarketShouldFail(pair asset.Pair) action.Action { - return closeMarketShouldFail{pair: pair} +func CloseMarketShouldFail(pair asset.Pair, adminAccount sdk.AccAddress) action.Action { + return closeMarketShouldFail{pair: pair, sender: adminAccount} } // settlePosition diff --git a/x/perp/v2/keeper/clearing_house_test.go b/x/perp/v2/keeper/clearing_house_test.go index a8f4c8021..834970762 100644 --- a/x/perp/v2/keeper/clearing_house_test.go +++ b/x/perp/v2/keeper/clearing_house_test.go @@ -29,6 +29,9 @@ func TestMarketOrder(t *testing.T) { pairBtcNusd := asset.Registry.Pair(denoms.BTC, denoms.NUSD) startBlockTime := time.Now() + adminUser, err := sdk.AccAddressFromBech32(testutil.ADDR_SUDO_ROOT) + require.NoError(t, err) + tc := TestCases{ TC("open big short position and then close after reducing swap invariant"). Given( @@ -885,7 +888,7 @@ func TestMarketOrder(t *testing.T) { SetBlockTime(startBlockTime), SetBlockNumber(1), FundAccount(alice, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(47_714_285_715)))), - CloseMarket(pairBtcNusd), + CloseMarket(pairBtcNusd, adminUser), ). When( MarketOrderFails(alice, pairBtcNusd, types.Direction_SHORT, sdk.NewInt(47_619_047_619), sdk.OneDec(), sdk.ZeroDec(), diff --git a/x/perp/v2/keeper/hooks_test.go b/x/perp/v2/keeper/hooks_test.go index 24d4c996a..6a7bcde5f 100644 --- a/x/perp/v2/keeper/hooks_test.go +++ b/x/perp/v2/keeper/hooks_test.go @@ -4,6 +4,10 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + + "github.com/NibiruChain/nibiru/x/common/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/NibiruChain/nibiru/x/common/asset" @@ -21,6 +25,9 @@ func TestAfterEpochEnd(t *testing.T) { pairBtcUsdc := asset.Registry.Pair(denoms.BTC, denoms.USDC) startTime := time.Now() + adminUser, err := sdk.AccAddressFromBech32(testutil.ADDR_SUDO_ROOT) + require.NoError(t, err) + tc := TestCases{ TC("index > mark"). Given( @@ -122,7 +129,7 @@ func TestAfterEpochEnd(t *testing.T) { TC("market closed"). Given( CreateCustomMarket(pairBtcUsdc, WithEnabled(true)), - CloseMarket(pairBtcUsdc), + CloseMarket(pairBtcUsdc, adminUser), SetBlockTime(startTime), StartEpoch(epochtypes.ThirtyMinuteEpochID), InsertOraclePriceSnapshot(pairBtcUsd, startTime.Add(15*time.Minute), sdk.NewDec(2)), @@ -137,7 +144,7 @@ func TestAfterEpochEnd(t *testing.T) { TC("not correct epoch id"). Given( CreateCustomMarket(pairBtcUsdc, WithEnabled(true)), - CloseMarket(pairBtcUsdc), + CloseMarket(pairBtcUsdc, adminUser), SetBlockTime(startTime), StartEpoch(epochtypes.DayEpochID), InsertOraclePriceSnapshot(pairBtcUsd, startTime.Add(15*time.Minute), sdk.NewDec(2)), diff --git a/x/perp/v2/keeper/msg_server.go b/x/perp/v2/keeper/msg_server.go index 6db05ede6..38586f68b 100644 --- a/x/perp/v2/keeper/msg_server.go +++ b/x/perp/v2/keeper/msg_server.go @@ -232,3 +232,10 @@ func (m msgServer) WithdrawFromPerpFund( ctx, msg.Amount, sender, toAddr, msg.Denom, ) } + +// CloseMarket closes a market. +func (m msgServer) CloseMarket(ctx context.Context, msg *types.MsgCloseMarket) (*types.MsgCloseMarketResponse, error) { + sender, _ := sdk.AccAddressFromBech32(msg.Sender) + err := m.k.Sudo().CloseMarket(sdk.UnwrapSDKContext(ctx), msg.Pair, sender) + return &types.MsgCloseMarketResponse{}, err +} diff --git a/x/perp/v2/keeper/msg_server_test.go b/x/perp/v2/keeper/msg_server_test.go index 736206169..ea7269dd2 100644 --- a/x/perp/v2/keeper/msg_server_test.go +++ b/x/perp/v2/keeper/msg_server_test.go @@ -408,6 +408,9 @@ func TestMsgServerSettlePosition(t *testing.T) { pair := asset.Registry.Pair(denoms.BTC, denoms.NUSD) alice := testutil.AccAddress() + adminUser, err := sdk.AccAddressFromBech32(testutil.ADDR_SUDO_ROOT) + require.NoError(t, err) + tests := TestCases{ TC("Settleposition"). Given( @@ -415,7 +418,7 @@ func TestMsgServerSettlePosition(t *testing.T) { FundAccount(alice, sdk.NewCoins(sdk.NewInt64Coin(types.TestingCollateralDenomNUSD, 100))), MarketOrder(alice, pair, types.Direction_LONG, sdk.OneInt(), sdk.OneDec(), sdk.ZeroDec()), MoveToNextBlock(), - CloseMarket(pair), + CloseMarket(pair, adminUser), ). When( MsgServerSettlePosition(alice, pair, 1), diff --git a/x/perp/v2/keeper/settlement_test.go b/x/perp/v2/keeper/settlement_test.go index c1368f986..d80faaa0d 100644 --- a/x/perp/v2/keeper/settlement_test.go +++ b/x/perp/v2/keeper/settlement_test.go @@ -4,6 +4,8 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/NibiruChain/nibiru/x/common/asset" @@ -23,6 +25,9 @@ func TestSettlePosition(t *testing.T) { alice := testutil.AccAddress() bob := testutil.AccAddress() + adminUser, err := sdk.AccAddressFromBech32(testutil.ADDR_SUDO_ROOT) + require.NoError(t, err) + tc := TestCases{ TC("Happy path").When( CreateCustomMarket( @@ -43,7 +48,7 @@ func TestSettlePosition(t *testing.T) { sdk.ZeroDec(), ), ).When( - CloseMarket(pairBtcUsdc), + CloseMarket(pairBtcUsdc, adminUser), SettlePosition(pairBtcUsdc, 1, alice), ).Then( PositionShouldNotExist(alice, pairBtcUsdc, 1), @@ -84,7 +89,7 @@ func TestSettlePosition(t *testing.T) { // Her Realized Pnl is -101.01010101 and her margin is 100, so -1.01010101 is bad debt // Bob's Realized Pnl is 1010, so he has 1010 more than his margin - CloseMarket(pairBtcUsdc), + CloseMarket(pairBtcUsdc, adminUser), SettlePosition( pairBtcUsdc, 1, @@ -160,7 +165,7 @@ func TestSettlePosition(t *testing.T) { sdk.ZeroDec(), ), ).When( - CloseMarket(pairBtcUsdc), + CloseMarket(pairBtcUsdc, adminUser), CreateCustomMarket( pairBtcUsdc, WithPricePeg(sdk.OneDec()), @@ -206,7 +211,7 @@ func TestSettlePosition(t *testing.T) { sdk.ZeroDec(), ), ).When( - CloseMarket(pairBtcUsdc), + CloseMarket(pairBtcUsdc, adminUser), CreateCustomMarket( pairBtcUsdc, WithPricePeg(sdk.OneDec()), diff --git a/x/perp/v2/keeper/sudo.go b/x/perp/v2/keeper/sudo.go index 0da898072..bd3636fcf 100644 --- a/x/perp/v2/keeper/sudo.go +++ b/x/perp/v2/keeper/sudo.go @@ -129,7 +129,10 @@ func (k sudoExtension) CreateMarket( // CloseMarket closes the market. From now on, no new position can be opened on // this market or closed. Only the open positions can be settled by calling // SettlePosition. -func (k sudoExtension) CloseMarket(ctx sdk.Context, pair asset.Pair) (err error) { +func (k sudoExtension) CloseMarket(ctx sdk.Context, pair asset.Pair, sender sdk.AccAddress) (err error) { + if err := k.SudoKeeper.CheckPermissions(sender, ctx); err != nil { + return err + } market, err := k.GetMarket(ctx, pair) if err != nil { return err @@ -157,7 +160,7 @@ func (k sudoExtension) CloseMarket(ctx sdk.Context, pair asset.Pair) (err error) return nil } -// ChangeCollateralDenom: Updates the collateral denom. A denom is valid if it is +// ChangeCollateralDenom Updates the collateral denom. A denom is valid if it is // possible to make an sdk.Coin using it. [SUDO] Only callable by sudoers. func (k sudoExtension) ChangeCollateralDenom( ctx sdk.Context, @@ -170,7 +173,7 @@ func (k sudoExtension) ChangeCollateralDenom( return k.UnsafeChangeCollateralDenom(ctx, denom) } -// UnsafeChangeCollateralDenom: Used in the genesis to set the collateral +// UnsafeChangeCollateralDenom Used in the genesis to set the collateral // without requiring an explicit call from sudoers. func (k sudoExtension) UnsafeChangeCollateralDenom( ctx sdk.Context, @@ -183,7 +186,7 @@ func (k sudoExtension) UnsafeChangeCollateralDenom( return nil } -// ShiftPegMultiplier: Edit the peg multiplier of an amm pool after making sure +// 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 sudoExtension) ShiftPegMultiplier( @@ -229,7 +232,7 @@ func (k sudoExtension) ShiftPegMultiplier( }) } -// ShiftSwapInvariant: Edit the swap invariant (liquidity depth) of an amm pool, +// 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 sudoExtension) ShiftSwapInvariant( diff --git a/x/perp/v2/keeper/sudo_test.go b/x/perp/v2/keeper/sudo_test.go index 9fdd4db63..6752e016c 100644 --- a/x/perp/v2/keeper/sudo_test.go +++ b/x/perp/v2/keeper/sudo_test.go @@ -93,9 +93,12 @@ func TestCreateMarket(t *testing.T) { app, ctx := testapp.NewNibiruTestAppAndContext() admin := app.PerpKeeperV2.Sudo() + adminUser, err := sdk.AccAddressFromBech32(testutil.ADDR_SUDO_ROOT) + require.NoError(t, err) + // Error because of invalid market market := perptypes.DefaultMarket(pair).WithMaintenanceMarginRatio(sdk.NewDec(2)) - err := admin.CreateMarket(ctx, keeper.ArgsCreateMarket{ + err = admin.CreateMarket(ctx, keeper.ArgsCreateMarket{ Pair: pair, PriceMultiplier: amm.PriceMultiplier, SqrtDepth: amm.SqrtDepth, @@ -152,7 +155,7 @@ func TestCreateMarket(t *testing.T) { require.ErrorContains(t, err, "already exists") // Close the market to test that we can create it again but with an increased version - err = admin.CloseMarket(ctx, pair) + err = admin.CloseMarket(ctx, pair, adminUser) require.NoError(t, err) err = admin.CreateMarket(ctx, keeper.ArgsCreateMarket{ @@ -181,6 +184,9 @@ func TestCloseMarket(t *testing.T) { startTime := time.Now() alice := testutil.AccAddress() + adminAccount, err := sdk.AccAddressFromBech32(testutil.ADDR_SUDO_ROOT) + require.NoError(t, err) + tc := TestCases{ TC("market can be disabled"). Given( @@ -192,7 +198,7 @@ func TestCloseMarket(t *testing.T) { ), ). When( - CloseMarket(pairBtcUsdc), + CloseMarket(pairBtcUsdc, adminAccount), ). Then( MarketShouldBeEqual( @@ -214,7 +220,7 @@ func TestCloseMarket(t *testing.T) { FundAccount(alice, sdk.NewCoins(sdk.NewCoin(perptypes.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( - CloseMarket(pairBtcUsdc), + CloseMarket(pairBtcUsdc, adminAccount), ). Then( MarketOrderFails( @@ -246,9 +252,9 @@ func TestCloseMarket(t *testing.T) { sdk.ZeroDec(), ), ).When( - CloseMarket(pairBtcUsdc), - CloseMarketShouldFail(pairBtcUsdc), - CloseMarketShouldFail("random:pair"), + CloseMarket(pairBtcUsdc, adminAccount), + CloseMarketShouldFail(pairBtcUsdc, adminAccount), + CloseMarketShouldFail("random:pair", adminAccount), ).Then( ClosePositionFails(alice, pairBtcUsdc, perptypes.ErrMarketNotEnabled), ), @@ -271,11 +277,25 @@ func TestCloseMarket(t *testing.T) { sdk.ZeroDec(), ), ).When( - CloseMarket(pairBtcUsdc), + CloseMarket(pairBtcUsdc, adminAccount), AMMShouldBeEqual(pairBtcUsdc, AMM_SettlementPriceShoulBeEqual(sdk.MustNewDecFromStr("1.099800000000000000"))), ).Then( PartialCloseFails(alice, pairBtcUsdc, sdk.NewDec(5_000), perptypes.ErrMarketNotEnabled), ), + TC("it fails when a non-admin tries to close a market"). + Given( + CreateCustomMarket(pairBtcUsdc, WithEnabled(true)), + SetBlockTime(startTime), + ). + When( + CloseMarketShouldFail(pairBtcUsdc, alice), + ). + Then( + MarketShouldBeEqual( + pairBtcUsdc, + Market_EnableShouldBeEqualTo(true), + ), + ), } NewTestSuite(t).WithTestCases(tc...).Run() diff --git a/x/perp/v2/types/msgs.go b/x/perp/v2/types/msgs.go index d8173d516..c58d88218 100644 --- a/x/perp/v2/types/msgs.go +++ b/x/perp/v2/types/msgs.go @@ -409,6 +409,28 @@ func (m MsgShiftSwapInvariant) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } +// ------------------------ MsgCloseMarket ------------------------ + +func (m MsgCloseMarket) 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 + } + return nil +} + +func (m MsgCloseMarket) GetSigners() []sdk.AccAddress { + signer, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + + return []sdk.AccAddress{signer} +} + // ------------------------ MsgWithdrawFromPerpFund ------------------------ func (m MsgWithdrawFromPerpFund) ValidateBasic() error { diff --git a/x/perp/v2/types/tx.pb.go b/x/perp/v2/types/tx.pb.go index 9b488a81b..1a57294d4 100644 --- a/x/perp/v2/types/tx.pb.go +++ b/x/perp/v2/types/tx.pb.go @@ -1467,6 +1467,89 @@ func (m *MsgWithdrawFromPerpFundResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgWithdrawFromPerpFundResponse proto.InternalMessageInfo +// CloseMarket: gRPC tx msg for closing a market. +// Admin-only. +type MsgCloseMarket 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"` +} + +func (m *MsgCloseMarket) Reset() { *m = MsgCloseMarket{} } +func (m *MsgCloseMarket) String() string { return proto.CompactTextString(m) } +func (*MsgCloseMarket) ProtoMessage() {} +func (*MsgCloseMarket) Descriptor() ([]byte, []int) { + return fileDescriptor_b95cda40bf0a0f91, []int{27} +} +func (m *MsgCloseMarket) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCloseMarket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCloseMarket.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 *MsgCloseMarket) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCloseMarket.Merge(m, src) +} +func (m *MsgCloseMarket) XXX_Size() int { + return m.Size() +} +func (m *MsgCloseMarket) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCloseMarket.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCloseMarket proto.InternalMessageInfo + +func (m *MsgCloseMarket) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +type MsgCloseMarketResponse struct { +} + +func (m *MsgCloseMarketResponse) Reset() { *m = MsgCloseMarketResponse{} } +func (m *MsgCloseMarketResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCloseMarketResponse) ProtoMessage() {} +func (*MsgCloseMarketResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b95cda40bf0a0f91, []int{28} +} +func (m *MsgCloseMarketResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCloseMarketResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCloseMarketResponse.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 *MsgCloseMarketResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCloseMarketResponse.Merge(m, src) +} +func (m *MsgCloseMarketResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCloseMarketResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCloseMarketResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCloseMarketResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgSettlePosition)(nil), "nibiru.perp.v2.MsgSettlePosition") proto.RegisterType((*MsgRemoveMargin)(nil), "nibiru.perp.v2.MsgRemoveMargin") @@ -1497,115 +1580,120 @@ func init() { proto.RegisterType((*MsgShiftSwapInvariantResponse)(nil), "nibiru.perp.v2.MsgShiftSwapInvariantResponse") proto.RegisterType((*MsgWithdrawFromPerpFund)(nil), "nibiru.perp.v2.MsgWithdrawFromPerpFund") proto.RegisterType((*MsgWithdrawFromPerpFundResponse)(nil), "nibiru.perp.v2.MsgWithdrawFromPerpFundResponse") + proto.RegisterType((*MsgCloseMarket)(nil), "nibiru.perp.v2.MsgCloseMarket") + proto.RegisterType((*MsgCloseMarketResponse)(nil), "nibiru.perp.v2.MsgCloseMarketResponse") } func init() { proto.RegisterFile("nibiru/perp/v2/tx.proto", fileDescriptor_b95cda40bf0a0f91) } var fileDescriptor_b95cda40bf0a0f91 = []byte{ - // 1648 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x59, 0x5f, 0x6f, 0x1b, 0xc5, - 0x16, 0xf7, 0xc6, 0x8e, 0x93, 0x9c, 0xa4, 0xf9, 0xb3, 0x4d, 0x13, 0xd7, 0xb7, 0xd7, 0x49, 0x57, - 0xf7, 0xf6, 0xe6, 0x3e, 0xc4, 0x6e, 0x03, 0x12, 0x02, 0x09, 0x50, 0xfe, 0x34, 0xa8, 0xa8, 0x6e, - 0xdd, 0x4d, 0xd5, 0xa2, 0x52, 0xb4, 0x9d, 0x78, 0x27, 0x9b, 0x55, 0xd7, 0x33, 0xee, 0xce, 0xd8, - 0x4e, 0xca, 0x1b, 0x9f, 0x80, 0x07, 0x1e, 0x90, 0x90, 0x78, 0x43, 0x42, 0x3c, 0x20, 0xf5, 0x01, -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, 0xd0, 0x23, 0x49, 0xed, - 0x6b, 0x05, 0x26, 0xca, 0xcc, 0x5a, 0x35, 0xcd, 0xbf, 0x48, 0x6e, 0xbe, 0x50, 0x60, 0x36, 0xee, - 0x70, 0x94, 0x18, 0x49, 0x60, 0x95, 0x63, 0x0f, 0xec, 0x50, 0xdf, 0x81, 0xfd, 0xdd, 0x5f, 0x8e, - 0xe5, 0x86, 0xc3, 0xed, 0xab, 0xf6, 0x83, 0x86, 0x6d, 0x22, 0x8e, 0xbb, 0x46, 0xf7, 0x06, 0x4c, - 0x38, 0x81, 0x90, 0xd8, 0x24, 0x72, 0x43, 0x8b, 0xe9, 0xa5, 0xf1, 0x95, 0xe5, 0x4e, 0x3b, 0x2f, - 0x00, 0x16, 0xaf, 0xb6, 0xb5, 0xf4, 0x04, 0x44, 0x9e, 0xc3, 0x78, 0x6c, 0x32, 0xca, 0x9f, 0x72, - 0x3c, 0xf9, 0x9b, 0x83, 0x2c, 0x77, 0x91, 0x20, 0x32, 0xe4, 0x13, 0xf1, 0x47, 0xda, 0xb7, 0x69, - 0x38, 0xfb, 0x82, 0x97, 0x51, 0x8e, 0x50, 0x07, 0x4d, 0xc5, 0xa3, 0xf9, 0xe6, 0xa1, 0x34, 0x43, - 0x80, 0x04, 0xdd, 0xe0, 0x5b, 0x07, 0xed, 0x6f, 0x86, 0xe0, 0xb4, 0x44, 0x4a, 0xec, 0x50, 0xac, - 0x51, 0xad, 0x62, 0xc6, 0xbc, 0x10, 0x8c, 0xea, 0xe1, 0x50, 0x9d, 0x85, 0x61, 0xec, 0xba, 0x34, - 0x64, 0xe2, 0x0f, 0xd4, 0x4d, 0x98, 0x0c, 0x71, 0xa9, 0x6b, 0xec, 0x60, 0xdc, 0x5f, 0xa1, 0x2a, - 0xfa, 0xa9, 0xb6, 0xda, 0x26, 0xc6, 0xea, 0xdb, 0x30, 0x2e, 0x68, 0x19, 0x78, 0xc7, 0x03, 0xc9, - 0xf4, 0x07, 0x32, 0x26, 0x74,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, 0x50, 0x6a, 0xb3, 0x57, 0x77, 0xd6, 0x52, 0xaa, 0x03, 0xaa, 0xa4, 0x43, - 0xfe, 0x57, 0x56, 0x3a, 0x2f, 0x88, 0xe5, 0x97, 0xfb, 0x12, 0x93, 0x58, 0x4b, 0xf6, 0xa6, 0xae, - 0xd6, 0x12, 0x62, 0xdd, 0xad, 0xc9, 0x7b, 0x41, 0x22, 0x9e, 0x89, 0x4e, 0xd0, 0x2b, 0x9e, 0x71, - 0xc1, 0x9e, 0xf1, 0x94, 0xed, 0xd8, 0x5a, 0x6a, 0xed, 0x9d, 0xc7, 0xcf, 0x0a, 0xca, 0x93, 0x67, - 0x05, 0xe5, 0x97, 0x67, 0x05, 0xe5, 0xe3, 0x83, 0x42, 0xea, 0xc9, 0x41, 0x21, 0xf5, 0xc3, 0x41, - 0x21, 0x75, 0x67, 0xf9, 0xb0, 0x9e, 0x1a, 0xfd, 0x0c, 0x29, 0x5a, 0xcb, 0x76, 0xd6, 0xfb, 0x29, - 0xf0, 0x95, 0x3f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xb3, 0x7a, 0xd3, 0x25, 0xa5, 0x1c, 0x00, 0x00, + // 1686 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x59, 0x4b, 0x6f, 0x1b, 0x47, + 0x12, 0xe6, 0x88, 0x14, 0x25, 0x95, 0x64, 0x3d, 0xc6, 0xb2, 0x44, 0x73, 0xbd, 0x94, 0x3c, 0xd8, + 0xf5, 0x6a, 0x0f, 0x22, 0x6d, 0xed, 0x02, 0x8b, 0x5d, 0x60, 0x77, 0xa1, 0x87, 0x15, 0x38, 0x30, + 0x6d, 0x7a, 0x64, 0xd8, 0x81, 0xe3, 0x60, 0xdc, 0xe2, 0xb4, 0x46, 0x03, 0x0f, 0xbb, 0xe9, 0x99, + 0x26, 0x29, 0x39, 0xb7, 0x1c, 0x73, 0xca, 0x21, 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0xdb, 0x65, 0x92, 0x52, + 0xb5, 0xbd, 0x7b, 0x9e, 0x94, 0xea, 0xc2, 0xbc, 0xb4, 0xe3, 0x91, 0x45, 0x44, 0x26, 0x98, 0x2f, + 0xf5, 0x29, 0x98, 0xd4, 0x29, 0x6d, 0x15, 0x64, 0x3a, 0x65, 0x82, 0x52, 0x9d, 0xbd, 0x1a, 0x06, + 0x2d, 0xa5, 0x3a, 0xa0, 0x4a, 0x8a, 0xf6, 0x5f, 0x65, 0xa9, 0xf3, 0x92, 0x58, 0x7e, 0xb5, 0x2f, + 0x31, 0x89, 0xb6, 0x64, 0xb9, 0xec, 0xaa, 0x2d, 0x21, 0xd6, 0x5d, 0x9b, 0xbc, 0x3c, 0x25, 0xfc, + 0x99, 0x28, 0x4e, 0xbd, 0xfc, 0x19, 0x17, 0xec, 0xe9, 0x4f, 0x69, 0x11, 0x11, 0x47, 0x53, 0xbc, + 0x86, 0x14, 0xba, 0x6d, 0x30, 0x7f, 0x5e, 0x7a, 0x34, 0x49, 0x4a, 0x81, 0x96, 0xda, 0x78, 0xed, + 0xc9, 0xf3, 0x82, 0xf2, 0xf4, 0x79, 0x41, 0xf9, 0xe1, 0x79, 0x41, 0x79, 0xef, 0xa8, 0x90, 0x7a, + 0x7a, 0x54, 0x48, 0x7d, 0x73, 0x54, 0x48, 0xdd, 0x5b, 0x3d, 0xae, 0xf2, 0x44, 0x3f, 0xb9, 0xf2, + 0x32, 0xba, 0x9b, 0x15, 0x3f, 0x7b, 0xfe, 0xe3, 0x97, 0x00, 0x00, 0x00, 0xff, 0xff, 0x86, 0x40, + 0x26, 0x57, 0x91, 0x1d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1642,6 +1730,9 @@ type MsgClient interface { // WithdrawFromPerpFund: gRPC tx msg to withdraw from the perp fund module // account. [SUDO] Only callable by sudoers. WithdrawFromPerpFund(ctx context.Context, in *MsgWithdrawFromPerpFund, opts ...grpc.CallOption) (*MsgWithdrawFromPerpFundResponse, error) + // CloseMarket: gRPC tx msg for closing a market. + // [Admin] Only callable by sudoers. + CloseMarket(ctx context.Context, in *MsgCloseMarket, opts ...grpc.CallOption) (*MsgCloseMarketResponse, error) } type msgClient struct { @@ -1778,6 +1869,15 @@ func (c *msgClient) WithdrawFromPerpFund(ctx context.Context, in *MsgWithdrawFro return out, nil } +func (c *msgClient) CloseMarket(ctx context.Context, in *MsgCloseMarket, opts ...grpc.CallOption) (*MsgCloseMarketResponse, error) { + out := new(MsgCloseMarketResponse) + err := c.cc.Invoke(ctx, "/nibiru.perp.v2.Msg/CloseMarket", 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) @@ -1802,6 +1902,9 @@ type MsgServer interface { // WithdrawFromPerpFund: gRPC tx msg to withdraw from the perp fund module // account. [SUDO] Only callable by sudoers. WithdrawFromPerpFund(context.Context, *MsgWithdrawFromPerpFund) (*MsgWithdrawFromPerpFundResponse, error) + // CloseMarket: gRPC tx msg for closing a market. + // [Admin] Only callable by sudoers. + CloseMarket(context.Context, *MsgCloseMarket) (*MsgCloseMarketResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -1850,6 +1953,9 @@ func (*UnimplementedMsgServer) ShiftSwapInvariant(ctx context.Context, req *MsgS func (*UnimplementedMsgServer) WithdrawFromPerpFund(ctx context.Context, req *MsgWithdrawFromPerpFund) (*MsgWithdrawFromPerpFundResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method WithdrawFromPerpFund not implemented") } +func (*UnimplementedMsgServer) CloseMarket(ctx context.Context, req *MsgCloseMarket) (*MsgCloseMarketResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CloseMarket not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -2107,6 +2213,24 @@ func _Msg_WithdrawFromPerpFund_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Msg_CloseMarket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCloseMarket) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CloseMarket(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/nibiru.perp.v2.Msg/CloseMarket", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CloseMarket(ctx, req.(*MsgCloseMarket)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "nibiru.perp.v2.Msg", HandlerType: (*MsgServer)(nil), @@ -2167,6 +2291,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "WithdrawFromPerpFund", Handler: _Msg_WithdrawFromPerpFund_Handler, }, + { + MethodName: "CloseMarket", + Handler: _Msg_CloseMarket_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "nibiru/perp/v2/tx.proto", @@ -3547,6 +3675,69 @@ func (m *MsgWithdrawFromPerpFundResponse) MarshalToSizedBuffer(dAtA []byte) (int return len(dAtA) - i, nil } +func (m *MsgCloseMarket) 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 *MsgCloseMarket) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCloseMarket) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + 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 *MsgCloseMarketResponse) 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 *MsgCloseMarketResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCloseMarketResponse) 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 @@ -4045,6 +4236,30 @@ func (m *MsgWithdrawFromPerpFundResponse) Size() (n int) { return n } +func (m *MsgCloseMarket) 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)) + return n +} + +func (m *MsgCloseMarketResponse) 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 } @@ -7981,6 +8196,172 @@ func (m *MsgWithdrawFromPerpFundResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgCloseMarket) 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: MsgCloseMarket: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCloseMarket: 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 + 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 *MsgCloseMarketResponse) 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: MsgCloseMarketResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCloseMarketResponse: 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