@0dotxyz/p0-ts-sdk 2.2.4 → 2.2.5-alpha.0
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.cjs +11 -75
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -63
- package/dist/index.d.ts +3 -63
- package/dist/index.js +12 -75
- package/dist/index.js.map +1 -1
- package/dist/instructions.d.cts +1 -1
- package/dist/instructions.d.ts +1 -1
- package/dist/{types-DuCxJVOn.d.ts → types-CZtn4lP8.d.ts} +4 -4
- package/dist/{types-CsLjciLo.d.cts → types-Dw9hSftB.d.cts} +4 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20878,62 +20878,6 @@ function computeHealthComponentsFromBalances(params) {
|
|
|
20878
20878
|
}
|
|
20879
20879
|
return { assets: totalAssets, liabilities: totalLiabilities };
|
|
20880
20880
|
}
|
|
20881
|
-
function computeHealthComponentsWithoutBiasFromBalances(params) {
|
|
20882
|
-
const {
|
|
20883
|
-
activeBalances,
|
|
20884
|
-
banksMap,
|
|
20885
|
-
oraclePricesByBank,
|
|
20886
|
-
marginRequirement,
|
|
20887
|
-
assetShareValueMultiplierByBank,
|
|
20888
|
-
activeEmodeWeightsByBank,
|
|
20889
|
-
excludedBanks
|
|
20890
|
-
} = params;
|
|
20891
|
-
const filteredBalances = activeBalances.filter(
|
|
20892
|
-
(accountBalance) => !(excludedBanks ?? []).find((b) => b.equals(accountBalance.bankPk))
|
|
20893
|
-
);
|
|
20894
|
-
let totalAssets = new BigNumber3__default.default(0);
|
|
20895
|
-
let totalLiabilities = new BigNumber3__default.default(0);
|
|
20896
|
-
for (const accountBalance of filteredBalances) {
|
|
20897
|
-
const bankKey = accountBalance.bankPk.toBase58();
|
|
20898
|
-
const bank = banksMap.get(bankKey);
|
|
20899
|
-
if (!bank) {
|
|
20900
|
-
console.warn(
|
|
20901
|
-
`Bank ${shortenAddress(accountBalance.bankPk)} not found, excluding from health computation`
|
|
20902
|
-
);
|
|
20903
|
-
continue;
|
|
20904
|
-
}
|
|
20905
|
-
const oraclePrice = oraclePricesByBank.get(bankKey);
|
|
20906
|
-
if (!oraclePrice) {
|
|
20907
|
-
console.warn(
|
|
20908
|
-
`Price info for bank ${shortenAddress(accountBalance.bankPk)} not found, excluding from health computation`
|
|
20909
|
-
);
|
|
20910
|
-
continue;
|
|
20911
|
-
}
|
|
20912
|
-
const emodeWeight = activeEmodeWeightsByBank?.get(bankKey);
|
|
20913
|
-
const assetShareValueMultiplier = assetShareValueMultiplierByBank?.get(bankKey);
|
|
20914
|
-
const activeEmodeWeights = emodeWeight ? {
|
|
20915
|
-
assetWeightInit: BigNumber3__default.default.max(
|
|
20916
|
-
bank.config.assetWeightInit,
|
|
20917
|
-
emodeWeight.assetWeightInit ?? bank.config.assetWeightInit
|
|
20918
|
-
),
|
|
20919
|
-
assetWeightMaint: BigNumber3__default.default.max(
|
|
20920
|
-
bank.config.assetWeightMaint,
|
|
20921
|
-
emodeWeight.assetWeightMaint ?? bank.config.assetWeightMaint
|
|
20922
|
-
)
|
|
20923
|
-
} : void 0;
|
|
20924
|
-
const { assets, liabilities } = computeBalanceUsdValue({
|
|
20925
|
-
balance: accountBalance,
|
|
20926
|
-
bank,
|
|
20927
|
-
oraclePrice,
|
|
20928
|
-
marginRequirement,
|
|
20929
|
-
activeEmodeWeights,
|
|
20930
|
-
assetShareValueMultiplier
|
|
20931
|
-
});
|
|
20932
|
-
totalAssets = totalAssets.plus(assets);
|
|
20933
|
-
totalLiabilities = totalLiabilities.plus(liabilities);
|
|
20934
|
-
}
|
|
20935
|
-
return { assets: totalAssets, liabilities: totalLiabilities };
|
|
20936
|
-
}
|
|
20937
20881
|
function computeHealthCacheStatus(params) {
|
|
20938
20882
|
const {
|
|
20939
20883
|
activeBalances,
|
|
@@ -20942,7 +20886,7 @@ function computeHealthCacheStatus(params) {
|
|
|
20942
20886
|
assetShareValueMultiplierByBank,
|
|
20943
20887
|
activeEmodeWeightsByBank
|
|
20944
20888
|
} = params;
|
|
20945
|
-
const { assets: assetValueEquity, liabilities: liabilityValueEquity } =
|
|
20889
|
+
const { assets: assetValueEquity, liabilities: liabilityValueEquity } = computeHealthComponentsFromBalances({
|
|
20946
20890
|
activeBalances,
|
|
20947
20891
|
marginRequirement: 2 /* Equity */,
|
|
20948
20892
|
banksMap,
|
|
@@ -48617,7 +48561,7 @@ async function simulateAccountHealthCacheWithFallback(params) {
|
|
|
48617
48561
|
} = params;
|
|
48618
48562
|
let marginfiAccount = params.marginfiAccount;
|
|
48619
48563
|
const activeBalances = marginfiAccount.balances.filter((b) => b.active);
|
|
48620
|
-
const { assets: assetValueEquity, liabilities: liabilityValueEquity } =
|
|
48564
|
+
const { assets: assetValueEquity, liabilities: liabilityValueEquity } = computeHealthComponentsFromBalances({
|
|
48621
48565
|
activeBalances,
|
|
48622
48566
|
banksMap,
|
|
48623
48567
|
oraclePricesByBank,
|
|
@@ -51498,7 +51442,7 @@ function mergeOracleResults(results, allBanks) {
|
|
|
51498
51442
|
|
|
51499
51443
|
// src/services/bank/utils/compute/value-computations.utils.ts
|
|
51500
51444
|
function isWeightedPrice(marginRequirement) {
|
|
51501
|
-
return marginRequirement === 0 /* Initial */;
|
|
51445
|
+
return marginRequirement === 0 /* Initial */ || marginRequirement === 2 /* Equity */;
|
|
51502
51446
|
}
|
|
51503
51447
|
function getAssetWeight(params) {
|
|
51504
51448
|
const {
|
|
@@ -51509,6 +51453,12 @@ function getAssetWeight(params) {
|
|
|
51509
51453
|
activeEmodeWeights,
|
|
51510
51454
|
ignoreSoftLimits
|
|
51511
51455
|
} = params;
|
|
51456
|
+
if (bank.config.riskTier === "Isolated" /* Isolated */) {
|
|
51457
|
+
return new BigNumber3__default.default(0);
|
|
51458
|
+
}
|
|
51459
|
+
if (marginRequirement === 0 /* Initial */ && bank.config.operationalState === "ReduceOnly" /* ReduceOnly */) {
|
|
51460
|
+
return new BigNumber3__default.default(0);
|
|
51461
|
+
}
|
|
51512
51462
|
const assetWeightInit = BigNumber3__default.default.max(
|
|
51513
51463
|
activeEmodeWeights?.assetWeightInit ?? BigNumber3__default.default(0),
|
|
51514
51464
|
bank.config.assetWeightInit
|
|
@@ -51525,6 +51475,8 @@ function getAssetWeight(params) {
|
|
|
51525
51475
|
bank,
|
|
51526
51476
|
oraclePrice,
|
|
51527
51477
|
assetShares: bank.totalAssetShares,
|
|
51478
|
+
// Unweighted (Equity => weight 1) total bank value, priced at the same time-weighted
|
|
51479
|
+
// low price used for the Initial balance valuation (program: maybe_get_asset_weight_init_discount).
|
|
51528
51480
|
marginRequirement: 2 /* Equity */,
|
|
51529
51481
|
priceBias: 0 /* Lowest */,
|
|
51530
51482
|
assetShareValueMultiplier,
|
|
@@ -53947,21 +53899,6 @@ var MarginfiAccount = class _MarginfiAccount {
|
|
|
53947
53899
|
...params
|
|
53948
53900
|
});
|
|
53949
53901
|
}
|
|
53950
|
-
/**
|
|
53951
|
-
* Computes health components from balances without price bias.
|
|
53952
|
-
*
|
|
53953
|
-
* Returns weighted asset and liability values using neutral pricing
|
|
53954
|
-
* (no conservative adjustments).
|
|
53955
|
-
*
|
|
53956
|
-
* @param params - Configuration for health computation (excluding activeBalances)
|
|
53957
|
-
* @returns Object containing assets and liabilities values in USD
|
|
53958
|
-
*/
|
|
53959
|
-
computeHealthComponentsWithoutBiasFromBalances(params) {
|
|
53960
|
-
return computeHealthComponentsWithoutBiasFromBalances({
|
|
53961
|
-
activeBalances: this.activeBalances,
|
|
53962
|
-
...params
|
|
53963
|
-
});
|
|
53964
|
-
}
|
|
53965
53902
|
/**
|
|
53966
53903
|
* Computes the total account value (equity).
|
|
53967
53904
|
*
|
|
@@ -55809,7 +55746,6 @@ exports.computeHealthCacheStatus = computeHealthCacheStatus;
|
|
|
55809
55746
|
exports.computeHealthCheckAccounts = computeHealthCheckAccounts;
|
|
55810
55747
|
exports.computeHealthComponentsFromBalances = computeHealthComponentsFromBalances;
|
|
55811
55748
|
exports.computeHealthComponentsFromCache = computeHealthComponentsFromCache;
|
|
55812
|
-
exports.computeHealthComponentsWithoutBiasFromBalances = computeHealthComponentsWithoutBiasFromBalances;
|
|
55813
55749
|
exports.computeInterestRates = computeInterestRates;
|
|
55814
55750
|
exports.computeLiabilityHealthComponent = computeLiabilityHealthComponent;
|
|
55815
55751
|
exports.computeLiabilityUsdValue = computeLiabilityUsdValue;
|