mirror of
https://github.com/vacp2p/staking-reward-streamer.git
synced 2026-01-09 21:18:01 -05:00
rename reposit to stake
This commit is contained in:
@@ -28,7 +28,7 @@ contract TimeWeightedStakingWithRewards {
|
||||
return MULTIPLIER + (elapsed * MULTIPLIER / ONE_YEAR);
|
||||
}
|
||||
|
||||
function deposit(uint256 amount) external {
|
||||
function stake(uint256 amount) external {
|
||||
require(amount > 0, "Cannot deposit 0");
|
||||
|
||||
Account storage account = accounts[msg.sender];
|
||||
@@ -51,6 +51,7 @@ contract TimeWeightedStakingWithRewards {
|
||||
uint256 currentRewardDebt = (account.shares * accRewardPerShare) / MULTIPLIER;
|
||||
|
||||
if (account.settledRewards < currentRewardDebt) {
|
||||
// uint256 pending = currentRewardDebt - account.settledRewards;
|
||||
account.settledRewards = currentRewardDebt;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ contract TimeWeightedStakingSimpleClaims is Test {
|
||||
|
||||
console.log("Day 0: Alice stakes 100");
|
||||
vm.prank(alice);
|
||||
staking.deposit(100e18);
|
||||
staking.stake(100e18);
|
||||
dump();
|
||||
|
||||
console.log("Half Year Passed - No Rewards Yet");
|
||||
@@ -48,7 +48,7 @@ contract TimeWeightedStakingSimpleClaims is Test {
|
||||
|
||||
console.log("Start of Year 2: Bob stakes 100");
|
||||
vm.prank(bob);
|
||||
staking.deposit(100e18);
|
||||
staking.stake(100e18);
|
||||
dump();
|
||||
|
||||
console.log("End of Year 2: Add 1000 rewards");
|
||||
|
||||
@@ -33,7 +33,7 @@ contract TimeWeightedStakingWithRewardsTest is Test {
|
||||
console.log("day 0");
|
||||
console.log("alice stakes 100");
|
||||
vm.prank(alice);
|
||||
staking.deposit(100e18);
|
||||
staking.stake(100e18);
|
||||
dump();
|
||||
|
||||
console.log("1 year");
|
||||
@@ -43,7 +43,7 @@ contract TimeWeightedStakingWithRewardsTest is Test {
|
||||
|
||||
console.log("bob stakes 100");
|
||||
vm.prank(bob);
|
||||
staking.deposit(100e18);
|
||||
staking.stake(100e18);
|
||||
dump();
|
||||
|
||||
console.log("2 years");
|
||||
@@ -53,7 +53,7 @@ contract TimeWeightedStakingWithRewardsTest is Test {
|
||||
|
||||
console.log("charlie stakes 100");
|
||||
vm.prank(charlie);
|
||||
staking.deposit(100e18);
|
||||
staking.stake(100e18);
|
||||
|
||||
dump();
|
||||
|
||||
@@ -87,7 +87,7 @@ contract TimeWeightedStakingWithRewardsTest is Test {
|
||||
console.log("day 0");
|
||||
console.log("alice stakes 100");
|
||||
vm.prank(alice);
|
||||
staking.deposit(100e18);
|
||||
staking.stake(100e18);
|
||||
dump();
|
||||
|
||||
console.log("1 year");
|
||||
@@ -96,8 +96,10 @@ contract TimeWeightedStakingWithRewardsTest is Test {
|
||||
staking.addRewards(1000e18);
|
||||
|
||||
console.log("bob stakes 100");
|
||||
console.log("alice weight 200");
|
||||
console.log("bob weight 100");
|
||||
vm.prank(bob);
|
||||
staking.deposit(100e18);
|
||||
staking.stake(100e18);
|
||||
dump();
|
||||
|
||||
console.log("2 years");
|
||||
@@ -105,13 +107,20 @@ contract TimeWeightedStakingWithRewardsTest is Test {
|
||||
vm.warp(start + 730 days);
|
||||
staking.addRewards(1000e18);
|
||||
|
||||
console.log("alice weight 300");
|
||||
console.log("bob weight 200");
|
||||
dump();
|
||||
|
||||
console.log("3 years alice");
|
||||
console.log("alice weight 400");
|
||||
console.log("bob weight 300");
|
||||
console.log("3 years alice unstakes 100");
|
||||
console.log("add 1000 rewards");
|
||||
console.log("alice weight 400");
|
||||
console.log("bob weight 300");
|
||||
vm.warp(start + 730 days);
|
||||
vm.prank(alice);
|
||||
staking.unstake(100e18);
|
||||
staking.unstake(50e18);
|
||||
console.log("add 1000 rewards");
|
||||
staking.addRewards(1000e18);
|
||||
dump();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user