mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
- Temporary removed nonReentrant from LendingPool, until this fix on ReentrancyGuard is released to prod https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2171.
This commit is contained in:
parent
0ac28cd89e
commit
2379fe7ae7
|
@ -300,7 +300,6 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable {
|
||||||
function deposit(address _reserve, uint256 _amount, uint16 _referralCode)
|
function deposit(address _reserve, uint256 _amount, uint16 _referralCode)
|
||||||
external
|
external
|
||||||
payable
|
payable
|
||||||
nonReentrant
|
|
||||||
onlyActiveReserve(_reserve)
|
onlyActiveReserve(_reserve)
|
||||||
onlyUnfreezedReserve(_reserve)
|
onlyUnfreezedReserve(_reserve)
|
||||||
onlyAmountGreaterThanZero(_amount)
|
onlyAmountGreaterThanZero(_amount)
|
||||||
|
@ -336,7 +335,6 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable {
|
||||||
uint256 _aTokenBalanceAfterRedeem
|
uint256 _aTokenBalanceAfterRedeem
|
||||||
)
|
)
|
||||||
external
|
external
|
||||||
nonReentrant
|
|
||||||
onlyOverlyingAToken(_reserve)
|
onlyOverlyingAToken(_reserve)
|
||||||
onlyActiveReserve(_reserve)
|
onlyActiveReserve(_reserve)
|
||||||
onlyAmountGreaterThanZero(_amount)
|
onlyAmountGreaterThanZero(_amount)
|
||||||
|
@ -393,7 +391,6 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable {
|
||||||
uint16 _referralCode
|
uint16 _referralCode
|
||||||
)
|
)
|
||||||
external
|
external
|
||||||
nonReentrant
|
|
||||||
onlyActiveReserve(_reserve)
|
onlyActiveReserve(_reserve)
|
||||||
onlyUnfreezedReserve(_reserve)
|
onlyUnfreezedReserve(_reserve)
|
||||||
onlyAmountGreaterThanZero(_amount)
|
onlyAmountGreaterThanZero(_amount)
|
||||||
|
@ -534,7 +531,6 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable {
|
||||||
function repay(address _reserve, uint256 _amount, address payable _onBehalfOf)
|
function repay(address _reserve, uint256 _amount, address payable _onBehalfOf)
|
||||||
external
|
external
|
||||||
payable
|
payable
|
||||||
nonReentrant
|
|
||||||
onlyActiveReserve(_reserve)
|
onlyActiveReserve(_reserve)
|
||||||
onlyAmountGreaterThanZero(_amount)
|
onlyAmountGreaterThanZero(_amount)
|
||||||
{
|
{
|
||||||
|
@ -648,7 +644,6 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable {
|
||||||
**/
|
**/
|
||||||
function swapBorrowRateMode(address _reserve)
|
function swapBorrowRateMode(address _reserve)
|
||||||
external
|
external
|
||||||
nonReentrant
|
|
||||||
onlyActiveReserve(_reserve)
|
onlyActiveReserve(_reserve)
|
||||||
onlyUnfreezedReserve(_reserve)
|
onlyUnfreezedReserve(_reserve)
|
||||||
{
|
{
|
||||||
|
@ -709,7 +704,6 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable {
|
||||||
**/
|
**/
|
||||||
function rebalanceStableBorrowRate(address _reserve, address _user)
|
function rebalanceStableBorrowRate(address _reserve, address _user)
|
||||||
external
|
external
|
||||||
nonReentrant
|
|
||||||
onlyActiveReserve(_reserve)
|
onlyActiveReserve(_reserve)
|
||||||
{
|
{
|
||||||
(, uint256 compoundedBalance, uint256 borrowBalanceIncrease) = core.getUserBorrowBalances(
|
(, uint256 compoundedBalance, uint256 borrowBalanceIncrease) = core.getUserBorrowBalances(
|
||||||
|
@ -772,7 +766,6 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable {
|
||||||
**/
|
**/
|
||||||
function setUserUseReserveAsCollateral(address _reserve, bool _useAsCollateral)
|
function setUserUseReserveAsCollateral(address _reserve, bool _useAsCollateral)
|
||||||
external
|
external
|
||||||
nonReentrant
|
|
||||||
onlyActiveReserve(_reserve)
|
onlyActiveReserve(_reserve)
|
||||||
onlyUnfreezedReserve(_reserve)
|
onlyUnfreezedReserve(_reserve)
|
||||||
{
|
{
|
||||||
|
@ -809,7 +802,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable {
|
||||||
address _user,
|
address _user,
|
||||||
uint256 _purchaseAmount,
|
uint256 _purchaseAmount,
|
||||||
bool _receiveAToken
|
bool _receiveAToken
|
||||||
) external payable nonReentrant onlyActiveReserve(_reserve) onlyActiveReserve(_collateral) {
|
) external payable onlyActiveReserve(_reserve) onlyActiveReserve(_collateral) {
|
||||||
address liquidationManager = addressesProvider.getLendingPoolLiquidationManager();
|
address liquidationManager = addressesProvider.getLendingPoolLiquidationManager();
|
||||||
|
|
||||||
//solium-disable-next-line
|
//solium-disable-next-line
|
||||||
|
@ -843,7 +836,6 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable {
|
||||||
**/
|
**/
|
||||||
function flashLoan(address _receiver, address _reserve, uint256 _amount, bytes memory _params)
|
function flashLoan(address _receiver, address _reserve, uint256 _amount, bytes memory _params)
|
||||||
public
|
public
|
||||||
nonReentrant
|
|
||||||
onlyActiveReserve(_reserve)
|
onlyActiveReserve(_reserve)
|
||||||
onlyAmountGreaterThanZero(_amount) // TODO: remove
|
onlyAmountGreaterThanZero(_amount) // TODO: remove
|
||||||
{
|
{
|
||||||
|
|
|
@ -311,7 +311,7 @@ export const getLendingPoolConfiguratorProxy = async (
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getLendingPoolProxy = async (address?: tEthereumAddress) => {
|
export const getLendingPool = async (address?: tEthereumAddress) => {
|
||||||
return await getContract<LendingPool>(
|
return await getContract<LendingPool>(
|
||||||
eContractid.LendingPool,
|
eContractid.LendingPool,
|
||||||
address ||
|
address ||
|
||||||
|
@ -323,7 +323,7 @@ export const getLendingPoolProxy = async (address?: tEthereumAddress) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getLendingPoolCoreProxy = async (address?: tEthereumAddress) => {
|
export const getLendingPoolCore = async (address?: tEthereumAddress) => {
|
||||||
const CoreLibraryFactory = await BRE.ethers.getContractFactory(
|
const CoreLibraryFactory = await BRE.ethers.getContractFactory(
|
||||||
eContractid.CoreLibrary
|
eContractid.CoreLibrary
|
||||||
);
|
);
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
deployLendingPool,
|
deployLendingPool,
|
||||||
deployPriceOracle,
|
deployPriceOracle,
|
||||||
getLendingPoolConfiguratorProxy,
|
getLendingPoolConfiguratorProxy,
|
||||||
getLendingPoolCoreProxy,
|
getLendingPoolCore,
|
||||||
deployMockAggregator,
|
deployMockAggregator,
|
||||||
deployChainlinkProxyPriceProvider,
|
deployChainlinkProxyPriceProvider,
|
||||||
deployLendingRateOracle,
|
deployLendingRateOracle,
|
||||||
|
@ -27,7 +27,7 @@ import {
|
||||||
getFeeProvider,
|
getFeeProvider,
|
||||||
getLendingPoolParametersProvider,
|
getLendingPoolParametersProvider,
|
||||||
getLendingPoolDataProvider,
|
getLendingPoolDataProvider,
|
||||||
getLendingPoolProxy,
|
getLendingPool,
|
||||||
insertContractAddressInDb,
|
insertContractAddressInDb,
|
||||||
deployAaveProtocolTestHelpers,
|
deployAaveProtocolTestHelpers,
|
||||||
} from "../helpers/contracts-helpers";
|
} from "../helpers/contracts-helpers";
|
||||||
|
@ -396,7 +396,7 @@ const buildTestEnv = async (deployer: Wallet, secondaryWallet: Wallet) => {
|
||||||
await waitForTx(
|
await waitForTx(
|
||||||
await addressesProvider.setLendingPoolCoreImpl(lendingPoolCoreImpl.address)
|
await addressesProvider.setLendingPoolCoreImpl(lendingPoolCoreImpl.address)
|
||||||
);
|
);
|
||||||
const lendingPoolCoreProxy = await getLendingPoolCoreProxy(
|
const lendingPoolCoreProxy = await getLendingPoolCore(
|
||||||
await addressesProvider.getLendingPoolCore()
|
await addressesProvider.getLendingPoolCore()
|
||||||
);
|
);
|
||||||
await insertContractAddressInDb(
|
await insertContractAddressInDb(
|
||||||
|
@ -436,7 +436,7 @@ const buildTestEnv = async (deployer: Wallet, secondaryWallet: Wallet) => {
|
||||||
await waitForTx(
|
await waitForTx(
|
||||||
await addressesProvider.setLendingPoolImpl(lendingPoolImpl.address)
|
await addressesProvider.setLendingPoolImpl(lendingPoolImpl.address)
|
||||||
);
|
);
|
||||||
const lendingPoolProxy = await getLendingPoolProxy(
|
const lendingPoolProxy = await getLendingPool(
|
||||||
await addressesProvider.getLendingPool()
|
await addressesProvider.getLendingPool()
|
||||||
);
|
);
|
||||||
await insertContractAddressInDb(
|
await insertContractAddressInDb(
|
||||||
|
|
|
@ -14,8 +14,8 @@ import {
|
||||||
getAToken,
|
getAToken,
|
||||||
convertToCurrencyDecimals,
|
convertToCurrencyDecimals,
|
||||||
getEthersSigners,
|
getEthersSigners,
|
||||||
getLendingPoolCoreProxy,
|
getLendingPoolCore,
|
||||||
getLendingPoolProxy,
|
getLendingPool,
|
||||||
} from "../helpers/contracts-helpers";
|
} from "../helpers/contracts-helpers";
|
||||||
import {expect} from "chai";
|
import {expect} from "chai";
|
||||||
import {ethers, Wallet, Signer} from "ethers";
|
import {ethers, Wallet, Signer} from "ethers";
|
||||||
|
@ -40,8 +40,8 @@ describe("AToken: Transfer", () => {
|
||||||
deployer = _deployer;
|
deployer = _deployer;
|
||||||
users = _users;
|
users = _users;
|
||||||
|
|
||||||
_lendingPool = await getLendingPoolProxy();
|
_lendingPool = await getLendingPool();
|
||||||
_lendingPoolCore = await getLendingPoolCoreProxy();
|
_lendingPoolCore = await getLendingPoolCore();
|
||||||
|
|
||||||
const testHelpers = await getAaveProtocolTestHelpers();
|
const testHelpers = await getAaveProtocolTestHelpers();
|
||||||
|
|
||||||
|
@ -72,9 +72,11 @@ describe("AToken: Transfer", () => {
|
||||||
|
|
||||||
console.log(_lendingPoolCore.address);
|
console.log(_lendingPoolCore.address);
|
||||||
|
|
||||||
|
console.time("approve");
|
||||||
await _dai
|
await _dai
|
||||||
.connect(users[0])
|
.connect(users[0])
|
||||||
.approve(_lendingPoolCore.address, APPROVAL_AMOUNT_LENDING_POOL_CORE);
|
.approve(_lendingPoolCore.address, APPROVAL_AMOUNT_LENDING_POOL_CORE);
|
||||||
|
console.timeEnd("approve");
|
||||||
|
|
||||||
//user 1 deposits 1000 DAI
|
//user 1 deposits 1000 DAI
|
||||||
const amountDAItoDeposit = await convertToCurrencyDecimals(
|
const amountDAItoDeposit = await convertToCurrencyDecimals(
|
||||||
|
@ -82,32 +84,32 @@ describe("AToken: Transfer", () => {
|
||||||
"1000"
|
"1000"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.time("getaddress");
|
||||||
await _lendingPool
|
await _lendingPool
|
||||||
.connect(users[0])
|
.connect(users[0])
|
||||||
.deposit(_dai.address, amountDAItoDeposit, "0");
|
.deposit(_dai.address, amountDAItoDeposit, "0");
|
||||||
|
console.timeEnd("getaddress");
|
||||||
|
|
||||||
// console.log(users[0])
|
await _aDai
|
||||||
// console.log(await users[0].getAddress())
|
.connect(users[0])
|
||||||
// await _aDai
|
.transfer(await users[1].getAddress(), amountDAItoDeposit);
|
||||||
// .connect(users[0])
|
|
||||||
// .transfer(await users[1].getAddress(), amountDAItoDeposit);
|
|
||||||
|
|
||||||
// const fromBalance = await _aDai.balanceOf(await users[0].getAddress());
|
const fromBalance = await _aDai.balanceOf(await users[0].getAddress());
|
||||||
// const toBalance = await _aDai.balanceOf(await users[1].getAddress());
|
const toBalance = await _aDai.balanceOf(await users[1].getAddress());
|
||||||
|
|
||||||
// expect(fromBalance.toString()).to.be.equal(
|
expect(fromBalance.toString()).to.be.equal(
|
||||||
// "0",
|
"0",
|
||||||
// "Invalid from balance after transfer"
|
"Invalid from balance after transfer"
|
||||||
// );
|
);
|
||||||
// expect(toBalance.toString()).to.be.equal(
|
expect(toBalance.toString()).to.be.equal(
|
||||||
// amountDAItoDeposit.toString(),
|
amountDAItoDeposit.toString(),
|
||||||
// "Invalid to balance after transfer"
|
"Invalid to balance after transfer"
|
||||||
// );
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// it('User 1 redirects interest to user 2, transfers 500 DAI back to user 0', async () => {
|
// it('User 1 redirects interest to user 2, transfers 500 DAI back to user 0', async () => {
|
||||||
|
|
||||||
// await _aDAI.redirectInterestStream(users[2], {from: users[1]});
|
// await _aDai.redirectInterestStream(await users[2].getAddress());
|
||||||
|
|
||||||
// const aDAIRedirected = await convertToCurrencyDecimals(_DAI.address, '1000');
|
// const aDAIRedirected = await convertToCurrencyDecimals(_DAI.address, '1000');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user