@reyaxyz/api-sdk 0.69.2 → 0.69.4

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.
@@ -31,9 +31,9 @@ var ApiClient = /** @class */ (function () {
31
31
  this._tradeSimulation = new trade_simulation_1.default(this._account);
32
32
  this._fundingRateHistory = new funding_rate_1.default(this._markets);
33
33
  this._editCollateralSimulation = new edit_collateral_simulation_1.default(ApiClient.network, this._account);
34
- this._depositExistingMASimulation = new deposit_existing_MA_simulation_1.default(this._editCollateralSimulation, ApiClient.config.chain, ApiClient.config.apiEndpoint);
34
+ this._depositExistingMASimulation = new deposit_existing_MA_simulation_1.default(this._editCollateralSimulation, ApiClient.config.apiEndpoint);
35
35
  this._depositNewMASimulation = new deposit_new_MA_simulation_1.default(this._depositExistingMASimulation);
36
- this._depositPassivePoolSimulation = new deposit_passive_pool_simulation_1.default(ApiClient.config.chain, ApiClient.config.apiEndpoint);
36
+ this._depositPassivePoolSimulation = new deposit_passive_pool_simulation_1.default(ApiClient.config.apiEndpoint);
37
37
  this._withdrawMASimulation = new withdraw_MA_simulation_1.default(this._editCollateralSimulation, ApiClient.config.chain);
38
38
  this._transferMarginBetweenMAsSimulation =
39
39
  new transfer_margin_between_MAs_simulation_1.default(ApiClient.network, this._account);
@@ -1 +1 @@
1
- {"version":3,"file":"api-client.js","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":";;;;;;AAAA,0CAAoE;AACpE,8DAA8C;AAC9C,8DAA8C;AAC9C,gFAA+D;AAC/D,oDAAoC;AACpC,4DAA4C;AAE5C,0DAA0C;AAC1C,oGAAkF;AAClF,4GAAyF;AACzF,kGAA+E;AAC/E,8GAA2F;AAC3F,4FAA0E;AAC1E,4HAAwG;AACxG,sGAAmF;AACnF,4FAA0E;AAC1E,wEAAuD;AAEvD;;GAEG;AACH;IAmBE;QACE,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAa,CAAC,SAAS,CAAC,MAAM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;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;IA3Sc,gBAAM,GAAkB,2BAAkB,CAAC,MAAM,CAAC,CAAC;IA4SpE,gBAAC;CAAA,AA9SD,IA8SC;AA9SY,8BAAS","sourcesContent":["import { API_CLIENT_CONFIGS, ServiceConfig } from '@reyaxyz/common';\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 DepositPassivePoolSimulationClient from './modules/deposit-passive-pool.simulation';\nimport WithdrawMASimulationClient from './modules/withdraw-MA.simulation';\nimport TransferMarginBetweenMAsSimulationClient from './modules/transfer-margin-between-MAs.simulation';\nimport TransferMAPoolSimulationClient from './modules/transfer-MA-Pool.simulation';\nimport DepthChartSimulationClient from './modules/depth-chart.simulation';\nimport FundingRateClient from './modules/funding-rate';\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 _fundingRateHistory: FundingRateClient;\n private readonly _editCollateralSimulation: EditCollateralSimulationClient;\n private readonly _depositExistingMASimulation: DepositExistingMASimulationClient;\n private readonly _depositNewMASimulation: DepositNewMASimulationClient;\n private readonly _depositPassivePoolSimulation: DepositPassivePoolSimulationClient;\n private readonly _withdrawMASimulation: WithdrawMASimulationClient;\n private readonly _transferMarginBetweenMAsSimulation: TransferMarginBetweenMAsSimulationClient;\n private readonly _transferMAPoolSimulation: TransferMAPoolSimulationClient;\n private readonly _depthSimulation: DepthChartSimulationClient;\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._fundingRateHistory = new FundingRateClient(this._markets);\n this._editCollateralSimulation = new EditCollateralSimulationClient(\n ApiClient.network,\n this._account,\n );\n this._depositExistingMASimulation = new DepositExistingMASimulationClient(\n this._editCollateralSimulation,\n ApiClient.config.chain,\n ApiClient.config.apiEndpoint,\n );\n this._depositNewMASimulation = new DepositNewMASimulationClient(\n this._depositExistingMASimulation,\n );\n this._depositPassivePoolSimulation = new DepositPassivePoolSimulationClient(\n ApiClient.config.chain,\n ApiClient.config.apiEndpoint,\n );\n this._withdrawMASimulation = new WithdrawMASimulationClient(\n this._editCollateralSimulation,\n ApiClient.config.chain,\n );\n this._transferMarginBetweenMAsSimulation =\n new TransferMarginBetweenMAsSimulationClient(\n ApiClient.network,\n this._account,\n );\n this._transferMAPoolSimulation = new TransferMAPoolSimulationClient(\n this._editCollateralSimulation,\n );\n\n this._depthSimulation = new DepthChartSimulationClient(this._lp);\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 public static get fundingRateHistory(): FundingRateClient {\n return ApiClient.getInstance()._fundingRateHistory;\n }\n\n /**\n * Retrieves the DepthChartSimulationClient instance used for depth simulation.\n * This method provides access to the depth simulation client through the ApiClient.\n * @returns {DepthChartSimulationClient} The DepthChartSimulationClient instance.\n * @static\n * @public\n */\n public static get depthSimulation(): DepthChartSimulationClient {\n return ApiClient.getInstance()._depthSimulation;\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 DepositPassivePoolSimulationClient 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 `_depositPassivePoolSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositPassivePoolSimulationClient} An instance of DepositPassivePoolSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit existing Ma simulation client from the ApiClient\n * const depositPassivePoolSimulationClient = ApiClient.depositPassivePoolSimulation;\n */\n\n public static get depositPassivePoolSimulation(): DepositPassivePoolSimulationClient {\n return ApiClient.getInstance()._depositPassivePoolSimulation;\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 * Provides access to the TransferMarginBetweenMAsSimulationClient 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 `_transferMarginBetweenMAsSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TransferMarginBetweenMAsSimulationClient} An instance of TransferMarginBetweenMAsSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the transfer margin between MAs simulation client from the ApiClient\n * const transferMarginBetweenMAsSimulationClient = ApiClient.transferMarginBetweenMAsSimulation;\n */\n\n public static get transferMarginBetweenMAsSimulation(): TransferMarginBetweenMAsSimulationClient {\n return ApiClient.getInstance()._transferMarginBetweenMAsSimulation;\n }\n\n /**\n * Provides access to the TransferMAPoolSimulationClient 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 `_TransferMAPoolSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TransferMAPoolSimulationClient} An instance of TransferMAPoolSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the transfer from MA to Pool simulation client from the ApiClient\n * const transferMAPoolSimulationClient = ApiClient.transferMAPoolSimulation;\n */\n\n public static get transferMAPoolSimulation(): TransferMAPoolSimulationClient {\n return ApiClient.getInstance()._transferMAPoolSimulation;\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,0CAAoE;AACpE,8DAA8C;AAC9C,8DAA8C;AAC9C,gFAA+D;AAC/D,oDAAoC;AACpC,4DAA4C;AAE5C,0DAA0C;AAC1C,oGAAkF;AAClF,4GAAyF;AACzF,kGAA+E;AAC/E,8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AAE;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;IAzSc,gBAAM,GAAkB,2BAAkB,CAAC,MAAM,CAAC,CAAC;IA0SpE,gBAAC;CAAA,AA5SD,IA4SC;AA5SY,8BAAS","sourcesContent":["import { API_CLIENT_CONFIGS, ServiceConfig } from '@reyaxyz/common';\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 DepositPassivePoolSimulationClient from './modules/deposit-passive-pool.simulation';\nimport WithdrawMASimulationClient from './modules/withdraw-MA.simulation';\nimport TransferMarginBetweenMAsSimulationClient from './modules/transfer-margin-between-MAs.simulation';\nimport TransferMAPoolSimulationClient from './modules/transfer-MA-Pool.simulation';\nimport DepthChartSimulationClient from './modules/depth-chart.simulation';\nimport FundingRateClient from './modules/funding-rate';\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 _fundingRateHistory: FundingRateClient;\n private readonly _editCollateralSimulation: EditCollateralSimulationClient;\n private readonly _depositExistingMASimulation: DepositExistingMASimulationClient;\n private readonly _depositNewMASimulation: DepositNewMASimulationClient;\n private readonly _depositPassivePoolSimulation: DepositPassivePoolSimulationClient;\n private readonly _withdrawMASimulation: WithdrawMASimulationClient;\n private readonly _transferMarginBetweenMAsSimulation: TransferMarginBetweenMAsSimulationClient;\n private readonly _transferMAPoolSimulation: TransferMAPoolSimulationClient;\n private readonly _depthSimulation: DepthChartSimulationClient;\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._fundingRateHistory = new FundingRateClient(this._markets);\n this._editCollateralSimulation = new EditCollateralSimulationClient(\n ApiClient.network,\n this._account,\n );\n this._depositExistingMASimulation = new DepositExistingMASimulationClient(\n this._editCollateralSimulation,\n ApiClient.config.apiEndpoint,\n );\n this._depositNewMASimulation = new DepositNewMASimulationClient(\n this._depositExistingMASimulation,\n );\n this._depositPassivePoolSimulation = new DepositPassivePoolSimulationClient(\n ApiClient.config.apiEndpoint,\n );\n this._withdrawMASimulation = new WithdrawMASimulationClient(\n this._editCollateralSimulation,\n ApiClient.config.chain,\n );\n this._transferMarginBetweenMAsSimulation =\n new TransferMarginBetweenMAsSimulationClient(\n ApiClient.network,\n this._account,\n );\n this._transferMAPoolSimulation = new TransferMAPoolSimulationClient(\n this._editCollateralSimulation,\n );\n\n this._depthSimulation = new DepthChartSimulationClient(this._lp);\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 public static get fundingRateHistory(): FundingRateClient {\n return ApiClient.getInstance()._fundingRateHistory;\n }\n\n /**\n * Retrieves the DepthChartSimulationClient instance used for depth simulation.\n * This method provides access to the depth simulation client through the ApiClient.\n * @returns {DepthChartSimulationClient} The DepthChartSimulationClient instance.\n * @static\n * @public\n */\n public static get depthSimulation(): DepthChartSimulationClient {\n return ApiClient.getInstance()._depthSimulation;\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 DepositPassivePoolSimulationClient 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 `_depositPassivePoolSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositPassivePoolSimulationClient} An instance of DepositPassivePoolSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit existing Ma simulation client from the ApiClient\n * const depositPassivePoolSimulationClient = ApiClient.depositPassivePoolSimulation;\n */\n\n public static get depositPassivePoolSimulation(): DepositPassivePoolSimulationClient {\n return ApiClient.getInstance()._depositPassivePoolSimulation;\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 * Provides access to the TransferMarginBetweenMAsSimulationClient 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 `_transferMarginBetweenMAsSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TransferMarginBetweenMAsSimulationClient} An instance of TransferMarginBetweenMAsSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the transfer margin between MAs simulation client from the ApiClient\n * const transferMarginBetweenMAsSimulationClient = ApiClient.transferMarginBetweenMAsSimulation;\n */\n\n public static get transferMarginBetweenMAsSimulation(): TransferMarginBetweenMAsSimulationClient {\n return ApiClient.getInstance()._transferMarginBetweenMAsSimulation;\n }\n\n /**\n * Provides access to the TransferMAPoolSimulationClient 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 `_TransferMAPoolSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TransferMAPoolSimulationClient} An instance of TransferMAPoolSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the transfer from MA to Pool simulation client from the ApiClient\n * const transferMAPoolSimulationClient = ApiClient.transferMAPoolSimulation;\n */\n\n public static get transferMAPoolSimulation(): TransferMAPoolSimulationClient {\n return ApiClient.getInstance()._transferMAPoolSimulation;\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"]}
@@ -52,41 +52,30 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
52
52
  };
53
53
  Object.defineProperty(exports, "__esModule", { value: true });
54
54
  var common_1 = require("@reyaxyz/common");
55
+ var common_2 = require("@reyaxyz/common");
55
56
  var DepositExistingMASimulationClient = /** @class */ (function (_super) {
56
57
  __extends(DepositExistingMASimulationClient, _super);
57
- function DepositExistingMASimulationClient(editCollateralClient, reyaChainId, host, apiTimeout) {
58
+ function DepositExistingMASimulationClient(editCollateralClient, host, apiTimeout) {
58
59
  var _this = _super.call(this, host, apiTimeout) || this;
59
- _this.socketDepositFees = {};
60
- _this.reyaChainId = reyaChainId;
60
+ _this.socketDepositFeesList = [];
61
61
  _this.editCollateralClient = editCollateralClient;
62
62
  return _this;
63
63
  }
64
64
  // Method to asynchronously load data based on accountId
65
65
  DepositExistingMASimulationClient.prototype.arm = function (params) {
66
66
  return __awaiter(this, void 0, void 0, function () {
67
- var moneyInOutChainIds, socketDepositFeesPromises, _i, moneyInOutChainIds_1, moneyInOutChainId, socketDepositFeesArray;
68
- var _this = this;
69
- return __generator(this, function (_a) {
70
- switch (_a.label) {
67
+ var _a;
68
+ return __generator(this, function (_b) {
69
+ switch (_b.label) {
71
70
  case 0: return [4 /*yield*/, this.editCollateralClient.arm({
72
71
  marginAccountId: params.marginAccountId,
73
72
  })];
74
73
  case 1:
75
- _a.sent();
76
- moneyInOutChainIds = (0, common_1.getMoneyInOutNetworksFromReyaChainId)(this.reyaChainId);
77
- socketDepositFeesPromises = [];
78
- for (_i = 0, moneyInOutChainIds_1 = moneyInOutChainIds; _i < moneyInOutChainIds_1.length; _i++) {
79
- moneyInOutChainId = moneyInOutChainIds_1[_i];
80
- socketDepositFeesPromises.push(this.get("/api/socket/deposit-fees/".concat(moneyInOutChainId)));
81
- }
82
- return [4 /*yield*/, Promise.all(socketDepositFeesPromises)];
74
+ _b.sent();
75
+ _a = this;
76
+ return [4 /*yield*/, this.get("/api/socket/deposit-fees")];
83
77
  case 2:
84
- socketDepositFeesArray = _a.sent();
85
- moneyInOutChainIds.forEach(function (moneyInOutChainId, index) {
86
- if (socketDepositFeesArray[index] !== undefined) {
87
- _this.socketDepositFees[moneyInOutChainId] = socketDepositFeesArray[index];
88
- }
89
- });
78
+ _a.socketDepositFeesList = _b.sent();
90
79
  return [2 /*return*/];
91
80
  }
92
81
  });
@@ -94,23 +83,33 @@ var DepositExistingMASimulationClient = /** @class */ (function (_super) {
94
83
  };
95
84
  // Synchronous method to simulate operations based on an amount
96
85
  DepositExistingMASimulationClient.prototype.simulate = function (params) {
97
- if (!(params.moneyInOutChainId in this.socketDepositFees)) {
98
- throw new Error("Socket deposit fees for chain ".concat(params.moneyInOutChainId, " not loaded. Call arm() first (or make sure arm will fetch info for this chain id)"));
86
+ var moneyInOutChainId = params.moneyInOutChainId;
87
+ var tokenInfo = (0, common_1.getTokenInfoByAddress)(params.tokenAddress, moneyInOutChainId);
88
+ var socketDpositFeesRow = this.socketDepositFeesList.find(function (socketDepositFeesRow) {
89
+ return socketDepositFeesRow.moneyInOutChainId === moneyInOutChainId &&
90
+ socketDepositFeesRow.tokenName === tokenInfo.name;
91
+ });
92
+ if (!socketDpositFeesRow) {
93
+ throw new Error("Socket deposit fees for chain ".concat(moneyInOutChainId, " and token ").concat(tokenInfo.name, " not loaded. Call arm() first (or make sure arm will fetch info for this chain id and token)"));
99
94
  }
95
+ var socketDepositFees = {
96
+ fees: socketDpositFeesRow.fees,
97
+ feesInUnderlyingToken: (0, common_1.descale)(18)(socketDpositFeesRow.fees),
98
+ underlyingTokenName: (0, common_2.getNativeToken)(moneyInOutChainId),
99
+ };
100
100
  var simulateEditCollateralEntity = this.editCollateralClient.simulate({
101
101
  signedAmount: params.amount,
102
102
  tokenAddress: params.tokenAddress,
103
103
  });
104
104
  var bridgeTimeInMS = (0, common_1.getSocketBridgeTime)({
105
- moneyInOutChainId: params.moneyInOutChainId,
105
+ moneyInOutChainId: moneyInOutChainId,
106
106
  }).bridgeTimeInMS;
107
- var result = {
108
- socketDepositFees: this.socketDepositFees[params.moneyInOutChainId],
107
+ return {
108
+ socketDepositFees: socketDepositFees,
109
109
  bridgeTimeInMS: bridgeTimeInMS,
110
110
  marginRatio: simulateEditCollateralEntity.marginRatio,
111
111
  marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,
112
112
  };
113
- return result;
114
113
  };
115
114
  return DepositExistingMASimulationClient;
116
115
  }(common_1.RestClient));
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAMyB;AAQzB;IAA+D,qDAAU;IAKvE,2CACE,oBAA0C,EAC1C,WAAwB,EACxB,IAAY,EACZ,UAA0B;QAE1B,YAAA,MAAK,YAAC,IAAI,EAAE,UAAU,CAAC,SAAC;QATlB,uBAAiB,GAAsC,EAAE,CAAC;QAUhE,KAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,KAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;;IACnD,CAAC;IAED,wDAAwD;IAClD,+CAAG,GAAT,UAAU,MAAiD;;;;;;4BACzD,qBAAM,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC;4BAClC,eAAe,EAAE,MAAM,CAAC,eAAe;yBACxC,CAAC,EAAA;;wBAFF,SAEE,CAAC;wBAEG,kBAAkB,GAAG,IAAA,6CAAoC,EAC7D,IAAI,CAAC,WAAW,CACjB,CAAC;wBAEI,yBAAyB,GAAiC,EAAE,CAAC;wBACnE,WAAkD,EAAlB,yCAAkB,EAAlB,gCAAkB,EAAlB,IAAkB,EAAE,CAAC;4BAA1C,iBAAiB;4BAC1B,yBAAyB,CAAC,IAAI,CAC5B,IAAI,CAAC,GAAG,CACN,mCAA4B,iBAAiB,CAAE,CAChD,CACF,CAAC;wBACJ,CAAC;wBAGC,qBAAM,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,EAAA;;wBADxC,sBAAsB,GAC1B,SAA4C;wBAC9C,kBAAkB,CAAC,OAAO,CAAC,UAAC,iBAAiB,EAAE,KAAK;4BAClD,IAAI,sBAAsB,CAAC,KAAK,CAAC,KAAK,SAAS,EAAE,CAAC;gCAChD,KAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,GAAG,sBAAsB,CAChE,KAAK,CACe,CAAC;4BACzB,CAAC;wBACH,CAAC,CAAC,CAAC;;;;;KACJ;IAED,+DAA+D;IAC/D,oDAAQ,GAAR,UACE,MAAiD;QAEjD,IAAI,CAAC,CAAC,MAAM,CAAC,iBAAiB,IAAI,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAC1D,MAAM,IAAI,KAAK,CACb,wCAAiC,MAAM,CAAC,iBAAiB,uFAAoF,CAC9I,CAAC;QACJ,CAAC;QACD,IAAM,4BAA4B,GAAG,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC;YACtE,YAAY,EAAE,MAAM,CAAC,MAAM;YAC3B,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,MAAM,GAAoC;YAC9C,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,iBAAiB,CAAC;YACnE,cAAc,EAAE,cAAc;YAC9B,WAAW,EAAE,4BAA4B,CAAC,WAAW;YACrD,iBAAiB,EAAE,4BAA4B,CAAC,iBAAiB;SAClE,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC;IACH,wCAAC;AAAD,CAAC,AAzED,CAA+D,mBAAU,GAyExE","sourcesContent":["import {\n RestClient,\n ReyaChainId,\n SocketDepositFees,\n getMoneyInOutNetworksFromReyaChainId,\n getSocketBridgeTime,\n} from '@reyaxyz/common';\nimport EditCollateralClient from '../edit-collateral.simulation';\nimport {\n DepositExistingMASimulationLoadDataParams,\n DepositExistingMASimulationSimulateParams,\n SimulateDepositExistingMAEntity,\n} from './types';\n\nexport default class DepositExistingMASimulationClient extends RestClient {\n private editCollateralClient: EditCollateralClient;\n private socketDepositFees: Record<number, SocketDepositFees> = {};\n private reyaChainId: ReyaChainId;\n\n constructor(\n editCollateralClient: EditCollateralClient,\n reyaChainId: ReyaChainId,\n host: string,\n apiTimeout?: number | null,\n ) {\n super(host, apiTimeout);\n this.reyaChainId = reyaChainId;\n this.editCollateralClient = editCollateralClient;\n }\n\n // Method to asynchronously load data based on accountId\n async arm(params: DepositExistingMASimulationLoadDataParams): Promise<void> {\n await this.editCollateralClient.arm({\n marginAccountId: params.marginAccountId,\n });\n\n const moneyInOutChainIds = getMoneyInOutNetworksFromReyaChainId(\n this.reyaChainId,\n );\n\n const socketDepositFeesPromises: Promise<SocketDepositFees>[] = [];\n for (const moneyInOutChainId of moneyInOutChainIds) {\n socketDepositFeesPromises.push(\n this.get<SocketDepositFees>(\n `/api/socket/deposit-fees/${moneyInOutChainId}`,\n ),\n );\n }\n\n const socketDepositFeesArray: (SocketDepositFees | undefined)[] =\n await Promise.all(socketDepositFeesPromises);\n moneyInOutChainIds.forEach((moneyInOutChainId, index) => {\n if (socketDepositFeesArray[index] !== undefined) {\n this.socketDepositFees[moneyInOutChainId] = socketDepositFeesArray[\n index\n ] as SocketDepositFees;\n }\n });\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(\n params: DepositExistingMASimulationSimulateParams,\n ): SimulateDepositExistingMAEntity {\n if (!(params.moneyInOutChainId in this.socketDepositFees)) {\n throw new Error(\n `Socket deposit fees for chain ${params.moneyInOutChainId} not loaded. Call arm() first (or make sure arm will fetch info for this chain id)`,\n );\n }\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 result: SimulateDepositExistingMAEntity = {\n socketDepositFees: this.socketDepositFees[params.moneyInOutChainId],\n bridgeTimeInMS: bridgeTimeInMS,\n marginRatio: simulateEditCollateralEntity.marginRatio,\n marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,\n };\n\n return result;\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAOyB;AAOzB,0CAAiD;AAEjD;IAA+D,qDAAU;IAIvE,2CACE,oBAA0C,EAC1C,IAAY,EACZ,UAA0B;QAE1B,YAAA,MAAK,YAAC,IAAI,EAAE,UAAU,CAAC,SAAC;QAPlB,2BAAqB,GAA2B,EAAE,CAAC;QAQzD,KAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;;IACnD,CAAC;IAED,wDAAwD;IAClD,+CAAG,GAAT,UAAU,MAAiD;;;;;4BACzD,qBAAM,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC;4BAClC,eAAe,EAAE,MAAM,CAAC,eAAe;yBACxC,CAAC,EAAA;;wBAFF,SAEE,CAAC;wBAEH,KAAA,IAAI,CAAA;wBAAyB,qBAAM,IAAI,CAAC,GAAG,CACzC,0BAA0B,CAC3B,EAAA;;wBAFD,GAAK,qBAAqB,GAAG,SAE5B,CAAC;;;;;KACH;IAED,+DAA+D;IAC/D,oDAAQ,GAAR,UACE,MAAiD;QAEjD,IAAM,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;QACnD,IAAM,SAAS,GAAG,IAAA,8BAAqB,EACrC,MAAM,CAAC,YAAY,EACnB,iBAAiB,CAClB,CAAC;QACF,IAAM,mBAAmB,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,CACzD,UAAC,oBAAoB;YACnB,OAAA,oBAAoB,CAAC,iBAAiB,KAAK,iBAAiB;gBAC5D,oBAAoB,CAAC,SAAS,KAAK,SAAS,CAAC,IAAI;QADjD,CACiD,CACpD,CAAC;QACF,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CACb,wCAAiC,iBAAiB,wBAAc,SAAS,CAAC,IAAI,iGAA8F,CAC7K,CAAC;QACJ,CAAC;QACD,IAAM,iBAAiB,GAAsB;YAC3C,IAAI,EAAE,mBAAmB,CAAC,IAAI;YAC9B,qBAAqB,EAAE,IAAA,gBAAO,EAAC,EAAE,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC;YAC5D,mBAAmB,EAAE,IAAA,uBAAc,EAAC,iBAAiB,CAAC;SACvD,CAAC;QAEF,IAAM,4BAA4B,GAAG,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC;YACtE,YAAY,EAAE,MAAM,CAAC,MAAM;YAC3B,YAAY,EAAE,MAAM,CAAC,YAAY;SAClC,CAAC,CAAC;QAEH,IAAM,cAAc,GAAG,IAAA,4BAAmB,EAAC;YACzC,iBAAiB,EAAE,iBAAiB;SACrC,CAAC,CAAC,cAAc,CAAC;QAElB,OAAO;YACL,iBAAiB,EAAE,iBAAiB;YACpC,cAAc,EAAE,cAAc;YAC9B,WAAW,EAAE,4BAA4B,CAAC,WAAW;YACrD,iBAAiB,EAAE,4BAA4B,CAAC,iBAAiB;SAClE,CAAC;IACJ,CAAC;IACH,wCAAC;AAAD,CAAC,AAjED,CAA+D,mBAAU,GAiExE","sourcesContent":["import {\n descale,\n getSocketBridgeTime,\n getTokenInfoByAddress,\n RestClient,\n SocketDepositFees,\n SocketDepositFeesRow,\n} from '@reyaxyz/common';\nimport EditCollateralClient from '../edit-collateral.simulation';\nimport {\n DepositExistingMASimulationLoadDataParams,\n DepositExistingMASimulationSimulateParams,\n SimulateDepositExistingMAEntity,\n} from './types';\nimport { getNativeToken } from '@reyaxyz/common';\n\nexport default class DepositExistingMASimulationClient extends RestClient {\n private editCollateralClient: EditCollateralClient;\n private socketDepositFeesList: SocketDepositFeesRow[] = [];\n\n constructor(\n editCollateralClient: EditCollateralClient,\n host: string,\n apiTimeout?: number | null,\n ) {\n super(host, apiTimeout);\n this.editCollateralClient = editCollateralClient;\n }\n\n // Method to asynchronously load data based on accountId\n async arm(params: DepositExistingMASimulationLoadDataParams): Promise<void> {\n await this.editCollateralClient.arm({\n marginAccountId: params.marginAccountId,\n });\n\n this.socketDepositFeesList = await this.get<SocketDepositFeesRow[]>(\n `/api/socket/deposit-fees`,\n );\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(\n params: DepositExistingMASimulationSimulateParams,\n ): SimulateDepositExistingMAEntity {\n const moneyInOutChainId = params.moneyInOutChainId;\n const tokenInfo = getTokenInfoByAddress(\n params.tokenAddress,\n moneyInOutChainId,\n );\n const socketDpositFeesRow = this.socketDepositFeesList.find(\n (socketDepositFeesRow) =>\n socketDepositFeesRow.moneyInOutChainId === moneyInOutChainId &&\n socketDepositFeesRow.tokenName === tokenInfo.name,\n );\n if (!socketDpositFeesRow) {\n throw new Error(\n `Socket deposit fees for chain ${moneyInOutChainId} and token ${tokenInfo.name} not loaded. Call arm() first (or make sure arm will fetch info for this chain id and token)`,\n );\n }\n const socketDepositFees: SocketDepositFees = {\n fees: socketDpositFeesRow.fees,\n feesInUnderlyingToken: descale(18)(socketDpositFeesRow.fees),\n underlyingTokenName: getNativeToken(moneyInOutChainId),\n };\n\n const simulateEditCollateralEntity = this.editCollateralClient.simulate({\n signedAmount: params.amount,\n tokenAddress: params.tokenAddress,\n });\n\n const bridgeTimeInMS = getSocketBridgeTime({\n moneyInOutChainId: moneyInOutChainId,\n }).bridgeTimeInMS;\n\n return {\n socketDepositFees: socketDepositFees,\n bridgeTimeInMS: bridgeTimeInMS,\n marginRatio: simulateEditCollateralEntity.marginRatio,\n marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,\n };\n }\n}\n"]}
@@ -52,36 +52,25 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
52
52
  };
53
53
  Object.defineProperty(exports, "__esModule", { value: true });
54
54
  var common_1 = require("@reyaxyz/common");
55
+ var common_2 = require("@reyaxyz/common");
55
56
  var DepositPassivePoolSimulationClient = /** @class */ (function (_super) {
56
57
  __extends(DepositPassivePoolSimulationClient, _super);
57
- function DepositPassivePoolSimulationClient(reyaChainId, host, apiTimeout) {
58
+ function DepositPassivePoolSimulationClient(host, apiTimeout) {
58
59
  var _this = _super.call(this, host, apiTimeout) || this;
59
- _this.socketDepositFees = {};
60
- _this.reyaChainId = reyaChainId;
60
+ _this.socketDepositFeesList = [];
61
61
  return _this;
62
62
  }
63
63
  // Method to asynchronously load data based on accountId
64
64
  DepositPassivePoolSimulationClient.prototype.arm = function () {
65
65
  return __awaiter(this, void 0, void 0, function () {
66
- var moneyInOutChainIds, socketDepositFeesPromises, _i, moneyInOutChainIds_1, moneyInOutChainId, socketDepositFeesArray;
67
- var _this = this;
68
- return __generator(this, function (_a) {
69
- switch (_a.label) {
66
+ var _a;
67
+ return __generator(this, function (_b) {
68
+ switch (_b.label) {
70
69
  case 0:
71
- moneyInOutChainIds = (0, common_1.getMoneyInOutNetworksFromReyaChainId)(this.reyaChainId);
72
- socketDepositFeesPromises = [];
73
- for (_i = 0, moneyInOutChainIds_1 = moneyInOutChainIds; _i < moneyInOutChainIds_1.length; _i++) {
74
- moneyInOutChainId = moneyInOutChainIds_1[_i];
75
- socketDepositFeesPromises.push(this.get("/api/socket/deposit-fees/".concat(moneyInOutChainId)));
76
- }
77
- return [4 /*yield*/, Promise.all(socketDepositFeesPromises)];
70
+ _a = this;
71
+ return [4 /*yield*/, this.get("/api/socket/deposit-fees")];
78
72
  case 1:
79
- socketDepositFeesArray = _a.sent();
80
- moneyInOutChainIds.forEach(function (moneyInOutChainId, index) {
81
- if (socketDepositFeesArray[index] !== undefined) {
82
- _this.socketDepositFees[moneyInOutChainId] = socketDepositFeesArray[index];
83
- }
84
- });
73
+ _a.socketDepositFeesList = _b.sent();
85
74
  return [2 /*return*/];
86
75
  }
87
76
  });
@@ -89,17 +78,27 @@ var DepositPassivePoolSimulationClient = /** @class */ (function (_super) {
89
78
  };
90
79
  // Synchronous method to simulate operations based on an amount
91
80
  DepositPassivePoolSimulationClient.prototype.simulate = function (params) {
92
- if (!(params.moneyInOutChainId in this.socketDepositFees)) {
93
- throw new Error("Socket deposit fees for chain ".concat(params.moneyInOutChainId, " not loaded. Call arm() first (or make sure arm will fetch info for this chain id)"));
81
+ var moneyInOutChainId = params.moneyInOutChainId;
82
+ var tokenInfo = (0, common_1.getRUSDUnderlyingTokenInfo)(moneyInOutChainId);
83
+ var socketDpositFeesRow = this.socketDepositFeesList.find(function (socketDepositFeesRow) {
84
+ return socketDepositFeesRow.moneyInOutChainId === moneyInOutChainId &&
85
+ socketDepositFeesRow.tokenName === tokenInfo.name;
86
+ });
87
+ if (!socketDpositFeesRow) {
88
+ throw new Error("Socket deposit fees for chain ".concat(moneyInOutChainId, " and token ").concat(tokenInfo.name, " not loaded. Call arm() first (or make sure arm will fetch info for this chain id and token)"));
94
89
  }
90
+ var socketDepositFees = {
91
+ fees: socketDpositFeesRow.fees,
92
+ feesInUnderlyingToken: (0, common_1.descale)(18)(socketDpositFeesRow.fees),
93
+ underlyingTokenName: (0, common_2.getNativeToken)(moneyInOutChainId),
94
+ };
95
95
  var bridgeTimeInMS = (0, common_1.getSocketBridgeTime)({
96
- moneyInOutChainId: params.moneyInOutChainId,
96
+ moneyInOutChainId: moneyInOutChainId,
97
97
  }).bridgeTimeInMS;
98
- var result = {
99
- socketDepositFees: this.socketDepositFees[params.moneyInOutChainId],
98
+ return {
99
+ socketDepositFees: socketDepositFees,
100
100
  bridgeTimeInMS: bridgeTimeInMS,
101
101
  };
102
- return result;
103
102
  };
104
103
  return DepositPassivePoolSimulationClient;
105
104
  }(common_1.RestClient));
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/deposit-passive-pool.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAMyB;AAMzB;IAAgE,sDAAU;IAIxE,4CACE,WAAwB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AAqC;YAC/C,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,iBAAiB,CAAC;YACnE,cAAc,EAAE,cAAc;SAC/B,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC;IACH,yCAAC;AAAD,CAAC,AA5DD,CAAgE,mBAAU,GA4DzE","sourcesContent":["import {\n RestClient,\n ReyaChainId,\n SocketDepositFees,\n getMoneyInOutNetworksFromReyaChainId,\n getSocketBridgeTime,\n} from '@reyaxyz/common';\nimport {\n DepositPassivePoolSimulationSimulateParams,\n SimulateDepositPassivePoolEntity,\n} from './types';\n\nexport default class DepositPassivePoolSimulationClient extends RestClient {\n private socketDepositFees: Record<number, SocketDepositFees> = {};\n private reyaChainId: ReyaChainId;\n\n constructor(\n reyaChainId: ReyaChainId,\n host: string,\n apiTimeout?: number | null,\n ) {\n super(host, apiTimeout);\n this.reyaChainId = reyaChainId;\n }\n\n // Method to asynchronously load data based on accountId\n async arm(): Promise<void> {\n const moneyInOutChainIds = getMoneyInOutNetworksFromReyaChainId(\n this.reyaChainId,\n );\n\n const socketDepositFeesPromises: Promise<SocketDepositFees>[] = [];\n for (const moneyInOutChainId of moneyInOutChainIds) {\n socketDepositFeesPromises.push(\n this.get<SocketDepositFees>(\n `/api/socket/deposit-fees/${moneyInOutChainId}`,\n ),\n );\n }\n\n const socketDepositFeesArray: (SocketDepositFees | undefined)[] =\n await Promise.all(socketDepositFeesPromises);\n moneyInOutChainIds.forEach((moneyInOutChainId, index) => {\n if (socketDepositFeesArray[index] !== undefined) {\n this.socketDepositFees[moneyInOutChainId] = socketDepositFeesArray[\n index\n ] as SocketDepositFees;\n }\n });\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(\n params: DepositPassivePoolSimulationSimulateParams,\n ): SimulateDepositPassivePoolEntity {\n if (!(params.moneyInOutChainId in this.socketDepositFees)) {\n throw new Error(\n `Socket deposit fees for chain ${params.moneyInOutChainId} not loaded. Call arm() first (or make sure arm will fetch info for this chain id)`,\n );\n }\n\n const bridgeTimeInMS = getSocketBridgeTime({\n moneyInOutChainId: params.moneyInOutChainId,\n }).bridgeTimeInMS;\n\n const result: SimulateDepositPassivePoolEntity = {\n socketDepositFees: this.socketDepositFees[params.moneyInOutChainId],\n bridgeTimeInMS: bridgeTimeInMS,\n };\n\n return result;\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/deposit-passive-pool.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAOyB;AAKzB,0CAAiD;AAEjD;IAAgE,sDAAU;IAGxE,4CAAY,IAAY,EAAE,UAA0B;QAClD,YAAA,MAAK,YAAC,IAAI,EAAE,UAAU,CAAC,SAAC;QAHlB,2BAAqB,GAA2B,EAAE,CAAC;;IAI3D,CAAC;IAED,wDAAwD;IAClD,gDAAG,GAAT;;;;;;wBACE,KAAA,IAAI,CAAA;wBAAyB,qBAAM,IAAI,CAAC,GAAG,CACzC,0BAA0B,CAC3B,EAAA;;wBAFD,GAAK,qBAAqB,GAAG,SAE5B,CAAC;;;;;KACH;IAED,+DAA+D;IAC/D,qDAAQ,GAAR,UACE,MAAkD;QAElD,IAAM,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;QACnD,IAAM,SAAS,GAAG,IAAA,mCAA0B,EAAC,iBAAiB,CAAC,CAAC;QAChE,IAAM,mBAAmB,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,CACzD,UAAC,oBAAoB;YACnB,OAAA,oBAAoB,CAAC,iBAAiB,KAAK,iBAAiB;gBAC5D,oBAAoB,CAAC,SAAS,KAAK,SAAS,CAAC,IAAI;QADjD,CACiD,CACpD,CAAC;QACF,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CACb,wCAAiC,iBAAiB,wBAAc,SAAS,CAAC,IAAI,iGAA8F,CAC7K,CAAC;QACJ,CAAC;QACD,IAAM,iBAAiB,GAAsB;YAC3C,IAAI,EAAE,mBAAmB,CAAC,IAAI;YAC9B,qBAAqB,EAAE,IAAA,gBAAO,EAAC,EAAE,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC;YAC5D,mBAAmB,EAAE,IAAA,uBAAc,EAAC,iBAAiB,CAAC;SACvD,CAAC;QAEF,IAAM,cAAc,GAAG,IAAA,4BAAmB,EAAC;YACzC,iBAAiB,EAAE,iBAAiB;SACrC,CAAC,CAAC,cAAc,CAAC;QAElB,OAAO;YACL,iBAAiB,EAAE,iBAAiB;YACpC,cAAc,EAAE,cAAc;SAC/B,CAAC;IACJ,CAAC;IACH,yCAAC;AAAD,CAAC,AA7CD,CAAgE,mBAAU,GA6CzE","sourcesContent":["import {\n descale,\n getRUSDUnderlyingTokenInfo,\n getSocketBridgeTime,\n RestClient,\n SocketDepositFees,\n SocketDepositFeesRow,\n} from '@reyaxyz/common';\nimport {\n DepositPassivePoolSimulationSimulateParams,\n SimulateDepositPassivePoolEntity,\n} from './types';\nimport { getNativeToken } from '@reyaxyz/common';\n\nexport default class DepositPassivePoolSimulationClient extends RestClient {\n private socketDepositFeesList: SocketDepositFeesRow[] = [];\n\n constructor(host: string, apiTimeout?: number | null) {\n super(host, apiTimeout);\n }\n\n // Method to asynchronously load data based on accountId\n async arm(): Promise<void> {\n this.socketDepositFeesList = await this.get<SocketDepositFeesRow[]>(\n `/api/socket/deposit-fees`,\n );\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(\n params: DepositPassivePoolSimulationSimulateParams,\n ): SimulateDepositPassivePoolEntity {\n const moneyInOutChainId = params.moneyInOutChainId;\n const tokenInfo = getRUSDUnderlyingTokenInfo(moneyInOutChainId);\n const socketDpositFeesRow = this.socketDepositFeesList.find(\n (socketDepositFeesRow) =>\n socketDepositFeesRow.moneyInOutChainId === moneyInOutChainId &&\n socketDepositFeesRow.tokenName === tokenInfo.name,\n );\n if (!socketDpositFeesRow) {\n throw new Error(\n `Socket deposit fees for chain ${moneyInOutChainId} and token ${tokenInfo.name} not loaded. Call arm() first (or make sure arm will fetch info for this chain id and token)`,\n );\n }\n const socketDepositFees: SocketDepositFees = {\n fees: socketDpositFeesRow.fees,\n feesInUnderlyingToken: descale(18)(socketDpositFeesRow.fees),\n underlyingTokenName: getNativeToken(moneyInOutChainId),\n };\n\n const bridgeTimeInMS = getSocketBridgeTime({\n moneyInOutChainId: moneyInOutChainId,\n }).bridgeTimeInMS;\n\n return {\n socketDepositFees: socketDepositFees,\n bridgeTimeInMS: bridgeTimeInMS,\n };\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"api-client.d.ts","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,qBAAqB,MAAM,4BAA4B,CAAC;AAC/D,OAAO,QAAQ,MAAM,cAAc,CAAC;AACpC,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,8BAA8B,MAAM,sCAAsC,CAAC;AAClF,OAAO,iCAAiC,MAAM,0CAA0C,CAAC;AACzF,OAAO,4BAA4B,MAAM,qCAAqC,CAAC;AAC/E,OAAO,kCAAkC,MAAM,2CAA2C,CAAC;AAC3F,OAAO,0BAA0B,MAAM,kCAAkC,CAAC;AAC1E,OAAO,wCAAwC,MAAM,kDAAkD,CAAC;AACxG,OAAO,8BAA8B,MAAM,uCAAuC,CAAC;AACnF,OAAO,0BAA0B,MAAM,kCAAkC,CAAC;AAC1E,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AAEvD;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,C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AEzC;IAED;;;;;;;;;;;;OAYG;IAEH,WAAkB,eAAe,IAAI,qBAAqB,CAEzD;IAED,WAAkB,kBAAkB,IAAI,iBAAiB,CAExD;IAED;;;;;;OAMG;IACH,WAAkB,eAAe,IAAI,0BAA0B,CAE9D;IAED;;;;;;;;;;;;OAYG;IAEH,WAAkB,8BAA8B,IAAI,8BAA8B,CAEjF;IAED;;;;;;;;;;;;OAYG;IAEH,WAAkB,2BAA2B,IAAI,iCAAiC,CAEjF;IAED;;;;;;;;;;;;OAYG;IAEH,WAAkB,sBAAsB,IAAI,4BAA4B,CAEvE;IAED;;;;;;;;;;;;OAYG;IAEH,WAAkB,4BAA4B,IAAI,kCAAkC,CAEnF;IAED;;;;;;;;;;;;OAYG;IAEH,WAAkB,oBAAoB,IAAI,0BAA0B,CAEnE;IAED;;;;;;;;;;;;OAYG;IAEH,WAAkB,kCAAkC,IAAI,wCAAwC,CAE/F;IAED;;;;;;;;;;;;OAYG;IAEH,WAAkB,wBAAwB,IAAI,8BAA8B,CAE3E;IAED;;;;;;;;;OASG;IACH,WAAkB,EAAE,IAAI,QAAQ,CAE/B;IAED;;;;;;;;;OASG;IACH,WAAkB,MAAM,IAAI,YAAY,CAEvC;IAED;;;;;;;;;OASG;IACH,WAAkB,KAAK,IAAI,WAAW,CAErC;CACF"}
@@ -1,11 +1,10 @@
1
- import { RestClient, ReyaChainId } from '@reyaxyz/common';
1
+ import { RestClient } from '@reyaxyz/common';
2
2
  import EditCollateralClient from '../edit-collateral.simulation';
3
3
  import { DepositExistingMASimulationLoadDataParams, DepositExistingMASimulationSimulateParams, SimulateDepositExistingMAEntity } from './types';
4
4
  export default class DepositExistingMASimulationClient extends RestClient {
5
5
  private editCollateralClient;
6
- private socketDepositFees;
7
- private reyaChainId;
8
- constructor(editCollateralClient: EditCollateralClient, reyaChainId: ReyaChainId, host: string, apiTimeout?: number | null);
6
+ private socketDepositFeesList;
7
+ constructor(editCollateralClient: EditCollateralClient, host: string, apiTimeout?: number | null);
9
8
  arm(params: DepositExistingMASimulationLoadDataParams): Promise<void>;
10
9
  simulate(params: DepositExistingMASimulationSimulateParams): SimulateDepositExistingMAEntity;
11
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,WAAW,EAIZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,oBAAoB,MAAM,+BAA+B,CAAC;AACjE,OAAO,EACL,yCAAyC,EACzC,yCAAyC,EACzC,+BAA+B,EAChC,MAAM,SAAS,CAAC;AAEjB,MAAM,CAAC,OAAO,OAAO,iCAAkC,SAAQ,UAAU;IACvE,OAAO,CAAC,oBAAoB,CAAuB;IACnD,OAAO,CAAC,iBAAiB,CAAyC;IAClE,OAAO,CAAC,WAAW,CAAc;gBAG/B,oBAAoB,EAAE,oBAAoB,EAC1C,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAQtB,GAAG,CAAC,MAAM,EAAE,yCAAyC,GAAG,OAAO,CAAC,IAAI,CAAC;IA8B3E,QAAQ,CACN,MAAM,EAAE,yCAAyC,GAChD,+BAA+B;CAwBnC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,UAAU,EAGX,MAAM,iBAAiB,CAAC;AACzB,OAAO,oBAAoB,MAAM,+BAA+B,CAAC;AACjE,OAAO,EACL,yCAAyC,EACzC,yCAAyC,EACzC,+BAA+B,EAChC,MAAM,SAAS,CAAC;AAGjB,MAAM,CAAC,OAAO,OAAO,iCAAkC,SAAQ,UAAU;IACvE,OAAO,CAAC,oBAAoB,CAAuB;IACnD,OAAO,CAAC,qBAAqB,CAA8B;gBAGzD,oBAAoB,EAAE,oBAAoB,EAC1C,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAOtB,GAAG,CAAC,MAAM,EAAE,yCAAyC,GAAG,OAAO,CAAC,IAAI,CAAC;IAW3E,QAAQ,CACN,MAAM,EAAE,yCAAyC,GAChD,+BAA+B;CAsCnC"}
@@ -1,9 +1,8 @@
1
- import { RestClient, ReyaChainId } from '@reyaxyz/common';
1
+ import { RestClient } from '@reyaxyz/common';
2
2
  import { DepositPassivePoolSimulationSimulateParams, SimulateDepositPassivePoolEntity } from './types';
3
3
  export default class DepositPassivePoolSimulationClient extends RestClient {
4
- private socketDepositFees;
5
- private reyaChainId;
6
- constructor(reyaChainId: ReyaChainId, host: string, apiTimeout?: number | null);
4
+ private socketDepositFeesList;
5
+ constructor(host: string, apiTimeout?: number | null);
7
6
  arm(): Promise<void>;
8
7
  simulate(params: DepositPassivePoolSimulationSimulateParams): SimulateDepositPassivePoolEntity;
9
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/deposit-passive-pool.simulation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,WAAW,EAIZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,0CAA0C,EAC1C,gCAAgC,EACjC,MAAM,SAAS,CAAC;AAEjB,MAAM,CAAC,OAAO,OAAO,kCAAmC,SAAQ,UAAU;IACxE,OAAO,CAAC,iBAAiB,CAAyC;IAClE,OAAO,CAAC,WAAW,CAAc;gBAG/B,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAOtB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IA0B1B,QAAQ,CACN,MAAM,EAAE,0CAA0C,GACjD,gCAAgC;CAkBpC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/deposit-passive-pool.simulation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,UAAU,EAGX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,0CAA0C,EAC1C,gCAAgC,EACjC,MAAM,SAAS,CAAC;AAGjB,MAAM,CAAC,OAAO,OAAO,kCAAmC,SAAQ,UAAU;IACxE,OAAO,CAAC,qBAAqB,CAA8B;gBAE/C,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAK9C,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAO1B,QAAQ,CACN,MAAM,EAAE,0CAA0C,GACjD,gCAAgC;CA4BpC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/api-sdk",
3
- "version": "0.69.2",
3
+ "version": "0.69.4",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -33,9 +33,9 @@
33
33
  "generate:coverage-badges": "npx istanbul-badges-readme --silent"
34
34
  },
35
35
  "dependencies": {
36
- "@reyaxyz/common": "0.73.0",
36
+ "@reyaxyz/common": "0.73.1",
37
37
  "bignumber.js": "^9.1.2"
38
38
  },
39
39
  "packageManager": "pnpm@8.10.4",
40
- "gitHead": "e515796e1445af959aa1083d01b884aaafc66055"
40
+ "gitHead": "295e2c471470d65be16adc928bbbab253b4776a4"
41
41
  }
@@ -50,14 +50,12 @@ export class ApiClient {
50
50
  );
51
51
  this._depositExistingMASimulation = new DepositExistingMASimulationClient(
52
52
  this._editCollateralSimulation,
53
- ApiClient.config.chain,
54
53
  ApiClient.config.apiEndpoint,
55
54
  );
56
55
  this._depositNewMASimulation = new DepositNewMASimulationClient(
57
56
  this._depositExistingMASimulation,
58
57
  );
59
58
  this._depositPassivePoolSimulation = new DepositPassivePoolSimulationClient(
60
- ApiClient.config.chain,
61
59
  ApiClient.config.apiEndpoint,
62
60
  );
63
61
  this._withdrawMASimulation = new WithdrawMASimulationClient(
@@ -1,9 +1,10 @@
1
1
  import {
2
+ descale,
3
+ getSocketBridgeTime,
4
+ getTokenInfoByAddress,
2
5
  RestClient,
3
- ReyaChainId,
4
6
  SocketDepositFees,
5
- getMoneyInOutNetworksFromReyaChainId,
6
- getSocketBridgeTime,
7
+ SocketDepositFeesRow,
7
8
  } from '@reyaxyz/common';
8
9
  import EditCollateralClient from '../edit-collateral.simulation';
9
10
  import {
@@ -11,20 +12,18 @@ import {
11
12
  DepositExistingMASimulationSimulateParams,
12
13
  SimulateDepositExistingMAEntity,
13
14
  } from './types';
15
+ import { getNativeToken } from '@reyaxyz/common';
14
16
 
15
17
  export default class DepositExistingMASimulationClient extends RestClient {
16
18
  private editCollateralClient: EditCollateralClient;
17
- private socketDepositFees: Record<number, SocketDepositFees> = {};
18
- private reyaChainId: ReyaChainId;
19
+ private socketDepositFeesList: SocketDepositFeesRow[] = [];
19
20
 
20
21
  constructor(
21
22
  editCollateralClient: EditCollateralClient,
22
- reyaChainId: ReyaChainId,
23
23
  host: string,
24
24
  apiTimeout?: number | null,
25
25
  ) {
26
26
  super(host, apiTimeout);
27
- this.reyaChainId = reyaChainId;
28
27
  this.editCollateralClient = editCollateralClient;
29
28
  }
30
29
 
@@ -34,55 +33,50 @@ export default class DepositExistingMASimulationClient extends RestClient {
34
33
  marginAccountId: params.marginAccountId,
35
34
  });
36
35
 
37
- const moneyInOutChainIds = getMoneyInOutNetworksFromReyaChainId(
38
- this.reyaChainId,
36
+ this.socketDepositFeesList = await this.get<SocketDepositFeesRow[]>(
37
+ `/api/socket/deposit-fees`,
39
38
  );
40
-
41
- const socketDepositFeesPromises: Promise<SocketDepositFees>[] = [];
42
- for (const moneyInOutChainId of moneyInOutChainIds) {
43
- socketDepositFeesPromises.push(
44
- this.get<SocketDepositFees>(
45
- `/api/socket/deposit-fees/${moneyInOutChainId}`,
46
- ),
47
- );
48
- }
49
-
50
- const socketDepositFeesArray: (SocketDepositFees | undefined)[] =
51
- await Promise.all(socketDepositFeesPromises);
52
- moneyInOutChainIds.forEach((moneyInOutChainId, index) => {
53
- if (socketDepositFeesArray[index] !== undefined) {
54
- this.socketDepositFees[moneyInOutChainId] = socketDepositFeesArray[
55
- index
56
- ] as SocketDepositFees;
57
- }
58
- });
59
39
  }
60
40
 
61
41
  // Synchronous method to simulate operations based on an amount
62
42
  simulate(
63
43
  params: DepositExistingMASimulationSimulateParams,
64
44
  ): SimulateDepositExistingMAEntity {
65
- if (!(params.moneyInOutChainId in this.socketDepositFees)) {
45
+ const moneyInOutChainId = params.moneyInOutChainId;
46
+ const tokenInfo = getTokenInfoByAddress(
47
+ params.tokenAddress,
48
+ moneyInOutChainId,
49
+ );
50
+ const socketDpositFeesRow = this.socketDepositFeesList.find(
51
+ (socketDepositFeesRow) =>
52
+ socketDepositFeesRow.moneyInOutChainId === moneyInOutChainId &&
53
+ socketDepositFeesRow.tokenName === tokenInfo.name,
54
+ );
55
+ if (!socketDpositFeesRow) {
66
56
  throw new Error(
67
- `Socket deposit fees for chain ${params.moneyInOutChainId} not loaded. Call arm() first (or make sure arm will fetch info for this chain id)`,
57
+ `Socket deposit fees for chain ${moneyInOutChainId} and token ${tokenInfo.name} not loaded. Call arm() first (or make sure arm will fetch info for this chain id and token)`,
68
58
  );
69
59
  }
60
+ const socketDepositFees: SocketDepositFees = {
61
+ fees: socketDpositFeesRow.fees,
62
+ feesInUnderlyingToken: descale(18)(socketDpositFeesRow.fees),
63
+ underlyingTokenName: getNativeToken(moneyInOutChainId),
64
+ };
65
+
70
66
  const simulateEditCollateralEntity = this.editCollateralClient.simulate({
71
67
  signedAmount: params.amount,
72
68
  tokenAddress: params.tokenAddress,
73
69
  });
74
70
 
75
71
  const bridgeTimeInMS = getSocketBridgeTime({
76
- moneyInOutChainId: params.moneyInOutChainId,
72
+ moneyInOutChainId: moneyInOutChainId,
77
73
  }).bridgeTimeInMS;
78
74
 
79
- const result: SimulateDepositExistingMAEntity = {
80
- socketDepositFees: this.socketDepositFees[params.moneyInOutChainId],
75
+ return {
76
+ socketDepositFees: socketDepositFees,
81
77
  bridgeTimeInMS: bridgeTimeInMS,
82
78
  marginRatio: simulateEditCollateralEntity.marginRatio,
83
79
  marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,
84
80
  };
85
-
86
- return result;
87
81
  }
88
82
  }
@@ -1,73 +1,60 @@
1
1
  import {
2
+ descale,
3
+ getRUSDUnderlyingTokenInfo,
4
+ getSocketBridgeTime,
2
5
  RestClient,
3
- ReyaChainId,
4
6
  SocketDepositFees,
5
- getMoneyInOutNetworksFromReyaChainId,
6
- getSocketBridgeTime,
7
+ SocketDepositFeesRow,
7
8
  } from '@reyaxyz/common';
8
9
  import {
9
10
  DepositPassivePoolSimulationSimulateParams,
10
11
  SimulateDepositPassivePoolEntity,
11
12
  } from './types';
13
+ import { getNativeToken } from '@reyaxyz/common';
12
14
 
13
15
  export default class DepositPassivePoolSimulationClient extends RestClient {
14
- private socketDepositFees: Record<number, SocketDepositFees> = {};
15
- private reyaChainId: ReyaChainId;
16
+ private socketDepositFeesList: SocketDepositFeesRow[] = [];
16
17
 
17
- constructor(
18
- reyaChainId: ReyaChainId,
19
- host: string,
20
- apiTimeout?: number | null,
21
- ) {
18
+ constructor(host: string, apiTimeout?: number | null) {
22
19
  super(host, apiTimeout);
23
- this.reyaChainId = reyaChainId;
24
20
  }
25
21
 
26
22
  // Method to asynchronously load data based on accountId
27
23
  async arm(): Promise<void> {
28
- const moneyInOutChainIds = getMoneyInOutNetworksFromReyaChainId(
29
- this.reyaChainId,
24
+ this.socketDepositFeesList = await this.get<SocketDepositFeesRow[]>(
25
+ `/api/socket/deposit-fees`,
30
26
  );
31
-
32
- const socketDepositFeesPromises: Promise<SocketDepositFees>[] = [];
33
- for (const moneyInOutChainId of moneyInOutChainIds) {
34
- socketDepositFeesPromises.push(
35
- this.get<SocketDepositFees>(
36
- `/api/socket/deposit-fees/${moneyInOutChainId}`,
37
- ),
38
- );
39
- }
40
-
41
- const socketDepositFeesArray: (SocketDepositFees | undefined)[] =
42
- await Promise.all(socketDepositFeesPromises);
43
- moneyInOutChainIds.forEach((moneyInOutChainId, index) => {
44
- if (socketDepositFeesArray[index] !== undefined) {
45
- this.socketDepositFees[moneyInOutChainId] = socketDepositFeesArray[
46
- index
47
- ] as SocketDepositFees;
48
- }
49
- });
50
27
  }
51
28
 
52
29
  // Synchronous method to simulate operations based on an amount
53
30
  simulate(
54
31
  params: DepositPassivePoolSimulationSimulateParams,
55
32
  ): SimulateDepositPassivePoolEntity {
56
- if (!(params.moneyInOutChainId in this.socketDepositFees)) {
33
+ const moneyInOutChainId = params.moneyInOutChainId;
34
+ const tokenInfo = getRUSDUnderlyingTokenInfo(moneyInOutChainId);
35
+ const socketDpositFeesRow = this.socketDepositFeesList.find(
36
+ (socketDepositFeesRow) =>
37
+ socketDepositFeesRow.moneyInOutChainId === moneyInOutChainId &&
38
+ socketDepositFeesRow.tokenName === tokenInfo.name,
39
+ );
40
+ if (!socketDpositFeesRow) {
57
41
  throw new Error(
58
- `Socket deposit fees for chain ${params.moneyInOutChainId} not loaded. Call arm() first (or make sure arm will fetch info for this chain id)`,
42
+ `Socket deposit fees for chain ${moneyInOutChainId} and token ${tokenInfo.name} not loaded. Call arm() first (or make sure arm will fetch info for this chain id and token)`,
59
43
  );
60
44
  }
45
+ const socketDepositFees: SocketDepositFees = {
46
+ fees: socketDpositFeesRow.fees,
47
+ feesInUnderlyingToken: descale(18)(socketDpositFeesRow.fees),
48
+ underlyingTokenName: getNativeToken(moneyInOutChainId),
49
+ };
61
50
 
62
51
  const bridgeTimeInMS = getSocketBridgeTime({
63
- moneyInOutChainId: params.moneyInOutChainId,
52
+ moneyInOutChainId: moneyInOutChainId,
64
53
  }).bridgeTimeInMS;
65
54
 
66
- const result: SimulateDepositPassivePoolEntity = {
67
- socketDepositFees: this.socketDepositFees[params.moneyInOutChainId],
55
+ return {
56
+ socketDepositFees: socketDepositFees,
68
57
  bridgeTimeInMS: bridgeTimeInMS,
69
58
  };
70
-
71
- return result;
72
59
  }
73
60
  }