@gainsnetwork/sdk 1.0.6-rc3 → 1.1.0-rc1

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.
Files changed (147) hide show
  1. package/lib/backend/globalTrades/index.js +10 -10
  2. package/lib/backend/tradingVariables/backend.types.d.ts +11 -4
  3. package/lib/backend/tradingVariables/converter.d.ts +7 -3
  4. package/lib/backend/tradingVariables/converter.js +70 -63
  5. package/lib/backend/tradingVariables/index.js +11 -7
  6. package/lib/backend/tradingVariables/types.d.ts +4 -2
  7. package/lib/contracts/addresses.js +1 -4
  8. package/lib/contracts/index.d.ts +1 -1
  9. package/lib/contracts/index.js +3 -3
  10. package/lib/contracts/types/generated/GFarmTradingStorageV5.d.ts +1911 -0
  11. package/lib/contracts/types/generated/GFarmTradingStorageV5.js +2 -0
  12. package/lib/contracts/types/generated/GNSBorrowingFees.d.ts +1067 -0
  13. package/lib/contracts/types/generated/GNSBorrowingFees.js +2 -0
  14. package/lib/contracts/types/generated/GNSBorrowingFeesV6_3_2.d.ts +979 -0
  15. package/lib/contracts/types/generated/GNSBorrowingFeesV6_3_2.js +2 -0
  16. package/lib/contracts/types/generated/GNSBorrowingFeesV6_4.d.ts +1058 -0
  17. package/lib/contracts/types/generated/GNSBorrowingFeesV6_4.js +2 -0
  18. package/lib/contracts/types/generated/GNSMultiCollatDiamond.d.ts +223 -40
  19. package/lib/contracts/types/generated/GNSNftRewardsV6.d.ts +533 -0
  20. package/lib/contracts/types/generated/GNSNftRewardsV6.js +2 -0
  21. package/lib/contracts/types/generated/GNSNftRewardsV6_3_1.d.ts +613 -0
  22. package/lib/contracts/types/generated/GNSNftRewardsV6_3_1.js +2 -0
  23. package/lib/contracts/types/generated/GNSPairInfosV6_1.d.ts +911 -0
  24. package/lib/contracts/types/generated/GNSPairInfosV6_1.js +2 -0
  25. package/lib/contracts/types/generated/GNSPairsStorageV6.d.ts +660 -0
  26. package/lib/contracts/types/generated/GNSPairsStorageV6.js +2 -0
  27. package/lib/contracts/types/generated/GNSTrading.d.ts +758 -0
  28. package/lib/contracts/types/generated/GNSTrading.js +2 -0
  29. package/lib/contracts/types/generated/GNSTradingCallbacks.d.ts +875 -0
  30. package/lib/contracts/types/generated/GNSTradingCallbacks.js +2 -0
  31. package/lib/contracts/types/generated/GNSTradingCallbacksV6_3_2.d.ts +806 -0
  32. package/lib/contracts/types/generated/GNSTradingCallbacksV6_3_2.js +2 -0
  33. package/lib/contracts/types/generated/GNSTradingCallbacksV6_4.d.ts +821 -0
  34. package/lib/contracts/types/generated/GNSTradingCallbacksV6_4.js +2 -0
  35. package/lib/contracts/types/generated/GNSTradingStorage.d.ts +1387 -0
  36. package/lib/contracts/types/generated/GNSTradingStorage.js +2 -0
  37. package/lib/contracts/types/generated/GTokenV6_3_2.d.ts +1838 -0
  38. package/lib/contracts/types/generated/GTokenV6_3_2.js +2 -0
  39. package/lib/contracts/types/generated/factories/GFarmTradingStorageV5__factory.d.ts +83 -0
  40. package/lib/contracts/types/generated/factories/GFarmTradingStorageV5__factory.js +2691 -0
  41. package/lib/contracts/types/generated/factories/GNSBorrowingFeesV6_3_2__factory.d.ts +88 -0
  42. package/lib/contracts/types/generated/factories/GNSBorrowingFeesV6_3_2__factory.js +1654 -0
  43. package/lib/contracts/types/generated/factories/GNSBorrowingFeesV6_4__factory.d.ts +113 -0
  44. package/lib/contracts/types/generated/factories/GNSBorrowingFeesV6_4__factory.js +1742 -0
  45. package/lib/contracts/types/generated/factories/GNSBorrowingFees__factory.d.ts +124 -0
  46. package/lib/contracts/types/generated/factories/GNSBorrowingFees__factory.js +1784 -0
  47. package/lib/contracts/types/generated/factories/GNSMultiCollatDiamond__factory.d.ts +10 -2
  48. package/lib/contracts/types/generated/factories/GNSMultiCollatDiamond__factory.js +317 -36
  49. package/lib/contracts/types/generated/factories/GNSNftRewardsV6_3_1__factory.d.ts +100 -0
  50. package/lib/contracts/types/generated/factories/GNSNftRewardsV6_3_1__factory.js +1116 -0
  51. package/lib/contracts/types/generated/factories/GNSNftRewardsV6__factory.d.ts +100 -0
  52. package/lib/contracts/types/generated/factories/GNSNftRewardsV6__factory.js +1003 -0
  53. package/lib/contracts/types/generated/factories/GNSPairInfosV6_1__factory.d.ts +98 -0
  54. package/lib/contracts/types/generated/factories/GNSPairInfosV6_1__factory.js +1485 -0
  55. package/lib/contracts/types/generated/factories/GNSPairsStorageV6__factory.d.ts +117 -0
  56. package/lib/contracts/types/generated/factories/GNSPairsStorageV6__factory.js +1265 -0
  57. package/lib/contracts/types/generated/factories/GNSTradingCallbacksV6_3_2__factory.d.ts +82 -0
  58. package/lib/contracts/types/generated/factories/GNSTradingCallbacksV6_3_2__factory.js +1273 -0
  59. package/lib/contracts/types/generated/factories/GNSTradingCallbacksV6_4__factory.d.ts +82 -0
  60. package/lib/contracts/types/generated/factories/GNSTradingCallbacksV6_4__factory.js +1326 -0
  61. package/lib/contracts/types/generated/factories/GNSTradingCallbacks__factory.d.ts +113 -0
  62. package/lib/contracts/types/generated/factories/GNSTradingCallbacks__factory.js +1428 -0
  63. package/lib/contracts/types/generated/factories/GNSTradingStorage__factory.d.ts +96 -0
  64. package/lib/contracts/types/generated/factories/GNSTradingStorage__factory.js +2241 -0
  65. package/lib/contracts/types/generated/factories/GNSTrading__factory.d.ts +95 -0
  66. package/lib/contracts/types/generated/factories/GNSTrading__factory.js +1071 -0
  67. package/lib/contracts/types/generated/factories/GTokenV6_3_2__factory.d.ts +110 -0
  68. package/lib/contracts/types/generated/factories/GTokenV6_3_2__factory.js +2682 -0
  69. package/lib/contracts/utils/borrowingFees.js +20 -9
  70. package/lib/contracts/utils/openTrades.js +20 -11
  71. package/lib/contracts/utils/pairs.d.ts +13 -2
  72. package/lib/contracts/utils/pairs.js +89 -21
  73. package/lib/index.d.ts +1 -0
  74. package/lib/index.js +1 -0
  75. package/lib/markets/forex.js +1 -1
  76. package/lib/markets/leverage/builder.js +2 -2
  77. package/lib/markets/oi/fetcher.d.ts +58 -0
  78. package/lib/markets/oi/fetcher.js +181 -0
  79. package/lib/markets/oi/validation.d.ts +80 -0
  80. package/lib/markets/oi/validation.js +172 -0
  81. package/lib/markets/price/index.d.ts +0 -1
  82. package/lib/markets/price/index.js +0 -1
  83. package/lib/markets/price/signedPrices.d.ts +7 -0
  84. package/lib/markets/price/signedPrices.js +55 -2
  85. package/lib/markets/price/types.d.ts +0 -27
  86. package/lib/pricing/depthBands/converter.d.ts +65 -0
  87. package/lib/pricing/depthBands/converter.js +155 -0
  88. package/lib/pricing/depthBands/decoder.d.ts +32 -0
  89. package/lib/pricing/depthBands/decoder.js +109 -0
  90. package/lib/pricing/depthBands/encoder.d.ts +19 -0
  91. package/lib/pricing/depthBands/encoder.js +105 -0
  92. package/lib/pricing/depthBands/index.d.ts +8 -0
  93. package/lib/pricing/depthBands/index.js +26 -0
  94. package/lib/pricing/depthBands/types.d.ts +49 -0
  95. package/lib/pricing/depthBands/types.js +10 -0
  96. package/lib/pricing/depthBands/validator.d.ts +22 -0
  97. package/lib/pricing/depthBands/validator.js +113 -0
  98. package/lib/pricing/depthBands.d.ts +39 -0
  99. package/lib/pricing/depthBands.js +92 -0
  100. package/lib/pricing/index.d.ts +4 -0
  101. package/lib/pricing/index.js +20 -0
  102. package/lib/trade/effectiveLeverage/builder.d.ts +23 -0
  103. package/lib/trade/effectiveLeverage/builder.js +30 -0
  104. package/lib/trade/fees/borrowing/builder.js +3 -2
  105. package/lib/trade/fees/borrowing/converter.js +1 -5
  106. package/lib/trade/fees/borrowing/index.js +5 -5
  107. package/lib/trade/fees/borrowingV2/builder.js +4 -3
  108. package/lib/trade/fees/borrowingV2/converter.js +1 -1
  109. package/lib/trade/fees/borrowingV2/fetcher.d.ts +0 -1
  110. package/lib/trade/fees/borrowingV2/fetcher.js +32 -26
  111. package/lib/trade/fees/borrowingV2/index.js +3 -3
  112. package/lib/trade/fees/converter.js +22 -22
  113. package/lib/trade/fees/fundingFees/builder.js +7 -6
  114. package/lib/trade/fees/fundingFees/converter.js +1 -1
  115. package/lib/trade/fees/fundingFees/fetcher.js +25 -16
  116. package/lib/trade/fees/fundingFees/index.js +3 -2
  117. package/lib/trade/fees/holdingFees/index.d.ts +46 -0
  118. package/lib/trade/fees/holdingFees/index.js +105 -0
  119. package/lib/trade/fees/holdingFees/types.d.ts +23 -0
  120. package/lib/trade/fees/holdingFees/types.js +5 -0
  121. package/lib/trade/fees/tiers/index.js +2 -1
  122. package/lib/trade/fees/trading/holdingFees.d.ts +28 -0
  123. package/lib/trade/fees/trading/holdingFees.js +66 -0
  124. package/lib/trade/fees/trading/holdingFeesStructured.d.ts +28 -0
  125. package/lib/trade/fees/trading/holdingFeesStructured.js +66 -0
  126. package/lib/trade/fees/trading/index.js +3 -5
  127. package/lib/trade/liquidation/builder.js +3 -6
  128. package/lib/trade/liquidation/index.js +6 -4
  129. package/lib/trade/oiWindows.js +2 -1
  130. package/lib/trade/pnl/builder.js +2 -1
  131. package/lib/trade/pnl/converter.js +1 -1
  132. package/lib/trade/pnl/index.js +7 -4
  133. package/lib/trade/priceImpact/close/builder.js +2 -1
  134. package/lib/trade/priceImpact/close/index.js +1 -4
  135. package/lib/trade/priceImpact/cumulVol/builder.js +11 -18
  136. package/lib/trade/priceImpact/cumulVol/converter.d.ts +63 -0
  137. package/lib/trade/priceImpact/cumulVol/converter.js +97 -1
  138. package/lib/trade/priceImpact/cumulVol/index.d.ts +3 -0
  139. package/lib/trade/priceImpact/cumulVol/index.js +123 -25
  140. package/lib/trade/priceImpact/cumulVol/types.d.ts +11 -0
  141. package/lib/trade/priceImpact/cumulVol/types.js +2 -0
  142. package/lib/trade/priceImpact/open/builder.js +2 -1
  143. package/lib/trade/priceImpact/open/index.js +1 -4
  144. package/lib/trade/priceImpact/skew/builder.js +3 -2
  145. package/lib/trade/priceImpact/skew/converter.js +1 -1
  146. package/lib/trade/priceImpact/skew/fetcher.js +33 -24
  147. package/package.json +2 -2
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @dev Holding fees calculation utilities for v10+ markets
3
+ * @dev Combines funding fees and borrowing v2 fees
4
+ */
5
+ import { FundingFeeParams, PairFundingFeeData, PairOiAfterV10 } from "../fundingFees/types";
6
+ import { BorrowingFeeParams, PairBorrowingFeeData } from "../borrowingV2/types";
7
+ export type HoldingFeeRates = {
8
+ longHourlyRate: number;
9
+ shortHourlyRate: number;
10
+ fundingFeeLongHourlyRate: number;
11
+ fundingFeeShortHourlyRate: number;
12
+ borrowingFeeHourlyRate: number;
13
+ currentFundingRatePerSecondP: number;
14
+ currentBorrowingRatePerSecondP: number;
15
+ };
16
+ export type GetPairHoldingFeeRatesInput = {
17
+ fundingParams: FundingFeeParams;
18
+ fundingData: PairFundingFeeData;
19
+ pairOiToken: PairOiAfterV10;
20
+ netExposureToken: number;
21
+ netExposureUsd: number;
22
+ borrowingParams: BorrowingFeeParams | null;
23
+ borrowingData: PairBorrowingFeeData | null;
24
+ currentPairPrice: number;
25
+ currentTimestamp: number;
26
+ };
27
+ /**
28
+ * @dev Calculates current holding fee rates per hour for display
29
+ * @param input Input parameters for calculation
30
+ * @returns Holding fee rates per hour with breakdown
31
+ */
32
+ export declare const getPairHoldingFeeRates: (input: GetPairHoldingFeeRatesInput) => HoldingFeeRates;
33
+ /**
34
+ * @dev Converts a per-second rate to annual percentage rate (APR)
35
+ * @param ratePerSecond Rate per second
36
+ * @returns Annual percentage rate
37
+ */
38
+ export declare const convertRatePerSecondToAPR: (ratePerSecond: number) => number;
39
+ /**
40
+ * @dev Formats a holding fee rate for display
41
+ * @param rate Hourly rate (can be negative)
42
+ * @param decimals Number of decimal places
43
+ * @returns Formatted string with sign
44
+ */
45
+ export declare const formatHoldingFeeRate: (rate: number, decimals?: number) => string;
46
+ export * as HoldingFees from "./types";
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ /**
3
+ * @dev Holding fees calculation utilities for v10+ markets
4
+ * @dev Combines funding fees and borrowing v2 fees
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || function (mod) {
23
+ if (mod && mod.__esModule) return mod;
24
+ var result = {};
25
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
26
+ __setModuleDefault(result, mod);
27
+ return result;
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.HoldingFees = exports.formatHoldingFeeRate = exports.convertRatePerSecondToAPR = exports.getPairHoldingFeeRates = void 0;
31
+ const fundingFees_1 = require("../fundingFees");
32
+ const SECONDS_PER_HOUR = 3600;
33
+ const SECONDS_PER_YEAR = 365 * 24 * 60 * 60;
34
+ const PERCENTAGE_PRECISION = 100;
35
+ /**
36
+ * @dev Calculates current holding fee rates per hour for display
37
+ * @param input Input parameters for calculation
38
+ * @returns Holding fee rates per hour with breakdown
39
+ */
40
+ const getPairHoldingFeeRates = (input) => {
41
+ const { fundingParams, fundingData, pairOiToken, netExposureToken, netExposureUsd, borrowingParams, borrowingData, currentPairPrice, currentTimestamp, } = input;
42
+ // Calculate funding fee rates
43
+ let fundingFeeLongHourlyRate = 0;
44
+ let fundingFeeShortHourlyRate = 0;
45
+ let currentFundingRatePerSecondP = 0;
46
+ if (fundingParams.fundingFeesEnabled) {
47
+ // Get current funding rate
48
+ const pendingFunding = (0, fundingFees_1.getPairPendingAccFundingFees)(fundingParams, fundingData, currentPairPrice, pairOiToken, netExposureToken, netExposureUsd, currentTimestamp);
49
+ currentFundingRatePerSecondP = pendingFunding.currentFundingRatePerSecondP;
50
+ // Get APR multipliers
51
+ const { longAprMultiplier, shortAprMultiplier } = (0, fundingFees_1.getLongShortAprMultiplier)(currentFundingRatePerSecondP, pairOiToken.oiLongToken, pairOiToken.oiShortToken, fundingParams.aprMultiplierEnabled);
52
+ // Calculate hourly rates
53
+ // Funding rate * seconds per hour * current price * APR multiplier / 100
54
+ const baseHourlyRate = (currentFundingRatePerSecondP * SECONDS_PER_HOUR * currentPairPrice) /
55
+ PERCENTAGE_PRECISION;
56
+ // Long side pays when rate is positive, earns when negative
57
+ fundingFeeLongHourlyRate = baseHourlyRate * longAprMultiplier;
58
+ // Short side is opposite
59
+ fundingFeeShortHourlyRate = -baseHourlyRate * shortAprMultiplier;
60
+ }
61
+ // Calculate borrowing v2 rates
62
+ let borrowingFeeHourlyRate = 0;
63
+ let currentBorrowingRatePerSecondP = 0;
64
+ if (borrowingParams && borrowingData) {
65
+ currentBorrowingRatePerSecondP = borrowingParams.borrowingRatePerSecondP;
66
+ // Borrowing rate * seconds per hour * current price / 100
67
+ borrowingFeeHourlyRate =
68
+ (currentBorrowingRatePerSecondP * SECONDS_PER_HOUR * currentPairPrice) /
69
+ PERCENTAGE_PRECISION;
70
+ }
71
+ // Total holding fees (funding can be negative/positive, borrowing always positive cost)
72
+ const longHourlyRate = fundingFeeLongHourlyRate + borrowingFeeHourlyRate;
73
+ const shortHourlyRate = fundingFeeShortHourlyRate + borrowingFeeHourlyRate;
74
+ return {
75
+ longHourlyRate,
76
+ shortHourlyRate,
77
+ fundingFeeLongHourlyRate,
78
+ fundingFeeShortHourlyRate,
79
+ borrowingFeeHourlyRate,
80
+ currentFundingRatePerSecondP,
81
+ currentBorrowingRatePerSecondP,
82
+ };
83
+ };
84
+ exports.getPairHoldingFeeRates = getPairHoldingFeeRates;
85
+ /**
86
+ * @dev Converts a per-second rate to annual percentage rate (APR)
87
+ * @param ratePerSecond Rate per second
88
+ * @returns Annual percentage rate
89
+ */
90
+ const convertRatePerSecondToAPR = (ratePerSecond) => {
91
+ return ratePerSecond * SECONDS_PER_YEAR * PERCENTAGE_PRECISION;
92
+ };
93
+ exports.convertRatePerSecondToAPR = convertRatePerSecondToAPR;
94
+ /**
95
+ * @dev Formats a holding fee rate for display
96
+ * @param rate Hourly rate (can be negative)
97
+ * @param decimals Number of decimal places
98
+ * @returns Formatted string with sign
99
+ */
100
+ const formatHoldingFeeRate = (rate, decimals = 4) => {
101
+ const sign = rate > 0 ? "+" : "";
102
+ return `${sign}${rate.toFixed(decimals)}%`;
103
+ };
104
+ exports.formatHoldingFeeRate = formatHoldingFeeRate;
105
+ exports.HoldingFees = __importStar(require("./types"));
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @dev Type definitions for holding fees (funding + borrowing v2)
3
+ */
4
+ export interface HoldingFeeRates {
5
+ longHourlyRate: number;
6
+ shortHourlyRate: number;
7
+ fundingFeeLongHourlyRate: number;
8
+ fundingFeeShortHourlyRate: number;
9
+ borrowingFeeHourlyRate: number;
10
+ currentFundingRatePerSecondP: number;
11
+ currentBorrowingRatePerSecondP: number;
12
+ }
13
+ export interface GetPairHoldingFeeRatesInput {
14
+ fundingParams: import("../fundingFees/types").FundingFeeParams;
15
+ fundingData: import("../fundingFees/types").PairFundingFeeData;
16
+ pairOiToken: import("../fundingFees/types").PairOiAfterV10;
17
+ netExposureToken: number;
18
+ netExposureUsd: number;
19
+ borrowingParams: import("../borrowingV2/types").BorrowingFeeParams | null;
20
+ borrowingData: import("../borrowingV2/types").PairBorrowingFeeData | null;
21
+ currentPairPrice: number;
22
+ currentTimestamp: number;
23
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * @dev Type definitions for holding fees (funding + borrowing v2)
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -24,8 +24,9 @@ exports.MAX_FEE_TIERS = 8;
24
24
  const getCurrentDay = () => Math.floor(Date.now() / 1000 / 60 / 60 / 24);
25
25
  exports.getCurrentDay = getCurrentDay;
26
26
  const getFeeTiersCount = (feeTiers) => {
27
+ var _a;
27
28
  for (let i = exports.MAX_FEE_TIERS; i > 0; --i) {
28
- if (feeTiers[i - 1]?.feeMultiplier > 0) {
29
+ if (((_a = feeTiers[i - 1]) === null || _a === void 0 ? void 0 : _a.feeMultiplier) > 0) {
29
30
  return i;
30
31
  }
31
32
  }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @dev Holding fees calculation for structured contexts
3
+ */
4
+ import { Trade, TradeInfo, TradeFeesData } from "../../types";
5
+ import { TradeHoldingFees } from "./types";
6
+ import { ContractsVersion } from "../../../contracts/types";
7
+ import type { BorrowingV1SubContext, BorrowingV2SubContext, FundingFeesSubContext } from "../../pnl";
8
+ /**
9
+ * @dev Context for holding fees calculation with structured sub-contexts
10
+ */
11
+ export type GetStructuredHoldingFeesContext = {
12
+ contractsVersion: ContractsVersion;
13
+ currentTimestamp: number;
14
+ collateralPriceUsd: number;
15
+ borrowingV1?: BorrowingV1SubContext;
16
+ borrowingV2?: BorrowingV2SubContext;
17
+ funding?: FundingFeesSubContext;
18
+ };
19
+ /**
20
+ * @dev Calculates total holding fees using structured context
21
+ * @param trade The trade to calculate fees for
22
+ * @param tradeInfo Trade info containing contracts version
23
+ * @param tradeFeesData Trade fees data containing initial acc fees
24
+ * @param currentPairPrice Current pair price
25
+ * @param context Structured context with sub-contexts for each fee type
26
+ * @returns Object containing all holding fee components
27
+ */
28
+ export declare const getTradePendingHoldingFeesCollateralStructured: (trade: Trade, tradeInfo: TradeInfo, tradeFeesData: TradeFeesData, currentPairPrice: number, context: GetStructuredHoldingFeesContext) => TradeHoldingFees;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ /**
3
+ * @dev Holding fees calculation for structured contexts
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getTradePendingHoldingFeesCollateralStructured = void 0;
7
+ const types_1 = require("../../../contracts/types");
8
+ const borrowing_1 = require("../borrowing");
9
+ const borrowingV2_1 = require("../borrowingV2");
10
+ const pairContext_1 = require("../fundingFees/pairContext");
11
+ /**
12
+ * @dev Calculates total holding fees using structured context
13
+ * @param trade The trade to calculate fees for
14
+ * @param tradeInfo Trade info containing contracts version
15
+ * @param tradeFeesData Trade fees data containing initial acc fees
16
+ * @param currentPairPrice Current pair price
17
+ * @param context Structured context with sub-contexts for each fee type
18
+ * @returns Object containing all holding fee components
19
+ */
20
+ const getTradePendingHoldingFeesCollateralStructured = (trade, tradeInfo, tradeFeesData, currentPairPrice, context) => {
21
+ const positionSizeCollateral = trade.collateralAmount * trade.leverage;
22
+ // Calculate funding fees (v10+ only)
23
+ let fundingFeeCollateral = 0;
24
+ if (context.contractsVersion >= types_1.ContractsVersion.V10 &&
25
+ context.funding &&
26
+ tradeFeesData.initialAccFundingFeeP !== undefined) {
27
+ fundingFeeCollateral = (0, pairContext_1.getPairTradeFundingFeesCollateral)({
28
+ positionSizeCollateral,
29
+ openPrice: trade.openPrice,
30
+ long: trade.long,
31
+ currentPairPrice,
32
+ initialAccFundingFeeP: tradeFeesData.initialAccFundingFeeP,
33
+ }, context.funding // TODO: Fix types once funding types are properly imported
34
+ );
35
+ }
36
+ // Calculate borrowing fees v2
37
+ let borrowingFeeCollateral = 0;
38
+ if (context.borrowingV2 && tradeFeesData.initialAccBorrowingFeeP !== undefined) {
39
+ borrowingFeeCollateral = (0, borrowingV2_1.getPairTradeBorrowingFeesCollateral)({
40
+ positionSizeCollateral,
41
+ openPrice: trade.openPrice,
42
+ currentPairPrice,
43
+ initialAccBorrowingFeeP: tradeFeesData.initialAccBorrowingFeeP,
44
+ currentTimestamp: context.currentTimestamp,
45
+ }, context.borrowingV2);
46
+ }
47
+ // Calculate v1 borrowing fees (some markets use v1 indefinitely)
48
+ let borrowingFeeCollateral_old = 0;
49
+ if (context.borrowingV1) {
50
+ borrowingFeeCollateral_old = (0, borrowing_1.getPairBorrowingFee)(positionSizeCollateral, trade.long, context.borrowingV1.initialAccFees || { accPairFee: 0, accGroupFee: 0, block: 0 }, {
51
+ currentBlock: context.borrowingV1.currentBlock,
52
+ group: context.borrowingV1.group,
53
+ pair: context.borrowingV1.pair,
54
+ collateralPriceUsd: context.collateralPriceUsd,
55
+ });
56
+ }
57
+ return {
58
+ fundingFeeCollateral,
59
+ borrowingFeeCollateral,
60
+ borrowingFeeCollateral_old,
61
+ totalFeeCollateral: fundingFeeCollateral +
62
+ borrowingFeeCollateral +
63
+ borrowingFeeCollateral_old,
64
+ };
65
+ };
66
+ exports.getTradePendingHoldingFeesCollateralStructured = getTradePendingHoldingFeesCollateralStructured;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @dev Holding fees calculation for structured contexts
3
+ */
4
+ import { Trade, TradeInfo, TradeFeesData } from "../../types";
5
+ import { TradeHoldingFees } from "./types";
6
+ import { ContractsVersion } from "../../../contracts/types";
7
+ import type { BorrowingV1SubContext, BorrowingV2SubContext, FundingFeesSubContext } from "../../pnl";
8
+ /**
9
+ * @dev Context for holding fees calculation with structured sub-contexts
10
+ */
11
+ export type GetStructuredHoldingFeesContext = {
12
+ contractsVersion: ContractsVersion;
13
+ currentTimestamp: number;
14
+ collateralPriceUsd: number;
15
+ borrowingV1?: BorrowingV1SubContext;
16
+ borrowingV2?: BorrowingV2SubContext;
17
+ funding?: FundingFeesSubContext;
18
+ };
19
+ /**
20
+ * @dev Calculates total holding fees using structured context
21
+ * @param trade The trade to calculate fees for
22
+ * @param tradeInfo Trade info containing contracts version
23
+ * @param tradeFeesData Trade fees data containing initial acc fees
24
+ * @param currentPairPrice Current pair price
25
+ * @param context Structured context with sub-contexts for each fee type
26
+ * @returns Object containing all holding fee components
27
+ */
28
+ export declare const getTradePendingHoldingFeesCollateralStructured: (trade: Trade, tradeInfo: TradeInfo, tradeFeesData: TradeFeesData, currentPairPrice: number, context: GetStructuredHoldingFeesContext) => TradeHoldingFees;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ /**
3
+ * @dev Holding fees calculation for structured contexts
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getTradePendingHoldingFeesCollateralStructured = void 0;
7
+ const types_1 = require("../../../contracts/types");
8
+ const borrowing_1 = require("../borrowing");
9
+ const borrowingV2_1 = require("../borrowingV2");
10
+ const fundingFees_1 = require("../fundingFees");
11
+ /**
12
+ * @dev Calculates total holding fees using structured context
13
+ * @param trade The trade to calculate fees for
14
+ * @param tradeInfo Trade info containing contracts version
15
+ * @param tradeFeesData Trade fees data containing initial acc fees
16
+ * @param currentPairPrice Current pair price
17
+ * @param context Structured context with sub-contexts for each fee type
18
+ * @returns Object containing all holding fee components
19
+ */
20
+ const getTradePendingHoldingFeesCollateralStructured = (trade, tradeInfo, tradeFeesData, currentPairPrice, context) => {
21
+ const positionSizeCollateral = trade.collateralAmount * trade.leverage;
22
+ // Calculate funding fees (v10+ only)
23
+ let fundingFeeCollateral = 0;
24
+ if (context.contractsVersion >= types_1.ContractsVersion.V10 &&
25
+ context.funding &&
26
+ tradeFeesData.initialAccFundingFeeP !== undefined) {
27
+ fundingFeeCollateral = (0, fundingFees_1.getTradeFundingFeesCollateral)(trade, tradeInfo, tradeFeesData, currentPairPrice, Object.assign(Object.assign({}, context.funding), { currentTimestamp: context.currentTimestamp }) // TODO: Fix types once funding types are properly imported
28
+ );
29
+ }
30
+ // Calculate borrowing fees v2
31
+ let borrowingFeeCollateral = 0;
32
+ if (context.borrowingV2 &&
33
+ tradeFeesData.initialAccBorrowingFeeP !== undefined) {
34
+ borrowingFeeCollateral = (0, borrowingV2_1.getTradeBorrowingFeesCollateral)({
35
+ positionSizeCollateral,
36
+ openPrice: trade.openPrice,
37
+ currentPairPrice,
38
+ initialAccBorrowingFeeP: tradeFeesData.initialAccBorrowingFeeP,
39
+ currentTimestamp: context.currentTimestamp,
40
+ }, context.borrowingV2);
41
+ }
42
+ // Calculate v1 borrowing fees (some markets use v1 indefinitely)
43
+ let borrowingFeeCollateral_old = 0;
44
+ if (context.borrowingV1) {
45
+ borrowingFeeCollateral_old = (0, borrowing_1.getBorrowingFee)(positionSizeCollateral, undefined, // pairIndex not needed for pair-specific context
46
+ trade.long, context.borrowingV1.initialAccFees || {
47
+ accPairFee: 0,
48
+ accGroupFee: 0,
49
+ block: 0,
50
+ }, {
51
+ currentBlock: context.borrowingV1.currentBlock,
52
+ group: context.borrowingV1.group,
53
+ pair: context.borrowingV1.pair,
54
+ collateralPriceUsd: context.collateralPriceUsd,
55
+ });
56
+ }
57
+ return {
58
+ fundingFeeCollateral,
59
+ borrowingFeeCollateral,
60
+ borrowingFeeCollateral_old,
61
+ totalFeeCollateral: fundingFeeCollateral +
62
+ borrowingFeeCollateral +
63
+ borrowingFeeCollateral_old,
64
+ };
65
+ };
66
+ exports.getTradePendingHoldingFeesCollateralStructured = getTradePendingHoldingFeesCollateralStructured;
@@ -35,10 +35,11 @@ const types_1 = require("../../../contracts/types");
35
35
  * @returns Total fee in collateral tokens
36
36
  */
37
37
  const getTotalTradeFeesCollateral = (collateralIndex, trader, pairIndex, positionSizeCollateral, isCounterTrade, context) => {
38
+ var _a;
38
39
  const { fee, collateralPriceUsd } = context;
39
40
  const { totalPositionSizeFeeP, minPositionSizeUsd } = fee;
40
41
  // Get counter trade fee rate multiplier (default 1 = 1x)
41
- const counterTradeFeeRateMultiplier = isCounterTrade && context.counterTradeSettings?.[pairIndex]
42
+ const counterTradeFeeRateMultiplier = isCounterTrade && ((_a = context.counterTradeSettings) === null || _a === void 0 ? void 0 : _a[pairIndex])
42
43
  ? context.counterTradeSettings[pairIndex].feeRateMultiplier
43
44
  : 1;
44
45
  // Apply counter trade multiplier to position size
@@ -118,10 +119,7 @@ const getTradePendingHoldingFeesCollateral = (trade, tradeInfo, tradeFeesData, c
118
119
  if (context.contractsVersion >= types_1.ContractsVersion.V10 &&
119
120
  context.funding &&
120
121
  tradeFeesData.initialAccFundingFeeP !== undefined) {
121
- fundingFeeCollateral = (0, fundingFees_1.getTradeFundingFeesCollateral)(trade, tradeInfo, tradeFeesData, currentPairPrice, {
122
- ...context.funding,
123
- currentTimestamp: context.currentTimestamp,
124
- });
122
+ fundingFeeCollateral = (0, fundingFees_1.getTradeFundingFeesCollateral)(trade, tradeInfo, tradeFeesData, currentPairPrice, Object.assign(Object.assign({}, context.funding), { currentTimestamp: context.currentTimestamp }));
125
123
  }
126
124
  // Calculate borrowing fees v2 (v10+ only)
127
125
  let borrowingFeeCollateral = 0;
@@ -17,6 +17,7 @@ const builder_4 = require("../fees/trading/builder");
17
17
  * @returns Complete context ready for getLiquidationPrice
18
18
  */
19
19
  const buildLiquidationPriceContext = (globalTradingVariables, tradeContainer, additionalParams) => {
20
+ var _a;
20
21
  const { trade, tradeInfo } = tradeContainer;
21
22
  const collateralIndex = trade.collateralIndex || 1;
22
23
  const collateral = globalTradingVariables.collaterals[collateralIndex - 1];
@@ -28,7 +29,7 @@ const buildLiquidationPriceContext = (globalTradingVariables, tradeContainer, ad
28
29
  core: {
29
30
  currentBlock: additionalParams.currentBlock,
30
31
  currentTimestamp: additionalParams.currentTimestamp,
31
- collateralPriceUsd: collateral.prices?.collateralPriceUsd || 1,
32
+ collateralPriceUsd: ((_a = collateral.prices) === null || _a === void 0 ? void 0 : _a.collateralPriceUsd) || 1,
32
33
  contractsVersion: tradeInfo.contractsVersion,
33
34
  spreadP: additionalParams.spreadP,
34
35
  },
@@ -36,11 +37,7 @@ const buildLiquidationPriceContext = (globalTradingVariables, tradeContainer, ad
36
37
  borrowingV1: (0, builder_1.buildBorrowingV1Context)(globalTradingVariables, collateralIndex, additionalParams.currentBlock),
37
38
  borrowingV2: (0, builder_2.buildBorrowingV2Context)(globalTradingVariables, collateralIndex, trade.pairIndex, additionalParams.currentTimestamp),
38
39
  funding: (0, builder_3.buildFundingContext)(globalTradingVariables, collateralIndex, trade.pairIndex, additionalParams.currentTimestamp),
39
- trading: {
40
- ...(0, builder_4.buildTradingFeesContext)(globalTradingVariables, trade.pairIndex, additionalParams.traderFeeMultiplier),
41
- counterTradeSettings: globalTradingVariables.counterTradeSettings,
42
- userPriceImpact: additionalParams.userPriceImpact,
43
- },
40
+ trading: Object.assign(Object.assign({}, (0, builder_4.buildTradingFeesContext)(globalTradingVariables, trade.pairIndex, additionalParams.traderFeeMultiplier)), { counterTradeSettings: globalTradingVariables.counterTradeSettings, userPriceImpact: additionalParams.userPriceImpact }),
44
41
  // Trade-specific data
45
42
  tradeData: {
46
43
  tradeInfo,
@@ -27,6 +27,7 @@ const __1 = require("..");
27
27
  * @returns Liquidation price
28
28
  */
29
29
  const getLiquidationPrice = (trade, context) => {
30
+ var _a, _b;
30
31
  // Extract parameters from structured context
31
32
  const { currentPairPrice, additionalFeeCollateral = 0, partialCloseMultiplier = 1, beforeOpened = false, isCounterTrade = false, } = context.liquidationSpecific;
32
33
  // 1. Calculate closing fees
@@ -71,9 +72,9 @@ const getLiquidationPrice = (trade, context) => {
71
72
  trade.leverage;
72
73
  // 6. Apply closing spread for v9.2+
73
74
  if (context.core.contractsVersion >= types_1.ContractsVersion.V9_2 &&
74
- ((context.tradeData.liquidationParams?.maxLiqSpreadP !== undefined &&
75
+ ((((_a = context.tradeData.liquidationParams) === null || _a === void 0 ? void 0 : _a.maxLiqSpreadP) !== undefined &&
75
76
  context.tradeData.liquidationParams.maxLiqSpreadP > 0) ||
76
- (context.liquidationSpecific.userPriceImpact?.fixedSpreadP !==
77
+ (((_b = context.liquidationSpecific.userPriceImpact) === null || _b === void 0 ? void 0 : _b.fixedSpreadP) !==
77
78
  undefined &&
78
79
  context.liquidationSpecific.userPriceImpact.fixedSpreadP > 0))) {
79
80
  const closingSpreadP = (0, __1.getSpreadP)(context.core.spreadP, true, context.tradeData.liquidationParams, context.liquidationSpecific.userPriceImpact);
@@ -98,6 +99,7 @@ exports.getLiquidationPrice = getLiquidationPrice;
98
99
  * @returns New liquidation price after the update
99
100
  */
100
101
  const getLiquidationPriceAfterPositionUpdate = (existingTrade, newCollateralAmount, newLeverage, isLeverageUpdate, positionSizeCollateralDelta, pnlToRealizeCollateral, context) => {
102
+ var _a, _b;
101
103
  const { currentPairPrice, isCounterTrade = false } = context.liquidationSpecific;
102
104
  // 1. Calculate closing fees on the new position size
103
105
  const closingFeeCollateral = (0, __1.getTotalTradeFeesCollateral)(existingTrade.collateralIndex, "", // No fee tiers applied for liquidation calculation
@@ -165,9 +167,9 @@ const getLiquidationPriceAfterPositionUpdate = (existingTrade, newCollateralAmou
165
167
  newLeverage;
166
168
  // 9. Apply closing spread for v9.2+
167
169
  if (context.core.contractsVersion >= types_1.ContractsVersion.V9_2 &&
168
- ((context.tradeData.liquidationParams?.maxLiqSpreadP !== undefined &&
170
+ ((((_a = context.tradeData.liquidationParams) === null || _a === void 0 ? void 0 : _a.maxLiqSpreadP) !== undefined &&
169
171
  context.tradeData.liquidationParams.maxLiqSpreadP > 0) ||
170
- (context.liquidationSpecific.userPriceImpact?.fixedSpreadP !==
172
+ (((_b = context.liquidationSpecific.userPriceImpact) === null || _b === void 0 ? void 0 : _b.fixedSpreadP) !==
171
173
  undefined &&
172
174
  context.liquidationSpecific.userPriceImpact.fixedSpreadP > 0))) {
173
175
  const closingSpreadP = (0, __1.getSpreadP)(context.core.spreadP, true, context.tradeData.liquidationParams, context.liquidationSpecific.userPriceImpact);
@@ -7,12 +7,13 @@ const getCurrentOiWindowId = (oiWindowSettings) => {
7
7
  };
8
8
  exports.getCurrentOiWindowId = getCurrentOiWindowId;
9
9
  const getActiveOi = (currentOiWindowId, windowsCount, oiWindows, buy) => {
10
+ var _a, _b;
10
11
  if (oiWindows === undefined || windowsCount === 0)
11
12
  return 0;
12
13
  let activeOi = 0;
13
14
  for (let id = currentOiWindowId - (windowsCount - 1); id <= currentOiWindowId; id++) {
14
15
  activeOi +=
15
- (buy ? oiWindows?.[id]?.oiLongUsd : oiWindows?.[id]?.oiShortUsd) || 0;
16
+ (buy ? (_a = oiWindows === null || oiWindows === void 0 ? void 0 : oiWindows[id]) === null || _a === void 0 ? void 0 : _a.oiLongUsd : (_b = oiWindows === null || oiWindows === void 0 ? void 0 : oiWindows[id]) === null || _b === void 0 ? void 0 : _b.oiShortUsd) || 0;
16
17
  }
17
18
  return activeOi;
18
19
  };
@@ -14,6 +14,7 @@ const builder_4 = require("../fees/trading/builder");
14
14
  * @returns Complete context ready for getComprehensivePnl
15
15
  */
16
16
  const buildComprehensivePnlContext = (globalTradingVariables, tradeContainer, additionalParams) => {
17
+ var _a;
17
18
  const { trade, tradeInfo } = tradeContainer;
18
19
  const collateralIndex = trade.collateralIndex || 1;
19
20
  const collateral = globalTradingVariables.collaterals[collateralIndex - 1];
@@ -22,7 +23,7 @@ const buildComprehensivePnlContext = (globalTradingVariables, tradeContainer, ad
22
23
  core: {
23
24
  currentBlock: additionalParams.currentBlock,
24
25
  currentTimestamp: additionalParams.currentTimestamp,
25
- collateralPriceUsd: collateral.prices?.collateralPriceUsd || 1,
26
+ collateralPriceUsd: ((_a = collateral.prices) === null || _a === void 0 ? void 0 : _a.collateralPriceUsd) || 1,
26
27
  contractsVersion: tradeInfo.contractsVersion,
27
28
  },
28
29
  // Build sub-contexts using dedicated builders
@@ -34,7 +34,7 @@ exports.encodePnlPercent = encodePnlPercent;
34
34
  */
35
35
  const convertCollateralAmount = (amount, collateralDecimals) => {
36
36
  const value = typeof amount === "bigint" ? Number(amount) : amount;
37
- return value / 10 ** collateralDecimals;
37
+ return value / Math.pow(10, collateralDecimals);
38
38
  };
39
39
  exports.convertCollateralAmount = convertCollateralAmount;
40
40
  /**
@@ -81,6 +81,7 @@ exports.getTradeValue = getTradeValue;
81
81
  * @returns Detailed PnL breakdown
82
82
  */
83
83
  const getComprehensivePnl = (trade, marketPrice, executionPrice, tradeInfo, context) => {
84
+ var _a;
84
85
  // Calculate both raw PnL (market price) and impact-adjusted PnL (execution price)
85
86
  let rawPnlPercent = (0, exports.getPnlPercent)(trade.openPrice, marketPrice, trade.long, trade.leverage);
86
87
  let impactPnlPercent = (0, exports.getPnlPercent)(trade.openPrice, executionPrice, trade.long, trade.leverage);
@@ -113,7 +114,7 @@ const getComprehensivePnl = (trade, marketPrice, executionPrice, tradeInfo, cont
113
114
  const totalHoldingFees = borrowingFeeV1 + borrowingFeeV2 + fundingFee;
114
115
  const totalFees = totalHoldingFees + closingFee;
115
116
  // Check liquidation (using raw PnL for liquidation check)
116
- const liquidationThreshold = context.tradeData?.liquidationParams
117
+ const liquidationThreshold = ((_a = context.tradeData) === null || _a === void 0 ? void 0 : _a.liquidationParams)
117
118
  ? (0, liquidation_1.getLiqPnlThresholdP)(context.tradeData.liquidationParams, trade.leverage) *
118
119
  -100
119
120
  : -90; // Default 90% loss
@@ -190,6 +191,7 @@ exports.getComprehensivePnl = getComprehensivePnl;
190
191
  * @returns [pnlCollateral, pnlPercentage] or undefined if no price
191
192
  */
192
193
  const getPnl = (price, trade, _tradeInfo, initialAccFees, liquidationParams, useFees, context) => {
194
+ var _a;
193
195
  if (!price) {
194
196
  return;
195
197
  }
@@ -221,7 +223,7 @@ const getPnl = (price, trade, _tradeInfo, initialAccFees, liquidationParams, use
221
223
  // Calculate closing fee using the same function as opening fees
222
224
  const positionSizeCollateral = posCollat * trade.leverage;
223
225
  const closingFee = (0, trading_1.getTotalTradeFeesCollateral)(0, // collateralIndex not used
224
- trade.user, trade.pairIndex, positionSizeCollateral, trade.isCounterTrade ?? false, {
226
+ trade.user, trade.pairIndex, positionSizeCollateral, (_a = trade.isCounterTrade) !== null && _a !== void 0 ? _a : false, {
225
227
  fee: context.fee,
226
228
  globalTradeFeeParams: context.globalTradeFeeParams,
227
229
  collateralPriceUsd: context.collateralPriceUsd || 1,
@@ -245,11 +247,12 @@ exports.getPnl = getPnl;
245
247
  * @returns The price that would result in the target PnL percentage
246
248
  */
247
249
  const getPriceForTargetPnlPercentage = (targetPnlPercent, trade, tradeInfo, context, netPnl = false) => {
250
+ var _a, _b;
248
251
  const { leverage, openPrice, long, collateralAmount } = trade;
249
252
  const positionSizeCollateral = collateralAmount * leverage;
250
253
  // Calculate holding fees - always use getTradePendingHoldingFeesCollateral
251
254
  // This mirrors the contract's getTradeValueCollateral which always calls this function
252
- const fees = (0, trading_1.getTradePendingHoldingFeesCollateral)(trade, tradeInfo, context.tradeData?.tradeFeesData || {
255
+ const fees = (0, trading_1.getTradePendingHoldingFeesCollateral)(trade, tradeInfo, ((_a = context.tradeData) === null || _a === void 0 ? void 0 : _a.tradeFeesData) || {
253
256
  realizedTradingFeesCollateral: 0,
254
257
  realizedPnlCollateral: 0,
255
258
  manuallyRealizedNegativePnlCollateral: 0,
@@ -265,7 +268,7 @@ const getPriceForTargetPnlPercentage = (targetPnlPercent, trade, tradeInfo, cont
265
268
  borrowingV1: context.borrowingV1,
266
269
  borrowingV2: context.borrowingV2,
267
270
  funding: context.funding,
268
- initialAccFees: context.tradeData?.initialAccFees,
271
+ initialAccFees: (_b = context.tradeData) === null || _b === void 0 ? void 0 : _b.initialAccFees,
269
272
  });
270
273
  const totalHoldingFees = fees.fundingFeeCollateral +
271
274
  fees.borrowingFeeCollateral +
@@ -14,6 +14,7 @@ const builder_2 = require("../skew/builder");
14
14
  * @returns Complete context ready for getTradeClosingPriceImpact
15
15
  */
16
16
  const buildTradeClosingPriceImpactContext = (globalTradingVariables, collateralIndex, pairIndex, tradeInfo, additionalParams) => {
17
+ var _a;
17
18
  const collateral = globalTradingVariables.collaterals[collateralIndex - 1];
18
19
  if (!collateral) {
19
20
  return undefined;
@@ -35,7 +36,7 @@ const buildTradeClosingPriceImpactContext = (globalTradingVariables, collateralI
35
36
  }
36
37
  // Return structured context with proper subcontexts
37
38
  return {
38
- collateralPriceUsd: collateral.prices?.collateralPriceUsd || 1,
39
+ collateralPriceUsd: ((_a = collateral.prices) === null || _a === void 0 ? void 0 : _a.collateralPriceUsd) || 1,
39
40
  cumulVolContext,
40
41
  skewContext,
41
42
  tradeInfo,
@@ -129,9 +129,6 @@ exports.getTradeClosingPriceImpact = getTradeClosingPriceImpact;
129
129
  * @returns Price impact breakdown and trade value
130
130
  */
131
131
  const getTradeClosingPriceImpactAtOracle = (input, context) => {
132
- return (0, exports.getTradeClosingPriceImpact)({
133
- ...input,
134
- currentPairPrice: input.oraclePrice,
135
- }, context);
132
+ return (0, exports.getTradeClosingPriceImpact)(Object.assign(Object.assign({}, input), { currentPairPrice: input.oraclePrice }), context);
136
133
  };
137
134
  exports.getTradeClosingPriceImpactAtOracle = getTradeClosingPriceImpactAtOracle;