Skip to content

Commit

Permalink
Merge branch 'adam/MsgUnlockAndMigrateSharesToFullRangeConcentratedPo…
Browse files Browse the repository at this point in the history
…sition-audit' into adam/duplicate-price-for-multiple-ticks-patch
  • Loading branch information
czarcas7ic committed May 15, 2023
2 parents b5923f0 + 17f5bde commit 3ace477
Show file tree
Hide file tree
Showing 26 changed files with 815 additions and 451 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-broken-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

- name: Link Checker
id: lychee
uses: lycheeverse/lychee-action@v1.7.0
uses: lycheeverse/lychee-action@v1.8.0
with:
args: --exclude-loopback --verbose --no-progress './**/*.md' './**/*.html'
env:
Expand Down
4 changes: 4 additions & 0 deletions osmomath/decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -887,12 +887,16 @@ func MaxDec(d1, d2 BigDec) BigDec {

// DecEq returns true if two given decimals are equal.
// Intended to be used with require/assert: require.True(t, DecEq(...))
//
//nolint:thelper
func DecEq(t *testing.T, exp, got BigDec) (*testing.T, bool, string, string, string) {
return t, exp.Equal(got), "expected:\t%v\ngot:\t\t%v", exp.String(), got.String()
}

// DecApproxEq returns true if the differences between two given decimals are smaller than the tolerance range.
// Intended to be used with require/assert: require.True(t, DecEq(...))
//
//nolint:thelper
func DecApproxEq(t *testing.T, d1 BigDec, d2 BigDec, tol BigDec) (*testing.T, bool, string, string, string) {
diff := d1.Sub(d2).Abs()
return t, diff.LTE(tol), "expected |d1 - d2| <:\t%v\ngot |d1 - d2| = \t\t%v", tol.String(), diff.String()
Expand Down
2 changes: 2 additions & 0 deletions osmomath/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ func (i BigInt) MarshalAmino() ([]byte, error) { return i.Marshal() }
func (i *BigInt) UnmarshalAmino(bz []byte) error { return i.Unmarshal(bz) }

// intended to be used with require/assert: require.True(IntEq(...))
//
//nolint:thelper
func IntEq(t *testing.T, exp, got BigInt) (*testing.T, bool, string, string, string) {
return t, exp.Equal(got), "expected:\t%v\ngot:\t\t%v", exp.String(), got.String()
}
13 changes: 3 additions & 10 deletions osmoutils/accum/prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,16 @@ const (
positionPrefix = "pos"
)

// formatAccumPrefix returns the key prefix used for any
// accum module values to be stored in the KVStore.
// Returns "accum/{key}" as bytes.
func formatModulePrefixKey(key string) []byte {
return []byte(fmt.Sprintf("%s/%s", modulePrefix, key))
}

// formatAccumPrefix returns the key prefix used
// specifically for accumulator values in the KVStore.
// Returns "accum/acc/{name}" as bytes.
func formatAccumPrefixKey(name string) []byte {
return formatModulePrefixKey(fmt.Sprintf("%s/%s", accumulatorPrefix, name))
return []byte(fmt.Sprintf(modulePrefix+"/"+accumulatorPrefix+"/%s", name))
}

// FormatPositionPrefixKey returns the key prefix used
// specifically for position values in the KVStore.
// Returns "accum/pos/{accumName}/{name}" as bytes.
// Returns "accum/acc/pos/{accumName}/{name}" as bytes.
func FormatPositionPrefixKey(accumName, name string) []byte {
return formatAccumPrefixKey(fmt.Sprintf("%s/%s/%s", positionPrefix, accumName, name))
return []byte(fmt.Sprintf(modulePrefix+"/"+accumulatorPrefix+"/"+positionPrefix+"/%s/%s", accumName, name))
}
5 changes: 3 additions & 2 deletions proto/osmosis/superfluid/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ message MsgUnlockAndMigrateSharesToFullRangeConcentratedPosition {
];
// token_out_mins indicates minimum token to exit Balancer pool with.
repeated cosmos.base.v1beta1.Coin token_out_mins = 4 [
(gogoproto.moretags) = "yaml:\"token_out_min_amounts\"",
(gogoproto.nullable) = false
(gogoproto.moretags) = "yaml:\"token_out_mins\"",
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

Expand Down
4 changes: 2 additions & 2 deletions tests/cl-genesis-positions/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/cosmos/cosmos-sdk v0.47.2
github.com/ignite/cli v0.23.0
github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230503232557-ba905586c111
github.com/osmosis-labs/osmosis/v15 v15.0.0-20230504143153-c7d6a52cd9f5
github.com/osmosis-labs/osmosis/v15 v15.0.0-20230513050746-13c81d83ef0d
github.com/tendermint/tendermint v0.34.26
)

Expand Down Expand Up @@ -101,7 +101,7 @@ require (
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.15.0 // indirect
github.com/prometheus/client_golang v1.15.1 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
Expand Down
10 changes: 4 additions & 6 deletions tests/cl-genesis-positions/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -695,12 +695,10 @@ github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20230326212251-7a2cf2993434 h1:RetE
github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20230326212251-7a2cf2993434/go.mod h1:ss3tUfPTwaa6NsoPZrCR7xOqLqCK0LwoNbc2Q8Zs5/Y=
github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230503232557-ba905586c111 h1:1ahWbf9iF9sxDOjxrHWFaBGLE0nWFdpiX1pqObUaJO8=
github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230503232557-ba905586c111/go.mod h1:a7lhiXRpn8QJ21OhFpaEnUNErTSIafaYpp02q6uI/Dk=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230504001814-1dbcc2079de1 h1:1yzJYsP1bWOX/8/aGA8Mk/UFiU9z/h6LRAr2OezyYQ8=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230504001814-1dbcc2079de1/go.mod h1:hk/o9/kmTSZmZqwXcSrPuwj/gpRMCqbE/d3vj6teL2A=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230510161551-8bf252f26bae h1:I1Cy+GpTPWbVi0lBw9+bS1w42YfQjvXNK9bW4YbHhcs=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230510161551-8bf252f26bae/go.mod h1:hk/o9/kmTSZmZqwXcSrPuwj/gpRMCqbE/d3vj6teL2A=
github.com/osmosis-labs/osmosis/v15 v15.0.0-20230504143153-c7d6a52cd9f5 h1:M4fG/zxok1+9y5SWas1sBzDZWfSbGs7vezE1NF7niCk=
github.com/osmosis-labs/osmosis/v15 v15.0.0-20230504143153-c7d6a52cd9f5/go.mod h1:NEoCQ+jkE0o6CUorEUhRdwdbvXYl5nt4oZeevaEz29o=
github.com/osmosis-labs/osmosis/v15 v15.0.0-20230513050746-13c81d83ef0d h1:8lJNaOABRchMwMO+DoHEGrlrBXlhDloms1GKs/ti8HA=
github.com/osmosis-labs/osmosis/v15 v15.0.0-20230513050746-13c81d83ef0d/go.mod h1:mdvXaHvcLi1Loo2sUF1FPV3RynReBpexO3g3ktEWQA4=
github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230328024000-175ec88e4304 h1:RIrWLzIiZN5Xd2JOfSOtGZaf6V3qEQYg6EaDTAkMnCo=
github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230328024000-175ec88e4304/go.mod h1:yPWoJTj5RKrXKUChAicp+G/4Ni/uVEpp27mi/FF/L9c=
github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230331072320-5d6f6cfa2627 h1:A0SwZgp4bmJFbivYJc8mmVhMjrr3EdUZluBYFke11+w=
Expand Down Expand Up @@ -744,8 +742,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
github.com/prometheus/client_golang v1.15.0 h1:5fCgGYogn0hFdhyhLbw7hEsWxufKtY9klyvdNfFlFhM=
github.com/prometheus/client_golang v1.15.0/go.mod h1:e9yaBhRPU2pPNsZwE+JdQl0KEt1N9XgF6zxWmaC0xOk=
github.com/prometheus/client_golang v1.15.1 h1:8tXpTmJbyH5lydzFPoxSIJ0J46jdh3tylbvM1xCv0LI=
github.com/prometheus/client_golang v1.15.1/go.mod h1:e9yaBhRPU2pPNsZwE+JdQl0KEt1N9XgF6zxWmaC0xOk=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
Expand Down
2 changes: 1 addition & 1 deletion tests/cl-go-client/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.20
require (
github.com/cosmos/cosmos-sdk v0.47.2
github.com/ignite/cli v0.23.0
github.com/osmosis-labs/osmosis/v15 v15.0.0-20230502194055-e465f0b40c14
github.com/osmosis-labs/osmosis/v15 v15.0.0-20230502194055-13c81d83ef0d

)

Expand Down
3 changes: 0 additions & 3 deletions tests/cl-go-client/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,6 @@ github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20230326212251-7a2cf2993434 h1:RetE
github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20230326212251-7a2cf2993434/go.mod h1:ss3tUfPTwaa6NsoPZrCR7xOqLqCK0LwoNbc2Q8Zs5/Y=
github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230503232557-ba905586c111 h1:1ahWbf9iF9sxDOjxrHWFaBGLE0nWFdpiX1pqObUaJO8=
github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230503232557-ba905586c111/go.mod h1:a7lhiXRpn8QJ21OhFpaEnUNErTSIafaYpp02q6uI/Dk=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230504190933-b174397f0bc5 h1:fBzTtgZHxvZkpwlg6YtAsNaexEHYaFZDXsYfPQWu9GE=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230510161551-8bf252f26bae h1:I1Cy+GpTPWbVi0lBw9+bS1w42YfQjvXNK9bW4YbHhcs=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230510161551-8bf252f26bae/go.mod h1:hk/o9/kmTSZmZqwXcSrPuwj/gpRMCqbE/d3vj6teL2A=
github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230328024000-175ec88e4304 h1:RIrWLzIiZN5Xd2JOfSOtGZaf6V3qEQYg6EaDTAkMnCo=
Expand Down Expand Up @@ -731,8 +730,6 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
github.com/prometheus/client_golang v1.15.0 h1:5fCgGYogn0hFdhyhLbw7hEsWxufKtY9klyvdNfFlFhM=
github.com/prometheus/client_golang v1.15.0/go.mod h1:e9yaBhRPU2pPNsZwE+JdQl0KEt1N9XgF6zxWmaC0xOk=
github.com/prometheus/client_golang v1.15.1 h1:8tXpTmJbyH5lydzFPoxSIJ0J46jdh3tylbvM1xCv0LI=
github.com/prometheus/client_golang v1.15.1/go.mod h1:e9yaBhRPU2pPNsZwE+JdQl0KEt1N9XgF6zxWmaC0xOk=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
Expand Down
44 changes: 44 additions & 0 deletions x/concentrated-liquidity/math/precompute.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package math

import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/osmosis-labs/osmosis/osmomath"
)

var (
sdkOneInt = sdk.OneInt()
sdkOneDec = sdk.NewDec(1)
sdkNineDec = sdk.NewDec(9)
sdkTenDec = sdk.NewDec(10)
powersOfTen []sdk.Dec
negPowersOfTen []sdk.Dec

osmomathBigOneDec = osmomath.NewBigDec(1)
osmomathBigTenDec = osmomath.NewBigDec(10)
bigPowersOfTen []osmomath.BigDec
bigNegPowersOfTen []osmomath.BigDec
)

// Set precision multipliers
func init() {
negPowersOfTen = make([]sdk.Dec, sdk.Precision+1)
for i := 0; i <= sdk.Precision; i++ {
negPowersOfTen[i] = sdkOneDec.Quo(sdkTenDec.Power(uint64(i)))
}
// 10^77 < sdk.MaxInt < 10^78
powersOfTen = make([]sdk.Dec, 78)
for i := 0; i <= 77; i++ {
powersOfTen[i] = sdkTenDec.Power(uint64(i))
}

bigNegPowersOfTen = make([]osmomath.BigDec, osmomath.Precision+1)
for i := 0; i <= osmomath.Precision; i++ {
bigNegPowersOfTen[i] = osmomathBigOneDec.Quo(osmomathBigTenDec.PowerInteger(uint64(i)))
}
// 10^308 < osmomath.MaxInt < 10^309
bigPowersOfTen = make([]osmomath.BigDec, 309)
for i := 0; i <= 308; i++ {
bigPowersOfTen[i] = osmomathBigTenDec.PowerInteger(uint64(i))
}
}
27 changes: 11 additions & 16 deletions x/concentrated-liquidity/math/tick.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ import (
"github.com/osmosis-labs/osmosis/v15/x/concentrated-liquidity/types"
)

var (
sdkNineDec = sdk.NewDec(9)
sdkTenDec = sdk.NewDec(10)
)

// TicksToSqrtPrice returns the sqrtPrice for the lower and upper ticks by
// individually calling `TickToSqrtPrice` method.
// Returns error if fails to calculate price.
Expand Down Expand Up @@ -77,7 +72,7 @@ func TickToPrice(tickIndex sdk.Int) (price sdk.Dec, err error) {
if tickIndex.IsNegative() {
// We must decrement the exponentAtCurrentTick when entering the negative tick range in order to constantly step up in precision when going further down in ticks
// Otherwise, from tick 0 to tick -(geometricExponentIncrementDistanceInTicks), we would use the same exponent as the exponentAtPriceOne
exponentAtCurrentTick = exponentAtCurrentTick.Sub(sdk.OneInt())
exponentAtCurrentTick = exponentAtCurrentTick.Sub(sdkOneInt)
}

// Knowing what our exponentAtCurrentTick is, we can then figure out what power of 10 this exponent corresponds to
Expand Down Expand Up @@ -146,16 +141,16 @@ func PriceToTickRoundDown(price sdk.Dec, tickSpacing uint64) (sdk.Int, error) {
// This is because the sdk.Dec.Power function does not support negative exponents
func PowTenInternal(exponent sdk.Int) sdk.Dec {
if exponent.GTE(sdk.ZeroInt()) {
return sdkTenDec.Power(exponent.Uint64())
return powersOfTen[exponent.Int64()]
}
return sdk.OneDec().Quo(sdkTenDec.Power(exponent.Abs().Uint64()))
return negPowersOfTen[-exponent.Int64()]
}

func powTenBigDec(exponent sdk.Int) osmomath.BigDec {
if exponent.GTE(sdk.ZeroInt()) {
return osmomath.NewBigDec(10).PowerInteger(exponent.Uint64())
return bigPowersOfTen[exponent.Int64()]
}
return osmomath.OneDec().Quo(osmomath.NewBigDec(10).PowerInteger(exponent.Abs().Uint64()))
return bigNegPowersOfTen[-exponent.Int64()]
}

// CalculatePriceToTick takes in a price and returns the corresponding tick index.
Expand All @@ -180,23 +175,23 @@ func CalculatePriceToTick(price sdk.Dec) (tickIndex sdk.Int) {
// as well as how many ticks that corresponds to
// In the opposite direction (price < 1), we do the same thing (just decrement the geometric exponent instead of incrementing).
// The only difference is we must reduce the increment distance by a factor of 10.
if price.GT(sdk.OneDec()) {
if price.GT(sdkOneDec) {
for currentPrice.LT(price) {
currentAdditiveIncrementInTicks = powTenBigDec(exponentAtCurrentTick)
maxPriceForCurrentAdditiveIncrementInTicks := osmomath.BigDecFromSDKDec(geometricExponentIncrementDistanceInTicks).Mul(currentAdditiveIncrementInTicks)
currentPrice = currentPrice.Add(maxPriceForCurrentAdditiveIncrementInTicks.SDKDec())
exponentAtCurrentTick = exponentAtCurrentTick.Add(sdk.OneInt())
currentPrice.AddMut(maxPriceForCurrentAdditiveIncrementInTicks.SDKDec())
exponentAtCurrentTick = exponentAtCurrentTick.Add(sdkOneInt)
ticksPassed = ticksPassed.Add(geometricExponentIncrementDistanceInTicks.TruncateInt())
}
} else {
// We must decrement the exponentAtCurrentTick by one when traversing negative ticks in order to constantly step up in precision when going further down in ticks
// Otherwise, from tick 0 to tick -(geometricExponentIncrementDistanceInTicks), we would use the same exponent as the exponentAtPriceOne
exponentAtCurrentTick := exponentAtPriceOne.Sub(sdk.OneInt())
exponentAtCurrentTick := exponentAtPriceOne.Sub(sdkOneInt)
for currentPrice.GT(price) {
currentAdditiveIncrementInTicks = powTenBigDec(exponentAtCurrentTick)
maxPriceForCurrentAdditiveIncrementInTicks := osmomath.BigDecFromSDKDec(geometricExponentIncrementDistanceInTicks).Mul(currentAdditiveIncrementInTicks)
currentPrice = currentPrice.Sub(maxPriceForCurrentAdditiveIncrementInTicks.SDKDec())
exponentAtCurrentTick = exponentAtCurrentTick.Sub(sdk.OneInt())
currentPrice.SubMut(maxPriceForCurrentAdditiveIncrementInTicks.SDKDec())
exponentAtCurrentTick = exponentAtCurrentTick.Sub(sdkOneInt)
ticksPassed = ticksPassed.Sub(geometricExponentIncrementDistanceInTicks.TruncateInt())
}
}
Expand Down
2 changes: 1 addition & 1 deletion x/concentrated-liquidity/swaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (ss *SwapState) updateFeeGrowthGlobal(feeChargeTotal sdk.Dec) {
// We round down here since we want to avoid overdistributing (the "fee charge" refers to
// the total fees that will be accrued to the fee accumulator)
feesAccruedPerUnitOfLiquidity := feeChargeTotal.QuoTruncate(ss.liquidity)
ss.feeGrowthGlobal = ss.feeGrowthGlobal.Add(feesAccruedPerUnitOfLiquidity)
ss.feeGrowthGlobal.AddMut(feesAccruedPerUnitOfLiquidity)
return
}
}
Expand Down
5 changes: 2 additions & 3 deletions x/gamm/types/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ var (
)

func MustGetPoolIdFromShareDenom(denom string) uint64 {
numberStr := strings.TrimLeft(denom, GAMMTokenPrefix)
number, err := strconv.Atoi(numberStr)
number, err := GetPoolIdFromShareDenom(denom)
if err != nil {
panic(err)
}
return uint64(number)
return number
}

func GetPoolIdFromShareDenom(denom string) (uint64, error) {
Expand Down
35 changes: 35 additions & 0 deletions x/superfluid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,41 @@ It then mints concentrated liquidity shares and locks them up for the
staking duration. From there, the normal superfluid delegation logic
is executed.

### Create Full Range Position and Superfluid Delegate

```{.go}
type MsgUnlockAndMigrateSharesToFullRangeConcentratedPosition struct {
Sender string
LockId uint64
SharesToMigrate sdk.Coin
TokenOutMins sdk.Coins
}
```

Upon completion, the following response is given:

```{.go}
type MsgUnlockAndMigrateSharesToFullRangeConcentratedPositionResponse struct {
Amount0 string
Amount1 string
LiquidityCreated sdk.Dec
JoinTime time.Time
}
```

The message starts by determining which migration method to use.
- If underlying lock is superfluid bonded
- `migrateSuperfluidBondedBalancerToConcentrated`
- If underlying lock is superfluid unbonding
- `migrateSuperfluidUnbondingBalancerToConcentrated`
- If underlying lock is not superfluid bonded (vanilla lock)
- `migrateNonSuperfluidLockBalancerToConcentrated`

It then routes to that migration message, which will migrate the gamm lock from
the previous state it was in, to the same state but in the concentrated pool. If
the sharesToMigrate is zero, then the entire lock is migrated. If only a subset
of the shares are migrated, then the remaining shares are left in the gamm pool.

## Epochs

Overall Epoch sequence
Expand Down
9 changes: 9 additions & 0 deletions x/superfluid/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func GetTxCmd() *cobra.Command {
)
osmocli.AddTxCmd(cmd, NewCreateFullRangePositionAndSuperfluidDelegateCmd)
osmocli.AddTxCmd(cmd, NewAddToConcentratedLiquiditySuperfluidPositionCmd)
osmocli.AddTxCmd(cmd, NewUnlockAndMigrateSharesToFullRangeConcentratedPositionCmd)

return cmd
}
Expand Down Expand Up @@ -414,3 +415,11 @@ func NewAddToConcentratedLiquiditySuperfluidPositionCmd() (*osmocli.TxCliDesc, *
Example: "add-to-superfluid-cl-position 10 1000000000uosmo 10000000uion",
}, &types.MsgAddToConcentratedLiquiditySuperfluidPosition{}
}

func NewUnlockAndMigrateSharesToFullRangeConcentratedPositionCmd() (*osmocli.TxCliDesc, *types.MsgUnlockAndMigrateSharesToFullRangeConcentratedPosition) {
return &osmocli.TxCliDesc{
Use: "unlock-and-migrate-to-cl [lock-id] [shares-to-migrate] [token-out-mins]",
Short: "unlock and migrate gamm shares to full range concentrated position",
Example: "unlock-and-migrate-cl 10 25000000000gamm/pool/2 1000000000uosmo,10000000uion",
}, &types.MsgUnlockAndMigrateSharesToFullRangeConcentratedPosition{}
}
2 changes: 1 addition & 1 deletion x/superfluid/keeper/concentrated_liquidity.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (k Keeper) addToConcentratedLiquiditySuperfluidPosition(ctx sdk.Context, ow

// Superfluid undelegate the superfluid delegated position.
// This deletes the connection between the lock and the intermediate account, deletes the synthetic lock, and burns the synthetic osmo.
intermediateAccount, err := k.SuperfluidUndelegateToConcentratedPosition(ctx, owner.String(), lockId)
intermediateAccount, err := k.superfluidUndelegateToConcentratedPosition(ctx, owner.String(), lockId)
if err != nil {
return 0, sdk.Int{}, sdk.Int{}, sdk.Dec{}, 0, err
}
Expand Down
Loading

0 comments on commit 3ace477

Please sign in to comment.