Last active
November 15, 2019 17:11
-
-
Save dekanbro/a8f1cd5b3789e5158b571d61a8e4fde8 to your computer and use it in GitHub Desktop.
Moloch forwarder Shim
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.3; | |
import "./metacartel.sol"; // Moloch | |
import "./SafeMath.sol"; | |
import "./IERC20.sol"; | |
contract MolochShim { | |
using SafeMath for uint256; | |
event Ragequit ( | |
uint256 sharesBurned | |
); | |
event WithdrawTo ( | |
uint256 tokenWithdraw | |
); | |
Moloch public moloch; // moloch contract | |
IERC20 public approvedToken; // approved token contract reference (copied from moloch contract) | |
address public withdrawTo; // address to withdraw to after ragequit | |
constructor(address _moloch, address _withdrawTo) public { | |
moloch = Moloch(_moloch); | |
withdrawTo = _withdrawTo; | |
approvedToken = IERC20(moloch.approvedToken()); | |
} | |
function ragequit() public { | |
(,uint shares,,) = moloch.members(address(this)); | |
moloch.ragequit(shares); | |
emit Ragequit(shares); | |
} | |
function withdraw() public { | |
require( | |
approvedToken.transfer(withdrawTo, approvedToken.balanceOf(address(this))), | |
"MolochShim: Withdrawal transfer failed" | |
); | |
emit WithdrawTo(approvedToken.balanceOf(address(this))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment