@carrot-protocol/boost-http-client 0.2.2 → 0.2.3-withdraw-jlp-dev-e591dae
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 +5 -0
- package/dist/types.d.ts +4 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +11 -0
- package/package.json +1 -1
- package/src/index.ts +5 -0
- package/src/types.ts +4 -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
|
*/
|
|
@@ -291,5 +292,9 @@ function parseBank(bankJson) {
|
|
|
291
292
|
liabilityAmount: new anchor_1.BN(bankJson.liabilityAmount, "hex"),
|
|
292
293
|
liabilityAmountUi: Number(bankJson.liabilityAmountUi),
|
|
293
294
|
price: Number(bankJson.price),
|
|
295
|
+
depositLimit: new anchor_1.BN(bankJson.depositLimit, "hex"),
|
|
296
|
+
depositLimitUi: Number(bankJson.depositLimitUi),
|
|
297
|
+
borrowLimit: new anchor_1.BN(bankJson.borrowLimit, "hex"),
|
|
298
|
+
borrowLimitUi: Number(bankJson.borrowLimitUi),
|
|
294
299
|
};
|
|
295
300
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -104,6 +104,10 @@ export interface Bank {
|
|
|
104
104
|
liabilityAmount: BN;
|
|
105
105
|
liabilityAmountUi: number;
|
|
106
106
|
price: number;
|
|
107
|
+
depositLimit: BN;
|
|
108
|
+
depositLimitUi: number;
|
|
109
|
+
borrowLimit: BN;
|
|
110
|
+
borrowLimitUi: number;
|
|
107
111
|
}
|
|
108
112
|
export interface ClendAccountEvent {
|
|
109
113
|
txSig: string;
|
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
|
@@ -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
|
|
@@ -382,5 +383,9 @@ function parseBank(bankJson: any): Bank {
|
|
|
382
383
|
liabilityAmount: new BN(bankJson.liabilityAmount, "hex"),
|
|
383
384
|
liabilityAmountUi: Number(bankJson.liabilityAmountUi),
|
|
384
385
|
price: Number(bankJson.price),
|
|
386
|
+
depositLimit: new BN(bankJson.depositLimit, "hex"),
|
|
387
|
+
depositLimitUi: Number(bankJson.depositLimitUi),
|
|
388
|
+
borrowLimit: new BN(bankJson.borrowLimit, "hex"),
|
|
389
|
+
borrowLimitUi: Number(bankJson.borrowLimitUi),
|
|
385
390
|
};
|
|
386
391
|
}
|
package/src/types.ts
CHANGED
|
@@ -120,6 +120,10 @@ export interface Bank {
|
|
|
120
120
|
liabilityAmount: BN;
|
|
121
121
|
liabilityAmountUi: number;
|
|
122
122
|
price: number;
|
|
123
|
+
depositLimit: BN;
|
|
124
|
+
depositLimitUi: number;
|
|
125
|
+
borrowLimit: BN;
|
|
126
|
+
borrowLimitUi: number;
|
|
123
127
|
}
|
|
124
128
|
|
|
125
129
|
export interface ClendAccountEvent {
|
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
|
+
}
|