From 254afe9932681bcb70d287ecb10f359f9bb9221b Mon Sep 17 00:00:00 2001 From: Ricardo Guilherme Schmidt <3esmit@gmail.com> Date: Wed, 24 May 2023 10:25:52 -0300 Subject: [PATCH] save progress --- contracts/StakeManager.sol | 14 +++++++++++- contracts/StakeVault.sol | 45 ++++++++++++++++++++++++++++++-------- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/contracts/StakeManager.sol b/contracts/StakeManager.sol index 35e45fd..b666394 100644 --- a/contracts/StakeManager.sol +++ b/contracts/StakeManager.sol @@ -9,6 +9,10 @@ contract StakeManager is ERC20 { address stakedToken; bytes32 vaultCodehash; + uint256 mp_supply = 0; + uint256 public constant MP_APY = 1; + uint256 public constant STAKE_APY = 1; + uint256 public constant MAX_BOOST = 1; mapping (address => Account) account; @@ -18,7 +22,7 @@ contract StakeManager is ERC20 { } function join(uint256 amount) external onlyVault { - stakedToken.transferFrom(msg.sender, ) + } function lock(uint256 amount, uint256 time) external onlyVault { @@ -33,6 +37,14 @@ contract StakeManager is ERC20 { } + function getRewardsEmissions() public view returns(uint256){ + + } + + + function increase_mp(uint256 amount) { + + } diff --git a/contracts/StakeVault.sol b/contracts/StakeVault.sol index 7bf0cc3..1936188 100644 --- a/contracts/StakeVault.sol +++ b/contracts/StakeVault.sol @@ -12,21 +12,21 @@ contract StakeVault { ERC20 stakedToken; uint256 balance; uint256 locked; + uint256 unlockTime; + uint256 lockedPeriod; uint256 multiplierPoints; - //uint256 constant FACTOR = 1; - uint256 constant MP_APY = 1; - uint256 constant MAX_MP = 1; - function join(uint256 amount) external { - stakedToken.transferFrom(msg.sender, address(this), amount); + _join(amount); } function lock(uint256 amount, uint256 time) external { - + _lock(amount,time); } function joinAndLock(uint256 amount, uint256 time) external { + _join(amount); + _lock(amount,time); } @@ -34,14 +34,41 @@ contract StakeVault { } + function getMaxMultiplierPoints() public view returns(uint256) { + return balance * (stakeManager.MAX_BOOST() + lockup + 1); + } + + function _join(uint256 amount) internal { + stakedToken.transferFrom(msg.sender, address(this), amount); + } + + function _lock(uint256 amount, uint256 time) internal { + require(time > 0, "Invalid lock time"); + lockedPeriod = time; + unlockTime = now() + time; + locked = amount; + multiplierPoints += amount * (time + 1); + } function mintMultiplierPoints() internal { uint256 new_mp = multiplierPoints + (balance * stakeManager.MP_APY()); - uint256 max_mp = stakeManager.MAX_MP(); + uint256 max_mp = getMaxMultiplierPoints(); multiplierPoints = new_mp > max_mp ? max_mp : new_mp; } - - + function distriuteRewards() internal { + uitn256 stakeApy = stakeManager.STAKE_APY() + + if(stakeApy > 0){ + return stake_apy * (balance + multiplierPoints) + } else { + uint256 cs = balance + multiplierPoints + uint256 rewards = stakeManager.getRewardEmissions(); + if(cs > 0){ + return = rewards * (balance + multiplierPoints) / cs + } + } + + } } \ No newline at end of file