Last active
March 8, 2023 19:45
-
-
Save sekrystal/763701a8347d41563e13d9613d9629e2 to your computer and use it in GitHub Desktop.
Defi Lending Concepts 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.8.13; | |
function getOverallBorrowRateInternal( | |
uint256 _totalBorrowsStable, | |
uint256 _totalBorrowsVariable, | |
uint256 _currentVariableBorrowRate, | |
uint256 _currentAverageStableBorrowRate | |
) internal pure returns (uint256) { | |
uint256 totalBorrows = _totalBorrowsStable.add(_totalBorrowsVariable); | |
if (totalBorrows == 0) return 0; | |
uint256 weightedVariableRate = _totalBorrowsVariable.wadToRay().rayMul( | |
_currentVariableBorrowRate | |
); | |
uint256 weightedStableRate = _totalBorrowsStable.wadToRay().rayMul( | |
_currentAverageStableBorrowRate | |
); | |
uint256 overallBorrowRate = weightedVariableRate.add(weightedStableRate).rayDiv( | |
totalBorrows.wadToRay() | |
); | |
return overallBorrowRate; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment