Signed-off-by: pradyuman-verma <pradyumnverma27@gmail.com>
This commit is contained in:
pradyuman-verma 2022-07-23 15:17:27 +05:30
parent fb523149c8
commit b72f8891e5
No known key found for this signature in database
GPG Key ID: E36FD6BC8923221F
2 changed files with 23 additions and 0 deletions

View File

@ -15,3 +15,11 @@ interface InstaAaveAutomation {
uint256 thresholdHealthFactor
) external;
}
interface AccountInterface {
function enable(address) external;
function disable(address) external;
function isAuth(address) external view returns (bool);
}

View File

@ -22,6 +22,13 @@ abstract contract Resolver is Events {
payable
returns (string memory _eventName, bytes memory _eventParam)
{
bool isAuth = AccountInterface(address(this)).isAuth(
address(automation)
);
if (!isAuth)
AccountInterface(address(this)).enable(address(automation));
automation.submitAutomationRequest(
safeHealthFactor,
thresholdHealthFactor
@ -39,6 +46,14 @@ abstract contract Resolver is Events {
returns (string memory _eventName, bytes memory _eventParam)
{
automation.cancelAutomationRequest();
bool isAuth = AccountInterface(address(this)).isAuth(
address(automation)
);
if (isAuth)
AccountInterface(address(this)).disable(address(automation));
(_eventName, _eventParam) = ("LogCancelAutomation()", "0x");
}