@haven-fi/solauto-sdk 1.0.297 → 1.0.299
Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,7 @@ interface AllMarginfiAssetAccounts extends MarginfiAssetAccounts {
|
|
8
8
|
mint: PublicKey;
|
9
9
|
}
|
10
10
|
export declare function findMarginfiAccounts(bank: PublicKey): AllMarginfiAssetAccounts;
|
11
|
-
export declare function
|
11
|
+
export declare function calcMaxLtvAndLiqThreshold(supplyBank: Bank, debtBank: Bank, supplyPrice: number): [number, number];
|
12
12
|
export declare function getMaxLtvAndLiqThreshold(umi: Umi, marginfiGroup: PublicKey, supply: {
|
13
13
|
mint: PublicKey;
|
14
14
|
bank?: Bank | null;
|
@@ -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,EAGJ,eAAe,EAGhB,MAAM,iBAAiB,CAAC;AAiBzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAsB,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D,UAAU,wBAAyB,SAAQ,qBAAqB;IAC9D,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,GAAG,wBAAwB,CAY9E;AAED,wBAAgB,
|
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,EAGJ,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AAM,GAAG;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAA;CAAE,CAAC;AAEhE,wBAAsB,+BAA+B,CACnD,GAAG,EAAE,GAAG,EACR,eAAe,EAAE;IAAE,EAAE,EAAE,SAAS,CAAC;IAAC,IAAI,CAAC,EAAE,eAAe,CAAA;CAAE,EAC1D,aAAa,CAAC,EAAE,SAAS,EACzB,MAAM,CAAC,EAAE,aAAa,EACtB,IAAI,CAAC,EAAE,aAAa,EACpB,mBAAmB,CAAC,EAAE,mBAAmB,GACxC,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CA0LpC;AA+DD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,oBAU7C;AAED,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAgB3B"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.findMarginfiAccounts = findMarginfiAccounts;
|
4
|
-
exports.
|
4
|
+
exports.calcMaxLtvAndLiqThreshold = calcMaxLtvAndLiqThreshold;
|
5
5
|
exports.getMaxLtvAndLiqThreshold = getMaxLtvAndLiqThreshold;
|
6
6
|
exports.getAllMarginfiAccountsByAuthority = getAllMarginfiAccountsByAuthority;
|
7
7
|
exports.getMarginfiAccountPositionState = getMarginfiAccountPositionState;
|
@@ -27,7 +27,7 @@ function findMarginfiAccounts(bank) {
|
|
27
27
|
}
|
28
28
|
throw new Error(`Marginfi accounts not found by the bank: ${bank}`);
|
29
29
|
}
|
30
|
-
function
|
30
|
+
function calcMaxLtvAndLiqThreshold(supplyBank, debtBank, supplyPrice) {
|
31
31
|
let maxLtv = (0, numberUtils_1.bytesToI80F48)(supplyBank.config.assetWeightInit.value) /
|
32
32
|
(0, numberUtils_1.bytesToI80F48)(debtBank.config.liabilityWeightInit.value);
|
33
33
|
const liqThreshold = (0, numberUtils_1.bytesToI80F48)(supplyBank.config.assetWeightMaint.value) /
|
@@ -38,7 +38,7 @@ function marginfiMaxLtvAndLiqThresholdBps(supplyBank, debtBank, supplyPrice) {
|
|
38
38
|
totalDepositedUsdValue > supplyBank.config.totalAssetValueInitLimit) {
|
39
39
|
const discount = Number(supplyBank.config.totalAssetValueInitLimit) /
|
40
40
|
totalDepositedUsdValue;
|
41
|
-
maxLtv =
|
41
|
+
maxLtv = maxLtv * Number(discount);
|
42
42
|
}
|
43
43
|
return [maxLtv, liqThreshold];
|
44
44
|
}
|
@@ -62,7 +62,7 @@ async function getMaxLtvAndLiqThreshold(umi, marginfiGroup, supply, debt, supply
|
|
62
62
|
if (!debt.bank || debt.bank === null) {
|
63
63
|
return [0, 0];
|
64
64
|
}
|
65
|
-
return
|
65
|
+
return calcMaxLtvAndLiqThreshold(supply.bank, debt.bank, supplyPrice);
|
66
66
|
}
|
67
67
|
async function getAllMarginfiAccountsByAuthority(umi, authority, compatibleWithSolauto) {
|
68
68
|
const marginfiAccounts = await umi.rpc.getProgramAccounts(marginfi_sdk_1.MARGINFI_PROGRAM_ID, {
|
package/package.json
CHANGED
@@ -49,7 +49,7 @@ export function findMarginfiAccounts(bank: PublicKey): AllMarginfiAssetAccounts
|
|
49
49
|
throw new Error(`Marginfi accounts not found by the bank: ${bank}`);
|
50
50
|
}
|
51
51
|
|
52
|
-
export function
|
52
|
+
export function calcMaxLtvAndLiqThreshold(
|
53
53
|
supplyBank: Bank,
|
54
54
|
debtBank: Bank,
|
55
55
|
supplyPrice: number
|
@@ -78,7 +78,7 @@ export function marginfiMaxLtvAndLiqThresholdBps(
|
|
78
78
|
const discount =
|
79
79
|
Number(supplyBank.config.totalAssetValueInitLimit) /
|
80
80
|
totalDepositedUsdValue;
|
81
|
-
maxLtv =
|
81
|
+
maxLtv = maxLtv * Number(discount);
|
82
82
|
}
|
83
83
|
|
84
84
|
return [maxLtv, liqThreshold];
|
@@ -135,7 +135,7 @@ export async function getMaxLtvAndLiqThreshold(
|
|
135
135
|
return [0, 0];
|
136
136
|
}
|
137
137
|
|
138
|
-
return
|
138
|
+
return calcMaxLtvAndLiqThreshold(supply.bank!, debt.bank, supplyPrice);
|
139
139
|
}
|
140
140
|
|
141
141
|
export async function getAllMarginfiAccountsByAuthority(
|