@0dotxyz/p0-ts-sdk 1.1.0-alpha.9 → 1.1.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 +14 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/dist/vendor.cjs +84 -87
- package/dist/vendor.cjs.map +1 -1
- package/dist/vendor.d.cts +46 -18
- package/dist/vendor.d.ts +46 -18
- package/dist/vendor.js +70 -74
- package/dist/vendor.js.map +1 -1
- package/package.json +1 -1
package/dist/vendor.d.cts
CHANGED
|
@@ -8103,14 +8103,14 @@ declare function deriveUserState(programId: PublicKey, farmState: PublicKey, obl
|
|
|
8103
8103
|
* Extracted all needed functions & constants out of their SDK
|
|
8104
8104
|
*/
|
|
8105
8105
|
|
|
8106
|
-
interface
|
|
8106
|
+
interface KlendInterestRateCurvePoint {
|
|
8107
8107
|
utilization: number;
|
|
8108
8108
|
borrowAPY: number;
|
|
8109
8109
|
supplyAPY: number;
|
|
8110
8110
|
}
|
|
8111
8111
|
interface KaminoReserveCurveData {
|
|
8112
8112
|
reserveAddress: string;
|
|
8113
|
-
curvePoints:
|
|
8113
|
+
curvePoints: KlendInterestRateCurvePoint[];
|
|
8114
8114
|
}
|
|
8115
8115
|
/**
|
|
8116
8116
|
* Linear interpolation between two points
|
|
@@ -8122,7 +8122,7 @@ declare const interpolateLinear: (x: number, x0: number, y0: number, x1: number,
|
|
|
8122
8122
|
* @param curve - Array of [utilization, rate] points
|
|
8123
8123
|
* @returns Borrow rate for the given utilization
|
|
8124
8124
|
*/
|
|
8125
|
-
declare const
|
|
8125
|
+
declare const getKaminoBorrowRate: (currentUtilization: number, curve: [number, number][]) => number;
|
|
8126
8126
|
/**
|
|
8127
8127
|
* Convert APR to APY using compound interest formula
|
|
8128
8128
|
* APY = (1 + APR/n)^n - 1, where n = SLOTS_PER_YEAR
|
|
@@ -8136,7 +8136,7 @@ declare function calculateAPYFromAPR(apr: number): number;
|
|
|
8136
8136
|
* @param reserve - The Kamino reserve
|
|
8137
8137
|
* @returns Total supply in lamports
|
|
8138
8138
|
*/
|
|
8139
|
-
declare function
|
|
8139
|
+
declare function getKaminoTotalSupply(reserve: ReserveRaw): Decimal;
|
|
8140
8140
|
/**
|
|
8141
8141
|
* Calculate utilization ratio of a reserve
|
|
8142
8142
|
* Formula: total borrowed / total supply
|
|
@@ -8162,7 +8162,7 @@ declare function calculateSlotAdjustmentFactor(reserve: ReserveRaw, recentSlotDu
|
|
|
8162
8162
|
* @param recentSlotDurationMs - Recent slot duration (optional)
|
|
8163
8163
|
* @returns Borrow rate as decimal (e.g., 0.05 = 5%)
|
|
8164
8164
|
*/
|
|
8165
|
-
declare function
|
|
8165
|
+
declare function calculateKaminoEstimatedBorrowRate(reserve: ReserveRaw, recentSlotDurationMs?: number): number;
|
|
8166
8166
|
/**
|
|
8167
8167
|
* Calculate estimated supply rate for a reserve
|
|
8168
8168
|
* Formula: borrow rate × utilization × (1 - protocol take rate)
|
|
@@ -8170,7 +8170,7 @@ declare function calculateEstimatedBorrowRate(reserve: ReserveRaw, recentSlotDur
|
|
|
8170
8170
|
* @param recentSlotDurationMs - Recent slot duration (optional)
|
|
8171
8171
|
* @returns Supply rate as decimal (e.g., 0.03 = 3%)
|
|
8172
8172
|
*/
|
|
8173
|
-
declare function
|
|
8173
|
+
declare function calculateKaminoEstimatedSupplyRate(reserve: ReserveRaw, recentSlotDurationMs?: number): number;
|
|
8174
8174
|
/**
|
|
8175
8175
|
* Calculate supply APY for a reserve
|
|
8176
8176
|
* APY includes compounding, making it higher than APR
|
|
@@ -8179,7 +8179,7 @@ declare function calculateEstimatedSupplyRate(reserve: ReserveRaw, recentSlotDur
|
|
|
8179
8179
|
* @param recentSlotDurationMs - Recent slot duration (defaults to 450ms)
|
|
8180
8180
|
* @returns Supply APY as decimal (e.g., 0.0512 = 5.12% APY)
|
|
8181
8181
|
*/
|
|
8182
|
-
declare function
|
|
8182
|
+
declare function calculateKaminoSupplyAPY(reserve: ReserveRaw, recentSlotDurationMs?: number): number;
|
|
8183
8183
|
declare function scaledSupplies(state: ReserveRaw): [Decimal, Decimal];
|
|
8184
8184
|
/**
|
|
8185
8185
|
* Convert raw curve points to normalized [utilization, rate] pairs
|
|
@@ -8204,7 +8204,7 @@ declare function getProtocolTakeRatePct(reserve: ReserveRaw): number;
|
|
|
8204
8204
|
* @param protocolTakeRatePct - Percentage kept by depositors (1 - protocol fee)
|
|
8205
8205
|
* @returns Array of curve points with utilization, borrow APY, and supply APY
|
|
8206
8206
|
*/
|
|
8207
|
-
declare function generateKaminoReserveCurve(curvePoints: CurvePointFields[], slotAdjustmentFactor: number, fixedHostInterestRate: number, protocolTakeRatePct: number):
|
|
8207
|
+
declare function generateKaminoReserveCurve(curvePoints: CurvePointFields[], slotAdjustmentFactor: number, fixedHostInterestRate: number, protocolTakeRatePct: number): KlendInterestRateCurvePoint[];
|
|
8208
8208
|
|
|
8209
8209
|
declare function getRewardPerTimeUnitSecond(reward: RewardInfoFields): Decimal;
|
|
8210
8210
|
declare function getReserveRewardsApy(priceByMint: Record<string, number>, farmState: FarmStateRaw, reserveState: ReserveRaw): Promise<{
|
|
@@ -22450,25 +22450,25 @@ declare const ONE_YEAR: BN$1;
|
|
|
22450
22450
|
/**
|
|
22451
22451
|
* Calculates the spot token amount including any accumulated interest.
|
|
22452
22452
|
*/
|
|
22453
|
-
declare function
|
|
22453
|
+
declare function getDriftTokenAmount(balanceAmount: BN$1, spotMarket: DriftSpotMarket, balanceType: DriftSpotBalanceType): BN$1;
|
|
22454
22454
|
/**
|
|
22455
22455
|
* Calculates the utilization rate of a spot market
|
|
22456
22456
|
* Utilization = borrows / deposits
|
|
22457
22457
|
*/
|
|
22458
|
-
declare function
|
|
22458
|
+
declare function calculateDriftUtilization(bank: DriftSpotMarket, delta?: BN$1): BN$1;
|
|
22459
22459
|
/**
|
|
22460
22460
|
* Calculates the interest rate based on utilization using a piecewise curve
|
|
22461
22461
|
*/
|
|
22462
|
-
declare function
|
|
22462
|
+
declare function calculateDriftInterestRate(bank: DriftSpotMarket, delta?: BN$1, currentUtilization?: BN$1 | null): BN$1;
|
|
22463
22463
|
/**
|
|
22464
22464
|
* Calculates the borrow rate (APR) for a spot market
|
|
22465
22465
|
*/
|
|
22466
|
-
declare function
|
|
22466
|
+
declare function calculateDriftBorrowRate(bank: DriftSpotMarket, delta?: BN$1, currentUtilization?: BN$1 | null): BN$1;
|
|
22467
22467
|
/**
|
|
22468
22468
|
* Calculates the deposit rate (APR) for a spot market
|
|
22469
22469
|
* This is the annualized interest rate lenders earn
|
|
22470
22470
|
*/
|
|
22471
|
-
declare function
|
|
22471
|
+
declare function calculateDriftDepositRate(bank: DriftSpotMarket, delta?: BN$1, currentUtilization?: BN$1 | null): BN$1;
|
|
22472
22472
|
/**
|
|
22473
22473
|
* Calculates the Annual Percentage Yield (APY) for a lending/deposit position.
|
|
22474
22474
|
*
|
|
@@ -22490,7 +22490,7 @@ declare function calculateDepositRate(bank: DriftSpotMarket, delta?: BN$1, curre
|
|
|
22490
22490
|
* console.log(`Lending APY: ${apyPercent.toFixed(2)}%`);
|
|
22491
22491
|
* ```
|
|
22492
22492
|
*/
|
|
22493
|
-
declare function
|
|
22493
|
+
declare function calculateDriftLendingAPY(bank: DriftSpotMarket, delta?: BN$1, currentUtilization?: BN$1 | null, compoundingPeriodsPerYear?: number): BN$1;
|
|
22494
22494
|
/**
|
|
22495
22495
|
* Calculates a simplified lending APY without compounding (essentially the APR).
|
|
22496
22496
|
* This is faster but less accurate than calculateLendingAPY.
|
|
@@ -22500,7 +22500,7 @@ declare function calculateLendingAPY(bank: DriftSpotMarket, delta?: BN$1, curren
|
|
|
22500
22500
|
* @param currentUtilization - Optional pre-calculated utilization (default: null)
|
|
22501
22501
|
* @returns APR as a percentage scaled by PERCENTAGE_PRECISION
|
|
22502
22502
|
*/
|
|
22503
|
-
declare function
|
|
22503
|
+
declare function calculateDriftLendingAPR(bank: DriftSpotMarket, delta?: BN$1, currentUtilization?: BN$1 | null): BN$1;
|
|
22504
22504
|
/**
|
|
22505
22505
|
* Calculates the borrowing APY for a borrow position.
|
|
22506
22506
|
*
|
|
@@ -22510,7 +22510,7 @@ declare function calculateLendingAPR(bank: DriftSpotMarket, delta?: BN$1, curren
|
|
|
22510
22510
|
* @param compoundingPeriodsPerYear - Number of times interest compounds per year (default: 365)
|
|
22511
22511
|
* @returns APY as a percentage scaled by PERCENTAGE_PRECISION
|
|
22512
22512
|
*/
|
|
22513
|
-
declare function
|
|
22513
|
+
declare function calculateDriftBorrowAPY(bank: DriftSpotMarket, delta?: BN$1, currentUtilization?: BN$1 | null, compoundingPeriodsPerYear?: number): BN$1;
|
|
22514
22514
|
/**
|
|
22515
22515
|
* Calculates the borrowing APR (without compounding).
|
|
22516
22516
|
*
|
|
@@ -22519,7 +22519,35 @@ declare function calculateBorrowAPY(bank: DriftSpotMarket, delta?: BN$1, current
|
|
|
22519
22519
|
* @param currentUtilization - Optional pre-calculated utilization (default: null)
|
|
22520
22520
|
* @returns APR as a percentage scaled by PERCENTAGE_PRECISION
|
|
22521
22521
|
*/
|
|
22522
|
-
declare function
|
|
22522
|
+
declare function calculateDriftBorrowAPR(bank: DriftSpotMarket, delta?: BN$1, currentUtilization?: BN$1 | null): BN$1;
|
|
22523
|
+
/**
|
|
22524
|
+
* Interest rate curve point for visualization
|
|
22525
|
+
*/
|
|
22526
|
+
interface DriftInterestRateCurvePoint {
|
|
22527
|
+
utilization: number;
|
|
22528
|
+
borrowAPY: number;
|
|
22529
|
+
supplyAPY: number;
|
|
22530
|
+
}
|
|
22531
|
+
/**
|
|
22532
|
+
* Generate complete interest rate curve for a Drift spot market
|
|
22533
|
+
* Creates 101 data points from 0% to 100% utilization
|
|
22534
|
+
*
|
|
22535
|
+
* @param spotMarket - The Drift spot market account
|
|
22536
|
+
* @returns Array of curve points with utilization, borrow APY, and supply APY
|
|
22537
|
+
*
|
|
22538
|
+
* @example
|
|
22539
|
+
* ```typescript
|
|
22540
|
+
* const spotMarket = getDriftSpotMarket(0); // USDC market
|
|
22541
|
+
* const curve = generateDriftReserveCurve(spotMarket);
|
|
22542
|
+
*
|
|
22543
|
+
* curve.forEach(point => {
|
|
22544
|
+
* console.log(`Utilization: ${point.utilization}%`);
|
|
22545
|
+
* console.log(`Borrow APY: ${point.borrowAPY.toFixed(2)}%`);
|
|
22546
|
+
* console.log(`Supply APY: ${point.supplyAPY.toFixed(2)}%`);
|
|
22547
|
+
* });
|
|
22548
|
+
* ```
|
|
22549
|
+
*/
|
|
22550
|
+
declare function generateDriftReserveCurve(spotMarket: DriftSpotMarket): DriftInterestRateCurvePoint[];
|
|
22523
22551
|
|
|
22524
22552
|
declare function getDriftRewards(spotMarkets: DriftSpotMarket[], userStates: {
|
|
22525
22553
|
bankAddress: PublicKey;
|
|
@@ -23099,4 +23127,4 @@ declare const transferCheckedInstructionData: _solana_buffer_layout.Structure<Tr
|
|
|
23099
23127
|
*/
|
|
23100
23128
|
declare function createTransferCheckedInstruction(source: PublicKey, mint: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint, decimals: number, multiSigners?: Signer[], programId?: PublicKey): TransactionInstruction;
|
|
23101
23129
|
|
|
23102
|
-
export { ACCOUNT_SIZE, ACCOUNT_TYPE_SIZE, ASSOCIATED_TOKEN_PROGRAM_ID, type Account, AccountLayout, AccountState, AccountType, type Base, type CloseAccountInstructionData, CorpAction, CurvePointFields, DEFAULT_RECENT_SLOT_DURATION_MS, DRIFT_IDL, DRIFT_PROGRAM_ID, type DriftIdlType, DriftRewards, DriftRewardsJSON, DriftSpotBalanceType, DriftSpotMarket, DriftSpotMarketJSON, type DriftSpotMarketRaw, type DriftState, type DriftStateJSON, DriftUser, DriftUserJSON, type DriftUserRaw, DriftUserStats, DriftUserStatsJSON, type Ema, ExtensionType, FARMS_PROGRAM_ID, FarmStateJSON, FarmStateRaw, FeeStructure, FeeStructureJSON, HistoricalIndexData, HistoricalOracleData, type InitializeAccountInstructionData, InsuranceFund,
|
|
23130
|
+
export { ACCOUNT_SIZE, ACCOUNT_TYPE_SIZE, ASSOCIATED_TOKEN_PROGRAM_ID, type Account, AccountLayout, AccountState, AccountType, type Base, type CloseAccountInstructionData, CorpAction, CurvePointFields, DEFAULT_RECENT_SLOT_DURATION_MS, DRIFT_IDL, DRIFT_PROGRAM_ID, type DriftIdlType, type DriftInterestRateCurvePoint, DriftRewards, DriftRewardsJSON, DriftSpotBalanceType, DriftSpotMarket, DriftSpotMarketJSON, type DriftSpotMarketRaw, type DriftState, type DriftStateJSON, DriftUser, DriftUserJSON, type DriftUserRaw, DriftUserStats, DriftUserStatsJSON, type Ema, ExtensionType, FARMS_PROGRAM_ID, FarmStateJSON, FarmStateRaw, FeeStructure, FeeStructureJSON, HistoricalIndexData, HistoricalOracleData, type InitializeAccountInstructionData, InsuranceFund, KFARMS_IDL, KLEND_ACCOUNT_CODER, KLEND_IDL, KLEND_PROGRAM_ID, type KaminoReserveCurveData, type KfarmsIdlType, type KlendIdlType, type KlendInterestRateCurvePoint, LENGTH_SIZE, MAX_SLOT_DIFFERENCE, MEMO_PROGRAM_ID, MINT_SIZE, MULTISIG_SIZE, type Mint, MintLayout, type Multisig, MultisigLayout, NATIVE_MINT, ONE, ONE_HUNDRED_PCT_IN_BPS, ONE_YEAR, ObligationJSON, ObligationRaw, OracleGuardRails, OracleGuardRailsJSON, PERCENTAGE_PRECISION, PERCENTAGE_PRECISION_EXP, PoolBalance, type Price, type PriceComponent, type PriceData, PriceStatus, PriceType, REFRESH_OBLIGATION_DISCRIMINATOR, type RawAccount, type RawMint, type RawMultisig, type RefreshObligationAccounts, ReserveJSON, ReserveRaw, RewardInfoFields, SEED_BASE_REFERRER_STATE, SEED_BASE_REFERRER_TOKEN_STATE, SEED_BASE_SHORT_URL, SEED_BASE_USER_METADATA, SEED_DRIFT_SIGNER, SEED_DRIFT_STATE, SEED_FEE_RECEIVER, SEED_LENDING_MARKET_AUTH, SEED_RESERVE_COLL_MINT, SEED_RESERVE_COLL_SUPPLY, SEED_RESERVE_LIQ_SUPPLY, SEED_SPOT_MARKET, SEED_SPOT_MARKET_VAULT, SEED_USER, SEED_USER_STATE, SEED_USER_STATS, SLOTS_PER_DAY, SLOTS_PER_HOUR, SLOTS_PER_MINUTE, SLOTS_PER_SECOND, SLOTS_PER_YEAR, SPOT_MARKET_RATE_PRECISION, SPOT_MARKET_RATE_PRECISION_EXP, SPOT_MARKET_UTILIZATION_PRECISION, SPOT_MARKET_UTILIZATION_PRECISION_EXP, SinglePoolInstruction, SplAccountType, SpotPosition, type StakeAccount, type SyncNativeInstructionData, TEN, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, TYPE_SIZE, TokenAccountNotFoundError, TokenError, TokenInstruction, TokenInvalidAccountError, TokenInvalidAccountOwnerError, TokenInvalidAccountSizeError, TokenInvalidInstructionDataError, TokenInvalidInstructionKeysError, TokenInvalidInstructionProgramError, TokenInvalidInstructionTypeError, TokenInvalidMintError, TokenInvalidOwnerError, TokenOwnerOffCurveError, TokenUnsupportedInstructionError, type TransferCheckedInstructionData, ZERO, addSigners, calculateAPYFromAPR, calculateDriftBorrowAPR, calculateDriftBorrowAPY, calculateDriftBorrowRate, calculateDriftDepositRate, calculateDriftInterestRate, calculateDriftLendingAPR, calculateDriftLendingAPY, calculateDriftUtilization, calculateKaminoEstimatedBorrowRate, calculateKaminoEstimatedSupplyRate, calculateKaminoSupplyAPY, calculateRewardApy, calculateSlotAdjustmentFactor, calculateUtilizationRatio, closeAccountInstructionData, createAccountIx, createAssociatedTokenAccountIdempotentInstruction, createAssociatedTokenAccountInstruction, createCloseAccountInstruction, createInitializeAccountInstruction, createMemoInstruction, createPoolOnrampIx, createSyncNativeInstruction, createTransferCheckedInstruction, decodeDriftSpotMarketData, decodeDriftStateData, decodeDriftUserData, decodeDriftUserStatsData, decodeFarmDataRaw, decodeKlendObligationData, decodeKlendReserveData, deriveBaseObligation, deriveDriftSigner, deriveDriftSpotMarket, deriveDriftSpotMarketVault, deriveDriftState, deriveDriftUser, deriveDriftUserStats, deriveFeeReceiver, deriveLendingMarketAuthority, deriveObligation, deriveReferrerState, deriveReferrerTokenState, deriveReserveCollateralMint, deriveReserveCollateralSupply, deriveReserveLiquiditySupply, deriveShortUrl, deriveUserMetadata, deriveUserState, driftRewardsRawToDto, driftSpotMarketRawToDto, driftStateRawToDto, driftUserRawToDto, driftUserStatsRawToDto, dtoToDriftRewardsRaw, dtoToDriftSpotMarketRaw, dtoToDriftStateRaw, dtoToDriftUserRaw, dtoToDriftUserStatsRaw, dtoToFarmRaw, dtoToObligationRaw, dtoToReserveRaw, farmRawToDto, findMplMetadataAddress, findPoolAddress, findPoolMintAddress, findPoolMintAddressByVoteAccount, findPoolMintAuthorityAddress, findPoolMplAuthorityAddress, findPoolOnRampAddress, findPoolStakeAddress, findPoolStakeAuthorityAddress, generateDriftReserveCurve, generateKaminoReserveCurve, getAccount, getAccountLen, getAllDerivedDriftAccounts, getAllDerivedKaminoAccounts, getAllRequiredMarkets, getAssociatedTokenAddressSync, getDriftRewards, getDriftTokenAmount, getFixedHostInterestRate, getKaminoBorrowRate, getKaminoTotalSupply, getMinimumBalanceForRentExemptAccount, getMinimumBalanceForRentExemptAccountWithExtensions, getMint, getMultipleAccounts, getProtocolTakeRatePct, getReserveRewardsApy, getRewardPerTimeUnitSecond, getStakeAccount, initializeAccountInstructionData, initializeStakedPoolIxs, initializeStakedPoolTx, interpolateLinear, layout, makeRefreshObligationIx, makeRefreshReservesBatchIx, makeRefreshingIxs, makeUpdateSpotMarketCumulativeInterestIx, makeUpdateSpotMarketIx, obligationRawToDto, parsePriceData, parsePriceInfo, replenishPoolIx, reserveRawToDto, scaledSupplies, slotAdjustmentFactor, syncNativeInstructionData, transferCheckedInstructionData, truncateBorrowCurve, unpackAccount };
|
package/dist/vendor.d.ts
CHANGED
|
@@ -8103,14 +8103,14 @@ declare function deriveUserState(programId: PublicKey, farmState: PublicKey, obl
|
|
|
8103
8103
|
* Extracted all needed functions & constants out of their SDK
|
|
8104
8104
|
*/
|
|
8105
8105
|
|
|
8106
|
-
interface
|
|
8106
|
+
interface KlendInterestRateCurvePoint {
|
|
8107
8107
|
utilization: number;
|
|
8108
8108
|
borrowAPY: number;
|
|
8109
8109
|
supplyAPY: number;
|
|
8110
8110
|
}
|
|
8111
8111
|
interface KaminoReserveCurveData {
|
|
8112
8112
|
reserveAddress: string;
|
|
8113
|
-
curvePoints:
|
|
8113
|
+
curvePoints: KlendInterestRateCurvePoint[];
|
|
8114
8114
|
}
|
|
8115
8115
|
/**
|
|
8116
8116
|
* Linear interpolation between two points
|
|
@@ -8122,7 +8122,7 @@ declare const interpolateLinear: (x: number, x0: number, y0: number, x1: number,
|
|
|
8122
8122
|
* @param curve - Array of [utilization, rate] points
|
|
8123
8123
|
* @returns Borrow rate for the given utilization
|
|
8124
8124
|
*/
|
|
8125
|
-
declare const
|
|
8125
|
+
declare const getKaminoBorrowRate: (currentUtilization: number, curve: [number, number][]) => number;
|
|
8126
8126
|
/**
|
|
8127
8127
|
* Convert APR to APY using compound interest formula
|
|
8128
8128
|
* APY = (1 + APR/n)^n - 1, where n = SLOTS_PER_YEAR
|
|
@@ -8136,7 +8136,7 @@ declare function calculateAPYFromAPR(apr: number): number;
|
|
|
8136
8136
|
* @param reserve - The Kamino reserve
|
|
8137
8137
|
* @returns Total supply in lamports
|
|
8138
8138
|
*/
|
|
8139
|
-
declare function
|
|
8139
|
+
declare function getKaminoTotalSupply(reserve: ReserveRaw): Decimal;
|
|
8140
8140
|
/**
|
|
8141
8141
|
* Calculate utilization ratio of a reserve
|
|
8142
8142
|
* Formula: total borrowed / total supply
|
|
@@ -8162,7 +8162,7 @@ declare function calculateSlotAdjustmentFactor(reserve: ReserveRaw, recentSlotDu
|
|
|
8162
8162
|
* @param recentSlotDurationMs - Recent slot duration (optional)
|
|
8163
8163
|
* @returns Borrow rate as decimal (e.g., 0.05 = 5%)
|
|
8164
8164
|
*/
|
|
8165
|
-
declare function
|
|
8165
|
+
declare function calculateKaminoEstimatedBorrowRate(reserve: ReserveRaw, recentSlotDurationMs?: number): number;
|
|
8166
8166
|
/**
|
|
8167
8167
|
* Calculate estimated supply rate for a reserve
|
|
8168
8168
|
* Formula: borrow rate × utilization × (1 - protocol take rate)
|
|
@@ -8170,7 +8170,7 @@ declare function calculateEstimatedBorrowRate(reserve: ReserveRaw, recentSlotDur
|
|
|
8170
8170
|
* @param recentSlotDurationMs - Recent slot duration (optional)
|
|
8171
8171
|
* @returns Supply rate as decimal (e.g., 0.03 = 3%)
|
|
8172
8172
|
*/
|
|
8173
|
-
declare function
|
|
8173
|
+
declare function calculateKaminoEstimatedSupplyRate(reserve: ReserveRaw, recentSlotDurationMs?: number): number;
|
|
8174
8174
|
/**
|
|
8175
8175
|
* Calculate supply APY for a reserve
|
|
8176
8176
|
* APY includes compounding, making it higher than APR
|
|
@@ -8179,7 +8179,7 @@ declare function calculateEstimatedSupplyRate(reserve: ReserveRaw, recentSlotDur
|
|
|
8179
8179
|
* @param recentSlotDurationMs - Recent slot duration (defaults to 450ms)
|
|
8180
8180
|
* @returns Supply APY as decimal (e.g., 0.0512 = 5.12% APY)
|
|
8181
8181
|
*/
|
|
8182
|
-
declare function
|
|
8182
|
+
declare function calculateKaminoSupplyAPY(reserve: ReserveRaw, recentSlotDurationMs?: number): number;
|
|
8183
8183
|
declare function scaledSupplies(state: ReserveRaw): [Decimal, Decimal];
|
|
8184
8184
|
/**
|
|
8185
8185
|
* Convert raw curve points to normalized [utilization, rate] pairs
|
|
@@ -8204,7 +8204,7 @@ declare function getProtocolTakeRatePct(reserve: ReserveRaw): number;
|
|
|
8204
8204
|
* @param protocolTakeRatePct - Percentage kept by depositors (1 - protocol fee)
|
|
8205
8205
|
* @returns Array of curve points with utilization, borrow APY, and supply APY
|
|
8206
8206
|
*/
|
|
8207
|
-
declare function generateKaminoReserveCurve(curvePoints: CurvePointFields[], slotAdjustmentFactor: number, fixedHostInterestRate: number, protocolTakeRatePct: number):
|
|
8207
|
+
declare function generateKaminoReserveCurve(curvePoints: CurvePointFields[], slotAdjustmentFactor: number, fixedHostInterestRate: number, protocolTakeRatePct: number): KlendInterestRateCurvePoint[];
|
|
8208
8208
|
|
|
8209
8209
|
declare function getRewardPerTimeUnitSecond(reward: RewardInfoFields): Decimal;
|
|
8210
8210
|
declare function getReserveRewardsApy(priceByMint: Record<string, number>, farmState: FarmStateRaw, reserveState: ReserveRaw): Promise<{
|
|
@@ -22450,25 +22450,25 @@ declare const ONE_YEAR: BN$1;
|
|
|
22450
22450
|
/**
|
|
22451
22451
|
* Calculates the spot token amount including any accumulated interest.
|
|
22452
22452
|
*/
|
|
22453
|
-
declare function
|
|
22453
|
+
declare function getDriftTokenAmount(balanceAmount: BN$1, spotMarket: DriftSpotMarket, balanceType: DriftSpotBalanceType): BN$1;
|
|
22454
22454
|
/**
|
|
22455
22455
|
* Calculates the utilization rate of a spot market
|
|
22456
22456
|
* Utilization = borrows / deposits
|
|
22457
22457
|
*/
|
|
22458
|
-
declare function
|
|
22458
|
+
declare function calculateDriftUtilization(bank: DriftSpotMarket, delta?: BN$1): BN$1;
|
|
22459
22459
|
/**
|
|
22460
22460
|
* Calculates the interest rate based on utilization using a piecewise curve
|
|
22461
22461
|
*/
|
|
22462
|
-
declare function
|
|
22462
|
+
declare function calculateDriftInterestRate(bank: DriftSpotMarket, delta?: BN$1, currentUtilization?: BN$1 | null): BN$1;
|
|
22463
22463
|
/**
|
|
22464
22464
|
* Calculates the borrow rate (APR) for a spot market
|
|
22465
22465
|
*/
|
|
22466
|
-
declare function
|
|
22466
|
+
declare function calculateDriftBorrowRate(bank: DriftSpotMarket, delta?: BN$1, currentUtilization?: BN$1 | null): BN$1;
|
|
22467
22467
|
/**
|
|
22468
22468
|
* Calculates the deposit rate (APR) for a spot market
|
|
22469
22469
|
* This is the annualized interest rate lenders earn
|
|
22470
22470
|
*/
|
|
22471
|
-
declare function
|
|
22471
|
+
declare function calculateDriftDepositRate(bank: DriftSpotMarket, delta?: BN$1, currentUtilization?: BN$1 | null): BN$1;
|
|
22472
22472
|
/**
|
|
22473
22473
|
* Calculates the Annual Percentage Yield (APY) for a lending/deposit position.
|
|
22474
22474
|
*
|
|
@@ -22490,7 +22490,7 @@ declare function calculateDepositRate(bank: DriftSpotMarket, delta?: BN$1, curre
|
|
|
22490
22490
|
* console.log(`Lending APY: ${apyPercent.toFixed(2)}%`);
|
|
22491
22491
|
* ```
|
|
22492
22492
|
*/
|
|
22493
|
-
declare function
|
|
22493
|
+
declare function calculateDriftLendingAPY(bank: DriftSpotMarket, delta?: BN$1, currentUtilization?: BN$1 | null, compoundingPeriodsPerYear?: number): BN$1;
|
|
22494
22494
|
/**
|
|
22495
22495
|
* Calculates a simplified lending APY without compounding (essentially the APR).
|
|
22496
22496
|
* This is faster but less accurate than calculateLendingAPY.
|
|
@@ -22500,7 +22500,7 @@ declare function calculateLendingAPY(bank: DriftSpotMarket, delta?: BN$1, curren
|
|
|
22500
22500
|
* @param currentUtilization - Optional pre-calculated utilization (default: null)
|
|
22501
22501
|
* @returns APR as a percentage scaled by PERCENTAGE_PRECISION
|
|
22502
22502
|
*/
|
|
22503
|
-
declare function
|
|
22503
|
+
declare function calculateDriftLendingAPR(bank: DriftSpotMarket, delta?: BN$1, currentUtilization?: BN$1 | null): BN$1;
|
|
22504
22504
|
/**
|
|
22505
22505
|
* Calculates the borrowing APY for a borrow position.
|
|
22506
22506
|
*
|
|
@@ -22510,7 +22510,7 @@ declare function calculateLendingAPR(bank: DriftSpotMarket, delta?: BN$1, curren
|
|
|
22510
22510
|
* @param compoundingPeriodsPerYear - Number of times interest compounds per year (default: 365)
|
|
22511
22511
|
* @returns APY as a percentage scaled by PERCENTAGE_PRECISION
|
|
22512
22512
|
*/
|
|
22513
|
-
declare function
|
|
22513
|
+
declare function calculateDriftBorrowAPY(bank: DriftSpotMarket, delta?: BN$1, currentUtilization?: BN$1 | null, compoundingPeriodsPerYear?: number): BN$1;
|
|
22514
22514
|
/**
|
|
22515
22515
|
* Calculates the borrowing APR (without compounding).
|
|
22516
22516
|
*
|
|
@@ -22519,7 +22519,35 @@ declare function calculateBorrowAPY(bank: DriftSpotMarket, delta?: BN$1, current
|
|
|
22519
22519
|
* @param currentUtilization - Optional pre-calculated utilization (default: null)
|
|
22520
22520
|
* @returns APR as a percentage scaled by PERCENTAGE_PRECISION
|
|
22521
22521
|
*/
|
|
22522
|
-
declare function
|
|
22522
|
+
declare function calculateDriftBorrowAPR(bank: DriftSpotMarket, delta?: BN$1, currentUtilization?: BN$1 | null): BN$1;
|
|
22523
|
+
/**
|
|
22524
|
+
* Interest rate curve point for visualization
|
|
22525
|
+
*/
|
|
22526
|
+
interface DriftInterestRateCurvePoint {
|
|
22527
|
+
utilization: number;
|
|
22528
|
+
borrowAPY: number;
|
|
22529
|
+
supplyAPY: number;
|
|
22530
|
+
}
|
|
22531
|
+
/**
|
|
22532
|
+
* Generate complete interest rate curve for a Drift spot market
|
|
22533
|
+
* Creates 101 data points from 0% to 100% utilization
|
|
22534
|
+
*
|
|
22535
|
+
* @param spotMarket - The Drift spot market account
|
|
22536
|
+
* @returns Array of curve points with utilization, borrow APY, and supply APY
|
|
22537
|
+
*
|
|
22538
|
+
* @example
|
|
22539
|
+
* ```typescript
|
|
22540
|
+
* const spotMarket = getDriftSpotMarket(0); // USDC market
|
|
22541
|
+
* const curve = generateDriftReserveCurve(spotMarket);
|
|
22542
|
+
*
|
|
22543
|
+
* curve.forEach(point => {
|
|
22544
|
+
* console.log(`Utilization: ${point.utilization}%`);
|
|
22545
|
+
* console.log(`Borrow APY: ${point.borrowAPY.toFixed(2)}%`);
|
|
22546
|
+
* console.log(`Supply APY: ${point.supplyAPY.toFixed(2)}%`);
|
|
22547
|
+
* });
|
|
22548
|
+
* ```
|
|
22549
|
+
*/
|
|
22550
|
+
declare function generateDriftReserveCurve(spotMarket: DriftSpotMarket): DriftInterestRateCurvePoint[];
|
|
22523
22551
|
|
|
22524
22552
|
declare function getDriftRewards(spotMarkets: DriftSpotMarket[], userStates: {
|
|
22525
22553
|
bankAddress: PublicKey;
|
|
@@ -23099,4 +23127,4 @@ declare const transferCheckedInstructionData: _solana_buffer_layout.Structure<Tr
|
|
|
23099
23127
|
*/
|
|
23100
23128
|
declare function createTransferCheckedInstruction(source: PublicKey, mint: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint, decimals: number, multiSigners?: Signer[], programId?: PublicKey): TransactionInstruction;
|
|
23101
23129
|
|
|
23102
|
-
export { ACCOUNT_SIZE, ACCOUNT_TYPE_SIZE, ASSOCIATED_TOKEN_PROGRAM_ID, type Account, AccountLayout, AccountState, AccountType, type Base, type CloseAccountInstructionData, CorpAction, CurvePointFields, DEFAULT_RECENT_SLOT_DURATION_MS, DRIFT_IDL, DRIFT_PROGRAM_ID, type DriftIdlType, DriftRewards, DriftRewardsJSON, DriftSpotBalanceType, DriftSpotMarket, DriftSpotMarketJSON, type DriftSpotMarketRaw, type DriftState, type DriftStateJSON, DriftUser, DriftUserJSON, type DriftUserRaw, DriftUserStats, DriftUserStatsJSON, type Ema, ExtensionType, FARMS_PROGRAM_ID, FarmStateJSON, FarmStateRaw, FeeStructure, FeeStructureJSON, HistoricalIndexData, HistoricalOracleData, type InitializeAccountInstructionData, InsuranceFund,
|
|
23130
|
+
export { ACCOUNT_SIZE, ACCOUNT_TYPE_SIZE, ASSOCIATED_TOKEN_PROGRAM_ID, type Account, AccountLayout, AccountState, AccountType, type Base, type CloseAccountInstructionData, CorpAction, CurvePointFields, DEFAULT_RECENT_SLOT_DURATION_MS, DRIFT_IDL, DRIFT_PROGRAM_ID, type DriftIdlType, type DriftInterestRateCurvePoint, DriftRewards, DriftRewardsJSON, DriftSpotBalanceType, DriftSpotMarket, DriftSpotMarketJSON, type DriftSpotMarketRaw, type DriftState, type DriftStateJSON, DriftUser, DriftUserJSON, type DriftUserRaw, DriftUserStats, DriftUserStatsJSON, type Ema, ExtensionType, FARMS_PROGRAM_ID, FarmStateJSON, FarmStateRaw, FeeStructure, FeeStructureJSON, HistoricalIndexData, HistoricalOracleData, type InitializeAccountInstructionData, InsuranceFund, KFARMS_IDL, KLEND_ACCOUNT_CODER, KLEND_IDL, KLEND_PROGRAM_ID, type KaminoReserveCurveData, type KfarmsIdlType, type KlendIdlType, type KlendInterestRateCurvePoint, LENGTH_SIZE, MAX_SLOT_DIFFERENCE, MEMO_PROGRAM_ID, MINT_SIZE, MULTISIG_SIZE, type Mint, MintLayout, type Multisig, MultisigLayout, NATIVE_MINT, ONE, ONE_HUNDRED_PCT_IN_BPS, ONE_YEAR, ObligationJSON, ObligationRaw, OracleGuardRails, OracleGuardRailsJSON, PERCENTAGE_PRECISION, PERCENTAGE_PRECISION_EXP, PoolBalance, type Price, type PriceComponent, type PriceData, PriceStatus, PriceType, REFRESH_OBLIGATION_DISCRIMINATOR, type RawAccount, type RawMint, type RawMultisig, type RefreshObligationAccounts, ReserveJSON, ReserveRaw, RewardInfoFields, SEED_BASE_REFERRER_STATE, SEED_BASE_REFERRER_TOKEN_STATE, SEED_BASE_SHORT_URL, SEED_BASE_USER_METADATA, SEED_DRIFT_SIGNER, SEED_DRIFT_STATE, SEED_FEE_RECEIVER, SEED_LENDING_MARKET_AUTH, SEED_RESERVE_COLL_MINT, SEED_RESERVE_COLL_SUPPLY, SEED_RESERVE_LIQ_SUPPLY, SEED_SPOT_MARKET, SEED_SPOT_MARKET_VAULT, SEED_USER, SEED_USER_STATE, SEED_USER_STATS, SLOTS_PER_DAY, SLOTS_PER_HOUR, SLOTS_PER_MINUTE, SLOTS_PER_SECOND, SLOTS_PER_YEAR, SPOT_MARKET_RATE_PRECISION, SPOT_MARKET_RATE_PRECISION_EXP, SPOT_MARKET_UTILIZATION_PRECISION, SPOT_MARKET_UTILIZATION_PRECISION_EXP, SinglePoolInstruction, SplAccountType, SpotPosition, type StakeAccount, type SyncNativeInstructionData, TEN, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, TYPE_SIZE, TokenAccountNotFoundError, TokenError, TokenInstruction, TokenInvalidAccountError, TokenInvalidAccountOwnerError, TokenInvalidAccountSizeError, TokenInvalidInstructionDataError, TokenInvalidInstructionKeysError, TokenInvalidInstructionProgramError, TokenInvalidInstructionTypeError, TokenInvalidMintError, TokenInvalidOwnerError, TokenOwnerOffCurveError, TokenUnsupportedInstructionError, type TransferCheckedInstructionData, ZERO, addSigners, calculateAPYFromAPR, calculateDriftBorrowAPR, calculateDriftBorrowAPY, calculateDriftBorrowRate, calculateDriftDepositRate, calculateDriftInterestRate, calculateDriftLendingAPR, calculateDriftLendingAPY, calculateDriftUtilization, calculateKaminoEstimatedBorrowRate, calculateKaminoEstimatedSupplyRate, calculateKaminoSupplyAPY, calculateRewardApy, calculateSlotAdjustmentFactor, calculateUtilizationRatio, closeAccountInstructionData, createAccountIx, createAssociatedTokenAccountIdempotentInstruction, createAssociatedTokenAccountInstruction, createCloseAccountInstruction, createInitializeAccountInstruction, createMemoInstruction, createPoolOnrampIx, createSyncNativeInstruction, createTransferCheckedInstruction, decodeDriftSpotMarketData, decodeDriftStateData, decodeDriftUserData, decodeDriftUserStatsData, decodeFarmDataRaw, decodeKlendObligationData, decodeKlendReserveData, deriveBaseObligation, deriveDriftSigner, deriveDriftSpotMarket, deriveDriftSpotMarketVault, deriveDriftState, deriveDriftUser, deriveDriftUserStats, deriveFeeReceiver, deriveLendingMarketAuthority, deriveObligation, deriveReferrerState, deriveReferrerTokenState, deriveReserveCollateralMint, deriveReserveCollateralSupply, deriveReserveLiquiditySupply, deriveShortUrl, deriveUserMetadata, deriveUserState, driftRewardsRawToDto, driftSpotMarketRawToDto, driftStateRawToDto, driftUserRawToDto, driftUserStatsRawToDto, dtoToDriftRewardsRaw, dtoToDriftSpotMarketRaw, dtoToDriftStateRaw, dtoToDriftUserRaw, dtoToDriftUserStatsRaw, dtoToFarmRaw, dtoToObligationRaw, dtoToReserveRaw, farmRawToDto, findMplMetadataAddress, findPoolAddress, findPoolMintAddress, findPoolMintAddressByVoteAccount, findPoolMintAuthorityAddress, findPoolMplAuthorityAddress, findPoolOnRampAddress, findPoolStakeAddress, findPoolStakeAuthorityAddress, generateDriftReserveCurve, generateKaminoReserveCurve, getAccount, getAccountLen, getAllDerivedDriftAccounts, getAllDerivedKaminoAccounts, getAllRequiredMarkets, getAssociatedTokenAddressSync, getDriftRewards, getDriftTokenAmount, getFixedHostInterestRate, getKaminoBorrowRate, getKaminoTotalSupply, getMinimumBalanceForRentExemptAccount, getMinimumBalanceForRentExemptAccountWithExtensions, getMint, getMultipleAccounts, getProtocolTakeRatePct, getReserveRewardsApy, getRewardPerTimeUnitSecond, getStakeAccount, initializeAccountInstructionData, initializeStakedPoolIxs, initializeStakedPoolTx, interpolateLinear, layout, makeRefreshObligationIx, makeRefreshReservesBatchIx, makeRefreshingIxs, makeUpdateSpotMarketCumulativeInterestIx, makeUpdateSpotMarketIx, obligationRawToDto, parsePriceData, parsePriceInfo, replenishPoolIx, reserveRawToDto, scaledSupplies, slotAdjustmentFactor, syncNativeInstructionData, transferCheckedInstructionData, truncateBorrowCurve, unpackAccount };
|