From a94c95213ba407e637f6b54c66fcf36d11c21164 Mon Sep 17 00:00:00 2001 From: Shrenuj Bansal Date: Tue, 23 Apr 2024 15:05:47 -0400 Subject: [PATCH] Fix IsIsolatedPerpetual function orientation Signed-off-by: Shrenuj Bansal --- protocol/x/perpetuals/keeper/perpetual.go | 8 ++++++-- protocol/x/subaccounts/keeper/negative_tnc_subaccount.go | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/protocol/x/perpetuals/keeper/perpetual.go b/protocol/x/perpetuals/keeper/perpetual.go index 1b8b5905fe..f11a164d16 100644 --- a/protocol/x/perpetuals/keeper/perpetual.go +++ b/protocol/x/perpetuals/keeper/perpetual.go @@ -33,8 +33,12 @@ import ( ) func (k Keeper) IsIsolatedPerpetual(ctx sdk.Context, perpetualId uint32) (bool, error) { - insuranceFundName, err := k.GetInsuranceFundName(ctx, perpetualId) - return insuranceFundName == types.InsuranceFundName, err + perpetual, err := k.GetPerpetual(ctx, perpetualId) + if err != nil { + return false, err + } + + return perpetual.Params.MarketType == types.PerpetualMarketType_PERPETUAL_MARKET_TYPE_ISOLATED, nil } // GetInsuranceFundName returns the name of the insurance fund account for a given perpetual. diff --git a/protocol/x/subaccounts/keeper/negative_tnc_subaccount.go b/protocol/x/subaccounts/keeper/negative_tnc_subaccount.go index ebef13a73e..069dcff2b7 100644 --- a/protocol/x/subaccounts/keeper/negative_tnc_subaccount.go +++ b/protocol/x/subaccounts/keeper/negative_tnc_subaccount.go @@ -112,9 +112,9 @@ func (k Keeper) getNegativeTncSubaccountStoreSuffix( return "", err } if isIsolated { - return types.CrossCollateralSuffix, nil - } else { return lib.UintToString(perpetualId), nil + } else { + return types.CrossCollateralSuffix, nil } }