@reyaxyz/api-sdk 0.27.0 → 0.28.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.
Files changed (92) hide show
  1. package/dist/clients/modules/{account.js → account/index.js} +2 -2
  2. package/dist/clients/modules/account/index.js.map +1 -0
  3. package/dist/clients/{helpers/trade.simulation.types.js → modules/account/types.js} +1 -1
  4. package/dist/clients/modules/account/types.js.map +1 -0
  5. package/dist/clients/modules/{lp.js → lp/index.js} +2 -2
  6. package/dist/clients/modules/lp/index.js.map +1 -0
  7. package/dist/clients/modules/lp/types.js +13 -0
  8. package/dist/clients/modules/lp/types.js.map +1 -0
  9. package/dist/clients/modules/{markets.js → markets/index.js} +2 -2
  10. package/dist/clients/modules/markets/index.js.map +1 -0
  11. package/dist/clients/modules/markets/types.js +3 -0
  12. package/dist/clients/modules/markets/types.js.map +1 -0
  13. package/dist/clients/modules/{rest.js → rest/index.js} +4 -4
  14. package/dist/clients/modules/rest/index.js.map +1 -0
  15. package/dist/clients/modules/{tokens.js → tokens/index.js} +2 -2
  16. package/dist/clients/modules/tokens/index.js.map +1 -0
  17. package/dist/clients/modules/tokens/types.js +3 -0
  18. package/dist/clients/modules/tokens/types.js.map +1 -0
  19. package/dist/clients/modules/{trade.simulation.js → trade.simulation/index.js} +10 -10
  20. package/dist/clients/modules/trade.simulation/index.js.map +1 -0
  21. package/dist/clients/modules/trade.simulation/types.js +3 -0
  22. package/dist/clients/modules/trade.simulation/types.js.map +1 -0
  23. package/dist/clients/types.js +4 -36
  24. package/dist/clients/types.js.map +1 -1
  25. package/dist/index.js +0 -2
  26. package/dist/index.js.map +1 -1
  27. package/dist/types/clients/modules/{account.d.ts → account/index.d.ts} +4 -4
  28. package/dist/types/clients/modules/account/index.d.ts.map +1 -0
  29. package/dist/types/clients/modules/account/types.d.ts +47 -0
  30. package/dist/types/clients/modules/account/types.d.ts.map +1 -0
  31. package/dist/types/clients/modules/{lp.d.ts → lp/index.d.ts} +4 -3
  32. package/dist/types/clients/modules/lp/index.d.ts.map +1 -0
  33. package/dist/types/clients/modules/lp/types.d.ts +46 -0
  34. package/dist/types/clients/modules/lp/types.d.ts.map +1 -0
  35. package/dist/types/clients/modules/{markets.d.ts → markets/index.d.ts} +3 -3
  36. package/dist/types/clients/modules/markets/index.d.ts.map +1 -0
  37. package/dist/types/clients/modules/markets/types.d.ts +23 -0
  38. package/dist/types/clients/modules/markets/types.d.ts.map +1 -0
  39. package/dist/types/clients/modules/{rest.d.ts → rest/index.d.ts} +2 -2
  40. package/dist/types/clients/modules/rest/index.d.ts.map +1 -0
  41. package/dist/types/clients/modules/{tokens.d.ts → tokens/index.d.ts} +3 -3
  42. package/dist/types/clients/modules/tokens/index.d.ts.map +1 -0
  43. package/dist/types/clients/modules/tokens/types.d.ts +8 -0
  44. package/dist/types/clients/modules/tokens/types.d.ts.map +1 -0
  45. package/dist/types/clients/modules/{trade.simulation.d.ts → trade.simulation/index.d.ts} +3 -3
  46. package/dist/types/clients/modules/trade.simulation/index.d.ts.map +1 -0
  47. package/dist/types/clients/modules/trade.simulation/types.d.ts +19 -0
  48. package/dist/types/clients/modules/trade.simulation/types.d.ts.map +1 -0
  49. package/dist/types/clients/types.d.ts +1 -309
  50. package/dist/types/clients/types.d.ts.map +1 -1
  51. package/dist/types/index.d.ts +0 -2
  52. package/dist/types/index.d.ts.map +1 -1
  53. package/package.json +6 -7
  54. package/src/clients/modules/{account.ts → account/index.ts} +3 -3
  55. package/src/clients/modules/account/types.ts +74 -0
  56. package/src/clients/modules/{lp.ts → lp/index.ts} +5 -3
  57. package/src/clients/modules/lp/types.ts +62 -0
  58. package/src/clients/modules/{markets.ts → markets/index.ts} +2 -2
  59. package/src/clients/modules/markets/types.ts +33 -0
  60. package/src/clients/modules/{rest.ts → rest/index.ts} +8 -3
  61. package/src/clients/modules/{tokens.ts → tokens/index.ts} +2 -2
  62. package/src/clients/modules/tokens/types.ts +9 -0
  63. package/src/clients/modules/{trade.simulation.ts → trade.simulation/index.ts} +3 -4
  64. package/src/clients/modules/trade.simulation/types.ts +21 -0
  65. package/src/clients/types.ts +16 -400
  66. package/src/index.ts +0 -2
  67. package/dist/clients/helpers/exposure.calculator.js +0 -448
  68. package/dist/clients/helpers/exposure.calculator.js.map +0 -1
  69. package/dist/clients/helpers/number.js +0 -13
  70. package/dist/clients/helpers/number.js.map +0 -1
  71. package/dist/clients/helpers/trade.simulation.types.js.map +0 -1
  72. package/dist/clients/modules/account.js.map +0 -1
  73. package/dist/clients/modules/lp.js.map +0 -1
  74. package/dist/clients/modules/markets.js.map +0 -1
  75. package/dist/clients/modules/rest.js.map +0 -1
  76. package/dist/clients/modules/tokens.js.map +0 -1
  77. package/dist/clients/modules/trade.simulation.js.map +0 -1
  78. package/dist/types/clients/helpers/exposure.calculator.d.ts +0 -58
  79. package/dist/types/clients/helpers/exposure.calculator.d.ts.map +0 -1
  80. package/dist/types/clients/helpers/number.d.ts +0 -3
  81. package/dist/types/clients/helpers/number.d.ts.map +0 -1
  82. package/dist/types/clients/helpers/trade.simulation.types.d.ts +0 -113
  83. package/dist/types/clients/helpers/trade.simulation.types.d.ts.map +0 -1
  84. package/dist/types/clients/modules/account.d.ts.map +0 -1
  85. package/dist/types/clients/modules/lp.d.ts.map +0 -1
  86. package/dist/types/clients/modules/markets.d.ts.map +0 -1
  87. package/dist/types/clients/modules/rest.d.ts.map +0 -1
  88. package/dist/types/clients/modules/tokens.d.ts.map +0 -1
  89. package/dist/types/clients/modules/trade.simulation.d.ts.map +0 -1
  90. package/src/clients/helpers/exposure.calculator.ts +0 -799
  91. package/src/clients/helpers/number.ts +0 -8
  92. package/src/clients/helpers/trade.simulation.types.ts +0 -125
@@ -54,7 +54,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
54
54
  return (mod && mod.__esModule) ? mod : { "default": mod };
55
55
  };
56
56
  Object.defineProperty(exports, "__esModule", { value: true });
57
- var rest_1 = __importDefault(require("./rest"));
57
+ var rest_1 = __importDefault(require("../rest"));
58
58
  var AccountClient = /** @class */ (function (_super) {
59
59
  __extends(AccountClient, _super);
60
60
  function AccountClient() {
@@ -167,4 +167,4 @@ var AccountClient = /** @class */ (function (_super) {
167
167
  return AccountClient;
168
168
  }(rest_1.default));
169
169
  exports.default = AccountClient;
170
- //# sourceMappingURL=account.js.map
170
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/account/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,iDAAiC;AAGjC;IAA2C,iCAAU;IAArD;;IA0FA,CAAC;IAzFC;;;;;;;;;;;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,GAA9B,UACE,MAAsC;;;;gBAEhC,GAAG,GAAG,wBAAiB,MAAM,CAAC,eAAe,oBAAiB,CAAC;gBACrE,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,QAAQ,EAAE,MAAM,CAAC,QAAQ;wBACzB,SAAS,EAAE,MAAM,CAAC,SAAS;qBAC5B,CAAC,EAAC;;;KACJ;IAEK,2DAAmC,GAAzC,UACE,MAAiD;;;;gBAE3C,GAAG,GAAG,wBAAiB,MAAM,CAAC,eAAe,2BAAwB,CAAC;gBAC5E,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,QAAQ,EAAE,MAAM,CAAC,QAAQ;qBAC1B,CAAC,EAAC;;;KACJ;IAEK,0DAAkC,GAAxC,UACE,MAAgD;;;;gBAE1C,GAAG,GAAG,wBAAiB,MAAM,CAAC,eAAe,yBAAsB,CAAC;gBAC1E,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,KAAK,EAAE,MAAM,CAAC,KAAK;qBACpB,CAAC,EAAC;;;KACJ;IAEK,uDAA+B,GAArC,UACE,MAA6C;;;;gBAEvC,GAAG,GAAG,wBAAiB,MAAM,CAAC,eAAe,yBAAsB,CAAC;gBAC1E,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,YAAY,EAAE,MAAM,CAAC,YAAY;qBAClC,CAAC,EAAC;;;KACJ;IACH,oBAAC;AAAD,CAAC,AA1FD,CAA2C,cAAU,GA0FpD","sourcesContent":["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} from './types';\nimport RestClient from '../rest';\nimport { TradeSimulationState } 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"]}
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=trade.simulation.types.js.map
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +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';\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"]}
@@ -54,7 +54,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
54
54
  return (mod && mod.__esModule) ? mod : { "default": mod };
55
55
  };
56
56
  Object.defineProperty(exports, "__esModule", { value: true });
57
- var rest_1 = __importDefault(require("./rest"));
57
+ var rest_1 = __importDefault(require("../rest"));
58
58
  var LpClient = /** @class */ (function (_super) {
59
59
  __extends(LpClient, _super);
60
60
  function LpClient() {
@@ -140,4 +140,4 @@ var LpClient = /** @class */ (function (_super) {
140
140
  return LpClient;
141
141
  }(rest_1.default));
142
142
  exports.default = LpClient;
143
- //# sourceMappingURL=lp.js.map
143
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/lp/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,iDAAiC;AAEjC;IAAsC,4BAAU;IAAhD;;IA2DA,CAAC;IA1DO,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;IAEK,8CAA2B,GAAjC,UACE,MAAyC;;;;gBAEnC,GAAG,GAAG,wBAAiB,MAAM,CAAC,EAAE,yBAAsB,CAAC;gBAC7D,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,KAAK,EAAE,MAAM,CAAC,KAAK;wBACnB,OAAO,EAAE,MAAM,CAAC,OAAO;qBACxB,CAAC,EAAC;;;KACJ;IAEK,iCAAc,GAApB,UACE,MAA4B;;;;gBAEtB,GAAG,GAAG,wBAAiB,MAAM,CAAC,EAAE,eAAY,CAAC;gBACnD,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,OAAO,EAAE,MAAM,CAAC,OAAO;qBACxB,CAAC,EAAC;;;KACJ;IAEK,2CAAwB,GAA9B,UACE,MAAsC;;;;gBAEhC,GAAG,GAAG,wBAAiB,MAAM,CAAC,EAAE,sBAAmB,CAAC;gBAC1D,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,OAAO,EAAE,MAAM,CAAC,OAAO;qBACxB,CAAC,EAAC;;;KACJ;IAEK,4CAAyB,GAA/B,UACE,MAAuC;;;;gBAEjC,GAAG,GAAG,wBAAiB,MAAM,CAAC,MAAM,wBAAqB,CAAC;gBAChE,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW;wBACvC,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW;qBACxC,CAAC,EAAC;;;KACJ;IAEK,gDAA6B,GAAnC,UACE,MAA2C;;;;gBAErC,GAAG,GAAG,wBAAiB,MAAM,CAAC,MAAM,4BAAyB,CAAC;gBACpE,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW;wBACvC,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW;wBACvC,OAAO,EAAE,MAAM,CAAC,OAAO;qBACxB,CAAC,EAAC;;;KACJ;IACH,eAAC;AAAD,CAAC,AA3DD,CAAsC,cAAU,GA2D/C","sourcesContent":["import {\n GetLpPoolParams,\n GetLpPositionsParams,\n GetLpPoolResult,\n GetLpPoolsResult,\n GetLpPoolTransactionHistoryParams,\n GetLpPoolTransactionHistoryResult,\n GetLpPositionsResult,\n GetLpPoolWithdrawBalanceParams,\n GetLpPoolWithdrawBalanceResult,\n GetLpPoolBalanceChartDataParams,\n GetLpPoolPerformanceChartDataParams,\n} from './types';\nimport {\n GetLpPoolPerformanceChartDataResult,\n GetLpPoolBalanceChartDataResult,\n} from '@reyaxyz/common';\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 async getLpPoolTransactionHistory(\n params: GetLpPoolTransactionHistoryParams,\n ): Promise<GetLpPoolTransactionHistoryResult> {\n const uri = `/api/lp-pools/${params.id}/transaction-history`;\n return this.get(uri, {\n limit: params.limit,\n address: params.address,\n });\n }\n\n async getLpPositions(\n params: GetLpPositionsParams,\n ): Promise<GetLpPositionsResult> {\n const uri = `/api/lp-pools/${params.id}/positions`;\n return this.get(uri, {\n address: params.address,\n });\n }\n\n async getLpPoolWithdrawBalance(\n params: GetLpPoolWithdrawBalanceParams,\n ): Promise<GetLpPoolWithdrawBalanceResult> {\n const uri = `/api/lp-pools/${params.id}/withdraw-balance`;\n return this.get(uri, {\n address: params.address,\n });\n }\n\n async getLpPoolBalanceChartData(\n params: GetLpPoolBalanceChartDataParams,\n ): Promise<GetLpPoolBalanceChartDataResult> {\n const uri = `/api/lp-pools/${params.poolId}/balance-chart-data`;\n return this.get(uri, {\n timeframeMs: params.filters.timeframeMs,\n granularity: params.filters.granularity,\n });\n }\n\n async getLpPoolPerformanceChartData(\n params: GetLpPoolPerformanceChartDataParams,\n ): Promise<GetLpPoolPerformanceChartDataResult> {\n const uri = `/api/lp-pools/${params.poolId}/performance-chart-data`;\n return this.get(uri, {\n timeframeMs: params.filters.timeframeMs,\n granularity: params.filters.granularity,\n address: params.address,\n });\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PerformanceGranularity = void 0;
4
+ var PerformanceGranularity;
5
+ (function (PerformanceGranularity) {
6
+ PerformanceGranularity[PerformanceGranularity["ONE_MINUTE"] = 60000] = "ONE_MINUTE";
7
+ PerformanceGranularity[PerformanceGranularity["ONE_HOUR"] = 3600000] = "ONE_HOUR";
8
+ PerformanceGranularity[PerformanceGranularity["ONE_DAY"] = 86400000] = "ONE_DAY";
9
+ PerformanceGranularity[PerformanceGranularity["ONE_WEEK"] = 604800000] = "ONE_WEEK";
10
+ PerformanceGranularity[PerformanceGranularity["ONE_MONTH"] = 2592000000] = "ONE_MONTH";
11
+ PerformanceGranularity[PerformanceGranularity["ONE_YEAR"] = 31536000000] = "ONE_YEAR";
12
+ })(PerformanceGranularity || (exports.PerformanceGranularity = PerformanceGranularity = {}));
13
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/lp/types.ts"],"names":[],"mappings":";;;AA6CA,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IAChC,mFAAsB,CAAA;IACtB,iFAAyB,CAAA;IACzB,gFAA6B,CAAA;IAC7B,mFAAkC,CAAA;IAClC,sFAAoC,CAAA;IACpC,qFAAoC,CAAA;AACtC,CAAC,EAPW,sBAAsB,sCAAtB,sBAAsB,QAOjC","sourcesContent":["import {\n LpPoolEntity,\n LpPositionEntity,\n LpTransactionHistoryEntity,\n BalanceGranularity,\n} from '@reyaxyz/common';\n\nexport type GetLpPoolsResult = LpPoolEntity[];\n\nexport type GetLpPoolResult = LpPoolEntity;\n\nexport type GetLpPoolParams = {\n id: LpPoolEntity['id'];\n};\n\nexport type GetLpPoolTransactionHistoryResult = LpTransactionHistoryEntity[];\n\nexport type GetLpPositionsParams = {\n id: LpPoolEntity['id'];\n address: string; // wallet address\n};\n\nexport type GetLpPositionsResult = LpPositionEntity[];\n\nexport type GetLpPoolWithdrawBalanceParams = {\n id: LpPoolEntity['id'];\n address: string; // wallet address\n};\n\nexport type GetLpPoolWithdrawBalanceResult = number;\n\nexport type GetLpPoolTransactionHistoryParams = {\n id: LpPoolEntity['id'];\n address: string; // wallet address\n limit?: number;\n};\n\nexport type GetLpPoolBalanceChartDataParams = {\n poolId: LpPoolEntity['id'];\n filters: {\n timeframeMs: number;\n granularity: BalanceGranularity;\n };\n};\n\nexport enum PerformanceGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\n\nexport type GetLpPoolPerformanceChartDataParams = {\n poolId: LpPoolEntity['id'];\n address: string; // wallet address\n filters: {\n timeframeMs: number;\n granularity: PerformanceGranularity;\n };\n};\n"]}
@@ -54,7 +54,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
54
54
  return (mod && mod.__esModule) ? mod : { "default": mod };
55
55
  };
56
56
  Object.defineProperty(exports, "__esModule", { value: true });
57
- var rest_1 = __importDefault(require("./rest"));
57
+ var rest_1 = __importDefault(require("../rest"));
58
58
  var MarketsClient = /** @class */ (function (_super) {
59
59
  __extends(MarketsClient, _super);
60
60
  function MarketsClient() {
@@ -137,4 +137,4 @@ var MarketsClient = /** @class */ (function (_super) {
137
137
  return MarketsClient;
138
138
  }(rest_1.default));
139
139
  exports.default = MarketsClient;
140
- //# sourceMappingURL=markets.js.map
140
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/markets/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,iDAAiC;AAEjC;IAA2C,iCAAU;IAArD;;IAgEA,CAAC;IA/DC;;;;;;;;;;;;;;;;OAgBG;IAEG,kCAAU,GAAhB;;;;gBACQ,GAAG,GAAG,cAAc,CAAC;gBAC3B,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IAEK,iCAAS,GAAf,UAAgB,MAAuB;;;;gBAC/B,GAAG,GAAG,uBAAgB,MAAM,CAAC,EAAE,CAAE,CAAC;gBACxC,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IAED;;;;;;;;;;;;OAYG;IAEG,wCAAgB,GAAtB,UACE,MAAwB;;;;gBAElB,GAAG,GAAG,+BAAwB,MAAM,CAAC,QAAQ,CAAE,CAAC;gBACtD,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,UAAU,EAAE,MAAM,CAAC,UAAU;wBAC7B,OAAO,EAAE,MAAM,CAAC,OAAO;wBACvB,KAAK,EAAE,MAAM,CAAC,KAAK;wBACnB,KAAK,EAAE,MAAM,CAAC,KAAK;qBACpB,CAAC,EAAC;;;KACJ;IAEK,+CAAuB,GAA7B,UACE,MAAqC;;;;gBAE/B,GAAG,GAAG,sBAAe,MAAM,CAAC,QAAQ,CAAE,CAAC;gBAC7C,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,KAAK,EAAE,MAAM,CAAC,KAAK;wBACnB,4BAA4B,EAAE,MAAM,CAAC,4BAA4B;qBAClE,CAAC,EAAC;;;KACJ;IACH,oBAAC;AAAD,CAAC,AAhED,CAA2C,cAAU,GAgEpD","sourcesContent":["import {\n GetCandlesParams,\n GetMarketParams,\n GetMarketResult,\n GetMarketsResult,\n GetMarketTradingHistoryParams,\n GetTradingHistoryResult,\n MarketCandlesResponse,\n} from './types';\nimport RestClient from '../rest';\n\nexport default class MarketsClient extends RestClient {\n /**\n * Asynchronously retrieves market data from the API.\n *\n * This method makes a request to the API to fetch data for markets. If a specific market is provided as a parameter,\n * it fetches data for that particular market; otherwise, it fetches data for all available markets.\n *\n * @returns {Promise<GetMarketsResult>} A promise that resolves to the response containing market data.\n * @memberof MarketsClient\n *\n * @example\n * // Fetch data for all markets\n * const allMarketsData = await market.getMarkets();\n *\n * @example\n * // Fetch data for a specific market\n * const specificMarketData = await market.getMarkets('ETH-USDC');\n */\n\n async getMarkets(): Promise<GetMarketsResult> {\n const uri = '/api/markets';\n return this.get(uri);\n }\n\n async getMarket(params: GetMarketParams): Promise<GetMarketResult> {\n const uri = `/api/markets/${params.id}`;\n return this.get(uri);\n }\n\n /**\n * Retrieves candlestick data for a specified market.\n *\n * This method fetches historical candlestick (or OHLC - Open, High, Low, Close) data for a given market.\n * The data can be filtered by time range (fromISO and toISO) and resolution.\n *\n * @param {GetCandlesParams} params\n * @returns {Promise<MarketCandlesResponse>} A promise that resolves to the market candlestick data.\n * @memberof MarketsClient\n *\n * @example\n * const marketCandles = await market.getMarketCandles('BTC-USD', '1HR', '2023-01-01T00:00:00Z', '2023-01-02T00:00:00Z');\n */\n\n async getMarketCandles(\n params: GetCandlesParams,\n ): Promise<MarketCandlesResponse> {\n const uri = `/api/markets/candles/${params.marketId}`;\n return this.get(uri, {\n resolution: params.resolution,\n fromISO: params.fromISO,\n toISO: params.toISO,\n limit: params.limit,\n });\n }\n\n async getMarketTradingHistory(\n params: GetMarketTradingHistoryParams,\n ): Promise<GetTradingHistoryResult> {\n const uri = `/api/trades/${params.marketId}`;\n return this.get(uri, {\n limit: params.limit,\n fromTimestampMillisecondsUTC: params.fromTimestampMillisecondsUTC,\n });\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/markets/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n CandlesResolution,\n MarketEntity,\n TradingHistoryEntity,\n Candle,\n} from '@reyaxyz/common';\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\nexport type GetMarketTradingHistoryParams = {\n marketId: number;\n limit?: number;\n fromTimestampMillisecondsUTC?: number;\n};\nexport type GetTradingHistoryResult = TradingHistoryEntity[];\n\nexport interface MarketCandlesResponse {\n candles: Candle[];\n}\n"]}
@@ -36,9 +36,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  }
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- var constants_1 = require("../helpers/constants");
40
- var query_helper_1 = require("../helpers/query-helper");
41
- var axios_1 = require("../lib/axios");
39
+ var constants_1 = require("../../helpers/constants");
40
+ var query_helper_1 = require("../../helpers/query-helper");
41
+ var axios_1 = require("../../lib/axios");
42
42
  var RestClient = /** @class */ (function () {
43
43
  function RestClient(host, apiTimeout) {
44
44
  this.host = host;
@@ -74,4 +74,4 @@ var RestClient = /** @class */ (function () {
74
74
  return RestClient;
75
75
  }());
76
76
  exports.default = RestClient;
77
- //# sourceMappingURL=rest.js.map
77
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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"]}
@@ -54,7 +54,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
54
54
  return (mod && mod.__esModule) ? mod : { "default": mod };
55
55
  };
56
56
  Object.defineProperty(exports, "__esModule", { value: true });
57
- var rest_1 = __importDefault(require("./rest"));
57
+ var rest_1 = __importDefault(require("../rest"));
58
58
  var TokensClient = /** @class */ (function (_super) {
59
59
  __extends(TokensClient, _super);
60
60
  function TokensClient() {
@@ -72,4 +72,4 @@ var TokensClient = /** @class */ (function (_super) {
72
72
  return TokensClient;
73
73
  }(rest_1.default));
74
74
  exports.default = TokensClient;
75
- //# sourceMappingURL=tokens.js.map
75
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/tokens/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iDAAiC;AAEjC;IAA0C,gCAAU;IAApD;;IAOA,CAAC;IANO,uCAAgB,GAAtB,UACE,MAA8B;;;;gBAExB,GAAG,GAAG,sBAAe,MAAM,CAAC,OAAO,CAAE,CAAC;gBAC5C,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IACH,mBAAC;AAAD,CAAC,AAPD,CAA0C,cAAU,GAOnD","sourcesContent":["import { GetAllowedTokensParams, GetAllowedTokenResult } from './types';\nimport RestClient from '../rest';\n\nexport default class TokensClient extends RestClient {\n async getAllowedTokens(\n params: GetAllowedTokensParams,\n ): Promise<GetAllowedTokenResult> {\n const uri = `/api/tokens/${params.chainId}`;\n return this.get(uri);\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/tokens/types.ts"],"names":[],"mappings":"","sourcesContent":["import { SupportedChainId, TokenEntity } from '@reyaxyz/common';\n\nexport type GetAllowedTokensParams = {\n chainId: SupportedChainId;\n};\n\nexport type GetAllowedTokenResult = {\n tokens: TokenEntity[];\n};\n"]}
@@ -39,7 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- var exposure_calculator_1 = require("../helpers/exposure.calculator");
42
+ var common_1 = require("@reyaxyz/common");
43
43
  var bignumber_js_1 = __importDefault(require("bignumber.js"));
44
44
  var TradeSimulationClient = /** @class */ (function () {
45
45
  function TradeSimulationClient(accountClient) {
@@ -85,19 +85,19 @@ var TradeSimulationClient = /** @class */ (function () {
85
85
  var amount = (0, bignumber_js_1.default)(params.amount)
86
86
  .div(this.loadedData.exposureDataPassivePool.oraclePricePerMarket[this.loadedData.marketConfiguration.market_id])
87
87
  .toNumber();
88
- var userAccountExposure = new exposure_calculator_1.ExposureCommand(this.loadedData.exposureDataAccount.rootCollateralPoolId, this.loadedData.exposureDataAccount.oraclePricePerMarket, this.loadedData.exposureDataAccount.accountBalancePerAsset, this.loadedData.exposureDataAccount.groupedByCollateral, this.loadedData.exposureDataAccount.riskMultipliers, this.loadedData.exposureDataAccount.riskMatrices, this.loadedData.exposureDataAccount.exchangeInfoPerAsset, this.loadedData.exposureDataAccount.positionInfoMarketConfiguration, this.loadedData.exposureDataAccount.uniqueTokenAddresses, this.loadedData.exposureDataAccount.uniqueQuoteCollaterals, this.loadedData.exposureDataAccount.tokenMarginInfoPerAsset, this.loadedData.exposureDataAccount.realizedPnLSum, this.loadedData.exposureDataAccount.unrealizedPnLSum);
89
- var passivePoolExposure = new exposure_calculator_1.ExposureCommand(this.loadedData.exposureDataPassivePool.rootCollateralPoolId, this.loadedData.exposureDataPassivePool.oraclePricePerMarket, this.loadedData.exposureDataPassivePool.accountBalancePerAsset, this.loadedData.exposureDataPassivePool.groupedByCollateral, this.loadedData.exposureDataPassivePool.riskMultipliers, this.loadedData.exposureDataPassivePool.riskMatrices, this.loadedData.exposureDataPassivePool.exchangeInfoPerAsset, this.loadedData.exposureDataPassivePool.positionInfoMarketConfiguration, this.loadedData.exposureDataPassivePool.uniqueTokenAddresses, this.loadedData.exposureDataPassivePool.uniqueQuoteCollaterals, this.loadedData.exposureDataPassivePool.tokenMarginInfoPerAsset, this.loadedData.exposureDataPassivePool.realizedPnLSum, this.loadedData.exposureDataPassivePool.unrealizedPnLSum);
88
+ var userAccountExposure = new common_1.ExposureCommand(this.loadedData.exposureDataAccount.rootCollateralPoolId, this.loadedData.exposureDataAccount.oraclePricePerMarket, this.loadedData.exposureDataAccount.accountBalancePerAsset, this.loadedData.exposureDataAccount.groupedByCollateral, this.loadedData.exposureDataAccount.riskMultipliers, this.loadedData.exposureDataAccount.riskMatrices, this.loadedData.exposureDataAccount.exchangeInfoPerAsset, this.loadedData.exposureDataAccount.positionInfoMarketConfiguration, this.loadedData.exposureDataAccount.uniqueTokenAddresses, this.loadedData.exposureDataAccount.uniqueQuoteCollaterals, this.loadedData.exposureDataAccount.tokenMarginInfoPerAsset, this.loadedData.exposureDataAccount.realizedPnLSum, this.loadedData.exposureDataAccount.unrealizedPnLSum);
89
+ var passivePoolExposure = new common_1.ExposureCommand(this.loadedData.exposureDataPassivePool.rootCollateralPoolId, this.loadedData.exposureDataPassivePool.oraclePricePerMarket, this.loadedData.exposureDataPassivePool.accountBalancePerAsset, this.loadedData.exposureDataPassivePool.groupedByCollateral, this.loadedData.exposureDataPassivePool.riskMultipliers, this.loadedData.exposureDataPassivePool.riskMatrices, this.loadedData.exposureDataPassivePool.exchangeInfoPerAsset, this.loadedData.exposureDataPassivePool.positionInfoMarketConfiguration, this.loadedData.exposureDataPassivePool.uniqueTokenAddresses, this.loadedData.exposureDataPassivePool.uniqueQuoteCollaterals, this.loadedData.exposureDataPassivePool.tokenMarginInfoPerAsset, this.loadedData.exposureDataPassivePool.realizedPnLSum, this.loadedData.exposureDataPassivePool.unrealizedPnLSum);
90
90
  var slippage = passivePoolExposure.getSlippage(amount, this.loadedData.marketConfiguration, this.loadedData.marketStorage);
91
- var estimatedPrice = exposure_calculator_1.ExposureCommand.calculateEstimatedPrice(this.loadedData.exposureDataPassivePool.oraclePricePerMarket[this.loadedData.marketConfiguration.market_id], slippage);
92
- var fees = exposure_calculator_1.ExposureCommand.calculateFee(this.loadedData.exposureDataPassivePool.oraclePricePerMarket[this.loadedData.marketConfiguration.market_id], amount, this.loadedData.feeParameter);
91
+ var estimatedPrice = common_1.ExposureCommand.calculateEstimatedPrice(this.loadedData.exposureDataPassivePool.oraclePricePerMarket[this.loadedData.marketConfiguration.market_id], slippage);
92
+ var fees = common_1.ExposureCommand.calculateFee(this.loadedData.exposureDataPassivePool.oraclePricePerMarket[this.loadedData.marketConfiguration.market_id], amount, this.loadedData.feeParameter);
93
93
  var oldMarginInfo = userAccountExposure.getUsdNodeMarginInfo;
94
94
  var newMarginInfo = userAccountExposure.getUsdNodeMarginInfoPostTrade(amount, this.loadedData.marketStorage.quote_collateral, this.loadedData.marketConfiguration);
95
- var impliedLeverage = exposure_calculator_1.ExposureCommand.calculateImpliedLeverage(amount *
95
+ var impliedLeverage = common_1.ExposureCommand.calculateImpliedLeverage(amount *
96
96
  this.loadedData.exposureDataPassivePool.oraclePricePerMarket[this.loadedData.marketConfiguration.market_id], oldMarginInfo.marginBalance - oldMarginInfo.initialDelta, newMarginInfo.marginBalance - newMarginInfo.initialDelta);
97
97
  var postTradeImr = newMarginInfo.marginBalance - newMarginInfo.initialDelta;
98
- var liquidationPrice = exposure_calculator_1.ExposureCommand.calculateLiquidation(newMarginInfo, this.loadedData.exposureDataPassivePool.oraclePricePerMarket[this.loadedData.marketConfiguration.market_id], amount);
99
- var marginRatio = exposure_calculator_1.ExposureCommand.getMarginRatio(newMarginInfo) * 100;
100
- var marginRatioHealth = exposure_calculator_1.ExposureCommand.evaluateHealthStatus(marginRatio);
98
+ var liquidationPrice = common_1.ExposureCommand.calculateLiquidation(newMarginInfo, this.loadedData.exposureDataPassivePool.oraclePricePerMarket[this.loadedData.marketConfiguration.market_id], amount);
99
+ var marginRatio = common_1.ExposureCommand.getMarginRatio(newMarginInfo) * 100;
100
+ var marginRatioHealth = common_1.ExposureCommand.evaluateHealthStatus(marginRatio);
101
101
  return {
102
102
  estimatedPrice: estimatedPrice,
103
103
  estimatedSlippage: slippage * 100,
@@ -112,4 +112,4 @@ var TradeSimulationClient = /** @class */ (function () {
112
112
  return TradeSimulationClient;
113
113
  }());
114
114
  exports.default = TradeSimulationClient;
115
- //# sourceMappingURL=trade.simulation.js.map
115
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/trade.simulation/index.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n SimulateTradeEntity,\n TradeSimulationLoadDataParams,\n TradeSimulationSimulateParams,\n} from './types';\nimport AccountClient from '../account';\nimport { ExposureCommand, TradeSimulationState } from '@reyaxyz/common';\nimport BigNumber from 'bignumber.js';\n\nexport default class TradeSimulationClient {\n private marketId: number | null = null;\n private accountId: number | null = null;\n private loadedData: TradeSimulationState | null = null;\n private accountClient: AccountClient;\n constructor(accountClient: AccountClient) {\n // Constructor added\n this.accountClient = accountClient;\n }\n\n // Method to asynchronously load data based on marketId and accountId\n async arm(params: TradeSimulationLoadDataParams): Promise<void> {\n this.marketId = params.marketId;\n this.accountId = params.marginAccountId;\n\n this.loadedData = await this.fetchMarketData(this.marketId, this.accountId);\n }\n\n private async fetchMarketData(\n marketId: number,\n accountId: number,\n ): Promise<TradeSimulationState> {\n return this.accountClient.getTransactionSimulationInitialData({\n marginAccountId: accountId,\n marketId: marketId,\n });\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 arm() first.');\n }\n\n const amount = BigNumber(params.amount)\n .div(\n this.loadedData.exposureDataPassivePool.oraclePricePerMarket[\n this.loadedData.marketConfiguration.market_id\n ],\n )\n .toNumber();\n\n const userAccountExposure = new ExposureCommand(\n this.loadedData.exposureDataAccount.rootCollateralPoolId,\n this.loadedData.exposureDataAccount.oraclePricePerMarket,\n this.loadedData.exposureDataAccount.accountBalancePerAsset,\n this.loadedData.exposureDataAccount.groupedByCollateral,\n this.loadedData.exposureDataAccount.riskMultipliers,\n this.loadedData.exposureDataAccount.riskMatrices,\n this.loadedData.exposureDataAccount.exchangeInfoPerAsset,\n this.loadedData.exposureDataAccount.positionInfoMarketConfiguration,\n this.loadedData.exposureDataAccount.uniqueTokenAddresses,\n this.loadedData.exposureDataAccount.uniqueQuoteCollaterals,\n this.loadedData.exposureDataAccount.tokenMarginInfoPerAsset,\n this.loadedData.exposureDataAccount.realizedPnLSum,\n this.loadedData.exposureDataAccount.unrealizedPnLSum,\n );\n\n const passivePoolExposure = new ExposureCommand(\n this.loadedData.exposureDataPassivePool.rootCollateralPoolId,\n this.loadedData.exposureDataPassivePool.oraclePricePerMarket,\n this.loadedData.exposureDataPassivePool.accountBalancePerAsset,\n this.loadedData.exposureDataPassivePool.groupedByCollateral,\n this.loadedData.exposureDataPassivePool.riskMultipliers,\n this.loadedData.exposureDataPassivePool.riskMatrices,\n this.loadedData.exposureDataPassivePool.exchangeInfoPerAsset,\n this.loadedData.exposureDataPassivePool.positionInfoMarketConfiguration,\n this.loadedData.exposureDataPassivePool.uniqueTokenAddresses,\n this.loadedData.exposureDataPassivePool.uniqueQuoteCollaterals,\n this.loadedData.exposureDataPassivePool.tokenMarginInfoPerAsset,\n this.loadedData.exposureDataPassivePool.realizedPnLSum,\n this.loadedData.exposureDataPassivePool.unrealizedPnLSum,\n );\n\n const slippage = passivePoolExposure.getSlippage(\n amount,\n this.loadedData.marketConfiguration,\n this.loadedData.marketStorage,\n );\n const estimatedPrice = ExposureCommand.calculateEstimatedPrice(\n this.loadedData.exposureDataPassivePool.oraclePricePerMarket[\n this.loadedData.marketConfiguration.market_id\n ],\n slippage,\n );\n const fees = ExposureCommand.calculateFee(\n this.loadedData.exposureDataPassivePool.oraclePricePerMarket[\n this.loadedData.marketConfiguration.market_id\n ],\n amount,\n this.loadedData.feeParameter,\n );\n\n const oldMarginInfo = userAccountExposure.getUsdNodeMarginInfo;\n\n const newMarginInfo = userAccountExposure.getUsdNodeMarginInfoPostTrade(\n amount,\n this.loadedData.marketStorage.quote_collateral,\n this.loadedData.marketConfiguration,\n );\n\n const impliedLeverage = ExposureCommand.calculateImpliedLeverage(\n amount *\n this.loadedData.exposureDataPassivePool.oraclePricePerMarket[\n this.loadedData.marketConfiguration.market_id\n ],\n oldMarginInfo.marginBalance - oldMarginInfo.initialDelta,\n newMarginInfo.marginBalance - newMarginInfo.initialDelta,\n );\n\n const postTradeImr =\n newMarginInfo.marginBalance - newMarginInfo.initialDelta;\n\n const liquidationPrice = ExposureCommand.calculateLiquidation(\n newMarginInfo,\n this.loadedData.exposureDataPassivePool.oraclePricePerMarket[\n this.loadedData.marketConfiguration.market_id\n ],\n amount,\n );\n\n const marginRatio = ExposureCommand.getMarginRatio(newMarginInfo) * 100;\n\n const marginRatioHealth = ExposureCommand.evaluateHealthStatus(marginRatio);\n\n return {\n estimatedPrice: estimatedPrice,\n estimatedSlippage: slippage * 100,\n fees: fees,\n impliedLeverage: impliedLeverage,\n imr: postTradeImr,\n liquidationPrice: liquidationPrice.toNumber(),\n marginRatio: marginRatio,\n marginRatioHealth: marginRatioHealth,\n } as SimulateTradeEntity;\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/trade.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import { MarginAccountEntity, MarketEntity } from '@reyaxyz/common';\n\nexport type TradeSimulationLoadDataParams = {\n marketId: MarketEntity['id'];\n marginAccountId: MarginAccountEntity['id'];\n};\n\nexport type TradeSimulationSimulateParams = {\n amount: number; // position size, + for long | - for short\n};\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"]}
@@ -1,39 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PerformanceGranularity = exports.BalanceGranularity = exports.SupportedChainId = exports.CandlesResolution = void 0;
4
- var CandlesResolution;
5
- (function (CandlesResolution) {
6
- CandlesResolution["ONE_MINUTE"] = "1MIN";
7
- CandlesResolution["FIVE_MINUTES"] = "5MINS";
8
- CandlesResolution["FIFTEEN_MINUTES"] = "15MINS";
9
- CandlesResolution["THIRTY_MINUTES"] = "30MINS";
10
- CandlesResolution["ONE_HOUR"] = "1HOUR";
11
- CandlesResolution["FOUR_HOURS"] = "4HOURS";
12
- CandlesResolution["ONE_DAY"] = "1DAY";
13
- })(CandlesResolution || (exports.CandlesResolution = CandlesResolution = {}));
14
- // ---- LP ----
15
- var SupportedChainId;
16
- (function (SupportedChainId) {
17
- SupportedChainId[SupportedChainId["polygonMumbai"] = 80001] = "polygonMumbai";
18
- SupportedChainId[SupportedChainId["reyaCronos"] = 1729] = "reyaCronos";
19
- })(SupportedChainId || (exports.SupportedChainId = SupportedChainId = {}));
20
- // --- Lp Pool Balance ---
21
- var BalanceGranularity;
22
- (function (BalanceGranularity) {
23
- BalanceGranularity[BalanceGranularity["ONE_MINUTE"] = 60000] = "ONE_MINUTE";
24
- BalanceGranularity[BalanceGranularity["ONE_HOUR"] = 3600000] = "ONE_HOUR";
25
- BalanceGranularity[BalanceGranularity["ONE_DAY"] = 86400000] = "ONE_DAY";
26
- BalanceGranularity[BalanceGranularity["ONE_WEEK"] = 604800000] = "ONE_WEEK";
27
- BalanceGranularity[BalanceGranularity["ONE_MONTH"] = 2592000000] = "ONE_MONTH";
28
- BalanceGranularity[BalanceGranularity["ONE_YEAR"] = 31536000000] = "ONE_YEAR";
29
- })(BalanceGranularity || (exports.BalanceGranularity = BalanceGranularity = {}));
30
- var PerformanceGranularity;
31
- (function (PerformanceGranularity) {
32
- PerformanceGranularity[PerformanceGranularity["ONE_MINUTE"] = 60000] = "ONE_MINUTE";
33
- PerformanceGranularity[PerformanceGranularity["ONE_HOUR"] = 3600000] = "ONE_HOUR";
34
- PerformanceGranularity[PerformanceGranularity["ONE_DAY"] = 86400000] = "ONE_DAY";
35
- PerformanceGranularity[PerformanceGranularity["ONE_WEEK"] = 604800000] = "ONE_WEEK";
36
- PerformanceGranularity[PerformanceGranularity["ONE_MONTH"] = 2592000000] = "ONE_MONTH";
37
- PerformanceGranularity[PerformanceGranularity["ONE_YEAR"] = 31536000000] = "ONE_YEAR";
38
- })(PerformanceGranularity || (exports.PerformanceGranularity = PerformanceGranularity = {}));
3
+ exports.CandlesResolution = void 0;
4
+ // reexporting what we want to share with integrators
5
+ var common_1 = require("@reyaxyz/common");
6
+ Object.defineProperty(exports, "CandlesResolution", { enumerable: true, get: function () { return common_1.CandlesResolution; } });
39
7
  //# 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;AA6MD,eAAe;AAEf,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,6EAAqB,CAAA;IACrB,sEAAiB,CAAA;AACnB,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B;AAmGD,0BAA0B;AAE1B,IAAY,kBAOX;AAPD,WAAY,kBAAkB;IAC5B,2EAAsB,CAAA;IACtB,yEAAyB,CAAA;IACzB,wEAA6B,CAAA;IAC7B,2EAAkC,CAAA;IAClC,8EAAoC,CAAA;IACpC,6EAAoC,CAAA;AACtC,CAAC,EAPW,kBAAkB,kCAAlB,kBAAkB,QAO7B;AAqCD,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IAChC,mFAAsB,CAAA;IACtB,iFAAyB,CAAA;IACzB,gFAA6B,CAAA;IAC7B,mFAAkC,CAAA;IAClC,sFAAoC,CAAA;IACpC,qFAAoC,CAAA;AACtC,CAAC,EAPW,sBAAsB,sCAAtB,sBAAsB,QAOjC","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 id: string;\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}\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 chainId: SupportedChainId;\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 fromTimestampMillisecondsUTC?: 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 marketId: 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 polygonMumbai = 80001,\n reyaCronos = 1729,\n}\n\nexport type LpPoolEntity = {\n id: number;\n name: string;\n description: string;\n longDescription: string;\n readMoreLink: string;\n currentAPY: number;\n balanceSupplied?: number | null;\n apyChange24H: 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\nexport type TransactionHistoryType = 'deposit' | 'withdrawal';\n\nexport type LpTransactionHistoryEntity = {\n id: number;\n type: TransactionHistoryType;\n token: string;\n amount: number;\n transactionHash: string;\n timestamp: number;\n};\n\nexport type GetLpPoolTransactionHistoryParams = {\n id: LpPoolEntity['id'];\n address: string; // wallet address\n limit?: number;\n};\n\nexport type GetLpPoolTransactionHistoryResult = LpTransactionHistoryEntity[];\n\nexport type GetLpPositionsParams = {\n id: LpPoolEntity['id'];\n address: string; // wallet address\n};\n\nexport type LpPositionEntity = {\n id: number;\n deposited: number;\n currentBalance: number;\n pnl: number;\n fundingRate: number;\n lpPool: LpPoolEntity;\n};\n\nexport type GetLpPositionsResult = LpPositionEntity[];\n\nexport type GetLpPoolWithdrawBalanceParams = {\n id: LpPoolEntity['id'];\n address: string; // wallet address\n};\n\nexport type GetLpPoolWithdrawBalanceResult = number;\n\n// ---- Transaction Simulation ----\n\nexport type GetTransactionSimulationInitialDataParams = {\n marketId: MarketEntity['id'];\n marginAccountId: MarginAccountEntity['id'];\n};\n\n// ---- Transaction History\n\nexport type GetMarginAccountTransactionHistoryParams = {\n marginAccountId: MarginAccountEntity['id'];\n limit?: number;\n};\n\nexport type MarginAccountTransactionHistoryType =\n | 'deposit'\n | 'withdrawal'\n | 'transfer'\n | 'auto_exchange';\n\nexport type MarginAccountTransactionHistoryEntity = {\n id: number;\n type: MarginAccountTransactionHistoryType;\n token: string;\n amount: number;\n transactionHash: string;\n timestamp: number;\n};\n\nexport type GetMarginAccountTransactionHistoryResult =\n MarginAccountTransactionHistoryEntity[];\n\n// --- Lp Pool Balance ---\n\nexport enum BalanceGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\n\nexport type GetLpPoolBalanceChartDataParams = {\n poolId: LpPoolEntity['id'];\n filters: {\n timeframeMs: number;\n granularity: BalanceGranularity;\n };\n};\n\nexport type GetLpPoolBalanceChartDataResult = {\n data: {\n timestampInMs: number;\n value: number;\n }[];\n tvl: number;\n tvlChangePercentage: number;\n apy: number;\n apyChangePercentage: number;\n};\n\n// - LP Account Performance -\nexport type GetLpPoolPerformanceChartDataResult = {\n capitalInvestedData: {\n timestampInMs: number;\n value: number;\n }[];\n balanceData: {\n timestampInMs: number;\n value: number;\n }[];\n balance: number;\n balanceChangePercentage: number;\n capitalInvested: number;\n capitalInvestedChangePercentage: number;\n};\n\nexport enum PerformanceGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\n\nexport type GetLpPoolPerformanceChartDataParams = {\n poolId: LpPoolEntity['id'];\n address: string; // wallet address\n filters: {\n timeframeMs: number;\n granularity: PerformanceGranularity;\n };\n};\n\n// --- Max Withdraw Balance for Margin Account ---\nexport type GetMaxWithdrawBalanceForAccountParams = {\n marginAccountId: MarginAccountEntity['id'];\n tokenAddress: string; // address of usdc/eth/btc\n};\n\nexport type GetMaxWithdrawBalanceForAccountResult = number;\n\n// -- Tokens --\nexport type GetAllowedTokensParams = {\n chainId: number;\n};\n\nexport type GetAllowedTokenResult = {\n tokens: {\n id: string;\n address: string;\n }[];\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,0CAcyB;AAZvB,2GAAA,iBAAiB,OAAA","sourcesContent":["// reexporting what we want to share with integrators\nexport {\n Candle,\n CandlesResolution,\n MarketEntity,\n LpTransactionHistoryEntity,\n TradingHistoryEntity,\n PositionHistoryEntity,\n PositionEntity,\n TransactionHistoryType,\n MarginAccountTransactionHistoryType,\n MarginAccountTransactionHistoryEntity,\n MarginAccountEntity,\n LpPositionEntity,\n LpPoolEntity,\n} from '@reyaxyz/common';\n"]}
package/dist/index.js CHANGED
@@ -18,6 +18,4 @@ exports.ApiClient = void 0;
18
18
  var api_client_1 = require("./clients/api-client");
19
19
  Object.defineProperty(exports, "ApiClient", { enumerable: true, get: function () { return api_client_1.ApiClient; } });
20
20
  __exportStar(require("./clients/types"), exports);
21
- __exportStar(require("./clients/helpers/exposure.calculator"), exports);
22
- __exportStar(require("./clients/helpers/trade.simulation.types"), exports);
23
21
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mDAAiD;AAAxC,uGAAA,SAAS,OAAA;AAClB,kDAAgC;AAChC,wEAAsD;AACtD,2EAAyD","sourcesContent":["export { ApiClient } from './clients/api-client';\nexport * from './clients/types';\nexport * from './clients/helpers/exposure.calculator';\nexport * from './clients/helpers/trade.simulation.types';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mDAAiD;AAAxC,uGAAA,SAAS,OAAA;AAClB,kDAAgC","sourcesContent":["export { ApiClient } from './clients/api-client';\nexport * from './clients/types';\n"]}
@@ -1,6 +1,6 @@
1
- import { GetMarginAccountParams, GetMarginAccountResult, GetMarginAccountsParams, GetMarginAccountsResult, GetMarginAccountTransactionHistoryParams, GetMarginAccountTransactionHistoryResult, GetMaxOrderSizeAvailableParams, GetMaxOrderSizeAvailableResult, GetMaxWithdrawBalanceForAccountParams, GetMaxWithdrawBalanceForAccountResult, GetPositionsForMarginAccountParams, GetPositionsForMarginAccountResult, GetPositionsHistoryForMarginAccountParams, GetPositionsHistoryForMarginAccountResult, GetTransactionSimulationInitialDataParams } from '../types';
2
- import RestClient from './rest';
3
- import { TradeSimulationState } from '../helpers/trade.simulation.types';
1
+ import { GetMarginAccountParams, GetMarginAccountResult, GetMarginAccountsParams, GetMarginAccountsResult, GetMarginAccountTransactionHistoryParams, GetMarginAccountTransactionHistoryResult, GetMaxOrderSizeAvailableParams, GetMaxOrderSizeAvailableResult, GetMaxWithdrawBalanceForAccountParams, GetMaxWithdrawBalanceForAccountResult, GetPositionsForMarginAccountParams, GetPositionsForMarginAccountResult, GetPositionsHistoryForMarginAccountParams, GetPositionsHistoryForMarginAccountResult, GetTransactionSimulationInitialDataParams } from './types';
2
+ import RestClient from '../rest';
3
+ import { TradeSimulationState } from '@reyaxyz/common';
4
4
  export default class AccountClient extends RestClient {
5
5
  /**
6
6
  * Asynchronously retrieves a list of margin accounts associated with a specific address.
@@ -34,4 +34,4 @@ export default class AccountClient extends RestClient {
34
34
  getMarginAccountTransactionHistory(params: GetMarginAccountTransactionHistoryParams): Promise<GetMarginAccountTransactionHistoryResult>;
35
35
  getMaxWithdrawBalanceForAccount(params: GetMaxWithdrawBalanceForAccountParams): Promise<GetMaxWithdrawBalanceForAccountResult>;
36
36
  }
37
- //# sourceMappingURL=account.d.ts.map
37
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/account/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,wCAAwC,EACxC,wCAAwC,EACxC,8BAA8B,EAC9B,8BAA8B,EAC9B,qCAAqC,EACrC,qCAAqC,EACrC,kCAAkC,EAClC,kCAAkC,EAClC,yCAAyC,EACzC,yCAAyC,EACzC,yCAAyC,EAC1C,MAAM,SAAS,CAAC;AACjB,OAAO,UAAU,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD;;;;;;;;;;;SAWK;IAEC,iBAAiB,CACrB,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,uBAAuB,CAAC;IAKnC;;;;;;;;;;OAUG;IAEG,gBAAgB,CACpB,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,sBAAsB,CAAC;IAK5B,4BAA4B,CAChC,MAAM,EAAE,kCAAkC,GACzC,OAAO,CAAC,kCAAkC,CAAC;IAKxC,mCAAmC,CACvC,MAAM,EAAE,yCAAyC,GAChD,OAAO,CAAC,yCAAyC,CAAC;IAK/C,wBAAwB,CAC5B,MAAM,EAAE,8BAA8B,GACrC,OAAO,CAAC,8BAA8B,CAAC;IAQpC,mCAAmC,CACvC,MAAM,EAAE,yCAAyC,GAChD,OAAO,CAAC,oBAAoB,CAAC;IAO1B,kCAAkC,CACtC,MAAM,EAAE,wCAAwC,GAC/C,OAAO,CAAC,wCAAwC,CAAC;IAO9C,+BAA+B,CACnC,MAAM,EAAE,qCAAqC,GAC5C,OAAO,CAAC,qCAAqC,CAAC;CAMlD"}
@@ -0,0 +1,47 @@
1
+ import { MarginAccountEntity, MarginAccountTransactionHistoryEntity, MarketEntity, PositionEntity, PositionHistoryEntity } from '@reyaxyz/common';
2
+ export type GetMarginAccountsParams = {
3
+ address: string;
4
+ limit?: number;
5
+ };
6
+ export type GetMarginAccountParams = {
7
+ address: string;
8
+ marginAccountId: MarginAccountEntity['id'];
9
+ };
10
+ export type GetPositionsForMarginAccountParams = {
11
+ address: string;
12
+ marginAccountId: MarginAccountEntity['id'];
13
+ limit?: number;
14
+ };
15
+ export type GetMarginAccountsResult = MarginAccountEntity[];
16
+ export type GetMarginAccountResult = MarginAccountEntity;
17
+ export type GetMarginAccountTransactionHistoryParams = {
18
+ marginAccountId: MarginAccountEntity['id'];
19
+ limit?: number;
20
+ };
21
+ export type GetMarginAccountTransactionHistoryResult = MarginAccountTransactionHistoryEntity[];
22
+ export type GetMaxOrderSizeAvailableParams = {
23
+ marketId: MarketEntity['id'];
24
+ marginAccountId: MarginAccountEntity['id'];
25
+ direction: 'long' | 'short';
26
+ };
27
+ export type GetMaxOrderSizeAvailableResult = number;
28
+ export type GetMaxWithdrawBalanceForAccountParams = {
29
+ marginAccountId: MarginAccountEntity['id'];
30
+ tokenAddress: string;
31
+ };
32
+ export type GetMaxWithdrawBalanceForAccountResult = number;
33
+ export type GetPositionsForMarginAccountResult = {
34
+ positions: PositionEntity[];
35
+ totalUnrealizedPNL: number;
36
+ };
37
+ export type GetPositionsHistoryForMarginAccountParams = {
38
+ address: string;
39
+ marginAccountId: MarginAccountEntity['id'];
40
+ limit?: number;
41
+ };
42
+ export type GetPositionsHistoryForMarginAccountResult = PositionHistoryEntity[];
43
+ export type GetTransactionSimulationInitialDataParams = {
44
+ marketId: MarketEntity['id'];
45
+ marginAccountId: MarginAccountEntity['id'];
46
+ };
47
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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;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,kCAAkC,GAAG;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,mBAAmB,EAAE,CAAC;AAE5D,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAGzD,MAAM,MAAM,wCAAwC,GAAG;IACrD,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,wCAAwC,GAClD,qCAAqC,EAAE,CAAC;AAG1C,MAAM,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;IAC7B,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,MAAM,CAAC;AAGpD,MAAM,MAAM,qCAAqC,GAAG;IAClD,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,qCAAqC,GAAG,MAAM,CAAC;AAE3D,MAAM,MAAM,kCAAkC,GAAG;IAC/C,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAIF,MAAM,MAAM,yCAAyC,GAAG;IACtD,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AACF,MAAM,MAAM,yCAAyC,GAAG,qBAAqB,EAAE,CAAC;AAIhF,MAAM,MAAM,yCAAyC,GAAG;IACtD,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;IAC7B,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;CAC5C,CAAC"}
@@ -1,5 +1,6 @@
1
- import { GetLpPoolParams, GetLpPositionsParams, GetLpPoolResult, GetLpPoolsResult, GetLpPoolTransactionHistoryParams, GetLpPoolTransactionHistoryResult, GetLpPositionsResult, GetLpPoolWithdrawBalanceParams, GetLpPoolWithdrawBalanceResult, GetLpPoolBalanceChartDataParams, GetLpPoolBalanceChartDataResult, GetLpPoolPerformanceChartDataParams, GetLpPoolPerformanceChartDataResult } from '../types';
2
- import RestClient from './rest';
1
+ import { GetLpPoolParams, GetLpPositionsParams, GetLpPoolResult, GetLpPoolsResult, GetLpPoolTransactionHistoryParams, GetLpPoolTransactionHistoryResult, GetLpPositionsResult, GetLpPoolWithdrawBalanceParams, GetLpPoolWithdrawBalanceResult, GetLpPoolBalanceChartDataParams, GetLpPoolPerformanceChartDataParams } from './types';
2
+ import { GetLpPoolPerformanceChartDataResult, GetLpPoolBalanceChartDataResult } from '@reyaxyz/common';
3
+ import RestClient from '../rest';
3
4
  export default class LpClient extends RestClient {
4
5
  getLpPools(): Promise<GetLpPoolsResult>;
5
6
  getLpPool(params: GetLpPoolParams): Promise<GetLpPoolResult>;
@@ -9,4 +10,4 @@ export default class LpClient extends RestClient {
9
10
  getLpPoolBalanceChartData(params: GetLpPoolBalanceChartDataParams): Promise<GetLpPoolBalanceChartDataResult>;
10
11
  getLpPoolPerformanceChartData(params: GetLpPoolPerformanceChartDataParams): Promise<GetLpPoolPerformanceChartDataResult>;
11
12
  }
12
- //# sourceMappingURL=lp.d.ts.map
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/lp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,iCAAiC,EACjC,iCAAiC,EACjC,oBAAoB,EACpB,8BAA8B,EAC9B,8BAA8B,EAC9B,+BAA+B,EAC/B,mCAAmC,EACpC,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,mCAAmC,EACnC,+BAA+B,EAChC,MAAM,iBAAiB,CAAC;AACzB,OAAO,UAAU,MAAM,SAAS,CAAC;AAEjC,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;IAK5D,2BAA2B,CAC/B,MAAM,EAAE,iCAAiC,GACxC,OAAO,CAAC,iCAAiC,CAAC;IAQvC,cAAc,CAClB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC;IAO1B,wBAAwB,CAC5B,MAAM,EAAE,8BAA8B,GACrC,OAAO,CAAC,8BAA8B,CAAC;IAOpC,yBAAyB,CAC7B,MAAM,EAAE,+BAA+B,GACtC,OAAO,CAAC,+BAA+B,CAAC;IAQrC,6BAA6B,CACjC,MAAM,EAAE,mCAAmC,GAC1C,OAAO,CAAC,mCAAmC,CAAC;CAQhD"}
@@ -0,0 +1,46 @@
1
+ import { LpPoolEntity, LpPositionEntity, LpTransactionHistoryEntity, BalanceGranularity } from '@reyaxyz/common';
2
+ export type GetLpPoolsResult = LpPoolEntity[];
3
+ export type GetLpPoolResult = LpPoolEntity;
4
+ export type GetLpPoolParams = {
5
+ id: LpPoolEntity['id'];
6
+ };
7
+ export type GetLpPoolTransactionHistoryResult = LpTransactionHistoryEntity[];
8
+ export type GetLpPositionsParams = {
9
+ id: LpPoolEntity['id'];
10
+ address: string;
11
+ };
12
+ export type GetLpPositionsResult = LpPositionEntity[];
13
+ export type GetLpPoolWithdrawBalanceParams = {
14
+ id: LpPoolEntity['id'];
15
+ address: string;
16
+ };
17
+ export type GetLpPoolWithdrawBalanceResult = number;
18
+ export type GetLpPoolTransactionHistoryParams = {
19
+ id: LpPoolEntity['id'];
20
+ address: string;
21
+ limit?: number;
22
+ };
23
+ export type GetLpPoolBalanceChartDataParams = {
24
+ poolId: LpPoolEntity['id'];
25
+ filters: {
26
+ timeframeMs: number;
27
+ granularity: BalanceGranularity;
28
+ };
29
+ };
30
+ export declare enum PerformanceGranularity {
31
+ ONE_MINUTE = 60000,
32
+ ONE_HOUR = 3600000,
33
+ ONE_DAY = 86400000,
34
+ ONE_WEEK = 604800000,
35
+ ONE_MONTH = 2592000000,
36
+ ONE_YEAR = 31536000000
37
+ }
38
+ export type GetLpPoolPerformanceChartDataParams = {
39
+ poolId: LpPoolEntity['id'];
40
+ address: string;
41
+ filters: {
42
+ timeframeMs: number;
43
+ granularity: PerformanceGranularity;
44
+ };
45
+ };
46
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/lp/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,0BAA0B,EAC1B,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,gBAAgB,GAAG,YAAY,EAAE,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC;AAE3C,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG,0BAA0B,EAAE,CAAC;AAE7E,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,EAAE,CAAC;AAEtD,MAAM,MAAM,8BAA8B,GAAG;IAC3C,EAAE,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,MAAM,CAAC;AAEpD,MAAM,MAAM,iCAAiC,GAAG;IAC9C,EAAE,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,kBAAkB,CAAC;KACjC,CAAC;CACH,CAAC;AAEF,oBAAY,sBAAsB;IAChC,UAAU,QAAY;IACtB,QAAQ,UAAiB;IACzB,OAAO,WAAsB;IAC7B,QAAQ,YAA0B;IAClC,SAAS,aAA2B;IACpC,QAAQ,cAA4B;CACrC;AAED,MAAM,MAAM,mCAAmC,GAAG;IAChD,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,sBAAsB,CAAC;KACrC,CAAC;CACH,CAAC"}
@@ -1,5 +1,5 @@
1
- import { GetCandlesParams, GetMarketParams, GetMarketResult, GetMarketsResult, GetMarketTradingHistoryParams, GetTradingHistoryResult, MarketCandlesResponse } from '../types';
2
- import RestClient from './rest';
1
+ import { GetCandlesParams, GetMarketParams, GetMarketResult, GetMarketsResult, GetMarketTradingHistoryParams, GetTradingHistoryResult, MarketCandlesResponse } from './types';
2
+ import RestClient from '../rest';
3
3
  export default class MarketsClient extends RestClient {
4
4
  /**
5
5
  * Asynchronously retrieves market data from the API.
@@ -36,4 +36,4 @@ export default class MarketsClient extends RestClient {
36
36
  getMarketCandles(params: GetCandlesParams): Promise<MarketCandlesResponse>;
37
37
  getMarketTradingHistory(params: GetMarketTradingHistoryParams): Promise<GetTradingHistoryResult>;
38
38
  }
39
- //# sourceMappingURL=markets.d.ts.map
39
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/markets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,6BAA6B,EAC7B,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AACjB,OAAO,UAAU,MAAM,SAAS,CAAC;AAEjC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD;;;;;;;;;;;;;;;;OAgBG;IAEG,UAAU,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAKvC,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAKlE;;;;;;;;;;;;OAYG;IAEG,gBAAgB,CACpB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,qBAAqB,CAAC;IAU3B,uBAAuB,CAC3B,MAAM,EAAE,6BAA6B,GACpC,OAAO,CAAC,uBAAuB,CAAC;CAOpC"}
@@ -0,0 +1,23 @@
1
+ import { CandlesResolution, MarketEntity, TradingHistoryEntity, Candle } from '@reyaxyz/common';
2
+ export type GetMarketsResult = MarketEntity[];
3
+ export type GetMarketResult = MarketEntity;
4
+ export type GetMarketParams = {
5
+ id: MarketEntity['id'];
6
+ };
7
+ export type GetCandlesParams = {
8
+ marketId: MarketEntity['id'];
9
+ resolution: CandlesResolution;
10
+ fromISO?: string | null;
11
+ toISO?: string | null;
12
+ limit?: number | null;
13
+ };
14
+ export type GetMarketTradingHistoryParams = {
15
+ marketId: number;
16
+ limit?: number;
17
+ fromTimestampMillisecondsUTC?: number;
18
+ };
19
+ export type GetTradingHistoryResult = TradingHistoryEntity[];
20
+ export interface MarketCandlesResponse {
21
+ candles: Candle[];
22
+ }
23
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/markets/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,MAAM,EACP,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,gBAAgB,GAAG,YAAY,EAAE,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC;AAE3C,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;IAC7B,UAAU,EAAE,iBAAiB,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4BAA4B,CAAC,EAAE,MAAM,CAAC;CACvC,CAAC;AACF,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,EAAE,CAAC;AAE7D,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB"}
@@ -1,4 +1,4 @@
1
- import { Response, ResponseData } from '../lib/axios';
1
+ import { Response, ResponseData } from '../../lib/axios';
2
2
  export default class RestClient {
3
3
  readonly host: string;
4
4
  readonly apiTimeout: number;
@@ -6,4 +6,4 @@ export default class RestClient {
6
6
  get(requestPath: string, params?: NonNullable<unknown>): Promise<ResponseData>;
7
7
  post(requestPath: string, params?: NonNullable<unknown>, body?: unknown | null, headers?: NonNullable<unknown>): Promise<Response>;
8
8
  }
9
- //# sourceMappingURL=rest.d.ts.map
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAK9C,GAAG,CACP,WAAW,EAAE,MAAM,EACnB,MAAM,GAAE,WAAW,CAAC,OAAO,CAAM,GAChC,OAAO,CAAC,YAAY,CAAC;IAMlB,IAAI,CACR,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;CAIrB"}
@@ -1,6 +1,6 @@
1
- import { GetAllowedTokensParams, GetAllowedTokenResult } from '../types';
2
- import RestClient from './rest';
1
+ import { GetAllowedTokensParams, GetAllowedTokenResult } from './types';
2
+ import RestClient from '../rest';
3
3
  export default class TokensClient extends RestClient {
4
4
  getAllowedTokens(params: GetAllowedTokensParams): Promise<GetAllowedTokenResult>;
5
5
  }
6
- //# sourceMappingURL=tokens.d.ts.map
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/tokens/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,UAAU,MAAM,SAAS,CAAC;AAEjC,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,UAAU;IAC5C,gBAAgB,CACpB,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,qBAAqB,CAAC;CAIlC"}