@reyaxyz/api-sdk 0.159.0 → 0.160.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.
|
@@ -86,12 +86,6 @@ var AccountClient = /** @class */ (function (_super) {
|
|
|
86
86
|
return {
|
|
87
87
|
id: account.id,
|
|
88
88
|
name: account.name,
|
|
89
|
-
marginRatioHealth: account.marginRatioHealth,
|
|
90
|
-
marginRatioPercentage: account.marginRatioPercentage,
|
|
91
|
-
marginRatioHealthDangerThreshold: account.marginRatioHealthDangerThreshold,
|
|
92
|
-
marginRatioHealthWarningThreshold: account.marginRatioHealthWarningThreshold,
|
|
93
|
-
isApproachingLiquidation: account.isApproachingLiquidation,
|
|
94
|
-
isLiquidationImminent: account.isLiquidationImminent,
|
|
95
89
|
};
|
|
96
90
|
});
|
|
97
91
|
return [2 /*return*/, strippedResponse];
|
|
@@ -123,12 +117,6 @@ var AccountClient = /** @class */ (function (_super) {
|
|
|
123
117
|
strippedResponse = {
|
|
124
118
|
id: response.id,
|
|
125
119
|
name: response.name,
|
|
126
|
-
marginRatioHealth: response.marginRatioHealth,
|
|
127
|
-
marginRatioPercentage: response.marginRatioPercentage,
|
|
128
|
-
marginRatioHealthDangerThreshold: response.marginRatioHealthDangerThreshold,
|
|
129
|
-
marginRatioHealthWarningThreshold: response.marginRatioHealthWarningThreshold,
|
|
130
|
-
isApproachingLiquidation: response.isApproachingLiquidation,
|
|
131
|
-
isLiquidationImminent: response.isLiquidationImminent,
|
|
132
120
|
};
|
|
133
121
|
return [2 /*return*/, strippedResponse];
|
|
134
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/account/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,0CAIyB;AAEzB;IAA2C,iCAAU;IAArD;;IA2LA,CAAC;IA1LC;;;;;;;;;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A2B,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,AA3LD,CAA2C,mBAAU,GA2LpD","sourcesContent":["import {\n GetMarginAccountParams,\n GetMarginAccountResult,\n GetMarginAccountsParams,\n GetMarginAccountsResult,\n GetMarginAccountTransactionHistoryParams,\n GetMarginAccountTransactionHistoryResult,\n GetMaxWithdrawBalanceForAccountParams,\n GetMaxWithdrawBalanceForAccountResult,\n EditMarginAccountParams,\n CloseMarginAccountParams,\n GetEditCollateralSimulationInitialDataParams,\n EditMarginAccountResult,\n CloseMarginAccountResult,\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 RestClient,\n StrippedMarginAccountEntity,\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 includePositions: false,\n });\n\n const strippedResponse = response.map(\n (account): StrippedMarginAccountEntity => {\n return {\n id: account.id,\n name: account.name,\n marginRatioHealth: account.marginRatioHealth,\n marginRatioPercentage: account.marginRatioPercentage,\n marginRatioHealthDangerThreshold:\n account.marginRatioHealthDangerThreshold,\n marginRatioHealthWarningThreshold:\n account.marginRatioHealthWarningThreshold,\n isApproachingLiquidation: account.isApproachingLiquidation,\n isLiquidationImminent: account.isLiquidationImminent,\n };\n },\n );\n\n return strippedResponse;\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 const response: GetMarginAccountResult = await this.get(uri);\n\n const strippedResponse = {\n id: response.id,\n name: response.name,\n marginRatioHealth: response.marginRatioHealth,\n marginRatioPercentage: response.marginRatioPercentage,\n marginRatioHealthDangerThreshold:\n response.marginRatioHealthDangerThreshold,\n marginRatioHealthWarningThreshold:\n response.marginRatioHealthWarningThreshold,\n isApproachingLiquidation: response.isApproachingLiquidation,\n isLiquidationImminent: response.isLiquidationImminent,\n };\n\n return strippedResponse;\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 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 // 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,0CAIyB;AAEzB;IAA2C,iCAAU;IAArD;;IA2KA,CAAC;IA1KC;;;;;;;;;;;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;gCACnB,gBAAg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MarginAccountsParams,\n GetMarginAccountsResult,\n GetMarginAccountTransactionHistoryParams,\n GetMarginAccountTransactionHistoryResult,\n GetMaxWithdrawBalanceForAccountParams,\n GetMaxWithdrawBalanceForAccountResult,\n EditMarginAccountParams,\n CloseMarginAccountParams,\n GetEditCollateralSimulationInitialDataParams,\n EditMarginAccountResult,\n CloseMarginAccountResult,\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 RestClient,\n StrippedMarginAccountEntity,\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 includePositions: false,\n });\n\n const strippedResponse = response.map(\n (account): StrippedMarginAccountEntity => {\n return {\n id: account.id,\n name: account.name,\n };\n },\n );\n\n return strippedResponse;\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 const response: GetMarginAccountResult = await this.get(uri);\n\n const strippedResponse = {\n id: response.id,\n name: response.name,\n };\n\n return strippedResponse;\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 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 // 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":"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,qCAAqC,EACrC,qCAAqC,EACrC,uBAAuB,EACvB,wBAAwB,EACxB,4CAA4C,EAC5C,uBAAuB,EACvB,wBAAwB,EACxB,2CAA2C,EAC3C,2CAA2C,EAC3C,0C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0C,GACjD,OAAO,CAAC,0CAA0C,CAAC;IAOhD,qCAAqC,CACzC,MAAM,EAAE,2CAA2C,GAClD,OAAO,CAAC,2CAA2C,CAAC;IAOjD,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;IAQ3C,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/api-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.160.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@reyaxyz/common": "0.
|
|
36
|
+
"@reyaxyz/common": "0.313.0",
|
|
37
37
|
"@simplewebauthn/types": "10.0.0",
|
|
38
38
|
"bignumber.js": "9.1.2",
|
|
39
39
|
"ethers": "6.9.0",
|
|
40
40
|
"isomorphic-ws": "5.0.0"
|
|
41
41
|
},
|
|
42
42
|
"packageManager": "pnpm@8.3.1",
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "249943954846e5be8503d04742c9597d25707dd1",
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@reyaxyz/database": "0.149.
|
|
45
|
+
"@reyaxyz/database": "0.149.8"
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -57,14 +57,6 @@ export default class AccountClient extends RestClient {
|
|
|
57
57
|
return {
|
|
58
58
|
id: account.id,
|
|
59
59
|
name: account.name,
|
|
60
|
-
marginRatioHealth: account.marginRatioHealth,
|
|
61
|
-
marginRatioPercentage: account.marginRatioPercentage,
|
|
62
|
-
marginRatioHealthDangerThreshold:
|
|
63
|
-
account.marginRatioHealthDangerThreshold,
|
|
64
|
-
marginRatioHealthWarningThreshold:
|
|
65
|
-
account.marginRatioHealthWarningThreshold,
|
|
66
|
-
isApproachingLiquidation: account.isApproachingLiquidation,
|
|
67
|
-
isLiquidationImminent: account.isLiquidationImminent,
|
|
68
60
|
};
|
|
69
61
|
},
|
|
70
62
|
);
|
|
@@ -93,14 +85,6 @@ export default class AccountClient extends RestClient {
|
|
|
93
85
|
const strippedResponse = {
|
|
94
86
|
id: response.id,
|
|
95
87
|
name: response.name,
|
|
96
|
-
marginRatioHealth: response.marginRatioHealth,
|
|
97
|
-
marginRatioPercentage: response.marginRatioPercentage,
|
|
98
|
-
marginRatioHealthDangerThreshold:
|
|
99
|
-
response.marginRatioHealthDangerThreshold,
|
|
100
|
-
marginRatioHealthWarningThreshold:
|
|
101
|
-
response.marginRatioHealthWarningThreshold,
|
|
102
|
-
isApproachingLiquidation: response.isApproachingLiquidation,
|
|
103
|
-
isLiquidationImminent: response.isLiquidationImminent,
|
|
104
88
|
};
|
|
105
89
|
|
|
106
90
|
return strippedResponse;
|