@reyaxyz/api-sdk 0.6.4 → 0.7.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} getMarginAccountsParams
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.getCollateralAccounts = function (getMarginAccountsParams) {
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(getMarginAccountsParams.address);
80
+ return [2 /*return*/, this.get(uri, { limit: getMarginAccountsParams.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} getMarginAccountParams
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 (getMarginAccountParams) {
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(getMarginAccountParams.address, "/collateralAccount/").concat(getMarginAccountParams.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,6CAAqB,GAA3B,UACE,uBAAgD;;;;gBAE1C,GAAG,GAAG,wBAAiB,uBAAuB,CAAC,OAAO,CAAE,CAAC;gBAC/D,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,uBAAuB,CAAC,KAAK,EAAE,CAAC,EAAC;;;KAChE;IAED;;;;;;;;;;OAUG;IAEG,4CAAoB,GAA1B,UACE,sBAA8C;;;;gBAExC,GAAG,GAAG,wBAAiB,sBAAsB,CAAC,OAAO,gCAAsB,sBAAsB,CAAC,mBAAmB,CAAE,CAAC;gBAC9H,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} getMarginAccountsParams\n * @returns {Promise<MarginAccountEntity[]>} A promise that resolves to the response containing the margin\n * account data.\n * @memberof account\n * */\n\n async getCollateralAccounts(\n getMarginAccountsParams: GetMarginAccountsParams,\n ): Promise<MarginAccountEntity[]> {\n const uri = `/api/accounts/${getMarginAccountsParams.address}`;\n return this.get(uri, { limit: getMarginAccountsParams.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} getMarginAccountParams\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 getMarginAccountParams: GetMarginAccountParams,\n ): Promise<MarginAccountEntity> {\n const uri = `/api/accounts/${getMarginAccountParams.address}/collateralAccount/${getMarginAccountParams.marginAccountNumber}`;\n return this.get(uri);\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} getMarginAccountsParams
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
+ getCollateralAccounts(getMarginAccountsParams: 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} getMarginAccountParams
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(getMarginAccountParams: 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,qBAAqB,CACzB,uBAAuB,EAAE,uBAAuB,GAC/C,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAKjC;;;;;;;;;;OAUG;IAEG,oBAAoB,CACxB,sBAAsB,EAAE,sBAAsB,GAC7C,OAAO,CAAC,mBAAmB,CAAC;CAIhC"}
@@ -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,E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AC;IACb,KAAK,EAAE,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.7.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": "0a81b19c8d03ac890f08059f697aa4d907ad39e0"
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} getMarginAccountsParams
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
22
  async getCollateralAccounts(
32
- address: string,
33
- limit?: number,
34
- ): Promise<CollateralAccountListResponse> {
35
- const uri = `/api/accounts/${address}`;
36
- return this.get(uri, { limit });
23
+ getMarginAccountsParams: GetMarginAccountsParams,
24
+ ): Promise<MarginAccountEntity[]> {
25
+ const uri = `/api/accounts/${getMarginAccountsParams.address}`;
26
+ return this.get(uri, { limit: getMarginAccountsParams.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} getMarginAccountParams
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
+ getMarginAccountParams: GetMarginAccountParams,
43
+ ): Promise<MarginAccountEntity> {
44
+ const uri = `/api/accounts/${getMarginAccountParams.address}/collateralAccount/${getMarginAccountParams.marginAccountNumber}`;
61
45
  return this.get(uri);
62
46
  }
63
47
  }
@@ -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;