@gainsnetwork/sdk 1.3.0-rc2 → 1.3.0-rc3

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.
@@ -3,7 +3,7 @@
3
3
  * @dev Mirrors contract's getTradeCumulVolPriceImpactP functionality
4
4
  */
5
5
  import { PairDepthBands, DepthBandsMapping } from "./types";
6
- import { LiquidationParams, OiWindows, OiWindowsSettings, PairDepth, PairFactor, UserPriceImpact } from "../../types";
6
+ import { LiquidationParams, OiWindows, OiWindowsSettings, PairFactor, UserPriceImpact } from "../../types";
7
7
  import { ContractsVersion } from "../../../contracts/types";
8
8
  export type CumulVolContext = {
9
9
  isOpen?: boolean;
@@ -85,13 +85,12 @@ export declare const getSpreadP: (pairSpreadP: number | undefined, isLiquidation
85
85
  * @param buy True for long, false for short
86
86
  * @param collateral Collateral amount
87
87
  * @param leverage Position leverage
88
- * @param pairDepth 1% depth values for the pair
89
88
  * @param oiWindowsSettings OI windows configuration
90
89
  * @param oiWindows Current OI windows data
91
90
  * @param context Additional context for the calculation
92
91
  * @returns Total spread + cumulative volume price impact percentage
93
92
  */
94
- export declare const getSpreadWithCumulVolPriceImpactP: (pairSpreadP: number, buy: boolean, collateral: number, leverage: number, pairDepth: PairDepth | undefined, oiWindowsSettings?: OiWindowsSettings | undefined, oiWindows?: OiWindows | undefined, context?: CumulVolContext | undefined) => number;
93
+ export declare const getSpreadWithCumulVolPriceImpactP: (pairSpreadP: number, buy: boolean, collateral: number, leverage: number, oiWindowsSettings?: OiWindowsSettings | undefined, oiWindows?: OiWindows | undefined, context?: CumulVolContext | undefined) => number;
95
94
  /**
96
95
  * @dev Convenience function for calculating cumulative volume price impact
97
96
  * @dev Uses collateral and leverage instead of USD position size
@@ -105,6 +104,6 @@ export declare const getSpreadWithCumulVolPriceImpactP: (pairSpreadP: number, bu
105
104
  export declare const getCumulVolPriceImpact: (buy: boolean, collateral: number, leverage: number, open: boolean, context: CumulVolContext & {
106
105
  collateralPriceUsd: number;
107
106
  }) => number;
108
- export declare const getSpreadWithPriceImpactP: (pairSpreadP: number, buy: boolean, collateral: number, leverage: number, pairDepth: PairDepth | undefined, oiWindowsSettings?: OiWindowsSettings | undefined, oiWindows?: OiWindows | undefined, context?: CumulVolContext | undefined) => number;
107
+ export declare const getSpreadWithPriceImpactP: (pairSpreadP: number, buy: boolean, collateral: number, leverage: number, oiWindowsSettings?: OiWindowsSettings | undefined, oiWindows?: OiWindows | undefined, context?: CumulVolContext | undefined) => number;
109
108
  export { convertOiWindowsSettings, convertOiWindow, convertOiWindows, convertOiWindowsSettingsArray, } from "./converter";
110
109
  export { buildCumulVolContext } from "./builder";
@@ -263,13 +263,12 @@ exports.getSpreadP = getSpreadP;
263
263
  * @param buy True for long, false for short
264
264
  * @param collateral Collateral amount
265
265
  * @param leverage Position leverage
266
- * @param pairDepth 1% depth values for the pair
267
266
  * @param oiWindowsSettings OI windows configuration
268
267
  * @param oiWindows Current OI windows data
269
268
  * @param context Additional context for the calculation
270
269
  * @returns Total spread + cumulative volume price impact percentage
271
270
  */
272
- const getSpreadWithCumulVolPriceImpactP = (pairSpreadP, buy, collateral, leverage, pairDepth, oiWindowsSettings, oiWindows, context) => {
271
+ const getSpreadWithCumulVolPriceImpactP = (pairSpreadP, buy, collateral, leverage, oiWindowsSettings, oiWindows, context) => {
273
272
  if (pairSpreadP === undefined) {
274
273
  return 0;
275
274
  }
@@ -280,8 +279,8 @@ const getSpreadWithCumulVolPriceImpactP = (pairSpreadP, buy, collateral, leverag
280
279
  0, // pairIndex - not used in calculation
281
280
  buy, positionSizeUsd, (context === null || context === void 0 ? void 0 : context.isPnlPositive) || false, (context === null || context === void 0 ? void 0 : context.isOpen) !== false, (context === null || context === void 0 ? void 0 : context.createdBlock) || 0, Object.assign(Object.assign({}, context), { oiWindowsSettings,
282
281
  oiWindows }));
283
- // If no depth or OI data, return just half spread
284
- if (cumulVolImpact === 0 && (!pairDepth || !oiWindowsSettings)) {
282
+ // If no cumulative volume impact calculated, return half of base spread
283
+ if (cumulVolImpact === 0 && !oiWindowsSettings) {
285
284
  return pairSpreadP / 2;
286
285
  }
287
286
  return baseSpread + cumulVolImpact;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gainsnetwork/sdk",
3
- "version": "1.3.0-rc2",
3
+ "version": "1.3.0-rc3",
4
4
  "description": "Gains Network SDK",
5
5
  "main": "./lib/index.js",
6
6
  "files": [