@reyaxyz/api-sdk 0.27.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.
- package/dist/clients/modules/{account.js → account/index.js} +2 -2
- package/dist/clients/modules/account/index.js.map +1 -0
- package/dist/clients/{helpers/trade.simulation.types.js → modules/account/types.js} +1 -1
- package/dist/clients/modules/account/types.js.map +1 -0
- package/dist/clients/modules/{lp.js → lp/index.js} +2 -2
- package/dist/clients/modules/lp/index.js.map +1 -0
- package/dist/clients/modules/lp/types.js +13 -0
- package/dist/clients/modules/lp/types.js.map +1 -0
- package/dist/clients/modules/{markets.js → markets/index.js} +2 -2
- package/dist/clients/modules/markets/index.js.map +1 -0
- package/dist/clients/modules/markets/types.js +3 -0
- package/dist/clients/modules/markets/types.js.map +1 -0
- package/dist/clients/modules/{rest.js → rest/index.js} +4 -4
- package/dist/clients/modules/rest/index.js.map +1 -0
- package/dist/clients/modules/{tokens.js → tokens/index.js} +2 -2
- package/dist/clients/modules/tokens/index.js.map +1 -0
- package/dist/clients/modules/tokens/types.js +3 -0
- package/dist/clients/modules/tokens/types.js.map +1 -0
- package/dist/clients/modules/{trade.simulation.js → trade.simulation/index.js} +10 -10
- package/dist/clients/modules/trade.simulation/index.js.map +1 -0
- package/dist/clients/modules/trade.simulation/types.js +3 -0
- package/dist/clients/modules/trade.simulation/types.js.map +1 -0
- package/dist/clients/types.js +4 -36
- package/dist/clients/types.js.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/types/clients/modules/{account.d.ts → account/index.d.ts} +4 -4
- package/dist/types/clients/modules/account/index.d.ts.map +1 -0
- package/dist/types/clients/modules/account/types.d.ts +47 -0
- package/dist/types/clients/modules/account/types.d.ts.map +1 -0
- package/dist/types/clients/modules/{lp.d.ts → lp/index.d.ts} +4 -3
- package/dist/types/clients/modules/lp/index.d.ts.map +1 -0
- package/dist/types/clients/modules/lp/types.d.ts +46 -0
- package/dist/types/clients/modules/lp/types.d.ts.map +1 -0
- package/dist/types/clients/modules/{markets.d.ts → markets/index.d.ts} +3 -3
- package/dist/types/clients/modules/markets/index.d.ts.map +1 -0
- package/dist/types/clients/modules/markets/types.d.ts +23 -0
- package/dist/types/clients/modules/markets/types.d.ts.map +1 -0
- package/dist/types/clients/modules/{rest.d.ts → rest/index.d.ts} +2 -2
- package/dist/types/clients/modules/rest/index.d.ts.map +1 -0
- package/dist/types/clients/modules/{tokens.d.ts → tokens/index.d.ts} +3 -3
- package/dist/types/clients/modules/tokens/index.d.ts.map +1 -0
- package/dist/types/clients/modules/tokens/types.d.ts +8 -0
- package/dist/types/clients/modules/tokens/types.d.ts.map +1 -0
- package/dist/types/clients/modules/{trade.simulation.d.ts → trade.simulation/index.d.ts} +3 -3
- package/dist/types/clients/modules/trade.simulation/index.d.ts.map +1 -0
- package/dist/types/clients/modules/trade.simulation/types.d.ts +19 -0
- package/dist/types/clients/modules/trade.simulation/types.d.ts.map +1 -0
- package/dist/types/clients/types.d.ts +1 -309
- package/dist/types/clients/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +6 -7
- package/src/clients/modules/{account.ts → account/index.ts} +3 -3
- package/src/clients/modules/account/types.ts +74 -0
- package/src/clients/modules/{lp.ts → lp/index.ts} +5 -3
- package/src/clients/modules/lp/types.ts +62 -0
- package/src/clients/modules/{markets.ts → markets/index.ts} +2 -2
- package/src/clients/modules/markets/types.ts +33 -0
- package/src/clients/modules/{rest.ts → rest/index.ts} +8 -3
- package/src/clients/modules/{tokens.ts → tokens/index.ts} +2 -2
- package/src/clients/modules/tokens/types.ts +9 -0
- package/src/clients/modules/{trade.simulation.ts → trade.simulation/index.ts} +3 -4
- package/src/clients/modules/trade.simulation/types.ts +21 -0
- package/src/clients/types.ts +16 -400
- package/src/index.ts +0 -2
- package/dist/clients/helpers/exposure.calculator.js +0 -448
- package/dist/clients/helpers/exposure.calculator.js.map +0 -1
- package/dist/clients/helpers/number.js +0 -13
- package/dist/clients/helpers/number.js.map +0 -1
- package/dist/clients/helpers/trade.simulation.types.js.map +0 -1
- package/dist/clients/modules/account.js.map +0 -1
- package/dist/clients/modules/lp.js.map +0 -1
- package/dist/clients/modules/markets.js.map +0 -1
- package/dist/clients/modules/rest.js.map +0 -1
- package/dist/clients/modules/tokens.js.map +0 -1
- package/dist/clients/modules/trade.simulation.js.map +0 -1
- package/dist/types/clients/helpers/exposure.calculator.d.ts +0 -58
- package/dist/types/clients/helpers/exposure.calculator.d.ts.map +0 -1
- package/dist/types/clients/helpers/number.d.ts +0 -3
- package/dist/types/clients/helpers/number.d.ts.map +0 -1
- package/dist/types/clients/helpers/trade.simulation.types.d.ts +0 -113
- package/dist/types/clients/helpers/trade.simulation.types.d.ts.map +0 -1
- package/dist/types/clients/modules/account.d.ts.map +0 -1
- package/dist/types/clients/modules/lp.d.ts.map +0 -1
- package/dist/types/clients/modules/markets.d.ts.map +0 -1
- package/dist/types/clients/modules/rest.d.ts.map +0 -1
- package/dist/types/clients/modules/tokens.d.ts.map +0 -1
- package/dist/types/clients/modules/trade.simulation.d.ts.map +0 -1
- package/src/clients/helpers/exposure.calculator.ts +0 -799
- package/src/clients/helpers/number.ts +0 -8
- package/src/clients/helpers/trade.simulation.types.ts +0 -125
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/tokens/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEhE,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,gBAAgB,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SimulateTradeEntity, TradeSimulationLoadDataParams, TradeSimulationSimulateParams } from '
|
|
2
|
-
import AccountClient from '
|
|
1
|
+
import { SimulateTradeEntity, TradeSimulationLoadDataParams, TradeSimulationSimulateParams } from './types';
|
|
2
|
+
import AccountClient from '../account';
|
|
3
3
|
export default class TradeSimulationClient {
|
|
4
4
|
private marketId;
|
|
5
5
|
private accountId;
|
|
@@ -10,4 +10,4 @@ export default class TradeSimulationClient {
|
|
|
10
10
|
private fetchMarketData;
|
|
11
11
|
simulate(params: TradeSimulationSimulateParams): SimulateTradeEntity;
|
|
12
12
|
}
|
|
13
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/trade.simulation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,6BAA6B,EAC7B,6BAA6B,EAC9B,MAAM,SAAS,CAAC;AACjB,OAAO,aAAa,MAAM,YAAY,CAAC;AAIvC,MAAM,CAAC,OAAO,OAAO,qBAAqB;IACxC,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,UAAU,CAAqC;IACvD,OAAO,CAAC,aAAa,CAAgB;gBACzB,aAAa,EAAE,aAAa;IAMlC,GAAG,CAAC,MAAM,EAAE,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC;YAOjD,eAAe;IAW7B,QAAQ,CAAC,MAAM,EAAE,6BAA6B,GAAG,mBAAmB;CA2GrE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MarginAccountEntity, MarketEntity } from '@reyaxyz/common';
|
|
2
|
+
export type TradeSimulationLoadDataParams = {
|
|
3
|
+
marketId: MarketEntity['id'];
|
|
4
|
+
marginAccountId: MarginAccountEntity['id'];
|
|
5
|
+
};
|
|
6
|
+
export type TradeSimulationSimulateParams = {
|
|
7
|
+
amount: number;
|
|
8
|
+
};
|
|
9
|
+
export type SimulateTradeEntity = {
|
|
10
|
+
liquidationPrice: number;
|
|
11
|
+
fees: number;
|
|
12
|
+
estimatedPrice: number;
|
|
13
|
+
estimatedSlippage: number;
|
|
14
|
+
imr: number;
|
|
15
|
+
impliedLeverage: number;
|
|
16
|
+
marginRatio: MarginAccountEntity['marginRatioPercentage'];
|
|
17
|
+
marginRatioHealth: MarginAccountEntity['marginRatioHealth'];
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/trade.simulation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpE,MAAM,MAAM,6BAA6B,GAAG;IAC1C,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;IAC7B,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,mBAAmB,CAAC,uBAAuB,CAAC,CAAC;IAC1D,iBAAiB,EAAE,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;CAC7D,CAAC"}
|
|
@@ -1,310 +1,2 @@
|
|
|
1
|
-
export
|
|
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
|
-
export interface Candle {
|
|
11
|
-
id: string;
|
|
12
|
-
startedAt: string;
|
|
13
|
-
ticker: string;
|
|
14
|
-
resolution: CandlesResolution;
|
|
15
|
-
low: string;
|
|
16
|
-
high: string;
|
|
17
|
-
open: string;
|
|
18
|
-
close: string;
|
|
19
|
-
baseTokenVolume: string;
|
|
20
|
-
usdVolume: string;
|
|
21
|
-
trades: number;
|
|
22
|
-
startingOpenInterest: string;
|
|
23
|
-
}
|
|
24
|
-
export interface MarketCandlesResponse {
|
|
25
|
-
candles: Candle[];
|
|
26
|
-
}
|
|
27
|
-
export type MarketOrderInfo = {
|
|
28
|
-
counterpartyAccountIds: number[];
|
|
29
|
-
exchangeId: number;
|
|
30
|
-
};
|
|
31
|
-
export type MarketEntity = {
|
|
32
|
-
id: number;
|
|
33
|
-
ticker: string;
|
|
34
|
-
underlyingAsset: string;
|
|
35
|
-
quoteToken: string;
|
|
36
|
-
markPrice: number;
|
|
37
|
-
isActive: boolean;
|
|
38
|
-
maxLeverage: number;
|
|
39
|
-
volume24H: number;
|
|
40
|
-
priceChange24H: number;
|
|
41
|
-
priceChange24HPercentage: number;
|
|
42
|
-
openInterest: number;
|
|
43
|
-
fundingRate: number;
|
|
44
|
-
description: string;
|
|
45
|
-
orderInfo: MarketOrderInfo;
|
|
46
|
-
tickSizeDecimals: number;
|
|
47
|
-
chainId: SupportedChainId;
|
|
48
|
-
};
|
|
49
|
-
export type GetMarketsResult = MarketEntity[];
|
|
50
|
-
export type GetMarketResult = MarketEntity;
|
|
51
|
-
export type GetMarketParams = {
|
|
52
|
-
id: MarketEntity['id'];
|
|
53
|
-
};
|
|
54
|
-
export type GetCandlesParams = {
|
|
55
|
-
marketId: MarketEntity['id'];
|
|
56
|
-
resolution: CandlesResolution;
|
|
57
|
-
fromISO?: string | null;
|
|
58
|
-
toISO?: string | null;
|
|
59
|
-
limit?: number | null;
|
|
60
|
-
};
|
|
61
|
-
export type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';
|
|
62
|
-
export type Side = 'long' | 'short';
|
|
63
|
-
export type GetMarginAccountsParams = {
|
|
64
|
-
address: string;
|
|
65
|
-
limit?: number;
|
|
66
|
-
};
|
|
67
|
-
export type GetMarginAccountParams = {
|
|
68
|
-
address: string;
|
|
69
|
-
marginAccountId: MarginAccountEntity['id'];
|
|
70
|
-
};
|
|
71
|
-
export type GetPositionsForMarginAccountParams = {
|
|
72
|
-
address: string;
|
|
73
|
-
marginAccountId: MarginAccountEntity['id'];
|
|
74
|
-
limit?: number;
|
|
75
|
-
};
|
|
76
|
-
export type MarginAccountEntity = {
|
|
77
|
-
id: number;
|
|
78
|
-
name: string;
|
|
79
|
-
marginRatioHealth: 'danger' | 'healthy' | 'warning';
|
|
80
|
-
marginRatioPercentage: number;
|
|
81
|
-
totalBalance: number;
|
|
82
|
-
totalBalanceUnderlyingAsset: string;
|
|
83
|
-
collaterals: {
|
|
84
|
-
token: string;
|
|
85
|
-
percentage: number;
|
|
86
|
-
balance: number;
|
|
87
|
-
balanceRUSD: number;
|
|
88
|
-
}[];
|
|
89
|
-
};
|
|
90
|
-
export type GetMarginAccountsResult = MarginAccountEntity[];
|
|
91
|
-
export type GetMarginAccountResult = MarginAccountEntity;
|
|
92
|
-
export type PositionEntity = {
|
|
93
|
-
id: number;
|
|
94
|
-
side: Side;
|
|
95
|
-
size: number;
|
|
96
|
-
base: number;
|
|
97
|
-
price: number;
|
|
98
|
-
markPrice: number;
|
|
99
|
-
orderStatus: Status;
|
|
100
|
-
realisedPnl?: number | null;
|
|
101
|
-
unrealisedPnl?: number | null;
|
|
102
|
-
liquidationPrice: number;
|
|
103
|
-
fundingRate: number;
|
|
104
|
-
market: MarketEntity;
|
|
105
|
-
date: Date;
|
|
106
|
-
};
|
|
107
|
-
export type GetPositionsForMarginAccountResult = {
|
|
108
|
-
positions: PositionEntity[];
|
|
109
|
-
totalUnrealizedPNL: number;
|
|
110
|
-
};
|
|
111
|
-
export type GetMarketTradingHistoryParams = {
|
|
112
|
-
marketId: number;
|
|
113
|
-
limit?: number;
|
|
114
|
-
fromTimestampMillisecondsUTC?: number;
|
|
115
|
-
};
|
|
116
|
-
export type TradingHistoryEntity = {
|
|
117
|
-
id: number;
|
|
118
|
-
price: number;
|
|
119
|
-
priceUnderlyingToken: string;
|
|
120
|
-
size: number;
|
|
121
|
-
sizeUnderlyingToken: string;
|
|
122
|
-
timestampMillisecondsUTC: number;
|
|
123
|
-
};
|
|
124
|
-
export type GetTradingHistoryResult = TradingHistoryEntity[];
|
|
125
|
-
export type GetPositionsHistoryForMarginAccountParams = {
|
|
126
|
-
address: string;
|
|
127
|
-
marginAccountId: MarginAccountEntity['id'];
|
|
128
|
-
limit?: number;
|
|
129
|
-
};
|
|
130
|
-
export type OrderType = 'market';
|
|
131
|
-
export type PositionHistoryType = 'long-trade' | 'short-trade' | 'long-liquidation' | 'short-liquidation';
|
|
132
|
-
export type PositionHistoryEntity = {
|
|
133
|
-
id: number;
|
|
134
|
-
action: PositionHistoryType;
|
|
135
|
-
orderType: OrderType;
|
|
136
|
-
size: number;
|
|
137
|
-
executionPrice: number;
|
|
138
|
-
realisedPnl?: number | null;
|
|
139
|
-
fees: number;
|
|
140
|
-
timestamp: number;
|
|
141
|
-
market: MarketEntity;
|
|
142
|
-
};
|
|
143
|
-
export type GetPositionsHistoryForMarginAccountResult = PositionHistoryEntity[];
|
|
144
|
-
export type GetMaxOrderSizeAvailableParams = {
|
|
145
|
-
marketId: MarketEntity['id'];
|
|
146
|
-
marginAccountId: MarginAccountEntity['id'];
|
|
147
|
-
direction: 'long' | 'short';
|
|
148
|
-
};
|
|
149
|
-
export type GetMaxOrderSizeAvailableResult = number;
|
|
150
|
-
export type SimulateTradeEntity = {
|
|
151
|
-
liquidationPrice: number;
|
|
152
|
-
fees: number;
|
|
153
|
-
estimatedPrice: number;
|
|
154
|
-
estimatedSlippage: number;
|
|
155
|
-
imr: number;
|
|
156
|
-
impliedLeverage: number;
|
|
157
|
-
marginRatio: MarginAccountEntity['marginRatioPercentage'];
|
|
158
|
-
marginRatioHealth: MarginAccountEntity['marginRatioHealth'];
|
|
159
|
-
};
|
|
160
|
-
export type TradeSimulationLoadDataParams = {
|
|
161
|
-
marketId: MarketEntity['id'];
|
|
162
|
-
marginAccountId: MarginAccountEntity['id'];
|
|
163
|
-
};
|
|
164
|
-
export type TradeSimulationSimulateParams = {
|
|
165
|
-
amount: number;
|
|
166
|
-
};
|
|
167
|
-
export declare enum SupportedChainId {
|
|
168
|
-
polygonMumbai = 80001,
|
|
169
|
-
reyaCronos = 1729
|
|
170
|
-
}
|
|
171
|
-
export type LpPoolEntity = {
|
|
172
|
-
id: number;
|
|
173
|
-
name: string;
|
|
174
|
-
description: string;
|
|
175
|
-
longDescription: string;
|
|
176
|
-
readMoreLink: string;
|
|
177
|
-
currentAPY: number;
|
|
178
|
-
balanceSupplied?: number | null;
|
|
179
|
-
apyChange24H: number;
|
|
180
|
-
tokenAddress: string;
|
|
181
|
-
token: string;
|
|
182
|
-
allowedChainsForLiquidity: number[];
|
|
183
|
-
chainId: SupportedChainId;
|
|
184
|
-
};
|
|
185
|
-
export type GetLpPoolsResult = LpPoolEntity[];
|
|
186
|
-
export type GetLpPoolResult = LpPoolEntity;
|
|
187
|
-
export type GetLpPoolParams = {
|
|
188
|
-
id: LpPoolEntity['id'];
|
|
189
|
-
};
|
|
190
|
-
export type TransactionHistoryType = 'deposit' | 'withdrawal';
|
|
191
|
-
export type LpTransactionHistoryEntity = {
|
|
192
|
-
id: number;
|
|
193
|
-
type: TransactionHistoryType;
|
|
194
|
-
token: string;
|
|
195
|
-
amount: number;
|
|
196
|
-
transactionHash: string;
|
|
197
|
-
timestamp: number;
|
|
198
|
-
};
|
|
199
|
-
export type GetLpPoolTransactionHistoryParams = {
|
|
200
|
-
id: LpPoolEntity['id'];
|
|
201
|
-
address: string;
|
|
202
|
-
limit?: number;
|
|
203
|
-
};
|
|
204
|
-
export type GetLpPoolTransactionHistoryResult = LpTransactionHistoryEntity[];
|
|
205
|
-
export type GetLpPositionsParams = {
|
|
206
|
-
id: LpPoolEntity['id'];
|
|
207
|
-
address: string;
|
|
208
|
-
};
|
|
209
|
-
export type LpPositionEntity = {
|
|
210
|
-
id: number;
|
|
211
|
-
deposited: number;
|
|
212
|
-
currentBalance: number;
|
|
213
|
-
pnl: number;
|
|
214
|
-
fundingRate: number;
|
|
215
|
-
lpPool: LpPoolEntity;
|
|
216
|
-
};
|
|
217
|
-
export type GetLpPositionsResult = LpPositionEntity[];
|
|
218
|
-
export type GetLpPoolWithdrawBalanceParams = {
|
|
219
|
-
id: LpPoolEntity['id'];
|
|
220
|
-
address: string;
|
|
221
|
-
};
|
|
222
|
-
export type GetLpPoolWithdrawBalanceResult = number;
|
|
223
|
-
export type GetTransactionSimulationInitialDataParams = {
|
|
224
|
-
marketId: MarketEntity['id'];
|
|
225
|
-
marginAccountId: MarginAccountEntity['id'];
|
|
226
|
-
};
|
|
227
|
-
export type GetMarginAccountTransactionHistoryParams = {
|
|
228
|
-
marginAccountId: MarginAccountEntity['id'];
|
|
229
|
-
limit?: number;
|
|
230
|
-
};
|
|
231
|
-
export type MarginAccountTransactionHistoryType = 'deposit' | 'withdrawal' | 'transfer' | 'auto_exchange';
|
|
232
|
-
export type MarginAccountTransactionHistoryEntity = {
|
|
233
|
-
id: number;
|
|
234
|
-
type: MarginAccountTransactionHistoryType;
|
|
235
|
-
token: string;
|
|
236
|
-
amount: number;
|
|
237
|
-
transactionHash: string;
|
|
238
|
-
timestamp: number;
|
|
239
|
-
};
|
|
240
|
-
export type GetMarginAccountTransactionHistoryResult = MarginAccountTransactionHistoryEntity[];
|
|
241
|
-
export declare enum BalanceGranularity {
|
|
242
|
-
ONE_MINUTE = 60000,
|
|
243
|
-
ONE_HOUR = 3600000,
|
|
244
|
-
ONE_DAY = 86400000,
|
|
245
|
-
ONE_WEEK = 604800000,
|
|
246
|
-
ONE_MONTH = 2592000000,
|
|
247
|
-
ONE_YEAR = 31536000000
|
|
248
|
-
}
|
|
249
|
-
export type GetLpPoolBalanceChartDataParams = {
|
|
250
|
-
poolId: LpPoolEntity['id'];
|
|
251
|
-
filters: {
|
|
252
|
-
timeframeMs: number;
|
|
253
|
-
granularity: BalanceGranularity;
|
|
254
|
-
};
|
|
255
|
-
};
|
|
256
|
-
export type GetLpPoolBalanceChartDataResult = {
|
|
257
|
-
data: {
|
|
258
|
-
timestampInMs: number;
|
|
259
|
-
value: number;
|
|
260
|
-
}[];
|
|
261
|
-
tvl: number;
|
|
262
|
-
tvlChangePercentage: number;
|
|
263
|
-
apy: number;
|
|
264
|
-
apyChangePercentage: number;
|
|
265
|
-
};
|
|
266
|
-
export type GetLpPoolPerformanceChartDataResult = {
|
|
267
|
-
capitalInvestedData: {
|
|
268
|
-
timestampInMs: number;
|
|
269
|
-
value: number;
|
|
270
|
-
}[];
|
|
271
|
-
balanceData: {
|
|
272
|
-
timestampInMs: number;
|
|
273
|
-
value: number;
|
|
274
|
-
}[];
|
|
275
|
-
balance: number;
|
|
276
|
-
balanceChangePercentage: number;
|
|
277
|
-
capitalInvested: number;
|
|
278
|
-
capitalInvestedChangePercentage: number;
|
|
279
|
-
};
|
|
280
|
-
export declare enum PerformanceGranularity {
|
|
281
|
-
ONE_MINUTE = 60000,
|
|
282
|
-
ONE_HOUR = 3600000,
|
|
283
|
-
ONE_DAY = 86400000,
|
|
284
|
-
ONE_WEEK = 604800000,
|
|
285
|
-
ONE_MONTH = 2592000000,
|
|
286
|
-
ONE_YEAR = 31536000000
|
|
287
|
-
}
|
|
288
|
-
export type GetLpPoolPerformanceChartDataParams = {
|
|
289
|
-
poolId: LpPoolEntity['id'];
|
|
290
|
-
address: string;
|
|
291
|
-
filters: {
|
|
292
|
-
timeframeMs: number;
|
|
293
|
-
granularity: PerformanceGranularity;
|
|
294
|
-
};
|
|
295
|
-
};
|
|
296
|
-
export type GetMaxWithdrawBalanceForAccountParams = {
|
|
297
|
-
marginAccountId: MarginAccountEntity['id'];
|
|
298
|
-
tokenAddress: string;
|
|
299
|
-
};
|
|
300
|
-
export type GetMaxWithdrawBalanceForAccountResult = number;
|
|
301
|
-
export type GetAllowedTokensParams = {
|
|
302
|
-
chainId: number;
|
|
303
|
-
};
|
|
304
|
-
export type GetAllowedTokenResult = {
|
|
305
|
-
tokens: {
|
|
306
|
-
id: string;
|
|
307
|
-
address: string;
|
|
308
|
-
}[];
|
|
309
|
-
};
|
|
1
|
+
export { Candle, CandlesResolution, MarketEntity, LpTransactionHistoryEntity, TradingHistoryEntity, PositionHistoryEntity, PositionEntity, TransactionHistoryType, MarginAccountTransactionHistoryType, MarginAccountTransactionHistoryEntity, MarginAccountEntity, LpPositionEntity, LpPoolEntity, } from '@reyaxyz/common';
|
|
310
2
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EACN,iBAAiB,EACjB,YAAY,EACZ,0BAA0B,EAC1B,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,sBAAsB,EACtB,mCAAmC,EACnC,qCAAqC,EACrC,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,GACb,MAAM,iBAAiB,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,cAAc,iBAAiB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,cAAc,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/api-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -24,20 +24,19 @@
|
|
|
24
24
|
"ts:circular-check": "dpdm --no-output --no-tree --no-warning --exit-code circular:1 -T src/index.ts",
|
|
25
25
|
"ts:check": "pnpm ts:check-types && pnpm ts:circular-check",
|
|
26
26
|
"lint:check": "eslint '{src,demo,tests}/**/*.{ts,tsx}'",
|
|
27
|
-
"prettier:check": "npx prettier --
|
|
27
|
+
"prettier:check": "npx prettier --log-level silent --check './{src,demo,tests}/**/*.{ts,tsx}'",
|
|
28
28
|
"code-quality:check": "npx concurrently 'pnpm ts:check' 'pnpm prettier:check' 'pnpm lint:check --quiet'",
|
|
29
29
|
"lint:fix": "npx eslint --fix '{src,demo,tests}/**/*.{ts,tsx}'",
|
|
30
|
-
"prettier:fix": "npx prettier --
|
|
30
|
+
"prettier:fix": "npx prettier --log-level silent --write './{src,demo,tests}/**/*.{ts,tsx}'",
|
|
31
31
|
"test": "npx jest --silent",
|
|
32
32
|
"test:coverage": "npx jest test --coverage",
|
|
33
33
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@
|
|
36
|
+
"@reyaxyz/common": "0.1.0",
|
|
37
37
|
"axios": "^1.6.2",
|
|
38
|
-
"bignumber.js": "^9.1.2"
|
|
39
|
-
"lodash": "^4.17.21"
|
|
38
|
+
"bignumber.js": "^9.1.2"
|
|
40
39
|
},
|
|
41
40
|
"packageManager": "pnpm@8.10.4",
|
|
42
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "d62614e48bb530169bacfc0e359a5cf63d73a86b"
|
|
43
42
|
}
|
|
@@ -14,9 +14,9 @@ import {
|
|
|
14
14
|
GetPositionsHistoryForMarginAccountParams,
|
|
15
15
|
GetPositionsHistoryForMarginAccountResult,
|
|
16
16
|
GetTransactionSimulationInitialDataParams,
|
|
17
|
-
} from '
|
|
18
|
-
import RestClient from '
|
|
19
|
-
import { TradeSimulationState } from '
|
|
17
|
+
} from './types';
|
|
18
|
+
import RestClient from '../rest';
|
|
19
|
+
import { TradeSimulationState } from '@reyaxyz/common';
|
|
20
20
|
|
|
21
21
|
export default class AccountClient extends RestClient {
|
|
22
22
|
/**
|
|
@@ -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
|
-
|
|
16
|
-
|
|
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 '
|
|
10
|
-
import RestClient from '
|
|
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 '
|
|
2
|
-
import { generateQueryPath } from '
|
|
3
|
-
import {
|
|
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 '
|
|
2
|
-
import RestClient from '
|
|
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(
|