Skip to content

Commit

Permalink
Fix nits.
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentwschau committed Mar 11, 2024
1 parent 603f470 commit d51033f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions protocol/x/subaccounts/keeper/isolated_subaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ func (k Keeper) checkIsolatedSubaccountConstraints(
}

for i, u := range settledUpdates {
_, exists := idOfSettledUpdates[*u.SettledSubaccount.Id]

if exists {
if _, exists := idOfSettledUpdates[*u.SettledSubaccount.Id]; exists {
return false, nil, types.ErrNonUniqueUpdatesSubaccount
}

Expand All @@ -61,7 +59,8 @@ func (k Keeper) checkIsolatedSubaccountConstraints(
// perpetuals. This function assumes the settled subaccount is valid and does not violate the
// the constraints.
// The constraint being checked is:
// - a subaccount with a position in an isolated perpetual cannot have updates other perpetuals
// - a subaccount with a position in an isolated perpetual cannot have updates for other
// perpetuals
// - a subaccount with a position in a non-isolated perpetual cannot have updates for isolated
// perpetuals
// - a subaccount with no positions cannot be updated to have positions in multiple isolated
Expand Down Expand Up @@ -90,6 +89,7 @@ func isValidIsolatedPerpetualUpdates(
if marketType == perptypes.PerpetualMarketType_PERPETUAL_MARKET_TYPE_ISOLATED {
hasIsolatedUpdate = true
isolatedUpdatePerpetualId = perpetualUpdate.PerpetualId
break
}
}

Expand All @@ -109,6 +109,7 @@ func isValidIsolatedPerpetualUpdates(
if marketType == perptypes.PerpetualMarketType_PERPETUAL_MARKET_TYPE_ISOLATED {
isIsolatedSubaccount = true
isolatedPositionPerpetualId = perpetualPosition.PerpetualId
break
}
}

Expand All @@ -130,7 +131,7 @@ func isValidIsolatedPerpetualUpdates(
return types.ViolatesIsolatedSubaccountConstraints, nil
}

// Note we can assume that if `hasIsolatedUpdate` is true, there is only a single perpetual
// Note we can assume that if `hasIsolatedUpdate` is true, there is only a single perpetual
// update for the subaccount, given the above check.
// A subaccount with a perpetual position in an isolated perpetual cannot have an update to
// another isolated perpetual.
Expand Down

0 comments on commit d51033f

Please sign in to comment.