@haven-fi/solauto-sdk 1.0.77 → 1.0.79
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/constants/tokenConstants.d.ts.map +1 -1
- package/dist/constants/tokenConstants.js +4 -0
- package/dist/utils/marginfiUtils.d.ts.map +1 -1
- package/dist/utils/marginfiUtils.js +3 -0
- package/package.json +1 -1
- package/src/constants/tokenConstants.ts +4 -0
- package/src/utils/marginfiUtils.ts +4 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"tokenConstants.d.ts","sourceRoot":"","sources":["../../src/constants/tokenConstants.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"tokenConstants.d.ts","sourceRoot":"","sources":["../../src/constants/tokenConstants.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,SAAS,iDAAiD,CAAC;AACxE,eAAO,MAAM,KAAK,gDAAgD,CAAC;AACnE,eAAO,MAAM,GAAG,gDAAgD,CAAC;AAGjE,eAAO,MAAM,oBAAoB,UAKhC,CAAC;AAEF,UAAU,SAAS;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,UAAU,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAkBlD,CAAC"}
|
@@ -2,6 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.TOKEN_INFO = exports.ALL_SUPPORTED_TOKENS = exports.JUP = exports.B_SOL = exports.USDC_MINT = void 0;
|
4
4
|
const spl_token_1 = require("@solana/spl-token");
|
5
|
+
const web3_js_1 = require("@solana/web3.js");
|
5
6
|
// When adding token ensure a price feed is provided in pythConstants.ts & the token is in TOKEN_INFO
|
6
7
|
exports.USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
7
8
|
exports.B_SOL = "bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1";
|
@@ -13,6 +14,9 @@ exports.ALL_SUPPORTED_TOKENS = [
|
|
13
14
|
exports.JUP,
|
14
15
|
];
|
15
16
|
exports.TOKEN_INFO = {
|
17
|
+
[web3_js_1.PublicKey.default.toString()]: {
|
18
|
+
decimals: 1
|
19
|
+
},
|
16
20
|
[spl_token_1.NATIVE_MINT.toString()]: {
|
17
21
|
decimals: 9,
|
18
22
|
},
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"marginfiUtils.d.ts","sourceRoot":"","sources":["../../src/utils/marginfiUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EACL,IAAI,EAKL,MAAM,iBAAiB,CAAC;AAWzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAsB,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,GAAG,qBAAqB,CAU3E;AAED,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,GAAG,EACR,MAAM,EAAE;IACN,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACpB,EACD,IAAI,EAAE;IACJ,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACpB,EACD,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,
|
1
|
+
{"version":3,"file":"marginfiUtils.d.ts","sourceRoot":"","sources":["../../src/utils/marginfiUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC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AAM,EAAE,MAAM,CAAC,CAAC,CA0B3B"}
|
@@ -25,6 +25,9 @@ function findMarginfiAccounts(bank) {
|
|
25
25
|
throw new Error(`Marginfi accounts not found by the bank: ${bank}`);
|
26
26
|
}
|
27
27
|
async function getMaxLtvAndLiqThreshold(umi, supply, debt, supplyPrice) {
|
28
|
+
if (!supply.bank && supply.mint.equals(web3_js_1.PublicKey.default)) {
|
29
|
+
return [0, 0];
|
30
|
+
}
|
28
31
|
if (!supply.bank || supply.bank === null) {
|
29
32
|
supply.bank = await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[supply.mint.toString()].bank));
|
30
33
|
}
|
package/package.json
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { NATIVE_MINT } from "@solana/spl-token";
|
2
|
+
import { PublicKey } from "@solana/web3.js";
|
2
3
|
|
3
4
|
// When adding token ensure a price feed is provided in pythConstants.ts & the token is in TOKEN_INFO
|
4
5
|
export const USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
@@ -20,6 +21,9 @@ interface TokenInfo {
|
|
20
21
|
}
|
21
22
|
|
22
23
|
export const TOKEN_INFO: { [key: string]: TokenInfo } = {
|
24
|
+
[PublicKey.default.toString()]: {
|
25
|
+
decimals: 1
|
26
|
+
},
|
23
27
|
[NATIVE_MINT.toString()]: {
|
24
28
|
decimals: 9,
|
25
29
|
},
|
@@ -48,6 +48,10 @@ export async function getMaxLtvAndLiqThreshold(
|
|
48
48
|
},
|
49
49
|
supplyPrice?: number
|
50
50
|
): Promise<[number, number]> {
|
51
|
+
if (!supply.bank && supply.mint.equals(PublicKey.default)) {
|
52
|
+
return [0, 0];
|
53
|
+
}
|
54
|
+
|
51
55
|
if (!supply.bank || supply.bank === null) {
|
52
56
|
supply.bank = await safeFetchBank(
|
53
57
|
umi,
|