staking_rewards.sol 2.71 KB
Newer Older
XFT-dev's avatar
XFT-dev committed
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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
contract StakingRewards {

	uint256 public immutable PID; // ip of pair XFT/ETH in Onsen

	IERC20 public rewardsTokenXFT;
	IERC20 public rewardsTokenSUSHI;
	IERC20 public stakingToken;
	IMasterChef public masterChef;

	PoolInfo public poolInfo;

	uint256 public periodFinish;
	uint256 public rewardRate;
	uint256 public rewardsDuration;
	uint256 public lastUpdateTime;
	uint256 public rewardPerTokenStored;

	mapping(address => UserInfo) public userInfo;
	mapping(address => uint256) public userRewardPerTokenPaid;
	mapping(address => uint256) public rewardsXFT;
	mapping(address => uint256) public rewardsSUSHI;

	uint256 private _totalStaked;

	function totalStaked() external view override returns (uint256);

    // staked balance for specific user
	function balanceOf(address _account)
		external
		view
		override
		returns (uint256);

    // reward notified for duration
	function getRewardForDuration() external view override returns (uint256);

    // withdraw all staked tokens and get reward
	function exit() external override; 

	function stake(uint256 _amount)
		external
		override
		nonReentrant
		whenNotPaused
		updateReward(msg.sender);

	function withdraw(uint256 _amount)
		public
		override
		nonReentrant
		updateReward(msg.sender);

    // get reward in both tokens
	function getReward() public override nonReentrant updateReward(msg.sender); // 

	function lastTimeRewardApplicable() public view override returns (uint256);

    // reward per token in XFT
	function rewardPerToken() public view override returns (uint256);

    // reward XFT for specific user
	function earnedXFT(address _account)
		public
		view
		override
		returns (uint256);

    // reward SUSHI for specific user
	function earnedSushi(address _account)
		public
		view
		override
		returns (uint256);

    // onlyOwner
	
	// Ensure the provided reward amount is not more than the balance in the contract.
    // This keeps the reward rate in the right range, preventing overflows due to
    // very high values of rewardRate in the earned and rewardsPerToken functions;
    // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow.
	function notifyRewardAmount(uint256 _reward)
		external
		onlyOwner
		updateReward(address(0));

    // 
	function updatePeriodFinish(uint256 _timestamp)
		external
		onlyOwner
		updateReward(address(0));


    // Pausable
    // status
    function paused() public view virtual returns (bool);

	function pause() public onlyOwner;

	function unpause() public onlyOwner;


    // Ownble
    function owner() public view virtual returns (address);

    // transfere ownership to zero address 
    function renounceOwnership() public virtual onlyOwner;

    function transferOwnership(address newOwner) public virtual onlyOwner;
}