@gainsnetwork/sdk 1.8.8-rc3 → 1.8.8-rc4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/trade/pnl/index.js +4 -1
- package/package.json +1 -1
package/lib/trade/pnl/index.js
CHANGED
|
@@ -271,8 +271,11 @@ const getPriceForTargetPnlPercentage = (targetPnlPercent, trade, tradeInfo, cont
|
|
|
271
271
|
const totalHoldingFees = fees.fundingFeeCollateral +
|
|
272
272
|
fees.borrowingFeeCollateral +
|
|
273
273
|
fees.borrowingFeeCollateral_old;
|
|
274
|
+
const { totalRealizedPnlCollateral } = context.tradeData?.tradeFeesData
|
|
275
|
+
? (0, exports.getTradeRealizedPnlCollateral)(context.tradeData.tradeFeesData)
|
|
276
|
+
: { totalRealizedPnlCollateral: 0 };
|
|
274
277
|
const targetPnlInCollateral = (collateralAmount * targetPnlPercent) / 100;
|
|
275
|
-
let targetPnlGross = targetPnlInCollateral + totalHoldingFees;
|
|
278
|
+
let targetPnlGross = targetPnlInCollateral + totalHoldingFees - totalRealizedPnlCollateral;
|
|
276
279
|
if (netPnl) {
|
|
277
280
|
// Include closing fees
|
|
278
281
|
const closingFee = (0, trading_1.getTotalTradeFeesCollateral)(trade.collateralIndex, trade.user, trade.pairIndex, positionSizeCollateral, trade.isCounterTrade || false, {
|