@reyaxyz/api-sdk 0.6.3
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/LICENSE.md +1 -0
- package/README.md +18 -0
- package/dist/clients/api-client.js +51 -0
- package/dist/clients/api-client.js.map +1 -0
- package/dist/clients/helpers/constants.js +13 -0
- package/dist/clients/helpers/constants.js.map +1 -0
- package/dist/clients/helpers/query-helper.js +21 -0
- package/dist/clients/helpers/query-helper.js.map +1 -0
- package/dist/clients/lib/axios.js +69 -0
- package/dist/clients/lib/axios.js.map +1 -0
- package/dist/clients/modules/account.js +122 -0
- package/dist/clients/modules/account.js.map +1 -0
- package/dist/clients/modules/markets.js +135 -0
- package/dist/clients/modules/markets.js.map +1 -0
- package/dist/clients/modules/rest.js +77 -0
- package/dist/clients/modules/rest.js.map +1 -0
- package/dist/clients/socket-client.js +2 -0
- package/dist/clients/socket-client.js.map +1 -0
- package/dist/clients/types.js +14 -0
- package/dist/clients/types.js.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/types/clients/api-client.d.ts +30 -0
- package/dist/types/clients/api-client.d.ts.map +1 -0
- package/dist/types/clients/helpers/constants.d.ts +7 -0
- package/dist/types/clients/helpers/constants.d.ts.map +1 -0
- package/dist/types/clients/helpers/query-helper.d.ts +2 -0
- package/dist/types/clients/helpers/query-helper.d.ts.map +1 -0
- package/dist/types/clients/lib/axios.d.ts +14 -0
- package/dist/types/clients/lib/axios.d.ts.map +1 -0
- package/dist/types/clients/modules/account.d.ts +45 -0
- package/dist/types/clients/modules/account.d.ts.map +1 -0
- package/dist/types/clients/modules/markets.d.ts +43 -0
- package/dist/types/clients/modules/markets.d.ts.map +1 -0
- package/dist/types/clients/modules/rest.d.ts +9 -0
- package/dist/types/clients/modules/rest.d.ts.map +1 -0
- package/dist/types/clients/socket-client.d.ts +1 -0
- package/dist/types/clients/socket-client.d.ts.map +1 -0
- package/dist/types/clients/types.d.ts +106 -0
- package/dist/types/clients/types.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +40 -0
- package/src/clients/api-client.ts +43 -0
- package/src/clients/helpers/constants.ts +11 -0
- package/src/clients/helpers/query-helper.ts +17 -0
- package/src/clients/lib/axios.ts +34 -0
- package/src/clients/modules/account.ts +63 -0
- package/src/clients/modules/markets.ts +77 -0
- package/src/clients/modules/rest.ts +31 -0
- package/src/clients/socket-client.ts +0 -0
- package/src/clients/types.ts +122 -0
- package/src/index.ts +1 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
MIT License
|
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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>
|
|
10
|
+
|
|
11
|
+
<p align="center"> API sdk for the Reya Network </p>
|
|
12
|
+
|
|
13
|
+
<br />
|
|
14
|
+
|
|
15
|
+
| Statements | Branches | Functions | Lines |
|
|
16
|
+
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
|
|
17
|
+
|  |  |  |  |
|
|
18
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ApiClient = void 0;
|
|
7
|
+
var constants_1 = require("./helpers/constants");
|
|
8
|
+
var markets_1 = __importDefault(require("./modules/markets"));
|
|
9
|
+
var account_1 = __importDefault(require("./modules/account"));
|
|
10
|
+
/**
|
|
11
|
+
* @description Client for API
|
|
12
|
+
*/
|
|
13
|
+
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);
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(ApiClient.prototype, "markets", {
|
|
21
|
+
/**
|
|
22
|
+
* Provides access to the MarketsClient instance.
|
|
23
|
+
* This getter allows for interacting with market-related API functionalities.
|
|
24
|
+
*
|
|
25
|
+
* @returns {MarketsClient} An instance of MarketsClient for market-related operations.
|
|
26
|
+
* @memberof ApiClient
|
|
27
|
+
*/
|
|
28
|
+
get: function () {
|
|
29
|
+
return this._markets;
|
|
30
|
+
},
|
|
31
|
+
enumerable: false,
|
|
32
|
+
configurable: true
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(ApiClient.prototype, "account", {
|
|
35
|
+
/**
|
|
36
|
+
* Provides access to the AccountClient instance.
|
|
37
|
+
* This getter allows for interacting with account-related API functionalities.
|
|
38
|
+
*
|
|
39
|
+
* @returns {AccountClient} An instance of AccountClient for account-related operations.
|
|
40
|
+
* @memberof ApiClient
|
|
41
|
+
*/
|
|
42
|
+
get: function () {
|
|
43
|
+
return this._account;
|
|
44
|
+
},
|
|
45
|
+
enumerable: false,
|
|
46
|
+
configurable: true
|
|
47
|
+
});
|
|
48
|
+
return ApiClient;
|
|
49
|
+
}());
|
|
50
|
+
exports.ApiClient = ApiClient;
|
|
51
|
+
//# sourceMappingURL=api-client.js.map
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServiceConfig = exports.API_TIMEOUT = void 0;
|
|
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;
|
|
13
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateQueryPath = void 0;
|
|
4
|
+
function generateQueryPath(url, params) {
|
|
5
|
+
var definedEntries = Object.entries(params).filter(function (_a) {
|
|
6
|
+
var value = _a[1];
|
|
7
|
+
return value !== undefined;
|
|
8
|
+
});
|
|
9
|
+
if (!definedEntries.length) {
|
|
10
|
+
return url;
|
|
11
|
+
}
|
|
12
|
+
var paramsString = definedEntries
|
|
13
|
+
.map(function (_a) {
|
|
14
|
+
var key = _a[0], value = _a[1];
|
|
15
|
+
return "".concat(key, "=").concat(value);
|
|
16
|
+
})
|
|
17
|
+
.join('&');
|
|
18
|
+
return "".concat(url, "?").concat(paramsString);
|
|
19
|
+
}
|
|
20
|
+
exports.generateQueryPath = generateQueryPath;
|
|
21
|
+
//# sourceMappingURL=query-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-helper.js","sourceRoot":"/","sources":["clients/helpers/query-helper.ts"],"names":[],"mappings":";;;AAAA,SAAgB,iBAAiB,CAC/B,GAAW,EACX,MAA4B;IAE5B,IAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAClD,UAAC,EAA4B;YAAzB,KAAK,QAAA;QAAyB,OAAA,KAAK,KAAK,SAAS;IAAnB,CAAmB,CACtD,CAAC;IAEF,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;QAC3B,OAAO,GAAG,CAAC;IACb,CAAC;IAED,IAAM,YAAY,GAAG,cAAc;SAChC,GAAG,CAAC,UAAC,EAA+B;YAA9B,GAAG,QAAA,EAAE,KAAK,QAAA;QAAyB,OAAA,UAAG,GAAG,cAAI,KAAK,CAAE;IAAjB,CAAiB,CAAC;SAC3D,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,OAAO,UAAG,GAAG,cAAI,YAAY,CAAE,CAAC;AAClC,CAAC;AAhBD,8CAgBC","sourcesContent":["export function generateQueryPath(\n url: string,\n params: NonNullable<unknown>,\n): string {\n const definedEntries = Object.entries(params).filter(\n ([, value]: [string, unknown]) => value !== undefined,\n );\n\n if (!definedEntries.length) {\n return url;\n }\n\n const paramsString = definedEntries\n .map(([key, value]: [string, unknown]) => `${key}=${value}`)\n .join('&');\n return `${url}?${paramsString}`;\n}\n"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.request = exports.RequestMethod = void 0;
|
|
43
|
+
var axios_1 = __importDefault(require("axios"));
|
|
44
|
+
var RequestMethod;
|
|
45
|
+
(function (RequestMethod) {
|
|
46
|
+
RequestMethod["POST"] = "POST";
|
|
47
|
+
RequestMethod["PUT"] = "PUT";
|
|
48
|
+
RequestMethod["GET"] = "GET";
|
|
49
|
+
RequestMethod["DELETE"] = "DELETE";
|
|
50
|
+
})(RequestMethod || (exports.RequestMethod = RequestMethod = {}));
|
|
51
|
+
function axiosRequest(options) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
+
return __generator(this, function (_a) {
|
|
54
|
+
return [2 /*return*/, (0, axios_1.default)(options)];
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function request(url, method, body, headers) {
|
|
59
|
+
if (method === void 0) { method = RequestMethod.GET; }
|
|
60
|
+
if (headers === void 0) { headers = {}; }
|
|
61
|
+
return axiosRequest({
|
|
62
|
+
url: url,
|
|
63
|
+
method: method,
|
|
64
|
+
data: body,
|
|
65
|
+
headers: headers,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
exports.request = request;
|
|
69
|
+
//# sourceMappingURL=axios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axios.js","sourceRoot":"/","sources":["clients/lib/axios.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkD;AAElD,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,8BAAa,CAAA;IACb,4BAAW,CAAA;IACX,4BAAW,CAAA;IACX,kCAAiB,CAAA;AACnB,CAAC,EALW,aAAa,6BAAb,aAAa,QAKxB;AAUD,SAAe,YAAY,CAAC,OAA2B;;;YACrD,sBAAO,IAAA,eAAK,EAAC,OAAO,CAAC,EAAC;;;CACvB;AAED,SAAgB,OAAO,CACrB,GAAW,EACX,MAAyC,EACzC,IAAqB,EACrB,OAAkC;IAFlC,uBAAA,EAAA,SAAwB,aAAa,CAAC,GAAG;IAEzC,wBAAA,EAAA,YAAkC;IAElC,OAAO,YAAY,CAAC;QAClB,GAAG,KAAA;QACH,MAAM,QAAA;QACN,IAAI,EAAE,IAAI;QACV,OAAO,SAAA;KACR,CAAC,CAAC;AACL,CAAC;AAZD,0BAYC","sourcesContent":["import axios, { AxiosRequestConfig } from 'axios';\n\nexport enum RequestMethod {\n POST = 'POST',\n PUT = 'PUT',\n GET = 'GET',\n DELETE = 'DELETE',\n}\n\nexport type ResponseData = never;\n\nexport interface Response {\n status: number;\n data: ResponseData;\n headers: NonNullable<unknown>;\n}\n\nasync function axiosRequest(options: AxiosRequestConfig): Promise<Response> {\n return axios(options);\n}\n\nexport function request(\n url: string,\n method: RequestMethod = RequestMethod.GET,\n body?: unknown | null,\n headers: NonNullable<unknown> = {},\n): Promise<Response> {\n return axiosRequest({\n url,\n method,\n data: body,\n headers,\n });\n}\n"]}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
|
+
};
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
var rest_1 = __importDefault(require("./rest"));
|
|
58
|
+
var AccountClient = /** @class */ (function (_super) {
|
|
59
|
+
__extends(AccountClient, _super);
|
|
60
|
+
function AccountClient() {
|
|
61
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Asynchronously retrieves a list of collateral accounts associated with a specific address.
|
|
65
|
+
*
|
|
66
|
+
* This method makes a request to the API endpoint to fetch collateral account data. The data is filtered
|
|
67
|
+
* based on the provided Ethereum address. An optional limit can be specified to control the number of
|
|
68
|
+
* collateral accounts returned in the response.
|
|
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
|
|
74
|
+
* account data.
|
|
75
|
+
* @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) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
+
var uri;
|
|
88
|
+
return __generator(this, function (_a) {
|
|
89
|
+
uri = "/api/accounts/".concat(address);
|
|
90
|
+
return [2 /*return*/, this.get(uri, { limit: limit })];
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Asynchronously retrieves details of a specific collateral account for a given Ethereum address.
|
|
96
|
+
*
|
|
97
|
+
* This method sends a request to the API to obtain detailed information about a specific collateral account
|
|
98
|
+
* associated with the provided Ethereum address. The account is identified using the collateral account number.
|
|
99
|
+
*
|
|
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.
|
|
104
|
+
* @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
|
+
*/
|
|
110
|
+
AccountClient.prototype.getCollateralAccount = function (address, collateralAccountNumber) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
112
|
+
var uri;
|
|
113
|
+
return __generator(this, function (_a) {
|
|
114
|
+
uri = "/api/accounts/".concat(address, "/collateralAccount/").concat(collateralAccountNumber);
|
|
115
|
+
return [2 /*return*/, this.get(uri)];
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
return AccountClient;
|
|
120
|
+
}(rest_1.default));
|
|
121
|
+
exports.default = AccountClient;
|
|
122
|
+
//# sourceMappingURL=account.js.map
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
|
+
};
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
var rest_1 = __importDefault(require("./rest"));
|
|
58
|
+
var MarketsClient = /** @class */ (function (_super) {
|
|
59
|
+
__extends(MarketsClient, _super);
|
|
60
|
+
function MarketsClient() {
|
|
61
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Asynchronously retrieves market data from the API.
|
|
65
|
+
*
|
|
66
|
+
* This method makes a request to the API to fetch data for markets. If a specific market is provided as a parameter,
|
|
67
|
+
* it fetches data for that particular market; otherwise, it fetches data for all available markets.
|
|
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.
|
|
71
|
+
* @memberof MarketsClient
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* // Fetch data for all markets
|
|
75
|
+
* const allMarketsData = await market.getMarkets();
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* // Fetch data for a specific market
|
|
79
|
+
* const specificMarketData = await market.getMarkets('ETH-USDC');
|
|
80
|
+
*/
|
|
81
|
+
MarketsClient.prototype.getMarkets = function (market) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
83
|
+
var uri;
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
uri = '/api/markets';
|
|
86
|
+
return [2 /*return*/, this.get(uri, { ticker: market })];
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Retrieves candlestick data for a specified market.
|
|
92
|
+
*
|
|
93
|
+
* This method fetches historical candlestick (or OHLC - Open, High, Low, Close) data for a given market.
|
|
94
|
+
* The data can be filtered by time range (fromISO and toISO) and resolution.
|
|
95
|
+
*
|
|
96
|
+
* @param {string} market - The market identifier for which candlestick data is to be retrieved.
|
|
97
|
+
* @param {CandlesResolution} resolution - The granularity of the candlestick data (e.g., '1MIN', '5MIN', '1HR').
|
|
98
|
+
* @param {string|null} [fromISO] - The start time for the range of candlestick data in ISO 8601 format. Optional.
|
|
99
|
+
* @param {string|null} [toISO] - The end time for the range of candlestick data in ISO 8601 format. Optional.
|
|
100
|
+
* @param {number|null} [limit] - The maximum number of candlestick data points to retrieve. Optional.
|
|
101
|
+
* @returns {Promise<MarketCandlesResponse>} A promise that resolves to the market candlestick data.
|
|
102
|
+
* @memberof MarketsClient
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* const marketCandles = await market.getMarketCandles('BTC-USD', '1HR', '2023-01-01T00:00:00Z', '2023-01-02T00:00:00Z');
|
|
106
|
+
*/
|
|
107
|
+
MarketsClient.prototype.getMarketCandles = function (market, resolution, fromISO, toISO, limit) {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
109
|
+
var uri;
|
|
110
|
+
return __generator(this, function (_a) {
|
|
111
|
+
uri = "/api/markets/candles/".concat(market);
|
|
112
|
+
return [2 /*return*/, this.get(uri, {
|
|
113
|
+
resolution: resolution,
|
|
114
|
+
fromISO: fromISO,
|
|
115
|
+
toISO: toISO,
|
|
116
|
+
limit: limit,
|
|
117
|
+
})];
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
MarketsClient.prototype.getPerpetualMarketTrades = function (market, limit) {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
123
|
+
var uri;
|
|
124
|
+
return __generator(this, function (_a) {
|
|
125
|
+
uri = "/api/trades/".concat(market);
|
|
126
|
+
return [2 /*return*/, this.get(uri, {
|
|
127
|
+
limit: limit,
|
|
128
|
+
})];
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
return MarketsClient;
|
|
133
|
+
}(rest_1.default));
|
|
134
|
+
exports.default = MarketsClient;
|
|
135
|
+
//# sourceMappingURL=markets.js.map
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var constants_1 = require("../helpers/constants");
|
|
40
|
+
var query_helper_1 = require("../helpers/query-helper");
|
|
41
|
+
var axios_1 = require("../lib/axios");
|
|
42
|
+
var RestClient = /** @class */ (function () {
|
|
43
|
+
function RestClient(host, apiTimeout) {
|
|
44
|
+
this.host = host;
|
|
45
|
+
this.apiTimeout = apiTimeout || constants_1.API_TIMEOUT;
|
|
46
|
+
}
|
|
47
|
+
RestClient.prototype.get = function (requestPath, params) {
|
|
48
|
+
if (params === void 0) { params = {}; }
|
|
49
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
50
|
+
var url, response;
|
|
51
|
+
return __generator(this, function (_a) {
|
|
52
|
+
switch (_a.label) {
|
|
53
|
+
case 0:
|
|
54
|
+
url = "".concat(this.host).concat((0, query_helper_1.generateQueryPath)(requestPath, params));
|
|
55
|
+
return [4 /*yield*/, (0, axios_1.request)(url)];
|
|
56
|
+
case 1:
|
|
57
|
+
response = _a.sent();
|
|
58
|
+
return [2 /*return*/, response.data];
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
RestClient.prototype.post = function (requestPath, params, body, headers) {
|
|
64
|
+
if (params === void 0) { params = {}; }
|
|
65
|
+
if (headers === void 0) { headers = {}; }
|
|
66
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
+
var url;
|
|
68
|
+
return __generator(this, function (_a) {
|
|
69
|
+
url = "".concat(this.host).concat((0, query_helper_1.generateQueryPath)(requestPath, params));
|
|
70
|
+
return [2 /*return*/, (0, axios_1.request)(url, axios_1.RequestMethod.POST, body, headers)];
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
return RestClient;
|
|
75
|
+
}());
|
|
76
|
+
exports.default = RestClient;
|
|
77
|
+
//# sourceMappingURL=rest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rest.js","sourceRoot":"/","sources":["clients/modules/rest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAmD;AACnD,wDAA4D;AAC5D,sCAA8E;AAC9E;IAIE,oBAAY,IAAY,EAAE,UAA0B;QAClD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,IAAI,uBAAW,CAAC;IAC9C,CAAC;IAEK,wBAAG,GAAT,UACE,WAAmB,EACnB,MAAiC;QAAjC,uBAAA,EAAA,WAAiC;;;;;;wBAE3B,GAAG,GAAG,UAAG,IAAI,CAAC,IAAI,SAAG,IAAA,gCAAiB,EAAC,WAAW,EAAE,MAAM,CAAC,CAAE,CAAC;wBACnD,qBAAM,IAAA,eAAO,EAAC,GAAG,CAAC,EAAA;;wBAA7B,QAAQ,GAAG,SAAkB;wBACnC,sBAAO,QAAQ,CAAC,IAAI,EAAC;;;;KACtB;IAEK,yBAAI,GAAV,UACE,WAAmB,EACnB,MAAiC,EACjC,IAAqB,EACrB,OAAkC;QAFlC,uBAAA,EAAA,WAAiC;QAEjC,wBAAA,EAAA,YAAkC;;;;gBAE5B,GAAG,GAAG,UAAG,IAAI,CAAC,IAAI,SAAG,IAAA,gCAAiB,EAAC,WAAW,EAAE,MAAM,CAAC,CAAE,CAAC;gBACpE,sBAAO,IAAA,eAAO,EAAC,GAAG,EAAE,qBAAa,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAC;;;KACxD;IACH,iBAAC;AAAD,CAAC,AA3BD,IA2BC","sourcesContent":["import { API_TIMEOUT } from '../helpers/constants';\nimport { generateQueryPath } from '../helpers/query-helper';\nimport { RequestMethod, Response, request, ResponseData } from '../lib/axios';\nexport default class RestClient {\n readonly host: string;\n readonly apiTimeout: number;\n\n constructor(host: string, apiTimeout?: number | null) {\n this.host = host;\n this.apiTimeout = apiTimeout || API_TIMEOUT;\n }\n\n async get(\n requestPath: string,\n params: NonNullable<unknown> = {},\n ): Promise<ResponseData> {\n const url = `${this.host}${generateQueryPath(requestPath, params)}`;\n const response = await request(url);\n return response.data;\n }\n\n async post(\n requestPath: string,\n params: NonNullable<unknown> = {},\n body?: unknown | null,\n headers: NonNullable<unknown> = {},\n ): Promise<Response> {\n const url = `${this.host}${generateQueryPath(requestPath, params)}`;\n return request(url, RequestMethod.POST, body, headers);\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket-client.js","sourceRoot":"/","sources":["clients/socket-client.ts"],"names":[],"mappings":"","sourcesContent":[""]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CandlesResolution = void 0;
|
|
4
|
+
var CandlesResolution;
|
|
5
|
+
(function (CandlesResolution) {
|
|
6
|
+
CandlesResolution["ONE_MINUTE"] = "1MIN";
|
|
7
|
+
CandlesResolution["FIVE_MINUTES"] = "5MINS";
|
|
8
|
+
CandlesResolution["FIFTEEN_MINUTES"] = "15MINS";
|
|
9
|
+
CandlesResolution["THIRTY_MINUTES"] = "30MINS";
|
|
10
|
+
CandlesResolution["ONE_HOUR"] = "1HOUR";
|
|
11
|
+
CandlesResolution["FOUR_HOURS"] = "4HOURS";
|
|
12
|
+
CandlesResolution["ONE_DAY"] = "1DAY";
|
|
13
|
+
})(CandlesResolution || (exports.CandlesResolution = CandlesResolution = {}));
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +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"]}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiClient = void 0;
|
|
4
|
+
var api_client_1 = require("./clients/api-client");
|
|
5
|
+
Object.defineProperty(exports, "ApiClient", { enumerable: true, get: function () { return api_client_1.ApiClient; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAAxC,uGAAA,SAAS,OAAA","sourcesContent":["export { ApiClient } from './clients/api-client';\n"]}
|