@reyaxyz/api-sdk 0.38.3 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,40 +1,4 @@
1
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
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
39
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
4
  };
@@ -48,17 +12,10 @@ var RequestMethod;
48
12
  RequestMethod["GET"] = "GET";
49
13
  RequestMethod["DELETE"] = "DELETE";
50
14
  })(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
15
  function request(url, method, body, headers) {
59
16
  if (method === void 0) { method = RequestMethod.GET; }
60
17
  if (headers === void 0) { headers = {}; }
61
- return axiosRequest({
18
+ return (0, axios_1.default)({
62
19
  url: url,
63
20
  method: method,
64
21
  data: body,
@@ -1 +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"]}
1
+ {"version":3,"file":"axios.js","sourceRoot":"/","sources":["clients/lib/axios.ts"],"names":[],"mappings":";;;;;;AAAA,gDAA0B;AAE1B,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,8BAAa,CAAA;IACb,4BAAW,CAAA;IACX,4BAAW,CAAA;IACX,kCAAiB,CAAA;AACnB,CAAC,EALW,aAAa,6BAAb,aAAa,QAKxB;AAQD,SAAgB,OAAO,CACrB,GAAW,EACX,MAAyC,EACzC,IAAqB,EACrB,OAAkC;IAFlC,uBAAA,EAAA,SAAwB,aAAa,CAAC,GAAG;IAEzC,wBAAA,EAAA,YAAkC;IAElC,OAAO,IAAA,eAAK,EAAmC;QAC7C,GAAG,KAAA;QACH,MAAM,QAAA;QACN,IAAI,EAAE,IAAI;QACV,OAAO,SAAA;KACR,CAAC,CAAC;AACL,CAAC;AAZD,0BAYC","sourcesContent":["import axios from 'axios';\n\nexport enum RequestMethod {\n POST = 'POST',\n PUT = 'PUT',\n GET = 'GET',\n DELETE = 'DELETE',\n}\n\nexport type ApiResponse<Data> = {\n status: number;\n data: Data;\n headers: NonNullable<unknown>;\n};\n\nexport function request<ResponseData>(\n url: string,\n method: RequestMethod = RequestMethod.GET,\n body?: unknown | null,\n headers: NonNullable<unknown> = {},\n): Promise<ApiResponse<ResponseData>> {\n return axios<never, ApiResponse<ResponseData>>({\n url,\n method,\n data: body,\n headers,\n });\n}\n"]}
@@ -188,6 +188,42 @@ var AccountClient = /** @class */ (function (_super) {
188
188
  });
189
189
  });
190
190
  };
191
+ // TODO: Milan validate
192
+ AccountClient.prototype.editMarginAccount = function (params) {
193
+ return __awaiter(this, void 0, void 0, function () {
194
+ var name, uri;
195
+ return __generator(this, function (_a) {
196
+ name = (params.name || '').trim();
197
+ if (!params.id) {
198
+ throw new Error('Missing margin account id');
199
+ }
200
+ if (name.length === 0 || name.length > 25) {
201
+ throw new Error('Max size 25 characters');
202
+ }
203
+ uri = "/api/accounts/".concat(params.id, "/edit");
204
+ return [2 /*return*/, this.put(uri, {
205
+ id: params.id,
206
+ name: params.name,
207
+ })];
208
+ });
209
+ });
210
+ };
211
+ // TODO: Milan validate
212
+ AccountClient.prototype.closeMarginAccount = function (params) {
213
+ return __awaiter(this, void 0, void 0, function () {
214
+ var uri;
215
+ return __generator(this, function (_a) {
216
+ // TODO: Milan do validation before DB
217
+ if (!params.id) {
218
+ throw new Error('Missing margin account id');
219
+ }
220
+ uri = "/api/accounts/".concat(params.id, "/edit");
221
+ return [2 /*return*/, this.delete(uri, {
222
+ id: params.id,
223
+ })];
224
+ });
225
+ });
226
+ };
191
227
  return AccountClient;
192
228
  }(rest_1.default));
193
229
  exports.default = AccountClient;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/account/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,iDAAiC;AAOjC;IAA2C,iCAAU;IAArD;;IA8GA,CAAC;IA7GC;;;;;;;;;;;SAWK;IAEC,yCAA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sResult,\n GetMarginAccountTransactionHistoryParams,\n GetMarginAccountTransactionHistoryResult,\n GetMaxOrderSizeAvailableParams,\n GetMaxOrderSizeAvailableResult,\n GetMaxWithdrawBalanceForAccountParams,\n GetMaxWithdrawBalanceForAccountResult,\n GetPositionsForMarginAccountParams,\n GetPositionsForMarginAccountResult,\n GetPositionsHistoryForMarginAccountParams,\n GetPositionsHistoryForMarginAccountResult,\n GetTransactionSimulationInitialDataParams,\n GetMarginAccountBalanceChartDataParams,\n GetMarginAccountCollateralsBalanceChartDataParams,\n} from './types';\nimport RestClient from '../rest';\nimport { TradeSimulationState } from '@reyaxyz/common';\nimport {\n GetMarginAccountCollateralsBalanceChartDataResult,\n GetMarginAccountBalanceChartDataResult,\n} from '@reyaxyz/common';\n\nexport default class AccountClient extends RestClient {\n /**\n * Asynchronously retrieves a list of margin accounts associated with a specific address.\n *\n * This method makes a request to the API endpoint to fetch collateral account data. The data is filtered\n * based on the provided Ethereum address. An optional limit can be specified to control the number of\n * collateral accounts returned in the response.\n *\n * @param {GetMarginAccountsParams} params\n * @returns {Promise<GetMarginAccountsResult>} A promise that resolves to the response containing the margin\n * account data.\n * @memberof account\n * */\n\n async getMarginAccounts(\n params: GetMarginAccountsParams,\n ): Promise<GetMarginAccountsResult> {\n const uri = `/api/accounts/${params.address}`;\n return this.get(uri, { limit: params.limit });\n }\n\n /**\n * Asynchronously retrieves details of a specific collateral account for a given Ethereum address.\n *\n * This method sends a request to the API to obtain detailed information about a specific collateral account\n * associated with the provided Ethereum address. The account is identified using the collateral account number.\n *\n * @param {GetMarginAccountParams} params\n * @returns {Promise<GetMarginAccountResult>} A promise that resolves to the response containing the detailed\n * information of the specified margin account.\n * @memberof account\n */\n\n async getMarginAccount(\n params: GetMarginAccountParams,\n ): Promise<GetMarginAccountResult> {\n const uri = `/api/accounts/${params.address}/marginAccount/${params.marginAccountId}`;\n return this.get(uri);\n }\n\n async getPositionsForMarginAccount(\n params: GetPositionsForMarginAccountParams,\n ): Promise<GetPositionsForMarginAccountResult> {\n const uri = `/api/accounts/${params.address}/marginAccount/${params.marginAccountId}/positions`;\n return this.get(uri, { limit: params.limit });\n }\n\n async getPositionsHistoryForMarginAccount(\n params: GetPositionsHistoryForMarginAccountParams,\n ): Promise<GetPositionsHistoryForMarginAccountResult> {\n const uri = `/api/accounts/${params.address}/marginAccount/${params.marginAccountId}/positions/history`;\n return this.get(uri, { limit: params.limit });\n }\n\n async getMaxOrderSizeAvailable(\n params: GetMaxOrderSizeAvailableParams,\n ): Promise<GetMaxOrderSizeAvailableResult> {\n const uri = `/api/accounts/${params.marginAccountId}/max-order-size`;\n return this.get(uri, {\n marketId: params.marketId,\n direction: params.direction,\n });\n }\n\n async getTransactionSimulationInitialData(\n params: GetTransactionSimulationInitialDataParams,\n ): Promise<TradeSimulationState> {\n const uri = `/api/accounts/${params.marginAccountId}/trade-simulation-data`;\n return this.get(uri, {\n marketId: params.marketId,\n });\n }\n\n async getMarginAccountTransactionHistory(\n params: GetMarginAccountTransactionHistoryParams,\n ): Promise<GetMarginAccountTransactionHistoryResult> {\n const uri = `/api/accounts/${params.marginAccountId}/transaction-history`;\n return this.get(uri, {\n limit: params.limit,\n });\n }\n\n async getMaxWithdrawBalanceForAccount(\n params: GetMaxWithdrawBalanceForAccountParams,\n ): Promise<GetMaxWithdrawBalanceForAccountResult> {\n const uri = `/api/accounts/${params.marginAccountId}/max-withdraw-amount`;\n return this.get(uri, {\n assetAddress: params.tokenAddress,\n });\n }\n\n async getMarginAccountBalanceChartData(\n params: GetMarginAccountBalanceChartDataParams,\n ): Promise<GetMarginAccountBalanceChartDataResult> {\n const uri = `/api/accounts/${params.marginAccountId}/balance-chart-data`;\n return this.get(uri, {\n timeframeMs: params.filters.timeframeMs,\n granularity: params.filters.granularity,\n });\n }\n\n async getMarginAccountCollateralsBalanceChartData(\n params: GetMarginAccountCollateralsBalanceChartDataParams,\n ): Promise<GetMarginAccountCollateralsBalanceChartDataResult> {\n const uri = `/api/accounts/${params.marginAccountId}/collaterals-balance-chart-data`;\n return this.get(uri, {\n timeframeMs: params.filters.timeframeMs,\n granularity: params.filters.granularity,\n });\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/account/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,iDAAiC;AAOjC;IAA2C,iCAAU;IAArD;;IAiJA,CAAC;IAhJC;;;;;;;;;;;SAWK;IAEC,yCAAiB,GAAvB,UACE,MAA+B;;;;gBAEzB,GAAG,GAAG,wBAAiB,MAAM,CAAC,OAAO,CAAE,CAAC;gBAC9C,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,EAAC;;;KAC/C;IAED;;;;;;;;;;OAUG;IAEG,wCAAgB,GAAtB,UACE,MAA8B;;;;gBAExB,GAAG,GAAG,wBAAiB,MAAM,CAAC,OAAO,4BAAkB,MAAM,CAAC,eAAe,CAAE,CAAC;gBACtF,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IAEK,oDAA4B,GAAlC,UACE,MAA0C;;;;gBAEpC,GAAG,GAAG,wBAAiB,MAAM,CAAC,OAAO,4BAAkB,MAAM,CAAC,eAAe,eAAY,CAAC;gBAChG,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,EAAC;;;KAC/C;IAEK,2DAAmC,GAAzC,UACE,MAAiD;;;;gBAE3C,GAAG,GAAG,wBAAiB,MAAM,CAAC,OAAO,4BAAkB,MAAM,CAAC,eAAe,uBAAoB,CAAC;gBACxG,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,EAAC;;;KAC/C;IAEK,gDAAwB,GAA9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cesContent":["import {\n GetMarginAccountParams,\n GetMarginAccountResult,\n GetMarginAccountsParams,\n GetMarginAccountsResult,\n GetMarginAccountTransactionHistoryParams,\n GetMarginAccountTransactionHistoryResult,\n GetMaxOrderSizeAvailableParams,\n GetMaxOrderSizeAvailableResult,\n GetMaxWithdrawBalanceForAccountParams,\n GetMaxWithdrawBalanceForAccountResult,\n GetPositionsForMarginAccountParams,\n GetPositionsForMarginAccountResult,\n GetPositionsHistoryForMarginAccountParams,\n GetPositionsHistoryForMarginAccountResult,\n GetTransactionSimulationInitialDataParams,\n GetMarginAccountBalanceChartDataParams,\n GetMarginAccountCollateralsBalanceChartDataParams,\n EditMarginAccountParams,\n CloseMarginAccountParams,\n} from './types';\nimport RestClient from '../rest';\nimport { TradeSimulationState } from '@reyaxyz/common';\nimport {\n GetMarginAccountCollateralsBalanceChartDataResult,\n GetMarginAccountBalanceChartDataResult,\n} from '@reyaxyz/common';\n\nexport default class AccountClient extends RestClient {\n /**\n * Asynchronously retrieves a list of margin accounts associated with a specific address.\n *\n * This method makes a request to the API endpoint to fetch collateral account data. The data is filtered\n * based on the provided Ethereum address. An optional limit can be specified to control the number of\n * collateral accounts returned in the response.\n *\n * @param {GetMarginAccountsParams} params\n * @returns {Promise<GetMarginAccountsResult>} A promise that resolves to the response containing the margin\n * account data.\n * @memberof account\n * */\n\n async getMarginAccounts(\n params: GetMarginAccountsParams,\n ): Promise<GetMarginAccountsResult> {\n const uri = `/api/accounts/${params.address}`;\n return this.get(uri, { limit: params.limit });\n }\n\n /**\n * Asynchronously retrieves details of a specific collateral account for a given Ethereum address.\n *\n * This method sends a request to the API to obtain detailed information about a specific collateral account\n * associated with the provided Ethereum address. The account is identified using the collateral account number.\n *\n * @param {GetMarginAccountParams} params\n * @returns {Promise<GetMarginAccountResult>} A promise that resolves to the response containing the detailed\n * information of the specified margin account.\n * @memberof account\n */\n\n async getMarginAccount(\n params: GetMarginAccountParams,\n ): Promise<GetMarginAccountResult> {\n const uri = `/api/accounts/${params.address}/marginAccount/${params.marginAccountId}`;\n return this.get(uri);\n }\n\n async getPositionsForMarginAccount(\n params: GetPositionsForMarginAccountParams,\n ): Promise<GetPositionsForMarginAccountResult> {\n const uri = `/api/accounts/${params.address}/marginAccount/${params.marginAccountId}/positions`;\n return this.get(uri, { limit: params.limit });\n }\n\n async getPositionsHistoryForMarginAccount(\n params: GetPositionsHistoryForMarginAccountParams,\n ): Promise<GetPositionsHistoryForMarginAccountResult> {\n const uri = `/api/accounts/${params.address}/marginAccount/${params.marginAccountId}/positions/history`;\n return this.get(uri, { limit: params.limit });\n }\n\n async getMaxOrderSizeAvailable(\n params: GetMaxOrderSizeAvailableParams,\n ): Promise<GetMaxOrderSizeAvailableResult> {\n const uri = `/api/accounts/${params.marginAccountId}/max-order-size`;\n return this.get(uri, {\n marketId: params.marketId,\n direction: params.direction,\n });\n }\n\n async getTransactionSimulationInitialData(\n params: GetTransactionSimulationInitialDataParams,\n ): Promise<TradeSimulationState> {\n const uri = `/api/accounts/${params.marginAccountId}/trade-simulation-data`;\n return this.get(uri, {\n marketId: params.marketId,\n });\n }\n\n async getMarginAccountTransactionHistory(\n params: GetMarginAccountTransactionHistoryParams,\n ): Promise<GetMarginAccountTransactionHistoryResult> {\n const uri = `/api/accounts/${params.marginAccountId}/transaction-history`;\n return this.get(uri, {\n limit: params.limit,\n });\n }\n\n async getMaxWithdrawBalanceForAccount(\n params: GetMaxWithdrawBalanceForAccountParams,\n ): Promise<GetMaxWithdrawBalanceForAccountResult> {\n const uri = `/api/accounts/${params.marginAccountId}/max-withdraw-amount`;\n return this.get(uri, {\n assetAddress: params.tokenAddress,\n });\n }\n\n async getMarginAccountBalanceChartData(\n params: GetMarginAccountBalanceChartDataParams,\n ): Promise<GetMarginAccountBalanceChartDataResult> {\n const uri = `/api/accounts/${params.marginAccountId}/balance-chart-data`;\n return this.get(uri, {\n timeframeMs: params.filters.timeframeMs,\n granularity: params.filters.granularity,\n });\n }\n\n async getMarginAccountCollateralsBalanceChartData(\n params: GetMarginAccountCollateralsBalanceChartDataParams,\n ): Promise<GetMarginAccountCollateralsBalanceChartDataResult> {\n const uri = `/api/accounts/${params.marginAccountId}/collaterals-balance-chart-data`;\n return this.get(uri, {\n timeframeMs: params.filters.timeframeMs,\n granularity: params.filters.granularity,\n });\n }\n\n // TODO: Milan validate\n async editMarginAccount(\n params: EditMarginAccountParams,\n ): Promise<{ success: boolean }> {\n // TODO: Milan do validation before DB\n const name = (params.name || '').trim();\n if (!params.id) {\n throw new Error('Missing margin account id');\n }\n if (name.length === 0 || name.length > 25) {\n throw new Error('Max size 25 characters');\n }\n\n const uri = `/api/accounts/${params.id}/edit`;\n return this.put(uri, {\n id: params.id,\n name: params.name,\n });\n }\n\n // TODO: Milan validate\n async closeMarginAccount(\n params: CloseMarginAccountParams,\n ): Promise<{ success: boolean }> {\n // TODO: Milan do validation before DB\n if (!params.id) {\n throw new Error('Missing margin account id');\n }\n\n const uri = `/api/accounts/${params.id}/edit`;\n return this.delete(uri, {\n id: params.id,\n });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/account/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MarginAccountEntity,\n MarginAccountTransactionHistoryEntity,\n MarketEntity,\n PositionEntity,\n PositionHistoryEntity,\n} from '@reyaxyz/common';\nimport {\n MarginAccountBalanceGranularity,\n MarginAccountCollateralsBalanceGranularity,\n} from '@reyaxyz/common';\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 GetMarginAccountsResult = MarginAccountEntity[];\n\nexport type GetMarginAccountResult = MarginAccountEntity;\n\n// ---- Transaction History\nexport type GetMarginAccountTransactionHistoryParams = {\n marginAccountId: MarginAccountEntity['id'];\n limit?: number;\n};\n\nexport type GetMarginAccountTransactionHistoryResult =\n MarginAccountTransactionHistoryEntity[];\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// --- Max Withdraw Balance for Margin Account ---\nexport type GetMaxWithdrawBalanceForAccountParams = {\n marginAccountId: MarginAccountEntity['id'];\n tokenAddress: string;\n};\n\nexport type GetMaxWithdrawBalanceForAccountResult = number;\n\nexport type GetPositionsForMarginAccountResult = {\n positions: PositionEntity[];\n totalUnrealizedPNL: number;\n};\n\n// --- Position History ---\n\nexport type GetPositionsHistoryForMarginAccountParams = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n limit?: number;\n};\nexport type GetPositionsHistoryForMarginAccountResult = PositionHistoryEntity[];\n\n// ---- Transaction Simulation ----\n\nexport type GetTransactionSimulationInitialDataParams = {\n marketId: MarketEntity['id'];\n marginAccountId: MarginAccountEntity['id'];\n};\n\nexport type GetMarginAccountBalanceChartDataParams = {\n marginAccountId: MarginAccountEntity['id'];\n filters: {\n timeframeMs: number;\n granularity: MarginAccountBalanceGranularity;\n };\n};\n\nexport type GetMarginAccountCollateralsBalanceChartDataParams = {\n marginAccountId: MarginAccountEntity['id'];\n filters: {\n timeframeMs: number;\n granularity: MarginAccountCollateralsBalanceGranularity;\n };\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/account/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MarginAccountEntity,\n MarginAccountTransactionHistoryEntity,\n MarketEntity,\n PositionEntity,\n PositionHistoryEntity,\n} from '@reyaxyz/common';\nimport {\n MarginAccountBalanceGranularity,\n MarginAccountCollateralsBalanceGranularity,\n} from '@reyaxyz/common';\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 GetMarginAccountsResult = MarginAccountEntity[];\n\nexport type GetMarginAccountResult = MarginAccountEntity;\n\n// ---- Transaction History\nexport type GetMarginAccountTransactionHistoryParams = {\n marginAccountId: MarginAccountEntity['id'];\n limit?: number;\n};\n\nexport type GetMarginAccountTransactionHistoryResult =\n MarginAccountTransactionHistoryEntity[];\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// --- Max Withdraw Balance for Margin Account ---\nexport type GetMaxWithdrawBalanceForAccountParams = {\n marginAccountId: MarginAccountEntity['id'];\n tokenAddress: string;\n};\n\nexport type GetMaxWithdrawBalanceForAccountResult = number;\n\nexport type GetPositionsForMarginAccountResult = {\n positions: PositionEntity[];\n totalUnrealizedPNL: number;\n};\n\n// --- Position History ---\n\nexport type GetPositionsHistoryForMarginAccountParams = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n limit?: number;\n};\nexport type GetPositionsHistoryForMarginAccountResult = PositionHistoryEntity[];\n\n// ---- Transaction Simulation ----\n\nexport type GetTransactionSimulationInitialDataParams = {\n marketId: MarketEntity['id'];\n marginAccountId: MarginAccountEntity['id'];\n};\n\nexport type GetMarginAccountBalanceChartDataParams = {\n marginAccountId: MarginAccountEntity['id'];\n filters: {\n timeframeMs: number;\n granularity: MarginAccountBalanceGranularity;\n };\n};\n\nexport type GetMarginAccountCollateralsBalanceChartDataParams = {\n marginAccountId: MarginAccountEntity['id'];\n filters: {\n timeframeMs: number;\n granularity: MarginAccountCollateralsBalanceGranularity;\n };\n};\n\nexport type EditMarginAccountParams = {\n id: MarginAccountEntity['id'];\n name: MarginAccountEntity['name'];\n};\n\nexport type CloseMarginAccountParams = {\n id: MarginAccountEntity['id'];\n};\n"]}
@@ -64,10 +64,50 @@ var RestClient = /** @class */ (function () {
64
64
  if (params === void 0) { params = {}; }
65
65
  if (headers === void 0) { headers = {}; }
66
66
  return __awaiter(this, void 0, void 0, function () {
67
- var url;
67
+ var url, response;
68
+ return __generator(this, function (_a) {
69
+ switch (_a.label) {
70
+ case 0:
71
+ url = "".concat(this.host).concat((0, query_helper_1.generateQueryPath)(requestPath, params));
72
+ return [4 /*yield*/, (0, axios_1.request)(url, axios_1.RequestMethod.POST, body, headers)];
73
+ case 1:
74
+ response = _a.sent();
75
+ return [2 /*return*/, response.data];
76
+ }
77
+ });
78
+ });
79
+ };
80
+ RestClient.prototype.put = function (requestPath, params, body, headers) {
81
+ if (params === void 0) { params = {}; }
82
+ if (headers === void 0) { headers = {}; }
83
+ return __awaiter(this, void 0, void 0, function () {
84
+ var url, response;
85
+ return __generator(this, function (_a) {
86
+ switch (_a.label) {
87
+ case 0:
88
+ url = "".concat(this.host).concat((0, query_helper_1.generateQueryPath)(requestPath, params));
89
+ return [4 /*yield*/, (0, axios_1.request)(url, axios_1.RequestMethod.PUT, body, headers)];
90
+ case 1:
91
+ response = _a.sent();
92
+ return [2 /*return*/, response.data];
93
+ }
94
+ });
95
+ });
96
+ };
97
+ RestClient.prototype.delete = function (requestPath, params, body, headers) {
98
+ if (params === void 0) { params = {}; }
99
+ if (headers === void 0) { headers = {}; }
100
+ return __awaiter(this, void 0, void 0, function () {
101
+ var url, response;
68
102
  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)];
103
+ switch (_a.label) {
104
+ case 0:
105
+ url = "".concat(this.host).concat((0, query_helper_1.generateQueryPath)(requestPath, params));
106
+ return [4 /*yield*/, (0, axios_1.request)(url, axios_1.RequestMethod.DELETE, body, headers)];
107
+ case 1:
108
+ response = _a.sent();
109
+ return [2 /*return*/, response.data];
110
+ }
71
111
  });
72
112
  });
73
113
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/rest/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAsD;AACtD,2DAA+D;AAC/D,yCAKyB;AACzB;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 {\n RequestMethod,\n Response,\n request,\n ResponseData,\n} 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"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/rest/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAsD;AACtD,2DAA+D;AAC/D,yCAAyD;AACzD;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,EAAW,GAAG,CAAC,EAAA;;wBAAvC,QAAQ,GAAG,SAA4B;wBAC7C,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;;;;;;wBAE5B,GAAG,GAAG,UAAG,IAAI,CAAC,IAAI,SAAG,IAAA,gCAAiB,EAAC,WAAW,EAAE,MAAM,CAAC,CAAE,CAAC;wBACnD,qBAAM,IAAA,eAAO,EAC5B,GAAG,EACH,qBAAa,CAAC,IAAI,EAClB,IAAI,EACJ,OAAO,CACR,EAAA;;wBALK,QAAQ,GAAG,SAKhB;wBACD,sBAAO,QAAQ,CAAC,IAAI,EAAC;;;;KACtB;IAEK,wBAAG,GAAT,UACE,WAAmB,EACnB,MAAiC,EACjC,IAAqB,EACrB,OAAkC;QAFlC,uBAAA,EAAA,WAAiC;QAEjC,wBAAA,EAAA,YAAkC;;;;;;wBAE5B,GAAG,GAAG,UAAG,IAAI,CAAC,IAAI,SAAG,IAAA,gCAAiB,EAAC,WAAW,EAAE,MAAM,CAAC,CAAE,CAAC;wBACnD,qBAAM,IAAA,eAAO,EAC5B,GAAG,EACH,qBAAa,CAAC,GAAG,EACjB,IAAI,EACJ,OAAO,CACR,EAAA;;wBALK,QAAQ,GAAG,SAKhB;wBACD,sBAAO,QAAQ,CAAC,IAAI,EAAC;;;;KACtB;IAEK,2BAAM,GAAZ,UACE,WAAmB,EACnB,MAAiC,EACjC,IAAqB,EACrB,OAAkC;QAFlC,uBAAA,EAAA,WAAiC;QAEjC,wBAAA,EAAA,YAAkC;;;;;;wBAE5B,GAAG,GAAG,UAAG,IAAI,CAAC,IAAI,SAAG,IAAA,gCAAiB,EAAC,WAAW,EAAE,MAAM,CAAC,CAAE,CAAC;wBACnD,qBAAM,IAAA,eAAO,EAC5B,GAAG,EACH,qBAAa,CAAC,MAAM,EACpB,IAAI,EACJ,OAAO,CACR,EAAA;;wBALK,QAAQ,GAAG,SAKhB;wBACD,sBAAO,QAAQ,CAAC,IAAI,EAAC;;;;KACtB;IACH,iBAAC;AAAD,CAAC,AAjED,IAiEC","sourcesContent":["import { API_TIMEOUT } from '../../helpers/constants';\nimport { generateQueryPath } from '../../helpers/query-helper';\nimport { RequestMethod, request } 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<Response>(\n requestPath: string,\n params: NonNullable<unknown> = {},\n ): Promise<Response> {\n const url = `${this.host}${generateQueryPath(requestPath, params)}`;\n const response = await request<Response>(url);\n return response.data;\n }\n\n async post<Response>(\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 const response = await request<Response>(\n url,\n RequestMethod.POST,\n body,\n headers,\n );\n return response.data;\n }\n\n async put<Response>(\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 const response = await request<Response>(\n url,\n RequestMethod.PUT,\n body,\n headers,\n );\n return response.data;\n }\n\n async delete<Response>(\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 const response = await request<Response>(\n url,\n RequestMethod.DELETE,\n body,\n headers,\n );\n return response.data;\n }\n}\n"]}
@@ -4,11 +4,10 @@ export declare enum RequestMethod {
4
4
  GET = "GET",
5
5
  DELETE = "DELETE"
6
6
  }
7
- export type ResponseData = never;
8
- export interface Response {
7
+ export type ApiResponse<Data> = {
9
8
  status: number;
10
- data: ResponseData;
9
+ data: Data;
11
10
  headers: NonNullable<unknown>;
12
- }
13
- export declare function request(url: string, method?: RequestMethod, body?: unknown | null, headers?: NonNullable<unknown>): Promise<Response>;
11
+ };
12
+ export declare function request<ResponseData>(url: string, method?: RequestMethod, body?: unknown | null, headers?: NonNullable<unknown>): Promise<ApiResponse<ResponseData>>;
14
13
  //# sourceMappingURL=axios.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"axios.d.ts","sourceRoot":"/","sources":["clients/lib/axios.ts"],"names":[],"mappings":"AAEA,oBAAY,aAAa;IACvB,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC;AAEjC,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CAC/B;AAMD,wBAAgB,OAAO,CACrB,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,aAAiC,EACzC,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,EACrB,OAAO,GAAE,WAAW,CAAC,OAAO,CAAM,GACjC,OAAO,CAAC,QAAQ,CAAC,CAOnB"}
1
+ {"version":3,"file":"axios.d.ts","sourceRoot":"/","sources":["clients/lib/axios.ts"],"names":[],"mappings":"AAEA,oBAAY,aAAa;IACvB,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,WAAW,CAAC,IAAI,IAAI;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CAC/B,CAAC;AAEF,wBAAgB,OAAO,CAAC,YAAY,EAClC,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,aAAiC,EACzC,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,EACrB,OAAO,GAAE,WAAW,CAAC,OAAO,CAAM,GACjC,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAOpC"}
@@ -1,4 +1,4 @@
1
- import { GetMarginAccountParams, GetMarginAccountResult, GetMarginAccountsParams, GetMarginAccountsResult, GetMarginAccountTransactionHistoryParams, GetMarginAccountTransactionHistoryResult, GetMaxOrderSizeAvailableParams, GetMaxOrderSizeAvailableResult, GetMaxWithdrawBalanceForAccountParams, GetMaxWithdrawBalanceForAccountResult, GetPositionsForMarginAccountParams, GetPositionsForMarginAccountResult, GetPositionsHistoryForMarginAccountParams, GetPositionsHistoryForMarginAccountResult, GetTransactionSimulationInitialDataParams, GetMarginAccountBalanceChartDataParams, GetMarginAccountCollateralsBalanceChartDataParams } from './types';
1
+ import { GetMarginAccountParams, GetMarginAccountResult, GetMarginAccountsParams, GetMarginAccountsResult, GetMarginAccountTransactionHistoryParams, GetMarginAccountTransactionHistoryResult, GetMaxOrderSizeAvailableParams, GetMaxOrderSizeAvailableResult, GetMaxWithdrawBalanceForAccountParams, GetMaxWithdrawBalanceForAccountResult, GetPositionsForMarginAccountParams, GetPositionsForMarginAccountResult, GetPositionsHistoryForMarginAccountParams, GetPositionsHistoryForMarginAccountResult, GetTransactionSimulationInitialDataParams, GetMarginAccountBalanceChartDataParams, GetMarginAccountCollateralsBalanceChartDataParams, EditMarginAccountParams, CloseMarginAccountParams } from './types';
2
2
  import RestClient from '../rest';
3
3
  import { TradeSimulationState } from '@reyaxyz/common';
4
4
  import { GetMarginAccountCollateralsBalanceChartDataResult, GetMarginAccountBalanceChartDataResult } from '@reyaxyz/common';
@@ -36,5 +36,11 @@ export default class AccountClient extends RestClient {
36
36
  getMaxWithdrawBalanceForAccount(params: GetMaxWithdrawBalanceForAccountParams): Promise<GetMaxWithdrawBalanceForAccountResult>;
37
37
  getMarginAccountBalanceChartData(params: GetMarginAccountBalanceChartDataParams): Promise<GetMarginAccountBalanceChartDataResult>;
38
38
  getMarginAccountCollateralsBalanceChartData(params: GetMarginAccountCollateralsBalanceChartDataParams): Promise<GetMarginAccountCollateralsBalanceChartDataResult>;
39
+ editMarginAccount(params: EditMarginAccountParams): Promise<{
40
+ success: boolean;
41
+ }>;
42
+ closeMarginAccount(params: CloseMarginAccountParams): Promise<{
43
+ success: boolean;
44
+ }>;
39
45
  }
40
46
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/account/index.ts"],"names":[],"mappings":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AO9C,+BAA+B,CACnC,MAAM,EAAE,qCAAqC,GAC5C,OAAO,CAAC,qCAAqC,CAAC;IAO3C,gCAAgC,CACpC,MAAM,EAAE,sCAAsC,GAC7C,OAAO,CAAC,sCAAsC,CAAC;IAQ5C,2CAA2C,CAC/C,MAAM,EAAE,iDAAiD,GACxD,OAAO,CAAC,iDAAiD,CAAC;IASvD,iBAAiB,CACrB,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAkB1B,kBAAkB,CACtB,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;CAWjC"}
@@ -59,4 +59,11 @@ export type GetMarginAccountCollateralsBalanceChartDataParams = {
59
59
  granularity: MarginAccountCollateralsBalanceGranularity;
60
60
  };
61
61
  };
62
+ export type EditMarginAccountParams = {
63
+ id: MarginAccountEntity['id'];
64
+ name: MarginAccountEntity['name'];
65
+ };
66
+ export type CloseMarginAccountParams = {
67
+ id: MarginAccountEntity['id'];
68
+ };
62
69
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/account/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,qCAAqC,EACrC,YAAY,EACZ,cAAc,EACd,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,+BAA+B,EAC/B,0CAA0C,EAC3C,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,kCAA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ACH,CAAC;AAEF,MAAM,MAAM,iDAAiD,GAAG;IAC9D,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,0CAA0C,CAAC;KACzD,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,EAAE,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,EAAE,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;CAC/B,CAAC"}
@@ -1,9 +1,10 @@
1
- import { Response, ResponseData } from '../../lib/axios';
2
1
  export default class RestClient {
3
2
  readonly host: string;
4
3
  readonly apiTimeout: number;
5
4
  constructor(host: string, apiTimeout?: number | null);
6
- get(requestPath: string, params?: NonNullable<unknown>): Promise<ResponseData>;
7
- post(requestPath: string, params?: NonNullable<unknown>, body?: unknown | null, headers?: NonNullable<unknown>): Promise<Response>;
5
+ get<Response>(requestPath: string, params?: NonNullable<unknown>): Promise<Response>;
6
+ post<Response>(requestPath: string, params?: NonNullable<unknown>, body?: unknown | null, headers?: NonNullable<unknown>): Promise<Response>;
7
+ put<Response>(requestPath: string, params?: NonNullable<unknown>, body?: unknown | null, headers?: NonNullable<unknown>): Promise<Response>;
8
+ delete<Response>(requestPath: string, params?: NonNullable<unknown>, body?: unknown | null, headers?: NonNullable<unknown>): Promise<Response>;
8
9
  }
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/rest/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,QAAQ,EAER,YAAY,EACb,MAAM,iBAAiB,CAAC;AACzB,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,QAAQ,CAAC,IAAI,EAAE,MA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AAC;IAWd,MAAM,CAAC,QAAQ,EACnB,WAAW,EAAE,MAAM,EACnB,MAAM,GAAE,WAAW,CAAC,OAAO,CAAM,EACjC,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,EACrB,OAAO,GAAE,WAAW,CAAC,OAAO,CAAM,GACjC,OAAO,CAAC,QAAQ,CAAC;CAUrB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/api-sdk",
3
- "version": "0.38.3",
3
+ "version": "0.39.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -33,10 +33,10 @@
33
33
  "generate:coverage-badges": "npx istanbul-badges-readme --silent"
34
34
  },
35
35
  "dependencies": {
36
- "@reyaxyz/common": "0.16.0",
36
+ "@reyaxyz/common": "0.17.0",
37
37
  "axios": "^1.6.2",
38
38
  "bignumber.js": "^9.1.2"
39
39
  },
40
40
  "packageManager": "pnpm@8.10.4",
41
- "gitHead": "28c4df4697c2cc0d031fe75e1bfb17aed8fe63d8"
41
+ "gitHead": "2157586c69a7f5f5242f620ff834c9670055ca6f"
42
42
  }
@@ -1,4 +1,4 @@
1
- import axios, { AxiosRequestConfig } from 'axios';
1
+ import axios from 'axios';
2
2
 
3
3
  export enum RequestMethod {
4
4
  POST = 'POST',
@@ -7,25 +7,19 @@ export enum RequestMethod {
7
7
  DELETE = 'DELETE',
8
8
  }
9
9
 
10
- export type ResponseData = never;
11
-
12
- export interface Response {
10
+ export type ApiResponse<Data> = {
13
11
  status: number;
14
- data: ResponseData;
12
+ data: Data;
15
13
  headers: NonNullable<unknown>;
16
- }
17
-
18
- async function axiosRequest(options: AxiosRequestConfig): Promise<Response> {
19
- return axios(options);
20
- }
14
+ };
21
15
 
22
- export function request(
16
+ export function request<ResponseData>(
23
17
  url: string,
24
18
  method: RequestMethod = RequestMethod.GET,
25
19
  body?: unknown | null,
26
20
  headers: NonNullable<unknown> = {},
27
- ): Promise<Response> {
28
- return axiosRequest({
21
+ ): Promise<ApiResponse<ResponseData>> {
22
+ return axios<never, ApiResponse<ResponseData>>({
29
23
  url,
30
24
  method,
31
25
  data: body,
@@ -16,6 +16,8 @@ import {
16
16
  GetTransactionSimulationInitialDataParams,
17
17
  GetMarginAccountBalanceChartDataParams,
18
18
  GetMarginAccountCollateralsBalanceChartDataParams,
19
+ EditMarginAccountParams,
20
+ CloseMarginAccountParams,
19
21
  } from './types';
20
22
  import RestClient from '../rest';
21
23
  import { TradeSimulationState } from '@reyaxyz/common';
@@ -134,4 +136,39 @@ export default class AccountClient extends RestClient {
134
136
  granularity: params.filters.granularity,
135
137
  });
136
138
  }
139
+
140
+ // TODO: Milan validate
141
+ async editMarginAccount(
142
+ params: EditMarginAccountParams,
143
+ ): Promise<{ success: boolean }> {
144
+ // TODO: Milan do validation before DB
145
+ const name = (params.name || '').trim();
146
+ if (!params.id) {
147
+ throw new Error('Missing margin account id');
148
+ }
149
+ if (name.length === 0 || name.length > 25) {
150
+ throw new Error('Max size 25 characters');
151
+ }
152
+
153
+ const uri = `/api/accounts/${params.id}/edit`;
154
+ return this.put(uri, {
155
+ id: params.id,
156
+ name: params.name,
157
+ });
158
+ }
159
+
160
+ // TODO: Milan validate
161
+ async closeMarginAccount(
162
+ params: CloseMarginAccountParams,
163
+ ): Promise<{ success: boolean }> {
164
+ // TODO: Milan do validation before DB
165
+ if (!params.id) {
166
+ throw new Error('Missing margin account id');
167
+ }
168
+
169
+ const uri = `/api/accounts/${params.id}/edit`;
170
+ return this.delete(uri, {
171
+ id: params.id,
172
+ });
173
+ }
137
174
  }
@@ -92,3 +92,12 @@ export type GetMarginAccountCollateralsBalanceChartDataParams = {
92
92
  granularity: MarginAccountCollateralsBalanceGranularity;
93
93
  };
94
94
  };
95
+
96
+ export type EditMarginAccountParams = {
97
+ id: MarginAccountEntity['id'];
98
+ name: MarginAccountEntity['name'];
99
+ };
100
+
101
+ export type CloseMarginAccountParams = {
102
+ id: MarginAccountEntity['id'];
103
+ };
@@ -1,11 +1,6 @@
1
1
  import { API_TIMEOUT } from '../../helpers/constants';
2
2
  import { generateQueryPath } from '../../helpers/query-helper';
3
- import {
4
- RequestMethod,
5
- Response,
6
- request,
7
- ResponseData,
8
- } from '../../lib/axios';
3
+ import { RequestMethod, request } from '../../lib/axios';
9
4
  export default class RestClient {
10
5
  readonly host: string;
11
6
  readonly apiTimeout: number;
@@ -15,22 +10,60 @@ export default class RestClient {
15
10
  this.apiTimeout = apiTimeout || API_TIMEOUT;
16
11
  }
17
12
 
18
- async get(
13
+ async get<Response>(
19
14
  requestPath: string,
20
15
  params: NonNullable<unknown> = {},
21
- ): Promise<ResponseData> {
16
+ ): Promise<Response> {
17
+ const url = `${this.host}${generateQueryPath(requestPath, params)}`;
18
+ const response = await request<Response>(url);
19
+ return response.data;
20
+ }
21
+
22
+ async post<Response>(
23
+ requestPath: string,
24
+ params: NonNullable<unknown> = {},
25
+ body?: unknown | null,
26
+ headers: NonNullable<unknown> = {},
27
+ ): Promise<Response> {
22
28
  const url = `${this.host}${generateQueryPath(requestPath, params)}`;
23
- const response = await request(url);
29
+ const response = await request<Response>(
30
+ url,
31
+ RequestMethod.POST,
32
+ body,
33
+ headers,
34
+ );
24
35
  return response.data;
25
36
  }
26
37
 
27
- async post(
38
+ async put<Response>(
28
39
  requestPath: string,
29
40
  params: NonNullable<unknown> = {},
30
41
  body?: unknown | null,
31
42
  headers: NonNullable<unknown> = {},
32
43
  ): Promise<Response> {
33
44
  const url = `${this.host}${generateQueryPath(requestPath, params)}`;
34
- return request(url, RequestMethod.POST, body, headers);
45
+ const response = await request<Response>(
46
+ url,
47
+ RequestMethod.PUT,
48
+ body,
49
+ headers,
50
+ );
51
+ return response.data;
52
+ }
53
+
54
+ async delete<Response>(
55
+ requestPath: string,
56
+ params: NonNullable<unknown> = {},
57
+ body?: unknown | null,
58
+ headers: NonNullable<unknown> = {},
59
+ ): Promise<Response> {
60
+ const url = `${this.host}${generateQueryPath(requestPath, params)}`;
61
+ const response = await request<Response>(
62
+ url,
63
+ RequestMethod.DELETE,
64
+ body,
65
+ headers,
66
+ );
67
+ return response.data;
35
68
  }
36
69
  }