@gainsnetwork/sdk 0.2.71-rc4 → 1.0.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 (247) hide show
  1. package/README.md +2 -2
  2. package/lib/backend/globalTrades/index.d.ts +11 -0
  3. package/lib/backend/globalTrades/index.js +69 -0
  4. package/lib/backend/index.d.ts +3 -0
  5. package/lib/backend/index.js +28 -0
  6. package/lib/backend/tradingVariables/backend.types.d.ts +318 -0
  7. package/lib/backend/tradingVariables/backend.types.js +2 -0
  8. package/lib/backend/tradingVariables/converter.d.ts +34 -0
  9. package/lib/backend/tradingVariables/converter.js +338 -0
  10. package/lib/backend/tradingVariables/index.d.ts +5 -0
  11. package/lib/backend/tradingVariables/index.js +96 -0
  12. package/lib/backend/tradingVariables/types.d.ts +113 -0
  13. package/lib/backend/tradingVariables/types.js +14 -0
  14. package/lib/constants.d.ts +0 -3
  15. package/lib/constants.js +7 -9
  16. package/lib/contracts/types/generated/GFarmTradingStorageV5.d.ts +1911 -0
  17. package/lib/contracts/types/generated/GFarmTradingStorageV5.js +2 -0
  18. package/lib/contracts/types/generated/GNSBorrowingFees.d.ts +1067 -0
  19. package/lib/contracts/types/generated/GNSBorrowingFees.js +2 -0
  20. package/lib/contracts/types/generated/GNSBorrowingFeesV6_3_2.d.ts +979 -0
  21. package/lib/contracts/types/generated/GNSBorrowingFeesV6_3_2.js +2 -0
  22. package/lib/contracts/types/generated/GNSBorrowingFeesV6_4.d.ts +1058 -0
  23. package/lib/contracts/types/generated/GNSBorrowingFeesV6_4.js +2 -0
  24. package/lib/contracts/types/generated/GNSMultiCollatDiamond.d.ts +2134 -293
  25. package/lib/contracts/types/generated/GNSNftRewardsV6.d.ts +533 -0
  26. package/lib/contracts/types/generated/GNSNftRewardsV6.js +2 -0
  27. package/lib/contracts/types/generated/GNSNftRewardsV6_3_1.d.ts +613 -0
  28. package/lib/contracts/types/generated/GNSNftRewardsV6_3_1.js +2 -0
  29. package/lib/contracts/types/generated/GNSPairInfosV6_1.d.ts +911 -0
  30. package/lib/contracts/types/generated/GNSPairInfosV6_1.js +2 -0
  31. package/lib/contracts/types/generated/GNSPairsStorageV6.d.ts +660 -0
  32. package/lib/contracts/types/generated/GNSPairsStorageV6.js +2 -0
  33. package/lib/contracts/types/generated/GNSTrading.d.ts +758 -0
  34. package/lib/contracts/types/generated/GNSTrading.js +2 -0
  35. package/lib/contracts/types/generated/GNSTradingCallbacks.d.ts +875 -0
  36. package/lib/contracts/types/generated/GNSTradingCallbacks.js +2 -0
  37. package/lib/contracts/types/generated/GNSTradingCallbacksV6_3_2.d.ts +806 -0
  38. package/lib/contracts/types/generated/GNSTradingCallbacksV6_3_2.js +2 -0
  39. package/lib/contracts/types/generated/GNSTradingCallbacksV6_4.d.ts +821 -0
  40. package/lib/contracts/types/generated/GNSTradingCallbacksV6_4.js +2 -0
  41. package/lib/contracts/types/generated/GNSTradingStorage.d.ts +1387 -0
  42. package/lib/contracts/types/generated/GNSTradingStorage.js +2 -0
  43. package/lib/contracts/types/generated/GToken.d.ts +78 -107
  44. package/lib/contracts/types/generated/GTokenV6_3_2.d.ts +1838 -0
  45. package/lib/contracts/types/generated/GTokenV6_3_2.js +2 -0
  46. package/lib/contracts/types/generated/factories/GFarmTradingStorageV5__factory.d.ts +83 -0
  47. package/lib/contracts/types/generated/factories/GFarmTradingStorageV5__factory.js +2691 -0
  48. package/lib/contracts/types/generated/factories/GNSBorrowingFeesV6_3_2__factory.d.ts +88 -0
  49. package/lib/contracts/types/generated/factories/GNSBorrowingFeesV6_3_2__factory.js +1654 -0
  50. package/lib/contracts/types/generated/factories/GNSBorrowingFeesV6_4__factory.d.ts +113 -0
  51. package/lib/contracts/types/generated/factories/GNSBorrowingFeesV6_4__factory.js +1742 -0
  52. package/lib/contracts/types/generated/factories/GNSBorrowingFees__factory.d.ts +124 -0
  53. package/lib/contracts/types/generated/factories/GNSBorrowingFees__factory.js +1784 -0
  54. package/lib/contracts/types/generated/factories/GNSMultiCollatDiamond__factory.d.ts +90 -53
  55. package/lib/contracts/types/generated/factories/GNSMultiCollatDiamond__factory.js +4496 -430
  56. package/lib/contracts/types/generated/factories/GNSNftRewardsV6_3_1__factory.d.ts +100 -0
  57. package/lib/contracts/types/generated/factories/GNSNftRewardsV6_3_1__factory.js +1116 -0
  58. package/lib/contracts/types/generated/factories/GNSNftRewardsV6__factory.d.ts +100 -0
  59. package/lib/contracts/types/generated/factories/GNSNftRewardsV6__factory.js +1003 -0
  60. package/lib/contracts/types/generated/factories/GNSPairInfosV6_1__factory.d.ts +98 -0
  61. package/lib/contracts/types/generated/factories/GNSPairInfosV6_1__factory.js +1485 -0
  62. package/lib/contracts/types/generated/factories/GNSPairsStorageV6__factory.d.ts +117 -0
  63. package/lib/contracts/types/generated/factories/GNSPairsStorageV6__factory.js +1265 -0
  64. package/lib/contracts/types/generated/factories/GNSTradingCallbacksV6_3_2__factory.d.ts +82 -0
  65. package/lib/contracts/types/generated/factories/GNSTradingCallbacksV6_3_2__factory.js +1273 -0
  66. package/lib/contracts/types/generated/factories/GNSTradingCallbacksV6_4__factory.d.ts +82 -0
  67. package/lib/contracts/types/generated/factories/GNSTradingCallbacksV6_4__factory.js +1326 -0
  68. package/lib/contracts/types/generated/factories/GNSTradingCallbacks__factory.d.ts +113 -0
  69. package/lib/contracts/types/generated/factories/GNSTradingCallbacks__factory.js +1428 -0
  70. package/lib/contracts/types/generated/factories/GNSTradingStorage__factory.d.ts +96 -0
  71. package/lib/contracts/types/generated/factories/GNSTradingStorage__factory.js +2241 -0
  72. package/lib/contracts/types/generated/factories/GNSTrading__factory.d.ts +95 -0
  73. package/lib/contracts/types/generated/factories/GNSTrading__factory.js +1071 -0
  74. package/lib/contracts/types/generated/factories/GTokenV6_3_2__factory.d.ts +110 -0
  75. package/lib/contracts/types/generated/factories/GTokenV6_3_2__factory.js +2682 -0
  76. package/lib/contracts/types/generated/factories/GToken__factory.d.ts +7 -0
  77. package/lib/contracts/types/generated/factories/GToken__factory.js +69 -142
  78. package/lib/contracts/types/index.d.ts +2 -1
  79. package/lib/contracts/types/index.js +1 -0
  80. package/lib/contracts/utils/openTrades.d.ts +1 -0
  81. package/lib/contracts/utils/openTrades.js +94 -56
  82. package/lib/contracts/utils/pairs.js +0 -3
  83. package/lib/index.d.ts +2 -0
  84. package/lib/index.js +5 -0
  85. package/lib/markets/collateral/converter.d.ts +5 -0
  86. package/lib/markets/collateral/converter.js +11 -0
  87. package/lib/markets/collateral/index.d.ts +1 -0
  88. package/lib/markets/collateral/index.js +17 -0
  89. package/lib/markets/collateral/types.d.ts +7 -0
  90. package/lib/markets/collateral/types.js +2 -0
  91. package/lib/markets/holdingFees/index.d.ts +46 -0
  92. package/lib/markets/holdingFees/index.js +105 -0
  93. package/lib/markets/holdingFees/types.d.ts +23 -0
  94. package/lib/markets/holdingFees/types.js +5 -0
  95. package/lib/markets/index.d.ts +5 -0
  96. package/lib/markets/index.js +5 -0
  97. package/lib/markets/leverage/builder.d.ts +12 -0
  98. package/lib/markets/leverage/builder.js +25 -0
  99. package/lib/markets/leverage/getMarketLeverageRestrictions.d.ts +7 -0
  100. package/lib/markets/leverage/getMarketLeverageRestrictions.js +38 -0
  101. package/lib/markets/leverage/index.d.ts +3 -0
  102. package/lib/markets/leverage/index.js +19 -0
  103. package/lib/markets/leverage/types.d.ts +15 -0
  104. package/lib/markets/leverage/types.js +2 -0
  105. package/lib/markets/oi/converter.d.ts +62 -0
  106. package/lib/markets/oi/converter.js +102 -0
  107. package/lib/markets/oi/fetcher.d.ts +58 -0
  108. package/lib/markets/oi/fetcher.js +181 -0
  109. package/lib/markets/oi/index.d.ts +49 -0
  110. package/lib/markets/oi/index.js +77 -0
  111. package/lib/markets/oi/types.d.ts +73 -0
  112. package/lib/markets/oi/types.js +6 -0
  113. package/lib/markets/oi/validation.d.ts +80 -0
  114. package/lib/markets/oi/validation.js +172 -0
  115. package/lib/markets/price/builder.d.ts +25 -0
  116. package/lib/markets/price/builder.js +69 -0
  117. package/lib/markets/price/index.d.ts +6 -0
  118. package/lib/markets/price/index.js +22 -0
  119. package/lib/markets/price/marketPrice.d.ts +13 -0
  120. package/lib/markets/price/marketPrice.js +35 -0
  121. package/lib/markets/price/types.d.ts +23 -0
  122. package/lib/markets/price/types.js +5 -0
  123. package/lib/trade/counterTrade/index.d.ts +2 -0
  124. package/lib/trade/counterTrade/index.js +18 -0
  125. package/lib/trade/counterTrade/types.d.ts +7 -0
  126. package/lib/trade/counterTrade/types.js +2 -0
  127. package/lib/trade/counterTrade/validateCounterTrade.d.ts +10 -0
  128. package/lib/trade/counterTrade/validateCounterTrade.js +29 -0
  129. package/lib/trade/effectiveLeverage/builder.d.ts +23 -0
  130. package/lib/trade/effectiveLeverage/builder.js +30 -0
  131. package/lib/trade/effectiveLeverage/getTradeNewEffectiveLeverage.d.ts +23 -0
  132. package/lib/trade/effectiveLeverage/getTradeNewEffectiveLeverage.js +64 -0
  133. package/lib/trade/effectiveLeverage/index.d.ts +3 -0
  134. package/lib/trade/effectiveLeverage/index.js +22 -0
  135. package/lib/trade/effectiveLeverage/types.d.ts +33 -0
  136. package/lib/trade/effectiveLeverage/types.js +2 -0
  137. package/lib/trade/fees/borrowing/builder.d.ts +14 -0
  138. package/lib/trade/fees/borrowing/builder.js +33 -0
  139. package/lib/trade/fees/borrowing/index.d.ts +23 -2
  140. package/lib/trade/fees/borrowing/index.js +50 -16
  141. package/lib/trade/fees/borrowingV2/builder.d.ts +6 -0
  142. package/lib/trade/fees/borrowingV2/builder.js +24 -0
  143. package/lib/trade/fees/borrowingV2/converter.d.ts +75 -0
  144. package/lib/trade/fees/borrowingV2/converter.js +132 -0
  145. package/lib/trade/fees/borrowingV2/fetcher.d.ts +75 -0
  146. package/lib/trade/fees/borrowingV2/fetcher.js +185 -0
  147. package/lib/trade/fees/borrowingV2/index.d.ts +48 -0
  148. package/lib/trade/fees/borrowingV2/index.js +112 -0
  149. package/lib/trade/fees/borrowingV2/types.d.ts +95 -0
  150. package/lib/trade/fees/borrowingV2/types.js +5 -0
  151. package/lib/trade/fees/converter.d.ts +48 -0
  152. package/lib/trade/fees/converter.js +114 -0
  153. package/lib/trade/fees/fundingFees/builder.d.ts +9 -0
  154. package/lib/trade/fees/fundingFees/builder.js +35 -0
  155. package/lib/trade/fees/fundingFees/converter.d.ts +102 -0
  156. package/lib/trade/fees/fundingFees/converter.js +196 -0
  157. package/lib/trade/fees/fundingFees/fetcher.d.ts +66 -0
  158. package/lib/trade/fees/fundingFees/fetcher.js +150 -0
  159. package/lib/trade/fees/fundingFees/index.d.ts +124 -0
  160. package/lib/trade/fees/fundingFees/index.js +309 -0
  161. package/lib/trade/fees/fundingFees/pairContext.d.ts +33 -0
  162. package/lib/trade/fees/fundingFees/pairContext.js +17 -0
  163. package/lib/trade/fees/fundingFees/types.d.ts +77 -0
  164. package/lib/trade/fees/fundingFees/types.js +5 -0
  165. package/lib/trade/fees/holdingFees/index.d.ts +46 -0
  166. package/lib/trade/fees/holdingFees/index.js +105 -0
  167. package/lib/trade/fees/holdingFees/types.d.ts +23 -0
  168. package/lib/trade/fees/holdingFees/types.js +5 -0
  169. package/lib/trade/fees/index.d.ts +8 -2
  170. package/lib/trade/fees/index.js +67 -16
  171. package/lib/trade/fees/tiers/converter.d.ts +54 -0
  172. package/lib/trade/fees/tiers/converter.js +81 -0
  173. package/lib/trade/fees/tiers/index.d.ts +18 -0
  174. package/lib/trade/fees/tiers/index.js +45 -1
  175. package/lib/trade/fees/trading/builder.d.ts +18 -0
  176. package/lib/trade/fees/trading/builder.js +20 -0
  177. package/lib/trade/fees/trading/converter.d.ts +32 -0
  178. package/lib/trade/fees/trading/converter.js +47 -0
  179. package/lib/trade/fees/trading/holdingFees.d.ts +28 -0
  180. package/lib/trade/fees/trading/holdingFees.js +66 -0
  181. package/lib/trade/fees/trading/holdingFeesStructured.d.ts +28 -0
  182. package/lib/trade/fees/trading/holdingFeesStructured.js +66 -0
  183. package/lib/trade/fees/trading/index.d.ts +62 -0
  184. package/lib/trade/fees/trading/index.js +155 -0
  185. package/lib/trade/fees/trading/types.d.ts +48 -0
  186. package/lib/trade/fees/trading/types.js +5 -0
  187. package/lib/trade/index.d.ts +5 -2
  188. package/lib/trade/index.js +5 -2
  189. package/lib/trade/liquidation/builder.d.ts +25 -0
  190. package/lib/trade/liquidation/builder.js +59 -0
  191. package/lib/trade/liquidation/converter.d.ts +23 -0
  192. package/lib/trade/liquidation/converter.js +46 -0
  193. package/lib/trade/liquidation/index.d.ts +29 -0
  194. package/lib/trade/liquidation/index.js +218 -0
  195. package/lib/trade/liquidation/types.d.ts +43 -0
  196. package/lib/trade/liquidation/types.js +2 -0
  197. package/lib/trade/pnl/builder.d.ts +16 -0
  198. package/lib/trade/pnl/builder.js +44 -0
  199. package/lib/trade/pnl/converter.d.ts +47 -0
  200. package/lib/trade/pnl/converter.js +72 -0
  201. package/lib/trade/pnl/index.d.ts +89 -0
  202. package/lib/trade/pnl/index.js +302 -0
  203. package/lib/trade/pnl/types.d.ts +79 -0
  204. package/lib/trade/pnl/types.js +5 -0
  205. package/lib/trade/priceImpact/close/builder.d.ts +23 -0
  206. package/lib/trade/priceImpact/close/builder.js +45 -0
  207. package/lib/trade/priceImpact/close/index.d.ts +22 -0
  208. package/lib/trade/priceImpact/close/index.js +134 -0
  209. package/lib/trade/priceImpact/close/types.d.ts +47 -0
  210. package/lib/trade/priceImpact/close/types.js +5 -0
  211. package/lib/trade/priceImpact/cumulVol/builder.d.ts +22 -0
  212. package/lib/trade/priceImpact/cumulVol/builder.js +43 -0
  213. package/lib/trade/priceImpact/cumulVol/converter.d.ts +31 -0
  214. package/lib/trade/priceImpact/cumulVol/converter.js +59 -0
  215. package/lib/trade/priceImpact/cumulVol/index.d.ts +108 -0
  216. package/lib/trade/priceImpact/cumulVol/index.js +235 -0
  217. package/lib/trade/priceImpact/index.d.ts +21 -0
  218. package/lib/trade/priceImpact/index.js +79 -0
  219. package/lib/trade/priceImpact/open/builder.d.ts +21 -0
  220. package/lib/trade/priceImpact/open/builder.js +43 -0
  221. package/lib/trade/priceImpact/open/index.d.ts +23 -0
  222. package/lib/trade/priceImpact/open/index.js +78 -0
  223. package/lib/trade/priceImpact/open/types.d.ts +44 -0
  224. package/lib/trade/priceImpact/open/types.js +5 -0
  225. package/lib/trade/priceImpact/skew/builder.d.ts +12 -0
  226. package/lib/trade/priceImpact/skew/builder.js +28 -0
  227. package/lib/trade/priceImpact/skew/converter.d.ts +46 -0
  228. package/lib/trade/priceImpact/skew/converter.js +81 -0
  229. package/lib/trade/priceImpact/skew/fetcher.d.ts +60 -0
  230. package/lib/trade/priceImpact/skew/fetcher.js +169 -0
  231. package/lib/trade/priceImpact/skew/index.d.ts +53 -0
  232. package/lib/trade/priceImpact/skew/index.js +148 -0
  233. package/lib/trade/priceImpact/skew/types.d.ts +44 -0
  234. package/lib/trade/priceImpact/skew/types.js +5 -0
  235. package/lib/trade/spread.d.ts +5 -18
  236. package/lib/trade/spread.js +17 -106
  237. package/lib/trade/types.d.ts +109 -12
  238. package/lib/trade/types.js +0 -3
  239. package/lib/trade/utils.d.ts +18 -0
  240. package/lib/trade/utils.js +30 -0
  241. package/lib/vault/index.d.ts +3 -1
  242. package/lib/vault/index.js +2 -2
  243. package/package.json +2 -1
  244. package/lib/trade/liquidation.d.ts +0 -12
  245. package/lib/trade/liquidation.js +0 -55
  246. package/lib/trade/pnl.d.ts +0 -10
  247. package/lib/trade/pnl.js +0 -33
@@ -0,0 +1,218 @@
1
+ "use strict";
2
+ /**
3
+ * @dev Main export file for liquidation module
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.encodeLiquidationParams = exports.convertLiquidationParamsArray = exports.convertLiquidationParams = exports.getLiqPnlThresholdP = exports.getLiquidationPriceAfterPositionUpdate = exports.getLiquidationPrice = void 0;
21
+ const types_1 = require("../../contracts/types");
22
+ const __1 = require("..");
23
+ /**
24
+ * @dev Calculate liquidation price with structured context
25
+ * @param trade The trade to calculate liquidation price for
26
+ * @param context Structured context with all required data
27
+ * @returns Liquidation price
28
+ */
29
+ const getLiquidationPrice = (trade, context) => {
30
+ var _a, _b;
31
+ // Extract parameters from structured context
32
+ const { currentPairPrice, additionalFeeCollateral = 0, partialCloseMultiplier = 1, beforeOpened = false, isCounterTrade = false, } = context.liquidationSpecific;
33
+ // 1. Calculate closing fees
34
+ const closingFee = (0, __1.getTotalTradeFeesCollateral)(trade.collateralIndex, "", // No fee tiers applied for liquidation calculation
35
+ trade.pairIndex, trade.collateralAmount * trade.leverage, isCounterTrade, {
36
+ fee: context.trading.fee,
37
+ collateralPriceUsd: context.core.collateralPriceUsd,
38
+ globalTradeFeeParams: context.trading.globalTradeFeeParams,
39
+ traderFeeMultiplier: 1,
40
+ counterTradeSettings: context.trading.counterTradeSettings,
41
+ });
42
+ // 2. Calculate holding fees and realized PnL for opened trades
43
+ let holdingFeesTotal = 0;
44
+ let totalRealizedPnlCollateral = 0;
45
+ if (!beforeOpened) {
46
+ // Calculate holding fees
47
+ const holdingFees = (0, __1.getTradePendingHoldingFeesCollateral)(trade, context.tradeData.tradeInfo, context.tradeData.tradeFeesData, currentPairPrice, {
48
+ contractsVersion: context.core.contractsVersion,
49
+ currentTimestamp: context.core.currentTimestamp,
50
+ collateralPriceUsd: context.core.collateralPriceUsd,
51
+ borrowingV1: context.borrowingV1,
52
+ borrowingV2: context.borrowingV2,
53
+ funding: context.funding,
54
+ initialAccFees: context.tradeData.initialAccFees,
55
+ });
56
+ holdingFeesTotal = holdingFees.totalFeeCollateral;
57
+ // Calculate total realized PnL (realized PnL minus realized trading fees)
58
+ totalRealizedPnlCollateral =
59
+ context.tradeData.tradeFeesData.realizedPnlCollateral -
60
+ context.tradeData.tradeFeesData.realizedTradingFeesCollateral;
61
+ }
62
+ // 3. Apply unified formula for all trades
63
+ const totalFeesCollateral = closingFee +
64
+ (holdingFeesTotal - totalRealizedPnlCollateral) * partialCloseMultiplier +
65
+ additionalFeeCollateral;
66
+ // 4. Calculate liquidation threshold
67
+ const liqThresholdP = (0, exports.getLiqPnlThresholdP)(context.tradeData.liquidationParams, trade.leverage);
68
+ // 5. Calculate liquidation price distance
69
+ const collateralLiqNegativePnl = trade.collateralAmount * liqThresholdP;
70
+ let liqPriceDistance = (trade.openPrice * (collateralLiqNegativePnl - totalFeesCollateral)) /
71
+ trade.collateralAmount /
72
+ trade.leverage;
73
+ // 6. Apply closing spread for v9.2+
74
+ if (context.core.contractsVersion >= types_1.ContractsVersion.V9_2 &&
75
+ ((((_a = context.tradeData.liquidationParams) === null || _a === void 0 ? void 0 : _a.maxLiqSpreadP) !== undefined &&
76
+ context.tradeData.liquidationParams.maxLiqSpreadP > 0) ||
77
+ (((_b = context.liquidationSpecific.userPriceImpact) === null || _b === void 0 ? void 0 : _b.fixedSpreadP) !==
78
+ undefined &&
79
+ context.liquidationSpecific.userPriceImpact.fixedSpreadP > 0))) {
80
+ const closingSpreadP = (0, __1.getSpreadP)(context.core.spreadP, true, context.tradeData.liquidationParams, context.liquidationSpecific.userPriceImpact);
81
+ liqPriceDistance -= trade.openPrice * closingSpreadP;
82
+ }
83
+ // 7. Calculate final liquidation price
84
+ return trade.long
85
+ ? Math.max(trade.openPrice - liqPriceDistance, 0)
86
+ : Math.max(trade.openPrice + liqPriceDistance, 0);
87
+ };
88
+ exports.getLiquidationPrice = getLiquidationPrice;
89
+ /**
90
+ * @dev Calculate liquidation price after a position size update
91
+ * @dev Mirrors the contract's IncreasePositionSizeUtils.sol and DecreasePositionSizeUtils.sol logic
92
+ * @param existingTrade The current trade before the update
93
+ * @param newCollateralAmount New collateral amount after the update
94
+ * @param newLeverage New leverage after the update
95
+ * @param isLeverageUpdate Whether this is a leverage update vs regular position change
96
+ * @param positionSizeCollateralDelta The absolute change in position size (in collateral terms)
97
+ * @param pnlToRealizeCollateral PnL to be realized (only relevant for leverage decrease)
98
+ * @param context Structured context with all required data (including additionalFeesCollateral for increases)
99
+ * @returns New liquidation price after the update
100
+ */
101
+ const getLiquidationPriceAfterPositionUpdate = (existingTrade, newCollateralAmount, newLeverage, isLeverageUpdate, positionSizeCollateralDelta, pnlToRealizeCollateral, context) => {
102
+ var _a, _b;
103
+ const { currentPairPrice, isCounterTrade = false } = context.liquidationSpecific;
104
+ // 1. Calculate closing fees on the new position size
105
+ const closingFeeCollateral = (0, __1.getTotalTradeFeesCollateral)(existingTrade.collateralIndex, "", // No fee tiers applied for liquidation calculation
106
+ existingTrade.pairIndex, newCollateralAmount * newLeverage, isCounterTrade, {
107
+ fee: context.trading.fee,
108
+ collateralPriceUsd: context.core.collateralPriceUsd,
109
+ globalTradeFeeParams: context.trading.globalTradeFeeParams,
110
+ traderFeeMultiplier: 1,
111
+ counterTradeSettings: context.trading.counterTradeSettings,
112
+ });
113
+ // 2. Calculate holding fees on the EXISTING trade (full position)
114
+ const holdingFees = (0, __1.getTradePendingHoldingFeesCollateral)(existingTrade, context.tradeData.tradeInfo, context.tradeData.tradeFeesData, currentPairPrice, {
115
+ contractsVersion: context.core.contractsVersion,
116
+ currentTimestamp: context.core.currentTimestamp,
117
+ collateralPriceUsd: context.core.collateralPriceUsd,
118
+ borrowingV1: context.borrowingV1,
119
+ borrowingV2: context.borrowingV2,
120
+ funding: context.funding,
121
+ initialAccFees: context.tradeData.initialAccFees,
122
+ });
123
+ // 3. Calculate total realized PnL
124
+ const totalRealizedPnlCollateral = context.tradeData.tradeFeesData.realizedPnlCollateral -
125
+ context.tradeData.tradeFeesData.realizedTradingFeesCollateral;
126
+ // 4. Determine if this is an increase or decrease
127
+ const existingPositionSizeCollateral = existingTrade.collateralAmount * existingTrade.leverage;
128
+ const newPositionSizeCollateral = newCollateralAmount * newLeverage;
129
+ const isIncrease = newPositionSizeCollateral > existingPositionSizeCollateral;
130
+ // 5. Calculate additional fee and partial close multiplier based on update type
131
+ let additionalFeeCollateral;
132
+ let partialCloseMultiplier;
133
+ if (isIncrease) {
134
+ // For position increases: use additional fees from context (e.g., opening fees)
135
+ additionalFeeCollateral =
136
+ context.liquidationSpecific.additionalFeeCollateral || 0;
137
+ partialCloseMultiplier = 1; // Set to 1
138
+ }
139
+ else if (isLeverageUpdate) {
140
+ // For leverage decreases: additional fee includes closing fee minus PnL to realize
141
+ additionalFeeCollateral = closingFeeCollateral - pnlToRealizeCollateral;
142
+ partialCloseMultiplier = 1; // Full multiplier for leverage updates
143
+ }
144
+ else {
145
+ // For regular position decreases: no additional fee, scaled multiplier
146
+ additionalFeeCollateral = 0;
147
+ partialCloseMultiplier =
148
+ (existingPositionSizeCollateral - positionSizeCollateralDelta) /
149
+ existingPositionSizeCollateral;
150
+ }
151
+ // 6. Calculate total fees
152
+ const totalFeesCollateral = closingFeeCollateral +
153
+ (holdingFees.totalFeeCollateral - totalRealizedPnlCollateral) *
154
+ partialCloseMultiplier +
155
+ additionalFeeCollateral;
156
+ // 7. Calculate liquidation threshold
157
+ const liqThresholdP = (0, exports.getLiqPnlThresholdP)(context.tradeData.liquidationParams, newLeverage);
158
+ // 8. Calculate liquidation price distance
159
+ const collateralLiqNegativePnl = newCollateralAmount * liqThresholdP;
160
+ // For increases, we need to use the new weighted average open price
161
+ // For decreases, we use the existing open price
162
+ const openPriceToUse = isIncrease
163
+ ? context.liquidationSpecific.newOpenPrice || existingTrade.openPrice
164
+ : existingTrade.openPrice;
165
+ let liqPriceDistance = (openPriceToUse * (collateralLiqNegativePnl - totalFeesCollateral)) /
166
+ newCollateralAmount /
167
+ newLeverage;
168
+ // 9. Apply closing spread for v9.2+
169
+ if (context.core.contractsVersion >= types_1.ContractsVersion.V9_2 &&
170
+ ((((_a = context.tradeData.liquidationParams) === null || _a === void 0 ? void 0 : _a.maxLiqSpreadP) !== undefined &&
171
+ context.tradeData.liquidationParams.maxLiqSpreadP > 0) ||
172
+ (((_b = context.liquidationSpecific.userPriceImpact) === null || _b === void 0 ? void 0 : _b.fixedSpreadP) !==
173
+ undefined &&
174
+ context.liquidationSpecific.userPriceImpact.fixedSpreadP > 0))) {
175
+ const closingSpreadP = (0, __1.getSpreadP)(context.core.spreadP, true, context.tradeData.liquidationParams, context.liquidationSpecific.userPriceImpact);
176
+ liqPriceDistance -= openPriceToUse * closingSpreadP;
177
+ }
178
+ // 10. Calculate final liquidation price
179
+ return existingTrade.long
180
+ ? Math.max(openPriceToUse - liqPriceDistance, 0)
181
+ : Math.max(openPriceToUse + liqPriceDistance, 0);
182
+ };
183
+ exports.getLiquidationPriceAfterPositionUpdate = getLiquidationPriceAfterPositionUpdate;
184
+ const getLiqPnlThresholdP = (liquidationParams, leverage) => {
185
+ if (liquidationParams === undefined ||
186
+ leverage === undefined ||
187
+ liquidationParams.maxLiqSpreadP === 0 ||
188
+ liquidationParams.startLiqThresholdP === 0 ||
189
+ liquidationParams.endLiqThresholdP === 0 ||
190
+ liquidationParams.startLeverage === 0 ||
191
+ liquidationParams.endLeverage === 0) {
192
+ return 0.9;
193
+ }
194
+ if (leverage < liquidationParams.startLeverage) {
195
+ return liquidationParams.startLiqThresholdP;
196
+ }
197
+ if (leverage > liquidationParams.endLeverage) {
198
+ return liquidationParams.endLiqThresholdP;
199
+ }
200
+ if (liquidationParams.startLiqThresholdP === liquidationParams.endLiqThresholdP) {
201
+ return liquidationParams.endLiqThresholdP;
202
+ }
203
+ return (liquidationParams.startLiqThresholdP -
204
+ ((leverage - liquidationParams.startLeverage) *
205
+ (liquidationParams.startLiqThresholdP -
206
+ liquidationParams.endLiqThresholdP)) /
207
+ (liquidationParams.endLeverage - liquidationParams.startLeverage));
208
+ };
209
+ exports.getLiqPnlThresholdP = getLiqPnlThresholdP;
210
+ // Converters
211
+ var converter_1 = require("./converter");
212
+ Object.defineProperty(exports, "convertLiquidationParams", { enumerable: true, get: function () { return converter_1.convertLiquidationParams; } });
213
+ Object.defineProperty(exports, "convertLiquidationParamsArray", { enumerable: true, get: function () { return converter_1.convertLiquidationParamsArray; } });
214
+ Object.defineProperty(exports, "encodeLiquidationParams", { enumerable: true, get: function () { return converter_1.encodeLiquidationParams; } });
215
+ // Types
216
+ __exportStar(require("./types"), exports);
217
+ // Builder
218
+ __exportStar(require("./builder"), exports);
@@ -0,0 +1,43 @@
1
+ import { GetBorrowingFeeContext, BorrowingFee } from "./../fees";
2
+ import { LiquidationParams, UserPriceImpact, TradeFeesData, TradeInfo, CounterTradeSettings } from "./../types";
3
+ import { ContractsVersion } from "../../contracts/types";
4
+ import { GetPairBorrowingFeeV2Context } from "../fees/borrowingV2";
5
+ import { GetPairFundingFeeContext } from "../fees/fundingFees";
6
+ import { TradingFeesSubContext } from "../fees/trading/builder";
7
+ /**
8
+ * @dev Structured context for liquidation price calculations
9
+ * @dev Follows the same pattern as GetComprehensivePnlContext
10
+ */
11
+ export type GetLiquidationPriceContext = {
12
+ core: {
13
+ currentBlock: number;
14
+ currentTimestamp: number;
15
+ collateralPriceUsd: number;
16
+ contractsVersion: ContractsVersion;
17
+ spreadP: number;
18
+ };
19
+ borrowingV1?: GetBorrowingFeeContext;
20
+ borrowingV2?: GetPairBorrowingFeeV2Context;
21
+ funding?: GetPairFundingFeeContext;
22
+ trading: TradingFeesSubContext & {
23
+ userPriceImpact?: UserPriceImpact;
24
+ counterTradeSettings?: {
25
+ [pairIndex: number]: CounterTradeSettings;
26
+ };
27
+ };
28
+ tradeData: {
29
+ tradeInfo: TradeInfo;
30
+ tradeFeesData: TradeFeesData;
31
+ liquidationParams: LiquidationParams;
32
+ initialAccFees?: BorrowingFee.InitialAccFees;
33
+ };
34
+ liquidationSpecific: {
35
+ currentPairPrice: number;
36
+ additionalFeeCollateral: number;
37
+ partialCloseMultiplier: number;
38
+ beforeOpened: boolean;
39
+ isCounterTrade: boolean;
40
+ userPriceImpact?: UserPriceImpact;
41
+ newOpenPrice?: number;
42
+ };
43
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,16 @@
1
+ import { TradeContainer } from "../types";
2
+ import { GlobalTradingVariablesType } from "src/backend/tradingVariables/types";
3
+ import { GetComprehensivePnlContext } from "./types";
4
+ /**
5
+ * @dev Builds a complete context for comprehensive PnL calculations
6
+ * @dev Uses sub-context builders to create properly scoped contexts
7
+ * @param globalTradingVariables The transformed global trading variables from backend
8
+ * @param tradeContainer Full trade container with trade, tradeInfo, fees data and liquidation params
9
+ * @param additionalParams Additional parameters not available in trading variables
10
+ * @returns Complete context ready for getComprehensivePnl
11
+ */
12
+ export declare const buildComprehensivePnlContext: (globalTradingVariables: GlobalTradingVariablesType, tradeContainer: TradeContainer, additionalParams: {
13
+ currentBlock: number;
14
+ currentTimestamp: number;
15
+ traderFeeMultiplier?: number;
16
+ }) => GetComprehensivePnlContext;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildComprehensivePnlContext = void 0;
4
+ const builder_1 = require("../fees/borrowingV2/builder");
5
+ const builder_2 = require("../fees/fundingFees/builder");
6
+ const builder_3 = require("../fees/borrowing/builder");
7
+ const builder_4 = require("../fees/trading/builder");
8
+ /**
9
+ * @dev Builds a complete context for comprehensive PnL calculations
10
+ * @dev Uses sub-context builders to create properly scoped contexts
11
+ * @param globalTradingVariables The transformed global trading variables from backend
12
+ * @param tradeContainer Full trade container with trade, tradeInfo, fees data and liquidation params
13
+ * @param additionalParams Additional parameters not available in trading variables
14
+ * @returns Complete context ready for getComprehensivePnl
15
+ */
16
+ const buildComprehensivePnlContext = (globalTradingVariables, tradeContainer, additionalParams) => {
17
+ var _a;
18
+ const { trade, tradeInfo } = tradeContainer;
19
+ const collateralIndex = trade.collateralIndex || 1;
20
+ const collateral = globalTradingVariables.collaterals[collateralIndex - 1];
21
+ return {
22
+ // Core shared context
23
+ core: {
24
+ currentBlock: additionalParams.currentBlock,
25
+ currentTimestamp: additionalParams.currentTimestamp,
26
+ collateralPriceUsd: ((_a = collateral.prices) === null || _a === void 0 ? void 0 : _a.collateralPriceUsd) || 1,
27
+ contractsVersion: tradeInfo.contractsVersion,
28
+ },
29
+ // Build sub-contexts using dedicated builders
30
+ borrowingV1: (0, builder_3.buildBorrowingV1Context)(globalTradingVariables, collateralIndex, additionalParams.currentBlock),
31
+ borrowingV2: (0, builder_1.buildBorrowingV2Context)(globalTradingVariables, collateralIndex, trade.pairIndex, additionalParams.currentTimestamp),
32
+ funding: (0, builder_2.buildFundingContext)(globalTradingVariables, collateralIndex, trade.pairIndex, additionalParams.currentTimestamp),
33
+ trading: (0, builder_4.buildTradingFeesContext)(globalTradingVariables, trade.pairIndex, additionalParams.traderFeeMultiplier),
34
+ // Trade-specific data
35
+ tradeData: tradeContainer.tradeFeesData && tradeContainer.liquidationParams
36
+ ? {
37
+ tradeFeesData: tradeContainer.tradeFeesData,
38
+ liquidationParams: tradeContainer.liquidationParams,
39
+ initialAccFees: tradeContainer.initialAccFees,
40
+ }
41
+ : undefined,
42
+ };
43
+ };
44
+ exports.buildComprehensivePnlContext = buildComprehensivePnlContext;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @dev Converters for PnL data between contract and SDK formats
3
+ */
4
+ /**
5
+ * @dev Convert PnL percentage from contract precision to SDK format
6
+ * @param pnlPercentContract PnL percentage with 1e10 precision
7
+ * @returns PnL percentage as regular number (e.g., 10 = 10%)
8
+ */
9
+ export declare const convertPnlPercent: (pnlPercentContract: bigint | number) => number;
10
+ /**
11
+ * @dev Convert PnL percentage from SDK format to contract precision
12
+ * @param pnlPercent PnL percentage as regular number
13
+ * @returns PnL percentage with 1e10 precision
14
+ */
15
+ export declare const encodePnlPercent: (pnlPercent: number) => bigint;
16
+ /**
17
+ * @dev Convert collateral amount considering precision
18
+ * @param amount Amount in contract format
19
+ * @param collateralDecimals Collateral token decimals (6 or 18)
20
+ * @returns Amount as SDK float
21
+ */
22
+ export declare const convertCollateralAmount: (amount: bigint | number, collateralDecimals: number) => number;
23
+ /**
24
+ * @dev Convert price from contract format to SDK format
25
+ * @param price Price with 1e10 precision
26
+ * @returns Price as SDK float
27
+ */
28
+ export declare const convertPrice: (price: bigint | number) => number;
29
+ /**
30
+ * @dev Convert leverage from contract format to SDK format
31
+ * @param leverage Leverage with 1e3 precision
32
+ * @returns Leverage as SDK float (e.g., 10 = 10x)
33
+ */
34
+ export declare const convertLeverage: (leverage: bigint | number) => number;
35
+ /**
36
+ * @dev Batch convert PnL results from contract format
37
+ * @param results Array of PnL results from contract
38
+ * @param collateralDecimals Collateral token decimals
39
+ * @returns Array of converted PnL results
40
+ */
41
+ export declare const convertPnlResults: (results: Array<{
42
+ pnlCollateral: bigint;
43
+ pnlPercent: bigint;
44
+ }>, collateralDecimals: number) => Array<{
45
+ pnlCollateral: number;
46
+ pnlPercent: number;
47
+ }>;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ /**
3
+ * @dev Converters for PnL data between contract and SDK formats
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.convertPnlResults = exports.convertLeverage = exports.convertPrice = exports.convertCollateralAmount = exports.encodePnlPercent = exports.convertPnlPercent = void 0;
7
+ /**
8
+ * @dev Convert PnL percentage from contract precision to SDK format
9
+ * @param pnlPercentContract PnL percentage with 1e10 precision
10
+ * @returns PnL percentage as regular number (e.g., 10 = 10%)
11
+ */
12
+ const convertPnlPercent = (pnlPercentContract) => {
13
+ const value = typeof pnlPercentContract === "bigint"
14
+ ? Number(pnlPercentContract)
15
+ : pnlPercentContract;
16
+ // Contract uses 1e10 precision for percentages
17
+ return value / 1e10;
18
+ };
19
+ exports.convertPnlPercent = convertPnlPercent;
20
+ /**
21
+ * @dev Convert PnL percentage from SDK format to contract precision
22
+ * @param pnlPercent PnL percentage as regular number
23
+ * @returns PnL percentage with 1e10 precision
24
+ */
25
+ const encodePnlPercent = (pnlPercent) => {
26
+ return BigInt(Math.round(pnlPercent * 1e10));
27
+ };
28
+ exports.encodePnlPercent = encodePnlPercent;
29
+ /**
30
+ * @dev Convert collateral amount considering precision
31
+ * @param amount Amount in contract format
32
+ * @param collateralDecimals Collateral token decimals (6 or 18)
33
+ * @returns Amount as SDK float
34
+ */
35
+ const convertCollateralAmount = (amount, collateralDecimals) => {
36
+ const value = typeof amount === "bigint" ? Number(amount) : amount;
37
+ return value / Math.pow(10, collateralDecimals);
38
+ };
39
+ exports.convertCollateralAmount = convertCollateralAmount;
40
+ /**
41
+ * @dev Convert price from contract format to SDK format
42
+ * @param price Price with 1e10 precision
43
+ * @returns Price as SDK float
44
+ */
45
+ const convertPrice = (price) => {
46
+ const value = typeof price === "bigint" ? Number(price) : price;
47
+ return value / 1e10;
48
+ };
49
+ exports.convertPrice = convertPrice;
50
+ /**
51
+ * @dev Convert leverage from contract format to SDK format
52
+ * @param leverage Leverage with 1e3 precision
53
+ * @returns Leverage as SDK float (e.g., 10 = 10x)
54
+ */
55
+ const convertLeverage = (leverage) => {
56
+ const value = typeof leverage === "bigint" ? Number(leverage) : leverage;
57
+ return value / 1e3;
58
+ };
59
+ exports.convertLeverage = convertLeverage;
60
+ /**
61
+ * @dev Batch convert PnL results from contract format
62
+ * @param results Array of PnL results from contract
63
+ * @param collateralDecimals Collateral token decimals
64
+ * @returns Array of converted PnL results
65
+ */
66
+ const convertPnlResults = (results, collateralDecimals) => {
67
+ return results.map(result => ({
68
+ pnlCollateral: (0, exports.convertCollateralAmount)(result.pnlCollateral, collateralDecimals),
69
+ pnlPercent: (0, exports.convertPnlPercent)(result.pnlPercent),
70
+ }));
71
+ };
72
+ exports.convertPnlResults = convertPnlResults;
@@ -0,0 +1,89 @@
1
+ /**
2
+ * @dev PnL calculation module
3
+ * @dev Provides functions matching v10 contract implementations
4
+ */
5
+ import { Trade, TradeInfo, LiquidationParams, Fee, GlobalTradeFeeParams, TradeFeesData } from "../types";
6
+ import { ComprehensivePnlResult, GetComprehensivePnlContext } from "./types";
7
+ import { BorrowingFee } from "../fees/borrowing";
8
+ import { ContractsVersion } from "../../contracts/types";
9
+ /**
10
+ * @dev Gets trade realized PnL components from TradeFeesData
11
+ * @dev Mirrors contract's getTradeRealizedPnlCollateral function
12
+ * @param tradeFeesData Trade fees data containing realized components
13
+ * @returns Tuple of [realizedPnlCollateral, realizedTradingFeesCollateral, totalRealizedPnlCollateral]
14
+ */
15
+ export declare const getTradeRealizedPnlCollateral: (tradeFeesData: TradeFeesData) => {
16
+ realizedPnlCollateral: number;
17
+ realizedTradingFeesCollateral: number;
18
+ totalRealizedPnlCollateral: number;
19
+ };
20
+ /**
21
+ * @dev Calculates PnL percentage for a position
22
+ * @dev Mirrors contract's getPnlPercent function
23
+ * @param openPrice Trade open price
24
+ * @param currentPrice Current market price
25
+ * @param long Whether position is long
26
+ * @param leverage Position leverage
27
+ * @returns PnL percentage (e.g., 10 = 10% profit, -50 = 50% loss)
28
+ */
29
+ export declare const getPnlPercent: (openPrice: number, currentPrice: number, long: boolean, leverage: number) => number;
30
+ /**
31
+ * @dev Calculates trade value from collateral and PnL
32
+ * @dev Mirrors contract's getTradeValuePure function
33
+ * @param collateral Trade collateral amount
34
+ * @param pnlPercent PnL percentage
35
+ * @param totalFees Total fees to deduct
36
+ * @returns Trade value after PnL and fees
37
+ */
38
+ export declare const getTradeValue: (collateral: number, pnlPercent: number, totalFees: number) => number;
39
+ /**
40
+ * @dev Comprehensive PnL calculation including all fees
41
+ * @param trade The trade to calculate PnL for
42
+ * @param marketPrice Current market price (without price impact)
43
+ * @param executionPrice Price after all impacts (spread, skew, volume)
44
+ * @param tradeInfo Trade info with version and timestamps
45
+ * @param context Context with all fee parameters
46
+ * @returns Detailed PnL breakdown
47
+ */
48
+ export declare const getComprehensivePnl: (trade: Trade, marketPrice: number, executionPrice: number, tradeInfo: TradeInfo, context: GetComprehensivePnlContext) => ComprehensivePnlResult;
49
+ /**
50
+ * @dev Legacy getPnl function for backward compatibility
51
+ * @deprecated Use getComprehensivePnl for new implementations
52
+ */
53
+ export type GetPnlContext = {
54
+ currentBlock: number;
55
+ groups: BorrowingFee.Group[];
56
+ pairs: BorrowingFee.Pair[];
57
+ collateralPriceUsd: number | undefined;
58
+ contractsVersion: ContractsVersion | undefined;
59
+ feeMultiplier: number | undefined;
60
+ fee: Fee;
61
+ globalTradeFeeParams: GlobalTradeFeeParams;
62
+ traderFeeMultiplier?: number;
63
+ };
64
+ /**
65
+ * @dev Legacy PnL calculation function
66
+ * @deprecated Use getComprehensivePnl for more comprehensive calculations
67
+ * @param price Current price
68
+ * @param trade Trade object
69
+ * @param tradeInfo Trade info (not used in legacy implementation)
70
+ * @param initialAccFees Initial accumulated fees
71
+ * @param liquidationParams Liquidation parameters
72
+ * @param useFees Whether to include fees
73
+ * @param context Context with fee calculation parameters
74
+ * @returns [pnlCollateral, pnlPercentage] or undefined if no price
75
+ */
76
+ export declare const getPnl: (price: number | undefined, trade: Trade, _tradeInfo: TradeInfo, initialAccFees: BorrowingFee.InitialAccFees, liquidationParams: LiquidationParams, useFees: boolean, context: GetPnlContext) => number[] | undefined;
77
+ /**
78
+ * @dev Calculates the price needed to achieve a target PnL percentage
79
+ * @param targetPnlPercent The target PnL percentage (e.g., 50 for 50% profit, -25 for 25% loss)
80
+ * @param trade The trade to calculate for
81
+ * @param tradeInfo Trade info with timestamps
82
+ * @param context Context with fee calculation parameters
83
+ * @param netPnl Whether to include closing fees in the calculation
84
+ * @returns The price that would result in the target PnL percentage
85
+ */
86
+ export declare const getPriceForTargetPnlPercentage: (targetPnlPercent: number, trade: Trade, tradeInfo: TradeInfo, context: GetComprehensivePnlContext, netPnl?: boolean) => number;
87
+ export * from "./types";
88
+ export * from "./converter";
89
+ export * from "./builder";