Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat(spike): taker fee #6034

Merged
merged 94 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from 76 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
4eb8594
add taker fee determination and extraction
czarcas7ic Aug 11, 2023
12dccfa
remove osmo multi hop logic
czarcas7ic Aug 11, 2023
e857cc9
route to both community pool and staking rewards
czarcas7ic Aug 14, 2023
f773225
fix a handfull of tests
czarcas7ic Aug 14, 2023
0e54b35
assign taker fee to pool at time of creation
czarcas7ic Aug 14, 2023
4d421fd
pull taker fee direct from pool struct
czarcas7ic Aug 14, 2023
8d1c8c6
Merge branch 'main' into adam/taker-fee-feat
czarcas7ic Aug 14, 2023
4177b7a
fix more tests
czarcas7ic Aug 14, 2023
49e6aff
fix tests, set back up osmo multi hop discount
czarcas7ic Aug 15, 2023
e57f4a6
correct taker fee extraction
czarcas7ic Aug 16, 2023
547232f
regen mocks
czarcas7ic Aug 16, 2023
5ea549b
abstract taker fee to pool manager (highest lvl)
czarcas7ic Aug 17, 2023
d43a1e5
Merge branch 'main' into adam/taker-fee-feat
czarcas7ic Aug 17, 2023
914cedc
fix extract cmd
czarcas7ic Aug 17, 2023
5a68fa6
update changelog
devbot-wizard Aug 17, 2023
4312222
Merge branch 'main' into adam/taker-fee-feat
czarcas7ic Aug 18, 2023
f0afc3d
tidy
czarcas7ic Aug 18, 2023
a3863d5
remove param that no longer exists
czarcas7ic Aug 18, 2023
e4294a4
add extra params to genesis logic
czarcas7ic Aug 18, 2023
f21dba0
add back osmo multihop tests
czarcas7ic Aug 18, 2023
48f1d6f
add comment
czarcas7ic Aug 18, 2023
3fe5742
fix e2e keeping prints
czarcas7ic Aug 20, 2023
925d619
fixes
czarcas7ic Aug 20, 2023
f51eb28
more test fixes
czarcas7ic Aug 20, 2023
aa02dad
remove prints
czarcas7ic Aug 20, 2023
bf5af4a
more naive approach to determining taker fee
czarcas7ic Aug 21, 2023
2177b15
fix e2e
czarcas7ic Aug 21, 2023
3b5453e
re-enable disabled test
czarcas7ic Aug 21, 2023
e4420d3
minor cleaning
czarcas7ic Aug 21, 2023
0834a30
simplify params
czarcas7ic Aug 21, 2023
9a7b1c2
not nullable
czarcas7ic Aug 21, 2023
279ae06
clean up
czarcas7ic Aug 21, 2023
323d742
add whitelist set message denom pair taker fees
czarcas7ic Aug 22, 2023
f96efbf
use real addresses
czarcas7ic Aug 22, 2023
7e2bcf4
add gov prop for denom pair taker fee update
czarcas7ic Aug 22, 2023
71f1e90
clean
czarcas7ic Aug 22, 2023
1bd9f15
move logic to its own taker_fee.go file
czarcas7ic Aug 22, 2023
21c7316
add CLI for gov prop for denomPairTakerFee
czarcas7ic Aug 22, 2023
89b0fe3
add admin address denomPairTakerFee cli msg
czarcas7ic Aug 22, 2023
7ec60cc
clean and simplifications
czarcas7ic Aug 22, 2023
eeefe36
use authorized quote denoms from poolmanger
czarcas7ic Aug 22, 2023
3ddd408
remove stableswap taker fee
czarcas7ic Aug 22, 2023
150eeb1
sim msg change
czarcas7ic Aug 22, 2023
08bb1ea
add test for CLI
czarcas7ic Aug 22, 2023
a300d6e
msg server tests
czarcas7ic Aug 22, 2023
411bfa6
add route_test test
czarcas7ic Aug 23, 2023
236505d
add gov_test.go
czarcas7ic Aug 23, 2023
9c17b70
add msgs_test.go
czarcas7ic Aug 23, 2023
41a1968
remove print line
czarcas7ic Aug 23, 2023
c2108b7
Merge branch 'main' into adam/taker-fee-feat
czarcas7ic Aug 26, 2023
d081c2a
change from v18 to v19
czarcas7ic Aug 26, 2023
4cb0230
Update upgrades.go
czarcas7ic Aug 26, 2023
5c9fbd8
set default taker fee to zero in upgrade handler
czarcas7ic Aug 26, 2023
214dd27
Merge branch 'main' into adam/taker-fee-feat
p0mvn Aug 26, 2023
f5ee761
Merge branch 'main' into adam/taker-fee-feat
devbot-wizard Aug 26, 2023
e617f04
conflicts
p0mvn Aug 26, 2023
7e8f86e
Update proto/osmosis/poolmanager/v1beta1/genesis.proto
p0mvn Aug 26, 2023
c23c5b5
Update proto/osmosis/poolmanager/v1beta1/genesis.proto
p0mvn Aug 26, 2023
6caac1f
Update x/poolmanager/taker_fee.go
p0mvn Aug 26, 2023
fbd5700
Generated protofile changes
invalid-email-address Aug 26, 2023
55be63b
rename extractTakerFeeAndDistribute to chargeTakerFee
p0mvn Aug 26, 2023
b716e72
clean up
p0mvn Aug 26, 2023
0e5d2eb
comment
p0mvn Aug 26, 2023
333dc17
rename
p0mvn Aug 26, 2023
fca43b5
godoc for NonNativeFeeCollectorForCommunityPoolName
p0mvn Aug 26, 2023
3b4d80c
baseDenom to defaultFeesDenom name change
p0mvn Aug 26, 2023
7563916
fix upgrade handler
AlpinYukseloglu Aug 26, 2023
72ffbb6
fix AfterEpochEnd order of denoms when getting pools; reduce code dup…
p0mvn Aug 26, 2023
cf5a80c
fix track volume
czarcas7ic Aug 27, 2023
aab35ca
add key separator for pool manager
czarcas7ic Aug 27, 2023
b2c7d50
add comment to denom pair route
czarcas7ic Aug 27, 2023
cbc2ff4
add basic lexicographical key test
czarcas7ic Aug 27, 2023
0f2da85
update chargeTakerFee godoc
czarcas7ic Aug 27, 2023
d129ea3
set the default taker fee back to non zero for e2e
czarcas7ic Aug 27, 2023
9a5616d
change PoolMangerGetParams API to GetAuthorizedQuoteDenoms (same for…
p0mvn Aug 27, 2023
573565e
update txfees & poolmanager READMEs with takerFee
czarcas7ic Aug 27, 2023
07b98f2
Merge branch 'main' into adam/taker-fee-feat
czarcas7ic Aug 27, 2023
bed1140
Merge branch 'main' into adam/taker-fee-feat
ValarDragon Aug 28, 2023
0ba3702
fix merge main
czarcas7ic Aug 28, 2023
95bfae1
Merge branch 'main' into adam/taker-fee-feat
ValarDragon Aug 28, 2023
b01f264
Merge branch 'main' into adam/taker-fee-feat
ValarDragon Aug 28, 2023
73830bc
add comment to denom pair taker fee
czarcas7ic Aug 28, 2023
518f68b
Merge branch 'main' into adam/taker-fee-feat
ValarDragon Aug 28, 2023
52e210c
de-dup taker fee param validation
ValarDragon Aug 28, 2023
303bfb9
Update x/poolmanager/types/msgs.go
ValarDragon Aug 28, 2023
e7b7a20
Apply suggestions from code review
ValarDragon Aug 28, 2023
d5e9123
Update x/poolmanager/taker_fee.go
ValarDragon Aug 28, 2023
708442e
remove unneeded setup test
czarcas7ic Aug 28, 2023
759c310
get pool creation free from previous
czarcas7ic Aug 28, 2023
ecaa3f3
take non native out of name
czarcas7ic Aug 28, 2023
87e4310
undo param pull instead of default
czarcas7ic Aug 28, 2023
84c8873
use current pool creation fee
czarcas7ic Aug 28, 2023
726532e
use default
czarcas7ic Aug 28, 2023
e48e614
e2e
czarcas7ic Aug 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* [#6162](https://github.com/osmosis-labs/osmosis/pull/6162) allow zero qualifying balancer shares in CL incentives

### Features

* [#6034](https://github.com/osmosis-labs/osmosis/pull/6034) feat(spike): taker fee
## v18.0.0

Fixes mainnet bugs w/ incorrect accumulation sumtrees, and CL handling for a balancer pool with 0 bonded shares.
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LEDGER_ENABLED ?= true
SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
BUILDDIR ?= $(CURDIR)/build
DOCKER := $(shell which docker)
E2E_UPGRADE_VERSION := "v18"
E2E_UPGRADE_VERSION := "v19"
#SHELL := /bin/bash

GO_VERSION := $(shell cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2)
Expand Down Expand Up @@ -586,7 +586,7 @@ cl-create-bigbang-config:
###############################################################################

go-mock-update:
mockgen -source=x/poolmanager/types/routes.go -destination=tests/mocks/pool_module.go -package=mocks
mockgen -source=x/poolmanager/types/expected_keepers.go -destination=tests/mocks/pool_module.go -package=mocks
mockgen -source=x/poolmanager/types/pool.go -destination=tests/mocks/pool.go -package=mocks
mockgen -source=x/gamm/types/pool.go -destination=tests/mocks/cfmm_pool.go -package=mocks
mockgen -source=x/concentrated-liquidity/types/cl_pool_extensionI.go -destination=tests/mocks/cl_pool.go -package=mocks
Expand Down
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import (
v16 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v16"
v17 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v17"
v18 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v18"
v19 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v19"
v3 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v3"
v4 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v4"
v5 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v5"
Expand Down Expand Up @@ -104,7 +105,7 @@ var (

// _ sdksimapp.App = (*OsmosisApp)(nil)

Upgrades = []upgrades.Upgrade{v4.Upgrade, v5.Upgrade, v7.Upgrade, v9.Upgrade, v11.Upgrade, v12.Upgrade, v13.Upgrade, v14.Upgrade, v15.Upgrade, v16.Upgrade, v17.Upgrade, v18.Upgrade}
Upgrades = []upgrades.Upgrade{v4.Upgrade, v5.Upgrade, v7.Upgrade, v9.Upgrade, v11.Upgrade, v12.Upgrade, v13.Upgrade, v14.Upgrade, v15.Upgrade, v16.Upgrade, v17.Upgrade, v18.Upgrade, v19.Upgrade}
Forks = []upgrades.Fork{v3.Fork, v6.Fork, v8.Fork, v10.Fork}
)

Expand Down
6 changes: 5 additions & 1 deletion app/apptesting/concentrated_liquidity.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

clmodel "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/model"
"github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types"
poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types"

cl "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity"
)
Expand Down Expand Up @@ -139,6 +140,9 @@ func (s *KeeperTestHelper) SetupConcentratedLiquidityDenomsAndPoolCreation() {
// modify authorized quote denoms to include test denoms.
defaultParams := types.DefaultParams()
defaultParams.IsPermissionlessPoolCreationEnabled = true
defaultParams.AuthorizedQuoteDenoms = append(defaultParams.AuthorizedQuoteDenoms, ETH, USDC, BAR, BAZ, FOO, UOSMO, STAKE, WBTC)
s.App.ConcentratedLiquidityKeeper.SetParams(s.Ctx, defaultParams)

poolManagerParams := s.App.PoolManagerKeeper.GetParams(s.Ctx)
poolManagerParams.AuthorizedQuoteDenoms = append(poolmanagertypes.DefaultParams().AuthorizedQuoteDenoms, ETH, USDC, BAR, BAZ, FOO, UOSMO, STAKE, WBTC)
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
s.App.PoolManagerKeeper.SetParams(s.Ctx, poolManagerParams)
}
5 changes: 4 additions & 1 deletion app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
appKeepers.keys[txfeestypes.StoreKey],
appKeepers.PoolManagerKeeper,
appKeepers.GAMMKeeper,
appKeepers.ProtoRevKeeper,
appKeepers.DistrKeeper,
)
appKeepers.TxFeesKeeper = &txFeesKeeper

Expand Down Expand Up @@ -509,7 +511,8 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
AddRoute(protorevtypes.RouterKey, protorev.NewProtoRevProposalHandler(*appKeepers.ProtoRevKeeper)).
AddRoute(gammtypes.RouterKey, gamm.NewGammProposalHandler(*appKeepers.GAMMKeeper)).
AddRoute(concentratedliquiditytypes.RouterKey, concentratedliquidity.NewConcentratedLiquidityProposalHandler(*appKeepers.ConcentratedLiquidityKeeper)).
AddRoute(cosmwasmpooltypes.RouterKey, cosmwasmpool.NewCosmWasmPoolProposalHandler(*appKeepers.CosmwasmPoolKeeper))
AddRoute(cosmwasmpooltypes.RouterKey, cosmwasmpool.NewCosmWasmPoolProposalHandler(*appKeepers.CosmwasmPoolKeeper)).
AddRoute(poolmanagertypes.RouterKey, poolmanager.NewPoolManagerProposalHandler(*appKeepers.PoolManagerKeeper))

// The gov proposal types can be individually enabled
if len(wasmEnabledProposals) != 0 {
Expand Down
49 changes: 25 additions & 24 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,30 +98,31 @@ import (
// moduleAccountPermissions defines module account permissions
// TODO: Having to input nil's here is unacceptable, we need a way to automatically derive this.
var moduleAccountPermissions = map[string][]string{
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
ibchookstypes.ModuleName: nil,
icatypes.ModuleName: nil,
icqtypes.ModuleName: nil,
minttypes.ModuleName: {authtypes.Minter, authtypes.Burner},
minttypes.DeveloperVestingModuleAcctName: nil,
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
gammtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
incentivestypes.ModuleName: {authtypes.Minter, authtypes.Burner},
protorevtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
lockuptypes.ModuleName: {authtypes.Minter, authtypes.Burner},
poolincentivestypes.ModuleName: nil,
superfluidtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
txfeestypes.ModuleName: nil,
txfeestypes.NonNativeFeeCollectorName: nil,
wasm.ModuleName: {authtypes.Burner},
tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
valsetpreftypes.ModuleName: {authtypes.Staking},
poolmanagertypes.ModuleName: nil,
cosmwasmpooltypes.ModuleName: nil,
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
ibchookstypes.ModuleName: nil,
icatypes.ModuleName: nil,
icqtypes.ModuleName: nil,
minttypes.ModuleName: {authtypes.Minter, authtypes.Burner},
minttypes.DeveloperVestingModuleAcctName: nil,
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
gammtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
incentivestypes.ModuleName: {authtypes.Minter, authtypes.Burner},
protorevtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
lockuptypes.ModuleName: {authtypes.Minter, authtypes.Burner},
poolincentivestypes.ModuleName: nil,
superfluidtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
txfeestypes.ModuleName: nil,
txfeestypes.NonNativeFeeCollectorForStakingRewardsName: nil,
txfeestypes.NonNativeFeeCollectorForCommunityPoolName: nil,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewer: Bad diff, only diff is these two lines

wasm.ModuleName: {authtypes.Burner},
tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
valsetpreftypes.ModuleName: {authtypes.Staking},
poolmanagertypes.ModuleName: nil,
cosmwasmpooltypes.ModuleName: nil,
}

// appModules return modules to initialize module manager.
Expand Down
3 changes: 2 additions & 1 deletion app/upgrades/v15/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ func CreateUpgradeHandler(
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
poolmanagerParams := poolmanagertypes.NewParams(keepers.GAMMKeeper.GetParams(ctx).PoolCreationFee)
poolmanagerParams := keepers.PoolManagerKeeper.GetParams(ctx)
poolmanagerParams.PoolCreationFee = keepers.GAMMKeeper.GetParams(ctx).PoolCreationFee

keepers.PoolManagerKeeper.SetParams(ctx, poolmanagerParams)
keepers.PacketForwardKeeper.SetParams(ctx, packetforwardtypes.DefaultParams())
Expand Down
3 changes: 2 additions & 1 deletion app/upgrades/v18/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func (s *UpgradeTestSuite) TestUpgrade() {

// Swap
toSwap := sdk.NewCoin(pool.GetToken0(), sdk.NewInt(100))
s.FundAcc(s.TestAccs[0], sdk.NewCoins(toSwap))
_, err = s.App.ConcentratedLiquidityKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], updatedCLPool, toSwap, pool.GetToken1(), sdk.NewInt(1), sdk.ZeroDec())
s.Require().NoError(err)

Expand Down Expand Up @@ -233,7 +234,7 @@ func (suite *UpgradeTestSuite) ensurePreUpgradeDistributionPanics() {
suite.App.ConcentratedLiquidityKeeper.SetParams(suite.Ctx, clParams)

// prepare CL pool with the same denom as pool 3, which is the pool we are testing with
clPool := suite.PrepareConcentratedPoolWithCoins(v17.OSMO, v17.AKTIBCDenom)
clPool := suite.PrepareConcentratedPoolWithCoins(v17.AKTIBCDenom, v17.OSMO)
balancerToCLPoolLink := []gammmigration.BalancerToConcentratedPoolLink{
{
BalancerPoolId: 3,
Expand Down
19 changes: 19 additions & 0 deletions app/upgrades/v19/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package v19

import (
"github.com/osmosis-labs/osmosis/v19/app/upgrades"

store "github.com/cosmos/cosmos-sdk/store/types"
)

// UpgradeName defines the on-chain upgrade name for the Osmosis v18 upgrade.
const UpgradeName = "v19"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{},
Deleted: []string{},
},
}
40 changes: 40 additions & 0 deletions app/upgrades/v19/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package v19

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/osmosis-labs/osmosis/v19/app/keepers"
"github.com/osmosis-labs/osmosis/v19/app/upgrades"
poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
bpm upgrades.BaseAppParamManager,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// Run migrations before applying any other state changes.
// NOTE: DO NOT PUT ANY STATE CHANGES BEFORE RunMigrations().
migrations, err := mm.RunMigrations(ctx, configurator, fromVM)
if err != nil {
return nil, err
}

// Move the current authorized quote denoms from the concentrated liquidity params to the pool manager params.
// This needs to be moved because the pool manager requires access to these denoms to determine if the taker fee should
// be swapped into OSMO or not. The concentrated liquidity module already requires access to the pool manager keeper,
// so the right move in this case is to move this parameter upwards in order to prevent circular dependencies.
// TODO: In v20 upgrade handler, delete this param from the concentrated liquidity params.
currentConcentratedLiquidityParams := keepers.ConcentratedLiquidityKeeper.GetParams(ctx)
defaultPoolManagerParams := poolmanagertypes.DefaultParams()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get the existing params from state instead of getting defaults.

There is also PoolCreationFee. By luck, the default happens to match the mainnet value but might not be the same on testnet.

So let's switch to getting the params so that environment-specific PoolCreationFee is preserved.

Please also add the upgrade unit tests to make that params are updated correctly

defaultPoolManagerParams.AuthorizedQuoteDenoms = currentConcentratedLiquidityParams.AuthorizedQuoteDenoms
defaultPoolManagerParams.TakerFeeParams.DefaultTakerFee = sdk.ZeroDec()
keepers.PoolManagerKeeper.SetParams(ctx, defaultPoolManagerParams)

return migrations, nil
}
}
76 changes: 76 additions & 0 deletions proto/osmosis/poolmanager/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ message Params {
(gogoproto.moretags) = "yaml:\"pool_creation_fee\"",
(gogoproto.nullable) = false
];
// taker_fee_params is the container of taker fee parameters.
TakerFeeParams taker_fee_params = 2 [
(gogoproto.moretags) = "yaml:\"taker_fee_params\"",
(gogoproto.nullable) = false
];
// authorized_quote_denoms is a list of quote denoms that can be used as
// token1 when creating a concentrated pool. We limit the quote assets to a
// small set for the purposes of having convinient price increments stemming
// from tick to price conversion. These increments are in a human readable
// magnitude only for token1 as a quote. For limit orders in the future, this
// will be a desirable property in terms of UX as to allow users to set limit
// orders at prices in terms of token1 (quote asset) that are easy to reason
// about.
repeated string authorized_quote_denoms = 3
[ (gogoproto.moretags) = "yaml:\"authorized_quote_denoms\"" ];
Comment on lines +25 to +34
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewer: As mentioned earlier, this was moved from CL params to here. It was not removed from CL params yet since we migrate in this upgrade, and then next upgrade we can completely remove from CL.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of today, we cannot fully delete parameters from a module. There is also a risk of not updating all instances of using these params from CL to poolmanager, and getting invalid state. Given the timeline, I suggest erroring on the side of caution and just importing the CL keeper into the pool manager

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case we do decide to keep this in poolmanager, please make sure:

  • all current instances are switched to use these params from pool manager
  • set them to empty in the upgrade handler
  • leave detailed comments that these cannot be used
  • create an issue to properly remove them in the future

I still strongly prefer we do not duplicate these even temporarily

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had massive issues importing CL keeper into pool manager with cyclical imports, but if you can figure it out I'm good with switching to this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Let's not block on this. Could you make an issue to remove the param from CL after the upgrade please?

By remove, I mean marking it as reserved in the proto in the next major upgrade

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

// GenesisState defines the poolmanager module's genesis state.
Expand All @@ -28,3 +43,64 @@ message GenesisState {
// pool_routes is the container of the mappings from pool id to pool type.
repeated ModuleRoute pool_routes = 3 [ (gogoproto.nullable) = false ];
}

// TakerFeeParams consolidates the taker fee parameters for the poolmanager.
message TakerFeeParams {
// default_taker_fee is the fee used when creating a new pool that doesn't
// fall under a custom pool taker fee or stableswap taker fee category.
string default_taker_fee = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.customname) = "DefaultTakerFee",
p0mvn marked this conversation as resolved.
Show resolved Hide resolved
(gogoproto.nullable) = false
];
// osmo_taker_fee_distribution defines the distribution of taker fees
// generated in OSMO. As of this writing, it has two catagories:
// - staking_rewards: the percent of the taker fee that gets distributed to
// stakers.
// - community_pool: the percent of the taker fee that gets sent to the
// community pool.
TakerFeeDistributionPercentage osmo_taker_fee_distribution = 2 [
(gogoproto.customname) = "OsmoTakerFeeDistribution",
(gogoproto.nullable) = false
];
// non_osmo_taker_fee_distribution defines the distribution of taker fees
// generated in non-OSMO. As of this writing, it has two categories:
// - staking_rewards: the percent of the taker fee that gets swapped to OSMO
// and then distirbuted to stakers.
// - community_pool: the percent of the taker fee that gets sent to the
// community pool. Note: If the non-OSMO asset is an authorized_quote_denom,
// that denom is sent directly to the community pool. Otherwise, it is
// swapped to the community_pool_denom_to_swap_non_whitelisted_assets_to and
// then sent to the community pool as that denom.
TakerFeeDistributionPercentage non_osmo_taker_fee_distribution = 3 [
(gogoproto.customname) = "NonOsmoTakerFeeDistribution",
(gogoproto.nullable) = false
];
// admin_addresses is a list of addresses that are allowed to set and remove
p0mvn marked this conversation as resolved.
Show resolved Hide resolved
// custom taker fees for denom pairs. Governance also has the ability to set
// and remove custom taker fees for denom pairs, but with the normal
// governance delay.
repeated string admin_addresses = 4
[ (gogoproto.moretags) = "yaml:\"admin_addresses\"" ];
// community_pool_denom_to_swap_non_whitelisted_assets_to is the denom that
// non-whitelisted taker fees will be swapped to before being sent to
// the community pool.
string community_pool_denom_to_swap_non_whitelisted_assets_to = 5
[ (gogoproto.moretags) =
"yaml:\"community_pool_denom_to_swap_non_whitelisted_assets_to\"" ];
}

// TakerFeeDistributionPercentage defines what percent of the taker fee category
// gets distributed to the available categories.
Comment on lines +93 to +94
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these percents or ratios that sum to 1?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

percents, where the total must sum to 1

message TakerFeeDistributionPercentage {
string staking_rewards = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.moretags) = "yaml:\"staking_rewards\"",
(gogoproto.nullable) = false
];
string community_pool = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.moretags) = "yaml:\"community_pool\"",
(gogoproto.nullable) = false
];
}
p0mvn marked this conversation as resolved.
Show resolved Hide resolved
20 changes: 20 additions & 0 deletions proto/osmosis/poolmanager/v1beta1/gov.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";
package osmosis.poolmanager.v1beta1;

import "gogoproto/gogo.proto";
import "osmosis/poolmanager/v1beta1/tx.proto";

option go_package = "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types";

// DenomPairTakerFeeProposal is a type for adding/removing a custom taker fee(s)
// for one or more denom pairs.
message DenomPairTakerFeeProposal {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;

string title = 1;
string description = 2;

repeated osmosis.poolmanager.v1beta1.DenomPairTakerFee denom_pair_taker_fee =
3 [ (gogoproto.nullable) = false ];
}
25 changes: 25 additions & 0 deletions proto/osmosis/poolmanager/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ service Msg {
returns (MsgSplitRouteSwapExactAmountInResponse);
rpc SplitRouteSwapExactAmountOut(MsgSplitRouteSwapExactAmountOut)
returns (MsgSplitRouteSwapExactAmountOutResponse);
rpc SetDenomPairTakerFee(MsgSetDenomPairTakerFee)
returns (MsgSetDenomPairTakerFeeResponse);
}

// ===================== MsgSwapExactAmountIn
Expand Down Expand Up @@ -114,3 +116,26 @@ message MsgSplitRouteSwapExactAmountOutResponse {
(gogoproto.nullable) = false
];
}

// ===================== MsgSetDenomPairTakerFee
message MsgSetDenomPairTakerFee {
option (amino.name) = "osmosis/poolmanager/set-denom-pair-taker-fee";

string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
repeated DenomPairTakerFee denom_pair_taker_fee = 2 [
(gogoproto.moretags) = "yaml:\"denom_pair_taker_fee\"",
(gogoproto.nullable) = false
];
}

message MsgSetDenomPairTakerFeeResponse { bool success = 1; }

message DenomPairTakerFee {
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
string denom0 = 1 [ (gogoproto.moretags) = "yaml:\"denom0\"" ];
string denom1 = 2 [ (gogoproto.moretags) = "yaml:\"denom1\"" ];
string taker_fee = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.moretags) = "yaml:\"taker_fee\"",
(gogoproto.nullable) = false
];
}
Loading