From d51033fe799e5ea0de3e46ae92e5211bacaa9ca4 Mon Sep 17 00:00:00 2001 From: Vincent Chau <99756290+vincentwschau@users.noreply.github.com> Date: Mon, 11 Mar 2024 12:08:19 -0400 Subject: [PATCH] Fix nits. --- protocol/x/subaccounts/keeper/isolated_subaccount.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/protocol/x/subaccounts/keeper/isolated_subaccount.go b/protocol/x/subaccounts/keeper/isolated_subaccount.go index 3f8000abff..0424934aea 100644 --- a/protocol/x/subaccounts/keeper/isolated_subaccount.go +++ b/protocol/x/subaccounts/keeper/isolated_subaccount.go @@ -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 } @@ -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 @@ -90,6 +89,7 @@ func isValidIsolatedPerpetualUpdates( if marketType == perptypes.PerpetualMarketType_PERPETUAL_MARKET_TYPE_ISOLATED { hasIsolatedUpdate = true isolatedUpdatePerpetualId = perpetualUpdate.PerpetualId + break } } @@ -109,6 +109,7 @@ func isValidIsolatedPerpetualUpdates( if marketType == perptypes.PerpetualMarketType_PERPETUAL_MARKET_TYPE_ISOLATED { isIsolatedSubaccount = true isolatedPositionPerpetualId = perpetualPosition.PerpetualId + break } } @@ -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.