@carrot-protocol/boost-http-client 0.2.2-more-math-dev-0eb87da → 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 +1 -0
- package/dist/index.js +1 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +11 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/utils.ts +17 -0
package/dist/index.d.ts
CHANGED
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
|
*/
|
package/dist/utils.d.ts
ADDED
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
package/src/index.ts
CHANGED
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
|
+
}
|