@carrot-protocol/boost-http-client 0.3.2 → 0.3.3-feat-historical-bank-balances-dev-df72015

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, GetGroupsResponse, GetAccountResponse, GetAccountRequest } from "./types";
2
+ import { GetBankResponse, GetUserResponse, GetGroupResponse, GetGroupsResponse, GetAccountResponse, GetAccountRequest, GetHistoricalBankBalancesRequest, GetHistoricalBankBalancesResponse } from "./types";
3
3
  export * from "./types";
4
4
  export * from "./utils";
5
5
  export * as Common from "@carrot-protocol/clend-common";
@@ -51,6 +51,7 @@ export declare class Client {
51
51
  * @returns Bank details
52
52
  */
53
53
  getBank(bankAddress: web3.PublicKey): Promise<GetBankResponse>;
54
+ getHistoricalBankBalances({ bank, resolution, startDate, endDate, }: GetHistoricalBankBalancesRequest): Promise<GetHistoricalBankBalancesResponse>;
54
55
  deposit(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey | null, inputTokenMint: web3.PublicKey, uiAmount: number): Promise<string>;
55
56
  withdraw(clendAccount: web3.PublicKey, outputTokenMint: web3.PublicKey, uiAmount: number, withdrawAll: boolean): Promise<string>;
56
57
  /**
package/dist/index.js CHANGED
@@ -305,6 +305,22 @@ class Client {
305
305
  };
306
306
  return response;
307
307
  }
308
+ async getHistoricalBankBalances({ bank, resolution, startDate, endDate, }) {
309
+ const queryParams = new URLSearchParams();
310
+ queryParams.append("bank", bank.toString());
311
+ if (resolution) {
312
+ queryParams.append("resolution", resolution);
313
+ }
314
+ if (startDate) {
315
+ queryParams.append("startDate", startDate.toISOString());
316
+ }
317
+ if (endDate) {
318
+ queryParams.append("endDate", endDate.toISOString());
319
+ }
320
+ const body = await handleApiCall(() => this.http.get(`/bank/historicalBalances?${queryParams.toString()}`));
321
+ const response = JSON.parse(body);
322
+ return response;
323
+ }
308
324
  async deposit(clendGroup, clendAccount, inputTokenMint, uiAmount) {
309
325
  const req = {
310
326
  owner: this.address(),
package/dist/types.d.ts CHANGED
@@ -247,3 +247,20 @@ export interface UserRequest {
247
247
  openPosition: boolean | null;
248
248
  closePosition: boolean | null;
249
249
  }
250
+ export interface GetHistoricalBankBalancesRequest {
251
+ bank: web3.PublicKey;
252
+ resolution?: "24h" | "6h" | "3h";
253
+ startDate?: Date;
254
+ endDate?: Date;
255
+ }
256
+ export interface GetHistoricalBankBalancesResponse {
257
+ bank: Bank;
258
+ historicalBalances: HistoricalBankBalance[];
259
+ }
260
+ export interface HistoricalBankBalance {
261
+ timestamp: string;
262
+ assetAmount: string | null;
263
+ liabilityAmount: string | null;
264
+ assetValue: string | null;
265
+ liabilityValue: string | null;
266
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carrot-protocol/boost-http-client",
3
- "version": "0.3.2",
3
+ "version": "0.3.3-feat-historical-bank-balances-dev-df72015",
4
4
  "description": "HTTP client for Carrot Boost",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -33,6 +33,8 @@ import {
33
33
  WithdrawResponse,
34
34
  GetAccountResponse,
35
35
  GetAccountRequest,
36
+ GetHistoricalBankBalancesRequest,
37
+ GetHistoricalBankBalancesResponse,
36
38
  } from "./types";
37
39
  import encode from "bs58";
38
40
 
@@ -391,6 +393,32 @@ export class Client {
391
393
  return response;
392
394
  }
393
395
 
396
+ async getHistoricalBankBalances({
397
+ bank,
398
+ resolution,
399
+ startDate,
400
+ endDate,
401
+ }: GetHistoricalBankBalancesRequest): Promise<GetHistoricalBankBalancesResponse> {
402
+ const queryParams = new URLSearchParams();
403
+ queryParams.append("bank", bank.toString());
404
+ if (resolution) {
405
+ queryParams.append("resolution", resolution);
406
+ }
407
+ if (startDate) {
408
+ queryParams.append("startDate", startDate.toISOString());
409
+ }
410
+ if (endDate) {
411
+ queryParams.append("endDate", endDate.toISOString());
412
+ }
413
+
414
+ const body = await handleApiCall(() =>
415
+ this.http.get(`/bank/historicalBalances?${queryParams.toString()}`),
416
+ );
417
+
418
+ const response: GetHistoricalBankBalancesResponse = JSON.parse(body);
419
+ return response;
420
+ }
421
+
394
422
  async deposit(
395
423
  clendGroup: web3.PublicKey,
396
424
  clendAccount: web3.PublicKey | null,
package/src/types.ts CHANGED
@@ -283,3 +283,23 @@ export interface UserRequest {
283
283
  openPosition: boolean | null;
284
284
  closePosition: boolean | null;
285
285
  }
286
+
287
+ export interface GetHistoricalBankBalancesRequest {
288
+ bank: web3.PublicKey;
289
+ resolution?: "24h" | "6h" | "3h";
290
+ startDate?: Date;
291
+ endDate?: Date;
292
+ }
293
+
294
+ export interface GetHistoricalBankBalancesResponse {
295
+ bank: Bank;
296
+ historicalBalances: HistoricalBankBalance[];
297
+ }
298
+
299
+ export interface HistoricalBankBalance {
300
+ timestamp: string;
301
+ assetAmount: string | null;
302
+ liabilityAmount: string | null;
303
+ assetValue: string | null;
304
+ liabilityValue: string | null;
305
+ }