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

[CL][Swap Router Module]: refactor simulation hack #3087

Closed
p0mvn opened this issue Oct 21, 2022 · 5 comments
Closed

[CL][Swap Router Module]: refactor simulation hack #3087

p0mvn opened this issue Oct 21, 2022 · 5 comments
Assignees
Labels
C:x/swap-router F: concentrated-liquidity Tracking the development of concentrated liquidity feature to improve filtering on the project board T:task ⚙️ A task belongs to a story

Comments

@p0mvn
Copy link
Member

p0mvn commented Oct 21, 2022

Background

In #3073, we ported swap messages from gamm to swap-router.

Additionally, we ported pre-existing simulation

Pre-existing setup for simulation requires access to several gamm keeper APIs.

Current simulation utility functions do not provide support to wire additional keepers. As a result, extra keeper methods were defined on swaprouter keeper to route the calls to gamm keeper internally.

// SimulationExtension defines the swap simulation extension.
// TODO: refactor simulator setup logic to avoid having to define these
// extra methods just for the simulation.
type SimulationExtension interface {
SwapI
GetPoolAndPoke(ctx sdk.Context, poolId uint64) (gammtypes.TraditionalAmmInterface, error)
GetNextPoolId(ctx sdk.Context) uint64
}

We should refactor simulator API to provide the ability for wiring additional keepers to avoid this issue.

Suggested Design

  • Remove GetPoolId from swaprouter
  • Remove GetNextPoolId from `swaprouter
  • Remove SimulatorExtension
  • Make gammKeeper in swaprouter keeper to be of type SwapI
  • Refactor simulator logic to support wiring additional keepers
  • wire up gamm keeper in swaprouter simulator

Acceptance Criteria

  • suggested design implemented
  • simulator `swaprouter tests work
  • tests pass
@p0mvn p0mvn added T:task ⚙️ A task belongs to a story F: concentrated-liquidity Tracking the development of concentrated liquidity feature to improve filtering on the project board labels Oct 21, 2022
@osmo-bot osmo-bot moved this to Needs Review 🔍 in Osmosis Chain Development Oct 21, 2022
@p0mvn
Copy link
Member Author

p0mvn commented Oct 24, 2022

@rusakh said that he's on it. Can you self-assign please?

@ValarDragon
Copy link
Member

I don't understand, the simulator already supports this? This shouldn't require any scaffolding or simulator changes?

All you'd have to do is add the other keepers to the AppModule in the case of simulator being ran, and then link the keeper in the call to getting the actions?

@p0mvn
Copy link
Member Author

p0mvn commented Oct 24, 2022

I think you are right and that is possible without additional changes, just not very intuitive.

@rusakh suggested this method:

We are thinking of creating a wrapper around swaprouters' keeper which will export all keepers, something like this:

type SimulationTest struct {
    swaprouter.Keeper
    GammKeeper gammkeeper.Keeper
}

and then to use this struct in simulations

func RandomSwapExactAmountIn(k swaprouter.Keeper SimulationTest, sim *simtypes.SimCtx, ctx sdk.Context) (*types.MsgSwapExactAmountIn, error) { (edited) 

and other functions as well

@pysel
Copy link
Member

pysel commented Oct 25, 2022

I don't understand, the simulator already supports this? This shouldn't require any scaffolding or simulator changes?

All you'd have to do is add the other keepers to the AppModule in the case of simulator being ran, and then link the keeper in the call to getting the actions?

But if we simply include new keepers in AppModule we will not be able to access them in simulations because AppModule does not export them, right? I thought we were trying to make all the logic of other keepers and swaprouter keeper available in one place (which I called SimulationKeeper or SimulationTest in Roman's comment) to be used in simulations. The reason for that is that with this approach we do not need to multiple these entities (SimulationExtensions) for each new keeper included.

I might be wrong and might not understand something correctly, but I think we would actually need to implement SimulationKeeper abstract. If I am wrong, please, I would really appreciate any corrections.

@p0mvn
Copy link
Member Author

p0mvn commented Nov 1, 2022

Can we supply the gamm keeper to swaprouter AppModule here?

swaproutermodule.NewAppModule(*app.SwapRouterKeeper),

@p0mvn p0mvn closed this as completed Nov 3, 2022
Repository owner moved this from Needs Review 🔍 to Done ✅ in Osmosis Chain Development Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:x/swap-router F: concentrated-liquidity Tracking the development of concentrated liquidity feature to improve filtering on the project board T:task ⚙️ A task belongs to a story
Projects
Archived in project
Development

No branches or pull requests

3 participants