Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
0x-r4bbit committed Sep 23, 2024
1 parent 616e266 commit 5bd0492
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/RewardsStreamerMP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity ^0.8.26;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import { console } from "forge-std/Test.sol";

// Rewards Streamer with Multiplier Points
contract RewardsStreamerMP is ReentrancyGuard {
Expand Down Expand Up @@ -79,22 +80,32 @@ contract RewardsStreamerMP is ReentrancyGuard {

uint256 initialMP = amount;
uint256 userPotentialMP = amount * MAX_MULTIPLIER;
console.log("user.userPotentialMP BEFORE: %s", userPotentialMP);

if (lockPeriod != 0) {
uint256 lockMultiplier = (lockPeriod * MAX_MULTIPLIER * SCALE_FACTOR) / MAX_LOCKING_PERIOD;
console.log("lockMultiplier BEFORE: %s", lockMultiplier);
console.log("SCALE_FACTOR: %s", SCALE_FACTOR);
lockMultiplier = lockMultiplier / SCALE_FACTOR;
console.log("lockMultiplier AFTER: %s", lockMultiplier);
initialMP += (amount * lockMultiplier);
console.log("user.userPotentialMP INCREASING BY: %s", (amount * lockMultiplier));
userPotentialMP += (amount * lockMultiplier);
console.log("user.userPotentialMP AFTER: %s", userPotentialMP);
user.lockUntil = block.timestamp + lockPeriod;
} else {
user.lockUntil = 0;
}

user.userMP += initialMP;
console.log("user.userMP: %s", user.userMP);
totalMP += initialMP;
console.log("totalMP: %s", totalMP);

user.userPotentialMP += userPotentialMP;
console.log("user.userPotentialMP AFTER 2: %s", user.userPotentialMP);
potentialMP += userPotentialMP;
console.log("potentialMP: %s", potentialMP);

user.userRewardIndex = rewardIndex;
user.lastMPUpdateTime = block.timestamp;
Expand Down
16 changes: 16 additions & 0 deletions test/RewardsStreamerMP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,22 @@ contract StakeTest is RewardsStreamerMPTest {
);
}

function test_StakeOneAccountWithLockUp() public {
_stake(alice, 10e18, streamer.MIN_LOCKING_PERIOD());

checkStreamer(
CheckStreamerParams({
totalStaked: 10e18,
totalMP: 10e18,
potentialMP: 40e18,
stakingBalance: 10e18,
rewardBalance: 0,
rewardIndex: 0,
accountedRewards: 0
})
);
}

function test_StakeMultipleAccounts() public {
// Alice stakes 10 tokens
_stake(alice, 10e18, 0);
Expand Down

0 comments on commit 5bd0492

Please sign in to comment.