Created
July 27, 2020 15:11
-
-
Save rahuldamodar94/bb553ad8d379ed4a1a7f0d2d7cddee9d to your computer and use it in GitHub Desktop.
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.5.0 <0.6.0; | |
import "../contracts-package/IERC20.sol"; | |
import "./ERC20Predicate.sol"; | |
contract MintableERC20Predicate is ERC20Predicate { | |
constructor( | |
address _withdrawManager, | |
address _depositManager, | |
address _registry | |
) public ERC20Predicate(_withdrawManager, _depositManager, _registry) {} | |
function onFinalizeExit(bytes calldata data) external onlyWithdrawManager { | |
( | |
, | |
address token, | |
address exitor, | |
uint256 amount | |
) = decodeExitForProcessExit(data); | |
uint256 toTransfer = IERC20(token).balanceOf(address(depositManager)); | |
if (toTransfer > 0) { | |
if (toTransfer > amount) { | |
toTransfer = amount; | |
} | |
depositManager.transferAssets(token, exitor, toTransfer); | |
amount = amount.sub(toTransfer); | |
} | |
if (amount > 0) { | |
IERC20(token).mint(exitor, amount); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment