@reyaxyz/api-sdk 0.169.12 → 0.170.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -1
- package/dist/clients/api-client-config.js +5 -13
- package/dist/clients/api-client-config.js.map +1 -1
- package/dist/clients/modules/account/index.js +0 -14
- package/dist/clients/modules/account/index.js.map +1 -1
- package/dist/clients/modules/account/types.js.map +1 -1
- package/dist/types/clients/api-client-config.d.ts +1 -1
- package/dist/types/clients/api-client-config.d.ts.map +1 -1
- package/dist/types/clients/modules/account/index.d.ts +1 -2
- package/dist/types/clients/modules/account/index.d.ts.map +1 -1
- package/dist/types/clients/modules/account/types.d.ts +0 -6
- package/dist/types/clients/modules/account/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/clients/api-client-config.ts +5 -23
- package/src/clients/modules/account/index.ts +0 -14
- package/src/clients/modules/account/types.ts +0 -6
package/README.md
CHANGED
|
@@ -6,5 +6,15 @@
|
|
|
6
6
|
|
|
7
7
|
| Statements | Branches | Functions | Lines |
|
|
8
8
|
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
|
|
9
|
-
|  |  |  |  |
|
|
10
10
|
|
|
11
|
+
## Environments
|
|
12
|
+
|
|
13
|
+
Supported environments are `production`, `staging`, `devnet`, `localmainnet`
|
|
14
|
+
and `localtestnet`. Choose an environment explicitly before using the clients,
|
|
15
|
+
for example `ApiClient.configure('devnet')`.
|
|
16
|
+
|
|
17
|
+
The retired backend's `test` environment is no longer supported. Existing callers
|
|
18
|
+
must choose the intended active environment; unsupported names throw instead of
|
|
19
|
+
falling back or redirecting to another deployment. Devnet1 continues to use the
|
|
20
|
+
live reya-cronos chain (89346162) and its own API and WebSocket endpoints.
|
|
@@ -42,18 +42,7 @@ var getApiClientConfig = function (env) {
|
|
|
42
42
|
timeout: API_TIMEOUT,
|
|
43
43
|
logging: false,
|
|
44
44
|
},
|
|
45
|
-
|
|
46
|
-
chain: 89346162,
|
|
47
|
-
apiEndpoint: getEnvVar('NEXT_PUBLIC_REYA_API_ENDPOINT', 'https://api-cronos.reya.xyz'),
|
|
48
|
-
webSocketEndpoint: getEnvVar('NEXT_PUBLIC_REYA_WEBSOCKET_ENDPOINT', 'wss://websocket-testnet.reya.xyz'),
|
|
49
|
-
environment: getEnvVar('NEXT_PUBLIC_REYA_ENVIRONMENT', 'test'),
|
|
50
|
-
timeout: API_TIMEOUT,
|
|
51
|
-
logging: true,
|
|
52
|
-
},
|
|
53
|
-
// Devnet1 shares the cronos chain (89346162) but has its own
|
|
54
|
-
// sub-deploy at `reya-cronos.network` (distinct from `reya.xyz`).
|
|
55
|
-
// Added so UIs can offer "devnet" as a first-class environment
|
|
56
|
-
// selection rather than overriding `test`'s default endpoint.
|
|
45
|
+
// Devnet1 uses the live reya-cronos chain (89346162).
|
|
57
46
|
devnet: {
|
|
58
47
|
chain: 89346162,
|
|
59
48
|
apiEndpoint: getEnvVar('NEXT_PUBLIC_REYA_API_ENDPOINT', 'https://api-devnet.reya-cronos.network'),
|
|
@@ -63,7 +52,10 @@ var getApiClientConfig = function (env) {
|
|
|
63
52
|
logging: true,
|
|
64
53
|
},
|
|
65
54
|
};
|
|
66
|
-
|
|
55
|
+
if (!Object.prototype.hasOwnProperty.call(configs, env)) {
|
|
56
|
+
throw new Error("Unsupported SDK environment: ".concat(env));
|
|
57
|
+
}
|
|
58
|
+
return configs[env];
|
|
67
59
|
};
|
|
68
60
|
exports.getApiClientConfig = getApiClientConfig;
|
|
69
61
|
//# sourceMappingURL=api-client-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client-config.js","sourceRoot":"/","sources":["clients/api-client-config.ts"],"names":[],"mappings":";;;AAEA,IAAM,WAAW,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"api-client-config.js","sourceRoot":"/","sources":["clients/api-client-config.ts"],"names":[],"mappings":";;;AAEA,IAAM,WAAW,GAAG,KAAK,CAAC;AAkB1B,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QACD,sDAAsD;QACtD,MAAM,EAAE;YACN,KAAK,EAAE,QAAuB;YAC9B,WAAW,EAAE,SAAS,CACpB,+BAA+B,EAC/B,wCAAwC,CACzC;YACD,iBAAiB,EAAE,SAAS,CAC1B,qCAAqC,EACrC,4CAA4C,CAC7C;YACD,WAAW,EAAE,SAAS,CACpB,8BAA8B,EAC9B,QAAQ,CACa;YACvB,OAAO,EAAE,WAAW;YACpB,OAAO,EAAE,IAAI;SACd;KACF,CAAC;IAEF,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;QACxD,MAAM,IAAI,KAAK,CAAC,uCAAgC,GAAG,CAAE,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;AACtB,CAAC,CAAC;AA5EW,QAAA,kBAAkB,sBA4E7B","sourcesContent":["import type { ReyaChainId } from '@reyaxyz/common';\n\nconst API_TIMEOUT = 30000;\n\nexport type ServiceEnvironment =\n | 'production'\n | 'staging'\n | 'devnet'\n | 'localmainnet'\n | 'localtestnet';\n\nexport interface ServiceConfig {\n chain: ReyaChainId;\n apiEndpoint: string;\n webSocketEndpoint: string;\n environment: ServiceEnvironment;\n timeout: number;\n logging: boolean;\n}\n\nconst getEnvVar = (name: string, fallback: string): string => {\n if (typeof process !== 'undefined' && process.env && process.env[name]) {\n return process.env[name] as string;\n }\n return fallback;\n};\n\nexport const getApiClientConfig = (env: ServiceEnvironment): ServiceConfig => {\n const configs: Record<ServiceEnvironment, ServiceConfig> = {\n localtestnet: {\n chain: 89346162 as ReyaChainId,\n apiEndpoint: 'http://localhost:8000',\n webSocketEndpoint: 'ws://localhost:8080',\n environment: 'localtestnet',\n timeout: API_TIMEOUT,\n logging: true,\n },\n localmainnet: {\n chain: 1729 as ReyaChainId,\n apiEndpoint: 'http://localhost:8000',\n webSocketEndpoint: 'ws://localhost:8080',\n environment: 'localmainnet',\n timeout: API_TIMEOUT,\n logging: true,\n },\n production: {\n chain: 1729 as ReyaChainId,\n apiEndpoint: getEnvVar(\n 'NEXT_PUBLIC_REYA_API_ENDPOINT',\n 'https://api.reya.xyz',\n ),\n webSocketEndpoint: getEnvVar(\n 'NEXT_PUBLIC_REYA_WEBSOCKET_ENDPOINT',\n 'wss://ws.reya.xyz',\n ),\n environment: getEnvVar(\n 'NEXT_PUBLIC_REYA_ENVIRONMENT',\n 'production',\n ) as ServiceEnvironment,\n timeout: API_TIMEOUT,\n logging: false,\n },\n staging: {\n chain: 1729 as ReyaChainId,\n apiEndpoint: getEnvVar(\n 'NEXT_PUBLIC_REYA_API_ENDPOINT',\n 'https://api-staging.reya.xyz',\n ),\n webSocketEndpoint: getEnvVar(\n 'NEXT_PUBLIC_REYA_WEBSOCKET_ENDPOINT',\n 'wss://websocket-staging.reya.xyz',\n ),\n environment: getEnvVar(\n 'NEXT_PUBLIC_REYA_ENVIRONMENT',\n 'staging',\n ) as ServiceEnvironment,\n timeout: API_TIMEOUT,\n logging: false,\n },\n // Devnet1 uses the live reya-cronos chain (89346162).\n devnet: {\n chain: 89346162 as ReyaChainId,\n apiEndpoint: getEnvVar(\n 'NEXT_PUBLIC_REYA_API_ENDPOINT',\n 'https://api-devnet.reya-cronos.network',\n ),\n webSocketEndpoint: getEnvVar(\n 'NEXT_PUBLIC_REYA_WEBSOCKET_ENDPOINT',\n 'wss://websocket-devnet.reya-cronos.network',\n ),\n environment: getEnvVar(\n 'NEXT_PUBLIC_REYA_ENVIRONMENT',\n 'devnet',\n ) as ServiceEnvironment,\n timeout: API_TIMEOUT,\n logging: true,\n },\n };\n\n if (!Object.prototype.hasOwnProperty.call(configs, env)) {\n throw new Error(`Unsupported SDK environment: ${env}`);\n }\n return configs[env];\n};\n"]}
|
|
@@ -167,20 +167,6 @@ var AccountClient = /** @class */ (function (_super) {
|
|
|
167
167
|
});
|
|
168
168
|
});
|
|
169
169
|
};
|
|
170
|
-
AccountClient.prototype.closeMarginAccount = function (params) {
|
|
171
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
172
|
-
var uri;
|
|
173
|
-
return __generator(this, function (_a) {
|
|
174
|
-
if (!params.id) {
|
|
175
|
-
throw new Error('Missing margin account id');
|
|
176
|
-
}
|
|
177
|
-
uri = "/api/accounts/".concat(params.id, "/close");
|
|
178
|
-
return [2 /*return*/, this.delete(uri, {
|
|
179
|
-
id: params.id,
|
|
180
|
-
})];
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
};
|
|
184
170
|
return AccountClient;
|
|
185
171
|
}(common_1.RestClient));
|
|
186
172
|
exports.default = AccountClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/account/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/account/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,0CAA0E;AAE1E;IAA2C,iCAAU;IAArD;;IAmGA,CAAC;IAlGC;;;;;;;;;;;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,gBAAgB,EAAE,KAAK;6BACxB,CAAC,EAAA;;wBAHI,QAAQ,GAA4B,SAGxC;wBAEI,gBAAgB,GAAG,QAAQ,CAAC,GAAG,CACnC,UAAC,OAAO;4BACN,OAAO;gCACL,EAAE,EAAE,OAAO,CAAC,EAAE;gCACd,IAAI,EAAE,OAAO,CAAC,IAAI;6BACnB,CAAC;wBACJ,CAAC,CACF,CAAC;wBAEF,sB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AAC,IAAI,IAAI,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;oBAC1C,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;gBAC5C,CAAC;gBAEK,GAAG,GAAG,wBAAiB,MAAM,CAAC,EAAE,UAAO,CAAC;gBAC9C,sBAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;wBACnB,EAAE,EAAE,MAAM,CAAC,EAAE;wBACb,IAAI,EAAE,MAAM,CAAC,IAAI;qBAClB,CAAC,EAAC;;;KACJ;IACH,oBAAC;AAAD,CAAC,AAnGD,CAA2C,mBAAU,GAmGpD","sourcesContent":["import {\n GetMarginAccountParams,\n GetMarginAccountResult,\n GetMarginAccountsParams,\n GetMarginAccountsResult,\n EditMarginAccountParams,\n EditMarginAccountResult,\n GetMarginAccountOrderHistoryPaginatedParams,\n GetMarginAccountOrderHistoryPaginatedResult,\n GetLiquidationHistoryForOwnerAddressResult,\n GetLiquidationHistoryForOwnerAddressParams,\n} from './types';\nimport { RestClient, StrippedMarginAccountEntity } 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 // 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}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/account/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MarketEntity,\n PositionEntity,\n OrderHistoryEntity,\n MarginRatioHealth,\n StrippedMarginAccountEntity,\n} from '@reyaxyz/common';\nimport {\n MarginAccountBalanceGranularity,\n MarginAccountCollateralsBalanceGranularity,\n AllMarginAccountsBalanceGranularity,\n} from '@reyaxyz/common';\nimport { Address } from '@reyaxyz/common';\n\nexport type GetMarginAccountsParams = {\n address: string;\n limit?: number;\n};\n\nexport type GetMarginAccountParams = {\n address: string;\n marginAccountId: number;\n};\n\nexport type GetPositionsForMarginAccountParams = {\n address: string;\n marginAccountId: number;\n limit?: number;\n};\n\nexport type GetMarginAccountsResult = StrippedMarginAccountEntity[];\n\nexport type GetMarginAccountResult = StrippedMarginAccountEntity;\n\n// -- Max Order Size --\n\nexport type GetMaxOrderSizeAvailableParams = {\n marketId: MarketEntity['id'];\n marginAccountId: number;\n direction: 'long' | 'short';\n};\n\nexport type GetMaxOrderSizeAvailableResult = {\n maxAmountBase: number;\n maxAmountSize: number;\n};\n\nexport type GetPositionsForMarginAccountResult = {\n positions: PositionEntity[];\n totalUnrealizedPNL: number;\n};\n\n// --- Order History ---\n\nexport type GetMarginAccountOrderHistoryParams = {\n address: string;\n marginAccountId: number;\n limit?: number;\n};\nexport type GetMarginAccountOrderHistoryPaginatedParams = {\n address: string;\n marginAccountId: number;\n page: number;\n perPage: number;\n type?: 'order' | 'liquidation';\n};\nexport type GetMarginAccountOrderHistoryResult = OrderHistoryEntity[];\nexport type GetMarginAccountOrderHistoryPaginatedResult = {\n data: OrderHistoryEntity[];\n totalCount: number;\n};\n\n//--- Liquidation History ---\nexport type GetLiquidationHistoryForOwnerAddressParams = {\n address: Address;\n timestampFromMS: number;\n};\nexport type GetLiquidationHistoryForOwnerAddressResult = {\n data: LiquidationHistoryEntity[];\n};\n\nexport type LiquidationHistoryEntity = {\n id: string;\n action: 'long-liquidation' | 'short-liquidation';\n executionPrice: number;\n fees: number;\n base: number;\n size: number; // price * base (liquidation size)\n timestamp: number;\n baseUnderlyingToken: string;\n marginAccount: {\n id: number;\n name: string;\n marginRatioPercentage: number;\n marginRatioHealth: MarginRatioHealth;\n };\n};\n\n// ---- Transaction Simulation ----\n\nexport type GetTransactionSimulationInitialDataParams = {\n marketId: MarketEntity['id'];\n marginAccountId: number;\n};\n\nexport type GetMarginAccountBalanceChartDataParams = {\n marginAccountId: number;\n filters: {\n timeframeMs: number;\n granularity: MarginAccountBalanceGranularity;\n };\n};\n\nexport type GetMarginAccountCollateralsBalanceChartDataParams = {\n marginAccountId: number;\n filters: {\n timeframeMs: number;\n granularity: MarginAccountCollateralsBalanceGranularity;\n };\n};\n\nexport type GetAllMarginAccountsBalanceChartDataParams = {\n ownerAddress: string;\n filters: {\n timeframeMs: number;\n granularity: AllMarginAccountsBalanceGranularity;\n };\n};\n\nexport type EditMarginAccountParams = {\n id: number;\n name: string;\n};\n\nexport type EditMarginAccountResult = { success: boolean };\n\nexport type
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/account/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MarketEntity,\n PositionEntity,\n OrderHistoryEntity,\n MarginRatioHealth,\n StrippedMarginAccountEntity,\n} from '@reyaxyz/common';\nimport {\n MarginAccountBalanceGranularity,\n MarginAccountCollateralsBalanceGranularity,\n AllMarginAccountsBalanceGranularity,\n} from '@reyaxyz/common';\nimport { Address } from '@reyaxyz/common';\n\nexport type GetMarginAccountsParams = {\n address: string;\n limit?: number;\n};\n\nexport type GetMarginAccountParams = {\n address: string;\n marginAccountId: number;\n};\n\nexport type GetPositionsForMarginAccountParams = {\n address: string;\n marginAccountId: number;\n limit?: number;\n};\n\nexport type GetMarginAccountsResult = StrippedMarginAccountEntity[];\n\nexport type GetMarginAccountResult = StrippedMarginAccountEntity;\n\n// -- Max Order Size --\n\nexport type GetMaxOrderSizeAvailableParams = {\n marketId: MarketEntity['id'];\n marginAccountId: number;\n direction: 'long' | 'short';\n};\n\nexport type GetMaxOrderSizeAvailableResult = {\n maxAmountBase: number;\n maxAmountSize: number;\n};\n\nexport type GetPositionsForMarginAccountResult = {\n positions: PositionEntity[];\n totalUnrealizedPNL: number;\n};\n\n// --- Order History ---\n\nexport type GetMarginAccountOrderHistoryParams = {\n address: string;\n marginAccountId: number;\n limit?: number;\n};\nexport type GetMarginAccountOrderHistoryPaginatedParams = {\n address: string;\n marginAccountId: number;\n page: number;\n perPage: number;\n type?: 'order' | 'liquidation';\n};\nexport type GetMarginAccountOrderHistoryResult = OrderHistoryEntity[];\nexport type GetMarginAccountOrderHistoryPaginatedResult = {\n data: OrderHistoryEntity[];\n totalCount: number;\n};\n\n//--- Liquidation History ---\nexport type GetLiquidationHistoryForOwnerAddressParams = {\n address: Address;\n timestampFromMS: number;\n};\nexport type GetLiquidationHistoryForOwnerAddressResult = {\n data: LiquidationHistoryEntity[];\n};\n\nexport type LiquidationHistoryEntity = {\n id: string;\n action: 'long-liquidation' | 'short-liquidation';\n executionPrice: number;\n fees: number;\n base: number;\n size: number; // price * base (liquidation size)\n timestamp: number;\n baseUnderlyingToken: string;\n marginAccount: {\n id: number;\n name: string;\n marginRatioPercentage: number;\n marginRatioHealth: MarginRatioHealth;\n };\n};\n\n// ---- Transaction Simulation ----\n\nexport type GetTransactionSimulationInitialDataParams = {\n marketId: MarketEntity['id'];\n marginAccountId: number;\n};\n\nexport type GetMarginAccountBalanceChartDataParams = {\n marginAccountId: number;\n filters: {\n timeframeMs: number;\n granularity: MarginAccountBalanceGranularity;\n };\n};\n\nexport type GetMarginAccountCollateralsBalanceChartDataParams = {\n marginAccountId: number;\n filters: {\n timeframeMs: number;\n granularity: MarginAccountCollateralsBalanceGranularity;\n };\n};\n\nexport type GetAllMarginAccountsBalanceChartDataParams = {\n ownerAddress: string;\n filters: {\n timeframeMs: number;\n granularity: AllMarginAccountsBalanceGranularity;\n };\n};\n\nexport type EditMarginAccountParams = {\n id: number;\n name: string;\n};\n\nexport type EditMarginAccountResult = { success: boolean };\n\nexport type GetAllMarginAccountsSummaryParams = {\n ownerAddress: string;\n};\n\nexport type GetAllMarginAccountsSummaryResult = {\n totalAccountsCount: number;\n totalBalance: number;\n totalBalanceChangePercentage: number;\n totalBalanceUnderlyingAsset: string;\n};\n\nexport type GetIsolatedOrderMaxSizeAvailableParams = {\n marketId: MarketEntity['id'];\n marginAccountId: number;\n direction: 'long' | 'short';\n};\n\nexport type GetIsolatedOrderMaxSizeAvailableResult = {\n maxAmountBase: number;\n maxAmountSize: number;\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReyaChainId } from '@reyaxyz/common';
|
|
2
|
-
export type ServiceEnvironment = 'production' | 'staging' | '
|
|
2
|
+
export type ServiceEnvironment = 'production' | 'staging' | 'devnet' | 'localmainnet' | 'localtestnet';
|
|
3
3
|
export interface ServiceConfig {
|
|
4
4
|
chain: ReyaChainId;
|
|
5
5
|
apiEndpoint: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client-config.d.ts","sourceRoot":"/","sources":["clients/api-client-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAInD,MAAM,MAAM,kBAAkB,GAC1B,YAAY,GACZ,SAAS,GACT,
|
|
1
|
+
{"version":3,"file":"api-client-config.d.ts","sourceRoot":"/","sources":["clients/api-client-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAInD,MAAM,MAAM,kBAAkB,GAC1B,YAAY,GACZ,SAAS,GACT,QAAQ,GACR,cAAc,GACd,cAAc,CAAC;AAEnB,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,WAAW,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,kBAAkB,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB;AASD,eAAO,MAAM,kBAAkB,QAAS,kBAAkB,KAAG,aA4E5D,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GetMarginAccountParams, GetMarginAccountResult, GetMarginAccountsParams, GetMarginAccountsResult, EditMarginAccountParams,
|
|
1
|
+
import { GetMarginAccountParams, GetMarginAccountResult, GetMarginAccountsParams, GetMarginAccountsResult, EditMarginAccountParams, EditMarginAccountResult, GetMarginAccountOrderHistoryPaginatedParams, GetMarginAccountOrderHistoryPaginatedResult, GetLiquidationHistoryForOwnerAddressResult, GetLiquidationHistoryForOwnerAddressParams } from './types';
|
|
2
2
|
import { RestClient } from '@reyaxyz/common';
|
|
3
3
|
export default class AccountClient extends RestClient {
|
|
4
4
|
/**
|
|
@@ -29,6 +29,5 @@ export default class AccountClient extends RestClient {
|
|
|
29
29
|
getMarginAccountOrderHistoryPaginated(params: GetMarginAccountOrderHistoryPaginatedParams): Promise<GetMarginAccountOrderHistoryPaginatedResult>;
|
|
30
30
|
getLiquidationHistoryForOwnerAddress(params: GetLiquidationHistoryForOwnerAddressParams): Promise<GetLiquidationHistoryForOwnerAddressResult>;
|
|
31
31
|
editMarginAccount(params: EditMarginAccountParams): Promise<EditMarginAccountResult>;
|
|
32
|
-
closeMarginAccount(params: CloseMarginAccountParams): Promise<CloseMarginAccountResult>;
|
|
33
32
|
}
|
|
34
33
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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,uBAAuB,EACvB,
|
|
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,uBAAuB,EACvB,uBAAuB,EACvB,2CAA2C,EAC3C,2CAA2C,EAC3C,0CAA0C,EAC1C,0CAA0C,EAC3C,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,UAAU,EAA+B,MAAM,iBAAiB,CAAC;AAE1E,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD;;;;;;;;;;;SAWK;IAEC,iBAAiB,CACrB,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,uBAAuB,CAAC;IAmBnC;;;;;;;;;;OAUG;IAEG,gBAAgB,CACpB,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,sBAAsB,CAAC;IAY5B,qCAAqC,CACzC,MAAM,EAAE,2CAA2C,GAClD,OAAO,CAAC,2CAA2C,CAAC;IASjD,oCAAoC,CACxC,MAAM,EAAE,0CAA0C,GACjD,OAAO,CAAC,0CAA0C,CAAC;IAQhD,iBAAiB,CACrB,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,uBAAuB,CAAC;CAepC"}
|
|
@@ -101,12 +101,6 @@ export type EditMarginAccountParams = {
|
|
|
101
101
|
export type EditMarginAccountResult = {
|
|
102
102
|
success: boolean;
|
|
103
103
|
};
|
|
104
|
-
export type CloseMarginAccountParams = {
|
|
105
|
-
id: number;
|
|
106
|
-
};
|
|
107
|
-
export type CloseMarginAccountResult = {
|
|
108
|
-
success: boolean;
|
|
109
|
-
};
|
|
110
104
|
export type GetAllMarginAccountsSummaryParams = {
|
|
111
105
|
ownerAddress: string;
|
|
112
106
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/account/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,2BAA2B,EAC5B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,+BAA+B,EAC/B,0CAA0C,EAC1C,mCAAmC,EACpC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;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AAE,YAAY,CAAC,IAAI,CAAC,CAAC;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,sCAAsC,GAAG;IACnD,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/api-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.170.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@reyaxyz/common": "0.
|
|
36
|
+
"@reyaxyz/common": "0.365.1",
|
|
37
37
|
"@simplewebauthn/types": "10.0.0",
|
|
38
38
|
"ethers": "6.17.0",
|
|
39
39
|
"isomorphic-ws": "5.0.0"
|
|
40
40
|
},
|
|
41
41
|
"packageManager": "pnpm@8.3.1",
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "ff13ef71817cd76722adfd0d4e471e8a4c513344",
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@reyaxyz/database": "0.174.
|
|
44
|
+
"@reyaxyz/database": "0.174.11"
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -5,7 +5,6 @@ const API_TIMEOUT = 30000;
|
|
|
5
5
|
export type ServiceEnvironment =
|
|
6
6
|
| 'production'
|
|
7
7
|
| 'staging'
|
|
8
|
-
| 'test'
|
|
9
8
|
| 'devnet'
|
|
10
9
|
| 'localmainnet'
|
|
11
10
|
| 'localtestnet';
|
|
@@ -78,27 +77,7 @@ export const getApiClientConfig = (env: ServiceEnvironment): ServiceConfig => {
|
|
|
78
77
|
timeout: API_TIMEOUT,
|
|
79
78
|
logging: false,
|
|
80
79
|
},
|
|
81
|
-
|
|
82
|
-
chain: 89346162 as ReyaChainId,
|
|
83
|
-
apiEndpoint: getEnvVar(
|
|
84
|
-
'NEXT_PUBLIC_REYA_API_ENDPOINT',
|
|
85
|
-
'https://api-cronos.reya.xyz',
|
|
86
|
-
),
|
|
87
|
-
webSocketEndpoint: getEnvVar(
|
|
88
|
-
'NEXT_PUBLIC_REYA_WEBSOCKET_ENDPOINT',
|
|
89
|
-
'wss://websocket-testnet.reya.xyz',
|
|
90
|
-
),
|
|
91
|
-
environment: getEnvVar(
|
|
92
|
-
'NEXT_PUBLIC_REYA_ENVIRONMENT',
|
|
93
|
-
'test',
|
|
94
|
-
) as ServiceEnvironment,
|
|
95
|
-
timeout: API_TIMEOUT,
|
|
96
|
-
logging: true,
|
|
97
|
-
},
|
|
98
|
-
// Devnet1 shares the cronos chain (89346162) but has its own
|
|
99
|
-
// sub-deploy at `reya-cronos.network` (distinct from `reya.xyz`).
|
|
100
|
-
// Added so UIs can offer "devnet" as a first-class environment
|
|
101
|
-
// selection rather than overriding `test`'s default endpoint.
|
|
80
|
+
// Devnet1 uses the live reya-cronos chain (89346162).
|
|
102
81
|
devnet: {
|
|
103
82
|
chain: 89346162 as ReyaChainId,
|
|
104
83
|
apiEndpoint: getEnvVar(
|
|
@@ -118,5 +97,8 @@ export const getApiClientConfig = (env: ServiceEnvironment): ServiceConfig => {
|
|
|
118
97
|
},
|
|
119
98
|
};
|
|
120
99
|
|
|
121
|
-
|
|
100
|
+
if (!Object.prototype.hasOwnProperty.call(configs, env)) {
|
|
101
|
+
throw new Error(`Unsupported SDK environment: ${env}`);
|
|
102
|
+
}
|
|
103
|
+
return configs[env];
|
|
122
104
|
};
|
|
@@ -4,9 +4,7 @@ import {
|
|
|
4
4
|
GetMarginAccountsParams,
|
|
5
5
|
GetMarginAccountsResult,
|
|
6
6
|
EditMarginAccountParams,
|
|
7
|
-
CloseMarginAccountParams,
|
|
8
7
|
EditMarginAccountResult,
|
|
9
|
-
CloseMarginAccountResult,
|
|
10
8
|
GetMarginAccountOrderHistoryPaginatedParams,
|
|
11
9
|
GetMarginAccountOrderHistoryPaginatedResult,
|
|
12
10
|
GetLiquidationHistoryForOwnerAddressResult,
|
|
@@ -113,16 +111,4 @@ export default class AccountClient extends RestClient {
|
|
|
113
111
|
name: params.name,
|
|
114
112
|
});
|
|
115
113
|
}
|
|
116
|
-
async closeMarginAccount(
|
|
117
|
-
params: CloseMarginAccountParams,
|
|
118
|
-
): Promise<CloseMarginAccountResult> {
|
|
119
|
-
if (!params.id) {
|
|
120
|
-
throw new Error('Missing margin account id');
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const uri = `/api/accounts/${params.id}/close`;
|
|
124
|
-
return this.delete(uri, {
|
|
125
|
-
id: params.id,
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
114
|
}
|
|
@@ -134,12 +134,6 @@ export type EditMarginAccountParams = {
|
|
|
134
134
|
|
|
135
135
|
export type EditMarginAccountResult = { success: boolean };
|
|
136
136
|
|
|
137
|
-
export type CloseMarginAccountParams = {
|
|
138
|
-
id: number;
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
export type CloseMarginAccountResult = { success: boolean };
|
|
142
|
-
|
|
143
137
|
export type GetAllMarginAccountsSummaryParams = {
|
|
144
138
|
ownerAddress: string;
|
|
145
139
|
};
|