From 56d665b57209c2d1743d0302848c818863d47df3 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 9 Nov 2023 23:37:17 -0700 Subject: [PATCH] feat: track and query protocol rev across all modules (#6804) * implement query to get protocol rev across all modules * add cli cmd * Auto: update go.mod after push to adam/all-protocol-rev-query that modified dependencies locally * add changelog * fix txfees tests * add upgrade test * fix remaining test * change from uint to int * int * dont recalc values at epoch hook call * fix upgrade test * clean up * merge taker fees into single struct * add default value for tests * add genesis test * remove old portion of test * fix test * fix tests * Auto: update go.mod after push to adam/all-protocol-rev-query that modified dependencies locally --------- Co-authored-by: github-actions --- CHANGELOG.md | 4 + app/apptesting/test_suite.go | 42 ++ app/apptesting/txfees.go | 85 +++ app/keepers/keepers.go | 2 + app/test_helpers.go | 23 + app/upgrades/v21/constants.go | 5 +- app/upgrades/v21/upgrades.go | 30 +- app/upgrades/v21/upgrades_test.go | 71 ++ go.mod | 2 +- go.sum | 4 +- osmoutils/coin_helper.go | 8 + osmoutils/coin_helper_test.go | 32 + .../osmosis/poolmanager/v1beta1/genesis.proto | 16 + proto/osmosis/protorev/v1beta1/genesis.proto | 4 +- proto/osmosis/protorev/v1beta1/protorev.proto | 28 +- proto/osmosis/protorev/v1beta1/query.proto | 16 + proto/osmosis/txfees/v1beta1/genesis.proto | 13 + x/poolmanager/keeper.go | 32 +- x/poolmanager/keeper_test.go | 22 +- x/poolmanager/protorev.go | 101 +++ x/poolmanager/protorev_test.go | 165 +++++ x/poolmanager/taker_fee.go | 31 +- x/poolmanager/taker_fee_test.go | 29 +- x/poolmanager/types/genesis.go | 11 +- x/poolmanager/types/genesis.pb.go | 457 +++++++++++-- x/poolmanager/types/keys.go | 9 + x/protorev/client/cli/query.go | 9 + x/protorev/keeper/genesis.go | 21 + x/protorev/keeper/genesis_test.go | 6 + x/protorev/keeper/grpc_query.go | 8 + x/protorev/keeper/grpc_query_test.go | 66 ++ x/protorev/keeper/keeper.go | 7 + x/protorev/keeper/protorev.go | 31 + x/protorev/keeper/protorev_test.go | 77 +++ x/protorev/keeper/statistics.go | 43 ++ x/protorev/keeper/statistics_test.go | 80 +++ x/protorev/types/expected_keepers.go | 8 + x/protorev/types/genesis.go | 5 + x/protorev/types/genesis.pb.go | 159 +++-- x/protorev/types/keys.go | 8 + x/protorev/types/protorev.pb.go | 634 ++++++++++++++++-- x/protorev/types/query.pb.go | 530 ++++++++++++--- x/protorev/types/query.pb.gw.go | 65 ++ x/txfees/keeper/feedecorator.go | 2 + x/txfees/keeper/feedecorator_test.go | 61 +- x/txfees/keeper/genesis.go | 18 + x/txfees/keeper/genesis_test.go | 64 ++ x/txfees/keeper/hooks_test.go | 20 +- x/txfees/keeper/protorev.go | 63 ++ x/txfees/keeper/protorev_test.go | 121 ++++ x/txfees/types/expected_keepers.go | 1 + x/txfees/types/genesis.go | 4 + x/txfees/types/genesis.pb.go | 322 ++++++++- x/txfees/types/keys.go | 9 +- 54 files changed, 3309 insertions(+), 375 deletions(-) create mode 100644 app/apptesting/txfees.go create mode 100644 app/upgrades/v21/upgrades_test.go create mode 100644 x/poolmanager/protorev.go create mode 100644 x/poolmanager/protorev_test.go create mode 100644 x/txfees/keeper/genesis_test.go create mode 100644 x/txfees/keeper/protorev.go create mode 100644 x/txfees/keeper/protorev_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ef4885896c..126a122c86d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Features + +* [#6804](https://github.com/osmosis-labs/osmosis/pull/6804) feat: track and query protocol rev across all modules + ### Fix Localosmosis docker-compose with state. * Updated the docker-compose for localosmosis with state to be inline with Operations updated process. diff --git a/app/apptesting/test_suite.go b/app/apptesting/test_suite.go index 8490e1ed31e..2d63997e8ee 100644 --- a/app/apptesting/test_suite.go +++ b/app/apptesting/test_suite.go @@ -117,6 +117,31 @@ func (s *KeeperTestHelper) Setup() { } } +func (s *KeeperTestHelper) SetupWithCustomChainId(chainId string) { + dir, err := os.MkdirTemp("", "osmosisd-test-home") + if err != nil { + panic(fmt.Sprintf("failed creating temporary directory: %v", err)) + } + s.T().Cleanup(func() { os.RemoveAll(dir); s.withCaching = false }) + s.App = app.SetupWithCustomHomeAndChainId(false, dir, chainId) + s.setupGeneralCustomChainId(chainId) + + // Manually set validator signing info, otherwise we panic + vals := s.App.StakingKeeper.GetAllValidators(s.Ctx) + for _, val := range vals { + consAddr, _ := val.GetConsAddr() + signingInfo := slashingtypes.NewValidatorSigningInfo( + consAddr, + s.Ctx.BlockHeight(), + 0, + time.Unix(0, 0), + false, + 0, + ) + s.App.SlashingKeeper.SetValidatorSigningInfo(s.Ctx, consAddr, signingInfo) + } +} + // PrepareAllSupportedPools creates all supported pools and returns their IDs. // Additionally, attaches an internal gauge ID for each pool. func (s *KeeperTestHelper) PrepareAllSupportedPools() SupportedPoolAndGaugeInfo { @@ -192,6 +217,23 @@ func (s *KeeperTestHelper) setupGeneral() { s.hasUsedAbci = false } +func (s *KeeperTestHelper) setupGeneralCustomChainId(chainId string) { + s.Ctx = s.App.BaseApp.NewContext(false, tmtypes.Header{Height: 1, ChainID: chainId, Time: defaultTestStartTime}) + if s.withCaching { + s.Ctx, _ = s.Ctx.CacheContext() + } + s.QueryHelper = &baseapp.QueryServiceTestHelper{ + GRPCQueryRouter: s.App.GRPCQueryRouter(), + Ctx: s.Ctx, + } + + s.SetEpochStartTime() + s.TestAccs = []sdk.AccAddress{} + s.TestAccs = append(s.TestAccs, baseTestAccts...) + s.SetupConcentratedLiquidityDenomsAndPoolCreation() + s.hasUsedAbci = false +} + func (s *KeeperTestHelper) SetupTestForInitGenesis() { // Setting to True, leads to init genesis not running s.App = app.Setup(true) diff --git a/app/apptesting/txfees.go b/app/apptesting/txfees.go new file mode 100644 index 00000000000..516c1d56aad --- /dev/null +++ b/app/apptesting/txfees.go @@ -0,0 +1,85 @@ +package apptesting + +import ( + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/testutil/testdata" + sdk "github.com/cosmos/cosmos-sdk/types" + authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" + "github.com/cosmos/cosmos-sdk/x/bank/testutil" + + "github.com/cosmos/cosmos-sdk/client" + + clienttx "github.com/cosmos/cosmos-sdk/client/tx" + + "github.com/osmosis-labs/osmosis/osmomath" + "github.com/osmosis-labs/osmosis/v20/x/txfees/keeper" + "github.com/osmosis-labs/osmosis/v20/x/txfees/types" +) + +var baseGas = uint64(10000) + +func (s *KeeperTestHelper) ExecuteUpgradeFeeTokenProposal(feeToken string, poolId uint64) error { + upgradeProp := types.NewUpdateFeeTokenProposal( + "Test Proposal", + "test", + []types.FeeToken{ + { + Denom: feeToken, + PoolID: poolId, + }, + }, + ) + return s.App.TxFeesKeeper.HandleUpdateFeeTokenProposal(s.Ctx, &upgradeProp) +} + +func (s *KeeperTestHelper) SetupTxFeeAnteHandlerAndChargeFee(clientCtx client.Context, minGasPrices sdk.DecCoins, gasRequested uint64, isCheckTx, isSimulate bool, txFee sdk.Coins) error { + mempoolFeeOpts := types.NewDefaultMempoolFeeOptions() + mempoolFeeOpts.MinGasPriceForHighGasTx = osmomath.MustNewDecFromStr("0.0025") + + uionPoolId := s.PrepareBalancerPoolWithCoins( + sdk.NewInt64Coin(sdk.DefaultBondDenom, 500), + sdk.NewInt64Coin("uion", 500), + ) + err := s.ExecuteUpgradeFeeTokenProposal("uion", uionPoolId) + s.Require().NoError(err) + + if gasRequested == 0 { + gasRequested = baseGas + } + s.Ctx = s.Ctx.WithIsCheckTx(isCheckTx).WithMinGasPrices(minGasPrices) + + // TODO: Cleanup this code. + // TxBuilder components reset for every test case + txBuilder := clientCtx.TxConfig.NewTxBuilder() + priv0, _, addr0 := testdata.KeyTestPubAddr() + acc1 := s.App.AccountKeeper.NewAccountWithAddress(s.Ctx, addr0) + s.App.AccountKeeper.SetAccount(s.Ctx, acc1) + msgs := []sdk.Msg{testdata.NewTestMsg(addr0)} + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv0}, []uint64{0}, []uint64{0} + signerData := authsigning.SignerData{ + ChainID: s.Ctx.ChainID(), + AccountNumber: accNums[0], + Sequence: accSeqs[0], + } + + gasLimit := gasRequested + sigV2, _ := clienttx.SignWithPrivKey( + 1, + signerData, + txBuilder, + privs[0], + clientCtx.TxConfig, + accSeqs[0], + ) + + err = testutil.FundAccount(s.App.BankKeeper, s.Ctx, addr0, txFee) + s.Require().NoError(err) + + tx := s.BuildTx(txBuilder, msgs, sigV2, "", txFee, gasLimit) + + mfd := keeper.NewMempoolFeeDecorator(*s.App.TxFeesKeeper, mempoolFeeOpts) + dfd := keeper.NewDeductFeeDecorator(*s.App.TxFeesKeeper, *s.App.AccountKeeper, s.App.BankKeeper, nil) + antehandlerMFD := sdk.ChainAnteDecorators(mfd, dfd) + _, err = antehandlerMFD(s.Ctx, tx, isSimulate) + return err +} diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index e701eb547dd..ad02a7d6a19 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -389,6 +389,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers( appKeepers.EpochsKeeper, appKeepers.PoolManagerKeeper, appKeepers.ConcentratedLiquidityKeeper, + appKeepers.TxFeesKeeper, ) appKeepers.ProtoRevKeeper = &protorevKeeper appKeepers.PoolManagerKeeper.SetProtorevKeeper(appKeepers.ProtoRevKeeper) @@ -403,6 +404,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers( appKeepers.DistrKeeper, ) appKeepers.TxFeesKeeper = &txFeesKeeper + appKeepers.ProtoRevKeeper.SetTxFeesKeeper(appKeepers.TxFeesKeeper) appKeepers.IncentivesKeeper = incentiveskeeper.NewKeeper( appKeepers.keys[incentivestypes.StoreKey], diff --git a/app/test_helpers.go b/app/test_helpers.go index d565c047ba8..c0ef47f5e39 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -136,6 +136,29 @@ func SetupWithCustomHome(isCheckTx bool, dir string) *OsmosisApp { return app } +func SetupWithCustomHomeAndChainId(isCheckTx bool, dir, chainId string) *OsmosisApp { + db := cometbftdb.NewMemDB() + app := NewOsmosisApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, dir, 0, sims.EmptyAppOptions{}, EmptyWasmOpts, baseapp.SetChainID(chainId)) + if !isCheckTx { + genesisState := GenesisStateWithValSet(app) + stateBytes, err := json.MarshalIndent(genesisState, "", " ") + if err != nil { + panic(err) + } + + app.InitChain( + abci.RequestInitChain{ + Validators: []abci.ValidatorUpdate{}, + ConsensusParams: sims.DefaultConsensusParams, + AppStateBytes: stateBytes, + ChainId: chainId, + }, + ) + } + + return app +} + // Setup initializes a new OsmosisApp. func Setup(isCheckTx bool) *OsmosisApp { return SetupWithCustomHome(isCheckTx, DefaultNodeHome) diff --git a/app/upgrades/v21/constants.go b/app/upgrades/v21/constants.go index 9806adb42b1..bdfe9737368 100644 --- a/app/upgrades/v21/constants.go +++ b/app/upgrades/v21/constants.go @@ -11,7 +11,10 @@ import ( ) // UpgradeName defines the on-chain upgrade name for the Osmosis v21 upgrade. -const UpgradeName = "v21" +const ( + UpgradeName = "v21" + TestingChainId = "testing-chain-id" +) var Upgrade = upgrades.Upgrade{ UpgradeName: UpgradeName, diff --git a/app/upgrades/v21/upgrades.go b/app/upgrades/v21/upgrades.go index 0b9ef126d75..2f6c02608b2 100644 --- a/app/upgrades/v21/upgrades.go +++ b/app/upgrades/v21/upgrades.go @@ -13,6 +13,7 @@ import ( icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/v20/app/keepers" "github.com/osmosis-labs/osmosis/v20/app/upgrades" concentratedliquiditytypes "github.com/osmosis-labs/osmosis/v20/x/concentrated-liquidity/types" @@ -48,8 +49,17 @@ func CreateUpgradeHandler( keepers *keepers.AppKeepers, ) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - // UNFORKINGNOTE: If we don't manually set this to 2, the gov modules doesn't go through its necessary migrations to version 4 - fromVM[govtypes.ModuleName] = 2 + // I spent a very long time trying to figure out how to test this in a non hacky way. + // TL;DR, on mainnet, we run a fork of v0.43, so we should be starting at version 2. + // Without this change, since we unfork to the primary repo, we start at version 5, which + // wouldn't allow us to run each migration. + // + // Now, starting from 2 only works on mainnet because the legacysubspace is set. + // Because the legacysubspace is not set in the gotest, we cant simply run these migrations without setting the legacysubspace. + // This legacysubspace can only be set at the initChain level, so it isn't clear to me how to directly set this in the test. + if ctx.ChainID() != TestingChainId { + fromVM[govtypes.ModuleName] = 2 + } baseAppLegacySS := keepers.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()) // https://github.com/cosmos/cosmos-sdk/pull/12363/files @@ -140,13 +150,13 @@ func CreateUpgradeHandler( return nil, err } - // set POB params + // Set POB Params: err = setAuctionParams(ctx, keepers) if err != nil { return nil, err } - // set expedited proposal param + // Set expedited proposal param: govParams := keepers.GovKeeper.GetParams(ctx) govParams.ExpeditedMinDeposit = sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(5000000000))) err = keepers.GovKeeper.SetParams(ctx, govParams) @@ -154,8 +164,20 @@ func CreateUpgradeHandler( return nil, err } + // Set CL param: keepers.ConcentratedLiquidityKeeper.SetParam(ctx, concentratedliquiditytypes.KeyHookGasLimit, concentratedliquiditytypes.DefaultContractHookGasLimit) + // Since we are now tracking all protocol rev, we set the accounting height to the current block height for each module + // that generates protocol rev. + keepers.PoolManagerKeeper.SetTakerFeeTrackerStartHeight(ctx, ctx.BlockHeight()) + keepers.TxFeesKeeper.SetTxFeesTrackerStartHeight(ctx, ctx.BlockHeight()) + // We start the cyclic arb tracker from the value it currently is at since it has been tracking since inception (without a start height). + // This will allow us to display the amount of cyclic arb profits that have been generated from a certain block height. + allCyclicArbProfits := keepers.ProtoRevKeeper.GetAllProfits(ctx) + allCyclicArbProfitsCoins := osmoutils.ConvertCoinArrayToCoins(allCyclicArbProfits) + keepers.ProtoRevKeeper.SetCyclicArbProfitTrackerValue(ctx, allCyclicArbProfitsCoins) + keepers.ProtoRevKeeper.SetCyclicArbProfitTrackerStartHeight(ctx, ctx.BlockHeight()) + return migrations, nil } } diff --git a/app/upgrades/v21/upgrades_test.go b/app/upgrades/v21/upgrades_test.go new file mode 100644 index 00000000000..172f05d9971 --- /dev/null +++ b/app/upgrades/v21/upgrades_test.go @@ -0,0 +1,71 @@ +package v21_test + +import ( + "testing" + + "github.com/stretchr/testify/suite" + + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + v21 "github.com/osmosis-labs/osmosis/v20/app/upgrades/v21" + + abci "github.com/cometbft/cometbft/abci/types" + + "github.com/osmosis-labs/osmosis/osmomath" + "github.com/osmosis-labs/osmosis/v20/app/apptesting" + "github.com/osmosis-labs/osmosis/v20/x/protorev/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + + poolmanagertypes "github.com/osmosis-labs/osmosis/v20/x/poolmanager/types" +) + +const ( + v21UpgradeHeight = int64(10) +) + +type UpgradeTestSuite struct { + apptesting.KeeperTestHelper +} + +func TestUpgradeTestSuite(t *testing.T) { + suite.Run(t, new(UpgradeTestSuite)) +} + +func (s *UpgradeTestSuite) TestUpgrade() { + s.SetupWithCustomChainId(v21.TestingChainId) + dummyUpgrade(s) + s.Require().NotPanics(func() { + s.App.BeginBlocker(s.Ctx, abci.RequestBeginBlock{}) + }) + + // Psuedo collect cyclic arb profits + cyclicArbProfits := sdk.NewCoins(sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(9000)), sdk.NewCoin("Atom", osmomath.NewInt(3000))) + err := s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, cyclicArbProfits[0].Denom, cyclicArbProfits[0].Amount) + s.Require().NoError(err) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, cyclicArbProfits[1].Denom, cyclicArbProfits[1].Amount) + s.Require().NoError(err) + + allProtocolRevenue := s.App.ProtoRevKeeper.GetAllProtocolRevenue(s.Ctx) + // Check all accounting start heights should be the same height as the upgrade + s.Require().Equal(v21UpgradeHeight, allProtocolRevenue.CyclicArbTracker.HeightAccountingStartsFrom) + s.Require().Equal(v21UpgradeHeight, allProtocolRevenue.TakerFeesTracker.HeightAccountingStartsFrom) + s.Require().Equal(v21UpgradeHeight, allProtocolRevenue.TxFeesTracker.HeightAccountingStartsFrom) + // All values should be nill except for the cyclic arb profits, which should start at the value it was at time of upgrade + s.Require().Equal(sdk.Coins(nil), allProtocolRevenue.TakerFeesTracker.TakerFeesToCommunityPool) + s.Require().Equal(sdk.Coins(nil), allProtocolRevenue.TakerFeesTracker.TakerFeesToStakers) + s.Require().Equal(sdk.Coins(nil), allProtocolRevenue.TxFeesTracker.TxFees) + s.Require().Equal(cyclicArbProfits, allProtocolRevenue.CyclicArbTracker.CyclicArb) + +} + +func dummyUpgrade(s *UpgradeTestSuite) { + s.Ctx = s.Ctx.WithBlockHeight(v21UpgradeHeight - 1) + plan := upgradetypes.Plan{Name: "v21", Height: v21UpgradeHeight} + err := s.App.UpgradeKeeper.ScheduleUpgrade(s.Ctx, plan) + s.Require().NoError(err) + _, exists := s.App.UpgradeKeeper.GetUpgradePlan(s.Ctx) + s.Require().True(exists) + + s.Ctx = s.Ctx.WithBlockHeight(v21UpgradeHeight) +} diff --git a/go.mod b/go.mod index a4a08fff98c..88a3cb6b51a 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( github.com/ory/dockertest/v3 v3.10.0 github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3 github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20231108202153-af031b1367bb - github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20231108202153-af031b1367bb + github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20231110043608-da030c5b18ac github.com/osmosis-labs/osmosis/x/epochs v0.0.3-0.20231108202153-af031b1367bb github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.9-0.20231108202153-af031b1367bb github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index f5259f73414..243490af304 100644 --- a/go.sum +++ b/go.sum @@ -1458,8 +1458,8 @@ github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3 h1:Ylmch github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3/go.mod h1:lV6KnqXYD/ayTe7310MHtM3I2q8Z6bBfMAi+bhwPYtI= github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20231108202153-af031b1367bb h1:d4JXafqN5tqmM5gQ56nMGsOccLI9M+zp3KgI3vFU8vk= github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20231108202153-af031b1367bb/go.mod h1:I8CSvdOyPJREATq1Kb4mFPiDVrl2jxCRd4W3NVQFom8= -github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20231108202153-af031b1367bb h1:Xt1HqDuWA4ix+B+wEJIqoFHTrcE6hxoK26Nk/6uC4qo= -github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20231108202153-af031b1367bb/go.mod h1:5vLzE4XFr/qa5bXq6zSFncM3jUwTMOW9hMjVRSlTQAc= +github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20231110043608-da030c5b18ac h1:60A8/hLeNPpEJ4QPoJbpN0BgJEjMzcAy+0lByxGIlaE= +github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20231110043608-da030c5b18ac/go.mod h1:5vLzE4XFr/qa5bXq6zSFncM3jUwTMOW9hMjVRSlTQAc= github.com/osmosis-labs/osmosis/x/epochs v0.0.3-0.20231108202153-af031b1367bb h1:Gz4FoT0QgrqbYUt+fj+pl7kpcmv/Jd4VAKWOq3Bjpow= github.com/osmosis-labs/osmosis/x/epochs v0.0.3-0.20231108202153-af031b1367bb/go.mod h1:mno+X8PKNJZ+zKX+nG0R2Z0tEc+IM5RSvIRWKjhY+UA= github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.9-0.20231108202153-af031b1367bb h1:GsepaIGS+uWEZT0K7cQ9hxjIVN5U6x+jzOr/7qNz7cc= diff --git a/osmoutils/coin_helper.go b/osmoutils/coin_helper.go index 50bda236e5c..6ff1c4b003b 100644 --- a/osmoutils/coin_helper.go +++ b/osmoutils/coin_helper.go @@ -125,3 +125,11 @@ func MergeCoinMaps[T comparable](currentEpochExpectedDistributionsOne map[T]sdk. } return newMap } + +func ConvertCoinArrayToCoins(coinArray []sdk.Coin) sdk.Coins { + coins := sdk.Coins{} + for _, coin := range coinArray { + coins = append(coins, coin) + } + return coins +} diff --git a/osmoutils/coin_helper_test.go b/osmoutils/coin_helper_test.go index a8615127132..58b781ed29b 100644 --- a/osmoutils/coin_helper_test.go +++ b/osmoutils/coin_helper_test.go @@ -291,3 +291,35 @@ func TestMergeCoinMaps(t *testing.T) { } }) } + +func TestConvertCoinArrayToCoins(t *testing.T) { + tests := []struct { + name string + coinArray []sdk.Coin + expectedCoins sdk.Coins + }{ + { + name: "Empty input", + coinArray: []sdk.Coin{}, + expectedCoins: sdk.NewCoins(), + }, + { + name: "Single coin", + coinArray: []sdk.Coin{sdk.NewCoin("atom", osmomath.NewInt(100000000))}, + expectedCoins: sdk.NewCoins(sdk.NewCoin("atom", osmomath.NewInt(100000000))), + }, + { + name: "Multiple coins", + coinArray: []sdk.Coin{sdk.NewCoin("atom", osmomath.NewInt(100000000)), sdk.NewCoin("usdc", osmomath.NewInt(500000000))}, + expectedCoins: sdk.NewCoins(sdk.NewCoin("atom", osmomath.NewInt(100000000)), sdk.NewCoin("usdc", osmomath.NewInt(500000000))), + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + result := osmoutils.ConvertCoinArrayToCoins(test.coinArray) + require.Equal(t, result, test.expectedCoins) + + }) + } +} diff --git a/proto/osmosis/poolmanager/v1beta1/genesis.proto b/proto/osmosis/poolmanager/v1beta1/genesis.proto index 3b599e41b86..a73f3d406e2 100644 --- a/proto/osmosis/poolmanager/v1beta1/genesis.proto +++ b/proto/osmosis/poolmanager/v1beta1/genesis.proto @@ -42,6 +42,9 @@ message GenesisState { Params params = 2 [ (gogoproto.nullable) = false ]; // pool_routes is the container of the mappings from pool id to pool type. repeated ModuleRoute pool_routes = 3 [ (gogoproto.nullable) = false ]; + + // KVStore state + TakerFeesTracker taker_fees_tracker = 4; } // TakerFeeParams consolidates the taker fee parameters for the poolmanager. @@ -117,3 +120,16 @@ message TakerFeeDistributionPercentage { (gogoproto.nullable) = false ]; } + +message TakerFeesTracker { + repeated cosmos.base.v1beta1.Coin taker_fees_to_stakers = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + repeated cosmos.base.v1beta1.Coin taker_fees_to_community_pool = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + int64 height_accounting_starts_from = 3 + [ (gogoproto.moretags) = "yaml:\"height_accounting_starts_from\"" ]; +} diff --git a/proto/osmosis/protorev/v1beta1/genesis.proto b/proto/osmosis/protorev/v1beta1/genesis.proto index fc3207d95f9..c258df05bc1 100644 --- a/proto/osmosis/protorev/v1beta1/genesis.proto +++ b/proto/osmosis/protorev/v1beta1/genesis.proto @@ -72,4 +72,6 @@ message GenesisState { (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"info_by_pool_type\"" ]; -} \ No newline at end of file + CyclicArbTracker cyclic_arb_tracker = 14 + [ (gogoproto.moretags) = "yaml:\"cyclic_arb_tracker\"" ]; +} diff --git a/proto/osmosis/protorev/v1beta1/protorev.proto b/proto/osmosis/protorev/v1beta1/protorev.proto index 250ec36ef1e..12e9aed17e9 100644 --- a/proto/osmosis/protorev/v1beta1/protorev.proto +++ b/proto/osmosis/protorev/v1beta1/protorev.proto @@ -5,6 +5,8 @@ import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; import "cosmos/base/v1beta1/coin.proto"; +import "osmosis/poolmanager/v1beta1/genesis.proto"; +import "osmosis/txfees/v1beta1/genesis.proto"; option go_package = "github.com/osmosis-labs/osmosis/v20/x/protorev/types"; @@ -179,4 +181,28 @@ message BaseDenom { (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"step_size\"" ]; -} \ No newline at end of file +} + +message AllProtocolRevenue { + osmosis.poolmanager.v1beta1.TakerFeesTracker taker_fees_tracker = 1 [ + (gogoproto.moretags) = "yaml:\"taker_fees_tracker\"", + (gogoproto.nullable) = false + ]; + osmosis.txfees.v1beta1.TxFeesTracker tx_fees_tracker = 2 [ + (gogoproto.moretags) = "yaml:\"tx_fees_tracker\"", + (gogoproto.nullable) = false + ]; + CyclicArbTracker cyclic_arb_tracker = 3 [ + (gogoproto.moretags) = "yaml:\"cyclic_arb_tracker\"", + (gogoproto.nullable) = false + ]; +} + +message CyclicArbTracker { + repeated cosmos.base.v1beta1.Coin cyclic_arb = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + int64 height_accounting_starts_from = 2 + [ (gogoproto.moretags) = "yaml:\"height_accounting_starts_from\"" ]; +} diff --git a/proto/osmosis/protorev/v1beta1/query.proto b/proto/osmosis/protorev/v1beta1/query.proto index f4e16cc7954..df67ece945b 100644 --- a/proto/osmosis/protorev/v1beta1/query.proto +++ b/proto/osmosis/protorev/v1beta1/query.proto @@ -113,6 +113,13 @@ service Query { returns (QueryGetProtoRevPoolResponse) { option (google.api.http).get = "/osmosis/protorev/pool"; } + + // GetAllProtocolRevenue queries all of the protocol revenue that has been + // accumulated by any module + rpc GetAllProtocolRevenue(QueryGetAllProtocolRevenueRequest) + returns (QueryGetAllProtocolRevenueResponse) { + option (google.api.http).get = "/osmosis/protorev/all_protocol_revenue"; + } } // QueryParamsRequest is request type for the Query/Params RPC method. @@ -324,4 +331,13 @@ message QueryGetProtoRevPoolRequest { message QueryGetProtoRevPoolResponse { // pool_id is the pool_id stored for the denom pair uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; +} + +message QueryGetAllProtocolRevenueRequest {} + +message QueryGetAllProtocolRevenueResponse { + AllProtocolRevenue all_protocol_revenue = 1 [ + (gogoproto.moretags) = "yaml:\"all_protocol_revenue\"", + (gogoproto.nullable) = false + ]; } \ No newline at end of file diff --git a/proto/osmosis/txfees/v1beta1/genesis.proto b/proto/osmosis/txfees/v1beta1/genesis.proto index 5bfcf88bec8..62aede6c35b 100644 --- a/proto/osmosis/txfees/v1beta1/genesis.proto +++ b/proto/osmosis/txfees/v1beta1/genesis.proto @@ -3,6 +3,7 @@ package osmosis.txfees.v1beta1; import "gogoproto/gogo.proto"; import "osmosis/txfees/v1beta1/feetoken.proto"; +import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/osmosis-labs/osmosis/v20/x/txfees/types"; @@ -10,4 +11,16 @@ option go_package = "github.com/osmosis-labs/osmosis/v20/x/txfees/types"; message GenesisState { string basedenom = 1; repeated FeeToken feetokens = 2 [ (gogoproto.nullable) = false ]; + + // KVStore state + TxFeesTracker txFeesTracker = 3; } + +message TxFeesTracker { + repeated cosmos.base.v1beta1.Coin tx_fees = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + int64 height_accounting_starts_from = 2 + [ (gogoproto.moretags) = "yaml:\"height_accounting_starts_from\"" ]; +} \ No newline at end of file diff --git a/x/poolmanager/keeper.go b/x/poolmanager/keeper.go index 4f41d37a7b0..ce49b60a85f 100644 --- a/x/poolmanager/keeper.go +++ b/x/poolmanager/keeper.go @@ -98,14 +98,40 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { for _, poolRoute := range genState.PoolRoutes { k.SetPoolRoute(ctx, poolRoute.PoolId, poolRoute.PoolType) } + + // We track taker fees generated in the module's KVStore. + // If the values were exported, we set them here. + // If the values were not exported, we initialize the tracker to zero and set the accounting height to the current height. + if !genState.TakerFeesTracker.TakerFeesToStakers.Empty() { + k.SetTakerFeeTrackerForStakers(ctx, genState.TakerFeesTracker.TakerFeesToStakers) + } else { + k.SetTakerFeeTrackerForStakers(ctx, sdk.NewCoins()) + } + if !genState.TakerFeesTracker.TakerFeesToCommunityPool.Empty() { + k.SetTakerFeeTrackerForCommunityPool(ctx, genState.TakerFeesTracker.TakerFeesToCommunityPool) + } else { + k.SetTakerFeeTrackerForCommunityPool(ctx, sdk.NewCoins()) + } + if genState.TakerFeesTracker.HeightAccountingStartsFrom != 0 { + k.SetTakerFeeTrackerStartHeight(ctx, genState.TakerFeesTracker.HeightAccountingStartsFrom) + } else { + k.SetTakerFeeTrackerStartHeight(ctx, ctx.BlockHeight()) + } } // ExportGenesis returns the poolmanager module's exported genesis. func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + // Export KVStore values to the genesis state so they can be imported in init genesis. + takerFeesTracker := types.TakerFeesTracker{ + TakerFeesToStakers: k.GetTakerFeeTrackerForStakers(ctx), + TakerFeesToCommunityPool: k.GetTakerFeeTrackerForCommunityPool(ctx), + HeightAccountingStartsFrom: k.GetTakerFeeTrackerStartHeight(ctx), + } return &types.GenesisState{ - Params: k.GetParams(ctx), - NextPoolId: k.GetNextPoolId(ctx), - PoolRoutes: k.getAllPoolRoutes(ctx), + Params: k.GetParams(ctx), + NextPoolId: k.GetNextPoolId(ctx), + PoolRoutes: k.getAllPoolRoutes(ctx), + TakerFeesTracker: &takerFeesTracker, } } diff --git a/x/poolmanager/keeper_test.go b/x/poolmanager/keeper_test.go index 686a93742f0..97fc51fcf1d 100644 --- a/x/poolmanager/keeper_test.go +++ b/x/poolmanager/keeper_test.go @@ -43,6 +43,12 @@ var ( PoolType: types.Stableswap, }, } + + testTakerFeesTracker = types.TakerFeesTracker{ + TakerFeesToStakers: sdk.Coins{sdk.NewCoin("uosmo", sdk.NewInt(1000))}, + TakerFeesToCommunityPool: sdk.Coins{sdk.NewCoin("uusdc", sdk.NewInt(1000))}, + HeightAccountingStartsFrom: 100, + } ) func TestKeeperTestSuite(t *testing.T) { @@ -101,8 +107,9 @@ func (s *KeeperTestSuite) TestInitGenesis() { }, AuthorizedQuoteDenoms: testAuthorizedQuoteDenoms, }, - NextPoolId: testExpectedPoolId, - PoolRoutes: testPoolRoute, + NextPoolId: testExpectedPoolId, + PoolRoutes: testPoolRoute, + TakerFeesTracker: &testTakerFeesTracker, }) params := s.App.PoolManagerKeeper.GetParams(s.Ctx) @@ -115,6 +122,9 @@ func (s *KeeperTestSuite) TestInitGenesis() { s.Require().Equal(testCommunityPoolDenomToSwapNonWhitelistedAssetsTo, params.TakerFeeParams.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) s.Require().Equal(testAuthorizedQuoteDenoms, params.AuthorizedQuoteDenoms) s.Require().Equal(testPoolRoute, s.App.PoolManagerKeeper.GetAllPoolRoutes(s.Ctx)) + s.Require().Equal(testTakerFeesTracker.TakerFeesToStakers, s.App.PoolManagerKeeper.GetTakerFeeTrackerForStakers(s.Ctx)) + s.Require().Equal(testTakerFeesTracker.TakerFeesToCommunityPool, s.App.PoolManagerKeeper.GetTakerFeeTrackerForCommunityPool(s.Ctx)) + s.Require().Equal(testTakerFeesTracker.HeightAccountingStartsFrom, s.App.PoolManagerKeeper.GetTakerFeeTrackerStartHeight(s.Ctx)) } func (s *KeeperTestSuite) TestExportGenesis() { @@ -130,8 +140,9 @@ func (s *KeeperTestSuite) TestExportGenesis() { }, AuthorizedQuoteDenoms: testAuthorizedQuoteDenoms, }, - NextPoolId: testExpectedPoolId, - PoolRoutes: testPoolRoute, + NextPoolId: testExpectedPoolId, + PoolRoutes: testPoolRoute, + TakerFeesTracker: &testTakerFeesTracker, }) genesis := s.App.PoolManagerKeeper.ExportGenesis(s.Ctx) @@ -144,4 +155,7 @@ func (s *KeeperTestSuite) TestExportGenesis() { s.Require().Equal(testCommunityPoolDenomToSwapNonWhitelistedAssetsTo, genesis.Params.TakerFeeParams.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) s.Require().Equal(testAuthorizedQuoteDenoms, genesis.Params.AuthorizedQuoteDenoms) s.Require().Equal(testPoolRoute, genesis.PoolRoutes) + s.Require().Equal(testTakerFeesTracker.TakerFeesToStakers, genesis.TakerFeesTracker.TakerFeesToStakers) + s.Require().Equal(testTakerFeesTracker.TakerFeesToCommunityPool, genesis.TakerFeesTracker.TakerFeesToCommunityPool) + s.Require().Equal(testTakerFeesTracker.HeightAccountingStartsFrom, genesis.TakerFeesTracker.HeightAccountingStartsFrom) } diff --git a/x/poolmanager/protorev.go b/x/poolmanager/protorev.go new file mode 100644 index 00000000000..286aa817569 --- /dev/null +++ b/x/poolmanager/protorev.go @@ -0,0 +1,101 @@ +package poolmanager + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + gogotypes "github.com/cosmos/gogoproto/types" + + "github.com/osmosis-labs/osmosis/osmoutils" + "github.com/osmosis-labs/osmosis/v20/x/poolmanager/types" +) + +// IncreaseTakerFeeTrackerForStakers gets the current value of the taker fee tracker for stakers, adds the given amount to it, and sets the new value. +func (k Keeper) IncreaseTakerFeeTrackerForStakers(ctx sdk.Context, takerFeeForStakers sdk.Coin) { + currentTakerFeeForStakers := k.GetTakerFeeTrackerForStakers(ctx) + if !takerFeeForStakers.IsZero() { + newTakerFeeForStakersCoins := currentTakerFeeForStakers.Add(takerFeeForStakers) + newTakerFeeForStakers := types.TrackedVolume{ + Amount: newTakerFeeForStakersCoins, + } + osmoutils.MustSet(ctx.KVStore(k.storeKey), types.KeyTakerFeeStakersProtoRev, &newTakerFeeForStakers) + } +} + +// IncreaseTakerFeeTrackerForCommunityPool gets the current value of the taker fee tracker for the community pool, adds the given amount to it, and sets the new value. +func (k Keeper) IncreaseTakerFeeTrackerForCommunityPool(ctx sdk.Context, takerFeeForCommunityPool sdk.Coin) { + currentTakerFeeForCommunityPool := k.GetTakerFeeTrackerForCommunityPool(ctx) + if !takerFeeForCommunityPool.IsZero() { + newTakerFeeForCommunityPoolCoins := currentTakerFeeForCommunityPool.Add(takerFeeForCommunityPool) + newTakerFeeForCommunityPool := types.TrackedVolume{ + Amount: newTakerFeeForCommunityPoolCoins, + } + osmoutils.MustSet(ctx.KVStore(k.storeKey), types.KeyTakerFeeCommunityPoolProtoRev, &newTakerFeeForCommunityPool) + } +} + +func (k Keeper) SetTakerFeeTrackerForStakers(ctx sdk.Context, takerFeeForStakers sdk.Coins) { + newTakerFeeForStakers := types.TrackedVolume{ + Amount: takerFeeForStakers, + } + osmoutils.MustSet(ctx.KVStore(k.storeKey), types.KeyTakerFeeStakersProtoRev, &newTakerFeeForStakers) +} + +func (k Keeper) SetTakerFeeTrackerForCommunityPool(ctx sdk.Context, takerFeeForCommunityPool sdk.Coins) { + newTakerFeeForCommunityPool := types.TrackedVolume{ + Amount: takerFeeForCommunityPool, + } + osmoutils.MustSet(ctx.KVStore(k.storeKey), types.KeyTakerFeeCommunityPoolProtoRev, &newTakerFeeForCommunityPool) +} + +func (k Keeper) GetTakerFeeTrackerForStakers(ctx sdk.Context) (currentTakerFeeForStakers sdk.Coins) { + var takerFeeForStakers types.TrackedVolume + takerFeeFound, err := osmoutils.Get(ctx.KVStore(k.storeKey), types.KeyTakerFeeStakersProtoRev, &takerFeeForStakers) + if err != nil { + // We can only encounter an error if a database or serialization errors occurs, so we panic here. + // Normally this would be handled by `osmoutils.MustGet`, but since we want to specifically use `osmoutils.Get`, + // we also have to manually panic here. + panic(err) + } + + // If no volume was found, we treat the existing volume as 0. + // While we can technically require volume to exist, we would need to store empty coins in state for each pool (past and present), + // which is a high storage cost to pay for a weak guardrail. + currentTakerFeeForStakers = sdk.Coins(nil) + if takerFeeFound { + currentTakerFeeForStakers = takerFeeForStakers.Amount + } + + return currentTakerFeeForStakers +} + +func (k Keeper) GetTakerFeeTrackerForCommunityPool(ctx sdk.Context) (currentTakerFeeForCommunityPool sdk.Coins) { + var takerFeeForCommunityPool types.TrackedVolume + takerFeeFound, err := osmoutils.Get(ctx.KVStore(k.storeKey), types.KeyTakerFeeCommunityPoolProtoRev, &takerFeeForCommunityPool) + if err != nil { + // We can only encounter an error if a database or serialization errors occurs, so we panic here. + // Normally this would be handled by `osmoutils.MustGet`, but since we want to specifically use `osmoutils.Get`, + // we also have to manually panic here. + panic(err) + } + + // If no volume was found, we treat the existing volume as 0. + // While we can technically require volume to exist, we would need to store empty coins in state for each pool (past and present), + // which is a high storage cost to pay for a weak guardrail. + currentTakerFeeForCommunityPool = sdk.Coins(nil) + if takerFeeFound { + currentTakerFeeForCommunityPool = takerFeeForCommunityPool.Amount + } + + return currentTakerFeeForCommunityPool +} + +// GetTakerFeeTrackerStartHeight gets the height from which we started accounting for taker fees. +func (k Keeper) GetTakerFeeTrackerStartHeight(ctx sdk.Context) int64 { + startHeight := gogotypes.Int64Value{} + osmoutils.MustGet(ctx.KVStore(k.storeKey), types.KeyTakerFeeProtoRevAccountingHeight, &startHeight) + return startHeight.Value +} + +// SetTakerFeeTrackerStartHeight sets the height from which we started accounting for taker fees. +func (k Keeper) SetTakerFeeTrackerStartHeight(ctx sdk.Context, startHeight int64) { + osmoutils.MustSet(ctx.KVStore(k.storeKey), types.KeyTakerFeeProtoRevAccountingHeight, &gogotypes.Int64Value{Value: startHeight}) +} diff --git a/x/poolmanager/protorev_test.go b/x/poolmanager/protorev_test.go new file mode 100644 index 00000000000..a7f828f4774 --- /dev/null +++ b/x/poolmanager/protorev_test.go @@ -0,0 +1,165 @@ +package poolmanager_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (s *KeeperTestSuite) TestGetSetTakerFeeTrackerForStakersAndCommunityPool() { + tests := map[string]struct { + firstTakerFeeForStakers sdk.Coins + secondTakerFeeForStakers sdk.Coins + firstTakerFeeForCommunityPool sdk.Coins + secondTakerFeeForCommunityPool sdk.Coins + }{ + "happy path: replace single coin with increased single coin": { + firstTakerFeeForStakers: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100))), + secondTakerFeeForStakers: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(200))), + + firstTakerFeeForCommunityPool: sdk.NewCoins(sdk.NewCoin("usdc", sdk.NewInt(100))), + secondTakerFeeForCommunityPool: sdk.NewCoins(sdk.NewCoin("usdc", sdk.NewInt(200))), + }, + "replace single coin with decreased single coin": { + firstTakerFeeForStakers: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100))), + secondTakerFeeForStakers: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(50))), + + firstTakerFeeForCommunityPool: sdk.NewCoins(sdk.NewCoin("usdc", sdk.NewInt(100))), + secondTakerFeeForCommunityPool: sdk.NewCoins(sdk.NewCoin("usdc", sdk.NewInt(50))), + }, + "replace single coin with different denom": { + firstTakerFeeForStakers: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100))), + secondTakerFeeForStakers: sdk.NewCoins(sdk.NewCoin("usdc", sdk.NewInt(100))), + + firstTakerFeeForCommunityPool: sdk.NewCoins(sdk.NewCoin("usdc", sdk.NewInt(100))), + secondTakerFeeForCommunityPool: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100))), + }, + "replace single coin with multiple coins": { + firstTakerFeeForStakers: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100))), + secondTakerFeeForStakers: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100)), sdk.NewCoin("usdc", sdk.NewInt(200))), + + firstTakerFeeForCommunityPool: sdk.NewCoins(sdk.NewCoin("usdc", sdk.NewInt(100))), + secondTakerFeeForCommunityPool: sdk.NewCoins(sdk.NewCoin("usdc", sdk.NewInt(100)), sdk.NewCoin("eth", sdk.NewInt(200))), + }, + "replace multiple coins with single coin": { + firstTakerFeeForStakers: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100)), sdk.NewCoin("usdc", sdk.NewInt(200))), + secondTakerFeeForStakers: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(200))), + + firstTakerFeeForCommunityPool: sdk.NewCoins(sdk.NewCoin("usdc", sdk.NewInt(100)), sdk.NewCoin("eth", sdk.NewInt(200))), + secondTakerFeeForCommunityPool: sdk.NewCoins(sdk.NewCoin("usdc", sdk.NewInt(50))), + }, + } + + for name, tc := range tests { + s.Run(name, func() { + s.SetupTest() + + s.Require().Empty(s.App.PoolManagerKeeper.GetTakerFeeTrackerStartHeight(s.Ctx)) + s.Require().Empty(s.App.PoolManagerKeeper.GetTakerFeeTrackerForStakers(s.Ctx)) + + s.App.PoolManagerKeeper.SetTakerFeeTrackerForStakers(s.Ctx, tc.firstTakerFeeForStakers) + s.App.PoolManagerKeeper.SetTakerFeeTrackerForCommunityPool(s.Ctx, tc.firstTakerFeeForCommunityPool) + + actualFirstTakerFeeForStakers := s.App.PoolManagerKeeper.GetTakerFeeTrackerForStakers(s.Ctx) + actualFirstTakerFeeForCommunityPool := s.App.PoolManagerKeeper.GetTakerFeeTrackerForCommunityPool(s.Ctx) + + s.Require().Equal(tc.firstTakerFeeForStakers, actualFirstTakerFeeForStakers) + s.Require().Equal(tc.firstTakerFeeForCommunityPool, actualFirstTakerFeeForCommunityPool) + + s.App.PoolManagerKeeper.SetTakerFeeTrackerForStakers(s.Ctx, tc.secondTakerFeeForStakers) + s.App.PoolManagerKeeper.SetTakerFeeTrackerForCommunityPool(s.Ctx, tc.secondTakerFeeForCommunityPool) + + actualSecondTakerFeeForStakers := s.App.PoolManagerKeeper.GetTakerFeeTrackerForStakers(s.Ctx) + actualSecondTakerFeeForCommunityPool := s.App.PoolManagerKeeper.GetTakerFeeTrackerForCommunityPool(s.Ctx) + + s.Require().Equal(tc.secondTakerFeeForStakers, actualSecondTakerFeeForStakers) + s.Require().Equal(tc.secondTakerFeeForCommunityPool, actualSecondTakerFeeForCommunityPool) + }) + } +} + +func (s *KeeperTestSuite) TestGetSetTakerFeeTrackerStartHeight() { + tests := map[string]struct { + firstTakerFeeTrackerStartHeight int64 + secondTakerFeeTrackerStartHeight int64 + }{ + "replace tracker height with a higher height": { + firstTakerFeeTrackerStartHeight: 100, + secondTakerFeeTrackerStartHeight: 5000, + }, + "replace tracker height with a lower height": { + firstTakerFeeTrackerStartHeight: 100, + secondTakerFeeTrackerStartHeight: 50, + }, + "replace tracker height back to zero": { + firstTakerFeeTrackerStartHeight: 100, + secondTakerFeeTrackerStartHeight: 0, + }, + } + + for name, tc := range tests { + s.Run(name, func() { + s.SetupTest() + + s.Require().Empty(s.App.PoolManagerKeeper.GetTakerFeeTrackerStartHeight(s.Ctx)) + + s.App.PoolManagerKeeper.SetTakerFeeTrackerStartHeight(s.Ctx, tc.firstTakerFeeTrackerStartHeight) + actualFirstTakerFeeTrackerStartHeight := s.App.PoolManagerKeeper.GetTakerFeeTrackerStartHeight(s.Ctx) + s.Require().Equal(tc.firstTakerFeeTrackerStartHeight, actualFirstTakerFeeTrackerStartHeight) + + s.App.PoolManagerKeeper.SetTakerFeeTrackerStartHeight(s.Ctx, tc.secondTakerFeeTrackerStartHeight) + actualSecondTakerFeeTrackerStartHeight := s.App.PoolManagerKeeper.GetTakerFeeTrackerStartHeight(s.Ctx) + s.Require().Equal(tc.secondTakerFeeTrackerStartHeight, actualSecondTakerFeeTrackerStartHeight) + }) + } +} + +func (s *KeeperTestSuite) TestIncreaseTakerFeeTrackerForStakersAndCommunityPool() { + tests := map[string]struct { + initialTakerFeeForStakers sdk.Coins + initialTakerFeeForCommunityPool sdk.Coins + + increaseTakerFeeForStakersBy sdk.Coin + increaseTakerFeeForCommunityPoolBy sdk.Coin + }{ + "happy path: increase single denom tracker": { + initialTakerFeeForStakers: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100))), + initialTakerFeeForCommunityPool: sdk.NewCoins(sdk.NewCoin("usdc", sdk.NewInt(100))), + + increaseTakerFeeForStakersBy: sdk.NewCoin("eth", sdk.NewInt(50)), + increaseTakerFeeForCommunityPoolBy: sdk.NewCoin("usdc", sdk.NewInt(50)), + }, + "increase multi denom tracker": { + initialTakerFeeForStakers: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100)), sdk.NewCoin("usdc", sdk.NewInt(200))), + initialTakerFeeForCommunityPool: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100)), sdk.NewCoin("usdc", sdk.NewInt(200))), + + increaseTakerFeeForStakersBy: sdk.NewCoin("eth", sdk.NewInt(50)), + increaseTakerFeeForCommunityPoolBy: sdk.NewCoin("usdc", sdk.NewInt(50)), + }, + } + + for name, tc := range tests { + s.Run(name, func() { + s.SetupTest() + + s.Require().Empty(s.App.PoolManagerKeeper.GetTakerFeeTrackerStartHeight(s.Ctx)) + s.Require().Empty(s.App.PoolManagerKeeper.GetTakerFeeTrackerForStakers(s.Ctx)) + + s.App.PoolManagerKeeper.SetTakerFeeTrackerForStakers(s.Ctx, tc.initialTakerFeeForStakers) + s.App.PoolManagerKeeper.SetTakerFeeTrackerForCommunityPool(s.Ctx, tc.initialTakerFeeForCommunityPool) + + actualInitialTakerFeeForStakers := s.App.PoolManagerKeeper.GetTakerFeeTrackerForStakers(s.Ctx) + actualInitialTakerFeeForCommunityPool := s.App.PoolManagerKeeper.GetTakerFeeTrackerForCommunityPool(s.Ctx) + + s.Require().Equal(tc.initialTakerFeeForStakers, actualInitialTakerFeeForStakers) + s.Require().Equal(tc.initialTakerFeeForCommunityPool, actualInitialTakerFeeForCommunityPool) + + s.App.PoolManagerKeeper.IncreaseTakerFeeTrackerForStakers(s.Ctx, tc.increaseTakerFeeForStakersBy) + s.App.PoolManagerKeeper.IncreaseTakerFeeTrackerForCommunityPool(s.Ctx, tc.increaseTakerFeeForCommunityPoolBy) + + takerFeeForStakersAfterIncrease := s.App.PoolManagerKeeper.GetTakerFeeTrackerForStakers(s.Ctx) + takerFeeForCommunityPoolAfterIncrease := s.App.PoolManagerKeeper.GetTakerFeeTrackerForCommunityPool(s.Ctx) + + s.Require().Equal(tc.initialTakerFeeForStakers.Add(sdk.NewCoins(tc.increaseTakerFeeForStakersBy)...), takerFeeForStakersAfterIncrease) + s.Require().Equal(tc.initialTakerFeeForCommunityPool.Add(sdk.NewCoins(tc.increaseTakerFeeForCommunityPoolBy)...), takerFeeForCommunityPoolAfterIncrease) + }) + } +} diff --git a/x/poolmanager/taker_fee.go b/x/poolmanager/taker_fee.go index dfc15d9056b..8bb677c76ec 100644 --- a/x/poolmanager/taker_fee.go +++ b/x/poolmanager/taker_fee.go @@ -116,22 +116,24 @@ func (k Keeper) chargeTakerFee(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom if poolManagerParams.TakerFeeParams.OsmoTakerFeeDistribution.CommunityPool.GT(osmomath.ZeroDec()) { // Osmo community pool funds is a direct send osmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToLegacyDec().Mul(poolManagerParams.TakerFeeParams.OsmoTakerFeeDistribution.CommunityPool) - osmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(defaultTakerFeeDenom, osmoTakerFeeToCommunityPoolDec.TruncateInt())) - err := k.communityPoolKeeper.FundCommunityPool(ctx, osmoTakerFeeToCommunityPoolCoins, sender) + osmoTakerFeeToCommunityPoolCoin := sdk.NewCoin(defaultTakerFeeDenom, osmoTakerFeeToCommunityPoolDec.TruncateInt()) + err := k.communityPoolKeeper.FundCommunityPool(ctx, sdk.NewCoins(osmoTakerFeeToCommunityPoolCoin), sender) if err != nil { return sdk.Coin{}, err } - takerFeeAmtRemaining = takerFeeAmtRemaining.Sub(osmoTakerFeeToCommunityPoolCoins.AmountOf(defaultTakerFeeDenom)) + k.IncreaseTakerFeeTrackerForCommunityPool(ctx, osmoTakerFeeToCommunityPoolCoin) + takerFeeAmtRemaining = takerFeeAmtRemaining.Sub(osmoTakerFeeToCommunityPoolCoin.Amount) } // Staking Rewards: if poolManagerParams.TakerFeeParams.OsmoTakerFeeDistribution.StakingRewards.GT(osmomath.ZeroDec()) { // Osmo staking rewards funds are sent to the non native fee pool module account (even though its native, we want to distribute at the same time as the non native fee tokens) // We could stream these rewards via the fee collector account, but this is decision to be made by governance. - osmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(defaultTakerFeeDenom, takerFeeAmtRemaining)) - err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, feeCollectorForStakingRewardsName, osmoTakerFeeToStakingRewardsCoins) + osmoTakerFeeToStakingRewardsCoin := sdk.NewCoin(defaultTakerFeeDenom, takerFeeAmtRemaining) + err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, feeCollectorForStakingRewardsName, sdk.NewCoins(osmoTakerFeeToStakingRewardsCoin)) if err != nil { return sdk.Coin{}, err } + k.IncreaseTakerFeeTrackerForStakers(ctx, osmoTakerFeeToStakingRewardsCoin) } // If the denom is not the base denom: @@ -142,32 +144,35 @@ func (k Keeper) chargeTakerFee(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom // If the non osmo denom is a whitelisted quote asset, we send to the community pool if denomIsWhitelisted { nonOsmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToLegacyDec().Mul(poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.CommunityPool) - nonOsmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToCommunityPoolDec.TruncateInt())) - err := k.communityPoolKeeper.FundCommunityPool(ctx, nonOsmoTakerFeeToCommunityPoolCoins, sender) + nonOsmoTakerFeeToCommunityPoolCoin := sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToCommunityPoolDec.TruncateInt()) + err := k.communityPoolKeeper.FundCommunityPool(ctx, sdk.NewCoins(nonOsmoTakerFeeToCommunityPoolCoin), sender) if err != nil { return sdk.Coin{}, err } - takerFeeAmtRemaining = takerFeeAmtRemaining.Sub(nonOsmoTakerFeeToCommunityPoolCoins.AmountOf(tokenIn.Denom)) + k.IncreaseTakerFeeTrackerForCommunityPool(ctx, nonOsmoTakerFeeToCommunityPoolCoin) + takerFeeAmtRemaining = takerFeeAmtRemaining.Sub(nonOsmoTakerFeeToCommunityPoolCoin.Amount) } else { // If the non osmo denom is not a whitelisted asset, we send to the non native fee pool for community pool module account. // At epoch, this account swaps the non native, non whitelisted assets for XXX and sends to the community pool. nonOsmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToLegacyDec().Mul(poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.CommunityPool) - nonOsmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToCommunityPoolDec.TruncateInt())) - err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, feeCollectorForCommunityPoolName, nonOsmoTakerFeeToCommunityPoolCoins) + nonOsmoTakerFeeToCommunityPoolCoin := sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToCommunityPoolDec.TruncateInt()) + err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, feeCollectorForCommunityPoolName, sdk.NewCoins(nonOsmoTakerFeeToCommunityPoolCoin)) if err != nil { return sdk.Coin{}, err } - takerFeeAmtRemaining = takerFeeAmtRemaining.Sub(nonOsmoTakerFeeToCommunityPoolCoins.AmountOf(tokenIn.Denom)) + k.IncreaseTakerFeeTrackerForCommunityPool(ctx, nonOsmoTakerFeeToCommunityPoolCoin) + takerFeeAmtRemaining = takerFeeAmtRemaining.Sub(nonOsmoTakerFeeToCommunityPoolCoin.Amount) } } // Staking Rewards: if poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.StakingRewards.GT(osmomath.ZeroDec()) { // Non Osmo staking rewards are sent to the non native fee pool module account - nonOsmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(takerFeeCoin.Denom, takerFeeAmtRemaining)) - err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, feeCollectorForStakingRewardsName, nonOsmoTakerFeeToStakingRewardsCoins) + nonOsmoTakerFeeToStakingRewardsCoin := sdk.NewCoin(takerFeeCoin.Denom, takerFeeAmtRemaining) + err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, feeCollectorForStakingRewardsName, sdk.NewCoins(nonOsmoTakerFeeToStakingRewardsCoin)) if err != nil { return sdk.Coin{}, err } + k.IncreaseTakerFeeTrackerForStakers(ctx, nonOsmoTakerFeeToStakingRewardsCoin) } } diff --git a/x/poolmanager/taker_fee_test.go b/x/poolmanager/taker_fee_test.go index 425c10522d0..dbdb44cfb32 100644 --- a/x/poolmanager/taker_fee_test.go +++ b/x/poolmanager/taker_fee_test.go @@ -19,7 +19,7 @@ func (s *KeeperTestSuite) TestChargeTakerFee() { var ( defaultTakerFee = osmomath.MustNewDecFromStr("0.01") - defaultAmount = sdk.NewInt(100) + defaultAmount = sdk.NewInt(10000000) ) tests := map[string]struct { @@ -89,17 +89,44 @@ func (s *KeeperTestSuite) TestChargeTakerFee() { // Pre-fund owner. s.FundAcc(s.TestAccs[tc.senderIndex], sdk.NewCoins(tc.tokenIn)) + // Check the taker fee tracker before the taker fee is charged. + takerFeeTrackerForStakersBefore := poolManager.GetTakerFeeTrackerForStakers(s.Ctx) + takerFeeTrackerForCommunityPoolBefore := poolManager.GetTakerFeeTrackerForCommunityPool(s.Ctx) + // System under test. tokenInAfterTakerFee, err := poolManager.ChargeTakerFee(s.Ctx, tc.tokenIn, tc.tokenOutDenom, s.TestAccs[tc.senderIndex], tc.exactIn) + // Check the taker fee tracker after the taker fee is charged. + takerFeeTrackerForStakersAfter := poolManager.GetTakerFeeTrackerForStakers(s.Ctx) + takerFeeTrackerForCommunityPoolAfter := poolManager.GetTakerFeeTrackerForCommunityPool(s.Ctx) + if tc.expectError != nil { s.Require().Error(err) + s.Require().Equal(takerFeeTrackerForStakersBefore, takerFeeTrackerForStakersAfter) + s.Require().Equal(takerFeeTrackerForCommunityPoolBefore, takerFeeTrackerForCommunityPoolAfter) return } s.Require().NoError(err) + params := s.App.PoolManagerKeeper.GetParams(s.Ctx) + expectedTotalTakerFee := defaultAmount.Sub(tc.expectedResult.Amount) + expectedTakerFeeToStakersAmount := expectedTotalTakerFee.ToLegacyDec().Mul(params.TakerFeeParams.NonOsmoTakerFeeDistribution.StakingRewards) + expectedTakerFeeToCommunityPoolAmount := expectedTotalTakerFee.ToLegacyDec().Mul(params.TakerFeeParams.NonOsmoTakerFeeDistribution.CommunityPool) + expectedTakerFeeToStakers := sdk.NewCoin(tc.expectedResult.Denom, expectedTakerFeeToStakersAmount.TruncateInt()) + expectedTakerFeeToCommunityPool := sdk.NewCoin(tc.expectedResult.Denom, expectedTakerFeeToCommunityPoolAmount.TruncateInt()) + // Validate results. s.Require().Equal(tc.expectedResult.String(), tokenInAfterTakerFee.String()) + expectedTakerFeeTrackerForStakersAfter := takerFeeTrackerForStakersBefore.Add(expectedTakerFeeToStakers) + if expectedTakerFeeTrackerForStakersAfter.Empty() { + expectedTakerFeeTrackerForStakersAfter = sdk.Coins(nil) + } + s.Require().Equal(expectedTakerFeeTrackerForStakersAfter, takerFeeTrackerForStakersAfter) + expectedTakerFeeTrackerForCommunityPoolAfter := takerFeeTrackerForCommunityPoolBefore.Add(expectedTakerFeeToCommunityPool) + if expectedTakerFeeTrackerForCommunityPoolAfter.Empty() { + expectedTakerFeeTrackerForCommunityPoolAfter = sdk.Coins(nil) + } + s.Require().Equal(expectedTakerFeeTrackerForCommunityPoolAfter, takerFeeTrackerForCommunityPoolAfter) }) } } diff --git a/x/poolmanager/types/genesis.go b/x/poolmanager/types/genesis.go index dc3cb4f8682..c4e8b1aa9bf 100644 --- a/x/poolmanager/types/genesis.go +++ b/x/poolmanager/types/genesis.go @@ -1,12 +1,21 @@ package types -import "errors" +import ( + "errors" + + sdk "github.com/cosmos/cosmos-sdk/types" +) // DefaultGenesis returns the default poolmanager genesis state. func DefaultGenesis() *GenesisState { return &GenesisState{ Params: DefaultParams(), NextPoolId: 1, + TakerFeesTracker: &TakerFeesTracker{ + TakerFeesToStakers: sdk.NewCoins(), + TakerFeesToCommunityPool: sdk.NewCoins(), + HeightAccountingStartsFrom: 0, + }, } } diff --git a/x/poolmanager/types/genesis.pb.go b/x/poolmanager/types/genesis.pb.go index fb198404987..ff1e0cdce82 100644 --- a/x/poolmanager/types/genesis.pb.go +++ b/x/poolmanager/types/genesis.pb.go @@ -107,6 +107,8 @@ type GenesisState struct { Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` // pool_routes is the container of the mappings from pool id to pool type. PoolRoutes []ModuleRoute `protobuf:"bytes,3,rep,name=pool_routes,json=poolRoutes,proto3" json:"pool_routes"` + // KVStore state + TakerFeesTracker *TakerFeesTracker `protobuf:"bytes,4,opt,name=taker_fees_tracker,json=takerFeesTracker,proto3" json:"taker_fees_tracker,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -163,6 +165,13 @@ func (m *GenesisState) GetPoolRoutes() []ModuleRoute { return nil } +func (m *GenesisState) GetTakerFeesTracker() *TakerFeesTracker { + if m != nil { + return m.TakerFeesTracker + } + return nil +} + // TakerFeeParams consolidates the taker fee parameters for the poolmanager. type TakerFeeParams struct { // default_taker_fee is the fee used when creating a new pool that doesn't @@ -312,11 +321,72 @@ func (m *TakerFeeDistributionPercentage) XXX_DiscardUnknown() { var xxx_messageInfo_TakerFeeDistributionPercentage proto.InternalMessageInfo +type TakerFeesTracker struct { + TakerFeesToStakers github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=taker_fees_to_stakers,json=takerFeesToStakers,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"taker_fees_to_stakers"` + TakerFeesToCommunityPool github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=taker_fees_to_community_pool,json=takerFeesToCommunityPool,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"taker_fees_to_community_pool"` + HeightAccountingStartsFrom int64 `protobuf:"varint,3,opt,name=height_accounting_starts_from,json=heightAccountingStartsFrom,proto3" json:"height_accounting_starts_from,omitempty" yaml:"height_accounting_starts_from"` +} + +func (m *TakerFeesTracker) Reset() { *m = TakerFeesTracker{} } +func (m *TakerFeesTracker) String() string { return proto.CompactTextString(m) } +func (*TakerFeesTracker) ProtoMessage() {} +func (*TakerFeesTracker) Descriptor() ([]byte, []int) { + return fileDescriptor_aa099d9fbdf68b35, []int{4} +} +func (m *TakerFeesTracker) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TakerFeesTracker) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TakerFeesTracker.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 *TakerFeesTracker) XXX_Merge(src proto.Message) { + xxx_messageInfo_TakerFeesTracker.Merge(m, src) +} +func (m *TakerFeesTracker) XXX_Size() int { + return m.Size() +} +func (m *TakerFeesTracker) XXX_DiscardUnknown() { + xxx_messageInfo_TakerFeesTracker.DiscardUnknown(m) +} + +var xxx_messageInfo_TakerFeesTracker proto.InternalMessageInfo + +func (m *TakerFeesTracker) GetTakerFeesToStakers() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.TakerFeesToStakers + } + return nil +} + +func (m *TakerFeesTracker) GetTakerFeesToCommunityPool() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.TakerFeesToCommunityPool + } + return nil +} + +func (m *TakerFeesTracker) GetHeightAccountingStartsFrom() int64 { + if m != nil { + return m.HeightAccountingStartsFrom + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "osmosis.poolmanager.v1beta1.Params") proto.RegisterType((*GenesisState)(nil), "osmosis.poolmanager.v1beta1.GenesisState") proto.RegisterType((*TakerFeeParams)(nil), "osmosis.poolmanager.v1beta1.TakerFeeParams") proto.RegisterType((*TakerFeeDistributionPercentage)(nil), "osmosis.poolmanager.v1beta1.TakerFeeDistributionPercentage") + proto.RegisterType((*TakerFeesTracker)(nil), "osmosis.poolmanager.v1beta1.TakerFeesTracker") } func init() { @@ -324,61 +394,69 @@ func init() { } var fileDescriptor_aa099d9fbdf68b35 = []byte{ - // 855 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4f, 0x6f, 0xdc, 0x44, - 0x14, 0x8f, 0x9b, 0xb0, 0x52, 0x26, 0x65, 0x97, 0x1a, 0x42, 0xdd, 0x04, 0xd9, 0x2b, 0xf7, 0xb2, - 0x08, 0xd5, 0xa6, 0x41, 0x2a, 0x12, 0xd0, 0x43, 0x36, 0x51, 0x10, 0x52, 0x69, 0x53, 0x37, 0x12, - 0x52, 0x2f, 0xa3, 0x59, 0xcf, 0x8b, 0x63, 0x65, 0xed, 0xb7, 0x78, 0xc6, 0x49, 0x97, 0xaf, 0xc0, - 0x05, 0x89, 0x2b, 0x67, 0x0e, 0xdc, 0xf8, 0x0e, 0x1c, 0x7a, 0xec, 0x11, 0x71, 0x30, 0x68, 0x73, - 0xe6, 0xb2, 0x9f, 0x00, 0x79, 0x66, 0x76, 0x13, 0x87, 0x64, 0x15, 0xc1, 0x69, 0x77,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x81, 0x98, 0x1d, 0xc2, 0x93, 0xad, 0x8f, 0xc3, 0x57, 0x8d, - 0x17, 0x4a, 0x3d, 0x01, 0x83, 0x96, 0x7a, 0x93, 0x3e, 0xf9, 0x27, 0x00, 0x00, 0xff, 0xff, 0x7d, - 0x1e, 0x36, 0xaf, 0x99, 0x07, 0x00, 0x00, + // 989 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4d, 0x6f, 0xdb, 0x46, + 0x13, 0x36, 0x2d, 0xbf, 0x06, 0xbc, 0xce, 0x6b, 0x39, 0xdb, 0xba, 0x61, 0xec, 0x54, 0x14, 0x98, + 0x1e, 0x54, 0x14, 0x26, 0x13, 0x17, 0x48, 0x81, 0xb6, 0x39, 0x48, 0x36, 0x5c, 0x14, 0x48, 0x13, + 0x87, 0x16, 0x50, 0x20, 0x3d, 0x2c, 0x56, 0xe4, 0x88, 0x22, 0x24, 0x72, 0xd5, 0xdd, 0xa5, 0x1d, + 0xf5, 0xd0, 0x3f, 0x10, 0x14, 0x28, 0xd0, 0x6b, 0x2f, 0xbd, 0xf4, 0xd0, 0x5b, 0xff, 0x45, 0x8e, + 0x39, 0x16, 0x3d, 0xb0, 0x85, 0x7c, 0xee, 0x45, 0xbf, 0xa0, 0xe0, 0x2e, 0xf5, 0x19, 0x5b, 0x75, + 0x3f, 0x4e, 0xf6, 0xce, 0xcc, 0xf3, 0xcc, 0x33, 0x33, 0x3b, 0x2b, 0xa2, 0x77, 0x99, 0x88, 0x99, + 0x88, 0x84, 0xdb, 0x67, 0xac, 0x17, 0xd3, 0x84, 0x86, 0xc0, 0xdd, 0xb3, 0xfb, 0x2d, 0x90, 0xf4, + 0xbe, 0x1b, 0x42, 0x02, 0x22, 0x12, 0x4e, 0x9f, 0x33, 0xc9, 0xf0, 0x5e, 0x11, 0xea, 0xcc, 0x84, + 0x3a, 0x45, 0xe8, 0xee, 0x9b,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, 0x1d, + 0x49, 0xa8, 0xef, 0xb3, 0x34, 0x91, 0xf9, 0xd4, 0x84, 0xa4, 0x5c, 0x0a, 0xd2, 0xe6, 0x2c, 0x56, + 0xef, 0x40, 0xa9, 0x51, 0x1b, 0x65, 0xd6, 0x3b, 0xba, 0xe7, 0x4b, 0xc3, 0x6d, 0x6f, 0x57, 0xfb, + 0xeb, 0x13, 0xf7, 0xa9, 0xf2, 0x1e, 0x73, 0x16, 0x37, 0x9e, 0xbe, 0x1c, 0x56, 0x8c, 0x57, 0xc3, + 0x8a, 0xf1, 0xfb, 0xb0, 0x62, 0x7c, 0x7b, 0x51, 0x59, 0x79, 0x75, 0x51, 0x59, 0xf9, 0xe5, 0xa2, + 0xb2, 0xf2, 0xec, 0x83, 0x99, 0x52, 0x8a, 0x17, 0x67, 0xbf, 0x47, 0x5b, 0x62, 0x7c, 0x70, 0xcf, + 0x0e, 0xee, 0xb9, 0xcf, 0xe7, 0x3e, 0x47, 0x54, 0x7d, 0xad, 0x75, 0xf5, 0x01, 0xf2, 0xfe, 0x9f, + 0x01, 0x00, 0x00, 0xff, 0xff, 0x44, 0xa8, 0x64, 0x7e, 0x86, 0x09, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -457,6 +535,18 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.TakerFeesTracker != nil { + { + size, err := m.TakerFeesTracker.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } if len(m.PoolRoutes) > 0 { for iNdEx := len(m.PoolRoutes) - 1; iNdEx >= 0; iNdEx-- { { @@ -610,6 +700,62 @@ func (m *TakerFeeDistributionPercentage) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *TakerFeesTracker) 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 *TakerFeesTracker) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TakerFeesTracker) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.HeightAccountingStartsFrom != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.HeightAccountingStartsFrom)) + i-- + dAtA[i] = 0x18 + } + if len(m.TakerFeesToCommunityPool) > 0 { + for iNdEx := len(m.TakerFeesToCommunityPool) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TakerFeesToCommunityPool[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.TakerFeesToStakers) > 0 { + for iNdEx := len(m.TakerFeesToStakers) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TakerFeesToStakers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { offset -= sovGenesis(v) base := offset @@ -661,6 +807,10 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if m.TakerFeesTracker != nil { + l = m.TakerFeesTracker.Size() + n += 1 + l + sovGenesis(uint64(l)) + } return n } @@ -708,6 +858,30 @@ func (m *TakerFeeDistributionPercentage) Size() (n int) { return n } +func (m *TakerFeesTracker) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.TakerFeesToStakers) > 0 { + for _, e := range m.TakerFeesToStakers { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.TakerFeesToCommunityPool) > 0 { + for _, e := range m.TakerFeesToCommunityPool { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.HeightAccountingStartsFrom != 0 { + n += 1 + sovGenesis(uint64(m.HeightAccountingStartsFrom)) + } + return n +} + func sovGenesis(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -978,6 +1152,42 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TakerFeesTracker", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.TakerFeesTracker == nil { + m.TakerFeesTracker = &TakerFeesTracker{} + } + if err := m.TakerFeesTracker.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) @@ -1363,6 +1573,143 @@ func (m *TakerFeeDistributionPercentage) Unmarshal(dAtA []byte) error { } return nil } +func (m *TakerFeesTracker) 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 ErrIntOverflowGenesis + } + 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: TakerFeesTracker: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TakerFeesTracker: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TakerFeesToStakers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TakerFeesToStakers = append(m.TakerFeesToStakers, types.Coin{}) + if err := m.TakerFeesToStakers[len(m.TakerFeesToStakers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TakerFeesToCommunityPool", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TakerFeesToCommunityPool = append(m.TakerFeesToCommunityPool, types.Coin{}) + if err := m.TakerFeesToCommunityPool[len(m.TakerFeesToCommunityPool)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field HeightAccountingStartsFrom", wireType) + } + m.HeightAccountingStartsFrom = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.HeightAccountingStartsFrom |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipGenesis(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/poolmanager/types/keys.go b/x/poolmanager/types/keys.go index f7f544ab81e..5f3272e8237 100644 --- a/x/poolmanager/types/keys.go +++ b/x/poolmanager/types/keys.go @@ -28,6 +28,15 @@ var ( // DenomTradePairPrefix defines prefix to store denom trade pair for taker fee. DenomTradePairPrefix = []byte{0x04} + + // KeyTakerFeeStakersProtoRev defines key to store the taker fee for stakers tracker. + KeyTakerFeeStakersProtoRev = []byte{0x05} + + // KeyTakerFeeCommunityPoolProtoRev defines key to store the taker fee for community pool tracker. + KeyTakerFeeCommunityPoolProtoRev = []byte{0x06} + + // KeyTakerFeeProtoRevAccountingHeight defines key to store the accounting height for the above taker fee trackers. + KeyTakerFeeProtoRevAccountingHeight = []byte{0x07} ) // ModuleRouteToBytes serializes moduleRoute to bytes. diff --git a/x/protorev/client/cli/query.go b/x/protorev/client/cli/query.go index 3e45a57dc01..41ede1e0fc5 100644 --- a/x/protorev/client/cli/query.go +++ b/x/protorev/client/cli/query.go @@ -30,6 +30,7 @@ func NewCmdQuery() *cobra.Command { osmocli.AddQueryCmd(cmd, types.NewQueryClient, NewQueryEnabledCmd) osmocli.AddQueryCmd(cmd, types.NewQueryClient, NewQueryInfoByPoolTypeCmd) osmocli.AddQueryCmd(cmd, types.NewQueryClient, NewQueryPoolCmd) + osmocli.AddQueryCmd(cmd, types.NewQueryClient, NewQueryAllProtocolRevenueCmd) return cmd } @@ -157,6 +158,14 @@ func NewQueryPoolCmd() (*osmocli.QueryDescriptor, *types.QueryGetProtoRevPoolReq }, &types.QueryGetProtoRevPoolRequest{} } +// NewQueryAllProtocolRevenueCmd returns the command to query protocol revenue across all modules +func NewQueryAllProtocolRevenueCmd() (*osmocli.QueryDescriptor, *types.QueryGetAllProtocolRevenueRequest) { + return &osmocli.QueryDescriptor{ + Use: "all-proto-rev", + Short: "Query protocol revenue across all modules", + }, &types.QueryGetAllProtocolRevenueRequest{} +} + // convert a string array "[1,2,3]" to []uint64 // //nolint:unparam diff --git a/x/protorev/keeper/genesis.go b/x/protorev/keeper/genesis.go index 2f013e8c9e8..83653ba9b8e 100644 --- a/x/protorev/keeper/genesis.go +++ b/x/protorev/keeper/genesis.go @@ -86,6 +86,20 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { panic(err) } } + + // Since we now track all aspects of protocol revenue, we need to take a snapshot of cyclic arb profits from this module at a certain block height. + // This allows us to display how much protocol revenue has been generated since block "X" instead of just since the module was initialized. + if !genState.CyclicArbTracker.CyclicArb.IsZero() { + k.SetCyclicArbProfitTrackerValue(ctx, genState.CyclicArbTracker.CyclicArb) + } else { + k.SetCyclicArbProfitTrackerValue(ctx, genState.Profits) + } + + if genState.CyclicArbTracker.HeightAccountingStartsFrom != 0 { + k.SetCyclicArbProfitTrackerStartHeight(ctx, genState.CyclicArbTracker.HeightAccountingStartsFrom) + } else { + k.SetCyclicArbProfitTrackerStartHeight(ctx, ctx.BlockHeight()) + } } // ExportGenesis returns the module's exported genesis. ExportGenesis intentionally ignores a few of the errors thrown @@ -155,5 +169,12 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { // Export the profits that have been collected by Protorev. genesis.Profits = k.GetAllProfits(ctx) + // Export the profits that have been collected by Protorev since a certain block height. + cyclicArbTracker := types.CyclicArbTracker{ + CyclicArb: k.GetCyclicArbProfitTrackerValue(ctx), + HeightAccountingStartsFrom: k.GetCyclicArbProfitTrackerStartHeight(ctx), + } + genesis.CyclicArbTracker = &cyclicArbTracker + return genesis } diff --git a/x/protorev/keeper/genesis_test.go b/x/protorev/keeper/genesis_test.go index 3ddba2cfd88..5555d249aba 100644 --- a/x/protorev/keeper/genesis_test.go +++ b/x/protorev/keeper/genesis_test.go @@ -60,4 +60,10 @@ func (s *KeeperTestSuite) TestInitGenesis() { profits := s.App.ProtoRevKeeper.GetAllProfits(s.Ctx) s.Require().Equal(len(profits), len(exportedGenesis.Profits)) s.Require().Equal(profits, exportedGenesis.Profits) + + cyclicArbProfit := s.App.ProtoRevKeeper.GetCyclicArbProfitTrackerValue(s.Ctx) + s.Require().Equal(cyclicArbProfit, exportedGenesis.CyclicArbTracker.CyclicArb) + + cyclicArbProfitAccountingHeight := s.App.ProtoRevKeeper.GetCyclicArbProfitTrackerStartHeight(s.Ctx) + s.Require().Equal(cyclicArbProfitAccountingHeight, exportedGenesis.CyclicArbTracker.HeightAccountingStartsFrom) } diff --git a/x/protorev/keeper/grpc_query.go b/x/protorev/keeper/grpc_query.go index fa9d636588c..00edbebd38a 100644 --- a/x/protorev/keeper/grpc_query.go +++ b/x/protorev/keeper/grpc_query.go @@ -246,3 +246,11 @@ func (q Querier) GetProtoRevPool(c context.Context, req *types.QueryGetProtoRevP return &types.QueryGetProtoRevPoolResponse{PoolId: poolId}, nil } + +// GetAllProtocolRevenue queries all types of protocol revenue (txfees, taker fees, and cyclic arbitrage profits) +func (q Querier) GetAllProtocolRevenue(c context.Context, req *types.QueryGetAllProtocolRevenueRequest) (*types.QueryGetAllProtocolRevenueResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + allProtocolRevenue := q.Keeper.GetAllProtocolRevenue(ctx) + + return &types.QueryGetAllProtocolRevenueResponse{AllProtocolRevenue: allProtocolRevenue}, nil +} diff --git a/x/protorev/keeper/grpc_query_test.go b/x/protorev/keeper/grpc_query_test.go index 9107a379569..0d92d2556d5 100644 --- a/x/protorev/keeper/grpc_query_test.go +++ b/x/protorev/keeper/grpc_query_test.go @@ -380,3 +380,69 @@ func (s *KeeperTestSuite) TestGetProtoRevPool() { s.Require().NoError(err) s.Require().Equal(res.PoolId, uint64(1)) } + +// TestGetAllProtocolRevenue tests the query for all protocol revenue profits +func (s *KeeperTestSuite) TestGetAllProtocolRevenueGRPCQuery() { + poolManagerParams := s.App.PoolManagerKeeper.GetParams(s.Ctx) + poolManagerParams.TakerFeeParams.DefaultTakerFee = sdk.MustNewDecFromStr("0.02") + s.App.PoolManagerKeeper.SetParams(s.Ctx, poolManagerParams) + + req := &types.QueryGetAllProtocolRevenueRequest{} + res, err := s.queryClient.GetAllProtocolRevenue(sdk.WrapSDKContext(s.Ctx), req) + s.Require().NoError(err) + s.Require().Empty(res.AllProtocolRevenue) + + // Swap on a pool to charge taker fee + swapInCoin := sdk.NewCoin("Atom", osmomath.NewInt(1000)) + s.FundAcc(s.TestAccs[0], sdk.NewCoins(sdk.NewCoin("Atom", osmomath.NewInt(10000)))) + poolId := s.PrepareBalancerPoolWithCoins(sdk.NewCoins(sdk.NewCoin("Atom", osmomath.NewInt(10000)), sdk.NewCoin("Akash", osmomath.NewInt(10000)))...) + _, err = s.App.PoolManagerKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], poolId, swapInCoin, "Akash", sdk.ZeroInt()) + s.Require().NoError(err) + expectedTakerFeeFromInput := swapInCoin.Amount.ToLegacyDec().Mul(poolManagerParams.TakerFeeParams.DefaultTakerFee) + expectedTakerFeeToCommunityPoolAmt := expectedTakerFeeFromInput.Mul(poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.CommunityPool).TruncateInt() + expectedTakerFeeToStakersAmt := expectedTakerFeeFromInput.Sub(expectedTakerFeeToCommunityPoolAmt.ToLegacyDec()).TruncateInt() + expectedTakerFeeToStakers := sdk.NewCoins(sdk.NewCoin("Atom", expectedTakerFeeToStakersAmt)) + expectedTakerFeeToCommunityPool := sdk.NewCoins(sdk.NewCoin("Atom", expectedTakerFeeToCommunityPoolAmt)) + + // Charge txfee of 1000 uion + txFeeCharged := sdk.NewCoins(sdk.NewCoin("uion", osmomath.NewInt(1000))) + s.SetupTxFeeAnteHandlerAndChargeFee(s.clientCtx, sdk.NewDecCoins(sdk.NewInt64DecCoin("uion", 1000000)), 0, true, false, txFeeCharged) + + // Psuedo collect cyclic arb profits + cyclicArbProfits := sdk.NewCoins(sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(9000)), sdk.NewCoin("Atom", osmomath.NewInt(3000))) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, cyclicArbProfits[0].Denom, cyclicArbProfits[0].Amount) + s.Require().NoError(err) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, cyclicArbProfits[1].Denom, cyclicArbProfits[1].Amount) + s.Require().NoError(err) + + // Check protocol revenue + res, err = s.queryClient.GetAllProtocolRevenue(sdk.WrapSDKContext(s.Ctx), req) + s.Require().NoError(err) + s.Require().Equal(cyclicArbProfits, res.AllProtocolRevenue.CyclicArbTracker.CyclicArb) + s.Require().Equal(txFeeCharged, res.AllProtocolRevenue.TxFeesTracker.TxFees) + s.Require().Equal(expectedTakerFeeToStakers, res.AllProtocolRevenue.TakerFeesTracker.TakerFeesToStakers) + s.Require().Equal(expectedTakerFeeToCommunityPool, res.AllProtocolRevenue.TakerFeesTracker.TakerFeesToCommunityPool) + + // A second round of the same thing + // Swap on a pool to charge taker fee + s.FundAcc(s.TestAccs[0], sdk.NewCoins(sdk.NewCoin("Atom", osmomath.NewInt(10000)))) + _, err = s.App.PoolManagerKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], poolId, swapInCoin, "Akash", sdk.ZeroInt()) + s.Require().NoError(err) + + // Charge txfee of 1000 uion + s.SetupTxFeeAnteHandlerAndChargeFee(s.clientCtx, sdk.NewDecCoins(sdk.NewInt64DecCoin("uion", 1000000)), 0, true, false, txFeeCharged) + + // Psuedo collect cyclic arb profits + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, cyclicArbProfits[0].Denom, cyclicArbProfits[0].Amount) + s.Require().NoError(err) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, cyclicArbProfits[1].Denom, cyclicArbProfits[1].Amount) + s.Require().NoError(err) + + // Check protocol revenue + res, err = s.queryClient.GetAllProtocolRevenue(sdk.WrapSDKContext(s.Ctx), req) + s.Require().NoError(err) + s.Require().Equal(cyclicArbProfits.Add(cyclicArbProfits...), res.AllProtocolRevenue.CyclicArbTracker.CyclicArb) + s.Require().Equal(txFeeCharged.Add(txFeeCharged...), res.AllProtocolRevenue.TxFeesTracker.TxFees) + s.Require().Equal(expectedTakerFeeToStakers.Add(expectedTakerFeeToStakers...), res.AllProtocolRevenue.TakerFeesTracker.TakerFeesToStakers) + s.Require().Equal(expectedTakerFeeToCommunityPool.Add(expectedTakerFeeToCommunityPool...), res.AllProtocolRevenue.TakerFeesTracker.TakerFeesToCommunityPool) +} diff --git a/x/protorev/keeper/keeper.go b/x/protorev/keeper/keeper.go index 63a24ecd8e2..40a9219f923 100644 --- a/x/protorev/keeper/keeper.go +++ b/x/protorev/keeper/keeper.go @@ -25,6 +25,7 @@ type ( epochKeeper types.EpochKeeper poolmanagerKeeper types.PoolManagerKeeper concentratedLiquidityKeeper types.ConcentratedLiquidityKeeper + txfeesKeeper types.TxFeesKeeper } ) @@ -38,6 +39,7 @@ func NewKeeper( epochKeeper types.EpochKeeper, poolmanagerKeeper types.PoolManagerKeeper, concentratedLiquidityKeeper types.ConcentratedLiquidityKeeper, + txfeesKeeper types.TxFeesKeeper, ) Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { @@ -54,9 +56,14 @@ func NewKeeper( epochKeeper: epochKeeper, poolmanagerKeeper: poolmanagerKeeper, concentratedLiquidityKeeper: concentratedLiquidityKeeper, + txfeesKeeper: txfeesKeeper, } } func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } + +func (k *Keeper) SetTxFeesKeeper(txFeesKeeper types.TxFeesKeeper) { + k.txfeesKeeper = txFeesKeeper +} diff --git a/x/protorev/keeper/protorev.go b/x/protorev/keeper/protorev.go index 36d9af18551..06533a5d160 100644 --- a/x/protorev/keeper/protorev.go +++ b/x/protorev/keeper/protorev.go @@ -4,7 +4,9 @@ import ( "errors" "fmt" + poolmanagertypes "github.com/osmosis-labs/osmosis/v20/x/poolmanager/types" "github.com/osmosis-labs/osmosis/v20/x/protorev/types" + txfeestypes "github.com/osmosis-labs/osmosis/v20/x/txfees/types" "github.com/cosmos/cosmos-sdk/store/prefix" @@ -483,3 +485,32 @@ func (k Keeper) SetInfoByPoolType(ctx sdk.Context, poolWeights types.InfoByPoolT store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixInfoByPoolType) osmoutils.MustSet(store, types.KeyPrefixInfoByPoolType, &poolWeights) } + +// GetAllProtocolRevenue returns all types of protocol revenue (txfees, taker fees, and cyclic arb profits), as well as the block height from which we started accounting +// for each of these revenue sources. +func (k Keeper) GetAllProtocolRevenue(ctx sdk.Context) types.AllProtocolRevenue { + currentCyclicArb := k.GetAllProfits(ctx) + currentCyclicArbCoins := osmoutils.ConvertCoinArrayToCoins(currentCyclicArb) + + cyclicArbTracker := types.CyclicArbTracker{ + CyclicArb: currentCyclicArbCoins.Sub(k.GetCyclicArbProfitTrackerValue(ctx)...), + HeightAccountingStartsFrom: k.GetCyclicArbProfitTrackerStartHeight(ctx), + } + + takerFeesTracker := poolmanagertypes.TakerFeesTracker{ + TakerFeesToStakers: k.poolmanagerKeeper.GetTakerFeeTrackerForStakers(ctx), + TakerFeesToCommunityPool: k.poolmanagerKeeper.GetTakerFeeTrackerForCommunityPool(ctx), + HeightAccountingStartsFrom: k.poolmanagerKeeper.GetTakerFeeTrackerStartHeight(ctx), + } + + txFeesTracker := txfeestypes.TxFeesTracker{ + TxFees: k.txfeesKeeper.GetTxFeesTrackerValue(ctx), + HeightAccountingStartsFrom: k.txfeesKeeper.GetTxFeesTrackerStartHeight(ctx), + } + + return types.AllProtocolRevenue{ + TakerFeesTracker: takerFeesTracker, + TxFeesTracker: txFeesTracker, + CyclicArbTracker: cyclicArbTracker, + } +} diff --git a/x/protorev/keeper/protorev_test.go b/x/protorev/keeper/protorev_test.go index f3817ee3517..aba8a03587d 100644 --- a/x/protorev/keeper/protorev_test.go +++ b/x/protorev/keeper/protorev_test.go @@ -4,7 +4,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/osmosis-labs/osmosis/osmomath" + poolmanagertypes "github.com/osmosis-labs/osmosis/v20/x/poolmanager/types" "github.com/osmosis-labs/osmosis/v20/x/protorev/types" + txfeestypes "github.com/osmosis-labs/osmosis/v20/x/txfees/types" ) // TestGetTokenPairArbRoutes tests the GetTokenPairArbRoutes function. @@ -323,3 +325,78 @@ func (s *KeeperTestSuite) TestGetInfoByPoolType() { poolWeights := s.App.ProtoRevKeeper.GetInfoByPoolType(s.Ctx) s.Require().Equal(newRouteWeights, poolWeights) } + +func (s *KeeperTestSuite) TestGetAllProtocolRevenue() { + poolManagerParams := s.App.PoolManagerKeeper.GetParams(s.Ctx) + poolManagerParams.TakerFeeParams.DefaultTakerFee = sdk.MustNewDecFromStr("0.02") + s.App.PoolManagerKeeper.SetParams(s.Ctx, poolManagerParams) + + allProtoRev := s.App.ProtoRevKeeper.GetAllProtocolRevenue(s.Ctx) + s.Require().Equal(types.AllProtocolRevenue{ + TakerFeesTracker: poolmanagertypes.TakerFeesTracker{ + TakerFeesToStakers: sdk.Coins(nil), + TakerFeesToCommunityPool: sdk.Coins(nil), + HeightAccountingStartsFrom: 0, + }, + TxFeesTracker: txfeestypes.TxFeesTracker{ + TxFees: sdk.Coins(nil), + HeightAccountingStartsFrom: 0, + }, + CyclicArbTracker: types.CyclicArbTracker{ + CyclicArb: sdk.NewCoins(), + HeightAccountingStartsFrom: 0, + }, + }, allProtoRev) + + // Swap on a pool to charge taker fee + swapInCoin := sdk.NewCoin("Atom", osmomath.NewInt(1000)) + s.FundAcc(s.TestAccs[0], sdk.NewCoins(sdk.NewCoin("Atom", osmomath.NewInt(10000)))) + poolId := s.PrepareBalancerPoolWithCoins(sdk.NewCoins(sdk.NewCoin("Atom", osmomath.NewInt(10000)), sdk.NewCoin("Akash", osmomath.NewInt(10000)))...) + _, err := s.App.PoolManagerKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], poolId, swapInCoin, "Akash", sdk.ZeroInt()) + s.Require().NoError(err) + expectedTakerFeeFromInput := swapInCoin.Amount.ToLegacyDec().Mul(poolManagerParams.TakerFeeParams.DefaultTakerFee) + expectedTakerFeeToCommunityPoolAmt := expectedTakerFeeFromInput.Mul(poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.CommunityPool).TruncateInt() + expectedTakerFeeToStakersAmt := expectedTakerFeeFromInput.Sub(expectedTakerFeeToCommunityPoolAmt.ToLegacyDec()).TruncateInt() + expectedTakerFeeToStakers := sdk.NewCoins(sdk.NewCoin("Atom", expectedTakerFeeToStakersAmt)) + expectedTakerFeeToCommunityPool := sdk.NewCoins(sdk.NewCoin("Atom", expectedTakerFeeToCommunityPoolAmt)) + + // Charge txfee of 1000 uion + txFeeCharged := sdk.NewCoins(sdk.NewCoin("uion", osmomath.NewInt(1000))) + s.SetupTxFeeAnteHandlerAndChargeFee(s.clientCtx, sdk.NewDecCoins(sdk.NewInt64DecCoin("uion", 1000000)), 0, true, false, txFeeCharged) + + // Psuedo collect cyclic arb profits + cyclicArbProfits := sdk.NewCoins(sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(9000)), sdk.NewCoin("Atom", osmomath.NewInt(3000))) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, cyclicArbProfits[0].Denom, cyclicArbProfits[0].Amount) + s.Require().NoError(err) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, cyclicArbProfits[1].Denom, cyclicArbProfits[1].Amount) + s.Require().NoError(err) + + // Check protocol revenue + allProtoRev = s.App.ProtoRevKeeper.GetAllProtocolRevenue(s.Ctx) + s.Require().Equal(cyclicArbProfits, allProtoRev.CyclicArbTracker.CyclicArb) + s.Require().Equal(txFeeCharged, allProtoRev.TxFeesTracker.TxFees) + s.Require().Equal(expectedTakerFeeToStakers, allProtoRev.TakerFeesTracker.TakerFeesToStakers) + s.Require().Equal(expectedTakerFeeToCommunityPool, allProtoRev.TakerFeesTracker.TakerFeesToCommunityPool) + + // A second round of the same thing + // Swap on a pool to charge taker fee + s.FundAcc(s.TestAccs[0], sdk.NewCoins(sdk.NewCoin("Atom", osmomath.NewInt(10000)))) + _, err = s.App.PoolManagerKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], poolId, swapInCoin, "Akash", sdk.ZeroInt()) + s.Require().NoError(err) + + // Charge txfee of 1000 uion + s.SetupTxFeeAnteHandlerAndChargeFee(s.clientCtx, sdk.NewDecCoins(sdk.NewInt64DecCoin("uion", 1000000)), 0, true, false, txFeeCharged) + + // Psuedo collect cyclic arb profits + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, cyclicArbProfits[0].Denom, cyclicArbProfits[0].Amount) + s.Require().NoError(err) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, cyclicArbProfits[1].Denom, cyclicArbProfits[1].Amount) + s.Require().NoError(err) + + // Check protocol revenue + allProtoRev = s.App.ProtoRevKeeper.GetAllProtocolRevenue(s.Ctx) + s.Require().Equal(cyclicArbProfits.Add(cyclicArbProfits...), allProtoRev.CyclicArbTracker.CyclicArb) + s.Require().Equal(txFeeCharged.Add(txFeeCharged...), allProtoRev.TxFeesTracker.TxFees) + s.Require().Equal(expectedTakerFeeToStakers.Add(expectedTakerFeeToStakers...), allProtoRev.TakerFeesTracker.TakerFeesToStakers) + s.Require().Equal(expectedTakerFeeToCommunityPool.Add(expectedTakerFeeToCommunityPool...), allProtoRev.TakerFeesTracker.TakerFeesToCommunityPool) +} diff --git a/x/protorev/keeper/statistics.go b/x/protorev/keeper/statistics.go index 82fc5304bc4..7ec09df1cde 100644 --- a/x/protorev/keeper/statistics.go +++ b/x/protorev/keeper/statistics.go @@ -7,7 +7,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + gogotypes "github.com/cosmos/gogoproto/types" + "github.com/osmosis-labs/osmosis/osmomath" + "github.com/osmosis-labs/osmosis/osmoutils" poolmanagertypes "github.com/osmosis-labs/osmosis/v20/x/poolmanager/types" "github.com/osmosis-labs/osmosis/v20/x/protorev/types" ) @@ -83,6 +86,46 @@ func (k Keeper) GetAllProfits(ctx sdk.Context) []sdk.Coin { return profits } +func (k Keeper) SetCyclicArbProfitTrackerValue(ctx sdk.Context, cyclicArbProfits sdk.Coins) { + newCyclicArbProfits := poolmanagertypes.TrackedVolume{ + Amount: cyclicArbProfits, + } + osmoutils.MustSet(ctx.KVStore(k.storeKey), types.KeyCyclicArbTracker, &newCyclicArbProfits) +} + +func (k Keeper) GetCyclicArbProfitTrackerValue(ctx sdk.Context) (currentCyclicArbProfits sdk.Coins) { + var cyclicArbProfits poolmanagertypes.TrackedVolume + cyclicArbProfitsFound, err := osmoutils.Get(ctx.KVStore(k.storeKey), types.KeyCyclicArbTracker, &cyclicArbProfits) + if err != nil { + // We can only encounter an error if a database or serialization errors occurs, so we panic here. + // Normally this would be handled by `osmoutils.MustGet`, but since we want to specifically use `osmoutils.Get`, + // we also have to manually panic here. + panic(err) + } + + // If no volume was found, we treat the existing volume as 0. + // While we can technically require volume to exist, we would need to store empty coins in state for each pool (past and present), + // which is a high storage cost to pay for a weak guardrail. + currentCyclicArbProfits = sdk.NewCoins() + if cyclicArbProfitsFound { + currentCyclicArbProfits = cyclicArbProfits.Amount + } + + return currentCyclicArbProfits +} + +// GetCyclicArbProfitTrackerStartHeight gets the height from which we started accounting for cyclic arb profits. +func (k Keeper) GetCyclicArbProfitTrackerStartHeight(ctx sdk.Context) int64 { + startHeight := gogotypes.Int64Value{} + osmoutils.MustGet(ctx.KVStore(k.storeKey), types.KeyCyclicArbTrackerStartHeight, &startHeight) + return startHeight.Value +} + +// SetCyclicArbProfitTrackerStartHeight sets the height from which we started accounting for cyclic arb profits. +func (k Keeper) SetCyclicArbProfitTrackerStartHeight(ctx sdk.Context, startHeight int64) { + osmoutils.MustSet(ctx.KVStore(k.storeKey), types.KeyCyclicArbTrackerStartHeight, &gogotypes.Int64Value{Value: startHeight}) +} + // UpdateProfitsByDenom updates the profits made by the ProtoRev module for the given denom func (k Keeper) UpdateProfitsByDenom(ctx sdk.Context, denom string, tradeProfit osmomath.Int) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixProfitByDenom) diff --git a/x/protorev/keeper/statistics_test.go b/x/protorev/keeper/statistics_test.go index a56bbdd98e1..fd6fd4be757 100644 --- a/x/protorev/keeper/statistics_test.go +++ b/x/protorev/keeper/statistics_test.go @@ -193,3 +193,83 @@ func (s *KeeperTestSuite) TestUpdateStatistics() { s.Require().NoError(err) s.Require().Equal(2, len(routes)) } + +func (s *KeeperTestSuite) TestGetSetCyclicArbProfitTrackerValue() { + tests := map[string]struct { + firstCyclicArbValue sdk.Coins + secondCyclicArbValue sdk.Coins + }{ + "happy path: replace single coin with increased single coin": { + firstCyclicArbValue: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100))), + secondCyclicArbValue: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(200))), + }, + "replace single coin with decreased single coin": { + firstCyclicArbValue: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100))), + secondCyclicArbValue: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(50))), + }, + "replace single coin with different denom": { + firstCyclicArbValue: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100))), + secondCyclicArbValue: sdk.NewCoins(sdk.NewCoin("usdc", sdk.NewInt(100))), + }, + "replace single coin with multiple coins": { + firstCyclicArbValue: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100))), + secondCyclicArbValue: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100)), sdk.NewCoin("usdc", sdk.NewInt(200))), + }, + "replace multiple coins with single coin": { + firstCyclicArbValue: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100)), sdk.NewCoin("usdc", sdk.NewInt(200))), + secondCyclicArbValue: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(200))), + }, + } + + for name, tc := range tests { + s.Run(name, func() { + s.SetupTest() + + s.Require().Empty(s.App.ProtoRevKeeper.GetCyclicArbProfitTrackerValue(s.Ctx)) + + s.App.ProtoRevKeeper.SetCyclicArbProfitTrackerValue(s.Ctx, tc.firstCyclicArbValue) + actualFirstCyclicArbValue := s.App.ProtoRevKeeper.GetCyclicArbProfitTrackerValue(s.Ctx) + s.Require().Equal(tc.firstCyclicArbValue, actualFirstCyclicArbValue) + + s.App.ProtoRevKeeper.SetCyclicArbProfitTrackerValue(s.Ctx, tc.secondCyclicArbValue) + actualSecondCyclicArbValue := s.App.ProtoRevKeeper.GetCyclicArbProfitTrackerValue(s.Ctx) + s.Require().Equal(tc.secondCyclicArbValue, actualSecondCyclicArbValue) + }) + } +} + +func (s *KeeperTestSuite) TestGetSetCyclicArbProfitTrackerStartHeight() { + tests := map[string]struct { + firstCyclicArbStartHeight int64 + secondCyclicArbStartHeight int64 + }{ + "replace tracker height with a higher height": { + firstCyclicArbStartHeight: 100, + secondCyclicArbStartHeight: 5000, + }, + "replace tracker height with a lower height": { + firstCyclicArbStartHeight: 100, + secondCyclicArbStartHeight: 50, + }, + "replace tracker height back to zero": { + firstCyclicArbStartHeight: 100, + secondCyclicArbStartHeight: 0, + }, + } + + for name, tc := range tests { + s.Run(name, func() { + s.SetupTest() + + s.Require().Empty(s.App.ProtoRevKeeper.GetCyclicArbProfitTrackerStartHeight(s.Ctx)) + + s.App.ProtoRevKeeper.SetCyclicArbProfitTrackerStartHeight(s.Ctx, tc.firstCyclicArbStartHeight) + actualFirstCyclicArbStartHeight := s.App.ProtoRevKeeper.GetCyclicArbProfitTrackerStartHeight(s.Ctx) + s.Require().Equal(tc.firstCyclicArbStartHeight, actualFirstCyclicArbStartHeight) + + s.App.ProtoRevKeeper.SetCyclicArbProfitTrackerStartHeight(s.Ctx, tc.secondCyclicArbStartHeight) + actualSecondCyclicArbStartHeight := s.App.ProtoRevKeeper.GetCyclicArbProfitTrackerStartHeight(s.Ctx) + s.Require().Equal(tc.secondCyclicArbStartHeight, actualSecondCyclicArbStartHeight) + }) + } +} diff --git a/x/protorev/types/expected_keepers.go b/x/protorev/types/expected_keepers.go index 0dd170e2b9e..fd4a4086047 100644 --- a/x/protorev/types/expected_keepers.go +++ b/x/protorev/types/expected_keepers.go @@ -60,6 +60,9 @@ type PoolManagerKeeper interface { GetPoolModule(ctx sdk.Context, poolId uint64) (poolmanagertypes.PoolModuleI, error) GetTotalPoolLiquidity(ctx sdk.Context, poolId uint64) (sdk.Coins, error) RouteGetPoolDenoms(ctx sdk.Context, poolId uint64) ([]string, error) + GetTakerFeeTrackerForStakers(ctx sdk.Context) sdk.Coins + GetTakerFeeTrackerForCommunityPool(ctx sdk.Context) sdk.Coins + GetTakerFeeTrackerStartHeight(ctx sdk.Context) int64 } // EpochKeeper defines the Epoch contract that must be fulfilled when @@ -78,3 +81,8 @@ type ConcentratedLiquidityKeeper interface { maxTicksCrossed uint64, ) (maxTokenIn, resultingTokenOut sdk.Coin, err error) } + +type TxFeesKeeper interface { + GetTxFeesTrackerValue(ctx sdk.Context) (currentTxFees sdk.Coins) + GetTxFeesTrackerStartHeight(ctx sdk.Context) int64 +} diff --git a/x/protorev/types/genesis.go b/x/protorev/types/genesis.go index f1a81b654cb..9655408d492 100644 --- a/x/protorev/types/genesis.go +++ b/x/protorev/types/genesis.go @@ -39,6 +39,10 @@ var ( DefaultMaxPoolPointsPerTx = uint64(18) DefaultPoolPointsConsumedInBlock = uint64(0) DefaultProfits = []sdk.Coin{} + DefaultCyclicArbTracker = CyclicArbTracker{ + CyclicArb: sdk.Coins(nil), + HeightAccountingStartsFrom: 0, + } ) // DefaultGenesis returns the default genesis state @@ -56,6 +60,7 @@ func DefaultGenesis() *GenesisState { MaxPoolPointsPerTx: DefaultMaxPoolPointsPerTx, PointCountForBlock: DefaultPoolPointsConsumedInBlock, Profits: DefaultProfits, + CyclicArbTracker: &DefaultCyclicArbTracker, } } diff --git a/x/protorev/types/genesis.pb.go b/x/protorev/types/genesis.pb.go index 1dd55f12241..0631b4ac9ab 100644 --- a/x/protorev/types/genesis.pb.go +++ b/x/protorev/types/genesis.pb.go @@ -60,7 +60,8 @@ type GenesisState struct { Profits []types.Coin `protobuf:"bytes,12,rep,name=profits,proto3" json:"profits" yaml:"profits"` // Information that is used to estimate execution time / gas // consumption of a swap on a given pool type. - InfoByPoolType InfoByPoolType `protobuf:"bytes,13,opt,name=info_by_pool_type,json=infoByPoolType,proto3" json:"info_by_pool_type" yaml:"info_by_pool_type"` + InfoByPoolType InfoByPoolType `protobuf:"bytes,13,opt,name=info_by_pool_type,json=infoByPoolType,proto3" json:"info_by_pool_type" yaml:"info_by_pool_type"` + CyclicArbTracker *CyclicArbTracker `protobuf:"bytes,14,opt,name=cyclic_arb_tracker,json=cyclicArbTracker,proto3" json:"cyclic_arb_tracker,omitempty" yaml:"cyclic_arb_tracker"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -187,6 +188,13 @@ func (m *GenesisState) GetInfoByPoolType() InfoByPoolType { return InfoByPoolType{} } +func (m *GenesisState) GetCyclicArbTracker() *CyclicArbTracker { + if m != nil { + return m.CyclicArbTracker + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "osmosis.protorev.v1beta1.GenesisState") } @@ -196,53 +204,56 @@ func init() { } var fileDescriptor_3c77fc2da5752af2 = []byte{ - // 727 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x94, 0xcd, 0x6e, 0xd3, 0x4a, - 0x14, 0xc7, 0xe3, 0xdb, 0xde, 0xf6, 0x76, 0xd2, 0x46, 0xb7, 0xd3, 0x9b, 0xca, 0xc9, 0xa5, 0x8e, - 0x31, 0x2d, 0x64, 0x41, 0x6d, 0x5a, 0x58, 0xb1, 0x40, 0xaa, 0x8b, 0x0a, 0x08, 0x51, 0x45, 0x6e, - 0x11, 0x12, 0x48, 0x0c, 0xe3, 0x64, 0x92, 0x5a, 0xb5, 0x3d, 0x96, 0x67, 0x12, 0x92, 0x07, 0x60, - 0xcf, 0xc3, 0xf0, 0x10, 0x5d, 0x56, 0xac, 0x58, 0x45, 0xa8, 0x7d, 0x83, 0x3c, 0x01, 0xf2, 0xcc, - 0x24, 0xe9, 0x47, 0x0c, 0x3b, 0xcf, 0x39, 0xbf, 0xf3, 0xff, 0x9f, 0x33, 0x1f, 0x06, 0xf7, 0x29, - 0x8b, 0x28, 0x0b, 0x98, 0x93, 0xa4, 0x94, 0xd3, 0x94, 0xf4, 0x9c, 0xde, 0x8e, 0x4f, 0x38, 0xde, - 0x71, 0x3a, 0x24, 0x26, 0x2c, 0x60, 0xb6, 0x48, 0x40, 0x5d, 0x71, 0xf6, 0x98, 0xb3, 0x15, 0x57, - 0xfd, 0xaf, 0x43, 0x3b, 0x54, 0x44, 0x9d, 0xec, 0x4b, 0x02, 0xd5, 0x07, 0xb9, 0xba, 0x13, 0x01, - 0x09, 0x6e, 0xe5, 0x83, 0x38, 0xc5, 0x91, 0x32, 0xac, 0x56, 0x9a, 0x82, 0x43, 0xd2, 0x48, 0x2e, - 0x54, 0xca, 0x90, 0x2b, 0xc7, 0xc7, 0x8c, 0x4c, 0x8a, 0x9b, 0x34, 0x88, 0x65, 0xde, 0x1a, 0x2e, - 0x81, 0xe5, 0x17, 0x72, 0x98, 0x23, 0x8e, 0x39, 0x81, 0xcf, 0xc0, 0x82, 0xd4, 0xd6, 0x35, 0x53, - 0xab, 0x17, 0x77, 0x4d, 0x3b, 0x6f, 0x38, 0xbb, 0x21, 0x38, 0x77, 0xfe, 0x6c, 0x58, 0x2b, 0x78, - 0xaa, 0x0a, 0x7e, 0xd1, 0x40, 0x99, 0xd3, 0x53, 0x12, 0xa3, 0x04, 0x07, 0x29, 0xc2, 0xa9, 0x8f, - 0x52, 0xda, 0xe5, 0x84, 0xe9, 0x7f, 0x99, 0x73, 0xf5, 0xe2, 0xee, 0xc3, 0x7c, 0xbd, 0xe3, 0xac, - 0xac, 0x81, 0x83, 0x74, 0x2f, 0xf5, 0x3d, 0x51, 0xe3, 0x6e, 0x66, 0xda, 0xa3, 0x61, 0xed, 0xce, - 0x00, 0x47, 0xe1, 0x53, 0x6b, 0xa6, 0xb0, 0xe5, 0x41, 0x7e, 0xab, 0x12, 0x7e, 0x02, 0xc5, 0x6c, - 0x66, 0xd4, 0x22, 0x31, 0x8d, 0x98, 0x3e, 0x27, 0xcc, 0xef, 0xe5, 0x9b, 0xbb, 0x98, 0x91, 0xe7, - 0x19, 0xeb, 0x56, 0x95, 0x27, 0x94, 0x9e, 0x57, 0x54, 0x2c, 0x0f, 0xf8, 0x63, 0x8c, 0x41, 0x02, - 0x96, 0x13, 0x4a, 0x43, 0xf4, 0x99, 0x04, 0x9d, 0x13, 0xce, 0xf4, 0x79, 0xb1, 0x5f, 0x5b, 0xbf, - 0xd9, 0x2f, 0x4a, 0xc3, 0x77, 0x12, 0x76, 0xff, 0x57, 0x26, 0x6b, 0xd2, 0xe4, 0xaa, 0x90, 0xe5, - 0x15, 0x93, 0x29, 0x09, 0x11, 0xa8, 0xb4, 0xf0, 0x80, 0x21, 0x16, 0xc4, 0x4d, 0x82, 0x22, 0xda, - 0xea, 0x86, 0x04, 0xa9, 0xfb, 0xa7, 0xff, 0x6d, 0x6a, 0xf5, 0x79, 0x77, 0x73, 0x34, 0xac, 0x99, - 0x52, 0x28, 0x17, 0xb5, 0xbc, 0xf5, 0x2c, 0x77, 0x94, 0xa5, 0xde, 0x88, 0x8c, 0x3a, 0x76, 0x88, - 0x40, 0xa9, 0x45, 0x7a, 0x24, 0xa4, 0x09, 0x49, 0x51, 0x9b, 0x10, 0xa6, 0x2f, 0x88, 0xcd, 0xaa, - 0xd8, 0xea, 0x26, 0x65, 0x33, 0x4f, 0x86, 0xd8, 0xa7, 0x41, 0xec, 0x6e, 0xa8, 0xee, 0xcb, 0xca, - 0xf4, 0x5a, 0xb9, 0xe5, 0xad, 0x4c, 0x02, 0x07, 0x84, 0x30, 0x78, 0x08, 0xd6, 0x42, 0xcc, 0x09, - 0xe3, 0xc8, 0x0f, 0x69, 0xf3, 0x14, 0x9d, 0x88, 0xc9, 0xf4, 0x45, 0xd1, 0xbb, 0x31, 0x1a, 0xd6, - 0xaa, 0x52, 0x66, 0x06, 0x64, 0x79, 0xab, 0x32, 0xea, 0x66, 0xc1, 0x97, 0x22, 0x06, 0x3f, 0x80, - 0xd5, 0xa9, 0x23, 0x6e, 0xb5, 0x52, 0xc2, 0x98, 0xfe, 0x8f, 0xa9, 0xd5, 0x97, 0x5c, 0x7b, 0x34, - 0xac, 0xe9, 0x37, 0x9b, 0x52, 0x88, 0xf5, 0xfd, 0xdb, 0x76, 0x49, 0x8d, 0xb4, 0x27, 0x43, 0xde, - 0xbf, 0x13, 0x4a, 0x45, 0xe0, 0x47, 0x50, 0x89, 0x70, 0x1f, 0x89, 0x03, 0x49, 0x68, 0x10, 0x73, - 0x86, 0x32, 0x0d, 0xd1, 0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0xc2, 0xe9, 0xed, 0x3e, 0x72, 0xfa, - 0xd3, 0x5f, 0x6f, 0xa6, 0xcf, 0xfc, 0x05, 0xb1, 0x7e, 0xfc, 0x2b, 0x00, 0x00, 0xff, 0xff, 0xe1, - 0xfb, 0x5d, 0x7a, 0x1c, 0x06, 0x00, 0x00, + // 771 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0xcf, 0x4e, 0xe3, 0x46, + 0x18, 0x8f, 0x0b, 0x85, 0x32, 0x81, 0x08, 0x86, 0x06, 0x39, 0x69, 0x71, 0x5c, 0x17, 0xda, 0xa8, + 0x2a, 0x76, 0xa1, 0x3d, 0xf5, 0x50, 0x09, 0x53, 0xd1, 0x56, 0x55, 0x51, 0x64, 0x52, 0x55, 0x6a, + 0xa5, 0x4e, 0xc7, 0xce, 0x24, 0x58, 0xd8, 0x1e, 0xcb, 0x33, 0x09, 0xc9, 0x03, 0xf4, 0xbe, 0x0f, + 0xb3, 0x0f, 0xc1, 0x11, 0xed, 0x65, 0xf7, 0x14, 0xad, 0xe0, 0x0d, 0xf2, 0x04, 0x2b, 0xcf, 0x4c, + 0x12, 0x08, 0xf1, 0xee, 0xcd, 0xf3, 0x7d, 0xbf, 0x3f, 0xdf, 0x6f, 0xfe, 0x18, 0x7c, 0x45, 0x59, + 0x4c, 0x59, 0xc8, 0x9c, 0x34, 0xa3, 0x9c, 0x66, 0x64, 0xe0, 0x0c, 0x8e, 0x7d, 0xc2, 0xf1, 0xb1, + 0xd3, 0x23, 0x09, 0x61, 0x21, 0xb3, 0x45, 0x03, 0xea, 0x0a, 0x67, 0x4f, 0x71, 0xb6, 0xc2, 0xd5, + 0x3f, 0xed, 0xd1, 0x1e, 0x15, 0x55, 0x27, 0xff, 0x92, 0x80, 0xfa, 0xd7, 0x85, 0xba, 0x33, 0x01, + 0x09, 0x3c, 0x2c, 0x06, 0xe2, 0x0c, 0x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d, 0x07, 0x8b, 0x84, 0x8b, 0xdb, 0x7b, + 0x43, 0xbb, 0xbb, 0x37, 0xb4, 0xb7, 0xf7, 0x86, 0xf6, 0xe2, 0xc1, 0x28, 0xdd, 0x3d, 0x18, 0xa5, + 0x37, 0x0f, 0x46, 0xe9, 0xef, 0x1f, 0x7a, 0x21, 0xbf, 0xea, 0xfb, 0x76, 0x40, 0x63, 0x47, 0x0d, + 0x70, 0x14, 0x61, 0x9f, 0x4d, 0x17, 0xce, 0xe0, 0xe4, 0x3b, 0x67, 0x38, 0xff, 0xe7, 0xe7, 0xc1, + 0x98, 0xbf, 0x26, 0xd6, 0xdf, 0xbf, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xe5, 0x47, 0xce, 0x94, 0x95, + 0x06, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -265,6 +276,18 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.CyclicArbTracker != nil { + { + size, err := m.CyclicArbTracker.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x72 + } { size, err := m.InfoByPoolType.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -452,6 +475,10 @@ func (m *GenesisState) Size() (n int) { } l = m.InfoByPoolType.Size() n += 1 + l + sovGenesis(uint64(l)) + if m.CyclicArbTracker != nil { + l = m.CyclicArbTracker.Size() + n += 1 + l + sovGenesis(uint64(l)) + } return n } @@ -852,6 +879,42 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 14: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CyclicArbTracker", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CyclicArbTracker == nil { + m.CyclicArbTracker = &CyclicArbTracker{} + } + if err := m.CyclicArbTracker.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/protorev/types/keys.go b/x/protorev/types/keys.go index cb5c906f289..a1d78808335 100644 --- a/x/protorev/types/keys.go +++ b/x/protorev/types/keys.go @@ -36,6 +36,8 @@ const ( prefixLatestBlockHeight prefixInfoByPoolType prefixSwapsToBackrun + prefixcyclicArbTracker + prefixcyclicArbTrackerStartHeight ) var ( @@ -89,6 +91,12 @@ var ( // KeyPrefixSwapsToBackrun is the prefix for store that keeps track of the swaps that need to be backrun for a given tx KeyPrefixSwapsToBackrun = []byte{prefixSwapsToBackrun} + + // KeyCyclicArbTracker is the prefix for store that keeps track of the profits made by cyclic arbitrage + KeyCyclicArbTracker = []byte{prefixcyclicArbTracker} + + // KeyCyclicArbTracker is the prefix for store that keeps track of the height we began tracking cyclic arbitrage + KeyCyclicArbTrackerStartHeight = []byte{prefixcyclicArbTrackerStartHeight} ) // Returns the key needed to fetch the pool id for a given denom diff --git a/x/protorev/types/protorev.pb.go b/x/protorev/types/protorev.pb.go index d8558497069..fb24ba44537 100644 --- a/x/protorev/types/protorev.pb.go +++ b/x/protorev/types/protorev.pb.go @@ -7,9 +7,12 @@ import ( cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-proto" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" + types1 "github.com/osmosis-labs/osmosis/v20/x/poolmanager/types" + types2 "github.com/osmosis-labs/osmosis/v20/x/txfees/types" io "io" math "math" math_bits "math/bits" @@ -720,6 +723,118 @@ func (m *BaseDenom) GetDenom() string { return "" } +type AllProtocolRevenue struct { + TakerFeesTracker types1.TakerFeesTracker `protobuf:"bytes,1,opt,name=taker_fees_tracker,json=takerFeesTracker,proto3" json:"taker_fees_tracker" yaml:"taker_fees_tracker"` + TxFeesTracker types2.TxFeesTracker `protobuf:"bytes,2,opt,name=tx_fees_tracker,json=txFeesTracker,proto3" json:"tx_fees_tracker" yaml:"tx_fees_tracker"` + CyclicArbTracker CyclicArbTracker `protobuf:"bytes,3,opt,name=cyclic_arb_tracker,json=cyclicArbTracker,proto3" json:"cyclic_arb_tracker" yaml:"cyclic_arb_tracker"` +} + +func (m *AllProtocolRevenue) Reset() { *m = AllProtocolRevenue{} } +func (m *AllProtocolRevenue) String() string { return proto.CompactTextString(m) } +func (*AllProtocolRevenue) ProtoMessage() {} +func (*AllProtocolRevenue) Descriptor() ([]byte, []int) { + return fileDescriptor_1e9f2391fd9fec01, []int{12} +} +func (m *AllProtocolRevenue) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AllProtocolRevenue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AllProtocolRevenue.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 *AllProtocolRevenue) XXX_Merge(src proto.Message) { + xxx_messageInfo_AllProtocolRevenue.Merge(m, src) +} +func (m *AllProtocolRevenue) XXX_Size() int { + return m.Size() +} +func (m *AllProtocolRevenue) XXX_DiscardUnknown() { + xxx_messageInfo_AllProtocolRevenue.DiscardUnknown(m) +} + +var xxx_messageInfo_AllProtocolRevenue proto.InternalMessageInfo + +func (m *AllProtocolRevenue) GetTakerFeesTracker() types1.TakerFeesTracker { + if m != nil { + return m.TakerFeesTracker + } + return types1.TakerFeesTracker{} +} + +func (m *AllProtocolRevenue) GetTxFeesTracker() types2.TxFeesTracker { + if m != nil { + return m.TxFeesTracker + } + return types2.TxFeesTracker{} +} + +func (m *AllProtocolRevenue) GetCyclicArbTracker() CyclicArbTracker { + if m != nil { + return m.CyclicArbTracker + } + return CyclicArbTracker{} +} + +type CyclicArbTracker struct { + CyclicArb github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=cyclic_arb,json=cyclicArb,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"cyclic_arb"` + HeightAccountingStartsFrom int64 `protobuf:"varint,2,opt,name=height_accounting_starts_from,json=heightAccountingStartsFrom,proto3" json:"height_accounting_starts_from,omitempty" yaml:"height_accounting_starts_from"` +} + +func (m *CyclicArbTracker) Reset() { *m = CyclicArbTracker{} } +func (m *CyclicArbTracker) String() string { return proto.CompactTextString(m) } +func (*CyclicArbTracker) ProtoMessage() {} +func (*CyclicArbTracker) Descriptor() ([]byte, []int) { + return fileDescriptor_1e9f2391fd9fec01, []int{13} +} +func (m *CyclicArbTracker) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CyclicArbTracker) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CyclicArbTracker.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 *CyclicArbTracker) XXX_Merge(src proto.Message) { + xxx_messageInfo_CyclicArbTracker.Merge(m, src) +} +func (m *CyclicArbTracker) XXX_Size() int { + return m.Size() +} +func (m *CyclicArbTracker) XXX_DiscardUnknown() { + xxx_messageInfo_CyclicArbTracker.DiscardUnknown(m) +} + +var xxx_messageInfo_CyclicArbTracker proto.InternalMessageInfo + +func (m *CyclicArbTracker) GetCyclicArb() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.CyclicArb + } + return nil +} + +func (m *CyclicArbTracker) GetHeightAccountingStartsFrom() int64 { + if m != nil { + return m.HeightAccountingStartsFrom + } + return 0 +} + func init() { proto.RegisterType((*TokenPairArbRoutes)(nil), "osmosis.protorev.v1beta1.TokenPairArbRoutes") proto.RegisterType((*Route)(nil), "osmosis.protorev.v1beta1.Route") @@ -733,6 +848,8 @@ func init() { proto.RegisterType((*CosmwasmPoolInfo)(nil), "osmosis.protorev.v1beta1.CosmwasmPoolInfo") proto.RegisterType((*WeightMap)(nil), "osmosis.protorev.v1beta1.WeightMap") proto.RegisterType((*BaseDenom)(nil), "osmosis.protorev.v1beta1.BaseDenom") + proto.RegisterType((*AllProtocolRevenue)(nil), "osmosis.protorev.v1beta1.AllProtocolRevenue") + proto.RegisterType((*CyclicArbTracker)(nil), "osmosis.protorev.v1beta1.CyclicArbTracker") } func init() { @@ -740,67 +857,82 @@ func init() { } var fileDescriptor_1e9f2391fd9fec01 = []byte{ - // 949 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4f, 0x6f, 0x1b, 0x45, - 0x1c, 0xcd, 0xd6, 0x4e, 0x1a, 0x8f, 0x53, 0xdb, 0x99, 0xa4, 0xad, 0xe3, 0x22, 0x6f, 0x34, 0x95, - 0xc0, 0x20, 0xb1, 0x26, 0x86, 0x03, 0x2a, 0xea, 0xa1, 0x6b, 0x84, 0x88, 0x10, 0x49, 0x35, 0xb1, - 0x54, 0xc1, 0x65, 0x99, 0x5d, 0x4f, 0x92, 0x55, 0xbc, 0x3b, 0xd6, 0xce, 0x38, 0x7f, 0x7a, 0xe0, - 0xc2, 0x91, 0x0b, 0x17, 0x6e, 0x1c, 0xb8, 0x71, 0xe2, 0x7b, 0xf4, 0xd8, 0x63, 0xc5, 0x61, 0x85, - 0x92, 0x0b, 0xe2, 0xb8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x2d, 0xa8, 0x14, 0xa2, - 0x9b, 0xf4, 0xfd, 0x19, 0x68, 0x04, 0x2c, 0xcf, 0x2d, 0x10, 0x1e, 0x19, 0x0e, 0x13, 0xca, 0xcd, - 0x63, 0xf8, 0x60, 0xfa, 0xde, 0xcd, 0x33, 0x10, 0xae, 0x1b, 0xe8, 0x89, 0x46, 0xbe, 0xb3, 0x40, - 0xc5, 0x25, 0x9c, 0x7e, 0x4a, 0x63, 0x16, 0xe5, 0xcf, 0xdf, 0x30, 0x1f, 0xc8, 0xfa, 0x95, 0xd9, - 0xe7, 0x4f, 0xc2, 0x08, 0xab, 0xe5, 0xff, 0xfa, 0x97, 0xcd, 0xdd, 0x7b, 0x71, 0xd9, 0xb6, 0x5e, - 0x5e, 0xb6, 0xad, 0xdf, 0x2f, 0xdb, 0xd6, 0x0f, 0x57, 0xed, 0xa5, 0x97, 0x57, 0xed, 0xa5, 0x57, - 0x57, 0xed, 0xa5, 0xaf, 0x3f, 0x3a, 0x0a, 0xc5, 0xf1, 0xc4, 0x77, 0x02, 0x16, 0x75, 0x75, 0xec, - 0xef, 0x8f, 0x88, 0xcf, 0xcd, 0xa4, 0x7b, 0xda, 0xfb, 0xa0, 0x7b, 0x3e, 0xfd, 0xab, 0x24, 0x2e, - 0xc6, 0x94, 0xfb, 0x2b, 0x72, 0xfe, 0xe1, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x7d, 0xee, 0x8f, - 0xfb, 0x4b, 0x09, 0x00, 0x00, + // 1195 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x41, 0x6f, 0x1b, 0x45, + 0x14, 0xce, 0xd6, 0x69, 0x5a, 0x8f, 0x5b, 0xdb, 0x9d, 0xa6, 0xad, 0xe3, 0x82, 0x37, 0x4c, 0x0b, + 0xb8, 0x48, 0xb5, 0x9b, 0xc0, 0x01, 0x15, 0xf5, 0x90, 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48, 0x04, 0x6d, + 0x27, 0x42, 0x39, 0x29, 0x54, 0x1b, 0x47, 0x66, 0x55, 0x09, 0x9d, 0x01, 0x42, 0x18, 0x4e, 0x47, + 0x27, 0xab, 0x8a, 0x0d, 0x3d, 0x20, 0xdc, 0x4f, 0xc4, 0xe6, 0xb3, 0xab, 0xca, 0x00, 0x10, 0x2e, + 0x26, 0x11, 0x25, 0x82, 0x7e, 0xcc, 0x81, 0xe2, 0x66, 0xd0, 0x61, 0xd6, 0x61, 0xec, 0x57, 0xeb, + 0x70, 0x40, 0xe1, 0x53, 0xb0, 0xa0, 0xba, 0x97, 0x2e, 0x15, 0x56, 0xeb, 0xb3, 0xf7, 0xd9, 0xae, + 0xc4, 0xc5, 0x4c, 0xa9, 0x91, 0xd9, 0x70, 0x4a, 0x05, 0x61, 0x2d, 0x07, 0x6d, 0x70, 0x35, 0xf1, + 0x44, 0xfa, 0x57, 0x58, 0x7d, 0x6f, 0xb6, 0xb4, 0xa5, 0x91, 0xa9, 0xf8, 0x1d, 0x2d, 0x5e, 0x3a, + 0xe9, 0x37, 0xc2, 0xa9, 0x28, 0x64, 0xe0, 0xda, 0xb4, 0x4f, 0xd2, 0xdb, 0xc2, 0x6a, 0x63, 0x76, + 0x91, 0xf5, 0x29, 0x74, 0x5a, 0xe8, 0xae, 0x2e, 0x74, 0xf3, 0xf4, 0x3c, 0x10, 0x3e, 0x51, 0x20, + 0xee, 0x28, 0xf1, 0x53, 0x7a, 0xff, 0xda, 0x8e, 0xd6, 0x35, 0x72, 0x56, 0x47, 0x89, 0x12, 0xc2, + 0xa9, 0x28, 0xfa, 0x08, 0x14, 0x4f, 0x7a, 0x0c, 0x1f, 0x80, 0x85, 0x13, 0xdf, 0xf0, 0x8d, 0x89, + 0xdf, 0xc9, 0x8c, 0x35, 0x00, 0x3d, 0x01, 0xe5, 0xac, 0x8b, 0x17, 0xa1, 0x7f, 0x67, 0x80, 0xc5, + 0xb3, 0x0c, 0xba, 0x80, 0x06, 0xf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0x1c, 0xd5, 0x8c, 0xef, 0x8f, 0x6b, 0x73, 0x2f, 0x8f, 0x6b, 0x73, 0xaf, 0x8e, 0x6b, + 0x73, 0x5f, 0x7c, 0x30, 0xb5, 0x76, 0x6d, 0xf9, 0xc3, 0x3e, 0x71, 0x78, 0xf2, 0xd2, 0xdc, 0x5f, + 0x7d, 0xd4, 0x1c, 0x4d, 0x2e, 0xfb, 0xb2, 0x1b, 0x67, 0x41, 0xbe, 0xbf, 0xff, 0x4f, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xd0, 0xf4, 0x6f, 0x6c, 0x0d, 0x0c, 0x00, 0x00, } func (this *TokenPairArbRoutes) Equal(that interface{}) bool { @@ -1412,6 +1544,101 @@ func (m *BaseDenom) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *AllProtocolRevenue) 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 *AllProtocolRevenue) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AllProtocolRevenue) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.CyclicArbTracker.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProtorev(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size, err := m.TxFeesTracker.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProtorev(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.TakerFeesTracker.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProtorev(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *CyclicArbTracker) 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 *CyclicArbTracker) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CyclicArbTracker) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.HeightAccountingStartsFrom != 0 { + i = encodeVarintProtorev(dAtA, i, uint64(m.HeightAccountingStartsFrom)) + i-- + dAtA[i] = 0x10 + } + if len(m.CyclicArb) > 0 { + for iNdEx := len(m.CyclicArb) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CyclicArb[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProtorev(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintProtorev(dAtA []byte, offset int, v uint64) int { offset -= sovProtorev(v) base := offset @@ -1630,6 +1857,39 @@ func (m *BaseDenom) Size() (n int) { return n } +func (m *AllProtocolRevenue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.TakerFeesTracker.Size() + n += 1 + l + sovProtorev(uint64(l)) + l = m.TxFeesTracker.Size() + n += 1 + l + sovProtorev(uint64(l)) + l = m.CyclicArbTracker.Size() + n += 1 + l + sovProtorev(uint64(l)) + return n +} + +func (m *CyclicArbTracker) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.CyclicArb) > 0 { + for _, e := range m.CyclicArb { + l = e.Size() + n += 1 + l + sovProtorev(uint64(l)) + } + } + if m.HeightAccountingStartsFrom != 0 { + n += 1 + sovProtorev(uint64(m.HeightAccountingStartsFrom)) + } + return n +} + func sovProtorev(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3064,6 +3324,258 @@ func (m *BaseDenom) Unmarshal(dAtA []byte) error { } return nil } +func (m *AllProtocolRevenue) 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 ErrIntOverflowProtorev + } + 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: AllProtocolRevenue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AllProtocolRevenue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TakerFeesTracker", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtorev + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProtorev + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProtorev + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TakerFeesTracker.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TxFeesTracker", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtorev + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProtorev + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProtorev + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TxFeesTracker.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CyclicArbTracker", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtorev + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProtorev + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProtorev + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.CyclicArbTracker.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProtorev(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProtorev + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CyclicArbTracker) 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 ErrIntOverflowProtorev + } + 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: CyclicArbTracker: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CyclicArbTracker: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CyclicArb", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtorev + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProtorev + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProtorev + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CyclicArb = append(m.CyclicArb, types.Coin{}) + if err := m.CyclicArb[len(m.CyclicArb)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field HeightAccountingStartsFrom", wireType) + } + m.HeightAccountingStartsFrom = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtorev + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.HeightAccountingStartsFrom |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipProtorev(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProtorev + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipProtorev(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/protorev/types/query.pb.go b/x/protorev/types/query.pb.go index 50f1beec796..87b53830202 100644 --- a/x/protorev/types/query.pb.go +++ b/x/protorev/types/query.pb.go @@ -1389,6 +1389,86 @@ func (m *QueryGetProtoRevPoolResponse) GetPoolId() uint64 { return 0 } +type QueryGetAllProtocolRevenueRequest struct { +} + +func (m *QueryGetAllProtocolRevenueRequest) Reset() { *m = QueryGetAllProtocolRevenueRequest{} } +func (m *QueryGetAllProtocolRevenueRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetAllProtocolRevenueRequest) ProtoMessage() {} +func (*QueryGetAllProtocolRevenueRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f5e7ac9973cce389, []int{30} +} +func (m *QueryGetAllProtocolRevenueRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetAllProtocolRevenueRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetAllProtocolRevenueRequest.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 *QueryGetAllProtocolRevenueRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetAllProtocolRevenueRequest.Merge(m, src) +} +func (m *QueryGetAllProtocolRevenueRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetAllProtocolRevenueRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetAllProtocolRevenueRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetAllProtocolRevenueRequest proto.InternalMessageInfo + +type QueryGetAllProtocolRevenueResponse struct { + AllProtocolRevenue AllProtocolRevenue `protobuf:"bytes,1,opt,name=all_protocol_revenue,json=allProtocolRevenue,proto3" json:"all_protocol_revenue" yaml:"all_protocol_revenue"` +} + +func (m *QueryGetAllProtocolRevenueResponse) Reset() { *m = QueryGetAllProtocolRevenueResponse{} } +func (m *QueryGetAllProtocolRevenueResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetAllProtocolRevenueResponse) ProtoMessage() {} +func (*QueryGetAllProtocolRevenueResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f5e7ac9973cce389, []int{31} +} +func (m *QueryGetAllProtocolRevenueResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetAllProtocolRevenueResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetAllProtocolRevenueResponse.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 *QueryGetAllProtocolRevenueResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetAllProtocolRevenueResponse.Merge(m, src) +} +func (m *QueryGetAllProtocolRevenueResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetAllProtocolRevenueResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetAllProtocolRevenueResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetAllProtocolRevenueResponse proto.InternalMessageInfo + +func (m *QueryGetAllProtocolRevenueResponse) GetAllProtocolRevenue() AllProtocolRevenue { + if m != nil { + return m.AllProtocolRevenue + } + return AllProtocolRevenue{} +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "osmosis.protorev.v1beta1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "osmosis.protorev.v1beta1.QueryParamsResponse") @@ -1420,6 +1500,8 @@ func init() { proto.RegisterType((*QueryGetProtoRevEnabledResponse)(nil), "osmosis.protorev.v1beta1.QueryGetProtoRevEnabledResponse") proto.RegisterType((*QueryGetProtoRevPoolRequest)(nil), "osmosis.protorev.v1beta1.QueryGetProtoRevPoolRequest") proto.RegisterType((*QueryGetProtoRevPoolResponse)(nil), "osmosis.protorev.v1beta1.QueryGetProtoRevPoolResponse") + proto.RegisterType((*QueryGetAllProtocolRevenueRequest)(nil), "osmosis.protorev.v1beta1.QueryGetAllProtocolRevenueRequest") + proto.RegisterType((*QueryGetAllProtocolRevenueResponse)(nil), "osmosis.protorev.v1beta1.QueryGetAllProtocolRevenueResponse") } func init() { @@ -1427,103 +1509,108 @@ func init() { } var fileDescriptor_f5e7ac9973cce389 = []byte{ - // 1527 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b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 0x16, 0x92, 0xd7, 0xba, 0x17, 0x4c, 0xcb, - 0xc1, 0x3a, 0x83, 0x18, 0x09, 0x90, 0xe8, 0x67, 0xcc, 0x9e, 0x0a, 0x92, 0x47, 0x97, 0xa3, 0x04, - 0xdf, 0x36, 0x76, 0xfd, 0x70, 0x91, 0x99, 0xb6, 0xe7, 0x16, 0xa9, 0xa3, 0x59, 0xac, 0xf2, 0x20, - 0x50, 0xf4, 0xa5, 0x82, 0x56, 0x06, 0x2c, 0x00, 0x61, 0x1f, 0xa2, 0xc9, 0x9a, 0xb1, 0x2b, 0x38, - 0xd4, 0x79, 0x4a, 0xc9, 0x1f, 0x6f, 0xd9, 0x4f, 0xe2, 0x02, 0x8f, 0x69, 0xb3, 0xed, 0x56, 0x36, - 0x27, 0x28, 0x27, 0xa6, 0x12, 0x7d, 0xac, 0x16, 0xd7, 0x27, 0x6e, 0xd7, 0x45, 0x09, 0x6d, 0xee, - 0x06, 0xf4, 0x3f, 0x89, 0xd9, 0x75, 0x71, 0xd9, 0xc0, 0xfd, 0x3d, 0x34, 0x1e, 0x47, 0xc8, 0xdb, - 0x05, 0xe2, 0xd3, 0xed, 0x56, 0xf6, 0x62, 0x32, 0x71, 0x6f, 0x97, 0xe8, 0xb8, 0x26, 0xc1, 0xc7, - 0x5d, 0x35, 0x9a, 0xe1, 0x52, 0x7e, 0xab, 0x75, 0x0e, 0x88, 0x4f, 0x15, 0xf9, 0xae, 0x09, 0x67, - 0x01, 0xc5, 0x8f, 0xd0, 0x49, 0xff, 0x52, 0x29, 0xf1, 0x4b, 0x33, 0x38, 0x1d, 0x66, 0x92, 0xbf, - 0x98, 0x0e, 0x84, 0xa6, 0xc2, 0xc7, 0x82, 0x85, 0x80, 0x10, 0x0a, 0xd1, 0x51, 0xb9, 0xd3, 0x89, - 0xe4, 0x50, 0x26, 0xca, 0xe3, 0x4d, 0xdb, 0x28, 0x5b, 0xb4, 0x1a, 0x50, 0xdd, 0x40, 0xd9, 0xc4, - 0x0c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 0xe5, 0xc9, 0xb3, 0x8c, 0xf2, 0xd7, 0xb3, 0x8c, 0xf2, 0xd5, 0x5e, 0x66, 0xe8, 0xc9, - 0x5e, 0x66, 0xe8, 0xf7, 0xbd, 0xcc, 0xd0, 0xfb, 0x37, 0xb6, 0x4d, 0xef, 0x7e, 0xa3, 0x9c, 0xaf, - 0xb0, 0x5a, 0x50, 0xbb, 0x62, 0x19, 0x65, 0xb7, 0x03, 0xb4, 0x73, 0xed, 0x4a, 0x61, 0x37, 0x74, - 0x3b, 0x35, 0xeb, 0xd4, 0x2d, 0x0f, 0xf3, 0xe7, 0xeb, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x92, - 0x9c, 0x4d, 0xfb, 0x83, 0x17, 0x00, 0x00, + // 1607 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0x4b, 0x6f, 0x1b, 0x55, + 0x1b, 0xce, 0xf4, 0x92, 0x7c, 0x3d, 0xbd, 0x7c, 0xcd, 0xf9, 0x92, 0xd4, 0x99, 0xa4, 0xb6, 0x73, + 0x92, 0x34, 0xb7, 0xc6, 0xee, 0xed, 0x83, 0x72, 0x29, 0x90, 0x69, 0xa0, 0x8a, 0x2a, 0x1a, 0x33, + 0x84, 0x0d, 0x48, 0x98, 0xb1, 0x3d, 0x49, 0x47, 0x1d, 0xcf, 0x99, 0xce, 0x8c, 0xa3, 0x78, 0x4b, + 0x25, 0x10, 0x12, 0x12, 0xb7, 0x1f, 0x00, 0x6b, 0xc4, 0x1f, 0x60, 0x09, 0xab, 0x0a, 0x36, 0x45, + 0x48, 0x08, 0x15, 0x64, 0xa1, 0x96, 0x05, 0x6b, 0xff, 0x00, 0x84, 0xe6, 0x9c, 0x77, 0xec, 0xf1, + 0x9c, 0x19, 0xc7, 0x93, 0x48, 0xec, 0xec, 0x39, 0xef, 0xfb, 0xbc, 0xcf, 0x73, 0xae, 0xc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0x6b, 0xd5, 0xd4, 0x2a, 0x6e, 0x07, 0x78, 0xf7, 0xca, 0xa5, 0xe2, 0x5e, 0xe8, + 0x89, 0x6d, 0xda, 0xba, 0x5b, 0x19, 0x66, 0xff, 0xaf, 0xfe, 0x13, 0x00, 0x00, 0xff, 0xff, 0x2b, + 0x75, 0xac, 0xbd, 0x1a, 0x19, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1578,6 +1665,9 @@ type QueryClient interface { // GetProtoRevPool queries the pool id used via the highest liquidity method // for arbitrage route building given a pair of denominations GetProtoRevPool(ctx context.Context, in *QueryGetProtoRevPoolRequest, opts ...grpc.CallOption) (*QueryGetProtoRevPoolResponse, error) + // GetAllProtocolRevenue queries all of the protocol revenue that has been + // accumulated by any module + GetAllProtocolRevenue(ctx context.Context, in *QueryGetAllProtocolRevenueRequest, opts ...grpc.CallOption) (*QueryGetAllProtocolRevenueResponse, error) } type queryClient struct { @@ -1723,6 +1813,15 @@ func (c *queryClient) GetProtoRevPool(ctx context.Context, in *QueryGetProtoRevP return out, nil } +func (c *queryClient) GetAllProtocolRevenue(ctx context.Context, in *QueryGetAllProtocolRevenueRequest, opts ...grpc.CallOption) (*QueryGetAllProtocolRevenueResponse, error) { + out := new(QueryGetAllProtocolRevenueResponse) + err := c.cc.Invoke(ctx, "/osmosis.protorev.v1beta1.Query/GetAllProtocolRevenue", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Params queries the parameters of the module. @@ -1765,6 +1864,9 @@ type QueryServer interface { // GetProtoRevPool queries the pool id used via the highest liquidity method // for arbitrage route building given a pair of denominations GetProtoRevPool(context.Context, *QueryGetProtoRevPoolRequest) (*QueryGetProtoRevPoolResponse, error) + // GetAllProtocolRevenue queries all of the protocol revenue that has been + // accumulated by any module + GetAllProtocolRevenue(context.Context, *QueryGetAllProtocolRevenueRequest) (*QueryGetAllProtocolRevenueResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -1816,6 +1918,9 @@ func (*UnimplementedQueryServer) GetProtoRevEnabled(ctx context.Context, req *Qu func (*UnimplementedQueryServer) GetProtoRevPool(ctx context.Context, req *QueryGetProtoRevPoolRequest) (*QueryGetProtoRevPoolResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetProtoRevPool not implemented") } +func (*UnimplementedQueryServer) GetAllProtocolRevenue(ctx context.Context, req *QueryGetAllProtocolRevenueRequest) (*QueryGetAllProtocolRevenueResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetAllProtocolRevenue not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -2091,6 +2196,24 @@ func _Query_GetProtoRevPool_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _Query_GetAllProtocolRevenue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetAllProtocolRevenueRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetAllProtocolRevenue(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.protorev.v1beta1.Query/GetAllProtocolRevenue", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetAllProtocolRevenue(ctx, req.(*QueryGetAllProtocolRevenueRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "osmosis.protorev.v1beta1.Query", HandlerType: (*QueryServer)(nil), @@ -2155,6 +2278,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "GetProtoRevPool", Handler: _Query_GetProtoRevPool_Handler, }, + { + MethodName: "GetAllProtocolRevenue", + Handler: _Query_GetAllProtocolRevenue_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "osmosis/protorev/v1beta1/query.proto", @@ -3036,6 +3163,62 @@ func (m *QueryGetProtoRevPoolResponse) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } +func (m *QueryGetAllProtocolRevenueRequest) 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 *QueryGetAllProtocolRevenueRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetAllProtocolRevenueRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryGetAllProtocolRevenueResponse) 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 *QueryGetAllProtocolRevenueResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetAllProtocolRevenueResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.AllProtocolRevenue.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -3392,6 +3575,26 @@ func (m *QueryGetProtoRevPoolResponse) Size() (n int) { return n } +func (m *QueryGetAllProtocolRevenueRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryGetAllProtocolRevenueResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.AllProtocolRevenue.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -5516,6 +5719,139 @@ func (m *QueryGetProtoRevPoolResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryGetAllProtocolRevenueRequest) 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 ErrIntOverflowQuery + } + 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: QueryGetAllProtocolRevenueRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetAllProtocolRevenueRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetAllProtocolRevenueResponse) 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 ErrIntOverflowQuery + } + 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: QueryGetAllProtocolRevenueResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetAllProtocolRevenueResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AllProtocolRevenue", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AllProtocolRevenue.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/protorev/types/query.pb.gw.go b/x/protorev/types/query.pb.gw.go index 0aab022797c..3116d8aede1 100644 --- a/x/protorev/types/query.pb.gw.go +++ b/x/protorev/types/query.pb.gw.go @@ -357,6 +357,24 @@ func local_request_Query_GetProtoRevPool_0(ctx context.Context, marshaler runtim } +func request_Query_GetAllProtocolRevenue_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetAllProtocolRevenueRequest + var metadata runtime.ServerMetadata + + msg, err := client.GetAllProtocolRevenue(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetAllProtocolRevenue_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetAllProtocolRevenueRequest + var metadata runtime.ServerMetadata + + msg, err := server.GetAllProtocolRevenue(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -708,6 +726,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_GetAllProtocolRevenue_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GetAllProtocolRevenue_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetAllProtocolRevenue_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1049,6 +1090,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_GetAllProtocolRevenue_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GetAllProtocolRevenue_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetAllProtocolRevenue_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1082,6 +1143,8 @@ var ( pattern_Query_GetProtoRevEnabled_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"osmosis", "protorev", "enabled"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_GetProtoRevPool_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"osmosis", "protorev", "pool"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_GetAllProtocolRevenue_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"osmosis", "protorev", "all_protocol_revenue"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -1114,4 +1177,6 @@ var ( forward_Query_GetProtoRevEnabled_0 = runtime.ForwardResponseMessage forward_Query_GetProtoRevPool_0 = runtime.ForwardResponseMessage + + forward_Query_GetAllProtocolRevenue_0 = runtime.ForwardResponseMessage ) diff --git a/x/txfees/keeper/feedecorator.go b/x/txfees/keeper/feedecorator.go index a0b5cf61187..c7c33ca5572 100644 --- a/x/txfees/keeper/feedecorator.go +++ b/x/txfees/keeper/feedecorator.go @@ -265,5 +265,7 @@ func DeductFees(txFeesKeeper types.TxFeesKeeper, bankKeeper types.BankKeeper, ct } } + txFeesKeeper.IncreaseTxFeesTracker(ctx, fees[0]) + return nil } diff --git a/x/txfees/keeper/feedecorator_test.go b/x/txfees/keeper/feedecorator_test.go index aac8d56b951..7b535658ada 100644 --- a/x/txfees/keeper/feedecorator_test.go +++ b/x/txfees/keeper/feedecorator_test.go @@ -3,16 +3,9 @@ package keeper_test import ( "fmt" - clienttx "github.com/cosmos/cosmos-sdk/client/tx" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" - authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" - "github.com/cosmos/cosmos-sdk/x/bank/testutil" - "github.com/osmosis-labs/osmosis/osmomath" - "github.com/osmosis-labs/osmosis/v20/x/txfees/keeper" "github.com/osmosis-labs/osmosis/v20/x/txfees/types" ) @@ -22,7 +15,6 @@ func (s *KeeperTestSuite) TestFeeDecorator() { mempoolFeeOpts := types.NewDefaultMempoolFeeOptions() mempoolFeeOpts.MinGasPriceForHighGasTx = osmomath.MustNewDecFromStr("0.0025") baseDenom, _ := s.App.TxFeesKeeper.GetBaseDenom(s.Ctx) - baseGas := uint64(10000) consensusMinFeeAmt := int64(25) point1BaseDenomMinGasPrices := sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, osmomath.MustNewDecFromStr("0.1"))) @@ -154,56 +146,8 @@ func (s *KeeperTestSuite) TestFeeDecorator() { // reset pool and accounts for each test s.SetupTest(false) s.Run(tc.name, func() { - // setup uion with 1:1 fee - uionPoolId := s.PrepareBalancerPoolWithCoins( - sdk.NewInt64Coin(sdk.DefaultBondDenom, 500), - sdk.NewInt64Coin(uion, 500), - ) - err := s.ExecuteUpgradeFeeTokenProposal(uion, uionPoolId) - s.Require().NoError(err) - - if tc.minGasPrices == nil { - tc.minGasPrices = sdk.NewDecCoins() - } - if tc.gasRequested == 0 { - tc.gasRequested = baseGas - } - s.Ctx = s.Ctx.WithIsCheckTx(tc.isCheckTx).WithMinGasPrices(tc.minGasPrices) - - // TODO: Cleanup this code. - // TxBuilder components reset for every test case - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() - priv0, _, addr0 := testdata.KeyTestPubAddr() - acc1 := s.App.AccountKeeper.NewAccountWithAddress(s.Ctx, addr0) - s.App.AccountKeeper.SetAccount(s.Ctx, acc1) - msgs := []sdk.Msg{testdata.NewTestMsg(addr0)} - privs, accNums, accSeqs := []cryptotypes.PrivKey{priv0}, []uint64{0}, []uint64{0} - signerData := authsigning.SignerData{ - ChainID: s.Ctx.ChainID(), - AccountNumber: accNums[0], - Sequence: accSeqs[0], - } - - gasLimit := tc.gasRequested - sigV2, _ := clienttx.SignWithPrivKey( - 1, - signerData, - txBuilder, - privs[0], - s.clientCtx.TxConfig, - accSeqs[0], - ) - - err = testutil.FundAccount(s.App.BankKeeper, s.Ctx, addr0, tc.txFee) - s.Require().NoError(err) - - tx := s.BuildTx(txBuilder, msgs, sigV2, "", tc.txFee, gasLimit) - - mfd := keeper.NewMempoolFeeDecorator(*s.App.TxFeesKeeper, mempoolFeeOpts) - dfd := keeper.NewDeductFeeDecorator(*s.App.TxFeesKeeper, *s.App.AccountKeeper, s.App.BankKeeper, nil) - antehandlerMFD := sdk.ChainAnteDecorators(mfd, dfd) - _, err = antehandlerMFD(s.Ctx, tx, tc.isSimulate) - + preFeeDecoratorTxFeeTrackerValue := s.App.TxFeesKeeper.GetTxFeesTrackerValue(s.Ctx) + err := s.SetupTxFeeAnteHandlerAndChargeFee(s.clientCtx, tc.minGasPrices, tc.gasRequested, tc.isCheckTx, tc.isSimulate, tc.txFee) if tc.expectPass { // ensure fee was collected if !tc.txFee.IsZero() { @@ -213,6 +157,7 @@ func (s *KeeperTestSuite) TestFeeDecorator() { } moduleAddr := s.App.AccountKeeper.GetModuleAddress(moduleName) s.Require().Equal(tc.txFee[0], s.App.BankKeeper.GetBalance(s.Ctx, moduleAddr, tc.txFee[0].Denom), tc.name) + s.Require().Equal(preFeeDecoratorTxFeeTrackerValue.Add(tc.txFee[0]), s.App.TxFeesKeeper.GetTxFeesTrackerValue(s.Ctx)) } s.Require().NoError(err, "test: %s", tc.name) } else { diff --git a/x/txfees/keeper/genesis.go b/x/txfees/keeper/genesis.go index d4eac7a1d6a..0a0ee4f9080 100644 --- a/x/txfees/keeper/genesis.go +++ b/x/txfees/keeper/genesis.go @@ -17,12 +17,30 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { if err != nil { panic(err) } + + // We track the txfees generated in the KVStore. + // If the values were exported, we set them here. + // If the values were not exported, we initialize them to zero as well as use the current block height. + if genState.TxFeesTracker != nil { + k.SetTxFeesTrackerValue(ctx, genState.TxFeesTracker.TxFees) + k.SetTxFeesTrackerStartHeight(ctx, genState.TxFeesTracker.HeightAccountingStartsFrom) + } else { + k.SetTxFeesTrackerValue(ctx, sdk.NewCoins()) + k.SetTxFeesTrackerStartHeight(ctx, ctx.BlockHeight()) + } } // ExportGenesis returns the txfees module's exported genesis. func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + // Export KVStore values to the genesis state so they can be imported in init genesis. + txFeesTracker := types.TxFeesTracker{ + TxFees: k.GetTxFeesTrackerValue(ctx), + HeightAccountingStartsFrom: k.GetTxFeesTrackerStartHeight(ctx), + } + genesis := types.DefaultGenesis() genesis.Basedenom, _ = k.GetBaseDenom(ctx) genesis.Feetokens = k.GetFeeTokens(ctx) + genesis.TxFeesTracker = &txFeesTracker return genesis } diff --git a/x/txfees/keeper/genesis_test.go b/x/txfees/keeper/genesis_test.go new file mode 100644 index 00000000000..71c09bc081f --- /dev/null +++ b/x/txfees/keeper/genesis_test.go @@ -0,0 +1,64 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/v20/x/txfees/types" +) + +var ( + testBaseDenom = "uosmo" + testFeeTokens = []types.FeeToken{ + { + Denom: "uion", + PoolID: 1, + }, + { + Denom: "wbtc", + PoolID: 2, + }, + } + + testTxFeesTracker = types.TxFeesTracker{ + TxFees: sdk.Coins{sdk.NewCoin("uosmo", sdk.NewInt(1000))}, + HeightAccountingStartsFrom: 100, + } +) + +func (s *KeeperTestSuite) TestInitGenesis() { + s.SetupTest(false) + s.PrepareBalancerPoolWithCoins(sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(1000000000000000000)), sdk.NewCoin("uion", sdk.NewInt(1000000000000000000)))...) + s.PrepareBalancerPoolWithCoins(sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(1000000000000000000)), sdk.NewCoin("wbtc", sdk.NewInt(1000000000000000000)))...) + + s.App.TxFeesKeeper.InitGenesis(s.Ctx, types.GenesisState{ + Basedenom: testBaseDenom, + Feetokens: testFeeTokens, + TxFeesTracker: &testTxFeesTracker, + }) + + actualBaseDenom, err := s.App.TxFeesKeeper.GetBaseDenom(s.Ctx) + s.Require().NoError(err) + + s.Require().Equal(testBaseDenom, actualBaseDenom) + s.Require().Equal(testFeeTokens, s.App.TxFeesKeeper.GetFeeTokens(s.Ctx)) + s.Require().Equal(testTxFeesTracker.TxFees, s.App.TxFeesKeeper.GetTxFeesTrackerValue(s.Ctx)) + s.Require().Equal(testTxFeesTracker.HeightAccountingStartsFrom, s.App.TxFeesKeeper.GetTxFeesTrackerStartHeight(s.Ctx)) +} + +func (s *KeeperTestSuite) TestExportGenesis() { + s.SetupTest(false) + s.PrepareBalancerPoolWithCoins(sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(1000000000000000000)), sdk.NewCoin("uion", sdk.NewInt(1000000000000000000)))...) + s.PrepareBalancerPoolWithCoins(sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(1000000000000000000)), sdk.NewCoin("wbtc", sdk.NewInt(1000000000000000000)))...) + + s.App.TxFeesKeeper.InitGenesis(s.Ctx, types.GenesisState{ + Basedenom: testBaseDenom, + Feetokens: testFeeTokens, + TxFeesTracker: &testTxFeesTracker, + }) + + genesis := s.App.TxFeesKeeper.ExportGenesis(s.Ctx) + s.Require().Equal(testBaseDenom, genesis.Basedenom) + s.Require().Equal(testFeeTokens, genesis.Feetokens) + s.Require().Equal(testTxFeesTracker.TxFees, genesis.TxFeesTracker.TxFees) + s.Require().Equal(testTxFeesTracker.HeightAccountingStartsFrom, genesis.TxFeesTracker.HeightAccountingStartsFrom) +} diff --git a/x/txfees/keeper/hooks_test.go b/x/txfees/keeper/hooks_test.go index 55c62916f60..e9d6a72553c 100644 --- a/x/txfees/keeper/hooks_test.go +++ b/x/txfees/keeper/hooks_test.go @@ -133,9 +133,10 @@ func (s *KeeperTestSuite) TestSwapNonNativeFeeToDenom() { s.Setup() var ( - defaultTxFeesDenom, _ = s.App.TxFeesKeeper.GetBaseDenom(s.Ctx) - defaultPoolCoins = sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(100)), sdk.NewCoin(defaultTxFeesDenom, osmomath.NewInt(100))) - defaultBalanceToSwap = sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(100))) + defaultTxFeesDenom, _ = s.App.TxFeesKeeper.GetBaseDenom(s.Ctx) + defaultPoolCoins = sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(100)), sdk.NewCoin(defaultTxFeesDenom, osmomath.NewInt(100))) + balanceToSwapFoo = sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(50))) + balanceToSwapBaseDenom = sdk.NewCoins(sdk.NewCoin(defaultTxFeesDenom, osmomath.NewInt(50))) ) tests := []struct { @@ -148,9 +149,15 @@ func (s *KeeperTestSuite) TestSwapNonNativeFeeToDenom() { }{ { name: "happy path", - denomToSwapTo: defaultTxFeesDenom, + denomToSwapTo: balanceToSwapBaseDenom[0].Denom, poolCoins: defaultPoolCoins, - preFundCoins: defaultBalanceToSwap, + preFundCoins: balanceToSwapFoo, + }, + { + name: "same denom to swap to", + denomToSwapTo: balanceToSwapFoo[0].Denom, + poolCoins: defaultPoolCoins, + preFundCoins: balanceToSwapFoo, }, // TODO: add more test cases @@ -400,6 +407,9 @@ func (s *KeeperTestSuite) TestAfterEpochEnd() { preFundCollectorCoins := prepareCoinsForSwapToDenomTest(denomToSwapTo) s.FundModuleAcc(collectorName, preFundCollectorCoins) + currentTxFeesTrackerValue := s.App.TxFeesKeeper.GetTxFeesTrackerValue(s.Ctx) + s.App.TxFeesKeeper.SetTxFeesTrackerValue(s.Ctx, currentTxFeesTrackerValue.Add(preFundCollectorCoins...)) + // Prepare pools. s.preparePoolsForSwappingToDenom(otherPreSwapDenom, preSwapDenom, denomToSwapTo) diff --git a/x/txfees/keeper/protorev.go b/x/txfees/keeper/protorev.go new file mode 100644 index 00000000000..df4557f7c17 --- /dev/null +++ b/x/txfees/keeper/protorev.go @@ -0,0 +1,63 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + gogotypes "github.com/cosmos/gogoproto/types" + + "github.com/osmosis-labs/osmosis/osmoutils" + poolmanagertypes "github.com/osmosis-labs/osmosis/v20/x/poolmanager/types" + "github.com/osmosis-labs/osmosis/v20/x/txfees/types" +) + +// IncreaseTxFeesTracker gets the current value of the txfees tracker, adds the given amount to it, and sets the new value. +func (k Keeper) IncreaseTxFeesTracker(ctx sdk.Context, txFees sdk.Coin) { + currentTxFees := k.GetTxFeesTrackerValue(ctx) + if !txFees.IsZero() { + newnewTxFeesCoins := currentTxFees.Add(txFees) + newTxFees := poolmanagertypes.TrackedVolume{ + Amount: newnewTxFeesCoins, + } + osmoutils.MustSet(ctx.KVStore(k.storeKey), types.KeyTxFeeProtorevTracker, &newTxFees) + } +} + +func (k Keeper) SetTxFeesTrackerValue(ctx sdk.Context, txFees sdk.Coins) { + newtxFees := poolmanagertypes.TrackedVolume{ + Amount: txFees, + } + osmoutils.MustSet(ctx.KVStore(k.storeKey), types.KeyTxFeeProtorevTracker, &newtxFees) +} + +func (k Keeper) GetTxFeesTrackerValue(ctx sdk.Context) (currentTxFees sdk.Coins) { + var txFees poolmanagertypes.TrackedVolume + txFeesFound, err := osmoutils.Get(ctx.KVStore(k.storeKey), types.KeyTxFeeProtorevTracker, &txFees) + if err != nil { + // We can only encounter an error if a database or serialization errors occurs, so we panic here. + // Normally this would be handled by `osmoutils.MustGet`, but since we want to specifically use `osmoutils.Get`, + // we also have to manually panic here. + panic(err) + } + + // If no volume was found, we treat the existing volume as 0. + // While we can technically require volume to exist, we would need to store empty coins in state for each pool (past and present), + // which is a high storage cost to pay for a weak guardrail. + currentTxFees = sdk.NewCoins() + if txFeesFound { + currentTxFees = txFees.Amount + } + + return currentTxFees +} + +// GetTxFeesTrackerStartHeight gets the height from which we started accounting for txfees. +func (k Keeper) GetTxFeesTrackerStartHeight(ctx sdk.Context) int64 { + startHeight := gogotypes.Int64Value{} + osmoutils.MustGet(ctx.KVStore(k.storeKey), types.KeyTxFeeProtorevTrackerStartHeight, &startHeight) + return startHeight.Value +} + +// SetTxFeesTrackerStartHeight sets the height from which we started accounting for txfees. +func (k Keeper) SetTxFeesTrackerStartHeight(ctx sdk.Context, startHeight int64) { + osmoutils.MustSet(ctx.KVStore(k.storeKey), types.KeyTxFeeProtorevTrackerStartHeight, &gogotypes.Int64Value{Value: startHeight}) +} diff --git a/x/txfees/keeper/protorev_test.go b/x/txfees/keeper/protorev_test.go new file mode 100644 index 00000000000..39474bff71a --- /dev/null +++ b/x/txfees/keeper/protorev_test.go @@ -0,0 +1,121 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (s *KeeperTestSuite) TestGetSetTxFeesTrackerValue() { + tests := map[string]struct { + firstTxFeesValue sdk.Coins + secondTxFeesValue sdk.Coins + }{ + "happy path: replace single coin with increased single coin": { + firstTxFeesValue: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100))), + secondTxFeesValue: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(200))), + }, + "replace single coin with decreased single coin": { + firstTxFeesValue: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100))), + secondTxFeesValue: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(50))), + }, + "replace single coin with different denom": { + firstTxFeesValue: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100))), + secondTxFeesValue: sdk.NewCoins(sdk.NewCoin("usdc", sdk.NewInt(100))), + }, + "replace single coin with multiple coins": { + firstTxFeesValue: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100))), + secondTxFeesValue: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100)), sdk.NewCoin("usdc", sdk.NewInt(200))), + }, + "replace multiple coins with single coin": { + firstTxFeesValue: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100)), sdk.NewCoin("usdc", sdk.NewInt(200))), + secondTxFeesValue: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(200))), + }, + } + + for name, tc := range tests { + s.Run(name, func() { + s.SetupTest(false) + + s.Require().Empty(s.App.TxFeesKeeper.GetTxFeesTrackerValue(s.Ctx)) + + s.App.TxFeesKeeper.SetTxFeesTrackerValue(s.Ctx, tc.firstTxFeesValue) + + actualFirstTxFeesValue := s.App.TxFeesKeeper.GetTxFeesTrackerValue(s.Ctx) + + s.Require().Equal(tc.firstTxFeesValue, actualFirstTxFeesValue) + + s.App.TxFeesKeeper.SetTxFeesTrackerValue(s.Ctx, tc.secondTxFeesValue) + + actualSecondTxFeesValue := s.App.TxFeesKeeper.GetTxFeesTrackerValue(s.Ctx) + + s.Require().Equal(tc.secondTxFeesValue, actualSecondTxFeesValue) + }) + } +} + +func (s *KeeperTestSuite) TestGetSetTxFeesTrackerStartHeight() { + tests := map[string]struct { + firstTxFeesTrackerStartHeight int64 + secondTxFeesTrackerStartHeight int64 + }{ + "replace tracker height with a higher height": { + firstTxFeesTrackerStartHeight: 100, + secondTxFeesTrackerStartHeight: 5000, + }, + "replace tracker height with a lower height": { + firstTxFeesTrackerStartHeight: 100, + secondTxFeesTrackerStartHeight: 50, + }, + "replace tracker height back to zero": { + firstTxFeesTrackerStartHeight: 100, + secondTxFeesTrackerStartHeight: 0, + }, + } + + for name, tc := range tests { + s.Run(name, func() { + s.SetupTest(false) + + s.Require().Empty(s.App.TxFeesKeeper.GetTxFeesTrackerStartHeight(s.Ctx)) + + s.App.TxFeesKeeper.SetTxFeesTrackerStartHeight(s.Ctx, tc.firstTxFeesTrackerStartHeight) + actualFirstTxFeesTrackerStartHeight := s.App.TxFeesKeeper.GetTxFeesTrackerStartHeight(s.Ctx) + s.Require().Equal(tc.firstTxFeesTrackerStartHeight, actualFirstTxFeesTrackerStartHeight) + + s.App.TxFeesKeeper.SetTxFeesTrackerStartHeight(s.Ctx, tc.secondTxFeesTrackerStartHeight) + actualSecondTxFeesTrackerStartHeight := s.App.TxFeesKeeper.GetTxFeesTrackerStartHeight(s.Ctx) + s.Require().Equal(tc.secondTxFeesTrackerStartHeight, actualSecondTxFeesTrackerStartHeight) + }) + } +} + +func (s *KeeperTestSuite) TestIncreaseTxFeesTracker() { + tests := map[string]struct { + initialTxFeesValue sdk.Coins + increaseTxFeesValueBy sdk.Coin + }{ + "happy path: increase single denom tracker": { + initialTxFeesValue: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100))), + increaseTxFeesValueBy: sdk.NewCoin("eth", sdk.NewInt(50)), + }, + "increase multi denom tracker": { + initialTxFeesValue: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(100)), sdk.NewCoin("usdc", sdk.NewInt(200))), + increaseTxFeesValueBy: sdk.NewCoin("eth", sdk.NewInt(50)), + }, + } + + for name, tc := range tests { + s.Run(name, func() { + s.SetupTest(false) + + s.Require().Empty(s.App.TxFeesKeeper.GetTxFeesTrackerStartHeight(s.Ctx)) + + s.App.TxFeesKeeper.SetTxFeesTrackerValue(s.Ctx, tc.initialTxFeesValue) + actualInitialTxFeesValue := s.App.TxFeesKeeper.GetTxFeesTrackerValue(s.Ctx) + s.Require().Equal(tc.initialTxFeesValue, actualInitialTxFeesValue) + + s.App.TxFeesKeeper.IncreaseTxFeesTracker(s.Ctx, tc.increaseTxFeesValueBy) + txFeesValueAfterIncrease := s.App.TxFeesKeeper.GetTxFeesTrackerValue(s.Ctx) + s.Require().Equal(tc.initialTxFeesValue.Add(sdk.NewCoins(tc.increaseTxFeesValueBy)...), txFeesValueAfterIncrease) + }) + } +} diff --git a/x/txfees/types/expected_keepers.go b/x/txfees/types/expected_keepers.go index 2f22c023891..80702d05345 100644 --- a/x/txfees/types/expected_keepers.go +++ b/x/txfees/types/expected_keepers.go @@ -71,6 +71,7 @@ type TxFeesKeeper interface { ConvertToBaseToken(ctx sdk.Context, inputFee sdk.Coin) (sdk.Coin, error) GetBaseDenom(ctx sdk.Context) (denom string, err error) GetFeeToken(ctx sdk.Context, denom string) (FeeToken, error) + IncreaseTxFeesTracker(ctx sdk.Context, txFees sdk.Coin) } type ProtorevKeeper interface { diff --git a/x/txfees/types/genesis.go b/x/txfees/types/genesis.go index 8f874dddbae..e39fa74ac73 100644 --- a/x/txfees/types/genesis.go +++ b/x/txfees/types/genesis.go @@ -7,6 +7,10 @@ func DefaultGenesis() *GenesisState { return &GenesisState{ Basedenom: sdk.DefaultBondDenom, Feetokens: []FeeToken{}, + TxFeesTracker: &TxFeesTracker{ + TxFees: sdk.NewCoins(), + HeightAccountingStartsFrom: 0, + }, } } diff --git a/x/txfees/types/genesis.pb.go b/x/txfees/types/genesis.pb.go index 5c7490bc809..16bd2c8af4a 100644 --- a/x/txfees/types/genesis.pb.go +++ b/x/txfees/types/genesis.pb.go @@ -5,6 +5,8 @@ package types import ( fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -27,6 +29,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { Basedenom string `protobuf:"bytes,1,opt,name=basedenom,proto3" json:"basedenom,omitempty"` Feetokens []FeeToken `protobuf:"bytes,2,rep,name=feetokens,proto3" json:"feetokens"` + // KVStore state + TxFeesTracker *TxFeesTracker `protobuf:"bytes,3,opt,name=txFeesTracker,proto3" json:"txFeesTracker,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -76,8 +80,68 @@ func (m *GenesisState) GetFeetokens() []FeeToken { return nil } +func (m *GenesisState) GetTxFeesTracker() *TxFeesTracker { + if m != nil { + return m.TxFeesTracker + } + return nil +} + +type TxFeesTracker struct { + TxFees github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=tx_fees,json=txFees,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"tx_fees"` + HeightAccountingStartsFrom int64 `protobuf:"varint,2,opt,name=height_accounting_starts_from,json=heightAccountingStartsFrom,proto3" json:"height_accounting_starts_from,omitempty" yaml:"height_accounting_starts_from"` +} + +func (m *TxFeesTracker) Reset() { *m = TxFeesTracker{} } +func (m *TxFeesTracker) String() string { return proto.CompactTextString(m) } +func (*TxFeesTracker) ProtoMessage() {} +func (*TxFeesTracker) Descriptor() ([]byte, []int) { + return fileDescriptor_4423c18e3d020b37, []int{1} +} +func (m *TxFeesTracker) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TxFeesTracker) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TxFeesTracker.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 *TxFeesTracker) XXX_Merge(src proto.Message) { + xxx_messageInfo_TxFeesTracker.Merge(m, src) +} +func (m *TxFeesTracker) XXX_Size() int { + return m.Size() +} +func (m *TxFeesTracker) XXX_DiscardUnknown() { + xxx_messageInfo_TxFeesTracker.DiscardUnknown(m) +} + +var xxx_messageInfo_TxFeesTracker proto.InternalMessageInfo + +func (m *TxFeesTracker) GetTxFees() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.TxFees + } + return nil +} + +func (m *TxFeesTracker) GetHeightAccountingStartsFrom() int64 { + if m != nil { + return m.HeightAccountingStartsFrom + } + return 0 +} + func init() { proto.RegisterType((*GenesisState)(nil), "osmosis.txfees.v1beta1.GenesisState") + proto.RegisterType((*TxFeesTracker)(nil), "osmosis.txfees.v1beta1.TxFeesTracker") } func init() { @@ -85,22 +149,33 @@ func init() { } var fileDescriptor_4423c18e3d020b37 = []byte{ - // 236 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xc9, 0x2f, 0xce, 0xcd, - 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0xa9, 0x48, 0x4b, 0x4d, 0x2d, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, - 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, - 0x17, 0x12, 0x83, 0xaa, 0xd2, 0x83, 0xa8, 0xd2, 0x83, 0xaa, 0x92, 0x12, 0x49, 0xcf, 0x4f, 0xcf, - 0x07, 0x2b, 0xd1, 0x07, 0xb1, 0x20, 0xaa, 0xa5, 0x54, 0x71, 0x98, 0x99, 0x96, 0x9a, 0x5a, 0x92, - 0x9f, 0x9d, 0x9a, 0x07, 0x51, 0xa6, 0x54, 0xc4, 0xc5, 0xe3, 0x0e, 0xb1, 0x25, 0xb8, 0x24, 0xb1, - 0x24, 0x55, 0x48, 0x86, 0x8b, 0x33, 0x29, 0xb1, 0x38, 0x35, 0x25, 0x35, 0x2f, 0x3f, 0x57, 0x82, - 0x51, 0x81, 0x51, 0x83, 0x33, 0x08, 0x21, 0x20, 0xe4, 0xc2, 0xc5, 0x09, 0xd3, 0x5f, 0x2c, 0xc1, - 0xa4, 0xc0, 0xac, 0xc1, 0x6d, 0xa4, 0xa0, 0x87, 0xdd, 0x59, 0x7a, 0x6e, 0xa9, 0xa9, 0x21, 0x20, - 0x85, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x21, 0x34, 0x3a, 0xf9, 0x9c, 0x78, 0x24, 0xc7, - 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, - 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x51, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, - 0x7e, 0xae, 0x3e, 0xd4, 0x58, 0xdd, 0x9c, 0xc4, 0xa4, 0x62, 0x18, 0x47, 0xbf, 0xcc, 0xc8, 0x40, - 0xbf, 0x02, 0xe6, 0xa5, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x47, 0x8c, 0x01, 0x01, - 0x00, 0x00, 0xff, 0xff, 0xc6, 0xe5, 0xce, 0xf8, 0x45, 0x01, 0x00, 0x00, + // 405 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xbb, 0x8e, 0xd3, 0x40, + 0x14, 0x86, 0x3d, 0x1b, 0xb4, 0x28, 0xb3, 0x6c, 0x63, 0x21, 0x64, 0x22, 0x70, 0x2c, 0x6b, 0x57, + 0x72, 0x93, 0x99, 0xc4, 0x74, 0x74, 0x18, 0x14, 0x0a, 0xa8, 0x9c, 0x54, 0x34, 0xd6, 0xd8, 0x39, + 0x71, 0x2c, 0xc7, 0x9e, 0xc8, 0x33, 0x89, 0x9c, 0xb7, 0xe0, 0x39, 0x78, 0x09, 0xda, 0x94, 0x29, + 0xa9, 0x02, 0x72, 0xde, 0x80, 0x27, 0x40, 0xbe, 0xe4, 0x26, 0x91, 0xad, 0x7c, 0xf9, 0xbf, 0xf3, + 0x9f, 0xff, 0x9c, 0x19, 0xfc,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, 0x7d, 0x12, 0xf0, + 0x84, 0x36, 0x2b, 0xab, 0x1f, 0x3d, 0x31, 0x89, 0xa9, 0x5c, 0x2f, 0x40, 0x54, 0x05, 0xc2, 0xbd, + 0xad, 0xdb, 0xab, 0x31, 0x7e, 0x3b, 0x83, 0x28, 0x9c, 0x49, 0x8f, 0x05, 0x01, 0x5f, 0xa6, 0x32, + 0x4a, 0x43, 0x4f, 0x48, 0x96, 0x49, 0xe1, 0x4d, 0x33, 0x9e, 0x68, 0x37, 0x06, 0xb2, 0x5a, 0x8e, + 0xf5, 0x77, 0xd7, 0x7d, 0x58, 0xb3, 0x64, 0xfe, 0xde, 0x7c, 0x12, 0x37, 0xdd, 0x4e, 0xad, 0x7f, + 0x38, 0xca, 0xa3, 0x4a, 0x1d, 0x66, 0x3c, 0x71, 0xbe, 0x6e, 0x0a, 0x1d, 0x6d, 0x0b, 0x1d, 0xfd, + 0x29, 0x74, 0xf4, 0x7d, 0xaf, 0x2b, 0xdb, 0xbd, 0xae, 0xfc, 0xda, 0xeb, 0xca, 0x37, 0xfb, 0x2c, + 0x78, 0xb3, 0xbe, 0xde, 0x9c, 0xf9, 0xe2, 0xf0, 0x41, 0x57, 0x76, 0x9f, 0xe6, 0x87, 0x5b, 0x52, + 0x0d, 0xe2, 0xdf, 0x56, 0x67, 0xff, 0xee, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x39, 0x23, 0x0f, + 0x42, 0x98, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -123,6 +198,18 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.TxFeesTracker != nil { + { + size, err := m.TxFeesTracker.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } if len(m.Feetokens) > 0 { for iNdEx := len(m.Feetokens) - 1; iNdEx >= 0; iNdEx-- { { @@ -147,6 +234,48 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *TxFeesTracker) 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 *TxFeesTracker) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TxFeesTracker) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.HeightAccountingStartsFrom != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.HeightAccountingStartsFrom)) + i-- + dAtA[i] = 0x10 + } + if len(m.TxFees) > 0 { + for iNdEx := len(m.TxFees) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TxFees[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { offset -= sovGenesis(v) base := offset @@ -174,6 +303,28 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if m.TxFeesTracker != nil { + l = m.TxFeesTracker.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *TxFeesTracker) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.TxFees) > 0 { + for _, e := range m.TxFees { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.HeightAccountingStartsFrom != 0 { + n += 1 + sovGenesis(uint64(m.HeightAccountingStartsFrom)) + } return n } @@ -278,6 +429,145 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TxFeesTracker", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.TxFeesTracker == nil { + m.TxFeesTracker = &TxFeesTracker{} + } + if err := m.TxFeesTracker.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TxFeesTracker) 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 ErrIntOverflowGenesis + } + 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: TxFeesTracker: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TxFeesTracker: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TxFees", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TxFees = append(m.TxFees, types.Coin{}) + if err := m.TxFees[len(m.TxFees)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field HeightAccountingStartsFrom", wireType) + } + m.HeightAccountingStartsFrom = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.HeightAccountingStartsFrom |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/txfees/types/keys.go b/x/txfees/types/keys.go index 13a39b957bc..8b75b853493 100644 --- a/x/txfees/types/keys.go +++ b/x/txfees/types/keys.go @@ -2,7 +2,8 @@ package types const ( // ModuleName defines the module name. - ModuleName = "txfees" + ModuleName = "txfees" + KeySeparator = "|" // StoreKey defines the primary module store key. StoreKey = ModuleName @@ -26,6 +27,8 @@ const ( ) var ( - BaseDenomKey = []byte("base_denom") - FeeTokensStorePrefix = []byte("fee_tokens") + BaseDenomKey = []byte("base_denom") + FeeTokensStorePrefix = []byte("fee_tokens") + KeyTxFeeProtorevTracker = []byte("txfee_protorev_tracker") + KeyTxFeeProtorevTrackerStartHeight = []byte("txfee_protorev_tracker_start_height") )