Skip to content

Commit

Permalink
Harmonize p2p rate computation
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubilmax committed Dec 1, 2022
1 parent 4d788cf commit 072742d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
4 changes: 2 additions & 2 deletions contracts/compound/lens/RatesLens.sol
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ abstract contract RatesLens is UsersLens {
// Do not take delta into account as it's already taken into account in p2pSupplyAmount & poolSupplyAmount
uint256 p2pSupplyRate = InterestRatesModel.computeP2PSupplyRatePerBlock(
InterestRatesModel.P2PRateComputeParams({
p2pRate: InterestRatesModel.computeRawP2PRatePerBlock(
p2pRate: PercentageMath.weightedAvg(
poolSupplyRate,
poolBorrowRate,
marketParams.p2pIndexCursor
Expand Down Expand Up @@ -252,7 +252,7 @@ abstract contract RatesLens is UsersLens {
// Do not take delta into account as it's already taken into account in p2pBorrowAmount & poolBorrowAmount
uint256 p2pBorrowRate = InterestRatesModel.computeP2PBorrowRatePerBlock(
InterestRatesModel.P2PRateComputeParams({
p2pRate: InterestRatesModel.computeRawP2PRatePerBlock(
p2pRate: PercentageMath.weightedAvg(
poolSupplyRate,
poolBorrowRate,
marketParams.p2pIndexCursor
Expand Down
17 changes: 0 additions & 17 deletions contracts/compound/libraries/InterestRatesModel.sol
Original file line number Diff line number Diff line change
Expand Up @@ -145,23 +145,6 @@ library InterestRatesModel {
}
}

/// @notice Computes and returns the raw peer-to-peer rate per block of a market given the pool rates.
/// @param _poolSupplyRate The pool's supply rate per block.
/// @param _poolBorrowRate The pool's borrow rate per block.
/// @param _p2pIndexCursor The market's p2p index cursor.
/// @return The raw peer-to-peer rate per block, without reserve factor, without delta.
function computeRawP2PRatePerBlock(
uint256 _poolSupplyRate,
uint256 _poolBorrowRate,
uint256 _p2pIndexCursor
) internal pure returns (uint256) {
return
((MAX_BASIS_POINTS - _p2pIndexCursor) *
_poolSupplyRate +
_p2pIndexCursor *
_poolBorrowRate) / MAX_BASIS_POINTS;
}

/// @notice Computes and returns the peer-to-peer supply rate per block of a market given its parameters.
/// @param _params The computation parameters.
/// @return p2pSupplyRate The peer-to-peer supply rate per block.
Expand Down

0 comments on commit 072742d

Please sign in to comment.