Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visibility #10

Merged
merged 8 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions test/examples/lending/AaveLendingPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ contract AaveLendingPool {

ILendingPoolAddressesProvider public addressesProvider;

uint256 internal UINT256_MAX = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
uint256 private UINT256_MAX = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;

/* LendingPoolCore variables*/
mapping(address => ReserveData) internal reserves;
mapping(address => ReserveData) private reserves;
mapping(address => mapping(address => UserReserveData))
internal usersReserveData;
private usersReserveData;
address[] public reservesList;

constructor(address _addressesProvider) {
Expand Down Expand Up @@ -385,7 +385,7 @@ contract AaveLendingPool {
address _user,
uint256 _amount,
bool _isFirstDeposit
) internal {
) private {
core_updateCumulativeIndexes(reserves[_reserve]);
core_updateReserveInterestRatesAndTimestampInternal(
_reserve,
Expand All @@ -403,7 +403,7 @@ contract AaveLendingPool {
address _user,
uint256 _amountRedeemed,
bool _userRedeemedEverything
) internal {
) private {
core_updateCumulativeIndexes(reserves[_reserve]);
core_updateReserveInterestRatesAndTimestampInternal(
_reserve,
Expand All @@ -418,7 +418,7 @@ contract AaveLendingPool {

function core_isReserveBorrowingEnabled(
address _reserve
) internal returns (bool) {
) private returns (bool) {
ReserveData storage reserve = reserves[_reserve];
return reserve.borrowingEnabled;
}
Expand All @@ -427,7 +427,7 @@ contract AaveLendingPool {
address _reserve,
address _user,
uint256 _amount
) internal returns (bool) {
) private returns (bool) {
ReserveData storage reserve = reserves[_reserve];
UserReserveData storage user = usersReserveData[_user][_reserve];

Expand All @@ -445,7 +445,7 @@ contract AaveLendingPool {
uint256 _amountBorrowed,
uint256 _borrowFee,
InterestRateMode _rateMode
) internal returns (uint256[] memory return_data) {
) private returns (uint256[] memory return_data) {
return_data = new uint256[](2);

uint256[]
Expand Down Expand Up @@ -487,7 +487,7 @@ contract AaveLendingPool {
function core_getUserOriginationFee(
address _reserve,
address _user
) internal returns (uint256) {
) private returns (uint256) {
UserReserveData storage user = usersReserveData[_user][_reserve];
return user.originationFee;
}
Expand All @@ -499,7 +499,7 @@ contract AaveLendingPool {
uint256 _originationFeeRepaid,
uint256 _balanceIncrease,
bool _repaidWholeLoan
) internal {
) private {
core_updateReserveStateOnRepayInternal(
_reserve,
_user,
Expand Down Expand Up @@ -580,7 +580,7 @@ contract AaveLendingPool {
address _reserve,
uint256 _liquidityAdded,
uint256 _liquidityTaken
) internal {
) private {
ReserveData storage reserve = reserves[_reserve];
uint256[] memory return_data = IReserveInterestRateStrategy(
reserve.interestRateStrategyAddress
Expand All @@ -605,7 +605,7 @@ contract AaveLendingPool {
reserve.lastUpdateTimestamp = uint40(block.timestamp);
}

function core_updateCumulativeIndexes(ReserveData storage _self) internal {
function core_updateCumulativeIndexes(ReserveData storage _self) private {
uint256 totalBorrows = _self.totalBorrowsStable +
_self.totalBorrowsVariable;

Expand Down Expand Up @@ -636,7 +636,7 @@ contract AaveLendingPool {
uint256 _balanceIncrease,
uint256 _amountBorrowed,
InterestRateMode _rateMode
) internal {
) private {
core_updateCumulativeIndexes(reserves[_reserve]);

core_updateReserveTotalBorrowsByRateModeInternal(
Expand All @@ -656,7 +656,7 @@ contract AaveLendingPool {
uint256 _balanceIncrease,
uint256 _fee,
InterestRateMode _rateMode
) internal {
) private {
ReserveData storage reserve = reserves[_reserve];
UserReserveData storage user = usersReserveData[_user][_reserve];

Expand Down Expand Up @@ -685,7 +685,7 @@ contract AaveLendingPool {
function core_getUserCurrentBorrowRate(
address _reserve,
address _user
) internal returns (uint256) {
) private returns (uint256) {
InterestRateMode rateMode = core_getUserCurrentBorrowRateMode(
_reserve,
_user
Expand All @@ -706,7 +706,7 @@ contract AaveLendingPool {
address _user,
uint256 _paybackAmountMinusFees,
uint256 _balanceIncrease
) internal {
) private {
ReserveData storage reserve = reserves[_reserve];
UserReserveData storage user = usersReserveData[_user][_reserve];

Expand Down Expand Up @@ -741,7 +741,7 @@ contract AaveLendingPool {
uint256 _originationFeeRepaid,
uint256 _balanceIncrease,
bool _repaidWholeLoan
) internal {
) private {
ReserveData storage reserve = reserves[_reserve];
UserReserveData storage user = usersReserveData[_user][_reserve];

Expand All @@ -765,7 +765,7 @@ contract AaveLendingPool {
ReserveData storage _reserve,
uint256 _amount,
uint256 _rate
) internal {
) private {
uint256 previousTotalBorrowStable = _reserve.totalBorrowsStable;
_reserve.totalBorrowsStable = _reserve.totalBorrowsStable + _amount;

Expand All @@ -783,7 +783,7 @@ contract AaveLendingPool {
ReserveData storage _reserve,
uint256 _amount,
uint256 _rate
) internal {
) private {
require(
_reserve.totalBorrowsStable >= _amount,
"Invalid amount to decrease"
Expand Down Expand Up @@ -816,14 +816,14 @@ contract AaveLendingPool {
function core_increaseTotalBorrowsVariable(
ReserveData storage _reserve,
uint256 _amount
) internal {
) private {
_reserve.totalBorrowsVariable = _reserve.totalBorrowsVariable + _amount;
}

function core_decreaseTotalBorrowsVariable(
ReserveData storage _reserve,
uint256 _amount
) internal {
) private {
require(
_reserve.totalBorrowsVariable >= _amount,
"The amount that is being subtracted from the variable total borrows is incorrect"
Expand All @@ -834,7 +834,7 @@ contract AaveLendingPool {
function core_getCompoundedBorrowBalance(
UserReserveData storage _self,
ReserveData storage _reserve
) internal returns (uint256) {
) private returns (uint256) {
if (_self.principalBorrowBalance == 0) return 0;

uint256 principalBorrowBalanceRay = _self.principalBorrowBalance * 1e9;
Expand Down Expand Up @@ -871,14 +871,14 @@ contract AaveLendingPool {
function core_calculateLinearInterest_mocked(
uint256 /*_rate*/,
uint40 /*_lastUpdateTimestamp*/
) internal returns (uint256) {
) private returns (uint256) {
return 1e27 + 0.01 * 1e27;
}

function core_calculateCompoundedInterest_mocked(
uint256 /*_rate*/,
uint40 /*_lastUpdateTimestamp*/
) internal returns (uint256) {
) private returns (uint256) {
return 1e27 + 0.01 * 1e27;
}

Expand All @@ -889,7 +889,7 @@ contract AaveLendingPool {
uint256 _balanceIncrease,
uint256 _amountBorrowed,
InterestRateMode _newBorrowRateMode
) internal {
) private {
InterestRateMode previousRateMode = core_getUserCurrentBorrowRateMode(
_reserve,
_user
Expand Down Expand Up @@ -929,7 +929,7 @@ contract AaveLendingPool {
function core_getUserBasicReserveData(
address _reserve,
address _user
) internal returns (uint256[] memory return_data) {
) private returns (uint256[] memory return_data) {
return_data = new uint256[](4);
ReserveData storage reserve = reserves[_reserve];
UserReserveData storage user = usersReserveData[_user][_reserve];
Expand All @@ -953,7 +953,7 @@ contract AaveLendingPool {

function core_getReserveConfiguration(
address _reserve
) internal returns (uint256[] memory return_data) {
) private returns (uint256[] memory return_data) {
return_data = new uint256[](4);

uint256 decimals;
Expand All @@ -976,7 +976,7 @@ contract AaveLendingPool {
function core_isUserUseReserveAsCollateralEnabled(
address _reserve,
address _user
) internal returns (bool) {
) private returns (bool) {
UserReserveData storage user = usersReserveData[_user][_reserve];
return user.useAsCollateral;
}
Expand Down Expand Up @@ -1084,7 +1084,7 @@ contract AaveLendingPool {
uint256 _userCurrentBorrowBalanceTH,
uint256 _userCurrentFeesETH,
uint256 _userCurrentLtv
) internal returns (uint256) {
) private returns (uint256) {
uint256 reserveDecimals = IERC20(_reserve).decimals();

IPriceOracleGetter oracle = IPriceOracleGetter(
Expand All @@ -1105,7 +1105,7 @@ contract AaveLendingPool {
address _reserve,
address _user,
uint256 _amount
) internal returns (bool) {
) private returns (bool) {
BalanceDecreaseAllowedLocalVars memory vars;
uint256[] memory reserve_conf_return;

Expand Down Expand Up @@ -1174,7 +1174,7 @@ contract AaveLendingPool {
uint256 borrowBalanceETH,
uint256 totalFeesETH,
uint256 liquidationThreshold
) internal returns (uint256) {
) private returns (uint256) {
if (borrowBalanceETH == 0) return UINT256_MAX;

return
Expand Down
42 changes: 21 additions & 21 deletions test/examples/lending/LendingPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,24 @@ contract LendingPool {
bool supported;
}

uint256 internal UINT256_MAX = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
uint256 private UINT256_MAX = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;

uint256 internal MAX_PROTOCOL_FEE = 0.5e4; // 5%
uint256 private MAX_PROTOCOL_FEE = 0.5e4; // 5%
uint256 public PRECISION = 1e18; // 18 decimals precision
uint256 public BPS = 1e5; // 5 decimals precision
uint256 public BLOCKS_PER_YEAR = 2102400; // Average Ethereum blocks per year
uint256 internal RATE_PRECISION = 1e18;
uint256 internal MIN_HEALTH_FACTOR = 1e18;
uint256 internal CLOSE_FACTOR_HF_THRESHOLD = 0.9e18;
uint256 internal LIQUIDATION_THRESHOLD = 8e4; // 80%
uint256 internal DEFAULT_LIQUIDATION_CLOSE_FACTOR = 5e4; // 50%
uint256 internal LIQUIDATION_REWARD = 5e3; // 5%
uint256 private RATE_PRECISION = 1e18;
uint256 private MIN_HEALTH_FACTOR = 1e18;
uint256 private CLOSE_FACTOR_HF_THRESHOLD = 0.9e18;
uint256 private LIQUIDATION_THRESHOLD = 8e4; // 80%
uint256 private DEFAULT_LIQUIDATION_CLOSE_FACTOR = 5e4; // 50%
uint256 private LIQUIDATION_REWARD = 5e3; // 5%

address[] internal supportedERC20s;
address[] internal supportedNFTs;
address[] private supportedERC20s;
address[] private supportedNFTs;

mapping(address => TokenVault) private vaults;
mapping(address => SupportedToken) internal supportedTokens;
mapping(address => SupportedToken) private supportedTokens;
mapping(address => mapping(address => AccountShares)) private userShares;

event AddSupportedToken(address token, TokenType tokenType);
Expand Down Expand Up @@ -435,7 +435,7 @@ contract LendingPool {
function vaultAboveReserveRatio(
address token,
uint256 pulledAmount
) internal returns (bool isAboveReserveRatio) {
) private returns (bool isAboveReserveRatio) {
uint256 minVaultReserve = (vaults[token].totalAsset.amount *
vaults[token].vaultInfo.reserveRatio) / BPS;
isAboveReserveRatio =
Expand All @@ -449,7 +449,7 @@ contract LendingPool {
uint256 amount,
uint256 minAmountOutOrMaxShareIn,
bool share
) internal {
) private {
_accrueInterest(token);
uint256 userCollShares = userShares[msg.sender][token].collateral;
uint256 shares;
Expand Down Expand Up @@ -477,7 +477,7 @@ contract LendingPool {
emit Withdraw(msg.sender, token, amount, shares);
}

function _accrueInterest(address token) internal {
function _accrueInterest(address token) private {
uint256 _interestEarned;
uint256 _feesAmount;
uint256 _feesShare;
Expand Down Expand Up @@ -548,7 +548,7 @@ contract LendingPool {
TokenType tokenType,
VaultSetupParams memory params,
bool addToken
) internal {
) private {
if (addToken) {
_addSupportedToken(token, priceFeed, tokenType);
}
Expand Down Expand Up @@ -582,7 +582,7 @@ contract LendingPool {
address token,
address priceFeed,
TokenType tokenType
) internal {
) private {
require(
!supportedTokens[token].supported,
"LendingPool: adding support for already supported token"
Expand Down Expand Up @@ -614,7 +614,7 @@ contract LendingPool {
}
function _getPrice(
AggregatorV3Interface priceFeed
) internal returns (uint256 price) {
) private returns (uint256 price) {
uint256[] memory returndata = priceFeed.latestRoundData();
uint256 roundId = returndata[0];
uint256 answer = returndata[1];
Expand All @@ -634,7 +634,7 @@ contract LendingPool {
address _from,
address _to,
uint256 _amount
) internal {
) private {
bool success;
if (_from == address(this)) {
success = IERC20(_token).transfer(_to, _amount);
Expand All @@ -648,7 +648,7 @@ contract LendingPool {
Vault memory total,
uint256 amount,
bool roundUp
) internal returns (uint256 shares) {
) private returns (uint256 shares) {
if (total.amount == 0) {
shares = amount;
} else {
Expand All @@ -663,7 +663,7 @@ contract LendingPool {
Vault memory total,
uint256 shares,
bool roundUp
) internal returns (uint256 amount) {
) private returns (uint256 amount) {
if (total.shares == 0) {
amount = shares;
} else {
Expand All @@ -677,7 +677,7 @@ contract LendingPool {
function _calculateInterestRate(
VaultInfo memory _interestRateInfo,
uint256 utilization
) internal returns (uint256 newRatePerSec) {
) private returns (uint256 newRatePerSec) {
uint256 optimalUtilization = _interestRateInfo.optimalUtilization;
uint256 baseRate = uint256(_interestRateInfo.baseRate);
uint256 slope1 = uint256(_interestRateInfo.slope1);
Expand Down
Loading