dsa-connectors/contracts/polygon/connectors/gelato/aave-services/protection/main.sol

80 lines
2.6 KiB
Solidity
Raw Normal View History

2021-08-18 19:30:56 +00:00
// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;
/**
* @title Aave Protection.
* @dev Protect DSA against Liquidation risk on Aave with Gelato.
*/
import {Events} from "./events.sol";
2021-08-18 19:30:56 +00:00
import {Helpers} from "./helpers.sol";
abstract contract GAaveProtectionResolver is Events, Helpers {
2021-08-18 19:30:56 +00:00
/// @dev Function for submitting a protection task
/// @param _wantedHealthFactor targeted health after protection.
/// @param _minimumHealthFactor trigger protection when current health
/// factor is below _minimumHealthFactor.
/// @param _isPermanent boolean to set a protection as permanent
function submitProtection(
uint256 _wantedHealthFactor,
uint256 _minimumHealthFactor,
bool _isPermanent
) external payable {
_submitProtection(
_wantedHealthFactor,
_minimumHealthFactor,
_isPermanent
);
emit LogSubmitProtection(
address(this),
_protectionAction,
_wantedHealthFactor,
_minimumHealthFactor,
_isPermanent
);
2021-08-18 19:30:56 +00:00
}
/// @dev Function for modifying a protection task
/// @param _wantedHealthFactor targeted health after protection.
/// @param _minimumHealthFactor trigger protection when current health
/// factor is below _minimumHealthFactor.
/// @param _isPermanent boolean to set a protection as permanent
function updateProtection(
uint256 _wantedHealthFactor,
uint256 _minimumHealthFactor,
bool _isPermanent
) external payable {
_updateProtection(
_wantedHealthFactor,
_minimumHealthFactor,
_isPermanent
);
emit LogUpdateProtection(
address(this),
_protectionAction,
_wantedHealthFactor,
_minimumHealthFactor,
_isPermanent
);
2021-08-18 19:30:56 +00:00
}
/// @dev Function for cancelling a protection task
function cancelProtection() external payable {
_cancelProtection();
emit LogCancelProtection(address(this), _protectionAction);
2021-08-18 19:30:56 +00:00
}
/// @dev Function for cancelling and removing allowance
/// of aToken to _protectionAction
function cancelAndRevoke() external payable {
2021-08-21 11:11:21 +00:00
if (_dsaHasProtection()) _cancelProtection();
_revokeAllowance();
2021-08-21 11:11:21 +00:00
emit LogCancelAndRevoke(address(this), _protectionAction);
2021-08-18 19:30:56 +00:00
}
}
contract GAaveProtectionPolygonConnector is GAaveProtectionResolver {
// solhint-disable-next-line const-name-snakecase
string public constant name = "GelatoAaveProtectionPolygonConnector-v1";
}