@carrot-protocol/boost-http-client 0.3.2 → 0.3.3-feat-historical-bank-balances-dev-df97a5f
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 +2 -1
- package/dist/index.js +18 -0
- package/dist/types.d.ts +16 -0
- package/package.json +1 -1
- package/src/index.ts +30 -0
- package/src/types.ts +19 -0
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,24 @@ 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 {
|
|
323
|
+
historicalBalances: response,
|
|
324
|
+
};
|
|
325
|
+
}
|
|
308
326
|
async deposit(clendGroup, clendAccount, inputTokenMint, uiAmount) {
|
|
309
327
|
const req = {
|
|
310
328
|
owner: this.address(),
|
package/dist/types.d.ts
CHANGED
|
@@ -247,3 +247,19 @@ 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
|
+
historicalBalances: HistoricalBankBalance[];
|
|
258
|
+
}
|
|
259
|
+
export interface HistoricalBankBalance {
|
|
260
|
+
timestamp: string;
|
|
261
|
+
assetAmount: string | null;
|
|
262
|
+
liabilityAmount: string | null;
|
|
263
|
+
assetValue: string | null;
|
|
264
|
+
liabilityValue: string | null;
|
|
265
|
+
}
|
package/package.json
CHANGED
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,34 @@ 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 = JSON.parse(body);
|
|
419
|
+
return {
|
|
420
|
+
historicalBalances: response,
|
|
421
|
+
} as GetHistoricalBankBalancesResponse;
|
|
422
|
+
}
|
|
423
|
+
|
|
394
424
|
async deposit(
|
|
395
425
|
clendGroup: web3.PublicKey,
|
|
396
426
|
clendAccount: web3.PublicKey | null,
|
package/src/types.ts
CHANGED
|
@@ -283,3 +283,22 @@ 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
|
+
historicalBalances: HistoricalBankBalance[];
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export interface HistoricalBankBalance {
|
|
299
|
+
timestamp: string;
|
|
300
|
+
assetAmount: string | null;
|
|
301
|
+
liabilityAmount: string | null;
|
|
302
|
+
assetValue: string | null;
|
|
303
|
+
liabilityValue: string | null;
|
|
304
|
+
}
|