@0dotxyz/p0-ts-sdk 2.2.0-alpha.6 → 2.2.0-alpha.7
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 +83 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +93 -1
- package/dist/index.d.ts +93 -1
- package/dist/index.js +73 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -51683,6 +51683,78 @@ function computeRemainingCapacity(bank) {
|
|
|
51683
51683
|
};
|
|
51684
51684
|
}
|
|
51685
51685
|
|
|
51686
|
+
// src/services/bank/utils/bank-metrics.utils.ts
|
|
51687
|
+
function computeBankTotalDeposits(bank, assetShareValueMultiplier) {
|
|
51688
|
+
const totalAssets = getTotalAssetQuantity(bank).times(
|
|
51689
|
+
assetShareValueMultiplier ?? 1
|
|
51690
|
+
);
|
|
51691
|
+
return nativeToUi(totalAssets, bank.mintDecimals);
|
|
51692
|
+
}
|
|
51693
|
+
function computeBankTotalBorrows(bank) {
|
|
51694
|
+
return nativeToUi(getTotalLiabilityQuantity(bank), bank.mintDecimals);
|
|
51695
|
+
}
|
|
51696
|
+
function computeBankTotalDepositsUsd(bank, oraclePrice, assetShareValueMultiplier) {
|
|
51697
|
+
return computeUsdValue({
|
|
51698
|
+
bank,
|
|
51699
|
+
oraclePrice,
|
|
51700
|
+
quantity: getTotalAssetQuantity(bank),
|
|
51701
|
+
priceBias: 1 /* None */,
|
|
51702
|
+
isWeightedPrice: false,
|
|
51703
|
+
assetShareValueMultiplier
|
|
51704
|
+
}).toNumber();
|
|
51705
|
+
}
|
|
51706
|
+
function computeBankTotalBorrowsUsd(bank, oraclePrice) {
|
|
51707
|
+
return computeUsdValue({
|
|
51708
|
+
bank,
|
|
51709
|
+
oraclePrice,
|
|
51710
|
+
quantity: getTotalLiabilityQuantity(bank),
|
|
51711
|
+
priceBias: 1 /* None */,
|
|
51712
|
+
isWeightedPrice: false
|
|
51713
|
+
}).toNumber();
|
|
51714
|
+
}
|
|
51715
|
+
function computeBankPoolSize(bank, assetShareValueMultiplier) {
|
|
51716
|
+
const totalDeposits = computeBankTotalDeposits(bank, assetShareValueMultiplier);
|
|
51717
|
+
const totalBorrows = computeBankTotalBorrows(bank);
|
|
51718
|
+
const borrowCap = nativeToUi(bank.config.borrowLimit, bank.mintDecimals);
|
|
51719
|
+
return Math.max(0, Math.min(totalDeposits, borrowCap) - totalBorrows);
|
|
51720
|
+
}
|
|
51721
|
+
function computeBankDepositCapRemaining(bank) {
|
|
51722
|
+
const { depositCapacity } = computeRemainingCapacity(bank);
|
|
51723
|
+
return Math.max(0, nativeToUi(depositCapacity, bank.mintDecimals));
|
|
51724
|
+
}
|
|
51725
|
+
function computeBankBorrowCapRemaining(bank) {
|
|
51726
|
+
const { borrowCapacity } = computeRemainingCapacity(bank);
|
|
51727
|
+
return Math.max(0, nativeToUi(borrowCapacity, bank.mintDecimals));
|
|
51728
|
+
}
|
|
51729
|
+
function computeBankSupplyApy(bank) {
|
|
51730
|
+
return aprToApy(computeInterestRates(bank).lendingRate.toNumber());
|
|
51731
|
+
}
|
|
51732
|
+
function computeBankBorrowApy(bank) {
|
|
51733
|
+
return aprToApy(computeInterestRates(bank).borrowingRate.toNumber());
|
|
51734
|
+
}
|
|
51735
|
+
function computeBankMetrics(params) {
|
|
51736
|
+
const { bank, oraclePrice, assetShareValueMultiplier, symbol = "" } = params;
|
|
51737
|
+
return {
|
|
51738
|
+
symbol,
|
|
51739
|
+
totalDeposits: computeBankTotalDeposits(bank, assetShareValueMultiplier),
|
|
51740
|
+
totalBorrows: computeBankTotalBorrows(bank),
|
|
51741
|
+
totalDepositsUsd: computeBankTotalDepositsUsd(
|
|
51742
|
+
bank,
|
|
51743
|
+
oraclePrice,
|
|
51744
|
+
assetShareValueMultiplier
|
|
51745
|
+
),
|
|
51746
|
+
totalBorrowsUsd: computeBankTotalBorrowsUsd(bank, oraclePrice),
|
|
51747
|
+
utilizationRate: computeUtilizationRate(bank).toNumber(),
|
|
51748
|
+
poolSize: computeBankPoolSize(bank, assetShareValueMultiplier),
|
|
51749
|
+
depositCap: nativeToUi(bank.config.depositLimit, bank.mintDecimals),
|
|
51750
|
+
borrowCap: nativeToUi(bank.config.borrowLimit, bank.mintDecimals),
|
|
51751
|
+
depositCapRemaining: computeBankDepositCapRemaining(bank),
|
|
51752
|
+
borrowCapRemaining: computeBankBorrowCapRemaining(bank),
|
|
51753
|
+
supplyApy: computeBankSupplyApy(bank),
|
|
51754
|
+
borrowApy: computeBankBorrowApy(bank)
|
|
51755
|
+
};
|
|
51756
|
+
}
|
|
51757
|
+
|
|
51686
51758
|
// src/services/bank/bank.service.ts
|
|
51687
51759
|
async function freezeBankConfigIx(program, bankAddress, bankConfigOpt) {
|
|
51688
51760
|
let bankConfigRaw;
|
|
@@ -55552,6 +55624,16 @@ exports.computeActiveEmodePairs = computeActiveEmodePairs;
|
|
|
55552
55624
|
exports.computeAssetHealthComponent = computeAssetHealthComponent;
|
|
55553
55625
|
exports.computeAssetUsdValue = computeAssetUsdValue;
|
|
55554
55626
|
exports.computeBalanceUsdValue = computeBalanceUsdValue;
|
|
55627
|
+
exports.computeBankBorrowApy = computeBankBorrowApy;
|
|
55628
|
+
exports.computeBankBorrowCapRemaining = computeBankBorrowCapRemaining;
|
|
55629
|
+
exports.computeBankDepositCapRemaining = computeBankDepositCapRemaining;
|
|
55630
|
+
exports.computeBankMetrics = computeBankMetrics;
|
|
55631
|
+
exports.computeBankPoolSize = computeBankPoolSize;
|
|
55632
|
+
exports.computeBankSupplyApy = computeBankSupplyApy;
|
|
55633
|
+
exports.computeBankTotalBorrows = computeBankTotalBorrows;
|
|
55634
|
+
exports.computeBankTotalBorrowsUsd = computeBankTotalBorrowsUsd;
|
|
55635
|
+
exports.computeBankTotalDeposits = computeBankTotalDeposits;
|
|
55636
|
+
exports.computeBankTotalDepositsUsd = computeBankTotalDepositsUsd;
|
|
55555
55637
|
exports.computeBaseInterestRate = computeBaseInterestRate;
|
|
55556
55638
|
exports.computeClaimedEmissions = computeClaimedEmissions;
|
|
55557
55639
|
exports.computeClosePositionTokenAmount = computeClosePositionTokenAmount;
|
|
@@ -55643,6 +55725,7 @@ exports.fetchSwbOraclePricesFromAPI = fetchSwbOraclePricesFromAPI;
|
|
|
55643
55725
|
exports.fetchSwbOraclePricesFromCrossbar = fetchSwbOraclePricesFromCrossbar;
|
|
55644
55726
|
exports.findRandomAvailableAccountIndex = findRandomAvailableAccountIndex;
|
|
55645
55727
|
exports.freezeBankConfigIx = freezeBankConfigIx;
|
|
55728
|
+
exports.generateDummyAccount = generateDummyAccount;
|
|
55646
55729
|
exports.getAccountKeys = getAccountKeys;
|
|
55647
55730
|
exports.getActiveAccountFlags = getActiveAccountFlags;
|
|
55648
55731
|
exports.getActiveBalances = getActiveBalances;
|