mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
feat: added fees for flashloans mode debt
This commit is contained in:
parent
717db22980
commit
2168a627eb
|
@ -436,6 +436,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
||||||
uint256 currentAmountPlusPremium;
|
uint256 currentAmountPlusPremium;
|
||||||
address debtToken;
|
address debtToken;
|
||||||
uint256 flashloanPremiumTotal;
|
uint256 flashloanPremiumTotal;
|
||||||
|
bool isDebtMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -492,8 +493,9 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
||||||
vars.currentPremium = premiums[vars.i];
|
vars.currentPremium = premiums[vars.i];
|
||||||
vars.currentATokenAddress = aTokenAddresses[vars.i];
|
vars.currentATokenAddress = aTokenAddresses[vars.i];
|
||||||
vars.currentAmountPlusPremium = vars.currentAmount.add(vars.currentPremium);
|
vars.currentAmountPlusPremium = vars.currentAmount.add(vars.currentPremium);
|
||||||
|
vars.isDebtMode =
|
||||||
|
DataTypes.InterestRateMode(modes[vars.i]) != DataTypes.InterestRateMode.NONE;
|
||||||
|
|
||||||
if (DataTypes.InterestRateMode(modes[vars.i]) == DataTypes.InterestRateMode.NONE) {
|
|
||||||
_reserves[vars.currentAsset].updateState();
|
_reserves[vars.currentAsset].updateState();
|
||||||
_reserves[vars.currentAsset].cumulateToLiquidityIndex(
|
_reserves[vars.currentAsset].cumulateToLiquidityIndex(
|
||||||
IERC20(vars.currentATokenAddress).totalSupply(),
|
IERC20(vars.currentATokenAddress).totalSupply(),
|
||||||
|
@ -509,9 +511,10 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
||||||
IERC20(vars.currentAsset).safeTransferFrom(
|
IERC20(vars.currentAsset).safeTransferFrom(
|
||||||
receiverAddress,
|
receiverAddress,
|
||||||
vars.currentATokenAddress,
|
vars.currentATokenAddress,
|
||||||
vars.currentAmountPlusPremium
|
vars.isDebtMode ? vars.currentPremium : vars.currentAmountPlusPremium
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
|
if (vars.isDebtMode) {
|
||||||
// If the user chose to not return the funds, the system checks if there is enough collateral and
|
// If the user chose to not return the funds, the system checks if there is enough collateral and
|
||||||
// eventually opens a debt position
|
// eventually opens a debt position
|
||||||
_executeBorrow(
|
_executeBorrow(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user