-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathSunStakerSimple.sol
83 lines (56 loc) · 1.95 KB
/
SunStakerSimple.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import "./SunStakerInterface.sol";
pragma solidity ^0.5.8;
contract SunStaker is SunStakerInterface {
modifier checkStart() {
require(block.timestamp >= starttime && block.timestamp < periodFinish,"only in start period");
_;
}
modifier checkEnd() {
require(block.timestamp >= periodFinish,"not end");
_;
}
using SafeMath for uint256;
event Deposit(address indexed dst, uint sad);
event Withdrawal(address indexed src, uint sad);
function initialize(uint256 _starttime, uint256 _periodFinish) public{
starttime = _starttime;
periodFinish = _periodFinish;
}
function rewardOneSun() public view returns (uint256) {
return 0;
}
function earned(address account) public view returns (uint256) {
return 0;
}
function earned(address account,address token) public view returns (uint256) {
return 0;
}
function lastTimeRewardApplicable() public view returns (uint256) {
return min(block.timestamp, periodFinish);
}
function deposit() checkStart public payable {
require( msg.value > 0,"deposit must gt 0");
balanceOf_[msg.sender] = balanceOf_[msg.sender].add(msg.value);
totalSupply_ = totalSupply_.add(msg.value);
emit Deposit(msg.sender, msg.value);
}
function withdraw(address token) checkEnd public {
uint256 sad = balanceOf_[msg.sender];
balanceOf_[msg.sender] = 0;
msg.sender.transfer(sad);
totalSupply_ = totalSupply_.sub(sad);
emit Withdrawal(msg.sender, sad);
}
function totalSupply() public view returns (uint) {
return totalSupply_;
}
function balanceOf(address guy) public view returns (uint){
return balanceOf_[guy];
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
}