@reyaxyz/api-sdk 0.10.1 → 0.11.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 +3 -3
- package/dist/clients/modules/account.js.map +1 -1
- package/dist/clients/modules/markets.js +18 -14
- package/dist/clients/modules/markets.js.map +1 -1
- package/dist/clients/types.js.map +1 -1
- package/dist/types/clients/modules/markets.d.ts +5 -9
- package/dist/types/clients/modules/markets.d.ts.map +1 -1
- package/dist/types/clients/types.d.ts +13 -5
- package/dist/types/clients/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/clients/modules/account.ts +3 -3
- package/src/clients/modules/markets.ts +17 -21
- package/src/clients/types.ts +16 -5
|
@@ -96,7 +96,7 @@ var AccountClient = /** @class */ (function (_super) {
|
|
|
96
96
|
return __awaiter(this, void 0, void 0, function () {
|
|
97
97
|
var uri;
|
|
98
98
|
return __generator(this, function (_a) {
|
|
99
|
-
uri = "/api/accounts/".concat(params.address, "/marginAccount/").concat(params.
|
|
99
|
+
uri = "/api/accounts/".concat(params.address, "/marginAccount/").concat(params.marginAccountId);
|
|
100
100
|
return [2 /*return*/, this.get(uri)];
|
|
101
101
|
});
|
|
102
102
|
});
|
|
@@ -105,7 +105,7 @@ var AccountClient = /** @class */ (function (_super) {
|
|
|
105
105
|
return __awaiter(this, void 0, void 0, function () {
|
|
106
106
|
var uri;
|
|
107
107
|
return __generator(this, function (_a) {
|
|
108
|
-
uri = "/api/accounts/".concat(params.address, "/marginAccount/").concat(params.
|
|
108
|
+
uri = "/api/accounts/".concat(params.address, "/marginAccount/").concat(params.marginAccountId, "/positions");
|
|
109
109
|
return [2 /*return*/, this.get(uri, { limit: params.limit })];
|
|
110
110
|
});
|
|
111
111
|
});
|
|
@@ -114,7 +114,7 @@ var AccountClient = /** @class */ (function (_super) {
|
|
|
114
114
|
return __awaiter(this, void 0, void 0, function () {
|
|
115
115
|
var uri;
|
|
116
116
|
return __generator(this, function (_a) {
|
|
117
|
-
uri = "/api/accounts/".concat(params.address, "/marginAccount/").concat(params.
|
|
117
|
+
uri = "/api/accounts/".concat(params.address, "/marginAccount/").concat(params.marginAccountId, "/positions/history");
|
|
118
118
|
return [2 /*return*/, this.get(uri, { limit: params.limit })];
|
|
119
119
|
});
|
|
120
120
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"/","sources":["clients/modules/account.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,gDAAgC;AAEhC;IAA2C,iCAAU;IAArD;;IAqDA,CAAC;IApDC;;;;;;;;;;;SAWK;IAEC,yCAAiB,GAAvB,UACE,MAA+B;;;;gBAEzB,GAAG,GAAG,wBAAiB,MAAM,CAAC,OAAO,CAAE,CAAC;gBAC9C,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,EAAC;;;KAC/C;IAED;;;;;;;;;;OAUG;IAEG,wCAAgB,GAAtB,UACE,MAA8B;;;;gBAExB,GAAG,GAAG,wBAAiB,MAAM,CAAC,OAAO,4BAAkB,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"/","sources":["clients/modules/account.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,gDAAgC;AAEhC;IAA2C,iCAAU;IAArD;;IAqDA,CAAC;IApDC;;;;;;;;;;;SAWK;IAEC,yCAAiB,GAAvB,UACE,MAA+B;;;;gBAEzB,GAAG,GAAG,wBAAiB,MAAM,CAAC,OAAO,CAAE,CAAC;gBAC9C,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,EAAC;;;KAC/C;IAED;;;;;;;;;;OAUG;IAEG,wCAAgB,GAAtB,UACE,MAA8B;;;;gBAExB,GAAG,GAAG,wBAAiB,MAAM,CAAC,OAAO,4BAAkB,MAAM,CAAC,eAAe,CAAE,CAAC;gBACtF,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IAEK,oDAA4B,GAAlC,UACE,MAA0C;;;;gBAEpC,GAAG,GAAG,wBAAiB,MAAM,CAAC,OAAO,4BAAkB,MAAM,CAAC,eAAe,eAAY,CAAC;gBAChG,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,EAAC;;;KAC/C;IAEK,2DAAmC,GAAzC,UACE,MAAiD;;;;gBAE3C,GAAG,GAAG,wBAAiB,MAAM,CAAC,OAAO,4BAAkB,MAAM,CAAC,eAAe,uBAAoB,CAAC;gBACxG,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,EAAC;;;KAC/C;IACH,oBAAC;AAAD,CAAC,AArDD,CAA2C,cAAU,GAqDpD","sourcesContent":["import {\n GetMarginAccountParams,\n GetMarginAccountResult,\n GetMarginAccountsParams,\n GetMarginAccountsResult,\n GetPositionsForMarginAccountParams,\n GetPositionsForMarginAccountResult,\n GetPositionsHistoryForMarginAccountParams,\n GetPositionsHistoryForMarginAccountResult,\n} from '../types';\nimport RestClient from './rest';\n\nexport default class AccountClient extends RestClient {\n /**\n * Asynchronously retrieves a list of margin accounts associated with a specific address.\n *\n * This method makes a request to the API endpoint to fetch collateral account data. The data is filtered\n * based on the provided Ethereum address. An optional limit can be specified to control the number of\n * collateral accounts returned in the response.\n *\n * @param {GetMarginAccountsParams} params\n * @returns {Promise<GetMarginAccountsResult>} A promise that resolves to the response containing the margin\n * account data.\n * @memberof account\n * */\n\n async getMarginAccounts(\n params: GetMarginAccountsParams,\n ): Promise<GetMarginAccountsResult> {\n const uri = `/api/accounts/${params.address}`;\n return this.get(uri, { limit: params.limit });\n }\n\n /**\n * Asynchronously retrieves details of a specific collateral account for a given Ethereum address.\n *\n * This method sends a request to the API to obtain detailed information about a specific collateral account\n * associated with the provided Ethereum address. The account is identified using the collateral account number.\n *\n * @param {GetMarginAccountParams} params\n * @returns {Promise<GetMarginAccountResult>} A promise that resolves to the response containing the detailed\n * information of the specified margin account.\n * @memberof account\n */\n\n async getMarginAccount(\n params: GetMarginAccountParams,\n ): Promise<GetMarginAccountResult> {\n const uri = `/api/accounts/${params.address}/marginAccount/${params.marginAccountId}`;\n return this.get(uri);\n }\n\n async getPositionsForMarginAccount(\n params: GetPositionsForMarginAccountParams,\n ): Promise<GetPositionsForMarginAccountResult> {\n const uri = `/api/accounts/${params.address}/marginAccount/${params.marginAccountId}/positions`;\n return this.get(uri, { limit: params.limit });\n }\n\n async getPositionsHistoryForMarginAccount(\n params: GetPositionsHistoryForMarginAccountParams,\n ): Promise<GetPositionsHistoryForMarginAccountResult> {\n const uri = `/api/accounts/${params.address}/marginAccount/${params.marginAccountId}/positions/history`;\n return this.get(uri, { limit: params.limit });\n }\n}\n"]}
|
|
@@ -66,7 +66,6 @@ var MarketsClient = /** @class */ (function (_super) {
|
|
|
66
66
|
* This method makes a request to the API to fetch data for markets. If a specific market is provided as a parameter,
|
|
67
67
|
* it fetches data for that particular market; otherwise, it fetches data for all available markets.
|
|
68
68
|
*
|
|
69
|
-
* @param {GetMarketsParams} [params] - The specific market ticker identifier for which data is requested. This parameter is optional.
|
|
70
69
|
* @returns {Promise<GetMarketsResult>} A promise that resolves to the response containing market data.
|
|
71
70
|
* @memberof MarketsClient
|
|
72
71
|
*
|
|
@@ -78,12 +77,21 @@ var MarketsClient = /** @class */ (function (_super) {
|
|
|
78
77
|
* // Fetch data for a specific market
|
|
79
78
|
* const specificMarketData = await market.getMarkets('ETH-USDC');
|
|
80
79
|
*/
|
|
81
|
-
MarketsClient.prototype.getMarkets = function (
|
|
80
|
+
MarketsClient.prototype.getMarkets = function () {
|
|
82
81
|
return __awaiter(this, void 0, void 0, function () {
|
|
83
82
|
var uri;
|
|
84
83
|
return __generator(this, function (_a) {
|
|
85
84
|
uri = '/api/markets';
|
|
86
|
-
return [2 /*return*/, this.get(uri
|
|
85
|
+
return [2 /*return*/, this.get(uri)];
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
MarketsClient.prototype.getMarket = function (params) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
91
|
+
var uri;
|
|
92
|
+
return __generator(this, function (_a) {
|
|
93
|
+
uri = "/api/markets/".concat(params.id);
|
|
94
|
+
return [2 /*return*/, this.get(uri)];
|
|
87
95
|
});
|
|
88
96
|
});
|
|
89
97
|
};
|
|
@@ -93,27 +101,23 @@ var MarketsClient = /** @class */ (function (_super) {
|
|
|
93
101
|
* This method fetches historical candlestick (or OHLC - Open, High, Low, Close) data for a given market.
|
|
94
102
|
* The data can be filtered by time range (fromISO and toISO) and resolution.
|
|
95
103
|
*
|
|
96
|
-
* @param {
|
|
97
|
-
* @param {CandlesResolution} resolution - The granularity of the candlestick data (e.g., '1MIN', '5MIN', '1HR').
|
|
98
|
-
* @param {string|null} [fromISO] - The start time for the range of candlestick data in ISO 8601 format. Optional.
|
|
99
|
-
* @param {string|null} [toISO] - The end time for the range of candlestick data in ISO 8601 format. Optional.
|
|
100
|
-
* @param {number|null} [limit] - The maximum number of candlestick data points to retrieve. Optional.
|
|
104
|
+
* @param {GetCandlesParams} params
|
|
101
105
|
* @returns {Promise<MarketCandlesResponse>} A promise that resolves to the market candlestick data.
|
|
102
106
|
* @memberof MarketsClient
|
|
103
107
|
*
|
|
104
108
|
* @example
|
|
105
109
|
* const marketCandles = await market.getMarketCandles('BTC-USD', '1HR', '2023-01-01T00:00:00Z', '2023-01-02T00:00:00Z');
|
|
106
110
|
*/
|
|
107
|
-
MarketsClient.prototype.getMarketCandles = function (
|
|
111
|
+
MarketsClient.prototype.getMarketCandles = function (params) {
|
|
108
112
|
return __awaiter(this, void 0, void 0, function () {
|
|
109
113
|
var uri;
|
|
110
114
|
return __generator(this, function (_a) {
|
|
111
|
-
uri = "/api/markets/candles/".concat(marketId);
|
|
115
|
+
uri = "/api/markets/candles/".concat(params.marketId);
|
|
112
116
|
return [2 /*return*/, this.get(uri, {
|
|
113
|
-
resolution: resolution,
|
|
114
|
-
fromISO: fromISO,
|
|
115
|
-
toISO: toISO,
|
|
116
|
-
limit: limit,
|
|
117
|
+
resolution: params.resolution,
|
|
118
|
+
fromISO: params.fromISO,
|
|
119
|
+
toISO: params.toISO,
|
|
120
|
+
limit: params.limit,
|
|
117
121
|
})];
|
|
118
122
|
});
|
|
119
123
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markets.js","sourceRoot":"/","sources":["clients/modules/markets.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,gDAAgC;AAEhC;IAA2C,iCAAU;IAArD;;
|
|
1
|
+
{"version":3,"file":"markets.js","sourceRoot":"/","sources":["clients/modules/markets.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,gDAAgC;AAEhC;IAA2C,iCAAU;IAArD;;IA+DA,CAAC;IA9DC;;;;;;;;;;;;;;;;OAgBG;IAEG,kCAAU,GAAhB;;;;gBACQ,GAAG,GAAG,cAAc,CAAC;gBAC3B,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IAEK,iCAAS,GAAf,UAAgB,MAAuB;;;;gBAC/B,GAAG,GAAG,uBAAgB,MAAM,CAAC,EAAE,CAAE,CAAC;gBACxC,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IAED;;;;;;;;;;;;OAYG;IAEG,wCAAgB,GAAtB,UACE,MAAwB;;;;gBAElB,GAAG,GAAG,+BAAwB,MAAM,CAAC,QAAQ,CAAE,CAAC;gBACtD,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,UAAU,EAAE,MAAM,CAAC,UAAU;wBAC7B,OAAO,EAAE,MAAM,CAAC,OAAO;wBACvB,KAAK,EAAE,MAAM,CAAC,KAAK;wBACnB,KAAK,EAAE,MAAM,CAAC,KAAK;qBACpB,CAAC,EAAC;;;KACJ;IAEK,+CAAuB,GAA7B,UACE,MAAqC;;;;gBAE/B,GAAG,GAAG,sBAAe,MAAM,CAAC,QAAQ,CAAE,CAAC;gBAC7C,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,KAAK,EAAE,MAAM,CAAC,KAAK;qBACpB,CAAC,EAAC;;;KACJ;IACH,oBAAC;AAAD,CAAC,AA/DD,CAA2C,cAAU,GA+DpD","sourcesContent":["import {\n GetCandlesParams,\n GetMarketParams,\n GetMarketResult,\n GetMarketsResult,\n GetMarketTradingHistoryParams,\n GetTradingHistoryResult,\n MarketCandlesResponse,\n} from '../types';\nimport RestClient from './rest';\n\nexport default class MarketsClient extends RestClient {\n /**\n * Asynchronously retrieves market data from the API.\n *\n * This method makes a request to the API to fetch data for markets. If a specific market is provided as a parameter,\n * it fetches data for that particular market; otherwise, it fetches data for all available markets.\n *\n * @returns {Promise<GetMarketsResult>} A promise that resolves to the response containing market data.\n * @memberof MarketsClient\n *\n * @example\n * // Fetch data for all markets\n * const allMarketsData = await market.getMarkets();\n *\n * @example\n * // Fetch data for a specific market\n * const specificMarketData = await market.getMarkets('ETH-USDC');\n */\n\n async getMarkets(): Promise<GetMarketsResult> {\n const uri = '/api/markets';\n return this.get(uri);\n }\n\n async getMarket(params: GetMarketParams): Promise<GetMarketResult> {\n const uri = `/api/markets/${params.id}`;\n return this.get(uri);\n }\n\n /**\n * Retrieves candlestick data for a specified market.\n *\n * This method fetches historical candlestick (or OHLC - Open, High, Low, Close) data for a given market.\n * The data can be filtered by time range (fromISO and toISO) and resolution.\n *\n * @param {GetCandlesParams} params\n * @returns {Promise<MarketCandlesResponse>} A promise that resolves to the market candlestick data.\n * @memberof MarketsClient\n *\n * @example\n * const marketCandles = await market.getMarketCandles('BTC-USD', '1HR', '2023-01-01T00:00:00Z', '2023-01-02T00:00:00Z');\n */\n\n async getMarketCandles(\n params: GetCandlesParams,\n ): Promise<MarketCandlesResponse> {\n const uri = `/api/markets/candles/${params.marketId}`;\n return this.get(uri, {\n resolution: params.resolution,\n fromISO: params.fromISO,\n toISO: params.toISO,\n limit: params.limit,\n });\n }\n\n async getMarketTradingHistory(\n params: GetMarketTradingHistoryParams,\n ): Promise<GetTradingHistoryResult> {\n const uri = `/api/trades/${params.marketId}`;\n return this.get(uri, {\n limit: params.limit,\n });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":";;;AAAA,IAAY,iBAQX;AARD,WAAY,iBAAiB;IAC3B,wCAAmB,CAAA;IACnB,2CAAsB,CAAA;IACtB,+CAA0B,CAAA;IAC1B,8CAAyB,CAAA;IACzB,uCAAkB,CAAA;IAClB,0CAAqB,CAAA;IACrB,qCAAgB,CAAA;AAClB,CAAC,EARW,iBAAiB,iCAAjB,iBAAiB,QAQ5B","sourcesContent":["export enum CandlesResolution {\n ONE_MINUTE = '1MIN',\n FIVE_MINUTES = '5MINS',\n FIFTEEN_MINUTES = '15MINS',\n THIRTY_MINUTES = '30MINS',\n ONE_HOUR = '1HOUR',\n FOUR_HOURS = '4HOURS',\n ONE_DAY = '1DAY',\n}\n\n// -- Candles --\nexport interface Candle {\n startedAt: string;\n ticker: string;\n resolution: CandlesResolution;\n low: string;\n high: string;\n open: string;\n close: string;\n baseTokenVolume: string;\n usdVolume: string;\n trades: number;\n startingOpenInterest: string;\n id: string;\n}\n\nexport interface MarketCandlesResponse {\n candles: Candle[];\n}\n\n// -- Markets --\n\nexport type MarketEntity = {\n id: number;\n ticker: string;\n underlyingAsset: string;\n quoteToken: string;\n markPrice: number;\n isActive: boolean;\n maxLeverage: number;\n volume24H: number;\n priceChange24H: number;\n priceChange24HPercentage: number;\n openInterest: number;\n fundingRate: number;\n description: string;\n tickSizeDecimals: number;\n};\n\nexport type GetMarketsResult = MarketEntity[];\n\nexport type
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":";;;AAAA,IAAY,iBAQX;AARD,WAAY,iBAAiB;IAC3B,wCAAmB,CAAA;IACnB,2CAAsB,CAAA;IACtB,+CAA0B,CAAA;IAC1B,8CAAyB,CAAA;IACzB,uCAAkB,CAAA;IAClB,0CAAqB,CAAA;IACrB,qCAAgB,CAAA;AAClB,CAAC,EARW,iBAAiB,iCAAjB,iBAAiB,QAQ5B","sourcesContent":["export enum CandlesResolution {\n ONE_MINUTE = '1MIN',\n FIVE_MINUTES = '5MINS',\n FIFTEEN_MINUTES = '15MINS',\n THIRTY_MINUTES = '30MINS',\n ONE_HOUR = '1HOUR',\n FOUR_HOURS = '4HOURS',\n ONE_DAY = '1DAY',\n}\n\n// -- Candles --\nexport interface Candle {\n startedAt: string;\n ticker: string;\n resolution: CandlesResolution;\n low: string;\n high: string;\n open: string;\n close: string;\n baseTokenVolume: string;\n usdVolume: string;\n trades: number;\n startingOpenInterest: string;\n id: string;\n}\n\nexport interface MarketCandlesResponse {\n candles: Candle[];\n}\n\n// -- Markets --\n\nexport type MarketEntity = {\n id: number;\n ticker: string;\n underlyingAsset: string;\n quoteToken: string;\n markPrice: number;\n isActive: boolean;\n maxLeverage: number;\n volume24H: number;\n priceChange24H: number;\n priceChange24HPercentage: number;\n openInterest: number;\n fundingRate: number;\n description: string;\n tickSizeDecimals: number;\n};\n\nexport type GetMarketsResult = MarketEntity[];\n\nexport type GetMarketResult = MarketEntity;\n\nexport type GetMarketParams = {\n id: MarketEntity['id'];\n};\n\nexport type GetCandlesParams = {\n marketId: MarketEntity['id'];\n resolution: CandlesResolution;\n fromISO?: string | null;\n toISO?: string | null;\n limit?: number | null;\n};\n\n// -- Account --\n\nexport type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';\nexport type Side = 'LONG' | 'SHORT';\n\nexport type GetMarginAccountsParams = {\n address: string;\n limit?: number;\n};\n\nexport type GetMarginAccountParams = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n};\n\nexport type GetPositionsForMarginAccountParams = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n limit?: number;\n};\n\nexport type MarginAccountEntity = {\n id: number;\n name: string;\n marginRatioHealth: 'danger' | 'healthy' | 'warning';\n marginRatioPercentage: number;\n totalBalance: number;\n totalBalanceUnderlyingAsset: string;\n collaterals: {\n token: string;\n percentage: number;\n balance: number;\n balanceRUSD: number;\n }[];\n};\n\nexport type GetMarginAccountsResult = MarginAccountEntity[];\nexport type GetMarginAccountResult = MarginAccountEntity;\n\nexport type PositionEntity = {\n id: number;\n side: Side;\n size: number;\n price: number;\n markPrice: number;\n orderStatus: Status;\n realisedPnl?: number | null;\n unrealisedPnl?: number | null;\n liquidationPrice: number;\n fundingRate: number;\n market: MarketEntity;\n date: Date;\n};\n\nexport type GetPositionsForMarginAccountResult = {\n positions: PositionEntity[];\n totalUnrealizedPNL: number;\n};\n\n// --- Trading History ----\n\nexport type GetMarketTradingHistoryParams = {\n marketId: number;\n limit?: number;\n};\n\nexport type TradingHistoryEntity = {\n id: number;\n price: number;\n priceUnderlyingToken: string;\n size: number;\n sizeUnderlyingToken: string;\n timestampMillisecondsUTC: number;\n};\n\nexport type GetTradingHistoryResult = TradingHistoryEntity[];\n\n// --- Position History ---\n\nexport type GetPositionsHistoryForMarginAccountParams = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n limit?: number;\n};\n\nexport type OrderType = 'market';\n\nexport type PositionHistoryType =\n | 'long-trade'\n | 'short-trade'\n | 'long-liquidation'\n | 'short-liquidation';\n\nexport type PositionHistoryEntity = {\n id: number;\n action: PositionHistoryType;\n orderType: OrderType;\n size: number;\n executionPrice: number;\n realisedPnl?: number | null;\n fees: number;\n timestamp: number;\n market: MarketEntity;\n};\n\nexport type GetPositionsHistoryForMarginAccountResult = PositionHistoryEntity[];\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GetCandlesParams, GetMarketParams, GetMarketResult, GetMarketsResult, GetMarketTradingHistoryParams, GetTradingHistoryResult, MarketCandlesResponse } from '../types';
|
|
2
2
|
import RestClient from './rest';
|
|
3
3
|
export default class MarketsClient extends RestClient {
|
|
4
4
|
/**
|
|
@@ -7,7 +7,6 @@ export default class MarketsClient extends RestClient {
|
|
|
7
7
|
* This method makes a request to the API to fetch data for markets. If a specific market is provided as a parameter,
|
|
8
8
|
* it fetches data for that particular market; otherwise, it fetches data for all available markets.
|
|
9
9
|
*
|
|
10
|
-
* @param {GetMarketsParams} [params] - The specific market ticker identifier for which data is requested. This parameter is optional.
|
|
11
10
|
* @returns {Promise<GetMarketsResult>} A promise that resolves to the response containing market data.
|
|
12
11
|
* @memberof MarketsClient
|
|
13
12
|
*
|
|
@@ -19,25 +18,22 @@ export default class MarketsClient extends RestClient {
|
|
|
19
18
|
* // Fetch data for a specific market
|
|
20
19
|
* const specificMarketData = await market.getMarkets('ETH-USDC');
|
|
21
20
|
*/
|
|
22
|
-
getMarkets(
|
|
21
|
+
getMarkets(): Promise<GetMarketsResult>;
|
|
22
|
+
getMarket(params: GetMarketParams): Promise<GetMarketResult>;
|
|
23
23
|
/**
|
|
24
24
|
* Retrieves candlestick data for a specified market.
|
|
25
25
|
*
|
|
26
26
|
* This method fetches historical candlestick (or OHLC - Open, High, Low, Close) data for a given market.
|
|
27
27
|
* The data can be filtered by time range (fromISO and toISO) and resolution.
|
|
28
28
|
*
|
|
29
|
-
* @param {
|
|
30
|
-
* @param {CandlesResolution} resolution - The granularity of the candlestick data (e.g., '1MIN', '5MIN', '1HR').
|
|
31
|
-
* @param {string|null} [fromISO] - The start time for the range of candlestick data in ISO 8601 format. Optional.
|
|
32
|
-
* @param {string|null} [toISO] - The end time for the range of candlestick data in ISO 8601 format. Optional.
|
|
33
|
-
* @param {number|null} [limit] - The maximum number of candlestick data points to retrieve. Optional.
|
|
29
|
+
* @param {GetCandlesParams} params
|
|
34
30
|
* @returns {Promise<MarketCandlesResponse>} A promise that resolves to the market candlestick data.
|
|
35
31
|
* @memberof MarketsClient
|
|
36
32
|
*
|
|
37
33
|
* @example
|
|
38
34
|
* const marketCandles = await market.getMarketCandles('BTC-USD', '1HR', '2023-01-01T00:00:00Z', '2023-01-02T00:00:00Z');
|
|
39
35
|
*/
|
|
40
|
-
getMarketCandles(
|
|
36
|
+
getMarketCandles(params: GetCandlesParams): Promise<MarketCandlesResponse>;
|
|
41
37
|
getMarketTradingHistory(params: GetMarketTradingHistoryParams): Promise<GetTradingHistoryResult>;
|
|
42
38
|
}
|
|
43
39
|
//# sourceMappingURL=markets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markets.d.ts","sourceRoot":"/","sources":["clients/modules/markets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"markets.d.ts","sourceRoot":"/","sources":["clients/modules/markets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,6BAA6B,EAC7B,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,UAAU,CAAC;AAClB,OAAO,UAAU,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD;;;;;;;;;;;;;;;;OAgBG;IAEG,UAAU,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAKvC,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAKlE;;;;;;;;;;;;OAYG;IAEG,gBAAgB,CACpB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,qBAAqB,CAAC;IAU3B,uBAAuB,CAC3B,MAAM,EAAE,6BAA6B,GACpC,OAAO,CAAC,uBAAuB,CAAC;CAMpC"}
|
|
@@ -41,8 +41,16 @@ export type MarketEntity = {
|
|
|
41
41
|
tickSizeDecimals: number;
|
|
42
42
|
};
|
|
43
43
|
export type GetMarketsResult = MarketEntity[];
|
|
44
|
-
export type
|
|
45
|
-
|
|
44
|
+
export type GetMarketResult = MarketEntity;
|
|
45
|
+
export type GetMarketParams = {
|
|
46
|
+
id: MarketEntity['id'];
|
|
47
|
+
};
|
|
48
|
+
export type GetCandlesParams = {
|
|
49
|
+
marketId: MarketEntity['id'];
|
|
50
|
+
resolution: CandlesResolution;
|
|
51
|
+
fromISO?: string | null;
|
|
52
|
+
toISO?: string | null;
|
|
53
|
+
limit?: number | null;
|
|
46
54
|
};
|
|
47
55
|
export type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';
|
|
48
56
|
export type Side = 'LONG' | 'SHORT';
|
|
@@ -52,11 +60,11 @@ export type GetMarginAccountsParams = {
|
|
|
52
60
|
};
|
|
53
61
|
export type GetMarginAccountParams = {
|
|
54
62
|
address: string;
|
|
55
|
-
|
|
63
|
+
marginAccountId: MarginAccountEntity['id'];
|
|
56
64
|
};
|
|
57
65
|
export type GetPositionsForMarginAccountParams = {
|
|
58
66
|
address: string;
|
|
59
|
-
|
|
67
|
+
marginAccountId: MarginAccountEntity['id'];
|
|
60
68
|
limit?: number;
|
|
61
69
|
};
|
|
62
70
|
export type MarginAccountEntity = {
|
|
@@ -108,7 +116,7 @@ export type TradingHistoryEntity = {
|
|
|
108
116
|
export type GetTradingHistoryResult = TradingHistoryEntity[];
|
|
109
117
|
export type GetPositionsHistoryForMarginAccountParams = {
|
|
110
118
|
address: string;
|
|
111
|
-
|
|
119
|
+
marginAccountId: MarginAccountEntity['id'];
|
|
112
120
|
limit?: number;
|
|
113
121
|
};
|
|
114
122
|
export type OrderType = 'market';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB;IAC3B,UAAU,SAAS;IACnB,YAAY,UAAU;IACtB,eAAe,WAAW;IAC1B,cAAc,WAAW;IACzB,QAAQ,UAAU;IAClB,UAAU,WAAW;IACrB,OAAO,SAAS;CACjB;AAGD,MAAM,WAAW,MAAM;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,iBAAiB,CAAC;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB,EAAE,MAAM,CAAC;IAC7B,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAID,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,wBAAwB,EAAE,MAAM,CAAC;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,gBAAgB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,oBAAoB,EAAE,CAAC;AAI7D,MAAM,MAAM,yCAAyC,GAAG;IACtD,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC;AAEjC,MAAM,MAAM,mBAAmB,GAC3B,YAAY,GACZ,aAAa,GACb,kBAAkB,GAClB,mBAAmB,CAAC;AAExB,MAAM,MAAM,qBAAqB,GAAG;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,mBAAmB,CAAC;IAC5B,SAAS,EAAE,SAAS,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,yCAAyC,GAAG,qBAAqB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/api-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"axios": "^1.6.2"
|
|
37
37
|
},
|
|
38
38
|
"packageManager": "pnpm@8.10.4",
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "fd3cc11b3fd31d81704adca09e2816b79d3a9721"
|
|
40
40
|
}
|
|
@@ -46,21 +46,21 @@ export default class AccountClient extends RestClient {
|
|
|
46
46
|
async getMarginAccount(
|
|
47
47
|
params: GetMarginAccountParams,
|
|
48
48
|
): Promise<GetMarginAccountResult> {
|
|
49
|
-
const uri = `/api/accounts/${params.address}/marginAccount/${params.
|
|
49
|
+
const uri = `/api/accounts/${params.address}/marginAccount/${params.marginAccountId}`;
|
|
50
50
|
return this.get(uri);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
async getPositionsForMarginAccount(
|
|
54
54
|
params: GetPositionsForMarginAccountParams,
|
|
55
55
|
): Promise<GetPositionsForMarginAccountResult> {
|
|
56
|
-
const uri = `/api/accounts/${params.address}/marginAccount/${params.
|
|
56
|
+
const uri = `/api/accounts/${params.address}/marginAccount/${params.marginAccountId}/positions`;
|
|
57
57
|
return this.get(uri, { limit: params.limit });
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
async getPositionsHistoryForMarginAccount(
|
|
61
61
|
params: GetPositionsHistoryForMarginAccountParams,
|
|
62
62
|
): Promise<GetPositionsHistoryForMarginAccountResult> {
|
|
63
|
-
const uri = `/api/accounts/${params.address}/marginAccount/${params.
|
|
63
|
+
const uri = `/api/accounts/${params.address}/marginAccount/${params.marginAccountId}/positions/history`;
|
|
64
64
|
return this.get(uri, { limit: params.limit });
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
GetCandlesParams,
|
|
3
|
+
GetMarketParams,
|
|
4
|
+
GetMarketResult,
|
|
4
5
|
GetMarketsResult,
|
|
5
6
|
GetMarketTradingHistoryParams,
|
|
6
7
|
GetTradingHistoryResult,
|
|
7
8
|
MarketCandlesResponse,
|
|
8
|
-
MarketEntity,
|
|
9
9
|
} from '../types';
|
|
10
10
|
import RestClient from './rest';
|
|
11
11
|
|
|
@@ -16,7 +16,6 @@ export default class MarketsClient extends RestClient {
|
|
|
16
16
|
* This method makes a request to the API to fetch data for markets. If a specific market is provided as a parameter,
|
|
17
17
|
* it fetches data for that particular market; otherwise, it fetches data for all available markets.
|
|
18
18
|
*
|
|
19
|
-
* @param {GetMarketsParams} [params] - The specific market ticker identifier for which data is requested. This parameter is optional.
|
|
20
19
|
* @returns {Promise<GetMarketsResult>} A promise that resolves to the response containing market data.
|
|
21
20
|
* @memberof MarketsClient
|
|
22
21
|
*
|
|
@@ -29,9 +28,14 @@ export default class MarketsClient extends RestClient {
|
|
|
29
28
|
* const specificMarketData = await market.getMarkets('ETH-USDC');
|
|
30
29
|
*/
|
|
31
30
|
|
|
32
|
-
async getMarkets(
|
|
31
|
+
async getMarkets(): Promise<GetMarketsResult> {
|
|
33
32
|
const uri = '/api/markets';
|
|
34
|
-
return this.get(uri
|
|
33
|
+
return this.get(uri);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async getMarket(params: GetMarketParams): Promise<GetMarketResult> {
|
|
37
|
+
const uri = `/api/markets/${params.id}`;
|
|
38
|
+
return this.get(uri);
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
/**
|
|
@@ -40,11 +44,7 @@ export default class MarketsClient extends RestClient {
|
|
|
40
44
|
* This method fetches historical candlestick (or OHLC - Open, High, Low, Close) data for a given market.
|
|
41
45
|
* The data can be filtered by time range (fromISO and toISO) and resolution.
|
|
42
46
|
*
|
|
43
|
-
* @param {
|
|
44
|
-
* @param {CandlesResolution} resolution - The granularity of the candlestick data (e.g., '1MIN', '5MIN', '1HR').
|
|
45
|
-
* @param {string|null} [fromISO] - The start time for the range of candlestick data in ISO 8601 format. Optional.
|
|
46
|
-
* @param {string|null} [toISO] - The end time for the range of candlestick data in ISO 8601 format. Optional.
|
|
47
|
-
* @param {number|null} [limit] - The maximum number of candlestick data points to retrieve. Optional.
|
|
47
|
+
* @param {GetCandlesParams} params
|
|
48
48
|
* @returns {Promise<MarketCandlesResponse>} A promise that resolves to the market candlestick data.
|
|
49
49
|
* @memberof MarketsClient
|
|
50
50
|
*
|
|
@@ -53,18 +53,14 @@ export default class MarketsClient extends RestClient {
|
|
|
53
53
|
*/
|
|
54
54
|
|
|
55
55
|
async getMarketCandles(
|
|
56
|
-
|
|
57
|
-
resolution: CandlesResolution,
|
|
58
|
-
fromISO?: string | null,
|
|
59
|
-
toISO?: string | null,
|
|
60
|
-
limit?: number | null,
|
|
56
|
+
params: GetCandlesParams,
|
|
61
57
|
): Promise<MarketCandlesResponse> {
|
|
62
|
-
const uri = `/api/markets/candles/${marketId}`;
|
|
58
|
+
const uri = `/api/markets/candles/${params.marketId}`;
|
|
63
59
|
return this.get(uri, {
|
|
64
|
-
resolution,
|
|
65
|
-
fromISO,
|
|
66
|
-
toISO,
|
|
67
|
-
limit,
|
|
60
|
+
resolution: params.resolution,
|
|
61
|
+
fromISO: params.fromISO,
|
|
62
|
+
toISO: params.toISO,
|
|
63
|
+
limit: params.limit,
|
|
68
64
|
});
|
|
69
65
|
}
|
|
70
66
|
|
package/src/clients/types.ts
CHANGED
|
@@ -49,9 +49,20 @@ export type MarketEntity = {
|
|
|
49
49
|
|
|
50
50
|
export type GetMarketsResult = MarketEntity[];
|
|
51
51
|
|
|
52
|
-
export type
|
|
53
|
-
|
|
52
|
+
export type GetMarketResult = MarketEntity;
|
|
53
|
+
|
|
54
|
+
export type GetMarketParams = {
|
|
55
|
+
id: MarketEntity['id'];
|
|
54
56
|
};
|
|
57
|
+
|
|
58
|
+
export type GetCandlesParams = {
|
|
59
|
+
marketId: MarketEntity['id'];
|
|
60
|
+
resolution: CandlesResolution;
|
|
61
|
+
fromISO?: string | null;
|
|
62
|
+
toISO?: string | null;
|
|
63
|
+
limit?: number | null;
|
|
64
|
+
};
|
|
65
|
+
|
|
55
66
|
// -- Account --
|
|
56
67
|
|
|
57
68
|
export type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';
|
|
@@ -64,12 +75,12 @@ export type GetMarginAccountsParams = {
|
|
|
64
75
|
|
|
65
76
|
export type GetMarginAccountParams = {
|
|
66
77
|
address: string;
|
|
67
|
-
|
|
78
|
+
marginAccountId: MarginAccountEntity['id'];
|
|
68
79
|
};
|
|
69
80
|
|
|
70
81
|
export type GetPositionsForMarginAccountParams = {
|
|
71
82
|
address: string;
|
|
72
|
-
|
|
83
|
+
marginAccountId: MarginAccountEntity['id'];
|
|
73
84
|
limit?: number;
|
|
74
85
|
};
|
|
75
86
|
|
|
@@ -133,7 +144,7 @@ export type GetTradingHistoryResult = TradingHistoryEntity[];
|
|
|
133
144
|
|
|
134
145
|
export type GetPositionsHistoryForMarginAccountParams = {
|
|
135
146
|
address: string;
|
|
136
|
-
|
|
147
|
+
marginAccountId: MarginAccountEntity['id'];
|
|
137
148
|
limit?: number;
|
|
138
149
|
};
|
|
139
150
|
|