AavePM
Inherits: IAavePM, FunctionChecks, FlashLoan, Initializable, AccessControlEnumerableUpgradeable, UUPSUpgradeable
Author: EridianAlpha
A contract to manage positions on Aave.
State Variables
s_creator
address internal s_creator;
s_contractAddresses
mapping(string => address) internal s_contractAddresses;
s_tokenAddresses
mapping(string => address) internal s_tokenAddresses;
s_uniswapV3Pools
mapping(string => UniswapV3Pool) internal s_uniswapV3Pools;
s_healthFactorTarget
uint16 internal s_healthFactorTarget;
s_slippageTolerance
uint16 internal s_slippageTolerance;
s_withdrawnUSDCTotal
uint256 internal s_withdrawnUSDCTotal = 0;
s_reinvestedDebtTotal
uint256 internal s_reinvestedDebtTotal = 0;
s_suppliedCollateralTotal
uint256 internal s_suppliedCollateralTotal = 0;
s_eventBlockNumbers
uint64[] internal s_eventBlockNumbers;
s_managerDailyInvocationLimit
uint16 internal s_managerDailyInvocationLimit;
s_managerInvocationTimestamps
uint64[] internal s_managerInvocationTimestamps;
VERSION
The version of the contract.
Contract is upgradeable so the version is a constant set on each implementation contract.
string internal constant VERSION = "0.0.1";
OWNER_ROLE
The role hashes for the contract.
Two independent roles are defined: OWNER_ROLE and MANAGER_ROLE.
bytes32 internal constant OWNER_ROLE = keccak256("OWNER_ROLE");
MANAGER_ROLE
bytes32 internal constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
HEALTH_FACTOR_TARGET_MINIMUM
The minimum Health Factor target.
The value is hardcoded in the contract to prevent the position from being liquidated cause by accidentally setting a low target. A contract upgrade is required to change this value.
uint16 internal constant HEALTH_FACTOR_TARGET_MINIMUM = 200;
SLIPPAGE_TOLERANCE_MAXIMUM
The maximum Slippage Tolerance.
The value is hardcoded in the contract to prevent terrible trades from occurring due to a high slippage tolerance. A contract upgrade is required to change this value.
uint16 internal constant SLIPPAGE_TOLERANCE_MAXIMUM = 100;
Functions
checkOwner
Modifier to check if the caller is the owner.
The function checks if the caller has the OWNER_ROLE.
modifier checkOwner(address _owner);
Parameters
| Name | Type | Description |
|---|---|---|
_owner | address | The address to check if it has the OWNER_ROLE. |
checkManagerInvocationLimit
Function to check the manager invocation limit.
The function checks if the manager has exceeded the daily invocation limit and updates the timestamp array.
function checkManagerInvocationLimit() internal;
constructor
Constructor implemented but unused.
Contract is upgradeable and therefore the constructor is not used.
constructor();
receive
Function to receive ETH when no function matches the call data.
receive() external payable;
fallback
Fallback function to revert calls to functions that do not exist when the msg.data is empty.
fallback() external payable;
initialize
Initializes contract with the owner and relevant addresses and parameters for operation.
This function sets up all necessary state variables for the contract and can only be called once due to the initializer modifier.
function initialize(
address owner,
ContractAddress[] memory contractAddresses,
TokenAddress[] memory tokenAddresses,
UniswapV3Pool[] memory uniswapV3Pools,
uint16 initialHealthFactorTarget,
uint16 initialSlippageTolerance,
uint16 initialManagerDailyInvocationLimit
) public initializer;
Parameters
| Name | Type | Description |
|---|---|---|
owner | address | The address of the owner of the contract. |
contractAddresses | ContractAddress[] | An array of ContractAddress structures containing addresses of related contracts. |
tokenAddresses | TokenAddress[] | An array of TokenAddress structures containing addresses of relevant ERC-20 tokens. |
uniswapV3Pools | UniswapV3Pool[] | An array of UniswapV3Pool structures containing the address and fee of the UniswapV3 pools. |
initialHealthFactorTarget | uint16 | The initial target health factor, used to manage risk. |
initialSlippageTolerance | uint16 | The initial slippage tolerance for token swaps. |
initialManagerDailyInvocationLimit | uint16 |
_initializeState
Internal function to initialize the state of the contract.
This function sets up all necessary state variables for the contract.
function _initializeState(
address owner,
ContractAddress[] memory contractAddresses,
TokenAddress[] memory tokenAddresses,
UniswapV3Pool[] memory uniswapV3Pools,
uint16 initialHealthFactorTarget,
uint16 initialSlippageTolerance,
uint16 initialManagerDailyInvocationLimit
) internal;
Parameters
| Name | Type | Description |
|---|---|---|
owner | address | The initial address of the owner of the contract. |
contractAddresses | ContractAddress[] | An array of ContractAddress structures containing addresses of related contracts. |
tokenAddresses | TokenAddress[] | An array of TokenAddress structures containing addresses of relevant ERC-20 tokens. |
uniswapV3Pools | UniswapV3Pool[] | An array of UniswapV3Pool structures containing the address and fee of the UniswapV3 pools. |
initialHealthFactorTarget | uint16 | The initial target health factor, used to manage risk. |
initialSlippageTolerance | uint16 | The initial slippage tolerance for token swaps. |
initialManagerDailyInvocationLimit | uint16 | The initial limit for the number of manager invocations per day. |
updateContractAddress
Generic update function to set the contract address for a given identifier.
Caller must have OWNER_ROLE.
Emits a ContractAddressUpdated event.
function updateContractAddress(string memory _identifier, address _newContractAddress) external onlyRole(OWNER_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
_identifier | string | The identifier for the contract address. |
_newContractAddress | address | The new contract address. |
updateTokenAddress
Generic update function to set the token address for a given identifier.
Caller must have OWNER_ROLE.
Emits a TokenAddressUpdated event.
function updateTokenAddress(string memory _identifier, address _newTokenAddress) external onlyRole(OWNER_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
_identifier | string | The identifier for the token address. |
_newTokenAddress | address | The new token address. |
updateUniswapV3Pool
Update UniSwapV3 pool details.
Caller must have OWNER_ROLE.
Emits a UniswapV3PoolUpdated event.
function updateUniswapV3Pool(string memory _identifier, address _newUniswapV3PoolAddress, uint24 _newUniswapV3PoolFee)
external
onlyRole(OWNER_ROLE);
updateHealthFactorTarget
Update the Health Factor target.
Caller must have MANAGER_ROLE.
Emits a HealthFactorTargetUpdated event.
function updateHealthFactorTarget(uint16 _healthFactorTarget) external onlyRole(MANAGER_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
_healthFactorTarget | uint16 | The new Health Factor target. |
updateSlippageTolerance
Update the Slippage Tolerance.
Caller must have MANAGER_ROLE.
Emits a SlippageToleranceUpdated event.
function updateSlippageTolerance(uint16 _slippageTolerance) external onlyRole(MANAGER_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
_slippageTolerance | uint16 | The new Slippage Tolerance. |
updateManagerDailyInvocationLimit
Update the Manager Daily Invocation Limit.
Caller must have OWNER_ROLE.
Emits a ManagerDailyInvocationLimitUpdated event.
function updateManagerDailyInvocationLimit(uint16 _managerDailyInvocationLimit) external onlyRole(OWNER_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
_managerDailyInvocationLimit | uint16 | The new Manager Daily Invocation Limit. |
_storeEventBlockNumber
Stores the block number of an event.
This function is called after an event is emitted to store the block number. Duplicates are not stored even if multiple events are emitted in the same block.
function _storeEventBlockNumber() private;
rebalance
Rebalance the Aave position.
The function rebalances the Aave position by converting any ETH to WETH, then WETH to wstETH.
It then deposits the wstETH into Aave.
If the health factor is below the target, it repays debt to increase the health factor.
Caller must have MANAGER_ROLE.
Emits a Rebalanced event.
function rebalance() public onlyRole(MANAGER_ROLE) returns (uint256 repaymentAmountUSDC);
Returns
| Name | Type | Description |
|---|---|---|
repaymentAmountUSDC | uint256 | The amount of debt repaid. |
reinvest
Reinvest any excess debt or collateral.
The function reinvests any excess collateral by converting any ETH to WETH, then WETH to wstETH.
It then deposits the wstETH into Aave.
If the health factor is below the target, outside of the allowed range, this function will fail.
Caller must have MANAGER_ROLE.
Emits a Reinvested event.
function reinvest() public payable onlyRole(MANAGER_ROLE) returns (uint256 reinvestedDebt);
Returns
| Name | Type | Description |
|---|---|---|
reinvestedDebt | uint256 | The amount of debt reinvested. |
deleverage
Deleverage the position by repaying all debt.
The function deleverages the position by taking out a flashloan to repay all debt
after setting the Health Factor target to the maximum value.
Caller must have MANAGER_ROLE.
Emits a Deleveraged event.
function deleverage() public onlyRole(MANAGER_ROLE);
aaveSupplyFromContractBalance
Convert any tokens in the contract to wstETH and supply to Aave.
The function converts any tokens in the contract to wstETH and supplies them to Aave.
Caller must have MANAGER_ROLE.
Emits a AaveSuppliedFromContractBalance event.
function aaveSupplyFromContractBalance() public payable onlyRole(MANAGER_ROLE) returns (uint256 suppliedCollateral);
Returns
| Name | Type | Description |
|---|---|---|
suppliedCollateral | uint256 | The amount of collateral supplied to Aave. |
aaveRepayUSDCFromContractBalance
Repay USDC debt from the contract balance.
The function repays USDC debt using all the USDC in the contract.
Caller must have MANAGER_ROLE.
Emits a AaveRepayedUSDCFromContractBalance event.
function aaveRepayUSDCFromContractBalance() public onlyRole(MANAGER_ROLE);
_delegateCallHelper
Delegate call helper function.
The internal function is used to delegate calls to other contracts.
function _delegateCallHelper(string memory _targetIdentifier, bytes memory _data) internal returns (bytes memory);
Parameters
| Name | Type | Description |
|---|---|---|
_targetIdentifier | string | The identifier of the target contract. |
_data | bytes | The data to send to the target contract. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes | result The result of the delegate call. |
delegateCallHelper
Delegate call helper function for the manager to call any function.
The public function is used to delegate calls to other contracts.
Caller must have MANAGER_ROLE.
As the manager can only use identifiers already set in the contract,
it cannot call a contract that is not set (e.g. a malicious contract).
function delegateCallHelper(string memory _targetIdentifier, bytes memory _data)
public
onlyRole(MANAGER_ROLE)
returns (bytes memory result);
Parameters
| Name | Type | Description |
|---|---|---|
_targetIdentifier | string | The identifier of the target contract. |
_data | bytes | The data to send to the target contract. |
Returns
| Name | Type | Description |
|---|---|---|
result | bytes | The result of the delegate call. |
rescueEth
Rescue all ETH from the contract.
This function is intended for emergency use.
In normal operation, the contract shouldn't hold ETH,
as it is used to swap for wstETH.
It is called without an argument to rescue the entire balance.
Caller must have MANAGER_ROLE.
The use of nonReentrant isn't required due to the rescueAddress check for the OWNER_ROLE
and it drains 100% of the ETH balance anyway.
Throws AavePM__RescueEthFailed if the ETH transfer fails.
Emits a RescueEth event.
function rescueEth(address _rescueAddress) external onlyRole(MANAGER_ROLE) checkOwner(_rescueAddress);
Parameters
| Name | Type | Description |
|---|---|---|
_rescueAddress | address | The address to send the rescued ETH to. |
withdrawTokensFromContractBalance
Withdraw specified tokens from the contract balance.
The function withdraws the specified tokens from the contract balance to the owner.
Caller must have MANAGER_ROLE.
Throws AavePM__InvalidWithdrawalToken if the token is awstETH.
Throws AavePM__NoTokensToWithdraw if there are no tokens to withdraw.
Emits a TokensWithdrawnFromContractBalance event.
function withdrawTokensFromContractBalance(string memory _identifier, address _owner)
public
onlyRole(MANAGER_ROLE)
checkOwner(_owner);
Parameters
| Name | Type | Description |
|---|---|---|
_identifier | string | The identifier of the token to withdraw. |
_owner | address | The address to send the withdrawn tokens to. |
aaveWithdrawWstETH
Withdraw wstETH from Aave.
The function withdraws wstETH from Aave and sends it to the specified owner.
Caller must have MANAGER_ROLE.
Throws AavePM__NoCollateralToWithdraw if there is no collateral to withdraw.
Emits a AaveWithdrawnWstETH event.
function aaveWithdrawWstETH(uint256 _amount, address _owner)
public
onlyRole(MANAGER_ROLE)
checkOwner(_owner)
returns (uint256 collateralDeltaBase);
Parameters
| Name | Type | Description |
|---|---|---|
_amount | uint256 | The amount of wstETH to withdraw in wstETH units. |
_owner | address | The address to send the withdrawn wstETH to. |
Returns
| Name | Type | Description |
|---|---|---|
collateralDeltaBase | uint256 | The change in collateral base value after withdrawing. |
aaveBorrowAndWithdrawUSDC
Borrow and withdraw USDC from Aave.
The function borrows USDC from Aave and withdraws it to the specified owner.
Caller must have MANAGER_ROLE.
Throws AavePM__ZeroBorrowAmount if the requested borrow amount is 0.
Throws AavePM__ZeroBorrowAndWithdrawUSDCAvailable if the available borrow and withdraw amount is 0.
Emits a AaveBorrowedAndWithdrawnUSDC event.
function aaveBorrowAndWithdrawUSDC(uint256 _amount, address _owner) public onlyRole(MANAGER_ROLE) checkOwner(_owner);
Parameters
| Name | Type | Description |
|---|---|---|
_amount | uint256 | The amount of USDC to borrow and withdraw. |
_owner | address | The address to send the borrowed and withdrawn USDC to. |
aaveClosePosition
Close the Aave position.
The function closes the Aave position by repaying all debt and withdrawing all wstETH to the specified owner.
Caller must have MANAGER_ROLE.
Emits a AaveClosedPosition event.
function aaveClosePosition(address _owner) public onlyRole(MANAGER_ROLE) checkOwner(_owner);
Parameters
| Name | Type | Description |
|---|---|---|
_owner | address | The address to send the withdrawn wstETH to. |
getCreator
Getter function to get the i_creator address.
Public function to allow anyone to view the contract creator.
function getCreator() public view returns (address creator);
Returns
| Name | Type | Description |
|---|---|---|
creator | address | The address of the creator. |
getEventBlockNumbers
Getter function to get the block numbers of all the contract events.
Public function to allow anyone to view the block numbers of all the contract events.
function getEventBlockNumbers() public view returns (uint64[] memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint64[] | eventBlockNumbers The array of event block numbers. |
getVersion
Getter function to get the contract version.
Public function to allow anyone to view the contract version.
function getVersion() public pure returns (string memory version);
Returns
| Name | Type | Description |
|---|---|---|
version | string | The contract version. |
getContractAddress
Generic getter function to get the contract address for a given identifier.
Public function to allow anyone to view the contract address for the given identifier.
function getContractAddress(string memory _identifier) public view returns (address contractAddress);
Parameters
| Name | Type | Description |
|---|---|---|
_identifier | string | The identifier for the contract address. |
Returns
| Name | Type | Description |
|---|---|---|
contractAddress | address | The contract address corresponding to the given identifier. |
getTokenAddress
Generic getter function to get the token address for a given identifier.
Public function to allow anyone to view the token address for the given identifier.
function getTokenAddress(string memory _identifier) public view returns (address tokenAddress);
Parameters
| Name | Type | Description |
|---|---|---|
_identifier | string | The identifier for the contract address. |
Returns
| Name | Type | Description |
|---|---|---|
tokenAddress | address | The token address corresponding to the given identifier. |
getUniswapV3Pool
Getter function to get the UniswapV3 pool address and fee.
Public function to allow anyone to view the UniswapV3 pool address and fee.
function getUniswapV3Pool(string memory _identifier)
public
view
returns (address uniswapV3PoolAddress, uint24 uniswapV3PoolFee);
Parameters
| Name | Type | Description |
|---|---|---|
_identifier | string | The identifier for the UniswapV3 pool. |
Returns
| Name | Type | Description |
|---|---|---|
uniswapV3PoolAddress | address | The UniswapV3 pool address. |
uniswapV3PoolFee | uint24 | The UniswapV3 pool fee. |
getHealthFactorTarget
Getter function to get the Health Factor target.
Public function to allow anyone to view the Health Factor target value.
function getHealthFactorTarget() public view returns (uint16 healthFactorTarget);
Returns
| Name | Type | Description |
|---|---|---|
healthFactorTarget | uint16 | The Health Factor target. |
getHealthFactorTargetMinimum
Getter function to get the Health Factor Target minimum.
Public function to allow anyone to view the Health Factor Target minimum value.
function getHealthFactorTargetMinimum() public pure returns (uint16 healthFactorTargetMinimum);
Returns
| Name | Type | Description |
|---|---|---|
healthFactorTargetMinimum | uint16 | The Health Factor Target minimum value. |
getSlippageTolerance
Getter function to get the Slippage Tolerance.
Public function to allow anyone to view the Slippage Tolerance value.
function getSlippageTolerance() public view returns (uint16 slippageTolerance);
Returns
| Name | Type | Description |
|---|---|---|
slippageTolerance | uint16 | The Slippage Tolerance value. |
getSlippageToleranceMaximum
Getter function to get the Slippage Tolerance maximum.
Public function to allow anyone to view the Slippage Tolerance maximum value.
function getSlippageToleranceMaximum() public pure returns (uint16 slippageToleranceMaximum);
Returns
| Name | Type | Description |
|---|---|---|
slippageToleranceMaximum | uint16 | The Slippage Tolerance maximum value. |
getManagerDailyInvocationLimit
Getter function to get the manager role daily invocation limit.
Public function to allow anyone to view the manager role daily invocation limit.
function getManagerDailyInvocationLimit() public view returns (uint16 managerDailyInvocationLimit);
Returns
| Name | Type | Description |
|---|---|---|
managerDailyInvocationLimit | uint16 | The manager role daily invocation limit. |
getManagerInvocationTimestamps
Getter function to get the manager invocation timestamps.
Public function to allow anyone to view the manager invocation timestamps.
function getManagerInvocationTimestamps() public view returns (uint64[] memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint64[] | managerInvocationTimestamps The array of manager invocation timestamps. |
getContractBalance
Getter function to get the balance of the provided identifier.
Public function to allow anyone to view the balance of the provided identifier.
function getContractBalance(string memory _identifier) public view returns (uint256 contractBalance);
Parameters
| Name | Type | Description |
|---|---|---|
_identifier | string | The identifier for the token address. |
Returns
| Name | Type | Description |
|---|---|---|
contractBalance | uint256 | The balance of the specified token identifier. |
getRoleMembers
Getter function to get all the members of a role.
Public function to allow anyone to view the members of a role.
function getRoleMembers(string memory _roleString) public view returns (address[] memory);
Parameters
| Name | Type | Description |
|---|---|---|
_roleString | string | The identifier for the role. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address[] | members The array of addresses that are members of the role. |
getWithdrawnUSDCTotal
Getter function to get the total amount of USDC withdrawn.
Public function to allow anyone to view the total amount of USDC withdrawn.
function getWithdrawnUSDCTotal() public view returns (uint256 withdrawnUSDCTotal);
Returns
| Name | Type | Description |
|---|---|---|
withdrawnUSDCTotal | uint256 | The total amount of USDC withdrawn. |
getReinvestedDebtTotal
Getter function to get the total amount of reinvested debt.
Public function to allow anyone to view the total amount of reinvested debt.
function getReinvestedDebtTotal() public view returns (uint256 reinvestedDebtTotal);
Returns
| Name | Type | Description |
|---|---|---|
reinvestedDebtTotal | uint256 | The total amount of reinvested debt. |
getTotalCollateralDelta
Getter function to get the total collateral delta.
Public function to allow anyone to view the total collateral delta.
function getTotalCollateralDelta() public returns (uint256 totalCollateralDelta, bool isPositive);
Returns
| Name | Type | Description |
|---|---|---|
totalCollateralDelta | uint256 | The total collateral delta. |
isPositive | bool | A boolean indicating if the total collateral delta is positive. |
getSuppliedCollateralTotal
Getter function to get the total amount of supplied collateral.
Public function to allow anyone to view the total amount of supplied collateral.
function getSuppliedCollateralTotal() public view returns (uint256 suppliedCollateralTotal);
Returns
| Name | Type | Description |
|---|---|---|
suppliedCollateralTotal | uint256 | The total amount of supplied collateral. |
getMaxBorrowAndWithdrawUSDCAmount
Getter function to get the maximum amount of USDC that can be borrowed and withdrawn.
Public function to allow anyone to view the maximum amount of USDC that can be borrowed and withdrawn.
function getMaxBorrowAndWithdrawUSDCAmount() public view returns (uint256 maxBorrowAndWithdrawUSDCAmount);
Returns
| Name | Type | Description |
|---|---|---|
maxBorrowAndWithdrawUSDCAmount | uint256 | The maximum amount of USDC that can be borrowed and withdrawn. |
getReinvestableAmount
Getter function to get the reinvestable amount.
Public function to allow anyone to view the reinvestable amount.
function getReinvestableAmount() public returns (uint256 reinvestableAmount);
Returns
| Name | Type | Description |
|---|---|---|
reinvestableAmount | uint256 | The reinvestable amount. |
getRoleMember
Getter function to get the role member at the specified index.
Public function to allow anyone to view the role member at the specified index.
function getRoleMember(bytes32 role, uint256 index)
public
view
override(IAavePM, AccessControlEnumerableUpgradeable)
returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
role | bytes32 | The role to get the member from in a bytes32 format keccak256("ROLE_NAME"). |
index | uint256 | The index of the member. |
getRoleMemberCount
Getter function to get the number of members in a role.
Public function to allow anyone to view the number of members in a role.
function getRoleMemberCount(bytes32 role)
public
view
override(IAavePM, AccessControlEnumerableUpgradeable)
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
role | bytes32 | The role to get the member count from in a bytes32 format keccak256("ROLE_NAME"). |
getRoleAdmin
Getter function to get the role admin role.
Public function to allow anyone to view the role admin role.
function getRoleAdmin(bytes32 role)
public
view
override(IAavePM, IAccessControl, AccessControlUpgradeable)
returns (bytes32);
Parameters
| Name | Type | Description |
|---|---|---|
role | bytes32 | The role to get the admin role from in a bytes32 format keccak256("ROLE_NAME"). |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes32 | The role admin role. |
grantRole
Grant a role to an account.
Caller must be an admin for the role.
function grantRole(bytes32 role, address account) public override(IAavePM, IAccessControl, AccessControlUpgradeable);
Parameters
| Name | Type | Description |
|---|---|---|
role | bytes32 | The role to grant in a bytes32 format keccak256("ROLE_NAME"). |
account | address | The account to grant the role to. |
hasRole
Check if an account has a role.
Public function to allow anyone to check if an account has a role.
function hasRole(bytes32 role, address account)
public
view
override(IAavePM, IAccessControl, AccessControlUpgradeable)
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
role | bytes32 | The role to check in a bytes32 format keccak256("ROLE_NAME"). |
account | address | The account to check if they have the role. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the account has the role, otherwise false. |
renounceRole
Renounce a role from an account.
Caller must have the role.
function renounceRole(bytes32 role, address callerConfirmation)
public
override(IAavePM, IAccessControl, AccessControlUpgradeable);
Parameters
| Name | Type | Description |
|---|---|---|
role | bytes32 | The role to renounce in a bytes32 format keccak256("ROLE_NAME"). |
callerConfirmation | address | The account to renounce the role from. |
revokeRole
Revoke a role from an account.
Caller must be an admin for the role.
function revokeRole(bytes32 role, address account) public override(IAavePM, IAccessControl, AccessControlUpgradeable);
Parameters
| Name | Type | Description |
|---|---|---|
role | bytes32 | The role to revoke in a bytes32 format keccak256("ROLE_NAME"). |
account | address | The account to revoke the role from. |
supportsInterface
Supports interface.
Public function to allow anyone to check if the contract supports the interface.
function supportsInterface(bytes4 interfaceId)
public
view
override(IAavePM, AccessControlEnumerableUpgradeable)
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 | The interface ID to check. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the contract supports the interface, otherwise false. |
_authorizeUpgrade
Internal function to authorize an upgrade.
Caller must have OWNER_ROLE.
function _authorizeUpgrade(address _newImplementation) internal override onlyRole(OWNER_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
_newImplementation | address | Address of the new contract implementation. |
upgradeToAndCall
Upgrade the contract to a new implementation.
Caller must have OWNER_ROLE.
function upgradeToAndCall(address newImplementation, bytes memory data)
public
payable
override(IAavePM, UUPSUpgradeable);
Parameters
| Name | Type | Description |
|---|---|---|
newImplementation | address | Address of the new contract implementation. |
data | bytes | Data to send to the new implementation. |
executeOperation
Flash loan callback function.
This function is called by the Aave pool contract after the flash loan is executed. It is used to repay the flash loan and execute the operation. The function is called by the Aave pool contract and is not intended to be called directly.
function executeOperation(address asset, uint256 amount, uint256 premium, address initiator, bytes calldata params)
external
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
asset | address | The address of the asset being flash loaned. |
amount | uint256 | The amount of the asset being flash loaned. |
premium | uint256 | The fee charged for the flash loan. |
initiator | address | The address of the contract that initiated the flash loan. |
params | bytes | The parameters for the flash loan operation. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | bool True if the operation was successful. |