Skip to content

Commit

Permalink
refactor(CL): move multihop to swap router, wire to concentrated liqu…
Browse files Browse the repository at this point in the history
…idity module (osmosis-labs#3128)

* feat/refactor(CL): move multihop to swaprouter, connect to concentrated liquidity

* comments

* godoc for RouteExactAmountOut

* link issues

* delete multihop_test.go

* Update x/swaprouter/router_test.go

Co-authored-by: Adam Tucker <[email protected]>

* Update x/swaprouter/router_test.go

Co-authored-by: Adam Tucker <[email protected]>

* Update x/concentrated-liquidity/pool.go

Co-authored-by: Adam Tucker <[email protected]>

* Update x/gamm/keeper/swap.go

Co-authored-by: Adam Tucker <[email protected]>

Co-authored-by: Adam Tucker <[email protected]>
  • Loading branch information
2 people authored and Ruslan Akhtariev committed Oct 25, 2022
1 parent a053c94 commit 9107d1e
Show file tree
Hide file tree
Showing 17 changed files with 386 additions and 521 deletions.
2 changes: 1 addition & 1 deletion app/apptesting/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func (s *KeeperTestHelper) SwapAndSetSpotPrice(poolId uint64, fromAsset sdk.Coin
coins := sdk.Coins{sdk.NewInt64Coin(fromAsset.Denom, 100000000000000)}
s.FundAcc(acc1, coins)

_, err := s.App.GAMMKeeper.SwapExactAmountOut(
_, err := s.App.GAMMKeeper.SwapExactAmountOutDefaultSwapFee(
s.Ctx,
acc1,
poolId,
Expand Down
2 changes: 1 addition & 1 deletion app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
appKeepers.keys[txfeestypes.StoreKey],
appKeepers.GAMMKeeper,
appKeepers.SwapRouterKeeper,
appKeepers.GAMMKeeper,
txfeestypes.FeeCollectorName,
txfeestypes.NonNativeFeeCollectorName,
Expand Down
6 changes: 6 additions & 0 deletions x/concentrated-liquidity/pool.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package concentrated_liquidity

import (
"errors"
fmt "fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -30,6 +31,11 @@ func (k Keeper) CreateNewConcentratedLiquidityPool(ctx sdk.Context, poolId uint6
return pool, nil
}

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

func priceToTick(price sdk.Dec) sdk.Int {
logOfPrice := osmomath.BigDecFromSDKDec(price).LogBase2()
logInt := osmomath.NewDecWithPrec(10001, 4)
Expand Down
22 changes: 13 additions & 9 deletions x/concentrated-liquidity/swaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,31 @@ package concentrated_liquidity
import (
sdk "github.com/cosmos/cosmos-sdk/types"

swaproutertypes "github.com/osmosis-labs/osmosis/v12/x/swaprouter/types"
gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types"
)

// TODO: godoc
func (k Keeper) MultihopSwapExactAmountIn(
// TODO: spec here and in gamm
func (k Keeper) SwapExactAmountIn(
ctx sdk.Context,
sender sdk.AccAddress,
routes []swaproutertypes.SwapAmountInRoute,
pool gammtypes.PoolI,
tokenIn sdk.Coin,
tokenOutDenom string,
tokenOutMinAmount sdk.Int,
swapFee sdk.Dec,
) (tokenOutAmount sdk.Int, err error) {
return sdk.Int{}, nil
panic("not implemented")
}

// TODO: godoc
func (k Keeper) MultihopSwapExactAmountOut(
// TODO: spec here and in gamm
func (k Keeper) SwapExactAmountOut(
ctx sdk.Context,
sender sdk.AccAddress,
routes []swaproutertypes.SwapAmountOutRoute,
poolI gammtypes.PoolI,
tokenInDenom string,
tokenInMaxAmount sdk.Int,
tokenOut sdk.Coin,
swapFee sdk.Dec,
) (tokenInAmount sdk.Int, err error) {
return sdk.Int{}, nil
panic("not implemented")
}
142 changes: 0 additions & 142 deletions x/gamm/keeper/multihop.go

This file was deleted.

Loading

0 comments on commit 9107d1e

Please sign in to comment.