@carrot-protocol/boost-http-client 0.2.14 → 0.2.15-group-refactor1-dev-616fdaa

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AnchorProvider, web3 } from "@coral-xyz/anchor";
2
- import { GetBankResponse, GetUserResponse, GetGroupResponse, GetUserRequest, GetGroupRequest } from "./types";
2
+ import { GetBankResponse, GetUserResponse, GetGroupResponse, GetUserRequest } from "./types";
3
3
  export * from "./types";
4
4
  export * from "./utils";
5
5
  export * as Common from "@carrot-protocol/clend-common";
@@ -30,22 +30,22 @@ export declare class Client {
30
30
  getUser(request: GetUserRequest): Promise<GetUserResponse>;
31
31
  /**
32
32
  * Get market details
33
- * @returns Group Details
33
+ * @param groupAddress group public key
34
+ * @returns Group Details, which is really just all the bank data for that group
34
35
  */
35
- getGroup(request: GetGroupRequest): Promise<GetGroupResponse>;
36
+ getGroup(groupAddress: web3.PublicKey): Promise<GetGroupResponse>;
36
37
  /**
37
38
  * Get bank details
38
- * @param addr token mint or bank public key
39
- * @param addrType "mint" or "bank"
39
+ * @param bankAddress bank public key
40
40
  * @returns Bank details
41
41
  */
42
- getBank(addr: web3.PublicKey, addrType: "mint" | "bank"): Promise<GetBankResponse>;
42
+ getBank(bankAddress: web3.PublicKey): Promise<GetBankResponse>;
43
43
  /**
44
44
  * Deposit collateral and create a leveraged position
45
45
  * @param request Deposit leverage request parameters
46
46
  * @returns Deposit leverage operation result
47
47
  */
48
- depositLeverage(selectedTokenMint: web3.PublicKey, uiAmount: number, leverage: number, slippageBps: number): Promise<string>;
48
+ depositLeverage(inputMint: web3.PublicKey, assetMint: web3.PublicKey, liabilityMint: web3.PublicKey, uiAmount: number, leverage: number, slippageBps: number): Promise<string>;
49
49
  /**
50
50
  * Adjust the leverage of an existing position
51
51
  * @param request Adjust leverage request parameters
package/dist/index.js CHANGED
@@ -223,10 +223,11 @@ class Client {
223
223
  }
224
224
  /**
225
225
  * Get market details
226
- * @returns Group Details
226
+ * @param groupAddress group public key
227
+ * @returns Group Details, which is really just all the bank data for that group
227
228
  */
228
- async getGroup(request) {
229
- const body = await handleApiCall(() => this.http.get(`/group?group=${request.group.toString()}`));
229
+ async getGroup(groupAddress) {
230
+ const body = await handleApiCall(() => this.http.get(`/group?group=${groupAddress.toString()}`));
230
231
  const marketJson = JSON.parse(body);
231
232
  const banks = [];
232
233
  for (const bankJson of marketJson.banks) {
@@ -240,12 +241,11 @@ class Client {
240
241
  }
241
242
  /**
242
243
  * Get bank details
243
- * @param addr token mint or bank public key
244
- * @param addrType "mint" or "bank"
244
+ * @param bankAddress bank public key
245
245
  * @returns Bank details
246
246
  */
247
- async getBank(addr, addrType) {
248
- const body = await handleApiCall(() => this.http.get(`/bank?${addrType}=${addr.toString()}`));
247
+ async getBank(bankAddress) {
248
+ const body = await handleApiCall(() => this.http.get(`/bank?bank=${bankAddress.toString()}`));
249
249
  const bankJson = JSON.parse(body);
250
250
  const bank = parseBank(bankJson.bank);
251
251
  const response = {
@@ -258,10 +258,15 @@ class Client {
258
258
  * @param request Deposit leverage request parameters
259
259
  * @returns Deposit leverage operation result
260
260
  */
261
- async depositLeverage(selectedTokenMint, uiAmount, leverage, slippageBps) {
261
+ async depositLeverage(inputMint, assetMint, liabilityMint, uiAmount, leverage, slippageBps) {
262
+ if (!inputMint.equals(assetMint) || !inputMint.equals(liabilityMint)) {
263
+ throw new Error("Input mint must be the same as the asset or liability mint");
264
+ }
262
265
  const req = {
263
266
  owner: this.address(),
264
- selectedTokenMint,
267
+ inputMint,
268
+ assetMint,
269
+ liabilityMint,
265
270
  depositAmountUi: uiAmount,
266
271
  leverage,
267
272
  slippageBps,
package/dist/types.d.ts CHANGED
@@ -8,7 +8,9 @@ export interface SendRequest {
8
8
  */
9
9
  export interface DepositLeverageRequest {
10
10
  owner: web3.PublicKey;
11
- selectedTokenMint: web3.PublicKey;
11
+ inputMint: web3.PublicKey;
12
+ assetMint: web3.PublicKey;
13
+ liabilityMint: web3.PublicKey;
12
14
  depositAmountUi: number;
13
15
  leverage: number;
14
16
  slippageBps: number;
@@ -52,9 +54,6 @@ export interface WithdrawLeverageResponse {
52
54
  userRequestId: string;
53
55
  unsignedBase64Tx: string;
54
56
  }
55
- export interface GetGroupRequest {
56
- group: web3.PublicKey;
57
- }
58
57
  export interface GetGroupResponse {
59
58
  banks: Bank[];
60
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carrot-protocol/boost-http-client",
3
- "version": "0.2.14",
3
+ "version": "0.2.15-group-refactor1-dev-616fdaa",
4
4
  "description": "HTTP client for Carrot Boost",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -19,7 +19,6 @@ import {
19
19
  GetUserRequest,
20
20
  ClendAccountTxSummary,
21
21
  UserRequest,
22
- GetGroupRequest,
23
22
  } from "./types";
24
23
  import encode from "bs58";
25
24
 
@@ -249,11 +248,12 @@ export class Client {
249
248
 
250
249
  /**
251
250
  * Get market details
252
- * @returns Group Details
251
+ * @param groupAddress group public key
252
+ * @returns Group Details, which is really just all the bank data for that group
253
253
  */
254
- async getGroup(request: GetGroupRequest): Promise<GetGroupResponse> {
254
+ async getGroup(groupAddress: web3.PublicKey): Promise<GetGroupResponse> {
255
255
  const body = await handleApiCall(() =>
256
- this.http.get(`/group?group=${request.group.toString()}`),
256
+ this.http.get(`/group?group=${groupAddress.toString()}`),
257
257
  );
258
258
 
259
259
  const marketJson: any = JSON.parse(body);
@@ -272,16 +272,12 @@ export class Client {
272
272
 
273
273
  /**
274
274
  * Get bank details
275
- * @param addr token mint or bank public key
276
- * @param addrType "mint" or "bank"
275
+ * @param bankAddress bank public key
277
276
  * @returns Bank details
278
277
  */
279
- async getBank(
280
- addr: web3.PublicKey,
281
- addrType: "mint" | "bank",
282
- ): Promise<GetBankResponse> {
278
+ async getBank(bankAddress: web3.PublicKey): Promise<GetBankResponse> {
283
279
  const body = await handleApiCall(() =>
284
- this.http.get(`/bank?${addrType}=${addr.toString()}`),
280
+ this.http.get(`/bank?bank=${bankAddress.toString()}`),
285
281
  );
286
282
 
287
283
  const bankJson: any = JSON.parse(body);
@@ -300,14 +296,24 @@ export class Client {
300
296
  * @returns Deposit leverage operation result
301
297
  */
302
298
  async depositLeverage(
303
- selectedTokenMint: web3.PublicKey,
299
+ inputMint: web3.PublicKey,
300
+ assetMint: web3.PublicKey,
301
+ liabilityMint: web3.PublicKey,
304
302
  uiAmount: number,
305
303
  leverage: number,
306
304
  slippageBps: number,
307
305
  ): Promise<string> {
306
+ if (!inputMint.equals(assetMint) || !inputMint.equals(liabilityMint)) {
307
+ throw new Error(
308
+ "Input mint must be the same as the asset or liability mint",
309
+ );
310
+ }
311
+
308
312
  const req: DepositLeverageRequest = {
309
313
  owner: this.address(),
310
- selectedTokenMint,
314
+ inputMint,
315
+ assetMint,
316
+ liabilityMint,
311
317
  depositAmountUi: uiAmount,
312
318
  leverage,
313
319
  slippageBps,
package/src/types.ts CHANGED
@@ -11,7 +11,9 @@ export interface SendRequest {
11
11
  */
12
12
  export interface DepositLeverageRequest {
13
13
  owner: web3.PublicKey;
14
- selectedTokenMint: web3.PublicKey;
14
+ inputMint: web3.PublicKey;
15
+ assetMint: web3.PublicKey;
16
+ liabilityMint: web3.PublicKey;
15
17
  depositAmountUi: number;
16
18
  leverage: number;
17
19
  slippageBps: number;
@@ -61,10 +63,6 @@ export interface WithdrawLeverageResponse {
61
63
  unsignedBase64Tx: string;
62
64
  }
63
65
 
64
- export interface GetGroupRequest {
65
- group: web3.PublicKey;
66
- }
67
-
68
66
  export interface GetGroupResponse {
69
67
  banks: Bank[];
70
68
  }