@carrot-protocol/boost-http-client 0.1.7-bug-fix-api-integration-dev-4e0eb09 → 0.2.0-mrgn-fork1-dev-be6fd99
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 +5 -9
- package/dist/index.js +8 -17
- package/dist/types.d.ts +6 -11
- package/package.json +1 -1
- package/src/index.ts +11 -37
- package/src/types.ts +6 -11
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnchorProvider, web3 } from "@coral-xyz/anchor";
|
|
2
|
-
import { DepositLeverageRequest,
|
|
2
|
+
import { DepositLeverageRequest, GetBankResponse, GetUserResponse, ModifyLeverageRequest, WithdrawLeverageRequest } from "./types";
|
|
3
3
|
export * from "./types";
|
|
4
4
|
/**
|
|
5
5
|
* HTTP Client for Carrot Boost API
|
|
@@ -27,15 +27,11 @@ export declare class Client {
|
|
|
27
27
|
*/
|
|
28
28
|
getUser(user?: web3.PublicKey): Promise<GetUserResponse>;
|
|
29
29
|
/**
|
|
30
|
-
* Get
|
|
31
|
-
* @
|
|
30
|
+
* Get bank details
|
|
31
|
+
* @param mint token mint of the bank public key
|
|
32
|
+
* @returns Bank details
|
|
32
33
|
*/
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Create an obligation for the client
|
|
36
|
-
* @returns Transaction signature
|
|
37
|
-
*/
|
|
38
|
-
createObligation(): Promise<string>;
|
|
34
|
+
getBank(mint: web3.PublicKey): Promise<GetBankResponse>;
|
|
39
35
|
/**
|
|
40
36
|
* Deposit collateral and create a leveraged position
|
|
41
37
|
* @param request Deposit leverage request parameters
|
package/dist/index.js
CHANGED
|
@@ -110,24 +110,15 @@ class Client {
|
|
|
110
110
|
return response;
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
|
-
* Get
|
|
114
|
-
* @
|
|
113
|
+
* Get bank details
|
|
114
|
+
* @param mint token mint of the bank public key
|
|
115
|
+
* @returns Bank details
|
|
115
116
|
*/
|
|
116
|
-
async
|
|
117
|
-
const body = await handleApiCall(() => this.http.get(`
|
|
117
|
+
async getBank(mint) {
|
|
118
|
+
const body = await handleApiCall(() => this.http.get(`/bank?mint=${mint.toString()}`));
|
|
118
119
|
const response = JSON.parse(body);
|
|
119
120
|
return response;
|
|
120
121
|
}
|
|
121
|
-
/**
|
|
122
|
-
* Create an obligation for the client
|
|
123
|
-
* @returns Transaction signature
|
|
124
|
-
*/
|
|
125
|
-
async createObligation() {
|
|
126
|
-
const body = await handleApiCall(() => this.http.post("createObligation", JSON.stringify({ owner: this.address() })));
|
|
127
|
-
const createObligationResponse = JSON.parse(body);
|
|
128
|
-
const txSig = await this.send(createObligationResponse.unsignedBase64Tx);
|
|
129
|
-
return txSig;
|
|
130
|
-
}
|
|
131
122
|
/**
|
|
132
123
|
* Deposit collateral and create a leveraged position
|
|
133
124
|
* @param request Deposit leverage request parameters
|
|
@@ -136,7 +127,7 @@ class Client {
|
|
|
136
127
|
async depositLeverage(params) {
|
|
137
128
|
const body = await handleApiCall(() => this.http.post("leverage/deposit", JSON.stringify(params)));
|
|
138
129
|
const depositLeverageResponse = JSON.parse(body);
|
|
139
|
-
const txSig = await this.send(depositLeverageResponse.unsignedBase64Tx
|
|
130
|
+
const txSig = await this.send(depositLeverageResponse.unsignedBase64Tx);
|
|
140
131
|
return txSig;
|
|
141
132
|
}
|
|
142
133
|
/**
|
|
@@ -147,7 +138,7 @@ class Client {
|
|
|
147
138
|
async modifyLeverage(params) {
|
|
148
139
|
const body = await handleApiCall(() => this.http.post("leverage/modify", JSON.stringify(params)));
|
|
149
140
|
const modifyLeverageResponse = JSON.parse(body);
|
|
150
|
-
const txSig = await this.send(modifyLeverageResponse.unsignedBase64Tx
|
|
141
|
+
const txSig = await this.send(modifyLeverageResponse.unsignedBase64Tx);
|
|
151
142
|
return txSig;
|
|
152
143
|
}
|
|
153
144
|
/**
|
|
@@ -158,7 +149,7 @@ class Client {
|
|
|
158
149
|
async withdrawLeverage(params) {
|
|
159
150
|
const body = await handleApiCall(() => this.http.post("leverage/withdraw", JSON.stringify(params)));
|
|
160
151
|
const withdrawLeverageResponse = JSON.parse(body);
|
|
161
|
-
const txSig = await this.send(withdrawLeverageResponse.unsignedBase64Tx
|
|
152
|
+
const txSig = await this.send(withdrawLeverageResponse.unsignedBase64Tx);
|
|
162
153
|
return txSig;
|
|
163
154
|
}
|
|
164
155
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -24,7 +24,6 @@ export interface DepositLeverageRequest {
|
|
|
24
24
|
*/
|
|
25
25
|
export interface DepositLeverageResponse {
|
|
26
26
|
unsignedBase64Tx: string;
|
|
27
|
-
signedSetBorrowRateBase64Tx: string;
|
|
28
27
|
}
|
|
29
28
|
/**
|
|
30
29
|
* Request to modify the leverage of an existing position
|
|
@@ -39,7 +38,6 @@ export interface ModifyLeverageRequest {
|
|
|
39
38
|
*/
|
|
40
39
|
export interface ModifyLeverageResponse {
|
|
41
40
|
unsignedBase64Tx: string;
|
|
42
|
-
signedSetBorrowRateBase64Tx: string;
|
|
43
41
|
}
|
|
44
42
|
/**
|
|
45
43
|
* Request to withdraw from a leveraged position
|
|
@@ -56,7 +54,6 @@ export interface WithdrawLeverageRequest {
|
|
|
56
54
|
*/
|
|
57
55
|
export interface WithdrawLeverageResponse {
|
|
58
56
|
unsignedBase64Tx: string;
|
|
59
|
-
signedSetBorrowRateBase64Tx: string;
|
|
60
57
|
}
|
|
61
58
|
export interface GetUserResponse {
|
|
62
59
|
netValue: number;
|
|
@@ -73,15 +70,13 @@ export interface GetUserResponse {
|
|
|
73
70
|
jlpBalanceUi: number;
|
|
74
71
|
solBalance: BN;
|
|
75
72
|
solBalanceUi: number;
|
|
76
|
-
obligationCreated: boolean;
|
|
77
73
|
}
|
|
78
|
-
export interface
|
|
74
|
+
export interface GetBankResponse {
|
|
79
75
|
totalBorrowTVL: number;
|
|
80
76
|
totalSupplyTVL: number;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
jlpPrice: number;
|
|
77
|
+
supplyApy: number;
|
|
78
|
+
borrowApy: number;
|
|
79
|
+
supplyAmount: number;
|
|
80
|
+
borrowAmount: number;
|
|
81
|
+
price: number;
|
|
87
82
|
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import axios, { AxiosInstance, AxiosError, AxiosResponse } from "axios";
|
|
2
2
|
import { AnchorProvider, Wallet, web3 } from "@coral-xyz/anchor";
|
|
3
3
|
import {
|
|
4
|
-
CreateObligationResponse,
|
|
5
4
|
DepositLeverageRequest,
|
|
6
5
|
DepositLeverageResponse,
|
|
7
|
-
|
|
6
|
+
GetBankResponse,
|
|
8
7
|
GetUserResponse,
|
|
9
8
|
ModifyLeverageRequest,
|
|
10
9
|
ModifyLeverageResponse,
|
|
@@ -106,34 +105,18 @@ export class Client {
|
|
|
106
105
|
}
|
|
107
106
|
|
|
108
107
|
/**
|
|
109
|
-
* Get
|
|
110
|
-
* @
|
|
108
|
+
* Get bank details
|
|
109
|
+
* @param mint token mint of the bank public key
|
|
110
|
+
* @returns Bank details
|
|
111
111
|
*/
|
|
112
|
-
async
|
|
113
|
-
const body = await handleApiCall(() => this.http.get(`market`));
|
|
114
|
-
|
|
115
|
-
const response: GetMarketResponse = JSON.parse(body);
|
|
116
|
-
|
|
117
|
-
return response;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Create an obligation for the client
|
|
122
|
-
* @returns Transaction signature
|
|
123
|
-
*/
|
|
124
|
-
async createObligation(): Promise<string> {
|
|
112
|
+
async getBank(mint: web3.PublicKey): Promise<GetBankResponse> {
|
|
125
113
|
const body = await handleApiCall(() =>
|
|
126
|
-
this.http.
|
|
127
|
-
"createObligation",
|
|
128
|
-
JSON.stringify({ owner: this.address() }),
|
|
129
|
-
),
|
|
114
|
+
this.http.get(`/bank?mint=${mint.toString()}`),
|
|
130
115
|
);
|
|
131
116
|
|
|
132
|
-
const
|
|
117
|
+
const response: GetBankResponse = JSON.parse(body);
|
|
133
118
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return txSig;
|
|
119
|
+
return response;
|
|
137
120
|
}
|
|
138
121
|
|
|
139
122
|
/**
|
|
@@ -148,10 +131,7 @@ export class Client {
|
|
|
148
131
|
|
|
149
132
|
const depositLeverageResponse: DepositLeverageResponse = JSON.parse(body);
|
|
150
133
|
|
|
151
|
-
const txSig = await this.send(
|
|
152
|
-
depositLeverageResponse.unsignedBase64Tx,
|
|
153
|
-
depositLeverageResponse.signedSetBorrowRateBase64Tx,
|
|
154
|
-
);
|
|
134
|
+
const txSig = await this.send(depositLeverageResponse.unsignedBase64Tx);
|
|
155
135
|
|
|
156
136
|
return txSig;
|
|
157
137
|
}
|
|
@@ -168,10 +148,7 @@ export class Client {
|
|
|
168
148
|
|
|
169
149
|
const modifyLeverageResponse: ModifyLeverageResponse = JSON.parse(body);
|
|
170
150
|
|
|
171
|
-
const txSig = await this.send(
|
|
172
|
-
modifyLeverageResponse.unsignedBase64Tx,
|
|
173
|
-
modifyLeverageResponse.signedSetBorrowRateBase64Tx,
|
|
174
|
-
);
|
|
151
|
+
const txSig = await this.send(modifyLeverageResponse.unsignedBase64Tx);
|
|
175
152
|
|
|
176
153
|
return txSig;
|
|
177
154
|
}
|
|
@@ -188,10 +165,7 @@ export class Client {
|
|
|
188
165
|
|
|
189
166
|
const withdrawLeverageResponse: WithdrawLeverageResponse = JSON.parse(body);
|
|
190
167
|
|
|
191
|
-
const txSig = await this.send(
|
|
192
|
-
withdrawLeverageResponse.unsignedBase64Tx,
|
|
193
|
-
withdrawLeverageResponse.signedSetBorrowRateBase64Tx,
|
|
194
|
-
);
|
|
168
|
+
const txSig = await this.send(withdrawLeverageResponse.unsignedBase64Tx);
|
|
195
169
|
|
|
196
170
|
return txSig;
|
|
197
171
|
}
|
package/src/types.ts
CHANGED
|
@@ -30,7 +30,6 @@ export interface DepositLeverageRequest {
|
|
|
30
30
|
*/
|
|
31
31
|
export interface DepositLeverageResponse {
|
|
32
32
|
unsignedBase64Tx: string;
|
|
33
|
-
signedSetBorrowRateBase64Tx: string;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
/**
|
|
@@ -47,7 +46,6 @@ export interface ModifyLeverageRequest {
|
|
|
47
46
|
*/
|
|
48
47
|
export interface ModifyLeverageResponse {
|
|
49
48
|
unsignedBase64Tx: string;
|
|
50
|
-
signedSetBorrowRateBase64Tx: string;
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
/**
|
|
@@ -66,7 +64,6 @@ export interface WithdrawLeverageRequest {
|
|
|
66
64
|
*/
|
|
67
65
|
export interface WithdrawLeverageResponse {
|
|
68
66
|
unsignedBase64Tx: string;
|
|
69
|
-
signedSetBorrowRateBase64Tx: string;
|
|
70
67
|
}
|
|
71
68
|
|
|
72
69
|
export interface GetUserResponse {
|
|
@@ -84,16 +81,14 @@ export interface GetUserResponse {
|
|
|
84
81
|
jlpBalanceUi: number;
|
|
85
82
|
solBalance: BN;
|
|
86
83
|
solBalanceUi: number;
|
|
87
|
-
obligationCreated: boolean;
|
|
88
84
|
}
|
|
89
85
|
|
|
90
|
-
export interface
|
|
86
|
+
export interface GetBankResponse {
|
|
91
87
|
totalBorrowTVL: number;
|
|
92
88
|
totalSupplyTVL: number;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
jlpPrice: number;
|
|
89
|
+
supplyApy: number;
|
|
90
|
+
borrowApy: number;
|
|
91
|
+
supplyAmount: number;
|
|
92
|
+
borrowAmount: number;
|
|
93
|
+
price: number;
|
|
99
94
|
}
|