@reyaxyz/api-sdk 0.26.0 → 0.28.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 (95) hide show
  1. package/dist/clients/api-client.js +19 -0
  2. package/dist/clients/api-client.js.map +1 -1
  3. package/dist/clients/modules/{account.js → account/index.js} +2 -2
  4. package/dist/clients/modules/account/index.js.map +1 -0
  5. package/dist/clients/{helpers/trade.simulation.types.js → modules/account/types.js} +1 -1
  6. package/dist/clients/modules/account/types.js.map +1 -0
  7. package/dist/clients/modules/{lp.js → lp/index.js} +2 -2
  8. package/dist/clients/modules/lp/index.js.map +1 -0
  9. package/dist/clients/modules/lp/types.js +13 -0
  10. package/dist/clients/modules/lp/types.js.map +1 -0
  11. package/dist/clients/modules/{markets.js → markets/index.js} +2 -2
  12. package/dist/clients/modules/markets/index.js.map +1 -0
  13. package/dist/clients/modules/markets/types.js +3 -0
  14. package/dist/clients/modules/markets/types.js.map +1 -0
  15. package/dist/clients/modules/{rest.js → rest/index.js} +4 -4
  16. package/dist/clients/modules/rest/index.js.map +1 -0
  17. package/dist/clients/modules/tokens/index.js +75 -0
  18. package/dist/clients/modules/tokens/index.js.map +1 -0
  19. package/dist/clients/modules/tokens/types.js +3 -0
  20. package/dist/clients/modules/tokens/types.js.map +1 -0
  21. package/dist/clients/modules/{trade.simulation.js → trade.simulation/index.js} +10 -10
  22. package/dist/clients/modules/trade.simulation/index.js.map +1 -0
  23. package/dist/clients/modules/trade.simulation/types.js +3 -0
  24. package/dist/clients/modules/trade.simulation/types.js.map +1 -0
  25. package/dist/clients/types.js +4 -36
  26. package/dist/clients/types.js.map +1 -1
  27. package/dist/index.js +0 -2
  28. package/dist/index.js.map +1 -1
  29. package/dist/types/clients/api-client.d.ts +13 -0
  30. package/dist/types/clients/api-client.d.ts.map +1 -1
  31. package/dist/types/clients/modules/{account.d.ts → account/index.d.ts} +4 -4
  32. package/dist/types/clients/modules/account/index.d.ts.map +1 -0
  33. package/dist/types/clients/modules/account/types.d.ts +47 -0
  34. package/dist/types/clients/modules/account/types.d.ts.map +1 -0
  35. package/dist/types/clients/modules/{lp.d.ts → lp/index.d.ts} +4 -3
  36. package/dist/types/clients/modules/lp/index.d.ts.map +1 -0
  37. package/dist/types/clients/modules/lp/types.d.ts +46 -0
  38. package/dist/types/clients/modules/lp/types.d.ts.map +1 -0
  39. package/dist/types/clients/modules/{markets.d.ts → markets/index.d.ts} +3 -3
  40. package/dist/types/clients/modules/markets/index.d.ts.map +1 -0
  41. package/dist/types/clients/modules/markets/types.d.ts +23 -0
  42. package/dist/types/clients/modules/markets/types.d.ts.map +1 -0
  43. package/dist/types/clients/modules/{rest.d.ts → rest/index.d.ts} +2 -2
  44. package/dist/types/clients/modules/rest/index.d.ts.map +1 -0
  45. package/dist/types/clients/modules/tokens/index.d.ts +6 -0
  46. package/dist/types/clients/modules/tokens/index.d.ts.map +1 -0
  47. package/dist/types/clients/modules/tokens/types.d.ts +8 -0
  48. package/dist/types/clients/modules/tokens/types.d.ts.map +1 -0
  49. package/dist/types/clients/modules/{trade.simulation.d.ts → trade.simulation/index.d.ts} +3 -3
  50. package/dist/types/clients/modules/trade.simulation/index.d.ts.map +1 -0
  51. package/dist/types/clients/modules/trade.simulation/types.d.ts +19 -0
  52. package/dist/types/clients/modules/trade.simulation/types.d.ts.map +1 -0
  53. package/dist/types/clients/types.d.ts +1 -300
  54. package/dist/types/clients/types.d.ts.map +1 -1
  55. package/dist/types/index.d.ts +0 -2
  56. package/dist/types/index.d.ts.map +1 -1
  57. package/package.json +6 -7
  58. package/src/clients/api-client.ts +17 -0
  59. package/src/clients/modules/{account.ts → account/index.ts} +3 -3
  60. package/src/clients/modules/account/types.ts +74 -0
  61. package/src/clients/modules/{lp.ts → lp/index.ts} +5 -3
  62. package/src/clients/modules/lp/types.ts +62 -0
  63. package/src/clients/modules/{markets.ts → markets/index.ts} +2 -2
  64. package/src/clients/modules/markets/types.ts +33 -0
  65. package/src/clients/modules/{rest.ts → rest/index.ts} +8 -3
  66. package/src/clients/modules/tokens/index.ts +11 -0
  67. package/src/clients/modules/tokens/types.ts +9 -0
  68. package/src/clients/modules/{trade.simulation.ts → trade.simulation/index.ts} +3 -4
  69. package/src/clients/modules/trade.simulation/types.ts +21 -0
  70. package/src/clients/types.ts +16 -388
  71. package/src/index.ts +0 -2
  72. package/dist/clients/helpers/exposure.calculator.js +0 -448
  73. package/dist/clients/helpers/exposure.calculator.js.map +0 -1
  74. package/dist/clients/helpers/number.js +0 -13
  75. package/dist/clients/helpers/number.js.map +0 -1
  76. package/dist/clients/helpers/trade.simulation.types.js.map +0 -1
  77. package/dist/clients/modules/account.js.map +0 -1
  78. package/dist/clients/modules/lp.js.map +0 -1
  79. package/dist/clients/modules/markets.js.map +0 -1
  80. package/dist/clients/modules/rest.js.map +0 -1
  81. package/dist/clients/modules/trade.simulation.js.map +0 -1
  82. package/dist/types/clients/helpers/exposure.calculator.d.ts +0 -58
  83. package/dist/types/clients/helpers/exposure.calculator.d.ts.map +0 -1
  84. package/dist/types/clients/helpers/number.d.ts +0 -3
  85. package/dist/types/clients/helpers/number.d.ts.map +0 -1
  86. package/dist/types/clients/helpers/trade.simulation.types.d.ts +0 -113
  87. package/dist/types/clients/helpers/trade.simulation.types.d.ts.map +0 -1
  88. package/dist/types/clients/modules/account.d.ts.map +0 -1
  89. package/dist/types/clients/modules/lp.d.ts.map +0 -1
  90. package/dist/types/clients/modules/markets.d.ts.map +0 -1
  91. package/dist/types/clients/modules/rest.d.ts.map +0 -1
  92. package/dist/types/clients/modules/trade.simulation.d.ts.map +0 -1
  93. package/src/clients/helpers/exposure.calculator.ts +0 -799
  94. package/src/clients/helpers/number.ts +0 -8
  95. package/src/clients/helpers/trade.simulation.types.ts +0 -125
@@ -1,388 +1,16 @@
1
- export enum CandlesResolution {
2
- ONE_MINUTE = '1MIN',
3
- FIVE_MINUTES = '5MINS',
4
- FIFTEEN_MINUTES = '15MINS',
5
- THIRTY_MINUTES = '30MINS',
6
- ONE_HOUR = '1HOUR',
7
- FOUR_HOURS = '4HOURS',
8
- ONE_DAY = '1DAY',
9
- }
10
-
11
- // -- Candles --
12
- export interface Candle {
13
- id: string;
14
- startedAt: string;
15
- ticker: string;
16
- resolution: CandlesResolution;
17
- low: string;
18
- high: string;
19
- open: string;
20
- close: string;
21
- baseTokenVolume: string;
22
- usdVolume: string;
23
- trades: number;
24
- startingOpenInterest: string;
25
- }
26
-
27
- export interface MarketCandlesResponse {
28
- candles: Candle[];
29
- }
30
-
31
- // -- Markets --
32
-
33
- export type MarketOrderInfo = {
34
- counterpartyAccountIds: number[];
35
- exchangeId: number;
36
- };
37
-
38
- export type MarketEntity = {
39
- id: number;
40
- ticker: string;
41
- underlyingAsset: string;
42
- quoteToken: string;
43
- markPrice: number;
44
- isActive: boolean;
45
- maxLeverage: number;
46
- volume24H: number;
47
- priceChange24H: number;
48
- priceChange24HPercentage: number;
49
- openInterest: number;
50
- fundingRate: number;
51
- description: string;
52
- orderInfo: MarketOrderInfo;
53
- tickSizeDecimals: number;
54
- chainId: SupportedChainId;
55
- };
56
-
57
- export type GetMarketsResult = MarketEntity[];
58
-
59
- export type GetMarketResult = MarketEntity;
60
-
61
- export type GetMarketParams = {
62
- id: MarketEntity['id'];
63
- };
64
-
65
- export type GetCandlesParams = {
66
- marketId: MarketEntity['id'];
67
- resolution: CandlesResolution;
68
- fromISO?: string | null;
69
- toISO?: string | null;
70
- limit?: number | null;
71
- };
72
-
73
- // -- Account --
74
-
75
- export type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';
76
- export type Side = 'long' | 'short';
77
-
78
- export type GetMarginAccountsParams = {
79
- address: string;
80
- limit?: number;
81
- };
82
-
83
- export type GetMarginAccountParams = {
84
- address: string;
85
- marginAccountId: MarginAccountEntity['id'];
86
- };
87
-
88
- export type GetPositionsForMarginAccountParams = {
89
- address: string;
90
- marginAccountId: MarginAccountEntity['id'];
91
- limit?: number;
92
- };
93
-
94
- export type MarginAccountEntity = {
95
- id: number;
96
- name: string;
97
- marginRatioHealth: 'danger' | 'healthy' | 'warning';
98
- marginRatioPercentage: number;
99
- totalBalance: number;
100
- totalBalanceUnderlyingAsset: string;
101
- collaterals: {
102
- token: string;
103
- percentage: number;
104
- balance: number;
105
- balanceRUSD: number;
106
- }[];
107
- };
108
-
109
- export type GetMarginAccountsResult = MarginAccountEntity[];
110
- export type GetMarginAccountResult = MarginAccountEntity;
111
-
112
- export type PositionEntity = {
113
- id: number;
114
- side: Side;
115
- size: number;
116
- base: number;
117
- price: number;
118
- markPrice: number;
119
- orderStatus: Status;
120
- realisedPnl?: number | null;
121
- unrealisedPnl?: number | null;
122
- liquidationPrice: number;
123
- fundingRate: number;
124
- market: MarketEntity;
125
- date: Date;
126
- };
127
-
128
- export type GetPositionsForMarginAccountResult = {
129
- positions: PositionEntity[];
130
- totalUnrealizedPNL: number;
131
- };
132
-
133
- // --- Trading History ----
134
-
135
- export type GetMarketTradingHistoryParams = {
136
- marketId: number;
137
- limit?: number;
138
- fromTimestampMillisecondsUTC?: number;
139
- };
140
-
141
- export type TradingHistoryEntity = {
142
- id: number;
143
- price: number;
144
- priceUnderlyingToken: string;
145
- size: number;
146
- sizeUnderlyingToken: string;
147
- timestampMillisecondsUTC: number;
148
- };
149
-
150
- export type GetTradingHistoryResult = TradingHistoryEntity[];
151
-
152
- // --- Position History ---
153
-
154
- export type GetPositionsHistoryForMarginAccountParams = {
155
- address: string;
156
- marginAccountId: MarginAccountEntity['id'];
157
- limit?: number;
158
- };
159
-
160
- export type OrderType = 'market';
161
-
162
- export type PositionHistoryType =
163
- | 'long-trade'
164
- | 'short-trade'
165
- | 'long-liquidation'
166
- | 'short-liquidation';
167
-
168
- export type PositionHistoryEntity = {
169
- id: number;
170
- action: PositionHistoryType;
171
- orderType: OrderType;
172
- size: number;
173
- executionPrice: number;
174
- realisedPnl?: number | null;
175
- fees: number;
176
- timestamp: number;
177
- market: MarketEntity;
178
- };
179
-
180
- export type GetPositionsHistoryForMarginAccountResult = PositionHistoryEntity[];
181
-
182
- // -- Max Order Size --
183
-
184
- export type GetMaxOrderSizeAvailableParams = {
185
- marketId: MarketEntity['id'];
186
- marginAccountId: MarginAccountEntity['id'];
187
- direction: 'long' | 'short';
188
- };
189
-
190
- export type GetMaxOrderSizeAvailableResult = number;
191
-
192
- // --- Trade Simulation ----
193
-
194
- export type SimulateTradeEntity = {
195
- liquidationPrice: number;
196
- fees: number;
197
- estimatedPrice: number;
198
- estimatedSlippage: number;
199
- imr: number;
200
- impliedLeverage: number;
201
- marginRatio: MarginAccountEntity['marginRatioPercentage'];
202
- marginRatioHealth: MarginAccountEntity['marginRatioHealth'];
203
- };
204
-
205
- export type TradeSimulationLoadDataParams = {
206
- marketId: MarketEntity['id'];
207
- marginAccountId: MarginAccountEntity['id'];
208
- };
209
-
210
- export type TradeSimulationSimulateParams = {
211
- amount: number; // position size, + for long | - for short
212
- };
213
-
214
- // ---- LP ----
215
-
216
- export enum SupportedChainId {
217
- polygonMumbai = 80001,
218
- reyaCronos = 1729,
219
- }
220
-
221
- export type LpPoolEntity = {
222
- id: number;
223
- name: string;
224
- description: string;
225
- longDescription: string;
226
- readMoreLink: string;
227
- currentAPY: number;
228
- balanceSupplied?: number | null;
229
- apyChange24H: number;
230
- tokenAddress: string;
231
- token: string;
232
- allowedChainsForLiquidity: number[];
233
- chainId: SupportedChainId;
234
- };
235
-
236
- export type GetLpPoolsResult = LpPoolEntity[];
237
-
238
- export type GetLpPoolResult = LpPoolEntity;
239
-
240
- export type GetLpPoolParams = {
241
- id: LpPoolEntity['id'];
242
- };
243
-
244
- export type TransactionHistoryType = 'deposit' | 'withdrawal';
245
-
246
- export type LpTransactionHistoryEntity = {
247
- id: number;
248
- type: TransactionHistoryType;
249
- token: string;
250
- amount: number;
251
- transactionHash: string;
252
- timestamp: number;
253
- };
254
-
255
- export type GetLpPoolTransactionHistoryParams = {
256
- id: LpPoolEntity['id'];
257
- address: string; // wallet address
258
- limit?: number;
259
- };
260
-
261
- export type GetLpPoolTransactionHistoryResult = LpTransactionHistoryEntity[];
262
-
263
- export type GetLpPositionsParams = {
264
- id: LpPoolEntity['id'];
265
- address: string; // wallet address
266
- };
267
-
268
- export type LpPositionEntity = {
269
- id: number;
270
- deposited: number;
271
- currentBalance: number;
272
- pnl: number;
273
- fundingRate: number;
274
- lpPool: LpPoolEntity;
275
- };
276
-
277
- export type GetLpPositionsResult = LpPositionEntity[];
278
-
279
- export type GetLpPoolWithdrawBalanceParams = {
280
- id: LpPoolEntity['id'];
281
- address: string; // wallet address
282
- };
283
-
284
- export type GetLpPoolWithdrawBalanceResult = number;
285
-
286
- // ---- Transaction Simulation ----
287
-
288
- export type GetTransactionSimulationInitialDataParams = {
289
- marketId: MarketEntity['id'];
290
- marginAccountId: MarginAccountEntity['id'];
291
- };
292
-
293
- // ---- Transaction History
294
-
295
- export type GetMarginAccountTransactionHistoryParams = {
296
- marginAccountId: MarginAccountEntity['id'];
297
- limit?: number;
298
- };
299
-
300
- export type MarginAccountTransactionHistoryType =
301
- | 'deposit'
302
- | 'withdrawal'
303
- | 'transfer'
304
- | 'auto_exchange';
305
-
306
- export type MarginAccountTransactionHistoryEntity = {
307
- id: number;
308
- type: MarginAccountTransactionHistoryType;
309
- token: string;
310
- amount: number;
311
- transactionHash: string;
312
- timestamp: number;
313
- };
314
-
315
- export type GetMarginAccountTransactionHistoryResult =
316
- MarginAccountTransactionHistoryEntity[];
317
-
318
- // --- Lp Pool Balance ---
319
-
320
- export enum BalanceGranularity {
321
- ONE_MINUTE = 60 * 1000,
322
- ONE_HOUR = 60 * 60 * 1000,
323
- ONE_DAY = 24 * 60 * 60 * 1000,
324
- ONE_WEEK = 7 * 24 * 60 * 60 * 1000,
325
- ONE_MONTH = 30 * 24 * 60 * 60 * 1000,
326
- ONE_YEAR = 365 * 24 * 60 * 60 * 1000,
327
- }
328
-
329
- export type GetLpPoolBalanceChartDataParams = {
330
- poolId: LpPoolEntity['id'];
331
- filters: {
332
- timeframeMs: number;
333
- granularity: BalanceGranularity;
334
- };
335
- };
336
-
337
- export type GetLpPoolBalanceChartDataResult = {
338
- data: {
339
- timestampInMs: number;
340
- value: number;
341
- }[];
342
- tvl: number;
343
- tvlChangePercentage: number;
344
- apy: number;
345
- apyChangePercentage: number;
346
- };
347
-
348
- // - LP Account Performance -
349
- export type GetLpPoolPerformanceChartDataResult = {
350
- capitalInvestedData: {
351
- timestampInMs: number;
352
- value: number;
353
- }[];
354
- balanceData: {
355
- timestampInMs: number;
356
- value: number;
357
- }[];
358
- balance: number;
359
- balanceChangePercentage: number;
360
- capitalInvested: number;
361
- capitalInvestedChangePercentage: number;
362
- };
363
-
364
- export enum PerformanceGranularity {
365
- ONE_MINUTE = 60 * 1000,
366
- ONE_HOUR = 60 * 60 * 1000,
367
- ONE_DAY = 24 * 60 * 60 * 1000,
368
- ONE_WEEK = 7 * 24 * 60 * 60 * 1000,
369
- ONE_MONTH = 30 * 24 * 60 * 60 * 1000,
370
- ONE_YEAR = 365 * 24 * 60 * 60 * 1000,
371
- }
372
-
373
- export type GetLpPoolPerformanceChartDataParams = {
374
- poolId: LpPoolEntity['id'];
375
- address: string; // wallet address
376
- filters: {
377
- timeframeMs: number;
378
- granularity: PerformanceGranularity;
379
- };
380
- };
381
-
382
- // --- Max Withdraw Balance for Margin Account ---
383
- export type GetMaxWithdrawBalanceForAccountParams = {
384
- marginAccountId: MarginAccountEntity['id'];
385
- tokenAddress: string; // address of usdc/eth/btc
386
- };
387
-
388
- export type GetMaxWithdrawBalanceForAccountResult = number;
1
+ // reexporting what we want to share with integrators
2
+ export {
3
+ Candle,
4
+ CandlesResolution,
5
+ MarketEntity,
6
+ LpTransactionHistoryEntity,
7
+ TradingHistoryEntity,
8
+ PositionHistoryEntity,
9
+ PositionEntity,
10
+ TransactionHistoryType,
11
+ MarginAccountTransactionHistoryType,
12
+ MarginAccountTransactionHistoryEntity,
13
+ MarginAccountEntity,
14
+ LpPositionEntity,
15
+ LpPoolEntity,
16
+ } from '@reyaxyz/common';
package/src/index.ts CHANGED
@@ -1,4 +1,2 @@
1
1
  export { ApiClient } from './clients/api-client';
2
2
  export * from './clients/types';
3
- export * from './clients/helpers/exposure.calculator';
4
- export * from './clients/helpers/trade.simulation.types';