Skip to content

Commit

Permalink
Merge pull request #318 from Instadapp/aave-v3
Browse files Browse the repository at this point in the history
Added disable collateral
  • Loading branch information
shriyatyagii authored Nov 28, 2023
2 parents 27c6080 + 77ab33a commit ad56081
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions contracts/mainnet/connectors/aave/v3/events.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
event LogDelegateBorrow(
Expand Down
29 changes: 28 additions & 1 deletion contracts/mainnet/connectors/aave/v3/main.sol
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,33 @@ 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++) {
bool isEth = tokens[i] == ethAddr;
address _token = isEth ? wethAddr : 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
Expand Down Expand Up @@ -490,5 +517,5 @@ abstract contract AaveResolver is Events, Helpers {
}

contract ConnectV2AaveV3 is AaveResolver {
string public constant name = "AaveV3-v1.0";
string public constant name = "AaveV3-v1.1";
}

0 comments on commit ad56081

Please sign in to comment.