From a57f02f938ee6c0664fc27a0aac9b274747c2d4c Mon Sep 17 00:00:00 2001 From: Evan Pipta <3pipta@gmail.com> Date: Tue, 22 Oct 2024 14:41:15 -0400 Subject: [PATCH] common: add fees and funding pnl to common --- common-ts/src/common-ui-utils/user.ts | 6 ++++++ common-ts/src/types/index.ts | 1 + 2 files changed, 7 insertions(+) diff --git a/common-ts/src/common-ui-utils/user.ts b/common-ts/src/common-ui-utils/user.ts index eb17cbdf..fc57f1cf 100644 --- a/common-ts/src/common-ui-utils/user.ts +++ b/common-ts/src/common-ui-utils/user.ts @@ -14,6 +14,7 @@ import { calculateClaimablePnl, calculateCostBasis, calculateEntryPrice, + calculateFeesAndFundingPnl, calculatePositionFundingPNL, calculatePositionPNL, isOracleValid, @@ -151,6 +152,11 @@ const getOpenPositionData = ( perpMarket, perpPositionWithLpSettle ), + // Includes both settled and unsettled funding as well as fees + feesAndFundingPnl: calculateFeesAndFundingPnl( + perpMarket, + perpPositionWithLpSettle + ), totalUnrealizedPnl: calculatePositionPNL( perpMarket, perpPositionWithLpSettle, diff --git a/common-ts/src/types/index.ts b/common-ts/src/types/index.ts index d5fd6313..0caadfb6 100644 --- a/common-ts/src/types/index.ts +++ b/common-ts/src/types/index.ts @@ -226,6 +226,7 @@ export type OpenPosition = { quoteEntryAmount: BN; quoteBreakEvenAmount: BN; unrealizedFundingPnl: BN; + feesAndFundingPnl: BN; lastCumulativeFundingRate: BN; openOrders: number; unsettledPnl: BN;