@carrot-protocol/boost-http-client 0.5.0-bank-token-apy-timeseries-dev-e208fe4 → 0.5.0-bank-token-apy-timeseries-dev-686f9e8
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/charting/bank/index.d.ts +5 -5
- package/dist/charting/bank/index.js +50 -8
- package/dist/index.d.ts +2 -6
- package/dist/index.js +2 -30
- package/dist/types.d.ts +21 -0
- package/package.json +1 -1
- package/src/charting/bank/index.ts +79 -13
- package/src/index.ts +2 -45
- package/src/types.ts +25 -0
- package/dist/charting/bank/types.d.ts +0 -5
- package/dist/charting/bank/types.js +0 -2
- package/src/charting/bank/types.ts +0 -5
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { web3 } from "@coral-xyz/anchor";
|
|
2
|
-
import {
|
|
3
|
-
import { DateRangeOptions } from "../../types";
|
|
2
|
+
import { ChartingOptions, GetBankApysResponse, GetBankMetricsResponse } from "../../types";
|
|
4
3
|
import { ApiClient } from "../../api";
|
|
5
4
|
export declare class BankChartingExtension extends ApiClient {
|
|
6
|
-
private readonly
|
|
7
|
-
constructor(baseUrl: string,
|
|
8
|
-
getApy(options?:
|
|
5
|
+
private readonly banks;
|
|
6
|
+
constructor(baseUrl: string, banks: web3.PublicKey[]);
|
|
7
|
+
getApy(options?: ChartingOptions): Promise<GetBankApysResponse>;
|
|
8
|
+
getMetrics(options?: ChartingOptions): Promise<GetBankMetricsResponse>;
|
|
9
9
|
}
|
|
@@ -1,26 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BankChartingExtension = void 0;
|
|
4
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
4
5
|
const api_1 = require("../../api");
|
|
5
6
|
class BankChartingExtension extends api_1.ApiClient {
|
|
6
|
-
constructor(baseUrl,
|
|
7
|
+
constructor(baseUrl, banks) {
|
|
7
8
|
super(baseUrl);
|
|
8
|
-
this.
|
|
9
|
+
this.banks = banks;
|
|
9
10
|
}
|
|
10
11
|
async getApy(options = {}) {
|
|
11
|
-
const { fromTime, toTime } = options;
|
|
12
|
+
const { fromTime, toTime, aggregationMethod } = options;
|
|
12
13
|
const body = await this.handleApiCall(() => this.http.get(`/bank/apys`, {
|
|
13
14
|
params: {
|
|
14
|
-
|
|
15
|
+
banks: this.banks.map((b) => b.toString()).join(","),
|
|
15
16
|
fromTime: fromTime?.toISOString(),
|
|
16
17
|
toTime: toTime?.toISOString(),
|
|
18
|
+
aggregationMethod,
|
|
17
19
|
},
|
|
18
20
|
}));
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const jsonResponse = JSON.parse(body);
|
|
22
|
+
const response = {
|
|
23
|
+
banks: jsonResponse.banks.map((bankData) => ({
|
|
24
|
+
bank: new anchor_1.web3.PublicKey(bankData.bank),
|
|
25
|
+
mint: new anchor_1.web3.PublicKey(bankData.mint),
|
|
26
|
+
timeseries: bankData.timeseries.map((ts) => ({
|
|
27
|
+
time: new Date(ts.time),
|
|
28
|
+
supplyApy: Number(ts.supplyApy),
|
|
29
|
+
borrowApy: Number(ts.borrowApy),
|
|
30
|
+
utilizationRate: Number(ts.utilizationRate),
|
|
31
|
+
})),
|
|
32
|
+
})),
|
|
33
|
+
};
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
async getMetrics(options = {}) {
|
|
37
|
+
const { fromTime, toTime, aggregationMethod } = options;
|
|
38
|
+
const body = await this.handleApiCall(() => this.http.get(`/bank/metrics`, {
|
|
39
|
+
params: {
|
|
40
|
+
banks: this.banks.map((b) => b.toString()).join(","),
|
|
41
|
+
fromTime: fromTime?.toISOString(),
|
|
42
|
+
toTime: toTime?.toISOString(),
|
|
43
|
+
aggregationMethod,
|
|
44
|
+
},
|
|
23
45
|
}));
|
|
46
|
+
const jsonResponse = JSON.parse(body);
|
|
47
|
+
const response = {
|
|
48
|
+
banks: jsonResponse.banks.map((bankData) => ({
|
|
49
|
+
bank: new anchor_1.web3.PublicKey(bankData.bank),
|
|
50
|
+
timeseries: bankData.timeseries.map((ts) => ({
|
|
51
|
+
time: new Date(ts.time),
|
|
52
|
+
mint: new anchor_1.web3.PublicKey(ts.mint),
|
|
53
|
+
mintDecimals: Number(ts.mintDecimals),
|
|
54
|
+
mintPrice: Number(ts.mintPrice),
|
|
55
|
+
mintSymbol: String(ts.mintSymbol),
|
|
56
|
+
supplyAmount: Number(ts.supplyAmount),
|
|
57
|
+
supplyValue: Number(ts.supplyValue),
|
|
58
|
+
supplyApy: Number(ts.supplyApy),
|
|
59
|
+
borrowAmount: Number(ts.borrowAmount),
|
|
60
|
+
borrowValue: Number(ts.borrowValue),
|
|
61
|
+
borrowApy: Number(ts.borrowApy),
|
|
62
|
+
utilizationRate: Number(ts.utilizationRate),
|
|
63
|
+
})),
|
|
64
|
+
})),
|
|
65
|
+
};
|
|
24
66
|
return response;
|
|
25
67
|
}
|
|
26
68
|
}
|
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, GetWalletBalancesRequest, GetWalletBalancesResponse,
|
|
2
|
+
import { GetBankResponse, GetUserResponse, GetGroupResponse, GetUserRequest, GetGroupsResponse, GetAccountResponse, GetAccountRequest, GetWalletBalancesRequest, GetWalletBalancesResponse, GetTokenApysRequest, GetTokenApysResponse } from "./types";
|
|
3
3
|
import { ApiClient } from "./api";
|
|
4
4
|
import { PositionChartingExtension } from "./charting/position";
|
|
5
5
|
import { BankChartingExtension } from "./charting/bank";
|
|
@@ -87,10 +87,6 @@ export declare class Client extends ApiClient {
|
|
|
87
87
|
* @returns Wallet balances grouped by group with timeseries data
|
|
88
88
|
*/
|
|
89
89
|
getWalletBalances(request?: GetWalletBalancesRequest): Promise<GetWalletBalancesResponse>;
|
|
90
|
-
/**
|
|
91
|
-
* Get bank APY timeseries for one or more banks
|
|
92
|
-
*/
|
|
93
|
-
getBankApys(request: GetBankApysRequest): Promise<GetBankApysResponse>;
|
|
94
90
|
/**
|
|
95
91
|
* Get token yield APY timeseries for one or more mints
|
|
96
92
|
*/
|
|
@@ -98,5 +94,5 @@ export declare class Client extends ApiClient {
|
|
|
98
94
|
getPerformanceChartingExtension(clendAccount: web3.PublicKey): Promise<PositionChartingExtension>;
|
|
99
95
|
getGroupChartingExtension(group: web3.PublicKey): Promise<GroupChartingExtension>;
|
|
100
96
|
getWalletChartingExtension(address?: web3.PublicKey): Promise<WalletChartingExtension>;
|
|
101
|
-
getBankChartingExtension(
|
|
97
|
+
getBankChartingExtension(banks: web3.PublicKey[]): Promise<BankChartingExtension>;
|
|
102
98
|
}
|
package/dist/index.js
CHANGED
|
@@ -507,34 +507,6 @@ class Client extends api_1.ApiClient {
|
|
|
507
507
|
};
|
|
508
508
|
return response;
|
|
509
509
|
}
|
|
510
|
-
/**
|
|
511
|
-
* Get bank APY timeseries for one or more banks
|
|
512
|
-
*/
|
|
513
|
-
async getBankApys(request) {
|
|
514
|
-
const { banks, fromTime, toTime, aggregationMethod } = request;
|
|
515
|
-
const body = await this.handleApiCall(() => this.http.get(`/bank/apys`, {
|
|
516
|
-
params: {
|
|
517
|
-
banks: banks.map((b) => b.toString()).join(","),
|
|
518
|
-
fromTime: fromTime?.toISOString(),
|
|
519
|
-
toTime: toTime?.toISOString(),
|
|
520
|
-
aggregationMethod,
|
|
521
|
-
},
|
|
522
|
-
}));
|
|
523
|
-
const jsonResponse = JSON.parse(body);
|
|
524
|
-
const response = {
|
|
525
|
-
banks: jsonResponse.banks.map((bankData) => ({
|
|
526
|
-
bank: new anchor_1.web3.PublicKey(bankData.bank),
|
|
527
|
-
mint: new anchor_1.web3.PublicKey(bankData.mint),
|
|
528
|
-
timeseries: bankData.timeseries.map((ts) => ({
|
|
529
|
-
time: new Date(ts.time),
|
|
530
|
-
supplyApy: Number(ts.supplyApy),
|
|
531
|
-
borrowApy: Number(ts.borrowApy),
|
|
532
|
-
utilizationRate: Number(ts.utilizationRate),
|
|
533
|
-
})),
|
|
534
|
-
})),
|
|
535
|
-
};
|
|
536
|
-
return response;
|
|
537
|
-
}
|
|
538
510
|
/**
|
|
539
511
|
* Get token yield APY timeseries for one or more mints
|
|
540
512
|
*/
|
|
@@ -569,8 +541,8 @@ class Client extends api_1.ApiClient {
|
|
|
569
541
|
async getWalletChartingExtension(address) {
|
|
570
542
|
return new wallet_1.WalletChartingExtension(this.baseUrl, address ?? this.address());
|
|
571
543
|
}
|
|
572
|
-
async getBankChartingExtension(
|
|
573
|
-
return new bank_1.BankChartingExtension(this.baseUrl,
|
|
544
|
+
async getBankChartingExtension(banks) {
|
|
545
|
+
return new bank_1.BankChartingExtension(this.baseUrl, banks);
|
|
574
546
|
}
|
|
575
547
|
}
|
|
576
548
|
exports.Client = Client;
|
package/dist/types.d.ts
CHANGED
|
@@ -341,6 +341,27 @@ export interface BankApysEntry {
|
|
|
341
341
|
export interface GetBankApysResponse {
|
|
342
342
|
banks: BankApysEntry[];
|
|
343
343
|
}
|
|
344
|
+
export interface BankMetricsTimeseries {
|
|
345
|
+
time: Date;
|
|
346
|
+
mint: web3.PublicKey;
|
|
347
|
+
mintDecimals: number;
|
|
348
|
+
mintPrice: number;
|
|
349
|
+
mintSymbol: string;
|
|
350
|
+
supplyAmount: number;
|
|
351
|
+
supplyValue: number;
|
|
352
|
+
supplyApy: number;
|
|
353
|
+
borrowAmount: number;
|
|
354
|
+
borrowValue: number;
|
|
355
|
+
borrowApy: number;
|
|
356
|
+
utilizationRate: number;
|
|
357
|
+
}
|
|
358
|
+
export interface BankMetricsEntry {
|
|
359
|
+
bank: web3.PublicKey;
|
|
360
|
+
timeseries: BankMetricsTimeseries[];
|
|
361
|
+
}
|
|
362
|
+
export interface GetBankMetricsResponse {
|
|
363
|
+
banks: BankMetricsEntry[];
|
|
364
|
+
}
|
|
344
365
|
export interface GetTokenApysRequest {
|
|
345
366
|
mints: web3.PublicKey[];
|
|
346
367
|
fromTime?: Date;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carrot-protocol/boost-http-client",
|
|
3
|
-
"version": "0.5.0-bank-token-apy-timeseries-dev-
|
|
3
|
+
"version": "0.5.0-bank-token-apy-timeseries-dev-686f9e8",
|
|
4
4
|
"description": "HTTP client for Carrot Boost",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -1,35 +1,101 @@
|
|
|
1
1
|
import { web3 } from "@coral-xyz/anchor";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
ChartingOptions,
|
|
4
|
+
GetBankApysResponse,
|
|
5
|
+
BankApysEntry,
|
|
6
|
+
BankApyTimeseries,
|
|
7
|
+
GetBankMetricsResponse,
|
|
8
|
+
BankMetricsEntry,
|
|
9
|
+
BankMetricsTimeseries,
|
|
10
|
+
} from "../../types";
|
|
4
11
|
import { ApiClient } from "../../api";
|
|
5
12
|
|
|
6
13
|
export class BankChartingExtension extends ApiClient {
|
|
7
|
-
private readonly
|
|
14
|
+
private readonly banks: web3.PublicKey[];
|
|
8
15
|
|
|
9
|
-
constructor(baseUrl: string,
|
|
16
|
+
constructor(baseUrl: string, banks: web3.PublicKey[]) {
|
|
10
17
|
super(baseUrl);
|
|
11
|
-
this.
|
|
18
|
+
this.banks = banks;
|
|
12
19
|
}
|
|
13
20
|
|
|
14
|
-
public async getApy(
|
|
15
|
-
|
|
21
|
+
public async getApy(
|
|
22
|
+
options: ChartingOptions = {},
|
|
23
|
+
): Promise<GetBankApysResponse> {
|
|
24
|
+
const { fromTime, toTime, aggregationMethod } = options;
|
|
16
25
|
const body = await this.handleApiCall(() =>
|
|
17
26
|
this.http.get(`/bank/apys`, {
|
|
18
27
|
params: {
|
|
19
|
-
|
|
28
|
+
banks: this.banks.map((b) => b.toString()).join(","),
|
|
20
29
|
fromTime: fromTime?.toISOString(),
|
|
21
30
|
toTime: toTime?.toISOString(),
|
|
31
|
+
aggregationMethod,
|
|
22
32
|
},
|
|
23
33
|
}),
|
|
24
34
|
);
|
|
25
35
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
const jsonResponse: any = JSON.parse(body);
|
|
37
|
+
|
|
38
|
+
const response: GetBankApysResponse = {
|
|
39
|
+
banks: jsonResponse.banks.map(
|
|
40
|
+
(bankData: any): BankApysEntry => ({
|
|
41
|
+
bank: new web3.PublicKey(bankData.bank),
|
|
42
|
+
mint: new web3.PublicKey(bankData.mint),
|
|
43
|
+
timeseries: bankData.timeseries.map(
|
|
44
|
+
(ts: any): BankApyTimeseries => ({
|
|
45
|
+
time: new Date(ts.time),
|
|
46
|
+
supplyApy: Number(ts.supplyApy),
|
|
47
|
+
borrowApy: Number(ts.borrowApy),
|
|
48
|
+
utilizationRate: Number(ts.utilizationRate),
|
|
49
|
+
}),
|
|
50
|
+
),
|
|
51
|
+
}),
|
|
52
|
+
),
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return response;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public async getMetrics(
|
|
59
|
+
options: ChartingOptions = {},
|
|
60
|
+
): Promise<GetBankMetricsResponse> {
|
|
61
|
+
const { fromTime, toTime, aggregationMethod } = options;
|
|
62
|
+
const body = await this.handleApiCall(() =>
|
|
63
|
+
this.http.get(`/bank/metrics`, {
|
|
64
|
+
params: {
|
|
65
|
+
banks: this.banks.map((b) => b.toString()).join(","),
|
|
66
|
+
fromTime: fromTime?.toISOString(),
|
|
67
|
+
toTime: toTime?.toISOString(),
|
|
68
|
+
aggregationMethod,
|
|
69
|
+
},
|
|
31
70
|
}),
|
|
32
71
|
);
|
|
72
|
+
|
|
73
|
+
const jsonResponse: any = JSON.parse(body);
|
|
74
|
+
|
|
75
|
+
const response: GetBankMetricsResponse = {
|
|
76
|
+
banks: jsonResponse.banks.map(
|
|
77
|
+
(bankData: any): BankMetricsEntry => ({
|
|
78
|
+
bank: new web3.PublicKey(bankData.bank),
|
|
79
|
+
timeseries: bankData.timeseries.map(
|
|
80
|
+
(ts: any): BankMetricsTimeseries => ({
|
|
81
|
+
time: new Date(ts.time),
|
|
82
|
+
mint: new web3.PublicKey(ts.mint),
|
|
83
|
+
mintDecimals: Number(ts.mintDecimals),
|
|
84
|
+
mintPrice: Number(ts.mintPrice),
|
|
85
|
+
mintSymbol: String(ts.mintSymbol),
|
|
86
|
+
supplyAmount: Number(ts.supplyAmount),
|
|
87
|
+
supplyValue: Number(ts.supplyValue),
|
|
88
|
+
supplyApy: Number(ts.supplyApy),
|
|
89
|
+
borrowAmount: Number(ts.borrowAmount),
|
|
90
|
+
borrowValue: Number(ts.borrowValue),
|
|
91
|
+
borrowApy: Number(ts.borrowApy),
|
|
92
|
+
utilizationRate: Number(ts.utilizationRate),
|
|
93
|
+
}),
|
|
94
|
+
),
|
|
95
|
+
}),
|
|
96
|
+
),
|
|
97
|
+
};
|
|
98
|
+
|
|
33
99
|
return response;
|
|
34
100
|
}
|
|
35
101
|
}
|
package/src/index.ts
CHANGED
|
@@ -41,10 +41,6 @@ import {
|
|
|
41
41
|
GroupWalletBalances,
|
|
42
42
|
WalletBalances,
|
|
43
43
|
WalletBalancesTimeseries,
|
|
44
|
-
GetBankApysRequest,
|
|
45
|
-
GetBankApysResponse,
|
|
46
|
-
BankApysEntry,
|
|
47
|
-
BankApyTimeseries,
|
|
48
44
|
GetTokenApysRequest,
|
|
49
45
|
GetTokenApysResponse,
|
|
50
46
|
TokenApysEntry,
|
|
@@ -764,45 +760,6 @@ export class Client extends ApiClient {
|
|
|
764
760
|
return response;
|
|
765
761
|
}
|
|
766
762
|
|
|
767
|
-
/**
|
|
768
|
-
* Get bank APY timeseries for one or more banks
|
|
769
|
-
*/
|
|
770
|
-
async getBankApys(request: GetBankApysRequest): Promise<GetBankApysResponse> {
|
|
771
|
-
const { banks, fromTime, toTime, aggregationMethod } = request;
|
|
772
|
-
|
|
773
|
-
const body = await this.handleApiCall(() =>
|
|
774
|
-
this.http.get(`/bank/apys`, {
|
|
775
|
-
params: {
|
|
776
|
-
banks: banks.map((b) => b.toString()).join(","),
|
|
777
|
-
fromTime: fromTime?.toISOString(),
|
|
778
|
-
toTime: toTime?.toISOString(),
|
|
779
|
-
aggregationMethod,
|
|
780
|
-
},
|
|
781
|
-
}),
|
|
782
|
-
);
|
|
783
|
-
|
|
784
|
-
const jsonResponse: any = JSON.parse(body);
|
|
785
|
-
|
|
786
|
-
const response: GetBankApysResponse = {
|
|
787
|
-
banks: jsonResponse.banks.map(
|
|
788
|
-
(bankData: any): BankApysEntry => ({
|
|
789
|
-
bank: new web3.PublicKey(bankData.bank),
|
|
790
|
-
mint: new web3.PublicKey(bankData.mint),
|
|
791
|
-
timeseries: bankData.timeseries.map(
|
|
792
|
-
(ts: any): BankApyTimeseries => ({
|
|
793
|
-
time: new Date(ts.time),
|
|
794
|
-
supplyApy: Number(ts.supplyApy),
|
|
795
|
-
borrowApy: Number(ts.borrowApy),
|
|
796
|
-
utilizationRate: Number(ts.utilizationRate),
|
|
797
|
-
}),
|
|
798
|
-
),
|
|
799
|
-
}),
|
|
800
|
-
),
|
|
801
|
-
};
|
|
802
|
-
|
|
803
|
-
return response;
|
|
804
|
-
}
|
|
805
|
-
|
|
806
763
|
/**
|
|
807
764
|
* Get token yield APY timeseries for one or more mints
|
|
808
765
|
*/
|
|
@@ -860,9 +817,9 @@ export class Client extends ApiClient {
|
|
|
860
817
|
}
|
|
861
818
|
|
|
862
819
|
public async getBankChartingExtension(
|
|
863
|
-
|
|
820
|
+
banks: web3.PublicKey[],
|
|
864
821
|
): Promise<BankChartingExtension> {
|
|
865
|
-
return new BankChartingExtension(this.baseUrl,
|
|
822
|
+
return new BankChartingExtension(this.baseUrl, banks);
|
|
866
823
|
}
|
|
867
824
|
}
|
|
868
825
|
|
package/src/types.ts
CHANGED
|
@@ -406,6 +406,31 @@ export interface GetBankApysResponse {
|
|
|
406
406
|
banks: BankApysEntry[];
|
|
407
407
|
}
|
|
408
408
|
|
|
409
|
+
// Bank metrics time-series
|
|
410
|
+
export interface BankMetricsTimeseries {
|
|
411
|
+
time: Date;
|
|
412
|
+
mint: web3.PublicKey;
|
|
413
|
+
mintDecimals: number;
|
|
414
|
+
mintPrice: number;
|
|
415
|
+
mintSymbol: string;
|
|
416
|
+
supplyAmount: number;
|
|
417
|
+
supplyValue: number;
|
|
418
|
+
supplyApy: number;
|
|
419
|
+
borrowAmount: number;
|
|
420
|
+
borrowValue: number;
|
|
421
|
+
borrowApy: number;
|
|
422
|
+
utilizationRate: number;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
export interface BankMetricsEntry {
|
|
426
|
+
bank: web3.PublicKey;
|
|
427
|
+
timeseries: BankMetricsTimeseries[];
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
export interface GetBankMetricsResponse {
|
|
431
|
+
banks: BankMetricsEntry[];
|
|
432
|
+
}
|
|
433
|
+
|
|
409
434
|
// Token yield APY time-series
|
|
410
435
|
export interface GetTokenApysRequest {
|
|
411
436
|
mints: web3.PublicKey[];
|