Skip to content

Commit

Permalink
Merge pull request #126 from drift-labs/evan/add-fees-and-funding-to-…
Browse files Browse the repository at this point in the history
…position-type

common-ts: add fees and funding pnl to common position type
  • Loading branch information
evanpipta authored Oct 22, 2024
2 parents f634508 + a57f02f commit a2f2cc5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions common-ts/src/common-ui-utils/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
calculateClaimablePnl,
calculateCostBasis,
calculateEntryPrice,
calculateFeesAndFundingPnl,
calculatePositionFundingPNL,
calculatePositionPNL,
isOracleValid,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions common-ts/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export type OpenPosition = {
quoteEntryAmount: BN;
quoteBreakEvenAmount: BN;
unrealizedFundingPnl: BN;
feesAndFundingPnl: BN;
lastCumulativeFundingRate: BN;
openOrders: number;
unsettledPnl: BN;
Expand Down

0 comments on commit a2f2cc5

Please sign in to comment.