-
Notifications
You must be signed in to change notification settings - Fork 49
/
RefundPoll.sol
54 lines (46 loc) · 1.43 KB
/
RefundPoll.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
pragma solidity ^0.4.21;
import './poll/BasePoll.sol';
import './fund/IPollManagedFund.sol';
/**
* @title RefundPoll
* @dev Enables fund refund mode
*/
contract RefundPoll is BasePoll {
uint256 public holdEndTime = 0;
/**
* RefundPoll constructor
* @param _tokenAddress ERC20 compatible token contract address
* @param _fundAddress Fund contract address
* @param _startTime Poll start time
* @param _endTime Poll end time
*/
function RefundPoll(
address _tokenAddress,
address _fundAddress,
uint256 _startTime,
uint256 _endTime,
uint256 _holdEndTime,
bool _checkTransfersAfterEnd
) public
BasePoll(_tokenAddress, _fundAddress, _startTime, _endTime, _checkTransfersAfterEnd)
{
holdEndTime = _holdEndTime;
}
function tryToFinalize() public returns(bool) {
if(holdEndTime > 0 && holdEndTime > endTime) {
require(now >= holdEndTime);
} else {
require(now >= endTime);
}
finalized = true;
onPollFinish(isSubjectApproved());
return true;
}
function isSubjectApproved() internal view returns(bool) {
return yesCounter > noCounter && yesCounter >= safeDiv(token.totalSupply(), 3);
}
function onPollFinish(bool agree) internal {
IPollManagedFund fund = IPollManagedFund(fundAddress);
fund.onRefundPollFinish(agree);
}
}