@dydxprotocol/v4-client-js 1.3.16 → 1.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dydxprotocol/v4-client-js",
3
- "version": "1.3.16",
3
+ "version": "1.4.0",
4
4
  "description": "General client library for the new dYdX system (v4 decentralized)",
5
5
  "main": "build/src/index.js",
6
6
  "scripts": {
@@ -11,8 +11,8 @@
11
11
  "coverage": "npm run test -- --coverage",
12
12
  "fix": "npm run lint -- --fix",
13
13
  "lint": "eslint --ext .ts,.js .",
14
- "prepublishOnly": "npm run compile && ls build/node_modules/@dydxprotocol/v4-proto",
15
- "release": "semantic-release --no-ci",
14
+ "prepublishOnly": "npm run compile",
15
+ "release": "semantic-release",
16
16
  "start": "node build/src/index.js",
17
17
  "test": "NODE_ENV=test jest --testPathIgnorePatterns=__tests__/modules/client/*",
18
18
  "test:watch": "npm test -- --watch",
@@ -176,6 +176,11 @@ export enum TimePeriod {
176
176
  SEVEN_DAYS = 'SEVEN_DAYS',
177
177
  }
178
178
 
179
+ export enum PnlTickInterval {
180
+ HOUR = "hour",
181
+ day = "day",
182
+ }
183
+
179
184
  // ------------ API Defaults ------------
180
185
  export const DEFAULT_API_TIMEOUT: number = 3_000;
181
186
 
@@ -2,6 +2,7 @@ import { IndexerConfig, DEFAULT_API_TIMEOUT } from './constants';
2
2
  import AccountClient from './modules/account';
3
3
  import MarketsClient from './modules/markets';
4
4
  import UtilityClient from './modules/utility';
5
+ import VaultClient from './modules/vault';
5
6
 
6
7
  /**
7
8
  * @description Client for Indexer
@@ -12,6 +13,7 @@ export class IndexerClient {
12
13
  readonly _markets: MarketsClient;
13
14
  readonly _account: AccountClient;
14
15
  readonly _utility: UtilityClient;
16
+ readonly _vault: VaultClient;
15
17
 
16
18
  constructor(config: IndexerConfig, apiTimeout?: number) {
17
19
  this.config = config;
@@ -20,6 +22,7 @@ export class IndexerClient {
20
22
  this._markets = new MarketsClient(config.restEndpoint);
21
23
  this._account = new AccountClient(config.restEndpoint);
22
24
  this._utility = new UtilityClient(config.restEndpoint);
25
+ this._vault = new VaultClient(config.restEndpoint);
23
26
  }
24
27
 
25
28
  /**
@@ -46,4 +49,13 @@ export class IndexerClient {
46
49
  get utility(): UtilityClient {
47
50
  return this._utility;
48
51
  }
52
+
53
+ /**
54
+ * @description Get the vault module, used for interacting with vault endpoints.
55
+ *
56
+ * @returns The vault module
57
+ */
58
+ get vault(): VaultClient {
59
+ return this._vault;
60
+ }
49
61
  }
@@ -194,4 +194,23 @@ export default class AccountClient extends RestClient {
194
194
  page,
195
195
  });
196
196
  }
197
+
198
+ async getTransfersBetween(
199
+ sourceAddress: string,
200
+ sourceSubaccountNumber: string,
201
+ recipientAddress: string,
202
+ recipientSubaccountNumber: string,
203
+ createdBeforeOrAtHeight?: number | null,
204
+ createdBeforeOrAt?: string | null
205
+ ): Promise<Data> {
206
+ const uri = '/v4/transfers/between';
207
+ return this.get(uri, {
208
+ sourceAddress,
209
+ sourceSubaccountNumber,
210
+ recipientAddress,
211
+ recipientSubaccountNumber,
212
+ createdBeforeOrAtHeight,
213
+ createdBeforeOrAt,
214
+ });
215
+ }
197
216
  }
@@ -0,0 +1,23 @@
1
+ import { PnlTickInterval } from '../constants';
2
+ import { Data } from '../types';
3
+ import RestClient from './rest';
4
+
5
+ /**
6
+ * @description REST endpoints for data unrelated to a particular address.
7
+ */
8
+ export default class VaultClient extends RestClient {
9
+ async getMegavaultHistoricalPnl(resolution?: PnlTickInterval | null): Promise<Data> {
10
+ const uri = '/v4/vault/v1/megavault/historicalPnl';
11
+ return this.get(uri, { resolution });
12
+ }
13
+
14
+ async getVaultsHistoricalPnl(resolution?: PnlTickInterval | null): Promise<Data> {
15
+ const uri = '/v4/vault/v1/vaults/historicalPnl';
16
+ return this.get(uri, { resolution });
17
+ }
18
+
19
+ async getMegavaultPositions(): Promise<Data> {
20
+ const uri = '/v4/vault/v1/megavault/positions';
21
+ return this.get(uri);
22
+ }
23
+ }