Skip to content

Commit

Permalink
refactor[CL]: remove freezeDuration as a parameter (#4724)
Browse files Browse the repository at this point in the history
* utilize new position id in position key

* add position id to migration response

* regen proto

* modify withdraw pos in e2e

* cmd order

* avoid store key formatting with fmt.Sprintf

* set default NextPositionId to 1

* lint

* return positionId from CreatePos E2E

* utilize bytes.Buffer to build keys

* Revert "utilize bytes.Buffer to build keys"

This reverts commit 0c1bc13.

* utilize sprintf for key

* remove extra positions logic

* initial push

* regen proto

* Update go.mod

* lints

* fix sim

* add posid to sim collectincentive

* e2e test fix

* lint

* clean up

* remove extra fields

* regen proto

* only use pos id for fees

* update cli and e2e

* fee accum updates

* modify claim to use only positionId

* fix functional fees test

* pool to position id map

* add pool store to delete position

* fix conflicts from main merge

* test updates

* lints / cleanup

* add position Id to create position response

* regen proto

* regen proto

* switch order

* regen proto

* add error comment to collectFees

* move key format to types

* rename to positionFields

* Remove unnecessary test field

* revert refactor to functional fees test

* define custom errors

* remove duplicate events emitted

* correct validatePositionUpdate inputs

* Update x/concentrated-liquidity/position.go

Co-authored-by: Roman <[email protected]>

* update README for KV stores

* other readme updates

* feat: query position by id (added to stargate whitelist) (#4718)

* feat(CL): position by id query (stargate whitelisted)

* fix test

* Update app/upgrades/v15/upgrade_test.go

---------

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

* initial push

* remove position age as input param

* [CL][bugfix] Refactor incentives tests and fix incentive forfeiting bug (#4735)

* link (#4708)

* daily check for broken links (#4712)

* Update README.md

* Create check-broken-links.yml

* Update check-broken-links.yml

* Update check-broken-links.yml

* Update check-broken-links.yml

* Update check-broken-links.yml

* Update check-broken-links.yml

* Update check-broken-links.yml

* Update README.md

* Update AutoStake seed from .net to .com (#4711)

Co-authored-by: AutoStake <[email protected]>

* [tests/e2e]: simplify the logic for adding accounts to genesis sdk side and integrate into e2e (#4706)

* update logic add account genesis

* clean unused package

* golint

* XCS + Registries integration: IBC forward generation using registries (#4694)

* initial attempt at splitting registries. Issues with circular deps

* properly split registries

* added reverse prefix map

* channel validation done by registries

* integrating registry into xcs and fixing the tests

* Printing error context on failure

* full integration with unwrapping

* remove replace

* removed unused deps

* clippy

* x86 bytecode

* fmt after lints

* gofumpt

* fix re-export

* lint

* added test-contract addr

* added missing newline

* remove recovery states

* x86 bytecode

* new bytecode

* added single pool query (#4549)

* added single pool query

* added changelog

* remove empty tests as they are invalid

* removed sender and made reserved

* remove and reserve unused sender

* removed sender

* actually remove sender

* querygen

* move impl to correct file

* more flexible querygen

* Update proto/osmosis/poolmanager/v1beta1/query.proto

Co-authored-by: Matt, Park <[email protected]>

* Update proto/osmosis/poolmanager/v1beta1/query.proto

Co-authored-by: Matt, Park <[email protected]>

* Update proto/osmosis/poolmanager/v1beta1/query.proto

Co-authored-by: Matt, Park <[email protected]>

* Update proto/osmosis/poolmanager/v1beta1/query.proto

Co-authored-by: Matt, Park <[email protected]>

* protos

* added cli

* fixed command parsing

* single line

* lint

* fix cli

* run proto gen

* added whitelisted query

* fix test for v15

---------

Co-authored-by: Matt, Park <[email protected]>

* Revert "[tests/e2e]: simplify the logic for adding accounts to genesis sdk side and integrate into e2e (#4706)" (#4727)

This reverts commit a9725d6.

* ProtoRev: Adding Txs to CLI (#4567)

* init set hot routes cli command

* adding remaining txs

* few more tests

* comments

* Update upgrade_test.go (#4734)

* refactor tests and fix incentive forfeiting bug

* update create position tx

* feat: whitelist poolmanager Pool, CL Params and ClaimableFees queries (#4725)

* feat: whitelist poolmanager Pool, CL Params and ClaimableFees queries

* lint

* conflict

* fix e2e query parsing

* increase gas

---------

Co-authored-by: Ruslan Akhtariev <[email protected]>
Co-authored-by: Master Pi <[email protected]>
Co-authored-by: AutoStake <[email protected]>
Co-authored-by: AutoStake <[email protected]>
Co-authored-by: Nguyen Thanh Nhan <[email protected]>
Co-authored-by: Nicolas Lara <[email protected]>
Co-authored-by: Matt, Park <[email protected]>
Co-authored-by: David Terpay <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Roman <[email protected]>

* refactor collect incentives test

* remove any final references to freezing

* merge main

* add back ParsePositionFromBz

* add comments to test

* add forfeit incentives withdraw test case

* add negative duration validation and test

* clean up

* add back multi-position test

* regen proto

---------

Co-authored-by: czarcas7ic <[email protected]>
Co-authored-by: Roman <[email protected]>
Co-authored-by: alpo <[email protected]>
Co-authored-by: Ruslan Akhtariev <[email protected]>
Co-authored-by: Master Pi <[email protected]>
Co-authored-by: AutoStake <[email protected]>
Co-authored-by: AutoStake <[email protected]>
Co-authored-by: Nguyen Thanh Nhan <[email protected]>
Co-authored-by: Nicolas Lara <[email protected]>
Co-authored-by: Matt, Park <[email protected]>
Co-authored-by: David Terpay <[email protected]>
  • Loading branch information
12 people authored Mar 30, 2023
1 parent 5646436 commit 3e50c8f
Show file tree
Hide file tree
Showing 37 changed files with 1,047 additions and 1,374 deletions.
10 changes: 2 additions & 8 deletions proto/osmosis/concentrated-liquidity/position.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import "gogoproto/gogo.proto";
option go_package = "github.com/osmosis-labs/osmosis/v15/x/concentrated-liquidity/model";

// Position contains position's id, address, pool id, lower tick, upper tick
// join time, freeze duration, and liquidity.
// join time, and liquidity.
message Position {
uint64 position_id = 1 [ (gogoproto.moretags) = "yaml:\"position_id\"" ];
string address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ];
Expand All @@ -25,13 +25,7 @@ message Position {
(gogoproto.stdtime) = true,
(gogoproto.moretags) = "yaml:\"join_time\""
];
google.protobuf.Duration freeze_duration = 7 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.jsontag) = "duration,omitempty",
(gogoproto.moretags) = "yaml:\"freeze_duration\""
];
string liquidity = 8 [
string liquidity = 7 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.moretags) = "yaml:\"liquidity\"",
(gogoproto.nullable) = false
Expand Down
6 changes: 0 additions & 6 deletions proto/osmosis/concentrated-liquidity/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ message MsgCreatePosition {
(gogoproto.moretags) = "yaml:\"token_min_amount1\"",
(gogoproto.nullable) = false
];
google.protobuf.Duration freeze_duration = 9 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.jsontag) = "duration,omitempty",
(gogoproto.moretags) = "yaml:\"freeze_duration\""
];
}

message MsgCreatePositionResponse {
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/configurer/chain/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ func (n *NodeConfig) CreateConcentratedPool(from, denom1, denom2 string, tickSpa
return poolID
}

func (n *NodeConfig) CreateConcentratedPosition(from, lowerTick, upperTick string, token0, token1 string, token0MinAmt, token1MinAmt int64, freezeDuration string, poolId uint64) uint64 {
func (n *NodeConfig) CreateConcentratedPosition(from, lowerTick, upperTick string, token0, token1 string, token0MinAmt, token1MinAmt int64, poolId uint64) uint64 {
n.LogActionF("creating concentrated position")

cmd := []string{"osmosisd", "tx", "concentratedliquidity", "create-position", lowerTick, upperTick, token0, token1, fmt.Sprintf("%d", token0MinAmt), fmt.Sprintf("%d", token1MinAmt), freezeDuration, fmt.Sprintf("--from=%s", from), fmt.Sprintf("--pool-id=%d", poolId), "-o json"}
cmd := []string{"osmosisd", "tx", "concentratedliquidity", "create-position", lowerTick, upperTick, token0, token1, fmt.Sprintf("%d", token0MinAmt), fmt.Sprintf("%d", token1MinAmt), fmt.Sprintf("--from=%s", from), fmt.Sprintf("--pool-id=%d", poolId), "-o json"}
outJson, _, err := n.containerManager.ExecTxCmdWithSuccessString(n.t, n.chainId, n.Name, cmd, "code\":0")
require.NoError(n.t, err)

Expand Down Expand Up @@ -101,7 +101,7 @@ func (n *NodeConfig) StoreWasmCode(wasmFile, from string) {

func (n *NodeConfig) WithdrawPosition(from, liquidityOut string, positionId uint64) {
n.LogActionF("withdrawing liquidity from position")
cmd := []string{"osmosisd", "tx", "concentratedliquidity", "withdraw-position", fmt.Sprint(positionId), liquidityOut, fmt.Sprintf("--from=%s", from)}
cmd := []string{"osmosisd", "tx", "concentratedliquidity", "withdraw-position", fmt.Sprint(positionId), liquidityOut, fmt.Sprintf("--from=%s", from), "--gas=auto", "--gas-prices=0.1uosmo", "--gas-adjustment=1.3"}
_, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd)
require.NoError(n.t, err)
n.LogActionF("successfully withdrew %s liquidity from position %d", liquidityOut, positionId)
Expand Down
21 changes: 10 additions & 11 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,11 @@ func (s *IntegrationTestSuite) TestConcentratedLiquidity() {
s.Require().NoError(err)

var (
denom0 string = "uion"
denom1 string = "uosmo"
tickSpacing uint64 = 1
exponentAtPriceOne int64 = -1
freezeDuration = time.Duration(time.Second)
swapFee = "0.01"
denom0 string = "uion"
denom1 string = "uosmo"
tickSpacing uint64 = 1
exponentAtPriceOne int64 = -1
swapFee = "0.01"
)

// helpers
Expand Down Expand Up @@ -228,15 +227,15 @@ func (s *IntegrationTestSuite) TestConcentratedLiquidity() {
address3 := node.CreateWalletAndFund("addr3", fundTokens)

// Create 2 positions for address1: overlap together, overlap with 2 address3 positions
addr1PosId := node.CreateConcentratedPosition(address1, "[-1200]", "400", fmt.Sprintf("1000%s", denom0), fmt.Sprintf("1000%s", denom1), 0, 0, freezeDuration.String(), poolID)
node.CreateConcentratedPosition(address1, "[-400]", "400", fmt.Sprintf("1000%s", denom0), fmt.Sprintf("1000%s", denom1), 0, 0, freezeDuration.String(), poolID)
addr1PosId := node.CreateConcentratedPosition(address1, "[-1200]", "400", fmt.Sprintf("1000%s", denom0), fmt.Sprintf("1000%s", denom1), 0, 0, poolID)
node.CreateConcentratedPosition(address1, "[-400]", "400", fmt.Sprintf("1000%s", denom0), fmt.Sprintf("1000%s", denom1), 0, 0, poolID)

// Create 1 position for address2: does not overlap with anything, ends at maximum
addr2PosId := node.CreateConcentratedPosition(address2, "2200", fmt.Sprintf("%d", maxTick), fmt.Sprintf("1000%s", denom0), fmt.Sprintf("1000%s", denom1), 0, 0, freezeDuration.String(), poolID)
addr2PosId := node.CreateConcentratedPosition(address2, "2200", fmt.Sprintf("%d", maxTick), fmt.Sprintf("1000%s", denom0), fmt.Sprintf("1000%s", denom1), 0, 0, poolID)

// Create 2 positions for address3: overlap together, overlap with 2 address1 positions, one position starts from minimum
addr3PosId := node.CreateConcentratedPosition(address3, "[-1600]", "[-200]", fmt.Sprintf("1000%s", denom0), fmt.Sprintf("1000%s", denom1), 0, 0, freezeDuration.String(), poolID)
node.CreateConcentratedPosition(address3, fmt.Sprintf("[%d]", minTick), "1400", fmt.Sprintf("1000%s", denom0), fmt.Sprintf("1000%s", denom1), 0, 0, freezeDuration.String(), poolID)
addr3PosId := node.CreateConcentratedPosition(address3, "[-1600]", "[-200]", fmt.Sprintf("1000%s", denom0), fmt.Sprintf("1000%s", denom1), 0, 0, poolID)
node.CreateConcentratedPosition(address3, fmt.Sprintf("[%d]", minTick), "1400", fmt.Sprintf("1000%s", denom0), fmt.Sprintf("1000%s", denom1), 0, 0, poolID)

// get newly created positions
positionsAddress1 := node.QueryConcentratedPositions(address1)
Expand Down
4 changes: 2 additions & 2 deletions x/concentrated-liquidity/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ func NewCreateConcentratedPoolCmd() (*osmocli.TxCliDesc, *clmodel.MsgCreateConce

func NewCreatePositionCmd() (*osmocli.TxCliDesc, *types.MsgCreatePosition) {
return &osmocli.TxCliDesc{
Use: "create-position [lower-tick] [upper-tick] [token-0] [token-1] [token-0-min-amount] [token-1-min-amount] [freeze-duration]",
Use: "create-position [lower-tick] [upper-tick] [token-0] [token-1] [token-0-min-amount] [token-1-min-amount]",
Short: "create or add to existing concentrated liquidity position",
Example: "create-position [-69082] 69082 1000000000uosmo 10000000uion 0 0 24h --pool-id 1 --from val --chain-id osmosis-1",
Example: "create-position [-69082] 69082 1000000000uosmo 10000000uion 0 0 --pool-id 1 --from val --chain-id osmosis-1",
CustomFlagOverrides: poolIdFlagOverride,
Flags: osmocli.FlagDesc{RequiredFlags: []*flag.FlagSet{FlagSetJustPoolId()}},
}, &types.MsgCreatePosition{}
Expand Down
24 changes: 12 additions & 12 deletions x/concentrated-liquidity/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ func (k *Keeper) SwapInAmtGivenOut(ctx sdk.Context, sender sdk.AccAddress, pool
return k.swapInAmtGivenOut(ctx, sender, pool, desiredTokenOut, tokenInDenom, swapFee, priceLimit)
}

func (k Keeper) UpdatePosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, lowerTick, upperTick int64, liquidityDelta sdk.Dec, joinTime time.Time, freezeDuration time.Duration, positionId uint64) (sdk.Int, sdk.Int, error) {
return k.updatePosition(ctx, poolId, owner, lowerTick, upperTick, liquidityDelta, joinTime, freezeDuration, positionId)
func (k Keeper) UpdatePosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, lowerTick, upperTick int64, liquidityDelta sdk.Dec, joinTime time.Time, positionId uint64) (sdk.Int, sdk.Int, error) {
return k.updatePosition(ctx, poolId, owner, lowerTick, upperTick, liquidityDelta, joinTime, positionId)
}

func (k Keeper) InitOrUpdateTick(ctx sdk.Context, poolId uint64, currentTick int64, tickIndex int64, liquidityIn sdk.Dec, upper bool) (err error) {
return k.initOrUpdateTick(ctx, poolId, currentTick, tickIndex, liquidityIn, upper)
}

func (k Keeper) InitOrUpdatePosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, lowerTick, upperTick int64, liquidityDelta sdk.Dec, joinTime time.Time, freezeDuration time.Duration, positionId uint64) (err error) {
return k.initOrUpdatePosition(ctx, poolId, owner, lowerTick, upperTick, liquidityDelta, joinTime, freezeDuration, positionId)
func (k Keeper) InitOrUpdatePosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, lowerTick, upperTick int64, liquidityDelta sdk.Dec, joinTime time.Time, positionId uint64) (err error) {
return k.initOrUpdatePosition(ctx, poolId, owner, lowerTick, upperTick, liquidityDelta, joinTime, positionId)
}

func (k Keeper) PoolExists(ctx sdk.Context, poolId uint64) bool {
Expand Down Expand Up @@ -113,8 +113,8 @@ func ConvertPoolInterfaceToConcentrated(poolI poolmanagertypes.PoolI) (types.Con
return convertPoolInterfaceToConcentrated(poolI)
}

func (k Keeper) SetPosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, lowerTick, upperTick int64, joinTime time.Time, freezeDuration time.Duration, liquidity sdk.Dec, positionId uint64) {
k.setPosition(ctx, poolId, owner, lowerTick, upperTick, joinTime, freezeDuration, liquidity, positionId)
func (k Keeper) SetPosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, lowerTick, upperTick int64, joinTime time.Time, liquidity sdk.Dec, positionId uint64) {
k.setPosition(ctx, poolId, owner, lowerTick, upperTick, joinTime, liquidity, positionId)
}

func (k Keeper) ValidateSwapFee(ctx sdk.Context, params types.Params, swapFee sdk.Dec) bool {
Expand Down Expand Up @@ -162,8 +162,8 @@ func PreparePositionAccumulator(feeAccumulator accum.AccumulatorObject, position
return preparePositionAccumulator(feeAccumulator, positionKey, feeGrowthOutside)
}

func (k Keeper) CreatePosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, amount0Desired, amount1Desired, amount0Min, amount1Min sdk.Int, lowerTick, upperTick int64, freezeDuration time.Duration) (uint64, sdk.Int, sdk.Int, sdk.Dec, time.Time, error) {
return k.createPosition(ctx, poolId, owner, amount0Desired, amount1Desired, amount0Min, amount1Min, lowerTick, upperTick, freezeDuration)
func (k Keeper) CreatePosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, amount0Desired, amount1Desired, amount0Min, amount1Min sdk.Int, lowerTick, upperTick int64) (uint64, sdk.Int, sdk.Int, sdk.Dec, time.Time, error) {
return k.createPosition(ctx, poolId, owner, amount0Desired, amount1Desired, amount0Min, amount1Min, lowerTick, upperTick)
}

func (k Keeper) WithdrawPosition(ctx sdk.Context, owner sdk.AccAddress, positionId uint64, requestedLiquidityAmountToWithdraw sdk.Dec) (amtDenom0, amtDenom1 sdk.Int, err error) {
Expand Down Expand Up @@ -220,8 +220,8 @@ func (k Keeper) GetInitialUptimeGrowthOutsidesForTick(ctx sdk.Context, poolId ui
return k.getInitialUptimeGrowthOutsidesForTick(ctx, poolId, tick)
}

func (k Keeper) InitPositionUptime(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, lowerTick, upperTick int64, liquidityDelta sdk.Dec, joinTime time.Time, freezeDuration time.Duration, positionId uint64) error {
return k.initPositionUptime(ctx, poolId, owner, lowerTick, upperTick, liquidityDelta, joinTime, freezeDuration, positionId)
func (k Keeper) InitOrUpdatePositionUptime(ctx sdk.Context, poolId uint64, position sdk.Dec, owner sdk.AccAddress, lowerTick, upperTick int64, liquidityDelta sdk.Dec, joinTime time.Time, positionId uint64) error {
return k.initOrUpdatePositionUptime(ctx, poolId, position, owner, lowerTick, upperTick, liquidityDelta, joinTime, positionId)
}

func (k Keeper) CollectIncentives(ctx sdk.Context, owner sdk.AccAddress, positionId uint64) (sdk.Coins, error) {
Expand All @@ -240,8 +240,8 @@ func PrepareAccumAndClaimRewards(accum accum.AccumulatorObject, positionKey stri
return prepareAccumAndClaimRewards(accum, positionKey, growthOutside)
}

func (k Keeper) ClaimAllIncentivesForPosition(ctx sdk.Context, positionId uint64, forfeitIncentives bool) (sdk.Coins, error) {
return k.claimAllIncentivesForPosition(ctx, positionId, forfeitIncentives)
func (k Keeper) ClaimAllIncentivesForPosition(ctx sdk.Context, positionId uint64) (sdk.Coins, sdk.Coins, error) {
return k.claimAllIncentivesForPosition(ctx, positionId)
}

func FindUptimeIndex(uptime time.Duration) (int, error) {
Expand Down
30 changes: 9 additions & 21 deletions x/concentrated-liquidity/fees_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ const (

// fields used to identify a fee position.
type positionFields struct {
poolId uint64
owner sdk.AccAddress
lowerTick int64
upperTick int64
freezeDuration time.Duration
positionId uint64
poolId uint64
owner sdk.AccAddress
lowerTick int64
upperTick int64
positionId uint64
}

var (
Expand All @@ -55,7 +54,6 @@ func (s *KeeperTestSuite) TestInitializeFeeAccumulatorPosition() {
defaultAccount,
DefaultLowerTick,
DefaultUpperTick,
DefaultFreezeDuration,
DefaultPositionId,
}
)
Expand Down Expand Up @@ -118,8 +116,7 @@ func (s *KeeperTestSuite) TestInitializeFeeAccumulatorPosition() {
defaultAccount,
DefaultLowerTick,
DefaultUpperTick,
DefaultFreezeDuration,
1,
DefaultPositionId,
},
expectedPass: false,
},
Expand Down Expand Up @@ -593,7 +590,6 @@ func (s *KeeperTestSuite) TestQueryAndCollectFees() {
owner sdk.AccAddress
lowerTick int64
upperTick int64
freezeDuration time.Duration
positionIdToCollectAndQuery uint64

// expectations.
Expand All @@ -617,7 +613,6 @@ func (s *KeeperTestSuite) TestQueryAndCollectFees() {
owner: ownerWithValidPosition,
lowerTick: 0,
upperTick: 1,
freezeDuration: DefaultFreezeDuration,
positionIdToCollectAndQuery: DefaultPositionId,

currentTick: 2,
Expand All @@ -635,7 +630,6 @@ func (s *KeeperTestSuite) TestQueryAndCollectFees() {
owner: ownerWithValidPosition,
lowerTick: 0,
upperTick: 2,
freezeDuration: DefaultFreezeDuration,
positionIdToCollectAndQuery: DefaultPositionId,

currentTick: 3,
Expand All @@ -653,7 +647,6 @@ func (s *KeeperTestSuite) TestQueryAndCollectFees() {
owner: ownerWithValidPosition,
lowerTick: 0,
upperTick: 1,
freezeDuration: DefaultFreezeDuration,
positionIdToCollectAndQuery: DefaultPositionId,

currentTick: 1,
Expand All @@ -678,7 +671,6 @@ func (s *KeeperTestSuite) TestQueryAndCollectFees() {
owner: ownerWithValidPosition,
lowerTick: 0,
upperTick: 1,
freezeDuration: DefaultFreezeDuration,
positionIdToCollectAndQuery: DefaultPositionId,

currentTick: 0,
Expand All @@ -697,7 +689,6 @@ func (s *KeeperTestSuite) TestQueryAndCollectFees() {
owner: ownerWithValidPosition,
lowerTick: 0,
upperTick: 1,
freezeDuration: DefaultFreezeDuration,
positionIdToCollectAndQuery: DefaultPositionId,

currentTick: -1,
Expand All @@ -719,7 +710,6 @@ func (s *KeeperTestSuite) TestQueryAndCollectFees() {
owner: ownerWithValidPosition,
lowerTick: 0,
upperTick: 1,
freezeDuration: DefaultFreezeDuration,
positionIdToCollectAndQuery: DefaultPositionId,

currentTick: 5,
Expand All @@ -738,7 +728,6 @@ func (s *KeeperTestSuite) TestQueryAndCollectFees() {
owner: ownerWithValidPosition,
lowerTick: -10,
upperTick: -4,
freezeDuration: DefaultFreezeDuration,
positionIdToCollectAndQuery: DefaultPositionId,

currentTick: -13,
Expand All @@ -759,7 +748,6 @@ func (s *KeeperTestSuite) TestQueryAndCollectFees() {
owner: s.TestAccs[1], // different owner from the one who initialized the position.
lowerTick: 0,
upperTick: 1,
freezeDuration: DefaultFreezeDuration,
positionIdToCollectAndQuery: DefaultPositionId + 1, // position id does not exist.

currentTick: 2,
Expand All @@ -782,7 +770,7 @@ func (s *KeeperTestSuite) TestQueryAndCollectFees() {
ctx := s.Ctx

// Set the position in store, otherwise querying via position id will fail.
clKeeper.SetPosition(ctx, validPoolId, tc.owner, tc.lowerTick, tc.upperTick, time.Now().UTC(), DefaultFreezeDuration, tc.initialLiquidity, DefaultPositionId)
clKeeper.SetPosition(ctx, validPoolId, tc.owner, tc.lowerTick, tc.upperTick, time.Now().UTC(), tc.initialLiquidity, DefaultPositionId)

s.initializeFeeAccumulatorPositionWithLiquidity(ctx, validPoolId, tc.lowerTick, tc.upperTick, DefaultPositionId, tc.initialLiquidity)

Expand Down Expand Up @@ -894,14 +882,14 @@ func (s *KeeperTestSuite) TestUpdateFeeAccumulatorPosition() {
poolOne := s.PrepareConcentratedPool()

// Setup test case position
s.App.ConcentratedLiquidityKeeper.SetPosition(s.Ctx, poolOne.GetId(), tc.owner, tc.lowerTick, tc.upperTick, time.Now().UTC(), DefaultFreezeDuration, tc.liquidity, tc.positionIdSetup)
s.App.ConcentratedLiquidityKeeper.SetPosition(s.Ctx, poolOne.GetId(), tc.owner, tc.lowerTick, tc.upperTick, time.Now().UTC(), tc.liquidity, tc.positionIdSetup)
err := s.App.ConcentratedLiquidityKeeper.InitializeFeeAccumulatorPosition(s.Ctx, poolOne.GetId(), tc.lowerTick, tc.upperTick, tc.positionIdSetup)
s.Require().NoError(err)

// Setup static position
// Note: setting the position manually here is a hack.
// When we call InitializeFeeAccumulatorPosition, the liquidity gets set to zero.
s.App.ConcentratedLiquidityKeeper.SetPosition(s.Ctx, poolOne.GetId(), tc.owner, tc.lowerTick, tc.upperTick, time.Now().UTC(), DefaultFreezeDuration, tc.liquidity, tc.positionIdSetup+1)
s.App.ConcentratedLiquidityKeeper.SetPosition(s.Ctx, poolOne.GetId(), tc.owner, tc.lowerTick, tc.upperTick, time.Now().UTC(), tc.liquidity, tc.positionIdSetup+1)
err = s.App.ConcentratedLiquidityKeeper.InitializeFeeAccumulatorPosition(s.Ctx, poolOne.GetId(), tc.lowerTick, tc.upperTick, tc.positionIdSetup+1)
s.Require().NoError(err)

Expand Down
2 changes: 1 addition & 1 deletion x/concentrated-liquidity/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState genesis.GenesisState) {
if _, ok := seenPoolIds[position.PoolId]; !ok {
panic(fmt.Sprintf("found position with pool id (%d) but there is no pool with such id that exists", position.PoolId))
}
k.setPosition(ctx, position.PoolId, sdk.MustAccAddressFromBech32(position.Address), position.LowerTick, position.UpperTick, position.JoinTime, position.FreezeDuration, position.Liquidity, position.PositionId)
k.setPosition(ctx, position.PoolId, sdk.MustAccAddressFromBech32(position.Address), position.LowerTick, position.UpperTick, position.JoinTime, position.Liquidity, position.PositionId)
}
}

Expand Down
15 changes: 7 additions & 8 deletions x/concentrated-liquidity/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,13 @@ var (
Info: testTickInfo,
}
testPositionModel = model.Position{
PositionId: 1,
PoolId: 1,
Address: testAddressOne.String(),
Liquidity: sdk.OneDec(),
LowerTick: -1,
UpperTick: 100,
JoinTime: defaultBlockTime,
FreezeDuration: DefaultFreezeDuration,
PositionId: 1,
PoolId: 1,
Address: testAddressOne.String(),
Liquidity: sdk.OneDec(),
LowerTick: -1,
UpperTick: 100,
JoinTime: defaultBlockTime,
}
)

Expand Down
Loading

0 comments on commit 3e50c8f

Please sign in to comment.