@reyaxyz/api-sdk 0.63.5 → 0.63.7

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.
@@ -29,12 +29,12 @@ var ApiClient = /** @class */ (function () {
29
29
  this._lp = new lp_1.default(ApiClient.config.apiEndpoint);
30
30
  this._tradeSimulation = new trade_simulation_1.default(this._account);
31
31
  this._fundingRateHistory = new funding_rate_1.default(this._markets);
32
- this._editCollateralSimulation = new edit_collateral_simulation_1.default(this._account);
32
+ this._editCollateralSimulation = new edit_collateral_simulation_1.default(ApiClient.network, this._account);
33
33
  this._depositExistingMASimulation = new deposit_existing_MA_simulation_1.default(this._editCollateralSimulation);
34
34
  this._depositNewMASimulation = new deposit_new_MA_simulation_1.default(this._depositExistingMASimulation);
35
35
  this._withdrawMASimulation = new withdraw_MA_simulation_1.default(this._editCollateralSimulation, ApiClient.config.chain);
36
36
  this._transferMarginBetweenMAsSimulation =
37
- new transfer_margin_between_MAs_simulation_1.default(this._account);
37
+ new transfer_margin_between_MAs_simulation_1.default(ApiClient.network, this._account);
38
38
  this._transferMAPoolSimulation = new transfer_MA_Pool_simulation_1.default(this._editCollateralSimulation);
39
39
  this._depthSimulation = new depth_chart_simulation_1.default(this._lp);
40
40
  this._tokens = new tokens_1.default(ApiClient.config.apiEndpoint);
@@ -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,4FAA0E;AAC1E,4HAAwG;AACxG,sGAAmF;AACnF,4FAA0E;AAC1E,wEAAuD;AAEvD;;GAEG;AACH;IAkBE;QACE,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAa,CAAC,SAAS,CAAC,MAAM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Config } 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 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 _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 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._transferMarginBetweenMAsSimulation =\n new TransferMarginBetweenMAsSimulationClient(this._account);\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 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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AC;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;IAlRc,gBAAM,GAAkB,2BAAkB,CAAC,MAAM,CAAC,CAAC;IAmRpE,gBAAC;CAAA,AArRD,IAqRC;AArRY,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 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 _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 );\n this._depositNewMASimulation = new DepositNewMASimulationClient(\n this._depositExistingMASimulation,\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 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"]}
@@ -38,10 +38,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  var common_1 = require("@reyaxyz/common");
40
40
  var EditCollateralSimulationClient = /** @class */ (function () {
41
- function EditCollateralSimulationClient(accountClient) {
41
+ function EditCollateralSimulationClient(reyaChainId, accountClient) {
42
42
  this.accountId = null;
43
43
  this.loadedData = null;
44
44
  // Constructor added
45
+ this.reyaChainId = reyaChainId;
45
46
  this.accountClient = accountClient;
46
47
  }
47
48
  // Method to asynchronously load data based on accountId
@@ -70,7 +71,11 @@ var EditCollateralSimulationClient = /** @class */ (function () {
70
71
  throw new Error('Data not loaded. Call arm() first.');
71
72
  }
72
73
  var userAccountExposure = new common_1.ExposureCommand(this.loadedData.exposureDataAccount.accountId, this.loadedData.exposureDataAccount.rootCollateralPoolId, this.loadedData.exposureDataAccount.oraclePricePerMarket, this.loadedData.exposureDataAccount.accountBalancePerAsset, this.loadedData.exposureDataAccount.groupedByCollateral, this.loadedData.exposureDataAccount.riskMultipliers, this.loadedData.exposureDataAccount.riskMatrices, this.loadedData.exposureDataAccount.exchangeInfoPerAsset, this.loadedData.exposureDataAccount.positionInfoMarketConfiguration, this.loadedData.exposureDataAccount.uniqueTokenAddresses, this.loadedData.exposureDataAccount.uniqueQuoteCollaterals, this.loadedData.exposureDataAccount.tokenMarginInfoPerAsset, this.loadedData.exposureDataAccount.realizedPnLSum, this.loadedData.exposureDataAccount.unrealizedPnLSum, this.loadedData.exposureDataAccount.collateralAddressToExchangePrice);
73
- var newMarginInfo = userAccountExposure.getUsdNodeMarginInfoPostEditCollateral(params.signedAmount, params.tokenAddress);
74
+ var tokenInfo = (0, common_1.getTokenInfoByAddress)(params.tokenAddress);
75
+ if (tokenInfo.name === 'USDC') {
76
+ tokenInfo = (0, common_1.getTokenInfoByName)('RUSD', this.reyaChainId);
77
+ }
78
+ var newMarginInfo = userAccountExposure.getUsdNodeMarginInfoPostEditCollateral(params.signedAmount, tokenInfo.address);
74
79
  var marginRatio = common_1.ExposureCommand.getMarginRatio(newMarginInfo);
75
80
  var marginRatioHealth = common_1.ExposureCommand.evaluateHealthStatus(marginRatio, newMarginInfo);
76
81
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/edit-collateral.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,0CAGyB;AAEzB;IAIE,wCAAY,aAA4B;QAHhC,cAAS,GAAkB,IAAI,CAAC;QAChC,eAAU,GAAyC,IAAI,CAAC;QAG9D,oBAAoB;QACpB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAED,wDAAwD;IAClD,4CAAG,GAAT,UAAU,MAA8C;;;;;;wBACtD,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,eAAe,CAAC;wBAExC,KAAA,IAAI,CAAA;wBACF,qBAAM,IAAI,CAAC,aAAa,CAAC,sCAAsC,CAAC;gCAC9D,eAAe,EAAE,IAAI,CAAC,SAAS;6BAChC,CAAC,EAAA;;wBAHJ,GAAK,UAAU;4BACb,SAEE,CAAC;;;;;KACN;IAED,+DAA+D;IAC/D,iDAAQ,GAAR,UACE,MAA8C;QAE9C,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CA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E,iBAAiB;SACL,CAAC;IACpC,CAAC;IACH,qCAAC;AAAD,CAAC,AA/DD,IA+DC","sourcesContent":["import {\n EditCollateralSimulationLoadDataParams,\n EditCollateralSimulationSimulateParams,\n SimulateEditCollateralEntity,\n} from './types';\nimport AccountClient from '../account';\nimport {\n EditCollateralSimulationState,\n ExposureCommand,\n} from '@reyaxyz/common';\n\nexport default class EditCollateralSimulationClient {\n private accountId: number | null = null;\n private loadedData: EditCollateralSimulationState | null = null;\n private accountClient: AccountClient;\n constructor(accountClient: AccountClient) {\n // Constructor added\n this.accountClient = accountClient;\n }\n\n // Method to asynchronously load data based on accountId\n async arm(params: EditCollateralSimulationLoadDataParams): Promise<void> {\n this.accountId = params.marginAccountId;\n\n this.loadedData =\n await this.accountClient.getEditCollateralSimulationInitialData({\n marginAccountId: this.accountId,\n });\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(\n params: EditCollateralSimulationSimulateParams,\n ): SimulateEditCollateralEntity {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const userAccountExposure = new ExposureCommand(\n this.loadedData.exposureDataAccount.accountId,\n this.loadedData.exposureDataAccount.rootCollateralPoolId,\n this.loadedData.exposureDataAccount.oraclePricePerMarket,\n this.loadedData.exposureDataAccount.accountBalancePerAsset,\n this.loadedData.exposureDataAccount.groupedByCollateral,\n this.loadedData.exposureDataAccount.riskMultipliers,\n this.loadedData.exposureDataAccount.riskMatrices,\n this.loadedData.exposureDataAccount.exchangeInfoPerAsset,\n this.loadedData.exposureDataAccount.positionInfoMarketConfiguration,\n this.loadedData.exposureDataAccount.uniqueTokenAddresses,\n this.loadedData.exposureDataAccount.uniqueQuoteCollaterals,\n this.loadedData.exposureDataAccount.tokenMarginInfoPerAsset,\n this.loadedData.exposureDataAccount.realizedPnLSum,\n this.loadedData.exposureDataAccount.unrealizedPnLSum,\n this.loadedData.exposureDataAccount.collateralAddressToExchangePrice,\n );\n\n const newMarginInfo =\n userAccountExposure.getUsdNodeMarginInfoPostEditCollateral(\n params.signedAmount,\n params.tokenAddress,\n );\n\n const marginRatio = ExposureCommand.getMarginRatio(newMarginInfo);\n\n const marginRatioHealth = ExposureCommand.evaluateHealthStatus(\n marginRatio,\n newMarginInfo,\n );\n\n return {\n marginRatio: marginRatio * 100,\n marginRatioHealth: marginRatioHealth,\n } as SimulateEditCollateralEntity;\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/edit-collateral.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,0CAMyB;AACzB;IAKE,wCAAY,WAAwB,EAAE,aAA4B;QAH1D,cAAS,GAAkB,IAAI,CAAC;QAChC,eAAU,GAAyC,IAAI,CAAC;QAG9D,oBAAoB;QACpB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAED,wDAAwD;IAClD,4CAAG,GAAT,UAAU,MAA8C;;;;;;wBACtD,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,eAAe,CAAC;wBAExC,KAAA,IAAI,CAAA;wBACF,qBAAM,IAAI,CAAC,aAAa,CAAC,sCAAsC,CAAC;gCAC9D,eAAe,EAAE,IAAI,CAAC,SAAS;6BAChC,CAAC,EAAA;;wBAHJ,GAAK,UAAU;4BACb,SAEE,CAAC;;;;;KACN;IAED,+DAA+D;IAC/D,iDAAQ,GAAR,UACE,MAA8C;QAE9C,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACxD,CAAC;QAED,IAAM,mBAAmB,GAAG,IAAI,wBAAe,CAC7C,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,SAAS,EAC7C,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,oBAAoB,EACxD,IAAI,CAAC,UAAU,CAAC,mBAAmB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pC,CAAC;IACH,qCAAC;AAAD,CAAC,AAtED,IAsEC","sourcesContent":["import {\n EditCollateralSimulationLoadDataParams,\n EditCollateralSimulationSimulateParams,\n SimulateEditCollateralEntity,\n} from './types';\nimport AccountClient from '../account';\nimport {\n EditCollateralSimulationState,\n ExposureCommand,\n ReyaChainId,\n getTokenInfoByAddress,\n getTokenInfoByName,\n} from '@reyaxyz/common';\nexport default class EditCollateralSimulationClient {\n private reyaChainId: ReyaChainId;\n private accountId: number | null = null;\n private loadedData: EditCollateralSimulationState | null = null;\n private accountClient: AccountClient;\n constructor(reyaChainId: ReyaChainId, accountClient: AccountClient) {\n // Constructor added\n this.reyaChainId = reyaChainId;\n this.accountClient = accountClient;\n }\n\n // Method to asynchronously load data based on accountId\n async arm(params: EditCollateralSimulationLoadDataParams): Promise<void> {\n this.accountId = params.marginAccountId;\n\n this.loadedData =\n await this.accountClient.getEditCollateralSimulationInitialData({\n marginAccountId: this.accountId,\n });\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(\n params: EditCollateralSimulationSimulateParams,\n ): SimulateEditCollateralEntity {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const userAccountExposure = new ExposureCommand(\n this.loadedData.exposureDataAccount.accountId,\n this.loadedData.exposureDataAccount.rootCollateralPoolId,\n this.loadedData.exposureDataAccount.oraclePricePerMarket,\n this.loadedData.exposureDataAccount.accountBalancePerAsset,\n this.loadedData.exposureDataAccount.groupedByCollateral,\n this.loadedData.exposureDataAccount.riskMultipliers,\n this.loadedData.exposureDataAccount.riskMatrices,\n this.loadedData.exposureDataAccount.exchangeInfoPerAsset,\n this.loadedData.exposureDataAccount.positionInfoMarketConfiguration,\n this.loadedData.exposureDataAccount.uniqueTokenAddresses,\n this.loadedData.exposureDataAccount.uniqueQuoteCollaterals,\n this.loadedData.exposureDataAccount.tokenMarginInfoPerAsset,\n this.loadedData.exposureDataAccount.realizedPnLSum,\n this.loadedData.exposureDataAccount.unrealizedPnLSum,\n this.loadedData.exposureDataAccount.collateralAddressToExchangePrice,\n );\n\n let tokenInfo = getTokenInfoByAddress(params.tokenAddress);\n if (tokenInfo.name === 'USDC') {\n tokenInfo = getTokenInfoByName('RUSD', this.reyaChainId);\n }\n\n const newMarginInfo =\n userAccountExposure.getUsdNodeMarginInfoPostEditCollateral(\n params.signedAmount,\n tokenInfo.address,\n );\n\n const marginRatio = ExposureCommand.getMarginRatio(newMarginInfo);\n\n const marginRatioHealth = ExposureCommand.evaluateHealthStatus(\n marginRatio,\n newMarginInfo,\n );\n\n return {\n marginRatio: marginRatio * 100,\n marginRatioHealth: marginRatioHealth,\n } as SimulateEditCollateralEntity;\n }\n}\n"]}
@@ -41,10 +41,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
42
  var edit_collateral_simulation_1 = __importDefault(require("../edit-collateral.simulation"));
43
43
  var TransferMarginBetweenMAsSimulationClient = /** @class */ (function () {
44
- function TransferMarginBetweenMAsSimulationClient(accountClient) {
44
+ function TransferMarginBetweenMAsSimulationClient(reyaChainId, accountClient) {
45
45
  // Constructor added
46
- this.fromEditCollateralClient = new edit_collateral_simulation_1.default(accountClient);
47
- this.toEditCollateralClient = new edit_collateral_simulation_1.default(accountClient);
46
+ this.fromEditCollateralClient = new edit_collateral_simulation_1.default(reyaChainId, accountClient);
47
+ this.toEditCollateralClient = new edit_collateral_simulation_1.default(reyaChainId, accountClient);
48
48
  }
49
49
  // Method to asynchronously load data based on accountId
50
50
  TransferMarginBetweenMAsSimulationClient.prototype.arm = function (params) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/transfer-margin-between-MAs.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,6FAA2E;AAE3E;IAGE,kDAAY,aAA4B;QACtC,oBAAoB;QACpB,IAAI,CAAC,wBAAwB,GAAG,IAAI,oCAA8B,CAChE,aAAa,CACd,CAAC;QACF,IAAI,CAAC,sBAAsB,GAAG,IAAI,oCAA8B,CAC9D,aAAa,CACd,CAAC;IACJ,CAAC;IAED,wDAAwD;IAClD,sDAAG,GAAT,UACE,MAAwD;;;;4BAExD,qBAAM,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC;4BACtC,eAAe,EAAE,MAAM,CAAC,mBAAmB;yBAC5C,CAAC,EAAA;;wBAFF,SAEE,CAAC;wBAEH,qBAAM,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC;gCACpC,eAAe,EAAE,MAAM,CAAC,iBAAiB;6BAC1C,CAAC,EAAA;;wBAFF,SAEE,CAAC;;;;;KACJ;IAED,+DAA+D;IAC/D,2DAAQ,GAAR,UACE,MAAwD;QAExD,IAAM,gCAAgC,GACpC,IAAI,CAAC,wBAAwB,CAAC,QAAQ,CAAC;YACrC,YAAY,EAAE,CAAC,MAAM,CAAC,MAAM;YAC5B,YAAY,EAAE,MAAM,CAAC,YAAY;SAClC,CAAC,CAAC;QAEL,IAAM,8BAA8B,GAAG,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CACzE;YACE,YAAY,EAAE,MAAM,CAAC,MAAM;YAC3B,YAAY,EAAE,MAAM,CAAC,YAAY;SAClC,CACF,CAAC;QAEF,IAAM,MAAM,GAA2C;YACrD,eAAe,EAAE,gCAAgC,CAAC,WAAW;YAC7D,qBAAqB,EAAE,gCAAgC,CAAC,iBAAiB;YACzE,aAAa,EAAE,8BAA8B,CAAC,WAAW;YACzD,mBAAmB,EAAE,8BAA8B,CAAC,iBAAiB;SACtE,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC;IACH,+CAAC;AAAD,CAAC,AApDD,IAoDC","sourcesContent":["import EditCollateralClient from '../edit-collateral.simulation';\nimport {\n TransferMarginBetweenMAsSimulationLoadDataParams,\n TransferMarginBetweenMAsSimulationSimulateParams,\n SimulateTransferMarginBetweenMAsEntity,\n} from './types';\nimport AccountClient from '../account';\nimport EditCollateralSimulationClient from '../edit-collateral.simulation';\n\nexport default class TransferMarginBetweenMAsSimulationClient {\n private fromEditCollateralClient: EditCollateralClient;\n private toEditCollateralClient: EditCollateralClient;\n constructor(accountClient: AccountClient) {\n // Constructor added\n this.fromEditCollateralClient = new EditCollateralSimulationClient(\n accountClient,\n );\n this.toEditCollateralClient = new EditCollateralSimulationClient(\n accountClient,\n );\n }\n\n // Method to asynchronously load data based on accountId\n async arm(\n params: TransferMarginBetweenMAsSimulationLoadDataParams,\n ): Promise<void> {\n await this.fromEditCollateralClient.arm({\n marginAccountId: params.fromMarginAccountId,\n });\n\n await this.toEditCollateralClient.arm({\n marginAccountId: params.toMarginAccountId,\n });\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(\n params: TransferMarginBetweenMAsSimulationSimulateParams,\n ): SimulateTransferMarginBetweenMAsEntity {\n const simulateFromEditCollateralEntity =\n this.fromEditCollateralClient.simulate({\n signedAmount: -params.amount,\n tokenAddress: params.tokenAddress,\n });\n\n const simulateToEditCollateralEntity = this.toEditCollateralClient.simulate(\n {\n signedAmount: params.amount,\n tokenAddress: params.tokenAddress,\n },\n );\n\n const result: SimulateTransferMarginBetweenMAsEntity = {\n fromMarginRatio: simulateFromEditCollateralEntity.marginRatio,\n fromMarginRatioHealth: simulateFromEditCollateralEntity.marginRatioHealth,\n toMarginRatio: simulateToEditCollateralEntity.marginRatio,\n toMarginRatioHealth: simulateToEditCollateralEntity.marginRatioHealth,\n };\n\n return result;\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/transfer-margin-between-MAs.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,6FAA2E;AAG3E;IAGE,kDAAY,WAAwB,EAAE,aAA4B;QAChE,oBAAoB;QACpB,IAAI,CAAC,wBAAwB,GAAG,IAAI,oCAA8B,CAChE,WAAW,EACX,aAAa,CACd,CAAC;QACF,IAAI,CAAC,sBAAsB,GAAG,IAAI,oCAA8B,CAC9D,WAAW,EACX,aAAa,CACd,CAAC;IACJ,CAAC;IAED,wDAAwD;IAClD,sDAAG,GAAT,UACE,MAAwD;;;;4BAExD,qBAAM,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC;4BACtC,eAAe,EAAE,MAAM,CAAC,mBAAmB;yBAC5C,CAAC,EAAA;;wBAFF,SAEE,CAAC;wBAEH,qBAAM,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC;gCACpC,eAAe,EAAE,MAAM,CAAC,iBAAiB;6BAC1C,CAAC,EAAA;;wBAFF,SAEE,CAAC;;;;;KACJ;IAED,+DAA+D;IAC/D,2DAAQ,GAAR,UACE,MAAwD;QAExD,IAAM,gCAAgC,GACpC,IAAI,CAAC,wBAAwB,CAAC,QAAQ,CAAC;YACrC,YAAY,EAAE,CAAC,MAAM,CAAC,MAAM;YAC5B,YAAY,EAAE,MAAM,CAAC,YAAY;SAClC,CAAC,CAAC;QAEL,IAAM,8BAA8B,GAAG,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CACzE;YACE,YAAY,EAAE,MAAM,CAAC,MAAM;YAC3B,YAAY,EAAE,MAAM,CAAC,YAAY;SAClC,CACF,CAAC;QAEF,IAAM,MAAM,GAA2C;YACrD,eAAe,EAAE,gCAAgC,CAAC,WAAW;YAC7D,qBAAqB,EAAE,gCAAgC,CAAC,iBAAiB;YACzE,aAAa,EAAE,8BAA8B,CAAC,WAAW;YACzD,mBAAmB,EAAE,8BAA8B,CAAC,iBAAiB;SACtE,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC;IACH,+CAAC;AAAD,CAAC,AAtDD,IAsDC","sourcesContent":["import EditCollateralClient from '../edit-collateral.simulation';\nimport {\n TransferMarginBetweenMAsSimulationLoadDataParams,\n TransferMarginBetweenMAsSimulationSimulateParams,\n SimulateTransferMarginBetweenMAsEntity,\n} from './types';\nimport AccountClient from '../account';\nimport EditCollateralSimulationClient from '../edit-collateral.simulation';\nimport { ReyaChainId } from '@reyaxyz/common';\n\nexport default class TransferMarginBetweenMAsSimulationClient {\n private fromEditCollateralClient: EditCollateralClient;\n private toEditCollateralClient: EditCollateralClient;\n constructor(reyaChainId: ReyaChainId, accountClient: AccountClient) {\n // Constructor added\n this.fromEditCollateralClient = new EditCollateralSimulationClient(\n reyaChainId,\n accountClient,\n );\n this.toEditCollateralClient = new EditCollateralSimulationClient(\n reyaChainId,\n accountClient,\n );\n }\n\n // Method to asynchronously load data based on accountId\n async arm(\n params: TransferMarginBetweenMAsSimulationLoadDataParams,\n ): Promise<void> {\n await this.fromEditCollateralClient.arm({\n marginAccountId: params.fromMarginAccountId,\n });\n\n await this.toEditCollateralClient.arm({\n marginAccountId: params.toMarginAccountId,\n });\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(\n params: TransferMarginBetweenMAsSimulationSimulateParams,\n ): SimulateTransferMarginBetweenMAsEntity {\n const simulateFromEditCollateralEntity =\n this.fromEditCollateralClient.simulate({\n signedAmount: -params.amount,\n tokenAddress: params.tokenAddress,\n });\n\n const simulateToEditCollateralEntity = this.toEditCollateralClient.simulate(\n {\n signedAmount: params.amount,\n tokenAddress: params.tokenAddress,\n },\n );\n\n const result: SimulateTransferMarginBetweenMAsEntity = {\n fromMarginRatio: simulateFromEditCollateralEntity.marginRatio,\n fromMarginRatioHealth: simulateFromEditCollateralEntity.marginRatioHealth,\n toMarginRatio: simulateToEditCollateralEntity.marginRatio,\n toMarginRatioHealth: simulateToEditCollateralEntity.marginRatioHealth,\n };\n\n return result;\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,M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AQ,CAAC,gBAAgB,CAA6B;IAC9D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;IAErC,OAAO;WAkCO,SAAS,CAAC,WAAW,EAAE,aAAa,CAAC,aAAa,CAAC,GAAG,IAAI;IAMxE,OAAO,CAAC,MAAM,CAAC,WAAW;IAQ1B,WAAkB,OAAO,IAAI,WAAW,CAKvC;IAED;;;;;;OAMG;IACH,WAAkB,OAAO,IAAI,aAAa,CAEzC;IAED;;;;;;OAMG;IACH,WAAkB,OAAO,IAAI,aAAa,CAEzC;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,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,10 +1,12 @@
1
1
  import { EditCollateralSimulationLoadDataParams, EditCollateralSimulationSimulateParams, SimulateEditCollateralEntity } from './types';
2
2
  import AccountClient from '../account';
3
+ import { ReyaChainId } from '@reyaxyz/common';
3
4
  export default class EditCollateralSimulationClient {
5
+ private reyaChainId;
4
6
  private accountId;
5
7
  private loadedData;
6
8
  private accountClient;
7
- constructor(accountClient: AccountClient);
9
+ constructor(reyaChainId: ReyaChainId, accountClient: AccountClient);
8
10
  arm(params: EditCollateralSimulationLoadDataParams): Promise<void>;
9
11
  simulate(params: EditCollateralSimulationSimulateParams): SimulateEditCollateralEntity;
10
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/edit-collateral.simulation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sCAAsC,EACtC,sCAAsC,EACtC,4BAA4B,EAC7B,MAAM,SAAS,CAAC;AACjB,OAAO,aAAa,MAAM,YAAY,CAAC;AAMvC,MAAM,CAAC,OAAO,OAAO,8BAA8B;IACjD,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,UAAU,CAA8C;IAChE,OAAO,CAAC,aAAa,CAAgB;gBACzB,aAAa,EAAE,aAAa;IAMlC,GAAG,CAAC,MAAM,EAAE,sCAAsC,GAAG,OAAO,CAAC,IAAI,CAAC;IAUxE,QAAQ,CACN,MAAM,EAAE,sCAAsC,GAC7C,4BAA4B;CAyChC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/edit-collateral.simulation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sCAAsC,EACtC,sCAAsC,EACtC,4BAA4B,EAC7B,MAAM,SAAS,CAAC;AACjB,OAAO,aAAa,MAAM,YAAY,CAAC;AACvC,OAAO,EAGL,WAAW,EAGZ,MAAM,iBAAiB,CAAC;AACzB,MAAM,CAAC,OAAO,OAAO,8BAA8B;IACjD,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,UAAU,CAA8C;IAChE,OAAO,CAAC,aAAa,CAAgB;gBACzB,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa;IAO5D,GAAG,CAAC,MAAM,EAAE,sCAAsC,GAAG,OAAO,CAAC,IAAI,CAAC;IAUxE,QAAQ,CACN,MAAM,EAAE,sCAAsC,GAC7C,4BAA4B;CA8ChC"}
@@ -1,9 +1,10 @@
1
1
  import { TransferMarginBetweenMAsSimulationLoadDataParams, TransferMarginBetweenMAsSimulationSimulateParams, SimulateTransferMarginBetweenMAsEntity } from './types';
2
2
  import AccountClient from '../account';
3
+ import { ReyaChainId } from '@reyaxyz/common';
3
4
  export default class TransferMarginBetweenMAsSimulationClient {
4
5
  private fromEditCollateralClient;
5
6
  private toEditCollateralClient;
6
- constructor(accountClient: AccountClient);
7
+ constructor(reyaChainId: ReyaChainId, accountClient: AccountClient);
7
8
  arm(params: TransferMarginBetweenMAsSimulationLoadDataParams): Promise<void>;
8
9
  simulate(params: TransferMarginBetweenMAsSimulationSimulateParams): SimulateTransferMarginBetweenMAsEntity;
9
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/transfer-margin-between-MAs.simulation/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gDAAgD,EAChD,gDAAgD,EAChD,sCAAsC,EACvC,MAAM,SAAS,CAAC;AACjB,OAAO,aAAa,MAAM,YAAY,CAAC;AAGvC,MAAM,CAAC,OAAO,OAAO,wCAAwC;IAC3D,OAAO,CAAC,wBAAwB,CAAuB;IACvD,OAAO,CAAC,sBAAsB,CAAuB;gBACzC,aAAa,EAAE,aAAa;IAWlC,GAAG,CACP,MAAM,EAAE,gDAAgD,GACvD,OAAO,CAAC,IAAI,CAAC;IAWhB,QAAQ,CACN,MAAM,EAAE,gDAAgD,GACvD,sCAAsC;CAuB1C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/transfer-margin-between-MAs.simulation/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gDAAgD,EAChD,gDAAgD,EAChD,sCAAsC,EACvC,MAAM,SAAS,CAAC;AACjB,OAAO,aAAa,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,CAAC,OAAO,OAAO,wCAAwC;IAC3D,OAAO,CAAC,wBAAwB,CAAuB;IACvD,OAAO,CAAC,sBAAsB,CAAuB;gBACzC,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa;IAa5D,GAAG,CACP,MAAM,EAAE,gDAAgD,GACvD,OAAO,CAAC,IAAI,CAAC;IAWhB,QAAQ,CACN,MAAM,EAAE,gDAAgD,GACvD,sCAAsC;CAuB1C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/api-sdk",
3
- "version": "0.63.5",
3
+ "version": "0.63.7",
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.51.0",
36
+ "@reyaxyz/common": "0.52.0",
37
37
  "bignumber.js": "^9.1.2"
38
38
  },
39
39
  "packageManager": "pnpm@8.10.4",
40
- "gitHead": "f24123eb4d3297b27388606da51290d1754a8b70"
40
+ "gitHead": "031c329cfe49150f445768fa0b9de547c898256a"
41
41
  }
@@ -43,6 +43,7 @@ export class ApiClient {
43
43
  this._tradeSimulation = new TradeSimulationClient(this._account);
44
44
  this._fundingRateHistory = new FundingRateClient(this._markets);
45
45
  this._editCollateralSimulation = new EditCollateralSimulationClient(
46
+ ApiClient.network,
46
47
  this._account,
47
48
  );
48
49
  this._depositExistingMASimulation = new DepositExistingMASimulationClient(
@@ -56,7 +57,10 @@ export class ApiClient {
56
57
  ApiClient.config.chain,
57
58
  );
58
59
  this._transferMarginBetweenMAsSimulation =
59
- new TransferMarginBetweenMAsSimulationClient(this._account);
60
+ new TransferMarginBetweenMAsSimulationClient(
61
+ ApiClient.network,
62
+ this._account,
63
+ );
60
64
  this._transferMAPoolSimulation = new TransferMAPoolSimulationClient(
61
65
  this._editCollateralSimulation,
62
66
  );
@@ -7,14 +7,18 @@ import AccountClient from '../account';
7
7
  import {
8
8
  EditCollateralSimulationState,
9
9
  ExposureCommand,
10
+ ReyaChainId,
11
+ getTokenInfoByAddress,
12
+ getTokenInfoByName,
10
13
  } from '@reyaxyz/common';
11
-
12
14
  export default class EditCollateralSimulationClient {
15
+ private reyaChainId: ReyaChainId;
13
16
  private accountId: number | null = null;
14
17
  private loadedData: EditCollateralSimulationState | null = null;
15
18
  private accountClient: AccountClient;
16
- constructor(accountClient: AccountClient) {
19
+ constructor(reyaChainId: ReyaChainId, accountClient: AccountClient) {
17
20
  // Constructor added
21
+ this.reyaChainId = reyaChainId;
18
22
  this.accountClient = accountClient;
19
23
  }
20
24
 
@@ -54,10 +58,15 @@ export default class EditCollateralSimulationClient {
54
58
  this.loadedData.exposureDataAccount.collateralAddressToExchangePrice,
55
59
  );
56
60
 
61
+ let tokenInfo = getTokenInfoByAddress(params.tokenAddress);
62
+ if (tokenInfo.name === 'USDC') {
63
+ tokenInfo = getTokenInfoByName('RUSD', this.reyaChainId);
64
+ }
65
+
57
66
  const newMarginInfo =
58
67
  userAccountExposure.getUsdNodeMarginInfoPostEditCollateral(
59
68
  params.signedAmount,
60
- params.tokenAddress,
69
+ tokenInfo.address,
61
70
  );
62
71
 
63
72
  const marginRatio = ExposureCommand.getMarginRatio(newMarginInfo);
@@ -6,16 +6,19 @@ import {
6
6
  } from './types';
7
7
  import AccountClient from '../account';
8
8
  import EditCollateralSimulationClient from '../edit-collateral.simulation';
9
+ import { ReyaChainId } from '@reyaxyz/common';
9
10
 
10
11
  export default class TransferMarginBetweenMAsSimulationClient {
11
12
  private fromEditCollateralClient: EditCollateralClient;
12
13
  private toEditCollateralClient: EditCollateralClient;
13
- constructor(accountClient: AccountClient) {
14
+ constructor(reyaChainId: ReyaChainId, accountClient: AccountClient) {
14
15
  // Constructor added
15
16
  this.fromEditCollateralClient = new EditCollateralSimulationClient(
17
+ reyaChainId,
16
18
  accountClient,
17
19
  );
18
20
  this.toEditCollateralClient = new EditCollateralSimulationClient(
21
+ reyaChainId,
19
22
  accountClient,
20
23
  );
21
24
  }