@gainsnetwork/sdk 0.0.0-v10.rc5 → 0.0.0-v10.rc6
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.
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.encodeUiRealizedPnlData = exports.encodeTradeFeesData = exports.convertUiRealizedPnlDataArray = exports.convertUiRealizedPnlData = exports.convertTradeFeesDataArray = exports.convertTradeFeesData = void 0;
|
|
7
|
+
const borrowingV2_1 = require("./borrowingV2");
|
|
8
|
+
const converter_1 = require("./fundingFees/converter");
|
|
7
9
|
/**
|
|
8
10
|
* @dev Converts contract TradeFeesData to SDK format
|
|
9
11
|
* @param data Trade fees data from contract
|
|
@@ -22,8 +24,10 @@ const convertTradeFeesData = (data, collateralConfig) => {
|
|
|
22
24
|
Math.pow(10, decimals),
|
|
23
25
|
virtualAvailableCollateralInDiamond: parseFloat(data.virtualAvailableCollateralInDiamond.toString()) /
|
|
24
26
|
Math.pow(10, decimals),
|
|
25
|
-
initialAccFundingFeeP: parseFloat(data.initialAccFundingFeeP.toString()) /
|
|
26
|
-
|
|
27
|
+
initialAccFundingFeeP: parseFloat(data.initialAccFundingFeeP.toString()) /
|
|
28
|
+
converter_1.FUNDING_FEES_PRECISION.ACC_FUNDING_FEE_P,
|
|
29
|
+
initialAccBorrowingFeeP: parseFloat(data.initialAccBorrowingFeeP.toString()) /
|
|
30
|
+
borrowingV2_1.BORROWING_V2_PRECISION.ACC_FEE,
|
|
27
31
|
};
|
|
28
32
|
};
|
|
29
33
|
exports.convertTradeFeesData = convertTradeFeesData;
|
|
@@ -85,8 +89,8 @@ const encodeTradeFeesData = (data, collateralConfig) => {
|
|
|
85
89
|
alreadyTransferredNegativePnlCollateral: Math.round(data.alreadyTransferredNegativePnlCollateral * Math.pow(10, decimals)),
|
|
86
90
|
virtualAvailableCollateralInDiamond: Math.round(data.virtualAvailableCollateralInDiamond * Math.pow(10, decimals)),
|
|
87
91
|
__placeholder: 0,
|
|
88
|
-
initialAccFundingFeeP: Math.round(data.initialAccFundingFeeP *
|
|
89
|
-
initialAccBorrowingFeeP: Math.round(data.initialAccBorrowingFeeP *
|
|
92
|
+
initialAccFundingFeeP: Math.round(data.initialAccFundingFeeP * converter_1.FUNDING_FEES_PRECISION.ACC_FUNDING_FEE_P),
|
|
93
|
+
initialAccBorrowingFeeP: Math.round(data.initialAccBorrowingFeeP * borrowingV2_1.BORROWING_V2_PRECISION.ACC_FEE),
|
|
90
94
|
};
|
|
91
95
|
};
|
|
92
96
|
exports.encodeTradeFeesData = encodeTradeFeesData;
|
|
@@ -126,6 +126,12 @@ const getTradePendingHoldingFeesCollateral = (trade, tradeInfo, tradeFeesData, c
|
|
|
126
126
|
if (context.contractsVersion >= types_1.ContractsVersion.V10 &&
|
|
127
127
|
context.borrowingV2 &&
|
|
128
128
|
tradeFeesData.initialAccBorrowingFeeP !== undefined) {
|
|
129
|
+
console.log("initialAccBorrowingFeeP", tradeFeesData.initialAccBorrowingFeeP);
|
|
130
|
+
console.log("positionSizeCollateral", positionSizeCollateral);
|
|
131
|
+
console.log("openPrice", trade.openPrice);
|
|
132
|
+
console.log("currentPairPrice", currentPairPrice);
|
|
133
|
+
console.log("currentTimestamp", context.currentTimestamp);
|
|
134
|
+
console.log("borrowingv2", context.borrowingV2);
|
|
129
135
|
borrowingFeeCollateral = (0, borrowingV2_1.getTradeBorrowingFeesCollateral)({
|
|
130
136
|
positionSizeCollateral,
|
|
131
137
|
openPrice: trade.openPrice,
|