mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Merge branch 'master' of gitlab.com:aave-tech/protocol-v2 into 97-create-a-utility-contract-to-deposit-withdraw-repay-with-eth
This commit is contained in:
commit
6174539966
|
@ -232,15 +232,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
||||||
_whenNotPaused();
|
_whenNotPaused();
|
||||||
ReserveLogic.ReserveData storage reserve = _reserves[asset];
|
ReserveLogic.ReserveData storage reserve = _reserves[asset];
|
||||||
|
|
||||||
if (onBehalfOf != msg.sender) {
|
|
||||||
address debtToken = reserve.getDebtTokenAddress(interestRateMode);
|
|
||||||
|
|
||||||
_borrowAllowance[debtToken][onBehalfOf][msg
|
|
||||||
.sender] = _borrowAllowance[debtToken][onBehalfOf][msg.sender].sub(
|
|
||||||
amount,
|
|
||||||
Errors.LP_BORROW_ALLOWANCE_ARE_NOT_ENOUGH
|
|
||||||
);
|
|
||||||
}
|
|
||||||
_executeBorrow(
|
_executeBorrow(
|
||||||
ExecuteBorrowParams(
|
ExecuteBorrowParams(
|
||||||
asset,
|
asset,
|
||||||
|
@ -583,14 +574,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
||||||
vars.currentAmountPlusPremium
|
vars.currentAmountPlusPremium
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (msg.sender != onBehalfOf) {
|
|
||||||
vars.debtToken = _reserves[vars.currentAsset].getDebtTokenAddress(modes[vars.i]);
|
|
||||||
|
|
||||||
_borrowAllowance[vars.debtToken][onBehalfOf][msg.sender] = _borrowAllowance[vars
|
|
||||||
.debtToken][onBehalfOf][msg.sender]
|
|
||||||
.sub(vars.currentAmount, Errors.LP_BORROW_ALLOWANCE_ARE_NOT_ENOUGH);
|
|
||||||
}
|
|
||||||
|
|
||||||
//if the user didn't choose to return the funds, the system checks if there
|
//if the user didn't choose to return the funds, the system checks if there
|
||||||
//is enough collateral and eventually open a position
|
//is enough collateral and eventually open a position
|
||||||
_executeBorrow(
|
_executeBorrow(
|
||||||
|
@ -915,6 +898,14 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
||||||
oracle
|
oracle
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (vars.onBehalfOf != msg.sender) {
|
||||||
|
address debtToken = reserve.getDebtTokenAddress(vars.interestRateMode);
|
||||||
|
|
||||||
|
_borrowAllowance[debtToken][vars.onBehalfOf][msg.sender] = _borrowAllowance[debtToken][vars
|
||||||
|
.onBehalfOf][msg.sender]
|
||||||
|
.sub(vars.amount, Errors.LP_BORROW_ALLOWANCE_NOT_ENOUGH);
|
||||||
|
}
|
||||||
|
|
||||||
reserve.updateState();
|
reserve.updateState();
|
||||||
|
|
||||||
//caching the current stable borrow rate
|
//caching the current stable borrow rate
|
||||||
|
|
|
@ -79,7 +79,7 @@ library Errors {
|
||||||
string public constant AT_INVALID_MINT_AMOUNT = '56'; //invalid amount to mint
|
string public constant AT_INVALID_MINT_AMOUNT = '56'; //invalid amount to mint
|
||||||
string public constant LP_FAILED_REPAY_WITH_COLLATERAL = '57';
|
string public constant LP_FAILED_REPAY_WITH_COLLATERAL = '57';
|
||||||
string public constant AT_INVALID_BURN_AMOUNT = '58'; //invalid amount to burn
|
string public constant AT_INVALID_BURN_AMOUNT = '58'; //invalid amount to burn
|
||||||
string public constant LP_BORROW_ALLOWANCE_ARE_NOT_ENOUGH = '59'; // User borrows on behalf, but allowance are too small
|
string public constant LP_BORROW_ALLOWANCE_NOT_ENOUGH = '59'; // User borrows on behalf, but allowance are too small
|
||||||
string public constant LP_FAILED_COLLATERAL_SWAP = '60';
|
string public constant LP_FAILED_COLLATERAL_SWAP = '60';
|
||||||
string public constant LP_INVALID_EQUAL_ASSETS_TO_SWAP = '61';
|
string public constant LP_INVALID_EQUAL_ASSETS_TO_SWAP = '61';
|
||||||
string public constant LP_REENTRANCY_NOT_ALLOWED = '62';
|
string public constant LP_REENTRANCY_NOT_ALLOWED = '62';
|
||||||
|
|
|
@ -138,7 +138,7 @@ export enum ProtocolErrors {
|
||||||
AT_INVALID_MINT_AMOUNT = '56', //invalid amount to mint
|
AT_INVALID_MINT_AMOUNT = '56', //invalid amount to mint
|
||||||
LP_FAILED_REPAY_WITH_COLLATERAL = '57',
|
LP_FAILED_REPAY_WITH_COLLATERAL = '57',
|
||||||
AT_INVALID_BURN_AMOUNT = '58', //invalid amount to burn
|
AT_INVALID_BURN_AMOUNT = '58', //invalid amount to burn
|
||||||
LP_BORROW_ALLOWANCE_ARE_NOT_ENOUGH = '59', // User borrows on behalf, but allowance are too small
|
LP_BORROW_ALLOWANCE_NOT_ENOUGH = '59', // User borrows on behalf, but allowance are too small
|
||||||
LP_FAILED_COLLATERAL_SWAP = '60',
|
LP_FAILED_COLLATERAL_SWAP = '60',
|
||||||
LP_INVALID_EQUAL_ASSETS_TO_SWAP = '61',
|
LP_INVALID_EQUAL_ASSETS_TO_SWAP = '61',
|
||||||
LP_REENTRANCY_NOT_ALLOWED = '62',
|
LP_REENTRANCY_NOT_ALLOWED = '62',
|
||||||
|
|
|
@ -24,7 +24,7 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => {
|
||||||
LP_INVALID_FLASHLOAN_MODE,
|
LP_INVALID_FLASHLOAN_MODE,
|
||||||
SAFEERC20_LOWLEVEL_CALL,
|
SAFEERC20_LOWLEVEL_CALL,
|
||||||
LP_INVALID_FLASH_LOAN_EXECUTOR_RETURN,
|
LP_INVALID_FLASH_LOAN_EXECUTOR_RETURN,
|
||||||
LP_BORROW_ALLOWANCE_ARE_NOT_ENOUGH,
|
LP_BORROW_ALLOWANCE_NOT_ENOUGH,
|
||||||
} = ProtocolErrors;
|
} = ProtocolErrors;
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
|
@ -443,7 +443,7 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => {
|
||||||
'0x10',
|
'0x10',
|
||||||
'0'
|
'0'
|
||||||
)
|
)
|
||||||
).to.be.revertedWith(LP_BORROW_ALLOWANCE_ARE_NOT_ENOUGH);
|
).to.be.revertedWith(LP_BORROW_ALLOWANCE_NOT_ENOUGH);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Caller takes a WETH flashloan with mode = 1 onBehalfOf user with allowance. A loan for onBehalfOf is creatd.', async () => {
|
it('Caller takes a WETH flashloan with mode = 1 onBehalfOf user with allowance. A loan for onBehalfOf is creatd.', async () => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user