From e445dce9b05c5a73726b2c0466346392f2413f34 Mon Sep 17 00:00:00 2001 From: Andrea Franz Date: Mon, 23 Sep 2024 16:51:52 +0200 Subject: [PATCH] chore: formatting with the new foundry config --- script/RewardsStreamer.s.sol | 6 +++--- src/RewardsStreamer.sol | 4 ++-- src/RewardsStreamerMP.sol | 4 ++-- test/RewardsStreamer.t.sol | 36 ++++++++++++++++++------------------ test/RewardsStreamerMP.t.sol | 21 +++++++++++---------- test/mocks/MockToken.sol | 4 ++-- 6 files changed, 38 insertions(+), 37 deletions(-) diff --git a/script/RewardsStreamer.s.sol b/script/RewardsStreamer.s.sol index 9196071..e216301 100644 --- a/script/RewardsStreamer.s.sol +++ b/script/RewardsStreamer.s.sol @@ -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(); diff --git a/src/RewardsStreamer.sol b/src/RewardsStreamer.sol index 2ac641d..d7302f9 100644 --- a/src/RewardsStreamer.sol +++ b/src/RewardsStreamer.sol @@ -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(); diff --git a/src/RewardsStreamerMP.sol b/src/RewardsStreamerMP.sol index d1ceb07..9064f07 100644 --- a/src/RewardsStreamerMP.sol +++ b/src/RewardsStreamerMP.sol @@ -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 { diff --git a/test/RewardsStreamer.t.sol b/test/RewardsStreamer.t.sol index 4a53f88..9ed3a2c 100644 --- a/test/RewardsStreamer.t.sol +++ b/test/RewardsStreamer.t.sol @@ -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; @@ -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); @@ -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); @@ -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); @@ -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); @@ -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 }) ); } diff --git a/test/RewardsStreamerMP.t.sol b/test/RewardsStreamerMP.t.sol index 3efe38b..ee3c4e7 100644 --- a/test/RewardsStreamerMP.t.sol +++ b/test/RewardsStreamerMP.t.sol @@ -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 { @@ -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, @@ -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 }) ); @@ -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 }) ); @@ -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 }) diff --git a/test/mocks/MockToken.sol b/test/mocks/MockToken.sol index bc79dd6..e1450c6 100644 --- a/test/mocks/MockToken.sol +++ b/test/mocks/MockToken.sol @@ -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);