2022-07-05 14:46:38 +00:00
|
|
|
//SPDX-License-Identifier: MIT
|
|
|
|
pragma solidity ^0.7.0;
|
|
|
|
pragma experimental ABIEncoderV2;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @title InstaAutomation
|
|
|
|
* @dev Insta-Aave-v3-Automation
|
|
|
|
*/
|
|
|
|
|
|
|
|
import "./events.sol";
|
|
|
|
import "./interfaces.sol";
|
|
|
|
|
|
|
|
abstract contract Resolver is Events {
|
|
|
|
InstaAaveAutomation internal immutable automation =
|
2022-08-03 12:22:02 +00:00
|
|
|
InstaAaveAutomation(0x3cF499Dbd2aBB6505f48Db27a9871523A38e6e2C);
|
2022-07-05 14:46:38 +00:00
|
|
|
|
|
|
|
function submitAutomationRequest(
|
|
|
|
uint256 safeHealthFactor,
|
|
|
|
uint256 thresholdHealthFactor
|
|
|
|
)
|
|
|
|
external
|
|
|
|
payable
|
|
|
|
returns (string memory _eventName, bytes memory _eventParam)
|
|
|
|
{
|
2022-07-23 09:47:27 +00:00
|
|
|
bool isAuth = AccountInterface(address(this)).isAuth(
|
|
|
|
address(automation)
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!isAuth)
|
|
|
|
AccountInterface(address(this)).enable(address(automation));
|
|
|
|
|
2022-07-05 14:46:38 +00:00
|
|
|
automation.submitAutomationRequest(
|
|
|
|
safeHealthFactor,
|
|
|
|
thresholdHealthFactor
|
|
|
|
);
|
|
|
|
|
|
|
|
(_eventName, _eventParam) = (
|
|
|
|
"LogSubmitAutomation(uint256,uint256)",
|
|
|
|
abi.encode(safeHealthFactor, thresholdHealthFactor)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function cancelAutomationRequest()
|
|
|
|
external
|
|
|
|
payable
|
|
|
|
returns (string memory _eventName, bytes memory _eventParam)
|
|
|
|
{
|
|
|
|
automation.cancelAutomationRequest();
|
2022-07-23 09:47:27 +00:00
|
|
|
|
|
|
|
bool isAuth = AccountInterface(address(this)).isAuth(
|
|
|
|
address(automation)
|
|
|
|
);
|
|
|
|
|
|
|
|
if (isAuth)
|
|
|
|
AccountInterface(address(this)).disable(address(automation));
|
|
|
|
|
2022-07-05 14:46:38 +00:00
|
|
|
(_eventName, _eventParam) = ("LogCancelAutomation()", "0x");
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateAutomationRequest(
|
|
|
|
uint256 safeHealthFactor,
|
|
|
|
uint256 thresholdHealthFactor
|
|
|
|
)
|
|
|
|
external
|
|
|
|
payable
|
|
|
|
returns (string memory _eventName, bytes memory _eventParam)
|
|
|
|
{
|
2022-07-22 12:38:53 +00:00
|
|
|
automation.cancelAutomationRequest();
|
|
|
|
|
|
|
|
automation.submitAutomationRequest(
|
|
|
|
safeHealthFactor,
|
|
|
|
thresholdHealthFactor
|
|
|
|
);
|
2022-07-05 14:46:38 +00:00
|
|
|
|
|
|
|
(_eventName, _eventParam) = (
|
|
|
|
"LogUpdateAutomation(uint256,uint256)",
|
|
|
|
abi.encode(safeHealthFactor, thresholdHealthFactor)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-30 17:40:44 +00:00
|
|
|
contract ConnectV2InstaAaveV3AutomationPolygon is Resolver {
|
2022-07-23 07:59:16 +00:00
|
|
|
string public constant name = "Insta-Aave-V3-Automation-v1";
|
2022-07-05 14:46:38 +00:00
|
|
|
}
|