Last active
August 9, 2022 07:57
-
-
Save prajwolrg/6692ba5ae61ecb6372fca6bb1ee10491 to your computer and use it in GitHub Desktop.
Redeem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity >=0.4.21 <0.7.0; | |
function redeem( | |
address _reserve, | |
address payable _user, | |
uint256 _amount | |
) external onlyActiveReserve(_reserve) onlyAmountGreaterThanZero(_amount) { | |
( | |
, | |
, | |
, | |
, | |
uint256 availableLiquidity, | |
, | |
, | |
, | |
address hTokenAddress, | |
) = dataProvider.getReserveData(_reserve); | |
require( | |
msg.sender == hTokenAddress, | |
"Only respective hToken can call this method" | |
); | |
require( | |
availableLiquidity >= _amount, | |
"Not enough liquidity in the reserve" | |
); | |
core.updateStateOnRedeem(_reserve, _amount); | |
core.transferToUser(_reserve, _user, _amount); | |
emit Redeem(_reserve, _user, _amount, block.timestamp); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment