Skip to content

Commit

Permalink
[Tier]: Fix usdc conversion (#949)
Browse files Browse the repository at this point in the history
* usdc conversion

* update
  • Loading branch information
amityadav0 authored Nov 15, 2024
1 parent 6387636 commit adb40b8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions x/tier/keeper/portfolio.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,17 @@ func (k Keeper) RetrievePerpetualTotal(ctx sdk.Context, user sdk.AccAddress) (sd
if err != nil {
return sdkmath.LegacyNewDec(0), sdkmath.LegacyNewDec(0), sdkmath.LegacyNewDec(0)
}
usdcDenom, found := k.assetProfileKeeper.GetUsdcDenom(ctx)
if !found {
return sdkmath.LegacyNewDec(0), sdkmath.LegacyNewDec(0), sdkmath.LegacyNewDec(0)
}

for _, perpetual := range perpetuals {
if perpetual.Mtp.Position == perpetualtypes.Position_LONG {
totalAssets = totalAssets.Add(k.CalculateUSDValue(ctx, perpetual.Mtp.GetTradingAsset(), perpetual.Mtp.Custody))
totalLiability = totalLiability.Add(sdkmath.LegacyDec(perpetual.Mtp.Liabilities.Add(perpetual.Mtp.BorrowInterestUnpaidLiability)))
totalLiability = totalLiability.Add(k.CalculateUSDValue(ctx, usdcDenom, perpetual.Mtp.Liabilities.Add(perpetual.Mtp.BorrowInterestUnpaidLiability)))
} else {
totalAssets = totalAssets.Add(perpetual.Mtp.Custody.ToLegacyDec())
totalAssets = totalAssets.Add(k.CalculateUSDValue(ctx, usdcDenom, perpetual.Mtp.Custody))
totalLiability = totalLiability.Add(k.CalculateUSDValue(ctx, perpetual.Mtp.LiabilitiesAsset, perpetual.Mtp.Liabilities.Add(perpetual.Mtp.BorrowInterestUnpaidLiability)))
}
}
Expand Down

0 comments on commit adb40b8

Please sign in to comment.