@reyaxyz/api-sdk 0.7.0 → 0.9.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.
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
15
  };
@@ -11,13 +22,23 @@ var account_1 = __importDefault(require("./modules/account"));
11
22
  * @description Client for API
12
23
  */
13
24
  var ApiClient = /** @class */ (function () {
14
- function ApiClient(config, apiTimeout) {
15
- this.config = config;
16
- this.apiTimeout = apiTimeout !== null && apiTimeout !== void 0 ? apiTimeout : constants_1.API_TIMEOUT;
17
- this._markets = new markets_1.default(config.restEndpoint);
18
- this._account = new account_1.default(config.restEndpoint);
25
+ function ApiClient(config) {
26
+ this.apiEndpoint = config.production ? constants_1.API_PRODUCTION : constants_1.API_TESTNET;
27
+ ApiClient.config = __assign(__assign({}, ApiClient.config), config);
28
+ this._markets = new markets_1.default(this.apiEndpoint);
29
+ this._account = new account_1.default(this.apiEndpoint);
19
30
  }
20
- Object.defineProperty(ApiClient.prototype, "markets", {
31
+ ApiClient.configure = function (config) {
32
+ ApiClient.config = config;
33
+ ApiClient.instance = new ApiClient(config);
34
+ };
35
+ ApiClient.getInstance = function () {
36
+ if (!ApiClient.instance) {
37
+ throw new Error('ApiClient is not configured. Please configure it before using.');
38
+ }
39
+ return ApiClient.instance;
40
+ };
41
+ Object.defineProperty(ApiClient, "markets", {
21
42
  /**
22
43
  * Provides access to the MarketsClient instance.
23
44
  * This getter allows for interacting with market-related API functionalities.
@@ -26,12 +47,12 @@ var ApiClient = /** @class */ (function () {
26
47
  * @memberof ApiClient
27
48
  */
28
49
  get: function () {
29
- return this._markets;
50
+ return ApiClient.getInstance()._markets;
30
51
  },
31
52
  enumerable: false,
32
53
  configurable: true
33
54
  });
34
- Object.defineProperty(ApiClient.prototype, "account", {
55
+ Object.defineProperty(ApiClient, "account", {
35
56
  /**
36
57
  * Provides access to the AccountClient instance.
37
58
  * This getter allows for interacting with account-related API functionalities.
@@ -40,11 +61,15 @@ var ApiClient = /** @class */ (function () {
40
61
  * @memberof ApiClient
41
62
  */
42
63
  get: function () {
43
- return this._account;
64
+ return ApiClient.getInstance()._account;
44
65
  },
45
66
  enumerable: false,
46
67
  configurable: true
47
68
  });
69
+ ApiClient.config = {
70
+ production: true, // default value
71
+ timeout: constants_1.API_TIMEOUT, // default value, e.g., 5000 milliseconds
72
+ };
48
73
  return ApiClient;
49
74
  }());
50
75
  exports.ApiClient = ApiClient;
@@ -1 +1 @@
1
- {"version":3,"file":"api-client.js","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":";;;;;;AAAA,iDAAiE;AACjE,8DAA8C;AAC9C,8DAA8C;AAE9C;;GAEG;AACH;IAME,mBAAY,MAAqB,EAAE,UAAmB;QACpD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,uBAAW,CAAC;QAE5C,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAa,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACvD,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAa,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACzD,CAAC;IASD,sBAAI,8BAAO;QAPX;;;;;;WAMG;aACH;YACE,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;;;OAAA;IASD,sBAAI,8BAAO;QAPX;;;;;;WAMG;aACH;YACE,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;;;OAAA;IACH,gBAAC;AAAD,CAAC,AAnCD,IAmCC;AAnCY,8BAAS","sourcesContent":["import { ServiceConfig, API_TIMEOUT } from './helpers/constants';\nimport MarketsClient from './modules/markets';\nimport AccountClient from './modules/account';\n\n/**\n * @description Client for API\n */\nexport class ApiClient {\n public readonly config: ServiceConfig;\n readonly apiTimeout: number;\n readonly _markets: MarketsClient;\n readonly _account: AccountClient;\n\n constructor(config: ServiceConfig, apiTimeout?: number) {\n this.config = config;\n this.apiTimeout = apiTimeout ?? API_TIMEOUT;\n\n this._markets = new MarketsClient(config.restEndpoint);\n this._account = new AccountClient(config.restEndpoint);\n }\n\n /**\n * Provides access to the MarketsClient instance.\n * This getter allows for interacting with market-related API functionalities.\n *\n * @returns {MarketsClient} An instance of MarketsClient for market-related operations.\n * @memberof ApiClient\n */\n get markets(): MarketsClient {\n return this._markets;\n }\n\n /**\n * Provides access to the AccountClient instance.\n * This getter allows for interacting with account-related API functionalities.\n *\n * @returns {AccountClient} An instance of AccountClient for account-related operations.\n * @memberof ApiClient\n */\n get account(): AccountClient {\n return this._account;\n }\n}\n"]}
1
+ {"version":3,"file":"api-client.js","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAK6B;AAC7B,8DAA8C;AAC9C,8DAA8C;AAE9C;;GAEG;AACH;IAUE,mBAAoB,MAAqB;QACvC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,0BAAc,CAAC,CAAC,CAAC,uBAAW,CAAC;QACpE,SAAS,CAAC,MAAM,yBAAQ,SAAS,CAAC,MAAM,GAAK,MAAM,CAAE,CAAC;QACtD,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACtD,CAAC;IAEa,mBAAS,GAAvB,UAAwB,MAAqB;QAC3C,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC;QAC1B,SAAS,CAAC,QAAQ,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IAEc,qBAAW,GAA1B;QACE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;QACJ,CAAC;QACD,OAAO,SAAS,CAAC,QAAQ,CAAC;IAC5B,CAAC;IASD,sBAAkB,oBAAO;QAPzB;;;;;;WAMG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC;QAC1C,CAAC;;;OAAA;IASD,sBAAkB,oBAAO;QAPzB;;;;;;WAMG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC;QAC1C,CAAC;;;OAAA;IAjDc,gBAAM,GAAkB;QACrC,UAAU,EAAE,IAAI,EAAE,gBAAgB;QAClC,OAAO,EAAE,uBAAW,EAAE,yCAAyC;KAChE,CAAC;IA+CJ,gBAAC;CAAA,AApDD,IAoDC;AApDY,8BAAS","sourcesContent":["import {\n ServiceConfig,\n API_TIMEOUT,\n API_TESTNET,\n API_PRODUCTION,\n} from './helpers/constants';\nimport MarketsClient from './modules/markets';\nimport AccountClient from './modules/account';\n\n/**\n * @description Client for API\n */\nexport class ApiClient {\n private static instance: ApiClient;\n private static config: ServiceConfig = {\n production: true, // default value\n timeout: API_TIMEOUT, // default value, e.g., 5000 milliseconds\n };\n private readonly apiEndpoint: string;\n private readonly _markets: MarketsClient;\n private readonly _account: AccountClient;\n\n private constructor(config: ServiceConfig) {\n this.apiEndpoint = config.production ? API_PRODUCTION : API_TESTNET;\n ApiClient.config = { ...ApiClient.config, ...config };\n this._markets = new MarketsClient(this.apiEndpoint);\n this._account = new AccountClient(this.apiEndpoint);\n }\n\n public static configure(config: ServiceConfig): void {\n ApiClient.config = config;\n ApiClient.instance = new ApiClient(config);\n }\n\n private static getInstance(): ApiClient {\n if (!ApiClient.instance) {\n throw new Error(\n 'ApiClient is not configured. Please configure it before using.',\n );\n }\n return ApiClient.instance;\n }\n\n /**\n * Provides access to the MarketsClient instance.\n * This getter allows for interacting with market-related API functionalities.\n *\n * @returns {MarketsClient} An instance of MarketsClient for market-related operations.\n * @memberof ApiClient\n */\n public static get markets(): MarketsClient {\n return ApiClient.getInstance()._markets;\n }\n\n /**\n * Provides access to the AccountClient instance.\n * This getter allows for interacting with account-related API functionalities.\n *\n * @returns {AccountClient} An instance of AccountClient for account-related operations.\n * @memberof ApiClient\n */\n public static get account(): AccountClient {\n return ApiClient.getInstance()._account;\n }\n}\n"]}
@@ -1,13 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ServiceConfig = exports.API_TIMEOUT = void 0;
3
+ exports.API_TESTNET = exports.API_PRODUCTION = exports.API_TIMEOUT = void 0;
4
4
  exports.API_TIMEOUT = 2500;
5
- var ServiceConfig = /** @class */ (function () {
6
- function ServiceConfig(restEndpoint, websocketEndpoint) {
7
- this.restEndpoint = restEndpoint;
8
- this.websocketEndpoint = websocketEndpoint;
9
- }
10
- return ServiceConfig;
11
- }());
12
- exports.ServiceConfig = ServiceConfig;
5
+ exports.API_PRODUCTION = 'https://m8mjgmqmte.eu-central-1.awsapprunner.com';
6
+ exports.API_TESTNET = 'https://m8mjgmqmte.eu-central-1.awsapprunner.com';
13
7
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"/","sources":["clients/helpers/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAW,IAAI,CAAC;AAExC;IAIE,uBAAY,YAAoB,EAAE,iBAAyB;QACzD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAC7C,CAAC;IACH,oBAAC;AAAD,CAAC,AARD,IAQC;AARY,sCAAa","sourcesContent":["export const API_TIMEOUT: number = 2500;\n\nexport class ServiceConfig {\n public restEndpoint: string;\n public websocketEndpoint: string;\n\n constructor(restEndpoint: string, websocketEndpoint: string) {\n this.restEndpoint = restEndpoint;\n this.websocketEndpoint = websocketEndpoint;\n }\n}\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"/","sources":["clients/helpers/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAW,IAAI,CAAC;AAO3B,QAAA,cAAc,GACzB,kDAAkD,CAAC;AAExC,QAAA,WAAW,GACtB,kDAAkD,CAAC","sourcesContent":["export const API_TIMEOUT: number = 2500;\n\nexport interface ServiceConfig {\n production?: boolean; // Base URL for the REST API\n timeout?: number; // Optional timeout for API requests\n}\n\nexport const API_PRODUCTION: string =\n 'https://m8mjgmqmte.eu-central-1.awsapprunner.com';\n\nexport const API_TESTNET: string =\n 'https://m8mjgmqmte.eu-central-1.awsapprunner.com';\n"]}
@@ -67,17 +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 {GetMarginAccountsParams} getMarginAccountsParams
70
+ * @param {GetMarginAccountsParams} params
71
71
  * @returns {Promise<MarginAccountEntity[]>} A promise that resolves to the response containing the margin
72
72
  * account data.
73
73
  * @memberof account
74
74
  * */
75
- AccountClient.prototype.getCollateralAccounts = function (getMarginAccountsParams) {
75
+ AccountClient.prototype.getMarginAccounts = function (params) {
76
76
  return __awaiter(this, void 0, void 0, function () {
77
77
  var uri;
78
78
  return __generator(this, function (_a) {
79
- uri = "/api/accounts/".concat(getMarginAccountsParams.address);
80
- return [2 /*return*/, this.get(uri, { limit: getMarginAccountsParams.limit })];
79
+ uri = "/api/accounts/".concat(params.address);
80
+ return [2 /*return*/, this.get(uri, { limit: params.limit })];
81
81
  });
82
82
  });
83
83
  };
@@ -87,16 +87,16 @@ var AccountClient = /** @class */ (function (_super) {
87
87
  * This method sends a request to the API to obtain detailed information about a specific collateral account
88
88
  * associated with the provided Ethereum address. The account is identified using the collateral account number.
89
89
  *
90
- * @param {GetMarginAccountParams} getMarginAccountParams
90
+ * @param {GetMarginAccountParams} params
91
91
  * @returns {Promise<MarginAccountEntity>} 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.getCollateralAccount = function (getMarginAccountParams) {
95
+ AccountClient.prototype.getCollateralAccount = 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(getMarginAccountParams.address, "/collateralAccount/").concat(getMarginAccountParams.marginAccountNumber);
99
+ uri = "/api/accounts/".concat(params.address, "/collateralAccount/").concat(params.marginAccountNumber);
100
100
  return [2 /*return*/, this.get(uri)];
101
101
  });
102
102
  });
@@ -1 +1 @@
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"]}
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,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,4CAAoB,GAA1B,UACE,MAA8B;;;;gBAExB,GAAG,GAAG,wBAAiB,MAAM,CAAC,OAAO,gCAAsB,MAAM,CAAC,mBAAmB,CAAE,CAAC;gBAC9F,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} params\n * @returns {Promise<MarginAccountEntity[]>} 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<MarginAccountEntity[]> {\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<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 params: GetMarginAccountParams,\n ): Promise<MarginAccountEntity> {\n const uri = `/api/accounts/${params.address}/collateralAccount/${params.marginAccountNumber}`;\n return this.get(uri);\n }\n}\n"]}
@@ -66,7 +66,7 @@ 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} [getMarketsParams] - The specific market ticker identifier for which data is requested. This parameter is optional.
69
+ * @param {GetMarketsParams} [params] - The specific market ticker identifier for which data is requested. This parameter is optional.
70
70
  * @returns {Promise<MarketEntity[]>} A promise that resolves to the response containing market data.
71
71
  * @memberof MarketsClient
72
72
  *
@@ -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 (getMarketsParams) {
81
+ MarketsClient.prototype.getMarkets = function (params) {
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, { id: getMarketsParams.id })];
86
+ return [2 /*return*/, this.get(uri, { id: params.id })];
87
87
  });
88
88
  });
89
89
  };
@@ -1 +1 @@
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
+ {"version":3,"file":"markets.js","sourceRoot":"/","sources":["clients/modules/markets.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,gDAAgC;AAEhC;IAA2C,iCAAU;IAArD;;IAoEA,CAAC;IAnEC;;;;;;;;;;;;;;;;;OAiBG;IAEG,kCAAU,GAAhB,UAAiB,MAAwB;;;;gBACjC,GAAG,GAAG,cAAc,CAAC;gBAC3B,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,EAAC;;;KACzC;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,AApED,CAA2C,cAAU,GAoEpD","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} [params] - 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(params: GetMarketsParams): Promise<MarketEntity[]> {\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 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"]}
@@ -5,11 +5,14 @@ import AccountClient from './modules/account';
5
5
  * @description Client for API
6
6
  */
7
7
  export declare class ApiClient {
8
- readonly config: ServiceConfig;
9
- readonly apiTimeout: number;
10
- readonly _markets: MarketsClient;
11
- readonly _account: AccountClient;
12
- constructor(config: ServiceConfig, apiTimeout?: number);
8
+ private static instance;
9
+ private static config;
10
+ private readonly apiEndpoint;
11
+ private readonly _markets;
12
+ private readonly _account;
13
+ private constructor();
14
+ static configure(config: ServiceConfig): void;
15
+ private static getInstance;
13
16
  /**
14
17
  * Provides access to the MarketsClient instance.
15
18
  * This getter allows for interacting with market-related API functionalities.
@@ -17,7 +20,7 @@ export declare class ApiClient {
17
20
  * @returns {MarketsClient} An instance of MarketsClient for market-related operations.
18
21
  * @memberof ApiClient
19
22
  */
20
- get markets(): MarketsClient;
23
+ static get markets(): MarketsClient;
21
24
  /**
22
25
  * Provides access to the AccountClient instance.
23
26
  * This getter allows for interacting with account-related API functionalities.
@@ -25,6 +28,6 @@ export declare class ApiClient {
25
28
  * @returns {AccountClient} An instance of AccountClient for account-related operations.
26
29
  * @memberof ApiClient
27
30
  */
28
- get account(): AccountClient;
31
+ static get account(): AccountClient;
29
32
  }
30
33
  //# sourceMappingURL=api-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-client.d.ts","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAe,MAAM,qBAAqB,CAAC;AACjE,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAE9C;;GAEG;AACH,qBAAa,SAAS;IACpB,SAAgB,MAAM,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;gBAErB,MAAM,EAAE,aAAa,EAAE,UAAU,CAAC,EAAE,MAAM;IAQtD;;;;;;OAMG;IACH,IAAI,OAAO,IAAI,aAAa,CAE3B;IAED;;;;;;OAMG;IACH,IAAI,OAAO,IAAI,aAAa,CAE3B;CACF"}
1
+ {"version":3,"file":"api-client.d.ts","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAId,MAAM,qBAAqB,CAAC;AAC7B,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAE9C;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAY;IACnC,OAAO,CAAC,MAAM,CAAC,MAAM,CAGnB;IACF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;IACzC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;IAEzC,OAAO;WAOO,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAKpD,OAAO,CAAC,MAAM,CAAC,WAAW;IAS1B;;;;;;OAMG;IACH,WAAkB,OAAO,IAAI,aAAa,CAEzC;IAED;;;;;;OAMG;IACH,WAAkB,OAAO,IAAI,aAAa,CAEzC;CACF"}
@@ -1,7 +1,8 @@
1
1
  export declare const API_TIMEOUT: number;
2
- export declare class ServiceConfig {
3
- restEndpoint: string;
4
- websocketEndpoint: string;
5
- constructor(restEndpoint: string, websocketEndpoint: string);
2
+ export interface ServiceConfig {
3
+ production?: boolean;
4
+ timeout?: number;
6
5
  }
6
+ export declare const API_PRODUCTION: string;
7
+ export declare const API_TESTNET: string;
7
8
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"/","sources":["clients/helpers/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,EAAE,MAAa,CAAC;AAExC,qBAAa,aAAa;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;gBAErB,YAAY,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM;CAI5D"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"/","sources":["clients/helpers/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,EAAE,MAAa,CAAC;AAExC,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,cAAc,EAAE,MACuB,CAAC;AAErD,eAAO,MAAM,WAAW,EAAE,MAC0B,CAAC"}
@@ -8,23 +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 {GetMarginAccountsParams} getMarginAccountsParams
11
+ * @param {GetMarginAccountsParams} params
12
12
  * @returns {Promise<MarginAccountEntity[]>} A promise that resolves to the response containing the margin
13
13
  * account data.
14
14
  * @memberof account
15
15
  * */
16
- getCollateralAccounts(getMarginAccountsParams: GetMarginAccountsParams): Promise<MarginAccountEntity[]>;
16
+ getMarginAccounts(params: GetMarginAccountsParams): Promise<MarginAccountEntity[]>;
17
17
  /**
18
18
  * Asynchronously retrieves details of a specific collateral account for a given Ethereum address.
19
19
  *
20
20
  * This method sends a request to the API to obtain detailed information about a specific collateral account
21
21
  * associated with the provided Ethereum address. The account is identified using the collateral account number.
22
22
  *
23
- * @param {GetMarginAccountParams} getMarginAccountParams
23
+ * @param {GetMarginAccountParams} params
24
24
  * @returns {Promise<MarginAccountEntity>} 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
- getCollateralAccount(getMarginAccountParams: GetMarginAccountParams): Promise<MarginAccountEntity>;
28
+ getCollateralAccount(params: GetMarginAccountParams): Promise<MarginAccountEntity>;
29
29
  }
30
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,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
+ {"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,iBAAiB,CACrB,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAKjC;;;;;;;;;;OAUG;IAEG,oBAAoB,CACxB,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,mBAAmB,CAAC;CAIhC"}
@@ -7,7 +7,7 @@ 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} [getMarketsParams] - The specific market ticker identifier for which data is requested. This parameter is optional.
10
+ * @param {GetMarketsParams} [params] - The specific market ticker identifier for which data is requested. This parameter is optional.
11
11
  * @returns {Promise<MarketEntity[]>} A promise that resolves to the response containing market data.
12
12
  * @memberof MarketsClient
13
13
  *
@@ -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(getMarketsParams: GetMarketsParams): Promise<MarketEntity[]>;
22
+ getMarkets(params: GetMarketsParams): Promise<MarketEntity[]>;
23
23
  /**
24
24
  * Retrieves candlestick data for a specified market.
25
25
  *
@@ -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,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"}
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,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAKnE;;;;;;;;;;;;;;;;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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/api-sdk",
3
- "version": "0.7.0",
3
+ "version": "0.9.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": "0a81b19c8d03ac890f08059f697aa4d907ad39e0"
39
+ "gitHead": "21e2e1bd85d1a87ed212743419f0f3e8785be09a"
40
40
  }
@@ -1,4 +1,9 @@
1
- import { ServiceConfig, API_TIMEOUT } from './helpers/constants';
1
+ import {
2
+ ServiceConfig,
3
+ API_TIMEOUT,
4
+ API_TESTNET,
5
+ API_PRODUCTION,
6
+ } from './helpers/constants';
2
7
  import MarketsClient from './modules/markets';
3
8
  import AccountClient from './modules/account';
4
9
 
@@ -6,17 +11,34 @@ import AccountClient from './modules/account';
6
11
  * @description Client for API
7
12
  */
8
13
  export class ApiClient {
9
- public readonly config: ServiceConfig;
10
- readonly apiTimeout: number;
11
- readonly _markets: MarketsClient;
12
- readonly _account: AccountClient;
14
+ private static instance: ApiClient;
15
+ private static config: ServiceConfig = {
16
+ production: true, // default value
17
+ timeout: API_TIMEOUT, // default value, e.g., 5000 milliseconds
18
+ };
19
+ private readonly apiEndpoint: string;
20
+ private readonly _markets: MarketsClient;
21
+ private readonly _account: AccountClient;
13
22
 
14
- constructor(config: ServiceConfig, apiTimeout?: number) {
15
- this.config = config;
16
- this.apiTimeout = apiTimeout ?? API_TIMEOUT;
23
+ private constructor(config: ServiceConfig) {
24
+ this.apiEndpoint = config.production ? API_PRODUCTION : API_TESTNET;
25
+ ApiClient.config = { ...ApiClient.config, ...config };
26
+ this._markets = new MarketsClient(this.apiEndpoint);
27
+ this._account = new AccountClient(this.apiEndpoint);
28
+ }
29
+
30
+ public static configure(config: ServiceConfig): void {
31
+ ApiClient.config = config;
32
+ ApiClient.instance = new ApiClient(config);
33
+ }
17
34
 
18
- this._markets = new MarketsClient(config.restEndpoint);
19
- this._account = new AccountClient(config.restEndpoint);
35
+ private static getInstance(): ApiClient {
36
+ if (!ApiClient.instance) {
37
+ throw new Error(
38
+ 'ApiClient is not configured. Please configure it before using.',
39
+ );
40
+ }
41
+ return ApiClient.instance;
20
42
  }
21
43
 
22
44
  /**
@@ -26,8 +48,8 @@ export class ApiClient {
26
48
  * @returns {MarketsClient} An instance of MarketsClient for market-related operations.
27
49
  * @memberof ApiClient
28
50
  */
29
- get markets(): MarketsClient {
30
- return this._markets;
51
+ public static get markets(): MarketsClient {
52
+ return ApiClient.getInstance()._markets;
31
53
  }
32
54
 
33
55
  /**
@@ -37,7 +59,7 @@ export class ApiClient {
37
59
  * @returns {AccountClient} An instance of AccountClient for account-related operations.
38
60
  * @memberof ApiClient
39
61
  */
40
- get account(): AccountClient {
41
- return this._account;
62
+ public static get account(): AccountClient {
63
+ return ApiClient.getInstance()._account;
42
64
  }
43
65
  }
@@ -1,11 +1,12 @@
1
1
  export const API_TIMEOUT: number = 2500;
2
2
 
3
- export class ServiceConfig {
4
- public restEndpoint: string;
5
- public websocketEndpoint: string;
6
-
7
- constructor(restEndpoint: string, websocketEndpoint: string) {
8
- this.restEndpoint = restEndpoint;
9
- this.websocketEndpoint = websocketEndpoint;
10
- }
3
+ export interface ServiceConfig {
4
+ production?: boolean; // Base URL for the REST API
5
+ timeout?: number; // Optional timeout for API requests
11
6
  }
7
+
8
+ export const API_PRODUCTION: string =
9
+ 'https://m8mjgmqmte.eu-central-1.awsapprunner.com';
10
+
11
+ export const API_TESTNET: string =
12
+ 'https://m8mjgmqmte.eu-central-1.awsapprunner.com';
@@ -13,17 +13,17 @@ export default class AccountClient extends RestClient {
13
13
  * based on the provided Ethereum address. An optional limit can be specified to control the number of
14
14
  * collateral accounts returned in the response.
15
15
  *
16
- * @param {GetMarginAccountsParams} getMarginAccountsParams
16
+ * @param {GetMarginAccountsParams} params
17
17
  * @returns {Promise<MarginAccountEntity[]>} A promise that resolves to the response containing the margin
18
18
  * account data.
19
19
  * @memberof account
20
20
  * */
21
21
 
22
- async getCollateralAccounts(
23
- getMarginAccountsParams: GetMarginAccountsParams,
22
+ async getMarginAccounts(
23
+ params: GetMarginAccountsParams,
24
24
  ): Promise<MarginAccountEntity[]> {
25
- const uri = `/api/accounts/${getMarginAccountsParams.address}`;
26
- return this.get(uri, { limit: getMarginAccountsParams.limit });
25
+ const uri = `/api/accounts/${params.address}`;
26
+ return this.get(uri, { limit: params.limit });
27
27
  }
28
28
 
29
29
  /**
@@ -32,16 +32,16 @@ export default class AccountClient extends RestClient {
32
32
  * This method sends a request to the API to obtain detailed information about a specific collateral account
33
33
  * associated with the provided Ethereum address. The account is identified using the collateral account number.
34
34
  *
35
- * @param {GetMarginAccountParams} getMarginAccountParams
35
+ * @param {GetMarginAccountParams} params
36
36
  * @returns {Promise<MarginAccountEntity>} A promise that resolves to the response containing the detailed
37
37
  * information of the specified margin account.
38
38
  * @memberof account
39
39
  */
40
40
 
41
41
  async getCollateralAccount(
42
- getMarginAccountParams: GetMarginAccountParams,
42
+ params: GetMarginAccountParams,
43
43
  ): Promise<MarginAccountEntity> {
44
- const uri = `/api/accounts/${getMarginAccountParams.address}/collateralAccount/${getMarginAccountParams.marginAccountNumber}`;
44
+ const uri = `/api/accounts/${params.address}/collateralAccount/${params.marginAccountNumber}`;
45
45
  return this.get(uri);
46
46
  }
47
47
  }
@@ -14,7 +14,7 @@ export default class MarketsClient extends RestClient {
14
14
  * This method makes a request to the API to fetch data for markets. If a specific market is provided as a parameter,
15
15
  * it fetches data for that particular market; otherwise, it fetches data for all available markets.
16
16
  *
17
- * @param {GetMarketsParams} [getMarketsParams] - The specific market ticker identifier for which data is requested. This parameter is optional.
17
+ * @param {GetMarketsParams} [params] - The specific market ticker identifier for which data is requested. This parameter is optional.
18
18
  * @returns {Promise<MarketEntity[]>} A promise that resolves to the response containing market data.
19
19
  * @memberof MarketsClient
20
20
  *
@@ -27,11 +27,9 @@ export default class MarketsClient extends RestClient {
27
27
  * const specificMarketData = await market.getMarkets('ETH-USDC');
28
28
  */
29
29
 
30
- async getMarkets(
31
- getMarketsParams: GetMarketsParams,
32
- ): Promise<MarketEntity[]> {
30
+ async getMarkets(params: GetMarketsParams): Promise<MarketEntity[]> {
33
31
  const uri = '/api/markets';
34
- return this.get(uri, { id: getMarketsParams.id });
32
+ return this.get(uri, { id: params.id });
35
33
  }
36
34
 
37
35
  /**