@gmx-io/sdk 1.5.0-alpha-8 → 1.5.0-alpha-9

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 (67) hide show
  1. package/build/cjs/src/clients/v1/testUtil.js +1 -1
  2. package/build/cjs/src/clients/v2/index.js +6 -2
  3. package/build/cjs/src/codegen/prebuilt/hashedKinkModelMarketRatesKeys.json +34 -0
  4. package/build/cjs/src/codegen/prebuilt/hashedMarketConfigKeys.json +230 -0
  5. package/build/cjs/src/codegen/prebuilt/hashedMarketValuesKeys.json +62 -0
  6. package/build/cjs/src/configs/__tests__/tokens.spec.js +1 -0
  7. package/build/cjs/src/configs/api.js +4 -3
  8. package/build/cjs/src/configs/batch.js +13 -0
  9. package/build/cjs/src/configs/chainIds.js +2 -1
  10. package/build/cjs/src/configs/chains.js +48 -2
  11. package/build/cjs/src/configs/contracts.js +67 -0
  12. package/build/cjs/src/configs/express.js +2 -0
  13. package/build/cjs/src/configs/gasLimits.js +7 -0
  14. package/build/cjs/src/configs/markets.js +30 -0
  15. package/build/cjs/src/configs/oracleKeeper.js +2 -0
  16. package/build/cjs/src/configs/tokens.js +89 -1
  17. package/build/cjs/src/utils/__tests__/orderTransactions/decreaseOrders.spec.js +2 -0
  18. package/build/cjs/src/utils/__tests__/orderTransactions/increaseOrders.spec.js +2 -0
  19. package/build/cjs/src/utils/__tests__/orderTransactions/swapOrders.spec.js +1 -0
  20. package/build/cjs/src/utils/__tests__/uiFeeReceiver.spec.js +24 -0
  21. package/build/cjs/src/utils/errors/parseError.js +3 -0
  22. package/build/cjs/src/utils/staking/api.js +11 -0
  23. package/build/cjs/src/utils/staking/types.js +2 -0
  24. package/build/cjs/src/utils/trade/decrease.js +131 -6
  25. package/build/cjs/src/utils/trade/increase.js +2 -6
  26. package/build/cjs/src/utils/twap/uiFeeReceiver.js +29 -13
  27. package/build/esm/src/clients/v1/testUtil.js +1 -1
  28. package/build/esm/src/clients/v2/index.js +4 -0
  29. package/build/esm/src/codegen/prebuilt/hashedKinkModelMarketRatesKeys.json +34 -0
  30. package/build/esm/src/codegen/prebuilt/hashedMarketConfigKeys.json +230 -0
  31. package/build/esm/src/codegen/prebuilt/hashedMarketValuesKeys.json +62 -0
  32. package/build/esm/src/configs/__tests__/tokens.spec.js +2 -1
  33. package/build/esm/src/configs/api.js +5 -4
  34. package/build/esm/src/configs/batch.js +14 -1
  35. package/build/esm/src/configs/chainIds.js +1 -0
  36. package/build/esm/src/configs/chains.js +48 -3
  37. package/build/esm/src/configs/contracts.js +68 -1
  38. package/build/esm/src/configs/express.js +3 -1
  39. package/build/esm/src/configs/gasLimits.js +8 -1
  40. package/build/esm/src/configs/markets.js +31 -1
  41. package/build/esm/src/configs/oracleKeeper.js +3 -1
  42. package/build/esm/src/configs/tokens.js +90 -2
  43. package/build/esm/src/utils/__tests__/orderTransactions/decreaseOrders.spec.js +2 -0
  44. package/build/esm/src/utils/__tests__/orderTransactions/increaseOrders.spec.js +2 -0
  45. package/build/esm/src/utils/__tests__/orderTransactions/swapOrders.spec.js +1 -0
  46. package/build/esm/src/utils/__tests__/uiFeeReceiver.spec.js +25 -1
  47. package/build/esm/src/utils/errors/parseError.js +3 -0
  48. package/build/esm/src/utils/staking/api.js +7 -0
  49. package/build/esm/src/utils/staking/types.js +1 -0
  50. package/build/esm/src/utils/trade/decrease.js +127 -7
  51. package/build/esm/src/utils/trade/increase.js +3 -7
  52. package/build/esm/src/utils/twap/uiFeeReceiver.js +27 -12
  53. package/build/types/src/clients/v1/index.d.ts +1 -1
  54. package/build/types/src/clients/v1/modules/base.d.ts +1 -1
  55. package/build/types/src/clients/v1/multicall.d.ts +1 -1
  56. package/build/types/src/clients/v2/index.d.ts +5 -0
  57. package/build/types/src/codegen/prebuilt/index.d.ts +326 -0
  58. package/build/types/src/configs/chainIds.d.ts +1 -0
  59. package/build/types/src/configs/chains.d.ts +26 -6
  60. package/build/types/src/configs/contracts.d.ts +64 -0
  61. package/build/types/src/utils/errors/parseError.d.ts +3 -0
  62. package/build/types/src/utils/staking/api.d.ts +7 -0
  63. package/build/types/src/utils/staking/types.d.ts +14 -0
  64. package/build/types/src/utils/trade/decrease.d.ts +41 -2
  65. package/build/types/src/utils/trade/types.d.ts +8 -0
  66. package/build/types/src/utils/twap/uiFeeReceiver.d.ts +9 -6
  67. package/package.json +1 -1
@@ -1,8 +1,9 @@
1
- import { MarketInfo } from "../markets/types";
1
+ import { MarketInfo, MarketsInfoData } from "../markets/types";
2
+ import { DecreasePositionSwapType } from "../orders/types";
2
3
  import { PositionInfo, PositionInfoLoaded } from "../positions/types";
3
4
  import { UserReferralInfo } from "../referrals/types";
4
5
  import { TokenData } from "../tokens/types";
5
- import { DecreasePositionAmounts, NextPositionValues } from "./types";
6
+ import { DecreasePositionAmounts, FindSwapPath, NextPositionValues, SwapAmounts } from "./types";
6
7
  export declare function getDecreasePositionAmounts(p: {
7
8
  marketInfo: MarketInfo;
8
9
  collateralToken: TokenData;
@@ -22,6 +23,7 @@ export declare function getDecreasePositionAmounts(p: {
22
23
  triggerOrderType?: DecreasePositionAmounts["triggerOrderType"];
23
24
  isSetAcceptablePriceImpactEnabled: boolean;
24
25
  receiveToken?: TokenData;
26
+ forceDecreaseSwapType?: DecreasePositionSwapType;
25
27
  }): DecreasePositionAmounts;
26
28
  export declare function getIsFullClose(p: {
27
29
  position: PositionInfoLoaded;
@@ -76,3 +78,40 @@ export declare function getNextPositionValuesForDecreaseTrade(p: {
76
78
  minCollateralUsd: bigint;
77
79
  userReferralInfo: UserReferralInfo | undefined;
78
80
  }): NextPositionValues;
81
+ export declare function getDecreaseSwapType(pnlToken: TokenData, collateralToken: TokenData, receiveToken: TokenData): DecreasePositionSwapType;
82
+ export declare function isThirdTokenDecreaseSwap(pnlToken: TokenData, collateralToken: TokenData, receiveToken: TokenData): boolean;
83
+ export declare function getCollateralToPnlInternalSwapStats(p: {
84
+ pnlToken: TokenData;
85
+ receiveUsd: bigint;
86
+ }): {
87
+ amountOut: bigint;
88
+ };
89
+ export declare function selectBetterDecreaseSwapType(p: {
90
+ pathAUsdOut: bigint;
91
+ pathBUsdOut: bigint;
92
+ }): "pathA" | "pathB";
93
+ export declare function getOptimalDecreaseAndSwapAmounts(p: {
94
+ marketInfo: MarketInfo;
95
+ collateralToken: TokenData;
96
+ isLong: boolean;
97
+ position: PositionInfoLoaded | undefined;
98
+ closeSizeUsd: bigint;
99
+ keepLeverage: boolean;
100
+ triggerPrice?: bigint;
101
+ fixedAcceptablePriceImpactBps?: bigint;
102
+ acceptablePriceImpactBuffer?: number;
103
+ userReferralInfo: UserReferralInfo | undefined;
104
+ minCollateralUsd: bigint;
105
+ minPositionSizeUsd: bigint;
106
+ uiFeeFactor: bigint;
107
+ triggerOrderType?: DecreasePositionAmounts["triggerOrderType"];
108
+ isSetAcceptablePriceImpactEnabled: boolean;
109
+ receiveToken: TokenData;
110
+ findSwapPath: FindSwapPath;
111
+ findSwapPathFromPnl: FindSwapPath;
112
+ marketsInfoData: MarketsInfoData | undefined;
113
+ chainId: number;
114
+ }): {
115
+ decreaseAmounts: DecreasePositionAmounts;
116
+ swapAmounts: SwapAmounts | undefined;
117
+ };
@@ -73,6 +73,11 @@ export type IncreasePositionAmounts = {
73
73
  positionPriceImpactDeltaUsd: bigint;
74
74
  potentialPriceImpactDiffUsd: bigint;
75
75
  };
76
+ export type DecreasePositionOutput = {
77
+ tokenAddress: string;
78
+ amount: bigint;
79
+ usd: bigint;
80
+ };
76
81
  export type DecreasePositionAmounts = {
77
82
  isFullClose: boolean;
78
83
  sizeDeltaUsd: bigint;
@@ -96,6 +101,7 @@ export type DecreasePositionAmounts = {
96
101
  borrowingFeeUsd: bigint;
97
102
  fundingFeeUsd: bigint;
98
103
  swapProfitFeeUsd: bigint;
104
+ swapProfitUsdIn: bigint;
99
105
  proportionalPendingImpactDeltaUsd: bigint;
100
106
  closePriceImpactDeltaUsd: bigint;
101
107
  totalPendingImpactDeltaUsd: bigint;
@@ -106,6 +112,8 @@ export type DecreasePositionAmounts = {
106
112
  payedRemainingCollateralUsd: bigint;
107
113
  receiveTokenAmount: bigint;
108
114
  receiveUsd: bigint;
115
+ primaryOutput: DecreasePositionOutput;
116
+ secondaryOutput: DecreasePositionOutput;
109
117
  triggerOrderType?: OrderType.LimitDecrease | OrderType.StopLossDecrease;
110
118
  triggerThresholdType?: TriggerThresholdType;
111
119
  decreaseSwapType: DecreasePositionSwapType;
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * Ui fee receiver structure:
3
- * 0-3 (4) bytes (0-7 chars) - PREFIX
4
- * 4-15 (12) bytes (8-32 chars) - 12 bytes buffer
5
- * 16 (1) byte (33-34 chars) - isExpress flag
6
- * 17 (1) byte (35-36 chars) - numberOfParts (hex encoded)
7
- * 18-19 (2) bytes (37-40 chars) - twapId
8
- * 20 (1) byte (41-42 chars) - VERSION
3
+ * 0-2 (3) bytes (0-5 chars) - PREFIX
4
+ * 3-13 (11) bytes (6-27 chars) - free buffer
5
+ * 14 (1) byte (28-29 chars) - isJit flag
6
+ * 15 (1) byte (30-31 chars) - isExpress flag
7
+ * 16 (1) byte (32-33 chars) - numberOfParts (hex encoded)
8
+ * 17-18 (2) bytes (34-37 chars) - twapId
9
+ * 19 (1) byte (38-39 chars) - VERSION
9
10
  *
10
11
  * Total: 0x + 20 bytes (41 hex characters)
11
12
  */
@@ -17,6 +18,8 @@ export declare function decodeTwapUiFeeReceiver(address: string): {
17
18
  twapId: string;
18
19
  numberOfParts: number;
19
20
  isExpress: boolean;
21
+ isJit: boolean;
20
22
  } | void;
21
23
  export declare function isValidTwapUiFeeReceiver(address: string): boolean;
22
24
  export declare function setUiFeeReceiverIsExpress(uiFeeReceiver: string, isExpress: boolean): string;
25
+ export declare function setUiFeeReceiverIsJit(uiFeeReceiver: string, isJit: boolean): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gmx-io/sdk",
3
- "version": "1.5.0-alpha-8",
3
+ "version": "1.5.0-alpha-9",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",