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

Twap: Add twapkeeper wiring #2193

Merged
merged 2 commits into from
Jul 22, 2022
Merged

Twap: Add twapkeeper wiring #2193

merged 2 commits into from
Jul 22, 2022

Conversation

ValarDragon
Copy link
Member

What is the purpose of the change

Extract from #2168 , does the app wiring for twap into the Osmosis app

Brief Changelog

  • Add TwapKeeper to osmosis app
  • Add Twap to v11 upgrade
  • Add GetPoolDenoms() to gamm keeper

Testing and Verifying

Wiring across an upgrade boundary is covered by existing test e2e

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? no
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? needs changelog entry
  • How is the feature or change documented? not applicable, in spec of subsequent logic PR

@ValarDragon ValarDragon requested a review from a team July 22, 2022 16:53
@github-actions github-actions bot added C:app-wiring Changes to the app folder C:x/gamm Changes, features and bugs related to the gamm module. labels Jul 22, 2022
@@ -121,6 +123,7 @@ func appModules(
params.NewAppModule(*app.ParamsKeeper),
app.TransferModule,
gamm.NewAppModule(appCodec, *app.GAMMKeeper, app.AccountKeeper, app.BankKeeper),
twap.NewAppModule(*app.TwapKeeper),
Copy link
Member Author

Choose a reason for hiding this comment

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

Something cool is that with the structure of keeper and module.go being defined in the same file, no other keepers need to be passed in.

Also AppCodec isn't needed in modules that don't serialize interfaces

@github-actions github-actions bot added the C:docs Improvements or additions to documentation label Jul 22, 2022
@ValarDragon ValarDragon merged commit dbb906f into main Jul 22, 2022
@ValarDragon ValarDragon deleted the dev/twap_app_integration branch July 22, 2022 19:44
Copy link
Member

@p0mvn p0mvn left a comment

Choose a reason for hiding this comment

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

LGTM

denoms, err := s.App.GAMMKeeper.GetPoolDenoms(s.Ctx, poolId)
s.Require().NoError(err)

swapIn := sdk.NewCoins(sdk.NewCoin(denoms[0], sdk.NewInt(1000)))
Copy link
Member

Choose a reason for hiding this comment

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

Do you think it would be useful to have these as parameters so that the caller can customize them?

I find that frequently in GAMM tests, we have to hard code some parameters because such test helpers are not customizable.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could let it take MsgSwapExactAmountIn for full control over how the caller wants the swap to behave?

Copy link
Member Author

Choose a reason for hiding this comment

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

The point of this one was to not have to think about anything, I think a second helper that does that would be helpful

TokenIn: swapIn[0],
TokenOutMinAmount: sdk.ZeroInt(),
}
// TODO: switch to message
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 create an issue for this please

@@ -241,6 +244,12 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
appKeepers.AccountKeeper, appKeepers.BankKeeper, appKeepers.DistrKeeper)
appKeepers.GAMMKeeper = &gammKeeper

appKeepers.TwapKeeper = twap.NewKeeper(
Copy link
Member

Choose a reason for hiding this comment

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

Asking to learn - since TWAP has its own keeper why would we not have a separate module for it? Isn't this inconsistent with the cosmos-sdk conventions?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah we can move it to its own module, the way its written this is really just a folder move

@@ -197,6 +198,12 @@ func (k Keeper) DeletePool(ctx sdk.Context, poolId uint64) error {
// return nil
// }

func (k Keeper) GetPoolDenoms(ctx sdk.Context, poolId uint64) ([]string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

godoc please

@@ -197,6 +198,12 @@ func (k Keeper) DeletePool(ctx sdk.Context, poolId uint64) error {
// return nil
// }

func (k Keeper) GetPoolDenoms(ctx sdk.Context, poolId uint64) ([]string, error) {
pool, err := k.GetPoolAndPoke(ctx, poolId)
Copy link
Member

Choose a reason for hiding this comment

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

err check

@@ -197,6 +198,12 @@ func (k Keeper) DeletePool(ctx sdk.Context, poolId uint64) error {
// return nil
// }

func (k Keeper) GetPoolDenoms(ctx sdk.Context, poolId uint64) ([]string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Also, let's make a test for this please with a success and an error case

return &Keeper{storeKey: storeKey, transientKey: transientKey, paramSpace: paramSpace, ammkeeper: ammKeeper}
}

// TODO: make this read from a parameter, or hardcode it.
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 make an issue please

@p0mvn
Copy link
Member

p0mvn commented Jul 22, 2022

I can help with creating issues / PRs for TODOs and comments that are not going to be immediately addressed. @ValarDragon do you mind resolving comments that you're planning on addressing in follow-ups, please? I can take care of the rest


// TODO: make this read from a parameter, or hardcode it.
func (k *Keeper) PruneEpochIdentifier(ctx sdk.Context) string {
return "daily"
Copy link
Member

Choose a reason for hiding this comment

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

Should it be "day" and not "daily" according to the epochs parameter?

Copy link
Member Author

Choose a reason for hiding this comment

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

oh woops, yeah it should

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:app-wiring Changes to the app folder C:docs Improvements or additions to documentation C:x/gamm Changes, features and bugs related to the gamm module.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants