@0dotxyz/p0-ts-sdk 2.7.2 → 2.7.4
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/{dto-rate-model.types-IT8wckYH.d.cts → dto-rate-model.types-DnQmHIO6.d.cts} +27 -1
- package/dist/{dto-rate-model.types-IT8wckYH.d.ts → dto-rate-model.types-DnQmHIO6.d.ts} +27 -1
- package/dist/index.cjs +27145 -27151
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -25
- package/dist/index.d.ts +4 -25
- package/dist/index.js +27146 -27150
- package/dist/index.js.map +1 -1
- package/dist/instructions.cjs +3 -20
- package/dist/instructions.cjs.map +1 -1
- package/dist/instructions.d.cts +2 -2
- package/dist/instructions.d.ts +2 -2
- package/dist/instructions.js +3 -20
- package/dist/instructions.js.map +1 -1
- package/dist/{types-B5SGXpex.d.ts → types-DJqANTTA.d.cts} +1 -1
- package/dist/{types-BFLi0Ozl.d.cts → types-sisv3J7l.d.ts} +1 -1
- package/dist/vendor.cjs +70 -15
- package/dist/vendor.cjs.map +1 -1
- package/dist/vendor.d.cts +71 -21
- package/dist/vendor.d.ts +71 -21
- package/dist/vendor.js +66 -16
- package/dist/vendor.js.map +1 -1
- package/package.json +1 -1
package/dist/vendor.cjs
CHANGED
|
@@ -3912,7 +3912,8 @@ var SLOTS_PER_MINUTE = SLOTS_PER_SECOND * 60;
|
|
|
3912
3912
|
var SLOTS_PER_HOUR = SLOTS_PER_MINUTE * 60;
|
|
3913
3913
|
var SLOTS_PER_DAY = SLOTS_PER_HOUR * 24;
|
|
3914
3914
|
var SLOTS_PER_YEAR = SLOTS_PER_DAY * 365;
|
|
3915
|
-
var
|
|
3915
|
+
var SECONDS_PER_YEAR = 31536e3;
|
|
3916
|
+
var DEFAULT_RECENT_SLOT_DURATION_MS = 350;
|
|
3916
3917
|
var ONE_HUNDRED_PCT_IN_BPS = 1e4;
|
|
3917
3918
|
|
|
3918
3919
|
// src/vendor/klend/instructions.ts
|
|
@@ -4063,6 +4064,13 @@ async function makeRefreshingIxs({
|
|
|
4063
4064
|
return [refreshReserveIx, refreshObligationIx];
|
|
4064
4065
|
}
|
|
4065
4066
|
|
|
4067
|
+
// src/vendor/klend/types/reserve/reserve.types.ts
|
|
4068
|
+
var KaminoInterestRateBasis = /* @__PURE__ */ ((KaminoInterestRateBasis2) => {
|
|
4069
|
+
KaminoInterestRateBasis2[KaminoInterestRateBasis2["Legacy"] = 0] = "Legacy";
|
|
4070
|
+
KaminoInterestRateBasis2[KaminoInterestRateBasis2["TrueApr"] = 1] = "TrueApr";
|
|
4071
|
+
return KaminoInterestRateBasis2;
|
|
4072
|
+
})(KaminoInterestRateBasis || {});
|
|
4073
|
+
|
|
4066
4074
|
// src/vendor/klend/utils/klend/serialize.utils.ts
|
|
4067
4075
|
function kaminoObligationToDto(obligation) {
|
|
4068
4076
|
return {
|
|
@@ -4102,6 +4110,7 @@ function kaminoReserveToDto(reserve) {
|
|
|
4102
4110
|
config: {
|
|
4103
4111
|
protocolTakeRatePct: reserve.config.protocolTakeRatePct,
|
|
4104
4112
|
hostFixedInterestRateBps: reserve.config.hostFixedInterestRateBps,
|
|
4113
|
+
interestRateBasis: reserve.config.interestRateBasis ?? 0 /* Legacy */,
|
|
4105
4114
|
depositLimit: reserve.config.depositLimit.toString(),
|
|
4106
4115
|
borrowLimit: reserve.config.borrowLimit.toString(),
|
|
4107
4116
|
borrowRateCurve: {
|
|
@@ -12284,7 +12293,12 @@ var reserveLayout = borsh__namespace.struct([
|
|
|
12284
12293
|
borsh__namespace.u8("status"),
|
|
12285
12294
|
borsh__namespace.u8("assetTier"),
|
|
12286
12295
|
borsh__namespace.u16("hostFixedInterestRateBps"),
|
|
12287
|
-
borsh__namespace.
|
|
12296
|
+
borsh__namespace.u16("minDeleveragingBonusBps"),
|
|
12297
|
+
borsh__namespace.u8("blockCtokenUsage"),
|
|
12298
|
+
borsh__namespace.u8("earlyRepayRemainingInterestPct"),
|
|
12299
|
+
borsh__namespace.u8("emergencyMode"),
|
|
12300
|
+
borsh__namespace.u8("interestRateBasis"),
|
|
12301
|
+
borsh__namespace.array(borsh__namespace.u8(), 3, "reserved2"),
|
|
12288
12302
|
borsh__namespace.u8("protocolOrderExecutionFeePct"),
|
|
12289
12303
|
borsh__namespace.u8("protocolTakeRatePct"),
|
|
12290
12304
|
borsh__namespace.u8("protocolLiquidationFeePct"),
|
|
@@ -12450,6 +12464,7 @@ function dtoToKaminoReserve(reserveDto) {
|
|
|
12450
12464
|
config: {
|
|
12451
12465
|
protocolTakeRatePct: reserveDto.config.protocolTakeRatePct,
|
|
12452
12466
|
hostFixedInterestRateBps: reserveDto.config.hostFixedInterestRateBps,
|
|
12467
|
+
interestRateBasis: reserveDto.config.interestRateBasis ?? 0 /* Legacy */,
|
|
12453
12468
|
depositLimit: new BN5__default.default(reserveDto.config.depositLimit),
|
|
12454
12469
|
borrowLimit: new BN5__default.default(reserveDto.config.borrowLimit),
|
|
12455
12470
|
borrowRateCurve: {
|
|
@@ -12690,8 +12705,8 @@ var getKaminoBorrowRate = (currentUtilization, curve) => {
|
|
|
12690
12705
|
}
|
|
12691
12706
|
return interpolateLinear(currentUtilization, x0, y0, x1, y1);
|
|
12692
12707
|
};
|
|
12693
|
-
function calculateAPYFromAPR(apr) {
|
|
12694
|
-
return Math.pow(1 + apr /
|
|
12708
|
+
function calculateAPYFromAPR(apr, periodsPerYear = SLOTS_PER_YEAR) {
|
|
12709
|
+
return Math.pow(1 + apr / periodsPerYear, periodsPerYear) - 1;
|
|
12695
12710
|
}
|
|
12696
12711
|
function getKaminoTotalSupply(reserve) {
|
|
12697
12712
|
const liquidityAvailableAmount = new Decimal3__default.default(reserve.liquidity.availableAmount.toString());
|
|
@@ -12713,17 +12728,43 @@ function calculateUtilizationRatio(reserve) {
|
|
|
12713
12728
|
}
|
|
12714
12729
|
return totalBorrows.dividedBy(totalSupply).toNumber();
|
|
12715
12730
|
}
|
|
12731
|
+
function getKaminoInterestRateBasis(reserve) {
|
|
12732
|
+
const basis = reserve.config.interestRateBasis ?? 0 /* Legacy */;
|
|
12733
|
+
switch (basis) {
|
|
12734
|
+
case 0 /* Legacy */:
|
|
12735
|
+
case 1 /* TrueApr */:
|
|
12736
|
+
return basis;
|
|
12737
|
+
default:
|
|
12738
|
+
throw new Error(`Unsupported Kamino interest rate basis: ${basis}`);
|
|
12739
|
+
}
|
|
12740
|
+
}
|
|
12716
12741
|
function slotAdjustmentFactor(recentSlotDurationMs = DEFAULT_RECENT_SLOT_DURATION_MS) {
|
|
12717
12742
|
return 1e3 / SLOTS_PER_SECOND / recentSlotDurationMs;
|
|
12718
12743
|
}
|
|
12719
|
-
function
|
|
12720
|
-
|
|
12744
|
+
function getKaminoRateBasis(reserve, recentSlotDurationMs = DEFAULT_RECENT_SLOT_DURATION_MS) {
|
|
12745
|
+
switch (getKaminoInterestRateBasis(reserve)) {
|
|
12746
|
+
case 0 /* Legacy */:
|
|
12747
|
+
if (!Number.isFinite(recentSlotDurationMs) || recentSlotDurationMs <= 0) {
|
|
12748
|
+
throw new Error(
|
|
12749
|
+
`Kamino recent slot duration must be positive, got ${recentSlotDurationMs}`
|
|
12750
|
+
);
|
|
12751
|
+
}
|
|
12752
|
+
return {
|
|
12753
|
+
multiplier: slotAdjustmentFactor(recentSlotDurationMs),
|
|
12754
|
+
periodsPerYear: SLOTS_PER_YEAR
|
|
12755
|
+
};
|
|
12756
|
+
case 1 /* TrueApr */:
|
|
12757
|
+
return { multiplier: 1, periodsPerYear: SECONDS_PER_YEAR };
|
|
12758
|
+
}
|
|
12759
|
+
}
|
|
12760
|
+
function calculateSlotAdjustmentFactor(reserve, recentSlotDurationMs = DEFAULT_RECENT_SLOT_DURATION_MS) {
|
|
12761
|
+
return getKaminoRateBasis(reserve, recentSlotDurationMs).multiplier;
|
|
12721
12762
|
}
|
|
12722
12763
|
function calculateKaminoEstimatedBorrowRate(reserve, recentSlotDurationMs = DEFAULT_RECENT_SLOT_DURATION_MS) {
|
|
12723
|
-
const
|
|
12764
|
+
const { multiplier } = getKaminoRateBasis(reserve, recentSlotDurationMs);
|
|
12724
12765
|
const currentUtilization = calculateUtilizationRatio(reserve);
|
|
12725
12766
|
const curve = truncateBorrowCurve(reserve.config.borrowRateCurve.points);
|
|
12726
|
-
return getKaminoBorrowRate(currentUtilization, curve) *
|
|
12767
|
+
return getKaminoBorrowRate(currentUtilization, curve) * multiplier;
|
|
12727
12768
|
}
|
|
12728
12769
|
function calculateKaminoEstimatedSupplyRate(reserve, recentSlotDurationMs = DEFAULT_RECENT_SLOT_DURATION_MS) {
|
|
12729
12770
|
const borrowRate = calculateKaminoEstimatedBorrowRate(reserve, recentSlotDurationMs);
|
|
@@ -12732,10 +12773,9 @@ function calculateKaminoEstimatedSupplyRate(reserve, recentSlotDurationMs = DEFA
|
|
|
12732
12773
|
return borrowRate * currentUtilization * protocolTakeRatePct;
|
|
12733
12774
|
}
|
|
12734
12775
|
function calculateKaminoSupplyAPY(reserve, recentSlotDurationMs = DEFAULT_RECENT_SLOT_DURATION_MS) {
|
|
12735
|
-
const
|
|
12736
|
-
const
|
|
12737
|
-
|
|
12738
|
-
return calculateAPYFromAPR(currentUtilization * borrowRate * protocolTakeRatePct);
|
|
12776
|
+
const { periodsPerYear } = getKaminoRateBasis(reserve, recentSlotDurationMs);
|
|
12777
|
+
const supplyApr = calculateKaminoEstimatedSupplyRate(reserve, recentSlotDurationMs);
|
|
12778
|
+
return calculateAPYFromAPR(supplyApr, periodsPerYear);
|
|
12739
12779
|
}
|
|
12740
12780
|
function scaledSupplies(state) {
|
|
12741
12781
|
const liqMintDecimals = new Decimal3__default.default(state.liquidity.mintDecimals.toString());
|
|
@@ -12766,7 +12806,7 @@ function getFixedHostInterestRate(reserve) {
|
|
|
12766
12806
|
function getProtocolTakeRatePct(reserve) {
|
|
12767
12807
|
return 1 - reserve.config.protocolTakeRatePct / 100;
|
|
12768
12808
|
}
|
|
12769
|
-
function generateKaminoReserveCurve(curvePoints, slotAdjustmentFactor2, fixedHostInterestRate, protocolTakeRatePct) {
|
|
12809
|
+
function generateKaminoReserveCurve(curvePoints, slotAdjustmentFactor2, fixedHostInterestRate, protocolTakeRatePct, periodsPerYear = SLOTS_PER_YEAR) {
|
|
12770
12810
|
if (curvePoints.length === 0) {
|
|
12771
12811
|
return [];
|
|
12772
12812
|
}
|
|
@@ -12776,8 +12816,8 @@ function generateKaminoReserveCurve(curvePoints, slotAdjustmentFactor2, fixedHos
|
|
|
12776
12816
|
const baseBorrowRate = getKaminoBorrowRate(utilization, curve) * slotAdjustmentFactor2;
|
|
12777
12817
|
const borrowAPR = baseBorrowRate + fixedHostInterestRate;
|
|
12778
12818
|
const supplyAPR = utilization * borrowAPR * protocolTakeRatePct;
|
|
12779
|
-
const borrowAPY = calculateAPYFromAPR(borrowAPR);
|
|
12780
|
-
const supplyAPY = calculateAPYFromAPR(supplyAPR);
|
|
12819
|
+
const borrowAPY = calculateAPYFromAPR(borrowAPR, periodsPerYear);
|
|
12820
|
+
const supplyAPY = calculateAPYFromAPR(supplyAPR, periodsPerYear);
|
|
12781
12821
|
return {
|
|
12782
12822
|
utilization: utilization * 100,
|
|
12783
12823
|
borrowAPY: borrowAPY * 100,
|
|
@@ -12785,6 +12825,16 @@ function generateKaminoReserveCurve(curvePoints, slotAdjustmentFactor2, fixedHos
|
|
|
12785
12825
|
};
|
|
12786
12826
|
});
|
|
12787
12827
|
}
|
|
12828
|
+
function generateKaminoReserveCurveFromReserve(reserve, recentSlotDurationMs = DEFAULT_RECENT_SLOT_DURATION_MS) {
|
|
12829
|
+
const { multiplier, periodsPerYear } = getKaminoRateBasis(reserve, recentSlotDurationMs);
|
|
12830
|
+
return generateKaminoReserveCurve(
|
|
12831
|
+
reserve.config.borrowRateCurve.points,
|
|
12832
|
+
multiplier,
|
|
12833
|
+
getFixedHostInterestRate(reserve),
|
|
12834
|
+
getProtocolTakeRatePct(reserve),
|
|
12835
|
+
periodsPerYear
|
|
12836
|
+
);
|
|
12837
|
+
}
|
|
12788
12838
|
function getRewardPerTimeUnitSecond(reward) {
|
|
12789
12839
|
const now = new Decimal3__default.default((/* @__PURE__ */ new Date()).getTime()).div(1e3);
|
|
12790
12840
|
let rewardPerTimeUnitSecond = new Decimal3__default.default(0);
|
|
@@ -52574,6 +52624,7 @@ exports.KFARMS_IDL = KFARMS_IDL;
|
|
|
52574
52624
|
exports.KLEND_ACCOUNT_CODER = KLEND_ACCOUNT_CODER;
|
|
52575
52625
|
exports.KLEND_IDL = KLEND_IDL;
|
|
52576
52626
|
exports.KLEND_PROGRAM_ID = KLEND_PROGRAM_ID;
|
|
52627
|
+
exports.KaminoInterestRateBasis = KaminoInterestRateBasis;
|
|
52577
52628
|
exports.LENGTH_SIZE = LENGTH_SIZE;
|
|
52578
52629
|
exports.MAX_SLOT_DIFFERENCE = MAX_SLOT_DIFFERENCE;
|
|
52579
52630
|
exports.MEMO_PROGRAM_ID = MEMO_PROGRAM_ID;
|
|
@@ -52590,6 +52641,7 @@ exports.PERCENTAGE_PRECISION_EXP = PERCENTAGE_PRECISION_EXP;
|
|
|
52590
52641
|
exports.PriceStatus = PriceStatus;
|
|
52591
52642
|
exports.PriceType = PriceType;
|
|
52592
52643
|
exports.REFRESH_OBLIGATION_DISCRIMINATOR = REFRESH_OBLIGATION_DISCRIMINATOR;
|
|
52644
|
+
exports.SECONDS_PER_YEAR = SECONDS_PER_YEAR;
|
|
52593
52645
|
exports.SEED_BASE_REFERRER_STATE = SEED_BASE_REFERRER_STATE;
|
|
52594
52646
|
exports.SEED_BASE_REFERRER_TOKEN_STATE = SEED_BASE_REFERRER_TOKEN_STATE;
|
|
52595
52647
|
exports.SEED_BASE_SHORT_URL = SEED_BASE_SHORT_URL;
|
|
@@ -52789,6 +52841,7 @@ exports.findPoolStakeAuthorityAddress = findPoolStakeAuthorityAddress;
|
|
|
52789
52841
|
exports.generateDriftReserveCurve = generateDriftReserveCurve;
|
|
52790
52842
|
exports.generateJupLendSupplyCurve = generateJupLendSupplyCurve;
|
|
52791
52843
|
exports.generateKaminoReserveCurve = generateKaminoReserveCurve;
|
|
52844
|
+
exports.generateKaminoReserveCurveFromReserve = generateKaminoReserveCurveFromReserve;
|
|
52792
52845
|
exports.getAccount = getAccount;
|
|
52793
52846
|
exports.getAccountLen = getAccountLen;
|
|
52794
52847
|
exports.getAllDerivedDriftAccounts = getAllDerivedDriftAccounts;
|
|
@@ -52801,6 +52854,8 @@ exports.getDriftTokenAmount = getDriftTokenAmount;
|
|
|
52801
52854
|
exports.getFixedHostInterestRate = getFixedHostInterestRate;
|
|
52802
52855
|
exports.getJupLendRewards = getJupLendRewards;
|
|
52803
52856
|
exports.getKaminoBorrowRate = getKaminoBorrowRate;
|
|
52857
|
+
exports.getKaminoInterestRateBasis = getKaminoInterestRateBasis;
|
|
52858
|
+
exports.getKaminoRateBasis = getKaminoRateBasis;
|
|
52804
52859
|
exports.getKaminoTotalSupply = getKaminoTotalSupply;
|
|
52805
52860
|
exports.getMinimumBalanceForRentExemptAccount = getMinimumBalanceForRentExemptAccount;
|
|
52806
52861
|
exports.getMinimumBalanceForRentExemptAccountWithExtensions = getMinimumBalanceForRentExemptAccountWithExtensions;
|