diff --git a/proto/osmosis/concentrated-liquidity/tx.proto b/proto/osmosis/concentrated-liquidity/tx.proto index 2df25a94f60..930d8e6d1cd 100644 --- a/proto/osmosis/concentrated-liquidity/tx.proto +++ b/proto/osmosis/concentrated-liquidity/tx.proto @@ -12,6 +12,11 @@ service Msg { rpc CreatePosition(MsgCreatePosition) returns (MsgCreatePositionResponse); rpc WithdrawPosition(MsgWithdrawPosition) returns (MsgWithdrawPositionResponse); + // AddToPosition attempts to add amount0 and amount1 to a position + // with the given position id. + // To maintain backwards-compatibility with future implementations of + // charging, this function deletes the old position and creates a new one with + // the resulting amount after addition. rpc AddToPosition(MsgAddToPosition) returns (MsgAddToPositionResponse); rpc CollectFees(MsgCollectFees) returns (MsgCollectFeesResponse); rpc CollectIncentives(MsgCollectIncentives) @@ -80,12 +85,34 @@ message MsgCreatePositionResponse { message MsgAddToPosition { uint64 position_id = 1 [ (gogoproto.moretags) = "yaml:\"position_id\"" ]; string sender = 2 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; - cosmos.base.v1beta1.Coin token_desired0 = 3 [ - (gogoproto.moretags) = "yaml:\"token_desired0\"", + // amount0 represents the amount of token0 willing to put in. + string amount0 = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"amount_0\"", + (gogoproto.nullable) = false + ]; + // amount1 represents the amount of token1 willing to put in. + string amount1 = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"amount1\"", (gogoproto.nullable) = false ]; - cosmos.base.v1beta1.Coin token_desired1 = 4 [ - (gogoproto.moretags) = "yaml:\"token_desired1\"", + // token_min_amount0 represents the minimum amount of token0 desired from the + // new position being created. Note that this field indicates the min amount0 + // corresponding to the total liquidity of the position, not just the + // liquidity that is being added. + string token_min_amount0 = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"token_min_amount0\"", + (gogoproto.nullable) = false + ]; + // token_min_amount1 represents the minimum amount of token1 desired from the + // new position being created. Note that this field indicates the min amount1 + // corresponding to the total liquidity of the position, not just the + // liquidity that is being added. + string token_min_amount1 = 6 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"token_min_amount1\"", (gogoproto.nullable) = false ]; } diff --git a/x/concentrated-liquidity/export_test.go b/x/concentrated-liquidity/export_test.go index a3e8a9e98d2..d67a6948ea2 100644 --- a/x/concentrated-liquidity/export_test.go +++ b/x/concentrated-liquidity/export_test.go @@ -218,8 +218,8 @@ func (k Keeper) CreatePosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddr return k.createPosition(ctx, poolId, owner, tokensProvided, amount0Min, amount1Min, lowerTick, upperTick) } -func (k Keeper) AddToPosition(ctx sdk.Context, owner sdk.AccAddress, positionId uint64, amount0Added, amount1Added sdk.Int) (uint64, sdk.Int, sdk.Int, error) { - return k.addToPosition(ctx, owner, positionId, amount0Added, amount1Added) +func (k Keeper) AddToPosition(ctx sdk.Context, owner sdk.AccAddress, positionId uint64, amount0Added, amount1Added, amount0Min, amount1Min sdk.Int) (uint64, sdk.Int, sdk.Int, error) { + return k.addToPosition(ctx, owner, positionId, amount0Added, amount1Added, amount0Min, amount1Min) } func (ss *SwapState) UpdateFeeGrowthGlobal(feeChargeTotal sdk.Dec) { diff --git a/x/concentrated-liquidity/lp.go b/x/concentrated-liquidity/lp.go index b8ad381fd58..6a2a2d76f0e 100644 --- a/x/concentrated-liquidity/lp.go +++ b/x/concentrated-liquidity/lp.go @@ -252,13 +252,16 @@ func (k Keeper) WithdrawPosition(ctx sdk.Context, owner sdk.AccAddress, position // For the sake of backwards-compatibility with future implementations of charging, this function deletes the old position and creates // a new one with the resulting amount after addition. Note that due to truncation after `withdrawPosition`, there is some rounding error // that is upper bounded by 1 unit of the more valuable token. +// Uses the amount0MinGiven,amount1MinGiven as the minimum token out for creating the new position. +// Note that these field indicates the min amount corresponding to the total liquidity of the position, +// not only for the liquidity amount that is being added. +// Uses amounts withdrawn from the original position if provided min amount is zero. // Returns error if // - Withdrawing full position fails // - Creating new position with added liquidity fails // - Position with `positionId` is the last position in the pool // - Position is superfluid staked -// TODO: handle adding to SFS positions -func (k Keeper) addToPosition(ctx sdk.Context, owner sdk.AccAddress, positionId uint64, amount0Added, amount1Added sdk.Int) (uint64, sdk.Int, sdk.Int, error) { +func (k Keeper) addToPosition(ctx sdk.Context, owner sdk.AccAddress, positionId uint64, amount0Added, amount1Added, amount0MinGiven, amount1MinGiven sdk.Int) (uint64, sdk.Int, sdk.Int, error) { position, err := k.GetPosition(ctx, positionId) if err != nil { return 0, sdk.Int{}, sdk.Int{}, err @@ -269,10 +272,15 @@ func (k Keeper) addToPosition(ctx sdk.Context, owner sdk.AccAddress, positionId return 0, sdk.Int{}, sdk.Int{}, types.NotPositionOwnerError{PositionId: positionId, Address: owner.String()} } + // if one of the liquidity is negative, or both liquidity being added is zero, error if amount0Added.IsNegative() || amount1Added.IsNegative() { return 0, sdk.Int{}, sdk.Int{}, types.NegativeAmountAddedError{PositionId: position.PositionId, Asset0Amount: amount0Added, Asset1Amount: amount1Added} } + if amount0Added.IsZero() && amount1Added.IsZero() { + return 0, sdk.Int{}, sdk.Int{}, types.ErrZeroLiquidity + } + // If the position is superfluid staked, return error. // This path is handled separately in the superfluid module. positionHasUnderlyingLock, _, err := k.positionHasActiveUnderlyingLockAndUpdate(ctx, positionId) @@ -306,7 +314,16 @@ func (k Keeper) addToPosition(ctx sdk.Context, owner sdk.AccAddress, positionId return 0, sdk.Int{}, sdk.Int{}, err } tokensProvided := sdk.NewCoins(sdk.NewCoin(pool.GetToken0(), amount0Desired), sdk.NewCoin(pool.GetToken1(), amount1Desired)) - newPositionId, actualAmount0, actualAmount1, _, _, _, _, err := k.createPosition(ctx, position.PoolId, owner, tokensProvided, amount0Withdrawn, amount1Withdrawn, position.LowerTick, position.UpperTick) + minimumAmount0 := amount0Withdrawn + minimumAmount1 := amount1Withdrawn + + if !amount0MinGiven.IsZero() { + minimumAmount0 = amount0MinGiven + } + if !amount1MinGiven.IsZero() { + minimumAmount1 = amount1MinGiven + } + newPositionId, actualAmount0, actualAmount1, _, _, _, _, err := k.createPosition(ctx, position.PoolId, owner, tokensProvided, minimumAmount0, minimumAmount1, position.LowerTick, position.UpperTick) if err != nil { return 0, sdk.Int{}, sdk.Int{}, err } diff --git a/x/concentrated-liquidity/lp_test.go b/x/concentrated-liquidity/lp_test.go index 69568f7bc46..e1ea4c44803 100644 --- a/x/concentrated-liquidity/lp_test.go +++ b/x/concentrated-liquidity/lp_test.go @@ -729,7 +729,6 @@ func (s *KeeperTestSuite) TestWithdrawPosition() { func (s *KeeperTestSuite) TestAddToPosition() { defaultTimeElapsed := time.Hour * 24 - roundingError := sdk.OneInt() invalidSender := s.TestAccs[2] // These amounts are set based on the actual amounts passed in as inputs @@ -821,22 +820,17 @@ func (s *KeeperTestSuite) TestAddToPosition() { amount0ToAdd: amount0PerfectRatio.QuoRaw(2).Add(roundingError), amount1ToAdd: amount1PerfectRatio.QuoRaw(2), }, - - // Error catching - - "error: attempt to add to a position with underlying lock that has finished unlocking": { + "Add to a position with underlying lock that has finished unlocking": { // setup parameters for creating a pool and position. setupConfig: baseCase, // system under test parameters sutConfigOverwrite: &lpTest{ - amount0Expected: amount0PerfectRatio.Add(amount0PerfectRatio).Sub(roundingError), - // Since we round on the other the asset when we withdraw, asset0 turns into the bottleneck and - // thus we cannot use the full amount of asset1. We calculate the below using the following formula and rounding up: - // amount1 = L * (sqrtPriceUpper - sqrtPriceLower) - // https://www.wolframalpha.com/input?i=3035764327.860030912175533748+*+%2870.710678118654752440+-+67.416615162732695594%29 - amount1Expected: sdk.NewInt(9999998816), - expectedError: types.PositionSuperfluidStakedError{PositionId: uint64(1)}, + // 1998976eth (amount withdrawn with rounded down amounts) + 998977(token amount in) + amount0Expected: sdk.NewInt(2997953), + // tokens Provided for token1 is 9999999999 (amount withdrawn) + 5000000000 = 14999999999usdc. + // we calcualte calc amount1 by using: https://www.wolframalpha.com/input?i=70.728769315114743567+*+212041526.154556192320661969 + amount1Expected: sdk.NewInt(14997436189), }, timeElapsed: defaultTimeElapsed, amount0ToAdd: amount0PerfectRatio, @@ -865,6 +859,58 @@ func (s *KeeperTestSuite) TestAddToPosition() { createLockLocked: true, }, + "error: attempt to add negative amounts for both assets to position": { + // setup parameters for creating a pool and position. + setupConfig: baseCase, + + // system under test parameters + sutConfigOverwrite: &lpTest{ + expectedError: types.NegativeAmountAddedError{PositionId: 1, Asset0Amount: amount0PerfectRatio.Neg(), Asset1Amount: amount1PerfectRatio.Neg()}, + }, + lastPositionInPool: true, + timeElapsed: defaultTimeElapsed, + amount0ToAdd: amount0PerfectRatio.Neg(), + amount1ToAdd: amount1PerfectRatio.Neg(), + }, + "error: attempt to add negative amounts for amount0": { + // setup parameters for creating a pool and position. + setupConfig: baseCase, + + // system under test parameters + sutConfigOverwrite: &lpTest{ + expectedError: types.NegativeAmountAddedError{PositionId: 1, Asset0Amount: amount0PerfectRatio.Neg(), Asset1Amount: amount1PerfectRatio}, + }, + lastPositionInPool: true, + timeElapsed: defaultTimeElapsed, + amount0ToAdd: amount0PerfectRatio.Neg(), + amount1ToAdd: amount1PerfectRatio, + }, + "error: attempt to add negative amounts for amount1": { + // setup parameters for creating a pool and position. + setupConfig: baseCase, + + // system under test parameters + sutConfigOverwrite: &lpTest{ + expectedError: types.NegativeAmountAddedError{PositionId: 1, Asset0Amount: amount0PerfectRatio, Asset1Amount: amount1PerfectRatio.Neg()}, + }, + lastPositionInPool: true, + timeElapsed: defaultTimeElapsed, + amount0ToAdd: amount0PerfectRatio, + amount1ToAdd: amount1PerfectRatio.Neg(), + }, + "error: both amounts are zero": { + // setup parameters for creating a pool and position. + setupConfig: baseCase, + + // system under test parameters + sutConfigOverwrite: &lpTest{ + expectedError: types.ErrZeroLiquidity, + }, + lastPositionInPool: true, + timeElapsed: defaultTimeElapsed, + amount0ToAdd: sdk.ZeroInt(), + amount1ToAdd: sdk.ZeroInt(), + }, "error: attempt to add to a position with underlying lock that is unlocking": { // setup parameters for creating a pool and position. setupConfig: baseCase, @@ -886,22 +932,6 @@ func (s *KeeperTestSuite) TestAddToPosition() { createLockUnlocking: true, }, - "error: final amount less than original amount": { - setupConfig: baseCase, - - // system under test parameters - sutConfigOverwrite: &lpTest{ - amount0Expected: amount0PerfectRatio.Sub(roundingError), - // Since we round on the other the asset when we withdraw, asset0 turns into the bottleneck and - // thus we cannot use the full amount of asset1. We calculate the below using the following formula and rounding up: - // amount1 = L * (sqrtPriceUpper - sqrtPriceLower) - // https://www.wolframalpha.com/input?i=3035764327.860030912175533748+*+%2870.710678118654752440+-+67.416615162732695594%29 - expectedError: types.InsufficientLiquidityCreatedError{Actual: sdk.NewInt(4999996906), Minimum: baseCase.tokensProvided.AmountOf(DefaultCoin1.Denom).Sub(roundingError)}, - }, - timeElapsed: defaultTimeElapsed, - amount0ToAdd: sdk.ZeroInt(), - amount1ToAdd: sdk.ZeroInt(), - }, "error: no position created": { // setup parameters for creation a pool and position. setupConfig: baseCase, @@ -929,53 +959,48 @@ func (s *KeeperTestSuite) TestAddToPosition() { amount0ToAdd: amount0PerfectRatio, amount1ToAdd: amount1PerfectRatio, }, - "error: attempt to add negative asset0 to position": { + "error: not position owner": { // setup parameters for creating a pool and position. - setupConfig: baseCase, + setupConfig: baseCase, + senderNotOwner: true, // system under test parameters sutConfigOverwrite: &lpTest{ - expectedError: types.NegativeAmountAddedError{PositionId: 1, Asset0Amount: amount0PerfectRatio.Neg(), Asset1Amount: amount1PerfectRatio}, + expectedError: types.NotPositionOwnerError{PositionId: 1, Address: invalidSender.String()}, }, - lastPositionInPool: true, - timeElapsed: defaultTimeElapsed, - amount0ToAdd: amount0PerfectRatio.Neg(), - amount1ToAdd: amount1PerfectRatio, + timeElapsed: defaultTimeElapsed, + amount0ToAdd: amount0PerfectRatio, + amount1ToAdd: amount1PerfectRatio, }, - "error: attempt to add negative asset1 to position": { + "error: minimum amount 0 is less than actual amount": { // setup parameters for creating a pool and position. setupConfig: baseCase, // system under test parameters sutConfigOverwrite: &lpTest{ - expectedError: types.NegativeAmountAddedError{PositionId: 1, Asset0Amount: amount0PerfectRatio, Asset1Amount: amount1PerfectRatio.Neg()}, + amount0Minimum: sdk.NewInt(1997960), + expectedError: types.InsufficientLiquidityCreatedError{ + Actual: sdk.NewInt(1997954), + Minimum: sdk.NewInt(1997960), + IsTokenZero: true, + }, }, - lastPositionInPool: true, - timeElapsed: defaultTimeElapsed, - amount0ToAdd: amount0PerfectRatio, - amount1ToAdd: amount1PerfectRatio.Neg(), + timeElapsed: defaultTimeElapsed, + amount0ToAdd: amount0PerfectRatio, + amount1ToAdd: amount1PerfectRatio, }, - "error: attempt to add negative amounts for both assets to position": { + "error: minimum amount 1 is less than actual amount": { // setup parameters for creating a pool and position. setupConfig: baseCase, // system under test parameters sutConfigOverwrite: &lpTest{ - expectedError: types.NegativeAmountAddedError{PositionId: 1, Asset0Amount: amount0PerfectRatio.Neg(), Asset1Amount: amount1PerfectRatio.Neg()}, - }, - lastPositionInPool: true, - timeElapsed: defaultTimeElapsed, - amount0ToAdd: amount0PerfectRatio.Neg(), - amount1ToAdd: amount1PerfectRatio.Neg(), - }, - "error: not position owner": { - // setup parameters for creating a pool and position. - setupConfig: baseCase, - senderNotOwner: true, - - // system under test parameters - sutConfigOverwrite: &lpTest{ - expectedError: types.NotPositionOwnerError{PositionId: 1, Address: invalidSender.String()}, + amount1Minimum: sdk.NewInt(9999998916), + expectedError: types.InsufficientLiquidityCreatedError{ + Actual: sdk.NewInt(9999998816), + Minimum: sdk.NewInt(9999998916), + IsTokenZero: false, + }, }, timeElapsed: defaultTimeElapsed, amount0ToAdd: amount0PerfectRatio, @@ -1005,27 +1030,29 @@ func (s *KeeperTestSuite) TestAddToPosition() { // If a setupConfig is provided, use it to create a pool and position. pool := s.PrepareConcentratedPool() fundCoins := config.tokensProvided + // Fund tokens that is used to create initial position if tc.amount0ToAdd.IsPositive() && tc.amount1ToAdd.IsPositive() { fundCoins = fundCoins.Add(sdk.NewCoins(sdk.NewCoin(ETH, tc.amount0ToAdd), sdk.NewCoin(USDC, tc.amount1ToAdd))...) } s.FundAcc(owner, fundCoins) // Create a position from the parameters in the test case. - var amount0Initial, amount1Initial sdk.Int + var positionId uint64 if tc.createLockLocked { - _, amount0Initial, amount1Initial, _, _, _, err = concentratedLiquidityKeeper.CreateFullRangePositionLocked(s.Ctx, pool.GetId(), owner, fundCoins, tc.timeElapsed) + positionId, _, _, _, _, _, err = concentratedLiquidityKeeper.CreateFullRangePositionLocked(s.Ctx, pool.GetId(), owner, fundCoins, tc.timeElapsed) s.Require().NoError(err) } else if tc.createLockUnlocking { - _, amount0Initial, amount1Initial, _, _, _, err = concentratedLiquidityKeeper.CreateFullRangePositionUnlocking(s.Ctx, pool.GetId(), owner, fundCoins, tc.timeElapsed+time.Hour) + positionId, _, _, _, _, _, err = concentratedLiquidityKeeper.CreateFullRangePositionUnlocking(s.Ctx, pool.GetId(), owner, fundCoins, tc.timeElapsed+time.Hour) s.Require().NoError(err) } else if tc.createLockUnlocked { - _, amount0Initial, amount1Initial, _, _, _, err = concentratedLiquidityKeeper.CreateFullRangePositionUnlocking(s.Ctx, pool.GetId(), owner, fundCoins, tc.timeElapsed-time.Hour) + positionId, _, _, _, _, _, err = concentratedLiquidityKeeper.CreateFullRangePositionUnlocking(s.Ctx, pool.GetId(), owner, fundCoins, tc.timeElapsed-time.Hour) s.Require().NoError(err) } else { - _, amount0Initial, amount1Initial, _, _, _, _, err = concentratedLiquidityKeeper.CreatePosition(s.Ctx, pool.GetId(), owner, config.tokensProvided, sdk.ZeroInt(), sdk.ZeroInt(), DefaultLowerTick, DefaultUpperTick) + positionId, _, _, _, _, _, _, err = concentratedLiquidityKeeper.CreatePosition(s.Ctx, pool.GetId(), owner, config.tokensProvided, sdk.ZeroInt(), sdk.ZeroInt(), DefaultLowerTick, DefaultUpperTick) s.Require().NoError(err) } - preSendBalanceSender := s.App.BankKeeper.GetAllBalances(s.Ctx, owner) + s.Ctx = s.Ctx.WithBlockTime(s.Ctx.BlockTime().Add(tc.timeElapsed)) + preBalanceToken0 := s.App.BankKeeper.GetBalance(s.Ctx, owner, pool.GetToken0()) if !tc.lastPositionInPool { s.FundAcc(s.TestAccs[1], fundCoins) @@ -1038,8 +1065,18 @@ func (s *KeeperTestSuite) TestAddToPosition() { sender = invalidSender } + // now we fund the sender account again for the amount0ToAdd and amount1ToAdd coins. + // only fund coins if the amount is non-negative or else test would panic here + if !tc.amount0ToAdd.IsNegative() { + s.FundAcc(sender, sdk.NewCoins(sdk.NewCoin(ETH, tc.amount0ToAdd))) + } + if !tc.amount1ToAdd.IsNegative() { + s.FundAcc(sender, sdk.NewCoins(sdk.NewCoin(USDC, tc.amount1ToAdd))) + } + // --- System under test --- - newPosId, newAmt0, newAmt1, err := concentratedLiquidityKeeper.AddToPosition(s.Ctx, sender, config.positionId, tc.amount0ToAdd, tc.amount1ToAdd) + newPosId, newAmt0, newAmt1, err := concentratedLiquidityKeeper.AddToPosition(s.Ctx, sender, config.positionId, tc.amount0ToAdd, tc.amount1ToAdd, config.amount0Minimum, config.amount1Minimum) + // config.amount0Minimum if config.expectedError != nil { s.Require().Error(err) s.Require().Equal(sdk.Int{}, newAmt0) @@ -1056,15 +1093,27 @@ func (s *KeeperTestSuite) TestAddToPosition() { // We expect the position ID to be 3 since we have two setup positions s.Require().Equal(uint64(3), newPosId) - // Ensure balances were deducted by the correct amounts - // Note that we subtract rounding error from the initial amount of - // both assets since both are truncated upon withdrawal (so there is at least one - // unit of each left in the pool). - postSendBalanceSender := s.App.BankKeeper.GetAllBalances(s.Ctx, sender) - s.Require().Equal( - sdk.NewCoins(sdk.NewCoin(pool.GetToken0(), config.amount0Expected.Sub(amount0Initial.Sub(roundingError))), sdk.NewCoin(pool.GetToken1(), config.amount1Expected.Sub(amount1Initial.Sub(roundingError)))), - preSendBalanceSender.Sub(postSendBalanceSender), - ) + expectedAmount1Delta := sdk.ZeroInt() + + // delta amount1 only exists if the actual amount from addToPosition is not equivilent to tokens provided. + // delta amount1 is calculated via (amount1 to create initial position) + (amount1 added to position) - (actual amount 1) + if fundCoins.AmountOf(pool.GetToken1()).Add(tc.amount1ToAdd).Sub(newAmt1).GT(sdk.ZeroInt()) { + expectedAmount1Delta = config.tokensProvided.AmountOf(pool.GetToken1()).Add(tc.amount1ToAdd).Sub(newAmt1) + } + + postBalanceToken0 := s.App.BankKeeper.GetBalance(s.Ctx, sender, pool.GetToken0()) + postBalanceToken1 := s.App.BankKeeper.GetBalance(s.Ctx, sender, pool.GetToken1()) + + var errTolerance osmomath.ErrTolerance + errTolerance.AdditiveTolerance = sdk.OneDec() + errTolerance.RoundingDir = osmomath.RoundDown + + s.Require().Equal(0, errTolerance.Compare(preBalanceToken0.Amount, postBalanceToken0.Amount)) + s.Require().Equal(0, errTolerance.Compare(expectedAmount1Delta, postBalanceToken1.Amount.Sub(tc.amount1ToAdd))) + + // now check that old position id has been succesfully deleted + _, err = s.App.ConcentratedLiquidityKeeper.GetPosition(s.Ctx, positionId) + s.Require().Error(err) }) } } diff --git a/x/concentrated-liquidity/math/math.go b/x/concentrated-liquidity/math/math.go index 9d1d608e0f6..58821b41ebe 100644 --- a/x/concentrated-liquidity/math/math.go +++ b/x/concentrated-liquidity/math/math.go @@ -94,6 +94,7 @@ func CalcAmount0Delta(liq, sqrtPriceA, sqrtPriceB sdk.Dec, roundUp bool) sdk.Dec // sqrtPriceB is the larger of sqrtpCur and the nextPrice // CalcAmount1Delta = liq * (sqrtPriceB - sqrtPriceA) func CalcAmount1Delta(liq, sqrtPriceA, sqrtPriceB sdk.Dec, roundUp bool) sdk.Dec { + // make sqrtPriceA the smaller value amongst sqrtPriceA and sqrtPriceB if sqrtPriceA.GT(sqrtPriceB) { sqrtPriceA, sqrtPriceB = sqrtPriceB, sqrtPriceA } diff --git a/x/concentrated-liquidity/msg_server.go b/x/concentrated-liquidity/msg_server.go index 7dab51f4b34..08b488e2a0b 100644 --- a/x/concentrated-liquidity/msg_server.go +++ b/x/concentrated-liquidity/msg_server.go @@ -78,7 +78,14 @@ func (server msgServer) AddToPosition(goCtx context.Context, msg *types.MsgAddTo return nil, err } - positionId, actualAmount0, actualAmount1, err := server.keeper.addToPosition(ctx, sender, msg.PositionId, msg.TokenDesired0.Amount, msg.TokenDesired1.Amount) + if msg.TokenMinAmount0.IsNil() { + msg.TokenMinAmount0 = sdk.ZeroInt() + } + if msg.TokenMinAmount1.IsNil() { + msg.TokenMinAmount1 = sdk.ZeroInt() + } + + positionId, actualAmount0, actualAmount1, err := server.keeper.addToPosition(ctx, sender, msg.PositionId, msg.Amount0, msg.Amount1, msg.TokenMinAmount0, msg.TokenMinAmount1) if err != nil { return nil, err } diff --git a/x/concentrated-liquidity/msg_server_test.go b/x/concentrated-liquidity/msg_server_test.go index 1c3e351193a..1b16b9c0090 100644 --- a/x/concentrated-liquidity/msg_server_test.go +++ b/x/concentrated-liquidity/msg_server_test.go @@ -112,7 +112,6 @@ func (s *KeeperTestSuite) TestCreatePositionMsg() { ctx := s.Ctx baseConfigCopy := *baseCase - fmt.Println(baseConfigCopy.tokensProvided) mergeConfigs(&baseConfigCopy, &tc) tc = baseConfigCopy @@ -191,10 +190,10 @@ func (s *KeeperTestSuite) TestAddToPosition_Events() { s.FundAcc(s.TestAccs[0], sdk.NewCoins(DefaultCoin0, DefaultCoin1)) msg := &types.MsgAddToPosition{ - PositionId: posId, - Sender: s.TestAccs[0].String(), - TokenDesired0: DefaultCoin0, - TokenDesired1: DefaultCoin1, + PositionId: posId, + Sender: s.TestAccs[0].String(), + Amount0: DefaultCoin0.Amount, + Amount1: DefaultCoin1.Amount, } response, err := msgServer.AddToPosition(sdk.WrapSDKContext(s.Ctx), msg) diff --git a/x/concentrated-liquidity/position.go b/x/concentrated-liquidity/position.go index 603427c689c..2baf35e5c2f 100644 --- a/x/concentrated-liquidity/position.go +++ b/x/concentrated-liquidity/position.go @@ -697,6 +697,8 @@ func (k Keeper) PositionHasActiveUnderlyingLock(ctx sdk.Context, positionId uint if lockIsMature { return false, lockId, nil } + + // if the lock id <> position id mapping exists, but the lock is not matured, we consider the lock to have active underlying lock. return true, lockId, nil } @@ -709,8 +711,9 @@ func (k Keeper) positionHasActiveUnderlyingLockAndUpdate(ctx sdk.Context, positi if err != nil { return false, 0, err } + + // Defense in depth check. If we have an active underlying lock but no lock ID, return an error. if hasActiveUnderlyingLock && lockId == 0 { - // Defense in depth check. If we have an active underlying lock but no lock ID, return an error. return false, 0, types.PositionIdToLockNotFoundError{PositionId: positionId} } // If the position does not have an active underlying lock but still has a lock ID associated with it, diff --git a/x/concentrated-liquidity/swaps_test.go b/x/concentrated-liquidity/swaps_test.go index 9f45a2acbc2..2fbb85a8952 100644 --- a/x/concentrated-liquidity/swaps_test.go +++ b/x/concentrated-liquidity/swaps_test.go @@ -1822,7 +1822,6 @@ func (s *KeeperTestSuite) TestComputeAndSwapInAmtGivenOut() { s.Ctx, s.TestAccs[0], pool, test.tokenOut, test.tokenInDenom, test.swapFee, test.priceLimit) - fmt.Println(name, sqrtPrice) if test.expectErr { s.Require().Error(err) } else { diff --git a/x/concentrated-liquidity/types/msgs.go b/x/concentrated-liquidity/types/msgs.go index a07cf0c0f52..0846f6d471c 100644 --- a/x/concentrated-liquidity/types/msgs.go +++ b/x/concentrated-liquidity/types/msgs.go @@ -86,12 +86,17 @@ func (msg MsgAddToPosition) ValidateBasic() error { return fmt.Errorf("Invalid position id (%s)", strconv.FormatUint(msg.PositionId, 10)) } - if !msg.TokenDesired0.IsValid() || !msg.TokenDesired0.IsPositive() { - return fmt.Errorf("Invalid coins (%s)", msg.TokenDesired0.String()) + if msg.Amount0.IsNegative() { + return fmt.Errorf("Amount 0 cannot be negative, given amount: %s", msg.Amount0.String()) } - - if !msg.TokenDesired1.IsValid() || !msg.TokenDesired1.IsPositive() { - return fmt.Errorf("Invalid coins (%s)", msg.TokenDesired1.String()) + if msg.Amount1.IsNegative() { + return fmt.Errorf("Amount 1 cannot be negative, given amount: %s", msg.Amount1.String()) + } + if msg.TokenMinAmount0.IsNegative() { + return fmt.Errorf("Amount 0 cannot be negative, given token min amount: %s", msg.TokenMinAmount0.String()) + } + if msg.TokenMinAmount1.IsNegative() { + return fmt.Errorf("Amount 1 cannot be negative, given token min amount: %s", msg.TokenMinAmount1.String()) } return nil diff --git a/x/concentrated-liquidity/types/tx.pb.go b/x/concentrated-liquidity/types/tx.pb.go index f946a7822c0..086ff89936f 100644 --- a/x/concentrated-liquidity/types/tx.pb.go +++ b/x/concentrated-liquidity/types/tx.pb.go @@ -194,10 +194,22 @@ func (m *MsgCreatePositionResponse) GetUpperTick() int64 { // ===================== MsgAddToPosition type MsgAddToPosition struct { - PositionId uint64 `protobuf:"varint,1,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty" yaml:"position_id"` - Sender string `protobuf:"bytes,2,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - TokenDesired0 types.Coin `protobuf:"bytes,3,opt,name=token_desired0,json=tokenDesired0,proto3" json:"token_desired0" yaml:"token_desired0"` - TokenDesired1 types.Coin `protobuf:"bytes,4,opt,name=token_desired1,json=tokenDesired1,proto3" json:"token_desired1" yaml:"token_desired1"` + PositionId uint64 `protobuf:"varint,1,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty" yaml:"position_id"` + Sender string `protobuf:"bytes,2,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + // amount0 represents the amount of token0 willing to put in. + Amount0 github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=amount0,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount0" yaml:"amount_0"` + // amount1 represents the amount of token1 willing to put in. + Amount1 github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=amount1,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount1" yaml:"amount1"` + // token_min_amount0 represents the minimum amount of token0 desired from the + // new position being created. Note that this field indicates the min amount0 + // corresponding to the total liquidity of the position, not just the + // liquidity that is being added. + TokenMinAmount0 github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=token_min_amount0,json=tokenMinAmount0,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_min_amount0" yaml:"token_min_amount0"` + // token_min_amount1 represents the minimum amount of token1 desired from the + // new position being created. Note that this field indicates the min amount1 + // corresponding to the total liquidity of the position, not just the + // liquidity that is being added. + TokenMinAmount1 github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=token_min_amount1,json=tokenMinAmount1,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_min_amount1" yaml:"token_min_amount1"` } func (m *MsgAddToPosition) Reset() { *m = MsgAddToPosition{} } @@ -247,20 +259,6 @@ func (m *MsgAddToPosition) GetSender() string { return "" } -func (m *MsgAddToPosition) GetTokenDesired0() types.Coin { - if m != nil { - return m.TokenDesired0 - } - return types.Coin{} -} - -func (m *MsgAddToPosition) GetTokenDesired1() types.Coin { - if m != nil { - return m.TokenDesired1 - } - return types.Coin{} -} - type MsgAddToPositionResponse struct { PositionId uint64 `protobuf:"varint,1,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty" yaml:"position_id"` Amount0 github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=amount0,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount0" yaml:"amount0"` @@ -718,76 +716,76 @@ func init() { } var fileDescriptor_1f1fff802923d7db = []byte{ - // 1101 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x58, 0x4d, 0x6f, 0xe3, 0x44, - 0x18, 0xae, 0xd3, 0x92, 0xd2, 0x29, 0xfd, 0x88, 0xdb, 0x6d, 0xb3, 0xde, 0x25, 0xae, 0x06, 0x01, - 0x41, 0x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0xd9, 0x0c, 0x3d, 0x22, 0x14, 0x87, 0x58, - 0xf9, 0x5d, 0x30, 0xdd, 0x21, 0xa4, 0x65, 0x61, 0xb7, 0x2c, 0xad, 0x49, 0xd5, 0xa9, 0x9a, 0xdc, - 0xef, 0xa9, 0xf3, 0x27, 0x76, 0xbb, 0xb5, 0x05, 0xe3, 0x0d, 0x68, 0x16, 0xc3, 0x5f, 0x75, 0x57, - 0x7e, 0x07, 0x14, 0x29, 0xf2, 0x5d, 0x14, 0x94, 0x0b, 0x6b, 0x52, 0x75, 0xa6, 0x56, 0xea, 0xf7, - 0xd4, 0x39, 0xee, 0xcb, 0xed, 0xd0, 0x8c, 0x1d, 0xe4, 0xf7, 0x01, 0x68, 0x91, 0x63, 0x14, 0x58, - 0x0c, 0x3b, 0x07, 0xe5, 0xc9, 0x35, 0xa9, 0x3a, 0x59, 0xbb, 0xd5, 0xef, 0xa9, 0x25, 0xee, 0x9e, - 0xee, 0x41, 0x73, 0x26, 0x5a, 0xec, 0x62, 0xe7, 0x20, 0x44, 0x75, 0x3b, 0x9d, 0x04, 0x35, 0x95, - 0x45, 0xa5, 0x7b, 0xd0, 0x9c, 0x89, 0x16, 0x11, 0x8a, 0x81, 0x05, 0x46, 0x0e, 0x90, 0x4f, 0xad, - 0x4e, 0x40, 0x8e, 0xb0, 0x8b, 0xdc, 0xf2, 0x2b, 0x6b, 0x93, 0xd5, 0xd9, 0xcd, 0xdb, 0x1a, 0x8f, - 0x89, 0x16, 0xc6, 0x24, 0x89, 0xbf, 0xb6, 0x43, 0xb0, 0x5f, 0xdb, 0x38, 0xed, 0xa9, 0x13, 0x3f, - 0xbd, 0x50, 0xab, 0x1e, 0x66, 0xfb, 0xdd, 0xa6, 0xe6, 0x90, 0xb6, 0x1e, 0x07, 0x90, 0xff, 0x59, - 0xa7, 0xee, 0x81, 0xce, 0x4e, 0x3a, 0x88, 0x46, 0x00, 0x6a, 0xce, 0x73, 0x8d, 0x47, 0xb1, 0x84, - 0x7c,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21, 0x34, 0x17, 0x85, 0x8d, 0xe7, 0xd3, 0xcd, 0x34, 0x6c, - 0x71, 0xac, 0x86, 0x9d, 0x1e, 0xae, 0x61, 0xe1, 0xcf, 0x05, 0xb0, 0xd8, 0xa0, 0xde, 0xb6, 0xeb, - 0xee, 0x12, 0x31, 0x89, 0xc6, 0xae, 0xa0, 0x11, 0xa6, 0x92, 0x05, 0x78, 0x17, 0x5b, 0x2e, 0xa2, - 0x38, 0x40, 0xee, 0x46, 0x54, 0x17, 0xff, 0x38, 0x28, 0x5e, 0x8f, 0x13, 0x77, 0x6b, 0xb0, 0x53, - 0x12, 0x38, 0x34, 0xe7, 0x22, 0xc3, 0x83, 0x78, 0x9d, 0x13, 0x30, 0xe2, 0xd2, 0x18, 0x53, 0xc0, - 0xc8, 0x08, 0x18, 0xf0, 0xdb, 0x02, 0x28, 0x67, 0x43, 0xf7, 0xbf, 0x6d, 0x42, 0xf8, 0xa7, 0x04, - 0x96, 0x1a, 0xd4, 0xfb, 0x1c, 0xb3, 0x7d, 0x37, 0xb0, 0x8f, 0x6f, 0xb4, 0x96, 0x18, 0x48, 0x9b, - 0x28, 0x1e, 0x9b, 0xf1, 0x05, 0xeb, 0x23, 0x37, 0xea, 0x6a, 0xb6, 0x51, 0x39, 0x1f, 0x34, 0x17, - 0x84, 0x89, 0x8f, 0x61, 0xf8, 0xab, 0x04, 0xee, 0x5c, 0x72, 0x63, 0x51, 0x02, 0x03, 0x99, 0x94, - 0xfe, 0xc3, 0x4c, 0x16, 0x5e, 0x76, 0x26, 0x8f, 0xc1, 0x7c, 0xf8, 0x70, 0x21, 0xad, 0x16, 0x72, - 0xd8, 0x43, 0x84, 0xa8, 0xbc, 0x05, 0x5e, 0x1b, 0x48, 0x13, 0x2d, 0x4b, 0x6b, 0x93, 0xd5, 0xa9, - 0xda, 0x6a, 0xbf, 0xa7, 0x2e, 0xe5, 0x92, 0x48, 0xa1, 0x39, 0x9b, 0x66, 0x91, 0x8e, 0x90, 0x46, -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xbe, 0x35, 0x3c, 0x6d, 0x16, 0xab, 0xd4, 0xc6, 0xc7, - 0x8a, 0x43, 0x7d, 0x23, 0x81, 0xb9, 0xcc, 0x5b, 0xca, 0xf0, 0xac, 0x17, 0x80, 0xca, 0x27, 0x63, - 0x02, 0xc5, 0x59, 0x9e, 0x4a, 0x60, 0x76, 0x70, 0x3e, 0xde, 0x1b, 0x21, 0xe4, 0x29, 0x4c, 0xf9, - 0x78, 0x2c, 0x98, 0x38, 0xc5, 0x0f, 0x12, 0x28, 0xe5, 0x27, 0xd6, 0x47, 0x23, 0x93, 0xa6, 0x60, - 0x65, 0xe7, 0x1a, 0x60, 0x71, 0xae, 0x1f, 0x25, 0xb0, 0x7a, 0x55, 0x0b, 0x6f, 0x0f, 0x2f, 0x70, - 0x05, 0x85, 0x52, 0xbf, 0x36, 0x45, 0x72, 0xd2, 0xda, 0x17, 0xa7, 0x67, 0x15, 0xe9, 0xf9, 0x59, - 0x45, 0xfa, 0xe3, 0xac, 0x22, 0x3d, 0x3b, 0xaf, 0x4c, 0x3c, 0x3f, 0xaf, 0x4c, 0xfc, 0x76, 0x5e, - 0x99, 0x78, 0x5c, 0x1b, 0x78, 0x8c, 0xc6, 0x72, 0xeb, 0x2d, 0xbb, 0x49, 0x93, 0x85, 0x7e, 0x64, - 0xdc, 0xd3, 0x9f, 0x5c, 0xf9, 0x6f, 0x88, 0xf0, 0x31, 0xdb, 0x2c, 0x46, 0xdf, 0x1e, 0xef, 0xfd, - 0x1d, 0x00, 0x00, 0xff, 0xff, 0x89, 0xf2, 0x29, 0x88, 0xb5, 0x10, 0x00, 0x00, + // 1100 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x58, 0xcf, 0x6f, 0xe3, 0x44, + 0x14, 0xae, 0xdb, 0x6c, 0x4a, 0xa7, 0xf4, 0x47, 0xdc, 0x6e, 0x9b, 0xf5, 0x2e, 0x71,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0xb0, 0x72, 0x9e, 0x58, 0xa4, 0xd2, 0x04, 0xf3, + 0x36, 0x37, 0x23, 0xc7, 0xdc, 0x45, 0x88, 0x1f, 0xe1, 0x5f, 0x5f, 0x9e, 0x5e, 0x8b, 0x1f, 0x66, + 0x37, 0x39, 0xd7, 0x79, 0x38, 0x34, 0xe6, 0x84, 0x21, 0x24, 0x82, 0x5f, 0x83, 0xe5, 0x94, 0xba, + 0x16, 0xbd, 0x19, 0xe3, 0xc3, 0xeb, 0xbb, 0xf9, 0x37, 0x93, 0xe0, 0xce, 0x45, 0xfc, 0x22, 0x01, + 0x07, 0x60, 0x39, 0xbd, 0x01, 0x16, 0xfb, 0xff, 0x9d, 0x86, 0xd7, 0xe3, 0x34, 0xdc, 0xce, 0xa6, + 0x21, 0x0d, 0x02, 0x8d, 0x25, 0x61, 0xee, 0xb9, 0xfa, 0x01, 0x58, 0xde, 0x25, 0xfe, 0x2e, 0xc2, + 0x19, 0xca, 0xc9, 0x11, 0x29, 0x2f, 0x0a, 0x02, 0x8d, 0x25, 0x61, 0x4e, 0x29, 0xe1, 0x13, 0x09, + 0x28, 0x75, 0xea, 0x3e, 0xe8, 0x78, 0x2e, 0xde, 0x3d, 0xde, 0xde, 0xb3, 0x7c, 0x17, 0x39, 0x49, + 0x5f, 0x5d, 0x5b, 0x31, 0xf6, 0x00, 0x1c, 0x7c, 0x08, 0x51, 0x91, 0x2a, 0x58, 0xf0, 0xd0, 0x91, + 0xd9, 0x3f, 0xdb, 0x94, 0x6e, 0xa0, 0xae, 0xf0, 0xc8, 0x19, 0x07, 0x68, 0xcc, 0x79, 0x48, 0xcc, + 0x89, 0x9a, 0xb3, 0xf1, 0x77, 0x1e, 0x4c, 0xd5, 0xa9, 0x2b, 0x7f, 0x2f, 0x81, 0xf9, 0xcc, 0x37, + 0xcf, 0x07, 0xda, 0x50, 0x1f, 0x6a, 0x5a, 0xdf, 0xdb, 0xae, 0x72, 0x7f, 0x5c, 0xa4, 0xb8, 0xda, + 0x0f, 0x12, 0x58, 0xec, 0x9b, 0xe3, 0x9b, 0xc3, 0x87, 0xcd, 0x62, 0x95, 0xea, 0xf8, 0x58, 0x71, + 0xa8, 0x6f, 0x25, 0x30, 0x97, 0x79, 0x19, 0x1b, 0x3e, 0xea, 0x39, 0xa0, 0xf2, 0xf1, 0x98, 0x40, + 0x71, 0x96, 0x27, 0x12, 0x98, 0xed, 0x9d, 0x8f, 0xf7, 0x46, 0x48, 0x79, 0x0a, 0x53, 0x3e, 0x1a, + 0x0b, 0x26, 0x4e, 0xf1, 0xa3, 0x04, 0x0a, 0xfd, 0x13, 0xeb, 0xc3, 0x91, 0x83, 0xa6, 0x60, 0x65, + 0xfb, 0x12, 0x60, 0x71, 0xae, 0x9f, 0x25, 0xb0, 0x3a, 0xa8, 0x85, 0xb7, 0x86, 0x27, 0x18, 0x10, + 0x42, 0xa9, 0x5d, 0x3a, 0x44, 0x72, 0xd2, 0xea, 0x97, 0x27, 0xa7, 0x25, 0xe9, 0xd9, 0x69, 0x49, + 0xfa, 0xf3, 0xb4, 0x24, 0x3d, 0x3d, 0x2b, 0x4d, 0x3c, 0x3b, 0x2b, 0x4d, 0xfc, 0x7e, 0x56, 0x9a, + 0x78, 0x54, 0xed, 0x79, 0x8c, 0xc6, 0x74, 0xeb, 0x4d, 0xab, 0x41, 0x93, 0x85, 0x7e, 0x58, 0xb9, + 0xa7, 0x3f, 0x1e, 0xf8, 0xdf, 0x96, 0xf0, 0x31, 0xdb, 0xc8, 0x47, 0x9f, 0x58, 0xef, 0xfe, 0x13, + 0x00, 0x00, 0xff, 0xff, 0xcc, 0x19, 0x3e, 0xe4, 0x9c, 0x11, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -804,6 +802,11 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { CreatePosition(ctx context.Context, in *MsgCreatePosition, opts ...grpc.CallOption) (*MsgCreatePositionResponse, error) WithdrawPosition(ctx context.Context, in *MsgWithdrawPosition, opts ...grpc.CallOption) (*MsgWithdrawPositionResponse, error) + // AddToPosition attempts to add amount0 and amount1 to a position + // with the given position id. + // To maintain backwards-compatibility with future implementations of + // charging, this function deletes the old position and creates a new one with + // the resulting amount after addition. AddToPosition(ctx context.Context, in *MsgAddToPosition, opts ...grpc.CallOption) (*MsgAddToPositionResponse, error) CollectFees(ctx context.Context, in *MsgCollectFees, opts ...grpc.CallOption) (*MsgCollectFeesResponse, error) CollectIncentives(ctx context.Context, in *MsgCollectIncentives, opts ...grpc.CallOption) (*MsgCollectIncentivesResponse, error) @@ -876,6 +879,11 @@ func (c *msgClient) FungifyChargedPositions(ctx context.Context, in *MsgFungifyC type MsgServer interface { CreatePosition(context.Context, *MsgCreatePosition) (*MsgCreatePositionResponse, error) WithdrawPosition(context.Context, *MsgWithdrawPosition) (*MsgWithdrawPositionResponse, error) + // AddToPosition attempts to add amount0 and amount1 to a position + // with the given position id. + // To maintain backwards-compatibility with future implementations of + // charging, this function deletes the old position and creates a new one with + // the resulting amount after addition. AddToPosition(context.Context, *MsgAddToPosition) (*MsgAddToPositionResponse, error) CollectFees(context.Context, *MsgCollectFees) (*MsgCollectFeesResponse, error) CollectIncentives(context.Context, *MsgCollectIncentives) (*MsgCollectIncentivesResponse, error) @@ -1226,21 +1234,41 @@ func (m *MsgAddToPosition) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l { - size, err := m.TokenDesired1.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { + size := m.TokenMinAmount1.Size() + i -= size + if _, err := m.TokenMinAmount1.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + { + size := m.TokenMinAmount0.Size() + i -= size + if _, err := m.TokenMinAmount0.MarshalTo(dAtA[i:]); err != nil { return 0, err } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.Amount1.Size() i -= size + if _, err := m.Amount1.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } i = encodeVarintTx(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x22 { - size, err := m.TokenDesired0.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { + size := m.Amount0.Size() + i -= size + if _, err := m.Amount0.MarshalTo(dAtA[i:]); err != nil { return 0, err } - i -= size i = encodeVarintTx(dAtA, i, uint64(size)) } i-- @@ -1424,20 +1452,20 @@ func (m *MsgCollectFees) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x12 } if len(m.PositionIds) > 0 { - dAtA5 := make([]byte, len(m.PositionIds)*10) - var j4 int + dAtA3 := make([]byte, len(m.PositionIds)*10) + var j2 int for _, num := range m.PositionIds { for num >= 1<<7 { - dAtA5[j4] = uint8(uint64(num)&0x7f | 0x80) + dAtA3[j2] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j4++ + j2++ } - dAtA5[j4] = uint8(num) - j4++ + dAtA3[j2] = uint8(num) + j2++ } - i -= j4 - copy(dAtA[i:], dAtA5[:j4]) - i = encodeVarintTx(dAtA, i, uint64(j4)) + i -= j2 + copy(dAtA[i:], dAtA3[:j2]) + i = encodeVarintTx(dAtA, i, uint64(j2)) i-- dAtA[i] = 0xa } @@ -1509,20 +1537,20 @@ func (m *MsgCollectIncentives) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x12 } if len(m.PositionIds) > 0 { - dAtA7 := make([]byte, len(m.PositionIds)*10) - var j6 int + dAtA5 := make([]byte, len(m.PositionIds)*10) + var j4 int for _, num := range m.PositionIds { for num >= 1<<7 { - dAtA7[j6] = uint8(uint64(num)&0x7f | 0x80) + dAtA5[j4] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j6++ + j4++ } - dAtA7[j6] = uint8(num) - j6++ + dAtA5[j4] = uint8(num) + j4++ } - i -= j6 - copy(dAtA[i:], dAtA7[:j6]) - i = encodeVarintTx(dAtA, i, uint64(j6)) + i -= j4 + copy(dAtA[i:], dAtA5[:j4]) + i = encodeVarintTx(dAtA, i, uint64(j4)) i-- dAtA[i] = 0xa } @@ -1608,20 +1636,20 @@ func (m *MsgFungifyChargedPositions) MarshalToSizedBuffer(dAtA []byte) (int, err dAtA[i] = 0x12 } if len(m.PositionIds) > 0 { - dAtA9 := make([]byte, len(m.PositionIds)*10) - var j8 int + dAtA7 := make([]byte, len(m.PositionIds)*10) + var j6 int for _, num := range m.PositionIds { for num >= 1<<7 { - dAtA9[j8] = uint8(uint64(num)&0x7f | 0x80) + dAtA7[j6] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j8++ + j6++ } - dAtA9[j8] = uint8(num) - j8++ + dAtA7[j6] = uint8(num) + j6++ } - i -= j8 - copy(dAtA[i:], dAtA9[:j8]) - i = encodeVarintTx(dAtA, i, uint64(j8)) + i -= j6 + copy(dAtA[i:], dAtA7[:j6]) + i = encodeVarintTx(dAtA, i, uint64(j6)) i-- dAtA[i] = 0xa } @@ -1738,9 +1766,13 @@ func (m *MsgAddToPosition) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = m.TokenDesired0.Size() + l = m.Amount0.Size() n += 1 + l + sovTx(uint64(l)) - l = m.TokenDesired1.Size() + l = m.Amount1.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.TokenMinAmount0.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.TokenMinAmount1.Size() n += 1 + l + sovTx(uint64(l)) return n } @@ -2471,9 +2503,9 @@ func (m *MsgAddToPosition) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TokenDesired0", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Amount0", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2483,30 +2515,31 @@ func (m *MsgAddToPosition) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.TokenDesired0.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Amount0.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TokenDesired1", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Amount1", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2516,22 +2549,91 @@ func (m *MsgAddToPosition) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount1.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenMinAmount0", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TokenMinAmount0.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenMinAmount1", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.TokenDesired1.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.TokenMinAmount1.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex