Skip to content

Commit

Permalink
allow max length 1 for linked synth locks
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic committed May 17, 2023
1 parent b71cb15 commit 478aa10
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions x/superfluid/keeper/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,18 +242,18 @@ func (k Keeper) migrateNonSuperfluidLockBalancerToConcentrated(ctx sdk.Context,
// It also returns the underlying synthetic locks of the provided lock, if any exist.
func (k Keeper) routeMigration(ctx sdk.Context, sender sdk.AccAddress, lockId uint64, sharesToMigrate sdk.Coin) (synthLocksBeforeMigration []lockuptypes.SyntheticLock, migrationType MigrationType, err error) {
synthLocksBeforeMigration = k.lk.GetAllSyntheticLockupsByLockup(ctx, lockId)
migrationType = NonSuperfluid

for _, synthLockBeforeMigration := range synthLocksBeforeMigration {
if strings.Contains(synthLockBeforeMigration.SynthDenom, "superbonding") {
migrationType = SuperfluidBonded
}
if strings.Contains(synthLockBeforeMigration.SynthDenom, "superunbonding") {
migrationType = SuperfluidUnbonding
}
if strings.Contains(synthLockBeforeMigration.SynthDenom, "superbonding") && strings.Contains(synthLockBeforeMigration.SynthDenom, "superunbonding") {
return nil, Unsupported, fmt.Errorf("lock %d contains both superfluid bonded and unbonded tokens", lockId)
}
if len(synthLocksBeforeMigration) > 1 {
return nil, Unsupported, fmt.Errorf("lock %d contains more than one synthetic lock", lockId)
}

if strings.Contains(synthLocksBeforeMigration[0].SynthDenom, "superbonding") {
migrationType = SuperfluidBonded
} else if strings.Contains(synthLocksBeforeMigration[0].SynthDenom, "superunbonding") {
migrationType = SuperfluidUnbonding
} else if len(synthLocksBeforeMigration) == 0 {
migrationType = NonSuperfluid
} else {
return nil, Unsupported, fmt.Errorf("lock %d contains an unsupported synthetic lock", lockId)
}

return synthLocksBeforeMigration, migrationType, nil
Expand Down

0 comments on commit 478aa10

Please sign in to comment.