@storm-trade/trading-sdk 1.0.0

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 (106) hide show
  1. package/README.md +354 -0
  2. package/dist/api-clients/clients/config-client.d.ts +56 -0
  3. package/dist/api-clients/clients/config-client.esm.js +72 -0
  4. package/dist/api-clients/clients/config-client.esm.js.map +1 -0
  5. package/dist/api-clients/clients/config-client.js +74 -0
  6. package/dist/api-clients/clients/config-client.js.map +1 -0
  7. package/dist/api-clients/clients/oracle-client.d.ts +17 -0
  8. package/dist/api-clients/clients/oracle-client.esm.js +24 -0
  9. package/dist/api-clients/clients/oracle-client.esm.js.map +1 -0
  10. package/dist/api-clients/clients/oracle-client.js +26 -0
  11. package/dist/api-clients/clients/oracle-client.js.map +1 -0
  12. package/dist/api-clients/clients/storm-client.d.ts +8 -0
  13. package/dist/api-clients/clients/storm-client.esm.js +18 -0
  14. package/dist/api-clients/clients/storm-client.esm.js.map +1 -0
  15. package/dist/api-clients/clients/storm-client.js +20 -0
  16. package/dist/api-clients/clients/storm-client.js.map +1 -0
  17. package/dist/api-clients/contracts/jetton-master.d.ts +8 -0
  18. package/dist/api-clients/contracts/jetton-master.esm.js +21 -0
  19. package/dist/api-clients/contracts/jetton-master.esm.js.map +1 -0
  20. package/dist/api-clients/contracts/jetton-master.js +23 -0
  21. package/dist/api-clients/contracts/jetton-master.js.map +1 -0
  22. package/dist/api-clients/contracts/position-manager/position-manager-packers.d.ts +10 -0
  23. package/dist/api-clients/contracts/position-manager/position-manager-packers.esm.js +148 -0
  24. package/dist/api-clients/contracts/position-manager/position-manager-packers.esm.js.map +1 -0
  25. package/dist/api-clients/contracts/position-manager/position-manager-packers.js +157 -0
  26. package/dist/api-clients/contracts/position-manager/position-manager-packers.js.map +1 -0
  27. package/dist/api-clients/contracts/position-manager/position-manager.types.d.ts +165 -0
  28. package/dist/api-clients/contracts/position-manager.d.ts +9 -0
  29. package/dist/api-clients/contracts/position-manager.esm.js +55 -0
  30. package/dist/api-clients/contracts/position-manager.esm.js.map +1 -0
  31. package/dist/api-clients/contracts/position-manager.js +57 -0
  32. package/dist/api-clients/contracts/position-manager.js.map +1 -0
  33. package/dist/api-clients/contracts/vault.d.ts +8 -0
  34. package/dist/api-clients/contracts/vault.esm.js +30 -0
  35. package/dist/api-clients/contracts/vault.esm.js.map +1 -0
  36. package/dist/api-clients/contracts/vault.js +32 -0
  37. package/dist/api-clients/contracts/vault.js.map +1 -0
  38. package/dist/api-clients/index.d.ts +7 -0
  39. package/dist/api-clients/index.esm.js +8 -0
  40. package/dist/api-clients/index.esm.js.map +1 -0
  41. package/dist/api-clients/index.js +20 -0
  42. package/dist/api-clients/index.js.map +1 -0
  43. package/dist/api-clients/utils/address-to-cell.d.ts +2 -0
  44. package/dist/api-clients/utils/address-to-cell.esm.js +8 -0
  45. package/dist/api-clients/utils/address-to-cell.esm.js.map +1 -0
  46. package/dist/api-clients/utils/address-to-cell.js +10 -0
  47. package/dist/api-clients/utils/address-to-cell.js.map +1 -0
  48. package/dist/api-clients/utils/ton-client-abstract.d.ts +8 -0
  49. package/dist/api-clients/utils/ton-client-abstract.esm.js +45 -0
  50. package/dist/api-clients/utils/ton-client-abstract.esm.js.map +1 -0
  51. package/dist/api-clients/utils/ton-client-abstract.js +47 -0
  52. package/dist/api-clients/utils/ton-client-abstract.js.map +1 -0
  53. package/dist/base-packers/index.d.ts +5 -0
  54. package/dist/base-packers/index.esm.js +4 -0
  55. package/dist/base-packers/index.esm.js.map +1 -0
  56. package/dist/base-packers/index.js +28 -0
  57. package/dist/base-packers/index.js.map +1 -0
  58. package/dist/base-packers/opcodes.d.ts +14 -0
  59. package/dist/base-packers/opcodes.esm.js +20 -0
  60. package/dist/base-packers/opcodes.esm.js.map +1 -0
  61. package/dist/base-packers/opcodes.js +20 -0
  62. package/dist/base-packers/opcodes.js.map +1 -0
  63. package/dist/base-packers/oracle-packer.d.ts +3 -0
  64. package/dist/base-packers/oracle-packer.esm.js +23 -0
  65. package/dist/base-packers/oracle-packer.esm.js.map +1 -0
  66. package/dist/base-packers/oracle-packer.js +25 -0
  67. package/dist/base-packers/oracle-packer.js.map +1 -0
  68. package/dist/base-packers/oracle-packer.types.d.ts +14 -0
  69. package/dist/base-packers/order-packers.d.ts +12 -0
  70. package/dist/base-packers/order-packers.esm.js +122 -0
  71. package/dist/base-packers/order-packers.esm.js.map +1 -0
  72. package/dist/base-packers/order-packers.js +133 -0
  73. package/dist/base-packers/order-packers.js.map +1 -0
  74. package/dist/base-packers/order-packers.types.d.ts +80 -0
  75. package/dist/base-packers/order-packers.types.esm.js +15 -0
  76. package/dist/base-packers/order-packers.types.esm.js.map +1 -0
  77. package/dist/base-packers/order-packers.types.js +15 -0
  78. package/dist/base-packers/order-packers.types.js.map +1 -0
  79. package/dist/common-packers/fees.d.ts +23 -0
  80. package/dist/common-packers/fees.esm.js +13 -0
  81. package/dist/common-packers/fees.esm.js.map +1 -0
  82. package/dist/common-packers/fees.js +15 -0
  83. package/dist/common-packers/fees.js.map +1 -0
  84. package/dist/common-packers/index.d.ts +2 -0
  85. package/dist/common-packers/index.esm.js +2 -0
  86. package/dist/common-packers/index.esm.js.map +1 -0
  87. package/dist/common-packers/index.js +15 -0
  88. package/dist/common-packers/index.js.map +1 -0
  89. package/dist/common-packers/order-packers.d.ts +10 -0
  90. package/dist/common-packers/order-packers.esm.js +146 -0
  91. package/dist/common-packers/order-packers.esm.js.map +1 -0
  92. package/dist/common-packers/order-packers.js +155 -0
  93. package/dist/common-packers/order-packers.js.map +1 -0
  94. package/dist/common-packers/order-packers.types.d.ts +102 -0
  95. package/dist/sdk/index.d.ts +2 -0
  96. package/dist/sdk/index.esm.js +2 -0
  97. package/dist/sdk/index.esm.js.map +1 -0
  98. package/dist/sdk/index.js +8 -0
  99. package/dist/sdk/index.js.map +1 -0
  100. package/dist/sdk/sdk.d.ts +42 -0
  101. package/dist/sdk/sdk.esm.js +352 -0
  102. package/dist/sdk/sdk.esm.js.map +1 -0
  103. package/dist/sdk/sdk.js +354 -0
  104. package/dist/sdk/sdk.js.map +1 -0
  105. package/dist/sdk/sdk.types.d.ts +327 -0
  106. package/package.json +102 -0
@@ -0,0 +1,327 @@
1
+ import { Direction, OraclePayload, OrderType } from '../base-packers';
2
+ export type CollateralAssets = 'TON' | 'USDT' | 'NOT';
3
+ export type MarketOpenOrderParams = {
4
+ /**
5
+ * Market's base asset, e.g BTC
6
+ */
7
+ baseAssetName: string;
8
+ /**
9
+ * Which asset will be used as collateral, e.g TON
10
+ */
11
+ collateralAssetName: CollateralAssets;
12
+ /**
13
+ * Position direction short/long
14
+ */
15
+ direction: Direction;
16
+ /**
17
+ * Amount of collateral asset to use, set decimals based on collateral. E.g 9 for TON, 6 for USDT, 9 for NOT
18
+ */
19
+ amount: bigint;
20
+ /**
21
+ * Leverage for this order, 9 decimals
22
+ */
23
+ leverage: bigint;
24
+ /**
25
+ * Minimal base asset amount, that will be added to position after order executed, 9 decimals
26
+ */
27
+ minBaseAssetAmount?: bigint;
28
+ /**
29
+ * If set will create stop loss order with specified trigger price, once market order is executed, 9 decimals
30
+ */
31
+ stopTriggerPrice?: bigint;
32
+ /**
33
+ * If set will create take profit order with specified trigger price, once market order is executed, 9 decimals
34
+ */
35
+ takeTriggerPrice?: bigint;
36
+ /**
37
+ * Order TTL, seconds, default to 15 minutes
38
+ */
39
+ expiration?: number;
40
+ };
41
+ export type MarketCloseOrderParams = {
42
+ /**
43
+ * Market's base asset, e.g BTC
44
+ */
45
+ baseAssetName: string;
46
+ /**
47
+ * Which asset will was used as collateral, e.g TON
48
+ */
49
+ collateralAssetName: CollateralAssets;
50
+ /**
51
+ * Position direction short/long
52
+ */
53
+ direction: Direction;
54
+ /**
55
+ * How much base asset will be swapped back to collateral asset, 9 decimals
56
+ */
57
+ size: bigint;
58
+ };
59
+ export type LimitOrderParams = {
60
+ /**
61
+ * Market's base asset, e.g BTC
62
+ */
63
+ baseAssetName: string;
64
+ /**
65
+ * Which asset will be used as collateral, e.g TON
66
+ */
67
+ collateralAssetName: CollateralAssets;
68
+ /**
69
+ * Position direction short/long
70
+ */
71
+ direction: Direction;
72
+ /**
73
+ * Amount of collateral asset to use, set decimals based on collateral. E.g 9 for TON, 6 for USDT, 9 for NOT
74
+ */
75
+ amount: bigint;
76
+ /**
77
+ * Leverage for this order, 9 decimals
78
+ */
79
+ leverage: bigint;
80
+ /**
81
+ * Price to trigger limit order execution, 9 decimals
82
+ */
83
+ limitPrice: bigint;
84
+ /**
85
+ * If set will create stop loss order with specified trigger price, once limit order is executed, 9 decimals
86
+ */
87
+ stopTriggerPrice?: bigint;
88
+ /**
89
+ * If set will create take profit order with specified trigger price, once limit order is executed, 9 decimals
90
+ */
91
+ takeTriggerPrice?: bigint;
92
+ /**
93
+ * Order TTL, seconds, default to 60 days
94
+ */
95
+ expiration?: number;
96
+ };
97
+ export type StopLimitOrderParams = {
98
+ /**
99
+ * Market's base asset, e.g BTC
100
+ */
101
+ baseAssetName: string;
102
+ /**
103
+ * Which asset will be used as collateral, e.g TON
104
+ */
105
+ collateralAssetName: CollateralAssets;
106
+ /**
107
+ * Position direction short/long
108
+ */
109
+ direction: Direction;
110
+ /**
111
+ * Amount of collateral asset to use, set decimals based on collateral. E.g 9 for TON, 6 for USDT, 9 for NOT
112
+ */
113
+ amount: bigint;
114
+ /**
115
+ * Leverage for this order, 9 decimals
116
+ */
117
+ leverage: bigint;
118
+ /**
119
+ * Price to trigger limit order creation, 9 decimals
120
+ */
121
+ stopPrice: bigint;
122
+ /**
123
+ * Price to trigger limit order execution, 9 decimals
124
+ */
125
+ limitPrice: bigint;
126
+ /**
127
+ * If set will create stop loss order with specified trigger price, once limit order is executed, 9 decimals
128
+ */
129
+ stopTriggerPrice?: bigint;
130
+ /**
131
+ * If set will create take profit order with specified trigger price, once limit order is executed, 9 decimals
132
+ */
133
+ takeTriggerPrice?: bigint;
134
+ /**
135
+ * Order TTL, seconds, default to 60 days
136
+ */
137
+ expiration?: number;
138
+ };
139
+ export type StopMarketOrderParams = {
140
+ /**
141
+ * Market's base asset, e.g BTC
142
+ */
143
+ baseAssetName: string;
144
+ /**
145
+ * Which asset will be used as collateral, e.g TON
146
+ */
147
+ collateralAssetName: CollateralAssets;
148
+ /**
149
+ * Position direction short/long
150
+ */
151
+ direction: Direction;
152
+ /**
153
+ * Amount of collateral asset to use, set decimals based on collateral. E.g 9 for TON, 6 for USDT, 9 for NOT
154
+ */
155
+ amount: bigint;
156
+ /**
157
+ * Leverage for this order, 9 decimals
158
+ */
159
+ leverage: bigint;
160
+ /**
161
+ * Price to trigger market order creation, 9 decimals
162
+ */
163
+ stopPrice: bigint;
164
+ /**
165
+ * If set will create stop loss order with specified trigger price, once limit order is executed, 9 decimals
166
+ */
167
+ stopTriggerPrice?: bigint;
168
+ /**
169
+ * If set will create take profit order with specified trigger price, once limit order is executed, 9 decimals
170
+ */
171
+ takeTriggerPrice?: bigint;
172
+ /**
173
+ * Order TTL, seconds, default to 60 days
174
+ */
175
+ expiration?: number;
176
+ };
177
+ export type StopLossOrderParams = {
178
+ /**
179
+ * Market's base asset, e.g BTC
180
+ */
181
+ baseAssetName: string;
182
+ /**
183
+ * Which asset will was used as collateral, e.g TON
184
+ */
185
+ collateralAssetName: CollateralAssets;
186
+ /**
187
+ * Position direction short/long
188
+ */
189
+ direction: Direction;
190
+ /**
191
+ * How much base asset will be swapped back to collateral asset, 9 decimals
192
+ */
193
+ amount: bigint;
194
+ /**
195
+ * Price to trigger order execution, 9 decimals
196
+ */
197
+ triggerPrice: bigint;
198
+ };
199
+ export type TakeProfitOrderParams = {
200
+ /**
201
+ * Market's base asset, e.g BTC
202
+ */
203
+ baseAssetName: string;
204
+ /**
205
+ * Which asset will was used as collateral, e.g TON
206
+ */
207
+ collateralAssetName: CollateralAssets;
208
+ /**
209
+ * Position direction short/long
210
+ */
211
+ direction: Direction;
212
+ /**
213
+ * How much base asset will be swapped back to collateral asset, 9 decimals
214
+ */
215
+ amount: bigint;
216
+ /**
217
+ * Price to trigger order execution, 9 decimals
218
+ */
219
+ triggerPrice: bigint;
220
+ };
221
+ export type CancelOrderParams = {
222
+ /**
223
+ * Market's base asset, e.g BTC
224
+ */
225
+ baseAssetName: string;
226
+ /**
227
+ * Which asset will was used as collateral, e.g TON
228
+ */
229
+ collateralAssetName: CollateralAssets;
230
+ /**
231
+ * Position direction short/long
232
+ */
233
+ direction: Direction;
234
+ /**
235
+ * Which order type will be cancelled
236
+ */
237
+ orderType: OrderType;
238
+ /**
239
+ * Order index in position manager storage.
240
+ * Get this from API, or from contract directly via getPositionManagerData method
241
+ */
242
+ orderIndex: number;
243
+ };
244
+ export type AddMarginParams = {
245
+ /**
246
+ * Market's base asset, e.g BTC
247
+ */
248
+ baseAssetName: string;
249
+ /**
250
+ * Which asset will was used as collateral, e.g TON
251
+ */
252
+ collateralAssetName: CollateralAssets;
253
+ /**
254
+ * Position direction short/long
255
+ */
256
+ direction: Direction;
257
+ /**
258
+ * Amount of collateral asset to add, set decimals based on collateral. E.g 9 for TON, 6 for USDT, 9 for NOT
259
+ */
260
+ amount: bigint;
261
+ /**
262
+ * If set will provide oracle prices for base and collateral assets, otherwise sdk will request them on it's own
263
+ */
264
+ oraclePayload?: OraclePayload;
265
+ };
266
+ export type RemoveMarginParams = {
267
+ /**
268
+ * Market's base asset, e.g BTC
269
+ */
270
+ baseAssetName: string;
271
+ /**
272
+ * Which asset will was used as collateral, e.g TON
273
+ */
274
+ collateralAssetName: CollateralAssets;
275
+ /**
276
+ * Position direction short/long
277
+ */
278
+ direction: Direction;
279
+ /**
280
+ * Amount of collateral asset to remove, set decimals based on collateral. E.g 9 for TON, 6 for USDT, 9 for NOT
281
+ */
282
+ amount: bigint;
283
+ /**
284
+ * If set will provide oracle prices for base and collateral assets, otherwise sdk will request them on it's own
285
+ */
286
+ oraclePayload?: OraclePayload;
287
+ };
288
+ export type ProvideLiquidityParams = {
289
+ /**
290
+ * Which asset will be used as collateral, e.g TON
291
+ */
292
+ assetName: CollateralAssets;
293
+ /**
294
+ * Amount of collateral asset to use, set decimals based on collateral. E.g 9 for TON, 6 for USDT, 9 for NOT
295
+ */
296
+ amount: bigint;
297
+ };
298
+ export type WithdrawLiquidityParams = {
299
+ /**
300
+ * Which asset will was used as collateral, e.g TON
301
+ */
302
+ assetName: CollateralAssets;
303
+ /**
304
+ * Amount of SLP tokens to swap back to collateral assets, 9 decimals
305
+ */
306
+ amountOfSLP: bigint;
307
+ };
308
+ export type CreateAnyLimitOrderParams = {
309
+ baseAssetName: string;
310
+ collateralAssetName: string;
311
+ direction: Direction;
312
+ amount: bigint;
313
+ leverage: bigint;
314
+ stopPrice: bigint;
315
+ limitPrice: bigint;
316
+ stopTriggerPrice?: bigint;
317
+ takeTriggerPrice?: bigint;
318
+ expiration?: number;
319
+ };
320
+ export type CreateSLTPOrderParams = {
321
+ baseAssetName: string;
322
+ collateralAssetName: string;
323
+ direction: Direction;
324
+ type: OrderType.stopLoss | OrderType.takeProfit;
325
+ amount: bigint;
326
+ triggerPrice: bigint;
327
+ };
package/package.json ADDED
@@ -0,0 +1,102 @@
1
+ {
2
+ "name": "@storm-trade/trading-sdk",
3
+ "version": "1.0.0",
4
+ "description": "Storm Trade trading SDK",
5
+ "private": false,
6
+ "exports": {
7
+ "./api-clients": {
8
+ "types": "./dist/api-clients/index.d.ts",
9
+ "require": "./dist/api-clients/index.js",
10
+ "import": "./dist/api-clients/index.esm.js"
11
+ },
12
+ "./common-packers": {
13
+ "types": "./dist/common-packers/index.d.ts",
14
+ "require": "./dist/common-packers/index.js",
15
+ "import": "./dist/common-packers/index.esm.js"
16
+ },
17
+ "./base-packers": {
18
+ "types": "./dist/base-packers/index.d.ts",
19
+ "require": "./dist/base-packers/index.js",
20
+ "import": "./dist/base-packers/index.esm.js"
21
+ },
22
+ "./sdk": {
23
+ "types": "./dist/sdk/index.d.ts",
24
+ "require": "./dist/sdk/index.js",
25
+ "import": "./dist/sdk/index.esm.js"
26
+ }
27
+ },
28
+ "files": [
29
+ "dist/*.js",
30
+ "dist/*.d.ts",
31
+ "dist/api-clients",
32
+ "dist/base-packers",
33
+ "dist/common-packers",
34
+ "dist/sdk",
35
+ "README.md"
36
+ ],
37
+ "scripts": {
38
+ "build": "rollup -c",
39
+ "test": "jest",
40
+ "lint": "eslint .",
41
+ "format": "prettier --write \"src/**/*.ts\"",
42
+ "prepare": "husky install",
43
+ "prepublishOnly": "npm run build",
44
+ "docs": "typedoc --out docs src/index.ts"
45
+ },
46
+ "keywords": [
47
+ "trading",
48
+ "sdk",
49
+ "storm-trade",
50
+ "dex",
51
+ "storm"
52
+ ],
53
+ "author": "",
54
+ "repository": "https://github.com/storm-trade/sdk-js",
55
+ "license": "MIT",
56
+ "devDependencies": {
57
+ "@eslint/js": "^9.21.0",
58
+ "@rollup/plugin-commonjs": "^28.0.2",
59
+ "@rollup/plugin-node-resolve": "^16.0.0",
60
+ "@rollup/plugin-typescript": "^12.1.2",
61
+ "@ton/ton": "^15.2.1",
62
+ "@types/jest": "^29.5.12",
63
+ "@types/node": "^20.11.19",
64
+ "@typescript-eslint/eslint-plugin": "^8.26.0",
65
+ "@typescript-eslint/parser": "^8.26.0",
66
+ "dotenv": "^16.4.7",
67
+ "eslint": "^9.21.0",
68
+ "eslint-config-prettier": "^10.0.2",
69
+ "eslint-plugin-import": "^2.29.1",
70
+ "eslint-plugin-prettier": "^5.1.3",
71
+ "eslint-plugin-unused-imports": "^4.1.4",
72
+ "globals": "^16.0.0",
73
+ "husky": "^9.1.7",
74
+ "jest": "^29.7.0",
75
+ "lint-staged": "^15.2.2",
76
+ "prettier": "^3.5.3",
77
+ "rollup": "^4.34.9",
78
+ "ton-lite-client": "^3.0.0",
79
+ "ts-jest": "^29.1.2",
80
+ "tslib": "^2.8.1",
81
+ "typescript": "^5.8.2",
82
+ "typescript-eslint": "^8.26.0"
83
+ },
84
+ "dependencies": {
85
+ "@hastom/fetch": "^1.0.4"
86
+ },
87
+ "peerDependencies": {
88
+ "@ton/ton": "^15.2.0",
89
+ "ton-lite-client": "^3.0.0"
90
+ },
91
+ "peerDependenciesMeta": {
92
+ "ton-lite-client": {
93
+ "optional": true
94
+ }
95
+ },
96
+ "lint-staged": {
97
+ "*.ts": [
98
+ "eslint --fix",
99
+ "prettier --write"
100
+ ]
101
+ }
102
+ }