@carrot-protocol/boost-http-client 0.4.0-stub-position-endpoints-dev-666335f → 0.4.0-stub-position-endpoints-dev-f996c8b
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 +2 -4
- package/dist/charting/bank/index.js +3 -2
- package/dist/charting/group/index.d.ts +2 -4
- package/dist/charting/group/index.js +3 -2
- package/dist/charting/position/index.d.ts +3 -8
- package/dist/charting/position/index.js +8 -4
- package/dist/charting/wallet/index.d.ts +2 -4
- package/dist/charting/wallet/index.js +3 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +11 -13
- package/dist/types.d.ts +8 -0
- package/package.json +1 -1
- package/src/charting/bank/index.ts +5 -5
- package/src/charting/group/index.ts +5 -3
- package/src/charting/position/index.ts +11 -8
- package/src/charting/wallet/index.ts +5 -3
- package/src/index.ts +22 -17
- package/src/types.ts +11 -0
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { web3 } from "@coral-xyz/anchor";
|
|
2
2
|
import { ApyResponse } from "./types";
|
|
3
|
+
import { DateRangeOptions } from "../../types";
|
|
3
4
|
import { ApiClient } from "../../api";
|
|
4
5
|
export declare class BankChartingExtension extends ApiClient {
|
|
5
6
|
private readonly bank;
|
|
6
7
|
constructor(baseUrl: string, bank: web3.PublicKey);
|
|
7
|
-
getApy(options?:
|
|
8
|
-
fromTime?: Date;
|
|
9
|
-
toTime?: Date;
|
|
10
|
-
}): Promise<ApyResponse[]>;
|
|
8
|
+
getApy(options?: DateRangeOptions): Promise<ApyResponse[]>;
|
|
11
9
|
}
|
|
@@ -8,11 +8,12 @@ class BankChartingExtension extends api_1.ApiClient {
|
|
|
8
8
|
this.bank = bank;
|
|
9
9
|
}
|
|
10
10
|
async getApy(options = {}) {
|
|
11
|
+
const { fromTime, toTime } = options;
|
|
11
12
|
const body = await this.handleApiCall(() => this.http.get(`/bank/apys`, {
|
|
12
13
|
params: {
|
|
13
14
|
bank: this.bank.toString(),
|
|
14
|
-
fromTime:
|
|
15
|
-
toTime:
|
|
15
|
+
fromTime: fromTime?.toISOString(),
|
|
16
|
+
toTime: toTime?.toISOString(),
|
|
16
17
|
},
|
|
17
18
|
}));
|
|
18
19
|
const response = JSON.parse(body).map((apy) => ({
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { web3 } from "@coral-xyz/anchor";
|
|
2
2
|
import { PerformanceResponse } from "./types";
|
|
3
3
|
import { ApiClient } from "../../api";
|
|
4
|
+
import { DateRangeOptions } from "../../types";
|
|
4
5
|
export declare class GroupChartingExtension extends ApiClient {
|
|
5
6
|
private readonly group;
|
|
6
7
|
constructor(baseUrl: string, group: web3.PublicKey);
|
|
7
|
-
getPerformance(options?:
|
|
8
|
-
fromTime?: Date;
|
|
9
|
-
toTime?: Date;
|
|
10
|
-
}): Promise<PerformanceResponse[]>;
|
|
8
|
+
getPerformance(options?: DateRangeOptions): Promise<PerformanceResponse[]>;
|
|
11
9
|
}
|
|
@@ -8,11 +8,12 @@ class GroupChartingExtension extends api_1.ApiClient {
|
|
|
8
8
|
this.group = group;
|
|
9
9
|
}
|
|
10
10
|
async getPerformance(options = {}) {
|
|
11
|
+
const { fromTime, toTime } = options;
|
|
11
12
|
const body = await this.handleApiCall(() => this.http.get(`/group/pnls`, {
|
|
12
13
|
params: {
|
|
13
14
|
group: this.group.toString(),
|
|
14
|
-
fromTime:
|
|
15
|
-
toTime:
|
|
15
|
+
fromTime: fromTime?.toISOString(),
|
|
16
|
+
toTime: toTime?.toISOString(),
|
|
16
17
|
},
|
|
17
18
|
}));
|
|
18
19
|
const response = JSON.parse(body).map((performance) => ({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { web3 } from "@coral-xyz/anchor";
|
|
2
2
|
import { ApyResponse, LoanBalanceResponse, PerformanceResponse } from "./types";
|
|
3
|
+
import { ChartingOptions } from "../../types";
|
|
3
4
|
import { ApiClient } from "../../api";
|
|
4
5
|
export declare class PositionChartingExtension extends ApiClient {
|
|
5
6
|
private readonly clendAccount;
|
|
@@ -8,12 +9,6 @@ export declare class PositionChartingExtension extends ApiClient {
|
|
|
8
9
|
fromTime?: Date;
|
|
9
10
|
toTime?: Date;
|
|
10
11
|
}): Promise<LoanBalanceResponse[]>;
|
|
11
|
-
getPerformance(options?:
|
|
12
|
-
|
|
13
|
-
toTime?: Date;
|
|
14
|
-
}): Promise<PerformanceResponse[]>;
|
|
15
|
-
getApy(options?: {
|
|
16
|
-
fromTime?: Date;
|
|
17
|
-
toTime?: Date;
|
|
18
|
-
}): Promise<ApyResponse[]>;
|
|
12
|
+
getPerformance(options?: ChartingOptions): Promise<PerformanceResponse[]>;
|
|
13
|
+
getApy(options?: ChartingOptions): Promise<ApyResponse[]>;
|
|
19
14
|
}
|
|
@@ -25,11 +25,13 @@ class PositionChartingExtension extends api_1.ApiClient {
|
|
|
25
25
|
return response;
|
|
26
26
|
}
|
|
27
27
|
async getPerformance(options = {}) {
|
|
28
|
+
const { fromTime, toTime, aggregationMethod } = options;
|
|
28
29
|
const body = await this.handleApiCall(() => this.http.get(`/account/performance`, {
|
|
29
30
|
params: {
|
|
30
31
|
account: this.clendAccount.toString(),
|
|
31
|
-
fromTime:
|
|
32
|
-
toTime:
|
|
32
|
+
fromTime: fromTime?.toISOString(),
|
|
33
|
+
toTime: toTime?.toISOString(),
|
|
34
|
+
aggregationMethod,
|
|
33
35
|
},
|
|
34
36
|
}));
|
|
35
37
|
const response = JSON.parse(body).map((performance) => ({
|
|
@@ -41,11 +43,13 @@ class PositionChartingExtension extends api_1.ApiClient {
|
|
|
41
43
|
return response;
|
|
42
44
|
}
|
|
43
45
|
async getApy(options = {}) {
|
|
46
|
+
const { fromTime, toTime, aggregationMethod } = options;
|
|
44
47
|
const body = await this.handleApiCall(() => this.http.get(`/account/apys`, {
|
|
45
48
|
params: {
|
|
46
49
|
account: this.clendAccount.toString(),
|
|
47
|
-
fromTime:
|
|
48
|
-
toTime:
|
|
50
|
+
fromTime: fromTime?.toISOString(),
|
|
51
|
+
toTime: toTime?.toISOString(),
|
|
52
|
+
aggregationMethod,
|
|
49
53
|
},
|
|
50
54
|
}));
|
|
51
55
|
const response = JSON.parse(body).map((apy) => ({
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { web3 } from "@coral-xyz/anchor";
|
|
2
2
|
import { PerformanceResponse } from "./types";
|
|
3
3
|
import { ApiClient } from "../../api";
|
|
4
|
+
import { DateRangeOptions } from "../../types";
|
|
4
5
|
export declare class WalletChartingExtension extends ApiClient {
|
|
5
6
|
private readonly address;
|
|
6
7
|
constructor(baseUrl: string, address: web3.PublicKey);
|
|
7
|
-
getPerformance(options?:
|
|
8
|
-
fromTime?: Date;
|
|
9
|
-
toTime?: Date;
|
|
10
|
-
}): Promise<PerformanceResponse[]>;
|
|
8
|
+
getPerformance(options?: DateRangeOptions): Promise<PerformanceResponse[]>;
|
|
11
9
|
}
|
|
@@ -8,11 +8,12 @@ class WalletChartingExtension extends api_1.ApiClient {
|
|
|
8
8
|
this.address = address;
|
|
9
9
|
}
|
|
10
10
|
async getPerformance(options = {}) {
|
|
11
|
+
const { fromTime, toTime } = options;
|
|
11
12
|
const body = await this.handleApiCall(() => this.http.get(`/user/pnls`, {
|
|
12
13
|
params: {
|
|
13
14
|
authority: this.address.toString(),
|
|
14
|
-
fromTime:
|
|
15
|
-
toTime:
|
|
15
|
+
fromTime: fromTime?.toISOString(),
|
|
16
|
+
toTime: toTime?.toISOString(),
|
|
16
17
|
},
|
|
17
18
|
}));
|
|
18
19
|
const response = JSON.parse(body).map((performance) => ({
|
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
|
|
2
|
+
import { GetBankResponse, GetUserResponse, GetGroupResponse, GetUserRequest, GetGroupsResponse, GetAccountResponse, GetAccountRequest } from "./types";
|
|
3
3
|
import { ApiClient } from "./api";
|
|
4
4
|
import { PositionChartingExtension } from "./charting/position";
|
|
5
5
|
import { BankChartingExtension } from "./charting/bank";
|
|
@@ -79,5 +79,8 @@ export declare class Client extends ApiClient {
|
|
|
79
79
|
* @returns Withdraw emissions operation result
|
|
80
80
|
*/
|
|
81
81
|
withdrawEmissions(clendAccount: web3.PublicKey): Promise<string>;
|
|
82
|
-
|
|
82
|
+
getPerformanceChartingExtension(clendAccount: web3.PublicKey): Promise<PositionChartingExtension>;
|
|
83
|
+
getGroupChartingExtension(group: web3.PublicKey): Promise<GroupChartingExtension>;
|
|
84
|
+
getWalletChartingExtension(address?: web3.PublicKey): Promise<WalletChartingExtension>;
|
|
85
|
+
getBankChartingExtension(bank: web3.PublicKey): Promise<BankChartingExtension>;
|
|
83
86
|
}
|
package/dist/index.js
CHANGED
|
@@ -428,19 +428,17 @@ class Client extends api_1.ApiClient {
|
|
|
428
428
|
const txSig = await this.send(withdrawEmissionsResponse.unsignedBase64Tx, withdrawEmissionsResponse.userRequestId);
|
|
429
429
|
return txSig;
|
|
430
430
|
}
|
|
431
|
-
async
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
throw new Error(`Unknown extension: ${extension}`);
|
|
443
|
-
}
|
|
431
|
+
async getPerformanceChartingExtension(clendAccount) {
|
|
432
|
+
return new position_1.PositionChartingExtension(this.baseUrl, clendAccount);
|
|
433
|
+
}
|
|
434
|
+
async getGroupChartingExtension(group) {
|
|
435
|
+
return new group_1.GroupChartingExtension(this.baseUrl, group);
|
|
436
|
+
}
|
|
437
|
+
async getWalletChartingExtension(address) {
|
|
438
|
+
return new wallet_1.WalletChartingExtension(this.baseUrl, address ?? this.address());
|
|
439
|
+
}
|
|
440
|
+
async getBankChartingExtension(bank) {
|
|
441
|
+
return new bank_1.BankChartingExtension(this.baseUrl, bank);
|
|
444
442
|
}
|
|
445
443
|
}
|
|
446
444
|
exports.Client = Client;
|
package/dist/types.d.ts
CHANGED
|
@@ -251,5 +251,13 @@ export interface UserRequest {
|
|
|
251
251
|
openPosition: boolean | null;
|
|
252
252
|
closePosition: boolean | null;
|
|
253
253
|
}
|
|
254
|
+
export type DateRangeOptions = {
|
|
255
|
+
fromTime?: Date;
|
|
256
|
+
toTime?: Date;
|
|
257
|
+
};
|
|
258
|
+
export type AggregationMethod = "average" | "endOfDay" | "startOfDay";
|
|
259
|
+
export type ChartingOptions = DateRangeOptions & {
|
|
260
|
+
aggregationMethod?: AggregationMethod;
|
|
261
|
+
};
|
|
254
262
|
export type ExtensionKey = "positionCharting" | "groupCharting" | "walletCharting" | "bankCharting";
|
|
255
263
|
export type Extension = InstanceType<typeof PositionChartingExtension> | InstanceType<typeof GroupChartingExtension> | InstanceType<typeof WalletChartingExtension> | InstanceType<typeof BankChartingExtension>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carrot-protocol/boost-http-client",
|
|
3
|
-
"version": "0.4.0-stub-position-endpoints-dev-
|
|
3
|
+
"version": "0.4.0-stub-position-endpoints-dev-f996c8b",
|
|
4
4
|
"description": "HTTP client for Carrot Boost",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { web3 } from "@coral-xyz/anchor";
|
|
2
2
|
import { ApyResponse } from "./types";
|
|
3
|
+
import { DateRangeOptions } from "../../types";
|
|
3
4
|
import { ApiClient } from "../../api";
|
|
4
5
|
|
|
5
6
|
export class BankChartingExtension extends ApiClient {
|
|
@@ -10,15 +11,14 @@ export class BankChartingExtension extends ApiClient {
|
|
|
10
11
|
this.bank = bank;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
public async getApy(
|
|
14
|
-
|
|
15
|
-
): Promise<ApyResponse[]> {
|
|
14
|
+
public async getApy(options: DateRangeOptions = {}): Promise<ApyResponse[]> {
|
|
15
|
+
const { fromTime, toTime } = options;
|
|
16
16
|
const body = await this.handleApiCall(() =>
|
|
17
17
|
this.http.get(`/bank/apys`, {
|
|
18
18
|
params: {
|
|
19
19
|
bank: this.bank.toString(),
|
|
20
|
-
fromTime:
|
|
21
|
-
toTime:
|
|
20
|
+
fromTime: fromTime?.toISOString(),
|
|
21
|
+
toTime: toTime?.toISOString(),
|
|
22
22
|
},
|
|
23
23
|
}),
|
|
24
24
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { web3 } from "@coral-xyz/anchor";
|
|
2
2
|
import { PerformanceResponse } from "./types";
|
|
3
3
|
import { ApiClient } from "../../api";
|
|
4
|
+
import { DateRangeOptions } from "../../types";
|
|
4
5
|
|
|
5
6
|
export class GroupChartingExtension extends ApiClient {
|
|
6
7
|
private readonly group: web3.PublicKey;
|
|
@@ -11,14 +12,15 @@ export class GroupChartingExtension extends ApiClient {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
public async getPerformance(
|
|
14
|
-
options:
|
|
15
|
+
options: DateRangeOptions = {},
|
|
15
16
|
): Promise<PerformanceResponse[]> {
|
|
17
|
+
const { fromTime, toTime } = options;
|
|
16
18
|
const body = await this.handleApiCall(() =>
|
|
17
19
|
this.http.get(`/group/pnls`, {
|
|
18
20
|
params: {
|
|
19
21
|
group: this.group.toString(),
|
|
20
|
-
fromTime:
|
|
21
|
-
toTime:
|
|
22
|
+
fromTime: fromTime?.toISOString(),
|
|
23
|
+
toTime: toTime?.toISOString(),
|
|
22
24
|
},
|
|
23
25
|
}),
|
|
24
26
|
);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { web3 } from "@coral-xyz/anchor";
|
|
2
2
|
import { ApyResponse, LoanBalanceResponse, PerformanceResponse } from "./types";
|
|
3
|
+
import { ChartingOptions } from "../../types";
|
|
3
4
|
import { ApiClient } from "../../api";
|
|
4
5
|
|
|
5
6
|
export class PositionChartingExtension extends ApiClient {
|
|
@@ -42,14 +43,16 @@ export class PositionChartingExtension extends ApiClient {
|
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
public async getPerformance(
|
|
45
|
-
options:
|
|
46
|
+
options: ChartingOptions = {},
|
|
46
47
|
): Promise<PerformanceResponse[]> {
|
|
48
|
+
const { fromTime, toTime, aggregationMethod } = options;
|
|
47
49
|
const body = await this.handleApiCall(() =>
|
|
48
50
|
this.http.get(`/account/performance`, {
|
|
49
51
|
params: {
|
|
50
52
|
account: this.clendAccount.toString(),
|
|
51
|
-
fromTime:
|
|
52
|
-
toTime:
|
|
53
|
+
fromTime: fromTime?.toISOString(),
|
|
54
|
+
toTime: toTime?.toISOString(),
|
|
55
|
+
aggregationMethod,
|
|
53
56
|
},
|
|
54
57
|
}),
|
|
55
58
|
);
|
|
@@ -70,15 +73,15 @@ export class PositionChartingExtension extends ApiClient {
|
|
|
70
73
|
return response;
|
|
71
74
|
}
|
|
72
75
|
|
|
73
|
-
public async getApy(
|
|
74
|
-
|
|
75
|
-
): Promise<ApyResponse[]> {
|
|
76
|
+
public async getApy(options: ChartingOptions = {}): Promise<ApyResponse[]> {
|
|
77
|
+
const { fromTime, toTime, aggregationMethod } = options;
|
|
76
78
|
const body = await this.handleApiCall(() =>
|
|
77
79
|
this.http.get(`/account/apys`, {
|
|
78
80
|
params: {
|
|
79
81
|
account: this.clendAccount.toString(),
|
|
80
|
-
fromTime:
|
|
81
|
-
toTime:
|
|
82
|
+
fromTime: fromTime?.toISOString(),
|
|
83
|
+
toTime: toTime?.toISOString(),
|
|
84
|
+
aggregationMethod,
|
|
82
85
|
},
|
|
83
86
|
}),
|
|
84
87
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { web3 } from "@coral-xyz/anchor";
|
|
2
2
|
import { PerformanceResponse } from "./types";
|
|
3
3
|
import { ApiClient } from "../../api";
|
|
4
|
+
import { DateRangeOptions } from "../../types";
|
|
4
5
|
|
|
5
6
|
export class WalletChartingExtension extends ApiClient {
|
|
6
7
|
private readonly address: web3.PublicKey;
|
|
@@ -11,14 +12,15 @@ export class WalletChartingExtension extends ApiClient {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
public async getPerformance(
|
|
14
|
-
options:
|
|
15
|
+
options: DateRangeOptions = {},
|
|
15
16
|
): Promise<PerformanceResponse[]> {
|
|
17
|
+
const { fromTime, toTime } = options;
|
|
16
18
|
const body = await this.handleApiCall(() =>
|
|
17
19
|
this.http.get(`/user/pnls`, {
|
|
18
20
|
params: {
|
|
19
21
|
authority: this.address.toString(),
|
|
20
|
-
fromTime:
|
|
21
|
-
toTime:
|
|
22
|
+
fromTime: fromTime?.toISOString(),
|
|
23
|
+
toTime: toTime?.toISOString(),
|
|
22
24
|
},
|
|
23
25
|
}),
|
|
24
26
|
);
|
package/src/index.ts
CHANGED
|
@@ -606,23 +606,28 @@ export class Client extends ApiClient {
|
|
|
606
606
|
return txSig;
|
|
607
607
|
}
|
|
608
608
|
|
|
609
|
-
public async
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
609
|
+
public async getPerformanceChartingExtension(
|
|
610
|
+
clendAccount: web3.PublicKey,
|
|
611
|
+
): Promise<PositionChartingExtension> {
|
|
612
|
+
return new PositionChartingExtension(this.baseUrl, clendAccount);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
public async getGroupChartingExtension(
|
|
616
|
+
group: web3.PublicKey,
|
|
617
|
+
): Promise<GroupChartingExtension> {
|
|
618
|
+
return new GroupChartingExtension(this.baseUrl, group);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
public async getWalletChartingExtension(
|
|
622
|
+
address?: web3.PublicKey,
|
|
623
|
+
): Promise<WalletChartingExtension> {
|
|
624
|
+
return new WalletChartingExtension(this.baseUrl, address ?? this.address());
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
public async getBankChartingExtension(
|
|
628
|
+
bank: web3.PublicKey,
|
|
629
|
+
): Promise<BankChartingExtension> {
|
|
630
|
+
return new BankChartingExtension(this.baseUrl, bank);
|
|
626
631
|
}
|
|
627
632
|
}
|
|
628
633
|
|
package/src/types.ts
CHANGED
|
@@ -288,6 +288,17 @@ export interface UserRequest {
|
|
|
288
288
|
closePosition: boolean | null;
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
+
export type DateRangeOptions = {
|
|
292
|
+
fromTime?: Date;
|
|
293
|
+
toTime?: Date;
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
export type AggregationMethod = "average" | "endOfDay" | "startOfDay";
|
|
297
|
+
|
|
298
|
+
export type ChartingOptions = DateRangeOptions & {
|
|
299
|
+
aggregationMethod?: AggregationMethod;
|
|
300
|
+
};
|
|
301
|
+
|
|
291
302
|
export type ExtensionKey =
|
|
292
303
|
| "positionCharting"
|
|
293
304
|
| "groupCharting"
|