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)
|
||||
external
|
||||
payable
|
||||
nonReentrant
|
||||
onlyActiveReserve(_reserve)
|
||||
onlyUnfreezedReserve(_reserve)
|
||||
onlyAmountGreaterThanZero(_amount)
|
||||
|
@ -336,7 +335,6 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable {
|
|||
uint256 _aTokenBalanceAfterRedeem
|
||||
)
|
||||
external
|
||||
nonReentrant
|
||||
onlyOverlyingAToken(_reserve)
|
||||
onlyActiveReserve(_reserve)
|
||||
onlyAmountGreaterThanZero(_amount)
|
||||
|
@ -393,7 +391,6 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable {
|
|||
uint16 _referralCode
|
||||
)
|
||||
external
|
||||
nonReentrant
|
||||
onlyActiveReserve(_reserve)
|
||||
onlyUnfreezedReserve(_reserve)
|
||||
onlyAmountGreaterThanZero(_amount)
|
||||
|
@ -534,7 +531,6 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable {
|
|||
function repay(address _reserve, uint256 _amount, address payable _onBehalfOf)
|
||||
external
|
||||
payable
|
||||
nonReentrant
|
||||
onlyActiveReserve(_reserve)
|
||||
onlyAmountGreaterThanZero(_amount)
|
||||
{
|
||||
|
@ -648,7 +644,6 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable {
|
|||
**/
|
||||
function swapBorrowRateMode(address _reserve)
|
||||
external
|
||||
nonReentrant
|
||||
onlyActiveReserve(_reserve)
|
||||
onlyUnfreezedReserve(_reserve)
|
||||
{
|
||||
|
@ -709,7 +704,6 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable {
|
|||
**/
|
||||
function rebalanceStableBorrowRate(address _reserve, address _user)
|
||||
external
|
||||
nonReentrant
|
||||
onlyActiveReserve(_reserve)
|
||||
{
|
||||
(, uint256 compoundedBalance, uint256 borrowBalanceIncrease) = core.getUserBorrowBalances(
|
||||
|
@ -772,7 +766,6 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable {
|
|||
**/
|
||||
function setUserUseReserveAsCollateral(address _reserve, bool _useAsCollateral)
|
||||
external
|
||||
nonReentrant
|
||||
onlyActiveReserve(_reserve)
|
||||
onlyUnfreezedReserve(_reserve)
|
||||
{
|
||||
|
@ -809,7 +802,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable {
|
|||
address _user,
|
||||
uint256 _purchaseAmount,
|
||||
bool _receiveAToken
|
||||
) external payable nonReentrant onlyActiveReserve(_reserve) onlyActiveReserve(_collateral) {
|
||||
) external payable onlyActiveReserve(_reserve) onlyActiveReserve(_collateral) {
|
||||
address liquidationManager = addressesProvider.getLendingPoolLiquidationManager();
|
||||
|
||||
//solium-disable-next-line
|
||||
|
@ -843,7 +836,6 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable {
|
|||
**/
|
||||
function flashLoan(address _receiver, address _reserve, uint256 _amount, bytes memory _params)
|
||||
public
|
||||
nonReentrant
|
||||
onlyActiveReserve(_reserve)
|
||||
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>(
|
||||
eContractid.LendingPool,
|
||||
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(
|
||||
eContractid.CoreLibrary
|
||||
);
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
deployLendingPool,
|
||||
deployPriceOracle,
|
||||
getLendingPoolConfiguratorProxy,
|
||||
getLendingPoolCoreProxy,
|
||||
getLendingPoolCore,
|
||||
deployMockAggregator,
|
||||
deployChainlinkProxyPriceProvider,
|
||||
deployLendingRateOracle,
|
||||
|
@ -27,7 +27,7 @@ import {
|
|||
getFeeProvider,
|
||||
getLendingPoolParametersProvider,
|
||||
getLendingPoolDataProvider,
|
||||
getLendingPoolProxy,
|
||||
getLendingPool,
|
||||
insertContractAddressInDb,
|
||||
deployAaveProtocolTestHelpers,
|
||||
} from "../helpers/contracts-helpers";
|
||||
|
@ -396,7 +396,7 @@ const buildTestEnv = async (deployer: Wallet, secondaryWallet: Wallet) => {
|
|||
await waitForTx(
|
||||
await addressesProvider.setLendingPoolCoreImpl(lendingPoolCoreImpl.address)
|
||||
);
|
||||
const lendingPoolCoreProxy = await getLendingPoolCoreProxy(
|
||||
const lendingPoolCoreProxy = await getLendingPoolCore(
|
||||
await addressesProvider.getLendingPoolCore()
|
||||
);
|
||||
await insertContractAddressInDb(
|
||||
|
@ -436,7 +436,7 @@ const buildTestEnv = async (deployer: Wallet, secondaryWallet: Wallet) => {
|
|||
await waitForTx(
|
||||
await addressesProvider.setLendingPoolImpl(lendingPoolImpl.address)
|
||||
);
|
||||
const lendingPoolProxy = await getLendingPoolProxy(
|
||||
const lendingPoolProxy = await getLendingPool(
|
||||
await addressesProvider.getLendingPool()
|
||||
);
|
||||
await insertContractAddressInDb(
|
||||
|
|
|
@ -14,8 +14,8 @@ import {
|
|||
getAToken,
|
||||
convertToCurrencyDecimals,
|
||||
getEthersSigners,
|
||||
getLendingPoolCoreProxy,
|
||||
getLendingPoolProxy,
|
||||
getLendingPoolCore,
|
||||
getLendingPool,
|
||||
} from "../helpers/contracts-helpers";
|
||||
import {expect} from "chai";
|
||||
import {ethers, Wallet, Signer} from "ethers";
|
||||
|
@ -40,8 +40,8 @@ describe("AToken: Transfer", () => {
|
|||
deployer = _deployer;
|
||||
users = _users;
|
||||
|
||||
_lendingPool = await getLendingPoolProxy();
|
||||
_lendingPoolCore = await getLendingPoolCoreProxy();
|
||||
_lendingPool = await getLendingPool();
|
||||
_lendingPoolCore = await getLendingPoolCore();
|
||||
|
||||
const testHelpers = await getAaveProtocolTestHelpers();
|
||||
|
||||
|
@ -72,9 +72,11 @@ describe("AToken: Transfer", () => {
|
|||
|
||||
console.log(_lendingPoolCore.address);
|
||||
|
||||
console.time("approve");
|
||||
await _dai
|
||||
.connect(users[0])
|
||||
.approve(_lendingPoolCore.address, APPROVAL_AMOUNT_LENDING_POOL_CORE);
|
||||
console.timeEnd("approve");
|
||||
|
||||
//user 1 deposits 1000 DAI
|
||||
const amountDAItoDeposit = await convertToCurrencyDecimals(
|
||||
|
@ -82,49 +84,49 @@ describe("AToken: Transfer", () => {
|
|||
"1000"
|
||||
);
|
||||
|
||||
console.time("getaddress");
|
||||
await _lendingPool
|
||||
.connect(users[0])
|
||||
.deposit(_dai.address, amountDAItoDeposit, "0");
|
||||
console.timeEnd("getaddress");
|
||||
|
||||
// console.log(users[0])
|
||||
// console.log(await users[0].getAddress())
|
||||
// await _aDai
|
||||
// .connect(users[0])
|
||||
// .transfer(await users[1].getAddress(), amountDAItoDeposit);
|
||||
await _aDai
|
||||
.connect(users[0])
|
||||
.transfer(await users[1].getAddress(), amountDAItoDeposit);
|
||||
|
||||
// const fromBalance = await _aDai.balanceOf(await users[0].getAddress());
|
||||
// const toBalance = await _aDai.balanceOf(await users[1].getAddress());
|
||||
const fromBalance = await _aDai.balanceOf(await users[0].getAddress());
|
||||
const toBalance = await _aDai.balanceOf(await users[1].getAddress());
|
||||
|
||||
// expect(fromBalance.toString()).to.be.equal(
|
||||
// "0",
|
||||
// "Invalid from balance after transfer"
|
||||
// );
|
||||
// expect(toBalance.toString()).to.be.equal(
|
||||
// amountDAItoDeposit.toString(),
|
||||
// "Invalid to balance after transfer"
|
||||
// );
|
||||
expect(fromBalance.toString()).to.be.equal(
|
||||
"0",
|
||||
"Invalid from balance after transfer"
|
||||
);
|
||||
expect(toBalance.toString()).to.be.equal(
|
||||
amountDAItoDeposit.toString(),
|
||||
"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');
|
||||
|
||||
// const aDAItoTransfer = await convertToCurrencyDecimals(_DAI.address, '500');
|
||||
// const aDAItoTransfer = await convertToCurrencyDecimals(_DAI.address, '500');
|
||||
|
||||
// const user2RedirectedBalanceBefore = await _aDAI.getRedirectedBalance(users[2])
|
||||
// expect(user2RedirectedBalanceBefore.toString()).to.be.equal(aDAIRedirected, "Invalid redirected balance for user 2 before transfer")
|
||||
// const user2RedirectedBalanceBefore = await _aDAI.getRedirectedBalance(users[2])
|
||||
// expect(user2RedirectedBalanceBefore.toString()).to.be.equal(aDAIRedirected, "Invalid redirected balance for user 2 before transfer")
|
||||
|
||||
// await _aDAI.transfer(users[0], aDAItoTransfer, {from: users[1]})
|
||||
// await _aDAI.transfer(users[0], aDAItoTransfer, {from: users[1]})
|
||||
|
||||
// const user2RedirectedBalanceAfter = await _aDAI.getRedirectedBalance(users[2])
|
||||
// const user1RedirectionAddress = await _aDAI.getInterestRedirectionAddress(users[1])
|
||||
// const user2RedirectedBalanceAfter = await _aDAI.getRedirectedBalance(users[2])
|
||||
// const user1RedirectionAddress = await _aDAI.getInterestRedirectionAddress(users[1])
|
||||
|
||||
// expect(user2RedirectedBalanceAfter.toString()).to.be.equal(aDAItoTransfer, "Invalid redirected balance for user 2 after transfer")
|
||||
// expect(user1RedirectionAddress.toString()).to.be.equal(users[2], "Invalid redirection address for user 1")
|
||||
// expect(user2RedirectedBalanceAfter.toString()).to.be.equal(aDAItoTransfer, "Invalid redirected balance for user 2 after transfer")
|
||||
// expect(user1RedirectionAddress.toString()).to.be.equal(users[2], "Invalid redirection address for user 1")
|
||||
|
||||
// });
|
||||
// });
|
||||
|
||||
// it('User 0 transfers back to user 1', async () => {
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user