@carrot-protocol/boost-http-client 0.1.3 → 0.1.4-set-borrow-rate-dev-eca8f55

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 { DepositLeverageRequest, ModifyLeverageRequest, WithdrawLeverageRequest } from "./types";
2
+ import { DepositLeverageRequest, GetMarketResponse, GetObligationResponse, ModifyLeverageRequest, WithdrawLeverageRequest } from "./types";
3
3
  export * from "./types";
4
4
  /**
5
5
  * HTTP Client for Carrot Boost API
@@ -25,12 +25,12 @@ export declare class Client {
25
25
  * @param owner Owner wallet public key
26
26
  * @returns Obligation details
27
27
  */
28
- getObligation(owner: web3.PublicKey): Promise<any>;
28
+ getObligation(owner: web3.PublicKey): Promise<GetObligationResponse>;
29
29
  /**
30
30
  * Get market details for the carrot boost market
31
31
  * @returns Market details
32
32
  */
33
- getMarket(): Promise<any>;
33
+ getMarket(): Promise<GetMarketResponse>;
34
34
  /**
35
35
  * Create an obligation for the client
36
36
  * @returns Transaction signature
package/dist/index.js CHANGED
@@ -102,7 +102,8 @@ class Client {
102
102
  */
103
103
  async getObligation(owner) {
104
104
  const body = await handleApiCall(() => this.http.get(`/obligation?owner=${owner.toString()}`));
105
- return body;
105
+ const response = JSON.parse(body);
106
+ return response;
106
107
  }
107
108
  /**
108
109
  * Get market details for the carrot boost market
@@ -110,7 +111,8 @@ class Client {
110
111
  */
111
112
  async getMarket() {
112
113
  const body = await handleApiCall(() => this.http.get(`market`));
113
- return body;
114
+ const response = JSON.parse(body);
115
+ return response;
114
116
  }
115
117
  /**
116
118
  * Create an obligation for the client
package/dist/types.d.ts CHANGED
@@ -14,8 +14,6 @@ export interface CreateObligationResponse {
14
14
  */
15
15
  export interface DepositLeverageRequest {
16
16
  owner: web3.PublicKey;
17
- collateralMint: web3.PublicKey;
18
- debtMint: web3.PublicKey;
19
17
  selectedTokenMint: web3.PublicKey;
20
18
  depositAmount: Decimal;
21
19
  leverage: number;
@@ -32,8 +30,6 @@ export interface DepositLeverageResponse {
32
30
  */
33
31
  export interface ModifyLeverageRequest {
34
32
  owner: web3.PublicKey;
35
- collateralMint: web3.PublicKey;
36
- debtMint: web3.PublicKey;
37
33
  leverage: number;
38
34
  slippagePct: number;
39
35
  }
@@ -48,8 +44,6 @@ export interface ModifyLeverageResponse {
48
44
  */
49
45
  export interface WithdrawLeverageRequest {
50
46
  owner: web3.PublicKey;
51
- collateralMint: web3.PublicKey;
52
- debtMint: web3.PublicKey;
53
47
  selectedTokenMint: web3.PublicKey;
54
48
  withdrawAmount: Decimal;
55
49
  slippagePct: number;
@@ -61,3 +55,21 @@ export interface WithdrawLeverageRequest {
61
55
  export interface WithdrawLeverageResponse {
62
56
  unsignedBase64Tx: string;
63
57
  }
58
+ export interface GetObligationResponse {
59
+ netValue: number;
60
+ pnl: number;
61
+ netAPY: number;
62
+ leverage: number;
63
+ totalCollateral: number;
64
+ totalDebt: number;
65
+ ltv: number;
66
+ liquidationLtv: number;
67
+ }
68
+ export interface GetMarketResponse {
69
+ totalBorrowTVL: number;
70
+ totalSupplyTVL: number;
71
+ usdcSupplyApy: number;
72
+ usdcBorrowApy: number;
73
+ usdcSupplyAmount: number;
74
+ usdcBorrowAmount: number;
75
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carrot-protocol/boost-http-client",
3
- "version": "0.1.3",
3
+ "version": "0.1.4-set-borrow-rate-dev-eca8f55",
4
4
  "description": "HTTP client for Carrot Boost API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -4,6 +4,8 @@ import {
4
4
  CreateObligationResponse,
5
5
  DepositLeverageRequest,
6
6
  DepositLeverageResponse,
7
+ GetMarketResponse,
8
+ GetObligationResponse,
7
9
  ModifyLeverageRequest,
8
10
  ModifyLeverageResponse,
9
11
  SendRequest,
@@ -85,20 +87,26 @@ export class Client {
85
87
  * @param owner Owner wallet public key
86
88
  * @returns Obligation details
87
89
  */
88
- async getObligation(owner: web3.PublicKey): Promise<any> {
90
+ async getObligation(owner: web3.PublicKey): Promise<GetObligationResponse> {
89
91
  const body = await handleApiCall(() =>
90
92
  this.http.get(`/obligation?owner=${owner.toString()}`),
91
93
  );
92
- return body;
94
+
95
+ const response: GetObligationResponse = JSON.parse(body);
96
+
97
+ return response;
93
98
  }
94
99
 
95
100
  /**
96
101
  * Get market details for the carrot boost market
97
102
  * @returns Market details
98
103
  */
99
- async getMarket(): Promise<any> {
104
+ async getMarket(): Promise<GetMarketResponse> {
100
105
  const body = await handleApiCall(() => this.http.get(`market`));
101
- return body;
106
+
107
+ const response: GetMarketResponse = JSON.parse(body);
108
+
109
+ return response;
102
110
  }
103
111
 
104
112
  /**
package/src/types.ts CHANGED
@@ -19,8 +19,6 @@ export interface CreateObligationResponse {
19
19
  */
20
20
  export interface DepositLeverageRequest {
21
21
  owner: web3.PublicKey;
22
- collateralMint: web3.PublicKey;
23
- debtMint: web3.PublicKey;
24
22
  selectedTokenMint: web3.PublicKey;
25
23
  depositAmount: Decimal;
26
24
  leverage: number;
@@ -39,8 +37,6 @@ export interface DepositLeverageResponse {
39
37
  */
40
38
  export interface ModifyLeverageRequest {
41
39
  owner: web3.PublicKey;
42
- collateralMint: web3.PublicKey;
43
- debtMint: web3.PublicKey;
44
40
  leverage: number;
45
41
  slippagePct: number;
46
42
  }
@@ -57,8 +53,6 @@ export interface ModifyLeverageResponse {
57
53
  */
58
54
  export interface WithdrawLeverageRequest {
59
55
  owner: web3.PublicKey;
60
- collateralMint: web3.PublicKey;
61
- debtMint: web3.PublicKey;
62
56
  selectedTokenMint: web3.PublicKey;
63
57
  withdrawAmount: Decimal;
64
58
  slippagePct: number;
@@ -71,3 +65,23 @@ export interface WithdrawLeverageRequest {
71
65
  export interface WithdrawLeverageResponse {
72
66
  unsignedBase64Tx: string;
73
67
  }
68
+
69
+ export interface GetObligationResponse {
70
+ netValue: number;
71
+ pnl: number;
72
+ netAPY: number;
73
+ leverage: number;
74
+ totalCollateral: number;
75
+ totalDebt: number;
76
+ ltv: number;
77
+ liquidationLtv: number;
78
+ }
79
+
80
+ export interface GetMarketResponse {
81
+ totalBorrowTVL: number;
82
+ totalSupplyTVL: number;
83
+ usdcSupplyApy: number;
84
+ usdcBorrowApy: number;
85
+ usdcSupplyAmount: number;
86
+ usdcBorrowAmount: number;
87
+ }