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

Increace pool limit #37

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
13 changes: 13 additions & 0 deletions contracts/protocol/configuration/AaveIncentivesController.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

contract AaveIncentivesController {
function handleAction(
address user,
uint256 userBalance,
uint256 totalSupply
) external{
require(true, "AHHA");
}
}
2 changes: 1 addition & 1 deletion contracts/protocol/lendingpool/LendingPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
_addressesProvider = provider;
_maxStableRateBorrowSizePercent = 2500;
_flashLoanPremiumTotal = 9;
_maxNumberOfReserves = 128;
_maxNumberOfReserves = 10000;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/protocol/lendingpool/LendingPoolStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract LendingPoolStorage {
// the list of the available reserves, structured as a mapping for gas savings reasons
mapping(uint256 => address) internal _reservesList;

uint256 internal _reservesCount;
uint256 public _reservesCount;

bool internal _paused;

Expand Down
57 changes: 41 additions & 16 deletions contracts/protocol/libraries/configuration/UserConfiguration.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ library UserConfiguration {
uint256 reserveIndex,
bool borrowing
) internal {
require(reserveIndex < 128, Errors.UL_INVALID_INDEX);
self.data =
(self.data & ~(1 << (reserveIndex * 2))) |
(uint256(borrowing ? 1 : 0) << (reserveIndex * 2));
require(reserveIndex < 10000, Errors.UL_INVALID_INDEX);
uint256 dataIndex;
for(uint256 reserveDataIndex = reserveIndex; reserveDataIndex>128; reserveDataIndex-=128){
dataIndex++;
}
self.data[dataIndex] =
(self.data[dataIndex] & ~(1 << (reserveIndex % 128 * 2))) |
(uint256(borrowing ? 1 : 0) << (reserveIndex % 128 * 2));
}

/**
Expand All @@ -41,10 +45,14 @@ library UserConfiguration {
uint256 reserveIndex,
bool usingAsCollateral
) internal {
require(reserveIndex < 128, Errors.UL_INVALID_INDEX);
self.data =
(self.data & ~(1 << (reserveIndex * 2 + 1))) |
(uint256(usingAsCollateral ? 1 : 0) << (reserveIndex * 2 + 1));
require(reserveIndex < 10000, Errors.UL_INVALID_INDEX);
uint dataIndex;
for(uint256 reserveDataIndex = reserveIndex; reserveDataIndex>128; reserveDataIndex-=128){
dataIndex++;
}
self.data[dataIndex] =
(self.data[dataIndex] & ~(1 << (reserveIndex % 128 * 2 + 1))) |
(uint256(usingAsCollateral ? 1 : 0) << (reserveIndex % 128 * 2 + 1));
}

/**
Expand All @@ -57,8 +65,12 @@ library UserConfiguration {
DataTypes.UserConfigurationMap memory self,
uint256 reserveIndex
) internal pure returns (bool) {
require(reserveIndex < 128, Errors.UL_INVALID_INDEX);
return (self.data >> (reserveIndex * 2)) & 3 != 0;
require(reserveIndex < 10000, Errors.UL_INVALID_INDEX);
uint256 dataIndex;
for(uint256 reserveDataIndex = reserveIndex; reserveDataIndex > 128; reserveDataIndex-=128){
dataIndex++;
}S
return (self.data[dataIndex] >> (reserveIndex % 128 * 2)) & 3 != 0;
}

/**
Expand All @@ -72,8 +84,13 @@ library UserConfiguration {
pure
returns (bool)
{
require(reserveIndex < 128, Errors.UL_INVALID_INDEX);
return (self.data >> (reserveIndex * 2)) & 1 != 0;
require(reserveIndex < 10000, Errors.UL_INVALID_INDEX);
uint256 dataIndex;
for(uint256 reserveDataIndex = reserveIndex; reserveDataIndex>128; reserveDataIndex-=128){
dataIndex++;
}

return (self.data[dataIndex] >> (reserveIndex % 128 * 2)) & 1 != 0;
}

/**
Expand All @@ -87,8 +104,12 @@ library UserConfiguration {
pure
returns (bool)
{
require(reserveIndex < 128, Errors.UL_INVALID_INDEX);
return (self.data >> (reserveIndex * 2 + 1)) & 1 != 0;
require(reserveIndex < 10000, Errors.UL_INVALID_INDEX);
uint256 dataIndex;
for(uint256 reserveDataIndex = reserveIndex; reserveDataIndex>128; reserveDataIndex-=128){
dataIndex++;
}
return (self.data[dataIndex] >> (reserveIndex % 128 * 2 + 1)) & 1 != 0;
}

/**
Expand All @@ -97,7 +118,11 @@ library UserConfiguration {
* @return True if the user has been borrowing any reserve, false otherwise
**/
function isBorrowingAny(DataTypes.UserConfigurationMap memory self) internal pure returns (bool) {
return self.data & BORROWING_MASK != 0;
for(uint i=0; i<79; i++){
if(self.data[i] & BORROWING_MASK != 0){
return true;
}
}
}

/**
Expand All @@ -106,6 +131,6 @@ library UserConfiguration {
* @return True if the user has been borrowing any reserve, false otherwise
**/
function isEmpty(DataTypes.UserConfigurationMap memory self) internal pure returns (bool) {
return self.data == 0;
return self.data[0] == 0;
}
}
13 changes: 8 additions & 5 deletions contracts/protocol/libraries/logic/GenericLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,14 @@ library GenericLogic {
)
{
CalculateUserAccountDataVars memory vars;

if (userConfig.isEmpty()) {
return (0, 0, 0, 0, uint256(-1));
}

for (vars.i = 0; vars.i < reservesCount; vars.i++) {
if (!userConfig.isUsingAsCollateralOrBorrowing(vars.i)) {
continue;
continue;
}

vars.currentReserveAddress = reserves[vars.i];
Expand All @@ -184,7 +185,7 @@ library GenericLogic {

vars.tokenUnit = 10**vars.decimals;
vars.reserveUnitPrice = IPriceOracleGetter(oracle).getAssetPrice(vars.currentReserveAddress);

if (vars.liquidationThreshold != 0 && userConfig.isUsingAsCollateral(vars.i)) {
vars.compoundedLiquidityBalance = IERC20(currentReserve.aTokenAddress).balanceOf(user);

Expand All @@ -198,8 +199,7 @@ library GenericLogic {
liquidityBalanceETH.mul(vars.liquidationThreshold)
);
}

if (userConfig.isBorrowing(vars.i)) {
if (userConfig.isBorrowing(vars.i)) {
vars.compoundedBorrowBalance = IERC20(currentReserve.stableDebtTokenAddress).balanceOf(
user
);
Expand All @@ -213,6 +213,9 @@ library GenericLogic {
}
}

vars.currentReserveAddress = reserves[vars.i];


vars.avgLtv = vars.totalCollateralInETH > 0 ? vars.avgLtv.div(vars.totalCollateralInETH) : 0;
vars.avgLiquidationThreshold = vars.totalCollateralInETH > 0
? vars.avgLiquidationThreshold.div(vars.totalCollateralInETH)
Expand Down
4 changes: 2 additions & 2 deletions contracts/protocol/libraries/types/DataTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ library DataTypes {
//address of the interest rate strategy
address interestRateStrategyAddress;
//the id of the reserve. Represents the position in the list of the active reserves
uint8 id;
uint256 id;
}

struct ReserveConfigurationMap {
Expand All @@ -42,7 +42,7 @@ library DataTypes {
}

struct UserConfigurationMap {
uint256 data;
uint256[79] data;
}

enum InterestRateMode {NONE, STABLE, VARIABLE}
Expand Down