@0dotxyz/p0-ts-sdk 2.7.1-alpha.1 → 2.7.1-alpha.2
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 +21 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -77840,17 +77840,28 @@ function computeMaxBorrowForBank(params) {
|
|
|
77840
77840
|
bank,
|
|
77841
77841
|
assetShareValueMultiplier
|
|
77842
77842
|
).div(originationFeeFactor);
|
|
77843
|
-
const rateLimitRemaining = computeOutflowRateLimitRemaining(
|
|
77843
|
+
const rateLimitRemaining = computeOutflowRateLimitRemaining(
|
|
77844
|
+
bank,
|
|
77845
|
+
oraclePrice,
|
|
77846
|
+
groupRateLimiter,
|
|
77847
|
+
assetShareValueMultiplier
|
|
77848
|
+
);
|
|
77844
77849
|
return BigNumber3.max(
|
|
77845
77850
|
0,
|
|
77846
77851
|
BigNumber3.min(healthMaxBorrow, borrowCapRemaining, availableLiquidity, rateLimitRemaining)
|
|
77847
77852
|
);
|
|
77848
77853
|
}
|
|
77849
|
-
function computeOutflowRateLimitRemaining(bank, oraclePrice, groupRateLimiter) {
|
|
77854
|
+
function computeOutflowRateLimitRemaining(bank, oraclePrice, groupRateLimiter, assetShareValueMultiplier) {
|
|
77850
77855
|
const nowSeconds = Date.now() / 1e3;
|
|
77851
77856
|
let remaining = new BigNumber3(Infinity);
|
|
77852
|
-
|
|
77853
|
-
if (bankRemaining !== null)
|
|
77857
|
+
let bankRemaining = computeBankRateLimitRemaining(bank, nowSeconds);
|
|
77858
|
+
if (bankRemaining !== null) {
|
|
77859
|
+
const limiterInBankMintUnits = bank.config.assetTag === 3 /* KAMINO */ || bank.config.assetTag === 2 /* STAKED */;
|
|
77860
|
+
if (limiterInBankMintUnits && assetShareValueMultiplier?.gt(0)) {
|
|
77861
|
+
bankRemaining = bankRemaining.times(assetShareValueMultiplier);
|
|
77862
|
+
}
|
|
77863
|
+
remaining = BigNumber3.min(remaining, bankRemaining);
|
|
77864
|
+
}
|
|
77854
77865
|
const groupRemainingUsd = computeGroupRateLimitRemainingUsd(groupRateLimiter, nowSeconds);
|
|
77855
77866
|
if (groupRemainingUsd !== null) {
|
|
77856
77867
|
const price = getPrice(oraclePrice, 1 /* None */, false);
|
|
@@ -77879,7 +77890,12 @@ function computeMaxWithdrawForBank(params) {
|
|
|
77879
77890
|
bank,
|
|
77880
77891
|
assetShareValueMultiplier
|
|
77881
77892
|
);
|
|
77882
|
-
const rateLimitRemaining = computeOutflowRateLimitRemaining(
|
|
77893
|
+
const rateLimitRemaining = computeOutflowRateLimitRemaining(
|
|
77894
|
+
bank,
|
|
77895
|
+
oraclePrice,
|
|
77896
|
+
groupRateLimiter,
|
|
77897
|
+
assetShareValueMultiplier
|
|
77898
|
+
);
|
|
77883
77899
|
const clamps = [healthMaxWithdraw, availableLiquidity, rateLimitRemaining];
|
|
77884
77900
|
const venueLiquidity = computeVenueAvailableLiquidity(bank, venueStates);
|
|
77885
77901
|
if (venueLiquidity !== void 0) clamps.push(venueLiquidity);
|