diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bbfad80c..e5edd07f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#1573](https://github.com/NibiruChain/nibiru/pull/1573) - feat(perp): Close markets and compute settlement price * [#1705](https://github.com/NibiruChain/nibiru/pull/1705) - feat(perp): Add oracle pair to market object * [#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 ### Non-breaking/Compatible Improvements @@ -85,9 +86,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Dependencies -- Bump `github.com/prometheus/client_golang` from 1.17.0 to 1.18.0 ([#1750](https://github.com/NibiruChain/nibiru/pull/1750)) +* Bump `github.com/prometheus/client_golang` from 1.17.0 to 1.18.0 ([#1750](https://github.com/NibiruChain/nibiru/pull/1750)) * Bump `google.golang.org/protobuf` from 1.31.0 to 1.32.0 ([#1756](https://github.com/NibiruChain/nibiru/pull/1756)) - * Bump `google.golang.org/grpc` from 1.59.0 to 1.60.0 ([#1720](https://github.com/NibiruChain/nibiru/pull/1720)) * Bump `golang.org/x/crypto` from 0.15.0 to 0.17.0 ([#1724](https://github.com/NibiruChain/nibiru/pull/1724)) * Bump `github.com/holiman/uint256` from 1.2.3 to 1.2.4 ([#1730](https://github.com/NibiruChain/nibiru/pull/1730)) diff --git a/app/keepers.go b/app/keepers.go index e252bc554..b623ebbbb 100644 --- a/app/keepers.go +++ b/app/keepers.go @@ -805,7 +805,7 @@ func ModuleAccPerms() map[string][]string { perptypes.ModuleName: {}, perptypes.VaultModuleAccount: {}, - perptypes.PerpEFModuleAccount: {}, + perptypes.PerpFundModuleAccount: {}, perptypes.FeePoolModuleAccount: {}, perptypes.DNRAllocationModuleAccount: {}, perptypes.DNREscrowModuleAccount: {}, diff --git a/proto/nibiru/perp/v2/tx.proto b/proto/nibiru/perp/v2/tx.proto index 7dba213c7..faae01c34 100644 --- a/proto/nibiru/perp/v2/tx.proto +++ b/proto/nibiru/perp/v2/tx.proto @@ -30,7 +30,7 @@ service Msg { 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. + // is possible to make an sdk.Coin using it. [SUDO] Only callable by sudoers. rpc ChangeCollateralDenom(MsgChangeCollateralDenom) returns (MsgChangeCollateralDenomResponse) {} @@ -41,14 +41,19 @@ service Msg { returns (MsgWithdrawEpochRebatesResponse) {} // ShiftPegMultiplier: gRPC tx msg for changing a market's peg multiplier. - // [Admin] Only callable by sudoers. + // [SUDO] 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. + // [SUDO] Only callable by sudoers. rpc ShiftSwapInvariant(MsgShiftSwapInvariant) returns (MsgShiftSwapInvariantResponse) {} + + // WithdrawFromPerpFund: gRPC tx msg to withdraw from the perp fund module + // account. [SUDO] Only callable by sudoers. + rpc WithdrawFromPerpFund(MsgWithdrawFromPerpFund) + returns (MsgWithdrawFromPerpFundResponse) {} } // -------------------------- Settle Position -------------------------- @@ -353,7 +358,7 @@ message MsgDonateToEcosystemFundResponse {} // ----------------------- MsgChangeCollateralDenom ----------------------- // MsgChangeCollateralDenom: Changes the collateral denom for the module. -// [Admin] Only callable by sudoers. +// [SUDO] Only callable by sudoers. message MsgChangeCollateralDenom { string sender = 1; string new_denom = 2; @@ -394,8 +399,8 @@ message MsgWithdrawEpochRebatesResponse { // -------------------------- ShiftPegMultiplier -------------------------- -// ShiftPegMultiplier: gRPC tx msg for changing the peg multiplier. -// Admin-only. +// MsgShiftPegMultiplier: gRPC tx msg for changing the peg multiplier. +// [SUDO] Only callable sudoers. message MsgShiftPegMultiplier { string sender = 1; string pair = 2 [ @@ -413,8 +418,8 @@ message MsgShiftPegMultiplierResponse {} // -------------------------- ShiftSwapInvariant -------------------------- -// ShiftSwapInvariant: gRPC tx msg for changing the swap invariant. -// Admin-only. +// MsgShiftSwapInvariant: gRPC tx msg for changing the swap invariant. +// [SUDO] Only callable sudoers. message MsgShiftSwapInvariant { string sender = 1; string pair = 2 [ @@ -429,3 +434,20 @@ message MsgShiftSwapInvariant { } message MsgShiftSwapInvariantResponse {} + +// -------------------------- WithdrawFromPerpFund -------------------------- + +// MsgWithdrawFromPerpFund: gRPC tx msg for changing the swap invariant. +// [SUDO] Only callable sudoers. +message MsgWithdrawFromPerpFund { + string sender = 1; + string amount = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + // Optional denom in case withdrawing assets aside from NUSD. + string denom = 3; + string to_addr = 4; +} + +message MsgWithdrawFromPerpFundResponse {} diff --git a/wasmbinding/bindings/msg.go b/wasmbinding/bindings/msg.go index 836406af1..42532c059 100644 --- a/wasmbinding/bindings/msg.go +++ b/wasmbinding/bindings/msg.go @@ -14,10 +14,8 @@ import ( type NibiruMsg struct { // bindings-perp ExecuteMsg enum types // MultiLiquidate *MultiLiquidate `json:"multi_liquidate,omitempty"` // TODO - DonateToInsuranceFund *DonateToInsuranceFund `json:"donate_to_insurance_fund,omitempty"` // TODO - InsuranceFundWithdraw *InsuranceFundWithdraw `json:"insurance_fund_withdraw,omitempty"` - SetMarketEnabled *SetMarketEnabled `json:"set_market_enabled,omitempty"` - CreateMarket *CreateMarket `json:"create_market,omitempty"` + SetMarketEnabled *SetMarketEnabled `json:"set_market_enabled,omitempty"` + CreateMarket *CreateMarket `json:"create_market,omitempty"` EditOracleParams *EditOracleParams `json:"edit_oracle_params,omitempty"` @@ -25,11 +23,6 @@ type NibiruMsg struct { NoOp *NoOp `json:"no_op,omitempty"` } -type DonateToInsuranceFund struct { - Sender string `json:"sender"` - Donation sdk.Coin `json:"donation"` -} - type EditOracleParams struct { VotePeriod *sdkmath.Int `json:"vote_period,omitempty"` VoteThreshold *sdk.Dec `json:"vote_threshold,omitempty"` @@ -43,11 +36,6 @@ type EditOracleParams struct { ValidatorFeeRatio *sdk.Dec `json:"validator_fee_ratio,omitempty"` } -type InsuranceFundWithdraw struct { - Amount sdkmath.Int `json:"amount"` - To string `json:"to"` -} - type SetMarketEnabled struct { Pair string `json:"pair"` Enabled bool `json:"enabled"` diff --git a/wasmbinding/exec_perp.go b/wasmbinding/exec_perp.go index d3c4badd6..f3defcf01 100644 --- a/wasmbinding/exec_perp.go +++ b/wasmbinding/exec_perp.go @@ -20,25 +20,6 @@ func (exec *ExecutorPerp) MsgServer() perpv2types.MsgServer { return perpv2keeper.NewMsgServerImpl(exec.PerpV2) } -func (exec *ExecutorPerp) InsuranceFundWithdraw( - cwMsg *bindings.InsuranceFundWithdraw, ctx sdk.Context, -) (err error) { - if cwMsg == nil { - return wasmvmtypes.InvalidRequest{Err: "null msg"} - } - - to, err := sdk.AccAddressFromBech32(cwMsg.To) - if err != nil { - return err - } - - return exec.PerpV2.Admin.WithdrawFromInsuranceFund( - ctx, - cwMsg.Amount, - to, - ) -} - // TODO: rename to CloseMarket func (exec *ExecutorPerp) SetMarketEnabled( cwMsg *bindings.SetMarketEnabled, ctx sdk.Context, @@ -52,7 +33,7 @@ func (exec *ExecutorPerp) SetMarketEnabled( return err } - return exec.PerpV2.Admin.CloseMarket(ctx, pair) + return exec.PerpV2.Sudo().CloseMarket(ctx, pair) } func (exec *ExecutorPerp) CreateMarket( @@ -90,7 +71,7 @@ func (exec *ExecutorPerp) CreateMarket( } } - return exec.PerpV2.Admin.CreateMarket(ctx, perpv2keeper.ArgsCreateMarket{ + return exec.PerpV2.Sudo().CreateMarket(ctx, perpv2keeper.ArgsCreateMarket{ Pair: pair, PriceMultiplier: cwMsg.PegMult, SqrtDepth: cwMsg.SqrtDepth, diff --git a/wasmbinding/exec_perp_test.go b/wasmbinding/exec_perp_test.go index 0aa232cbc..e25571d42 100644 --- a/wasmbinding/exec_perp_test.go +++ b/wasmbinding/exec_perp_test.go @@ -134,7 +134,6 @@ func (s *TestSuitePerpExecutor) OnSetupEnd() { // Happy path coverage func (s *TestSuitePerpExecutor) TestPerpExecutorHappy() { for _, err := range []error{ - s.DoInsuranceFundWithdrawTest(sdk.NewInt(69), s.contractDeployer), s.DoCreateMarketTest(asset.MustNewPair("ufoo:ubar")), s.DoCreateMarketTestWithParams(asset.MustNewPair("ufoo2:ubar")), } { @@ -142,25 +141,6 @@ func (s *TestSuitePerpExecutor) TestPerpExecutorHappy() { } } -func (s *TestSuitePerpExecutor) DoInsuranceFundWithdrawTest( - amt sdkmath.Int, to sdk.AccAddress, -) error { - cwMsg := &bindings.InsuranceFundWithdraw{ - Amount: amt, - To: to.String(), - } - - err := testapp.FundModuleAccount( - s.nibiru.BankKeeper, - s.ctx, - perpv2types.PerpEFModuleAccount, - sdk.NewCoins(sdk.NewCoin(perpv2types.TestingCollateralDenomNUSD, sdk.NewInt(420))), - ) - s.NoError(err) - - return s.exec.InsuranceFundWithdraw(cwMsg, s.ctx) -} - func (s *TestSuitePerpExecutor) DoCreateMarketTest(pair asset.Pair) error { cwMsg := &bindings.CreateMarket{ Pair: pair.String(), @@ -197,11 +177,6 @@ func (s *TestSuitePerpExecutor) DoCreateMarketTestWithParams(pair asset.Pair) er return s.exec.CreateMarket(cwMsg, s.ctx) } -func (s *TestSuitePerpExecutor) TestSadPaths_Nil() { - err := s.exec.InsuranceFundWithdraw(nil, s.ctx) - s.Error(err) -} - func (s *TestSuitePerpExecutor) DoSetMarketEnabledTest( pair asset.Pair, enabled bool, ) error { @@ -220,13 +195,6 @@ func (s *TestSuitePerpExecutor) DoSetMarketEnabledTest( return err } -func (s *TestSuitePerpExecutor) TestSadPath_InsuranceFundWithdraw() { - fundsToWithdraw := sdk.NewCoin(perpv2types.TestingCollateralDenomNUSD, sdk.NewInt(69_000)) - - err := s.DoInsuranceFundWithdrawTest(fundsToWithdraw.Amount, s.contractDeployer) - s.Error(err) -} - func (s *TestSuitePerpExecutor) TestSadPaths_InvalidPair() { sadPair := asset.Pair("ftt:ust:doge") pair := sadPair diff --git a/wasmbinding/exec_test.go b/wasmbinding/exec_test.go index 0ad880db0..cdbc5776c 100644 --- a/wasmbinding/exec_test.go +++ b/wasmbinding/exec_test.go @@ -313,55 +313,6 @@ func (s *TestSuiteExecutor) TestNoOp() { s.NoErrorf(err, "contractRespBz: %s", contractRespBz) } -func (s *TestSuiteExecutor) TestInsuranceFundWithdraw() { - admin := s.contractDeployer.String() - amtToWithdraw := sdk.NewInt(69) - execMsg := bindings.NibiruMsg{ - InsuranceFundWithdraw: &bindings.InsuranceFundWithdraw{ - Amount: amtToWithdraw, - To: admin, - }, - } - - s.T().Log("Executing should fail since the IF doesn't have funds") - contract := s.contractController - s.keeper.SetSudoContracts( - []string{contract.String()}, s.ctx, - ) - contractRespBz, err := s.ExecuteAgainstContract(contract, execMsg) - s.Errorf(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 should work when the IF has funds") - err = testapp.FundModuleAccount( - s.nibiru.BankKeeper, - s.ctx, - perpv2types.PerpEFModuleAccount, - sdk.NewCoins(sdk.NewCoin(perpv2types.TestingCollateralDenomNUSD, sdk.NewInt(420))), - ) - s.NoError(err) - s.keeper.SetSudoContracts( - []string{contract.String()}, s.ctx, - ) - contractRespBz, err = s.ExecuteAgainstContract(contract, execMsg) - s.NoErrorf(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) TestSetMarketEnabled() { // admin := s.contractDeployer.String() perpv2Genesis := genesis.PerpV2Genesis() diff --git a/wasmbinding/message_plugin.go b/wasmbinding/message_plugin.go index 51ef552ba..6642c90dd 100644 --- a/wasmbinding/message_plugin.go +++ b/wasmbinding/message_plugin.go @@ -71,13 +71,6 @@ func (messenger *CustomMessenger) DispatchMsg( err = messenger.Perp.CreateMarket(cwMsg, ctx) return events, data, err - case contractExecuteMsg.ExecuteMsg.InsuranceFundWithdraw != nil: - if err := messenger.Sudo.CheckPermissions(contractAddr, ctx); err != nil { - return events, data, err - } - cwMsg := contractExecuteMsg.ExecuteMsg.InsuranceFundWithdraw - err = messenger.Perp.InsuranceFundWithdraw(cwMsg, ctx) - return events, data, err case contractExecuteMsg.ExecuteMsg.SetMarketEnabled != nil: if err := messenger.Sudo.CheckPermissions(contractAddr, ctx); err != nil { return events, data, err diff --git a/x/oracle/keeper/hooks.go b/x/oracle/keeper/hooks.go index 5d5ae2888..69e26117d 100644 --- a/x/oracle/keeper/hooks.go +++ b/x/oracle/keeper/hooks.go @@ -57,7 +57,7 @@ func (h Hooks) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, _ uint64) } if !totalRemainder.IsZero() { - err = h.bankKeeper.SendCoinsFromModuleToModule(ctx, perptypes.FeePoolModuleAccount, perptypes.PerpEFModuleAccount, totalRemainder) + err = h.bankKeeper.SendCoinsFromModuleToModule(ctx, perptypes.FeePoolModuleAccount, perptypes.PerpFundModuleAccount, totalRemainder) if err != nil { h.k.Logger(ctx).Error("Failed to send coins to perp ef module", "err", err) } diff --git a/x/oracle/keeper/hooks_test.go b/x/oracle/keeper/hooks_test.go index 516c0dc38..5f655dfc9 100644 --- a/x/oracle/keeper/hooks_test.go +++ b/x/oracle/keeper/hooks_test.go @@ -73,7 +73,7 @@ func TestHooks_AfterEpochEnd(t *testing.T) { balances := app.BankKeeper.GetAllBalances(ctx, account.GetAddress()) assert.Equal(t, tt.expectedOracleBalances, balances) - account = app.AccountKeeper.GetModuleAccount(ctx, perptypes.PerpEFModuleAccount) + account = app.AccountKeeper.GetModuleAccount(ctx, perptypes.PerpFundModuleAccount) balances = app.BankKeeper.GetAllBalances(ctx, account.GetAddress()) assert.Equal(t, tt.expectedEFBalances, balances) }) diff --git a/x/perp/v2/client/cli/cli_test.go b/x/perp/v2/client/cli/cli_test.go index 9113d95c7..47a6a8b4f 100644 --- a/x/perp/v2/client/cli/cli_test.go +++ b/x/perp/v2/client/cli/cli_test.go @@ -8,6 +8,7 @@ import ( abcitypes "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/cli" "github.com/stretchr/testify/suite" @@ -714,16 +715,21 @@ func (s *IntegrationTestSuite) TestDonateToEcosystemFund() { s.NoError(s.network.WaitForNextBlock()) resp := new(sdk.Coin) - moduleAccountAddrPerpEF := "nibi1trh2mamq64u4g042zfeevvjk4cukrthvppfnc7" + + moduleAccPerpFund := authtypes.NewModuleAddress( + types.PerpFundModuleAccount).String() s.NoError( testutilcli.ExecQuery( s.network.Validators[0].ClientCtx, bankcli.GetBalancesCmd(), - []string{moduleAccountAddrPerpEF, "--denom", types.TestingCollateralDenomNUSD}, + []string{moduleAccPerpFund, "--denom", types.TestingCollateralDenomNUSD}, resp, ), ) - s.Require().EqualValues(sdk.NewInt64Coin(types.TestingCollateralDenomNUSD, 100), *resp) + s.Require().EqualValues( + sdk.NewInt64Coin(types.TestingCollateralDenomNUSD, 100).String(), + resp.String(), + ) } func (s *IntegrationTestSuite) TestQueryModuleAccount() { diff --git a/x/perp/v2/integration/action/market.go b/x/perp/v2/integration/action/market.go index 896479ef3..73b966a17 100644 --- a/x/perp/v2/integration/action/market.go +++ b/x/perp/v2/integration/action/market.go @@ -127,7 +127,7 @@ type shiftPegMultiplier struct { } func (e shiftPegMultiplier) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) { - err := app.PerpKeeperV2.Admin.ShiftPegMultiplier( + err := app.PerpKeeperV2.Sudo().ShiftPegMultiplier( ctx, e.pair, e.newValue, testapp.DefaultSudoRoot(), ) return ctx, err @@ -146,7 +146,7 @@ type shiftSwapInvariant struct { } func (e shiftSwapInvariant) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) { - err := app.PerpKeeperV2.Admin.ShiftSwapInvariant( + err := app.PerpKeeperV2.Sudo().ShiftSwapInvariant( ctx, e.pair, e.newValue, testapp.DefaultSudoRoot(), ) return ctx, err @@ -166,7 +166,7 @@ type createPool struct { } func (c createPool) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) { - err := app.PerpKeeperV2.Admin.CreateMarket(ctx, keeper.ArgsCreateMarket{ + err := app.PerpKeeperV2.Sudo().CreateMarket(ctx, keeper.ArgsCreateMarket{ Pair: c.pair, PriceMultiplier: c.amm.PriceMultiplier, SqrtDepth: c.amm.SqrtDepth, @@ -200,7 +200,7 @@ func (c setCollateral) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, err if err != nil { return ctx, err } - err = app.PerpKeeperV2.Admin.ChangeCollateralDenom(ctx, c.Denom, senderAddr) + err = app.PerpKeeperV2.Sudo().ChangeCollateralDenom(ctx, c.Denom, senderAddr) return ctx, err } diff --git a/x/perp/v2/integration/action/settlement.go b/x/perp/v2/integration/action/settlement.go index 62cafc869..1719d581a 100644 --- a/x/perp/v2/integration/action/settlement.go +++ b/x/perp/v2/integration/action/settlement.go @@ -17,7 +17,7 @@ type closeMarket struct { } func (c closeMarket) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) { - err := app.PerpKeeperV2.Admin.CloseMarket(ctx, c.pair) + err := app.PerpKeeperV2.Sudo().CloseMarket(ctx, c.pair) if err != nil { return ctx, err } @@ -35,7 +35,7 @@ type closeMarketShouldFail struct { } func (c closeMarketShouldFail) Do(app *app.NibiruApp, ctx sdk.Context) (sdk.Context, error) { - err := app.PerpKeeperV2.Admin.CloseMarket(ctx, c.pair) + err := app.PerpKeeperV2.Sudo().CloseMarket(ctx, c.pair) if err == nil { return ctx, err } diff --git a/x/perp/v2/keeper/amm.go b/x/perp/v2/keeper/amm.go index ae317d7f0..fe94ad4be 100644 --- a/x/perp/v2/keeper/amm.go +++ b/x/perp/v2/keeper/amm.go @@ -28,7 +28,7 @@ func (k Keeper) handleMarketUpdateCost( ) err = k.BankKeeper.SendCoinsFromModuleToModule( ctx, - types.PerpEFModuleAccount, + types.PerpFundModuleAccount, types.VaultModuleAccount, cost, ) @@ -36,7 +36,7 @@ func (k Keeper) handleMarketUpdateCost( return costPaid, types.ErrNotEnoughFundToPayAction.Wrapf( "need %s, got %s", cost.String(), - k.BankKeeper.GetBalance(ctx, k.AccountKeeper.GetModuleAddress(types.PerpEFModuleAccount), collateral).String(), + k.BankKeeper.GetBalance(ctx, k.AccountKeeper.GetModuleAddress(types.PerpFundModuleAccount), collateral).String(), ) } else { costPaid = cost[0] @@ -46,7 +46,7 @@ func (k Keeper) handleMarketUpdateCost( err = k.BankKeeper.SendCoinsFromModuleToModule( ctx, types.VaultModuleAccount, - types.PerpEFModuleAccount, + types.PerpFundModuleAccount, sdk.NewCoins( sdk.NewCoin(collateral, costAmt.Neg()), ), diff --git a/x/perp/v2/keeper/amm_test.go b/x/perp/v2/keeper/amm_test.go index 3dee582a0..0136778f9 100644 --- a/x/perp/v2/keeper/amm_test.go +++ b/x/perp/v2/keeper/amm_test.go @@ -29,14 +29,14 @@ func TestShiftPegMultiplier(t *testing.T) { Given( CreateCustomMarket(pair, WithTotalLong(sdk.NewDec(1000)), WithTotalShort(sdk.NewDec(500))), FundModule(types.VaultModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( ShiftPegMultiplier(pair, sdk.OneDec()), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)), AMMShouldBeEqual(pair, AMM_SqrtDepthShouldBeEqual(sdk.NewDec(1e12)), AMM_BaseReserveShouldBeEqual(sdk.NewDec(1e12)), @@ -52,14 +52,14 @@ func TestShiftPegMultiplier(t *testing.T) { WithEnabled(true), ), FundModule(types.VaultModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( ShiftPegMultiplier(pair, sdk.NewDec(10)), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)), AMMShouldBeEqual(pair, AMM_SqrtDepthShouldBeEqual(sdk.NewDec(1e12)), AMM_BaseReserveShouldBeEqual(sdk.NewDec(1e12)), @@ -72,14 +72,14 @@ func TestShiftPegMultiplier(t *testing.T) { Given( CreateCustomMarket(pair, WithTotalLong(sdk.NewDec(1000)), WithTotalShort(sdk.NewDec(500))), FundModule(types.VaultModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( ShiftPegMultiplier(pair, sdk.NewDec(10)), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1004500)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(995500)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(995500)), AMMShouldBeEqual(pair, AMM_SqrtDepthShouldBeEqual(sdk.NewDec(1e12)), AMM_BaseReserveShouldBeEqual(sdk.NewDec(1e12)), @@ -92,14 +92,14 @@ func TestShiftPegMultiplier(t *testing.T) { Given( CreateCustomMarket(pair, WithTotalLong(sdk.NewDec(1000)), WithTotalShort(sdk.NewDec(500))), FundModule(types.VaultModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( ShiftPegMultiplier(pair, sdk.MustNewDecFromStr("0.25")), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(999626)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1000374)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1000374)), AMMShouldBeEqual(pair, AMM_SqrtDepthShouldBeEqual(sdk.NewDec(1e12)), AMM_BaseReserveShouldBeEqual(sdk.NewDec(1e12)), @@ -112,14 +112,14 @@ func TestShiftPegMultiplier(t *testing.T) { Given( CreateCustomMarket(pair, WithTotalLong(sdk.NewDec(500)), WithTotalShort(sdk.NewDec(1000))), FundModule(types.VaultModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( ShiftPegMultiplier(pair, sdk.NewDec(10)), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(995500)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1004500)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1004500)), AMMShouldBeEqual(pair, AMM_SqrtDepthShouldBeEqual(sdk.NewDec(1e12)), AMM_BaseReserveShouldBeEqual(sdk.NewDec(1e12)), @@ -132,14 +132,14 @@ func TestShiftPegMultiplier(t *testing.T) { Given( CreateCustomMarket(pair, WithTotalLong(sdk.NewDec(500)), WithTotalShort(sdk.NewDec(1000))), FundModule(types.VaultModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( ShiftPegMultiplier(pair, sdk.MustNewDecFromStr("0.25")), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1000376)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(999624)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(999624)), AMMShouldBeEqual(pair, AMM_SqrtDepthShouldBeEqual(sdk.NewDec(1e12)), AMM_BaseReserveShouldBeEqual(sdk.NewDec(1e12)), @@ -160,7 +160,7 @@ func TestShiftPegMultiplier_Fail(t *testing.T) { account := testutil.AccAddress() - err := app.PerpKeeperV2.Admin.CreateMarket( + err := app.PerpKeeperV2.Sudo().CreateMarket( ctx, keeper.ArgsCreateMarket{ Pair: pair, @@ -188,12 +188,12 @@ func TestShiftPegMultiplier_Fail(t *testing.T) { adminAddr := testapp.DefaultSudoRoot() // Error because of invalid pair - err = app.PerpKeeperV2.Admin.ShiftPegMultiplier( + err = app.PerpKeeperV2.Sudo().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.ShiftPegMultiplier(ctx, pair, sdk.NewDec(-1), adminAddr) + err = app.PerpKeeperV2.Sudo().ShiftPegMultiplier(ctx, pair, sdk.NewDec(-1), adminAddr) require.ErrorIs(t, err, types.ErrAmmNonPositivePegMult) // Add market activity @@ -215,11 +215,11 @@ func TestShiftPegMultiplier_Fail(t *testing.T) { require.NoError(t, err) // Error because no money in perp ef fund - err = app.PerpKeeperV2.Admin.ShiftPegMultiplier(ctx, pair, sdk.NewDec(3), adminAddr) + err = app.PerpKeeperV2.Sudo().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.ShiftPegMultiplier(ctx, pair, sdk.NewDec(1), adminAddr) + err = app.PerpKeeperV2.Sudo().ShiftPegMultiplier(ctx, pair, sdk.NewDec(1), adminAddr) require.NoError(t, err) } @@ -230,7 +230,7 @@ func TestShiftSwapInvariant_Fail(t *testing.T) { app, ctx := testapp.NewNibiruTestAppAndContext() account := testutil.AccAddress() - err := app.PerpKeeperV2.Admin.CreateMarket( + err := app.PerpKeeperV2.Sudo().CreateMarket( ctx, keeper.ArgsCreateMarket{ Pair: pair, @@ -258,11 +258,11 @@ func TestShiftSwapInvariant_Fail(t *testing.T) { adminAddr := testapp.DefaultSudoRoot() // Error because of invalid price multiplier - err = app.PerpKeeperV2.Admin.ShiftSwapInvariant(ctx, asset.MustNewPair("luna:usdt"), sdk.NewInt(-1), adminAddr) + err = app.PerpKeeperV2.Sudo().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.ShiftSwapInvariant(ctx, pair, sdk.NewInt(-1), adminAddr) + err = app.PerpKeeperV2.Sudo().ShiftSwapInvariant(ctx, pair, sdk.NewInt(-1), adminAddr) require.ErrorIs(t, err, types.ErrAmmNonPositiveSwapInvariant) // Add market activity @@ -284,15 +284,15 @@ func TestShiftSwapInvariant_Fail(t *testing.T) { require.NoError(t, err) // Error because no money in perp ef fund - err = app.PerpKeeperV2.Admin.ShiftSwapInvariant(ctx, pair, sdk.NewInt(2_000_000), adminAddr) + err = app.PerpKeeperV2.Sudo().ShiftSwapInvariant(ctx, pair, sdk.NewInt(2_000_000), adminAddr) require.ErrorContains(t, err, types.ErrNotEnoughFundToPayAction.Error()) // Fail at validate - err = app.PerpKeeperV2.Admin.ShiftSwapInvariant(ctx, pair, sdk.NewInt(0), adminAddr) + err = app.PerpKeeperV2.Sudo().ShiftSwapInvariant(ctx, pair, sdk.NewInt(0), adminAddr) require.ErrorContains(t, err, types.ErrAmmNonPositiveSwapInvariant.Error()) // Works because it goes in the other way - err = app.PerpKeeperV2.Admin.ShiftSwapInvariant(ctx, pair, sdk.NewInt(500_000), adminAddr) + err = app.PerpKeeperV2.Sudo().ShiftSwapInvariant(ctx, pair, sdk.NewInt(500_000), adminAddr) require.NoError(t, err) } @@ -308,14 +308,14 @@ func TestShiftSwapInvariant(t *testing.T) { WithSqrtDepth(sdk.NewDec(1e6)), ), FundModule(types.VaultModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( ShiftSwapInvariant(pair, sdk.NewInt(1e12)), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)), AMMShouldBeEqual(pair, AMM_SqrtDepthShouldBeEqual(sdk.NewDec(1e6)), AMM_BaseReserveShouldBeEqual(sdk.NewDec(1e6)), @@ -332,14 +332,14 @@ func TestShiftSwapInvariant(t *testing.T) { WithSqrtDepth(sdk.NewDec(1e6)), ), FundModule(types.VaultModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( ShiftSwapInvariant(pair, sdk.NewInt(1e18)), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)), AMMShouldBeEqual(pair, AMM_SqrtDepthShouldBeEqual(sdk.NewDec(1e9)), AMM_BaseReserveShouldBeEqual(sdk.NewDec(1e9)), @@ -352,14 +352,14 @@ func TestShiftSwapInvariant(t *testing.T) { Given( CreateCustomMarket(pair, WithTotalLong(sdk.NewDec(1e5)), WithSqrtDepth(sdk.NewDec(1e6))), FundModule(types.VaultModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( ShiftSwapInvariant(pair, sdk.NewInt(1e14)), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1008101)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(991899)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(991899)), AMMShouldBeEqual(pair, AMM_SqrtDepthShouldBeEqual(sdk.NewDec(1e7)), AMM_BaseReserveShouldBeEqual(sdk.NewDec(1e7)), @@ -372,14 +372,14 @@ func TestShiftSwapInvariant(t *testing.T) { Given( CreateCustomMarket(pair, WithTotalLong(sdk.NewDec(1e2)), WithSqrtDepth(sdk.NewDec(1e6))), FundModule(types.VaultModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( ShiftSwapInvariant(pair, sdk.NewInt(1e6)), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(999991)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1000009)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1000009)), AMMShouldBeEqual(pair, AMM_SqrtDepthShouldBeEqual(sdk.NewDec(1e3)), AMM_BaseReserveShouldBeEqual(sdk.NewDec(1e3)), @@ -392,14 +392,14 @@ func TestShiftSwapInvariant(t *testing.T) { Given( CreateCustomMarket(pair, WithTotalShort(sdk.NewDec(1e5)), WithSqrtDepth(sdk.NewDec(1e6))), FundModule(types.VaultModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( ShiftSwapInvariant(pair, sdk.NewInt(1e14)), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1010102)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(989898)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(989898)), AMMShouldBeEqual(pair, AMM_SqrtDepthShouldBeEqual(sdk.NewDec(1e7)), AMM_BaseReserveShouldBeEqual(sdk.NewDec(1e7)), @@ -412,14 +412,14 @@ func TestShiftSwapInvariant(t *testing.T) { Given( CreateCustomMarket(pair, WithTotalShort(sdk.NewDec(1e2)), WithSqrtDepth(sdk.NewDec(1e6))), FundModule(types.VaultModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1e6)))), ). When( ShiftSwapInvariant(pair, sdk.NewInt(1e6)), ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(999989)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1000011)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1000011)), AMMShouldBeEqual(pair, AMM_SqrtDepthShouldBeEqual(sdk.NewDec(1e3)), AMM_BaseReserveShouldBeEqual(sdk.NewDec(1e3)), @@ -437,7 +437,7 @@ func TestKeeper_GetMarketByPairAndVersion(t *testing.T) { pair := asset.Registry.Pair(denoms.BTC, denoms.NUSD) - err := app.PerpKeeperV2.Admin.CreateMarket( + err := app.PerpKeeperV2.Sudo().CreateMarket( ctx, keeper.ArgsCreateMarket{ Pair: pair, @@ -448,12 +448,12 @@ func TestKeeper_GetMarketByPairAndVersion(t *testing.T) { ) require.NoError(t, err) - market, err := app.PerpKeeperV2.Admin.GetMarketByPairAndVersion(ctx, pair, 1) + market, err := app.PerpKeeperV2.Sudo().GetMarketByPairAndVersion(ctx, pair, 1) require.NoError(t, err) require.Equal(t, market.Version, uint64(1)) require.Equal(t, market.Pair, pair) - market, err = app.PerpKeeperV2.Admin.GetMarketByPairAndVersion(ctx, pair, 2) + market, err = app.PerpKeeperV2.Sudo().GetMarketByPairAndVersion(ctx, pair, 2) require.ErrorContains(t, err, fmt.Sprintf("market with pair %s and version 2 not found", pair.String())) } @@ -462,7 +462,7 @@ func TestKeeper_GetAMMByPairAndVersion(t *testing.T) { pair := asset.Registry.Pair(denoms.BTC, denoms.NUSD) - err := app.PerpKeeperV2.Admin.CreateMarket( + err := app.PerpKeeperV2.Sudo().CreateMarket( ctx, keeper.ArgsCreateMarket{ Pair: pair, @@ -473,11 +473,11 @@ func TestKeeper_GetAMMByPairAndVersion(t *testing.T) { ) require.NoError(t, err) - amm, err := app.PerpKeeperV2.Admin.GetAMMByPairAndVersion(ctx, pair, 1) + amm, err := app.PerpKeeperV2.Sudo().GetAMMByPairAndVersion(ctx, pair, 1) require.NoError(t, err) require.Equal(t, amm.Version, uint64(1)) require.Equal(t, amm.Pair, pair) - amm, err = app.PerpKeeperV2.Admin.GetAMMByPairAndVersion(ctx, pair, 2) + amm, err = app.PerpKeeperV2.Sudo().GetAMMByPairAndVersion(ctx, pair, 2) require.ErrorContains(t, err, fmt.Sprintf("amm with pair %s and version 2 not found", pair.String())) } diff --git a/x/perp/v2/keeper/clearing_house.go b/x/perp/v2/keeper/clearing_house.go index 65fe2e61d..1dedae8b0 100644 --- a/x/perp/v2/keeper/clearing_house.go +++ b/x/perp/v2/keeper/clearing_house.go @@ -685,7 +685,7 @@ func (k Keeper) transferFee( if err = k.BankKeeper.SendCoinsFromAccountToModule( ctx, /* from */ trader, - /* to */ types.PerpEFModuleAccount, + /* to */ types.PerpFundModuleAccount, /* coins */ sdk.NewCoins( sdk.NewCoin( collateral, diff --git a/x/perp/v2/keeper/clearing_house_test.go b/x/perp/v2/keeper/clearing_house_test.go index 3fcbb8305..a8f4c8021 100644 --- a/x/perp/v2/keeper/clearing_house_test.go +++ b/x/perp/v2/keeper/clearing_house_test.go @@ -43,7 +43,7 @@ func TestMarketOrder(t *testing.T) { FundAccount(alice, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(10_200)))), FundAccount(bob, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(10_200)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), 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()), @@ -263,7 +263,7 @@ func TestMarketOrder(t *testing.T) { SetBlockTime(startBlockTime), 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)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), ShiftSwapInvariant(pairBtcNusd, sdk.NewInt(1)), ). When( @@ -1273,7 +1273,7 @@ func TestPartialClose(t *testing.T) { SetBlockTime(startBlockTime), SetBlockNumber(1), FundAccount(alice, sdk.NewCoins(sdk.NewInt64Coin(types.TestingCollateralDenomNUSD, 2))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewInt64Coin(types.TestingCollateralDenomNUSD, 27))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewInt64Coin(types.TestingCollateralDenomNUSD, 27))), InsertPosition( WithPair(pairBtcNusd), WithTrader(alice), @@ -1493,7 +1493,7 @@ func TestPartialClose(t *testing.T) { SetBlockTime(startBlockTime), SetBlockNumber(1), FundAccount(alice, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(18)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewInt64Coin(types.TestingCollateralDenomNUSD, 48))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewInt64Coin(types.TestingCollateralDenomNUSD, 48))), InsertPosition( WithPair(pairBtcNusd), WithTrader(alice), @@ -1679,7 +1679,7 @@ func TestClosePosition(t *testing.T) { ), FundAccount(alice, sdk.NewCoins(sdk.NewInt64Coin(types.TestingCollateralDenomNUSD, 18))), FundModule(types.VaultModuleAccount, sdk.NewCoins(sdk.NewInt64Coin(types.TestingCollateralDenomNUSD, 1000))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewInt64Coin(types.TestingCollateralDenomNUSD, 102))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewInt64Coin(types.TestingCollateralDenomNUSD, 102))), ). When( MoveToNextBlock(), @@ -1709,7 +1709,7 @@ func TestClosePosition(t *testing.T) { ExchangedSize: sdk.MustNewDecFromStr("-10000.000000000000000000"), }), ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1102)), // 1000 + 102 from perp ef - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(0)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(0)), ), TC("close short position with positive PnL"). @@ -1824,7 +1824,7 @@ func TestClosePosition(t *testing.T) { ), FundAccount(alice, sdk.NewCoins(sdk.NewInt64Coin(types.TestingCollateralDenomNUSD, 22))), FundModule(types.VaultModuleAccount, sdk.NewCoins(sdk.NewInt64Coin(types.TestingCollateralDenomNUSD, 1000))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewInt64Coin(types.TestingCollateralDenomNUSD, 98))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewInt64Coin(types.TestingCollateralDenomNUSD, 98))), ). When( MoveToNextBlock(), @@ -1854,7 +1854,7 @@ func TestClosePosition(t *testing.T) { ExchangedSize: sdk.MustNewDecFromStr("10000.000000000000000000"), }), ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(1098)), // 1000 + 98 from perp ef - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(0)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(0)), ), } @@ -1876,7 +1876,7 @@ func TestUpdateSwapInvariant(t *testing.T) { SetBlockTime(startBlockTime), SetBlockNumber(1), FundAccount(alice, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(10_200_000_000)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100000)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100000)))), ). When( MarketOrder(alice, pairBtcNusd, types.Direction_LONG, sdk.NewInt(10_000_000_000), sdk.OneDec(), sdk.ZeroDec()), @@ -1891,7 +1891,7 @@ func TestUpdateSwapInvariant(t *testing.T) { SetBlockTime(startBlockTime), SetBlockNumber(1), FundAccount(alice, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(10_200_000_000)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100000)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100000)))), ). When( MarketOrder(alice, pairBtcNusd, types.Direction_SHORT, sdk.NewInt(10_000_000_000), sdk.OneDec(), sdk.NewDec(10_000_000_000_000)), @@ -1906,7 +1906,7 @@ func TestUpdateSwapInvariant(t *testing.T) { SetBlockTime(startBlockTime), SetBlockNumber(1), FundAccount(alice, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(10_200_000_000)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), ). When( MarketOrder(alice, pairBtcNusd, types.Direction_LONG, sdk.NewInt(10_000_000_000), sdk.OneDec(), sdk.ZeroDec()), @@ -1926,7 +1926,7 @@ func TestUpdateSwapInvariant(t *testing.T) { SetBlockTime(startBlockTime), SetBlockNumber(1), FundAccount(alice, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(10_200_000_000)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), ). When( MarketOrder(alice, pairBtcNusd, types.Direction_SHORT, sdk.NewInt(10_000_000_000), sdk.OneDec(), sdk.ZeroDec()), @@ -1947,7 +1947,7 @@ func TestUpdateSwapInvariant(t *testing.T) { SetBlockTime(startBlockTime), SetBlockNumber(1), FundAccount(alice, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(10_200_000_000)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), ). When( MarketOrder(alice, pairBtcNusd, types.Direction_LONG, sdk.NewInt(10_000_000_000), sdk.OneDec(), sdk.ZeroDec()), @@ -1969,7 +1969,7 @@ func TestUpdateSwapInvariant(t *testing.T) { SetBlockTime(startBlockTime), SetBlockNumber(1), FundAccount(alice, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(10_200_000_000)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), ). When( MarketOrder(alice, pairBtcNusd, types.Direction_SHORT, sdk.NewInt(10_000_000_000), sdk.OneDec(), sdk.ZeroDec()), @@ -2015,7 +2015,7 @@ func TestUpdateSwapInvariant(t *testing.T) { PositionShouldNotExist(bob, pairBtcNusd, 1), ModuleBalanceShouldBeEqualTo(types.VaultModuleAccount, sdk.NewCoins()), - ModuleBalanceShouldBeEqualTo(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(39_960_000)))), + ModuleBalanceShouldBeEqualTo(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(39_960_000)))), ), TC("long and short position - reducing k"). Given( @@ -2047,7 +2047,7 @@ func TestUpdateSwapInvariant(t *testing.T) { PositionShouldNotExist(bob, pairBtcNusd, 1), ModuleBalanceShouldBeEqualTo(types.VaultModuleAccount, sdk.NewCoins()), - ModuleBalanceShouldBeEqualTo(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(39_960_000)))), + ModuleBalanceShouldBeEqualTo(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(39_960_000)))), ), } diff --git a/x/perp/v2/keeper/dnr_test.go b/x/perp/v2/keeper/dnr_test.go index 1dcab9e46..ced828f7c 100644 --- a/x/perp/v2/keeper/dnr_test.go +++ b/x/perp/v2/keeper/dnr_test.go @@ -38,7 +38,7 @@ func TestUserVolumes(t *testing.T) { SetBlockTime(startBlockTime), FundAccount(alice, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, positionSize.AddRaw(1000)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), ). When( MarketOrder(alice, pairBtcNusd, types.Direction_LONG, sdk.NewInt(10_000), sdk.OneDec(), sdk.ZeroDec()), @@ -59,7 +59,7 @@ func TestUserVolumes(t *testing.T) { SetBlockTime(startBlockTime), FundAccount(alice, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, positionSize.AddRaw(1000)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), ). When( DnREpochIs(1), @@ -83,7 +83,7 @@ func TestUserVolumes(t *testing.T) { SetBlockTime(startBlockTime), FundAccount(alice, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, positionSize.AddRaw(1000)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), ).When( DnREpochIs(1), MarketOrder(alice, pairBtcNusd, types.Direction_LONG, sdk.NewInt(10_000), sdk.OneDec(), sdk.ZeroDec()), // open epoch 1 @@ -126,7 +126,7 @@ func TestDiscount(t *testing.T) { SetBlockTime(startBlockTime), FundAccount(alice, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, positionSize.AddRaw(1000)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), ). When( DnREpochIs(1), @@ -147,7 +147,7 @@ func TestDiscount(t *testing.T) { SetBlockTime(startBlockTime), FundAccount(alice, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, positionSize.AddRaw(1000)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), ). When( SetGlobalDiscount(fauxGlobalFeeDiscount, sdk.NewInt(50_000)), @@ -172,7 +172,7 @@ func TestDiscount(t *testing.T) { SetBlockTime(startBlockTime), FundAccount(alice, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, positionSize.AddRaw(1000)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), ). When( SetGlobalDiscount(globalFeeDiscount, sdk.NewInt(50_000)), @@ -197,7 +197,7 @@ func TestDiscount(t *testing.T) { SetBlockTime(startBlockTime), FundAccount(alice, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, positionSize.AddRaw(1000)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(100_000_000)))), ). When( SetGlobalDiscount(sdk.MustNewDecFromStr("0.0004"), sdk.NewInt(50_000)), @@ -235,7 +235,7 @@ func TestRebates(t *testing.T) { FundAccount(alice, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, positionSize.AddRaw(100_000)))), FundAccount(bob, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, positionSize.AddRaw(100_000)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(denoms.NUSD, sdk.NewInt(100_000_000)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(denoms.NUSD, sdk.NewInt(100_000_000)))), ). When( DnREpochIs(1), diff --git a/x/perp/v2/keeper/grpc_query_test.go b/x/perp/v2/keeper/grpc_query_test.go index de30f16b9..80f119641 100644 --- a/x/perp/v2/keeper/grpc_query_test.go +++ b/x/perp/v2/keeper/grpc_query_test.go @@ -347,7 +347,7 @@ func TestQueryMarkets(t *testing.T) { WithEnabled(true), WithPricePeg(sdk.NewDec(2)), ), - FundModule("perp_ef", sdk.NewCoins(sdk.NewCoin(denoms.NUSD, sdk.NewInt(10)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(denoms.NUSD, sdk.NewInt(10)))), ). When( InsertPosition( @@ -364,7 +364,7 @@ func TestQueryMarkets(t *testing.T) { ), QueryModuleAccounts(QueryModuleAccounts_ModulesBalanceShouldBe( map[string]sdk.Coins{ - "perp_ef": sdk.NewCoins( + types.PerpFundModuleAccount: sdk.NewCoins( sdk.NewCoin(denoms.BTC, sdk.ZeroInt()), sdk.NewCoin(denoms.NUSD, sdk.NewInt(10)), ), diff --git a/x/perp/v2/keeper/keeper.go b/x/perp/v2/keeper/keeper.go index 998e36b7f..309e6e124 100644 --- a/x/perp/v2/keeper/keeper.go +++ b/x/perp/v2/keeper/keeper.go @@ -28,9 +28,6 @@ type Keeper struct { EpochKeeper types.EpochKeeper SudoKeeper types.SudoKeeper - // Extends the Keeper with admin functions. See admin.go. - Admin admin - MarketLastVersion collections.Map[asset.Pair, types.MarketLastVersion] Markets collections.Map[collections.Pair[asset.Pair, uint64], types.Market] AMMs collections.Map[collections.Pair[asset.Pair, uint64], types.AMM] @@ -63,7 +60,7 @@ func NewKeeper( panic("The x/perp module account has not been set") } - k := Keeper{ + return Keeper{ cdc: cdc, storeKey: storeKey, BankKeeper: bankKeeper, @@ -134,8 +131,6 @@ func NewKeeper( common.StringValueEncoder, ), } - k.Admin = admin{&k} - return k } const ( diff --git a/x/perp/v2/keeper/liquidate.go b/x/perp/v2/keeper/liquidate.go index 25290ec09..3be649238 100644 --- a/x/perp/v2/keeper/liquidate.go +++ b/x/perp/v2/keeper/liquidate.go @@ -418,7 +418,7 @@ func (k Keeper) distributeLiquidateRewards( if err = k.BankKeeper.SendCoinsFromModuleToModule( ctx, /* from */ types.VaultModuleAccount, - /* to */ types.PerpEFModuleAccount, + /* to */ types.PerpFundModuleAccount, sdk.NewCoins(ecosystemFundFee), ); err != nil { return err diff --git a/x/perp/v2/keeper/liquidate_test.go b/x/perp/v2/keeper/liquidate_test.go index dc3ec4b6a..736dcd672 100644 --- a/x/perp/v2/keeper/liquidate_test.go +++ b/x/perp/v2/keeper/liquidate_test.go @@ -47,7 +47,7 @@ func TestMultiLiquidate(t *testing.T) { ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(750)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(125)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(125)), BalanceEqual(liquidator, types.TestingCollateralDenomNUSD, sdk.NewInt(125)), PositionShouldBeEqual(alice, pairBtcUsdc, Position_PositionShouldBeEqualTo( @@ -81,7 +81,7 @@ func TestMultiLiquidate(t *testing.T) { ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(600)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(150)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(150)), BalanceEqual(liquidator, types.TestingCollateralDenomNUSD, sdk.NewInt(250)), PositionShouldNotExist(alice, pairBtcUsdc, 1), ), @@ -102,7 +102,7 @@ func TestMultiLiquidate(t *testing.T) { ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(600)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(150)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(150)), BalanceEqual(liquidator, types.TestingCollateralDenomNUSD, sdk.NewInt(250)), PositionShouldNotExist(alice, pairBtcUsdc, 1), ), @@ -124,7 +124,7 @@ func TestMultiLiquidate(t *testing.T) { ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(600)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(150)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(150)), BalanceEqual(liquidator, types.TestingCollateralDenomNUSD, sdk.NewInt(250)), PositionShouldNotExist(alice, pairBtcUsdc, 1), ), @@ -146,7 +146,7 @@ func TestMultiLiquidate(t *testing.T) { ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(600)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(150)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(150)), BalanceEqual(liquidator, types.TestingCollateralDenomNUSD, sdk.NewInt(250)), PositionShouldNotExist(alice, pairBtcUsdc, 1), ), @@ -158,7 +158,7 @@ func TestMultiLiquidate(t *testing.T) { CreateCustomMarket(pairBtcUsdc), InsertPosition(WithTrader(alice), WithPair(pairBtcUsdc), WithSize(sdk.NewDec(10000)), WithMargin(sdk.NewDec(1000)), WithOpenNotional(sdk.NewDec(10800))), FundModule(types.VaultModuleAccount, sdk.NewCoins(sdk.NewInt64Coin(types.TestingCollateralDenomNUSD, 1000))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewInt64Coin(types.TestingCollateralDenomNUSD, 50))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewInt64Coin(types.TestingCollateralDenomNUSD, 50))), ). When( MoveToNextBlock(), @@ -168,7 +168,7 @@ func TestMultiLiquidate(t *testing.T) { ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(800)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.ZeroInt()), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.ZeroInt()), BalanceEqual(liquidator, types.TestingCollateralDenomNUSD, sdk.NewInt(250)), PositionShouldNotExist(alice, pairBtcUsdc, 1), ), @@ -189,7 +189,7 @@ func TestMultiLiquidate(t *testing.T) { ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(750)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.ZeroInt()), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.ZeroInt()), BalanceEqual(liquidator, types.TestingCollateralDenomNUSD, sdk.NewInt(250)), PositionShouldNotExist(alice, pairBtcUsdc, 1), MarketShouldBeEqual(pairBtcUsdc, Market_PrepaidBadDebtShouldBeEqualTo(sdk.ZeroInt(), types.TestingCollateralDenomNUSD)), @@ -211,7 +211,7 @@ func TestMultiLiquidate(t *testing.T) { ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(10)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.ZeroInt()), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.ZeroInt()), BalanceEqual(liquidator, types.TestingCollateralDenomNUSD, sdk.ZeroInt()), PositionShouldBeEqual(alice, pairBtcUsdc, Position_PositionShouldBeEqualTo( @@ -258,7 +258,7 @@ func TestMultiLiquidate(t *testing.T) { ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(2350)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(275)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(275)), BalanceEqual(liquidator, types.TestingCollateralDenomNUSD, sdk.NewInt(375)), PositionShouldBeEqual(alice, pairBtcUsdc, Position_PositionShouldBeEqualTo( diff --git a/x/perp/v2/keeper/margin_test.go b/x/perp/v2/keeper/margin_test.go index f1cb16a80..45dbc7e02 100644 --- a/x/perp/v2/keeper/margin_test.go +++ b/x/perp/v2/keeper/margin_test.go @@ -71,7 +71,7 @@ func TestAddMargin(t *testing.T) { ExchangedSize: sdk.MustNewDecFromStr("0"), }), BalanceEqual(alice, types.TestingCollateralDenomNUSD, sdk.ZeroInt()), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(10)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(10)), ModuleBalanceEqual(types.FeePoolModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(10)), ), @@ -121,7 +121,7 @@ func TestAddMargin(t *testing.T) { ExchangedSize: sdk.MustNewDecFromStr("0"), }), BalanceEqual(alice, types.TestingCollateralDenomNUSD, sdk.ZeroInt()), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(10)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(10)), ModuleBalanceEqual(types.FeePoolModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(10)), ), @@ -201,7 +201,7 @@ func TestRemoveMargin(t *testing.T) { ExchangedSize: sdk.MustNewDecFromStr("0"), }), BalanceEqual(alice, types.TestingCollateralDenomNUSD, sdk.NewInt(500)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.OneInt()), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.OneInt()), ModuleBalanceEqual(types.FeePoolModuleAccount, types.TestingCollateralDenomNUSD, sdk.OneInt()), ), @@ -228,7 +228,7 @@ func TestRemoveMargin(t *testing.T) { LastUpdatedBlockNumber: 1, })), BalanceEqual(alice, types.TestingCollateralDenomNUSD, sdk.ZeroInt()), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.OneInt()), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.OneInt()), ModuleBalanceEqual(types.FeePoolModuleAccount, types.TestingCollateralDenomNUSD, sdk.OneInt()), ), @@ -276,7 +276,7 @@ func TestRemoveMargin(t *testing.T) { ExchangedSize: sdk.MustNewDecFromStr("0"), }), BalanceEqual(alice, types.TestingCollateralDenomNUSD, sdk.NewInt(500)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.OneInt()), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.OneInt()), ModuleBalanceEqual(types.FeePoolModuleAccount, types.TestingCollateralDenomNUSD, sdk.OneInt()), ), @@ -303,7 +303,7 @@ func TestRemoveMargin(t *testing.T) { LastUpdatedBlockNumber: 1, })), BalanceEqual(alice, types.TestingCollateralDenomNUSD, sdk.ZeroInt()), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.OneInt()), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.OneInt()), ModuleBalanceEqual(types.FeePoolModuleAccount, types.TestingCollateralDenomNUSD, sdk.OneInt()), ), } diff --git a/x/perp/v2/keeper/msg_server.go b/x/perp/v2/keeper/msg_server.go index 650526b41..6db05ede6 100644 --- a/x/perp/v2/keeper/msg_server.go +++ b/x/perp/v2/keeper/msg_server.go @@ -131,7 +131,7 @@ func (m msgServer) DonateToEcosystemFund(ctx context.Context, msg *types.MsgDona if err := m.k.BankKeeper.SendCoinsFromAccountToModule( sdk.UnwrapSDKContext(ctx), sdk.MustAccAddressFromBech32(msg.Sender), - types.PerpEFModuleAccount, + types.PerpFundModuleAccount, sdk.NewCoins(msg.Donation), ); err != nil { return nil, err @@ -141,7 +141,7 @@ func (m msgServer) DonateToEcosystemFund(ctx context.Context, msg *types.MsgDona } // 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. +// possible to make an sdk.Coin using it. [SUDO] Only callable by sudoers. func (m msgServer) ChangeCollateralDenom( goCtx context.Context, txMsg *types.MsgChangeCollateralDenom, ) (resp *types.MsgChangeCollateralDenomResponse, err error) { @@ -153,7 +153,7 @@ func (m msgServer) ChangeCollateralDenom( } ctx := sdk.UnwrapSDKContext(goCtx) - err = m.k.Admin.ChangeCollateralDenom(ctx, txMsg.NewDenom, txMsg.GetSigners()[0]) + err = m.k.Sudo().ChangeCollateralDenom(ctx, txMsg.NewDenom, txMsg.GetSigners()[0]) return &types.MsgChangeCollateralDenomResponse{}, err } @@ -196,25 +196,39 @@ func (m msgServer) WithdrawEpochRebates(ctx context.Context, msg *types.MsgWithd } // ShiftPegMultiplier: gRPC tx msg for changing a market's peg multiplier. -// [Admin] Only callable by sudoers. +// [SUDO] 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) + err := m.k.Sudo().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. +// [SUDO] 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) + err := m.k.Sudo().ShiftSwapInvariant(ctx, msg.Pair, msg.NewSwapInvariant, sender) return &types.MsgShiftSwapInvariantResponse{}, err } + +// WithdrawFromPerpFund: gRPC tx msg for changing a market's swap invariant. +// [SUDO] Only callable by sudoers. +func (m msgServer) WithdrawFromPerpFund( + goCtx context.Context, msg *types.MsgWithdrawFromPerpFund, +) (resp *types.MsgWithdrawFromPerpFundResponse, err error) { + // Sender is checked in `msg.ValidateBasic` before reaching this fn call. + sender, _ := sdk.AccAddressFromBech32(msg.Sender) + toAddr, _ := sdk.AccAddressFromBech32(msg.ToAddr) + ctx := sdk.UnwrapSDKContext(goCtx) + return resp, m.k.Sudo().WithdrawFromPerpFund( + ctx, msg.Amount, sender, toAddr, msg.Denom, + ) +} diff --git a/x/perp/v2/keeper/msg_server_test.go b/x/perp/v2/keeper/msg_server_test.go index 0d357178a..736206169 100644 --- a/x/perp/v2/keeper/msg_server_test.go +++ b/x/perp/v2/keeper/msg_server_test.go @@ -246,7 +246,7 @@ func TestMsgServerDonateToPerpEf(t *testing.T) { ). Then( BalanceEqual(alice, types.TestingCollateralDenomNUSD, sdk.NewInt(50)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(50)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(50)), ), } @@ -276,7 +276,7 @@ func TestMsgServerMultiLiquidate(t *testing.T) { ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(750)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(125)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(125)), BalanceEqual(liquidator, types.TestingCollateralDenomNUSD, sdk.NewInt(125)), PositionShouldBeEqual(alice, pairBtcUsdc, Position_PositionShouldBeEqualTo( @@ -309,7 +309,7 @@ func TestMsgServerMultiLiquidate(t *testing.T) { ). Then( ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(600)), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(150)), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.NewInt(150)), BalanceEqual(liquidator, types.TestingCollateralDenomNUSD, sdk.NewInt(250)), PositionShouldNotExist(alice, pairBtcUsdc, 1), ), diff --git a/x/perp/v2/keeper/admin.go b/x/perp/v2/keeper/sudo.go similarity index 76% rename from x/perp/v2/keeper/admin.go rename to x/perp/v2/keeper/sudo.go index 78270101a..0da898072 100644 --- a/x/perp/v2/keeper/admin.go +++ b/x/perp/v2/keeper/sudo.go @@ -11,46 +11,54 @@ import ( types "github.com/NibiruChain/nibiru/x/perp/v2/types" ) -// Extends the Keeper with admin functions. Admin is syntactic sugar to separate -// admin calls off from the other Keeper methods. +// Sudo extends the Keeper with sudo functions. Sudo is syntactic sugar to separate +// sudoExtension calls off from the other Keeper methods. // -// These Admin functions should: -// 1. Not be wired into the MsgServer. -// 2. Not be called in other methods in the x/perp module. -// 3. Only be callable from nibiru/wasmbinding via sudo contracts. +// These Sudo functions should: +// 1. Not be called in other methods in the x/perp module. +// 2. Only be callable from the x/sudo root or sudo contracts. // -// The intention here is to make it more obvious to the developer that an unsafe -// function is being used when it's called from the PerpKeeper.Admin struct. -type admin struct{ *Keeper } - -/* -WithdrawFromInsuranceFund sends funds from the Insurance Fund to the given "to" -address. - -Args: -- ctx: Blockchain context holding the current state -- amount: Amount of micro-NUSD to withdraw. -- to: Recipient address -*/ -func (k admin) WithdrawFromInsuranceFund( - ctx sdk.Context, amount sdkmath.Int, to sdk.AccAddress, +// The intention behind "sudoExtension" is to make it more obvious to the +// developer that an unsafe function is being used when it's called from +// "PerpKeeper.Sudo()" +func (k Keeper) Sudo() sudoExtension { return sudoExtension{k} } + +type sudoExtension struct{ Keeper } + +// WithdrawFromPerpFund sends funds from the Perp Fund to the "to" address. +// +// Args: +// - ctx: Blockchain context holding the current state +// - amount: Amount of micro-NUSD to withdraw. +// - sender: Admin address registered in x/sudo +// - to: Recipient address +func (k sudoExtension) WithdrawFromPerpFund( + ctx sdk.Context, amount sdkmath.Int, sender, to sdk.AccAddress, denom string, ) (err error) { - collateral, err := k.Collateral.Get(ctx) - if err != nil { + if err := k.SudoKeeper.CheckPermissions(sender, ctx); err != nil { return err } - coinToSend := sdk.NewCoin(collateral, amount) + var collateralDenom string = denom + if denom == "" { + denomFromState, err := k.Collateral.Get(ctx) + if err != nil { + return err + } + collateralDenom = denomFromState + } + + coinToSend := sdk.NewCoin(collateralDenom, amount) if err = k.BankKeeper.SendCoinsFromModuleToAccount( ctx, - /* from */ types.PerpEFModuleAccount, + /* from */ types.PerpFundModuleAccount, /* to */ to, /* amount */ sdk.NewCoins(coinToSend), ); err != nil { return err } ctx.EventManager().EmitEvent(sdk.NewEvent( - "withdraw_from_if", + "withdraw_from_perp_fund", sdk.NewAttribute("to", to.String()), sdk.NewAttribute("funds", coinToSend.String()), )) @@ -68,7 +76,7 @@ type ArgsCreateMarket struct { } // CreateMarket creates a pool for a specific pair. -func (k admin) CreateMarket( +func (k sudoExtension) CreateMarket( ctx sdk.Context, args ArgsCreateMarket, ) error { @@ -121,7 +129,7 @@ func (k admin) 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 admin) CloseMarket(ctx sdk.Context, pair asset.Pair) (err error) { +func (k sudoExtension) CloseMarket(ctx sdk.Context, pair asset.Pair) (err error) { market, err := k.GetMarket(ctx, pair) if err != nil { return err @@ -150,8 +158,8 @@ func (k admin) CloseMarket(ctx sdk.Context, pair asset.Pair) (err 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. -func (k admin) ChangeCollateralDenom( +// possible to make an sdk.Coin using it. [SUDO] Only callable by sudoers. +func (k sudoExtension) ChangeCollateralDenom( ctx sdk.Context, denom string, sender sdk.AccAddress, @@ -164,7 +172,7 @@ func (k admin) ChangeCollateralDenom( // UnsafeChangeCollateralDenom: Used in the genesis to set the collateral // without requiring an explicit call from sudoers. -func (k admin) UnsafeChangeCollateralDenom( +func (k sudoExtension) UnsafeChangeCollateralDenom( ctx sdk.Context, denom string, ) error { @@ -178,7 +186,7 @@ func (k admin) UnsafeChangeCollateralDenom( // 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( +func (k sudoExtension) ShiftPegMultiplier( ctx sdk.Context, pair asset.Pair, newPriceMultiplier sdk.Dec, @@ -224,7 +232,7 @@ func (k admin) ShiftPegMultiplier( // 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( +func (k sudoExtension) ShiftSwapInvariant( ctx sdk.Context, pair asset.Pair, newSwapInvariant sdkmath.Int, diff --git a/x/perp/v2/keeper/admin_test.go b/x/perp/v2/keeper/sudo_test.go similarity index 85% rename from x/perp/v2/keeper/admin_test.go rename to x/perp/v2/keeper/sudo_test.go index 365140995..9fdd4db63 100644 --- a/x/perp/v2/keeper/admin_test.go +++ b/x/perp/v2/keeper/sudo_test.go @@ -28,78 +28,70 @@ import ( . "github.com/NibiruChain/nibiru/x/perp/v2/integration/assertion" ) -func TestAdmin_WithdrawFromInsuranceFund(t *testing.T) { - expectBalance := func( - want sdkmath.Int, t *testing.T, nibiru *app.NibiruApp, ctx sdk.Context, - ) { - insuranceFund := nibiru.AccountKeeper.GetModuleAddress(perptypes.PerpEFModuleAccount) - balances := nibiru.BankKeeper.GetAllBalances(ctx, insuranceFund) - got := balances.AmountOf(perptypes.TestingCollateralDenomNUSD) - require.EqualValues(t, want.String(), got.String()) - } - - setup := func() (nibiru *app.NibiruApp, ctx sdk.Context) { - testapp.EnsureNibiruPrefix() - nibiru, ctx = testapp.NewNibiruTestAppAndContext() - expectBalance(sdk.ZeroInt(), t, nibiru, ctx) - nibiru.PerpKeeperV2.Collateral.Set(ctx, perptypes.TestingCollateralDenomNUSD) - return nibiru, ctx - } - - fundModule := func(t *testing.T, amount sdkmath.Int, ctx sdk.Context, nibiru *app.NibiruApp) { +func (s *TestSuiteAdmin) TestAdmin_WithdrawFromPerpFund() { + fundModule := func(amount sdkmath.Int, ctx sdk.Context, nibiru *app.NibiruApp) { coins := sdk.NewCoins(sdk.NewCoin(perptypes.TestingCollateralDenomNUSD, amount)) err := testapp.FundModuleAccount( - nibiru.BankKeeper, ctx, perptypes.PerpEFModuleAccount, + nibiru.BankKeeper, ctx, perptypes.PerpFundModuleAccount, coins, ) - require.NoError(t, err) + s.NoError(err) } testCases := []testutil.FunctionTestCase{ { Name: "withdraw all", Test: func() { - nibiru, ctx := setup() - admin := testutil.AccAddress() + s.SetupTest() + nibiru, ctx := s.nibiru, s.ctx + admin := s.addrAdmin amountToFund := sdk.NewInt(420) - fundModule(t, amountToFund, ctx, nibiru) + fundModule(amountToFund, ctx, nibiru) + balBefore := nibiru.BankKeeper.GetBalance(ctx, admin, perptypes.TestingCollateralDenomNUSD).Amount amountToWithdraw := amountToFund - err := nibiru.PerpKeeperV2.Admin.WithdrawFromInsuranceFund( - ctx, amountToWithdraw, admin) - require.NoError(t, err) + err := nibiru.PerpKeeperV2.Sudo().WithdrawFromPerpFund( + ctx, amountToWithdraw, admin, admin, "") + s.Require().NoError(err) - require.EqualValues(t, + balAfter := nibiru.BankKeeper.GetBalance(ctx, admin, perptypes.TestingCollateralDenomNUSD).Amount + s.EqualValues( amountToFund.String(), - nibiru.BankKeeper.GetBalance(ctx, admin, perptypes.TestingCollateralDenomNUSD).Amount.String(), + balAfter.Sub(balBefore).String(), ) - expectBalance(sdk.ZeroInt(), t, nibiru, ctx) + + perpFundAddr := nibiru.AccountKeeper.GetModuleAddress(perptypes.PerpFundModuleAccount) + got := nibiru.BankKeeper.GetAllBalances(ctx, perpFundAddr).AmountOf(perptypes.TestingCollateralDenomNUSD) + s.EqualValues(sdkmath.ZeroInt().String(), got.String()) }, }, { Name: "withdraw too much - err", Test: func() { - nibiru, ctx := setup() - admin := testutil.AccAddress() + s.SetupTest() + nibiru, ctx := s.nibiru, s.ctx + admin := s.addrAdmin amountToFund := sdk.NewInt(420) - fundModule(t, amountToFund, ctx, nibiru) + fundModule(amountToFund, ctx, nibiru) amountToWithdraw := amountToFund.MulRaw(5) - err := nibiru.PerpKeeperV2.Admin.WithdrawFromInsuranceFund( - ctx, amountToWithdraw, admin) - require.Error(t, err) + err := nibiru.PerpKeeperV2.Sudo().WithdrawFromPerpFund( + ctx, amountToWithdraw, admin, admin, "") + s.Require().Error(err) }, }, } - testutil.RunFunctionTests(t, testCases) + for _, tc := range testCases { + s.Run(tc.Name, tc.Test) + } } func TestCreateMarket(t *testing.T) { pair := asset.Registry.Pair(denoms.BTC, denoms.NUSD) amm := *mock.TestAMMDefault() app, ctx := testapp.NewNibiruTestAppAndContext() - admin := app.PerpKeeperV2.Admin + admin := app.PerpKeeperV2.Sudo() // Error because of invalid market market := perptypes.DefaultMarket(pair).WithMaintenanceMarginRatio(sdk.NewDec(2)) @@ -343,7 +335,7 @@ func TestAdmin_ChangeCollateralDenom(t *testing.T) { } { t.Run(tc.name, func(t *testing.T) { bapp, ctx := setup() - err := bapp.PerpKeeperV2.Admin.ChangeCollateralDenom( + err := bapp.PerpKeeperV2.Sudo().ChangeCollateralDenom( ctx, tc.newDenom, tc.sender, ) @@ -412,6 +404,8 @@ func (s *TestSuiteAdmin) HandleMsg(txMsg sdk.Msg) (err error) { _, err = s.perpMsgServer.ShiftSwapInvariant(ctx, msg) case *perptypes.MsgChangeCollateralDenom: _, err = s.perpMsgServer.ChangeCollateralDenom(ctx, msg) + case *perptypes.MsgWithdrawFromPerpFund: + _, err = s.perpMsgServer.WithdrawFromPerpFund(ctx, msg) default: return fmt.Errorf("unexpected message of type %T encountered", msg) } @@ -438,6 +432,12 @@ func (s *TestSuiteAdmin) TestCheckPermissions() { &perptypes.MsgChangeCollateralDenom{ Sender: sender, NewDenom: "newdenom", }, + &perptypes.MsgWithdrawFromPerpFund{ + Sender: sender, + Amount: sdk.NewInt(420), + Denom: "", + ToAddr: sender, + }, } { s.Run(fmt.Sprintf("%T", testCaseMsg), func() { err := s.HandleMsg(testCaseMsg) @@ -468,6 +468,24 @@ func (s *TestSuiteAdmin) DoShiftSwapInvariantTest(pair asset.Pair) error { return err } +func (s *TestSuiteAdmin) DoWithdrawFromPerpFundTest(toAddr string) error { + wantCoin := sdk.NewInt64Coin("perpfundtest", 25) + s.NoError( + testapp.FundModuleAccount( + s.nibiru.BankKeeper, s.ctx, types.PerpFundModuleAccount, + sdk.NewCoins(wantCoin)), + ) + _, err := s.perpMsgServer.WithdrawFromPerpFund( + sdk.WrapSDKContext(s.ctx), &perptypes.MsgWithdrawFromPerpFund{ + Sender: s.addrAdmin.String(), + Amount: wantCoin.Amount, + Denom: wantCoin.Denom, + ToAddr: toAddr, + }, + ) + return err +} + // TestAdmin_DoHappy: Happy path test cases func (s *TestSuiteAdmin) TestAdmin_DoHappy() { pair := asset.Registry.Pair(denoms.ATOM, denoms.NUSD) @@ -475,6 +493,7 @@ func (s *TestSuiteAdmin) TestAdmin_DoHappy() { for _, err := range []error{ s.DoShiftPegTest(pair), s.DoShiftSwapInvariantTest(pair), + s.DoWithdrawFromPerpFundTest(s.addrAdmin.String()), } { s.NoError(err) } diff --git a/x/perp/v2/keeper/withdraw.go b/x/perp/v2/keeper/withdraw.go index f39f4ab71..29c89ff23 100644 --- a/x/perp/v2/keeper/withdraw.go +++ b/x/perp/v2/keeper/withdraw.go @@ -62,7 +62,7 @@ func (k Keeper) WithdrawFromVault( if err := k.BankKeeper.SendCoinsFromModuleToModule( ctx, - types.PerpEFModuleAccount, + types.PerpFundModuleAccount, types.VaultModuleAccount, sdk.NewCoins( sdk.NewCoin(collateral, shortage), @@ -125,7 +125,7 @@ func (k Keeper) realizeBadDebt(ctx sdk.Context, market types.Market, badDebtToRe } return k.BankKeeper.SendCoinsFromModuleToModule(ctx, - /*from=*/ types.PerpEFModuleAccount, + /*from=*/ types.PerpFundModuleAccount, /*to=*/ types.VaultModuleAccount, sdk.NewCoins( sdk.NewCoin( diff --git a/x/perp/v2/keeper/withdraw_test.go b/x/perp/v2/keeper/withdraw_test.go index 5415c6b5c..040ff7e15 100644 --- a/x/perp/v2/keeper/withdraw_test.go +++ b/x/perp/v2/keeper/withdraw_test.go @@ -44,7 +44,7 @@ func TestWithdrawFromVault(t *testing.T) { SetBlockTime(startBlockTime), CreateCustomMarket(pairBtcUsdc), FundModule(types.VaultModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(500)))), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(500)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(500)))), ). When( WithdrawFromVault(pairBtcUsdc, alice, sdk.NewInt(1000)), @@ -52,7 +52,7 @@ func TestWithdrawFromVault(t *testing.T) { Then( BalanceEqual(alice, types.TestingCollateralDenomNUSD, sdk.NewInt(1000)), ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.ZeroInt()), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.ZeroInt()), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.ZeroInt()), MarketShouldBeEqual(pairBtcUsdc, Market_PrepaidBadDebtShouldBeEqualTo(sdk.NewInt(500), types.TestingCollateralDenomNUSD)), ), @@ -61,7 +61,7 @@ func TestWithdrawFromVault(t *testing.T) { SetBlockNumber(1), SetBlockTime(startBlockTime), CreateCustomMarket(pairBtcUsdc), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1000)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1000)))), ). When( WithdrawFromVault(pairBtcUsdc, alice, sdk.NewInt(1000)), @@ -69,7 +69,7 @@ func TestWithdrawFromVault(t *testing.T) { Then( BalanceEqual(alice, types.TestingCollateralDenomNUSD, sdk.NewInt(1000)), ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.ZeroInt()), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.ZeroInt()), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.ZeroInt()), MarketShouldBeEqual(pairBtcUsdc, Market_PrepaidBadDebtShouldBeEqualTo(sdk.NewInt(1000), types.TestingCollateralDenomNUSD)), ), @@ -78,7 +78,7 @@ func TestWithdrawFromVault(t *testing.T) { SetBlockNumber(1), SetBlockTime(startBlockTime), CreateCustomMarket(pairBtcUsdc, WithPrepaidBadDebt(sdk.NewInt(1000), types.TestingCollateralDenomNUSD)), - FundModule(types.PerpEFModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1000)))), + FundModule(types.PerpFundModuleAccount, sdk.NewCoins(sdk.NewCoin(types.TestingCollateralDenomNUSD, sdk.NewInt(1000)))), ). When( WithdrawFromVault(pairBtcUsdc, alice, sdk.NewInt(1000)), @@ -86,7 +86,7 @@ func TestWithdrawFromVault(t *testing.T) { Then( BalanceEqual(alice, types.TestingCollateralDenomNUSD, sdk.NewInt(1000)), ModuleBalanceEqual(types.VaultModuleAccount, types.TestingCollateralDenomNUSD, sdk.ZeroInt()), - ModuleBalanceEqual(types.PerpEFModuleAccount, types.TestingCollateralDenomNUSD, sdk.ZeroInt()), + ModuleBalanceEqual(types.PerpFundModuleAccount, types.TestingCollateralDenomNUSD, sdk.ZeroInt()), MarketShouldBeEqual(pairBtcUsdc, Market_PrepaidBadDebtShouldBeEqualTo(sdk.NewInt(2000), types.TestingCollateralDenomNUSD)), ), } diff --git a/x/perp/v2/module/abci_test.go b/x/perp/v2/module/abci_test.go index 4da2dbc78..164262f80 100644 --- a/x/perp/v2/module/abci_test.go +++ b/x/perp/v2/module/abci_test.go @@ -34,7 +34,7 @@ func TestSnapshotUpdates(t *testing.T) { ctx = ctx.WithBlockTime(time.Date(2015, 10, 21, 0, 0, 0, 0, time.UTC)).WithBlockHeight(1) - require.NoError(t, app.PerpKeeperV2.Admin.CreateMarket( + require.NoError(t, app.PerpKeeperV2.Sudo().CreateMarket( /* ctx */ ctx, keeper.ArgsCreateMarket{ Pair: asset.Registry.Pair(denoms.BTC, denoms.NUSD), PriceMultiplier: initialAmm.PriceMultiplier, @@ -119,7 +119,7 @@ func TestEndBlocker(t *testing.T) { runBlock(5 * time.Second) - require.NoError(t, app.PerpKeeperV2.Admin.CreateMarket( + require.NoError(t, app.PerpKeeperV2.Sudo().CreateMarket( /* ctx */ ctx, keeper.ArgsCreateMarket{ Pair: asset.Registry.Pair(denoms.BTC, denoms.NUSD), PriceMultiplier: initialAmm.PriceMultiplier, diff --git a/x/perp/v2/module/genesis.go b/x/perp/v2/module/genesis.go index 623ae04c5..080bc5443 100644 --- a/x/perp/v2/module/genesis.go +++ b/x/perp/v2/module/genesis.go @@ -74,7 +74,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) } if genState.CollateralDenom != "" { - err := k.Admin.UnsafeChangeCollateralDenom(ctx, genState.CollateralDenom) + err := k.Sudo().UnsafeChangeCollateralDenom(ctx, genState.CollateralDenom) if err != nil { panic(err) } diff --git a/x/perp/v2/module/genesis_test.go b/x/perp/v2/module/genesis_test.go index 7844f8885..f92dcbf45 100644 --- a/x/perp/v2/module/genesis_test.go +++ b/x/perp/v2/module/genesis_test.go @@ -91,7 +91,7 @@ func RunTestGenesis(t *testing.T, tc TestCase) { app.SudoKeeper.Sudoers.Set(ctx, sudoers) // create some params - require.NoError(t, app.PerpKeeperV2.Admin.ChangeCollateralDenom( + require.NoError(t, app.PerpKeeperV2.Sudo().ChangeCollateralDenom( ctx, "unusd", sudoersRoot)) app.PerpKeeperV2.SaveMarket(ctx, *mock.TestMarket()) app.PerpKeeperV2.MarketLastVersion.Insert(ctx, pair, types.MarketLastVersion{Version: 1}) diff --git a/x/perp/v2/module/module.go b/x/perp/v2/module/module.go index c58d70c7a..8770bb84a 100644 --- a/x/perp/v2/module/module.go +++ b/x/perp/v2/module/module.go @@ -145,7 +145,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.Ra InitGenesis(ctx, am.keeper, genState) // See https://github.com/cosmos/cosmos-sdk/issues/5569 on why we do this. - am.ak.GetModuleAccount(ctx, types.PerpEFModuleAccount) + am.ak.GetModuleAccount(ctx, types.PerpFundModuleAccount) am.ak.GetModuleAccount(ctx, types.VaultModuleAccount) am.ak.GetModuleAccount(ctx, types.FeePoolModuleAccount) diff --git a/x/perp/v2/types/errors.go b/x/perp/v2/types/errors.go index abd3a008b..dd16027e9 100644 --- a/x/perp/v2/types/errors.go +++ b/x/perp/v2/types/errors.go @@ -50,6 +50,7 @@ var ( ErrSettlementPositionMarketEnabled = registerError("market is enabled, you can only settle position on disabled market") ErrCollateralDenomNotSet = registerError("ErrorCollateral: no collateral denom set for the perp keeper") ErrInvalidCollateral = registerError("ErrorCollateral: invalid collateral denom") + ErrGeneric = registerError("perp GenericError") ) // Register error instance for "ErrorMarketOrder" diff --git a/x/perp/v2/types/keys.go b/x/perp/v2/types/keys.go index 3ce91b28a..00e36f632 100644 --- a/x/perp/v2/types/keys.go +++ b/x/perp/v2/types/keys.go @@ -5,7 +5,7 @@ import "github.com/NibiruChain/nibiru/x/common" const ( ModuleName = "perp" VaultModuleAccount = "vault" - PerpEFModuleAccount = "perp_ef" + PerpFundModuleAccount = "perp_fund" FeePoolModuleAccount = "fee_pool" DNRAllocationModuleAccount = "dnr_allocation" DNREscrowModuleAccount = "dnr_escrow" @@ -26,7 +26,7 @@ var ( var ModuleAccounts = []string{ ModuleName, - PerpEFModuleAccount, + PerpFundModuleAccount, VaultModuleAccount, FeePoolModuleAccount, common.TreasuryPoolModuleAccount, diff --git a/x/perp/v2/types/msgs.go b/x/perp/v2/types/msgs.go index 2dbf0a380..d8173d516 100644 --- a/x/perp/v2/types/msgs.go +++ b/x/perp/v2/types/msgs.go @@ -21,6 +21,7 @@ var ( _ sdk.Msg = &MsgWithdrawEpochRebates{} _ sdk.Msg = &MsgShiftPegMultiplier{} _ sdk.Msg = &MsgShiftSwapInvariant{} + _ sdk.Msg = &MsgWithdrawFromPerpFund{} ) // ------------------------ MsgRemoveMargin ------------------------ @@ -407,3 +408,35 @@ func (m MsgShiftSwapInvariant) GetSigners() []sdk.AccAddress { func (m MsgShiftSwapInvariant) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } + +// ------------------------ MsgWithdrawFromPerpFund ------------------------ + +func (m MsgWithdrawFromPerpFund) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Sender); err != nil { + return fmt.Errorf("%w: invalid sender address (%s): %s", + errors.ErrInvalidAddress, m.Sender, err, + ) + } + if !m.Amount.IsPositive() { + return fmt.Errorf( + "%w: msg \"amount\" must be positive, got %s", ErrGeneric, m.Amount) + } + if _, err := sdk.AccAddressFromBech32(m.ToAddr); err != nil { + return fmt.Errorf("%w: invalid \"to_addr\" (%s): %s", + errors.ErrInvalidAddress, m.ToAddr, err, + ) + } + return nil +} + +func (m MsgWithdrawFromPerpFund) GetSigners() []sdk.AccAddress { + signer, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{signer} +} + +func (m MsgWithdrawFromPerpFund) 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 3b894bab1..fcc13e75c 100644 --- a/x/perp/v2/types/msgs_test.go +++ b/x/perp/v2/types/msgs_test.go @@ -4,6 +4,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/require" "github.com/NibiruChain/nibiru/x/common/asset" @@ -392,7 +393,8 @@ func TestMsgValidateBasic(t *testing.T) { expectErr: true, expectedError: ErrAmmNonPositivePegMult.Error(), }, - // MsgDonateToEcosystemFund test cases + + // MsgShiftSwapInvariant test cases { name: "MsgShiftSwapInvariant: Invalid pair", msg: &MsgShiftSwapInvariant{ @@ -423,6 +425,41 @@ func TestMsgValidateBasic(t *testing.T) { expectErr: true, expectedError: ErrAmmNonPositiveSwapInvariant.Error(), }, + + // MsgWithdrawFromPerpFund test cases + { + name: "MsgWithdrawFromPerpFund: invalid to addr", + msg: &MsgWithdrawFromPerpFund{ + Sender: validSender, + Amount: sdk.NewInt(420), // valid positive + Denom: "", + ToAddr: "invalidaddr", + }, + expectErr: true, + expectedError: sdkerrors.ErrInvalidAddress.Error(), + }, + { + name: "MsgWithdrawFromPerpFund: invalid sender", + msg: &MsgWithdrawFromPerpFund{ + Sender: "invalidaddr", + Amount: sdk.NewInt(420), // valid positive + Denom: "", + ToAddr: validSender, + }, + expectErr: true, + expectedError: sdkerrors.ErrInvalidAddress.Error(), + }, + { + name: "MsgWithdrawFromPerpFund: invalid amount", + msg: &MsgWithdrawFromPerpFund{ + Sender: validSender, + Amount: sdk.NewInt(-420), + Denom: "", + ToAddr: validSender, + }, + expectErr: true, + expectedError: ErrGeneric.Error(), + }, } for _, tc := range testCases { @@ -453,6 +490,7 @@ func TestMsg_GetSigners(t *testing.T) { &MsgMultiLiquidate{Sender: validSender}, &MsgShiftPegMultiplier{Sender: validSender}, &MsgShiftSwapInvariant{Sender: validSender}, + &MsgWithdrawFromPerpFund{Sender: validSender}, } msgInvalidSenderList := []sdk.Msg{ &MsgAddMargin{Sender: invalidSender}, @@ -465,6 +503,7 @@ func TestMsg_GetSigners(t *testing.T) { &MsgMultiLiquidate{Sender: invalidSender}, &MsgShiftPegMultiplier{Sender: invalidSender}, &MsgShiftSwapInvariant{Sender: invalidSender}, + &MsgWithdrawFromPerpFund{Sender: invalidSender}, } for _, msg := range msgValidSenderList { @@ -609,6 +648,10 @@ func TestMsg_GetSignBytes(t *testing.T) { name: "MsgShiftSwapInvariant", msg: &MsgShiftSwapInvariant{}, }, + { + name: "MsgWithdrawFromPerpFund", + msg: &MsgWithdrawFromPerpFund{}, + }, } for _, tc := range testCases { diff --git a/x/perp/v2/types/tx.pb.go b/x/perp/v2/types/tx.pb.go index a20200646..9b488a81b 100644 --- a/x/perp/v2/types/tx.pb.go +++ b/x/perp/v2/types/tx.pb.go @@ -915,7 +915,7 @@ func (m *MsgDonateToEcosystemFundResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgDonateToEcosystemFundResponse proto.InternalMessageInfo // MsgChangeCollateralDenom: Changes the collateral denom for the module. -// [Admin] Only callable by sudoers. +// [SUDO] Only callable by sudoers. type MsgChangeCollateralDenom struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` NewDenom string `protobuf:"bytes,2,opt,name=new_denom,json=newDenom,proto3" json:"new_denom,omitempty"` @@ -1199,8 +1199,8 @@ func (m *MsgWithdrawEpochRebatesResponse) GetWithdrawnRebates() github_com_cosmo return nil } -// ShiftPegMultiplier: gRPC tx msg for changing the peg multiplier. -// Admin-only. +// MsgShiftPegMultiplier: gRPC tx msg for changing the peg multiplier. +// [SUDO] Only callable sudoers. 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"` @@ -1283,8 +1283,8 @@ func (m *MsgShiftPegMultiplierResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgShiftPegMultiplierResponse proto.InternalMessageInfo -// ShiftSwapInvariant: gRPC tx msg for changing the swap invariant. -// Admin-only. +// MsgShiftSwapInvariant: gRPC tx msg for changing the swap invariant. +// [SUDO] Only callable sudoers. 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"` @@ -1367,6 +1367,106 @@ func (m *MsgShiftSwapInvariantResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgShiftSwapInvariantResponse proto.InternalMessageInfo +// MsgWithdrawFromPerpFund: gRPC tx msg for changing the swap invariant. +// [SUDO] Only callable sudoers. +type MsgWithdrawFromPerpFund struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` + // Optional denom in case withdrawing assets aside from NUSD. + Denom string `protobuf:"bytes,3,opt,name=denom,proto3" json:"denom,omitempty"` + ToAddr string `protobuf:"bytes,4,opt,name=to_addr,json=toAddr,proto3" json:"to_addr,omitempty"` +} + +func (m *MsgWithdrawFromPerpFund) Reset() { *m = MsgWithdrawFromPerpFund{} } +func (m *MsgWithdrawFromPerpFund) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawFromPerpFund) ProtoMessage() {} +func (*MsgWithdrawFromPerpFund) Descriptor() ([]byte, []int) { + return fileDescriptor_b95cda40bf0a0f91, []int{25} +} +func (m *MsgWithdrawFromPerpFund) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawFromPerpFund) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawFromPerpFund.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 *MsgWithdrawFromPerpFund) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawFromPerpFund.Merge(m, src) +} +func (m *MsgWithdrawFromPerpFund) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawFromPerpFund) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawFromPerpFund.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawFromPerpFund proto.InternalMessageInfo + +func (m *MsgWithdrawFromPerpFund) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgWithdrawFromPerpFund) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func (m *MsgWithdrawFromPerpFund) GetToAddr() string { + if m != nil { + return m.ToAddr + } + return "" +} + +type MsgWithdrawFromPerpFundResponse struct { +} + +func (m *MsgWithdrawFromPerpFundResponse) Reset() { *m = MsgWithdrawFromPerpFundResponse{} } +func (m *MsgWithdrawFromPerpFundResponse) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawFromPerpFundResponse) ProtoMessage() {} +func (*MsgWithdrawFromPerpFundResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b95cda40bf0a0f91, []int{26} +} +func (m *MsgWithdrawFromPerpFundResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawFromPerpFundResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawFromPerpFundResponse.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 *MsgWithdrawFromPerpFundResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawFromPerpFundResponse.Merge(m, src) +} +func (m *MsgWithdrawFromPerpFundResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawFromPerpFundResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawFromPerpFundResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawFromPerpFundResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgSettlePosition)(nil), "nibiru.perp.v2.MsgSettlePosition") proto.RegisterType((*MsgRemoveMargin)(nil), "nibiru.perp.v2.MsgRemoveMargin") @@ -1395,111 +1495,117 @@ func init() { proto.RegisterType((*MsgShiftPegMultiplierResponse)(nil), "nibiru.perp.v2.MsgShiftPegMultiplierResponse") proto.RegisterType((*MsgShiftSwapInvariant)(nil), "nibiru.perp.v2.MsgShiftSwapInvariant") proto.RegisterType((*MsgShiftSwapInvariantResponse)(nil), "nibiru.perp.v2.MsgShiftSwapInvariantResponse") + proto.RegisterType((*MsgWithdrawFromPerpFund)(nil), "nibiru.perp.v2.MsgWithdrawFromPerpFund") + proto.RegisterType((*MsgWithdrawFromPerpFundResponse)(nil), "nibiru.perp.v2.MsgWithdrawFromPerpFundResponse") } func init() { proto.RegisterFile("nibiru/perp/v2/tx.proto", fileDescriptor_b95cda40bf0a0f91) } var fileDescriptor_b95cda40bf0a0f91 = []byte{ - // 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, 0xdf, 0x39, 0xbf, - 0x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0x58, 0xf1, 0x1c, - 0x41, 0xae, 0x92, 0x07, 0x1e, 0xa9, 0x23, 0x81, 0x7b, 0x7a, 0xf7, 0x06, 0x8c, 0x3b, 0xa1, 0x90, - 0x2c, 0x12, 0xf9, 0xa1, 0x85, 0xec, 0xe2, 0xd8, 0xf2, 0x52, 0xb7, 0x9e, 0xe7, 0x00, 0x4b, 0x57, - 0x3b, 0xab, 0xcc, 0x14, 0x44, 0x41, 0xc0, 0x58, 0x62, 0x32, 0x8e, 0x9f, 0x76, 0x34, 0xf1, 0x9b, - 0x85, 0x61, 0xe1, 0x22, 0x49, 0x64, 0x28, 0x20, 0x12, 0x8c, 0x8c, 0x6f, 0xb2, 0x70, 0xf6, 0x39, - 0x2b, 0xe3, 0x18, 0xa1, 0x2e, 0x9a, 0x9a, 0x4f, 0xf3, 0x8d, 0x03, 0x69, 0x46, 0x00, 0x29, 0xba, - 0xe1, 0xb7, 0x2e, 0xda, 0x5f, 0x0f, 0xc1, 0x69, 0x85, 0x94, 0xac, 0x50, 0xdc, 0xab, 0xd5, 0x30, - 0xe7, 0xbe, 0x0b, 0x46, 0xcc, 0x68, 0xa8, 0xcf, 0xc0, 0x09, 0xec, 0xba, 0x2c, 0x62, 0x12, 0x0c, - 0xf4, 0xcb, 0x30, 0x11, 0xe1, 0x32, 0xd7, 0xda, 0xc2, 0xb8, 0xbf, 0x44, 0xd5, 0xcc, 0x53, 0x9d, - 0x65, 0x97, 0x31, 0xd6, 0xdf, 0x82, 0x31, 0x49, 0xcb, 0xc2, 0x5b, 0x3e, 0x48, 0xae, 0x3f, 0x90, - 0x51, 0xb9, 0xe6, 0xd2, 0x96, 0x04, 0xe8, 0x78, 0xfa, 0x44, 0xd2, 0xd3, 0x71, 0x40, 0x87, 0x8f, - 0x24, 0xa0, 0xc6, 0xb7, 0x59, 0x98, 0x90, 0x7e, 0x47, 0xee, 0x7d, 0x2c, 0xae, 0xbb, 0x52, 0xc3, - 0x31, 0x95, 0x82, 0x25, 0xc8,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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, 0x60, 0xba, 0x1d, 0xce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0x05, 0xc5, 0xd2, 0x94, - 0x44, 0x61, 0xf1, 0x20, 0x89, 0x04, 0xfc, 0x1d, 0x18, 0x4f, 0x1d, 0xdb, 0x54, 0x81, 0x4c, 0x0a, - 0x28, 0x03, 0xa9, 0x3a, 0x39, 0x19, 0x19, 0xdd, 0x82, 0x89, 0xae, 0x17, 0x76, 0x95, 0xd7, 0xd3, - 0x22, 0x87, 0x32, 0xde, 0x83, 0x33, 0xea, 0x06, 0xae, 0x02, 0x51, 0x4a, 0x16, 0x2e, 0xf4, 0x2b, - 0x99, 0x56, 0xab, 0xee, 0xc7, 0x4a, 0xdb, 0x55, 0x92, 0x4a, 0xb5, 0xfb, 0xb7, 0xe4, 0x8c, 0xee, - 0xc2, 0x8c, 0xb2, 0x21, 0xab, 0x22, 0xa2, 0x12, 0x2c, 0x94, 0xfb, 0x14, 0x4c, 0xeb, 0x54, 0x76, - 0x32, 0x95, 0x4e, 0x95, 0xa0, 0x52, 0xe7, 0x7e, 0xfd, 0xcc, 0xc8, 0xe8, 0x0e, 0xe8, 0x8a, 0x9e, - 0xf2, 0x3f, 0x55, 0xea, 0x3c, 0x27, 0x56, 0x58, 0xea, 0x4b, 0x4c, 0xa1, 0x2d, 0x5d, 0xcd, 0x7b, - 0x6a, 0x4b, 0x89, 0xf5, 0xd6, 0xa6, 0xac, 0x9e, 0x46, 0x66, 0xf5, 0xed, 0x47, 0x4f, 0x8b, 0xda, - 0xe3, 0xa7, 0x45, 0xed, 0x97, 0xa7, 0x45, 0xed, 0xa3, 0xbd, 0x62, 0xe6, 0xf1, 0x5e, 0x31, 0xf3, - 0xc3, 0x5e, 0x31, 0x73, 0x67, 0xe9, 0xa0, 0x8e, 0x10, 0xff, 0x88, 0x26, 0xeb, 0xf7, 0xe6, 0xb0, - 0xff, 0x43, 0xd6, 0xcb, 0x7f, 0x04, 0x00, 0x00, 0xff, 0xff, 0x4e, 0xc7, 0xc2, 0xd7, 0x63, 0x1b, - 0x00, 0x00, + // 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, + 0x78, 0xe1, 0x03, 0xf4, 0xb1, 0x8f, 0x08, 0xa1, 0x82, 0x9a, 0x17, 0x5e, 0xa9, 0xf8, 0x00, 0x68, + 0xf6, 0x9f, 0x77, 0xdd, 0xb1, 0xe3, 0x98, 0x34, 0x12, 0x88, 0xa7, 0x64, 0x76, 0xce, 0xf9, 0x9d, + 0xf3, 0x3b, 0xe7, 0xcc, 0x9c, 0x99, 0x31, 0xcc, 0x13, 0x7b, 0xdb, 0x76, 0x1b, 0xa5, 0x3a, 0x76, + 0xeb, 0xa5, 0xe6, 0x4a, 0x89, 0xef, 0x15, 0xeb, 0x2e, 0xe5, 0x54, 0x9d, 0xf4, 0x27, 0x8a, 0x62, + 0xa2, 0xd8, 0x5c, 0xc9, 0x9f, 0xb3, 0x28, 0xb5, 0x1c, 0x5c, 0x42, 0x75, 0xbb, 0x84, 0x08, 0xa1, + 0x1c, 0x71, 0x9b, 0x12, 0xe6, 0x4b, 0xe7, 0x0b, 0x55, 0xca, 0x6a, 0x94, 0x95, 0xb6, 0x11, 0xc3, + 0xa5, 0xe6, 0xa5,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3, 0x67, 0x1d, 0xb3, 0x3a, 0x25, 0x0c, 0xab, + 0x6f, 0x01, 0xf8, 0x52, 0x06, 0x6d, 0x70, 0xcf, 0xff, 0x3e, 0x80, 0xc7, 0x7c, 0x95, 0xeb, 0x0d, + 0xae, 0xde, 0x86, 0xa9, 0x9d, 0x06, 0x31, 0x6d, 0x62, 0x19, 0x75, 0xb4, 0x5f, 0xc3, 0x84, 0x07, + 0x74, 0x8b, 0x01, 0xdd, 0x0b, 0x31, 0xba, 0x41, 0x91, 0xf8, 0x7f, 0x96, 0x99, 0x79, 0xbf, 0xc4, + 0xf7, 0xeb, 0x98, 0x15, 0x37, 0x70, 0x55, 0x9f, 0x0c, 0x60, 0x2a, 0x3e, 0x8a, 0xfa, 0x2a, 0x8c, + 0xd6, 0x83, 0xac, 0x07, 0x7c, 0x73, 0xc5, 0x64, 0x49, 0x16, 0xc3, 0xaa, 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, 0x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2f, 0x1d, 0x26, 0x11, 0x83, 0xbf, 0x03, 0x13, 0x89, 0x43, 0xa8, 0x2c, 0x91, 0x71, 0x01, 0x69, + 0x22, 0x65, 0xe7, 0x40, 0x2d, 0xa5, 0x1a, 0x30, 0xd9, 0xf1, 0x7b, 0x81, 0x2c, 0xea, 0x49, 0x91, + 0x23, 0x39, 0xdf, 0x80, 0x33, 0xf2, 0xe3, 0x88, 0x0c, 0x44, 0x2a, 0x99, 0xbf, 0xd8, 0xaf, 0x64, + 0xd2, 0xac, 0xfc, 0x74, 0x21, 0xf5, 0x5d, 0x26, 0x29, 0x35, 0xdb, 0xfb, 0x80, 0x91, 0x52, 0x5d, + 0x98, 0x95, 0x1e, 0x2f, 0x64, 0x19, 0x91, 0x09, 0xe6, 0x4b, 0x7d, 0x0a, 0x26, 0x6d, 0x4a, 0xfb, + 0xb2, 0xcc, 0xa6, 0x4c, 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, } // Reference imports to suppress errors if they are not otherwise used. @@ -1523,16 +1629,19 @@ type MsgClient interface { 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. + // is possible to make an sdk.Coin using it. [SUDO] 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. + // [SUDO] 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. + // [SUDO] Only callable by sudoers. ShiftSwapInvariant(ctx context.Context, in *MsgShiftSwapInvariant, opts ...grpc.CallOption) (*MsgShiftSwapInvariantResponse, error) + // 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) } type msgClient struct { @@ -1660,6 +1769,15 @@ func (c *msgClient) ShiftSwapInvariant(ctx context.Context, in *MsgShiftSwapInva return out, nil } +func (c *msgClient) WithdrawFromPerpFund(ctx context.Context, in *MsgWithdrawFromPerpFund, opts ...grpc.CallOption) (*MsgWithdrawFromPerpFundResponse, error) { + out := new(MsgWithdrawFromPerpFundResponse) + err := c.cc.Invoke(ctx, "/nibiru.perp.v2.Msg/WithdrawFromPerpFund", 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) @@ -1671,16 +1789,19 @@ type MsgServer interface { 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. + // is possible to make an sdk.Coin using it. [SUDO] 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. + // [SUDO] 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. + // [SUDO] Only callable by sudoers. ShiftSwapInvariant(context.Context, *MsgShiftSwapInvariant) (*MsgShiftSwapInvariantResponse, error) + // WithdrawFromPerpFund: gRPC tx msg to withdraw from the perp fund module + // account. [SUDO] Only callable by sudoers. + WithdrawFromPerpFund(context.Context, *MsgWithdrawFromPerpFund) (*MsgWithdrawFromPerpFundResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -1726,6 +1847,9 @@ func (*UnimplementedMsgServer) ShiftPegMultiplier(ctx context.Context, req *MsgS func (*UnimplementedMsgServer) ShiftSwapInvariant(ctx context.Context, req *MsgShiftSwapInvariant) (*MsgShiftSwapInvariantResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ShiftSwapInvariant not implemented") } +func (*UnimplementedMsgServer) WithdrawFromPerpFund(ctx context.Context, req *MsgWithdrawFromPerpFund) (*MsgWithdrawFromPerpFundResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method WithdrawFromPerpFund not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -1965,6 +2089,24 @@ func _Msg_ShiftSwapInvariant_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _Msg_WithdrawFromPerpFund_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgWithdrawFromPerpFund) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).WithdrawFromPerpFund(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/nibiru.perp.v2.Msg/WithdrawFromPerpFund", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).WithdrawFromPerpFund(ctx, req.(*MsgWithdrawFromPerpFund)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "nibiru.perp.v2.Msg", HandlerType: (*MsgServer)(nil), @@ -2021,6 +2163,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "ShiftSwapInvariant", Handler: _Msg_ShiftSwapInvariant_Handler, }, + { + MethodName: "WithdrawFromPerpFund", + Handler: _Msg_WithdrawFromPerpFund_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "nibiru/perp/v2/tx.proto", @@ -3324,6 +3470,83 @@ func (m *MsgShiftSwapInvariantResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *MsgWithdrawFromPerpFund) 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 *MsgWithdrawFromPerpFund) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawFromPerpFund) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ToAddr) > 0 { + i -= len(m.ToAddr) + copy(dAtA[i:], m.ToAddr) + i = encodeVarintTx(dAtA, i, uint64(len(m.ToAddr))) + i-- + dAtA[i] = 0x22 + } + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x1a + } + { + size := m.Amount.Size() + i -= size + if _, err := m.Amount.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 *MsgWithdrawFromPerpFundResponse) 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 *MsgWithdrawFromPerpFundResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawFromPerpFundResponse) 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 @@ -3790,6 +4013,38 @@ func (m *MsgShiftSwapInvariantResponse) Size() (n int) { return n } +func (m *MsgWithdrawFromPerpFund) 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.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ToAddr) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgWithdrawFromPerpFundResponse) 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 } @@ -7496,6 +7751,236 @@ func (m *MsgShiftSwapInvariantResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgWithdrawFromPerpFund) 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: MsgWithdrawFromPerpFund: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdrawFromPerpFund: 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 Amount", 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.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", 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.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ToAddr", 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.ToAddr = string(dAtA[iNdEx:postIndex]) + 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 *MsgWithdrawFromPerpFundResponse) 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: MsgWithdrawFromPerpFundResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdrawFromPerpFundResponse: 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