diff --git a/contracts/mainnet/connectors/compound/v2/events.sol b/contracts/mainnet/connectors/compound/v2/events.sol index 0dec9ff4..b79d007d 100644 --- a/contracts/mainnet/connectors/compound/v2/events.sol +++ b/contracts/mainnet/connectors/compound/v2/events.sol @@ -60,13 +60,4 @@ contract Events { uint256 getId, uint256 setId ); - - event LogLiquidate( - address indexed borrower, - address indexed tokenToPay, - address indexed tokenInReturn, - uint256 tokenAmt, - uint256 getId, - uint256 setId - ); } diff --git a/contracts/mainnet/connectors/compound/v2/main.sol b/contracts/mainnet/connectors/compound/v2/main.sol index 377689e9..f605d06c 100644 --- a/contracts/mainnet/connectors/compound/v2/main.sol +++ b/contracts/mainnet/connectors/compound/v2/main.sol @@ -405,96 +405,6 @@ abstract contract CompoundConnector is Events, Helpers { (address token, address cToken) = compMapping.getMapping(tokenId); (_eventName, _eventParam) = withdrawCTokenRaw(token, cToken, cTokenAmt, getId, setId); } - - /** - * @dev Liquidate a position. - * @notice Liquidate a position. - * @param borrower Borrower's Address. - * @param tokenToPay The address of the token to pay for liquidation.(For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) - * @param cTokenPay Corresponding cToken address. - * @param tokenInReturn The address of the token to return for liquidation. - * @param cTokenColl Corresponding cToken address. - * @param amt The token amount to pay for liquidation. - * @param getId ID to retrieve amt. - * @param setId ID stores the amount of paid for liquidation. - */ - function liquidateRaw( - address borrower, - address tokenToPay, - address cTokenPay, - address tokenInReturn, - address cTokenColl, - uint256 amt, - uint256 getId, - uint256 setId - ) public payable returns (string memory _eventName, bytes memory _eventParam) { - uint _amt = getUint(getId, amt); - require(tokenToPay != address(0) && cTokenPay != address(0), "invalid token/ctoken address"); - require(tokenInReturn != address(0) && cTokenColl != address(0), "invalid token/ctoken address"); - - CTokenInterface cTokenContract = CTokenInterface(cTokenPay); - - { - (,, uint shortfal) = troller.getAccountLiquidity(borrower); - require(shortfal != 0, "account-cannot-be-liquidated"); - _amt = _amt == uint(-1) ? cTokenContract.borrowBalanceCurrent(borrower) : _amt; - } - - if (tokenToPay == ethAddr) { - require(address(this).balance >= _amt, "not-enought-eth"); - CETHInterface(cTokenPay).liquidateBorrow{value: _amt}(borrower, cTokenColl); - } else { - TokenInterface tokenContract = TokenInterface(tokenToPay); - require(tokenContract.balanceOf(address(this)) >= _amt, "not-enough-token"); - approve(tokenContract, cTokenPay, _amt); - require(cTokenContract.liquidateBorrow(borrower, _amt, cTokenColl) == 0, "liquidate-failed"); - } - - setUint(setId, _amt); - - _eventName = "LogLiquidate(address,address,address,uint256,uint256,uint256)"; - _eventParam = abi.encode( - address(this), - tokenToPay, - tokenInReturn, - _amt, - getId, - setId - ); - } - - /** - * @dev Liquidate a position using the mapping. - * @notice Liquidate a position using the mapping. - * @param borrower Borrower's Address. - * @param tokenIdToPay token id of the token to pay for liquidation.(For eg: ETH-A) - * @param tokenIdInReturn token id of the token to return for liquidation.(For eg: USDC-A) - * @param amt token amount to pay for liquidation. - * @param getId ID to retrieve amt. - * @param setId ID stores the amount of paid for liquidation. - */ - function liquidate( - address borrower, - string calldata tokenIdToPay, - string calldata tokenIdInReturn, - uint256 amt, - uint256 getId, - uint256 setId - ) external payable returns (string memory _eventName, bytes memory _eventParam) { - (address tokenToPay, address cTokenToPay) = compMapping.getMapping(tokenIdToPay); - (address tokenInReturn, address cTokenColl) = compMapping.getMapping(tokenIdInReturn); - - (_eventName, _eventParam) = liquidateRaw( - borrower, - tokenToPay, - cTokenToPay, - tokenInReturn, - cTokenColl, - amt, - getId, - setId - ); - } } contract ConnectV2Compound is CompoundConnector {