-
Notifications
You must be signed in to change notification settings - Fork 611
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
Add local cache inside the takerfee #8148
Changes from all commits
0bced61
16543ba
74b693d
17f918b
3cd99a5
ef97dc5
5327f96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,9 @@ type Keeper struct { | |
poolModules []types.PoolModuleI | ||
|
||
paramSpace paramtypes.Subspace | ||
|
||
defaultTakerFeeBz []byte | ||
defaultTakerFeeVal sdk.Dec | ||
Comment on lines
+45
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Initialization of new fields in The new fields |
||
} | ||
|
||
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 { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/v25/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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto here for the value for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intended to be nil! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is still wrong though, which was highlighted as I was stepping through with debugger. Don't we want to set k.defaultTakerFeeBz to defaultTakerFeeBz at the end? Otherwise this will always hit the if statement. Its not "wrong", but we are forced to unmarshal the value every time which defeats the purpose. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yes, whoops |
||
var defaultTakerFeeValue sdk.Dec | ||
err := json.Unmarshal(defaultTakerFeeBz, &defaultTakerFeeValue) | ||
if err != nil { | ||
defaultTakerFeeValue = sdk.ZeroDec() | ||
} | ||
k.defaultTakerFeeBz = defaultTakerFeeBz | ||
ValarDragon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
k.defaultTakerFeeVal = defaultTakerFeeValue | ||
} | ||
return k.defaultTakerFeeVal | ||
} | ||
|
||
// SetDenomPairTakerFee sets the taker fee for the given trading pair. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to initialize this value somewhere right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no its intended to be set to nil until initialization!