withdraw fund
This commit is contained in:
parent
98205ca9b7
commit
03995f194e
@ -34,6 +34,7 @@ contract Vault is EtherTokenConstant, AragonApp, DepositableStorage {
|
||||
bytes32[4] public appIds;
|
||||
|
||||
event VaultDeposit(address indexed token, address indexed sender, uint256 amount);
|
||||
event VaultWithdraw(address indexed token, address indexed receiver, uint256 amount);
|
||||
|
||||
function () external payable isInitialized {
|
||||
_deposit(ETH, msg.value);
|
||||
@ -100,6 +101,17 @@ contract Vault is EtherTokenConstant, AragonApp, DepositableStorage {
|
||||
_deposit(_token, _value);
|
||||
}
|
||||
|
||||
function withdraw(address _token) external payable isInitialized {
|
||||
uint256 contributorFundPercentage = (balanceOf(msg.sender) * 100) / totalSupply();
|
||||
//to check if sender is a contributor
|
||||
require(contributorFundPercentage > 0, "Contributor have no fund");
|
||||
|
||||
uint256 contributorFund = (address(this).balance * contributorFundPercentage) / 100;
|
||||
msg.sender.transfer(contributorFund);
|
||||
|
||||
emit VaultWithdraw(_token, msg.sender, contributorFund);
|
||||
}
|
||||
|
||||
function balance(address _token) public view returns (uint256) {
|
||||
if (_token == ETH) {
|
||||
return address(this).balance;
|
||||
|
Loading…
x
Reference in New Issue
Block a user