Skip to content

Instantly share code, notes, and snippets.

@dekanbro
Last active November 15, 2019 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dekanbro/a8f1cd5b3789e5158b571d61a8e4fde8 to your computer and use it in GitHub Desktop.
Save dekanbro/a8f1cd5b3789e5158b571d61a8e4fde8 to your computer and use it in GitHub Desktop.
Moloch forwarder Shim
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