Skip to content

Commit

Permalink
Don't load all params (#7074)
Browse files Browse the repository at this point in the history
  • Loading branch information
ValarDragon authored Dec 12, 2023
1 parent acb26bd commit 5cea95c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 9 additions & 2 deletions x/poolmanager/taker_fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,21 @@ import (
txfeestypes "github.com/osmosis-labs/osmosis/v21/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
}

// SetDenomPairTakerFee sets the taker fee for the given trading pair.
// If the taker fee for this denom pair matches the default taker fee, then
// it is deleted from state.
func (k Keeper) SetDenomPairTakerFee(ctx sdk.Context, denom0, denom1 string, takerFee osmomath.Dec) {
store := ctx.KVStore(k.storeKey)
// if given taker fee is equal to the default taker fee,
// delete whatever we have in current state to use default taker fee.
if takerFee.Equal(k.GetParams(ctx).TakerFeeParams.DefaultTakerFee) {
// TODO: This logic is actually wrong imo, where it can be valid to set an override over the default.
if takerFee.Equal(k.GetDefaultTakerFee(ctx)) {
store.Delete(types.FormatDenomTradePairKey(denom0, denom1))
return
} else {
Expand Down Expand Up @@ -71,7 +78,7 @@ func (k Keeper) GetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string) (
return osmomath.Dec{}, err
}
if !found {
return k.GetParams(ctx).TakerFeeParams.DefaultTakerFee, nil
return k.GetDefaultTakerFee(ctx), nil
}

return takerFee.Dec, nil
Expand Down
4 changes: 3 additions & 1 deletion x/protorev/keeper/rebalance.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/osmosis-labs/osmosis/v21/x/protorev/types"
)

var zeroInt = osmomath.ZeroInt()

// IterateRoutes checks the profitability of every single route that is passed in
// and returns the optimal route if there is one
func (k Keeper) IterateRoutes(ctx sdk.Context, routes []RouteMetaData, remainingTxPoolPoints, remainingBlockPoolPoints *uint64) (sdk.Coin, osmomath.Int, poolmanagertypes.SwapAmountInRoutes) {
Expand All @@ -30,7 +32,7 @@ func (k Keeper) IterateRoutes(ctx sdk.Context, routes []RouteMetaData, remaining
}

// If the profit is greater than zero, then we convert the profits to uosmo and compare profits in terms of uosmo
if profit.GT(osmomath.ZeroInt()) {
if profit.GT(zeroInt) {
profit, err := k.ConvertProfits(ctx, inputCoin, profit)
if err != nil {
k.Logger(ctx).Error("Error converting profits: " + err.Error())
Expand Down

0 comments on commit 5cea95c

Please sign in to comment.