Skip to content

Commit

Permalink
refactor(CL): move id management and pool creation to swaprouter (#3170)
Browse files Browse the repository at this point in the history
* refactor(CL): move id management and pool creation to swaprouter

* gamm genesis

* try fixing sim

* lint

* basic create test

* fix TestExitPool

* fix gamm queries

* swaprouter genesis test

* Update x/swaprouter/types/params.go

Co-authored-by: Matt, Park <45252226+mattverse@users.noreply.github.com>

* fix tests

* migrations

* remove build tags

* fix e2e

* fix simulation

* Adam's comments

* lint

* migrations

* updates

* Update x/gamm/keeper/pool.go

Co-authored-by: Matt, Park <45252226+mattverse@users.noreply.github.com>

* remove gamm parameters from constructor

* type check early

* move max and min pool assets to swaprouter

* add second test case for create pool

* fix migrations

* lint

* add test

* Add prints

* fix(e2e): various e2e build issues breaking debugging on linux amd64 (#3207)

* fix(e2e): various e2e build issues breaking debugging on linux amd64

* fix test-e2e-debug

* test

* Revert "test"

This reverts commit 6cdca82.

* fix num pools query

* fix query, add e2e test

* skip e2e migration tests

* try fixing migrations

* Update proto/osmosis/gamm/v1beta1/genesis.proto

* remove wrap

* whitelist num pools in swaprouter

* update comment

* regen proto

* try fixing simulation

* query swaprouter in e2e pools

* regen query proto

* remove migrations test

* update proto comment

* configure address

* Update x/swaprouter/keeper.go

Co-authored-by: Adam Tucker <adam@osmosis.team>

* update spec

* remove addressed TODOs

Co-authored-by: Matt, Park <45252226+mattverse@users.noreply.github.com>
Co-authored-by: Dev Ojha <dojha@berkeley.edu>
Co-authored-by: Adam Tucker <adam@osmosis.team>
  • Loading branch information
4 people authored Nov 4, 2022
1 parent f9a994f commit 1f255b5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@ import (

"github.com/osmosis-labs/osmosis/v12/osmomath"
cltypes "github.com/osmosis-labs/osmosis/v12/x/concentrated-liquidity/types"
"github.com/osmosis-labs/osmosis/v12/x/gamm/types"
gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types"
)

// TODO: spec, tests, implementation
func (k Keeper) InitializePool(ctx sdk.Context, pool gammtypes.PoolI, creatorAddress sdk.AccAddress) error {
panic("not implemented")
}

func (k Keeper) CreateNewConcentratedLiquidityPool(ctx sdk.Context, poolId uint64, denom0, denom1 string, currSqrtPrice sdk.Dec, currTick sdk.Int) (Pool, error) {
poolAddr := types.NewPoolAddress(poolId)
denom0, denom1, err := cltypes.OrderInitialPoolDenoms(denom0, denom1)
if err != nil {
return Pool{}, err
}
pool := Pool{
Address: poolAddr.String(),
// TODO: move gammtypes.NewPoolAddress(poolId) to swaproutertypes
Address: gammtypes.NewPoolAddress(poolId).String(),
Id: poolId,
CurrentSqrtPrice: currSqrtPrice,
CurrentTick: currTick,
Expand All @@ -33,7 +38,7 @@ func (k Keeper) CreateNewConcentratedLiquidityPool(ctx sdk.Context, poolId uint6
}

// GetPool returns a pool with a given id.
func (k Keeper) GetPool(ctx sdk.Context, poolId uint64) (types.PoolI, error) {
func (k Keeper) GetPool(ctx sdk.Context, poolId uint64) (gammtypes.PoolI, error) {
return nil, errors.New("not implemented")
}

Expand Down Expand Up @@ -326,7 +331,7 @@ func (k Keeper) CalcInAmtGivenOut(ctx sdk.Context, tokenOut sdk.Coin, tokenInDen
// ApplySwap.
func (k *Keeper) applySwap(ctx sdk.Context, tokenIn sdk.Coin, tokenOut sdk.Coin, poolId uint64, newLiquidity sdk.Dec, newCurrentTick sdk.Int, newCurrentSqrtPrice sdk.Dec) {
// Fixed gas consumption per swap to prevent spam
ctx.GasMeter().ConsumeGas(types.BalancerGasFeeForSwap, "cl pool swap computation")
ctx.GasMeter().ConsumeGas(gammtypes.BalancerGasFeeForSwap, "cl pool swap computation")
pool := k.getPoolbyId(ctx, poolId)

pool.Liquidity = newLiquidity
Expand Down

0 comments on commit 1f255b5

Please sign in to comment.