@grvt/client 1.4.16 → 1.4.17

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 CHANGED
@@ -1,62 +1,62 @@
1
- # GRVT
2
-
3
- Node.js & JavaScript client for GRVT REST APIs & WebSockets
4
-
5
- ## Installing
6
-
7
- Using npm:
8
-
9
- ```bash
10
- npm install @grvt/client
11
- ```
12
-
13
- Using yarn:
14
-
15
- ```bash
16
- yarn add @grvt/client
17
- ```
18
-
19
- Using pnpm:
20
-
21
- ```bash
22
- pnpm add @grvt/client
23
- ```
24
-
25
- Once the package is installed, you can import the library using `import` or `require` approach:
26
-
27
- ```js
28
- import GRVT from '@grvt/client'
29
- ```
30
-
31
- You can also use the default export, since the named export is just a re-export from the GRVT factory:
32
-
33
- ```js
34
- import GRVT from '@grvt/client'
35
- console.log(
36
- new GRVT.MDG({
37
- host: 'https://market-data.dev.gravitymarkets.io',
38
- version: 'v1'
39
- })
40
- )
41
- ```
42
-
43
- If you use `require` for importing:
44
-
45
- ```js
46
- const GRVT = require('@grvt/client')
47
- console.log(
48
- new GRVT.MDG({
49
- host: 'https://market-data.dev.gravitymarkets.io',
50
- version: 'v1'
51
- })
52
- )
53
- ```
54
-
55
- ## To use WebSocket (available only in browsers/platforms that support WebSocket)
56
-
57
- [Browsers supported](https://caniuse.com/websockets)
58
-
59
- ```js
60
- import { EStreamEndpoints, WS } from '@grvt/client/ws'
61
- console.log(new WS('wss://market-data.dev.gravitymarkets.io/ws'))
62
- ```
1
+ # GRVT
2
+
3
+ Node.js & JavaScript client for GRVT REST APIs & WebSockets
4
+
5
+ ## Installing
6
+
7
+ Using npm:
8
+
9
+ ```bash
10
+ npm install @grvt/client
11
+ ```
12
+
13
+ Using yarn:
14
+
15
+ ```bash
16
+ yarn add @grvt/client
17
+ ```
18
+
19
+ Using pnpm:
20
+
21
+ ```bash
22
+ pnpm add @grvt/client
23
+ ```
24
+
25
+ Once the package is installed, you can import the library using `import` or `require` approach:
26
+
27
+ ```js
28
+ import GRVT from '@grvt/client'
29
+ ```
30
+
31
+ You can also use the default export, since the named export is just a re-export from the GRVT factory:
32
+
33
+ ```js
34
+ import GRVT from '@grvt/client'
35
+ console.log(
36
+ new GRVT.MDG({
37
+ host: 'https://market-data.dev.gravitymarkets.io',
38
+ version: 'v1'
39
+ })
40
+ )
41
+ ```
42
+
43
+ If you use `require` for importing:
44
+
45
+ ```js
46
+ const GRVT = require('@grvt/client')
47
+ console.log(
48
+ new GRVT.MDG({
49
+ host: 'https://market-data.dev.gravitymarkets.io',
50
+ version: 'v1'
51
+ })
52
+ )
53
+ ```
54
+
55
+ ## To use WebSocket (available only in browsers/platforms that support WebSocket)
56
+
57
+ [Browsers supported](https://caniuse.com/websockets)
58
+
59
+ ```js
60
+ import { EStreamEndpoints, WS } from '@grvt/client/ws'
61
+ console.log(new WS('wss://market-data.dev.gravitymarkets.io/ws'))
62
+ ```
@@ -651,6 +651,8 @@ export interface IApiQueryVaultPerformanceRequest {
651
651
  export interface IApiQueryVaultPerformanceResponse {
652
652
  trading_volume?: string;
653
653
  apr?: number;
654
+ realized_pnl?: string;
655
+ pnl?: string;
654
656
  }
655
657
  export interface IApiQueryVaultPerformanceTrendRequest {
656
658
  vault_id?: string;
@@ -855,6 +857,9 @@ export interface IApiVaultDetailResponse {
855
857
  share_price?: string;
856
858
  total_equity?: string;
857
859
  valuation_cap?: string;
860
+ unrealized_pnl?: string;
861
+ initial_margin?: string;
862
+ maintenance_margin?: string;
858
863
  }
859
864
  export interface IApiVaultInvestRequest {
860
865
  main_account_id?: string;
@@ -5,10 +5,14 @@ exports.API_QUERY_VAULT_PERFORMANCE_RESPONSE_MAP = void 0;
5
5
  exports.API_QUERY_VAULT_PERFORMANCE_RESPONSE_MAP = Object.freeze({
6
6
  FULL_TO_LITE: {
7
7
  trading_volume: 'tv',
8
- apr: 'a'
8
+ apr: 'a',
9
+ realized_pnl: 'rp',
10
+ pnl: 'p'
9
11
  },
10
12
  LITE_TO_FULL: {
11
13
  tv: 'trading_volume',
12
- a: 'apr'
14
+ a: 'apr',
15
+ rp: 'realized_pnl',
16
+ p: 'pnl'
13
17
  }
14
18
  });
@@ -6,11 +6,17 @@ exports.API_VAULT_DETAIL_RESPONSE_MAP = Object.freeze({
6
6
  FULL_TO_LITE: {
7
7
  share_price: 'sp',
8
8
  total_equity: 'te',
9
- valuation_cap: 'vc'
9
+ valuation_cap: 'vc',
10
+ unrealized_pnl: 'up',
11
+ initial_margin: 'im',
12
+ maintenance_margin: 'mm'
10
13
  },
11
14
  LITE_TO_FULL: {
12
15
  sp: 'share_price',
13
16
  te: 'total_equity',
14
- vc: 'valuation_cap'
17
+ vc: 'valuation_cap',
18
+ up: 'unrealized_pnl',
19
+ im: 'initial_margin',
20
+ mm: 'maintenance_margin'
15
21
  }
16
22
  });
package/package.json CHANGED
@@ -1,50 +1,50 @@
1
- {
2
- "name": "@grvt/client",
3
- "version": "1.4.16",
4
- "description": "Node.js & JavaScript client for GRVT REST APIs & WebSockets",
5
- "repository": {
6
- "type": "git",
7
- "url": "git+https://github.com/gravity-technologies/grvt-js-client.git"
8
- },
9
- "keywords": [
10
- "GRVT"
11
- ],
12
- "bugs": {
13
- "url": "https://github.com/gravity-technologies/grvt-js-client/issues"
14
- },
15
- "homepage": "https://github.com/gravity-technologies/grvt-js-client#readme",
16
- "author": "danh@grvt.io",
17
- "license": "UNLICENSED",
18
- "engines": {
19
- "node": ">=20"
20
- },
21
- "main": "index.js",
22
- "types": "index.d.ts",
23
- "scripts": {
24
- "start": "tsc --watch",
25
- "prebuild": "rimraf dist",
26
- "build": "tsc",
27
- "postbuild": "cp package.json dist/ && cp README.md dist/ && cp LICENSE dist/",
28
- "prerelease": "npm run build",
29
- "release": "cd dist/ && npm publish --access public",
30
- "link-local": "cp package.json dist/ && cd dist/ && npm link && cd ..",
31
- "lint": "npx eslint \"src/**/*.{js,ts}\"",
32
- "lint-fix": "npx eslint \"src/**/*.{js,ts}\" --fix",
33
- "test": "nodemon dist/index.js"
34
- },
35
- "dependencies": {
36
- "axios": "^1.8.2"
37
- },
38
- "devDependencies": {
39
- "@typescript-eslint/eslint-plugin": "^6.10.0",
40
- "eslint": "^8.56.0",
41
- "eslint-config-standard-with-typescript": "^39.1.1",
42
- "eslint-plugin-import": "^2.29.0",
43
- "eslint-plugin-import-newlines": "^1.3.4",
44
- "eslint-plugin-n": "^16.3.0",
45
- "eslint-plugin-promise": "^6.1.1",
46
- "nodemon": "^3.0.2",
47
- "rimraf": "^5.0.5",
48
- "typescript": "^5.2.2"
49
- }
50
- }
1
+ {
2
+ "name": "@grvt/client",
3
+ "version": "1.4.17",
4
+ "description": "Node.js & JavaScript client for GRVT REST APIs & WebSockets",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/gravity-technologies/grvt-js-client.git"
8
+ },
9
+ "keywords": [
10
+ "GRVT"
11
+ ],
12
+ "bugs": {
13
+ "url": "https://github.com/gravity-technologies/grvt-js-client/issues"
14
+ },
15
+ "homepage": "https://github.com/gravity-technologies/grvt-js-client#readme",
16
+ "author": "danh@grvt.io",
17
+ "license": "UNLICENSED",
18
+ "engines": {
19
+ "node": ">=20"
20
+ },
21
+ "main": "index.js",
22
+ "types": "index.d.ts",
23
+ "scripts": {
24
+ "start": "tsc --watch",
25
+ "prebuild": "rimraf dist",
26
+ "build": "tsc",
27
+ "postbuild": "cp package.json dist/ && cp README.md dist/ && cp LICENSE dist/",
28
+ "prerelease": "npm run build",
29
+ "release": "cd dist/ && npm publish --access public",
30
+ "link-local": "cp package.json dist/ && cd dist/ && npm link && cd ..",
31
+ "lint": "npx eslint \"src/**/*.{js,ts}\"",
32
+ "lint-fix": "npx eslint \"src/**/*.{js,ts}\" --fix",
33
+ "test": "nodemon dist/index.js"
34
+ },
35
+ "dependencies": {
36
+ "axios": "^1.8.2"
37
+ },
38
+ "devDependencies": {
39
+ "@typescript-eslint/eslint-plugin": "^6.10.0",
40
+ "eslint": "^8.56.0",
41
+ "eslint-config-standard-with-typescript": "^39.1.1",
42
+ "eslint-plugin-import": "^2.29.0",
43
+ "eslint-plugin-import-newlines": "^1.3.4",
44
+ "eslint-plugin-n": "^16.3.0",
45
+ "eslint-plugin-promise": "^6.1.1",
46
+ "nodemon": "^3.0.2",
47
+ "rimraf": "^5.0.5",
48
+ "typescript": "^5.2.2"
49
+ }
50
+ }
package/ws/ws.js CHANGED
@@ -217,11 +217,11 @@ class WS {
217
217
  const depositDestinationAccountId = omitZeroStr(result.to_account_id);
218
218
  const transferSourceKey = [
219
219
  omitZeroStr(result.from_account_id),
220
- omitZeroStr(result.from_sub_account_id) ? result.from_sub_account_id : 0
220
+ omitZeroStr(result.from_sub_account_id)
221
221
  ].filter(Boolean).join('-');
222
222
  const transferDestinationKey = [
223
223
  omitZeroStr(result.to_account_id),
224
- omitZeroStr(result.to_sub_account_id) ? result.to_sub_account_id : 0
224
+ omitZeroStr(result.to_sub_account_id)
225
225
  ].filter(Boolean).join('-');
226
226
  const withdrawalFromAccountId = omitZeroStr(result.from_account_id);
227
227
  switch (stream) {
@@ -408,10 +408,7 @@ class WS {
408
408
  return params.main_account_id;
409
409
  };
410
410
  const transferFeed = (params) => {
411
- if (params.sub_account_id) {
412
- return [params.main_account_id, params.sub_account_id].join('-');
413
- }
414
- return params.main_account_id;
411
+ return [params.main_account_id, params.sub_account_id].filter(Boolean).join('-');
415
412
  };
416
413
  const withdrawalFeed = (params) => {
417
414
  return params.main_account_id;