@carrot-protocol/boost-http-client 0.4.8 → 0.5.0-bank-token-apy-timeseries-dev-e208fe4
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 +9 -1
- package/dist/index.js +53 -0
- package/dist/types.d.ts +37 -0
- package/package.json +1 -1
- package/src/index.ts +85 -0
- package/src/types.ts +47 -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, GetUserRequest, GetGroupsResponse, GetAccountResponse, GetAccountRequest, GetWalletBalancesRequest, GetWalletBalancesResponse } from "./types";
|
|
2
|
+
import { GetBankResponse, GetUserResponse, GetGroupResponse, GetUserRequest, GetGroupsResponse, GetAccountResponse, GetAccountRequest, GetWalletBalancesRequest, GetWalletBalancesResponse, GetBankApysRequest, GetBankApysResponse, 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,6 +87,14 @@ 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
|
+
/**
|
|
95
|
+
* Get token yield APY timeseries for one or more mints
|
|
96
|
+
*/
|
|
97
|
+
getTokenApys(request: GetTokenApysRequest): Promise<GetTokenApysResponse>;
|
|
90
98
|
getPerformanceChartingExtension(clendAccount: web3.PublicKey): Promise<PositionChartingExtension>;
|
|
91
99
|
getGroupChartingExtension(group: web3.PublicKey): Promise<GroupChartingExtension>;
|
|
92
100
|
getWalletChartingExtension(address?: web3.PublicKey): Promise<WalletChartingExtension>;
|
package/dist/index.js
CHANGED
|
@@ -507,6 +507,59 @@ 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
|
+
/**
|
|
539
|
+
* Get token yield APY timeseries for one or more mints
|
|
540
|
+
*/
|
|
541
|
+
async getTokenApys(request) {
|
|
542
|
+
const { mints, fromTime, toTime, aggregationMethod } = request;
|
|
543
|
+
const body = await this.handleApiCall(() => this.http.get(`/token/apys`, {
|
|
544
|
+
params: {
|
|
545
|
+
mints: mints.map((m) => m.toString()).join(","),
|
|
546
|
+
fromTime: fromTime?.toISOString(),
|
|
547
|
+
toTime: toTime?.toISOString(),
|
|
548
|
+
aggregationMethod,
|
|
549
|
+
},
|
|
550
|
+
}));
|
|
551
|
+
const jsonResponse = JSON.parse(body);
|
|
552
|
+
const response = {
|
|
553
|
+
tokens: jsonResponse.tokens.map((tokenData) => ({
|
|
554
|
+
mint: new anchor_1.web3.PublicKey(tokenData.mint),
|
|
555
|
+
timeseries: tokenData.timeseries.map((ts) => ({
|
|
556
|
+
time: new Date(ts.time),
|
|
557
|
+
apy: Number(ts.apy),
|
|
558
|
+
})),
|
|
559
|
+
})),
|
|
560
|
+
};
|
|
561
|
+
return response;
|
|
562
|
+
}
|
|
510
563
|
async getPerformanceChartingExtension(clendAccount) {
|
|
511
564
|
return new position_1.PositionChartingExtension(this.baseUrl, clendAccount);
|
|
512
565
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -321,3 +321,40 @@ export interface GroupWalletBalances {
|
|
|
321
321
|
export interface GetWalletBalancesResponse {
|
|
322
322
|
groups: GroupWalletBalances[];
|
|
323
323
|
}
|
|
324
|
+
export interface GetBankApysRequest {
|
|
325
|
+
banks: web3.PublicKey[];
|
|
326
|
+
fromTime?: Date;
|
|
327
|
+
toTime?: Date;
|
|
328
|
+
aggregationMethod?: AggregationMethod;
|
|
329
|
+
}
|
|
330
|
+
export interface BankApyTimeseries {
|
|
331
|
+
time: Date;
|
|
332
|
+
supplyApy: number;
|
|
333
|
+
borrowApy: number;
|
|
334
|
+
utilizationRate: number;
|
|
335
|
+
}
|
|
336
|
+
export interface BankApysEntry {
|
|
337
|
+
bank: web3.PublicKey;
|
|
338
|
+
mint: web3.PublicKey;
|
|
339
|
+
timeseries: BankApyTimeseries[];
|
|
340
|
+
}
|
|
341
|
+
export interface GetBankApysResponse {
|
|
342
|
+
banks: BankApysEntry[];
|
|
343
|
+
}
|
|
344
|
+
export interface GetTokenApysRequest {
|
|
345
|
+
mints: web3.PublicKey[];
|
|
346
|
+
fromTime?: Date;
|
|
347
|
+
toTime?: Date;
|
|
348
|
+
aggregationMethod?: AggregationMethod;
|
|
349
|
+
}
|
|
350
|
+
export interface TokenApyTimeseries {
|
|
351
|
+
time: Date;
|
|
352
|
+
apy: number;
|
|
353
|
+
}
|
|
354
|
+
export interface TokenApysEntry {
|
|
355
|
+
mint: web3.PublicKey;
|
|
356
|
+
timeseries: TokenApyTimeseries[];
|
|
357
|
+
}
|
|
358
|
+
export interface GetTokenApysResponse {
|
|
359
|
+
tokens: TokenApysEntry[];
|
|
360
|
+
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -41,6 +41,14 @@ import {
|
|
|
41
41
|
GroupWalletBalances,
|
|
42
42
|
WalletBalances,
|
|
43
43
|
WalletBalancesTimeseries,
|
|
44
|
+
GetBankApysRequest,
|
|
45
|
+
GetBankApysResponse,
|
|
46
|
+
BankApysEntry,
|
|
47
|
+
BankApyTimeseries,
|
|
48
|
+
GetTokenApysRequest,
|
|
49
|
+
GetTokenApysResponse,
|
|
50
|
+
TokenApysEntry,
|
|
51
|
+
TokenApyTimeseries,
|
|
44
52
|
} from "./types";
|
|
45
53
|
import encode from "bs58";
|
|
46
54
|
import { ApiClient } from "./api";
|
|
@@ -756,6 +764,83 @@ export class Client extends ApiClient {
|
|
|
756
764
|
return response;
|
|
757
765
|
}
|
|
758
766
|
|
|
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
|
+
/**
|
|
807
|
+
* Get token yield APY timeseries for one or more mints
|
|
808
|
+
*/
|
|
809
|
+
async getTokenApys(
|
|
810
|
+
request: GetTokenApysRequest,
|
|
811
|
+
): Promise<GetTokenApysResponse> {
|
|
812
|
+
const { mints, fromTime, toTime, aggregationMethod } = request;
|
|
813
|
+
|
|
814
|
+
const body = await this.handleApiCall(() =>
|
|
815
|
+
this.http.get(`/token/apys`, {
|
|
816
|
+
params: {
|
|
817
|
+
mints: mints.map((m) => m.toString()).join(","),
|
|
818
|
+
fromTime: fromTime?.toISOString(),
|
|
819
|
+
toTime: toTime?.toISOString(),
|
|
820
|
+
aggregationMethod,
|
|
821
|
+
},
|
|
822
|
+
}),
|
|
823
|
+
);
|
|
824
|
+
|
|
825
|
+
const jsonResponse: any = JSON.parse(body);
|
|
826
|
+
|
|
827
|
+
const response: GetTokenApysResponse = {
|
|
828
|
+
tokens: jsonResponse.tokens.map(
|
|
829
|
+
(tokenData: any): TokenApysEntry => ({
|
|
830
|
+
mint: new web3.PublicKey(tokenData.mint),
|
|
831
|
+
timeseries: tokenData.timeseries.map(
|
|
832
|
+
(ts: any): TokenApyTimeseries => ({
|
|
833
|
+
time: new Date(ts.time),
|
|
834
|
+
apy: Number(ts.apy),
|
|
835
|
+
}),
|
|
836
|
+
),
|
|
837
|
+
}),
|
|
838
|
+
),
|
|
839
|
+
};
|
|
840
|
+
|
|
841
|
+
return response;
|
|
842
|
+
}
|
|
843
|
+
|
|
759
844
|
public async getPerformanceChartingExtension(
|
|
760
845
|
clendAccount: web3.PublicKey,
|
|
761
846
|
): Promise<PositionChartingExtension> {
|
package/src/types.ts
CHANGED
|
@@ -380,3 +380,50 @@ export interface GroupWalletBalances {
|
|
|
380
380
|
export interface GetWalletBalancesResponse {
|
|
381
381
|
groups: GroupWalletBalances[];
|
|
382
382
|
}
|
|
383
|
+
|
|
384
|
+
// Bank APY time-series
|
|
385
|
+
export interface GetBankApysRequest {
|
|
386
|
+
banks: web3.PublicKey[];
|
|
387
|
+
fromTime?: Date;
|
|
388
|
+
toTime?: Date;
|
|
389
|
+
aggregationMethod?: AggregationMethod;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
export interface BankApyTimeseries {
|
|
393
|
+
time: Date;
|
|
394
|
+
supplyApy: number;
|
|
395
|
+
borrowApy: number;
|
|
396
|
+
utilizationRate: number;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
export interface BankApysEntry {
|
|
400
|
+
bank: web3.PublicKey;
|
|
401
|
+
mint: web3.PublicKey;
|
|
402
|
+
timeseries: BankApyTimeseries[];
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
export interface GetBankApysResponse {
|
|
406
|
+
banks: BankApysEntry[];
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// Token yield APY time-series
|
|
410
|
+
export interface GetTokenApysRequest {
|
|
411
|
+
mints: web3.PublicKey[];
|
|
412
|
+
fromTime?: Date;
|
|
413
|
+
toTime?: Date;
|
|
414
|
+
aggregationMethod?: AggregationMethod;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
export interface TokenApyTimeseries {
|
|
418
|
+
time: Date;
|
|
419
|
+
apy: number;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export interface TokenApysEntry {
|
|
423
|
+
mint: web3.PublicKey;
|
|
424
|
+
timeseries: TokenApyTimeseries[];
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
export interface GetTokenApysResponse {
|
|
428
|
+
tokens: TokenApysEntry[];
|
|
429
|
+
}
|