@reyaxyz/api-sdk 0.67.1 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clients/api-client.js +23 -1
- package/dist/clients/api-client.js.map +1 -1
- package/dist/clients/modules/deposit-existing-MA.simulation/index.js +44 -10
- package/dist/clients/modules/deposit-existing-MA.simulation/index.js.map +1 -1
- package/dist/clients/modules/deposit-existing-MA.simulation/types.js.map +1 -1
- package/dist/clients/modules/deposit-passive-pool.simulation/index.js +107 -0
- package/dist/clients/modules/deposit-passive-pool.simulation/index.js.map +1 -0
- package/dist/clients/modules/deposit-passive-pool.simulation/types.js +3 -0
- package/dist/clients/modules/deposit-passive-pool.simulation/types.js.map +1 -0
- package/dist/clients/modules/withdraw-MA.simulation/types.js.map +1 -1
- package/dist/clients/types.js +1 -0
- package/dist/clients/types.js.map +1 -1
- package/dist/types/clients/api-client.d.ts +16 -0
- package/dist/types/clients/api-client.d.ts.map +1 -1
- package/dist/types/clients/modules/deposit-existing-MA.simulation/index.d.ts +5 -2
- package/dist/types/clients/modules/deposit-existing-MA.simulation/index.d.ts.map +1 -1
- package/dist/types/clients/modules/deposit-existing-MA.simulation/types.d.ts +2 -3
- package/dist/types/clients/modules/deposit-existing-MA.simulation/types.d.ts.map +1 -1
- package/dist/types/clients/modules/deposit-passive-pool.simulation/index.d.ts +10 -0
- package/dist/types/clients/modules/deposit-passive-pool.simulation/index.d.ts.map +1 -0
- package/dist/types/clients/modules/deposit-passive-pool.simulation/types.d.ts +9 -0
- package/dist/types/clients/modules/deposit-passive-pool.simulation/types.d.ts.map +1 -0
- package/dist/types/clients/modules/withdraw-MA.simulation/types.d.ts +2 -2
- package/dist/types/clients/modules/withdraw-MA.simulation/types.d.ts.map +1 -1
- package/dist/types/clients/types.d.ts +1 -0
- package/dist/types/clients/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/clients/api-client.ts +26 -0
- package/src/clients/modules/deposit-existing-MA.simulation/index.ts +48 -10
- package/src/clients/modules/deposit-existing-MA.simulation/types.ts +2 -2
- package/src/clients/modules/deposit-passive-pool.simulation/index.ts +73 -0
- package/src/clients/modules/deposit-passive-pool.simulation/types.ts +10 -0
- package/src/clients/modules/withdraw-MA.simulation/types.ts +2 -1
- package/src/clients/types.ts +1 -0
|
@@ -14,6 +14,7 @@ var owner_1 = __importDefault(require("./modules/owner"));
|
|
|
14
14
|
var edit_collateral_simulation_1 = __importDefault(require("./modules/edit-collateral.simulation"));
|
|
15
15
|
var deposit_existing_MA_simulation_1 = __importDefault(require("./modules/deposit-existing-MA.simulation"));
|
|
16
16
|
var deposit_new_MA_simulation_1 = __importDefault(require("./modules/deposit-new-MA.simulation"));
|
|
17
|
+
var deposit_passive_pool_simulation_1 = __importDefault(require("./modules/deposit-passive-pool.simulation"));
|
|
17
18
|
var withdraw_MA_simulation_1 = __importDefault(require("./modules/withdraw-MA.simulation"));
|
|
18
19
|
var transfer_margin_between_MAs_simulation_1 = __importDefault(require("./modules/transfer-margin-between-MAs.simulation"));
|
|
19
20
|
var transfer_MA_Pool_simulation_1 = __importDefault(require("./modules/transfer-MA-Pool.simulation"));
|
|
@@ -30,8 +31,9 @@ var ApiClient = /** @class */ (function () {
|
|
|
30
31
|
this._tradeSimulation = new trade_simulation_1.default(this._account);
|
|
31
32
|
this._fundingRateHistory = new funding_rate_1.default(this._markets);
|
|
32
33
|
this._editCollateralSimulation = new edit_collateral_simulation_1.default(ApiClient.network, this._account);
|
|
33
|
-
this._depositExistingMASimulation = new deposit_existing_MA_simulation_1.default(this._editCollateralSimulation);
|
|
34
|
+
this._depositExistingMASimulation = new deposit_existing_MA_simulation_1.default(this._editCollateralSimulation, ApiClient.config.chain, ApiClient.config.apiEndpoint);
|
|
34
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);
|
|
35
37
|
this._withdrawMASimulation = new withdraw_MA_simulation_1.default(this._editCollateralSimulation, ApiClient.config.chain);
|
|
36
38
|
this._transferMarginBetweenMAsSimulation =
|
|
37
39
|
new transfer_margin_between_MAs_simulation_1.default(ApiClient.network, this._account);
|
|
@@ -190,6 +192,26 @@ var ApiClient = /** @class */ (function () {
|
|
|
190
192
|
enumerable: false,
|
|
191
193
|
configurable: true
|
|
192
194
|
});
|
|
195
|
+
Object.defineProperty(ApiClient, "depositPassivePoolSimulation", {
|
|
196
|
+
/**
|
|
197
|
+
* Provides access to the DepositPassivePoolSimulationClient instance.
|
|
198
|
+
* This getter allows for interacting with trade simulation functionalities.
|
|
199
|
+
* It ensures a singleton pattern by fetching the instance from the ApiClient's
|
|
200
|
+
* private `_depositPassivePoolSimulation` property, ensuring that trade simulation operations
|
|
201
|
+
* use a consistent client configuration and state.
|
|
202
|
+
*
|
|
203
|
+
* @returns {DepositPassivePoolSimulationClient} An instance of DepositPassivePoolSimulationClient for trade simulation operations.
|
|
204
|
+
* @memberof ApiClient
|
|
205
|
+
* @example
|
|
206
|
+
* // Access the deposit existing Ma simulation client from the ApiClient
|
|
207
|
+
* const depositPassivePoolSimulationClient = ApiClient.depositPassivePoolSimulation;
|
|
208
|
+
*/
|
|
209
|
+
get: function () {
|
|
210
|
+
return ApiClient.getInstance()._depositPassivePoolSimulation;
|
|
211
|
+
},
|
|
212
|
+
enumerable: false,
|
|
213
|
+
configurable: true
|
|
214
|
+
});
|
|
193
215
|
Object.defineProperty(ApiClient, "withdrawMASimulation", {
|
|
194
216
|
/**
|
|
195
217
|
* Provides access to the WithdrawMASimulationClient instance.
|
|
@@ -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,0DAA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;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"]}
|
|
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,CAAC,WAAW,CAAC,CAAC;QAChE,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAa,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAChE,IAAI,CAAC,GAAG,GAAG,IAAI,YAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACtD,IAAI,CAAC,gBAAgB,GAAG,IAAI,0BAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjE,IAAI,CAAC,mBAAmB,GAAG,IAAI,sBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChE,IAAI,CAAC,yBAAyB,GAAG,IAAI,oCAA8B,CACjE,SAAS,CAAC,OAAO,EACjB,IAAI,CAAC,QAAQ,CACd,CAAC;QACF,IAAI,CAAC,4BAA4B,GAAG,IAAI,wCAAiC,CACvE,IAAI,CAAC,yBAAyB,E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C;QACzD,CAAC;;;OAAA;IAgBD,sBAAkB,yCAA4B;QAd9C;;;;;;;;;;;;WAYG;aAEH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,6BAA6B,CAAC;QAC/D,CAAC;;;OAAA;IAgBD,sBAAkB,iCAAoB;QAdtC;;;;;;;;;;;;WAYG;aAEH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,qBAAqB,CAAC;QACvD,CAAC;;;OAAA;IAgBD,sBAAkB,+CAAkC;QAdpD;;;;;;;;;;;;WAYG;aAEH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,mCAAmC,CAAC;QACrE,CAAC;;;OAAA;IAgBD,sBAAkB,qCAAwB;QAd1C;;;;;;;;;;;;WAYG;aAEH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,yBAAyB,CAAC;QAC3D,CAAC;;;OAAA;IAYD,sBAAkB,eAAE;QAVpB;;;;;;;;;WASG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC;QACrC,CAAC;;;OAAA;IAYD,sBAAkB,mBAAM;QAVxB;;;;;;;;;WASG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC;QACzC,CAAC;;;OAAA;IAYD,sBAAkB,kBAAK;QAVvB;;;;;;;;;WASG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC;QACxC,CAAC;;;OAAA;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,4 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
2
17
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
18
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
19
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -37,14 +52,20 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
52
|
};
|
|
38
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
54
|
var common_1 = require("@reyaxyz/common");
|
|
40
|
-
var DepositExistingMASimulationClient = /** @class */ (function () {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
55
|
+
var DepositExistingMASimulationClient = /** @class */ (function (_super) {
|
|
56
|
+
__extends(DepositExistingMASimulationClient, _super);
|
|
57
|
+
function DepositExistingMASimulationClient(editCollateralClient, reyaChainId, host, apiTimeout) {
|
|
58
|
+
var _this = _super.call(this, host, apiTimeout) || this;
|
|
59
|
+
_this.socketDepositFees = {};
|
|
60
|
+
_this.reyaChainId = reyaChainId;
|
|
61
|
+
_this.editCollateralClient = editCollateralClient;
|
|
62
|
+
return _this;
|
|
44
63
|
}
|
|
45
64
|
// Method to asynchronously load data based on accountId
|
|
46
65
|
DepositExistingMASimulationClient.prototype.arm = function (params) {
|
|
47
66
|
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
+
var moneyInOutChainIds, socketDepositFeesPromises, _i, moneyInOutChainIds_1, moneyInOutChainId, socketDepositFeesArray;
|
|
68
|
+
var _this = this;
|
|
48
69
|
return __generator(this, function (_a) {
|
|
49
70
|
switch (_a.label) {
|
|
50
71
|
case 0: return [4 /*yield*/, this.editCollateralClient.arm({
|
|
@@ -52,6 +73,20 @@ var DepositExistingMASimulationClient = /** @class */ (function () {
|
|
|
52
73
|
})];
|
|
53
74
|
case 1:
|
|
54
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)];
|
|
83
|
+
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
|
+
});
|
|
55
90
|
return [2 /*return*/];
|
|
56
91
|
}
|
|
57
92
|
});
|
|
@@ -59,6 +94,9 @@ var DepositExistingMASimulationClient = /** @class */ (function () {
|
|
|
59
94
|
};
|
|
60
95
|
// Synchronous method to simulate operations based on an amount
|
|
61
96
|
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)"));
|
|
99
|
+
}
|
|
62
100
|
var simulateEditCollateralEntity = this.editCollateralClient.simulate({
|
|
63
101
|
signedAmount: params.amount,
|
|
64
102
|
tokenAddress: params.tokenAddress,
|
|
@@ -66,12 +104,8 @@ var DepositExistingMASimulationClient = /** @class */ (function () {
|
|
|
66
104
|
var bridgeTimeInMS = (0, common_1.getSocketBridgeTime)({
|
|
67
105
|
moneyInOutChainId: params.moneyInOutChainId,
|
|
68
106
|
}).bridgeTimeInMS;
|
|
69
|
-
var fees = (0, common_1.getSocketDepositFees)({
|
|
70
|
-
moneyInOutChainId: params.moneyInOutChainId,
|
|
71
|
-
});
|
|
72
107
|
var result = {
|
|
73
|
-
|
|
74
|
-
feesUnderlyingToken: fees.feesUnderlyingToken,
|
|
108
|
+
socketDepositFees: this.socketDepositFees[params.moneyInOutChainId],
|
|
75
109
|
bridgeTimeInMS: bridgeTimeInMS,
|
|
76
110
|
marginRatio: simulateEditCollateralEntity.marginRatio,
|
|
77
111
|
marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,
|
|
@@ -79,6 +113,6 @@ var DepositExistingMASimulationClient = /** @class */ (function () {
|
|
|
79
113
|
return result;
|
|
80
114
|
};
|
|
81
115
|
return DepositExistingMASimulationClient;
|
|
82
|
-
}());
|
|
116
|
+
}(common_1.RestClient));
|
|
83
117
|
exports.default = DepositExistingMASimulationClient;
|
|
84
118
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/index.ts"],"names":[],"mappings":"
|
|
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,I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","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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MarginAccountEntity,\n MoneyInOutChainId,\n TokenEntity,\n} from '@reyaxyz/common';\nimport { EditCollateralSimulationLoadDataParams } from '../edit-collateral.simulation/types';\n\nexport type DepositExistingMASimulationLoadDataParams =\n EditCollateralSimulationLoadDataParams;\n\nexport type DepositExistingMASimulationSimulateParams = {\n moneyInOutChainId: MoneyInOutChainId;\n amount: number;\n tokenAddress: TokenEntity['address'];\n};\n\nexport type SimulateDepositExistingMAEntity = {\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MarginAccountEntity,\n MoneyInOutChainId,\n SocketDepositFees,\n TokenEntity,\n} from '@reyaxyz/common';\nimport { EditCollateralSimulationLoadDataParams } from '../edit-collateral.simulation/types';\n\nexport type DepositExistingMASimulationLoadDataParams =\n EditCollateralSimulationLoadDataParams;\n\nexport type DepositExistingMASimulationSimulateParams = {\n moneyInOutChainId: MoneyInOutChainId;\n amount: number;\n tokenAddress: TokenEntity['address'];\n};\n\nexport type SimulateDepositExistingMAEntity = {\n socketDepositFees: SocketDepositFees;\n bridgeTimeInMS: number;\n marginRatio: MarginAccountEntity['marginRatioPercentage'];\n marginRatioHealth: MarginAccountEntity['marginRatioHealth'];\n};\n"]}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
var common_1 = require("@reyaxyz/common");
|
|
55
|
+
var DepositPassivePoolSimulationClient = /** @class */ (function (_super) {
|
|
56
|
+
__extends(DepositPassivePoolSimulationClient, _super);
|
|
57
|
+
function DepositPassivePoolSimulationClient(reyaChainId, host, apiTimeout) {
|
|
58
|
+
var _this = _super.call(this, host, apiTimeout) || this;
|
|
59
|
+
_this.socketDepositFees = {};
|
|
60
|
+
_this.reyaChainId = reyaChainId;
|
|
61
|
+
return _this;
|
|
62
|
+
}
|
|
63
|
+
// Method to asynchronously load data based on accountId
|
|
64
|
+
DepositPassivePoolSimulationClient.prototype.arm = function () {
|
|
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) {
|
|
70
|
+
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)];
|
|
78
|
+
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
|
+
});
|
|
85
|
+
return [2 /*return*/];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
// Synchronous method to simulate operations based on an amount
|
|
91
|
+
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)"));
|
|
94
|
+
}
|
|
95
|
+
var bridgeTimeInMS = (0, common_1.getSocketBridgeTime)({
|
|
96
|
+
moneyInOutChainId: params.moneyInOutChainId,
|
|
97
|
+
}).bridgeTimeInMS;
|
|
98
|
+
var result = {
|
|
99
|
+
socketDepositFees: this.socketDepositFees[params.moneyInOutChainId],
|
|
100
|
+
bridgeTimeInMS: bridgeTimeInMS,
|
|
101
|
+
};
|
|
102
|
+
return result;
|
|
103
|
+
};
|
|
104
|
+
return DepositPassivePoolSimulationClient;
|
|
105
|
+
}(common_1.RestClient));
|
|
106
|
+
exports.default = DepositPassivePoolSimulationClient;
|
|
107
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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,EACxB,IAAY,EACZ,UAA0B;QAE1B,YAAA,MAAK,YAAC,IAAI,EAAE,UAAU,CAAC,SAAC;QARlB,uBAAiB,GAAsC,EAAE,CAAC;QAShE,KAAI,CAAC,WAAW,GAAG,WAAW,CAAC;;IACjC,CAAC;IAED,wDAAwD;IAClD,gDAAG,GAAT;;;;;;;wBACQ,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,qDAAQ,GAAR,UACE,MAAkD;QAElD,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;QAED,IAAM,cAAc,GAAG,IAAA,4BAAmB,EAAC;YACzC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;SAC5C,CAAC,CAAC,cAAc,CAAC;QAElB,IAAM,MAAM,GAAqC;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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/deposit-passive-pool.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import { MoneyInOutChainId, SocketDepositFees } from '@reyaxyz/common';\n\nexport type DepositPassivePoolSimulationSimulateParams = {\n moneyInOutChainId: MoneyInOutChainId;\n};\n\nexport type SimulateDepositPassivePoolEntity = {\n socketDepositFees: SocketDepositFees;\n bridgeTimeInMS: number;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/withdraw-MA.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MarginAccountEntity,\n MoneyInOutChainId,\n TokenEntity,\n} from '@reyaxyz/common';\nimport { EditCollateralSimulationLoadDataParams } from '../edit-collateral.simulation/types';\n\nexport type WithdrawMASimulationLoadDataParams =\n EditCollateralSimulationLoadDataParams;\n\nexport type WithdrawMASimulationSimulateParams = {\n moneyInOutChainId: MoneyInOutChainId;\n amount: number;\n tokenAddress: TokenEntity['address'];\n};\n\nexport type SimulateWithdrawMAEntity = {\n fees: number;\n feesUnderlyingToken:
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/withdraw-MA.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MarginAccountEntity,\n MoneyInOutChainId,\n TokenEntity,\n TokenName,\n} from '@reyaxyz/common';\nimport { EditCollateralSimulationLoadDataParams } from '../edit-collateral.simulation/types';\n\nexport type WithdrawMASimulationLoadDataParams =\n EditCollateralSimulationLoadDataParams;\n\nexport type WithdrawMASimulationSimulateParams = {\n moneyInOutChainId: MoneyInOutChainId;\n amount: number;\n tokenAddress: TokenEntity['address'];\n};\n\nexport type SimulateWithdrawMAEntity = {\n fees: number;\n feesUnderlyingToken: TokenName;\n bridgeTimeInMS: number;\n marginRatio: MarginAccountEntity['marginRatioPercentage'];\n marginRatioHealth: MarginAccountEntity['marginRatioHealth'];\n};\n"]}
|
package/dist/clients/types.js
CHANGED
|
@@ -33,6 +33,7 @@ __exportStar(require("./modules/trade.simulation/types"), exports);
|
|
|
33
33
|
__exportStar(require("./modules/owner/types"), exports);
|
|
34
34
|
__exportStar(require("./modules/deposit-existing-MA.simulation/types"), exports);
|
|
35
35
|
__exportStar(require("./modules/deposit-new-MA.simulation/types"), exports);
|
|
36
|
+
__exportStar(require("./modules/deposit-passive-pool.simulation/types"), exports);
|
|
36
37
|
__exportStar(require("./modules/edit-collateral.simulation/types"), exports);
|
|
37
38
|
__exportStar(require("./modules/withdraw-MA.simulation/types"), exports);
|
|
38
39
|
__exportStar(require("./modules/transfer-margin-between-MAs.simulation/types"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAAqD;AACrD,0CA2ByB;AAzBvB,2GAAA,iBAAiB,OAAA;AAYjB,qGAAA,WAAW,OAAA;AACX,2GAAA,iBAAiB,OAAA;AAGjB,8GAAA,oBAAoB,OAAA;AACpB,yHAAA,+BAA+B,OAAA;AAE/B,oIAAA,0CAA0C,OAAA;AAG1C,6HAAA,mCAAmC,OAAA;AAEnC,uHAAA,6BAA6B,OAAA;AAE/B,0DAAwC;AACxC,qDAAmC;AACnC,0DAAwC;AACxC,yDAAuC;AACvC,mEAAiD;AACjD,wDAAsC;AACtC,iFAA+D;AAC/D,4EAA0D;AAC1D,6EAA2D;AAC3D,yEAAuD;AACvD,yFAAuE;AACvE,8EAA4D;AAC5D,+DAA6C;AAC7C,yEAAuD","sourcesContent":["// reexporting what we want to share with integrators\nexport {\n Candle,\n CandlesResolution,\n MarketEntity,\n LpTransactionHistoryEntity,\n TradingHistoryEntity,\n PositionHistoryEntity,\n PositionEntity,\n TransactionHistoryType,\n MarginAccountTransactionHistoryType,\n MarginAccountTransactionHistoryEntity,\n MarginAccountEntity,\n LpPositionEntity,\n LpPoolEntity,\n ReyaChainId,\n MoneyInOutChainId,\n GetLpPoolPerformanceChartDataResult,\n GetLpPoolBalanceChartDataResult,\n LpBalanceGranularity,\n MarginAccountBalanceGranularity,\n GetMarginAccountBalanceChartDataResult,\n MarginAccountCollateralsBalanceGranularity,\n GetMarginAccountCollateralsBalanceChartDataResult,\n GetAllMarginAccountsBalanceChartDataResult,\n AllMarginAccountsBalanceGranularity,\n GetFundingRateChartDataResult,\n FundingRateHistoryGranularity,\n} from '@reyaxyz/common';\nexport * from './modules/account/types';\nexport * from './modules/lp/types';\nexport * from './modules/markets/types';\nexport * from './modules/tokens/types';\nexport * from './modules/trade.simulation/types';\nexport * from './modules/owner/types';\nexport * from './modules/deposit-existing-MA.simulation/types';\nexport * from './modules/deposit-new-MA.simulation/types';\nexport * from './modules/edit-collateral.simulation/types';\nexport * from './modules/withdraw-MA.simulation/types';\nexport * from './modules/transfer-margin-between-MAs.simulation/types';\nexport * from './modules/transfer-MA-Pool.simulation/types';\nexport * from './modules/funding-rate/types';\nexport * from './modules/depth-chart.simulation/types';\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAAqD;AACrD,0CA2ByB;AAzBvB,2GAAA,iBAAiB,OAAA;AAYjB,qGAAA,WAAW,OAAA;AACX,2GAAA,iBAAiB,OAAA;AAGjB,8GAAA,oBAAoB,OAAA;AACpB,yHAAA,+BAA+B,OAAA;AAE/B,oIAAA,0CAA0C,OAAA;AAG1C,6HAAA,mCAAmC,OAAA;AAEnC,uHAAA,6BAA6B,OAAA;AAE/B,0DAAwC;AACxC,qDAAmC;AACnC,0DAAwC;AACxC,yDAAuC;AACvC,mEAAiD;AACjD,wDAAsC;AACtC,iFAA+D;AAC/D,4EAA0D;AAC1D,kFAAgE;AAChE,6EAA2D;AAC3D,yEAAuD;AACvD,yFAAuE;AACvE,8EAA4D;AAC5D,+DAA6C;AAC7C,yEAAuD","sourcesContent":["// reexporting what we want to share with integrators\nexport {\n Candle,\n CandlesResolution,\n MarketEntity,\n LpTransactionHistoryEntity,\n TradingHistoryEntity,\n PositionHistoryEntity,\n PositionEntity,\n TransactionHistoryType,\n MarginAccountTransactionHistoryType,\n MarginAccountTransactionHistoryEntity,\n MarginAccountEntity,\n LpPositionEntity,\n LpPoolEntity,\n ReyaChainId,\n MoneyInOutChainId,\n GetLpPoolPerformanceChartDataResult,\n GetLpPoolBalanceChartDataResult,\n LpBalanceGranularity,\n MarginAccountBalanceGranularity,\n GetMarginAccountBalanceChartDataResult,\n MarginAccountCollateralsBalanceGranularity,\n GetMarginAccountCollateralsBalanceChartDataResult,\n GetAllMarginAccountsBalanceChartDataResult,\n AllMarginAccountsBalanceGranularity,\n GetFundingRateChartDataResult,\n FundingRateHistoryGranularity,\n} from '@reyaxyz/common';\nexport * from './modules/account/types';\nexport * from './modules/lp/types';\nexport * from './modules/markets/types';\nexport * from './modules/tokens/types';\nexport * from './modules/trade.simulation/types';\nexport * from './modules/owner/types';\nexport * from './modules/deposit-existing-MA.simulation/types';\nexport * from './modules/deposit-new-MA.simulation/types';\nexport * from './modules/deposit-passive-pool.simulation/types';\nexport * from './modules/edit-collateral.simulation/types';\nexport * from './modules/withdraw-MA.simulation/types';\nexport * from './modules/transfer-margin-between-MAs.simulation/types';\nexport * from './modules/transfer-MA-Pool.simulation/types';\nexport * from './modules/funding-rate/types';\nexport * from './modules/depth-chart.simulation/types';\n"]}
|
|
@@ -9,6 +9,7 @@ import OwnerClient from './modules/owner';
|
|
|
9
9
|
import EditCollateralSimulationClient from './modules/edit-collateral.simulation';
|
|
10
10
|
import DepositExistingMASimulationClient from './modules/deposit-existing-MA.simulation';
|
|
11
11
|
import DepositNewMASimulationClient from './modules/deposit-new-MA.simulation';
|
|
12
|
+
import DepositPassivePoolSimulationClient from './modules/deposit-passive-pool.simulation';
|
|
12
13
|
import WithdrawMASimulationClient from './modules/withdraw-MA.simulation';
|
|
13
14
|
import TransferMarginBetweenMAsSimulationClient from './modules/transfer-margin-between-MAs.simulation';
|
|
14
15
|
import TransferMAPoolSimulationClient from './modules/transfer-MA-Pool.simulation';
|
|
@@ -28,6 +29,7 @@ export declare class ApiClient {
|
|
|
28
29
|
private readonly _editCollateralSimulation;
|
|
29
30
|
private readonly _depositExistingMASimulation;
|
|
30
31
|
private readonly _depositNewMASimulation;
|
|
32
|
+
private readonly _depositPassivePoolSimulation;
|
|
31
33
|
private readonly _withdrawMASimulation;
|
|
32
34
|
private readonly _transferMarginBetweenMAsSimulation;
|
|
33
35
|
private readonly _transferMAPoolSimulation;
|
|
@@ -119,6 +121,20 @@ export declare class ApiClient {
|
|
|
119
121
|
* const depositNewMASimulationClient = ApiClient.depositNewMASimulation;
|
|
120
122
|
*/
|
|
121
123
|
static get depositNewMASimulation(): DepositNewMASimulationClient;
|
|
124
|
+
/**
|
|
125
|
+
* Provides access to the DepositPassivePoolSimulationClient instance.
|
|
126
|
+
* This getter allows for interacting with trade simulation functionalities.
|
|
127
|
+
* It ensures a singleton pattern by fetching the instance from the ApiClient's
|
|
128
|
+
* private `_depositPassivePoolSimulation` property, ensuring that trade simulation operations
|
|
129
|
+
* use a consistent client configuration and state.
|
|
130
|
+
*
|
|
131
|
+
* @returns {DepositPassivePoolSimulationClient} An instance of DepositPassivePoolSimulationClient for trade simulation operations.
|
|
132
|
+
* @memberof ApiClient
|
|
133
|
+
* @example
|
|
134
|
+
* // Access the deposit existing Ma simulation client from the ApiClient
|
|
135
|
+
* const depositPassivePoolSimulationClient = ApiClient.depositPassivePoolSimulation;
|
|
136
|
+
*/
|
|
137
|
+
static get depositPassivePoolSimulation(): DepositPassivePoolSimulationClient;
|
|
122
138
|
/**
|
|
123
139
|
* Provides access to the WithdrawMASimulationClient instance.
|
|
124
140
|
* This getter allows for interacting with trade simulation functionalities.
|
|
@@ -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,Y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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,8 +1,11 @@
|
|
|
1
|
+
import { RestClient, ReyaChainId } from '@reyaxyz/common';
|
|
1
2
|
import EditCollateralClient from '../edit-collateral.simulation';
|
|
2
3
|
import { DepositExistingMASimulationLoadDataParams, DepositExistingMASimulationSimulateParams, SimulateDepositExistingMAEntity } from './types';
|
|
3
|
-
export default class DepositExistingMASimulationClient {
|
|
4
|
+
export default class DepositExistingMASimulationClient extends RestClient {
|
|
4
5
|
private editCollateralClient;
|
|
5
|
-
|
|
6
|
+
private socketDepositFees;
|
|
7
|
+
private reyaChainId;
|
|
8
|
+
constructor(editCollateralClient: EditCollateralClient, reyaChainId: ReyaChainId, host: string, apiTimeout?: number | null);
|
|
6
9
|
arm(params: DepositExistingMASimulationLoadDataParams): Promise<void>;
|
|
7
10
|
simulate(params: DepositExistingMASimulationSimulateParams): SimulateDepositExistingMAEntity;
|
|
8
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/index.ts"],"names":[],"mappings":"
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import { MarginAccountEntity, MoneyInOutChainId, TokenEntity } from '@reyaxyz/common';
|
|
1
|
+
import { MarginAccountEntity, MoneyInOutChainId, SocketDepositFees, TokenEntity } from '@reyaxyz/common';
|
|
2
2
|
import { EditCollateralSimulationLoadDataParams } from '../edit-collateral.simulation/types';
|
|
3
3
|
export type DepositExistingMASimulationLoadDataParams = EditCollateralSimulationLoadDataParams;
|
|
4
4
|
export type DepositExistingMASimulationSimulateParams = {
|
|
@@ -7,8 +7,7 @@ export type DepositExistingMASimulationSimulateParams = {
|
|
|
7
7
|
tokenAddress: TokenEntity['address'];
|
|
8
8
|
};
|
|
9
9
|
export type SimulateDepositExistingMAEntity = {
|
|
10
|
-
|
|
11
|
-
feesUnderlyingToken: TokenEntity['id'];
|
|
10
|
+
socketDepositFees: SocketDepositFees;
|
|
12
11
|
bridgeTimeInMS: number;
|
|
13
12
|
marginRatio: MarginAccountEntity['marginRatioPercentage'];
|
|
14
13
|
marginRatioHealth: MarginAccountEntity['marginRatioHealth'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,sCAAsC,EAAE,MAAM,qCAAqC,CAAC;AAE7F,MAAM,MAAM,yCAAyC,GACnD,sCAAsC,CAAC;AAEzC,MAAM,MAAM,yCAAyC,GAAG;IACtD,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,sCAAsC,EAAE,MAAM,qCAAqC,CAAC;AAE7F,MAAM,MAAM,yCAAyC,GACnD,sCAAsC,CAAC;AAEzC,MAAM,MAAM,yCAAyC,GAAG;IACtD,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,mBAAmB,CAAC,uBAAuB,CAAC,CAAC;IAC1D,iBAAiB,EAAE,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;CAC7D,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RestClient, ReyaChainId } from '@reyaxyz/common';
|
|
2
|
+
import { DepositPassivePoolSimulationSimulateParams, SimulateDepositPassivePoolEntity } from './types';
|
|
3
|
+
export default class DepositPassivePoolSimulationClient extends RestClient {
|
|
4
|
+
private socketDepositFees;
|
|
5
|
+
private reyaChainId;
|
|
6
|
+
constructor(reyaChainId: ReyaChainId, host: string, apiTimeout?: number | null);
|
|
7
|
+
arm(): Promise<void>;
|
|
8
|
+
simulate(params: DepositPassivePoolSimulationSimulateParams): SimulateDepositPassivePoolEntity;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MoneyInOutChainId, SocketDepositFees } from '@reyaxyz/common';
|
|
2
|
+
export type DepositPassivePoolSimulationSimulateParams = {
|
|
3
|
+
moneyInOutChainId: MoneyInOutChainId;
|
|
4
|
+
};
|
|
5
|
+
export type SimulateDepositPassivePoolEntity = {
|
|
6
|
+
socketDepositFees: SocketDepositFees;
|
|
7
|
+
bridgeTimeInMS: number;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/deposit-passive-pool.simulation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEvE,MAAM,MAAM,0CAA0C,GAAG;IACvD,iBAAiB,EAAE,iBAAiB,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MarginAccountEntity, MoneyInOutChainId, TokenEntity } from '@reyaxyz/common';
|
|
1
|
+
import { MarginAccountEntity, MoneyInOutChainId, TokenEntity, TokenName } from '@reyaxyz/common';
|
|
2
2
|
import { EditCollateralSimulationLoadDataParams } from '../edit-collateral.simulation/types';
|
|
3
3
|
export type WithdrawMASimulationLoadDataParams = EditCollateralSimulationLoadDataParams;
|
|
4
4
|
export type WithdrawMASimulationSimulateParams = {
|
|
@@ -8,7 +8,7 @@ export type WithdrawMASimulationSimulateParams = {
|
|
|
8
8
|
};
|
|
9
9
|
export type SimulateWithdrawMAEntity = {
|
|
10
10
|
fees: number;
|
|
11
|
-
feesUnderlyingToken:
|
|
11
|
+
feesUnderlyingToken: TokenName;
|
|
12
12
|
bridgeTimeInMS: number;
|
|
13
13
|
marginRatio: MarginAccountEntity['marginRatioPercentage'];
|
|
14
14
|
marginRatioHealth: MarginAccountEntity['marginRatioHealth'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/withdraw-MA.simulation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/withdraw-MA.simulation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,SAAS,EACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,sCAAsC,EAAE,MAAM,qCAAqC,CAAC;AAE7F,MAAM,MAAM,kCAAkC,GAC5C,sCAAsC,CAAC;AAEzC,MAAM,MAAM,kCAAkC,GAAG;IAC/C,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB,EAAE,SAAS,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,mBAAmB,CAAC,uBAAuB,CAAC,CAAC;IAC1D,iBAAiB,EAAE,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;CAC7D,CAAC"}
|
|
@@ -7,6 +7,7 @@ export * from './modules/trade.simulation/types';
|
|
|
7
7
|
export * from './modules/owner/types';
|
|
8
8
|
export * from './modules/deposit-existing-MA.simulation/types';
|
|
9
9
|
export * from './modules/deposit-new-MA.simulation/types';
|
|
10
|
+
export * from './modules/deposit-passive-pool.simulation/types';
|
|
10
11
|
export * from './modules/edit-collateral.simulation/types';
|
|
11
12
|
export * from './modules/withdraw-MA.simulation/types';
|
|
12
13
|
export * from './modules/transfer-margin-between-MAs.simulation/types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EACN,iBAAiB,EACjB,YAAY,EACZ,0BAA0B,EAC1B,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,sBAAsB,EACtB,mCAAmC,EACnC,qCAAqC,EACrC,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,mCAAmC,EACnC,+BAA+B,EAC/B,oBAAoB,EACpB,+BAA+B,EAC/B,sCAAsC,EACtC,0CAA0C,EAC1C,iDAAiD,EACjD,0CAA0C,EAC1C,mCAAmC,EACnC,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC;AACzB,cAA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Ac,wCAAwC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/api-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.68.0",
|
|
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.
|
|
36
|
+
"@reyaxyz/common": "0.71.0",
|
|
37
37
|
"bignumber.js": "^9.1.2"
|
|
38
38
|
},
|
|
39
39
|
"packageManager": "pnpm@8.10.4",
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "6516e75f156f541a08db222c483bfa983f2ea316"
|
|
41
41
|
}
|
|
@@ -9,6 +9,7 @@ import OwnerClient from './modules/owner';
|
|
|
9
9
|
import EditCollateralSimulationClient from './modules/edit-collateral.simulation';
|
|
10
10
|
import DepositExistingMASimulationClient from './modules/deposit-existing-MA.simulation';
|
|
11
11
|
import DepositNewMASimulationClient from './modules/deposit-new-MA.simulation';
|
|
12
|
+
import DepositPassivePoolSimulationClient from './modules/deposit-passive-pool.simulation';
|
|
12
13
|
import WithdrawMASimulationClient from './modules/withdraw-MA.simulation';
|
|
13
14
|
import TransferMarginBetweenMAsSimulationClient from './modules/transfer-margin-between-MAs.simulation';
|
|
14
15
|
import TransferMAPoolSimulationClient from './modules/transfer-MA-Pool.simulation';
|
|
@@ -29,6 +30,7 @@ export class ApiClient {
|
|
|
29
30
|
private readonly _editCollateralSimulation: EditCollateralSimulationClient;
|
|
30
31
|
private readonly _depositExistingMASimulation: DepositExistingMASimulationClient;
|
|
31
32
|
private readonly _depositNewMASimulation: DepositNewMASimulationClient;
|
|
33
|
+
private readonly _depositPassivePoolSimulation: DepositPassivePoolSimulationClient;
|
|
32
34
|
private readonly _withdrawMASimulation: WithdrawMASimulationClient;
|
|
33
35
|
private readonly _transferMarginBetweenMAsSimulation: TransferMarginBetweenMAsSimulationClient;
|
|
34
36
|
private readonly _transferMAPoolSimulation: TransferMAPoolSimulationClient;
|
|
@@ -48,10 +50,16 @@ export class ApiClient {
|
|
|
48
50
|
);
|
|
49
51
|
this._depositExistingMASimulation = new DepositExistingMASimulationClient(
|
|
50
52
|
this._editCollateralSimulation,
|
|
53
|
+
ApiClient.config.chain,
|
|
54
|
+
ApiClient.config.apiEndpoint,
|
|
51
55
|
);
|
|
52
56
|
this._depositNewMASimulation = new DepositNewMASimulationClient(
|
|
53
57
|
this._depositExistingMASimulation,
|
|
54
58
|
);
|
|
59
|
+
this._depositPassivePoolSimulation = new DepositPassivePoolSimulationClient(
|
|
60
|
+
ApiClient.config.chain,
|
|
61
|
+
ApiClient.config.apiEndpoint,
|
|
62
|
+
);
|
|
55
63
|
this._withdrawMASimulation = new WithdrawMASimulationClient(
|
|
56
64
|
this._editCollateralSimulation,
|
|
57
65
|
ApiClient.config.chain,
|
|
@@ -200,6 +208,24 @@ export class ApiClient {
|
|
|
200
208
|
return ApiClient.getInstance()._depositNewMASimulation;
|
|
201
209
|
}
|
|
202
210
|
|
|
211
|
+
/**
|
|
212
|
+
* Provides access to the DepositPassivePoolSimulationClient instance.
|
|
213
|
+
* This getter allows for interacting with trade simulation functionalities.
|
|
214
|
+
* It ensures a singleton pattern by fetching the instance from the ApiClient's
|
|
215
|
+
* private `_depositPassivePoolSimulation` property, ensuring that trade simulation operations
|
|
216
|
+
* use a consistent client configuration and state.
|
|
217
|
+
*
|
|
218
|
+
* @returns {DepositPassivePoolSimulationClient} An instance of DepositPassivePoolSimulationClient for trade simulation operations.
|
|
219
|
+
* @memberof ApiClient
|
|
220
|
+
* @example
|
|
221
|
+
* // Access the deposit existing Ma simulation client from the ApiClient
|
|
222
|
+
* const depositPassivePoolSimulationClient = ApiClient.depositPassivePoolSimulation;
|
|
223
|
+
*/
|
|
224
|
+
|
|
225
|
+
public static get depositPassivePoolSimulation(): DepositPassivePoolSimulationClient {
|
|
226
|
+
return ApiClient.getInstance()._depositPassivePoolSimulation;
|
|
227
|
+
}
|
|
228
|
+
|
|
203
229
|
/**
|
|
204
230
|
* Provides access to the WithdrawMASimulationClient instance.
|
|
205
231
|
* This getter allows for interacting with trade simulation functionalities.
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
RestClient,
|
|
3
|
+
ReyaChainId,
|
|
4
|
+
SocketDepositFees,
|
|
5
|
+
getMoneyInOutNetworksFromReyaChainId,
|
|
6
|
+
getSocketBridgeTime,
|
|
7
|
+
} from '@reyaxyz/common';
|
|
2
8
|
import EditCollateralClient from '../edit-collateral.simulation';
|
|
3
9
|
import {
|
|
4
10
|
DepositExistingMASimulationLoadDataParams,
|
|
@@ -6,10 +12,19 @@ import {
|
|
|
6
12
|
SimulateDepositExistingMAEntity,
|
|
7
13
|
} from './types';
|
|
8
14
|
|
|
9
|
-
export default class DepositExistingMASimulationClient {
|
|
15
|
+
export default class DepositExistingMASimulationClient extends RestClient {
|
|
10
16
|
private editCollateralClient: EditCollateralClient;
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
private socketDepositFees: Record<number, SocketDepositFees> = {};
|
|
18
|
+
private reyaChainId: ReyaChainId;
|
|
19
|
+
|
|
20
|
+
constructor(
|
|
21
|
+
editCollateralClient: EditCollateralClient,
|
|
22
|
+
reyaChainId: ReyaChainId,
|
|
23
|
+
host: string,
|
|
24
|
+
apiTimeout?: number | null,
|
|
25
|
+
) {
|
|
26
|
+
super(host, apiTimeout);
|
|
27
|
+
this.reyaChainId = reyaChainId;
|
|
13
28
|
this.editCollateralClient = editCollateralClient;
|
|
14
29
|
}
|
|
15
30
|
|
|
@@ -18,12 +33,40 @@ export default class DepositExistingMASimulationClient {
|
|
|
18
33
|
await this.editCollateralClient.arm({
|
|
19
34
|
marginAccountId: params.marginAccountId,
|
|
20
35
|
});
|
|
36
|
+
|
|
37
|
+
const moneyInOutChainIds = getMoneyInOutNetworksFromReyaChainId(
|
|
38
|
+
this.reyaChainId,
|
|
39
|
+
);
|
|
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
|
+
});
|
|
21
59
|
}
|
|
22
60
|
|
|
23
61
|
// Synchronous method to simulate operations based on an amount
|
|
24
62
|
simulate(
|
|
25
63
|
params: DepositExistingMASimulationSimulateParams,
|
|
26
64
|
): SimulateDepositExistingMAEntity {
|
|
65
|
+
if (!(params.moneyInOutChainId in this.socketDepositFees)) {
|
|
66
|
+
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)`,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
27
70
|
const simulateEditCollateralEntity = this.editCollateralClient.simulate({
|
|
28
71
|
signedAmount: params.amount,
|
|
29
72
|
tokenAddress: params.tokenAddress,
|
|
@@ -33,13 +76,8 @@ export default class DepositExistingMASimulationClient {
|
|
|
33
76
|
moneyInOutChainId: params.moneyInOutChainId,
|
|
34
77
|
}).bridgeTimeInMS;
|
|
35
78
|
|
|
36
|
-
const fees = getSocketDepositFees({
|
|
37
|
-
moneyInOutChainId: params.moneyInOutChainId,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
79
|
const result: SimulateDepositExistingMAEntity = {
|
|
41
|
-
|
|
42
|
-
feesUnderlyingToken: fees.feesUnderlyingToken,
|
|
80
|
+
socketDepositFees: this.socketDepositFees[params.moneyInOutChainId],
|
|
43
81
|
bridgeTimeInMS: bridgeTimeInMS,
|
|
44
82
|
marginRatio: simulateEditCollateralEntity.marginRatio,
|
|
45
83
|
marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MarginAccountEntity,
|
|
3
3
|
MoneyInOutChainId,
|
|
4
|
+
SocketDepositFees,
|
|
4
5
|
TokenEntity,
|
|
5
6
|
} from '@reyaxyz/common';
|
|
6
7
|
import { EditCollateralSimulationLoadDataParams } from '../edit-collateral.simulation/types';
|
|
@@ -15,8 +16,7 @@ export type DepositExistingMASimulationSimulateParams = {
|
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
export type SimulateDepositExistingMAEntity = {
|
|
18
|
-
|
|
19
|
-
feesUnderlyingToken: TokenEntity['id'];
|
|
19
|
+
socketDepositFees: SocketDepositFees;
|
|
20
20
|
bridgeTimeInMS: number;
|
|
21
21
|
marginRatio: MarginAccountEntity['marginRatioPercentage'];
|
|
22
22
|
marginRatioHealth: MarginAccountEntity['marginRatioHealth'];
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RestClient,
|
|
3
|
+
ReyaChainId,
|
|
4
|
+
SocketDepositFees,
|
|
5
|
+
getMoneyInOutNetworksFromReyaChainId,
|
|
6
|
+
getSocketBridgeTime,
|
|
7
|
+
} from '@reyaxyz/common';
|
|
8
|
+
import {
|
|
9
|
+
DepositPassivePoolSimulationSimulateParams,
|
|
10
|
+
SimulateDepositPassivePoolEntity,
|
|
11
|
+
} from './types';
|
|
12
|
+
|
|
13
|
+
export default class DepositPassivePoolSimulationClient extends RestClient {
|
|
14
|
+
private socketDepositFees: Record<number, SocketDepositFees> = {};
|
|
15
|
+
private reyaChainId: ReyaChainId;
|
|
16
|
+
|
|
17
|
+
constructor(
|
|
18
|
+
reyaChainId: ReyaChainId,
|
|
19
|
+
host: string,
|
|
20
|
+
apiTimeout?: number | null,
|
|
21
|
+
) {
|
|
22
|
+
super(host, apiTimeout);
|
|
23
|
+
this.reyaChainId = reyaChainId;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Method to asynchronously load data based on accountId
|
|
27
|
+
async arm(): Promise<void> {
|
|
28
|
+
const moneyInOutChainIds = getMoneyInOutNetworksFromReyaChainId(
|
|
29
|
+
this.reyaChainId,
|
|
30
|
+
);
|
|
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
|
+
}
|
|
51
|
+
|
|
52
|
+
// Synchronous method to simulate operations based on an amount
|
|
53
|
+
simulate(
|
|
54
|
+
params: DepositPassivePoolSimulationSimulateParams,
|
|
55
|
+
): SimulateDepositPassivePoolEntity {
|
|
56
|
+
if (!(params.moneyInOutChainId in this.socketDepositFees)) {
|
|
57
|
+
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)`,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const bridgeTimeInMS = getSocketBridgeTime({
|
|
63
|
+
moneyInOutChainId: params.moneyInOutChainId,
|
|
64
|
+
}).bridgeTimeInMS;
|
|
65
|
+
|
|
66
|
+
const result: SimulateDepositPassivePoolEntity = {
|
|
67
|
+
socketDepositFees: this.socketDepositFees[params.moneyInOutChainId],
|
|
68
|
+
bridgeTimeInMS: bridgeTimeInMS,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MoneyInOutChainId, SocketDepositFees } from '@reyaxyz/common';
|
|
2
|
+
|
|
3
|
+
export type DepositPassivePoolSimulationSimulateParams = {
|
|
4
|
+
moneyInOutChainId: MoneyInOutChainId;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type SimulateDepositPassivePoolEntity = {
|
|
8
|
+
socketDepositFees: SocketDepositFees;
|
|
9
|
+
bridgeTimeInMS: number;
|
|
10
|
+
};
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
MarginAccountEntity,
|
|
3
3
|
MoneyInOutChainId,
|
|
4
4
|
TokenEntity,
|
|
5
|
+
TokenName,
|
|
5
6
|
} from '@reyaxyz/common';
|
|
6
7
|
import { EditCollateralSimulationLoadDataParams } from '../edit-collateral.simulation/types';
|
|
7
8
|
|
|
@@ -16,7 +17,7 @@ export type WithdrawMASimulationSimulateParams = {
|
|
|
16
17
|
|
|
17
18
|
export type SimulateWithdrawMAEntity = {
|
|
18
19
|
fees: number;
|
|
19
|
-
feesUnderlyingToken:
|
|
20
|
+
feesUnderlyingToken: TokenName;
|
|
20
21
|
bridgeTimeInMS: number;
|
|
21
22
|
marginRatio: MarginAccountEntity['marginRatioPercentage'];
|
|
22
23
|
marginRatioHealth: MarginAccountEntity['marginRatioHealth'];
|
package/src/clients/types.ts
CHANGED
|
@@ -35,6 +35,7 @@ export * from './modules/trade.simulation/types';
|
|
|
35
35
|
export * from './modules/owner/types';
|
|
36
36
|
export * from './modules/deposit-existing-MA.simulation/types';
|
|
37
37
|
export * from './modules/deposit-new-MA.simulation/types';
|
|
38
|
+
export * from './modules/deposit-passive-pool.simulation/types';
|
|
38
39
|
export * from './modules/edit-collateral.simulation/types';
|
|
39
40
|
export * from './modules/withdraw-MA.simulation/types';
|
|
40
41
|
export * from './modules/transfer-margin-between-MAs.simulation/types';
|