@reyaxyz/api-sdk 0.13.0 → 0.15.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.
@@ -18,6 +18,8 @@ exports.ApiClient = void 0;
18
18
  var constants_1 = require("./helpers/constants");
19
19
  var markets_1 = __importDefault(require("./modules/markets"));
20
20
  var account_1 = __importDefault(require("./modules/account"));
21
+ var trade_simulation_1 = __importDefault(require("./modules/trade.simulation"));
22
+ var lp_1 = __importDefault(require("./modules/lp"));
21
23
  /**
22
24
  * @description Client for API
23
25
  */
@@ -27,6 +29,8 @@ var ApiClient = /** @class */ (function () {
27
29
  ApiClient.config = __assign(__assign({}, ApiClient.config), config);
28
30
  this._markets = new markets_1.default(this.apiEndpoint);
29
31
  this._account = new account_1.default(this.apiEndpoint);
32
+ this._lp = new lp_1.default(this.apiEndpoint);
33
+ this._trade_simulation = new trade_simulation_1.default();
30
34
  }
31
35
  ApiClient.configure = function (config) {
32
36
  ApiClient.config = config;
@@ -66,6 +70,43 @@ var ApiClient = /** @class */ (function () {
66
70
  enumerable: false,
67
71
  configurable: true
68
72
  });
73
+ Object.defineProperty(ApiClient, "tradeSimulation", {
74
+ /**
75
+ * Provides access to the TradeSimulationClient instance.
76
+ * This getter allows for interacting with trade simulation functionalities.
77
+ * It ensures a singleton pattern by fetching the instance from the ApiClient's
78
+ * private `_trade_simulation` property, ensuring that trade simulation operations
79
+ * use a consistent client configuration and state.
80
+ *
81
+ * @returns {TradeSimulationClient} An instance of TradeSimulationClient for trade simulation operations.
82
+ * @memberof ApiClient
83
+ * @example
84
+ * // Access the trade simulation client from the ApiClient
85
+ * const tradeSimulationClient = ApiClient.tradeSimulation;
86
+ */
87
+ get: function () {
88
+ return ApiClient.getInstance()._trade_simulation;
89
+ },
90
+ enumerable: false,
91
+ configurable: true
92
+ });
93
+ Object.defineProperty(ApiClient, "lp", {
94
+ /**
95
+ * Gets the current instance of the LpClient from the ApiClient.
96
+ *
97
+ * This static getter allows access to the LpClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the LpClient directly, bypassing the need to manually access the internal `_lp` property of the ApiClient instance.
98
+ *
99
+ * @returns {LpClient} The LpClient instance currently held by the ApiClient.
100
+ * @example
101
+ * // Assuming ApiClient and LpClient are properly set up
102
+ * const lpClient = ApiClient.lp;
103
+ */
104
+ get: function () {
105
+ return ApiClient.getInstance()._lp;
106
+ },
107
+ enumerable: false,
108
+ configurable: true
109
+ });
69
110
  ApiClient.config = {
70
111
  production: true, // default value
71
112
  timeout: constants_1.API_TIMEOUT, // default value, e.g., 5000 milliseconds
@@ -1 +1 @@
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
+ {"version":3,"file":"api-client.js","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAK6B;AAC7B,8DAA8C;AAC9C,8DAA8C;AAC9C,gFAA+D;AAC/D,oDAAoC;AAEpC;;GAEG;AACH;IAYE,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;QACpD,IAAI,CAAC,GAAG,GAAG,IAAI,YAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC1C,IAAI,CAAC,iBAAiB,GAAG,IAAI,0BAAqB,EAAE,CAAC;IACvD,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;IAgBD,sBAAkB,4BAAe;QAdjC;;;;;;;;;;;;WAYG;aAEH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,iBAAiB,CAAC;QACnD,CAAC;;;OAAA;IAYD,sBAAkB,eAAE;QAVpB;;;;;;;;;WASG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC;QACrC,CAAC;;;OAAA;IArFc,gBAAM,GAAkB;QACrC,UAAU,EAAE,IAAI,EAAE,gBAAgB;QAClC,OAAO,EAAE,uBAAW,EAAE,yCAAyC;KAChE,CAAC;IAmFJ,gBAAC;CAAA,AAxFD,IAwFC;AAxFY,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';\nimport TradeSimulationClient from './modules/trade.simulation';\nimport LpClient from './modules/lp';\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 private readonly _lp: LpClient;\n private readonly _trade_simulation: TradeSimulationClient;\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 this._lp = new LpClient(this.apiEndpoint);\n this._trade_simulation = new TradeSimulationClient();\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 /**\n * Provides access to the TradeSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_trade_simulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TradeSimulationClient} An instance of TradeSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the trade simulation client from the ApiClient\n * const tradeSimulationClient = ApiClient.tradeSimulation;\n */\n\n public static get tradeSimulation(): TradeSimulationClient {\n return ApiClient.getInstance()._trade_simulation;\n }\n\n /**\n * Gets the current instance of the LpClient from the ApiClient.\n *\n * This static getter allows access to the LpClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the LpClient directly, bypassing the need to manually access the internal `_lp` property of the ApiClient instance.\n *\n * @returns {LpClient} The LpClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and LpClient are properly set up\n * const lpClient = ApiClient.lp;\n */\n public static get lp(): LpClient {\n return ApiClient.getInstance()._lp;\n }\n}\n"]}
@@ -0,0 +1,84 @@
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 LpClient = /** @class */ (function (_super) {
59
+ __extends(LpClient, _super);
60
+ function LpClient() {
61
+ return _super !== null && _super.apply(this, arguments) || this;
62
+ }
63
+ LpClient.prototype.getLpPools = function () {
64
+ return __awaiter(this, void 0, void 0, function () {
65
+ var uri;
66
+ return __generator(this, function (_a) {
67
+ uri = '/api/lp-pools';
68
+ return [2 /*return*/, this.get(uri)];
69
+ });
70
+ });
71
+ };
72
+ LpClient.prototype.getLpPool = function (params) {
73
+ return __awaiter(this, void 0, void 0, function () {
74
+ var uri;
75
+ return __generator(this, function (_a) {
76
+ uri = "/api/lp-pools/".concat(params.id);
77
+ return [2 /*return*/, this.get(uri)];
78
+ });
79
+ });
80
+ };
81
+ return LpClient;
82
+ }(rest_1.default));
83
+ exports.default = LpClient;
84
+ //# sourceMappingURL=lp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lp.js","sourceRoot":"/","sources":["clients/modules/lp.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,gDAAgC;AAEhC;IAAsC,4BAAU;IAAhD;;IAUA,CAAC;IATO,6BAAU,GAAhB;;;;gBACQ,GAAG,GAAG,eAAe,CAAC;gBAC5B,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IAEK,4BAAS,GAAf,UAAgB,MAAuB;;;;gBAC/B,GAAG,GAAG,wBAAiB,MAAM,CAAC,EAAE,CAAE,CAAC;gBACzC,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IACH,eAAC;AAAD,CAAC,AAVD,CAAsC,cAAU,GAU/C","sourcesContent":["import { GetLpPoolParams, GetLpPoolResult, GetLpPoolsResult } from '../types';\nimport RestClient from './rest';\n\nexport default class LpClient extends RestClient {\n async getLpPools(): Promise<GetLpPoolsResult> {\n const uri = '/api/lp-pools';\n return this.get(uri);\n }\n\n async getLpPool(params: GetLpPoolParams): Promise<GetLpPoolResult> {\n const uri = `/api/lp-pools/${params.id}`;\n return this.get(uri);\n }\n}\n"]}
@@ -0,0 +1,112 @@
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
+ // The maximum is inclusive and the minimum is inclusive
40
+ function getRandomIntInclusive(min, max) {
41
+ min = Math.ceil(min);
42
+ max = Math.floor(max);
43
+ return Math.floor(Math.random() * (max - min + 1) + min);
44
+ }
45
+ var randomHealth = function () {
46
+ return Math.random() * 100 > 50
47
+ ? 'healthy'
48
+ : Math.random() * 100 > 50
49
+ ? 'danger'
50
+ : 'warning';
51
+ };
52
+ function getRandomFloat(min, max) {
53
+ return Math.random() * (max - min) + min;
54
+ }
55
+ var TradeSimulationClient = /** @class */ (function () {
56
+ function TradeSimulationClient() {
57
+ this.marketId = null;
58
+ this.accountId = null;
59
+ this.loadedData = null;
60
+ }
61
+ // Method to asynchronously load data based on marketId and accountId
62
+ TradeSimulationClient.prototype.loadData = function (params) {
63
+ return __awaiter(this, void 0, void 0, function () {
64
+ var marketData;
65
+ return __generator(this, function (_a) {
66
+ switch (_a.label) {
67
+ case 0:
68
+ this.marketId = params.market_id;
69
+ this.accountId = params.marginAccountId;
70
+ return [4 /*yield*/, this.fetchMarketData(this.marketId, this.accountId)];
71
+ case 1:
72
+ marketData = _a.sent();
73
+ // Store the loaded data
74
+ this.loadedData = { marketData: marketData };
75
+ return [2 /*return*/];
76
+ }
77
+ });
78
+ });
79
+ };
80
+ TradeSimulationClient.prototype.fetchMarketData = function (marketId, accountId) {
81
+ return __awaiter(this, void 0, void 0, function () {
82
+ return __generator(this, function (_a) {
83
+ switch (_a.label) {
84
+ case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 500); })];
85
+ case 1:
86
+ _a.sent(); // wait for 500ms
87
+ return [2 /*return*/, 1 + marketId + accountId];
88
+ }
89
+ });
90
+ });
91
+ };
92
+ // Synchronous method to simulate operations based on an amount
93
+ TradeSimulationClient.prototype.simulate = function (params) {
94
+ if (!this.loadedData) {
95
+ throw new Error('Data not loaded. Call loadData() first.');
96
+ }
97
+ // @todo perform simulation
98
+ return {
99
+ estimatedPrice: getRandomIntInclusive(1000, 100000) + params.amount,
100
+ estimatedSlippage: getRandomFloat(0.00001, 0.05),
101
+ fees: getRandomIntInclusive(1000, 100000),
102
+ impliedLeverage: getRandomIntInclusive(20, 50),
103
+ imr: getRandomIntInclusive(1000, 100000),
104
+ liquidationPrice: getRandomIntInclusive(1000, 100000),
105
+ marginRatio: getRandomIntInclusive(0, 100),
106
+ marginRatioHealth: randomHealth(),
107
+ };
108
+ };
109
+ return TradeSimulationClient;
110
+ }());
111
+ exports.default = TradeSimulationClient;
112
+ //# sourceMappingURL=trade.simulation.js.map
@@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AAA;;wBAHK,UAAU,GAAG,SAGlB;wBAED,wBAAwB;wBACxB,IAAI,CAAC,UAAU,GAAG,EAAE,UAAU,YAAA,EAAE,CAAC;;;;;KAClC;IAEa,+CAAe,GAA7B,UACE,QAAgB,EAChB,SAAiB;;;;4BAEjB,qBAAM,IAAI,OAAO,CAAC,UAAC,OAAO,IAAK,OAAA,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,EAAxB,CAAwB,CAAC,EAAA;;wBAAxD,SAAwD,CAAC,CAAC,iBAAiB;wBAC3E,sBAAO,CAAC,GAAG,QAAQ,GAAG,SAAS,EAAC;;;;KACjC;IAED,+DAA+D;IAC/D,wCAAQ,GAAR,UAAS,MAAqC;QAC5C,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC7D,CAAC;QAED,2BAA2B;QAE3B,OAAO;YACL,cAAc,EAAE,qBAAqB,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM;YACnE,iBAAiB,EAAE,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC;YAChD,IAAI,EAAE,qBAAqB,CAAC,IAAI,EAAE,MAAM,CAAC;YACzC,eAAe,EAAE,qBAAqB,CAAC,EAAE,EAAE,EAAE,CAAC;YAC9C,GAAG,EAAE,qBAAqB,CAAC,IAAI,EAAE,MAAM,CAAC;YACxC,gBAAgB,EAAE,qBAAqB,CAAC,IAAI,EAAE,MAAM,CAAC;YACrD,WAAW,EAAE,qBAAqB,CAAC,CAAC,EAAE,GAAG,CAAC;YAC1C,iBAAiB,EAAE,YAAY,EAAE;SACX,CAAC;IAC3B,CAAC;IACH,4BAAC;AAAD,CAAC,AA/CD,IA+CC","sourcesContent":["import {\n SimulateTradeEntity,\n TradeSimulationLoadDataParams,\n TradeSimulationSimulateParams,\n} from '../types';\n\ntype LoadedData = {\n marketData: number;\n};\n\n// The maximum is inclusive and the minimum is inclusive\nfunction getRandomIntInclusive(min: number, max: number) {\n min = Math.ceil(min);\n max = Math.floor(max);\n return Math.floor(Math.random() * (max - min + 1) + min);\n}\n\nconst randomHealth = () => {\n return Math.random() * 100 > 50\n ? 'healthy'\n : Math.random() * 100 > 50\n ? 'danger'\n : 'warning';\n};\n\nfunction getRandomFloat(min: number, max: number): number {\n return Math.random() * (max - min) + min;\n}\n\nexport default class TradeSimulationClient {\n private marketId: number | null = null;\n private accountId: number | null = null;\n private loadedData: LoadedData | null = null;\n\n // Method to asynchronously load data based on marketId and accountId\n async loadData(params: TradeSimulationLoadDataParams): Promise<void> {\n this.marketId = params.market_id;\n this.accountId = params.marginAccountId;\n\n // Simulate fetching data (@todo replace this with actual data fetching logic)\n const marketData = await this.fetchMarketData(\n this.marketId,\n this.accountId,\n );\n\n // Store the loaded data\n this.loadedData = { marketData };\n }\n\n private async fetchMarketData(\n marketId: number,\n accountId: number,\n ): Promise<number> {\n await new Promise((resolve) => setTimeout(resolve, 500)); // wait for 500ms\n return 1 + marketId + accountId;\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(params: TradeSimulationSimulateParams): SimulateTradeEntity {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call loadData() first.');\n }\n\n // @todo perform simulation\n\n return {\n estimatedPrice: getRandomIntInclusive(1000, 100000) + params.amount,\n estimatedSlippage: getRandomFloat(0.00001, 0.05),\n fees: getRandomIntInclusive(1000, 100000),\n impliedLeverage: getRandomIntInclusive(20, 50),\n imr: getRandomIntInclusive(1000, 100000),\n liquidationPrice: getRandomIntInclusive(1000, 100000),\n marginRatio: getRandomIntInclusive(0, 100),\n marginRatioHealth: randomHealth(),\n } as SimulateTradeEntity;\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CandlesResolution = void 0;
3
+ exports.SupportedChainId = exports.CandlesResolution = void 0;
4
4
  var CandlesResolution;
5
5
  (function (CandlesResolution) {
6
6
  CandlesResolution["ONE_MINUTE"] = "1MIN";
@@ -11,4 +11,10 @@ var CandlesResolution;
11
11
  CandlesResolution["FOUR_HOURS"] = "4HOURS";
12
12
  CandlesResolution["ONE_DAY"] = "1DAY";
13
13
  })(CandlesResolution || (exports.CandlesResolution = CandlesResolution = {}));
14
+ // ---- LP ----
15
+ var SupportedChainId;
16
+ (function (SupportedChainId) {
17
+ SupportedChainId[SupportedChainId["mainnet"] = 1] = "mainnet";
18
+ SupportedChainId[SupportedChainId["polygonMumbai"] = 80001] = "polygonMumbai";
19
+ })(SupportedChainId || (exports.SupportedChainId = SupportedChainId = {}));
14
20
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":";;;AAAA,IAAY,iBAQX;AARD,WAAY,iBAAiB;IAC3B,wCAAmB,CAAA;IACnB,2CAAsB,CAAA;IACtB,+CAA0B,CAAA;IAC1B,8CAAyB,CAAA;IACzB,uCAAkB,CAAA;IAClB,0CAAqB,CAAA;IACrB,qCAAgB,CAAA;AAClB,CAAC,EARW,iBAAiB,iCAAjB,iBAAiB,QAQ5B","sourcesContent":["export enum CandlesResolution {\n ONE_MINUTE = '1MIN',\n FIVE_MINUTES = '5MINS',\n FIFTEEN_MINUTES = '15MINS',\n THIRTY_MINUTES = '30MINS',\n ONE_HOUR = '1HOUR',\n FOUR_HOURS = '4HOURS',\n ONE_DAY = '1DAY',\n}\n\n// -- Candles --\nexport interface Candle {\n startedAt: string;\n ticker: string;\n resolution: CandlesResolution;\n low: string;\n high: string;\n open: string;\n close: string;\n baseTokenVolume: string;\n usdVolume: string;\n trades: number;\n startingOpenInterest: string;\n id: string;\n}\n\nexport interface MarketCandlesResponse {\n candles: Candle[];\n}\n\n// -- Markets --\n\nexport type MarketOrderInfo = {\n counterpartyAccountIds: number[];\n exchangeId: number;\n};\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 orderInfo: MarketOrderInfo;\n tickSizeDecimals: number;\n};\n\nexport type GetMarketsResult = MarketEntity[];\n\nexport type GetMarketResult = MarketEntity;\n\nexport type GetMarketParams = {\n id: MarketEntity['id'];\n};\n\nexport type GetCandlesParams = {\n marketId: MarketEntity['id'];\n resolution: CandlesResolution;\n fromISO?: string | null;\n toISO?: string | null;\n limit?: number | null;\n};\n\n// -- Account --\n\nexport type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';\nexport type Side = 'LONG' | 'SHORT';\n\nexport type GetMarginAccountsParams = {\n address: string;\n limit?: number;\n};\n\nexport type GetMarginAccountParams = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n};\n\nexport type GetPositionsForMarginAccountParams = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n limit?: number;\n};\n\nexport type MarginAccountEntity = {\n id: number;\n name: string;\n marginRatioHealth: 'danger' | 'healthy' | 'warning';\n marginRatioPercentage: number;\n totalBalance: number;\n totalBalanceUnderlyingAsset: string;\n collaterals: {\n token: string;\n percentage: number;\n balance: number;\n balanceRUSD: number;\n }[];\n};\n\nexport type GetMarginAccountsResult = MarginAccountEntity[];\nexport type GetMarginAccountResult = MarginAccountEntity;\n\nexport type PositionEntity = {\n id: number;\n side: Side;\n size: number;\n base: number;\n price: number;\n markPrice: number;\n orderStatus: Status;\n realisedPnl?: number | null;\n unrealisedPnl?: number | null;\n liquidationPrice: number;\n fundingRate: number;\n market: MarketEntity;\n date: Date;\n};\n\nexport type GetPositionsForMarginAccountResult = {\n positions: PositionEntity[];\n totalUnrealizedPNL: number;\n};\n\n// --- Trading History ----\n\nexport type GetMarketTradingHistoryParams = {\n marketId: number;\n limit?: number;\n};\n\nexport type TradingHistoryEntity = {\n id: number;\n price: number;\n priceUnderlyingToken: string;\n size: number;\n sizeUnderlyingToken: string;\n timestampMillisecondsUTC: number;\n};\n\nexport type GetTradingHistoryResult = TradingHistoryEntity[];\n\n// --- Position History ---\n\nexport type GetPositionsHistoryForMarginAccountParams = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n limit?: number;\n};\n\nexport type OrderType = 'market';\n\nexport type PositionHistoryType =\n | 'long-trade'\n | 'short-trade'\n | 'long-liquidation'\n | 'short-liquidation';\n\nexport type PositionHistoryEntity = {\n id: number;\n action: PositionHistoryType;\n orderType: OrderType;\n size: number;\n executionPrice: number;\n realisedPnl?: number | null;\n fees: number;\n timestamp: number;\n market: MarketEntity;\n};\n\nexport type GetPositionsHistoryForMarginAccountResult = PositionHistoryEntity[];\n\n// -- Max Order Size --\n\nexport type GetMaxOrderSizeAvailableParams = {\n marketId: MarketEntity['id'];\n marginAccountId: MarginAccountEntity['id'];\n direction: 'long' | 'short';\n};\n\nexport type GetMaxOrderSizeAvailableResult = number;\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;AA2MD,eAAe;AAEf,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,6DAAW,CAAA;IACX,6EAAqB,CAAA;AACvB,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B","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 MarketOrderInfo = {\n counterpartyAccountIds: number[];\n exchangeId: number;\n};\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 orderInfo: MarketOrderInfo;\n tickSizeDecimals: number;\n};\n\nexport type GetMarketsResult = MarketEntity[];\n\nexport type GetMarketResult = MarketEntity;\n\nexport type GetMarketParams = {\n id: MarketEntity['id'];\n};\n\nexport type GetCandlesParams = {\n marketId: MarketEntity['id'];\n resolution: CandlesResolution;\n fromISO?: string | null;\n toISO?: string | null;\n limit?: number | null;\n};\n\n// -- Account --\n\nexport type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';\nexport type Side = 'LONG' | 'SHORT';\n\nexport type GetMarginAccountsParams = {\n address: string;\n limit?: number;\n};\n\nexport type GetMarginAccountParams = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n};\n\nexport type GetPositionsForMarginAccountParams = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n limit?: number;\n};\n\nexport type MarginAccountEntity = {\n id: number;\n name: string;\n marginRatioHealth: 'danger' | 'healthy' | 'warning';\n marginRatioPercentage: number;\n totalBalance: number;\n totalBalanceUnderlyingAsset: string;\n collaterals: {\n token: string;\n percentage: number;\n balance: number;\n balanceRUSD: number;\n }[];\n};\n\nexport type GetMarginAccountsResult = MarginAccountEntity[];\nexport type GetMarginAccountResult = MarginAccountEntity;\n\nexport type PositionEntity = {\n id: number;\n side: Side;\n size: number;\n base: number;\n price: number;\n markPrice: number;\n orderStatus: Status;\n realisedPnl?: number | null;\n unrealisedPnl?: number | null;\n liquidationPrice: number;\n fundingRate: number;\n market: MarketEntity;\n date: Date;\n};\n\nexport type GetPositionsForMarginAccountResult = {\n positions: PositionEntity[];\n totalUnrealizedPNL: number;\n};\n\n// --- Trading History ----\n\nexport type GetMarketTradingHistoryParams = {\n marketId: number;\n limit?: number;\n};\n\nexport type TradingHistoryEntity = {\n id: number;\n price: number;\n priceUnderlyingToken: string;\n size: number;\n sizeUnderlyingToken: string;\n timestampMillisecondsUTC: number;\n};\n\nexport type GetTradingHistoryResult = TradingHistoryEntity[];\n\n// --- Position History ---\n\nexport type GetPositionsHistoryForMarginAccountParams = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n limit?: number;\n};\n\nexport type OrderType = 'market';\n\nexport type PositionHistoryType =\n | 'long-trade'\n | 'short-trade'\n | 'long-liquidation'\n | 'short-liquidation';\n\nexport type PositionHistoryEntity = {\n id: number;\n action: PositionHistoryType;\n orderType: OrderType;\n size: number;\n executionPrice: number;\n realisedPnl?: number | null;\n fees: number;\n timestamp: number;\n market: MarketEntity;\n};\n\nexport type GetPositionsHistoryForMarginAccountResult = PositionHistoryEntity[];\n\n// -- Max Order Size --\n\nexport type GetMaxOrderSizeAvailableParams = {\n marketId: MarketEntity['id'];\n marginAccountId: MarginAccountEntity['id'];\n direction: 'long' | 'short';\n};\n\nexport type GetMaxOrderSizeAvailableResult = number;\n\n// --- Trade Simulation ----\n\nexport type SimulateTradeEntity = {\n liquidationPrice: number;\n fees: number;\n estimatedPrice: number;\n estimatedSlippage: number;\n imr: number;\n impliedLeverage: number;\n marginRatio: MarginAccountEntity['marginRatioPercentage'];\n marginRatioHealth: MarginAccountEntity['marginRatioHealth'];\n};\n\nexport type TradeSimulationLoadDataParams = {\n market_id: MarketEntity['id'];\n marginAccountId: MarginAccountEntity['id'];\n};\n\nexport type TradeSimulationSimulateParams = {\n amount: number; // position size, + for long | - for short\n};\n\n// ---- LP ----\n\nexport enum SupportedChainId {\n mainnet = 1,\n polygonMumbai = 80001,\n}\n\nexport type LpPoolEntity = {\n id: number;\n name: string;\n description: string;\n currentAPY: number;\n balanceSupplied?: number | null;\n balanceChange24H: number;\n tokenAddress: string;\n token: string;\n allowedChainsForLiquidity: number[];\n chainId: SupportedChainId;\n};\n\nexport type GetLpPoolsResult = LpPoolEntity[];\n\nexport type GetLpPoolResult = LpPoolEntity;\n\nexport type GetLpPoolParams = {\n id: LpPoolEntity['id'];\n};\n"]}
@@ -1,6 +1,8 @@
1
1
  import { ServiceConfig } from './helpers/constants';
2
2
  import MarketsClient from './modules/markets';
3
3
  import AccountClient from './modules/account';
4
+ import TradeSimulationClient from './modules/trade.simulation';
5
+ import LpClient from './modules/lp';
4
6
  /**
5
7
  * @description Client for API
6
8
  */
@@ -10,6 +12,8 @@ export declare class ApiClient {
10
12
  private readonly apiEndpoint;
11
13
  private readonly _markets;
12
14
  private readonly _account;
15
+ private readonly _lp;
16
+ private readonly _trade_simulation;
13
17
  private constructor();
14
18
  static configure(config: ServiceConfig): void;
15
19
  private static getInstance;
@@ -29,5 +33,30 @@ export declare class ApiClient {
29
33
  * @memberof ApiClient
30
34
  */
31
35
  static get account(): AccountClient;
36
+ /**
37
+ * Provides access to the TradeSimulationClient instance.
38
+ * This getter allows for interacting with trade simulation functionalities.
39
+ * It ensures a singleton pattern by fetching the instance from the ApiClient's
40
+ * private `_trade_simulation` property, ensuring that trade simulation operations
41
+ * use a consistent client configuration and state.
42
+ *
43
+ * @returns {TradeSimulationClient} An instance of TradeSimulationClient for trade simulation operations.
44
+ * @memberof ApiClient
45
+ * @example
46
+ * // Access the trade simulation client from the ApiClient
47
+ * const tradeSimulationClient = ApiClient.tradeSimulation;
48
+ */
49
+ static get tradeSimulation(): TradeSimulationClient;
50
+ /**
51
+ * Gets the current instance of the LpClient from the ApiClient.
52
+ *
53
+ * This static getter allows access to the LpClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the LpClient directly, bypassing the need to manually access the internal `_lp` property of the ApiClient instance.
54
+ *
55
+ * @returns {LpClient} The LpClient instance currently held by the ApiClient.
56
+ * @example
57
+ * // Assuming ApiClient and LpClient are properly set up
58
+ * const lpClient = ApiClient.lp;
59
+ */
60
+ static get lp(): LpClient;
32
61
  }
33
62
  //# 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,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
+ {"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;AAC9C,OAAO,qBAAqB,MAAM,4BAA4B,CAAC;AAC/D,OAAO,QAAQ,MAAM,cAAc,CAAC;AAEpC;;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;IACzC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAW;IAC/B,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAwB;IAE1D,OAAO;WASO,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;IAED;;;;;;;;;;;;OAYG;IAEH,WAAkB,eAAe,IAAI,qBAAqB,CAEzD;IAED;;;;;;;;;OASG;IACH,WAAkB,EAAE,IAAI,QAAQ,CAE/B;CACF"}
@@ -0,0 +1,7 @@
1
+ import { GetLpPoolParams, GetLpPoolResult, GetLpPoolsResult } from '../types';
2
+ import RestClient from './rest';
3
+ export default class LpClient extends RestClient {
4
+ getLpPools(): Promise<GetLpPoolsResult>;
5
+ getLpPool(params: GetLpPoolParams): Promise<GetLpPoolResult>;
6
+ }
7
+ //# sourceMappingURL=lp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lp.d.ts","sourceRoot":"/","sources":["clients/modules/lp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC9E,OAAO,UAAU,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,UAAU;IACxC,UAAU,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAKvC,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;CAInE"}
@@ -0,0 +1,10 @@
1
+ import { SimulateTradeEntity, TradeSimulationLoadDataParams, TradeSimulationSimulateParams } from '../types';
2
+ export default class TradeSimulationClient {
3
+ private marketId;
4
+ private accountId;
5
+ private loadedData;
6
+ loadData(params: TradeSimulationLoadDataParams): Promise<void>;
7
+ private fetchMarketData;
8
+ simulate(params: TradeSimulationSimulateParams): SimulateTradeEntity;
9
+ }
10
+ //# sourceMappingURL=trade.simulation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trade.simulation.d.ts","sourceRoot":"/","sources":["clients/modules/trade.simulation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,6BAA6B,EAC7B,6BAA6B,EAC9B,MAAM,UAAU,CAAC;AAyBlB,MAAM,CAAC,OAAO,OAAO,qBAAqB;IACxC,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,UAAU,CAA2B;IAGvC,QAAQ,CAAC,MAAM,EAAE,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC;YActD,eAAe;IAS7B,QAAQ,CAAC,MAAM,EAAE,6BAA6B,GAAG,mBAAmB;CAkBrE"}
@@ -145,4 +145,42 @@ export type GetMaxOrderSizeAvailableParams = {
145
145
  direction: 'long' | 'short';
146
146
  };
147
147
  export type GetMaxOrderSizeAvailableResult = number;
148
+ export type SimulateTradeEntity = {
149
+ liquidationPrice: number;
150
+ fees: number;
151
+ estimatedPrice: number;
152
+ estimatedSlippage: number;
153
+ imr: number;
154
+ impliedLeverage: number;
155
+ marginRatio: MarginAccountEntity['marginRatioPercentage'];
156
+ marginRatioHealth: MarginAccountEntity['marginRatioHealth'];
157
+ };
158
+ export type TradeSimulationLoadDataParams = {
159
+ market_id: MarketEntity['id'];
160
+ marginAccountId: MarginAccountEntity['id'];
161
+ };
162
+ export type TradeSimulationSimulateParams = {
163
+ amount: number;
164
+ };
165
+ export declare enum SupportedChainId {
166
+ mainnet = 1,
167
+ polygonMumbai = 80001
168
+ }
169
+ export type LpPoolEntity = {
170
+ id: number;
171
+ name: string;
172
+ description: string;
173
+ currentAPY: number;
174
+ balanceSupplied?: number | null;
175
+ balanceChange24H: number;
176
+ tokenAddress: string;
177
+ token: string;
178
+ allowedChainsForLiquidity: number[];
179
+ chainId: SupportedChainId;
180
+ };
181
+ export type GetLpPoolsResult = LpPoolEntity[];
182
+ export type GetLpPoolResult = LpPoolEntity;
183
+ export type GetLpPoolParams = {
184
+ id: LpPoolEntity['id'];
185
+ };
148
186
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB;IAC3B,UAAU,SAAS;IACnB,YAAY,UAAU;IACtB,eAAe,WAAW;IAC1B,cAAc,WAAW;IACzB,QAAQ,UAAU;IAClB,UAAU,WAAW;IACrB,OAAO,SAAS;CACjB;AAGD,MAAM,WAAW,MAAM;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,iBAAiB,CAAC;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB,EAAE,MAAM,CAAC;IAC7B,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAID,MAAM,MAAM,eAAe,GAAG;IAC5B,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAA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15.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": "87e449e615b82a9bcd2e38296f2c2c0daa09a61b"
39
+ "gitHead": "38108ef2cabc3987f006db1dc85235fa85a2acf5"
40
40
  }
@@ -6,6 +6,8 @@ import {
6
6
  } from './helpers/constants';
7
7
  import MarketsClient from './modules/markets';
8
8
  import AccountClient from './modules/account';
9
+ import TradeSimulationClient from './modules/trade.simulation';
10
+ import LpClient from './modules/lp';
9
11
 
10
12
  /**
11
13
  * @description Client for API
@@ -19,12 +21,16 @@ export class ApiClient {
19
21
  private readonly apiEndpoint: string;
20
22
  private readonly _markets: MarketsClient;
21
23
  private readonly _account: AccountClient;
24
+ private readonly _lp: LpClient;
25
+ private readonly _trade_simulation: TradeSimulationClient;
22
26
 
23
27
  private constructor(config: ServiceConfig) {
24
28
  this.apiEndpoint = config.production ? API_PRODUCTION : API_TESTNET;
25
29
  ApiClient.config = { ...ApiClient.config, ...config };
26
30
  this._markets = new MarketsClient(this.apiEndpoint);
27
31
  this._account = new AccountClient(this.apiEndpoint);
32
+ this._lp = new LpClient(this.apiEndpoint);
33
+ this._trade_simulation = new TradeSimulationClient();
28
34
  }
29
35
 
30
36
  public static configure(config: ServiceConfig): void {
@@ -62,4 +68,36 @@ export class ApiClient {
62
68
  public static get account(): AccountClient {
63
69
  return ApiClient.getInstance()._account;
64
70
  }
71
+
72
+ /**
73
+ * Provides access to the TradeSimulationClient instance.
74
+ * This getter allows for interacting with trade simulation functionalities.
75
+ * It ensures a singleton pattern by fetching the instance from the ApiClient's
76
+ * private `_trade_simulation` property, ensuring that trade simulation operations
77
+ * use a consistent client configuration and state.
78
+ *
79
+ * @returns {TradeSimulationClient} An instance of TradeSimulationClient for trade simulation operations.
80
+ * @memberof ApiClient
81
+ * @example
82
+ * // Access the trade simulation client from the ApiClient
83
+ * const tradeSimulationClient = ApiClient.tradeSimulation;
84
+ */
85
+
86
+ public static get tradeSimulation(): TradeSimulationClient {
87
+ return ApiClient.getInstance()._trade_simulation;
88
+ }
89
+
90
+ /**
91
+ * Gets the current instance of the LpClient from the ApiClient.
92
+ *
93
+ * This static getter allows access to the LpClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the LpClient directly, bypassing the need to manually access the internal `_lp` property of the ApiClient instance.
94
+ *
95
+ * @returns {LpClient} The LpClient instance currently held by the ApiClient.
96
+ * @example
97
+ * // Assuming ApiClient and LpClient are properly set up
98
+ * const lpClient = ApiClient.lp;
99
+ */
100
+ public static get lp(): LpClient {
101
+ return ApiClient.getInstance()._lp;
102
+ }
65
103
  }
@@ -0,0 +1,14 @@
1
+ import { GetLpPoolParams, GetLpPoolResult, GetLpPoolsResult } from '../types';
2
+ import RestClient from './rest';
3
+
4
+ export default class LpClient extends RestClient {
5
+ async getLpPools(): Promise<GetLpPoolsResult> {
6
+ const uri = '/api/lp-pools';
7
+ return this.get(uri);
8
+ }
9
+
10
+ async getLpPool(params: GetLpPoolParams): Promise<GetLpPoolResult> {
11
+ const uri = `/api/lp-pools/${params.id}`;
12
+ return this.get(uri);
13
+ }
14
+ }
@@ -0,0 +1,77 @@
1
+ import {
2
+ SimulateTradeEntity,
3
+ TradeSimulationLoadDataParams,
4
+ TradeSimulationSimulateParams,
5
+ } from '../types';
6
+
7
+ type LoadedData = {
8
+ marketData: number;
9
+ };
10
+
11
+ // The maximum is inclusive and the minimum is inclusive
12
+ function getRandomIntInclusive(min: number, max: number) {
13
+ min = Math.ceil(min);
14
+ max = Math.floor(max);
15
+ return Math.floor(Math.random() * (max - min + 1) + min);
16
+ }
17
+
18
+ const randomHealth = () => {
19
+ return Math.random() * 100 > 50
20
+ ? 'healthy'
21
+ : Math.random() * 100 > 50
22
+ ? 'danger'
23
+ : 'warning';
24
+ };
25
+
26
+ function getRandomFloat(min: number, max: number): number {
27
+ return Math.random() * (max - min) + min;
28
+ }
29
+
30
+ export default class TradeSimulationClient {
31
+ private marketId: number | null = null;
32
+ private accountId: number | null = null;
33
+ private loadedData: LoadedData | null = null;
34
+
35
+ // Method to asynchronously load data based on marketId and accountId
36
+ async loadData(params: TradeSimulationLoadDataParams): Promise<void> {
37
+ this.marketId = params.market_id;
38
+ this.accountId = params.marginAccountId;
39
+
40
+ // Simulate fetching data (@todo replace this with actual data fetching logic)
41
+ const marketData = await this.fetchMarketData(
42
+ this.marketId,
43
+ this.accountId,
44
+ );
45
+
46
+ // Store the loaded data
47
+ this.loadedData = { marketData };
48
+ }
49
+
50
+ private async fetchMarketData(
51
+ marketId: number,
52
+ accountId: number,
53
+ ): Promise<number> {
54
+ await new Promise((resolve) => setTimeout(resolve, 500)); // wait for 500ms
55
+ return 1 + marketId + accountId;
56
+ }
57
+
58
+ // Synchronous method to simulate operations based on an amount
59
+ simulate(params: TradeSimulationSimulateParams): SimulateTradeEntity {
60
+ if (!this.loadedData) {
61
+ throw new Error('Data not loaded. Call loadData() first.');
62
+ }
63
+
64
+ // @todo perform simulation
65
+
66
+ return {
67
+ estimatedPrice: getRandomIntInclusive(1000, 100000) + params.amount,
68
+ estimatedSlippage: getRandomFloat(0.00001, 0.05),
69
+ fees: getRandomIntInclusive(1000, 100000),
70
+ impliedLeverage: getRandomIntInclusive(20, 50),
71
+ imr: getRandomIntInclusive(1000, 100000),
72
+ liquidationPrice: getRandomIntInclusive(1000, 100000),
73
+ marginRatio: getRandomIntInclusive(0, 100),
74
+ marginRatioHealth: randomHealth(),
75
+ } as SimulateTradeEntity;
76
+ }
77
+ }
@@ -186,3 +186,53 @@ export type GetMaxOrderSizeAvailableParams = {
186
186
  };
187
187
 
188
188
  export type GetMaxOrderSizeAvailableResult = number;
189
+
190
+ // --- Trade Simulation ----
191
+
192
+ export type SimulateTradeEntity = {
193
+ liquidationPrice: number;
194
+ fees: number;
195
+ estimatedPrice: number;
196
+ estimatedSlippage: number;
197
+ imr: number;
198
+ impliedLeverage: number;
199
+ marginRatio: MarginAccountEntity['marginRatioPercentage'];
200
+ marginRatioHealth: MarginAccountEntity['marginRatioHealth'];
201
+ };
202
+
203
+ export type TradeSimulationLoadDataParams = {
204
+ market_id: MarketEntity['id'];
205
+ marginAccountId: MarginAccountEntity['id'];
206
+ };
207
+
208
+ export type TradeSimulationSimulateParams = {
209
+ amount: number; // position size, + for long | - for short
210
+ };
211
+
212
+ // ---- LP ----
213
+
214
+ export enum SupportedChainId {
215
+ mainnet = 1,
216
+ polygonMumbai = 80001,
217
+ }
218
+
219
+ export type LpPoolEntity = {
220
+ id: number;
221
+ name: string;
222
+ description: string;
223
+ currentAPY: number;
224
+ balanceSupplied?: number | null;
225
+ balanceChange24H: number;
226
+ tokenAddress: string;
227
+ token: string;
228
+ allowedChainsForLiquidity: number[];
229
+ chainId: SupportedChainId;
230
+ };
231
+
232
+ export type GetLpPoolsResult = LpPoolEntity[];
233
+
234
+ export type GetLpPoolResult = LpPoolEntity;
235
+
236
+ export type GetLpPoolParams = {
237
+ id: LpPoolEntity['id'];
238
+ };