@reyaxyz/api-sdk 0.27.0 → 0.29.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 (101) hide show
  1. package/dist/clients/api-client.js +4 -2
  2. package/dist/clients/api-client.js.map +1 -1
  3. package/dist/clients/helpers/constants.js +6 -3
  4. package/dist/clients/helpers/constants.js.map +1 -1
  5. package/dist/clients/modules/{account.js → account/index.js} +2 -2
  6. package/dist/clients/modules/account/index.js.map +1 -0
  7. package/dist/clients/{helpers/trade.simulation.types.js → modules/account/types.js} +1 -1
  8. package/dist/clients/modules/account/types.js.map +1 -0
  9. package/dist/clients/modules/{lp.js → lp/index.js} +2 -2
  10. package/dist/clients/modules/lp/index.js.map +1 -0
  11. package/dist/clients/modules/lp/types.js +13 -0
  12. package/dist/clients/modules/lp/types.js.map +1 -0
  13. package/dist/clients/modules/{markets.js → markets/index.js} +2 -2
  14. package/dist/clients/modules/markets/index.js.map +1 -0
  15. package/dist/clients/modules/markets/types.js +3 -0
  16. package/dist/clients/modules/markets/types.js.map +1 -0
  17. package/dist/clients/modules/{rest.js → rest/index.js} +4 -4
  18. package/dist/clients/modules/rest/index.js.map +1 -0
  19. package/dist/clients/modules/{tokens.js → tokens/index.js} +2 -2
  20. package/dist/clients/modules/tokens/index.js.map +1 -0
  21. package/dist/clients/modules/tokens/types.js +3 -0
  22. package/dist/clients/modules/tokens/types.js.map +1 -0
  23. package/dist/clients/modules/{trade.simulation.js → trade.simulation/index.js} +10 -10
  24. package/dist/clients/modules/trade.simulation/index.js.map +1 -0
  25. package/dist/clients/modules/trade.simulation/types.js +3 -0
  26. package/dist/clients/modules/trade.simulation/types.js.map +1 -0
  27. package/dist/clients/types.js +4 -36
  28. package/dist/clients/types.js.map +1 -1
  29. package/dist/index.js +0 -2
  30. package/dist/index.js.map +1 -1
  31. package/dist/types/clients/api-client.d.ts.map +1 -1
  32. package/dist/types/clients/helpers/constants.d.ts +4 -3
  33. package/dist/types/clients/helpers/constants.d.ts.map +1 -1
  34. package/dist/types/clients/modules/{account.d.ts → account/index.d.ts} +4 -4
  35. package/dist/types/clients/modules/account/index.d.ts.map +1 -0
  36. package/dist/types/clients/modules/account/types.d.ts +47 -0
  37. package/dist/types/clients/modules/account/types.d.ts.map +1 -0
  38. package/dist/types/clients/modules/{lp.d.ts → lp/index.d.ts} +4 -3
  39. package/dist/types/clients/modules/lp/index.d.ts.map +1 -0
  40. package/dist/types/clients/modules/lp/types.d.ts +46 -0
  41. package/dist/types/clients/modules/lp/types.d.ts.map +1 -0
  42. package/dist/types/clients/modules/{markets.d.ts → markets/index.d.ts} +3 -3
  43. package/dist/types/clients/modules/markets/index.d.ts.map +1 -0
  44. package/dist/types/clients/modules/markets/types.d.ts +23 -0
  45. package/dist/types/clients/modules/markets/types.d.ts.map +1 -0
  46. package/dist/types/clients/modules/{rest.d.ts → rest/index.d.ts} +2 -2
  47. package/dist/types/clients/modules/rest/index.d.ts.map +1 -0
  48. package/dist/types/clients/modules/{tokens.d.ts → tokens/index.d.ts} +3 -3
  49. package/dist/types/clients/modules/tokens/index.d.ts.map +1 -0
  50. package/dist/types/clients/modules/tokens/types.d.ts +8 -0
  51. package/dist/types/clients/modules/tokens/types.d.ts.map +1 -0
  52. package/dist/types/clients/modules/{trade.simulation.d.ts → trade.simulation/index.d.ts} +3 -3
  53. package/dist/types/clients/modules/trade.simulation/index.d.ts.map +1 -0
  54. package/dist/types/clients/modules/trade.simulation/types.d.ts +19 -0
  55. package/dist/types/clients/modules/trade.simulation/types.d.ts.map +1 -0
  56. package/dist/types/clients/types.d.ts +1 -309
  57. package/dist/types/clients/types.d.ts.map +1 -1
  58. package/dist/types/index.d.ts +0 -2
  59. package/dist/types/index.d.ts.map +1 -1
  60. package/package.json +6 -7
  61. package/src/clients/api-client.ts +5 -8
  62. package/src/clients/helpers/constants.ts +7 -6
  63. package/src/clients/modules/{account.ts → account/index.ts} +3 -3
  64. package/src/clients/modules/account/types.ts +74 -0
  65. package/src/clients/modules/{lp.ts → lp/index.ts} +5 -3
  66. package/src/clients/modules/lp/types.ts +62 -0
  67. package/src/clients/modules/{markets.ts → markets/index.ts} +2 -2
  68. package/src/clients/modules/markets/types.ts +33 -0
  69. package/src/clients/modules/{rest.ts → rest/index.ts} +8 -3
  70. package/src/clients/modules/{tokens.ts → tokens/index.ts} +2 -2
  71. package/src/clients/modules/tokens/types.ts +9 -0
  72. package/src/clients/modules/{trade.simulation.ts → trade.simulation/index.ts} +3 -4
  73. package/src/clients/modules/trade.simulation/types.ts +21 -0
  74. package/src/clients/types.ts +16 -400
  75. package/src/index.ts +0 -2
  76. package/dist/clients/helpers/exposure.calculator.js +0 -448
  77. package/dist/clients/helpers/exposure.calculator.js.map +0 -1
  78. package/dist/clients/helpers/number.js +0 -13
  79. package/dist/clients/helpers/number.js.map +0 -1
  80. package/dist/clients/helpers/trade.simulation.types.js.map +0 -1
  81. package/dist/clients/modules/account.js.map +0 -1
  82. package/dist/clients/modules/lp.js.map +0 -1
  83. package/dist/clients/modules/markets.js.map +0 -1
  84. package/dist/clients/modules/rest.js.map +0 -1
  85. package/dist/clients/modules/tokens.js.map +0 -1
  86. package/dist/clients/modules/trade.simulation.js.map +0 -1
  87. package/dist/types/clients/helpers/exposure.calculator.d.ts +0 -58
  88. package/dist/types/clients/helpers/exposure.calculator.d.ts.map +0 -1
  89. package/dist/types/clients/helpers/number.d.ts +0 -3
  90. package/dist/types/clients/helpers/number.d.ts.map +0 -1
  91. package/dist/types/clients/helpers/trade.simulation.types.d.ts +0 -113
  92. package/dist/types/clients/helpers/trade.simulation.types.d.ts.map +0 -1
  93. package/dist/types/clients/modules/account.d.ts.map +0 -1
  94. package/dist/types/clients/modules/lp.d.ts.map +0 -1
  95. package/dist/types/clients/modules/markets.d.ts.map +0 -1
  96. package/dist/types/clients/modules/rest.d.ts.map +0 -1
  97. package/dist/types/clients/modules/tokens.d.ts.map +0 -1
  98. package/dist/types/clients/modules/trade.simulation.d.ts.map +0 -1
  99. package/src/clients/helpers/exposure.calculator.ts +0 -799
  100. package/src/clients/helpers/number.ts +0 -8
  101. package/src/clients/helpers/trade.simulation.types.ts +0 -125
@@ -0,0 +1,74 @@
1
+ import {
2
+ MarginAccountEntity,
3
+ MarginAccountTransactionHistoryEntity,
4
+ MarketEntity,
5
+ PositionEntity,
6
+ PositionHistoryEntity,
7
+ } from '@reyaxyz/common';
8
+
9
+ export type GetMarginAccountsParams = {
10
+ address: string;
11
+ limit?: number;
12
+ };
13
+
14
+ export type GetMarginAccountParams = {
15
+ address: string;
16
+ marginAccountId: MarginAccountEntity['id'];
17
+ };
18
+
19
+ export type GetPositionsForMarginAccountParams = {
20
+ address: string;
21
+ marginAccountId: MarginAccountEntity['id'];
22
+ limit?: number;
23
+ };
24
+
25
+ export type GetMarginAccountsResult = MarginAccountEntity[];
26
+
27
+ export type GetMarginAccountResult = MarginAccountEntity;
28
+
29
+ // ---- Transaction History
30
+ export type GetMarginAccountTransactionHistoryParams = {
31
+ marginAccountId: MarginAccountEntity['id'];
32
+ limit?: number;
33
+ };
34
+
35
+ export type GetMarginAccountTransactionHistoryResult =
36
+ MarginAccountTransactionHistoryEntity[];
37
+ // -- Max Order Size --
38
+
39
+ export type GetMaxOrderSizeAvailableParams = {
40
+ marketId: MarketEntity['id'];
41
+ marginAccountId: MarginAccountEntity['id'];
42
+ direction: 'long' | 'short';
43
+ };
44
+
45
+ export type GetMaxOrderSizeAvailableResult = number;
46
+
47
+ // --- Max Withdraw Balance for Margin Account ---
48
+ export type GetMaxWithdrawBalanceForAccountParams = {
49
+ marginAccountId: MarginAccountEntity['id'];
50
+ tokenAddress: string;
51
+ };
52
+
53
+ export type GetMaxWithdrawBalanceForAccountResult = number;
54
+
55
+ export type GetPositionsForMarginAccountResult = {
56
+ positions: PositionEntity[];
57
+ totalUnrealizedPNL: number;
58
+ };
59
+
60
+ // --- Position History ---
61
+
62
+ export type GetPositionsHistoryForMarginAccountParams = {
63
+ address: string;
64
+ marginAccountId: MarginAccountEntity['id'];
65
+ limit?: number;
66
+ };
67
+ export type GetPositionsHistoryForMarginAccountResult = PositionHistoryEntity[];
68
+
69
+ // ---- Transaction Simulation ----
70
+
71
+ export type GetTransactionSimulationInitialDataParams = {
72
+ marketId: MarketEntity['id'];
73
+ marginAccountId: MarginAccountEntity['id'];
74
+ };
@@ -9,11 +9,13 @@ import {
9
9
  GetLpPoolWithdrawBalanceParams,
10
10
  GetLpPoolWithdrawBalanceResult,
11
11
  GetLpPoolBalanceChartDataParams,
12
- GetLpPoolBalanceChartDataResult,
13
12
  GetLpPoolPerformanceChartDataParams,
13
+ } from './types';
14
+ import {
14
15
  GetLpPoolPerformanceChartDataResult,
15
- } from '../types';
16
- import RestClient from './rest';
16
+ GetLpPoolBalanceChartDataResult,
17
+ } from '@reyaxyz/common';
18
+ import RestClient from '../rest';
17
19
 
18
20
  export default class LpClient extends RestClient {
19
21
  async getLpPools(): Promise<GetLpPoolsResult> {
@@ -0,0 +1,62 @@
1
+ import {
2
+ LpPoolEntity,
3
+ LpPositionEntity,
4
+ LpTransactionHistoryEntity,
5
+ BalanceGranularity,
6
+ } from '@reyaxyz/common';
7
+
8
+ export type GetLpPoolsResult = LpPoolEntity[];
9
+
10
+ export type GetLpPoolResult = LpPoolEntity;
11
+
12
+ export type GetLpPoolParams = {
13
+ id: LpPoolEntity['id'];
14
+ };
15
+
16
+ export type GetLpPoolTransactionHistoryResult = LpTransactionHistoryEntity[];
17
+
18
+ export type GetLpPositionsParams = {
19
+ id: LpPoolEntity['id'];
20
+ address: string; // wallet address
21
+ };
22
+
23
+ export type GetLpPositionsResult = LpPositionEntity[];
24
+
25
+ export type GetLpPoolWithdrawBalanceParams = {
26
+ id: LpPoolEntity['id'];
27
+ address: string; // wallet address
28
+ };
29
+
30
+ export type GetLpPoolWithdrawBalanceResult = number;
31
+
32
+ export type GetLpPoolTransactionHistoryParams = {
33
+ id: LpPoolEntity['id'];
34
+ address: string; // wallet address
35
+ limit?: number;
36
+ };
37
+
38
+ export type GetLpPoolBalanceChartDataParams = {
39
+ poolId: LpPoolEntity['id'];
40
+ filters: {
41
+ timeframeMs: number;
42
+ granularity: BalanceGranularity;
43
+ };
44
+ };
45
+
46
+ export enum PerformanceGranularity {
47
+ ONE_MINUTE = 60 * 1000,
48
+ ONE_HOUR = 60 * 60 * 1000,
49
+ ONE_DAY = 24 * 60 * 60 * 1000,
50
+ ONE_WEEK = 7 * 24 * 60 * 60 * 1000,
51
+ ONE_MONTH = 30 * 24 * 60 * 60 * 1000,
52
+ ONE_YEAR = 365 * 24 * 60 * 60 * 1000,
53
+ }
54
+
55
+ export type GetLpPoolPerformanceChartDataParams = {
56
+ poolId: LpPoolEntity['id'];
57
+ address: string; // wallet address
58
+ filters: {
59
+ timeframeMs: number;
60
+ granularity: PerformanceGranularity;
61
+ };
62
+ };
@@ -6,8 +6,8 @@ import {
6
6
  GetMarketTradingHistoryParams,
7
7
  GetTradingHistoryResult,
8
8
  MarketCandlesResponse,
9
- } from '../types';
10
- import RestClient from './rest';
9
+ } from './types';
10
+ import RestClient from '../rest';
11
11
 
12
12
  export default class MarketsClient extends RestClient {
13
13
  /**
@@ -0,0 +1,33 @@
1
+ import {
2
+ CandlesResolution,
3
+ MarketEntity,
4
+ TradingHistoryEntity,
5
+ Candle,
6
+ } from '@reyaxyz/common';
7
+
8
+ export type GetMarketsResult = MarketEntity[];
9
+
10
+ export type GetMarketResult = MarketEntity;
11
+
12
+ export type GetMarketParams = {
13
+ id: MarketEntity['id'];
14
+ };
15
+
16
+ export type GetCandlesParams = {
17
+ marketId: MarketEntity['id'];
18
+ resolution: CandlesResolution;
19
+ fromISO?: string | null;
20
+ toISO?: string | null;
21
+ limit?: number | null;
22
+ };
23
+
24
+ export type GetMarketTradingHistoryParams = {
25
+ marketId: number;
26
+ limit?: number;
27
+ fromTimestampMillisecondsUTC?: number;
28
+ };
29
+ export type GetTradingHistoryResult = TradingHistoryEntity[];
30
+
31
+ export interface MarketCandlesResponse {
32
+ candles: Candle[];
33
+ }
@@ -1,6 +1,11 @@
1
- import { API_TIMEOUT } from '../helpers/constants';
2
- import { generateQueryPath } from '../helpers/query-helper';
3
- import { RequestMethod, Response, request, ResponseData } from '../lib/axios';
1
+ import { API_TIMEOUT } from '../../helpers/constants';
2
+ import { generateQueryPath } from '../../helpers/query-helper';
3
+ import {
4
+ RequestMethod,
5
+ Response,
6
+ request,
7
+ ResponseData,
8
+ } from '../../lib/axios';
4
9
  export default class RestClient {
5
10
  readonly host: string;
6
11
  readonly apiTimeout: number;
@@ -1,5 +1,5 @@
1
- import { GetAllowedTokensParams, GetAllowedTokenResult } from '../types';
2
- import RestClient from './rest';
1
+ import { GetAllowedTokensParams, GetAllowedTokenResult } from './types';
2
+ import RestClient from '../rest';
3
3
 
4
4
  export default class TokensClient extends RestClient {
5
5
  async getAllowedTokens(
@@ -0,0 +1,9 @@
1
+ import { SupportedChainId, TokenEntity } from '@reyaxyz/common';
2
+
3
+ export type GetAllowedTokensParams = {
4
+ chainId: SupportedChainId;
5
+ };
6
+
7
+ export type GetAllowedTokenResult = {
8
+ tokens: TokenEntity[];
9
+ };
@@ -2,10 +2,9 @@ import {
2
2
  SimulateTradeEntity,
3
3
  TradeSimulationLoadDataParams,
4
4
  TradeSimulationSimulateParams,
5
- } from '../types';
6
- import AccountClient from './account';
7
- import { TradeSimulationState } from '../helpers/trade.simulation.types';
8
- import { ExposureCommand } from '../helpers/exposure.calculator';
5
+ } from './types';
6
+ import AccountClient from '../account';
7
+ import { ExposureCommand, TradeSimulationState } from '@reyaxyz/common';
9
8
  import BigNumber from 'bignumber.js';
10
9
 
11
10
  export default class TradeSimulationClient {
@@ -0,0 +1,21 @@
1
+ import { MarginAccountEntity, MarketEntity } from '@reyaxyz/common';
2
+
3
+ export type TradeSimulationLoadDataParams = {
4
+ marketId: MarketEntity['id'];
5
+ marginAccountId: MarginAccountEntity['id'];
6
+ };
7
+
8
+ export type TradeSimulationSimulateParams = {
9
+ amount: number; // position size, + for long | - for short
10
+ };
11
+
12
+ export type SimulateTradeEntity = {
13
+ liquidationPrice: number;
14
+ fees: number;
15
+ estimatedPrice: number;
16
+ estimatedSlippage: number;
17
+ imr: number;
18
+ impliedLeverage: number;
19
+ marginRatio: MarginAccountEntity['marginRatioPercentage'];
20
+ marginRatioHealth: MarginAccountEntity['marginRatioHealth'];
21
+ };
@@ -1,400 +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;
389
-
390
- // -- Tokens --
391
- export type GetAllowedTokensParams = {
392
- chainId: number;
393
- };
394
-
395
- export type GetAllowedTokenResult = {
396
- tokens: {
397
- id: string;
398
- address: string;
399
- }[];
400
- };
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';