zellic-audit
Initial commit
f998fcd
raw
history blame
62.8 kB
{
"language": "Solidity",
"sources": {
"contracts/strategies/FlashStrategyAAVEv2.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity ^0.8.4;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"../interfaces/AAVE/ILendingPool.sol\";\nimport \"../interfaces/AAVE/IAaveIncentivesController.sol\";\nimport \"../interfaces/IFlashStrategy.sol\";\nimport \"../interfaces/IUserIncentive.sol\";\nimport \"../interfaces/IFlashFToken.sol\";\n\ncontract FlashStrategyAAVEv2 is IFlashStrategy, Ownable, ReentrancyGuard {\n using SafeERC20 for IERC20;\n\n address immutable flashProtocolAddress;\n address immutable lendingPoolAddress; // The AAVE V2 lending pool address\n address immutable principalTokenAddress; // The Principal token address (eg DAI)\n address immutable interestBearingTokenAddress; // The AAVE V2 interest bearing token address\n uint8 immutable principalDecimals;\n\n address fTokenAddress; // The Flash fERC20 token address\n uint16 referralCode = 0; // The AAVE V2 referral code\n uint256 principalBalance; // The amount of principal in this strategy\n address constant aaveIncentivesAddress = 0xd784927Ff2f95ba542BfC824c8a8a98F3495f6b5;\n\n address public userIncentiveAddress;\n bool public userIncentiveAddressLocked;\n\n constructor(\n address _lendingPoolAddress,\n address _principalTokenAddress,\n address _interestBearingTokenAddress,\n address _flashProtocolAddress\n ) public {\n lendingPoolAddress = _lendingPoolAddress;\n principalTokenAddress = _principalTokenAddress;\n interestBearingTokenAddress = _interestBearingTokenAddress;\n flashProtocolAddress = _flashProtocolAddress;\n\n // Read the number of decimals from the principal token\n principalDecimals = IFlashFToken(principalTokenAddress).decimals();\n\n increaseAllowance();\n }\n\n // Implemented as a separate function just in case the strategy ever runs out of allowance\n function increaseAllowance() public {\n IERC20(principalTokenAddress).safeApprove(lendingPoolAddress, 0);\n IERC20(principalTokenAddress).safeApprove(lendingPoolAddress, type(uint256).max);\n }\n\n function depositPrincipal(uint256 _tokenAmount) external override onlyAuthorised returns (uint256) {\n // Register how much we are depositing\n principalBalance = principalBalance + _tokenAmount;\n\n // Deposit into AAVE\n ILendingPool(lendingPoolAddress).deposit(principalTokenAddress, _tokenAmount, address(this), referralCode);\n\n return _tokenAmount;\n }\n\n function withdrawYield(uint256 _tokenAmount) private {\n // Withdraw from AAVE\n uint256 returnedTokens = ILendingPool(lendingPoolAddress).withdraw(\n principalTokenAddress,\n _tokenAmount,\n address(this)\n );\n require(returnedTokens >= _tokenAmount);\n\n uint256 aTokenBalance = IERC20(interestBearingTokenAddress).balanceOf(address(this));\n require(aTokenBalance >= getPrincipalBalance(), \"PRINCIPAL BALANCE INVALID\");\n }\n\n function withdrawPrincipal(uint256 _tokenAmount) external override onlyAuthorised {\n // Withdraw from AAVE\n uint256 returnedTokens = ILendingPool(lendingPoolAddress).withdraw(\n principalTokenAddress,\n _tokenAmount,\n address(this)\n );\n require(returnedTokens >= _tokenAmount);\n\n IERC20(principalTokenAddress).safeTransfer(msg.sender, _tokenAmount);\n\n principalBalance = principalBalance - _tokenAmount;\n }\n\n function withdrawERC20(address[] calldata _tokenAddresses, uint256[] calldata _tokenAmounts) external onlyOwner {\n require(_tokenAddresses.length == _tokenAmounts.length, \"ARRAY SIZE MISMATCH\");\n\n for (uint256 i = 0; i < _tokenAddresses.length; i++) {\n // Ensure the token being withdrawn is not the interest bearing token\n require(_tokenAddresses[i] != interestBearingTokenAddress, \"TOKEN ADDRESS PROHIBITED\");\n\n // Transfer the token to the caller\n IERC20(_tokenAddresses[i]).safeTransfer(msg.sender, _tokenAmounts[i]);\n }\n }\n\n function getPrincipalBalance() public view override returns (uint256) {\n return principalBalance;\n }\n\n function getYieldBalance() public view override returns (uint256) {\n uint256 interestBearingTokenBalance = IERC20(interestBearingTokenAddress).balanceOf(address(this));\n\n return (interestBearingTokenBalance - getPrincipalBalance());\n }\n\n function getPrincipalAddress() external view override returns (address) {\n return principalTokenAddress;\n }\n\n function getFTokenAddress() external view returns (address) {\n return fTokenAddress;\n }\n\n function setFTokenAddress(address _fTokenAddress) external override onlyAuthorised {\n require(fTokenAddress == address(0), \"FTOKEN ADDRESS ALREADY SET\");\n fTokenAddress = _fTokenAddress;\n }\n\n function quoteMintFToken(uint256 _tokenAmount, uint256 _duration) external view override returns (uint256) {\n // Enforce minimum _duration\n require(_duration >= 60, \"DURATION TOO LOW\");\n\n // 1 ERC20 for 365 DAYS = 1 fERC20\n // 1 second = 0.000000031709792000\n // eg (100000000000000000 * (1 second * 31709792000)) / 10**18\n // eg (1000000 * (1 second * 31709792000)) / 10**6\n uint256 amountToMint = (_tokenAmount * (_duration * 31709792000)) / (10**principalDecimals);\n\n require(amountToMint > 0, \"INSUFFICIENT OUTPUT\");\n\n return amountToMint;\n }\n\n function quoteBurnFToken(uint256 _tokenAmount) public view override returns (uint256) {\n uint256 totalSupply = IERC20(fTokenAddress).totalSupply();\n require(totalSupply > 0, \"INSUFFICIENT fERC20 TOKEN SUPPLY\");\n\n if (_tokenAmount > totalSupply) {\n _tokenAmount = totalSupply;\n }\n\n // Calculate the percentage of _tokenAmount vs totalSupply provided\n // and multiply by total yield\n return (getYieldBalance() * _tokenAmount) / totalSupply;\n }\n\n function burnFToken(\n uint256 _tokenAmount,\n uint256 _minimumReturned,\n address _yieldTo\n ) external override nonReentrant returns (uint256) {\n // Calculate how much yield to give back\n uint256 tokensOwed = quoteBurnFToken(_tokenAmount);\n require(tokensOwed >= _minimumReturned && tokensOwed > 0, \"INSUFFICIENT OUTPUT\");\n\n // Transfer fERC20 (from caller) tokens to contract so we can burn them\n IFlashFToken(fTokenAddress).burnFrom(msg.sender, _tokenAmount);\n\n withdrawYield(tokensOwed);\n IERC20(principalTokenAddress).safeTransfer(_yieldTo, tokensOwed);\n\n // Distribute rewards if there is a reward balance within contract\n if (userIncentiveAddress != address(0)) {\n IUserIncentive(userIncentiveAddress).claimReward(_tokenAmount, _yieldTo);\n }\n\n emit BurnedFToken(msg.sender, _tokenAmount, tokensOwed);\n\n return tokensOwed;\n }\n\n modifier onlyAuthorised() {\n require(msg.sender == flashProtocolAddress || msg.sender == address(this), \"NOT FLASH PROTOCOL\");\n _;\n }\n\n function getMaxStakeDuration() public pure override returns (uint256) {\n return 63072000; // Static 730 days (2 years)\n }\n\n function claimAAVEv2Rewards(address[] calldata _assets, uint256 _amount) external onlyOwner {\n IAaveIncentivesController(aaveIncentivesAddress).claimRewards(_assets, _amount, address(this));\n }\n\n function setUserIncentiveAddress(address _userIncentiveAddress) external onlyOwner {\n require(userIncentiveAddressLocked == false);\n userIncentiveAddress = _userIncentiveAddress;\n }\n\n function lockSetUserIncentiveAddress() external onlyOwner {\n require(userIncentiveAddressLocked == false);\n userIncentiveAddressLocked = true;\n }\n}\n"
},
"@openzeppelin/contracts/access/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n _;\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n"
},
"@openzeppelin/contracts/security/ReentrancyGuard.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n}\n"
},
"contracts/interfaces/AAVE/ILendingPool.sol": {
"content": "// SPDX-License-Identifier: agpl-3.0\npragma solidity ^0.8.4;\npragma experimental ABIEncoderV2;\n\nimport { ILendingPoolAddressesProvider } from \"./ILendingPoolAddressesProvider.sol\";\nimport { DataTypes } from \"./DataTypes.sol\";\n\ninterface ILendingPool {\n /**\n * @dev Emitted on deposit()\n * @param reserve The address of the underlying asset of the reserve\n * @param user The address initiating the deposit\n * @param onBehalfOf The beneficiary of the deposit, receiving the aTokens\n * @param amount The amount deposited\n * @param referral The referral code used\n **/\n event Deposit(\n address indexed reserve,\n address user,\n address indexed onBehalfOf,\n uint256 amount,\n uint16 indexed referral\n );\n\n /**\n * @dev Emitted on withdraw()\n * @param reserve The address of the underlyng asset being withdrawn\n * @param user The address initiating the withdrawal, owner of aTokens\n * @param to Address that will receive the underlying\n * @param amount The amount to be withdrawn\n **/\n event Withdraw(address indexed reserve, address indexed user, address indexed to, uint256 amount);\n\n /**\n * @dev Emitted on borrow() and flashLoan() when debt needs to be opened\n * @param reserve The address of the underlying asset being borrowed\n * @param user The address of the user initiating the borrow(), receiving the funds on borrow() or just\n * initiator of the transaction on flashLoan()\n * @param onBehalfOf The address that will be getting the debt\n * @param amount The amount borrowed out\n * @param borrowRateMode The rate mode: 1 for Stable, 2 for Variable\n * @param borrowRate The numeric rate at which the user has borrowed\n * @param referral The referral code used\n **/\n event Borrow(\n address indexed reserve,\n address user,\n address indexed onBehalfOf,\n uint256 amount,\n uint256 borrowRateMode,\n uint256 borrowRate,\n uint16 indexed referral\n );\n\n /**\n * @dev Emitted on repay()\n * @param reserve The address of the underlying asset of the reserve\n * @param user The beneficiary of the repayment, getting his debt reduced\n * @param repayer The address of the user initiating the repay(), providing the funds\n * @param amount The amount repaid\n **/\n event Repay(address indexed reserve, address indexed user, address indexed repayer, uint256 amount);\n\n /**\n * @dev Emitted on swapBorrowRateMode()\n * @param reserve The address of the underlying asset of the reserve\n * @param user The address of the user swapping his rate mode\n * @param rateMode The rate mode that the user wants to swap to\n **/\n event Swap(address indexed reserve, address indexed user, uint256 rateMode);\n\n /**\n * @dev Emitted on setUserUseReserveAsCollateral()\n * @param reserve The address of the underlying asset of the reserve\n * @param user The address of the user enabling the usage as collateral\n **/\n event ReserveUsedAsCollateralEnabled(address indexed reserve, address indexed user);\n\n /**\n * @dev Emitted on setUserUseReserveAsCollateral()\n * @param reserve The address of the underlying asset of the reserve\n * @param user The address of the user enabling the usage as collateral\n **/\n event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user);\n\n /**\n * @dev Emitted on rebalanceStableBorrowRate()\n * @param reserve The address of the underlying asset of the reserve\n * @param user The address of the user for which the rebalance has been executed\n **/\n event RebalanceStableBorrowRate(address indexed reserve, address indexed user);\n\n /**\n * @dev Emitted on flashLoan()\n * @param target The address of the flash loan receiver contract\n * @param initiator The address initiating the flash loan\n * @param asset The address of the asset being flash borrowed\n * @param amount The amount flash borrowed\n * @param premium The fee flash borrowed\n * @param referralCode The referral code used\n **/\n event FlashLoan(\n address indexed target,\n address indexed initiator,\n address indexed asset,\n uint256 amount,\n uint256 premium,\n uint16 referralCode\n );\n\n /**\n * @dev Emitted when the pause is triggered.\n */\n event Paused();\n\n /**\n * @dev Emitted when the pause is lifted.\n */\n event Unpaused();\n\n /**\n * @dev Emitted when a borrower is liquidated. This event is emitted by the LendingPool via\n * LendingPoolCollateral manager using a DELEGATECALL\n * This allows to have the events in the generated ABI for LendingPool.\n * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation\n * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation\n * @param user The address of the borrower getting liquidated\n * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover\n * @param liquidatedCollateralAmount The amount of collateral received by the liiquidator\n * @param liquidator The address of the liquidator\n * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants\n * to receive the underlying collateral asset directly\n **/\n event LiquidationCall(\n address indexed collateralAsset,\n address indexed debtAsset,\n address indexed user,\n uint256 debtToCover,\n uint256 liquidatedCollateralAmount,\n address liquidator,\n bool receiveAToken\n );\n\n /**\n * @dev Emitted when the state of a reserve is updated. NOTE: This event is actually declared\n * in the ReserveLogic library and emitted in the updateInterestRates() function. Since the function is internal,\n * the event will actually be fired by the LendingPool contract. The event is therefore replicated here so it\n * gets added to the LendingPool ABI\n * @param reserve The address of the underlying asset of the reserve\n * @param liquidityRate The new liquidity rate\n * @param stableBorrowRate The new stable borrow rate\n * @param variableBorrowRate The new variable borrow rate\n * @param liquidityIndex The new liquidity index\n * @param variableBorrowIndex The new variable borrow index\n **/\n event ReserveDataUpdated(\n address indexed reserve,\n uint256 liquidityRate,\n uint256 stableBorrowRate,\n uint256 variableBorrowRate,\n uint256 liquidityIndex,\n uint256 variableBorrowIndex\n );\n\n /**\n * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens.\n * - E.g. User deposits 100 USDC and gets in return 100 aUSDC\n * @param asset The address of the underlying asset to deposit\n * @param amount The amount to be deposited\n * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user\n * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens\n * is a different wallet\n * @param referralCode Code used to register the integrator originating the operation, for potential rewards.\n * 0 if the action is executed directly by the user, without any middle-man\n **/\n function deposit(\n address asset,\n uint256 amount,\n address onBehalfOf,\n uint16 referralCode\n ) external;\n\n /**\n * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned\n * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC\n * @param asset The address of the underlying asset to withdraw\n * @param amount The underlying amount to be withdrawn\n * - Send the value type(uint256).max in order to withdraw the whole aToken balance\n * @param to Address that will receive the underlying, same as msg.sender if the user\n * wants to receive it on his own wallet, or a different address if the beneficiary is a\n * different wallet\n * @return The final amount withdrawn\n **/\n function withdraw(\n address asset,\n uint256 amount,\n address to\n ) external returns (uint256);\n\n /**\n * @dev Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower\n * already deposited enough collateral, or he was given enough allowance by a credit delegator on the\n * corresponding debt token (StableDebtToken or VariableDebtToken)\n * - E.g. User borrows 100 USDC passing as `onBehalfOf` his own address, receiving the 100 USDC in his wallet\n * and 100 stable/variable debt tokens, depending on the `interestRateMode`\n * @param asset The address of the underlying asset to borrow\n * @param amount The amount to be borrowed\n * @param interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable\n * @param referralCode Code used to register the integrator originating the operation, for potential rewards.\n * 0 if the action is executed directly by the user, without any middle-man\n * @param onBehalfOf Address of the user who will receive the debt. Should be the address of the borrower itself\n * calling the function if he wants to borrow against his own collateral, or the address of the credit delegator\n * if he has been given credit delegation allowance\n **/\n function borrow(\n address asset,\n uint256 amount,\n uint256 interestRateMode,\n uint16 referralCode,\n address onBehalfOf\n ) external;\n\n /**\n * @notice Repays a borrowed `amount` on a specific reserve, burning the equivalent debt tokens owned\n * - E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the `onBehalfOf` address\n * @param asset The address of the borrowed underlying asset previously borrowed\n * @param amount The amount to repay\n * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode`\n * @param rateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable\n * @param onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the\n * user calling the function if he wants to reduce/remove his own debt, or the address of any other\n * other borrower whose debt should be removed\n * @return The final amount repaid\n **/\n function repay(\n address asset,\n uint256 amount,\n uint256 rateMode,\n address onBehalfOf\n ) external returns (uint256);\n\n /**\n * @dev Allows a borrower to swap his debt between stable and variable mode, or viceversa\n * @param asset The address of the underlying asset borrowed\n * @param rateMode The rate mode that the user wants to swap to\n **/\n function swapBorrowRateMode(address asset, uint256 rateMode) external;\n\n /**\n * @dev Rebalances the stable interest rate of a user to the current stable rate defined on the reserve.\n * - Users can be rebalanced if the following conditions are satisfied:\n * 1. Usage ratio is above 95%\n * 2. the current deposit APY is below REBALANCE_UP_THRESHOLD * maxVariableBorrowRate, which means that too much has been\n * borrowed at a stable rate and depositors are not earning enough\n * @param asset The address of the underlying asset borrowed\n * @param user The address of the user to be rebalanced\n **/\n function rebalanceStableBorrowRate(address asset, address user) external;\n\n /**\n * @dev Allows depositors to enable/disable a specific deposited asset as collateral\n * @param asset The address of the underlying asset deposited\n * @param useAsCollateral `true` if the user wants to use the deposit as collateral, `false` otherwise\n **/\n function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) external;\n\n /**\n * @dev Function to liquidate a non-healthy position collateral-wise, with Health Factor below 1\n * - The caller (liquidator) covers `debtToCover` amount of debt of the user getting liquidated, and receives\n * a proportionally amount of the `collateralAsset` plus a bonus to cover market risk\n * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation\n * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation\n * @param user The address of the borrower getting liquidated\n * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover\n * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants\n * to receive the underlying collateral asset directly\n **/\n function liquidationCall(\n address collateralAsset,\n address debtAsset,\n address user,\n uint256 debtToCover,\n bool receiveAToken\n ) external;\n\n /**\n * @dev Allows smartcontracts to access the liquidity of the pool within one transaction,\n * as long as the amount taken plus a fee is returned.\n * IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept into consideration.\n * For further details please visit https://developers.aave.com\n * @param receiverAddress The address of the contract receiving the funds, implementing the IFlashLoanReceiver interface\n * @param assets The addresses of the assets being flash-borrowed\n * @param amounts The amounts amounts being flash-borrowed\n * @param modes Types of the debt to open if the flash loan is not returned:\n * 0 -> Don't open any debt, just revert if funds can't be transferred from the receiver\n * 1 -> Open debt at stable rate for the value of the amount flash-borrowed to the `onBehalfOf` address\n * 2 -> Open debt at variable rate for the value of the amount flash-borrowed to the `onBehalfOf` address\n * @param onBehalfOf The address that will receive the debt in the case of using on `modes` 1 or 2\n * @param params Variadic packed params to pass to the receiver as extra information\n * @param referralCode Code used to register the integrator originating the operation, for potential rewards.\n * 0 if the action is executed directly by the user, without any middle-man\n **/\n function flashLoan(\n address receiverAddress,\n address[] calldata assets,\n uint256[] calldata amounts,\n uint256[] calldata modes,\n address onBehalfOf,\n bytes calldata params,\n uint16 referralCode\n ) external;\n\n /**\n * @dev Returns the user account data across all the reserves\n * @param user The address of the user\n * @return totalCollateralETH the total collateral in ETH of the user\n * @return totalDebtETH the total debt in ETH of the user\n * @return availableBorrowsETH the borrowing power left of the user\n * @return currentLiquidationThreshold the liquidation threshold of the user\n * @return ltv the loan to value of the user\n * @return healthFactor the current health factor of the user\n **/\n function getUserAccountData(address user)\n external\n view\n returns (\n uint256 totalCollateralETH,\n uint256 totalDebtETH,\n uint256 availableBorrowsETH,\n uint256 currentLiquidationThreshold,\n uint256 ltv,\n uint256 healthFactor\n );\n\n function initReserve(\n address reserve,\n address aTokenAddress,\n address stableDebtAddress,\n address variableDebtAddress,\n address interestRateStrategyAddress\n ) external;\n\n function setReserveInterestRateStrategyAddress(address reserve, address rateStrategyAddress) external;\n\n function setConfiguration(address reserve, uint256 configuration) external;\n\n /**\n * @dev Returns the configuration of the reserve\n * @param asset The address of the underlying asset of the reserve\n * @return The configuration of the reserve\n **/\n function getConfiguration(address asset) external view returns (DataTypes.ReserveConfigurationMap memory);\n\n /**\n * @dev Returns the configuration of the user across all the reserves\n * @param user The user address\n * @return The configuration of the user\n **/\n function getUserConfiguration(address user) external view returns (DataTypes.UserConfigurationMap memory);\n\n /**\n * @dev Returns the normalized income normalized income of the reserve\n * @param asset The address of the underlying asset of the reserve\n * @return The reserve's normalized income\n */\n function getReserveNormalizedIncome(address asset) external view returns (uint256);\n\n /**\n * @dev Returns the normalized variable debt per unit of asset\n * @param asset The address of the underlying asset of the reserve\n * @return The reserve normalized variable debt\n */\n function getReserveNormalizedVariableDebt(address asset) external view returns (uint256);\n\n /**\n * @dev Returns the state and configuration of the reserve\n * @param asset The address of the underlying asset of the reserve\n * @return The state of the reserve\n **/\n function getReserveData(address asset) external view returns (DataTypes.ReserveData memory);\n\n function finalizeTransfer(\n address asset,\n address from,\n address to,\n uint256 amount,\n uint256 balanceFromAfter,\n uint256 balanceToBefore\n ) external;\n\n function getReservesList() external view returns (address[] memory);\n\n function getAddressesProvider() external view returns (ILendingPoolAddressesProvider);\n\n function setPause(bool val) external;\n\n function paused() external view returns (bool);\n}\n"
},
"contracts/interfaces/AAVE/IAaveIncentivesController.sol": {
"content": "// SPDX-License-Identifier: agpl-3.0\npragma solidity ^0.8.4;\npragma experimental ABIEncoderV2;\n\ninterface IAaveIncentivesController {\n event RewardsAccrued(address indexed user, uint256 amount);\n\n event RewardsClaimed(address indexed user, address indexed to, uint256 amount);\n\n event RewardsClaimed(address indexed user, address indexed to, address indexed claimer, uint256 amount);\n\n event ClaimerSet(address indexed user, address indexed claimer);\n\n /*\n * @dev Returns the configuration of the distribution for a certain asset\n * @param asset The address of the reference asset of the distribution\n * @return The asset index, the emission per second and the last updated timestamp\n **/\n function getAssetData(address asset)\n external\n view\n returns (\n uint256,\n uint256,\n uint256\n );\n\n /*\n * LEGACY **************************\n * @dev Returns the configuration of the distribution for a certain asset\n * @param asset The address of the reference asset of the distribution\n * @return The asset index, the emission per second and the last updated timestamp\n **/\n function assets(address asset)\n external\n view\n returns (\n uint128,\n uint128,\n uint256\n );\n\n /**\n * @dev Whitelists an address to claim the rewards on behalf of another address\n * @param user The address of the user\n * @param claimer The address of the claimer\n */\n function setClaimer(address user, address claimer) external;\n\n /**\n * @dev Returns the whitelisted claimer for a certain address (0x0 if not set)\n * @param user The address of the user\n * @return The claimer address\n */\n function getClaimer(address user) external view returns (address);\n\n /**\n * @dev Configure assets for a certain rewards emission\n * @param assets The assets to incentivize\n * @param emissionsPerSecond The emission for each asset\n */\n function configureAssets(address[] calldata assets, uint256[] calldata emissionsPerSecond) external;\n\n /**\n * @dev Called by the corresponding asset on any update that affects the rewards distribution\n * @param asset The address of the user\n * @param userBalance The balance of the user of the asset in the lending pool\n * @param totalSupply The total supply of the asset in the lending pool\n **/\n function handleAction(\n address asset,\n uint256 userBalance,\n uint256 totalSupply\n ) external;\n\n /**\n * @dev Returns the total of rewards of an user, already accrued + not yet accrued\n * @param user The address of the user\n * @return The rewards\n **/\n function getRewardsBalance(address[] calldata assets, address user) external view returns (uint256);\n\n /**\n * @dev Claims reward for an user, on all the assets of the lending pool, accumulating the pending rewards\n * @param amount Amount of rewards to claim\n * @param to Address that will be receiving the rewards\n * @return Rewards claimed\n **/\n function claimRewards(\n address[] calldata assets,\n uint256 amount,\n address to\n ) external returns (uint256);\n\n /**\n * @dev Claims reward for an user on behalf, on all the assets of the lending pool, accumulating the pending rewards. The caller must\n * be whitelisted via \"allowClaimOnBehalf\" function by the RewardsAdmin role manager\n * @param amount Amount of rewards to claim\n * @param user Address to check and claim rewards\n * @param to Address that will be receiving the rewards\n * @return Rewards claimed\n **/\n function claimRewardsOnBehalf(\n address[] calldata assets,\n uint256 amount,\n address user,\n address to\n ) external returns (uint256);\n\n /**\n * @dev returns the unclaimed rewards of the user\n * @param user the address of the user\n * @return the unclaimed user rewards\n */\n function getUserUnclaimedRewards(address user) external view returns (uint256);\n\n /**\n * @dev returns the unclaimed rewards of the user\n * @param user the address of the user\n * @param asset The asset to incentivize\n * @return the user index for the asset\n */\n function getUserAssetData(address user, address asset) external view returns (uint256);\n\n /**\n * @dev for backward compatibility with previous implementation of the Incentives controller\n */\n function REWARD_TOKEN() external view returns (address);\n\n /**\n * @dev for backward compatibility with previous implementation of the Incentives controller\n */\n function PRECISION() external view returns (uint8);\n\n /**\n * @dev Gets the distribution end timestamp of the emissions\n */\n function DISTRIBUTION_END() external view returns (uint256);\n}\n"
},
"contracts/interfaces/IFlashStrategy.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface IFlashStrategy {\n event BurnedFToken(address indexed _address, uint256 _tokenAmount, uint256 _yieldReturned);\n\n // This is how principal will be deposited into the contract\n // The Flash protocol allows the strategy to specify how much\n // should be registered. This allows the strategy to manipulate (eg take fee)\n // on the principal if the strategy requires\n function depositPrincipal(uint256 _tokenAmount) external returns (uint256);\n\n // This is how principal will be returned from the contract\n function withdrawPrincipal(uint256 _tokenAmount) external;\n\n // Responsible for instant upfront yield. Takes fERC20 tokens specific to this\n // strategy. The strategy is responsible for returning some amount of principal tokens\n function burnFToken(\n uint256 _tokenAmount,\n uint256 _minimumReturned,\n address _yieldTo\n ) external returns (uint256);\n\n // This should return the current total of all principal within the contract\n function getPrincipalBalance() external view returns (uint256);\n\n // This should return the current total of all yield generated to date (including bootstrapped tokens)\n function getYieldBalance() external view returns (uint256);\n\n // This should return the principal token address (eg DAI)\n function getPrincipalAddress() external view returns (address);\n\n // View function which quotes how many principal tokens would be returned if x\n // fERC20 tokens are burned\n function quoteMintFToken(uint256 _tokenAmount, uint256 duration) external view returns (uint256);\n\n // View function which quotes how many principal tokens would be returned if x\n // fERC20 tokens are burned\n // IMPORTANT NOTE: This should utilise bootstrap tokens if they exist\n // bootstrapped tokens are any principal tokens that exist within the smart contract\n function quoteBurnFToken(uint256 _tokenAmount) external view returns (uint256);\n\n // The function to set the fERC20 address within the strategy\n function setFTokenAddress(address _fTokenAddress) external;\n\n // This should return what the maximum stake duration is\n function getMaxStakeDuration() external view returns (uint256);\n}\n"
},
"contracts/interfaces/IUserIncentive.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface IUserIncentive {\n event RewardClaimed(address _rewardToken, address indexed _address);\n\n // This will be called by the Strategy to claim rewards for the user\n // This should be permissioned such that only the Strategy address can call\n function claimReward(uint256 _fERC20Burned, address _yieldTo) external;\n\n // This is a view function to determine how many reward tokens will be paid out\n // providing ??? fERC20 tokens are burned\n function quoteReward(uint256 _fERC20Burned) external view returns (uint256);\n\n // Administrator: setting the reward ratio\n function setRewardRatio(uint256 _ratio) external;\n\n // Administrator: adding the reward tokens\n function addRewardTokens(uint256 _tokenAmount) external;\n\n // Administrator: depositing the reward tokens\n function depositReward(\n address _rewardTokenAddress,\n uint256 _tokenAmount,\n uint256 _ratio\n ) external;\n}\n"
},
"contracts/interfaces/IFlashFToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface IFlashFToken {\n function mint(address account, uint256 amount) external;\n\n function burnFrom(address from, uint256 amount) external;\n\n function decimals() external returns (uint8);\n}\n"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"
},
"contracts/interfaces/AAVE/ILendingPoolAddressesProvider.sol": {
"content": "// SPDX-License-Identifier: agpl-3.0\npragma solidity ^0.8.4;\n\n/**\n * @title LendingPoolAddressesProvider contract\n * @dev Main registry of addresses part of or connected to the protocol, including permissioned roles\n * - Acting also as factory of proxies and admin of those, so with right to change its implementations\n * - Owned by the Aave Governance\n * @author Aave\n **/\ninterface ILendingPoolAddressesProvider {\n event MarketIdSet(string newMarketId);\n event LendingPoolUpdated(address indexed newAddress);\n event ConfigurationAdminUpdated(address indexed newAddress);\n event EmergencyAdminUpdated(address indexed newAddress);\n event LendingPoolConfiguratorUpdated(address indexed newAddress);\n event LendingPoolCollateralManagerUpdated(address indexed newAddress);\n event PriceOracleUpdated(address indexed newAddress);\n event LendingRateOracleUpdated(address indexed newAddress);\n event ProxyCreated(bytes32 id, address indexed newAddress);\n event AddressSet(bytes32 id, address indexed newAddress, bool hasProxy);\n\n function getMarketId() external view returns (string memory);\n\n function setMarketId(string calldata marketId) external;\n\n function setAddress(bytes32 id, address newAddress) external;\n\n function setAddressAsProxy(bytes32 id, address impl) external;\n\n function getAddress(bytes32 id) external view returns (address);\n\n function getLendingPool() external view returns (address);\n\n function setLendingPoolImpl(address pool) external;\n\n function getLendingPoolConfigurator() external view returns (address);\n\n function setLendingPoolConfiguratorImpl(address configurator) external;\n\n function getLendingPoolCollateralManager() external view returns (address);\n\n function setLendingPoolCollateralManager(address manager) external;\n\n function getPoolAdmin() external view returns (address);\n\n function setPoolAdmin(address admin) external;\n\n function getEmergencyAdmin() external view returns (address);\n\n function setEmergencyAdmin(address admin) external;\n\n function getPriceOracle() external view returns (address);\n\n function setPriceOracle(address priceOracle) external;\n\n function getLendingRateOracle() external view returns (address);\n\n function setLendingRateOracle(address lendingRateOracle) external;\n}\n"
},
"contracts/interfaces/AAVE/DataTypes.sol": {
"content": "// SPDX-License-Identifier: agpl-3.0\npragma solidity ^0.8.4;\n\nlibrary DataTypes {\n // refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties.\n struct ReserveData {\n //stores the reserve configuration\n ReserveConfigurationMap configuration;\n //the liquidity index. Expressed in ray\n uint128 liquidityIndex;\n //variable borrow index. Expressed in ray\n uint128 variableBorrowIndex;\n //the current supply rate. Expressed in ray\n uint128 currentLiquidityRate;\n //the current variable borrow rate. Expressed in ray\n uint128 currentVariableBorrowRate;\n //the current stable borrow rate. Expressed in ray\n uint128 currentStableBorrowRate;\n uint40 lastUpdateTimestamp;\n //tokens addresses\n address aTokenAddress;\n address stableDebtTokenAddress;\n address variableDebtTokenAddress;\n //address of the interest rate strategy\n address interestRateStrategyAddress;\n //the id of the reserve. Represents the position in the list of the active reserves\n uint8 id;\n }\n\n struct ReserveConfigurationMap {\n //bit 0-15: LTV\n //bit 16-31: Liq. threshold\n //bit 32-47: Liq. bonus\n //bit 48-55: Decimals\n //bit 56: Reserve is active\n //bit 57: reserve is frozen\n //bit 58: borrowing is enabled\n //bit 59: stable rate borrowing enabled\n //bit 60-63: reserved\n //bit 64-79: reserve factor\n uint256 data;\n }\n\n struct UserConfigurationMap {\n uint256 data;\n }\n\n enum InterestRateMode {\n NONE,\n STABLE,\n VARIABLE\n }\n}\n"
}
},
"settings": {
"metadata": {
"bytecodeHash": "none"
},
"optimizer": {
"enabled": true,
"runs": 800
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}
}