Skip to content

Commit d4b0a94

Browse files
committed
refactor(sdk): refine oracle price data input types
1 parent e871a6a commit d4b0a94

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

sdk/src/math/market.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export function calculateUnrealizedAssetWeight(
186186
quoteSpotMarket: SpotMarketAccount,
187187
unrealizedPnl: BN,
188188
marginCategory: MarginCategory,
189-
oraclePriceData: OraclePriceData
189+
oraclePriceData: Pick<OraclePriceData, 'price'>
190190
): BN {
191191
let assetWeight: BN;
192192
switch (marginCategory) {
@@ -252,7 +252,7 @@ export function calculateMarketMaxAvailableInsurance(
252252

253253
export function calculateNetUserPnl(
254254
perpMarket: PerpMarketAccount,
255-
oraclePriceData: OraclePriceData
255+
oraclePriceData: Pick<OraclePriceData, 'price'>
256256
): BN {
257257
const netUserPositionValue = perpMarket.amm.baseAssetAmountWithAmm
258258
.add(perpMarket.amm.baseAssetAmountWithUnsettledLp)
@@ -272,7 +272,7 @@ export function calculateNetUserPnl(
272272
export function calculateNetUserPnlImbalance(
273273
perpMarket: PerpMarketAccount,
274274
spotMarket: SpotMarketAccount,
275-
oraclePriceData: OraclePriceData,
275+
oraclePriceData: Pick<OraclePriceData, 'price'>,
276276
applyFeePoolDiscount = true
277277
): BN {
278278
const netUserPnl = calculateNetUserPnl(perpMarket, oraclePriceData);

sdk/src/math/position.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export function calculatePositionPNL(
103103
market: PerpMarketAccount,
104104
perpPosition: PerpPosition,
105105
withFunding = false,
106-
oraclePriceData: OraclePriceData
106+
oraclePriceData: Pick<OraclePriceData, 'price'>
107107
): BN {
108108
if (perpPosition.baseAssetAmount.eq(ZERO)) {
109109
return perpPosition.quoteAssetAmount;
@@ -135,7 +135,7 @@ export function calculateClaimablePnl(
135135
market: PerpMarketAccount,
136136
spotMarket: SpotMarketAccount,
137137
perpPosition: PerpPosition,
138-
oraclePriceData: OraclePriceData
138+
oraclePriceData: Pick<OraclePriceData, 'price'>
139139
): BN {
140140
const unrealizedPnl = calculatePositionPNL(
141141
market,

0 commit comments

Comments
 (0)