mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
Merge pull request #208 from Instadapp/aave-v3-disable-collateral
Aave v3 disable collateral
This commit is contained in:
commit
e1821276fa
|
@ -29,6 +29,7 @@ contract Events {
|
|||
uint256 setId
|
||||
);
|
||||
event LogEnableCollateral(address[] tokens);
|
||||
event LogDisableCollateral(address[] tokens);
|
||||
event LogSwapRateMode(address indexed token, uint256 rateMode);
|
||||
event LogSetUserEMode(uint8 categoryId);
|
||||
}
|
||||
|
|
|
@ -251,6 +251,32 @@ abstract contract AaveResolver is Events, Helpers {
|
|||
_eventParam = abi.encode(tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Disable collateral
|
||||
* @notice Disable an array of tokens as collateral
|
||||
* @param tokens Array of tokens to disable as collateral
|
||||
*/
|
||||
function disableCollateral(address[] calldata tokens)
|
||||
external
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
uint256 _length = tokens.length;
|
||||
require(_length > 0, "0-tokens-not-allowed");
|
||||
|
||||
AaveInterface aave = AaveInterface(aaveProvider.getPool());
|
||||
|
||||
for (uint256 i = 0; i < _length; i++) {
|
||||
address token = tokens[i];
|
||||
if (getCollateralBalance(token) > 0 && getIsColl(token)) {
|
||||
aave.setUserUseReserveAsCollateral(token, false);
|
||||
}
|
||||
}
|
||||
|
||||
_eventName = "LogDisableCollateral(address[])";
|
||||
_eventParam = abi.encode(tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Swap borrow rate mode
|
||||
* @notice Swaps user borrow rate mode between variable and stable
|
||||
|
@ -293,5 +319,5 @@ abstract contract AaveResolver is Events, Helpers {
|
|||
}
|
||||
|
||||
contract ConnectV2AaveV3Arbitrum is AaveResolver {
|
||||
string public constant name = "AaveV3-v1.0";
|
||||
string public constant name = "AaveV3-v1.1";
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ contract Events {
|
|||
uint256 setId
|
||||
);
|
||||
event LogEnableCollateral(address[] tokens);
|
||||
event LogDisableCollateral(address[] tokens);
|
||||
event LogSwapRateMode(address indexed token, uint256 rateMode);
|
||||
event LogSetUserEMode(uint8 categoryId);
|
||||
}
|
||||
|
|
|
@ -251,6 +251,31 @@ abstract contract AaveResolver is Events, Helpers {
|
|||
_eventParam = abi.encode(tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Disable collateral
|
||||
* @notice Disable an array of tokens as collateral
|
||||
* @param tokens Array of tokens to disable as collateral
|
||||
*/
|
||||
function disableCollateral(address[] calldata tokens)
|
||||
external
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
uint256 _length = tokens.length;
|
||||
require(_length > 0, "0-tokens-not-allowed");
|
||||
|
||||
AaveInterface aave = AaveInterface(aaveProvider.getPool());
|
||||
|
||||
for (uint256 i = 0; i < _length; i++) {
|
||||
address token = tokens[i];
|
||||
if (getCollateralBalance(token) > 0 && getIsColl(token)) {
|
||||
aave.setUserUseReserveAsCollateral(token, false);
|
||||
}
|
||||
}
|
||||
|
||||
_eventName = "LogDisableCollateral(address[])";
|
||||
_eventParam = abi.encode(tokens);
|
||||
}
|
||||
/**
|
||||
* @dev Swap borrow rate mode
|
||||
* @notice Swaps user borrow rate mode between variable and stable
|
||||
|
@ -293,5 +318,5 @@ abstract contract AaveResolver is Events, Helpers {
|
|||
}
|
||||
|
||||
contract ConnectV2AaveV3Avalanche is AaveResolver {
|
||||
string public constant name = "AaveV3-v1.0";
|
||||
string public constant name = "AaveV3-v1.1";
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ contract Events {
|
|||
uint256 setId
|
||||
);
|
||||
event LogEnableCollateral(address[] tokens);
|
||||
event LogDisableCollateral(address[] tokens);
|
||||
event LogSwapRateMode(address indexed token, uint256 rateMode);
|
||||
event LogSetUserEMode(uint8 categoryId);
|
||||
}
|
||||
|
|
|
@ -251,6 +251,32 @@ abstract contract AaveResolver is Events, Helpers {
|
|||
_eventParam = abi.encode(tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Disable collateral
|
||||
* @notice Disable an array of tokens as collateral
|
||||
* @param tokens Array of tokens to disable as collateral
|
||||
*/
|
||||
function disableCollateral(address[] calldata tokens)
|
||||
external
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
uint256 _length = tokens.length;
|
||||
require(_length > 0, "0-tokens-not-allowed");
|
||||
|
||||
AaveInterface aave = AaveInterface(aaveProvider.getPool());
|
||||
|
||||
for (uint256 i = 0; i < _length; i++) {
|
||||
address token = tokens[i];
|
||||
if (getCollateralBalance(token) > 0 && getIsColl(token)) {
|
||||
aave.setUserUseReserveAsCollateral(token, false);
|
||||
}
|
||||
}
|
||||
|
||||
_eventName = "LogDisableCollateral(address[])";
|
||||
_eventParam = abi.encode(tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Swap borrow rate mode
|
||||
* @notice Swaps user borrow rate mode between variable and stable
|
||||
|
@ -293,5 +319,5 @@ abstract contract AaveResolver is Events, Helpers {
|
|||
}
|
||||
|
||||
contract ConnectV2AaveV3Fantom is AaveResolver {
|
||||
string public constant name = "AaveV3-v1";
|
||||
string public constant name = "AaveV3-v1.1";
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ contract Events {
|
|||
uint256 setId
|
||||
);
|
||||
event LogEnableCollateral(address[] tokens);
|
||||
event LogDisableCollateral(address[] tokens);
|
||||
event LogSwapRateMode(address indexed token, uint256 rateMode);
|
||||
event LogSetUserEMode(uint8 categoryId);
|
||||
}
|
||||
|
|
|
@ -251,6 +251,32 @@ abstract contract AaveResolver is Events, Helpers {
|
|||
_eventParam = abi.encode(tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Disable collateral
|
||||
* @notice Disable an array of tokens as collateral
|
||||
* @param tokens Array of tokens to disable as collateral
|
||||
*/
|
||||
function disableCollateral(address[] calldata tokens)
|
||||
external
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
uint256 _length = tokens.length;
|
||||
require(_length > 0, "0-tokens-not-allowed");
|
||||
|
||||
AaveInterface aave = AaveInterface(aaveProvider.getPool());
|
||||
|
||||
for (uint256 i = 0; i < _length; i++) {
|
||||
address token = tokens[i];
|
||||
if (getCollateralBalance(token) > 0 && getIsColl(token)) {
|
||||
aave.setUserUseReserveAsCollateral(token, false);
|
||||
}
|
||||
}
|
||||
|
||||
_eventName = "LogDisableCollateral(address[])";
|
||||
_eventParam = abi.encode(tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Swap borrow rate mode
|
||||
* @notice Swaps user borrow rate mode between variable and stable
|
||||
|
@ -293,5 +319,5 @@ abstract contract AaveResolver is Events, Helpers {
|
|||
}
|
||||
|
||||
contract ConnectV2AaveV3Optimism is AaveResolver {
|
||||
string public constant name = "AaveV3-v1.0";
|
||||
string public constant name = "AaveV3-v1.1";
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ contract Events {
|
|||
uint256 setId
|
||||
);
|
||||
event LogEnableCollateral(address[] tokens);
|
||||
event LogDisableCollateral(address[] tokens);
|
||||
event LogSwapRateMode(address indexed token, uint256 rateMode);
|
||||
event LogSetUserEMode(uint8 categoryId);
|
||||
}
|
||||
|
|
|
@ -251,6 +251,32 @@ abstract contract AaveResolver is Events, Helpers {
|
|||
_eventParam = abi.encode(tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Disable collateral
|
||||
* @notice Disable an array of tokens as collateral
|
||||
* @param tokens Array of tokens to disable as collateral
|
||||
*/
|
||||
function disableCollateral(address[] calldata tokens)
|
||||
external
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
uint256 _length = tokens.length;
|
||||
require(_length > 0, "0-tokens-not-allowed");
|
||||
|
||||
AaveInterface aave = AaveInterface(aaveProvider.getPool());
|
||||
|
||||
for (uint256 i = 0; i < _length; i++) {
|
||||
address token = tokens[i];
|
||||
if (getCollateralBalance(token) > 0 && getIsColl(token)) {
|
||||
aave.setUserUseReserveAsCollateral(token, false);
|
||||
}
|
||||
}
|
||||
|
||||
_eventName = "LogDisableCollateral(address[])";
|
||||
_eventParam = abi.encode(tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Swap borrow rate mode
|
||||
* @notice Swaps user borrow rate mode between variable and stable
|
||||
|
@ -294,5 +320,5 @@ abstract contract AaveResolver is Events, Helpers {
|
|||
}
|
||||
|
||||
contract ConnectV2AaveV3Polygon is AaveResolver {
|
||||
string public constant name = "AaveV3-v1.0";
|
||||
string public constant name = "AaveV3-v1.1";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user