@reyaxyz/api-sdk 0.151.14 → 0.151.16
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/README.md +1 -1
- package/dist/clients/modules/account/index.js +0 -11
- package/dist/clients/modules/account/index.js.map +1 -1
- package/dist/clients/modules/account/types.js.map +1 -1
- package/dist/clients/modules/markets/index.js +0 -23
- package/dist/clients/modules/markets/index.js.map +1 -1
- package/dist/clients/modules/markets/types.js.map +1 -1
- package/dist/clients/socket-client.js +0 -16
- package/dist/clients/socket-client.js.map +1 -1
- package/dist/types/clients/modules/account/index.d.ts +1 -2
- package/dist/types/clients/modules/account/index.d.ts.map +1 -1
- package/dist/types/clients/modules/account/types.d.ts +0 -16
- package/dist/types/clients/modules/account/types.d.ts.map +1 -1
- package/dist/types/clients/modules/markets/index.d.ts +1 -3
- package/dist/types/clients/modules/markets/index.d.ts.map +1 -1
- package/dist/types/clients/modules/markets/types.d.ts +1 -9
- package/dist/types/clients/modules/markets/types.d.ts.map +1 -1
- package/dist/types/clients/socket-client.d.ts +1 -4
- package/dist/types/clients/socket-client.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/clients/modules/account/index.ts +0 -11
- package/src/clients/modules/account/types.ts +0 -18
- package/src/clients/modules/markets/index.ts +0 -19
- package/src/clients/modules/markets/types.ts +0 -10
- package/src/clients/socket-client.ts +0 -24
package/README.md
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
|
|
7
7
|
| Statements | Branches | Functions | Lines |
|
|
8
8
|
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
|
|
9
|
-
|  |  |  |  |
|
|
10
10
|
|
|
@@ -150,17 +150,6 @@ var AccountClient = /** @class */ (function (_super) {
|
|
|
150
150
|
});
|
|
151
151
|
});
|
|
152
152
|
};
|
|
153
|
-
AccountClient.prototype.getSwapHistoryForWalletAddress = function (params) {
|
|
154
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
155
|
-
var uri;
|
|
156
|
-
return __generator(this, function (_a) {
|
|
157
|
-
uri = "/api/accounts/".concat(params.address, "/swaps/history");
|
|
158
|
-
return [2 /*return*/, this.get(uri, {
|
|
159
|
-
timestampFromMS: params.timestampFromMS,
|
|
160
|
-
})];
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
};
|
|
164
153
|
AccountClient.prototype.getMaxOrderSizeAvailable = function (params) {
|
|
165
154
|
return __awaiter(this, void 0, void 0, function () {
|
|
166
155
|
var uri;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/account/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,0CAOyB;AAEzB;IAA2C,iCAAU;IAArD;;IA4OA,CAAC;IA3OC;;;;;;;;;;;SAWK;IAEC,yCAAiB,GAAvB,UACE,MAA+B;;;;;;wBAEzB,GAAG,GAAG,wBAAiB,MAAM,CAAC,OAAO,CAAE,CAAC;wBACJ,qBAAM,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;gCAC5D,KAAK,EAAE,MAAM,CAAC,KAAK;6BACpB,CAAC,EAAA;;wBAFI,QAAQ,GAA4B,SAExC;wBAEF,sBAAO,QAAQ,EAAC;;;;KACjB;IAED;;;;;;;;;;OAUG;IAEG,wCAAgB,GAAtB,UACE,MAA8B;;;;gBAExB,GAAG,GAAG,wBAAiB,MAAM,CAAC,OAAO,4BAAkB,MAAM,CAAC,eAAe,CAAE,CAAC;gBACtF,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IAEK,oDAA4B,GAAlC,UACE,MAA0C;;;;gBAEpC,GAAG,GAAG,wBAAiB,MAAM,CAAC,OAAO,4BAAkB,MAAM,CAAC,eAAe,eAAY,CAAC;gBAChG,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,C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C,mBAAU,GA4OpD","sourcesContent":["import {\n GetMarginAccountParams,\n GetMarginAccountResult,\n GetMarginAccountsParams,\n GetMarginAccountsResult,\n GetMarginAccountTransactionHistoryParams,\n GetMarginAccountTransactionHistoryResult,\n GetMaxOrderSizeAvailableParams,\n GetMaxOrderSizeAvailableResult,\n GetMaxWithdrawBalanceForAccountParams,\n GetMaxWithdrawBalanceForAccountResult,\n GetPositionsForMarginAccountParams,\n GetPositionsForMarginAccountResult,\n GetTransactionSimulationInitialDataParams,\n GetMarginAccountBalanceChartDataParams,\n GetMarginAccountCollateralsBalanceChartDataParams,\n GetAllMarginAccountsBalanceChartDataParams,\n EditMarginAccountParams,\n CloseMarginAccountParams,\n GetAllMarginAccountsSummaryResult,\n GetAllMarginAccountsSummaryParams,\n GetEditCollateralSimulationInitialDataParams,\n EditMarginAccountResult,\n CloseMarginAccountResult,\n GetIsolatedOrderMaxSizeAvailableParams,\n GetIsolatedOrderMaxSizeAvailableResult,\n GetMarginAccountOrderHistoryPaginatedParams,\n GetMarginAccountOrderHistoryPaginatedResult,\n GetLiquidationHistoryForOwnerAddressResult,\n GetLiquidationHistoryForOwnerAddressParams,\n GetAccountFeeRebatesHistoryParams,\n GetAccountFeeRebatesHistoryResult,\n GetAutoExchangeHistoryForOwnerAddressResult,\n GetAutoExchangeHistoryForOwnerAddressParams,\n UpdateLeverageForAccountAndMarketParams,\n UpdateLeverageForAccountAndMarketResult,\n GetSwapHistoryForWalletAddressResult,\n GetSwapHistoryForWalletAddressParams,\n} from './types';\nimport {\n EditCollateralSimulationState,\n TradeSimulationState,\n GetMarginAccountCollateralsBalanceChartDataResult,\n GetMarginAccountBalanceChartDataResult,\n GetAllMarginAccountsBalanceChartDataResult,\n RestClient,\n} from '@reyaxyz/common';\n\nexport default class AccountClient extends RestClient {\n /**\n * Asynchronously retrieves a list of margin accounts associated with a specific address.\n *\n * This method makes a request to the API endpoint to fetch collateral account data. The data is filtered\n * based on the provided Ethereum address. An optional limit can be specified to control the number of\n * collateral accounts returned in the response.\n *\n * @param {GetMarginAccountsParams} params\n * @returns {Promise<GetMarginAccountsResult>} A promise that resolves to the response containing the margin\n * account data.\n * @memberof account\n * */\n\n async getMarginAccounts(\n params: GetMarginAccountsParams,\n ): Promise<GetMarginAccountsResult> {\n const uri = `/api/accounts/${params.address}`;\n const response: GetMarginAccountsResult = await this.get(uri, {\n limit: params.limit,\n });\n\n return response;\n }\n\n /**\n * Asynchronously retrieves details of a specific collateral account for a given Ethereum address.\n *\n * This method sends a request to the API to obtain detailed information about a specific collateral account\n * associated with the provided Ethereum address. The account is identified using the collateral account number.\n *\n * @param {GetMarginAccountParams} params\n * @returns {Promise<GetMarginAccountResult>} A promise that resolves to the response containing the detailed\n * information of the specified margin account.\n * @memberof account\n */\n\n async getMarginAccount(\n params: GetMarginAccountParams,\n ): Promise<GetMarginAccountResult> {\n const uri = `/api/accounts/${params.address}/marginAccount/${params.marginAccountId}`;\n return this.get(uri);\n }\n\n async getPositionsForMarginAccount(\n params: GetPositionsForMarginAccountParams,\n ): Promise<GetPositionsForMarginAccountResult> {\n const uri = `/api/accounts/${params.address}/marginAccount/${params.marginAccountId}/positions`;\n return this.get(uri, { limit: params.limit });\n }\n\n async getMarginAccountOrderHistoryPaginated(\n params: GetMarginAccountOrderHistoryPaginatedParams,\n ): Promise<GetMarginAccountOrderHistoryPaginatedResult> {\n const uri = `/api/accounts/${params.address}/marginAccount/${params.marginAccountId}/positions/history/paginated`;\n return this.get(uri, {\n type: params.type,\n page: params.page,\n perPage: params.perPage,\n });\n }\n\n async getLiquidationHistoryForOwnerAddress(\n params: GetLiquidationHistoryForOwnerAddressParams,\n ): Promise<GetLiquidationHistoryForOwnerAddressResult> {\n const uri = `/api/accounts/${params.address}/positions/liquidations`;\n return this.get(uri, {\n timestampFromMS: params.timestampFromMS,\n });\n }\n\n async getAutoExchangeHistoryForOwnerAddress(\n params: GetAutoExchangeHistoryForOwnerAddressParams,\n ): Promise<GetAutoExchangeHistoryForOwnerAddressResult> {\n const uri = `/api/accounts/${params.address}/positions/auto-exchange`;\n return this.get(uri, {\n timestampFromMS: params.timestampFromMS,\n });\n }\n\n async getSwapHistoryForWalletAddress(\n params: GetSwapHistoryForWalletAddressParams,\n ): Promise<GetSwapHistoryForWalletAddressResult> {\n const uri = `/api/accounts/${params.address}/swaps/history`;\n return this.get(uri, {\n timestampFromMS: params.timestampFromMS,\n });\n }\n\n async getMaxOrderSizeAvailable(\n params: GetMaxOrderSizeAvailableParams,\n ): Promise<GetMaxOrderSizeAvailableResult> {\n const uri = `/api/accounts/${params.marginAccountId}/max-order-size`;\n return this.get(uri, {\n marketId: params.marketId,\n direction: params.direction,\n });\n }\n\n async getIsolatedOrderMaxSizeAvailable(\n params: GetIsolatedOrderMaxSizeAvailableParams,\n ): Promise<GetIsolatedOrderMaxSizeAvailableResult> {\n const uri = `/api/accounts/${params.marginAccountId}/max-order-size-isolated`;\n return this.get(uri, {\n marketId: params.marketId,\n direction: params.direction,\n });\n }\n\n async getTransactionSimulationInitialData(\n params: GetTransactionSimulationInitialDataParams,\n ): Promise<TradeSimulationState> {\n const uri = `/api/accounts/${params.marginAccountId}/trade-simulation-data`;\n return this.get(uri, {\n marketId: params.marketId,\n });\n }\n\n async getEditCollateralSimulationInitialData(\n params: GetEditCollateralSimulationInitialDataParams,\n ): Promise<EditCollateralSimulationState> {\n const uri = `/api/accounts/${params.marginAccountId}/edit-collateral-simulation-data`;\n return this.get(uri);\n }\n\n async getMarginAccountTransactionHistory(\n params: GetMarginAccountTransactionHistoryParams,\n ): Promise<GetMarginAccountTransactionHistoryResult> {\n const uri = `/api/accounts/${params.marginAccountId}/transaction-history`;\n return this.get(uri, {\n limit: params.limit,\n });\n }\n\n async getAccountFeeRebatesHistory(\n params: GetAccountFeeRebatesHistoryParams,\n ): Promise<GetAccountFeeRebatesHistoryResult> {\n const uri = `/api/accounts/${params.marginAccountId}/referral-fee-history`;\n return this.get(uri, {\n limit: params.limit,\n });\n }\n\n async getMaxWithdrawBalanceForAccount(\n params: GetMaxWithdrawBalanceForAccountParams,\n ): Promise<GetMaxWithdrawBalanceForAccountResult> {\n const uri = `/api/accounts/${params.marginAccountId}/max-withdraw-amount`;\n return this.get(uri, {\n assetAddress: params.tokenAddress,\n });\n }\n\n async getMarginAccountBalanceChartData(\n params: GetMarginAccountBalanceChartDataParams,\n ): Promise<GetMarginAccountBalanceChartDataResult> {\n const uri = `/api/accounts/${params.marginAccountId}/balance-chart-data`;\n return this.get(uri, {\n timeframeMs: params.filters.timeframeMs,\n granularity: params.filters.granularity,\n });\n }\n\n async getMarginAccountCollateralsBalanceChartData(\n params: GetMarginAccountCollateralsBalanceChartDataParams,\n ): Promise<GetMarginAccountCollateralsBalanceChartDataResult> {\n const uri = `/api/accounts/${params.marginAccountId}/collaterals-balance-chart-data`;\n return this.get(uri, {\n timeframeMs: params.filters.timeframeMs,\n granularity: params.filters.granularity,\n });\n }\n\n async getAllMarginAccountsBalanceChart(\n params: GetAllMarginAccountsBalanceChartDataParams,\n ): Promise<GetAllMarginAccountsBalanceChartDataResult> {\n const uri = `/api/accounts/owner/${params.ownerAddress}/balance`;\n return this.get(uri, {\n timeframeMs: params.filters.timeframeMs,\n granularity: params.filters.granularity,\n });\n }\n\n async getAllMarginAccountsSummary(\n params: GetAllMarginAccountsSummaryParams,\n ): Promise<GetAllMarginAccountsSummaryResult> {\n const uri = `/api/accounts/owner/${params.ownerAddress}/summary`;\n return this.get(uri);\n }\n\n // TODO: Milan validate\n async editMarginAccount(\n params: EditMarginAccountParams,\n ): Promise<EditMarginAccountResult> {\n const name = (params.name || '').trim();\n if (!params.id) {\n throw new Error('Missing margin account id');\n }\n if (name.length === 0 || name.length > 25) {\n throw new Error('Max size 25 characters');\n }\n\n const uri = `/api/accounts/${params.id}/edit`;\n return this.put(uri, {\n id: params.id,\n name: params.name,\n });\n }\n async closeMarginAccount(\n params: CloseMarginAccountParams,\n ): Promise<CloseMarginAccountResult> {\n if (!params.id) {\n throw new Error('Missing margin account id');\n }\n\n const uri = `/api/accounts/${params.id}/close`;\n return this.delete(uri, {\n id: params.id,\n });\n }\n\n async updateLeverageForAccountAndMarket(\n params: UpdateLeverageForAccountAndMarketParams,\n ): Promise<UpdateLeverageForAccountAndMarketResult> {\n if (!params.accountId || !params.marketId || !params.leverage) {\n throw new Error('Missing required parameters');\n }\n\n const uri = `/api/accounts/${params.accountId}/marginAccount/${params.marketId}/set-max-leverage`;\n return this.post(\n uri,\n {},\n {\n leverage: params.leverage,\n },\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/account/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,0CAOyB;AAEzB;IAA2C,iCAAU;IAArD;;IAmOA,CAAC;IAlOC;;;;;;;;;;;SAWK;IAEC,yCAAiB,GAAvB,UACE,MAA+B;;;;;;wBAEzB,GAAG,GAAG,wBAAiB,MAAM,CAAC,OAAO,CAAE,CAAC;wBACJ,qBAAM,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;gCAC5D,KAAK,EAAE,MAAM,CAAC,KAAK;6BACpB,CAAC,EAAA;;wBAFI,QAAQ,GAA4B,SAExC;wBAEF,sBAAO,QAAQ,EAAC;;;;KACjB;IAED;;;;;;;;;;OAUG;IAEG,wCAAgB,GAAtB,UACE,MAA8B;;;;gBAExB,GAAG,GAAG,wBAAiB,MAAM,CAAC,OAAO,4BAAkB,MAAM,CAAC,eAAe,CAAE,CAAC;gBACtF,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IAEK,oDAA4B,GAAlC,UACE,MAA0C;;;;gBAEpC,GAAG,GAAG,wBAAiB,MAAM,CAAC,OAAO,4BAAkB,MAAM,CAAC,eAAe,eAAY,CAAC;gBAChG,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,CAA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gBAC5C,CAAC;gBAEK,GAAG,GAAG,wBAAiB,MAAM,CAAC,EAAE,UAAO,CAAC;gBAC9C,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,EAAE,EAAE,MAAM,CAAC,EAAE;wBACb,IAAI,EAAE,MAAM,CAAC,IAAI;qBAClB,CAAC,EAAC;;;KACJ;IACK,0CAAkB,GAAxB,UACE,MAAgC;;;;gBAEhC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;oBACf,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;gBAC/C,CAAC;gBAEK,GAAG,GAAG,wBAAiB,MAAM,CAAC,EAAE,WAAQ,CAAC;gBAC/C,sBAAO,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE;wBACtB,EAAE,EAAE,MAAM,CAAC,EAAE;qBACd,CAAC,EAAC;;;KACJ;IAEK,yDAAiC,GAAvC,UACE,MAA+C;;;;gBAE/C,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;oBAC9D,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;gBACjD,CAAC;gBAEK,GAAG,GAAG,wBAAiB,MAAM,CAAC,SAAS,4BAAkB,MAAM,CAAC,QAAQ,sBAAmB,CAAC;gBAClG,sBAAO,IAAI,CAAC,IAAI,CACd,GAAG,EACH,EAAE,EACF;wBACE,QAAQ,EAAE,MAAM,CAAC,QAAQ;qBAC1B,CACF,EAAC;;;KACH;IACH,oBAAC;AAAD,CAAC,AAnOD,CAA2C,mBAAU,GAmOpD","sourcesContent":["import {\n GetMarginAccountParams,\n GetMarginAccountResult,\n GetMarginAccountsParams,\n GetMarginAccountsResult,\n GetMarginAccountTransactionHistoryParams,\n GetMarginAccountTransactionHistoryResult,\n GetMaxOrderSizeAvailableParams,\n GetMaxOrderSizeAvailableResult,\n GetMaxWithdrawBalanceForAccountParams,\n GetMaxWithdrawBalanceForAccountResult,\n GetPositionsForMarginAccountParams,\n GetPositionsForMarginAccountResult,\n GetTransactionSimulationInitialDataParams,\n GetMarginAccountBalanceChartDataParams,\n GetMarginAccountCollateralsBalanceChartDataParams,\n GetAllMarginAccountsBalanceChartDataParams,\n EditMarginAccountParams,\n CloseMarginAccountParams,\n GetAllMarginAccountsSummaryResult,\n GetAllMarginAccountsSummaryParams,\n GetEditCollateralSimulationInitialDataParams,\n EditMarginAccountResult,\n CloseMarginAccountResult,\n GetIsolatedOrderMaxSizeAvailableParams,\n GetIsolatedOrderMaxSizeAvailableResult,\n GetMarginAccountOrderHistoryPaginatedParams,\n GetMarginAccountOrderHistoryPaginatedResult,\n GetLiquidationHistoryForOwnerAddressResult,\n GetLiquidationHistoryForOwnerAddressParams,\n GetAccountFeeRebatesHistoryParams,\n GetAccountFeeRebatesHistoryResult,\n GetAutoExchangeHistoryForOwnerAddressResult,\n GetAutoExchangeHistoryForOwnerAddressParams,\n UpdateLeverageForAccountAndMarketParams,\n UpdateLeverageForAccountAndMarketResult,\n} from './types';\nimport {\n EditCollateralSimulationState,\n TradeSimulationState,\n GetMarginAccountCollateralsBalanceChartDataResult,\n GetMarginAccountBalanceChartDataResult,\n GetAllMarginAccountsBalanceChartDataResult,\n RestClient,\n} from '@reyaxyz/common';\n\nexport default class AccountClient extends RestClient {\n /**\n * Asynchronously retrieves a list of margin accounts associated with a specific address.\n *\n * This method makes a request to the API endpoint to fetch collateral account data. The data is filtered\n * based on the provided Ethereum address. An optional limit can be specified to control the number of\n * collateral accounts returned in the response.\n *\n * @param {GetMarginAccountsParams} params\n * @returns {Promise<GetMarginAccountsResult>} A promise that resolves to the response containing the margin\n * account data.\n * @memberof account\n * */\n\n async getMarginAccounts(\n params: GetMarginAccountsParams,\n ): Promise<GetMarginAccountsResult> {\n const uri = `/api/accounts/${params.address}`;\n const response: GetMarginAccountsResult = await this.get(uri, {\n limit: params.limit,\n });\n\n return response;\n }\n\n /**\n * Asynchronously retrieves details of a specific collateral account for a given Ethereum address.\n *\n * This method sends a request to the API to obtain detailed information about a specific collateral account\n * associated with the provided Ethereum address. The account is identified using the collateral account number.\n *\n * @param {GetMarginAccountParams} params\n * @returns {Promise<GetMarginAccountResult>} A promise that resolves to the response containing the detailed\n * information of the specified margin account.\n * @memberof account\n */\n\n async getMarginAccount(\n params: GetMarginAccountParams,\n ): Promise<GetMarginAccountResult> {\n const uri = `/api/accounts/${params.address}/marginAccount/${params.marginAccountId}`;\n return this.get(uri);\n }\n\n async getPositionsForMarginAccount(\n params: GetPositionsForMarginAccountParams,\n ): Promise<GetPositionsForMarginAccountResult> {\n const uri = `/api/accounts/${params.address}/marginAccount/${params.marginAccountId}/positions`;\n return this.get(uri, { limit: params.limit });\n }\n\n async getMarginAccountOrderHistoryPaginated(\n params: GetMarginAccountOrderHistoryPaginatedParams,\n ): Promise<GetMarginAccountOrderHistoryPaginatedResult> {\n const uri = `/api/accounts/${params.address}/marginAccount/${params.marginAccountId}/positions/history/paginated`;\n return this.get(uri, {\n type: params.type,\n page: params.page,\n perPage: params.perPage,\n });\n }\n\n async getLiquidationHistoryForOwnerAddress(\n params: GetLiquidationHistoryForOwnerAddressParams,\n ): Promise<GetLiquidationHistoryForOwnerAddressResult> {\n const uri = `/api/accounts/${params.address}/positions/liquidations`;\n return this.get(uri, {\n timestampFromMS: params.timestampFromMS,\n });\n }\n\n async getAutoExchangeHistoryForOwnerAddress(\n params: GetAutoExchangeHistoryForOwnerAddressParams,\n ): Promise<GetAutoExchangeHistoryForOwnerAddressResult> {\n const uri = `/api/accounts/${params.address}/positions/auto-exchange`;\n return this.get(uri, {\n timestampFromMS: params.timestampFromMS,\n });\n }\n\n async getMaxOrderSizeAvailable(\n params: GetMaxOrderSizeAvailableParams,\n ): Promise<GetMaxOrderSizeAvailableResult> {\n const uri = `/api/accounts/${params.marginAccountId}/max-order-size`;\n return this.get(uri, {\n marketId: params.marketId,\n direction: params.direction,\n });\n }\n\n async getIsolatedOrderMaxSizeAvailable(\n params: GetIsolatedOrderMaxSizeAvailableParams,\n ): Promise<GetIsolatedOrderMaxSizeAvailableResult> {\n const uri = `/api/accounts/${params.marginAccountId}/max-order-size-isolated`;\n return this.get(uri, {\n marketId: params.marketId,\n direction: params.direction,\n });\n }\n\n async getTransactionSimulationInitialData(\n params: GetTransactionSimulationInitialDataParams,\n ): Promise<TradeSimulationState> {\n const uri = `/api/accounts/${params.marginAccountId}/trade-simulation-data`;\n return this.get(uri, {\n marketId: params.marketId,\n });\n }\n\n async getEditCollateralSimulationInitialData(\n params: GetEditCollateralSimulationInitialDataParams,\n ): Promise<EditCollateralSimulationState> {\n const uri = `/api/accounts/${params.marginAccountId}/edit-collateral-simulation-data`;\n return this.get(uri);\n }\n\n async getMarginAccountTransactionHistory(\n params: GetMarginAccountTransactionHistoryParams,\n ): Promise<GetMarginAccountTransactionHistoryResult> {\n const uri = `/api/accounts/${params.marginAccountId}/transaction-history`;\n return this.get(uri, {\n limit: params.limit,\n });\n }\n\n async getAccountFeeRebatesHistory(\n params: GetAccountFeeRebatesHistoryParams,\n ): Promise<GetAccountFeeRebatesHistoryResult> {\n const uri = `/api/accounts/${params.marginAccountId}/referral-fee-history`;\n return this.get(uri, {\n limit: params.limit,\n });\n }\n\n async getMaxWithdrawBalanceForAccount(\n params: GetMaxWithdrawBalanceForAccountParams,\n ): Promise<GetMaxWithdrawBalanceForAccountResult> {\n const uri = `/api/accounts/${params.marginAccountId}/max-withdraw-amount`;\n return this.get(uri, {\n assetAddress: params.tokenAddress,\n });\n }\n\n async getMarginAccountBalanceChartData(\n params: GetMarginAccountBalanceChartDataParams,\n ): Promise<GetMarginAccountBalanceChartDataResult> {\n const uri = `/api/accounts/${params.marginAccountId}/balance-chart-data`;\n return this.get(uri, {\n timeframeMs: params.filters.timeframeMs,\n granularity: params.filters.granularity,\n });\n }\n\n async getMarginAccountCollateralsBalanceChartData(\n params: GetMarginAccountCollateralsBalanceChartDataParams,\n ): Promise<GetMarginAccountCollateralsBalanceChartDataResult> {\n const uri = `/api/accounts/${params.marginAccountId}/collaterals-balance-chart-data`;\n return this.get(uri, {\n timeframeMs: params.filters.timeframeMs,\n granularity: params.filters.granularity,\n });\n }\n\n async getAllMarginAccountsBalanceChart(\n params: GetAllMarginAccountsBalanceChartDataParams,\n ): Promise<GetAllMarginAccountsBalanceChartDataResult> {\n const uri = `/api/accounts/owner/${params.ownerAddress}/balance`;\n return this.get(uri, {\n timeframeMs: params.filters.timeframeMs,\n granularity: params.filters.granularity,\n });\n }\n\n async getAllMarginAccountsSummary(\n params: GetAllMarginAccountsSummaryParams,\n ): Promise<GetAllMarginAccountsSummaryResult> {\n const uri = `/api/accounts/owner/${params.ownerAddress}/summary`;\n return this.get(uri);\n }\n\n // TODO: Milan validate\n async editMarginAccount(\n params: EditMarginAccountParams,\n ): Promise<EditMarginAccountResult> {\n const name = (params.name || '').trim();\n if (!params.id) {\n throw new Error('Missing margin account id');\n }\n if (name.length === 0 || name.length > 25) {\n throw new Error('Max size 25 characters');\n }\n\n const uri = `/api/accounts/${params.id}/edit`;\n return this.put(uri, {\n id: params.id,\n name: params.name,\n });\n }\n async closeMarginAccount(\n params: CloseMarginAccountParams,\n ): Promise<CloseMarginAccountResult> {\n if (!params.id) {\n throw new Error('Missing margin account id');\n }\n\n const uri = `/api/accounts/${params.id}/close`;\n return this.delete(uri, {\n id: params.id,\n });\n }\n\n async updateLeverageForAccountAndMarket(\n params: UpdateLeverageForAccountAndMarketParams,\n ): Promise<UpdateLeverageForAccountAndMarketResult> {\n if (!params.accountId || !params.marketId || !params.leverage) {\n throw new Error('Missing required parameters');\n }\n\n const uri = `/api/accounts/${params.accountId}/marginAccount/${params.marketId}/set-max-leverage`;\n return this.post(\n uri,\n {},\n {\n leverage: params.leverage,\n },\n );\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/account/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MarginAccountEntity,\n MarginAccountTransactionHistoryEntity,\n MarketEntity,\n PositionEntity,\n OrderHistoryEntity,\n} from '@reyaxyz/common';\nimport {\n MarginAccountBalanceGranularity,\n MarginAccountCollateralsBalanceGranularity,\n AllMarginAccountsBalanceGranularity,\n ReferralFeeTransactionHistoryEntity,\n AutoExchangeEvent,\n} from '@reyaxyz/common';\nimport { Address } from '@reyaxyz/common';\n\nexport type GetMarginAccountsParams = {\n address: string;\n limit?: number;\n};\n\nexport type GetMarginAccountParams = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n};\n\nexport type GetPositionsForMarginAccountParams = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n limit?: number;\n};\n\nexport type GetMarginAccountsResult = MarginAccountEntity[];\n\nexport type GetMarginAccountResult = MarginAccountEntity;\n\n// ---- Transaction History\nexport type GetMarginAccountTransactionHistoryParams = {\n marginAccountId: MarginAccountEntity['id'];\n limit?: number;\n};\n\nexport type GetMarginAccountTransactionHistoryResult =\n MarginAccountTransactionHistoryEntity[];\n\nexport type GetAccountFeeRebatesHistoryParams = {\n marginAccountId: MarginAccountEntity['id'];\n limit?: number;\n};\n\nexport type GetAccountFeeRebatesHistoryResult = {\n result: ReferralFeeTransactionHistoryEntity[];\n};\n// -- Max Order Size --\n\nexport type GetMaxOrderSizeAvailableParams = {\n marketId: MarketEntity['id'];\n marginAccountId: MarginAccountEntity['id'];\n direction: 'long' | 'short';\n};\n\nexport type GetMaxOrderSizeAvailableResult = {\n maxAmountBase: number;\n maxAmountSize: number;\n};\n\n// --- Max Withdraw Balance for Margin Account ---\nexport type GetMaxWithdrawBalanceForAccountParams = {\n marginAccountId: MarginAccountEntity['id'];\n tokenAddress: string;\n};\n\nexport type GetMaxWithdrawBalanceForAccountResult = number;\n\nexport type GetPositionsForMarginAccountResult = {\n positions: PositionEntity[];\n totalUnrealizedPNL: number;\n};\n\n// --- Order History ---\n\nexport type GetMarginAccountOrderHistoryParams = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n limit?: number;\n};\nexport type GetMarginAccountOrderHistoryPaginatedParams = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n page: number;\n perPage: number;\n type?: 'order' | 'liquidation';\n};\nexport type GetMarginAccountOrderHistoryResult = OrderHistoryEntity[];\nexport type GetMarginAccountOrderHistoryPaginatedResult = {\n data: OrderHistoryEntity[];\n totalCount: number;\n};\n\n//--- Liquidation History ---\nexport type GetLiquidationHistoryForOwnerAddressParams = {\n address: Address;\n timestampFromMS: number;\n};\nexport type GetLiquidationHistoryForOwnerAddressResult = {\n data: LiquidationHistoryEntity[];\n};\n\nexport type LiquidationHistoryEntity = {\n id: string;\n action: 'long-liquidation' | 'short-liquidation';\n executionPrice: number;\n fees: number;\n base: number;\n size: number; // price * base (liquidation size)\n timestamp: number;\n baseUnderlyingToken: string;\n marginAccount: {\n id: MarginAccountEntity['id'];\n name: MarginAccountEntity['name'];\n marginRatioPercentage: MarginAccountEntity['marginRatioPercentage'];\n marginRatioHealth: MarginAccountEntity['marginRatioHealth'];\n };\n};\n\nexport type GetAutoExchangeHistoryForOwnerAddressParams =\n GetLiquidationHistoryForOwnerAddressParams;\nexport type GetAutoExchangeHistoryForOwnerAddressResult = {\n data: AutoExchangeEvent[];\n};\n\
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/account/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MarginAccountEntity,\n MarginAccountTransactionHistoryEntity,\n MarketEntity,\n PositionEntity,\n OrderHistoryEntity,\n} from '@reyaxyz/common';\nimport {\n MarginAccountBalanceGranularity,\n MarginAccountCollateralsBalanceGranularity,\n AllMarginAccountsBalanceGranularity,\n ReferralFeeTransactionHistoryEntity,\n AutoExchangeEvent,\n} from '@reyaxyz/common';\nimport { Address } from '@reyaxyz/common';\n\nexport type GetMarginAccountsParams = {\n address: string;\n limit?: number;\n};\n\nexport type GetMarginAccountParams = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n};\n\nexport type GetPositionsForMarginAccountParams = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n limit?: number;\n};\n\nexport type GetMarginAccountsResult = MarginAccountEntity[];\n\nexport type GetMarginAccountResult = MarginAccountEntity;\n\n// ---- Transaction History\nexport type GetMarginAccountTransactionHistoryParams = {\n marginAccountId: MarginAccountEntity['id'];\n limit?: number;\n};\n\nexport type GetMarginAccountTransactionHistoryResult =\n MarginAccountTransactionHistoryEntity[];\n\nexport type GetAccountFeeRebatesHistoryParams = {\n marginAccountId: MarginAccountEntity['id'];\n limit?: number;\n};\n\nexport type GetAccountFeeRebatesHistoryResult = {\n result: ReferralFeeTransactionHistoryEntity[];\n};\n// -- Max Order Size --\n\nexport type GetMaxOrderSizeAvailableParams = {\n marketId: MarketEntity['id'];\n marginAccountId: MarginAccountEntity['id'];\n direction: 'long' | 'short';\n};\n\nexport type GetMaxOrderSizeAvailableResult = {\n maxAmountBase: number;\n maxAmountSize: number;\n};\n\n// --- Max Withdraw Balance for Margin Account ---\nexport type GetMaxWithdrawBalanceForAccountParams = {\n marginAccountId: MarginAccountEntity['id'];\n tokenAddress: string;\n};\n\nexport type GetMaxWithdrawBalanceForAccountResult = number;\n\nexport type GetPositionsForMarginAccountResult = {\n positions: PositionEntity[];\n totalUnrealizedPNL: number;\n};\n\n// --- Order History ---\n\nexport type GetMarginAccountOrderHistoryParams = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n limit?: number;\n};\nexport type GetMarginAccountOrderHistoryPaginatedParams = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n page: number;\n perPage: number;\n type?: 'order' | 'liquidation';\n};\nexport type GetMarginAccountOrderHistoryResult = OrderHistoryEntity[];\nexport type GetMarginAccountOrderHistoryPaginatedResult = {\n data: OrderHistoryEntity[];\n totalCount: number;\n};\n\n//--- Liquidation History ---\nexport type GetLiquidationHistoryForOwnerAddressParams = {\n address: Address;\n timestampFromMS: number;\n};\nexport type GetLiquidationHistoryForOwnerAddressResult = {\n data: LiquidationHistoryEntity[];\n};\n\nexport type LiquidationHistoryEntity = {\n id: string;\n action: 'long-liquidation' | 'short-liquidation';\n executionPrice: number;\n fees: number;\n base: number;\n size: number; // price * base (liquidation size)\n timestamp: number;\n baseUnderlyingToken: string;\n marginAccount: {\n id: MarginAccountEntity['id'];\n name: MarginAccountEntity['name'];\n marginRatioPercentage: MarginAccountEntity['marginRatioPercentage'];\n marginRatioHealth: MarginAccountEntity['marginRatioHealth'];\n };\n};\n\nexport type GetAutoExchangeHistoryForOwnerAddressParams =\n GetLiquidationHistoryForOwnerAddressParams;\nexport type GetAutoExchangeHistoryForOwnerAddressResult = {\n data: AutoExchangeEvent[];\n};\n\n// ---- Transaction Simulation ----\n\nexport type GetTransactionSimulationInitialDataParams = {\n marketId: MarketEntity['id'];\n marginAccountId: MarginAccountEntity['id'];\n};\n\n// ---- Edit Collateral Simulation ----\n\nexport type GetEditCollateralSimulationInitialDataParams = {\n marginAccountId: MarginAccountEntity['id'];\n};\n\nexport type GetMarginAccountBalanceChartDataParams = {\n marginAccountId: MarginAccountEntity['id'];\n filters: {\n timeframeMs: number;\n granularity: MarginAccountBalanceGranularity;\n };\n};\n\nexport type GetMarginAccountCollateralsBalanceChartDataParams = {\n marginAccountId: MarginAccountEntity['id'];\n filters: {\n timeframeMs: number;\n granularity: MarginAccountCollateralsBalanceGranularity;\n };\n};\n\nexport type GetAllMarginAccountsBalanceChartDataParams = {\n ownerAddress: string;\n filters: {\n timeframeMs: number;\n granularity: AllMarginAccountsBalanceGranularity;\n };\n};\n\nexport type EditMarginAccountParams = {\n id: MarginAccountEntity['id'];\n name: MarginAccountEntity['name'];\n};\n\nexport type EditMarginAccountResult = { success: boolean };\n\nexport type CloseMarginAccountParams = {\n id: MarginAccountEntity['id'];\n};\n\nexport type CloseMarginAccountResult = { success: boolean };\n\nexport type GetAllMarginAccountsSummaryParams = {\n ownerAddress: string;\n};\n\nexport type GetAllMarginAccountsSummaryResult = {\n totalAccountsCount: number;\n totalBalance: number;\n totalBalanceChangePercentage: number;\n totalBalanceUnderlyingAsset: string;\n};\n\nexport type GetIsolatedOrderMaxSizeAvailableParams = {\n marketId: MarketEntity['id'];\n marginAccountId: MarginAccountEntity['id'];\n direction: 'long' | 'short';\n};\n\nexport type GetIsolatedOrderMaxSizeAvailableResult = {\n maxAmountBase: number;\n maxAmountSize: number;\n};\n\nexport type UpdateLeverageForAccountAndMarketParams = {\n accountId: MarginAccountEntity['id'];\n marketId: MarketEntity['id'];\n leverage: number;\n};\n\nexport type UpdateLeverageForAccountAndMarketResult = {\n successful: boolean;\n leverage: number;\n};\n"]}
|
|
@@ -83,15 +83,6 @@ var MarketsClient = /** @class */ (function (_super) {
|
|
|
83
83
|
});
|
|
84
84
|
});
|
|
85
85
|
};
|
|
86
|
-
MarketsClient.prototype.getSpotMarkets = function () {
|
|
87
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
88
|
-
var uri;
|
|
89
|
-
return __generator(this, function (_a) {
|
|
90
|
-
uri = '/api/spot-markets';
|
|
91
|
-
return [2 /*return*/, this.get(uri)];
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
86
|
MarketsClient.prototype.getMarket = function (params) {
|
|
96
87
|
return __awaiter(this, void 0, void 0, function () {
|
|
97
88
|
var uri;
|
|
@@ -143,20 +134,6 @@ var MarketsClient = /** @class */ (function (_super) {
|
|
|
143
134
|
});
|
|
144
135
|
});
|
|
145
136
|
};
|
|
146
|
-
MarketsClient.prototype.getSpotMarketCandles = function (params) {
|
|
147
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
148
|
-
var uri;
|
|
149
|
-
return __generator(this, function (_a) {
|
|
150
|
-
uri = "/api/spot-markets/candles/".concat(params.marketId);
|
|
151
|
-
return [2 /*return*/, this.get(uri, {
|
|
152
|
-
resolution: params.resolution,
|
|
153
|
-
fromISO: params.fromISO,
|
|
154
|
-
toISO: params.toISO,
|
|
155
|
-
limit: params.limit,
|
|
156
|
-
})];
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
};
|
|
160
137
|
MarketsClient.prototype.getMarketTradingHistory = function (params) {
|
|
161
138
|
return __awaiter(this, void 0, void 0, function () {
|
|
162
139
|
var uri;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/markets/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/markets/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,0CAIyB;AAEzB;IAA2C,iCAAU;IAArD;;IAgFA,CAAC;IA/EC;;;;;;;;;;;;;;;;OAgBG;IAEG,kCAAU,GAAhB;;;;gBACQ,GAAG,GAAG,cAAc,CAAC;gBAC3B,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IAEK,iCAAS,GAAf,UAAgB,MAAuB;;;;gBAC/B,GAAG,GAAG,uBAAgB,MAAM,CAAC,EAAE,CAAE,CAAC;gBACxC,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IAEK,oCAAY,GAAlB,UAAmB,MAAuB;;;;;;wBAClC,GAAG,GAAG,uBAAgB,MAAM,CAAC,EAAE,iBAAc,CAAC;wBACH,qBAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAA;;wBAA9D,aAAa,GAA8B,SAAmB;wBACpE,sBAAO,EAAE,KAAK,EAAE,aAAa,CAAC,SAAS,EAAE,EAAC;;;;KAC3C;IAED;;;;;;;;;;;;OAYG;IAEG,wCAAgB,GAAtB,UACE,MAAwB;;;;gBAElB,GAAG,GAAG,+BAAwB,MAAM,CAAC,QAAQ,CAAE,CAAC;gBACtD,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,UAAU,EAAE,MAAM,CAAC,UAAU;wBAC7B,OAAO,EAAE,MAAM,CAAC,OAAO;wBACvB,KAAK,EAAE,MAAM,CAAC,KAAK;wBACnB,KAAK,EAAE,MAAM,CAAC,KAAK;qBACpB,CAAC,EAAC;;;KACJ;IAEK,+CAAuB,GAA7B,UACE,MAAqC;;;;gBAE/B,GAAG,GAAG,sBAAe,MAAM,CAAC,QAAQ,CAAE,CAAC;gBAC7C,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,KAAK,EAAE,MAAM,CAAC,KAAK;wBACnB,4BAA4B,EAAE,MAAM,CAAC,4BAA4B;qBAClE,CAAC,EAAC;;;KACJ;IAEK,+CAAuB,GAA7B,UACE,MAAqC;;;;gBAE/B,GAAG,GAAG,uBAAgB,MAAM,CAAC,QAAQ,0BAAuB,CAAC;gBACnE,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW;wBACvC,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW;qBACxC,CAAC,EAAC;;;KACJ;IACH,oBAAC;AAAD,CAAC,AAhFD,CAA2C,mBAAU,GAgFpD","sourcesContent":["import {\n GetCandlesParams,\n GetFundingRateChartDataParams,\n GetMarketParams,\n GetMarketResult,\n GetMarketsResult,\n GetMarketTradingHistoryParams,\n GetPoolPriceResult,\n GetTradingHistoryResult,\n MarketCandlesResponse,\n} from './types';\nimport {\n GetFundingRateChartDataResult,\n RestClient,\n GetInstantPoolPriceResult,\n} from '@reyaxyz/common';\n\nexport default class MarketsClient extends RestClient {\n /**\n * Asynchronously retrieves market data from the API.\n *\n * This method makes a request to the API to fetch data for markets. If a specific market is provided as a parameter,\n * it fetches data for that particular market; otherwise, it fetches data for all available markets.\n *\n * @returns {Promise<GetMarketsResult>} A promise that resolves to the response containing market data.\n * @memberof MarketsClient\n *\n * @example\n * // Fetch data for all markets\n * const allMarketsData = await market.getMarkets();\n *\n * @example\n * // Fetch data for a specific market\n * const specificMarketData = await market.getMarkets('ETH-USDC');\n */\n\n async getMarkets(): Promise<GetMarketsResult> {\n const uri = '/api/markets';\n return this.get(uri);\n }\n\n async getMarket(params: GetMarketParams): Promise<GetMarketResult> {\n const uri = `/api/markets/${params.id}`;\n return this.get(uri);\n }\n\n async getPoolPrice(params: GetMarketParams): Promise<GetPoolPriceResult> {\n const uri = `/api/markets/${params.id}/pool-price/`;\n const poolPriceInfo: GetInstantPoolPriceResult = await this.get(uri);\n return { price: poolPriceInfo.poolPrice };\n }\n\n /**\n * Retrieves candlestick data for a specified market.\n *\n * This method fetches historical candlestick (or OHLC - Open, High, Low, Close) data for a given market.\n * The data can be filtered by time range (fromISO and toISO) and resolution.\n *\n * @param {GetCandlesParams} params\n * @returns {Promise<MarketCandlesResponse>} A promise that resolves to the market candlestick data.\n * @memberof MarketsClient\n *\n * @example\n * const marketCandles = await market.getMarketCandles('BTC-USD', '1HR', '2023-01-01T00:00:00Z', '2023-01-02T00:00:00Z');\n */\n\n async getMarketCandles(\n params: GetCandlesParams,\n ): Promise<MarketCandlesResponse> {\n const uri = `/api/markets/candles/${params.marketId}`;\n return this.get(uri, {\n resolution: params.resolution,\n fromISO: params.fromISO,\n toISO: params.toISO,\n limit: params.limit,\n });\n }\n\n async getMarketTradingHistory(\n params: GetMarketTradingHistoryParams,\n ): Promise<GetTradingHistoryResult> {\n const uri = `/api/trades/${params.marketId}`;\n return this.get(uri, {\n limit: params.limit,\n fromTimestampMillisecondsUTC: params.fromTimestampMillisecondsUTC,\n });\n }\n\n async getFundingRateChartData(\n params: GetFundingRateChartDataParams,\n ): Promise<GetFundingRateChartDataResult> {\n const uri = `/api/markets/${params.marketId}/funding-rate-history`;\n return this.get(uri, {\n timeframeMs: params.filters.timeframeMs,\n granularity: params.filters.granularity,\n });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/markets/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n CandlesResolution,\n MarketEntity,\n TradingHistoryEntity,\n Candle,\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/markets/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n CandlesResolution,\n MarketEntity,\n TradingHistoryEntity,\n Candle,\n} from '@reyaxyz/common';\nimport { FundingRateHistoryGranularity } from '@reyaxyz/common';\n\nexport type GetMarketsResult = MarketEntity[];\n\nexport type GetMarketResult = MarketEntity;\n\nexport type GetMarketParams = {\n id: MarketEntity['id'];\n};\n\nexport type GetPoolPriceParams = {\n id: MarketEntity['id'];\n};\n\nexport type GetCandlesParams = {\n marketId: MarketEntity['id'];\n resolution: CandlesResolution;\n fromISO?: string | null;\n toISO?: string | null;\n limit?: number | null;\n};\n\nexport type GetMarketTradingHistoryParams = {\n marketId: number;\n limit?: number;\n fromTimestampMillisecondsUTC?: number;\n};\nexport type GetTradingHistoryResult = TradingHistoryEntity[];\n\nexport interface MarketCandlesResponse {\n candles: Candle[];\n}\n\nexport type GetFundingRateChartDataParams = {\n marketId: MarketEntity['id'];\n filters: {\n timeframeMs: number;\n granularity: FundingRateHistoryGranularity;\n };\n};\n\nexport type GetPoolPriceResult = {\n price: number;\n};\n"]}
|
|
@@ -29,7 +29,6 @@ var SocketChannels;
|
|
|
29
29
|
SocketChannels["PRICES"] = "prices";
|
|
30
30
|
SocketChannels["FUNDING_RATES"] = "funding-rates";
|
|
31
31
|
SocketChannels["MARKETS_UPDATES"] = "markets-updates";
|
|
32
|
-
SocketChannels["SPOT_CANDLES"] = "spot-candles";
|
|
33
32
|
})(SocketChannels || (exports.SocketChannels = SocketChannels = {}));
|
|
34
33
|
var IncomingMessageTypes;
|
|
35
34
|
(function (IncomingMessageTypes) {
|
|
@@ -191,14 +190,6 @@ var SocketClient = /** @class */ (function () {
|
|
|
191
190
|
};
|
|
192
191
|
this.subscribe(channel, params);
|
|
193
192
|
};
|
|
194
|
-
SocketClient.prototype.subscribeToSpotCandles = function (marketTicker, resolution) {
|
|
195
|
-
var channel = SocketChannels.SPOT_CANDLES;
|
|
196
|
-
var params = {
|
|
197
|
-
id: "".concat(marketTicker, "/").concat(resolution),
|
|
198
|
-
batched: true,
|
|
199
|
-
};
|
|
200
|
-
this.subscribe(channel, params);
|
|
201
|
-
};
|
|
202
193
|
/**
|
|
203
194
|
* @description Unsubscribe from candles channel
|
|
204
195
|
* for a specific market and resolution.
|
|
@@ -210,13 +201,6 @@ var SocketClient = /** @class */ (function () {
|
|
|
210
201
|
};
|
|
211
202
|
this.unsubscribe(channel, params);
|
|
212
203
|
};
|
|
213
|
-
SocketClient.prototype.unsubscribeFromSpotCandles = function (market, resolution) {
|
|
214
|
-
var channel = SocketChannels.SPOT_CANDLES;
|
|
215
|
-
var params = {
|
|
216
|
-
id: "".concat(market, "/").concat(resolution),
|
|
217
|
-
};
|
|
218
|
-
this.unsubscribe(channel, params);
|
|
219
|
-
};
|
|
220
204
|
/**
|
|
221
205
|
* @description Subscribe to prices channel
|
|
222
206
|
* for a specific assets pair.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket-client.js","sourceRoot":"/","sources":["clients/socket-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,gEAAwD;AAExD,0CAOyB;AAEzB,IAAK,oBAIJ;AAJD,WAAK,oBAAoB;IACvB,qCAAa,CAAA;IACb,+CAAuB,CAAA;IACvB,mDAA2B,CAAA;AAC7B,CAAC,EAJI,oBAAoB,KAApB,oBAAoB,QAIxB;AAED,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,qCAAmB,CAAA;IACnB,mCAAiB,CAAA;IACjB,iDAA+B,CAAA;IAC/B,qDAAmC,CAAA;IACnC,+CAA6B,CAAA;AAC/B,CAAC,EANW,cAAc,8BAAd,cAAc,QAMzB;AAED,IAAY,oBAOX;AAPD,WAAY,oBAAoB;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YACb,EAAE,EAAE,GAAG;SACR,CAAC;QACF,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IACH,mBAAC;AAAD,CAAC,AArQD,IAqQC;AArQY,oCAAY","sourcesContent":["import WebSocket, { MessageEvent } from 'isomorphic-ws';\n\nimport {\n Candle,\n CandlesResolution,\n getApiClientConfig,\n MarketEntity,\n ServiceConfig,\n StorkSignedPayload,\n} from '@reyaxyz/common';\n\nenum OutgoingMessageTypes {\n PING = 'ping',\n SUBSCRIBE = 'subscribe',\n UNSUBSCRIBE = 'unsubscribe',\n}\n\nexport enum SocketChannels {\n CANDLES = 'candles',\n PRICES = 'prices',\n FUNDING_RATES = 'funding-rates',\n MARKETS_UPDATES = 'markets-updates',\n SPOT_CANDLES = 'spot-candles',\n}\n\nexport enum IncomingMessageTypes {\n CONNECTED = 'connected',\n SUBSCRIBED = 'subscribed',\n ERROR = 'error',\n CHANNEL_DATA = 'channel_data',\n CHANNEL_BATCH_DATA = 'channel_batch_data',\n PONG = 'pong',\n}\nexport enum OutgoingMessageType {\n ERROR = 'error',\n CONNECTED = 'connected',\n SUBSCRIBED = 'subscribed',\n UNSUBSCRIBED = 'unsubscribed',\n CHANNEL_DATA = 'channel_data',\n CHANNEL_BATCH_DATA = 'channel_batch_data',\n PONG = 'pong',\n}\nexport interface OutgoingMessage {\n type: OutgoingMessageType;\n connection_id: string;\n message_id: number;\n}\nexport interface SocketMessage<\n C extends SocketChannels = SocketChannels,\n T = unknown,\n> {\n message_id: number;\n connection_id: string;\n type: OutgoingMessageType;\n channel: C;\n contents: T;\n id?: string;\n}\n\nexport type CandleMessage = SocketMessage<\n SocketChannels.CANDLES,\n {\n candles: Candle[];\n }\n>;\n\nexport type PricesMessage = SocketMessage<\n SocketChannels.PRICES,\n {\n signedPrice: StorkSignedPayload;\n poolPrice: string;\n spotPrice: string;\n marketId: number | null;\n assetPairId: string;\n }\n>;\n\nexport type MarketsUpdateMessage = SocketMessage<\n SocketChannels.MARKETS_UPDATES,\n MarketEntity[]\n>;\n\nexport type FundingRateMessage = SocketMessage<\n SocketChannels.FUNDING_RATES,\n { timestamp: number; value: string; assetsPair: string }\n>;\n\nexport interface SocketClientConfig {\n environment: ServiceConfig['environment'];\n onOpen: () => void;\n onClose: () => void;\n onMessage: (event: SocketMessage) => void;\n}\n\nexport class SocketClient {\n private url: string;\n private ws?: WebSocket;\n private onOpenCallback?: () => void;\n private onCloseCallback?: () => void;\n private onMessageCallback?: (event: SocketMessage) => void;\n private pingInterval: number = 30_000;\n private lastMessageTime: number = Date.now();\n private pingIntervalId?: NodeJS.Timeout;\n constructor(config: SocketClientConfig) {\n this.onOpenCallback = config.onOpen;\n this.onCloseCallback = config.onClose;\n this.onMessageCallback = config.onMessage;\n this.url = getApiClientConfig(config.environment).webSocketEndpoint;\n }\n\n connect(): void {\n this.ws = new WebSocket(this.url);\n this.ws.addEventListener('open', this.handleOpen.bind(this));\n this.ws.addEventListener('close', this.handleClose.bind(this));\n this.ws.addEventListener('message', this.handleMessage.bind(this));\n }\n\n /**\n * @description Close the websocket connection.\n *\n */\n close(): void {\n this.ws?.close();\n this.ws = undefined;\n }\n\n /**\n * @description Send data to the websocket connection.\n *\n */\n send(data: string): void {\n this.ws?.send(data);\n }\n\n private handleOpen(): void {\n if (this.onOpenCallback) {\n this.onOpenCallback();\n }\n this.restartPingInterval();\n }\n\n private handleClose(): void {\n if (this.onCloseCallback) {\n this.onCloseCallback();\n }\n clearInterval(this.pingIntervalId);\n }\n\n private handleMessage(event: MessageEvent): void {\n if (event.data === 'PING') {\n this.send('PONG');\n } else {\n this.lastMessageTime = Date.now();\n try {\n const parsedMessage: SocketMessage = JSON.parse(event.data as string);\n if (typeof this.onMessageCallback === 'function') {\n this.onMessageCallback(parsedMessage);\n }\n } catch (error) {\n console.error('Error parsing message', error);\n }\n }\n this.restartPingInterval();\n }\n\n private restartPingInterval(): void {\n clearInterval(this.pingIntervalId);\n this.pingIntervalId = setInterval(() => {\n const elapsedTime = Date.now() - this.lastMessageTime;\n if (elapsedTime > this.pingInterval) {\n const message = {\n type: OutgoingMessageTypes.PING,\n };\n this.send(JSON.stringify(message));\n }\n }, this.pingInterval);\n }\n\n /**\n * @description Set callback when the socket is opened.\n *\n */\n set onOpen(callback: () => void) {\n this.onOpenCallback = callback;\n }\n\n /**\n * @description Set callback when the socket is closed.\n *\n */\n set onClose(callback: () => void) {\n this.onCloseCallback = callback;\n }\n\n /**\n * @description Set callback when the socket receives a message.\n *\n */\n set onMessage(callback: (event: SocketMessage) => void) {\n this.onMessageCallback = callback;\n }\n\n getReadyState() {\n return this.ws?.readyState;\n }\n\n /**\n * @description Send a subscribe message to the websocket connection.\n *\n */\n subscribe(channel: string, params?: object): void {\n const message = {\n type: OutgoingMessageTypes.SUBSCRIBE,\n channel,\n ...params,\n };\n this.send(JSON.stringify(message));\n }\n\n /**\n * @description Send an unsubscribe message to the websocket connection.\n *\n */\n unsubscribe(channel: string, params?: object): void {\n const message = {\n type: OutgoingMessageTypes.UNSUBSCRIBE,\n channel,\n ...params,\n };\n this.send(JSON.stringify(message));\n }\n /**\n * @description Subscribe to candles channel\n * for a specific market and resolution.\n *\n */\n subscribeToCandles(\n marketTicker: string,\n resolution: CandlesResolution,\n ): void {\n const channel = SocketChannels.CANDLES;\n const params = {\n id: `${marketTicker}/${resolution}`,\n batched: true,\n };\n this.subscribe(channel, params);\n }\n\n subscribeToSpotCandles(\n marketTicker: string,\n resolution: CandlesResolution,\n ): void {\n const channel = SocketChannels.SPOT_CANDLES;\n const params = {\n id: `${marketTicker}/${resolution}`,\n batched: true,\n };\n this.subscribe(channel, params);\n }\n\n /**\n * @description Unsubscribe from candles channel\n * for a specific market and resolution.\n */\n unsubscribeFromCandles(market: string, resolution: CandlesResolution): void {\n const channel = SocketChannels.CANDLES;\n const params = {\n id: `${market}/${resolution}`,\n };\n this.unsubscribe(channel, params);\n }\n\n unsubscribeFromSpotCandles(\n market: string,\n resolution: CandlesResolution,\n ): void {\n const channel = SocketChannels.SPOT_CANDLES;\n const params = {\n id: `${market}/${resolution}`,\n };\n this.unsubscribe(channel, params);\n }\n\n /**\n * @description Subscribe to prices channel\n * for a specific assets pair.\n *\n */\n subscribeToPrices(assetsPair: string): void {\n const channel = SocketChannels.PRICES;\n const params = {\n id: assetsPair,\n };\n this.subscribe(channel, params);\n }\n\n /**\n * @description Unsubscribe from prices channel\n * for a specific market and resolution.\n */\n unsubscribeFromPrices(assetsPair: string): void {\n const channel = SocketChannels.PRICES;\n const params = {\n id: assetsPair,\n };\n this.unsubscribe(channel, params);\n }\n\n /**\n * @description Subscribe to funding rate channel\n * for a specific assets pair.\n *\n */\n subscribeToFundingRate(assetsPair: string): void {\n const channel = SocketChannels.FUNDING_RATES;\n const params = {\n id: assetsPair,\n };\n this.subscribe(channel, params);\n }\n\n /**\n * @description Unsubscribe from funding rate channel\n * for a specific market and resolution.\n */\n unsubscribeFromFundingRate(assetsPair: string): void {\n const channel = SocketChannels.FUNDING_RATES;\n const params = {\n id: assetsPair,\n };\n this.unsubscribe(channel, params);\n }\n\n /**\n * @description Subscribe to markets updates channel\n *\n */\n subscribeToMarketsUpdates(): void {\n const channel = SocketChannels.MARKETS_UPDATES;\n const params = {\n id: '1',\n };\n this.subscribe(channel, params);\n }\n\n /**\n * @description Unsubscribe from markets updates channel\n */\n unsubscribeFromMarketsUpdates(): void {\n const channel = SocketChannels.MARKETS_UPDATES;\n const params = {\n id: '1',\n };\n this.unsubscribe(channel, params);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"socket-client.js","sourceRoot":"/","sources":["clients/socket-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,gEAAwD;AAExD,0CAOyB;AAEzB,IAAK,oBAIJ;AAJD,WAAK,oBAAoB;IACvB,qCAAa,CAAA;IACb,+CAAuB,CAAA;IACvB,mDAA2B,CAAA;AAC7B,CAAC,EAJI,oBAAoB,KAApB,oBAAoB,QAIxB;AAED,IAAY,cA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C,IAAM,MAAM,GAAG;YACb,EAAE,EAAE,UAAU;SACf,CAAC;QACF,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACH,6CAAsB,GAAtB,UAAuB,UAAkB;QACvC,IAAM,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC;QAC7C,IAAM,MAAM,GAAG;YACb,EAAE,EAAE,UAAU;SACf,CAAC;QACF,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAClC,CAAC;IAED;;;OAGG;IACH,iDAA0B,GAA1B,UAA2B,UAAkB;QAC3C,IAAM,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC;QAC7C,IAAM,MAAM,GAAG;YACb,EAAE,EAAE,UAAU;SACf,CAAC;QACF,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,gDAAyB,GAAzB;QACE,IAAM,OAAO,GAAG,cAAc,CAAC,eAAe,CAAC;QAC/C,IAAM,MAAM,GAAG;YACb,EAAE,EAAE,GAAG;SACR,CAAC;QACF,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,oDAA6B,GAA7B;QACE,IAAM,OAAO,GAAG,cAAc,CAAC,eAAe,CAAC;QAC/C,IAAM,MAAM,GAAG;YACb,EAAE,EAAE,GAAG;SACR,CAAC;QACF,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IACH,mBAAC;AAAD,CAAC,AA9OD,IA8OC;AA9OY,oCAAY","sourcesContent":["import WebSocket, { MessageEvent } from 'isomorphic-ws';\n\nimport {\n Candle,\n CandlesResolution,\n getApiClientConfig,\n MarketEntity,\n ServiceConfig,\n StorkSignedPayload,\n} from '@reyaxyz/common';\n\nenum OutgoingMessageTypes {\n PING = 'ping',\n SUBSCRIBE = 'subscribe',\n UNSUBSCRIBE = 'unsubscribe',\n}\n\nexport enum SocketChannels {\n CANDLES = 'candles',\n PRICES = 'prices',\n FUNDING_RATES = 'funding-rates',\n MARKETS_UPDATES = 'markets-updates',\n}\n\nexport enum IncomingMessageTypes {\n CONNECTED = 'connected',\n SUBSCRIBED = 'subscribed',\n ERROR = 'error',\n CHANNEL_DATA = 'channel_data',\n CHANNEL_BATCH_DATA = 'channel_batch_data',\n PONG = 'pong',\n}\nexport enum OutgoingMessageType {\n ERROR = 'error',\n CONNECTED = 'connected',\n SUBSCRIBED = 'subscribed',\n UNSUBSCRIBED = 'unsubscribed',\n CHANNEL_DATA = 'channel_data',\n CHANNEL_BATCH_DATA = 'channel_batch_data',\n PONG = 'pong',\n}\nexport interface OutgoingMessage {\n type: OutgoingMessageType;\n connection_id: string;\n message_id: number;\n}\nexport interface SocketMessage<\n C extends SocketChannels = SocketChannels,\n T = unknown,\n> {\n message_id: number;\n connection_id: string;\n type: OutgoingMessageType;\n channel: C;\n contents: T;\n id?: string;\n}\n\nexport type CandleMessage = SocketMessage<\n SocketChannels.CANDLES,\n {\n candles: Candle[];\n }\n>;\n\nexport type PricesMessage = SocketMessage<\n SocketChannels.PRICES,\n {\n signedPrice: StorkSignedPayload;\n poolPrice: string;\n spotPrice: string;\n marketId: number | null;\n assetPairId: string;\n }\n>;\n\nexport type MarketsUpdateMessage = SocketMessage<\n SocketChannels.MARKETS_UPDATES,\n MarketEntity[]\n>;\n\nexport type FundingRateMessage = SocketMessage<\n SocketChannels.FUNDING_RATES,\n { timestamp: number; value: string; assetsPair: string }\n>;\n\nexport interface SocketClientConfig {\n environment: ServiceConfig['environment'];\n onOpen: () => void;\n onClose: () => void;\n onMessage: (event: SocketMessage) => void;\n}\n\nexport class SocketClient {\n private url: string;\n private ws?: WebSocket;\n private onOpenCallback?: () => void;\n private onCloseCallback?: () => void;\n private onMessageCallback?: (event: SocketMessage) => void;\n private pingInterval: number = 30_000;\n private lastMessageTime: number = Date.now();\n private pingIntervalId?: NodeJS.Timeout;\n constructor(config: SocketClientConfig) {\n this.onOpenCallback = config.onOpen;\n this.onCloseCallback = config.onClose;\n this.onMessageCallback = config.onMessage;\n this.url = getApiClientConfig(config.environment).webSocketEndpoint;\n }\n\n connect(): void {\n this.ws = new WebSocket(this.url);\n this.ws.addEventListener('open', this.handleOpen.bind(this));\n this.ws.addEventListener('close', this.handleClose.bind(this));\n this.ws.addEventListener('message', this.handleMessage.bind(this));\n }\n\n /**\n * @description Close the websocket connection.\n *\n */\n close(): void {\n this.ws?.close();\n this.ws = undefined;\n }\n\n /**\n * @description Send data to the websocket connection.\n *\n */\n send(data: string): void {\n this.ws?.send(data);\n }\n\n private handleOpen(): void {\n if (this.onOpenCallback) {\n this.onOpenCallback();\n }\n this.restartPingInterval();\n }\n\n private handleClose(): void {\n if (this.onCloseCallback) {\n this.onCloseCallback();\n }\n clearInterval(this.pingIntervalId);\n }\n\n private handleMessage(event: MessageEvent): void {\n if (event.data === 'PING') {\n this.send('PONG');\n } else {\n this.lastMessageTime = Date.now();\n try {\n const parsedMessage: SocketMessage = JSON.parse(event.data as string);\n if (typeof this.onMessageCallback === 'function') {\n this.onMessageCallback(parsedMessage);\n }\n } catch (error) {\n console.error('Error parsing message', error);\n }\n }\n this.restartPingInterval();\n }\n\n private restartPingInterval(): void {\n clearInterval(this.pingIntervalId);\n this.pingIntervalId = setInterval(() => {\n const elapsedTime = Date.now() - this.lastMessageTime;\n if (elapsedTime > this.pingInterval) {\n const message = {\n type: OutgoingMessageTypes.PING,\n };\n this.send(JSON.stringify(message));\n }\n }, this.pingInterval);\n }\n\n /**\n * @description Set callback when the socket is opened.\n *\n */\n set onOpen(callback: () => void) {\n this.onOpenCallback = callback;\n }\n\n /**\n * @description Set callback when the socket is closed.\n *\n */\n set onClose(callback: () => void) {\n this.onCloseCallback = callback;\n }\n\n /**\n * @description Set callback when the socket receives a message.\n *\n */\n set onMessage(callback: (event: SocketMessage) => void) {\n this.onMessageCallback = callback;\n }\n\n getReadyState() {\n return this.ws?.readyState;\n }\n\n /**\n * @description Send a subscribe message to the websocket connection.\n *\n */\n subscribe(channel: string, params?: object): void {\n const message = {\n type: OutgoingMessageTypes.SUBSCRIBE,\n channel,\n ...params,\n };\n this.send(JSON.stringify(message));\n }\n\n /**\n * @description Send an unsubscribe message to the websocket connection.\n *\n */\n unsubscribe(channel: string, params?: object): void {\n const message = {\n type: OutgoingMessageTypes.UNSUBSCRIBE,\n channel,\n ...params,\n };\n this.send(JSON.stringify(message));\n }\n /**\n * @description Subscribe to candles channel\n * for a specific market and resolution.\n *\n */\n subscribeToCandles(\n marketTicker: string,\n resolution: CandlesResolution,\n ): void {\n const channel = SocketChannels.CANDLES;\n const params = {\n id: `${marketTicker}/${resolution}`,\n batched: true,\n };\n this.subscribe(channel, params);\n }\n\n /**\n * @description Unsubscribe from candles channel\n * for a specific market and resolution.\n */\n unsubscribeFromCandles(market: string, resolution: CandlesResolution): void {\n const channel = SocketChannels.CANDLES;\n const params = {\n id: `${market}/${resolution}`,\n };\n this.unsubscribe(channel, params);\n }\n\n /**\n * @description Subscribe to prices channel\n * for a specific assets pair.\n *\n */\n subscribeToPrices(assetsPair: string): void {\n const channel = SocketChannels.PRICES;\n const params = {\n id: assetsPair,\n };\n this.subscribe(channel, params);\n }\n\n /**\n * @description Unsubscribe from prices channel\n * for a specific market and resolution.\n */\n unsubscribeFromPrices(assetsPair: string): void {\n const channel = SocketChannels.PRICES;\n const params = {\n id: assetsPair,\n };\n this.unsubscribe(channel, params);\n }\n\n /**\n * @description Subscribe to funding rate channel\n * for a specific assets pair.\n *\n */\n subscribeToFundingRate(assetsPair: string): void {\n const channel = SocketChannels.FUNDING_RATES;\n const params = {\n id: assetsPair,\n };\n this.subscribe(channel, params);\n }\n\n /**\n * @description Unsubscribe from funding rate channel\n * for a specific market and resolution.\n */\n unsubscribeFromFundingRate(assetsPair: string): void {\n const channel = SocketChannels.FUNDING_RATES;\n const params = {\n id: assetsPair,\n };\n this.unsubscribe(channel, params);\n }\n\n /**\n * @description Subscribe to markets updates channel\n *\n */\n subscribeToMarketsUpdates(): void {\n const channel = SocketChannels.MARKETS_UPDATES;\n const params = {\n id: '1',\n };\n this.subscribe(channel, params);\n }\n\n /**\n * @description Unsubscribe from markets updates channel\n */\n unsubscribeFromMarketsUpdates(): void {\n const channel = SocketChannels.MARKETS_UPDATES;\n const params = {\n id: '1',\n };\n this.unsubscribe(channel, params);\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GetMarginAccountParams, GetMarginAccountResult, GetMarginAccountsParams, GetMarginAccountsResult, GetMarginAccountTransactionHistoryParams, GetMarginAccountTransactionHistoryResult, GetMaxOrderSizeAvailableParams, GetMaxOrderSizeAvailableResult, GetMaxWithdrawBalanceForAccountParams, GetMaxWithdrawBalanceForAccountResult, GetPositionsForMarginAccountParams, GetPositionsForMarginAccountResult, GetTransactionSimulationInitialDataParams, GetMarginAccountBalanceChartDataParams, GetMarginAccountCollateralsBalanceChartDataParams, GetAllMarginAccountsBalanceChartDataParams, EditMarginAccountParams, CloseMarginAccountParams, GetAllMarginAccountsSummaryResult, GetAllMarginAccountsSummaryParams, GetEditCollateralSimulationInitialDataParams, EditMarginAccountResult, CloseMarginAccountResult, GetIsolatedOrderMaxSizeAvailableParams, GetIsolatedOrderMaxSizeAvailableResult, GetMarginAccountOrderHistoryPaginatedParams, GetMarginAccountOrderHistoryPaginatedResult, GetLiquidationHistoryForOwnerAddressResult, GetLiquidationHistoryForOwnerAddressParams, GetAccountFeeRebatesHistoryParams, GetAccountFeeRebatesHistoryResult, GetAutoExchangeHistoryForOwnerAddressResult, GetAutoExchangeHistoryForOwnerAddressParams, UpdateLeverageForAccountAndMarketParams, UpdateLeverageForAccountAndMarketResult
|
|
1
|
+
import { GetMarginAccountParams, GetMarginAccountResult, GetMarginAccountsParams, GetMarginAccountsResult, GetMarginAccountTransactionHistoryParams, GetMarginAccountTransactionHistoryResult, GetMaxOrderSizeAvailableParams, GetMaxOrderSizeAvailableResult, GetMaxWithdrawBalanceForAccountParams, GetMaxWithdrawBalanceForAccountResult, GetPositionsForMarginAccountParams, GetPositionsForMarginAccountResult, GetTransactionSimulationInitialDataParams, GetMarginAccountBalanceChartDataParams, GetMarginAccountCollateralsBalanceChartDataParams, GetAllMarginAccountsBalanceChartDataParams, EditMarginAccountParams, CloseMarginAccountParams, GetAllMarginAccountsSummaryResult, GetAllMarginAccountsSummaryParams, GetEditCollateralSimulationInitialDataParams, EditMarginAccountResult, CloseMarginAccountResult, GetIsolatedOrderMaxSizeAvailableParams, GetIsolatedOrderMaxSizeAvailableResult, GetMarginAccountOrderHistoryPaginatedParams, GetMarginAccountOrderHistoryPaginatedResult, GetLiquidationHistoryForOwnerAddressResult, GetLiquidationHistoryForOwnerAddressParams, GetAccountFeeRebatesHistoryParams, GetAccountFeeRebatesHistoryResult, GetAutoExchangeHistoryForOwnerAddressResult, GetAutoExchangeHistoryForOwnerAddressParams, UpdateLeverageForAccountAndMarketParams, UpdateLeverageForAccountAndMarketResult } from './types';
|
|
2
2
|
import { EditCollateralSimulationState, TradeSimulationState, GetMarginAccountCollateralsBalanceChartDataResult, GetMarginAccountBalanceChartDataResult, GetAllMarginAccountsBalanceChartDataResult, RestClient } from '@reyaxyz/common';
|
|
3
3
|
export default class AccountClient extends RestClient {
|
|
4
4
|
/**
|
|
@@ -30,7 +30,6 @@ export default class AccountClient extends RestClient {
|
|
|
30
30
|
getMarginAccountOrderHistoryPaginated(params: GetMarginAccountOrderHistoryPaginatedParams): Promise<GetMarginAccountOrderHistoryPaginatedResult>;
|
|
31
31
|
getLiquidationHistoryForOwnerAddress(params: GetLiquidationHistoryForOwnerAddressParams): Promise<GetLiquidationHistoryForOwnerAddressResult>;
|
|
32
32
|
getAutoExchangeHistoryForOwnerAddress(params: GetAutoExchangeHistoryForOwnerAddressParams): Promise<GetAutoExchangeHistoryForOwnerAddressResult>;
|
|
33
|
-
getSwapHistoryForWalletAddress(params: GetSwapHistoryForWalletAddressParams): Promise<GetSwapHistoryForWalletAddressResult>;
|
|
34
33
|
getMaxOrderSizeAvailable(params: GetMaxOrderSizeAvailableParams): Promise<GetMaxOrderSizeAvailableResult>;
|
|
35
34
|
getIsolatedOrderMaxSizeAvailable(params: GetIsolatedOrderMaxSizeAvailableParams): Promise<GetIsolatedOrderMaxSizeAvailableResult>;
|
|
36
35
|
getTransactionSimulationInitialData(params: GetTransactionSimulationInitialDataParams): Promise<TradeSimulationState>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/account/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,wCAAwC,EACxC,wCAAwC,EACxC,8BAA8B,EAC9B,8BAA8B,EAC9B,qCAAqC,EACrC,qCAAqC,EACrC,kCAAkC,EAClC,kCAAkC,EAClC,yCAAyC,EACzC,sCAAsC,EACtC,iDAAiD,EACjD,0CAA0C,EAC1C,uBAAuB,EACvB,wBAAwB,EACxB,iCAAiC,EACjC,iCAAiC,EACjC,4CAA4C,EAC5C,uBAAuB,EACvB,wBAAwB,EACxB,sCAAsC,EACtC,sCAAsC,EACtC,2CAA2C,EAC3C,2CAA2C,EAC3C,0CAA0C,EAC1C,0CAA0C,EAC1C,iCAAiC,EACjC,iCAAiC,EACjC,2CAA2C,EAC3C,2CAA2C,EAC3C,uCAAuC,EACvC,uCAAuC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/account/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,wCAAwC,EACxC,wCAAwC,EACxC,8BAA8B,EAC9B,8BAA8B,EAC9B,qCAAqC,EACrC,qCAAqC,EACrC,kCAAkC,EAClC,kCAAkC,EAClC,yCAAyC,EACzC,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,CAAC;IAO1B,sCAAsC,CAC1C,MAAM,EAAE,4CAA4C,GACnD,OAAO,CAAC,6BAA6B,CAAC;IAKnC,kCAAkC,CACtC,MAAM,EAAE,wCAAwC,GAC/C,OAAO,CAAC,wCAAwC,CAAC;IAO9C,2BAA2B,CAC/B,MAAM,EAAE,iCAAiC,GACxC,OAAO,CAAC,iCAAiC,CAAC;IAOvC,+BAA+B,CACnC,MAAM,EAAE,qCAAqC,GAC5C,OAAO,CAAC,qCAAqC,CAAC;IAO3C,gCAAgC,CACpC,MAAM,EAAE,sCAAsC,GAC7C,OAAO,CAAC,sCAAsC,CAAC;IAQ5C,2CAA2C,CAC/C,MAAM,EAAE,iDAAiD,GACxD,OAAO,CAAC,iDAAiD,CAAC;IAQvD,gCAAgC,CACpC,MAAM,EAAE,0CAA0C,GACjD,OAAO,CAAC,0CAA0C,CAAC;IAQhD,2BAA2B,CAC/B,MAAM,EAAE,iCAAiC,GACxC,OAAO,CAAC,iCAAiC,CAAC;IAMvC,iBAAiB,CACrB,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,uBAAuB,CAAC;IAe7B,kBAAkB,CACtB,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,wBAAwB,CAAC;IAW9B,iCAAiC,CACrC,MAAM,EAAE,uCAAuC,GAC9C,OAAO,CAAC,uCAAuC,CAAC;CAcpD"}
|
|
@@ -90,22 +90,6 @@ export type GetAutoExchangeHistoryForOwnerAddressParams = GetLiquidationHistoryF
|
|
|
90
90
|
export type GetAutoExchangeHistoryForOwnerAddressResult = {
|
|
91
91
|
data: AutoExchangeEvent[];
|
|
92
92
|
};
|
|
93
|
-
export type SwapHistoryEntity = {
|
|
94
|
-
id: string;
|
|
95
|
-
tokenFrom: string;
|
|
96
|
-
tokenTo: string;
|
|
97
|
-
amountIn: number;
|
|
98
|
-
amountOut: number;
|
|
99
|
-
blockTimestamp: number;
|
|
100
|
-
transactionHash: string;
|
|
101
|
-
};
|
|
102
|
-
export type GetSwapHistoryForWalletAddressParams = {
|
|
103
|
-
address: string;
|
|
104
|
-
timestampFromMS: number;
|
|
105
|
-
};
|
|
106
|
-
export type GetSwapHistoryForWalletAddressResult = {
|
|
107
|
-
data: SwapHistoryEntity[];
|
|
108
|
-
};
|
|
109
93
|
export type GetTransactionSimulationInitialDataParams = {
|
|
110
94
|
marketId: MarketEntity['id'];
|
|
111
95
|
marginAccountId: MarginAccountEntity['id'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/account/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,qCAAqC,EACrC,YAAY,EACZ,cAAc,EACd,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,+BAA+B,EAC/B,0CAA0C,EAC1C,mCAAmC,EACnC,mCAAmC,EACnC,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAAG;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,mBAAmB,EAAE,CAAC;AAE5D,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAGzD,MAAM,MAAM,wCAAwC,GAAG;IACrD,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,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AC;IACrC,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,uCAAuC,GAAG;IACpD,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GetCandlesParams, GetFundingRateChartDataParams, GetMarketParams, GetMarketResult, GetMarketsResult, GetMarketTradingHistoryParams, GetPoolPriceResult,
|
|
1
|
+
import { GetCandlesParams, GetFundingRateChartDataParams, GetMarketParams, GetMarketResult, GetMarketsResult, GetMarketTradingHistoryParams, GetPoolPriceResult, GetTradingHistoryResult, MarketCandlesResponse } from './types';
|
|
2
2
|
import { GetFundingRateChartDataResult, RestClient } from '@reyaxyz/common';
|
|
3
3
|
export default class MarketsClient extends RestClient {
|
|
4
4
|
/**
|
|
@@ -19,7 +19,6 @@ export default class MarketsClient extends RestClient {
|
|
|
19
19
|
* const specificMarketData = await market.getMarkets('ETH-USDC');
|
|
20
20
|
*/
|
|
21
21
|
getMarkets(): Promise<GetMarketsResult>;
|
|
22
|
-
getSpotMarkets(): Promise<GetSpotMarketsResult>;
|
|
23
22
|
getMarket(params: GetMarketParams): Promise<GetMarketResult>;
|
|
24
23
|
getPoolPrice(params: GetMarketParams): Promise<GetPoolPriceResult>;
|
|
25
24
|
/**
|
|
@@ -36,7 +35,6 @@ export default class MarketsClient extends RestClient {
|
|
|
36
35
|
* const marketCandles = await market.getMarketCandles('BTC-USD', '1HR', '2023-01-01T00:00:00Z', '2023-01-02T00:00:00Z');
|
|
37
36
|
*/
|
|
38
37
|
getMarketCandles(params: GetCandlesParams): Promise<MarketCandlesResponse>;
|
|
39
|
-
getSpotMarketCandles(params: GetSpotCandlesParams): Promise<MarketCandlesResponse>;
|
|
40
38
|
getMarketTradingHistory(params: GetMarketTradingHistoryParams): Promise<GetTradingHistoryResult>;
|
|
41
39
|
getFundingRateChartData(params: GetFundingRateChartDataParams): Promise<GetFundingRateChartDataResult>;
|
|
42
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/markets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,6BAA6B,EAC7B,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,6BAA6B,EAC7B,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/markets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,6BAA6B,EAC7B,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,6BAA6B,EAC7B,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,6BAA6B,EAC7B,UAAU,EAEX,MAAM,iBAAiB,CAAC;AAEzB,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD;;;;;;;;;;;;;;;;OAgBG;IAEG,UAAU,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAKvC,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAK5D,YAAY,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAMxE;;;;;;;;;;;;OAYG;IAEG,gBAAgB,CACpB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,qBAAqB,CAAC;IAU3B,uBAAuB,CAC3B,MAAM,EAAE,6BAA6B,GACpC,OAAO,CAAC,uBAAuB,CAAC;IAQ7B,uBAAuB,CAC3B,MAAM,EAAE,6BAA6B,GACpC,OAAO,CAAC,6BAA6B,CAAC;CAO1C"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { CandlesResolution, MarketEntity, TradingHistoryEntity, Candle
|
|
1
|
+
import { CandlesResolution, MarketEntity, TradingHistoryEntity, Candle } from '@reyaxyz/common';
|
|
2
2
|
import { FundingRateHistoryGranularity } from '@reyaxyz/common';
|
|
3
3
|
export type GetMarketsResult = MarketEntity[];
|
|
4
|
-
export type GetSpotMarketsResult = SpotMarketEntity[];
|
|
5
4
|
export type GetMarketResult = MarketEntity;
|
|
6
5
|
export type GetMarketParams = {
|
|
7
6
|
id: MarketEntity['id'];
|
|
@@ -16,13 +15,6 @@ export type GetCandlesParams = {
|
|
|
16
15
|
toISO?: string | null;
|
|
17
16
|
limit?: number | null;
|
|
18
17
|
};
|
|
19
|
-
export type GetSpotCandlesParams = {
|
|
20
|
-
marketId: SpotMarketEntity['id'];
|
|
21
|
-
resolution: CandlesResolution;
|
|
22
|
-
fromISO?: string | null;
|
|
23
|
-
toISO?: string | null;
|
|
24
|
-
limit?: number | null;
|
|
25
|
-
};
|
|
26
18
|
export type GetMarketTradingHistoryParams = {
|
|
27
19
|
marketId: number;
|
|
28
20
|
limit?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/markets/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/markets/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,MAAM,EACP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AAEhE,MAAM,MAAM,gBAAgB,GAAG,YAAY,EAAE,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC;AAE3C,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,EAAE,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;IAC7B,UAAU,EAAE,iBAAiB,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4BAA4B,CAAC,EAAE,MAAM,CAAC;CACvC,CAAC;AACF,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,EAAE,CAAC;AAE7D,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,MAAM,6BAA6B,GAAG;IAC1C,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;IAC7B,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,6BAA6B,CAAC;KAC5C,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC"}
|
|
@@ -3,8 +3,7 @@ export declare enum SocketChannels {
|
|
|
3
3
|
CANDLES = "candles",
|
|
4
4
|
PRICES = "prices",
|
|
5
5
|
FUNDING_RATES = "funding-rates",
|
|
6
|
-
MARKETS_UPDATES = "markets-updates"
|
|
7
|
-
SPOT_CANDLES = "spot-candles"
|
|
6
|
+
MARKETS_UPDATES = "markets-updates"
|
|
8
7
|
}
|
|
9
8
|
export declare enum IncomingMessageTypes {
|
|
10
9
|
CONNECTED = "connected",
|
|
@@ -115,13 +114,11 @@ export declare class SocketClient {
|
|
|
115
114
|
*
|
|
116
115
|
*/
|
|
117
116
|
subscribeToCandles(marketTicker: string, resolution: CandlesResolution): void;
|
|
118
|
-
subscribeToSpotCandles(marketTicker: string, resolution: CandlesResolution): void;
|
|
119
117
|
/**
|
|
120
118
|
* @description Unsubscribe from candles channel
|
|
121
119
|
* for a specific market and resolution.
|
|
122
120
|
*/
|
|
123
121
|
unsubscribeFromCandles(market: string, resolution: CandlesResolution): void;
|
|
124
|
-
unsubscribeFromSpotCandles(market: string, resolution: CandlesResolution): void;
|
|
125
122
|
/**
|
|
126
123
|
* @description Subscribe to prices channel
|
|
127
124
|
* for a specific assets pair.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket-client.d.ts","sourceRoot":"/","sources":["clients/socket-client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,MAAM,EACN,iBAAiB,EAEjB,YAAY,EACZ,aAAa,EACb,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAQzB,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,aAAa,kBAAkB;IAC/B,eAAe,oBAAoB;
|
|
1
|
+
{"version":3,"file":"socket-client.d.ts","sourceRoot":"/","sources":["clients/socket-client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,MAAM,EACN,iBAAiB,EAEjB,YAAY,EACZ,aAAa,EACb,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAQzB,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,aAAa,kBAAkB;IAC/B,eAAe,oBAAoB;CACpC;AAED,oBAAY,oBAAoB;IAC9B,SAAS,cAAc;IACvB,UAAU,eAAe;IACzB,KAAK,UAAU;IACf,YAAY,iBAAiB;IAC7B,kBAAkB,uBAAuB;IACzC,IAAI,SAAS;CACd;AACD,oBAAY,mBAAmB;IAC7B,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAC7B,YAAY,iBAAiB;IAC7B,kBAAkB,uBAAuB;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,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAQ3C;;;OAGG;IACH,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAQ/C;;;;OAIG;IACH,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAQhD;;;OAGG;IACH,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAQpD;;;OAGG;IACH,yBAAyB,IAAI,IAAI;IAQjC;;OAEG;IACH,6BAA6B,IAAI,IAAI;CAOtC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/api-sdk",
|
|
3
|
-
"version": "0.151.
|
|
3
|
+
"version": "0.151.16",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@reyaxyz/common": "0.
|
|
36
|
+
"@reyaxyz/common": "0.273.1",
|
|
37
37
|
"@simplewebauthn/types": "^10.0.0",
|
|
38
38
|
"axios": "^1.6.2",
|
|
39
39
|
"bignumber.js": "^9.1.2",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"ws": "^8.16.0"
|
|
43
43
|
},
|
|
44
44
|
"packageManager": "pnpm@8.3.1",
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "00b22f980063c9b2e22034988f06345991d57e9f",
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@reyaxyz/database": "0.
|
|
47
|
+
"@reyaxyz/database": "0.123.1"
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -34,8 +34,6 @@ import {
|
|
|
34
34
|
GetAutoExchangeHistoryForOwnerAddressParams,
|
|
35
35
|
UpdateLeverageForAccountAndMarketParams,
|
|
36
36
|
UpdateLeverageForAccountAndMarketResult,
|
|
37
|
-
GetSwapHistoryForWalletAddressResult,
|
|
38
|
-
GetSwapHistoryForWalletAddressParams,
|
|
39
37
|
} from './types';
|
|
40
38
|
import {
|
|
41
39
|
EditCollateralSimulationState,
|
|
@@ -126,15 +124,6 @@ export default class AccountClient extends RestClient {
|
|
|
126
124
|
});
|
|
127
125
|
}
|
|
128
126
|
|
|
129
|
-
async getSwapHistoryForWalletAddress(
|
|
130
|
-
params: GetSwapHistoryForWalletAddressParams,
|
|
131
|
-
): Promise<GetSwapHistoryForWalletAddressResult> {
|
|
132
|
-
const uri = `/api/accounts/${params.address}/swaps/history`;
|
|
133
|
-
return this.get(uri, {
|
|
134
|
-
timestampFromMS: params.timestampFromMS,
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
127
|
async getMaxOrderSizeAvailable(
|
|
139
128
|
params: GetMaxOrderSizeAvailableParams,
|
|
140
129
|
): Promise<GetMaxOrderSizeAvailableResult> {
|
|
@@ -129,24 +129,6 @@ export type GetAutoExchangeHistoryForOwnerAddressResult = {
|
|
|
129
129
|
data: AutoExchangeEvent[];
|
|
130
130
|
};
|
|
131
131
|
|
|
132
|
-
export type SwapHistoryEntity = {
|
|
133
|
-
id: string;
|
|
134
|
-
tokenFrom: string;
|
|
135
|
-
tokenTo: string;
|
|
136
|
-
amountIn: number;
|
|
137
|
-
amountOut: number;
|
|
138
|
-
blockTimestamp: number;
|
|
139
|
-
transactionHash: string;
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
export type GetSwapHistoryForWalletAddressParams = {
|
|
143
|
-
address: string;
|
|
144
|
-
timestampFromMS: number;
|
|
145
|
-
};
|
|
146
|
-
export type GetSwapHistoryForWalletAddressResult = {
|
|
147
|
-
data: SwapHistoryEntity[];
|
|
148
|
-
};
|
|
149
|
-
|
|
150
132
|
// ---- Transaction Simulation ----
|
|
151
133
|
|
|
152
134
|
export type GetTransactionSimulationInitialDataParams = {
|
|
@@ -6,8 +6,6 @@ import {
|
|
|
6
6
|
GetMarketsResult,
|
|
7
7
|
GetMarketTradingHistoryParams,
|
|
8
8
|
GetPoolPriceResult,
|
|
9
|
-
GetSpotCandlesParams,
|
|
10
|
-
GetSpotMarketsResult,
|
|
11
9
|
GetTradingHistoryResult,
|
|
12
10
|
MarketCandlesResponse,
|
|
13
11
|
} from './types';
|
|
@@ -41,11 +39,6 @@ export default class MarketsClient extends RestClient {
|
|
|
41
39
|
return this.get(uri);
|
|
42
40
|
}
|
|
43
41
|
|
|
44
|
-
async getSpotMarkets(): Promise<GetSpotMarketsResult> {
|
|
45
|
-
const uri = '/api/spot-markets';
|
|
46
|
-
return this.get(uri);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
42
|
async getMarket(params: GetMarketParams): Promise<GetMarketResult> {
|
|
50
43
|
const uri = `/api/markets/${params.id}`;
|
|
51
44
|
return this.get(uri);
|
|
@@ -83,18 +76,6 @@ export default class MarketsClient extends RestClient {
|
|
|
83
76
|
});
|
|
84
77
|
}
|
|
85
78
|
|
|
86
|
-
async getSpotMarketCandles(
|
|
87
|
-
params: GetSpotCandlesParams,
|
|
88
|
-
): Promise<MarketCandlesResponse> {
|
|
89
|
-
const uri = `/api/spot-markets/candles/${params.marketId}`;
|
|
90
|
-
return this.get(uri, {
|
|
91
|
-
resolution: params.resolution,
|
|
92
|
-
fromISO: params.fromISO,
|
|
93
|
-
toISO: params.toISO,
|
|
94
|
-
limit: params.limit,
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
79
|
async getMarketTradingHistory(
|
|
99
80
|
params: GetMarketTradingHistoryParams,
|
|
100
81
|
): Promise<GetTradingHistoryResult> {
|
|
@@ -3,12 +3,10 @@ import {
|
|
|
3
3
|
MarketEntity,
|
|
4
4
|
TradingHistoryEntity,
|
|
5
5
|
Candle,
|
|
6
|
-
SpotMarketEntity,
|
|
7
6
|
} from '@reyaxyz/common';
|
|
8
7
|
import { FundingRateHistoryGranularity } from '@reyaxyz/common';
|
|
9
8
|
|
|
10
9
|
export type GetMarketsResult = MarketEntity[];
|
|
11
|
-
export type GetSpotMarketsResult = SpotMarketEntity[];
|
|
12
10
|
|
|
13
11
|
export type GetMarketResult = MarketEntity;
|
|
14
12
|
|
|
@@ -28,14 +26,6 @@ export type GetCandlesParams = {
|
|
|
28
26
|
limit?: number | null;
|
|
29
27
|
};
|
|
30
28
|
|
|
31
|
-
export type GetSpotCandlesParams = {
|
|
32
|
-
marketId: SpotMarketEntity['id'];
|
|
33
|
-
resolution: CandlesResolution;
|
|
34
|
-
fromISO?: string | null;
|
|
35
|
-
toISO?: string | null;
|
|
36
|
-
limit?: number | null;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
29
|
export type GetMarketTradingHistoryParams = {
|
|
40
30
|
marketId: number;
|
|
41
31
|
limit?: number;
|
|
@@ -20,7 +20,6 @@ export enum SocketChannels {
|
|
|
20
20
|
PRICES = 'prices',
|
|
21
21
|
FUNDING_RATES = 'funding-rates',
|
|
22
22
|
MARKETS_UPDATES = 'markets-updates',
|
|
23
|
-
SPOT_CANDLES = 'spot-candles',
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
export enum IncomingMessageTypes {
|
|
@@ -246,18 +245,6 @@ export class SocketClient {
|
|
|
246
245
|
this.subscribe(channel, params);
|
|
247
246
|
}
|
|
248
247
|
|
|
249
|
-
subscribeToSpotCandles(
|
|
250
|
-
marketTicker: string,
|
|
251
|
-
resolution: CandlesResolution,
|
|
252
|
-
): void {
|
|
253
|
-
const channel = SocketChannels.SPOT_CANDLES;
|
|
254
|
-
const params = {
|
|
255
|
-
id: `${marketTicker}/${resolution}`,
|
|
256
|
-
batched: true,
|
|
257
|
-
};
|
|
258
|
-
this.subscribe(channel, params);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
248
|
/**
|
|
262
249
|
* @description Unsubscribe from candles channel
|
|
263
250
|
* for a specific market and resolution.
|
|
@@ -270,17 +257,6 @@ export class SocketClient {
|
|
|
270
257
|
this.unsubscribe(channel, params);
|
|
271
258
|
}
|
|
272
259
|
|
|
273
|
-
unsubscribeFromSpotCandles(
|
|
274
|
-
market: string,
|
|
275
|
-
resolution: CandlesResolution,
|
|
276
|
-
): void {
|
|
277
|
-
const channel = SocketChannels.SPOT_CANDLES;
|
|
278
|
-
const params = {
|
|
279
|
-
id: `${market}/${resolution}`,
|
|
280
|
-
};
|
|
281
|
-
this.unsubscribe(channel, params);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
260
|
/**
|
|
285
261
|
* @description Subscribe to prices channel
|
|
286
262
|
* for a specific assets pair.
|