The following readme describes all the functions and their parameters exposed by the partitionedLinearInterestRateModel class of the K2 SDK. This sub-class contains all the important functions from the K2 Partitioned Linear Interest Rate Model contract of the K2 Lending protocol.

getUtilizationRatio function

Get the max utilisation percentage of the pool at 100% utilisation.

Input Parameters

assumedLiquidity: Total liquidity in the pool, including available and borrowed funds
borrowedLiquidity: Liquidity borrowed from the pool
borrowAmount: Borrow amount

Using getUtilizationRatio function

await sdk.partitionedLinearInterestRateModel.getUtilizationRatio(assumedLiquidity, borrowedLiquidity, borrowAmount);

Return Parameters

Returns the max utilization percentage.

maxSlashableAmountPerLivenessUpper function

Upper bound for the ETH slashing amount that can take place for a given liveness event.

Input Parameters

assumedLiquidity: Total liquidity in the pool, including available and borrowed funds
borrowedLiquidity: Liquidity borrowed from the pool
borrowAmount: Borrow amount

Using maxSlashableAmountPerLivenessUpper function

await sdk.partitionedLinearInterestRateModel.maxSlashableAmountPerLivenessUpper(assumedLiquidity, borrowedLiquidity, borrowAmount);

Return Parameters

Returns the max ETH slashing amount possible for a given liveness event.

maxSlashableAmountPerCorruptionUpper function

Upper bound for the ETH slashing amount that can take place for a given corruption event.

Input Parameters

assumedLiquidity: Total liquidity in the pool, including available and borrowed funds
borrowedLiquidity: Liquidity borrowed from the pool
borrowAmount: Borrow amount

Using maxSlashableAmountPerCorruptionUpper function

await sdk.partitionedLinearInterestRateModel.maxSlashableAmountPerCorruptionUpper(assumedLiquidity, borrowedLiquidity, borrowAmount);

Return Parameters

Returns the max ETH slashing amount possible for a given corruption event.

getInterestRate function

Get the current interest rate based on assumed (total) and available liquidity.

Input Parameters

assumedLiquidity: Total liquidity in the pool, including available and borrowed funds
borrowedLiquidity: Liquidity borrowed from the pool
borrowAmount: Borrow amount
maxSlashableAmountPerLiveness: Maximum slashable amount per liveness
maxSlashableAmountPerCorruption: Maximum slashable amount per corruption

Using getInterestRate function

await sdk.partitionedLinearInterestRateModel.getInterestRate(assumedLiquidity, borrowedLiquidity, borrowAmount, maxSlashableAmountPerLiveness, maxSlashableAmountPerCorruption);

Return Parameters

Returns the current interest rate in RAY format.

getMaxBorrowableAmount function

Get the expected max borrow amount for SBP using interest.

Input Parameters

interestAmount: The interest amount
currentBorrowAmount: Curent debt principal
maxSlashableAmountPerLiveness: Maximum slashable amount per liveness
maxSlashableAmountPerCorruption: Maximum slashable amount per corruption
duration: Borrow duration

Using getMaxBorrowableAmount function

await sdk.partitionedLinearInterestRateModel.getMaxBorrowableAmount(interestAmount, currentBorrowAmount, maxSlashableAmountPerLiveness, maxSlashableAmountPerCorruption, duration);

Return Parameters

Returns the expected max borrow amount using interest.

getExpectedInterest function

Get the expected interest accrued over a duration, assuming interest rate doesn’t change after the initial borrow.

Input Parameters

newBorrowAmount: The debt principal to compute interest for
currentBorrowAmount: Curent debt principal
maxSlashableAmountPerLiveness: Maximum slashable amount per liveness
maxSlashableAmountPerCorruption: Maximum slashable amount per corruption
duration: Borrow duration

Using getExpectedInterest function

await sdk.partitionedLinearInterestRateModel.getExpectedInterest(newBorrowAmount, currentBorrowAmount, maxSlashableAmountPerLiveness, maxSlashableAmountPerCorruption, duration);

Return Parameters

Returns the expected interest accrued over a duration.

getBorrowableAmountBounds function

Get the upper and lower boundaries on the given borrow amount.

Input Parameters

currentBorrowAmount: Curent debt principal
maxSlashableAmountPerLiveness: Maximum slashable amount per liveness
maxSlashableAmountPerCorruption: Maximum slashable amount per corruption

Using getBorrowableAmountBounds function

await sdk.partitionedLinearInterestRateModel.getBorrowableAmountBounds(currentBorrowAmount, maxSlashableAmountPerLiveness, maxSlashableAmountPerCorruption);

Return Parameters

Returns the lower and upper bounds on new borrow amount.