diff --git a/CHANGELOG.md b/CHANGELOG.md index f4f8df90a5e..234718da4cb 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 +* [#8128](https://github.com/osmosis-labs/osmosis/pull/8128) Cache the result for poolmanager.GetPoolModule + +## v25.0.0 + ### State Breaking * [#7935](https://github.com/osmosis-labs/osmosis/pull/7935) Add block sdk and top of block auction from skip-mev @@ -71,6 +75,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased * [#8128](https://github.com/osmosis-labs/osmosis/pull/8128) Cache the result for poolmanager.GetPoolModule +* [#8148](https://github.com/osmosis-labs/osmosis/pull/8148) Remove the deserialization time for GetDefaultTakerFee() ## v24.0.4 diff --git a/x/poolmanager/keeper.go b/x/poolmanager/keeper.go index 15ab0cb892e..4a9de1414c8 100644 --- a/x/poolmanager/keeper.go +++ b/x/poolmanager/keeper.go @@ -34,6 +34,9 @@ type Keeper struct { poolModules []types.PoolModuleI paramSpace paramtypes.Subspace + + defaultTakerFeeBz []byte + defaultTakerFeeVal sdk.Dec } func NewKeeper(storeKey storetypes.StoreKey, paramSpace paramtypes.Subspace, gammKeeper types.PoolModuleI, concentratedKeeper types.PoolModuleI, cosmwasmpoolKeeper types.PoolModuleI, bankKeeper types.BankI, accountKeeper types.AccountI, communityPoolKeeper types.CommunityPoolI, stakingKeeper types.StakingKeeper, protorevKeeper types.ProtorevKeeper) *Keeper { diff --git a/x/poolmanager/taker_fee.go b/x/poolmanager/taker_fee.go index 0ea6982ab72..78724248925 100644 --- a/x/poolmanager/taker_fee.go +++ b/x/poolmanager/taker_fee.go @@ -1,6 +1,8 @@ package poolmanager import ( + "bytes" + "encoding/json" "fmt" sdk "github.com/cosmos/cosmos-sdk/types" @@ -12,10 +14,18 @@ import ( txfeestypes "github.com/osmosis-labs/osmosis/v24/x/txfees/types" ) -func (k Keeper) GetDefaultTakerFee(ctx sdk.Context) sdk.Dec { - var defaultTakerFee sdk.Dec - k.paramSpace.Get(ctx, types.KeyDefaultTakerFee, &defaultTakerFee) - return defaultTakerFee +func (k *Keeper) GetDefaultTakerFee(ctx sdk.Context) sdk.Dec { + defaultTakerFeeBz := k.paramSpace.GetRaw(ctx, types.KeyDefaultTakerFee) + if !bytes.Equal(defaultTakerFeeBz, k.defaultTakerFeeBz) { + var defaultTakerFeeValue sdk.Dec + err := json.Unmarshal(defaultTakerFeeBz, &defaultTakerFeeValue) + if err != nil { + defaultTakerFeeValue = sdk.ZeroDec() + } + k.defaultTakerFeeBz = defaultTakerFeeBz + k.defaultTakerFeeVal = defaultTakerFeeValue + } + return k.defaultTakerFeeVal } // SetDenomPairTakerFee sets the taker fee for the given trading pair.