@carrot-protocol/boost-http-client 0.4.5 → 0.4.6-feat-http-client-wallet-balances-dev-0bf8340

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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AnchorProvider, web3 } from "@coral-xyz/anchor";
2
- import { GetBankResponse, GetUserResponse, GetGroupResponse, GetUserRequest, GetGroupsResponse, GetAccountResponse, GetAccountRequest } from "./types";
2
+ import { GetBankResponse, GetUserResponse, GetGroupResponse, GetUserRequest, GetGroupsResponse, GetAccountResponse, GetAccountRequest, GetWalletBalancesRequest, GetWalletBalancesResponse } from "./types";
3
3
  import { ApiClient } from "./api";
4
4
  import { PositionChartingExtension } from "./charting/position";
5
5
  import { BankChartingExtension } from "./charting/bank";
@@ -79,6 +79,12 @@ export declare class Client extends ApiClient {
79
79
  * @returns Withdraw emissions operation result
80
80
  */
81
81
  withdrawEmissions(clendAccount: web3.PublicKey): Promise<string>;
82
+ /**
83
+ * Get wallet balances timeseries grouped by group
84
+ * @param request Optional filters for groups, time range, and aggregation
85
+ * @returns Wallet balances grouped by group with timeseries data
86
+ */
87
+ getWalletBalances(request?: GetWalletBalancesRequest): Promise<GetWalletBalancesResponse>;
82
88
  getPerformanceChartingExtension(clendAccount: web3.PublicKey): Promise<PositionChartingExtension>;
83
89
  getGroupChartingExtension(group: web3.PublicKey): Promise<GroupChartingExtension>;
84
90
  getWalletChartingExtension(address?: web3.PublicKey): Promise<WalletChartingExtension>;
package/dist/index.js CHANGED
@@ -451,6 +451,37 @@ class Client extends api_1.ApiClient {
451
451
  const txSig = await this.send(withdrawEmissionsResponse.unsignedBase64Tx, withdrawEmissionsResponse.userRequestId, req.useJito);
452
452
  return txSig;
453
453
  }
454
+ /**
455
+ * Get wallet balances timeseries grouped by group
456
+ * @param request Optional filters for groups, time range, and aggregation
457
+ * @returns Wallet balances grouped by group with timeseries data
458
+ */
459
+ async getWalletBalances(request = {}) {
460
+ const { groups, fromTime, toTime, aggregationMethod } = request;
461
+ const body = await this.handleApiCall(() => this.http.get(`/analytics/wallet-balances`, {
462
+ params: {
463
+ groups: groups?.map((g) => g.toString()).join(","),
464
+ fromTime: fromTime?.toISOString(),
465
+ toTime: toTime?.toISOString(),
466
+ aggregationMethod,
467
+ },
468
+ }));
469
+ const jsonResponse = JSON.parse(body);
470
+ const response = {
471
+ groups: jsonResponse.groups.map((groupData) => ({
472
+ group: new anchor_1.web3.PublicKey(groupData.group),
473
+ groupName: groupData.groupName,
474
+ wallets: groupData.wallets.map((walletData) => ({
475
+ authority: new anchor_1.web3.PublicKey(walletData.authority),
476
+ timeseries: walletData.timeseries.map((ts) => ({
477
+ time: new Date(ts.time),
478
+ netValue: Number(ts.netValue),
479
+ })),
480
+ })),
481
+ })),
482
+ };
483
+ return response;
484
+ }
454
485
  async getPerformanceChartingExtension(clendAccount) {
455
486
  return new position_1.PositionChartingExtension(this.baseUrl, clendAccount);
456
487
  }
package/dist/types.d.ts CHANGED
@@ -272,3 +272,25 @@ export type ChartingOptions = DateRangeOptions & {
272
272
  };
273
273
  export type ExtensionKey = "positionCharting" | "groupCharting" | "walletCharting" | "bankCharting";
274
274
  export type Extension = InstanceType<typeof PositionChartingExtension> | InstanceType<typeof GroupChartingExtension> | InstanceType<typeof WalletChartingExtension> | InstanceType<typeof BankChartingExtension>;
275
+ export interface GetWalletBalancesRequest {
276
+ groups?: web3.PublicKey[];
277
+ fromTime?: Date;
278
+ toTime?: Date;
279
+ aggregationMethod?: AggregationMethod;
280
+ }
281
+ export interface WalletBalancesTimeseries {
282
+ time: Date;
283
+ netValue: number;
284
+ }
285
+ export interface WalletBalances {
286
+ authority: web3.PublicKey;
287
+ timeseries: WalletBalancesTimeseries[];
288
+ }
289
+ export interface GroupWalletBalances {
290
+ group: web3.PublicKey;
291
+ groupName: string;
292
+ wallets: WalletBalances[];
293
+ }
294
+ export interface GetWalletBalancesResponse {
295
+ groups: GroupWalletBalances[];
296
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carrot-protocol/boost-http-client",
3
- "version": "0.4.5",
3
+ "version": "0.4.6-feat-http-client-wallet-balances-dev-0bf8340",
4
4
  "description": "HTTP client for Carrot Boost",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,4 +28,4 @@
28
28
  "@carrot-protocol/clend-common": "^0.1.0",
29
29
  "@coral-xyz/anchor": "^0.29.0"
30
30
  }
31
- }
31
+ }
package/src/index.ts CHANGED
@@ -32,6 +32,11 @@ import {
32
32
  WithdrawResponse,
33
33
  GetAccountResponse,
34
34
  GetAccountRequest,
35
+ GetWalletBalancesRequest,
36
+ GetWalletBalancesResponse,
37
+ GroupWalletBalances,
38
+ WalletBalances,
39
+ WalletBalancesTimeseries,
35
40
  } from "./types";
36
41
  import encode from "bs58";
37
42
  import { ApiClient } from "./api";
@@ -643,6 +648,52 @@ export class Client extends ApiClient {
643
648
  return txSig;
644
649
  }
645
650
 
651
+ /**
652
+ * Get wallet balances timeseries grouped by group
653
+ * @param request Optional filters for groups, time range, and aggregation
654
+ * @returns Wallet balances grouped by group with timeseries data
655
+ */
656
+ async getWalletBalances(
657
+ request: GetWalletBalancesRequest = {},
658
+ ): Promise<GetWalletBalancesResponse> {
659
+ const { groups, fromTime, toTime, aggregationMethod } = request;
660
+
661
+ const body = await this.handleApiCall(() =>
662
+ this.http.get(`/analytics/wallet-balances`, {
663
+ params: {
664
+ groups: groups?.map((g) => g.toString()).join(","),
665
+ fromTime: fromTime?.toISOString(),
666
+ toTime: toTime?.toISOString(),
667
+ aggregationMethod,
668
+ },
669
+ }),
670
+ );
671
+
672
+ const jsonResponse: any = JSON.parse(body);
673
+
674
+ const response: GetWalletBalancesResponse = {
675
+ groups: jsonResponse.groups.map(
676
+ (groupData: any): GroupWalletBalances => ({
677
+ group: new web3.PublicKey(groupData.group),
678
+ groupName: groupData.groupName,
679
+ wallets: groupData.wallets.map(
680
+ (walletData: any): WalletBalances => ({
681
+ authority: new web3.PublicKey(walletData.authority),
682
+ timeseries: walletData.timeseries.map(
683
+ (ts: any): WalletBalancesTimeseries => ({
684
+ time: new Date(ts.time),
685
+ netValue: Number(ts.netValue),
686
+ }),
687
+ ),
688
+ }),
689
+ ),
690
+ }),
691
+ ),
692
+ };
693
+
694
+ return response;
695
+ }
696
+
646
697
  public async getPerformanceChartingExtension(
647
698
  clendAccount: web3.PublicKey,
648
699
  ): Promise<PositionChartingExtension> {
package/src/types.ts CHANGED
@@ -321,3 +321,31 @@ export type Extension =
321
321
  | InstanceType<typeof GroupChartingExtension>
322
322
  | InstanceType<typeof WalletChartingExtension>
323
323
  | InstanceType<typeof BankChartingExtension>;
324
+
325
+ // Analytics types
326
+ export interface GetWalletBalancesRequest {
327
+ groups?: web3.PublicKey[];
328
+ fromTime?: Date;
329
+ toTime?: Date;
330
+ aggregationMethod?: AggregationMethod;
331
+ }
332
+
333
+ export interface WalletBalancesTimeseries {
334
+ time: Date;
335
+ netValue: number;
336
+ }
337
+
338
+ export interface WalletBalances {
339
+ authority: web3.PublicKey;
340
+ timeseries: WalletBalancesTimeseries[];
341
+ }
342
+
343
+ export interface GroupWalletBalances {
344
+ group: web3.PublicKey;
345
+ groupName: string;
346
+ wallets: WalletBalances[];
347
+ }
348
+
349
+ export interface GetWalletBalancesResponse {
350
+ groups: GroupWalletBalances[];
351
+ }