mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Merge branch 'master' into fix/interfaces-guideline
This commit is contained in:
commit
bd0377198c
|
@ -18,17 +18,6 @@ import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddresses
|
||||||
contract LendingPoolAddressesProvider is Ownable, ILendingPoolAddressesProvider {
|
contract LendingPoolAddressesProvider is Ownable, ILendingPoolAddressesProvider {
|
||||||
mapping(bytes32 => address) private _addresses;
|
mapping(bytes32 => address) private _addresses;
|
||||||
|
|
||||||
//events
|
|
||||||
event LendingPoolUpdated(address indexed newAddress);
|
|
||||||
event LendingPoolManagerUpdated(address indexed newAddress);
|
|
||||||
event LendingPoolConfiguratorUpdated(address indexed newAddress);
|
|
||||||
event LendingPoolLiquidationManagerUpdated(address indexed newAddress);
|
|
||||||
event EthereumAddressUpdated(address indexed newAddress);
|
|
||||||
event PriceOracleUpdated(address indexed newAddress);
|
|
||||||
event LendingRateOracleUpdated(address indexed newAddress);
|
|
||||||
|
|
||||||
event ProxyCreated(bytes32 id, address indexed newAddress);
|
|
||||||
|
|
||||||
bytes32 private constant LENDING_POOL = 'LENDING_POOL';
|
bytes32 private constant LENDING_POOL = 'LENDING_POOL';
|
||||||
bytes32 private constant LENDING_POOL_CORE = 'LENDING_POOL_CORE';
|
bytes32 private constant LENDING_POOL_CORE = 'LENDING_POOL_CORE';
|
||||||
bytes32 private constant LENDING_POOL_CONFIGURATOR = 'LENDING_POOL_CONFIGURATOR';
|
bytes32 private constant LENDING_POOL_CONFIGURATOR = 'LENDING_POOL_CONFIGURATOR';
|
||||||
|
|
|
@ -13,12 +13,8 @@ import {
|
||||||
**/
|
**/
|
||||||
|
|
||||||
contract LendingPoolAddressesProviderRegistry is Ownable, ILendingPoolAddressesProviderRegistry {
|
contract LendingPoolAddressesProviderRegistry is Ownable, ILendingPoolAddressesProviderRegistry {
|
||||||
//events
|
mapping(address => uint256) addressesProviders;
|
||||||
event AddressesProviderRegistered(address indexed newAddress);
|
address[] addressesProvidersList;
|
||||||
event AddressesProviderUnregistered(address indexed newAddress);
|
|
||||||
|
|
||||||
mapping(address => uint256) internal _addressesProviders;
|
|
||||||
address[] internal _addressesProvidersList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev returns if an addressesProvider is registered or not
|
* @dev returns if an addressesProvider is registered or not
|
||||||
|
@ -31,7 +27,7 @@ contract LendingPoolAddressesProviderRegistry is Ownable, ILendingPoolAddressesP
|
||||||
view
|
view
|
||||||
returns (uint256)
|
returns (uint256)
|
||||||
{
|
{
|
||||||
return _addressesProviders[provider];
|
return addressesProviders[provider];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,13 +35,13 @@ contract LendingPoolAddressesProviderRegistry is Ownable, ILendingPoolAddressesP
|
||||||
* @return the list of addressesProviders
|
* @return the list of addressesProviders
|
||||||
**/
|
**/
|
||||||
function getAddressesProvidersList() external override view returns (address[] memory) {
|
function getAddressesProvidersList() external override view returns (address[] memory) {
|
||||||
uint256 maxLength = _addressesProvidersList.length;
|
uint256 maxLength = addressesProvidersList.length;
|
||||||
|
|
||||||
address[] memory activeProviders = new address[](maxLength);
|
address[] memory activeProviders = new address[](maxLength);
|
||||||
|
|
||||||
for (uint256 i = 0; i < _addressesProvidersList.length; i++) {
|
for (uint256 i = 0; i < addressesProvidersList.length; i++) {
|
||||||
if (_addressesProviders[_addressesProvidersList[i]] > 0) {
|
if (addressesProviders[addressesProvidersList[i]] > 0) {
|
||||||
activeProviders[i] = _addressesProvidersList[i];
|
activeProviders[i] = addressesProvidersList[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +53,7 @@ contract LendingPoolAddressesProviderRegistry is Ownable, ILendingPoolAddressesP
|
||||||
* @param provider the pool address to be registered
|
* @param provider the pool address to be registered
|
||||||
**/
|
**/
|
||||||
function registerAddressesProvider(address provider, uint256 id) external override onlyOwner {
|
function registerAddressesProvider(address provider, uint256 id) external override onlyOwner {
|
||||||
_addressesProviders[provider] = id;
|
addressesProviders[provider] = id;
|
||||||
_addToAddressesProvidersList(provider);
|
_addToAddressesProvidersList(provider);
|
||||||
emit AddressesProviderRegistered(provider);
|
emit AddressesProviderRegistered(provider);
|
||||||
}
|
}
|
||||||
|
@ -67,8 +63,8 @@ contract LendingPoolAddressesProviderRegistry is Ownable, ILendingPoolAddressesP
|
||||||
* @param provider the pool address to be unregistered
|
* @param provider the pool address to be unregistered
|
||||||
**/
|
**/
|
||||||
function unregisterAddressesProvider(address provider) external override onlyOwner {
|
function unregisterAddressesProvider(address provider) external override onlyOwner {
|
||||||
require(_addressesProviders[provider] > 0, 'Provider is not registered');
|
require(addressesProviders[provider] > 0, 'Provider is not registered');
|
||||||
_addressesProviders[provider] = 0;
|
addressesProviders[provider] = 0;
|
||||||
emit AddressesProviderUnregistered(provider);
|
emit AddressesProviderUnregistered(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,12 +73,12 @@ contract LendingPoolAddressesProviderRegistry is Ownable, ILendingPoolAddressesP
|
||||||
* @param provider the pool address to be added
|
* @param provider the pool address to be added
|
||||||
**/
|
**/
|
||||||
function _addToAddressesProvidersList(address provider) internal {
|
function _addToAddressesProvidersList(address provider) internal {
|
||||||
for (uint256 i = 0; i < _addressesProvidersList.length; i++) {
|
for (uint256 i = 0; i < addressesProvidersList.length; i++) {
|
||||||
if (_addressesProvidersList[i] == provider) {
|
if (addressesProvidersList[i] == provider) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_addressesProvidersList.push(provider);
|
addressesProvidersList.push(provider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,25 +14,25 @@ abstract contract FlashLoanReceiverBase is IFlashLoanReceiver {
|
||||||
|
|
||||||
ILendingPoolAddressesProvider public addressesProvider;
|
ILendingPoolAddressesProvider public addressesProvider;
|
||||||
|
|
||||||
constructor(ILendingPoolAddressesProvider _provider) public {
|
constructor(ILendingPoolAddressesProvider provider) public {
|
||||||
addressesProvider = _provider;
|
addressesProvider = provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
receive() external payable {}
|
receive() external payable {}
|
||||||
|
|
||||||
function transferFundsBackInternal(
|
function transferFundsBackInternal(
|
||||||
address _reserve,
|
address reserve,
|
||||||
address _destination,
|
address destination,
|
||||||
uint256 _amount
|
uint256 amount
|
||||||
) internal {
|
) internal {
|
||||||
transferInternal(_destination, _reserve, _amount);
|
transferInternal(destination, reserve, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
function transferInternal(
|
function transferInternal(
|
||||||
address _destination,
|
address destination,
|
||||||
address _reserve,
|
address reserve,
|
||||||
uint256 _amount
|
uint256 amount
|
||||||
) internal {
|
) internal {
|
||||||
IERC20(_reserve).safeTransfer(_destination, _amount);
|
IERC20(reserve).safeTransfer(destination, amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,10 @@ pragma solidity ^0.6.8;
|
||||||
**/
|
**/
|
||||||
interface IFlashLoanReceiver {
|
interface IFlashLoanReceiver {
|
||||||
function executeOperation(
|
function executeOperation(
|
||||||
address _reserve,
|
address reserve,
|
||||||
address _destination,
|
address destination,
|
||||||
uint256 _amount,
|
uint256 amount,
|
||||||
uint256 _fee,
|
uint256 fee,
|
||||||
bytes calldata _params
|
bytes calldata params
|
||||||
) external;
|
) external;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,142 @@ import {ReserveConfiguration} from '../libraries/configuration/ReserveConfigurat
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
interface ILendingPool {
|
interface ILendingPool {
|
||||||
|
/**
|
||||||
|
* @dev emitted on deposit
|
||||||
|
* @param reserve the address of the reserve
|
||||||
|
* @param user the address of the user
|
||||||
|
* @param amount the amount to be deposited
|
||||||
|
* @param referral the referral number of the action
|
||||||
|
**/
|
||||||
|
event Deposit(
|
||||||
|
address indexed reserve,
|
||||||
|
address indexed user,
|
||||||
|
uint256 amount,
|
||||||
|
uint16 indexed referral
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev emitted during a withdraw action.
|
||||||
|
* @param reserve the address of the reserve
|
||||||
|
* @param user the address of the user
|
||||||
|
* @param amount the amount to be withdrawn
|
||||||
|
**/
|
||||||
|
event Withdraw(address indexed reserve, address indexed user, uint256 amount);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev emitted on borrow
|
||||||
|
* @param reserve the address of the reserve
|
||||||
|
* @param user the address of the user
|
||||||
|
* @param amount the amount to be deposited
|
||||||
|
* @param borrowRateMode the rate mode, can be either 1-stable or 2-variable
|
||||||
|
* @param borrowRate the rate at which the user has borrowed
|
||||||
|
* @param referral the referral number of the action
|
||||||
|
**/
|
||||||
|
event Borrow(
|
||||||
|
address indexed reserve,
|
||||||
|
address indexed user,
|
||||||
|
uint256 amount,
|
||||||
|
uint256 borrowRateMode,
|
||||||
|
uint256 borrowRate,
|
||||||
|
uint16 indexed referral
|
||||||
|
);
|
||||||
|
/**
|
||||||
|
* @dev emitted on repay
|
||||||
|
* @param reserve the address of the reserve
|
||||||
|
* @param user the address of the user for which the repay has been executed
|
||||||
|
* @param repayer the address of the user that has performed the repay action
|
||||||
|
* @param amount the amount repaid
|
||||||
|
**/
|
||||||
|
event Repay(
|
||||||
|
address indexed reserve,
|
||||||
|
address indexed user,
|
||||||
|
address indexed repayer,
|
||||||
|
uint256 amount
|
||||||
|
);
|
||||||
|
/**
|
||||||
|
* @dev emitted when a user performs a rate swap
|
||||||
|
* @param reserve the address of the reserve
|
||||||
|
* @param user the address of the user executing the swap
|
||||||
|
**/
|
||||||
|
event Swap(address indexed reserve, address indexed user, uint256 timestamp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev emitted when a user enables a reserve as collateral
|
||||||
|
* @param reserve the address of the reserve
|
||||||
|
* @param user the address of the user
|
||||||
|
**/
|
||||||
|
event ReserveUsedAsCollateralEnabled(address indexed reserve, address indexed user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev emitted when a user disables a reserve as collateral
|
||||||
|
* @param reserve the address of the reserve
|
||||||
|
* @param user the address of the user
|
||||||
|
**/
|
||||||
|
event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev emitted when the stable rate of a user gets rebalanced
|
||||||
|
* @param reserve the address of the reserve
|
||||||
|
* @param user the address of the user for which the rebalance has been executed
|
||||||
|
**/
|
||||||
|
event RebalanceStableBorrowRate(address indexed reserve, address indexed user);
|
||||||
|
/**
|
||||||
|
* @dev emitted when a flashloan is executed
|
||||||
|
* @param target the address of the flashLoanReceiver
|
||||||
|
* @param reserve the address of the reserve
|
||||||
|
* @param amount the amount requested
|
||||||
|
* @param totalFee the total fee on the amount
|
||||||
|
**/
|
||||||
|
event FlashLoan(
|
||||||
|
address indexed target,
|
||||||
|
address indexed reserve,
|
||||||
|
uint256 amount,
|
||||||
|
uint256 totalFee
|
||||||
|
);
|
||||||
|
/**
|
||||||
|
* @dev these events are not emitted directly by the LendingPool
|
||||||
|
* but they are declared here as the LendingPoolLiquidationManager
|
||||||
|
* is executed using a delegateCall().
|
||||||
|
* This allows to have the events in the generated ABI for LendingPool.
|
||||||
|
**/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev emitted when a borrow fee is liquidated
|
||||||
|
* @param collateral the address of the collateral being liquidated
|
||||||
|
* @param reserve the address of the reserve
|
||||||
|
* @param user the address of the user being liquidated
|
||||||
|
* @param feeLiquidated the total fee liquidated
|
||||||
|
* @param liquidatedCollateralForFee the amount of collateral received by the protocol in exchange for the fee
|
||||||
|
**/
|
||||||
|
event OriginationFeeLiquidated(
|
||||||
|
address indexed collateral,
|
||||||
|
address indexed reserve,
|
||||||
|
address indexed user,
|
||||||
|
uint256 feeLiquidated,
|
||||||
|
uint256 liquidatedCollateralForFee
|
||||||
|
);
|
||||||
|
/**
|
||||||
|
* @dev emitted when a borrower is liquidated
|
||||||
|
* @param collateral the address of the collateral being liquidated
|
||||||
|
* @param reserve the address of the reserve
|
||||||
|
* @param user the address of the user being liquidated
|
||||||
|
* @param purchaseAmount the total amount liquidated
|
||||||
|
* @param liquidatedCollateralAmount the amount of collateral being liquidated
|
||||||
|
* @param accruedBorrowInterest the amount of interest accrued by the borrower since the last action
|
||||||
|
* @param liquidator the address of the liquidator
|
||||||
|
* @param receiveAToken true if the liquidator wants to receive aTokens, false otherwise
|
||||||
|
**/
|
||||||
|
event LiquidationCall(
|
||||||
|
address indexed collateral,
|
||||||
|
address indexed reserve,
|
||||||
|
address indexed user,
|
||||||
|
uint256 purchaseAmount,
|
||||||
|
uint256 liquidatedCollateralAmount,
|
||||||
|
uint256 accruedBorrowInterest,
|
||||||
|
address liquidator,
|
||||||
|
bool receiveAToken
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev deposits The underlying asset into the reserve. A corresponding amount of the overlying asset (aTokens)
|
* @dev deposits The underlying asset into the reserve. A corresponding amount of the overlying asset (aTokens)
|
||||||
* is minted.
|
* is minted.
|
||||||
|
|
|
@ -7,6 +7,17 @@ pragma solidity ^0.6.8;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
interface ILendingPoolAddressesProvider {
|
interface ILendingPoolAddressesProvider {
|
||||||
|
//events
|
||||||
|
event LendingPoolUpdated(address indexed newAddress);
|
||||||
|
event LendingPoolManagerUpdated(address indexed newAddress);
|
||||||
|
event LendingPoolConfiguratorUpdated(address indexed newAddress);
|
||||||
|
event LendingPoolLiquidationManagerUpdated(address indexed newAddress);
|
||||||
|
event EthereumAddressUpdated(address indexed newAddress);
|
||||||
|
event PriceOracleUpdated(address indexed newAddress);
|
||||||
|
event LendingRateOracleUpdated(address indexed newAddress);
|
||||||
|
|
||||||
|
event ProxyCreated(bytes32 id, address indexed newAddress);
|
||||||
|
|
||||||
function getLendingPool() external view returns (address);
|
function getLendingPool() external view returns (address);
|
||||||
|
|
||||||
function setLendingPoolImpl(address pool) external;
|
function setLendingPoolImpl(address pool) external;
|
||||||
|
|
|
@ -7,6 +7,10 @@ pragma solidity ^0.6.8;
|
||||||
**/
|
**/
|
||||||
|
|
||||||
interface ILendingPoolAddressesProviderRegistry {
|
interface ILendingPoolAddressesProviderRegistry {
|
||||||
|
//events
|
||||||
|
event AddressesProviderRegistered(address indexed newAddress);
|
||||||
|
event AddressesProviderUnregistered(address indexed newAddress);
|
||||||
|
|
||||||
function getAddressesProvidersList() external view returns (address[] memory);
|
function getAddressesProvidersList() external view returns (address[] memory);
|
||||||
|
|
||||||
function isAddressesProviderRegistered(address provider) external view returns (uint256);
|
function isAddressesProviderRegistered(address provider) external view returns (uint256);
|
||||||
|
|
|
@ -51,141 +51,6 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
|
||||||
|
|
||||||
address[] internal reservesList;
|
address[] internal reservesList;
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev emitted on deposit
|
|
||||||
* @param reserve the address of the reserve
|
|
||||||
* @param user the address of the user
|
|
||||||
* @param amount the amount to be deposited
|
|
||||||
* @param referral the referral number of the action
|
|
||||||
**/
|
|
||||||
event Deposit(
|
|
||||||
address indexed reserve,
|
|
||||||
address indexed user,
|
|
||||||
uint256 amount,
|
|
||||||
uint16 indexed referral
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev emitted during a withdraw action.
|
|
||||||
* @param reserve the address of the reserve
|
|
||||||
* @param user the address of the user
|
|
||||||
* @param amount the amount to be withdrawn
|
|
||||||
**/
|
|
||||||
event Withdraw(address indexed reserve, address indexed user, uint256 amount);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev emitted on borrow
|
|
||||||
* @param reserve the address of the reserve
|
|
||||||
* @param user the address of the user
|
|
||||||
* @param amount the amount to be deposited
|
|
||||||
* @param borrowRateMode the rate mode, can be either 1-stable or 2-variable
|
|
||||||
* @param borrowRate the rate at which the user has borrowed
|
|
||||||
* @param referral the referral number of the action
|
|
||||||
**/
|
|
||||||
event Borrow(
|
|
||||||
address indexed reserve,
|
|
||||||
address indexed user,
|
|
||||||
uint256 amount,
|
|
||||||
uint256 borrowRateMode,
|
|
||||||
uint256 borrowRate,
|
|
||||||
uint16 indexed referral
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* @dev emitted on repay
|
|
||||||
* @param reserve the address of the reserve
|
|
||||||
* @param user the address of the user for which the repay has been executed
|
|
||||||
* @param repayer the address of the user that has performed the repay action
|
|
||||||
* @param amount the amount repaid
|
|
||||||
**/
|
|
||||||
event Repay(
|
|
||||||
address indexed reserve,
|
|
||||||
address indexed user,
|
|
||||||
address indexed repayer,
|
|
||||||
uint256 amount
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* @dev emitted when a user performs a rate swap
|
|
||||||
* @param reserve the address of the reserve
|
|
||||||
* @param user the address of the user executing the swap
|
|
||||||
**/
|
|
||||||
event Swap(address indexed reserve, address indexed user, uint256 timestamp);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev emitted when a user enables a reserve as collateral
|
|
||||||
* @param reserve the address of the reserve
|
|
||||||
* @param user the address of the user
|
|
||||||
**/
|
|
||||||
event ReserveUsedAsCollateralEnabled(address indexed reserve, address indexed user);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev emitted when a user disables a reserve as collateral
|
|
||||||
* @param reserve the address of the reserve
|
|
||||||
* @param user the address of the user
|
|
||||||
**/
|
|
||||||
event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev emitted when the stable rate of a user gets rebalanced
|
|
||||||
* @param reserve the address of the reserve
|
|
||||||
* @param user the address of the user for which the rebalance has been executed
|
|
||||||
**/
|
|
||||||
event RebalanceStableBorrowRate(address indexed reserve, address indexed user);
|
|
||||||
/**
|
|
||||||
* @dev emitted when a flashloan is executed
|
|
||||||
* @param target the address of the flashLoanReceiver
|
|
||||||
* @param reserve the address of the reserve
|
|
||||||
* @param amount the amount requested
|
|
||||||
* @param totalFee the total fee on the amount
|
|
||||||
**/
|
|
||||||
event FlashLoan(
|
|
||||||
address indexed target,
|
|
||||||
address indexed reserve,
|
|
||||||
uint256 amount,
|
|
||||||
uint256 totalFee
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* @dev these events are not emitted directly by the LendingPool
|
|
||||||
* but they are declared here as the LendingPoolLiquidationManager
|
|
||||||
* is executed using a delegateCall().
|
|
||||||
* This allows to have the events in the generated ABI for LendingPool.
|
|
||||||
**/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev emitted when a borrow fee is liquidated
|
|
||||||
* @param collateral the address of the collateral being liquidated
|
|
||||||
* @param reserve the address of the reserve
|
|
||||||
* @param user the address of the user being liquidated
|
|
||||||
* @param feeLiquidated the total fee liquidated
|
|
||||||
* @param liquidatedCollateralForFee the amount of collateral received by the protocol in exchange for the fee
|
|
||||||
**/
|
|
||||||
event OriginationFeeLiquidated(
|
|
||||||
address indexed collateral,
|
|
||||||
address indexed reserve,
|
|
||||||
address indexed user,
|
|
||||||
uint256 feeLiquidated,
|
|
||||||
uint256 liquidatedCollateralForFee
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* @dev emitted when a borrower is liquidated
|
|
||||||
* @param collateral the address of the collateral being liquidated
|
|
||||||
* @param reserve the address of the reserve
|
|
||||||
* @param user the address of the user being liquidated
|
|
||||||
* @param purchaseAmount the total amount liquidated
|
|
||||||
* @param liquidatedCollateralAmount the amount of collateral being liquidated
|
|
||||||
* @param accruedBorrowInterest the amount of interest accrued by the borrower since the last action
|
|
||||||
* @param liquidator the address of the liquidator
|
|
||||||
* @param receiveAToken true if the liquidator wants to receive aTokens, false otherwise
|
|
||||||
**/
|
|
||||||
event LiquidationCall(
|
|
||||||
address indexed collateral,
|
|
||||||
address indexed reserve,
|
|
||||||
address indexed user,
|
|
||||||
uint256 purchaseAmount,
|
|
||||||
uint256 liquidatedCollateralAmount,
|
|
||||||
uint256 accruedBorrowInterest,
|
|
||||||
address liquidator,
|
|
||||||
bool receiveAToken
|
|
||||||
);
|
|
||||||
/**
|
/**
|
||||||
* @dev only lending pools configurator can use functions affected by this modifier
|
* @dev only lending pools configurator can use functions affected by this modifier
|
||||||
**/
|
**/
|
||||||
|
@ -415,12 +280,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
|
||||||
|
|
||||||
IERC20(asset).safeTransferFrom(msg.sender, reserve.aTokenAddress, paybackAmount);
|
IERC20(asset).safeTransferFrom(msg.sender, reserve.aTokenAddress, paybackAmount);
|
||||||
|
|
||||||
emit Repay(
|
emit Repay(asset, _onBehalfOf, msg.sender, paybackAmount);
|
||||||
asset,
|
|
||||||
_onBehalfOf,
|
|
||||||
msg.sender,
|
|
||||||
paybackAmount
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -511,10 +371,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
|
||||||
|
|
||||||
reserve.updateInterestRates(asset, 0, 0);
|
reserve.updateInterestRates(asset, 0, 0);
|
||||||
|
|
||||||
emit RebalanceStableBorrowRate(
|
emit RebalanceStableBorrowRate(asset, _user);
|
||||||
asset,
|
|
||||||
_user
|
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -875,18 +732,18 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev returns the normalized income per unit of asset
|
* @dev returns the normalized income per unit of asset
|
||||||
* @param asset the address of the reserve
|
* @param asset the address of the reserve
|
||||||
* @return the reserve normalized income
|
* @return the reserve normalized income
|
||||||
*/
|
*/
|
||||||
function getReserveNormalizedIncome(address asset) external override view returns (uint256) {
|
function getReserveNormalizedIncome(address asset) external override view returns (uint256) {
|
||||||
return _reserves[asset].getNormalizedIncome();
|
return _reserves[asset].getNormalizedIncome();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev returns the normalized variable debt per unit of asset
|
* @dev returns the normalized variable debt per unit of asset
|
||||||
* @param asset the address of the reserve
|
* @param asset the address of the reserve
|
||||||
* @return the reserve normalized debt
|
* @return the reserve normalized debt
|
||||||
*/
|
*/
|
||||||
function getReserveNormalizedVariableDebt(address asset)
|
function getReserveNormalizedVariableDebt(address asset)
|
||||||
external
|
external
|
||||||
|
@ -898,11 +755,11 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev validate if a balance decrease for an asset is allowed
|
* @dev validate if a balance decrease for an asset is allowed
|
||||||
* @param asset the address of the reserve
|
* @param asset the address of the reserve
|
||||||
* @param user the user related to the balance decrease
|
* @param user the user related to the balance decrease
|
||||||
* @param amount the amount being transferred/redeemed
|
* @param amount the amount being transferred/redeemed
|
||||||
* @return true if the balance decrease can be allowed, false otherwise
|
* @return true if the balance decrease can be allowed, false otherwise
|
||||||
*/
|
*/
|
||||||
function balanceDecreaseAllowed(
|
function balanceDecreaseAllowed(
|
||||||
address asset,
|
address asset,
|
||||||
|
@ -922,16 +779,16 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev returns the list of the initialized reserves
|
* @dev returns the list of the initialized reserves
|
||||||
**/
|
**/
|
||||||
function getReservesList() external view returns(address[] memory){
|
function getReservesList() external view returns (address[] memory) {
|
||||||
return reservesList;
|
return reservesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev returns the addresses provider
|
* @dev returns the addresses provider
|
||||||
**/
|
**/
|
||||||
function getAddressesProvider() external view returns(ILendingPoolAddressesProvider){
|
function getAddressesProvider() external view returns (ILendingPoolAddressesProvider) {
|
||||||
return addressesProvider;
|
return addressesProvider;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,84 +22,6 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
|
||||||
|
|
||||||
uint256 public constant UINT_MAX_VALUE = uint256(-1);
|
uint256 public constant UINT_MAX_VALUE = uint256(-1);
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev emitted after aTokens are burned
|
|
||||||
* @param from the address performing the redeem
|
|
||||||
* @param value the amount to be redeemed
|
|
||||||
* @param fromBalanceIncrease the cumulated balance since the last update of the user
|
|
||||||
* @param fromIndex the last index of the user
|
|
||||||
**/
|
|
||||||
event Burn(
|
|
||||||
address indexed from,
|
|
||||||
address indexed target,
|
|
||||||
uint256 value,
|
|
||||||
uint256 fromBalanceIncrease,
|
|
||||||
uint256 fromIndex
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev emitted after the mint action
|
|
||||||
* @param from the address performing the mint
|
|
||||||
* @param value the amount to be minted
|
|
||||||
* @param fromBalanceIncrease the cumulated balance since the last update of the user
|
|
||||||
* @param fromIndex the last index of the user
|
|
||||||
**/
|
|
||||||
event Mint(address indexed from, uint256 value, uint256 fromBalanceIncrease, uint256 fromIndex);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev emitted during the transfer action
|
|
||||||
* @param from the address from which the tokens are being transferred
|
|
||||||
* @param to the adress of the destination
|
|
||||||
* @param value the amount to be minted
|
|
||||||
* @param fromBalanceIncrease the cumulated balance since the last update of the user
|
|
||||||
* @param toBalanceIncrease the cumulated balance since the last update of the destination
|
|
||||||
* @param fromIndex the last index of the user
|
|
||||||
* @param toIndex the last index of the liquidator
|
|
||||||
**/
|
|
||||||
event BalanceTransfer(
|
|
||||||
address indexed from,
|
|
||||||
address indexed to,
|
|
||||||
uint256 value,
|
|
||||||
uint256 fromBalanceIncrease,
|
|
||||||
uint256 toBalanceIncrease,
|
|
||||||
uint256 fromIndex,
|
|
||||||
uint256 toIndex
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev emitted when the accumulation of the interest
|
|
||||||
* by an user is redirected to another user
|
|
||||||
* @param from the address from which the interest is being redirected
|
|
||||||
* @param to the adress of the destination
|
|
||||||
* @param fromBalanceIncrease the cumulated balance since the last update of the user
|
|
||||||
* @param fromIndex the last index of the user
|
|
||||||
**/
|
|
||||||
event InterestStreamRedirected(
|
|
||||||
address indexed from,
|
|
||||||
address indexed to,
|
|
||||||
uint256 redirectedBalance,
|
|
||||||
uint256 fromBalanceIncrease,
|
|
||||||
uint256 fromIndex
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev emitted when the redirected balance of an user is being updated
|
|
||||||
* @param targetAddress the address of which the balance is being updated
|
|
||||||
* @param targetBalanceIncrease the cumulated balance since the last update of the target
|
|
||||||
* @param targetIndex the last index of the user
|
|
||||||
* @param redirectedBalanceAdded the redirected balance being added
|
|
||||||
* @param redirectedBalanceRemoved the redirected balance being removed
|
|
||||||
**/
|
|
||||||
event RedirectedBalanceUpdated(
|
|
||||||
address indexed targetAddress,
|
|
||||||
uint256 targetBalanceIncrease,
|
|
||||||
uint256 targetIndex,
|
|
||||||
uint256 redirectedBalanceAdded,
|
|
||||||
uint256 redirectedBalanceRemoved
|
|
||||||
);
|
|
||||||
|
|
||||||
event InterestRedirectionAllowanceChanged(address indexed from, address indexed to);
|
|
||||||
|
|
||||||
address public immutable UNDERLYING_ASSET_ADDRESS;
|
address public immutable UNDERLYING_ASSET_ADDRESS;
|
||||||
|
|
||||||
mapping(address => uint256) private _userIndexes;
|
mapping(address => uint256) private _userIndexes;
|
||||||
|
|
|
@ -33,40 +33,6 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase {
|
||||||
|
|
||||||
mapping(address => UserData) private _usersData;
|
mapping(address => UserData) private _usersData;
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev emitted when new stable debt is minted
|
|
||||||
* @param user the address of the user
|
|
||||||
* @param amount the amount minted
|
|
||||||
* @param previousBalance the previous balance of the user
|
|
||||||
* @param currentBalance the current balance of the user
|
|
||||||
* @param balanceIncrease the debt increase since the last update
|
|
||||||
* @param newRate the rate of the debt after the minting
|
|
||||||
**/
|
|
||||||
event MintDebt(
|
|
||||||
address user,
|
|
||||||
uint256 amount,
|
|
||||||
uint256 previousBalance,
|
|
||||||
uint256 currentBalance,
|
|
||||||
uint256 balanceIncrease,
|
|
||||||
uint256 newRate
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev emitted when new stable debt is burned
|
|
||||||
* @param user the address of the user
|
|
||||||
* @param amount the amount minted
|
|
||||||
* @param previousBalance the previous balance of the user
|
|
||||||
* @param currentBalance the current balance of the user
|
|
||||||
* @param balanceIncrease the debt increase since the last update
|
|
||||||
**/
|
|
||||||
event BurnDebt(
|
|
||||||
address user,
|
|
||||||
uint256 amount,
|
|
||||||
uint256 previousBalance,
|
|
||||||
uint256 currentBalance,
|
|
||||||
uint256 balanceIncrease
|
|
||||||
);
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
address pool,
|
address pool,
|
||||||
address underlyingAsset,
|
address underlyingAsset,
|
||||||
|
|
|
@ -22,42 +22,6 @@ contract VariableDebtToken is DebtTokenBase, IVariableDebtToken {
|
||||||
|
|
||||||
mapping(address => uint256) private _userIndexes;
|
mapping(address => uint256) private _userIndexes;
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev emitted when new variable debt is minted
|
|
||||||
* @param user the user receiving the debt
|
|
||||||
* @param amount the amount of debt being minted
|
|
||||||
* @param previousBalance the previous balance of the user
|
|
||||||
* @param currentBalance the current balance of the user
|
|
||||||
* @param balanceIncrease the debt accumulated since the last action
|
|
||||||
* @param index the index of the user
|
|
||||||
**/
|
|
||||||
event MintDebt(
|
|
||||||
address user,
|
|
||||||
uint256 amount,
|
|
||||||
uint256 previousBalance,
|
|
||||||
uint256 currentBalance,
|
|
||||||
uint256 balanceIncrease,
|
|
||||||
uint256 index
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev emitted when variable debt is burnt
|
|
||||||
* @param user the user which debt has been burned
|
|
||||||
* @param amount the amount of debt being burned
|
|
||||||
* @param previousBalance the previous balance of the user
|
|
||||||
* @param currentBalance the current balance of the user
|
|
||||||
* @param balanceIncrease the debt accumulated since the last action
|
|
||||||
* @param index the index of the user
|
|
||||||
**/
|
|
||||||
event BurnDebt(
|
|
||||||
address user,
|
|
||||||
uint256 amount,
|
|
||||||
uint256 previousBalance,
|
|
||||||
uint256 currentBalance,
|
|
||||||
uint256 balanceIncrease,
|
|
||||||
uint256 index
|
|
||||||
);
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
address pool,
|
address pool,
|
||||||
address underlyingAsset,
|
address underlyingAsset,
|
||||||
|
|
|
@ -4,6 +4,84 @@ pragma solidity ^0.6.8;
|
||||||
import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
|
import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
|
||||||
|
|
||||||
interface IAToken is IERC20 {
|
interface IAToken is IERC20 {
|
||||||
|
/**
|
||||||
|
* @dev emitted after aTokens are burned
|
||||||
|
* @param from the address performing the redeem
|
||||||
|
* @param value the amount to be redeemed
|
||||||
|
* @param fromBalanceIncrease the cumulated balance since the last update of the user
|
||||||
|
* @param fromIndex the last index of the user
|
||||||
|
**/
|
||||||
|
event Burn(
|
||||||
|
address indexed from,
|
||||||
|
address indexed target,
|
||||||
|
uint256 value,
|
||||||
|
uint256 fromBalanceIncrease,
|
||||||
|
uint256 fromIndex
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev emitted after the mint action
|
||||||
|
* @param from the address performing the mint
|
||||||
|
* @param value the amount to be minted
|
||||||
|
* @param fromBalanceIncrease the cumulated balance since the last update of the user
|
||||||
|
* @param fromIndex the last index of the user
|
||||||
|
**/
|
||||||
|
event Mint(address indexed from, uint256 value, uint256 fromBalanceIncrease, uint256 fromIndex);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev emitted during the transfer action
|
||||||
|
* @param from the address from which the tokens are being transferred
|
||||||
|
* @param to the adress of the destination
|
||||||
|
* @param value the amount to be minted
|
||||||
|
* @param fromBalanceIncrease the cumulated balance since the last update of the user
|
||||||
|
* @param toBalanceIncrease the cumulated balance since the last update of the destination
|
||||||
|
* @param fromIndex the last index of the user
|
||||||
|
* @param toIndex the last index of the liquidator
|
||||||
|
**/
|
||||||
|
event BalanceTransfer(
|
||||||
|
address indexed from,
|
||||||
|
address indexed to,
|
||||||
|
uint256 value,
|
||||||
|
uint256 fromBalanceIncrease,
|
||||||
|
uint256 toBalanceIncrease,
|
||||||
|
uint256 fromIndex,
|
||||||
|
uint256 toIndex
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev emitted when the accumulation of the interest
|
||||||
|
* by an user is redirected to another user
|
||||||
|
* @param from the address from which the interest is being redirected
|
||||||
|
* @param to the adress of the destination
|
||||||
|
* @param fromBalanceIncrease the cumulated balance since the last update of the user
|
||||||
|
* @param fromIndex the last index of the user
|
||||||
|
**/
|
||||||
|
event InterestStreamRedirected(
|
||||||
|
address indexed from,
|
||||||
|
address indexed to,
|
||||||
|
uint256 redirectedBalance,
|
||||||
|
uint256 fromBalanceIncrease,
|
||||||
|
uint256 fromIndex
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev emitted when the redirected balance of an user is being updated
|
||||||
|
* @param targetAddress the address of which the balance is being updated
|
||||||
|
* @param targetBalanceIncrease the cumulated balance since the last update of the target
|
||||||
|
* @param targetIndex the last index of the user
|
||||||
|
* @param redirectedBalanceAdded the redirected balance being added
|
||||||
|
* @param redirectedBalanceRemoved the redirected balance being removed
|
||||||
|
**/
|
||||||
|
event RedirectedBalanceUpdated(
|
||||||
|
address indexed targetAddress,
|
||||||
|
uint256 targetBalanceIncrease,
|
||||||
|
uint256 targetIndex,
|
||||||
|
uint256 redirectedBalanceAdded,
|
||||||
|
uint256 redirectedBalanceRemoved
|
||||||
|
);
|
||||||
|
|
||||||
|
event InterestRedirectionAllowanceChanged(address indexed from, address indexed to);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev redirects the interest generated to a target address.
|
* @dev redirects the interest generated to a target address.
|
||||||
* when the interest is redirected, the user balance is added to
|
* when the interest is redirected, the user balance is added to
|
||||||
|
|
|
@ -13,6 +13,40 @@ pragma solidity ^0.6.8;
|
||||||
**/
|
**/
|
||||||
|
|
||||||
interface IStableDebtToken {
|
interface IStableDebtToken {
|
||||||
|
/**
|
||||||
|
* @dev emitted when new stable debt is minted
|
||||||
|
* @param user the address of the user
|
||||||
|
* @param amount the amount minted
|
||||||
|
* @param previousBalance the previous balance of the user
|
||||||
|
* @param currentBalance the current balance of the user
|
||||||
|
* @param balanceIncrease the debt increase since the last update
|
||||||
|
* @param newRate the rate of the debt after the minting
|
||||||
|
**/
|
||||||
|
event MintDebt(
|
||||||
|
address user,
|
||||||
|
uint256 amount,
|
||||||
|
uint256 previousBalance,
|
||||||
|
uint256 currentBalance,
|
||||||
|
uint256 balanceIncrease,
|
||||||
|
uint256 newRate
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev emitted when new stable debt is burned
|
||||||
|
* @param user the address of the user
|
||||||
|
* @param amount the amount minted
|
||||||
|
* @param previousBalance the previous balance of the user
|
||||||
|
* @param currentBalance the current balance of the user
|
||||||
|
* @param balanceIncrease the debt increase since the last update
|
||||||
|
**/
|
||||||
|
event BurnDebt(
|
||||||
|
address user,
|
||||||
|
uint256 amount,
|
||||||
|
uint256 previousBalance,
|
||||||
|
uint256 currentBalance,
|
||||||
|
uint256 balanceIncrease
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev mints debt token to the target user. The resulting rate is the weighted average
|
* @dev mints debt token to the target user. The resulting rate is the weighted average
|
||||||
* between the rate of the new debt and the rate of the previous debt
|
* between the rate of the new debt and the rate of the previous debt
|
||||||
|
|
|
@ -8,6 +8,42 @@ pragma solidity ^0.6.8;
|
||||||
* @dev does not inherit from IERC20 to save in contract size
|
* @dev does not inherit from IERC20 to save in contract size
|
||||||
**/
|
**/
|
||||||
interface IVariableDebtToken {
|
interface IVariableDebtToken {
|
||||||
|
/**
|
||||||
|
* @dev emitted when new variable debt is minted
|
||||||
|
* @param user the user receiving the debt
|
||||||
|
* @param amount the amount of debt being minted
|
||||||
|
* @param previousBalance the previous balance of the user
|
||||||
|
* @param currentBalance the current balance of the user
|
||||||
|
* @param balanceIncrease the debt accumulated since the last action
|
||||||
|
* @param index the index of the user
|
||||||
|
**/
|
||||||
|
event MintDebt(
|
||||||
|
address user,
|
||||||
|
uint256 amount,
|
||||||
|
uint256 previousBalance,
|
||||||
|
uint256 currentBalance,
|
||||||
|
uint256 balanceIncrease,
|
||||||
|
uint256 index
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev emitted when variable debt is burnt
|
||||||
|
* @param user the user which debt has been burned
|
||||||
|
* @param amount the amount of debt being burned
|
||||||
|
* @param previousBalance the previous balance of the user
|
||||||
|
* @param currentBalance the current balance of the user
|
||||||
|
* @param balanceIncrease the debt accumulated since the last action
|
||||||
|
* @param index the index of the user
|
||||||
|
**/
|
||||||
|
event BurnDebt(
|
||||||
|
address user,
|
||||||
|
uint256 amount,
|
||||||
|
uint256 previousBalance,
|
||||||
|
uint256 currentBalance,
|
||||||
|
uint256 balanceIncrease,
|
||||||
|
uint256 index
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev mints new variable debt
|
* @dev mints new variable debt
|
||||||
* @param user the user receiving the debt
|
* @param user the user receiving the debt
|
||||||
|
|
Loading…
Reference in New Issue
Block a user