@gainsnetwork/sdk 0.2.67-rc8 → 0.2.69

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 (136) hide show
  1. package/lib/contracts/addresses.json +20 -0
  2. package/lib/{trade/fees/borrowingV2/fetcher.d.ts → contracts/fetch/fees/borrowingFeesV2.d.ts} +3 -2
  3. package/lib/{trade/fees/borrowingV2/fetcher.js → contracts/fetch/fees/borrowingFeesV2.js} +14 -6
  4. package/lib/{trade/fees/fundingFees/fetcher.d.ts → contracts/fetch/fees/fundingFees.d.ts} +2 -2
  5. package/lib/{trade/priceImpact/skew/fetcher.d.ts → contracts/fetch/priceImpact/skew.d.ts} +2 -2
  6. package/lib/{trade/priceImpact/skew/fetcher.js → contracts/fetch/priceImpact/skew.js} +6 -6
  7. package/lib/contracts/index.js +3 -1
  8. package/lib/contracts/types/generated/GNSMultiCollatDiamond.d.ts +258 -2112
  9. package/lib/contracts/types/generated/GToken.d.ts +107 -78
  10. package/lib/contracts/types/generated/factories/GNSMultiCollatDiamond__factory.d.ts +53 -90
  11. package/lib/contracts/types/generated/factories/GNSMultiCollatDiamond__factory.js +421 -4496
  12. package/lib/contracts/types/generated/factories/GToken__factory.js +142 -65
  13. package/lib/contracts/types/index.d.ts +2 -1
  14. package/lib/contracts/types/index.js +1 -0
  15. package/lib/trade/fees/borrowingV2/converter.d.ts +3 -12
  16. package/lib/trade/fees/borrowingV2/converter.js +18 -29
  17. package/lib/trade/fees/borrowingV2/index.d.ts +17 -6
  18. package/lib/trade/fees/borrowingV2/index.js +37 -10
  19. package/lib/trade/fees/borrowingV2/types.d.ts +6 -22
  20. package/lib/trade/fees/fundingFees/index.d.ts +2 -13
  21. package/lib/trade/fees/fundingFees/index.js +3 -27
  22. package/lib/trade/fees/trading/index.d.ts +2 -30
  23. package/lib/trade/fees/trading/index.js +1 -52
  24. package/lib/trade/fees/trading/types.d.ts +0 -9
  25. package/lib/trade/priceImpact/index.d.ts +2 -6
  26. package/lib/trade/priceImpact/index.js +3 -30
  27. package/lib/trade/priceImpact/skew/index.d.ts +0 -1
  28. package/lib/trade/priceImpact/skew/index.js +0 -4
  29. package/package.json +1 -1
  30. package/lib/backend/globalTrades/index.d.ts +0 -11
  31. package/lib/backend/globalTrades/index.js +0 -69
  32. package/lib/backend/index.d.ts +0 -3
  33. package/lib/backend/index.js +0 -28
  34. package/lib/backend/tradingVariables/backend.types.d.ts +0 -312
  35. package/lib/backend/tradingVariables/backend.types.js +0 -2
  36. package/lib/backend/tradingVariables/converter.d.ts +0 -31
  37. package/lib/backend/tradingVariables/converter.js +0 -330
  38. package/lib/backend/tradingVariables/index.d.ts +0 -5
  39. package/lib/backend/tradingVariables/index.js +0 -95
  40. package/lib/backend/tradingVariables/types.d.ts +0 -109
  41. package/lib/backend/tradingVariables/types.js +0 -14
  42. package/lib/contracts/types/generated/GFarmTradingStorageV5.d.ts +0 -1911
  43. package/lib/contracts/types/generated/GFarmTradingStorageV5.js +0 -2
  44. package/lib/contracts/types/generated/GNSBorrowingFees.d.ts +0 -1067
  45. package/lib/contracts/types/generated/GNSBorrowingFees.js +0 -2
  46. package/lib/contracts/types/generated/GNSNftRewardsV6.d.ts +0 -533
  47. package/lib/contracts/types/generated/GNSNftRewardsV6.js +0 -2
  48. package/lib/contracts/types/generated/GNSNftRewardsV6_3_1.d.ts +0 -613
  49. package/lib/contracts/types/generated/GNSNftRewardsV6_3_1.js +0 -2
  50. package/lib/contracts/types/generated/GNSTrading.d.ts +0 -758
  51. package/lib/contracts/types/generated/GNSTrading.js +0 -2
  52. package/lib/contracts/types/generated/GNSTradingCallbacks.d.ts +0 -875
  53. package/lib/contracts/types/generated/GNSTradingCallbacks.js +0 -2
  54. package/lib/contracts/types/generated/GNSTradingStorage.d.ts +0 -1387
  55. package/lib/contracts/types/generated/GNSTradingStorage.js +0 -2
  56. package/lib/contracts/types/generated/GTokenV6_3_2.d.ts +0 -1838
  57. package/lib/contracts/types/generated/GTokenV6_3_2.js +0 -2
  58. package/lib/contracts/types/generated/factories/GFarmTradingStorageV5__factory.d.ts +0 -83
  59. package/lib/contracts/types/generated/factories/GFarmTradingStorageV5__factory.js +0 -2691
  60. package/lib/contracts/types/generated/factories/GNSBorrowingFees__factory.d.ts +0 -124
  61. package/lib/contracts/types/generated/factories/GNSBorrowingFees__factory.js +0 -1784
  62. package/lib/contracts/types/generated/factories/GNSNftRewardsV6_3_1__factory.d.ts +0 -100
  63. package/lib/contracts/types/generated/factories/GNSNftRewardsV6_3_1__factory.js +0 -1116
  64. package/lib/contracts/types/generated/factories/GNSNftRewardsV6__factory.d.ts +0 -100
  65. package/lib/contracts/types/generated/factories/GNSNftRewardsV6__factory.js +0 -1003
  66. package/lib/contracts/types/generated/factories/GNSTradingCallbacks__factory.d.ts +0 -113
  67. package/lib/contracts/types/generated/factories/GNSTradingCallbacks__factory.js +0 -1428
  68. package/lib/contracts/types/generated/factories/GNSTradingStorage__factory.d.ts +0 -96
  69. package/lib/contracts/types/generated/factories/GNSTradingStorage__factory.js +0 -2241
  70. package/lib/contracts/types/generated/factories/GNSTrading__factory.d.ts +0 -95
  71. package/lib/contracts/types/generated/factories/GNSTrading__factory.js +0 -1071
  72. package/lib/contracts/types/generated/factories/GTokenV6_3_2__factory.d.ts +0 -110
  73. package/lib/contracts/types/generated/factories/GTokenV6_3_2__factory.js +0 -2682
  74. package/lib/contracts/utils/openLimitOrders.d.ts +0 -8
  75. package/lib/contracts/utils/openLimitOrders.js +0 -88
  76. package/lib/markets/collateral/converter.d.ts +0 -5
  77. package/lib/markets/collateral/converter.js +0 -11
  78. package/lib/markets/collateral/index.d.ts +0 -1
  79. package/lib/markets/collateral/index.js +0 -17
  80. package/lib/markets/collateral/types.d.ts +0 -7
  81. package/lib/markets/collateral/types.js +0 -2
  82. package/lib/markets/oi/converter.d.ts +0 -63
  83. package/lib/markets/oi/converter.js +0 -103
  84. package/lib/markets/oi/fetcher.d.ts +0 -58
  85. package/lib/markets/oi/fetcher.js +0 -181
  86. package/lib/markets/oi/index.d.ts +0 -10
  87. package/lib/markets/oi/index.js +0 -37
  88. package/lib/markets/oi/types.d.ts +0 -82
  89. package/lib/markets/oi/types.js +0 -6
  90. package/lib/markets/oi/validation.d.ts +0 -80
  91. package/lib/markets/oi/validation.js +0 -172
  92. package/lib/trade/fees/borrowing/builder.d.ts +0 -14
  93. package/lib/trade/fees/borrowing/builder.js +0 -33
  94. package/lib/trade/fees/borrowingV2/builder.d.ts +0 -6
  95. package/lib/trade/fees/borrowingV2/builder.js +0 -24
  96. package/lib/trade/fees/converter.d.ts +0 -48
  97. package/lib/trade/fees/converter.js +0 -110
  98. package/lib/trade/fees/fundingFees/builder.d.ts +0 -9
  99. package/lib/trade/fees/fundingFees/builder.js +0 -35
  100. package/lib/trade/fees/fundingFees/pairContext.d.ts +0 -33
  101. package/lib/trade/fees/fundingFees/pairContext.js +0 -17
  102. package/lib/trade/fees/tiers/converter.d.ts +0 -54
  103. package/lib/trade/fees/tiers/converter.js +0 -81
  104. package/lib/trade/fees/trading/builder.d.ts +0 -18
  105. package/lib/trade/fees/trading/builder.js +0 -20
  106. package/lib/trade/liquidation/builder.d.ts +0 -25
  107. package/lib/trade/liquidation/builder.js +0 -59
  108. package/lib/trade/liquidation/converter.d.ts +0 -23
  109. package/lib/trade/liquidation/converter.js +0 -46
  110. package/lib/trade/liquidation/index.d.ts +0 -26
  111. package/lib/trade/liquidation/index.js +0 -142
  112. package/lib/trade/liquidation/types.d.ts +0 -59
  113. package/lib/trade/liquidation/types.js +0 -2
  114. package/lib/trade/openLimitOrder.d.ts +0 -2
  115. package/lib/trade/openLimitOrder.js +0 -23
  116. package/lib/trade/pnl/builder.d.ts +0 -16
  117. package/lib/trade/pnl/builder.js +0 -44
  118. package/lib/trade/pnl/converter.d.ts +0 -47
  119. package/lib/trade/pnl/converter.js +0 -72
  120. package/lib/trade/pnl/index.d.ts +0 -77
  121. package/lib/trade/pnl/index.js +0 -270
  122. package/lib/trade/pnl/types.d.ts +0 -114
  123. package/lib/trade/pnl/types.js +0 -5
  124. package/lib/trade/priceImpact/close/index.d.ts +0 -21
  125. package/lib/trade/priceImpact/close/index.js +0 -131
  126. package/lib/trade/priceImpact/close/types.d.ts +0 -43
  127. package/lib/trade/priceImpact/close/types.js +0 -5
  128. package/lib/trade/priceImpact/cumulVol/converter.d.ts +0 -31
  129. package/lib/trade/priceImpact/cumulVol/converter.js +0 -59
  130. package/lib/trade/priceImpact/cumulVol/index.d.ts +0 -107
  131. package/lib/trade/priceImpact/cumulVol/index.js +0 -228
  132. package/lib/trade/priceImpact/open/index.d.ts +0 -22
  133. package/lib/trade/priceImpact/open/index.js +0 -76
  134. package/lib/trade/priceImpact/open/types.d.ts +0 -41
  135. package/lib/trade/priceImpact/open/types.js +0 -5
  136. /package/lib/{trade/fees/fundingFees/fetcher.js → contracts/fetch/fees/fundingFees.js} +0 -0
@@ -1,76 +0,0 @@
1
- "use strict";
2
- /**
3
- * @dev Trade opening price impact calculations
4
- * @dev Mirrors contract's TradingCommonUtils.getTradeOpeningPriceImpact
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.getTradeOpeningPriceImpactAtMarket = exports.getTradeOpeningPriceImpact = void 0;
8
- const cumulVol_1 = require("../cumulVol");
9
- const skew_1 = require("../skew");
10
- /**
11
- * @dev Calculates all price impacts for trade opening
12
- * @dev Mirrors contract's getTradeOpeningPriceImpact function
13
- * @param input Trade parameters
14
- * @param context Combined context for calculations
15
- * @returns Price impact breakdown and final price
16
- */
17
- const getTradeOpeningPriceImpact = (input, context) => {
18
- const positionSizeCollateral = input.collateralAmount * input.leverage;
19
- // Calculate fixed spread
20
- const spreadP = (0, cumulVol_1.getFixedSpreadP)(input.pairSpreadP, input.long, true // opening
21
- );
22
- // Calculate position size in USD
23
- const positionSizeUsd = positionSizeCollateral * context.collateralPriceUsd;
24
- // Calculate cumulative volume price impact
25
- const cumulVolPriceImpactP = (0, cumulVol_1.getTradeCumulVolPriceImpactP)("", // trader - not needed for calculation
26
- input.pairIndex, input.long, positionSizeUsd, false, // isPnlPositive - not relevant for opening
27
- true, // open
28
- 0, // lastPosIncreaseBlock - not relevant for opening
29
- context);
30
- // Calculate skew price impact (v10+ only)
31
- const skewPriceImpactP = (0, skew_1.getTradeSkewPriceImpactWithChecks)({
32
- collateralIndex: input.collateralIndex,
33
- pairIndex: input.pairIndex,
34
- long: input.long,
35
- open: true,
36
- positionSizeCollateral,
37
- currentPrice: input.openPrice,
38
- contractsVersion: input.contractsVersion,
39
- isCounterTrade: input.isCounterTrade,
40
- }, context.skewContext);
41
- // Total price impact (signed - can be positive or negative)
42
- // Spread is always positive, impacts can be negative
43
- const totalPriceImpactP = spreadP + cumulVolPriceImpactP + skewPriceImpactP;
44
- // Calculate final price after impact
45
- // For longs: price increases with positive impact
46
- // For shorts: price decreases with positive impact
47
- const priceImpactFactor = 1 + totalPriceImpactP / 100;
48
- const priceAfterImpact = input.long
49
- ? input.openPrice * priceImpactFactor
50
- : input.openPrice / priceImpactFactor;
51
- // Calculate percent profit from impact
52
- // Positive when trader benefits, negative when trader loses
53
- const percentProfitP = input.long
54
- ? -totalPriceImpactP // Long loses when price goes up
55
- : totalPriceImpactP; // Short gains when price goes up
56
- return {
57
- priceAfterImpact,
58
- priceImpactP: Math.abs(totalPriceImpactP),
59
- percentProfitP,
60
- cumulVolPriceImpactP,
61
- skewPriceImpactP,
62
- totalPriceImpactP,
63
- };
64
- };
65
- exports.getTradeOpeningPriceImpact = getTradeOpeningPriceImpact;
66
- /**
67
- * @dev Simplified version using current market price
68
- * @param input Trade parameters
69
- * @param context Combined context
70
- * @param currentMarketPrice Current market price to use as open price
71
- * @returns Price impact breakdown and final price
72
- */
73
- const getTradeOpeningPriceImpactAtMarket = (input, context, currentMarketPrice) => {
74
- return (0, exports.getTradeOpeningPriceImpact)(Object.assign(Object.assign({}, input), { openPrice: currentMarketPrice }), context);
75
- };
76
- exports.getTradeOpeningPriceImpactAtMarket = getTradeOpeningPriceImpactAtMarket;
@@ -1,41 +0,0 @@
1
- /**
2
- * @dev Types for trade opening price impact calculations
3
- */
4
- import { CumulVolContext } from "../cumulVol";
5
- import { SkewPriceImpactContext } from "../skew/types";
6
- import { Fee, PairIndex } from "../../types";
7
- /**
8
- * @dev Input parameters for trade opening price impact
9
- */
10
- export type TradeOpeningPriceImpactInput = {
11
- collateralIndex: number;
12
- pairIndex: PairIndex;
13
- long: boolean;
14
- collateralAmount: number;
15
- leverage: number;
16
- openPrice: number;
17
- pairSpreadP: number;
18
- fee: Fee;
19
- contractsVersion: number;
20
- isCounterTrade?: boolean;
21
- };
22
- /**
23
- * @dev Context for trade opening price impact calculation
24
- * Combines contexts from spread, cumul vol, and skew
25
- */
26
- export type TradeOpeningPriceImpactContext = CumulVolContext & {
27
- skewContext: SkewPriceImpactContext;
28
- collateralPriceUsd: number;
29
- };
30
- /**
31
- * @dev Result of trade opening price impact calculation
32
- * Mirrors contract's PriceImpact struct
33
- */
34
- export type TradeOpeningPriceImpactResult = {
35
- priceAfterImpact: number;
36
- priceImpactP: number;
37
- percentProfitP: number;
38
- cumulVolPriceImpactP: number;
39
- skewPriceImpactP: number;
40
- totalPriceImpactP: number;
41
- };
@@ -1,5 +0,0 @@
1
- "use strict";
2
- /**
3
- * @dev Types for trade opening price impact calculations
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });