@haven-fi/solauto-sdk 1.0.64 → 1.0.65
Sign up to get free protection for your applications and to get access to all the features.
@@ -10,10 +10,10 @@ export declare function findMarginfiAccounts({ mint, bank, }: {
|
|
10
10
|
}): MarginfiAssetAccounts;
|
11
11
|
export declare function getMaxLtvAndLiqThreshold(umi: Umi, supply: {
|
12
12
|
mint: PublicKey;
|
13
|
-
bank
|
13
|
+
bank?: Bank | null;
|
14
14
|
}, debt: {
|
15
15
|
mint: PublicKey;
|
16
|
-
bank
|
16
|
+
bank?: Bank | null;
|
17
17
|
}, supplyPrice?: number): Promise<[number, number]>;
|
18
18
|
export declare function getAllMarginfiAccountsByAuthority(umi: Umi, authority: PublicKey, compatibleWithSolauto?: boolean): Promise<{
|
19
19
|
marginfiAccount: PublicKey;
|
@@ -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;AAUzB,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,EACnC,IAAI,EACJ,IAAI,GACL,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,qBAAqB,CAWxB;AAED,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,GAAG,EACR,MAAM,EAAE;IACN,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;
|
1
|
+
{"version":3,"file":"marginfiUtils.d.ts","sour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,EAAE,SAAS,EACpB,mBAAmB,CAAC,EAAE,mBAAmB,GACxC,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CA+IpC;AA+DD,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA0B3B"}
|
@@ -28,12 +28,12 @@ function findMarginfiAccounts({ mint, bank, }) {
|
|
28
28
|
throw new Error(`Marginfi accounts not found by the mint: ${mint}`);
|
29
29
|
}
|
30
30
|
async function getMaxLtvAndLiqThreshold(umi, supply, debt, supplyPrice) {
|
31
|
-
if (!supply.bank) {
|
31
|
+
if (!supply.bank || supply.bank === null) {
|
32
32
|
supply.bank = await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(findMarginfiAccounts({
|
33
33
|
mint: supply.mint.toString(),
|
34
34
|
}).bank));
|
35
35
|
}
|
36
|
-
if (!debt.bank && !debt.mint.equals(web3_js_1.PublicKey.default)) {
|
36
|
+
if ((!debt.bank || debt.bank === null) && !debt.mint.equals(web3_js_1.PublicKey.default)) {
|
37
37
|
debt.bank = await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(findMarginfiAccounts({
|
38
38
|
mint: debt.mint.toString(),
|
39
39
|
}).bank));
|
@@ -44,7 +44,7 @@ async function getMaxLtvAndLiqThreshold(umi, supply, debt, supplyPrice) {
|
|
44
44
|
]);
|
45
45
|
supplyPrice = price;
|
46
46
|
}
|
47
|
-
if (debt.bank === null) {
|
47
|
+
if (!debt.bank || debt.bank === null) {
|
48
48
|
return [0, 0];
|
49
49
|
}
|
50
50
|
let maxLtv = (0, numberUtils_1.bytesToI80F48)(supply.bank.config.assetWeightInit.value) /
|
package/package.json
CHANGED
@@ -46,15 +46,15 @@ export async function getMaxLtvAndLiqThreshold(
|
|
46
46
|
umi: Umi,
|
47
47
|
supply: {
|
48
48
|
mint: PublicKey;
|
49
|
-
bank
|
49
|
+
bank?: Bank | null;
|
50
50
|
},
|
51
51
|
debt: {
|
52
52
|
mint: PublicKey;
|
53
|
-
bank
|
53
|
+
bank?: Bank | null;
|
54
54
|
},
|
55
55
|
supplyPrice?: number
|
56
56
|
): Promise<[number, number]> {
|
57
|
-
if (!supply.bank) {
|
57
|
+
if (!supply.bank || supply.bank === null) {
|
58
58
|
supply.bank = await safeFetchBank(
|
59
59
|
umi,
|
60
60
|
publicKey(
|
@@ -65,7 +65,7 @@ export async function getMaxLtvAndLiqThreshold(
|
|
65
65
|
);
|
66
66
|
}
|
67
67
|
|
68
|
-
if (!debt.bank && !debt.mint.equals(PublicKey.default)) {
|
68
|
+
if ((!debt.bank || debt.bank === null) && !debt.mint.equals(PublicKey.default)) {
|
69
69
|
debt.bank = await safeFetchBank(
|
70
70
|
umi,
|
71
71
|
publicKey(
|
@@ -83,7 +83,7 @@ export async function getMaxLtvAndLiqThreshold(
|
|
83
83
|
supplyPrice = price;
|
84
84
|
}
|
85
85
|
|
86
|
-
if (debt.bank === null) {
|
86
|
+
if (!debt.bank || debt.bank === null) {
|
87
87
|
return [0, 0];
|
88
88
|
}
|
89
89
|
|