@carrot-protocol/boost-http-client 0.2.2 → 0.2.3-withdraw-jlp-dev-c39f2a4

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,6 +1,7 @@
1
1
  import { AnchorProvider, web3 } from "@coral-xyz/anchor";
2
2
  import { GetBankResponse, GetUserResponse, GetGroupResponse } from "./types";
3
3
  export * from "./types";
4
+ export * from "./utils";
4
5
  /**
5
6
  * HTTP Client for Carrot Boost API
6
7
  */
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ const anchor_1 = require("@coral-xyz/anchor");
23
23
  const bs58_1 = __importDefault(require("bs58"));
24
24
  // Re-export types
25
25
  __exportStar(require("./types"), exports);
26
+ __exportStar(require("./utils"), exports);
26
27
  /**
27
28
  * HTTP Client for Carrot Boost API
28
29
  */
@@ -0,0 +1,3 @@
1
+ import { web3 } from "@coral-xyz/anchor";
2
+ import { ClendAccount } from "./types";
3
+ export declare function netValueInToken(clendAccount: ClendAccount, tokenMint: web3.PublicKey): number;
package/dist/utils.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.netValueInToken = netValueInToken;
4
+ // returns the net value of the clend account in a given tokens price
5
+ function netValueInToken(clendAccount, tokenMint) {
6
+ const clendAccountTokenBalance = clendAccount.balances.find((balance) => balance.mint.equals(tokenMint));
7
+ if (!clendAccountTokenBalance) {
8
+ return 0;
9
+ }
10
+ return clendAccount.netValue / clendAccountTokenBalance.price;
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carrot-protocol/boost-http-client",
3
- "version": "0.2.2",
3
+ "version": "0.2.3-withdraw-jlp-dev-c39f2a4",
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
@@ -21,6 +21,7 @@ import encode from "bs58";
21
21
 
22
22
  // Re-export types
23
23
  export * from "./types";
24
+ export * from "./utils";
24
25
 
25
26
  /**
26
27
  * HTTP Client for Carrot Boost API
package/src/utils.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { web3 } from "@coral-xyz/anchor";
2
+ import { ClendAccount } from "./types";
3
+
4
+ // returns the net value of the clend account in a given tokens price
5
+ export function netValueInToken(
6
+ clendAccount: ClendAccount,
7
+ tokenMint: web3.PublicKey,
8
+ ): number {
9
+ const clendAccountTokenBalance = clendAccount.balances.find((balance) =>
10
+ balance.mint.equals(tokenMint),
11
+ );
12
+ if (!clendAccountTokenBalance) {
13
+ return 0;
14
+ }
15
+
16
+ return clendAccount.netValue / clendAccountTokenBalance.price;
17
+ }