@reyaxyz/api-sdk 0.6.4 → 0.8.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.
@@ -67,27 +67,17 @@ var AccountClient = /** @class */ (function (_super) {
67
67
  * based on the provided Ethereum address. An optional limit can be specified to control the number of
68
68
  * collateral accounts returned in the response.
69
69
  *
70
- * @param {string} address - The Ethereum address for which collateral account data is being requested.
71
- * @param {number} [limit] - An optional limit on the number of collateral accounts to retrieve. If not specified,
72
- * all available collateral accounts for the address will be returned.
73
- * @returns {Promise<CollateralAccountListResponse>} A promise that resolves to the response containing the collateral
70
+ * @param {GetMarginAccountsParams} params
71
+ * @returns {Promise<MarginAccountEntity[]>} A promise that resolves to the response containing the margin
74
72
  * account data.
75
73
  * @memberof account
76
- *
77
- * @example
78
- * // Fetch all collateral accounts for a specific address
79
- * const accounts = await account.getCollateralAccounts('0x123...');
80
- *
81
- * @example
82
- * // Fetch a limited number of collateral accounts for a specific address
83
- * const limitedAccounts = await account.getCollateralAccounts('0x123...', 5);
84
- */
85
- AccountClient.prototype.getCollateralAccounts = function (address, limit) {
74
+ * */
75
+ AccountClient.prototype.getMarginAccounts = function (params) {
86
76
  return __awaiter(this, void 0, void 0, function () {
87
77
  var uri;
88
78
  return __generator(this, function (_a) {
89
- uri = "/api/accounts/".concat(address);
90
- return [2 /*return*/, this.get(uri, { limit: limit })];
79
+ uri = "/api/accounts/".concat(params.address);
80
+ return [2 /*return*/, this.get(uri, { limit: params.limit })];
91
81
  });
92
82
  });
93
83
  };
@@ -97,21 +87,16 @@ var AccountClient = /** @class */ (function (_super) {
97
87
  * This method sends a request to the API to obtain detailed information about a specific collateral account
98
88
  * associated with the provided Ethereum address. The account is identified using the collateral account number.
99
89
  *
100
- * @param {string} address - The Ethereum address associated with the collateral account.
101
- * @param {number} collateralAccountNumber - The number identifying the specific collateral account.
102
- * @returns {Promise<CollateralAccountResponse>} A promise that resolves to the response containing the detailed
103
- * information of the specified collateral account.
90
+ * @param {GetMarginAccountParams} params
91
+ * @returns {Promise<MarginAccountEntity>} A promise that resolves to the response containing the detailed
92
+ * information of the specified margin account.
104
93
  * @memberof account
105
- *
106
- * @example
107
- * // Fetch details of a specific collateral account by its number for a given address
108
- * const accountDetails = await account.getCollateralAccount('0x123...', 1);
109
94
  */
110
- AccountClient.prototype.getCollateralAccount = function (address, collateralAccountNumber) {
95
+ AccountClient.prototype.getCollateralAccount = function (params) {
111
96
  return __awaiter(this, void 0, void 0, function () {
112
97
  var uri;
113
98
  return __generator(this, function (_a) {
114
- uri = "/api/accounts/".concat(address, "/collateralAccount/").concat(collateralAccountNumber);
99
+ uri = "/api/accounts/".concat(params.address, "/collateralAccount/").concat(params.marginAccountNumber);
115
100
  return [2 /*return*/, this.get(uri)];
116
101
  });
117
102
  });
@@ -1 +1 @@
1
- {"version":3,"file":"account.js","sourceRoot":"/","sources":["clients/modules/account.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,gDAAgC;AAEhC;IAA2C,iCAAU;IAArD;;IAwDA,CAAC;IAvDC;;;;;;;;;;;;;;;;;;;;;OAqBG;IAEG,6CAAqB,GAA3B,UACE,OAAe,EACf,KAAc;;;;gBAER,GAAG,GAAG,wBAAiB,OAAO,CAAE,CAAC;gBACvC,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,OAAA,EAAE,CAAC,EAAC;;;KACjC;IAED;;;;;;;;;;;;;;;OAeG;IAEG,4CAAoB,GAA1B,UACE,OAAe,EACf,uBAA+B;;;;gBAEzB,GAAG,GAAG,wBAAiB,OAAO,gCAAsB,uBAAuB,CAAE,CAAC;gBACpF,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IACH,oBAAC;AAAD,CAAC,AAxDD,CAA2C,cAAU,GAwDpD","sourcesContent":["import {\n CollateralAccountListResponse,\n CollateralAccountResponse,\n} from '../types';\nimport RestClient from './rest';\n\nexport default class AccountClient extends RestClient {\n /**\n * Asynchronously retrieves a list of collateral 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 {string} address - The Ethereum address for which collateral account data is being requested.\n * @param {number} [limit] - An optional limit on the number of collateral accounts to retrieve. If not specified,\n * all available collateral accounts for the address will be returned.\n * @returns {Promise<CollateralAccountListResponse>} A promise that resolves to the response containing the collateral\n * account data.\n * @memberof account\n *\n * @example\n * // Fetch all collateral accounts for a specific address\n * const accounts = await account.getCollateralAccounts('0x123...');\n *\n * @example\n * // Fetch a limited number of collateral accounts for a specific address\n * const limitedAccounts = await account.getCollateralAccounts('0x123...', 5);\n */\n\n async getCollateralAccounts(\n address: string,\n limit?: number,\n ): Promise<CollateralAccountListResponse> {\n const uri = `/api/accounts/${address}`;\n return this.get(uri, { limit });\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 {string} address - The Ethereum address associated with the collateral account.\n * @param {number} collateralAccountNumber - The number identifying the specific collateral account.\n * @returns {Promise<CollateralAccountResponse>} A promise that resolves to the response containing the detailed\n * information of the specified collateral account.\n * @memberof account\n *\n * @example\n * // Fetch details of a specific collateral account by its number for a given address\n * const accountDetails = await account.getCollateralAccount('0x123...', 1);\n */\n\n async getCollateralAccount(\n address: string,\n collateralAccountNumber: number,\n ): Promise<CollateralAccountResponse> {\n const uri = `/api/accounts/${address}/collateralAccount/${collateralAccountNumber}`;\n return this.get(uri);\n }\n}\n"]}
1
+ {"version":3,"file":"account.js","sourceRoot":"/","sources":["clients/modules/account.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,gDAAgC;AAEhC;IAA2C,iCAAU;IAArD;;IAuCA,CAAC;IAtCC;;;;;;;;;;;SAWK;IAEC,yCAAiB,GAAvB,UACE,MAA+B;;;;gBAEzB,GAAG,GAAG,wBAAiB,MAAM,CAAC,OAAO,CAAE,CAAC;gBAC9C,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,EAAC;;;KAC/C;IAED;;;;;;;;;;OAUG;IAEG,4CAAoB,GAA1B,UACE,MAA8B;;;;gBAExB,GAAG,GAAG,wBAAiB,MAAM,CAAC,OAAO,gCAAsB,MAAM,CAAC,mBAAmB,CAAE,CAAC;gBAC9F,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACtB;IACH,oBAAC;AAAD,CAAC,AAvCD,CAA2C,cAAU,GAuCpD","sourcesContent":["import {\n GetMarginAccountParams,\n GetMarginAccountsParams,\n MarginAccountEntity,\n} from '../types';\nimport RestClient from './rest';\n\nexport default class AccountClient extends RestClient {\n /**\n * Asynchronously retrieves a list of collateral 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<MarginAccountEntity[]>} 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<MarginAccountEntity[]> {\n const uri = `/api/accounts/${params.address}`;\n return this.get(uri, { limit: params.limit });\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<MarginAccountEntity>} A promise that resolves to the response containing the detailed\n * information of the specified margin account.\n * @memberof account\n */\n\n async getCollateralAccount(\n params: GetMarginAccountParams,\n ): Promise<MarginAccountEntity> {\n const uri = `/api/accounts/${params.address}/collateralAccount/${params.marginAccountNumber}`;\n return this.get(uri);\n }\n}\n"]}
@@ -66,7 +66,7 @@ var MarketsClient = /** @class */ (function (_super) {
66
66
  * This method makes a request to the API to fetch data for markets. If a specific market is provided as a parameter,
67
67
  * it fetches data for that particular market; otherwise, it fetches data for all available markets.
68
68
  *
69
- * @param {GetMarketsParams} [getMarketsParams] - The specific market ticker identifier for which data is requested. This parameter is optional.
69
+ * @param {GetMarketsParams} [params] - The specific market ticker identifier for which data is requested. This parameter is optional.
70
70
  * @returns {Promise<MarketEntity[]>} A promise that resolves to the response containing market data.
71
71
  * @memberof MarketsClient
72
72
  *
@@ -78,12 +78,12 @@ var MarketsClient = /** @class */ (function (_super) {
78
78
  * // Fetch data for a specific market
79
79
  * const specificMarketData = await market.getMarkets('ETH-USDC');
80
80
  */
81
- MarketsClient.prototype.getMarkets = function (getMarketsParams) {
81
+ MarketsClient.prototype.getMarkets = function (params) {
82
82
  return __awaiter(this, void 0, void 0, function () {
83
83
  var uri;
84
84
  return __generator(this, function (_a) {
85
85
  uri = '/api/markets';
86
- return [2 /*return*/, this.get(uri, { id: getMarketsParams.id })];
86
+ return [2 /*return*/, this.get(uri, { id: params.id })];
87
87
  });
88
88
  });
89
89
  };
@@ -1 +1 @@
1
- {"version":3,"file":"markets.js","sourceRoot":"/","sources":["clients/modules/markets.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,gDAAgC;AAEhC;IAA2C,iCAAU;IAArD;;IAsEA,CAAC;IArEC;;;;;;;;;;;;;;;;;OAiBG;IAEG,kCAAU,GAAhB,UACE,gBAAkC;;;;gBAE5B,GAAG,GAAG,cAAc,CAAC;gBAC3B,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,gBAAgB,CAAC,EAAE,EAAE,CAAC,EAAC;;;KACnD;IAED;;;;;;;;;;;;;;;;OAgBG;IAEG,wCAAgB,GAAtB,UACE,QAA4B,EAC5B,UAA6B,EAC7B,OAAuB,EACvB,KAAqB,EACrB,KAAqB;;;;gBAEf,GAAG,GAAG,+BAAwB,QAAQ,CAAE,CAAC;gBAC/C,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,UAAU,YAAA;wBACV,OAAO,SAAA;wBACP,KAAK,OAAA;wBACL,KAAK,OAAA;qBACN,CAAC,EAAC;;;KACJ;IAEK,gDAAwB,GAA9B,UACE,QAAgB,EAChB,KAAqB;;;;gBAEf,GAAG,GAAG,sBAAe,QAAQ,CAAE,CAAC;gBACtC,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,KAAK,OAAA;qBACN,CAAC,EAAC;;;KACJ;IACH,oBAAC;AAAD,CAAC,AAtED,CAA2C,cAAU,GAsEpD","sourcesContent":["import {\n CandlesResolution,\n GetMarketsParams,\n MarketCandlesResponse,\n MarketEntity,\n TradesResponse,\n} from '../types';\nimport RestClient from './rest';\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 * @param {GetMarketsParams} [getMarketsParams] - The specific market ticker identifier for which data is requested. This parameter is optional.\n * @returns {Promise<MarketEntity[]>} 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(\n getMarketsParams: GetMarketsParams,\n ): Promise<MarketEntity[]> {\n const uri = '/api/markets';\n return this.get(uri, { id: getMarketsParams.id });\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 {number} marketId - The market identifier for which candlestick data is to be retrieved.\n * @param {CandlesResolution} resolution - The granularity of the candlestick data (e.g., '1MIN', '5MIN', '1HR').\n * @param {string|null} [fromISO] - The start time for the range of candlestick data in ISO 8601 format. Optional.\n * @param {string|null} [toISO] - The end time for the range of candlestick data in ISO 8601 format. Optional.\n * @param {number|null} [limit] - The maximum number of candlestick data points to retrieve. Optional.\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 marketId: MarketEntity['id'],\n resolution: CandlesResolution,\n fromISO?: string | null,\n toISO?: string | null,\n limit?: number | null,\n ): Promise<MarketCandlesResponse> {\n const uri = `/api/markets/candles/${marketId}`;\n return this.get(uri, {\n resolution,\n fromISO,\n toISO,\n limit,\n });\n }\n\n async getPerpetualMarketTrades(\n marketId: number,\n limit?: number | null,\n ): Promise<TradesResponse> {\n const uri = `/api/trades/${marketId}`;\n return this.get(uri, {\n limit,\n });\n }\n}\n"]}
1
+ {"version":3,"file":"markets.js","sourceRoot":"/","sources":["clients/modules/markets.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,gDAAgC;AAEhC;IAA2C,iCAAU;IAArD;;IAoEA,CAAC;IAnEC;;;;;;;;;;;;;;;;;OAiBG;IAEG,kCAAU,GAAhB,UAAiB,MAAwB;;;;gBACjC,GAAG,GAAG,cAAc,CAAC;gBAC3B,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,EAAC;;;KACzC;IAED;;;;;;;;;;;;;;;;OAgBG;IAEG,wCAAgB,GAAtB,UACE,QAA4B,EAC5B,UAA6B,EAC7B,OAAuB,EACvB,KAAqB,EACrB,KAAqB;;;;gBAEf,GAAG,GAAG,+BAAwB,QAAQ,CAAE,CAAC;gBAC/C,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,UAAU,YAAA;wBACV,OAAO,SAAA;wBACP,KAAK,OAAA;wBACL,KAAK,OAAA;qBACN,CAAC,EAAC;;;KACJ;IAEK,gDAAwB,GAA9B,UACE,QAAgB,EAChB,KAAqB;;;;gBAEf,GAAG,GAAG,sBAAe,QAAQ,CAAE,CAAC;gBACtC,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,KAAK,OAAA;qBACN,CAAC,EAAC;;;KACJ;IACH,oBAAC;AAAD,CAAC,AApED,CAA2C,cAAU,GAoEpD","sourcesContent":["import {\n CandlesResolution,\n GetMarketsParams,\n MarketCandlesResponse,\n MarketEntity,\n TradesResponse,\n} from '../types';\nimport RestClient from './rest';\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 * @param {GetMarketsParams} [params] - The specific market ticker identifier for which data is requested. This parameter is optional.\n * @returns {Promise<MarketEntity[]>} 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(params: GetMarketsParams): Promise<MarketEntity[]> {\n const uri = '/api/markets';\n return this.get(uri, { id: params.id });\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 {number} marketId - The market identifier for which candlestick data is to be retrieved.\n * @param {CandlesResolution} resolution - The granularity of the candlestick data (e.g., '1MIN', '5MIN', '1HR').\n * @param {string|null} [fromISO] - The start time for the range of candlestick data in ISO 8601 format. Optional.\n * @param {string|null} [toISO] - The end time for the range of candlestick data in ISO 8601 format. Optional.\n * @param {number|null} [limit] - The maximum number of candlestick data points to retrieve. Optional.\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 marketId: MarketEntity['id'],\n resolution: CandlesResolution,\n fromISO?: string | null,\n toISO?: string | null,\n limit?: number | null,\n ): Promise<MarketCandlesResponse> {\n const uri = `/api/markets/candles/${marketId}`;\n return this.get(uri, {\n resolution,\n fromISO,\n toISO,\n limit,\n });\n }\n\n async getPerpetualMarketTrades(\n marketId: number,\n limit?: number | null,\n ): Promise<TradesResponse> {\n const uri = `/api/trades/${marketId}`;\n return this.get(uri, {\n limit,\n });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":";;;AAAA,IAAY,iBAQX;AARD,WAAY,iBAAiB;IAC3B,wCAAmB,CAAA;IACnB,2CAAsB,CAAA;IACtB,+CAA0B,CAAA;IAC1B,8CAAyB,CAAA;IACzB,uCAAkB,CAAA;IAClB,0CAAqB,CAAA;IACrB,qCAAgB,CAAA;AAClB,CAAC,EARW,iBAAiB,iCAAjB,iBAAiB,QAQ5B","sourcesContent":["export enum CandlesResolution {\n ONE_MINUTE = '1MIN',\n FIVE_MINUTES = '5MINS',\n FIFTEEN_MINUTES = '15MINS',\n THIRTY_MINUTES = '30MINS',\n ONE_HOUR = '1HOUR',\n FOUR_HOURS = '4HOURS',\n ONE_DAY = '1DAY',\n}\n\n// -- Candles --\nexport interface Candle {\n startedAt: string;\n ticker: string;\n resolution: CandlesResolution;\n low: string;\n high: string;\n open: string;\n close: string;\n baseTokenVolume: string;\n usdVolume: string;\n trades: number;\n startingOpenInterest: string;\n id: string;\n}\n\nexport interface MarketCandlesResponse {\n candles: Candle[];\n}\n\n// -- Markets --\n\nexport type MarketEntity = {\n id: number;\n ticker: string;\n underlyingAsset: string;\n quoteToken: string;\n markPrice: number;\n isActive: boolean;\n maxLeverage: number;\n volume24H: number;\n priceChange24H: number;\n priceChange24HPercentage: number;\n openInterest: number;\n fundingRate: number;\n description: string;\n tickSizeDecimals: number;\n};\n\nexport type GetMarketsParams = {\n id?: number;\n};\n// -- Account --\n\nexport interface CollateralAccount {\n id: number;\n name: string;\n equity: number;\n balance: number;\n marginRatio: string;\n collaterals: Collateral[];\n positions: Position[];\n}\n\nexport interface Collateral {\n collateralAsset: string;\n balance: number;\n availableBalance: number;\n withdrawableBalance: number;\n collateralValue: number;\n}\n\nexport type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';\nexport type Side = 'LONG' | 'SHORT';\n\nexport interface Position {\n id: number;\n symbol: string;\n side: Side;\n size: number;\n price: number;\n orderStatus: Status;\n markPrice: number;\n unrealisedPnl: number;\n realisedPnl: number;\n liquidationPrice: number;\n fundingRate: string;\n date: string;\n}\n\nexport interface CollateralAccountListResponse {\n address: string;\n collateralAccounts: CollateralAccount[];\n}\n\nexport interface CollateralAccountResponse {\n address: string;\n id: number;\n name: string;\n equity: number;\n balance: number;\n marginRatio: string;\n collaterals: Collateral[];\n positions: Position[];\n}\n\nexport type Trade = {\n id: number;\n side: Side;\n size: string;\n price: number;\n date: string;\n txId: string;\n};\n\nexport type TradesResponse = {\n trades: Trade[];\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":";;;AAAA,IAAY,iBAQX;AARD,WAAY,iBAAiB;IAC3B,wCAAmB,CAAA;IACnB,2CAAsB,CAAA;IACtB,+CAA0B,CAAA;IAC1B,8CAAyB,CAAA;IACzB,uCAAkB,CAAA;IAClB,0CAAqB,CAAA;IACrB,qCAAgB,CAAA;AAClB,CAAC,EARW,iBAAiB,iCAAjB,iBAAiB,QAQ5B","sourcesContent":["export enum CandlesResolution {\n ONE_MINUTE = '1MIN',\n FIVE_MINUTES = '5MINS',\n FIFTEEN_MINUTES = '15MINS',\n THIRTY_MINUTES = '30MINS',\n ONE_HOUR = '1HOUR',\n FOUR_HOURS = '4HOURS',\n ONE_DAY = '1DAY',\n}\n\n// -- Candles --\nexport interface Candle {\n startedAt: string;\n ticker: string;\n resolution: CandlesResolution;\n low: string;\n high: string;\n open: string;\n close: string;\n baseTokenVolume: string;\n usdVolume: string;\n trades: number;\n startingOpenInterest: string;\n id: string;\n}\n\nexport interface MarketCandlesResponse {\n candles: Candle[];\n}\n\n// -- Markets --\n\nexport type MarketEntity = {\n id: number;\n ticker: string;\n underlyingAsset: string;\n quoteToken: string;\n markPrice: number;\n isActive: boolean;\n maxLeverage: number;\n volume24H: number;\n priceChange24H: number;\n priceChange24HPercentage: number;\n openInterest: number;\n fundingRate: number;\n description: string;\n tickSizeDecimals: number;\n};\n\nexport type GetMarketsParams = {\n id?: number;\n};\n// -- Account --\n\nexport type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';\nexport type Side = 'LONG' | 'SHORT';\n\nexport type GetMarginAccountsParams = {\n address: string;\n limit?: number;\n};\n\nexport type GetMarginAccountParams = {\n address: string;\n marginAccountNumber: number;\n};\n\nexport type MarginAccountEntity = {\n id: number;\n name: string;\n marginRatioHealth: 'danger' | 'healthy' | 'warning';\n marginRatioPercentage: number;\n totalBalance: number;\n totalBalanceUnderlyingAsset: string;\n collaterals: {\n token: string;\n percentage: number;\n balance: number;\n balanceRUSD: number;\n }[];\n};\n\nexport interface Position {\n id: number;\n symbol: string;\n side: Side;\n size: number;\n price: number;\n orderStatus: Status;\n markPrice: number;\n unrealisedPnl: number;\n realisedPnl: number;\n liquidationPrice: number;\n fundingRate: string;\n date: string;\n}\n\nexport type Trade = {\n id: number;\n side: Side;\n size: string;\n price: number;\n date: string;\n txId: string;\n};\n\nexport type TradesResponse = {\n trades: Trade[];\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { CollateralAccountListResponse, CollateralAccountResponse } from '../types';
1
+ import { GetMarginAccountParams, GetMarginAccountsParams, MarginAccountEntity } from '../types';
2
2
  import RestClient from './rest';
3
3
  export default class AccountClient extends RestClient {
4
4
  /**
@@ -8,38 +8,23 @@ export default class AccountClient extends RestClient {
8
8
  * based on the provided Ethereum address. An optional limit can be specified to control the number of
9
9
  * collateral accounts returned in the response.
10
10
  *
11
- * @param {string} address - The Ethereum address for which collateral account data is being requested.
12
- * @param {number} [limit] - An optional limit on the number of collateral accounts to retrieve. If not specified,
13
- * all available collateral accounts for the address will be returned.
14
- * @returns {Promise<CollateralAccountListResponse>} A promise that resolves to the response containing the collateral
11
+ * @param {GetMarginAccountsParams} params
12
+ * @returns {Promise<MarginAccountEntity[]>} A promise that resolves to the response containing the margin
15
13
  * account data.
16
14
  * @memberof account
17
- *
18
- * @example
19
- * // Fetch all collateral accounts for a specific address
20
- * const accounts = await account.getCollateralAccounts('0x123...');
21
- *
22
- * @example
23
- * // Fetch a limited number of collateral accounts for a specific address
24
- * const limitedAccounts = await account.getCollateralAccounts('0x123...', 5);
25
- */
26
- getCollateralAccounts(address: string, limit?: number): Promise<CollateralAccountListResponse>;
15
+ * */
16
+ getMarginAccounts(params: GetMarginAccountsParams): Promise<MarginAccountEntity[]>;
27
17
  /**
28
18
  * Asynchronously retrieves details of a specific collateral account for a given Ethereum address.
29
19
  *
30
20
  * This method sends a request to the API to obtain detailed information about a specific collateral account
31
21
  * associated with the provided Ethereum address. The account is identified using the collateral account number.
32
22
  *
33
- * @param {string} address - The Ethereum address associated with the collateral account.
34
- * @param {number} collateralAccountNumber - The number identifying the specific collateral account.
35
- * @returns {Promise<CollateralAccountResponse>} A promise that resolves to the response containing the detailed
36
- * information of the specified collateral account.
23
+ * @param {GetMarginAccountParams} params
24
+ * @returns {Promise<MarginAccountEntity>} A promise that resolves to the response containing the detailed
25
+ * information of the specified margin account.
37
26
  * @memberof account
38
- *
39
- * @example
40
- * // Fetch details of a specific collateral account by its number for a given address
41
- * const accountDetails = await account.getCollateralAccount('0x123...', 1);
42
27
  */
43
- getCollateralAccount(address: string, collateralAccountNumber: number): Promise<CollateralAccountResponse>;
28
+ getCollateralAccount(params: GetMarginAccountParams): Promise<MarginAccountEntity>;
44
29
  }
45
30
  //# sourceMappingURL=account.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"account.d.ts","sourceRoot":"/","sources":["clients/modules/account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,yBAAyB,EAC1B,MAAM,UAAU,CAAC;AAClB,OAAO,UAAU,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD;;;;;;;;;;;;;;;;;;;;;OAqBG;IAEG,qBAAqB,CACzB,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,6BAA6B,CAAC;IAKzC;;;;;;;;;;;;;;;OAeG;IAEG,oBAAoB,CACxB,OAAO,EAAE,MAAM,EACf,uBAAuB,EAAE,MAAM,GAC9B,OAAO,CAAC,yBAAyB,CAAC;CAItC"}
1
+ {"version":3,"file":"account.d.ts","sourceRoot":"/","sources":["clients/modules/account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAClB,OAAO,UAAU,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD;;;;;;;;;;;SAWK;IAEC,iBAAiB,CACrB,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAKjC;;;;;;;;;;OAUG;IAEG,oBAAoB,CACxB,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,mBAAmB,CAAC;CAIhC"}
@@ -7,7 +7,7 @@ export default class MarketsClient extends RestClient {
7
7
  * This method makes a request to the API to fetch data for markets. If a specific market is provided as a parameter,
8
8
  * it fetches data for that particular market; otherwise, it fetches data for all available markets.
9
9
  *
10
- * @param {GetMarketsParams} [getMarketsParams] - The specific market ticker identifier for which data is requested. This parameter is optional.
10
+ * @param {GetMarketsParams} [params] - The specific market ticker identifier for which data is requested. This parameter is optional.
11
11
  * @returns {Promise<MarketEntity[]>} A promise that resolves to the response containing market data.
12
12
  * @memberof MarketsClient
13
13
  *
@@ -19,7 +19,7 @@ export default class MarketsClient extends RestClient {
19
19
  * // Fetch data for a specific market
20
20
  * const specificMarketData = await market.getMarkets('ETH-USDC');
21
21
  */
22
- getMarkets(getMarketsParams: GetMarketsParams): Promise<MarketEntity[]>;
22
+ getMarkets(params: GetMarketsParams): Promise<MarketEntity[]>;
23
23
  /**
24
24
  * Retrieves candlestick data for a specified market.
25
25
  *
@@ -1 +1 @@
1
- {"version":3,"file":"markets.d.ts","sourceRoot":"/","sources":["clients/modules/markets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACf,MAAM,UAAU,CAAC;AAClB,OAAO,UAAU,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD;;;;;;;;;;;;;;;;;OAiBG;IAEG,UAAU,CACd,gBAAgB,EAAE,gBAAgB,GACjC,OAAO,CAAC,YAAY,EAAE,CAAC;IAK1B;;;;;;;;;;;;;;;;OAgBG;IAEG,gBAAgB,CACpB,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,EAC5B,UAAU,EAAE,iBAAiB,EAC7B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,EACvB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,EACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GACpB,OAAO,CAAC,qBAAqB,CAAC;IAU3B,wBAAwB,CAC5B,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GACpB,OAAO,CAAC,cAAc,CAAC;CAM3B"}
1
+ {"version":3,"file":"markets.d.ts","sourceRoot":"/","sources":["clients/modules/markets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACf,MAAM,UAAU,CAAC;AAClB,OAAO,UAAU,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD;;;;;;;;;;;;;;;;;OAiBG;IAEG,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAKnE;;;;;;;;;;;;;;;;OAgBG;IAEG,gBAAgB,CACpB,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,EAC5B,UAAU,EAAE,iBAAiB,EAC7B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,EACvB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,EACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GACpB,OAAO,CAAC,qBAAqB,CAAC;IAU3B,wBAAwB,CAC5B,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GACpB,OAAO,CAAC,cAAc,CAAC;CAM3B"}
@@ -43,24 +43,30 @@ export type MarketEntity = {
43
43
  export type GetMarketsParams = {
44
44
  id?: number;
45
45
  };
46
- export interface CollateralAccount {
47
- id: number;
48
- name: string;
49
- equity: number;
50
- balance: number;
51
- marginRatio: string;
52
- collaterals: Collateral[];
53
- positions: Position[];
54
- }
55
- export interface Collateral {
56
- collateralAsset: string;
57
- balance: number;
58
- availableBalance: number;
59
- withdrawableBalance: number;
60
- collateralValue: number;
61
- }
62
46
  export type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';
63
47
  export type Side = 'LONG' | 'SHORT';
48
+ export type GetMarginAccountsParams = {
49
+ address: string;
50
+ limit?: number;
51
+ };
52
+ export type GetMarginAccountParams = {
53
+ address: string;
54
+ marginAccountNumber: number;
55
+ };
56
+ export type MarginAccountEntity = {
57
+ id: number;
58
+ name: string;
59
+ marginRatioHealth: 'danger' | 'healthy' | 'warning';
60
+ marginRatioPercentage: number;
61
+ totalBalance: number;
62
+ totalBalanceUnderlyingAsset: string;
63
+ collaterals: {
64
+ token: string;
65
+ percentage: number;
66
+ balance: number;
67
+ balanceRUSD: number;
68
+ }[];
69
+ };
64
70
  export interface Position {
65
71
  id: number;
66
72
  symbol: string;
@@ -75,20 +81,6 @@ export interface Position {
75
81
  fundingRate: string;
76
82
  date: string;
77
83
  }
78
- export interface CollateralAccountListResponse {
79
- address: string;
80
- collateralAccounts: CollateralAccount[];
81
- }
82
- export interface CollateralAccountResponse {
83
- address: string;
84
- id: number;
85
- name: string;
86
- equity: number;
87
- balance: number;
88
- marginRatio: string;
89
- collaterals: Collateral[];
90
- positions: Position[];
91
- }
92
84
  export type Trade = {
93
85
  id: number;
94
86
  side: Side;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB;IAC3B,UAAU,SAAS;IACnB,YAAY,UAAU;IACtB,eAAe,WAAW;IAC1B,cAAc,WAAW;IACzB,QAAQ,UAAU;IAClB,UAAU,WAAW;IACrB,OAAO,SAAS;CACjB;AAGD,MAAM,WAAW,MAAM;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,iBAAiB,CAAC;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IAC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,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/api-sdk",
3
- "version": "0.6.4",
3
+ "version": "0.8.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -36,5 +36,5 @@
36
36
  "axios": "^1.6.2"
37
37
  },
38
38
  "packageManager": "pnpm@8.10.4",
39
- "gitHead": "dba265659591bc135dc84f4c799fb8e9d19af3b4"
39
+ "gitHead": "f762d6bc89fe5866fc0f22e21c4c804dc6147f08"
40
40
  }
@@ -1,6 +1,7 @@
1
1
  import {
2
- CollateralAccountListResponse,
3
- CollateralAccountResponse,
2
+ GetMarginAccountParams,
3
+ GetMarginAccountsParams,
4
+ MarginAccountEntity,
4
5
  } from '../types';
5
6
  import RestClient from './rest';
6
7
 
@@ -12,28 +13,17 @@ export default class AccountClient extends RestClient {
12
13
  * based on the provided Ethereum address. An optional limit can be specified to control the number of
13
14
  * collateral accounts returned in the response.
14
15
  *
15
- * @param {string} address - The Ethereum address for which collateral account data is being requested.
16
- * @param {number} [limit] - An optional limit on the number of collateral accounts to retrieve. If not specified,
17
- * all available collateral accounts for the address will be returned.
18
- * @returns {Promise<CollateralAccountListResponse>} A promise that resolves to the response containing the collateral
16
+ * @param {GetMarginAccountsParams} params
17
+ * @returns {Promise<MarginAccountEntity[]>} A promise that resolves to the response containing the margin
19
18
  * account data.
20
19
  * @memberof account
21
- *
22
- * @example
23
- * // Fetch all collateral accounts for a specific address
24
- * const accounts = await account.getCollateralAccounts('0x123...');
25
- *
26
- * @example
27
- * // Fetch a limited number of collateral accounts for a specific address
28
- * const limitedAccounts = await account.getCollateralAccounts('0x123...', 5);
29
- */
20
+ * */
30
21
 
31
- async getCollateralAccounts(
32
- address: string,
33
- limit?: number,
34
- ): Promise<CollateralAccountListResponse> {
35
- const uri = `/api/accounts/${address}`;
36
- return this.get(uri, { limit });
22
+ async getMarginAccounts(
23
+ params: GetMarginAccountsParams,
24
+ ): Promise<MarginAccountEntity[]> {
25
+ const uri = `/api/accounts/${params.address}`;
26
+ return this.get(uri, { limit: params.limit });
37
27
  }
38
28
 
39
29
  /**
@@ -42,22 +32,16 @@ export default class AccountClient extends RestClient {
42
32
  * This method sends a request to the API to obtain detailed information about a specific collateral account
43
33
  * associated with the provided Ethereum address. The account is identified using the collateral account number.
44
34
  *
45
- * @param {string} address - The Ethereum address associated with the collateral account.
46
- * @param {number} collateralAccountNumber - The number identifying the specific collateral account.
47
- * @returns {Promise<CollateralAccountResponse>} A promise that resolves to the response containing the detailed
48
- * information of the specified collateral account.
35
+ * @param {GetMarginAccountParams} params
36
+ * @returns {Promise<MarginAccountEntity>} A promise that resolves to the response containing the detailed
37
+ * information of the specified margin account.
49
38
  * @memberof account
50
- *
51
- * @example
52
- * // Fetch details of a specific collateral account by its number for a given address
53
- * const accountDetails = await account.getCollateralAccount('0x123...', 1);
54
39
  */
55
40
 
56
41
  async getCollateralAccount(
57
- address: string,
58
- collateralAccountNumber: number,
59
- ): Promise<CollateralAccountResponse> {
60
- const uri = `/api/accounts/${address}/collateralAccount/${collateralAccountNumber}`;
42
+ params: GetMarginAccountParams,
43
+ ): Promise<MarginAccountEntity> {
44
+ const uri = `/api/accounts/${params.address}/collateralAccount/${params.marginAccountNumber}`;
61
45
  return this.get(uri);
62
46
  }
63
47
  }
@@ -14,7 +14,7 @@ export default class MarketsClient extends RestClient {
14
14
  * This method makes a request to the API to fetch data for markets. If a specific market is provided as a parameter,
15
15
  * it fetches data for that particular market; otherwise, it fetches data for all available markets.
16
16
  *
17
- * @param {GetMarketsParams} [getMarketsParams] - The specific market ticker identifier for which data is requested. This parameter is optional.
17
+ * @param {GetMarketsParams} [params] - The specific market ticker identifier for which data is requested. This parameter is optional.
18
18
  * @returns {Promise<MarketEntity[]>} A promise that resolves to the response containing market data.
19
19
  * @memberof MarketsClient
20
20
  *
@@ -27,11 +27,9 @@ export default class MarketsClient extends RestClient {
27
27
  * const specificMarketData = await market.getMarkets('ETH-USDC');
28
28
  */
29
29
 
30
- async getMarkets(
31
- getMarketsParams: GetMarketsParams,
32
- ): Promise<MarketEntity[]> {
30
+ async getMarkets(params: GetMarketsParams): Promise<MarketEntity[]> {
33
31
  const uri = '/api/markets';
34
- return this.get(uri, { id: getMarketsParams.id });
32
+ return this.get(uri, { id: params.id });
35
33
  }
36
34
 
37
35
  /**
@@ -52,27 +52,34 @@ export type GetMarketsParams = {
52
52
  };
53
53
  // -- Account --
54
54
 
55
- export interface CollateralAccount {
56
- id: number;
57
- name: string;
58
- equity: number;
59
- balance: number;
60
- marginRatio: string;
61
- collaterals: Collateral[];
62
- positions: Position[];
63
- }
64
-
65
- export interface Collateral {
66
- collateralAsset: string;
67
- balance: number;
68
- availableBalance: number;
69
- withdrawableBalance: number;
70
- collateralValue: number;
71
- }
72
-
73
55
  export type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';
74
56
  export type Side = 'LONG' | 'SHORT';
75
57
 
58
+ export type GetMarginAccountsParams = {
59
+ address: string;
60
+ limit?: number;
61
+ };
62
+
63
+ export type GetMarginAccountParams = {
64
+ address: string;
65
+ marginAccountNumber: number;
66
+ };
67
+
68
+ export type MarginAccountEntity = {
69
+ id: number;
70
+ name: string;
71
+ marginRatioHealth: 'danger' | 'healthy' | 'warning';
72
+ marginRatioPercentage: number;
73
+ totalBalance: number;
74
+ totalBalanceUnderlyingAsset: string;
75
+ collaterals: {
76
+ token: string;
77
+ percentage: number;
78
+ balance: number;
79
+ balanceRUSD: number;
80
+ }[];
81
+ };
82
+
76
83
  export interface Position {
77
84
  id: number;
78
85
  symbol: string;
@@ -88,22 +95,6 @@ export interface Position {
88
95
  date: string;
89
96
  }
90
97
 
91
- export interface CollateralAccountListResponse {
92
- address: string;
93
- collateralAccounts: CollateralAccount[];
94
- }
95
-
96
- export interface CollateralAccountResponse {
97
- address: string;
98
- id: number;
99
- name: string;
100
- equity: number;
101
- balance: number;
102
- marginRatio: string;
103
- collaterals: Collateral[];
104
- positions: Position[];
105
- }
106
-
107
98
  export type Trade = {
108
99
  id: number;
109
100
  side: Side;