@reyaxyz/api-sdk 0.47.1 → 0.48.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 (24) hide show
  1. package/dist/clients/api-client.js +28 -51
  2. package/dist/clients/api-client.js.map +1 -1
  3. package/dist/clients/helpers/constants.js +21 -5
  4. package/dist/clients/helpers/constants.js.map +1 -1
  5. package/dist/clients/modules/deposit-existing-MA.simulation/types.js.map +1 -1
  6. package/dist/clients/modules/withdraw-MA.simulation/index.js +6 -3
  7. package/dist/clients/modules/withdraw-MA.simulation/index.js.map +1 -1
  8. package/dist/clients/modules/withdraw-MA.simulation/types.js.map +1 -1
  9. package/dist/types/clients/api-client.d.ts +11 -13
  10. package/dist/types/clients/api-client.d.ts.map +1 -1
  11. package/dist/types/clients/helpers/constants.d.ts +6 -3
  12. package/dist/types/clients/helpers/constants.d.ts.map +1 -1
  13. package/dist/types/clients/modules/deposit-existing-MA.simulation/types.d.ts +1 -1
  14. package/dist/types/clients/modules/deposit-existing-MA.simulation/types.d.ts.map +1 -1
  15. package/dist/types/clients/modules/withdraw-MA.simulation/index.d.ts +3 -1
  16. package/dist/types/clients/modules/withdraw-MA.simulation/index.d.ts.map +1 -1
  17. package/dist/types/clients/modules/withdraw-MA.simulation/types.d.ts +2 -2
  18. package/dist/types/clients/modules/withdraw-MA.simulation/types.d.ts.map +1 -1
  19. package/package.json +3 -3
  20. package/src/clients/api-client.ts +40 -50
  21. package/src/clients/helpers/constants.ts +25 -6
  22. package/src/clients/modules/deposit-existing-MA.simulation/types.ts +1 -1
  23. package/src/clients/modules/withdraw-MA.simulation/index.ts +12 -3
  24. package/src/clients/modules/withdraw-MA.simulation/types.ts +1 -2
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
4
  };
@@ -21,7 +10,6 @@ var account_1 = __importDefault(require("./modules/account"));
21
10
  var trade_simulation_1 = __importDefault(require("./modules/trade.simulation"));
22
11
  var lp_1 = __importDefault(require("./modules/lp"));
23
12
  var tokens_1 = __importDefault(require("./modules/tokens"));
24
- var common_1 = require("@reyaxyz/common");
25
13
  var owner_1 = __importDefault(require("./modules/owner"));
26
14
  var edit_collateral_simulation_1 = __importDefault(require("./modules/edit-collateral.simulation"));
27
15
  var deposit_existing_MA_simulation_1 = __importDefault(require("./modules/deposit-existing-MA.simulation"));
@@ -31,30 +19,22 @@ var withdraw_MA_simulation_1 = __importDefault(require("./modules/withdraw-MA.si
31
19
  * @description Client for API
32
20
  */
33
21
  var ApiClient = /** @class */ (function () {
34
- function ApiClient(config) {
35
- this.apiEndpoint = config.environment
36
- ? constants_1.API_URLS[config.environment]
37
- : constants_1.API_URLS['test'];
38
- ApiClient.chain =
39
- config.environment === 'production'
40
- ? common_1.ReyaChainId.reyaNetwork
41
- : common_1.ReyaChainId.reyaCronos;
42
- ApiClient.config = __assign(__assign({}, ApiClient.config), config);
43
- this._markets = new markets_1.default(this.apiEndpoint);
44
- this._account = new account_1.default(this.apiEndpoint);
45
- this._lp = new lp_1.default(this.apiEndpoint);
46
- this._trade_simulation = new trade_simulation_1.default(this._account);
47
- this._edit_collateral_simulation = new edit_collateral_simulation_1.default(this._account);
48
- this._deposit_existing_MA_simulation =
49
- new deposit_existing_MA_simulation_1.default(this._edit_collateral_simulation);
50
- this._deposit_new_MA_simulation = new deposit_new_MA_simulation_1.default(this._deposit_existing_MA_simulation);
51
- this._withdraw_MA_simulation = new withdraw_MA_simulation_1.default(this._edit_collateral_simulation);
52
- this._tokens = new tokens_1.default(this.apiEndpoint);
53
- this._owner = new owner_1.default(this.apiEndpoint);
22
+ function ApiClient() {
23
+ this._markets = new markets_1.default(ApiClient.config.apiEndpoint);
24
+ this._account = new account_1.default(ApiClient.config.apiEndpoint);
25
+ this._lp = new lp_1.default(ApiClient.config.apiEndpoint);
26
+ this._tradeSimulation = new trade_simulation_1.default(this._account);
27
+ this._editCollateralSimulation = new edit_collateral_simulation_1.default(this._account);
28
+ this._depositExistingMASimulation = new deposit_existing_MA_simulation_1.default(this._editCollateralSimulation);
29
+ this._depositNewMASimulation = new deposit_new_MA_simulation_1.default(this._depositExistingMASimulation);
30
+ this._withdrawMASimulation = new withdraw_MA_simulation_1.default(this._editCollateralSimulation, ApiClient.config.chain);
31
+ this._tokens = new tokens_1.default(ApiClient.config.apiEndpoint);
32
+ this._owner = new owner_1.default(ApiClient.config.apiEndpoint);
54
33
  }
55
- ApiClient.configure = function (config) {
56
- ApiClient.config = config;
57
- ApiClient.instance = new ApiClient(config);
34
+ ApiClient.configure = function (environment) {
35
+ ApiClient.config =
36
+ constants_1.API_CLIENT_CONFIGS[environment] || constants_1.API_CLIENT_CONFIGS['test'];
37
+ ApiClient.instance = new ApiClient();
58
38
  };
59
39
  ApiClient.getInstance = function () {
60
40
  if (!ApiClient.instance) {
@@ -64,10 +44,10 @@ var ApiClient = /** @class */ (function () {
64
44
  };
65
45
  Object.defineProperty(ApiClient, "network", {
66
46
  get: function () {
67
- if (!ApiClient.chain) {
47
+ if (!ApiClient.config.chain) {
68
48
  throw new Error('ApiClient is not configured');
69
49
  }
70
- return ApiClient.chain;
50
+ return ApiClient.config.chain;
71
51
  },
72
52
  enumerable: false,
73
53
  configurable: true
@@ -105,7 +85,7 @@ var ApiClient = /** @class */ (function () {
105
85
  * Provides access to the TradeSimulationClient instance.
106
86
  * This getter allows for interacting with trade simulation functionalities.
107
87
  * It ensures a singleton pattern by fetching the instance from the ApiClient's
108
- * private `_trade_simulation` property, ensuring that trade simulation operations
88
+ * private `_tradeSimulation` property, ensuring that trade simulation operations
109
89
  * use a consistent client configuration and state.
110
90
  *
111
91
  * @returns {TradeSimulationClient} An instance of TradeSimulationClient for trade simulation operations.
@@ -115,7 +95,7 @@ var ApiClient = /** @class */ (function () {
115
95
  * const tradeSimulationClient = ApiClient.tradeSimulation;
116
96
  */
117
97
  get: function () {
118
- return ApiClient.getInstance()._trade_simulation;
98
+ return ApiClient.getInstance()._tradeSimulation;
119
99
  },
120
100
  enumerable: false,
121
101
  configurable: true
@@ -125,7 +105,7 @@ var ApiClient = /** @class */ (function () {
125
105
  * Provides access to the EditCollateralSimulationClient instance.
126
106
  * This getter allows for interacting with edit collateral simulation functionalities.
127
107
  * It ensures a singleton pattern by fetching the instance from the ApiClient's
128
- * private `_edit_collateral_simulation` property, ensuring that edit collateral simulation operations
108
+ * private `_editCollateralSimulation` property, ensuring that edit collateral simulation operations
129
109
  * use a consistent client configuration and state.
130
110
  *
131
111
  * @returns {EditCollateralSimulationClient} An instance of EditCollateralSimulationClient for edit collateral simulation operations.
@@ -135,7 +115,7 @@ var ApiClient = /** @class */ (function () {
135
115
  * const editCollateralSimulationClient = ApiClient.editCollateralSimulation;
136
116
  */
137
117
  get: function () {
138
- return ApiClient.getInstance()._edit_collateral_simulation;
118
+ return ApiClient.getInstance()._editCollateralSimulation;
139
119
  },
140
120
  enumerable: false,
141
121
  configurable: true
@@ -145,7 +125,7 @@ var ApiClient = /** @class */ (function () {
145
125
  * Provides access to the DepositExistingMASimulationClient instance.
146
126
  * This getter allows for interacting with trade simulation functionalities.
147
127
  * It ensures a singleton pattern by fetching the instance from the ApiClient's
148
- * private `_deposit_existing_MA_simulation` property, ensuring that trade simulation operations
128
+ * private `_depositExistingMASimulation` property, ensuring that trade simulation operations
149
129
  * use a consistent client configuration and state.
150
130
  *
151
131
  * @returns {DepositExistingMASimulationClient} An instance of DepositExistingMASimulationClient for trade simulation operations.
@@ -155,7 +135,7 @@ var ApiClient = /** @class */ (function () {
155
135
  * const depositExistingMASimulationClient = ApiClient.depositExistingMASimulation;
156
136
  */
157
137
  get: function () {
158
- return ApiClient.getInstance()._deposit_existing_MA_simulation;
138
+ return ApiClient.getInstance()._depositExistingMASimulation;
159
139
  },
160
140
  enumerable: false,
161
141
  configurable: true
@@ -165,7 +145,7 @@ var ApiClient = /** @class */ (function () {
165
145
  * Provides access to the DepositNewMASimulationClient instance.
166
146
  * This getter allows for interacting with trade simulation functionalities.
167
147
  * It ensures a singleton pattern by fetching the instance from the ApiClient's
168
- * private `_deposit_new_MA_simulation` property, ensuring that trade simulation operations
148
+ * private `_depositNewMASimulation` property, ensuring that trade simulation operations
169
149
  * use a consistent client configuration and state.
170
150
  *
171
151
  * @returns {DepositNewMASimulationClient} An instance of DepositNewMASimulationClient for trade simulation operations.
@@ -175,7 +155,7 @@ var ApiClient = /** @class */ (function () {
175
155
  * const depositNewMASimulationClient = ApiClient.depositNewMASimulation;
176
156
  */
177
157
  get: function () {
178
- return ApiClient.getInstance()._deposit_new_MA_simulation;
158
+ return ApiClient.getInstance()._depositNewMASimulation;
179
159
  },
180
160
  enumerable: false,
181
161
  configurable: true
@@ -185,7 +165,7 @@ var ApiClient = /** @class */ (function () {
185
165
  * Provides access to the WithdrawMASimulationClient instance.
186
166
  * This getter allows for interacting with trade simulation functionalities.
187
167
  * It ensures a singleton pattern by fetching the instance from the ApiClient's
188
- * private `_withdraw_MA_simulation` property, ensuring that trade simulation operations
168
+ * private `_withdrawMASimulation` property, ensuring that trade simulation operations
189
169
  * use a consistent client configuration and state.
190
170
  *
191
171
  * @returns {WithdrawMASimulationClient} An instance of WithrawMASimulationClient for trade simulation operations.
@@ -195,7 +175,7 @@ var ApiClient = /** @class */ (function () {
195
175
  * const withdrawMASimulationClient = ApiClient.withdrawMASimulation;
196
176
  */
197
177
  get: function () {
198
- return ApiClient.getInstance()._withdraw_MA_simulation;
178
+ return ApiClient.getInstance()._withdrawMASimulation;
199
179
  },
200
180
  enumerable: false,
201
181
  configurable: true
@@ -251,10 +231,7 @@ var ApiClient = /** @class */ (function () {
251
231
  enumerable: false,
252
232
  configurable: true
253
233
  });
254
- ApiClient.config = {
255
- environment: 'test', // default value
256
- timeout: constants_1.API_TIMEOUT, // default value, e.g., 5000 milliseconds
257
- };
234
+ ApiClient.config = constants_1.API_CLIENT_CONFIGS['test'];
258
235
  return ApiClient;
259
236
  }());
260
237
  exports.ApiClient = ApiClient;
@@ -1 +1 @@
1
- {"version":3,"file":"api-client.js","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAA2E;AAC3E,8DAA8C;AAC9C,8DAA8C;AAC9C,gFAA+D;AAC/D,oDAAoC;AACpC,4DAA4C;AAC5C,0CAA8C;AAC9C,0DAA0C;AAC1C,oGAAkF;AAClF,4GAAyF;AACzF,kGAA+E;AAC/E,4FAA0E;AAE1E;;GAEG;AACH;IAmBE,mBAAoB,MAAqB;QACvC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW;YACnC,CAAC,CAAC,oBAAQ,CAAC,MAAM,CAAC,WAAW,CAAC;YAC9B,CAAC,CAAC,oBAAQ,CAAC,MAAM,CAAC,CAAC;QACrB,SAAS,CAAC,KAAK;YACb,MAAM,CAAC,WAAW,KAAK,YAAY;gBACjC,CAAC,CAAC,oBAAW,CAAC,WAAW;gBACzB,CAAC,CAAC,oBAAW,CAAC,UAAU,CAAC;QAC7B,SAAS,CAAC,MAAM,yBAAQ,SAAS,CAAC,MAAM,GAAK,MAAM,CAAE,CAAC;QACtD,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,CAAC,GAAG,GAAG,IAAI,YAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC1C,IAAI,CAAC,iBAAiB,GAAG,IAAI,0BAAqB,CAAC,IAAI,CAAC,Q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ND,IA4NC;AA5NY,8BAAS","sourcesContent":["import { API_TIMEOUT, API_URLS, ServiceConfig } from './helpers/constants';\nimport MarketsClient from './modules/markets';\nimport AccountClient from './modules/account';\nimport TradeSimulationClient from './modules/trade.simulation';\nimport LpClient from './modules/lp';\nimport TokensClient from './modules/tokens';\nimport { ReyaChainId } from '@reyaxyz/common';\nimport OwnerClient from './modules/owner';\nimport EditCollateralSimulationClient from './modules/edit-collateral.simulation';\nimport DepositExistingMASimulationClient from './modules/deposit-existing-MA.simulation';\nimport DepositNewMASimulationClient from './modules/deposit-new-MA.simulation';\nimport WithdrawMASimulationClient from './modules/withdraw-MA.simulation';\n\n/**\n * @description Client for API\n */\nexport class ApiClient {\n private static instance: ApiClient;\n private static config: ServiceConfig = {\n environment: 'test', // default value\n timeout: API_TIMEOUT, // default value, e.g., 5000 milliseconds\n };\n private readonly apiEndpoint: string;\n private readonly _markets: MarketsClient;\n private readonly _account: AccountClient;\n private readonly _lp: LpClient;\n private readonly _trade_simulation: TradeSimulationClient;\n private readonly _edit_collateral_simulation: EditCollateralSimulationClient;\n private readonly _deposit_existing_MA_simulation: DepositExistingMASimulationClient;\n private readonly _deposit_new_MA_simulation: DepositNewMASimulationClient;\n private readonly _withdraw_MA_simulation: WithdrawMASimulationClient;\n private readonly _tokens: TokensClient;\n private readonly _owner: OwnerClient;\n private static chain: ReyaChainId;\n\n private constructor(config: ServiceConfig) {\n this.apiEndpoint = config.environment\n ? API_URLS[config.environment]\n : API_URLS['test'];\n ApiClient.chain =\n config.environment === 'production'\n ? ReyaChainId.reyaNetwork\n : ReyaChainId.reyaCronos;\n ApiClient.config = { ...ApiClient.config, ...config };\n this._markets = new MarketsClient(this.apiEndpoint);\n this._account = new AccountClient(this.apiEndpoint);\n this._lp = new LpClient(this.apiEndpoint);\n this._trade_simulation = new TradeSimulationClient(this._account);\n this._edit_collateral_simulation = new EditCollateralSimulationClient(\n this._account,\n );\n this._deposit_existing_MA_simulation =\n new DepositExistingMASimulationClient(this._edit_collateral_simulation);\n this._deposit_new_MA_simulation = new DepositNewMASimulationClient(\n this._deposit_existing_MA_simulation,\n );\n this._withdraw_MA_simulation = new WithdrawMASimulationClient(\n this._edit_collateral_simulation,\n );\n this._tokens = new TokensClient(this.apiEndpoint);\n this._owner = new OwnerClient(this.apiEndpoint);\n }\n\n public static configure(config: ServiceConfig): void {\n ApiClient.config = config;\n ApiClient.instance = new ApiClient(config);\n }\n\n private static getInstance(): ApiClient {\n if (!ApiClient.instance) {\n throw new Error(\n 'ApiClient is not configured. Please configure it before using.',\n );\n }\n return ApiClient.instance;\n }\n public static get network(): ReyaChainId {\n if (!ApiClient.chain) {\n throw new Error('ApiClient is not configured');\n }\n return ApiClient.chain;\n }\n\n /**\n * Provides access to the MarketsClient instance.\n * This getter allows for interacting with market-related API functionalities.\n *\n * @returns {MarketsClient} An instance of MarketsClient for market-related operations.\n * @memberof ApiClient\n */\n public static get markets(): MarketsClient {\n return ApiClient.getInstance()._markets;\n }\n\n /**\n * Provides access to the AccountClient instance.\n * This getter allows for interacting with account-related API functionalities.\n *\n * @returns {AccountClient} An instance of AccountClient for account-related operations.\n * @memberof ApiClient\n */\n public static get account(): AccountClient {\n return ApiClient.getInstance()._account;\n }\n\n /**\n * Provides access to the TradeSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_trade_simulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TradeSimulationClient} An instance of TradeSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the trade simulation client from the ApiClient\n * const tradeSimulationClient = ApiClient.tradeSimulation;\n */\n\n public static get tradeSimulation(): TradeSimulationClient {\n return ApiClient.getInstance()._trade_simulation;\n }\n\n /**\n * Provides access to the EditCollateralSimulationClient instance.\n * This getter allows for interacting with edit collateral simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_edit_collateral_simulation` property, ensuring that edit collateral simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {EditCollateralSimulationClient} An instance of EditCollateralSimulationClient for edit collateral simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the edit collateral simulation client from the ApiClient\n * const editCollateralSimulationClient = ApiClient.editCollateralSimulation;\n */\n\n public static get editCollateralSimulationClient(): EditCollateralSimulationClient {\n return ApiClient.getInstance()._edit_collateral_simulation;\n }\n\n /**\n * Provides access to the DepositExistingMASimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_deposit_existing_MA_simulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositExistingMASimulationClient} An instance of DepositExistingMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit existing Ma simulation client from the ApiClient\n * const depositExistingMASimulationClient = ApiClient.depositExistingMASimulation;\n */\n\n public static get depositExistingMASimulation(): DepositExistingMASimulationClient {\n return ApiClient.getInstance()._deposit_existing_MA_simulation;\n }\n\n /**\n * Provides access to the DepositNewMASimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_deposit_new_MA_simulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositNewMASimulationClient} An instance of DepositNewMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit new MA simulation client from the ApiClient\n * const depositNewMASimulationClient = ApiClient.depositNewMASimulation;\n */\n\n public static get depositNewMASimulation(): DepositNewMASimulationClient {\n return ApiClient.getInstance()._deposit_new_MA_simulation;\n }\n\n /**\n * Provides access to the WithdrawMASimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_withdraw_MA_simulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {WithdrawMASimulationClient} An instance of WithrawMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the withdraw MA simulation client from the ApiClient\n * const withdrawMASimulationClient = ApiClient.withdrawMASimulation;\n */\n\n public static get withdrawMASimulation(): WithdrawMASimulationClient {\n return ApiClient.getInstance()._withdraw_MA_simulation;\n }\n\n /**\n * Gets the current instance of the LpClient from the ApiClient.\n *\n * This static getter allows access to the LpClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the LpClient directly, bypassing the need to manually access the internal `_lp` property of the ApiClient instance.\n *\n * @returns {LpClient} The LpClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and LpClient are properly set up\n * const lpClient = ApiClient.lp;\n */\n public static get lp(): LpClient {\n return ApiClient.getInstance()._lp;\n }\n\n /**\n * Gets the current instance of the TokensClient from the ApiClient.\n *\n * This static getter allows access to the TokensClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the TokensClient directly, bypassing the need to manually access the internal `_tokens` property of the ApiClient instance.\n *\n * @returns {TokensClient} The TokensClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and TokensClient are properly set up\n * const tokensClient = ApiClient.tokens;\n */\n public static get tokens(): TokensClient {\n return ApiClient.getInstance()._tokens;\n }\n\n /**\n * Gets the current instance of the OwnerClient from the ApiClient.\n *\n * This static getter allows access to the OwnerClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the OwnerClient directly, bypassing the need to manually access the internal `_owner` property of the ApiClient instance.\n *\n * @returns {OwnerClient} The OwnerClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and OwnerClient are properly set up\n * const ownerClient = ApiClient.tokens;\n */\n public static get owner(): OwnerClient {\n return ApiClient.getInstance()._owner;\n }\n}\n"]}
1
+ {"version":3,"file":"api-client.js","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":";;;;;;AAAA,iDAAwE;AACxE,8DAA8C;AAC9C,8DAA8C;AAC9C,gFAA+D;AAC/D,oDAAoC;AACpC,4DAA4C;AAE5C,0DA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C,WAAW,EAAE,CAAC,qBAAqB,CAAC;QACvD,CAAC;;;OAAA;IAYD,sBAAkB,eAAE;QAVpB;;;;;;;;;WASG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC;QACrC,CAAC;;;OAAA;IAYD,sBAAkB,mBAAM;QAVxB;;;;;;;;;WASG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC;QACzC,CAAC;;;OAAA;IAYD,sBAAkB,kBAAK;QAVvB;;;;;;;;;WASG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC;QACxC,CAAC;;;OAAA;IA/Mc,gBAAM,GAAkB,8BAAkB,CAAC,MAAM,CAAC,CAAC;IAgNpE,gBAAC;CAAA,AAlND,IAkNC;AAlNY,8BAAS","sourcesContent":["import { API_CLIENT_CONFIGS, ServiceConfig } from './helpers/constants';\nimport MarketsClient from './modules/markets';\nimport AccountClient from './modules/account';\nimport TradeSimulationClient from './modules/trade.simulation';\nimport LpClient from './modules/lp';\nimport TokensClient from './modules/tokens';\nimport { ReyaChainId } from '@reyaxyz/common';\nimport OwnerClient from './modules/owner';\nimport EditCollateralSimulationClient from './modules/edit-collateral.simulation';\nimport DepositExistingMASimulationClient from './modules/deposit-existing-MA.simulation';\nimport DepositNewMASimulationClient from './modules/deposit-new-MA.simulation';\nimport WithdrawMASimulationClient from './modules/withdraw-MA.simulation';\n\n/**\n * @description Client for API\n */\nexport class ApiClient {\n private static instance: ApiClient;\n private static config: ServiceConfig = API_CLIENT_CONFIGS['test'];\n private readonly _markets: MarketsClient;\n private readonly _account: AccountClient;\n private readonly _lp: LpClient;\n private readonly _tradeSimulation: TradeSimulationClient;\n private readonly _editCollateralSimulation: EditCollateralSimulationClient;\n private readonly _depositExistingMASimulation: DepositExistingMASimulationClient;\n private readonly _depositNewMASimulation: DepositNewMASimulationClient;\n private readonly _withdrawMASimulation: WithdrawMASimulationClient;\n private readonly _tokens: TokensClient;\n private readonly _owner: OwnerClient;\n\n private constructor() {\n this._markets = new MarketsClient(ApiClient.config.apiEndpoint);\n this._account = new AccountClient(ApiClient.config.apiEndpoint);\n this._lp = new LpClient(ApiClient.config.apiEndpoint);\n this._tradeSimulation = new TradeSimulationClient(this._account);\n this._editCollateralSimulation = new EditCollateralSimulationClient(\n this._account,\n );\n this._depositExistingMASimulation = new DepositExistingMASimulationClient(\n this._editCollateralSimulation,\n );\n this._depositNewMASimulation = new DepositNewMASimulationClient(\n this._depositExistingMASimulation,\n );\n this._withdrawMASimulation = new WithdrawMASimulationClient(\n this._editCollateralSimulation,\n ApiClient.config.chain,\n );\n this._tokens = new TokensClient(ApiClient.config.apiEndpoint);\n this._owner = new OwnerClient(ApiClient.config.apiEndpoint);\n }\n\n public static configure(environment: ServiceConfig['environment']): void {\n ApiClient.config =\n API_CLIENT_CONFIGS[environment] || API_CLIENT_CONFIGS['test'];\n ApiClient.instance = new ApiClient();\n }\n\n private static getInstance(): ApiClient {\n if (!ApiClient.instance) {\n throw new Error(\n 'ApiClient is not configured. Please configure it before using.',\n );\n }\n return ApiClient.instance;\n }\n public static get network(): ReyaChainId {\n if (!ApiClient.config.chain) {\n throw new Error('ApiClient is not configured');\n }\n return ApiClient.config.chain;\n }\n\n /**\n * Provides access to the MarketsClient instance.\n * This getter allows for interacting with market-related API functionalities.\n *\n * @returns {MarketsClient} An instance of MarketsClient for market-related operations.\n * @memberof ApiClient\n */\n public static get markets(): MarketsClient {\n return ApiClient.getInstance()._markets;\n }\n\n /**\n * Provides access to the AccountClient instance.\n * This getter allows for interacting with account-related API functionalities.\n *\n * @returns {AccountClient} An instance of AccountClient for account-related operations.\n * @memberof ApiClient\n */\n public static get account(): AccountClient {\n return ApiClient.getInstance()._account;\n }\n\n /**\n * Provides access to the TradeSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_tradeSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TradeSimulationClient} An instance of TradeSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the trade simulation client from the ApiClient\n * const tradeSimulationClient = ApiClient.tradeSimulation;\n */\n\n public static get tradeSimulation(): TradeSimulationClient {\n return ApiClient.getInstance()._tradeSimulation;\n }\n\n /**\n * Provides access to the EditCollateralSimulationClient instance.\n * This getter allows for interacting with edit collateral simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_editCollateralSimulation` property, ensuring that edit collateral simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {EditCollateralSimulationClient} An instance of EditCollateralSimulationClient for edit collateral simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the edit collateral simulation client from the ApiClient\n * const editCollateralSimulationClient = ApiClient.editCollateralSimulation;\n */\n\n public static get editCollateralSimulationClient(): EditCollateralSimulationClient {\n return ApiClient.getInstance()._editCollateralSimulation;\n }\n\n /**\n * Provides access to the DepositExistingMASimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_depositExistingMASimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositExistingMASimulationClient} An instance of DepositExistingMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit existing Ma simulation client from the ApiClient\n * const depositExistingMASimulationClient = ApiClient.depositExistingMASimulation;\n */\n\n public static get depositExistingMASimulation(): DepositExistingMASimulationClient {\n return ApiClient.getInstance()._depositExistingMASimulation;\n }\n\n /**\n * Provides access to the DepositNewMASimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_depositNewMASimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositNewMASimulationClient} An instance of DepositNewMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit new MA simulation client from the ApiClient\n * const depositNewMASimulationClient = ApiClient.depositNewMASimulation;\n */\n\n public static get depositNewMASimulation(): DepositNewMASimulationClient {\n return ApiClient.getInstance()._depositNewMASimulation;\n }\n\n /**\n * Provides access to the WithdrawMASimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_withdrawMASimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {WithdrawMASimulationClient} An instance of WithrawMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the withdraw MA simulation client from the ApiClient\n * const withdrawMASimulationClient = ApiClient.withdrawMASimulation;\n */\n\n public static get withdrawMASimulation(): WithdrawMASimulationClient {\n return ApiClient.getInstance()._withdrawMASimulation;\n }\n\n /**\n * Gets the current instance of the LpClient from the ApiClient.\n *\n * This static getter allows access to the LpClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the LpClient directly, bypassing the need to manually access the internal `_lp` property of the ApiClient instance.\n *\n * @returns {LpClient} The LpClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and LpClient are properly set up\n * const lpClient = ApiClient.lp;\n */\n public static get lp(): LpClient {\n return ApiClient.getInstance()._lp;\n }\n\n /**\n * Gets the current instance of the TokensClient from the ApiClient.\n *\n * This static getter allows access to the TokensClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the TokensClient directly, bypassing the need to manually access the internal `_tokens` property of the ApiClient instance.\n *\n * @returns {TokensClient} The TokensClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and TokensClient are properly set up\n * const tokensClient = ApiClient.tokens;\n */\n public static get tokens(): TokensClient {\n return ApiClient.getInstance()._tokens;\n }\n\n /**\n * Gets the current instance of the OwnerClient from the ApiClient.\n *\n * This static getter allows access to the OwnerClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the OwnerClient directly, bypassing the need to manually access the internal `_owner` property of the ApiClient instance.\n *\n * @returns {OwnerClient} The OwnerClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and OwnerClient are properly set up\n * const ownerClient = ApiClient.tokens;\n */\n public static get owner(): OwnerClient {\n return ApiClient.getInstance()._owner;\n }\n}\n"]}
@@ -1,10 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.API_URLS = exports.API_TIMEOUT = void 0;
3
+ exports.API_CLIENT_CONFIGS = exports.API_TIMEOUT = void 0;
4
+ var common_1 = require("@reyaxyz/common");
4
5
  exports.API_TIMEOUT = 2500;
5
- exports.API_URLS = {
6
- production: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',
7
- test: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',
8
- local: 'http://localhost:3000',
6
+ exports.API_CLIENT_CONFIGS = {
7
+ local: {
8
+ chain: common_1.ReyaChainId.reyaCronos,
9
+ apiEndpoint: 'http://localhost:3000',
10
+ environment: 'local',
11
+ timeout: exports.API_TIMEOUT,
12
+ },
13
+ production: {
14
+ chain: common_1.ReyaChainId.reyaNetwork,
15
+ apiEndpoint: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',
16
+ environment: 'production',
17
+ timeout: exports.API_TIMEOUT,
18
+ },
19
+ test: {
20
+ chain: common_1.ReyaChainId.reyaCronos,
21
+ apiEndpoint: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',
22
+ environment: 'test',
23
+ timeout: exports.API_TIMEOUT,
24
+ },
9
25
  };
10
26
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"/","sources":["clients/helpers/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAW,IAAI,CAAC;AAQ3B,QAAA,QAAQ,GAAuC;IAC1D,UAAU,EAAE,kDAAkD;IAC9D,IAAI,EAAE,kDAAkD;IACxD,KAAK,EAAE,uBAAuB;CAC/B,CAAC","sourcesContent":["export const API_TIMEOUT: number = 2500;\n\ntype ServiceEnvironment = 'production' | 'test' | 'local';\nexport interface ServiceConfig {\n environment?: ServiceEnvironment; // Configuration for SDK, such as base URL for the REST API\n timeout?: number; // Optional timeout for API requests\n}\n\nexport const API_URLS: Record<ServiceEnvironment, string> = {\n production: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',\n test: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',\n local: 'http://localhost:3000',\n};\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"/","sources":["clients/helpers/constants.ts"],"names":[],"mappings":";;;AAAA,0CAA8C;AAEjC,QAAA,WAAW,GAAW,IAAI,CAAC;AAU3B,QAAA,kBAAkB,GAA8C;IAC3E,KAAK,EAAE;QACL,KAAK,EAAE,oBAAW,CAAC,UAAU;QAC7B,WAAW,EAAE,uBAAuB;QACpC,WAAW,EAAE,OAAO;QACpB,OAAO,EAAE,mBAAW;KACrB;IACD,UAAU,EAAE;QACV,KAAK,EAAE,oBAAW,CAAC,WAAW;QAC9B,WAAW,EAAE,kDAAkD;QAC/D,WAAW,EAAE,YAAY;QACzB,OAAO,EAAE,mBAAW;KACrB;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,oBAAW,CAAC,UAAU;QAC7B,WAAW,EAAE,kDAAkD;QAC/D,WAAW,EAAE,MAAM;QACnB,OAAO,EAAE,mBAAW;KACrB;CACF,CAAC","sourcesContent":["import { ReyaChainId } from '@reyaxyz/common';\n\nexport const API_TIMEOUT: number = 2500;\n\ntype ServiceEnvironment = 'production' | 'test' | 'local';\nexport interface ServiceConfig {\n chain: ReyaChainId;\n apiEndpoint: string;\n environment: ServiceEnvironment; // Configuration for SDK, such as base URL for the REST API\n timeout: number; // Optional timeout for API requests\n}\n\nexport const API_CLIENT_CONFIGS: Record<ServiceEnvironment, ServiceConfig> = {\n local: {\n chain: ReyaChainId.reyaCronos,\n apiEndpoint: 'http://localhost:3000',\n environment: 'local',\n timeout: API_TIMEOUT,\n },\n production: {\n chain: ReyaChainId.reyaNetwork,\n apiEndpoint: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',\n environment: 'production',\n timeout: API_TIMEOUT,\n },\n test: {\n chain: ReyaChainId.reyaCronos,\n apiEndpoint: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',\n environment: 'test',\n timeout: API_TIMEOUT,\n },\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MarginAccountEntity,\n MoneyInOutChainId,\n TokenEntity,\n} from '@reyaxyz/common';\nimport { EditCollateralSimulationLoadDataParams } from '../edit-collateral.simulation/types';\n\nexport type DepositExistingMASimulationLoadDataParams =\n EditCollateralSimulationLoadDataParams;\n\nexport type DepositExistingMASimulationSimulateParams = {\n moneyInOutChainId: MoneyInOutChainId;\n amount: number;\n tokenAddress: TokenEntity['address'];\n};\n\nexport type SimulateDepositExistingMAEntity = {\n fees: number;\n feesUnderlyingToken: string;\n bridgeTimeInMS: number;\n marginRatio: MarginAccountEntity['marginRatioPercentage'];\n marginRatioHealth: MarginAccountEntity['marginRatioHealth'];\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MarginAccountEntity,\n MoneyInOutChainId,\n TokenEntity,\n} from '@reyaxyz/common';\nimport { EditCollateralSimulationLoadDataParams } from '../edit-collateral.simulation/types';\n\nexport type DepositExistingMASimulationLoadDataParams =\n EditCollateralSimulationLoadDataParams;\n\nexport type DepositExistingMASimulationSimulateParams = {\n moneyInOutChainId: MoneyInOutChainId;\n amount: number;\n tokenAddress: TokenEntity['address'];\n};\n\nexport type SimulateDepositExistingMAEntity = {\n fees: number;\n feesUnderlyingToken: TokenEntity['id'];\n bridgeTimeInMS: number;\n marginRatio: MarginAccountEntity['marginRatioPercentage'];\n marginRatioHealth: MarginAccountEntity['marginRatioHealth'];\n};\n"]}
@@ -37,10 +37,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  var common_1 = require("@reyaxyz/common");
40
+ var common_2 = require("@reyaxyz/common");
40
41
  var WithdrawMASimulationClient = /** @class */ (function () {
41
- function WithdrawMASimulationClient(editCollateralClient) {
42
- // Constructor added
42
+ function WithdrawMASimulationClient(editCollateralClient, reyaChainId) {
43
43
  this.editCollateralClient = editCollateralClient;
44
+ this.reyaChainId = reyaChainId;
44
45
  }
45
46
  // Method to asynchronously load data based on accountId
46
47
  WithdrawMASimulationClient.prototype.arm = function (params) {
@@ -67,11 +68,13 @@ var WithdrawMASimulationClient = /** @class */ (function () {
67
68
  moneyInOutChainId: params.moneyInOutChainId,
68
69
  }).bridgeTimeInMS;
69
70
  var fees = (0, common_1.getSocketWithdrawFees)({
70
- reyaChainId: params.reyaChainId,
71
+ reyaChainId: this.reyaChainId,
71
72
  tokenAddress: params.tokenAddress,
72
73
  });
74
+ var feesUnderlyingToken = (0, common_2.getTokenDetails)(params.tokenAddress).tokenName;
73
75
  return {
74
76
  fees: fees.fees,
77
+ feesUnderlyingToken: feesUnderlyingToken,
75
78
  bridgeTimeInMS: bridgeTimeInMS,
76
79
  marginRatio: simulateEditCollateralEntity.marginRatio,
77
80
  marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/withdraw-MA.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA6E;AAQ7E;IAEE,oCAAY,oBAA0C;QACpD,oBAAoB;QACpB,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACnD,CAAC;IAED,wDAAwD;IAClD,wCAAG,GAAT,UAAU,MAA0C;;;;4BAClD,qBAAM,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC;4BAClC,eAAe,EAAE,MAAM,CAAC,eAAe;yBACxC,CAAC,EAAA;;wBAFF,SAEE,CAAC;;;;;KACJ;IAED,+DAA+D;IAC/D,6CAAQ,GAAR,UACE,MAA0C;QAE1C,IAAM,4BAA4B,GAAG,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC;YACtE,YAAY,EAAE,CAAC,MAAM,CAAC,MAAM;YAC5B,YAAY,EAAE,MAAM,CAAC,YAAY;SAClC,CAAC,CAAC;QAEH,IAAM,cAAc,GAAG,IAAA,4BAAmB,EAAC;YACzC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;SAC5C,CAAC,CAAC,cAAc,CAAC;QAElB,IAAM,IAAI,GAAG,IAAA,8BAAqB,EAAC;YACjC,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,YAAY,EAAE,MAAM,CAAC,YAAY;SAClC,CAAC,CAAC;QAEH,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,cAAc,EAAE,cAAc;YAC9B,WAAW,EAAE,4BAA4B,CAAC,WAAW;YACrD,iBAAiB,EAAE,4BAA4B,CAAC,iBAAiB;SACtC,CAAC;IAChC,CAAC;IACH,iCAAC;AAAD,CAAC,AAvCD,IAuCC","sourcesContent":["import { getSocketBridgeTime, getSocketWithdrawFees } from '@reyaxyz/common';\nimport EditCollateralClient from '../edit-collateral.simulation';\nimport {\n SimulateWithdrawMAEntity,\n WithdrawMASimulationLoadDataParams,\n WithdrawMASimulationSimulateParams,\n} from './types';\n\nexport default class WithdrawMASimulationClient {\n private editCollateralClient: EditCollateralClient;\n constructor(editCollateralClient: EditCollateralClient) {\n // Constructor added\n this.editCollateralClient = editCollateralClient;\n }\n\n // Method to asynchronously load data based on accountId\n async arm(params: WithdrawMASimulationLoadDataParams): Promise<void> {\n await this.editCollateralClient.arm({\n marginAccountId: params.marginAccountId,\n });\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(\n params: WithdrawMASimulationSimulateParams,\n ): SimulateWithdrawMAEntity {\n const simulateEditCollateralEntity = this.editCollateralClient.simulate({\n signedAmount: -params.amount,\n tokenAddress: params.tokenAddress,\n });\n\n const bridgeTimeInMS = getSocketBridgeTime({\n moneyInOutChainId: params.moneyInOutChainId,\n }).bridgeTimeInMS;\n\n const fees = getSocketWithdrawFees({\n reyaChainId: params.reyaChainId,\n tokenAddress: params.tokenAddress,\n });\n\n return {\n fees: fees.fees,\n bridgeTimeInMS: bridgeTimeInMS,\n marginRatio: simulateEditCollateralEntity.marginRatio,\n marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,\n } as SimulateWithdrawMAEntity;\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/withdraw-MA.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA6E;AAO7E,0CAA+D;AAE/D;IAIE,oCACE,oBAA0C,EAC1C,WAAwB;QAExB,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;QACjD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED,wDAAwD;IAClD,wCAAG,GAAT,UAAU,MAA0C;;;;4BAClD,qBAAM,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC;4BAClC,eAAe,EAAE,MAAM,CAAC,eAAe;yBACxC,CAAC,EAAA;;wBAFF,SAEE,CAAC;;;;;KACJ;IAED,+DAA+D;IAC/D,6CAAQ,GAAR,UACE,MAA0C;QAE1C,IAAM,4BAA4B,GAAG,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC;YACtE,YAAY,EAAE,CAAC,MAAM,CAAC,MAAM;YAC5B,YAAY,EAAE,MAAM,CAAC,YAAY;SAClC,CAAC,CAAC;QAEH,IAAM,cAAc,GAAG,IAAA,4BAAmB,EAAC;YACzC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;SAC5C,CAAC,CAAC,cAAc,CAAC;QAElB,IAAM,IAAI,GAAG,IAAA,8BAAqB,EAAC;YACjC,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,YAAY,EAAE,MAAM,CAAC,YAAY;SAClC,CAAC,CAAC;QAEH,IAAM,mBAAmB,GAAG,IAAA,wBAAe,EAAC,MAAM,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC;QAE3E,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,mBAAmB,EAAE,mBAAmB;YACxC,cAAc,EAAE,cAAc;YAC9B,WAAW,EAAE,4BAA4B,CAAC,WAAW;YACrD,iBAAiB,EAAE,4BAA4B,CAAC,iBAAiB;SACtC,CAAC;IAChC,CAAC;IACH,iCAAC;AAAD,CAAC,AA/CD,IA+CC","sourcesContent":["import { getSocketBridgeTime, getSocketWithdrawFees } from '@reyaxyz/common';\nimport EditCollateralClient from '../edit-collateral.simulation';\nimport {\n SimulateWithdrawMAEntity,\n WithdrawMASimulationLoadDataParams,\n WithdrawMASimulationSimulateParams,\n} from './types';\nimport { ReyaChainId, getTokenDetails } from '@reyaxyz/common';\n\nexport default class WithdrawMASimulationClient {\n private editCollateralClient: EditCollateralClient;\n private reyaChainId: ReyaChainId;\n\n constructor(\n editCollateralClient: EditCollateralClient,\n reyaChainId: ReyaChainId,\n ) {\n this.editCollateralClient = editCollateralClient;\n this.reyaChainId = reyaChainId;\n }\n\n // Method to asynchronously load data based on accountId\n async arm(params: WithdrawMASimulationLoadDataParams): Promise<void> {\n await this.editCollateralClient.arm({\n marginAccountId: params.marginAccountId,\n });\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(\n params: WithdrawMASimulationSimulateParams,\n ): SimulateWithdrawMAEntity {\n const simulateEditCollateralEntity = this.editCollateralClient.simulate({\n signedAmount: -params.amount,\n tokenAddress: params.tokenAddress,\n });\n\n const bridgeTimeInMS = getSocketBridgeTime({\n moneyInOutChainId: params.moneyInOutChainId,\n }).bridgeTimeInMS;\n\n const fees = getSocketWithdrawFees({\n reyaChainId: this.reyaChainId,\n tokenAddress: params.tokenAddress,\n });\n\n const feesUnderlyingToken = getTokenDetails(params.tokenAddress).tokenName;\n\n return {\n fees: fees.fees,\n feesUnderlyingToken: feesUnderlyingToken,\n bridgeTimeInMS: bridgeTimeInMS,\n marginRatio: simulateEditCollateralEntity.marginRatio,\n marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,\n } as SimulateWithdrawMAEntity;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/withdraw-MA.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MarginAccountEntity,\n MoneyInOutChainId,\n ReyaChainId,\n TokenEntity,\n} from '@reyaxyz/common';\nimport { EditCollateralSimulationLoadDataParams } from '../edit-collateral.simulation/types';\n\nexport type WithdrawMASimulationLoadDataParams =\n EditCollateralSimulationLoadDataParams;\n\nexport type WithdrawMASimulationSimulateParams = {\n reyaChainId: ReyaChainId;\n moneyInOutChainId: MoneyInOutChainId;\n amount: number;\n tokenAddress: TokenEntity['address'];\n};\n\nexport type SimulateWithdrawMAEntity = {\n fees: number;\n bridgeTimeInMS: number;\n marginRatio: MarginAccountEntity['marginRatioPercentage'];\n marginRatioHealth: MarginAccountEntity['marginRatioHealth'];\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/withdraw-MA.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MarginAccountEntity,\n MoneyInOutChainId,\n TokenEntity,\n} from '@reyaxyz/common';\nimport { EditCollateralSimulationLoadDataParams } from '../edit-collateral.simulation/types';\n\nexport type WithdrawMASimulationLoadDataParams =\n EditCollateralSimulationLoadDataParams;\n\nexport type WithdrawMASimulationSimulateParams = {\n moneyInOutChainId: MoneyInOutChainId;\n amount: number;\n tokenAddress: TokenEntity['address'];\n};\n\nexport type SimulateWithdrawMAEntity = {\n fees: number;\n feesUnderlyingToken: TokenEntity['id'];\n bridgeTimeInMS: number;\n marginRatio: MarginAccountEntity['marginRatioPercentage'];\n marginRatioHealth: MarginAccountEntity['marginRatioHealth'];\n};\n"]}
@@ -16,20 +16,18 @@ import WithdrawMASimulationClient from './modules/withdraw-MA.simulation';
16
16
  export declare class ApiClient {
17
17
  private static instance;
18
18
  private static config;
19
- private readonly apiEndpoint;
20
19
  private readonly _markets;
21
20
  private readonly _account;
22
21
  private readonly _lp;
23
- private readonly _trade_simulation;
24
- private readonly _edit_collateral_simulation;
25
- private readonly _deposit_existing_MA_simulation;
26
- private readonly _deposit_new_MA_simulation;
27
- private readonly _withdraw_MA_simulation;
22
+ private readonly _tradeSimulation;
23
+ private readonly _editCollateralSimulation;
24
+ private readonly _depositExistingMASimulation;
25
+ private readonly _depositNewMASimulation;
26
+ private readonly _withdrawMASimulation;
28
27
  private readonly _tokens;
29
28
  private readonly _owner;
30
- private static chain;
31
29
  private constructor();
32
- static configure(config: ServiceConfig): void;
30
+ static configure(environment: ServiceConfig['environment']): void;
33
31
  private static getInstance;
34
32
  static get network(): ReyaChainId;
35
33
  /**
@@ -52,7 +50,7 @@ export declare class ApiClient {
52
50
  * Provides access to the TradeSimulationClient instance.
53
51
  * This getter allows for interacting with trade simulation functionalities.
54
52
  * It ensures a singleton pattern by fetching the instance from the ApiClient's
55
- * private `_trade_simulation` property, ensuring that trade simulation operations
53
+ * private `_tradeSimulation` property, ensuring that trade simulation operations
56
54
  * use a consistent client configuration and state.
57
55
  *
58
56
  * @returns {TradeSimulationClient} An instance of TradeSimulationClient for trade simulation operations.
@@ -66,7 +64,7 @@ export declare class ApiClient {
66
64
  * Provides access to the EditCollateralSimulationClient instance.
67
65
  * This getter allows for interacting with edit collateral simulation functionalities.
68
66
  * It ensures a singleton pattern by fetching the instance from the ApiClient's
69
- * private `_edit_collateral_simulation` property, ensuring that edit collateral simulation operations
67
+ * private `_editCollateralSimulation` property, ensuring that edit collateral simulation operations
70
68
  * use a consistent client configuration and state.
71
69
  *
72
70
  * @returns {EditCollateralSimulationClient} An instance of EditCollateralSimulationClient for edit collateral simulation operations.
@@ -80,7 +78,7 @@ export declare class ApiClient {
80
78
  * Provides access to the DepositExistingMASimulationClient instance.
81
79
  * This getter allows for interacting with trade simulation functionalities.
82
80
  * It ensures a singleton pattern by fetching the instance from the ApiClient's
83
- * private `_deposit_existing_MA_simulation` property, ensuring that trade simulation operations
81
+ * private `_depositExistingMASimulation` property, ensuring that trade simulation operations
84
82
  * use a consistent client configuration and state.
85
83
  *
86
84
  * @returns {DepositExistingMASimulationClient} An instance of DepositExistingMASimulationClient for trade simulation operations.
@@ -94,7 +92,7 @@ export declare class ApiClient {
94
92
  * Provides access to the DepositNewMASimulationClient instance.
95
93
  * This getter allows for interacting with trade simulation functionalities.
96
94
  * It ensures a singleton pattern by fetching the instance from the ApiClient's
97
- * private `_deposit_new_MA_simulation` property, ensuring that trade simulation operations
95
+ * private `_depositNewMASimulation` property, ensuring that trade simulation operations
98
96
  * use a consistent client configuration and state.
99
97
  *
100
98
  * @returns {DepositNewMASimulationClient} An instance of DepositNewMASimulationClient for trade simulation operations.
@@ -108,7 +106,7 @@ export declare class ApiClient {
108
106
  * Provides access to the WithdrawMASimulationClient instance.
109
107
  * This getter allows for interacting with trade simulation functionalities.
110
108
  * It ensures a singleton pattern by fetching the instance from the ApiClient's
111
- * private `_withdraw_MA_simulation` property, ensuring that trade simulation operations
109
+ * private `_withdrawMASimulation` property, ensuring that trade simulation operations
112
110
  * use a consistent client configuration and state.
113
111
  *
114
112
  * @returns {WithdrawMASimulationClient} An instance of WithrawMASimulationClient for trade simulation operations.
@@ -1 +1 @@
1
- {"version":3,"file":"api-client.d.ts","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,qBAAqB,MAAM,4BAA4B,CAAC;AAC/D,OAAO,QAAQ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{ ReyaChainId } from '@reyaxyz/common';
1
2
  export declare const API_TIMEOUT: number;
2
3
  type ServiceEnvironment = 'production' | 'test' | 'local';
3
4
  export interface ServiceConfig {
4
- environment?: ServiceEnvironment;
5
- timeout?: number;
5
+ chain: ReyaChainId;
6
+ apiEndpoint: string;
7
+ environment: ServiceEnvironment;
8
+ timeout: number;
6
9
  }
7
- export declare const API_URLS: Record<ServiceEnvironment, string>;
10
+ export declare const API_CLIENT_CONFIGS: Record<ServiceEnvironment, ServiceConfig>;
8
11
  export {};
9
12
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"/","sources":["clients/helpers/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,EAAE,MAAa,CAAC;AAExC,KAAK,kBAAkB,GAAG,YAAY,GAAG,MAAM,GAAG,OAAO,CAAC;AAC1D,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAIvD,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"/","sources":["clients/helpers/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,eAAO,MAAM,WAAW,EAAE,MAAa,CAAC;AAExC,KAAK,kBAAkB,GAAG,YAAY,GAAG,MAAM,GAAG,OAAO,CAAC;AAC1D,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,WAAW,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,kBAAkB,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAmBxE,CAAC"}
@@ -8,7 +8,7 @@ export type DepositExistingMASimulationSimulateParams = {
8
8
  };
9
9
  export type SimulateDepositExistingMAEntity = {
10
10
  fees: number;
11
- feesUnderlyingToken: string;
11
+ feesUnderlyingToken: TokenEntity['id'];
12
12
  bridgeTimeInMS: number;
13
13
  marginRatio: MarginAccountEntity['marginRatioPercentage'];
14
14
  marginRatioHealth: MarginAccountEntity['marginRatioHealth'];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,sCAAsC,EAAE,MAAM,qCAAqC,CAAC;AAE7F,MAAM,MAAM,yCAAyC,GACnD,sCAAsC,CAAC;AAEzC,MAAM,MAAM,yCAAyC,GAAG;IACtD,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,mBAAmB,CAAC,uBAAuB,CAAC,CAAC;IAC1D,iBAAiB,EAAE,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;CAC7D,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,sCAAsC,EAAE,MAAM,qCAAqC,CAAC;AAE7F,MAAM,MAAM,yCAAyC,GACnD,sCAAsC,CAAC;AAEzC,MAAM,MAAM,yCAAyC,GAAG;IACtD,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,mBAAmB,CAAC,uBAAuB,CAAC,CAAC;IAC1D,iBAAiB,EAAE,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;CAC7D,CAAC"}
@@ -1,8 +1,10 @@
1
1
  import EditCollateralClient from '../edit-collateral.simulation';
2
2
  import { SimulateWithdrawMAEntity, WithdrawMASimulationLoadDataParams, WithdrawMASimulationSimulateParams } from './types';
3
+ import { ReyaChainId } from '@reyaxyz/common';
3
4
  export default class WithdrawMASimulationClient {
4
5
  private editCollateralClient;
5
- constructor(editCollateralClient: EditCollateralClient);
6
+ private reyaChainId;
7
+ constructor(editCollateralClient: EditCollateralClient, reyaChainId: ReyaChainId);
6
8
  arm(params: WithdrawMASimulationLoadDataParams): Promise<void>;
7
9
  simulate(params: WithdrawMASimulationSimulateParams): SimulateWithdrawMAEntity;
8
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/withdraw-MA.simulation/index.ts"],"names":[],"mappings":"AACA,OAAO,oBAAoB,MAAM,+BAA+B,CAAC;AACjE,OAAO,EACL,wBAAwB,EACxB,kCAAkC,EAClC,kCAAkC,EACnC,MAAM,SAAS,CAAC;AAEjB,MAAM,CAAC,OAAO,OAAO,0BAA0B;IAC7C,OAAO,CAAC,oBAAoB,CAAuB;gBACvC,oBAAoB,EAAE,oBAAoB;IAMhD,GAAG,CAAC,MAAM,EAAE,kCAAkC,GAAG,OAAO,CAAC,IAAI,CAAC;IAOpE,QAAQ,CACN,MAAM,EAAE,kCAAkC,GACzC,wBAAwB;CAsB5B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/withdraw-MA.simulation/index.ts"],"names":[],"mappings":"AACA,OAAO,oBAAoB,MAAM,+BAA+B,CAAC;AACjE,OAAO,EACL,wBAAwB,EACxB,kCAAkC,EAClC,kCAAkC,EACnC,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,WAAW,EAAmB,MAAM,iBAAiB,CAAC;AAE/D,MAAM,CAAC,OAAO,OAAO,0BAA0B;IAC7C,OAAO,CAAC,oBAAoB,CAAuB;IACnD,OAAO,CAAC,WAAW,CAAc;gBAG/B,oBAAoB,EAAE,oBAAoB,EAC1C,WAAW,EAAE,WAAW;IAOpB,GAAG,CAAC,MAAM,EAAE,kCAAkC,GAAG,OAAO,CAAC,IAAI,CAAC;IAOpE,QAAQ,CACN,MAAM,EAAE,kCAAkC,GACzC,wBAAwB;CAyB5B"}
@@ -1,14 +1,14 @@
1
- import { MarginAccountEntity, MoneyInOutChainId, ReyaChainId, TokenEntity } from '@reyaxyz/common';
1
+ import { MarginAccountEntity, MoneyInOutChainId, TokenEntity } from '@reyaxyz/common';
2
2
  import { EditCollateralSimulationLoadDataParams } from '../edit-collateral.simulation/types';
3
3
  export type WithdrawMASimulationLoadDataParams = EditCollateralSimulationLoadDataParams;
4
4
  export type WithdrawMASimulationSimulateParams = {
5
- reyaChainId: ReyaChainId;
6
5
  moneyInOutChainId: MoneyInOutChainId;
7
6
  amount: number;
8
7
  tokenAddress: TokenEntity['address'];
9
8
  };
10
9
  export type SimulateWithdrawMAEntity = {
11
10
  fees: number;
11
+ feesUnderlyingToken: TokenEntity['id'];
12
12
  bridgeTimeInMS: number;
13
13
  marginRatio: MarginAccountEntity['marginRatioPercentage'];
14
14
  marginRatioHealth: MarginAccountEntity['marginRatioHealth'];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/withdraw-MA.simulation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,E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,CAAC,CAAC;CAC7D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/api-sdk",
3
- "version": "0.47.1",
3
+ "version": "0.48.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.23.1",
36
+ "@reyaxyz/common": "0.24.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": "40570712c4a61a1e4627fc97302baa602c2155a5"
41
+ "gitHead": "a3abad43a112fb76ffa96e100360d5cecd6333b1"
42
42
  }
@@ -1,4 +1,4 @@
1
- import { API_TIMEOUT, API_URLS, ServiceConfig } from './helpers/constants';
1
+ import { API_CLIENT_CONFIGS, ServiceConfig } from './helpers/constants';
2
2
  import MarketsClient from './modules/markets';
3
3
  import AccountClient from './modules/account';
4
4
  import TradeSimulationClient from './modules/trade.simulation';
@@ -16,54 +16,44 @@ import WithdrawMASimulationClient from './modules/withdraw-MA.simulation';
16
16
  */
17
17
  export class ApiClient {
18
18
  private static instance: ApiClient;
19
- private static config: ServiceConfig = {
20
- environment: 'test', // default value
21
- timeout: API_TIMEOUT, // default value, e.g., 5000 milliseconds
22
- };
23
- private readonly apiEndpoint: string;
19
+ private static config: ServiceConfig = API_CLIENT_CONFIGS['test'];
24
20
  private readonly _markets: MarketsClient;
25
21
  private readonly _account: AccountClient;
26
22
  private readonly _lp: LpClient;
27
- private readonly _trade_simulation: TradeSimulationClient;
28
- private readonly _edit_collateral_simulation: EditCollateralSimulationClient;
29
- private readonly _deposit_existing_MA_simulation: DepositExistingMASimulationClient;
30
- private readonly _deposit_new_MA_simulation: DepositNewMASimulationClient;
31
- private readonly _withdraw_MA_simulation: WithdrawMASimulationClient;
23
+ private readonly _tradeSimulation: TradeSimulationClient;
24
+ private readonly _editCollateralSimulation: EditCollateralSimulationClient;
25
+ private readonly _depositExistingMASimulation: DepositExistingMASimulationClient;
26
+ private readonly _depositNewMASimulation: DepositNewMASimulationClient;
27
+ private readonly _withdrawMASimulation: WithdrawMASimulationClient;
32
28
  private readonly _tokens: TokensClient;
33
29
  private readonly _owner: OwnerClient;
34
- private static chain: ReyaChainId;
35
-
36
- private constructor(config: ServiceConfig) {
37
- this.apiEndpoint = config.environment
38
- ? API_URLS[config.environment]
39
- : API_URLS['test'];
40
- ApiClient.chain =
41
- config.environment === 'production'
42
- ? ReyaChainId.reyaNetwork
43
- : ReyaChainId.reyaCronos;
44
- ApiClient.config = { ...ApiClient.config, ...config };
45
- this._markets = new MarketsClient(this.apiEndpoint);
46
- this._account = new AccountClient(this.apiEndpoint);
47
- this._lp = new LpClient(this.apiEndpoint);
48
- this._trade_simulation = new TradeSimulationClient(this._account);
49
- this._edit_collateral_simulation = new EditCollateralSimulationClient(
30
+
31
+ private constructor() {
32
+ this._markets = new MarketsClient(ApiClient.config.apiEndpoint);
33
+ this._account = new AccountClient(ApiClient.config.apiEndpoint);
34
+ this._lp = new LpClient(ApiClient.config.apiEndpoint);
35
+ this._tradeSimulation = new TradeSimulationClient(this._account);
36
+ this._editCollateralSimulation = new EditCollateralSimulationClient(
50
37
  this._account,
51
38
  );
52
- this._deposit_existing_MA_simulation =
53
- new DepositExistingMASimulationClient(this._edit_collateral_simulation);
54
- this._deposit_new_MA_simulation = new DepositNewMASimulationClient(
55
- this._deposit_existing_MA_simulation,
39
+ this._depositExistingMASimulation = new DepositExistingMASimulationClient(
40
+ this._editCollateralSimulation,
41
+ );
42
+ this._depositNewMASimulation = new DepositNewMASimulationClient(
43
+ this._depositExistingMASimulation,
56
44
  );
57
- this._withdraw_MA_simulation = new WithdrawMASimulationClient(
58
- this._edit_collateral_simulation,
45
+ this._withdrawMASimulation = new WithdrawMASimulationClient(
46
+ this._editCollateralSimulation,
47
+ ApiClient.config.chain,
59
48
  );
60
- this._tokens = new TokensClient(this.apiEndpoint);
61
- this._owner = new OwnerClient(this.apiEndpoint);
49
+ this._tokens = new TokensClient(ApiClient.config.apiEndpoint);
50
+ this._owner = new OwnerClient(ApiClient.config.apiEndpoint);
62
51
  }
63
52
 
64
- public static configure(config: ServiceConfig): void {
65
- ApiClient.config = config;
66
- ApiClient.instance = new ApiClient(config);
53
+ public static configure(environment: ServiceConfig['environment']): void {
54
+ ApiClient.config =
55
+ API_CLIENT_CONFIGS[environment] || API_CLIENT_CONFIGS['test'];
56
+ ApiClient.instance = new ApiClient();
67
57
  }
68
58
 
69
59
  private static getInstance(): ApiClient {
@@ -75,10 +65,10 @@ export class ApiClient {
75
65
  return ApiClient.instance;
76
66
  }
77
67
  public static get network(): ReyaChainId {
78
- if (!ApiClient.chain) {
68
+ if (!ApiClient.config.chain) {
79
69
  throw new Error('ApiClient is not configured');
80
70
  }
81
- return ApiClient.chain;
71
+ return ApiClient.config.chain;
82
72
  }
83
73
 
84
74
  /**
@@ -107,7 +97,7 @@ export class ApiClient {
107
97
  * Provides access to the TradeSimulationClient instance.
108
98
  * This getter allows for interacting with trade simulation functionalities.
109
99
  * It ensures a singleton pattern by fetching the instance from the ApiClient's
110
- * private `_trade_simulation` property, ensuring that trade simulation operations
100
+ * private `_tradeSimulation` property, ensuring that trade simulation operations
111
101
  * use a consistent client configuration and state.
112
102
  *
113
103
  * @returns {TradeSimulationClient} An instance of TradeSimulationClient for trade simulation operations.
@@ -118,14 +108,14 @@ export class ApiClient {
118
108
  */
119
109
 
120
110
  public static get tradeSimulation(): TradeSimulationClient {
121
- return ApiClient.getInstance()._trade_simulation;
111
+ return ApiClient.getInstance()._tradeSimulation;
122
112
  }
123
113
 
124
114
  /**
125
115
  * Provides access to the EditCollateralSimulationClient instance.
126
116
  * This getter allows for interacting with edit collateral simulation functionalities.
127
117
  * It ensures a singleton pattern by fetching the instance from the ApiClient's
128
- * private `_edit_collateral_simulation` property, ensuring that edit collateral simulation operations
118
+ * private `_editCollateralSimulation` property, ensuring that edit collateral simulation operations
129
119
  * use a consistent client configuration and state.
130
120
  *
131
121
  * @returns {EditCollateralSimulationClient} An instance of EditCollateralSimulationClient for edit collateral simulation operations.
@@ -136,14 +126,14 @@ export class ApiClient {
136
126
  */
137
127
 
138
128
  public static get editCollateralSimulationClient(): EditCollateralSimulationClient {
139
- return ApiClient.getInstance()._edit_collateral_simulation;
129
+ return ApiClient.getInstance()._editCollateralSimulation;
140
130
  }
141
131
 
142
132
  /**
143
133
  * Provides access to the DepositExistingMASimulationClient instance.
144
134
  * This getter allows for interacting with trade simulation functionalities.
145
135
  * It ensures a singleton pattern by fetching the instance from the ApiClient's
146
- * private `_deposit_existing_MA_simulation` property, ensuring that trade simulation operations
136
+ * private `_depositExistingMASimulation` property, ensuring that trade simulation operations
147
137
  * use a consistent client configuration and state.
148
138
  *
149
139
  * @returns {DepositExistingMASimulationClient} An instance of DepositExistingMASimulationClient for trade simulation operations.
@@ -154,14 +144,14 @@ export class ApiClient {
154
144
  */
155
145
 
156
146
  public static get depositExistingMASimulation(): DepositExistingMASimulationClient {
157
- return ApiClient.getInstance()._deposit_existing_MA_simulation;
147
+ return ApiClient.getInstance()._depositExistingMASimulation;
158
148
  }
159
149
 
160
150
  /**
161
151
  * Provides access to the DepositNewMASimulationClient instance.
162
152
  * This getter allows for interacting with trade simulation functionalities.
163
153
  * It ensures a singleton pattern by fetching the instance from the ApiClient's
164
- * private `_deposit_new_MA_simulation` property, ensuring that trade simulation operations
154
+ * private `_depositNewMASimulation` property, ensuring that trade simulation operations
165
155
  * use a consistent client configuration and state.
166
156
  *
167
157
  * @returns {DepositNewMASimulationClient} An instance of DepositNewMASimulationClient for trade simulation operations.
@@ -172,14 +162,14 @@ export class ApiClient {
172
162
  */
173
163
 
174
164
  public static get depositNewMASimulation(): DepositNewMASimulationClient {
175
- return ApiClient.getInstance()._deposit_new_MA_simulation;
165
+ return ApiClient.getInstance()._depositNewMASimulation;
176
166
  }
177
167
 
178
168
  /**
179
169
  * Provides access to the WithdrawMASimulationClient instance.
180
170
  * This getter allows for interacting with trade simulation functionalities.
181
171
  * It ensures a singleton pattern by fetching the instance from the ApiClient's
182
- * private `_withdraw_MA_simulation` property, ensuring that trade simulation operations
172
+ * private `_withdrawMASimulation` property, ensuring that trade simulation operations
183
173
  * use a consistent client configuration and state.
184
174
  *
185
175
  * @returns {WithdrawMASimulationClient} An instance of WithrawMASimulationClient for trade simulation operations.
@@ -190,7 +180,7 @@ export class ApiClient {
190
180
  */
191
181
 
192
182
  public static get withdrawMASimulation(): WithdrawMASimulationClient {
193
- return ApiClient.getInstance()._withdraw_MA_simulation;
183
+ return ApiClient.getInstance()._withdrawMASimulation;
194
184
  }
195
185
 
196
186
  /**
@@ -1,13 +1,32 @@
1
+ import { ReyaChainId } from '@reyaxyz/common';
2
+
1
3
  export const API_TIMEOUT: number = 2500;
2
4
 
3
5
  type ServiceEnvironment = 'production' | 'test' | 'local';
4
6
  export interface ServiceConfig {
5
- environment?: ServiceEnvironment; // Configuration for SDK, such as base URL for the REST API
6
- timeout?: number; // Optional timeout for API requests
7
+ chain: ReyaChainId;
8
+ apiEndpoint: string;
9
+ environment: ServiceEnvironment; // Configuration for SDK, such as base URL for the REST API
10
+ timeout: number; // Optional timeout for API requests
7
11
  }
8
12
 
9
- export const API_URLS: Record<ServiceEnvironment, string> = {
10
- production: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',
11
- test: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',
12
- local: 'http://localhost:3000',
13
+ export const API_CLIENT_CONFIGS: Record<ServiceEnvironment, ServiceConfig> = {
14
+ local: {
15
+ chain: ReyaChainId.reyaCronos,
16
+ apiEndpoint: 'http://localhost:3000',
17
+ environment: 'local',
18
+ timeout: API_TIMEOUT,
19
+ },
20
+ production: {
21
+ chain: ReyaChainId.reyaNetwork,
22
+ apiEndpoint: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',
23
+ environment: 'production',
24
+ timeout: API_TIMEOUT,
25
+ },
26
+ test: {
27
+ chain: ReyaChainId.reyaCronos,
28
+ apiEndpoint: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',
29
+ environment: 'test',
30
+ timeout: API_TIMEOUT,
31
+ },
13
32
  };
@@ -16,7 +16,7 @@ export type DepositExistingMASimulationSimulateParams = {
16
16
 
17
17
  export type SimulateDepositExistingMAEntity = {
18
18
  fees: number;
19
- feesUnderlyingToken: string;
19
+ feesUnderlyingToken: TokenEntity['id'];
20
20
  bridgeTimeInMS: number;
21
21
  marginRatio: MarginAccountEntity['marginRatioPercentage'];
22
22
  marginRatioHealth: MarginAccountEntity['marginRatioHealth'];
@@ -5,12 +5,18 @@ import {
5
5
  WithdrawMASimulationLoadDataParams,
6
6
  WithdrawMASimulationSimulateParams,
7
7
  } from './types';
8
+ import { ReyaChainId, getTokenDetails } from '@reyaxyz/common';
8
9
 
9
10
  export default class WithdrawMASimulationClient {
10
11
  private editCollateralClient: EditCollateralClient;
11
- constructor(editCollateralClient: EditCollateralClient) {
12
- // Constructor added
12
+ private reyaChainId: ReyaChainId;
13
+
14
+ constructor(
15
+ editCollateralClient: EditCollateralClient,
16
+ reyaChainId: ReyaChainId,
17
+ ) {
13
18
  this.editCollateralClient = editCollateralClient;
19
+ this.reyaChainId = reyaChainId;
14
20
  }
15
21
 
16
22
  // Method to asynchronously load data based on accountId
@@ -34,12 +40,15 @@ export default class WithdrawMASimulationClient {
34
40
  }).bridgeTimeInMS;
35
41
 
36
42
  const fees = getSocketWithdrawFees({
37
- reyaChainId: params.reyaChainId,
43
+ reyaChainId: this.reyaChainId,
38
44
  tokenAddress: params.tokenAddress,
39
45
  });
40
46
 
47
+ const feesUnderlyingToken = getTokenDetails(params.tokenAddress).tokenName;
48
+
41
49
  return {
42
50
  fees: fees.fees,
51
+ feesUnderlyingToken: feesUnderlyingToken,
43
52
  bridgeTimeInMS: bridgeTimeInMS,
44
53
  marginRatio: simulateEditCollateralEntity.marginRatio,
45
54
  marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  MarginAccountEntity,
3
3
  MoneyInOutChainId,
4
- ReyaChainId,
5
4
  TokenEntity,
6
5
  } from '@reyaxyz/common';
7
6
  import { EditCollateralSimulationLoadDataParams } from '../edit-collateral.simulation/types';
@@ -10,7 +9,6 @@ export type WithdrawMASimulationLoadDataParams =
10
9
  EditCollateralSimulationLoadDataParams;
11
10
 
12
11
  export type WithdrawMASimulationSimulateParams = {
13
- reyaChainId: ReyaChainId;
14
12
  moneyInOutChainId: MoneyInOutChainId;
15
13
  amount: number;
16
14
  tokenAddress: TokenEntity['address'];
@@ -18,6 +16,7 @@ export type WithdrawMASimulationSimulateParams = {
18
16
 
19
17
  export type SimulateWithdrawMAEntity = {
20
18
  fees: number;
19
+ feesUnderlyingToken: TokenEntity['id'];
21
20
  bridgeTimeInMS: number;
22
21
  marginRatio: MarginAccountEntity['marginRatioPercentage'];
23
22
  marginRatioHealth: MarginAccountEntity['marginRatioHealth'];