Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When health changes update #208

Merged
merged 16 commits into from
Nov 6, 2024
Prev Previous commit
Next Next commit
PR comments
  • Loading branch information
pahor167 committed Nov 6, 2024
commit 6c728f6e6f468b7e39c09d8a43ab35c92cc4d09a
14 changes: 7 additions & 7 deletions contracts/Manager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,10 @@ contract Manager is Errors, UUPSOwnableUpgradeable, UsingRegistryUpgradeable, Pa
* @notice Allows owner to change strategy for account.
* address(0) = default strategy
* !address(0) = voting for validator group.
* @param account The account to change strategy for.
* @param _account The account to change strategy for.
* @param newStrategy The new strategy.
*/
function forceChangeStrategy(address account, address newStrategy) public onlyOwner {
function forceChangeStrategy(address _account, address newStrategy) public onlyOwner {
_changeStrategy(_account, newStrategy);
}

Expand Down Expand Up @@ -742,17 +742,17 @@ contract Manager is Errors, UUPSOwnableUpgradeable, UsingRegistryUpgradeable, Pa
* @notice Allows strategy to change strategy for account.
* address(0) = default strategy
* !address(0) = voting for validator group.
* @param account The account to change strategy for.
* @param _account The account to change strategy for.
* @param newStrategy The new strategy.
*/
function _changeStrategy(address _account, address newStrategy) private {
uint256 stCeloAmount = stakedCelo.balanceOf(account) +
stakedCelo.lockedVoteBalanceOf(account);
uint256 stCeloAmount = stakedCelo.balanceOf(_account) +
stakedCelo.lockedVoteBalanceOf(_account);
if (stCeloAmount != 0) {
_transfer(strategies[account], newStrategy, stCeloAmount);
_transfer(strategies[_account], newStrategy, stCeloAmount);
}

strategies[account] = newStrategy;
strategies[_account] = newStrategy;
emit StrategyChanged(newStrategy);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import { parseUnits } from "ethers/lib/utils";
import hre from "hardhat";
import { ACCOUNT_REVOKE } from "../lib/tasksNames";
import { Account } from "../typechain-types/Account";
import { DefaultStrategy } from "../typechain-types/DefaultStrategy";
import { GroupHealth } from "../typechain-types/GroupHealth";
import { Manager } from "../typechain-types/Manager";
Expand Down Expand Up @@ -37,7 +36,6 @@
});

describe("e2e specific group strategy voting removed validator group", () => {
let accountContract: Account;
let managerContract: Manager;
let groupHealthContract: MockGroupHealth;
let validatorsWrapper: ValidatorsWrapper;
Expand Down Expand Up @@ -108,7 +106,7 @@

beforeEach(async () => {
await hre.deployments.fixture("core");
accountContract = await hre.ethers.getContract("Account");

Check failure on line 109 in test-ts/end-to-end-specific-group-strategy-remove-validator-group.test.ts

View workflow job for this annotation

GitHub Actions / test

Cannot find name 'accountContract'.
managerContract = await hre.ethers.getContract("Manager");
stakedCeloContract = await hre.ethers.getContract("StakedCelo");
groupHealthContract = await hre.ethers.getContract("GroupHealth");
Expand Down
24 changes: 12 additions & 12 deletions test-ts/manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2559,7 +2559,7 @@ describe("Manager", () => {
});
});

describe("#changeStrategyForce()", () => {
describe("#forceChangeStrategy()", () => {
const withdrawals = [40, 50];
let specificGroupStrategyAddress: string;

Expand Down Expand Up @@ -2587,13 +2587,13 @@ describe("Manager", () => {
slashedGroup.address,
]);
await expect(
manager.connect(nonOwner).changeStrategyForce(depositor.address, slashedGroup.address)
manager.connect(nonOwner).forceChangeStrategy(depositor.address, slashedGroup.address)
).revertedWith("Ownable: caller is not the owner");
});

describe("When changing with no previous stCelo", () => {
beforeEach(async () => {
await manager.connect(owner).changeStrategyForce(depositor.address, groupAddresses[0]);
await manager.connect(owner).forceChangeStrategy(depositor.address, groupAddresses[0]);
});

it("should add group to voted strategies", async () => {
Expand All @@ -2615,15 +2615,15 @@ describe("Manager", () => {
specificGroupStrategyDeposit = parseUnits("2");
await manager
.connect(owner)
.changeStrategyForce(depositor.address, specificGroupStrategyAddress);
.forceChangeStrategy(depositor.address, specificGroupStrategyAddress);
await manager.connect(depositor).deposit({ value: specificGroupStrategyDeposit });
await account.setCeloForGroup(specificGroupStrategyAddress, specificGroupStrategyDeposit);
});

it("should schedule nothing when trying to change to same specific strategy", async () => {
await manager
.connect(owner)
.changeStrategyForce(depositor.address, specificGroupStrategyAddress);
.forceChangeStrategy(depositor.address, specificGroupStrategyAddress);
const [
lastTransferFromGroups,
lastTransferFromVotes,
Expand All @@ -2639,7 +2639,7 @@ describe("Manager", () => {

it("should schedule transfers when changing to different specific strategy", async () => {
const differentSpecificGroupStrategy = groupAddresses[0];
await manager.connect(owner).changeStrategyForce(depositor.address, ADDRESS_ZERO);
await manager.connect(owner).forceChangeStrategy(depositor.address, ADDRESS_ZERO);

const stCeloInSpecificStrategy = await specificGroupStrategyContract.stCeloInGroup(
specificGroupStrategyAddress
Expand All @@ -2656,7 +2656,7 @@ describe("Manager", () => {

it("should schedule transfers when changing to default strategy", async () => {
const [tail] = await defaultStrategyContract.getGroupsTail();
await manager.connect(owner).changeStrategyForce(depositor.address, ADDRESS_ZERO);
await manager.connect(owner).forceChangeStrategy(depositor.address, ADDRESS_ZERO);

const stCeloInSpecificStrategy = await specificGroupStrategyContract.stCeloInGroup(
specificGroupStrategyAddress
Expand Down Expand Up @@ -2690,7 +2690,7 @@ describe("Manager", () => {
const differentSpecificGroupStrategy = groupAddresses[0];
await manager
.connect(owner)
.changeStrategyForce(depositor.address, differentSpecificGroupStrategy);
.forceChangeStrategy(depositor.address, differentSpecificGroupStrategy);

const stCeloInSpecificStrategy = await specificGroupStrategyContract.stCeloInGroup(
specificGroupStrategyAddress
Expand All @@ -2717,7 +2717,7 @@ describe("Manager", () => {

it("should schedule transfers when changing to default strategy", async () => {
const [tail] = await defaultStrategyContract.getGroupsTail();
await manager.connect(owner).changeStrategyForce(depositor.address, ADDRESS_ZERO);
await manager.connect(owner).forceChangeStrategy(depositor.address, ADDRESS_ZERO);

const [stCeloInSpecificStrategy, stCeloOverflow, stCeloUnhealthy] =
await specificGroupStrategyContract.getStCeloInGroup(specificGroupStrategyAddress);
Expand All @@ -2732,7 +2732,7 @@ describe("Manager", () => {

it("should schedule transfers when changing to default strategy", async () => {
const [tail] = await defaultStrategyContract.getGroupsTail();
await manager.connect(owner).changeStrategyForce(depositor.address, ADDRESS_ZERO);
await manager.connect(owner).forceChangeStrategy(depositor.address, ADDRESS_ZERO);

const stCeloInSpecificStrategy = await specificGroupStrategyContract.stCeloInGroup(
specificGroupStrategyAddress
Expand Down Expand Up @@ -2767,7 +2767,7 @@ describe("Manager", () => {
});

it("should schedule nothing when changing to default strategy", async () => {
await manager.connect(owner).changeStrategyForce(depositor.address, ADDRESS_ZERO);
await manager.connect(owner).forceChangeStrategy(depositor.address, ADDRESS_ZERO);

const [
lastTransferFromGroups,
Expand All @@ -2785,7 +2785,7 @@ describe("Manager", () => {
it("should schedule transfers when changing to specific strategy", async () => {
await manager
.connect(owner)
.changeStrategyForce(depositor.address, specificGroupStrategyAddress);
.forceChangeStrategy(depositor.address, specificGroupStrategyAddress);

const stCeloInSpecificStrategy = await specificGroupStrategyContract.stCeloInGroup(
specificGroupStrategyAddress
Expand Down
Loading