@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.
- package/dist/clients/modules/account.js +11 -26
- package/dist/clients/modules/account.js.map +1 -1
- package/dist/clients/types.js.map +1 -1
- package/dist/types/clients/modules/account.d.ts +9 -24
- package/dist/types/clients/modules/account.d.ts.map +1 -1
- package/dist/types/clients/types.d.ts +22 -30
- package/dist/types/clients/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/clients/modules/account.ts +16 -32
- package/src/clients/types.ts +25 -34
|
@@ -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 {
|
|
71
|
-
* @
|
|
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
|
-
|
|
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 {
|
|
101
|
-
* @
|
|
102
|
-
*
|
|
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 (
|
|
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(
|
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
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
|
|
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 {
|
|
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 {
|
|
12
|
-
* @
|
|
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
|
-
|
|
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 {
|
|
34
|
-
* @
|
|
35
|
-
*
|
|
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(
|
|
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,
|
|
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,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB,EAAE,MAAM,CAAC;IAC7B,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAID,MAAM,MAAM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OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;KACrB,EAAE,CAAC;CACL,CAAC;AAEF,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,KAAK,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;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.
|
|
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": "
|
|
39
|
+
"gitHead": "0a81b19c8d03ac890f08059f697aa4d907ad39e0"
|
|
40
40
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
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 {
|
|
16
|
-
* @
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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 {
|
|
46
|
-
* @
|
|
47
|
-
*
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
}
|
package/src/clients/types.ts
CHANGED
|
@@ -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;
|