@reyaxyz/api-sdk 0.9.0 → 0.10.1
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 +23 -5
- package/dist/clients/modules/account.js.map +1 -1
- package/dist/clients/modules/markets.js +5 -5
- package/dist/clients/modules/markets.js.map +1 -1
- package/dist/clients/types.js.map +1 -1
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/dist/types/clients/modules/account.d.ts +8 -6
- package/dist/types/clients/modules/account.d.ts.map +1 -1
- package/dist/types/clients/modules/markets.d.ts +4 -4
- package/dist/types/clients/modules/markets.d.ts.map +1 -1
- package/dist/types/clients/types.d.ts +48 -15
- package/dist/types/clients/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/clients/modules/account.ts +27 -8
- package/src/clients/modules/markets.ts +11 -10
- package/src/clients/types.ts +66 -15
- package/src/index.ts +1 -0
|
@@ -61,14 +61,14 @@ var AccountClient = /** @class */ (function (_super) {
|
|
|
61
61
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
* Asynchronously retrieves a list of
|
|
64
|
+
* Asynchronously retrieves a list of margin accounts associated with a specific address.
|
|
65
65
|
*
|
|
66
66
|
* This method makes a request to the API endpoint to fetch collateral account data. The data is filtered
|
|
67
67
|
* based on the provided Ethereum address. An optional limit can be specified to control the number of
|
|
68
68
|
* collateral accounts returned in the response.
|
|
69
69
|
*
|
|
70
70
|
* @param {GetMarginAccountsParams} params
|
|
71
|
-
* @returns {Promise<
|
|
71
|
+
* @returns {Promise<GetMarginAccountsResult>} A promise that resolves to the response containing the margin
|
|
72
72
|
* account data.
|
|
73
73
|
* @memberof account
|
|
74
74
|
* */
|
|
@@ -88,19 +88,37 @@ var AccountClient = /** @class */ (function (_super) {
|
|
|
88
88
|
* associated with the provided Ethereum address. The account is identified using the collateral account number.
|
|
89
89
|
*
|
|
90
90
|
* @param {GetMarginAccountParams} params
|
|
91
|
-
* @returns {Promise<
|
|
91
|
+
* @returns {Promise<GetMarginAccountResult>} A promise that resolves to the response containing the detailed
|
|
92
92
|
* information of the specified margin account.
|
|
93
93
|
* @memberof account
|
|
94
94
|
*/
|
|
95
|
-
AccountClient.prototype.
|
|
95
|
+
AccountClient.prototype.getMarginAccount = function (params) {
|
|
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, "/
|
|
99
|
+
uri = "/api/accounts/".concat(params.address, "/marginAccount/").concat(params.marginAccountNumber);
|
|
100
100
|
return [2 /*return*/, this.get(uri)];
|
|
101
101
|
});
|
|
102
102
|
});
|
|
103
103
|
};
|
|
104
|
+
AccountClient.prototype.getPositionsForMarginAccount = function (params) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
+
var uri;
|
|
107
|
+
return __generator(this, function (_a) {
|
|
108
|
+
uri = "/api/accounts/".concat(params.address, "/marginAccount/").concat(params.marginAccountNumber, "/positions");
|
|
109
|
+
return [2 /*return*/, this.get(uri, { limit: params.limit })];
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
AccountClient.prototype.getPositionsHistoryForMarginAccount = function (params) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
115
|
+
var uri;
|
|
116
|
+
return __generator(this, function (_a) {
|
|
117
|
+
uri = "/api/accounts/".concat(params.address, "/marginAccount/").concat(params.marginAccountNumber, "/positions/history");
|
|
118
|
+
return [2 /*return*/, this.get(uri, { limit: params.limit })];
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
};
|
|
104
122
|
return AccountClient;
|
|
105
123
|
}(rest_1.default));
|
|
106
124
|
exports.default = AccountClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"/","sources":["clients/modules/account.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
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,mBAAmB,CAAE,CAAC;gBAC1F,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IAEK,oDAA4B,GAAlC,UACE,MAA0C;;;;gBAEpC,GAAG,GAAG,wBAAiB,MAAM,CAAC,OAAO,4BAAkB,MAAM,CAAC,mBAAmB,eAAY,CAAC;gBACpG,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,mBAAmB,uBAAoB,CAAC;gBAC5G,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.marginAccountNumber}`;\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.marginAccountNumber}/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.marginAccountNumber}/positions/history`;\n return this.get(uri, { limit: params.limit });\n }\n}\n"]}
|
|
@@ -67,7 +67,7 @@ var MarketsClient = /** @class */ (function (_super) {
|
|
|
67
67
|
* it fetches data for that particular market; otherwise, it fetches data for all available markets.
|
|
68
68
|
*
|
|
69
69
|
* @param {GetMarketsParams} [params] - The specific market ticker identifier for which data is requested. This parameter is optional.
|
|
70
|
-
* @returns {Promise<
|
|
70
|
+
* @returns {Promise<GetMarketsResult>} A promise that resolves to the response containing market data.
|
|
71
71
|
* @memberof MarketsClient
|
|
72
72
|
*
|
|
73
73
|
* @example
|
|
@@ -83,7 +83,7 @@ var MarketsClient = /** @class */ (function (_super) {
|
|
|
83
83
|
var uri;
|
|
84
84
|
return __generator(this, function (_a) {
|
|
85
85
|
uri = '/api/markets';
|
|
86
|
-
return [2 /*return*/, this.get(uri, { id: params.id })];
|
|
86
|
+
return [2 /*return*/, this.get(uri, { id: params === null || params === void 0 ? void 0 : params.id })];
|
|
87
87
|
});
|
|
88
88
|
});
|
|
89
89
|
};
|
|
@@ -118,13 +118,13 @@ var MarketsClient = /** @class */ (function (_super) {
|
|
|
118
118
|
});
|
|
119
119
|
});
|
|
120
120
|
};
|
|
121
|
-
MarketsClient.prototype.
|
|
121
|
+
MarketsClient.prototype.getMarketTradingHistory = function (params) {
|
|
122
122
|
return __awaiter(this, void 0, void 0, function () {
|
|
123
123
|
var uri;
|
|
124
124
|
return __generator(this, function (_a) {
|
|
125
|
-
uri = "/api/trades/".concat(marketId);
|
|
125
|
+
uri = "/api/trades/".concat(params.marketId);
|
|
126
126
|
return [2 /*return*/, this.get(uri, {
|
|
127
|
-
limit: limit,
|
|
127
|
+
limit: params.limit,
|
|
128
128
|
})];
|
|
129
129
|
});
|
|
130
130
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markets.js","sourceRoot":"/","sources":["clients/modules/markets.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"markets.js","sourceRoot":"/","sources":["clients/modules/markets.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,gDAAgC;AAEhC;IAA2C,iCAAU;IAArD;;IAmEA,CAAC;IAlEC;;;;;;;;;;;;;;;;;OAiBG;IAEG,kCAAU,GAAhB,UAAiB,MAAyB;;;;gBAClC,GAAG,GAAG,cAAc,CAAC;gBAC3B,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,EAAE,EAAE,CAAC,EAAC;;;KAC1C;IAED;;;;;;;;;;;;;;;;OAgBG;IAEG,wCAAgB,GAAtB,UACE,QAA4B,EAC5B,UAA6B,EAC7B,OAAuB,EACvB,KAAqB,EACrB,KAAqB;;;;gBAEf,GAAG,GAAG,+BAAwB,QAAQ,CAAE,CAAC;gBAC/C,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,UAAU,YAAA;wBACV,OAAO,SAAA;wBACP,KAAK,OAAA;wBACL,KAAK,OAAA;qBACN,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,AAnED,CAA2C,cAAU,GAmEpD","sourcesContent":["import {\n CandlesResolution,\n GetMarketsParams,\n GetMarketsResult,\n GetMarketTradingHistoryParams,\n GetTradingHistoryResult,\n MarketCandlesResponse,\n MarketEntity,\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 * @param {GetMarketsParams} [params] - The specific market ticker identifier for which data is requested. This parameter is optional.\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(params?: GetMarketsParams): Promise<GetMarketsResult> {\n const uri = '/api/markets';\n return this.get(uri, { id: params?.id });\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 {number} marketId - The market identifier for which candlestick data is to be retrieved.\n * @param {CandlesResolution} resolution - The granularity of the candlestick data (e.g., '1MIN', '5MIN', '1HR').\n * @param {string|null} [fromISO] - The start time for the range of candlestick data in ISO 8601 format. Optional.\n * @param {string|null} [toISO] - The end time for the range of candlestick data in ISO 8601 format. Optional.\n * @param {number|null} [limit] - The maximum number of candlestick data points to retrieve. Optional.\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 marketId: MarketEntity['id'],\n resolution: CandlesResolution,\n fromISO?: string | null,\n toISO?: string | null,\n limit?: number | null,\n ): Promise<MarketCandlesResponse> {\n const uri = `/api/markets/candles/${marketId}`;\n return this.get(uri, {\n resolution,\n fromISO,\n toISO,\n 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 GetMarketsParams = {\n id?: number;\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 marginAccountNumber: 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
|
|
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 GetMarketsParams = {\n id?: number;\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 marginAccountNumber: number;\n};\n\nexport type GetPositionsForMarginAccountParams = {\n address: string;\n marginAccountNumber: number;\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 marginAccountNumber: number;\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"]}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.ApiClient = void 0;
|
|
4
18
|
var api_client_1 = require("./clients/api-client");
|
|
5
19
|
Object.defineProperty(exports, "ApiClient", { enumerable: true, get: function () { return api_client_1.ApiClient; } });
|
|
20
|
+
__exportStar(require("./clients/types"), exports);
|
|
6
21
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mDAAiD;AAAxC,uGAAA,SAAS,OAAA;AAClB,kDAAgC","sourcesContent":["export { ApiClient } from './clients/api-client';\nexport * from './clients/types';\n"]}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { GetMarginAccountParams, GetMarginAccountsParams,
|
|
1
|
+
import { GetMarginAccountParams, GetMarginAccountResult, GetMarginAccountsParams, GetMarginAccountsResult, GetPositionsForMarginAccountParams, GetPositionsForMarginAccountResult, GetPositionsHistoryForMarginAccountParams, GetPositionsHistoryForMarginAccountResult } from '../types';
|
|
2
2
|
import RestClient from './rest';
|
|
3
3
|
export default class AccountClient extends RestClient {
|
|
4
4
|
/**
|
|
5
|
-
* Asynchronously retrieves a list of
|
|
5
|
+
* Asynchronously retrieves a list of margin accounts associated with a specific address.
|
|
6
6
|
*
|
|
7
7
|
* This method makes a request to the API endpoint to fetch collateral account data. The data is filtered
|
|
8
8
|
* based on the provided Ethereum address. An optional limit can be specified to control the number of
|
|
9
9
|
* collateral accounts returned in the response.
|
|
10
10
|
*
|
|
11
11
|
* @param {GetMarginAccountsParams} params
|
|
12
|
-
* @returns {Promise<
|
|
12
|
+
* @returns {Promise<GetMarginAccountsResult>} A promise that resolves to the response containing the margin
|
|
13
13
|
* account data.
|
|
14
14
|
* @memberof account
|
|
15
15
|
* */
|
|
16
|
-
getMarginAccounts(params: GetMarginAccountsParams): Promise<
|
|
16
|
+
getMarginAccounts(params: GetMarginAccountsParams): Promise<GetMarginAccountsResult>;
|
|
17
17
|
/**
|
|
18
18
|
* Asynchronously retrieves details of a specific collateral account for a given Ethereum address.
|
|
19
19
|
*
|
|
@@ -21,10 +21,12 @@ export default class AccountClient extends RestClient {
|
|
|
21
21
|
* associated with the provided Ethereum address. The account is identified using the collateral account number.
|
|
22
22
|
*
|
|
23
23
|
* @param {GetMarginAccountParams} params
|
|
24
|
-
* @returns {Promise<
|
|
24
|
+
* @returns {Promise<GetMarginAccountResult>} A promise that resolves to the response containing the detailed
|
|
25
25
|
* information of the specified margin account.
|
|
26
26
|
* @memberof account
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
getMarginAccount(params: GetMarginAccountParams): Promise<GetMarginAccountResult>;
|
|
29
|
+
getPositionsForMarginAccount(params: GetPositionsForMarginAccountParams): Promise<GetPositionsForMarginAccountResult>;
|
|
30
|
+
getPositionsHistoryForMarginAccount(params: GetPositionsHistoryForMarginAccountParams): Promise<GetPositionsHistoryForMarginAccountResult>;
|
|
29
31
|
}
|
|
30
32
|
//# sourceMappingURL=account.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"/","sources":["clients/modules/account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"/","sources":["clients/modules/account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,kCAAkC,EAClC,kCAAkC,EAClC,yCAAyC,EACzC,yCAAyC,EAC1C,MAAM,UAAU,CAAC;AAClB,OAAO,UAAU,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD;;;;;;;;;;;SAWK;IAEC,iBAAiB,CACrB,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,uBAAuB,CAAC;IAKnC;;;;;;;;;;OAUG;IAEG,gBAAgB,CACpB,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,sBAAsB,CAAC;IAK5B,4BAA4B,CAChC,MAAM,EAAE,kCAAkC,GACzC,OAAO,CAAC,kCAAkC,CAAC;IAKxC,mCAAmC,CACvC,MAAM,EAAE,yCAAyC,GAChD,OAAO,CAAC,yCAAyC,CAAC;CAItD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CandlesResolution, GetMarketsParams, MarketCandlesResponse, MarketEntity
|
|
1
|
+
import { CandlesResolution, GetMarketsParams, GetMarketsResult, GetMarketTradingHistoryParams, GetTradingHistoryResult, MarketCandlesResponse, MarketEntity } from '../types';
|
|
2
2
|
import RestClient from './rest';
|
|
3
3
|
export default class MarketsClient extends RestClient {
|
|
4
4
|
/**
|
|
@@ -8,7 +8,7 @@ export default class MarketsClient extends RestClient {
|
|
|
8
8
|
* it fetches data for that particular market; otherwise, it fetches data for all available markets.
|
|
9
9
|
*
|
|
10
10
|
* @param {GetMarketsParams} [params] - The specific market ticker identifier for which data is requested. This parameter is optional.
|
|
11
|
-
* @returns {Promise<
|
|
11
|
+
* @returns {Promise<GetMarketsResult>} A promise that resolves to the response containing market data.
|
|
12
12
|
* @memberof MarketsClient
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
@@ -19,7 +19,7 @@ export default class MarketsClient extends RestClient {
|
|
|
19
19
|
* // Fetch data for a specific market
|
|
20
20
|
* const specificMarketData = await market.getMarkets('ETH-USDC');
|
|
21
21
|
*/
|
|
22
|
-
getMarkets(params
|
|
22
|
+
getMarkets(params?: GetMarketsParams): Promise<GetMarketsResult>;
|
|
23
23
|
/**
|
|
24
24
|
* Retrieves candlestick data for a specified market.
|
|
25
25
|
*
|
|
@@ -38,6 +38,6 @@ export default class MarketsClient extends RestClient {
|
|
|
38
38
|
* const marketCandles = await market.getMarketCandles('BTC-USD', '1HR', '2023-01-01T00:00:00Z', '2023-01-02T00:00:00Z');
|
|
39
39
|
*/
|
|
40
40
|
getMarketCandles(marketId: MarketEntity['id'], resolution: CandlesResolution, fromISO?: string | null, toISO?: string | null, limit?: number | null): Promise<MarketCandlesResponse>;
|
|
41
|
-
|
|
41
|
+
getMarketTradingHistory(params: GetMarketTradingHistoryParams): Promise<GetTradingHistoryResult>;
|
|
42
42
|
}
|
|
43
43
|
//# 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,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,
|
|
1
|
+
{"version":3,"file":"markets.d.ts","sourceRoot":"/","sources":["clients/modules/markets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,6BAA6B,EAC7B,uBAAuB,EACvB,qBAAqB,EACrB,YAAY,EACb,MAAM,UAAU,CAAC;AAClB,OAAO,UAAU,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD;;;;;;;;;;;;;;;;;OAiBG;IAEG,UAAU,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAKtE;;;;;;;;;;;;;;;;OAgBG;IAEG,gBAAgB,CACpB,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,EAC5B,UAAU,EAAE,iBAAiB,EAC7B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,EACvB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,EACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GACpB,OAAO,CAAC,qBAAqB,CAAC;IAU3B,uBAAuB,CAC3B,MAAM,EAAE,6BAA6B,GACpC,OAAO,CAAC,uBAAuB,CAAC;CAMpC"}
|
|
@@ -40,6 +40,7 @@ export type MarketEntity = {
|
|
|
40
40
|
description: string;
|
|
41
41
|
tickSizeDecimals: number;
|
|
42
42
|
};
|
|
43
|
+
export type GetMarketsResult = MarketEntity[];
|
|
43
44
|
export type GetMarketsParams = {
|
|
44
45
|
id?: number;
|
|
45
46
|
};
|
|
@@ -53,6 +54,11 @@ export type GetMarginAccountParams = {
|
|
|
53
54
|
address: string;
|
|
54
55
|
marginAccountNumber: number;
|
|
55
56
|
};
|
|
57
|
+
export type GetPositionsForMarginAccountParams = {
|
|
58
|
+
address: string;
|
|
59
|
+
marginAccountNumber: number;
|
|
60
|
+
limit?: number;
|
|
61
|
+
};
|
|
56
62
|
export type MarginAccountEntity = {
|
|
57
63
|
id: number;
|
|
58
64
|
name: string;
|
|
@@ -67,29 +73,56 @@ export type MarginAccountEntity = {
|
|
|
67
73
|
balanceRUSD: number;
|
|
68
74
|
}[];
|
|
69
75
|
};
|
|
70
|
-
export
|
|
76
|
+
export type GetMarginAccountsResult = MarginAccountEntity[];
|
|
77
|
+
export type GetMarginAccountResult = MarginAccountEntity;
|
|
78
|
+
export type PositionEntity = {
|
|
71
79
|
id: number;
|
|
72
|
-
symbol: string;
|
|
73
80
|
side: Side;
|
|
74
81
|
size: number;
|
|
75
82
|
price: number;
|
|
76
|
-
orderStatus: Status;
|
|
77
83
|
markPrice: number;
|
|
78
|
-
|
|
79
|
-
realisedPnl
|
|
84
|
+
orderStatus: Status;
|
|
85
|
+
realisedPnl?: number | null;
|
|
86
|
+
unrealisedPnl?: number | null;
|
|
80
87
|
liquidationPrice: number;
|
|
81
|
-
fundingRate:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
88
|
+
fundingRate: number;
|
|
89
|
+
market: MarketEntity;
|
|
90
|
+
date: Date;
|
|
91
|
+
};
|
|
92
|
+
export type GetPositionsForMarginAccountResult = {
|
|
93
|
+
positions: PositionEntity[];
|
|
94
|
+
totalUnrealizedPNL: number;
|
|
95
|
+
};
|
|
96
|
+
export type GetMarketTradingHistoryParams = {
|
|
97
|
+
marketId: number;
|
|
98
|
+
limit?: number;
|
|
99
|
+
};
|
|
100
|
+
export type TradingHistoryEntity = {
|
|
85
101
|
id: number;
|
|
86
|
-
side: Side;
|
|
87
|
-
size: string;
|
|
88
102
|
price: number;
|
|
89
|
-
|
|
90
|
-
|
|
103
|
+
priceUnderlyingToken: string;
|
|
104
|
+
size: number;
|
|
105
|
+
sizeUnderlyingToken: string;
|
|
106
|
+
timestampMillisecondsUTC: number;
|
|
107
|
+
};
|
|
108
|
+
export type GetTradingHistoryResult = TradingHistoryEntity[];
|
|
109
|
+
export type GetPositionsHistoryForMarginAccountParams = {
|
|
110
|
+
address: string;
|
|
111
|
+
marginAccountNumber: number;
|
|
112
|
+
limit?: number;
|
|
91
113
|
};
|
|
92
|
-
export type
|
|
93
|
-
|
|
114
|
+
export type OrderType = 'market';
|
|
115
|
+
export type PositionHistoryType = 'long-trade' | 'short-trade' | 'long-liquidation' | 'short-liquidation';
|
|
116
|
+
export type PositionHistoryEntity = {
|
|
117
|
+
id: number;
|
|
118
|
+
action: PositionHistoryType;
|
|
119
|
+
orderType: OrderType;
|
|
120
|
+
size: number;
|
|
121
|
+
executionPrice: number;
|
|
122
|
+
realisedPnl?: number | null;
|
|
123
|
+
fees: number;
|
|
124
|
+
timestamp: number;
|
|
125
|
+
market: MarketEntity;
|
|
94
126
|
};
|
|
127
|
+
export type GetPositionsHistoryForMarginAccountResult = PositionHistoryEntity[];
|
|
95
128
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -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;IACl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M,CAAC;IAClB,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,yCAAyC,GAAG,qBAAqB,EAAE,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"}
|
|
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.10.1",
|
|
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": "578285433d56b0e3b463f63283a83401edafec40"
|
|
40
40
|
}
|
|
@@ -1,27 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
GetMarginAccountParams,
|
|
3
|
+
GetMarginAccountResult,
|
|
3
4
|
GetMarginAccountsParams,
|
|
4
|
-
|
|
5
|
+
GetMarginAccountsResult,
|
|
6
|
+
GetPositionsForMarginAccountParams,
|
|
7
|
+
GetPositionsForMarginAccountResult,
|
|
8
|
+
GetPositionsHistoryForMarginAccountParams,
|
|
9
|
+
GetPositionsHistoryForMarginAccountResult,
|
|
5
10
|
} from '../types';
|
|
6
11
|
import RestClient from './rest';
|
|
7
12
|
|
|
8
13
|
export default class AccountClient extends RestClient {
|
|
9
14
|
/**
|
|
10
|
-
* Asynchronously retrieves a list of
|
|
15
|
+
* Asynchronously retrieves a list of margin accounts associated with a specific address.
|
|
11
16
|
*
|
|
12
17
|
* This method makes a request to the API endpoint to fetch collateral account data. The data is filtered
|
|
13
18
|
* based on the provided Ethereum address. An optional limit can be specified to control the number of
|
|
14
19
|
* collateral accounts returned in the response.
|
|
15
20
|
*
|
|
16
21
|
* @param {GetMarginAccountsParams} params
|
|
17
|
-
* @returns {Promise<
|
|
22
|
+
* @returns {Promise<GetMarginAccountsResult>} A promise that resolves to the response containing the margin
|
|
18
23
|
* account data.
|
|
19
24
|
* @memberof account
|
|
20
25
|
* */
|
|
21
26
|
|
|
22
27
|
async getMarginAccounts(
|
|
23
28
|
params: GetMarginAccountsParams,
|
|
24
|
-
): Promise<
|
|
29
|
+
): Promise<GetMarginAccountsResult> {
|
|
25
30
|
const uri = `/api/accounts/${params.address}`;
|
|
26
31
|
return this.get(uri, { limit: params.limit });
|
|
27
32
|
}
|
|
@@ -33,15 +38,29 @@ export default class AccountClient extends RestClient {
|
|
|
33
38
|
* associated with the provided Ethereum address. The account is identified using the collateral account number.
|
|
34
39
|
*
|
|
35
40
|
* @param {GetMarginAccountParams} params
|
|
36
|
-
* @returns {Promise<
|
|
41
|
+
* @returns {Promise<GetMarginAccountResult>} A promise that resolves to the response containing the detailed
|
|
37
42
|
* information of the specified margin account.
|
|
38
43
|
* @memberof account
|
|
39
44
|
*/
|
|
40
45
|
|
|
41
|
-
async
|
|
46
|
+
async getMarginAccount(
|
|
42
47
|
params: GetMarginAccountParams,
|
|
43
|
-
): Promise<
|
|
44
|
-
const uri = `/api/accounts/${params.address}/
|
|
48
|
+
): Promise<GetMarginAccountResult> {
|
|
49
|
+
const uri = `/api/accounts/${params.address}/marginAccount/${params.marginAccountNumber}`;
|
|
45
50
|
return this.get(uri);
|
|
46
51
|
}
|
|
52
|
+
|
|
53
|
+
async getPositionsForMarginAccount(
|
|
54
|
+
params: GetPositionsForMarginAccountParams,
|
|
55
|
+
): Promise<GetPositionsForMarginAccountResult> {
|
|
56
|
+
const uri = `/api/accounts/${params.address}/marginAccount/${params.marginAccountNumber}/positions`;
|
|
57
|
+
return this.get(uri, { limit: params.limit });
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async getPositionsHistoryForMarginAccount(
|
|
61
|
+
params: GetPositionsHistoryForMarginAccountParams,
|
|
62
|
+
): Promise<GetPositionsHistoryForMarginAccountResult> {
|
|
63
|
+
const uri = `/api/accounts/${params.address}/marginAccount/${params.marginAccountNumber}/positions/history`;
|
|
64
|
+
return this.get(uri, { limit: params.limit });
|
|
65
|
+
}
|
|
47
66
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CandlesResolution,
|
|
3
3
|
GetMarketsParams,
|
|
4
|
+
GetMarketsResult,
|
|
5
|
+
GetMarketTradingHistoryParams,
|
|
6
|
+
GetTradingHistoryResult,
|
|
4
7
|
MarketCandlesResponse,
|
|
5
8
|
MarketEntity,
|
|
6
|
-
TradesResponse,
|
|
7
9
|
} from '../types';
|
|
8
10
|
import RestClient from './rest';
|
|
9
11
|
|
|
@@ -15,7 +17,7 @@ export default class MarketsClient extends RestClient {
|
|
|
15
17
|
* it fetches data for that particular market; otherwise, it fetches data for all available markets.
|
|
16
18
|
*
|
|
17
19
|
* @param {GetMarketsParams} [params] - The specific market ticker identifier for which data is requested. This parameter is optional.
|
|
18
|
-
* @returns {Promise<
|
|
20
|
+
* @returns {Promise<GetMarketsResult>} A promise that resolves to the response containing market data.
|
|
19
21
|
* @memberof MarketsClient
|
|
20
22
|
*
|
|
21
23
|
* @example
|
|
@@ -27,9 +29,9 @@ export default class MarketsClient extends RestClient {
|
|
|
27
29
|
* const specificMarketData = await market.getMarkets('ETH-USDC');
|
|
28
30
|
*/
|
|
29
31
|
|
|
30
|
-
async getMarkets(params
|
|
32
|
+
async getMarkets(params?: GetMarketsParams): Promise<GetMarketsResult> {
|
|
31
33
|
const uri = '/api/markets';
|
|
32
|
-
return this.get(uri, { id: params
|
|
34
|
+
return this.get(uri, { id: params?.id });
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
/**
|
|
@@ -66,13 +68,12 @@ export default class MarketsClient extends RestClient {
|
|
|
66
68
|
});
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
async
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const uri = `/api/trades/${marketId}`;
|
|
71
|
+
async getMarketTradingHistory(
|
|
72
|
+
params: GetMarketTradingHistoryParams,
|
|
73
|
+
): Promise<GetTradingHistoryResult> {
|
|
74
|
+
const uri = `/api/trades/${params.marketId}`;
|
|
74
75
|
return this.get(uri, {
|
|
75
|
-
limit,
|
|
76
|
+
limit: params.limit,
|
|
76
77
|
});
|
|
77
78
|
}
|
|
78
79
|
}
|
package/src/clients/types.ts
CHANGED
|
@@ -47,6 +47,8 @@ export type MarketEntity = {
|
|
|
47
47
|
tickSizeDecimals: number;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
+
export type GetMarketsResult = MarketEntity[];
|
|
51
|
+
|
|
50
52
|
export type GetMarketsParams = {
|
|
51
53
|
id?: number;
|
|
52
54
|
};
|
|
@@ -65,6 +67,12 @@ export type GetMarginAccountParams = {
|
|
|
65
67
|
marginAccountNumber: number;
|
|
66
68
|
};
|
|
67
69
|
|
|
70
|
+
export type GetPositionsForMarginAccountParams = {
|
|
71
|
+
address: string;
|
|
72
|
+
marginAccountNumber: number;
|
|
73
|
+
limit?: number;
|
|
74
|
+
};
|
|
75
|
+
|
|
68
76
|
export type MarginAccountEntity = {
|
|
69
77
|
id: number;
|
|
70
78
|
name: string;
|
|
@@ -80,30 +88,73 @@ export type MarginAccountEntity = {
|
|
|
80
88
|
}[];
|
|
81
89
|
};
|
|
82
90
|
|
|
83
|
-
export
|
|
91
|
+
export type GetMarginAccountsResult = MarginAccountEntity[];
|
|
92
|
+
export type GetMarginAccountResult = MarginAccountEntity;
|
|
93
|
+
|
|
94
|
+
export type PositionEntity = {
|
|
84
95
|
id: number;
|
|
85
|
-
symbol: string;
|
|
86
96
|
side: Side;
|
|
87
97
|
size: number;
|
|
88
98
|
price: number;
|
|
89
|
-
orderStatus: Status;
|
|
90
99
|
markPrice: number;
|
|
91
|
-
|
|
92
|
-
realisedPnl
|
|
100
|
+
orderStatus: Status;
|
|
101
|
+
realisedPnl?: number | null;
|
|
102
|
+
unrealisedPnl?: number | null;
|
|
93
103
|
liquidationPrice: number;
|
|
94
|
-
fundingRate:
|
|
95
|
-
|
|
96
|
-
|
|
104
|
+
fundingRate: number;
|
|
105
|
+
market: MarketEntity;
|
|
106
|
+
date: Date;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export type GetPositionsForMarginAccountResult = {
|
|
110
|
+
positions: PositionEntity[];
|
|
111
|
+
totalUnrealizedPNL: number;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// --- Trading History ----
|
|
115
|
+
|
|
116
|
+
export type GetMarketTradingHistoryParams = {
|
|
117
|
+
marketId: number;
|
|
118
|
+
limit?: number;
|
|
119
|
+
};
|
|
97
120
|
|
|
98
|
-
export type
|
|
121
|
+
export type TradingHistoryEntity = {
|
|
99
122
|
id: number;
|
|
100
|
-
side: Side;
|
|
101
|
-
size: string;
|
|
102
123
|
price: number;
|
|
103
|
-
|
|
104
|
-
|
|
124
|
+
priceUnderlyingToken: string;
|
|
125
|
+
size: number;
|
|
126
|
+
sizeUnderlyingToken: string;
|
|
127
|
+
timestampMillisecondsUTC: number;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export type GetTradingHistoryResult = TradingHistoryEntity[];
|
|
131
|
+
|
|
132
|
+
// --- Position History ---
|
|
133
|
+
|
|
134
|
+
export type GetPositionsHistoryForMarginAccountParams = {
|
|
135
|
+
address: string;
|
|
136
|
+
marginAccountNumber: number;
|
|
137
|
+
limit?: number;
|
|
105
138
|
};
|
|
106
139
|
|
|
107
|
-
export type
|
|
108
|
-
|
|
140
|
+
export type OrderType = 'market';
|
|
141
|
+
|
|
142
|
+
export type PositionHistoryType =
|
|
143
|
+
| 'long-trade'
|
|
144
|
+
| 'short-trade'
|
|
145
|
+
| 'long-liquidation'
|
|
146
|
+
| 'short-liquidation';
|
|
147
|
+
|
|
148
|
+
export type PositionHistoryEntity = {
|
|
149
|
+
id: number;
|
|
150
|
+
action: PositionHistoryType;
|
|
151
|
+
orderType: OrderType;
|
|
152
|
+
size: number;
|
|
153
|
+
executionPrice: number;
|
|
154
|
+
realisedPnl?: number | null;
|
|
155
|
+
fees: number;
|
|
156
|
+
timestamp: number;
|
|
157
|
+
market: MarketEntity;
|
|
109
158
|
};
|
|
159
|
+
|
|
160
|
+
export type GetPositionsHistoryForMarginAccountResult = PositionHistoryEntity[];
|
package/src/index.ts
CHANGED