Skip to content

Commit

Permalink
chore: formatting with the new foundry config
Browse files Browse the repository at this point in the history
  • Loading branch information
gravityblast authored and 0x-r4bbit committed Sep 24, 2024
1 parent 8e5471b commit e445dce
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 37 deletions.
6 changes: 3 additions & 3 deletions script/RewardsStreamer.s.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

import {Script, console} from "forge-std/Script.sol";
import {RewardsStreamer} from "../src/RewardsStreamer.sol";
import { Script, console } from "forge-std/Script.sol";
import { RewardsStreamer } from "../src/RewardsStreamer.sol";

contract RewardsStreamerScript is Script {
RewardsStreamer public rewardsStreamer;

function setUp() public {}
function setUp() public { }

function run() public {
vm.startBroadcast();
Expand Down
4 changes: 2 additions & 2 deletions src/RewardsStreamer.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

contract RewardsStreamer is ReentrancyGuard {
error StakingManager__AmountCannotBeZero();
Expand Down
4 changes: 2 additions & 2 deletions src/RewardsStreamerMP.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

// Rewards Streamer with Multiplier Points
contract RewardsStreamerMP is ReentrancyGuard {
Expand Down
36 changes: 18 additions & 18 deletions test/RewardsStreamer.t.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

import {Test, console} from "forge-std/Test.sol";
import {RewardsStreamer} from "../src/RewardsStreamer.sol";
import {MockToken} from "./mocks/MockToken.sol";
import { Test, console } from "forge-std/Test.sol";
import { RewardsStreamer } from "../src/RewardsStreamer.sol";
import { MockToken } from "./mocks/MockToken.sol";

contract RewardsStreamerTest is Test {
MockToken rewardToken;
Expand Down Expand Up @@ -122,8 +122,8 @@ contract RewardsStreamerTest is Test {
})
);

checkUser(CheckUserParams({user: alice, rewardBalance: 0, stakedBalance: 10e18, rewardIndex: 0}));
checkUser(CheckUserParams({user: bob, rewardBalance: 0, stakedBalance: 30e18, rewardIndex: 0}));
checkUser(CheckUserParams({ user: alice, rewardBalance: 0, stakedBalance: 10e18, rewardIndex: 0 }));
checkUser(CheckUserParams({ user: bob, rewardBalance: 0, stakedBalance: 30e18, rewardIndex: 0 }));

// T4
vm.prank(alice);
Expand All @@ -139,8 +139,8 @@ contract RewardsStreamerTest is Test {
})
);

checkUser(CheckUserParams({user: alice, rewardBalance: 250e18, stakedBalance: 0e18, rewardIndex: 25e18}));
checkUser(CheckUserParams({user: bob, rewardBalance: 0, stakedBalance: 30e18, rewardIndex: 0}));
checkUser(CheckUserParams({ user: alice, rewardBalance: 250e18, stakedBalance: 0e18, rewardIndex: 25e18 }));
checkUser(CheckUserParams({ user: bob, rewardBalance: 0, stakedBalance: 30e18, rewardIndex: 0 }));

// T5
vm.prank(charlie);
Expand All @@ -156,9 +156,9 @@ contract RewardsStreamerTest is Test {
})
);

checkUser(CheckUserParams({user: alice, rewardBalance: 250e18, stakedBalance: 0e18, rewardIndex: 25e18}));
checkUser(CheckUserParams({user: bob, rewardBalance: 0, stakedBalance: 30e18, rewardIndex: 0}));
checkUser(CheckUserParams({user: charlie, rewardBalance: 0, stakedBalance: 30e18, rewardIndex: 25e18}));
checkUser(CheckUserParams({ user: alice, rewardBalance: 250e18, stakedBalance: 0e18, rewardIndex: 25e18 }));
checkUser(CheckUserParams({ user: bob, rewardBalance: 0, stakedBalance: 30e18, rewardIndex: 0 }));
checkUser(CheckUserParams({ user: charlie, rewardBalance: 0, stakedBalance: 30e18, rewardIndex: 25e18 }));

// T6
vm.prank(admin);
Expand All @@ -170,14 +170,14 @@ contract RewardsStreamerTest is Test {
totalStaked: 60e18,
stakingBalance: 60e18,
rewardBalance: 1750e18,
rewardIndex: 41666666666666666666,
rewardIndex: 41_666_666_666_666_666_666,
accountedRewards: 1750e18
})
);

checkUser(CheckUserParams({user: alice, rewardBalance: 250e18, stakedBalance: 0, rewardIndex: 25e18}));
checkUser(CheckUserParams({user: bob, rewardBalance: 0, stakedBalance: 30e18, rewardIndex: 0}));
checkUser(CheckUserParams({user: charlie, rewardBalance: 0, stakedBalance: 30e18, rewardIndex: 25e18}));
checkUser(CheckUserParams({ user: alice, rewardBalance: 250e18, stakedBalance: 0, rewardIndex: 25e18 }));
checkUser(CheckUserParams({ user: bob, rewardBalance: 0, stakedBalance: 30e18, rewardIndex: 0 }));
checkUser(CheckUserParams({ user: charlie, rewardBalance: 0, stakedBalance: 30e18, rewardIndex: 25e18 }));

//T7
vm.prank(bob);
Expand All @@ -188,18 +188,18 @@ contract RewardsStreamerTest is Test {
totalStaked: 30e18,
stakingBalance: 30e18,
rewardBalance: 500e18 + 20, // 500e18 (with rounding error of 20 wei)
rewardIndex: 41666666666666666666,
rewardIndex: 41_666_666_666_666_666_666,
accountedRewards: 500e18 + 20
})
);

checkUser(CheckUserParams({user: alice, rewardBalance: 250e18, stakedBalance: 0, rewardIndex: 25e18}));
checkUser(CheckUserParams({ user: alice, rewardBalance: 250e18, stakedBalance: 0, rewardIndex: 25e18 }));
checkUser(
CheckUserParams({
user: bob,
rewardBalance: 1249999999999999999980, // 750e18 + 500e18 (with rounding error)
rewardBalance: 1_249_999_999_999_999_999_980, // 750e18 + 500e18 (with rounding error)
stakedBalance: 0,
rewardIndex: 41666666666666666666
rewardIndex: 41_666_666_666_666_666_666
})
);
}
Expand Down
21 changes: 11 additions & 10 deletions test/RewardsStreamerMP.t.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

import {Test, console} from "forge-std/Test.sol";
import {RewardsStreamerMP} from "../src/RewardsStreamerMP.sol";
import {MockToken} from "./mocks/MockToken.sol";
import { Test, console } from "forge-std/Test.sol";
import { RewardsStreamerMP } from "../src/RewardsStreamerMP.sol";
import { MockToken } from "./mocks/MockToken.sol";
import "forge-std/console.sol";

contract RewardsStreamerMPTest is Test {
Expand Down Expand Up @@ -222,7 +222,8 @@ contract RewardsStreamerMPTest is Test {
CheckStreamerParams({
totalStaked: 30e18,
totalMP: 45e18, // 60 - 15 from Alice (10 + 6 months = 5)
potentialMP: 105e18, // Alice's initial potential MP: 40. 5 already accrued in 6 months. new potentialMP = 140 - 35 = 105
potentialMP: 105e18, // Alice's initial potential MP: 40. 5 already accrued in 6 months. new potentialMP
// = 140 - 35 = 105
stakingBalance: 30e18,
rewardBalance: 750e18,
rewardIndex: 10e18,
Expand Down Expand Up @@ -313,7 +314,7 @@ contract RewardsStreamerMPTest is Test {
potentialMP: 225e18,
stakingBalance: 60e18,
rewardBalance: 1750e18,
rewardIndex: 17407407407407407407,
rewardIndex: 17_407_407_407_407_407_407,
accountedRewards: 1750e18
})
);
Expand Down Expand Up @@ -363,9 +364,9 @@ contract RewardsStreamerMPTest is Test {
potentialMP: 120e18,
stakingBalance: 30e18,
// 1750 - (750 + 555.55) = 444.44
rewardBalance: 444444444444444444475,
rewardIndex: 17407407407407407407,
accountedRewards: 444444444444444444475
rewardBalance: 444_444_444_444_444_444_475,
rewardIndex: 17_407_407_407_407_407_407,
accountedRewards: 444_444_444_444_444_444_475
})
);

Expand All @@ -390,9 +391,9 @@ contract RewardsStreamerMPTest is Test {
// total weight = 135
// bobs rewards = 1000 * 75 / 135 = 555.555555555555555555
// bobs total rewards = 555.55 + 750 of the first bucket = 1305.55
rewardBalance: 1305555555555555555525,
rewardBalance: 1_305_555_555_555_555_555_525,
stakedBalance: 0e18,
rewardIndex: 17407407407407407407,
rewardIndex: 17_407_407_407_407_407_407,
userMP: 0,
userPotentialMP: 0
})
Expand Down
4 changes: 2 additions & 2 deletions test/mocks/MockToken.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MockToken is ERC20 {
constructor(string memory name, string memory symbol) ERC20(name, symbol) {}
constructor(string memory name, string memory symbol) ERC20(name, symbol) { }

function mint(address account, uint256 amount) external {
_mint(account, amount);
Expand Down

0 comments on commit e445dce

Please sign in to comment.