@0dotxyz/p0-ts-sdk 2.2.0-alpha.6 → 2.2.0-alpha.8
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 +97 -7
- 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 +87 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -49185,23 +49185,27 @@ var getTitanSwapIxsForFlashloan = async ({
|
|
|
49185
49185
|
quoteParams.swapMode === "ExactIn" ? quoteParams.outputMint : quoteParams.inputMint
|
|
49186
49186
|
);
|
|
49187
49187
|
const { feeAccount, hasFeeAccount } = await checkTitanFeeAccount(connection, feeMint);
|
|
49188
|
+
const useFeeAccount = hasFeeAccount && !!quoteParams.platformFeeBps;
|
|
49188
49189
|
let finalQuoteParams = quoteParams;
|
|
49189
|
-
if (!
|
|
49190
|
-
|
|
49190
|
+
if (!useFeeAccount) {
|
|
49191
|
+
if (!hasFeeAccount) {
|
|
49192
|
+
console.warn("Warning: Titan fee account ATA does not exist, disabling platform fee");
|
|
49193
|
+
}
|
|
49191
49194
|
finalQuoteParams = {
|
|
49192
49195
|
...quoteParams,
|
|
49193
49196
|
platformFeeBps: void 0
|
|
49194
49197
|
};
|
|
49195
49198
|
}
|
|
49199
|
+
const effectiveFeeAccount = useFeeAccount ? feeAccount : void 0;
|
|
49196
49200
|
if (basePath.startsWith("wss://") || basePath.startsWith("ws://")) {
|
|
49197
49201
|
return getTitanSwapIxsViaWebSocket(
|
|
49198
49202
|
{ quoteParams: finalQuoteParams, authority, connection, destinationTokenAccount, apiConfig },
|
|
49199
|
-
|
|
49203
|
+
effectiveFeeAccount
|
|
49200
49204
|
);
|
|
49201
49205
|
} else {
|
|
49202
49206
|
return getTitanSwapIxsViaHttpProxy(
|
|
49203
49207
|
{ quoteParams: finalQuoteParams, authority, connection, destinationTokenAccount, apiConfig },
|
|
49204
|
-
|
|
49208
|
+
effectiveFeeAccount
|
|
49205
49209
|
);
|
|
49206
49210
|
}
|
|
49207
49211
|
};
|
|
@@ -49707,9 +49711,12 @@ var getJupiterSwapIxsForFlashloan = async ({
|
|
|
49707
49711
|
const feeMint = quoteParams.swapMode === "ExactIn" ? quoteParams.outputMint : quoteParams.inputMint;
|
|
49708
49712
|
const { feeAccount, hasFeeAccount } = await checkFeeAccount(connection, new web3_js.PublicKey(feeMint));
|
|
49709
49713
|
const project0JupiterLut = (await connection.getAddressLookupTable(ADDRESS_LOOKUP_TABLE_FOR_SWAP))?.value;
|
|
49714
|
+
const useFeeAccount = hasFeeAccount && !!quoteParams.platformFeeBps;
|
|
49710
49715
|
let finalQuoteParams = quoteParams;
|
|
49711
|
-
if (!
|
|
49712
|
-
|
|
49716
|
+
if (!useFeeAccount) {
|
|
49717
|
+
if (!hasFeeAccount) {
|
|
49718
|
+
console.warn("Warning: feeAccountInfo is undefined");
|
|
49719
|
+
}
|
|
49713
49720
|
finalQuoteParams = {
|
|
49714
49721
|
...quoteParams,
|
|
49715
49722
|
platformFeeBps: void 0
|
|
@@ -49725,7 +49732,7 @@ var getJupiterSwapIxsForFlashloan = async ({
|
|
|
49725
49732
|
swapRequest: {
|
|
49726
49733
|
quoteResponse: swapQuote,
|
|
49727
49734
|
userPublicKey: authority.toBase58(),
|
|
49728
|
-
feeAccount:
|
|
49735
|
+
feeAccount: useFeeAccount ? feeAccount : void 0,
|
|
49729
49736
|
wrapAndUnwrapSol: false,
|
|
49730
49737
|
destinationTokenAccount: destinationTokenAccount.toBase58()
|
|
49731
49738
|
}
|
|
@@ -51683,6 +51690,78 @@ function computeRemainingCapacity(bank) {
|
|
|
51683
51690
|
};
|
|
51684
51691
|
}
|
|
51685
51692
|
|
|
51693
|
+
// src/services/bank/utils/bank-metrics.utils.ts
|
|
51694
|
+
function computeBankTotalDeposits(bank, assetShareValueMultiplier) {
|
|
51695
|
+
const totalAssets = getTotalAssetQuantity(bank).times(
|
|
51696
|
+
assetShareValueMultiplier ?? 1
|
|
51697
|
+
);
|
|
51698
|
+
return nativeToUi(totalAssets, bank.mintDecimals);
|
|
51699
|
+
}
|
|
51700
|
+
function computeBankTotalBorrows(bank) {
|
|
51701
|
+
return nativeToUi(getTotalLiabilityQuantity(bank), bank.mintDecimals);
|
|
51702
|
+
}
|
|
51703
|
+
function computeBankTotalDepositsUsd(bank, oraclePrice, assetShareValueMultiplier) {
|
|
51704
|
+
return computeUsdValue({
|
|
51705
|
+
bank,
|
|
51706
|
+
oraclePrice,
|
|
51707
|
+
quantity: getTotalAssetQuantity(bank),
|
|
51708
|
+
priceBias: 1 /* None */,
|
|
51709
|
+
isWeightedPrice: false,
|
|
51710
|
+
assetShareValueMultiplier
|
|
51711
|
+
}).toNumber();
|
|
51712
|
+
}
|
|
51713
|
+
function computeBankTotalBorrowsUsd(bank, oraclePrice) {
|
|
51714
|
+
return computeUsdValue({
|
|
51715
|
+
bank,
|
|
51716
|
+
oraclePrice,
|
|
51717
|
+
quantity: getTotalLiabilityQuantity(bank),
|
|
51718
|
+
priceBias: 1 /* None */,
|
|
51719
|
+
isWeightedPrice: false
|
|
51720
|
+
}).toNumber();
|
|
51721
|
+
}
|
|
51722
|
+
function computeBankPoolSize(bank, assetShareValueMultiplier) {
|
|
51723
|
+
const totalDeposits = computeBankTotalDeposits(bank, assetShareValueMultiplier);
|
|
51724
|
+
const totalBorrows = computeBankTotalBorrows(bank);
|
|
51725
|
+
const borrowCap = nativeToUi(bank.config.borrowLimit, bank.mintDecimals);
|
|
51726
|
+
return Math.max(0, Math.min(totalDeposits, borrowCap) - totalBorrows);
|
|
51727
|
+
}
|
|
51728
|
+
function computeBankDepositCapRemaining(bank) {
|
|
51729
|
+
const { depositCapacity } = computeRemainingCapacity(bank);
|
|
51730
|
+
return Math.max(0, nativeToUi(depositCapacity, bank.mintDecimals));
|
|
51731
|
+
}
|
|
51732
|
+
function computeBankBorrowCapRemaining(bank) {
|
|
51733
|
+
const { borrowCapacity } = computeRemainingCapacity(bank);
|
|
51734
|
+
return Math.max(0, nativeToUi(borrowCapacity, bank.mintDecimals));
|
|
51735
|
+
}
|
|
51736
|
+
function computeBankSupplyApy(bank) {
|
|
51737
|
+
return aprToApy(computeInterestRates(bank).lendingRate.toNumber());
|
|
51738
|
+
}
|
|
51739
|
+
function computeBankBorrowApy(bank) {
|
|
51740
|
+
return aprToApy(computeInterestRates(bank).borrowingRate.toNumber());
|
|
51741
|
+
}
|
|
51742
|
+
function computeBankMetrics(params) {
|
|
51743
|
+
const { bank, oraclePrice, assetShareValueMultiplier, symbol = "" } = params;
|
|
51744
|
+
return {
|
|
51745
|
+
symbol,
|
|
51746
|
+
totalDeposits: computeBankTotalDeposits(bank, assetShareValueMultiplier),
|
|
51747
|
+
totalBorrows: computeBankTotalBorrows(bank),
|
|
51748
|
+
totalDepositsUsd: computeBankTotalDepositsUsd(
|
|
51749
|
+
bank,
|
|
51750
|
+
oraclePrice,
|
|
51751
|
+
assetShareValueMultiplier
|
|
51752
|
+
),
|
|
51753
|
+
totalBorrowsUsd: computeBankTotalBorrowsUsd(bank, oraclePrice),
|
|
51754
|
+
utilizationRate: computeUtilizationRate(bank).toNumber(),
|
|
51755
|
+
poolSize: computeBankPoolSize(bank, assetShareValueMultiplier),
|
|
51756
|
+
depositCap: nativeToUi(bank.config.depositLimit, bank.mintDecimals),
|
|
51757
|
+
borrowCap: nativeToUi(bank.config.borrowLimit, bank.mintDecimals),
|
|
51758
|
+
depositCapRemaining: computeBankDepositCapRemaining(bank),
|
|
51759
|
+
borrowCapRemaining: computeBankBorrowCapRemaining(bank),
|
|
51760
|
+
supplyApy: computeBankSupplyApy(bank),
|
|
51761
|
+
borrowApy: computeBankBorrowApy(bank)
|
|
51762
|
+
};
|
|
51763
|
+
}
|
|
51764
|
+
|
|
51686
51765
|
// src/services/bank/bank.service.ts
|
|
51687
51766
|
async function freezeBankConfigIx(program, bankAddress, bankConfigOpt) {
|
|
51688
51767
|
let bankConfigRaw;
|
|
@@ -55552,6 +55631,16 @@ exports.computeActiveEmodePairs = computeActiveEmodePairs;
|
|
|
55552
55631
|
exports.computeAssetHealthComponent = computeAssetHealthComponent;
|
|
55553
55632
|
exports.computeAssetUsdValue = computeAssetUsdValue;
|
|
55554
55633
|
exports.computeBalanceUsdValue = computeBalanceUsdValue;
|
|
55634
|
+
exports.computeBankBorrowApy = computeBankBorrowApy;
|
|
55635
|
+
exports.computeBankBorrowCapRemaining = computeBankBorrowCapRemaining;
|
|
55636
|
+
exports.computeBankDepositCapRemaining = computeBankDepositCapRemaining;
|
|
55637
|
+
exports.computeBankMetrics = computeBankMetrics;
|
|
55638
|
+
exports.computeBankPoolSize = computeBankPoolSize;
|
|
55639
|
+
exports.computeBankSupplyApy = computeBankSupplyApy;
|
|
55640
|
+
exports.computeBankTotalBorrows = computeBankTotalBorrows;
|
|
55641
|
+
exports.computeBankTotalBorrowsUsd = computeBankTotalBorrowsUsd;
|
|
55642
|
+
exports.computeBankTotalDeposits = computeBankTotalDeposits;
|
|
55643
|
+
exports.computeBankTotalDepositsUsd = computeBankTotalDepositsUsd;
|
|
55555
55644
|
exports.computeBaseInterestRate = computeBaseInterestRate;
|
|
55556
55645
|
exports.computeClaimedEmissions = computeClaimedEmissions;
|
|
55557
55646
|
exports.computeClosePositionTokenAmount = computeClosePositionTokenAmount;
|
|
@@ -55643,6 +55732,7 @@ exports.fetchSwbOraclePricesFromAPI = fetchSwbOraclePricesFromAPI;
|
|
|
55643
55732
|
exports.fetchSwbOraclePricesFromCrossbar = fetchSwbOraclePricesFromCrossbar;
|
|
55644
55733
|
exports.findRandomAvailableAccountIndex = findRandomAvailableAccountIndex;
|
|
55645
55734
|
exports.freezeBankConfigIx = freezeBankConfigIx;
|
|
55735
|
+
exports.generateDummyAccount = generateDummyAccount;
|
|
55646
55736
|
exports.getAccountKeys = getAccountKeys;
|
|
55647
55737
|
exports.getActiveAccountFlags = getActiveAccountFlags;
|
|
55648
55738
|
exports.getActiveBalances = getActiveBalances;
|