@carrot-protocol/boost-http-client 0.2.3-withdraw-jlp-dev-c39f2a4 → 0.2.3-withdraw-jlp-dev-4ead85f
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 -2
- package/dist/index.js +7 -2
- package/dist/types.d.ts +8 -0
- package/package.json +1 -1
- package/src/index.ts +10 -2
- package/src/types.ts +9 -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 } from "./types";
|
|
2
|
+
import { GetBankResponse, GetUserResponse, GetGroupResponse, GetUserRequest } from "./types";
|
|
3
3
|
export * from "./types";
|
|
4
4
|
export * from "./utils";
|
|
5
5
|
/**
|
|
@@ -26,7 +26,7 @@ export declare class Client {
|
|
|
26
26
|
* @param user wallet public key
|
|
27
27
|
* @returns User details
|
|
28
28
|
*/
|
|
29
|
-
getUser(
|
|
29
|
+
getUser(request: GetUserRequest): Promise<GetUserResponse>;
|
|
30
30
|
/**
|
|
31
31
|
* Get market details
|
|
32
32
|
* @returns Group Details
|
package/dist/index.js
CHANGED
|
@@ -79,12 +79,13 @@ class Client {
|
|
|
79
79
|
* @param user wallet public key
|
|
80
80
|
* @returns User details
|
|
81
81
|
*/
|
|
82
|
-
async getUser(
|
|
82
|
+
async getUser(request) {
|
|
83
83
|
// use loaded wallet if not provided
|
|
84
|
+
let user = request.user;
|
|
84
85
|
if (!user) {
|
|
85
86
|
user = this.address();
|
|
86
87
|
}
|
|
87
|
-
const body = await handleApiCall(() => this.http.get(`/user?user=${user.toString()}`));
|
|
88
|
+
const body = await handleApiCall(() => this.http.get(`/user?user=${user.toString()}&getClendEvents=${request.getClendEvents}`));
|
|
88
89
|
const jsonRawResponse = JSON.parse(body);
|
|
89
90
|
// get tokens still in user wallet
|
|
90
91
|
const wallet = {
|
|
@@ -292,5 +293,9 @@ function parseBank(bankJson) {
|
|
|
292
293
|
liabilityAmount: new anchor_1.BN(bankJson.liabilityAmount, "hex"),
|
|
293
294
|
liabilityAmountUi: Number(bankJson.liabilityAmountUi),
|
|
294
295
|
price: Number(bankJson.price),
|
|
296
|
+
depositLimit: new anchor_1.BN(bankJson.depositLimit, "hex"),
|
|
297
|
+
depositLimitUi: Number(bankJson.depositLimitUi),
|
|
298
|
+
borrowLimit: new anchor_1.BN(bankJson.borrowLimit, "hex"),
|
|
299
|
+
borrowLimitUi: Number(bankJson.borrowLimitUi),
|
|
295
300
|
};
|
|
296
301
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -51,6 +51,10 @@ export interface WithdrawLeverageResponse {
|
|
|
51
51
|
export interface GetGroupResponse {
|
|
52
52
|
banks: Bank[];
|
|
53
53
|
}
|
|
54
|
+
export interface GetUserRequest {
|
|
55
|
+
user?: web3.PublicKey;
|
|
56
|
+
getClendEvents?: boolean;
|
|
57
|
+
}
|
|
54
58
|
export interface GetUserResponse {
|
|
55
59
|
wallet: UserWallet;
|
|
56
60
|
clendAccount: ClendAccount | undefined;
|
|
@@ -104,6 +108,10 @@ export interface Bank {
|
|
|
104
108
|
liabilityAmount: BN;
|
|
105
109
|
liabilityAmountUi: number;
|
|
106
110
|
price: number;
|
|
111
|
+
depositLimit: BN;
|
|
112
|
+
depositLimitUi: number;
|
|
113
|
+
borrowLimit: BN;
|
|
114
|
+
borrowLimitUi: number;
|
|
107
115
|
}
|
|
108
116
|
export interface ClendAccountEvent {
|
|
109
117
|
txSig: string;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
Bank,
|
|
17
17
|
GetGroupResponse,
|
|
18
18
|
ClendAccountEvent,
|
|
19
|
+
GetUserRequest,
|
|
19
20
|
} from "./types";
|
|
20
21
|
import encode from "bs58";
|
|
21
22
|
|
|
@@ -93,14 +94,17 @@ export class Client {
|
|
|
93
94
|
* @param user wallet public key
|
|
94
95
|
* @returns User details
|
|
95
96
|
*/
|
|
96
|
-
async getUser(
|
|
97
|
+
async getUser(request: GetUserRequest): Promise<GetUserResponse> {
|
|
97
98
|
// use loaded wallet if not provided
|
|
99
|
+
let user = request.user;
|
|
98
100
|
if (!user) {
|
|
99
101
|
user = this.address();
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
const body = await handleApiCall(() =>
|
|
103
|
-
this.http.get(
|
|
105
|
+
this.http.get(
|
|
106
|
+
`/user?user=${user.toString()}&getClendEvents=${request.getClendEvents}`,
|
|
107
|
+
),
|
|
104
108
|
);
|
|
105
109
|
|
|
106
110
|
const jsonRawResponse: any = JSON.parse(body);
|
|
@@ -383,5 +387,9 @@ function parseBank(bankJson: any): Bank {
|
|
|
383
387
|
liabilityAmount: new BN(bankJson.liabilityAmount, "hex"),
|
|
384
388
|
liabilityAmountUi: Number(bankJson.liabilityAmountUi),
|
|
385
389
|
price: Number(bankJson.price),
|
|
390
|
+
depositLimit: new BN(bankJson.depositLimit, "hex"),
|
|
391
|
+
depositLimitUi: Number(bankJson.depositLimitUi),
|
|
392
|
+
borrowLimit: new BN(bankJson.borrowLimit, "hex"),
|
|
393
|
+
borrowLimitUi: Number(bankJson.borrowLimitUi),
|
|
386
394
|
};
|
|
387
395
|
}
|
package/src/types.ts
CHANGED
|
@@ -62,6 +62,11 @@ export interface GetGroupResponse {
|
|
|
62
62
|
banks: Bank[];
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
export interface GetUserRequest {
|
|
66
|
+
user?: web3.PublicKey;
|
|
67
|
+
getClendEvents?: boolean;
|
|
68
|
+
}
|
|
69
|
+
|
|
65
70
|
export interface GetUserResponse {
|
|
66
71
|
wallet: UserWallet;
|
|
67
72
|
clendAccount: ClendAccount | undefined;
|
|
@@ -120,6 +125,10 @@ export interface Bank {
|
|
|
120
125
|
liabilityAmount: BN;
|
|
121
126
|
liabilityAmountUi: number;
|
|
122
127
|
price: number;
|
|
128
|
+
depositLimit: BN;
|
|
129
|
+
depositLimitUi: number;
|
|
130
|
+
borrowLimit: BN;
|
|
131
|
+
borrowLimitUi: number;
|
|
123
132
|
}
|
|
124
133
|
|
|
125
134
|
export interface ClendAccountEvent {
|