@reyaxyz/api-sdk 0.6.3 → 0.7.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/README.md CHANGED
@@ -1,12 +1,4 @@
1
- # @reya-network/api-sdk
2
-
3
- <p align="center">
4
- <a href="https://app.voltz.xyz/">
5
- <picture>
6
- <img src="./assets/voltz-background.jpeg" alt="Voltz" width="512" />
7
- </picture>
8
- </a>
9
- </p>
1
+ # @reyaxyz/api-sdk
10
2
 
11
3
  <p align="center"> API sdk for the Reya Network </p>
12
4
 
@@ -67,27 +67,17 @@ var AccountClient = /** @class */ (function (_super) {
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
- * @param {string} address - The Ethereum address for which collateral account data is being requested.
71
- * @param {number} [limit] - An optional limit on the number of collateral accounts to retrieve. If not specified,
72
- * all available collateral accounts for the address will be returned.
73
- * @returns {Promise<CollateralAccountListResponse>} A promise that resolves to the response containing the collateral
70
+ * @param {GetMarginAccountsParams} getMarginAccountsParams
71
+ * @returns {Promise<MarginAccountEntity[]>} A promise that resolves to the response containing the margin
74
72
  * account data.
75
73
  * @memberof account
76
- *
77
- * @example
78
- * // Fetch all collateral accounts for a specific address
79
- * const accounts = await account.getCollateralAccounts('0x123...');
80
- *
81
- * @example
82
- * // Fetch a limited number of collateral accounts for a specific address
83
- * const limitedAccounts = await account.getCollateralAccounts('0x123...', 5);
84
- */
85
- AccountClient.prototype.getCollateralAccounts = function (address, limit) {
74
+ * */
75
+ AccountClient.prototype.getCollateralAccounts = function (getMarginAccountsParams) {
86
76
  return __awaiter(this, void 0, void 0, function () {
87
77
  var uri;
88
78
  return __generator(this, function (_a) {
89
- uri = "/api/accounts/".concat(address);
90
- return [2 /*return*/, this.get(uri, { limit: limit })];
79
+ uri = "/api/accounts/".concat(getMarginAccountsParams.address);
80
+ return [2 /*return*/, this.get(uri, { limit: getMarginAccountsParams.limit })];
91
81
  });
92
82
  });
93
83
  };
@@ -97,21 +87,16 @@ var AccountClient = /** @class */ (function (_super) {
97
87
  * This method sends a request to the API to obtain detailed information about a specific collateral account
98
88
  * associated with the provided Ethereum address. The account is identified using the collateral account number.
99
89
  *
100
- * @param {string} address - The Ethereum address associated with the collateral account.
101
- * @param {number} collateralAccountNumber - The number identifying the specific collateral account.
102
- * @returns {Promise<CollateralAccountResponse>} A promise that resolves to the response containing the detailed
103
- * information of the specified collateral account.
90
+ * @param {GetMarginAccountParams} getMarginAccountParams
91
+ * @returns {Promise<MarginAccountEntity>} A promise that resolves to the response containing the detailed
92
+ * information of the specified margin account.
104
93
  * @memberof account
105
- *
106
- * @example
107
- * // Fetch details of a specific collateral account by its number for a given address
108
- * const accountDetails = await account.getCollateralAccount('0x123...', 1);
109
94
  */
110
- AccountClient.prototype.getCollateralAccount = function (address, collateralAccountNumber) {
95
+ AccountClient.prototype.getCollateralAccount = function (getMarginAccountParams) {
111
96
  return __awaiter(this, void 0, void 0, function () {
112
97
  var uri;
113
98
  return __generator(this, function (_a) {
114
- uri = "/api/accounts/".concat(address, "/collateralAccount/").concat(collateralAccountNumber);
99
+ uri = "/api/accounts/".concat(getMarginAccountParams.address, "/collateralAccount/").concat(getMarginAccountParams.marginAccountNumber);
115
100
  return [2 /*return*/, this.get(uri)];
116
101
  });
117
102
  });
@@ -1 +1 @@
1
- {"version":3,"file":"account.js","sourceRoot":"/","sources":["clients/modules/account.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,gDAAgC;AAEhC;IAA2C,iCAAU;IAArD;;IAwDA,CAAC;IAvDC;;;;;;;;;;;;;;;;;;;;;OAqBG;IAEG,6CAAqB,GAA3B,UACE,OAAe,EACf,KAAc;;;;gBAER,GAAG,GAAG,wBAAiB,OAAO,CAAE,CAAC;gBACvC,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,OAAA,EAAE,CAAC,EAAC;;;KACjC;IAED;;;;;;;;;;;;;;;OAeG;IAEG,4CAAoB,GAA1B,UACE,OAAe,EACf,uBAA+B;;;;gBAEzB,GAAG,GAAG,wBAAiB,OAAO,gCAAsB,uBAAuB,CAAE,CAAC;gBACpF,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IACH,oBAAC;AAAD,CAAC,AAxDD,CAA2C,cAAU,GAwDpD","sourcesContent":["import {\n CollateralAccountListResponse,\n CollateralAccountResponse,\n} from '../types';\nimport RestClient from './rest';\n\nexport default class AccountClient extends RestClient {\n /**\n * Asynchronously retrieves a list of collateral 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 {string} address - The Ethereum address for which collateral account data is being requested.\n * @param {number} [limit] - An optional limit on the number of collateral accounts to retrieve. If not specified,\n * all available collateral accounts for the address will be returned.\n * @returns {Promise<CollateralAccountListResponse>} A promise that resolves to the response containing the collateral\n * account data.\n * @memberof account\n *\n * @example\n * // Fetch all collateral accounts for a specific address\n * const accounts = await account.getCollateralAccounts('0x123...');\n *\n * @example\n * // Fetch a limited number of collateral accounts for a specific address\n * const limitedAccounts = await account.getCollateralAccounts('0x123...', 5);\n */\n\n async getCollateralAccounts(\n address: string,\n limit?: number,\n ): Promise<CollateralAccountListResponse> {\n const uri = `/api/accounts/${address}`;\n return this.get(uri, { 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 {string} address - The Ethereum address associated with the collateral account.\n * @param {number} collateralAccountNumber - The number identifying the specific collateral account.\n * @returns {Promise<CollateralAccountResponse>} A promise that resolves to the response containing the detailed\n * information of the specified collateral account.\n * @memberof account\n *\n * @example\n * // Fetch details of a specific collateral account by its number for a given address\n * const accountDetails = await account.getCollateralAccount('0x123...', 1);\n */\n\n async getCollateralAccount(\n address: string,\n collateralAccountNumber: number,\n ): Promise<CollateralAccountResponse> {\n const uri = `/api/accounts/${address}/collateralAccount/${collateralAccountNumber}`;\n return this.get(uri);\n }\n}\n"]}
1
+ {"version":3,"file":"account.js","sourceRoot":"/","sources":["clients/modules/account.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,gDAAgC;AAEhC;IAA2C,iCAAU;IAArD;;IAuCA,CAAC;IAtCC;;;;;;;;;;;SAWK;IAEC,6CAAqB,GAA3B,UACE,uBAAgD;;;;gBAE1C,GAAG,GAAG,wBAAiB,uBAAuB,CAAC,OAAO,CAAE,CAAC;gBAC/D,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,uBAAuB,CAAC,KAAK,EAAE,CAAC,EAAC;;;KAChE;IAED;;;;;;;;;;OAUG;IAEG,4CAAoB,GAA1B,UACE,sBAA8C;;;;gBAExC,GAAG,GAAG,wBAAiB,sBAAsB,CAAC,OAAO,gCAAsB,sBAAsB,CAAC,mBAAmB,CAAE,CAAC;gBAC9H,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IACH,oBAAC;AAAD,CAAC,AAvCD,CAA2C,cAAU,GAuCpD","sourcesContent":["import {\n GetMarginAccountParams,\n GetMarginAccountsParams,\n MarginAccountEntity,\n} from '../types';\nimport RestClient from './rest';\n\nexport default class AccountClient extends RestClient {\n /**\n * Asynchronously retrieves a list of collateral 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} getMarginAccountsParams\n * @returns {Promise<MarginAccountEntity[]>} A promise that resolves to the response containing the margin\n * account data.\n * @memberof account\n * */\n\n async getCollateralAccounts(\n getMarginAccountsParams: GetMarginAccountsParams,\n ): Promise<MarginAccountEntity[]> {\n const uri = `/api/accounts/${getMarginAccountsParams.address}`;\n return this.get(uri, { limit: getMarginAccountsParams.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} getMarginAccountParams\n * @returns {Promise<MarginAccountEntity>} A promise that resolves to the response containing the detailed\n * information of the specified margin account.\n * @memberof account\n */\n\n async getCollateralAccount(\n getMarginAccountParams: GetMarginAccountParams,\n ): Promise<MarginAccountEntity> {\n const uri = `/api/accounts/${getMarginAccountParams.address}/collateralAccount/${getMarginAccountParams.marginAccountNumber}`;\n return this.get(uri);\n }\n}\n"]}
@@ -66,8 +66,8 @@ 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 {string} [market] - The specific market ticker identifier for which data is requested. This parameter is optional.
70
- * @returns {Promise<MarketListResponse>} A promise that resolves to the response containing market data.
69
+ * @param {GetMarketsParams} [getMarketsParams] - The specific market ticker identifier for which data is requested. This parameter is optional.
70
+ * @returns {Promise<MarketEntity[]>} A promise that resolves to the response containing market data.
71
71
  * @memberof MarketsClient
72
72
  *
73
73
  * @example
@@ -78,12 +78,12 @@ var MarketsClient = /** @class */ (function (_super) {
78
78
  * // Fetch data for a specific market
79
79
  * const specificMarketData = await market.getMarkets('ETH-USDC');
80
80
  */
81
- MarketsClient.prototype.getMarkets = function (market) {
81
+ MarketsClient.prototype.getMarkets = function (getMarketsParams) {
82
82
  return __awaiter(this, void 0, void 0, function () {
83
83
  var uri;
84
84
  return __generator(this, function (_a) {
85
85
  uri = '/api/markets';
86
- return [2 /*return*/, this.get(uri, { ticker: market })];
86
+ return [2 /*return*/, this.get(uri, { id: getMarketsParams.id })];
87
87
  });
88
88
  });
89
89
  };
@@ -93,7 +93,7 @@ var MarketsClient = /** @class */ (function (_super) {
93
93
  * This method fetches historical candlestick (or OHLC - Open, High, Low, Close) data for a given market.
94
94
  * The data can be filtered by time range (fromISO and toISO) and resolution.
95
95
  *
96
- * @param {string} market - The market identifier for which candlestick data is to be retrieved.
96
+ * @param {number} marketId - The market identifier for which candlestick data is to be retrieved.
97
97
  * @param {CandlesResolution} resolution - The granularity of the candlestick data (e.g., '1MIN', '5MIN', '1HR').
98
98
  * @param {string|null} [fromISO] - The start time for the range of candlestick data in ISO 8601 format. Optional.
99
99
  * @param {string|null} [toISO] - The end time for the range of candlestick data in ISO 8601 format. Optional.
@@ -104,11 +104,11 @@ var MarketsClient = /** @class */ (function (_super) {
104
104
  * @example
105
105
  * const marketCandles = await market.getMarketCandles('BTC-USD', '1HR', '2023-01-01T00:00:00Z', '2023-01-02T00:00:00Z');
106
106
  */
107
- MarketsClient.prototype.getMarketCandles = function (market, resolution, fromISO, toISO, limit) {
107
+ MarketsClient.prototype.getMarketCandles = function (marketId, resolution, fromISO, toISO, limit) {
108
108
  return __awaiter(this, void 0, void 0, function () {
109
109
  var uri;
110
110
  return __generator(this, function (_a) {
111
- uri = "/api/markets/candles/".concat(market);
111
+ uri = "/api/markets/candles/".concat(marketId);
112
112
  return [2 /*return*/, this.get(uri, {
113
113
  resolution: resolution,
114
114
  fromISO: fromISO,
@@ -118,11 +118,11 @@ var MarketsClient = /** @class */ (function (_super) {
118
118
  });
119
119
  });
120
120
  };
121
- MarketsClient.prototype.getPerpetualMarketTrades = function (market, limit) {
121
+ MarketsClient.prototype.getPerpetualMarketTrades = function (marketId, limit) {
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(market);
125
+ uri = "/api/trades/".concat(marketId);
126
126
  return [2 /*return*/, this.get(uri, {
127
127
  limit: limit,
128
128
  })];
@@ -1 +1 @@
1
- {"version":3,"file":"markets.js","sourceRoot":"/","sources":["clients/modules/markets.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,gDAAgC;AAEhC;IAA2C,iCAAU;IAArD;;IAoEA,CAAC;IAnEC;;;;;;;;;;;;;;;;;OAiBG;IAEG,kCAAU,GAAhB,UAAiB,MAAe;;;;gBACxB,GAAG,GAAG,cAAc,CAAC;gBAC3B,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAC;;;KAC1C;IAED;;;;;;;;;;;;;;;;OAgBG;IAEG,wCAAgB,GAAtB,UACE,MAAc,EACd,UAA6B,EAC7B,OAAuB,EACvB,KAAqB,EACrB,KAAqB;;;;gBAEf,GAAG,GAAG,+BAAwB,MAAM,CAAE,CAAC;gBAC7C,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,UAAU,YAAA;wBACV,OAAO,SAAA;wBACP,KAAK,OAAA;wBACL,KAAK,OAAA;qBACN,CAAC,EAAC;;;KACJ;IAEK,gDAAwB,GAA9B,UACE,MAAc,EACd,KAAqB;;;;gBAEf,GAAG,GAAG,sBAAe,MAAM,CAAE,CAAC;gBACpC,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,KAAK,OAAA;qBACN,CAAC,EAAC;;;KACJ;IACH,oBAAC;AAAD,CAAC,AApED,CAA2C,cAAU,GAoEpD","sourcesContent":["import {\n CandlesResolution,\n MarketCandlesResponse,\n MarketListResponse,\n TradesResponse,\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 {string} [market] - The specific market ticker identifier for which data is requested. This parameter is optional.\n * @returns {Promise<MarketListResponse>} 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(market?: string): Promise<MarketListResponse> {\n const uri = '/api/markets';\n return this.get(uri, { ticker: market });\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 {string} market - 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 market: string,\n resolution: CandlesResolution,\n fromISO?: string | null,\n toISO?: string | null,\n limit?: number | null,\n ): Promise<MarketCandlesResponse> {\n const uri = `/api/markets/candles/${market}`;\n return this.get(uri, {\n resolution,\n fromISO,\n toISO,\n limit,\n });\n }\n\n async getPerpetualMarketTrades(\n market: string,\n limit?: number | null,\n ): Promise<TradesResponse> {\n const uri = `/api/trades/${market}`;\n return this.get(uri, {\n limit,\n });\n }\n}\n"]}
1
+ {"version":3,"file":"markets.js","sourceRoot":"/","sources":["clients/modules/markets.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,gDAAgC;AAEhC;IAA2C,iCAAU;IAArD;;IAsEA,CAAC;IArEC;;;;;;;;;;;;;;;;;OAiBG;IAEG,kCAAU,GAAhB,UACE,gBAAkC;;;;gBAE5B,GAAG,GAAG,cAAc,CAAC;gBAC3B,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,gBAAgB,CAAC,EAAE,EAAE,CAAC,EAAC;;;KACnD;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,gDAAwB,GAA9B,UACE,QAAgB,EAChB,KAAqB;;;;gBAEf,GAAG,GAAG,sBAAe,QAAQ,CAAE,CAAC;gBACtC,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,KAAK,OAAA;qBACN,CAAC,EAAC;;;KACJ;IACH,oBAAC;AAAD,CAAC,AAtED,CAA2C,cAAU,GAsEpD","sourcesContent":["import {\n CandlesResolution,\n GetMarketsParams,\n MarketCandlesResponse,\n MarketEntity,\n TradesResponse,\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} [getMarketsParams] - The specific market ticker identifier for which data is requested. This parameter is optional.\n * @returns {Promise<MarketEntity[]>} 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(\n getMarketsParams: GetMarketsParams,\n ): Promise<MarketEntity[]> {\n const uri = '/api/markets';\n return this.get(uri, { id: getMarketsParams.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 getPerpetualMarketTrades(\n marketId: number,\n limit?: number | null,\n ): Promise<TradesResponse> {\n const uri = `/api/trades/${marketId}`;\n return this.get(uri, {\n 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 interface MarketEntry {\n id: number;\n ticker: string;\n instrumentName: string;\n instrumentType: string;\n underlyingAsset: string;\n quoteAsset: string;\n markPrice: number;\n indexPrice: number;\n isActive: boolean;\n maxLeverage: number;\n volume24H: number;\n priceChange24H: number;\n priceChange24HPercentage: string;\n openInterest: string;\n fundingRate: string;\n priceStep: number;\n amountStep: number;\n minOrderValue: number;\n}\n\nexport interface MarketListResponse {\n [key: string]: MarketEntry;\n}\n\n// -- Account --\n\nexport interface CollateralAccount {\n id: number;\n name: string;\n equity: number;\n balance: number;\n marginRatio: string;\n collaterals: Collateral[];\n positions: Position[];\n}\n\nexport interface Collateral {\n collateralAsset: string;\n balance: number;\n availableBalance: number;\n withdrawableBalance: number;\n collateralValue: number;\n}\n\nexport type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';\nexport type Side = 'LONG' | 'SHORT';\n\nexport interface Position {\n id: number;\n symbol: string;\n side: Side;\n size: number;\n price: number;\n orderStatus: Status;\n markPrice: number;\n unrealisedPnl: number;\n realisedPnl: number;\n liquidationPrice: number;\n fundingRate: string;\n date: string;\n}\n\nexport interface CollateralAccountListResponse {\n address: string;\n collateralAccounts: CollateralAccount[];\n}\n\nexport interface CollateralAccountResponse {\n address: string;\n id: number;\n name: string;\n equity: number;\n balance: number;\n marginRatio: string;\n collaterals: Collateral[];\n positions: Position[];\n}\n\nexport type Trade = {\n id: number;\n side: Side;\n size: string;\n price: number;\n date: string;\n};\n\nexport type TradesResponse = {\n trades: Trade[];\n};\n"]}
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 interface Position {\n id: number;\n symbol: string;\n side: Side;\n size: number;\n price: number;\n orderStatus: Status;\n markPrice: number;\n unrealisedPnl: number;\n realisedPnl: number;\n liquidationPrice: number;\n fundingRate: string;\n date: string;\n}\n\nexport type Trade = {\n id: number;\n side: Side;\n size: string;\n price: number;\n date: string;\n txId: string;\n};\n\nexport type TradesResponse = {\n trades: Trade[];\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { CollateralAccountListResponse, CollateralAccountResponse } from '../types';
1
+ import { GetMarginAccountParams, GetMarginAccountsParams, MarginAccountEntity } from '../types';
2
2
  import RestClient from './rest';
3
3
  export default class AccountClient extends RestClient {
4
4
  /**
@@ -8,38 +8,23 @@ export default class AccountClient extends RestClient {
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
- * @param {string} address - The Ethereum address for which collateral account data is being requested.
12
- * @param {number} [limit] - An optional limit on the number of collateral accounts to retrieve. If not specified,
13
- * all available collateral accounts for the address will be returned.
14
- * @returns {Promise<CollateralAccountListResponse>} A promise that resolves to the response containing the collateral
11
+ * @param {GetMarginAccountsParams} getMarginAccountsParams
12
+ * @returns {Promise<MarginAccountEntity[]>} A promise that resolves to the response containing the margin
15
13
  * account data.
16
14
  * @memberof account
17
- *
18
- * @example
19
- * // Fetch all collateral accounts for a specific address
20
- * const accounts = await account.getCollateralAccounts('0x123...');
21
- *
22
- * @example
23
- * // Fetch a limited number of collateral accounts for a specific address
24
- * const limitedAccounts = await account.getCollateralAccounts('0x123...', 5);
25
- */
26
- getCollateralAccounts(address: string, limit?: number): Promise<CollateralAccountListResponse>;
15
+ * */
16
+ getCollateralAccounts(getMarginAccountsParams: GetMarginAccountsParams): Promise<MarginAccountEntity[]>;
27
17
  /**
28
18
  * Asynchronously retrieves details of a specific collateral account for a given Ethereum address.
29
19
  *
30
20
  * This method sends a request to the API to obtain detailed information about a specific collateral account
31
21
  * associated with the provided Ethereum address. The account is identified using the collateral account number.
32
22
  *
33
- * @param {string} address - The Ethereum address associated with the collateral account.
34
- * @param {number} collateralAccountNumber - The number identifying the specific collateral account.
35
- * @returns {Promise<CollateralAccountResponse>} A promise that resolves to the response containing the detailed
36
- * information of the specified collateral account.
23
+ * @param {GetMarginAccountParams} getMarginAccountParams
24
+ * @returns {Promise<MarginAccountEntity>} A promise that resolves to the response containing the detailed
25
+ * information of the specified margin account.
37
26
  * @memberof account
38
- *
39
- * @example
40
- * // Fetch details of a specific collateral account by its number for a given address
41
- * const accountDetails = await account.getCollateralAccount('0x123...', 1);
42
27
  */
43
- getCollateralAccount(address: string, collateralAccountNumber: number): Promise<CollateralAccountResponse>;
28
+ getCollateralAccount(getMarginAccountParams: GetMarginAccountParams): Promise<MarginAccountEntity>;
44
29
  }
45
30
  //# 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,6BAA6B,EAC7B,yBAAyB,EAC1B,MAAM,UAAU,CAAC;AAClB,OAAO,UAAU,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD;;;;;;;;;;;;;;;;;;;;;OAqBG;IAEG,qBAAqB,CACzB,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,6BAA6B,CAAC;IAKzC;;;;;;;;;;;;;;;OAeG;IAEG,oBAAoB,CACxB,OAAO,EAAE,MAAM,EACf,uBAAuB,EAAE,MAAM,GAC9B,OAAO,CAAC,yBAAyB,CAAC;CAItC"}
1
+ {"version":3,"file":"account.d.ts","sourceRoot":"/","sources":["clients/modules/account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAClB,OAAO,UAAU,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD;;;;;;;;;;;SAWK;IAEC,qBAAqB,CACzB,uBAAuB,EAAE,uBAAuB,GAC/C,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAKjC;;;;;;;;;;OAUG;IAEG,oBAAoB,CACxB,sBAAsB,EAAE,sBAAsB,GAC7C,OAAO,CAAC,mBAAmB,CAAC;CAIhC"}
@@ -1,4 +1,4 @@
1
- import { CandlesResolution, MarketCandlesResponse, MarketListResponse, TradesResponse } from '../types';
1
+ import { CandlesResolution, GetMarketsParams, MarketCandlesResponse, MarketEntity, TradesResponse } from '../types';
2
2
  import RestClient from './rest';
3
3
  export default class MarketsClient extends RestClient {
4
4
  /**
@@ -7,8 +7,8 @@ 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 {string} [market] - The specific market ticker identifier for which data is requested. This parameter is optional.
11
- * @returns {Promise<MarketListResponse>} A promise that resolves to the response containing market data.
10
+ * @param {GetMarketsParams} [getMarketsParams] - The specific market ticker identifier for which data is requested. This parameter is optional.
11
+ * @returns {Promise<MarketEntity[]>} A promise that resolves to the response containing market data.
12
12
  * @memberof MarketsClient
13
13
  *
14
14
  * @example
@@ -19,14 +19,14 @@ 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(market?: string): Promise<MarketListResponse>;
22
+ getMarkets(getMarketsParams: GetMarketsParams): Promise<MarketEntity[]>;
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 {string} market - The market identifier for which candlestick data is to be retrieved.
29
+ * @param {number} marketId - The market identifier for which candlestick data is to be retrieved.
30
30
  * @param {CandlesResolution} resolution - The granularity of the candlestick data (e.g., '1MIN', '5MIN', '1HR').
31
31
  * @param {string|null} [fromISO] - The start time for the range of candlestick data in ISO 8601 format. Optional.
32
32
  * @param {string|null} [toISO] - The end time for the range of candlestick data in ISO 8601 format. Optional.
@@ -37,7 +37,7 @@ export default class MarketsClient extends RestClient {
37
37
  * @example
38
38
  * const marketCandles = await market.getMarketCandles('BTC-USD', '1HR', '2023-01-01T00:00:00Z', '2023-01-02T00:00:00Z');
39
39
  */
40
- getMarketCandles(market: string, resolution: CandlesResolution, fromISO?: string | null, toISO?: string | null, limit?: number | null): Promise<MarketCandlesResponse>;
41
- getPerpetualMarketTrades(market: string, limit?: number | null): Promise<TradesResponse>;
40
+ getMarketCandles(marketId: MarketEntity['id'], resolution: CandlesResolution, fromISO?: string | null, toISO?: string | null, limit?: number | null): Promise<MarketCandlesResponse>;
41
+ getPerpetualMarketTrades(marketId: number, limit?: number | null): Promise<TradesResponse>;
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,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACf,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,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAK9D;;;;;;;;;;;;;;;;OAgBG;IAEG,gBAAgB,CACpB,MAAM,EAAE,MAAM,EACd,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,wBAAwB,CAC5B,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GACpB,OAAO,CAAC,cAAc,CAAC;CAM3B"}
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,EACZ,cAAc,EACf,MAAM,UAAU,CAAC;AAClB,OAAO,UAAU,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD;;;;;;;;;;;;;;;;;OAiBG;IAEG,UAAU,CACd,gBAAgB,EAAE,gBAAgB,GACjC,OAAO,CAAC,YAAY,EAAE,CAAC;IAK1B;;;;;;;;;;;;;;;;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,wBAAwB,CAC5B,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GACpB,OAAO,CAAC,cAAc,CAAC;CAM3B"}
@@ -24,47 +24,49 @@ export interface Candle {
24
24
  export interface MarketCandlesResponse {
25
25
  candles: Candle[];
26
26
  }
27
- export interface MarketEntry {
27
+ export type MarketEntity = {
28
28
  id: number;
29
29
  ticker: string;
30
- instrumentName: string;
31
- instrumentType: string;
32
30
  underlyingAsset: string;
33
- quoteAsset: string;
31
+ quoteToken: string;
34
32
  markPrice: number;
35
- indexPrice: number;
36
33
  isActive: boolean;
37
34
  maxLeverage: number;
38
35
  volume24H: number;
39
36
  priceChange24H: number;
40
- priceChange24HPercentage: string;
41
- openInterest: string;
42
- fundingRate: string;
43
- priceStep: number;
44
- amountStep: number;
45
- minOrderValue: number;
46
- }
47
- export interface MarketListResponse {
48
- [key: string]: MarketEntry;
49
- }
50
- export interface CollateralAccount {
51
- id: number;
52
- name: string;
53
- equity: number;
54
- balance: number;
55
- marginRatio: string;
56
- collaterals: Collateral[];
57
- positions: Position[];
58
- }
59
- export interface Collateral {
60
- collateralAsset: string;
61
- balance: number;
62
- availableBalance: number;
63
- withdrawableBalance: number;
64
- collateralValue: number;
65
- }
37
+ priceChange24HPercentage: number;
38
+ openInterest: number;
39
+ fundingRate: number;
40
+ description: string;
41
+ tickSizeDecimals: number;
42
+ };
43
+ export type GetMarketsParams = {
44
+ id?: number;
45
+ };
66
46
  export type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';
67
47
  export type Side = 'LONG' | 'SHORT';
48
+ export type GetMarginAccountsParams = {
49
+ address: string;
50
+ limit?: number;
51
+ };
52
+ export type GetMarginAccountParams = {
53
+ address: string;
54
+ marginAccountNumber: number;
55
+ };
56
+ export type MarginAccountEntity = {
57
+ id: number;
58
+ name: string;
59
+ marginRatioHealth: 'danger' | 'healthy' | 'warning';
60
+ marginRatioPercentage: number;
61
+ totalBalance: number;
62
+ totalBalanceUnderlyingAsset: string;
63
+ collaterals: {
64
+ token: string;
65
+ percentage: number;
66
+ balance: number;
67
+ balanceRUSD: number;
68
+ }[];
69
+ };
68
70
  export interface Position {
69
71
  id: number;
70
72
  symbol: string;
@@ -79,26 +81,13 @@ export interface Position {
79
81
  fundingRate: string;
80
82
  date: string;
81
83
  }
82
- export interface CollateralAccountListResponse {
83
- address: string;
84
- collateralAccounts: CollateralAccount[];
85
- }
86
- export interface CollateralAccountResponse {
87
- address: string;
88
- id: number;
89
- name: string;
90
- equity: number;
91
- balance: number;
92
- marginRatio: string;
93
- collaterals: Collateral[];
94
- positions: Position[];
95
- }
96
84
  export type Trade = {
97
85
  id: number;
98
86
  side: Side;
99
87
  size: string;
100
88
  price: number;
101
89
  date: string;
90
+ txId: string;
102
91
  };
103
92
  export type TradesResponse = {
104
93
  trades: Trade[];
@@ -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,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB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AAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;IACpD,qBAAqB,EAAE,MAAM,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,2BAA2B,EAAE,MAAM,CAAC;IACpC,WAAW,EAAE;QACX,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;KACrB,EAAE,CAAC;CACL,CAAC;AAEF,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,KAAK,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/api-sdk",
3
- "version": "0.6.3",
3
+ "version": "0.7.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": "12b257e116bed35f8bb69fcd44e5619715228906"
39
+ "gitHead": "0a81b19c8d03ac890f08059f697aa4d907ad39e0"
40
40
  }
@@ -1,6 +1,7 @@
1
1
  import {
2
- CollateralAccountListResponse,
3
- CollateralAccountResponse,
2
+ GetMarginAccountParams,
3
+ GetMarginAccountsParams,
4
+ MarginAccountEntity,
4
5
  } from '../types';
5
6
  import RestClient from './rest';
6
7
 
@@ -12,28 +13,17 @@ export default class AccountClient extends RestClient {
12
13
  * based on the provided Ethereum address. An optional limit can be specified to control the number of
13
14
  * collateral accounts returned in the response.
14
15
  *
15
- * @param {string} address - The Ethereum address for which collateral account data is being requested.
16
- * @param {number} [limit] - An optional limit on the number of collateral accounts to retrieve. If not specified,
17
- * all available collateral accounts for the address will be returned.
18
- * @returns {Promise<CollateralAccountListResponse>} A promise that resolves to the response containing the collateral
16
+ * @param {GetMarginAccountsParams} getMarginAccountsParams
17
+ * @returns {Promise<MarginAccountEntity[]>} A promise that resolves to the response containing the margin
19
18
  * account data.
20
19
  * @memberof account
21
- *
22
- * @example
23
- * // Fetch all collateral accounts for a specific address
24
- * const accounts = await account.getCollateralAccounts('0x123...');
25
- *
26
- * @example
27
- * // Fetch a limited number of collateral accounts for a specific address
28
- * const limitedAccounts = await account.getCollateralAccounts('0x123...', 5);
29
- */
20
+ * */
30
21
 
31
22
  async getCollateralAccounts(
32
- address: string,
33
- limit?: number,
34
- ): Promise<CollateralAccountListResponse> {
35
- const uri = `/api/accounts/${address}`;
36
- return this.get(uri, { limit });
23
+ getMarginAccountsParams: GetMarginAccountsParams,
24
+ ): Promise<MarginAccountEntity[]> {
25
+ const uri = `/api/accounts/${getMarginAccountsParams.address}`;
26
+ return this.get(uri, { limit: getMarginAccountsParams.limit });
37
27
  }
38
28
 
39
29
  /**
@@ -42,22 +32,16 @@ export default class AccountClient extends RestClient {
42
32
  * This method sends a request to the API to obtain detailed information about a specific collateral account
43
33
  * associated with the provided Ethereum address. The account is identified using the collateral account number.
44
34
  *
45
- * @param {string} address - The Ethereum address associated with the collateral account.
46
- * @param {number} collateralAccountNumber - The number identifying the specific collateral account.
47
- * @returns {Promise<CollateralAccountResponse>} A promise that resolves to the response containing the detailed
48
- * information of the specified collateral account.
35
+ * @param {GetMarginAccountParams} getMarginAccountParams
36
+ * @returns {Promise<MarginAccountEntity>} A promise that resolves to the response containing the detailed
37
+ * information of the specified margin account.
49
38
  * @memberof account
50
- *
51
- * @example
52
- * // Fetch details of a specific collateral account by its number for a given address
53
- * const accountDetails = await account.getCollateralAccount('0x123...', 1);
54
39
  */
55
40
 
56
41
  async getCollateralAccount(
57
- address: string,
58
- collateralAccountNumber: number,
59
- ): Promise<CollateralAccountResponse> {
60
- const uri = `/api/accounts/${address}/collateralAccount/${collateralAccountNumber}`;
42
+ getMarginAccountParams: GetMarginAccountParams,
43
+ ): Promise<MarginAccountEntity> {
44
+ const uri = `/api/accounts/${getMarginAccountParams.address}/collateralAccount/${getMarginAccountParams.marginAccountNumber}`;
61
45
  return this.get(uri);
62
46
  }
63
47
  }
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  CandlesResolution,
3
+ GetMarketsParams,
3
4
  MarketCandlesResponse,
4
- MarketListResponse,
5
+ MarketEntity,
5
6
  TradesResponse,
6
7
  } from '../types';
7
8
  import RestClient from './rest';
@@ -13,8 +14,8 @@ export default class MarketsClient extends RestClient {
13
14
  * This method makes a request to the API to fetch data for markets. If a specific market is provided as a parameter,
14
15
  * it fetches data for that particular market; otherwise, it fetches data for all available markets.
15
16
  *
16
- * @param {string} [market] - The specific market ticker identifier for which data is requested. This parameter is optional.
17
- * @returns {Promise<MarketListResponse>} A promise that resolves to the response containing market data.
17
+ * @param {GetMarketsParams} [getMarketsParams] - The specific market ticker identifier for which data is requested. This parameter is optional.
18
+ * @returns {Promise<MarketEntity[]>} A promise that resolves to the response containing market data.
18
19
  * @memberof MarketsClient
19
20
  *
20
21
  * @example
@@ -26,9 +27,11 @@ export default class MarketsClient extends RestClient {
26
27
  * const specificMarketData = await market.getMarkets('ETH-USDC');
27
28
  */
28
29
 
29
- async getMarkets(market?: string): Promise<MarketListResponse> {
30
+ async getMarkets(
31
+ getMarketsParams: GetMarketsParams,
32
+ ): Promise<MarketEntity[]> {
30
33
  const uri = '/api/markets';
31
- return this.get(uri, { ticker: market });
34
+ return this.get(uri, { id: getMarketsParams.id });
32
35
  }
33
36
 
34
37
  /**
@@ -37,7 +40,7 @@ export default class MarketsClient extends RestClient {
37
40
  * This method fetches historical candlestick (or OHLC - Open, High, Low, Close) data for a given market.
38
41
  * The data can be filtered by time range (fromISO and toISO) and resolution.
39
42
  *
40
- * @param {string} market - The market identifier for which candlestick data is to be retrieved.
43
+ * @param {number} marketId - The market identifier for which candlestick data is to be retrieved.
41
44
  * @param {CandlesResolution} resolution - The granularity of the candlestick data (e.g., '1MIN', '5MIN', '1HR').
42
45
  * @param {string|null} [fromISO] - The start time for the range of candlestick data in ISO 8601 format. Optional.
43
46
  * @param {string|null} [toISO] - The end time for the range of candlestick data in ISO 8601 format. Optional.
@@ -50,13 +53,13 @@ export default class MarketsClient extends RestClient {
50
53
  */
51
54
 
52
55
  async getMarketCandles(
53
- market: string,
56
+ marketId: MarketEntity['id'],
54
57
  resolution: CandlesResolution,
55
58
  fromISO?: string | null,
56
59
  toISO?: string | null,
57
60
  limit?: number | null,
58
61
  ): Promise<MarketCandlesResponse> {
59
- const uri = `/api/markets/candles/${market}`;
62
+ const uri = `/api/markets/candles/${marketId}`;
60
63
  return this.get(uri, {
61
64
  resolution,
62
65
  fromISO,
@@ -66,10 +69,10 @@ export default class MarketsClient extends RestClient {
66
69
  }
67
70
 
68
71
  async getPerpetualMarketTrades(
69
- market: string,
72
+ marketId: number,
70
73
  limit?: number | null,
71
74
  ): Promise<TradesResponse> {
72
- const uri = `/api/trades/${market}`;
75
+ const uri = `/api/trades/${marketId}`;
73
76
  return this.get(uri, {
74
77
  limit,
75
78
  });
@@ -30,54 +30,56 @@ export interface MarketCandlesResponse {
30
30
 
31
31
  // -- Markets --
32
32
 
33
- export interface MarketEntry {
33
+ export type MarketEntity = {
34
34
  id: number;
35
35
  ticker: string;
36
- instrumentName: string;
37
- instrumentType: string;
38
36
  underlyingAsset: string;
39
- quoteAsset: string;
37
+ quoteToken: string;
40
38
  markPrice: number;
41
- indexPrice: number;
42
39
  isActive: boolean;
43
40
  maxLeverage: number;
44
41
  volume24H: number;
45
42
  priceChange24H: number;
46
- priceChange24HPercentage: string;
47
- openInterest: string;
48
- fundingRate: string;
49
- priceStep: number;
50
- amountStep: number;
51
- minOrderValue: number;
52
- }
53
-
54
- export interface MarketListResponse {
55
- [key: string]: MarketEntry;
56
- }
43
+ priceChange24HPercentage: number;
44
+ openInterest: number;
45
+ fundingRate: number;
46
+ description: string;
47
+ tickSizeDecimals: number;
48
+ };
57
49
 
50
+ export type GetMarketsParams = {
51
+ id?: number;
52
+ };
58
53
  // -- Account --
59
54
 
60
- export interface CollateralAccount {
61
- id: number;
62
- name: string;
63
- equity: number;
64
- balance: number;
65
- marginRatio: string;
66
- collaterals: Collateral[];
67
- positions: Position[];
68
- }
69
-
70
- export interface Collateral {
71
- collateralAsset: string;
72
- balance: number;
73
- availableBalance: number;
74
- withdrawableBalance: number;
75
- collateralValue: number;
76
- }
77
-
78
55
  export type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';
79
56
  export type Side = 'LONG' | 'SHORT';
80
57
 
58
+ export type GetMarginAccountsParams = {
59
+ address: string;
60
+ limit?: number;
61
+ };
62
+
63
+ export type GetMarginAccountParams = {
64
+ address: string;
65
+ marginAccountNumber: number;
66
+ };
67
+
68
+ export type MarginAccountEntity = {
69
+ id: number;
70
+ name: string;
71
+ marginRatioHealth: 'danger' | 'healthy' | 'warning';
72
+ marginRatioPercentage: number;
73
+ totalBalance: number;
74
+ totalBalanceUnderlyingAsset: string;
75
+ collaterals: {
76
+ token: string;
77
+ percentage: number;
78
+ balance: number;
79
+ balanceRUSD: number;
80
+ }[];
81
+ };
82
+
81
83
  export interface Position {
82
84
  id: number;
83
85
  symbol: string;
@@ -93,28 +95,13 @@ export interface Position {
93
95
  date: string;
94
96
  }
95
97
 
96
- export interface CollateralAccountListResponse {
97
- address: string;
98
- collateralAccounts: CollateralAccount[];
99
- }
100
-
101
- export interface CollateralAccountResponse {
102
- address: string;
103
- id: number;
104
- name: string;
105
- equity: number;
106
- balance: number;
107
- marginRatio: string;
108
- collaterals: Collateral[];
109
- positions: Position[];
110
- }
111
-
112
98
  export type Trade = {
113
99
  id: number;
114
100
  side: Side;
115
101
  size: string;
116
102
  price: number;
117
103
  date: string;
104
+ txId: string;
118
105
  };
119
106
 
120
107
  export type TradesResponse = {