Skip to content

Commit

Permalink
Release 2 -> master (#151)
Browse files Browse the repository at this point in the history
* Enable voting for specific validator group (#88)

* deposit + withdraw + partly transfer

* Possibly working

* StCelo token transfer

* Some tests + bug fixes

* Manager tests

* Working and tests running

* Comments

* yml update

* removal of HH console

* Comment updates

* Version update

* Minor changes

* added test when specific group does not have enough stCelo

* Withdraw dust from specific group

* deprecate specific group

* part of e2e test

* PR comments

* Rebalancing

* Rebalance tests

* Update contracts/Account.sol

Co-authored-by: Martin <[email protected]>

* Update contracts/Manager.sol

Co-authored-by: Martin <[email protected]>

* Some PR comments

* Default to default strategy

* Allow groups

* rename to allowed

* almost working :-)

* Tests working

* Rebalancing script working

* Activate and vote working

* simple e2e with rebalance

* e2e with transfer/rebalance working

* e2e done and working

* e2e comments updated

* Manager contract split to not to exceed allowed smart contract size

* Update contracts/Account.sol

Co-authored-by: Martin <[email protected]>

* PR comments

* Tests

* versions

* Method ordering

* Some of PR comments

* separation of default strategy from manager

* comment

* Update contracts/Account.sol

Co-authored-by: soloseng <[email protected]>

* Update contracts/Manager.sol

Co-authored-by: soloseng <[email protected]>

* Update contracts/Manager.sol

Co-authored-by: soloseng <[email protected]>

* Update contracts/SpecificGroupStrategy.sol

Co-authored-by: soloseng <[email protected]>

* Some PR comments

* extend e2e test

* Minor comment fix

* Default strategy accounting

* Group health update

* PR comments

* rebalance back to manager

* PR comments 2

* e2e cleanup

* AddressSortedLinkedList added and simple tests are working

* All tests working

* Finalize Revoke Task (#106)

* distributeWithdrawals during transfer

* Pr comments

* PR comments

* Pr comments

* Group health refactor

* Update contracts/Manager.sol

Co-authored-by: Martin <[email protected]>

* Update contracts/Manager.sol

Co-authored-by: Martin <[email protected]>

* Update contracts/Manager.sol

Co-authored-by: Martin <[email protected]>

* Update contracts/Manager.sol

Co-authored-by: Martin <[email protected]>

* Pr comments

* updateGroupHealth added

* blacklisting of specific group strategies

* Update of depositing to unhealthy specific strategy

* Introduce round robin to Default strategy (#109)

* Manager deposit tests working

* e2e working

* sort tests

* all tests working

* tests working

* added tests

* lint

* removal of console

* test split + block unhealthy validator group

* sorting limit 1

* Max number of groups limitation for specific group

* lint

* PR comments 2

* PR comments 3

* Update contracts/DefaultStrategy.sol

Co-authored-by: Martin <[email protected]>

* Update contracts/DefaultStrategy.sol

Co-authored-by: Martin <[email protected]>

* Update contracts/Manager.sol

Co-authored-by: soloseng <[email protected]>

* Update contracts/DefaultStrategy.sol

Co-authored-by: Martin <[email protected]>

* Update contracts/DefaultStrategy.sol

Co-authored-by: Martin <[email protected]>

* Update contracts/DefaultStrategy.sol

Co-authored-by: Martin <[email protected]>

* Update contracts/DefaultStrategy.sol

Co-authored-by: Martin <[email protected]>

* Pr comments

* PR comments 2

* sort helper

* PR comments

* Simplification of lesser and greater

* removal of comments

* PR comments

* PR comments

* Update contracts/DefaultStrategy.sol

Co-authored-by: soloseng <[email protected]>

* Update contracts/Manager.sol

Co-authored-by: soloseng <[email protected]>

* Update contracts/SpecificGroupStrategy.sol

Co-authored-by: soloseng <[email protected]>

* Update contracts/Manager.sol

Co-authored-by: soloseng <[email protected]>

* Update contracts/Manager.sol

Co-authored-by: soloseng <[email protected]>

* PR comments

* Handle overflow of validator groups (#112)

* mostly working

* V1 -> V2 test

* Rename activeGroups in default strategy

* overflow e2e test

* PR comments

* overflow refactoring

* overflow specific group when group limit reached

* rebalanceOverflow tests

* Update contracts/SpecificGroupStrategy.sol

Co-authored-by: soloseng <[email protected]>

* Update contracts/SpecificGroupStrategy.sol

Co-authored-by: soloseng <[email protected]>

* Update contracts/Manager.sol

Co-authored-by: soloseng <[email protected]>

* Update contracts/Manager.sol

Co-authored-by: soloseng <[email protected]>

* Update contracts/Manager.sol

Co-authored-by: soloseng <[email protected]>

* Update contracts/Manager.sol

Co-authored-by: soloseng <[email protected]>

* PR comments

* Update contracts/DefaultStrategy.sol

Co-authored-by: soloseng <[email protected]>

* Update contracts/DefaultStrategy.sol

Co-authored-by: soloseng <[email protected]>

* Update contracts/Manager.sol

Co-authored-by: soloseng <[email protected]>

* Update contracts/Manager.sol

Co-authored-by: soloseng <[email protected]>

* Update contracts/SpecificGroupStrategy.sol

Co-authored-by: soloseng <[email protected]>

* CELO vs stCELO tests

* healthy -> unhealthy -> healthy group e2e test

* compiler warning fix

* Update group health deploy script

* PR comments

* utils fixes

* Fork somehow working

* Revert "Fork somehow working"

This reverts commit d5ac488.

* Deployment fix

* PR comments

* Unhealthy group deployment fix

---------

Co-authored-by: soloseng <[email protected]>

---------

Co-authored-by: Martin <[email protected]>
Co-authored-by: soloseng <[email protected]>

* Update lib/account-tasks/helpers/revokeHelper.ts

Co-authored-by: soloseng <[email protected]>

* Update contracts/Account.sol

Co-authored-by: soloseng <[email protected]>

* PR comments

* test util fix

* Refactor + test optimizations

* Before removal of mock default strategy

* Minor comments fixes

* Group health optimizations 1

* Group health test fixes

* Proxy tests

* Fix for unhealthy specific group

* rebalanceWhenHealthChanged tests

* stCelo to Celo ratios tests

* Block strategy update

* PR comments

* PR comments + version update

* removal of unused methods + added tests

* split of methods because compiler complains

---------

Co-authored-by: Martin <[email protected]>
Co-authored-by: soloseng <[email protected]>

* Make sure that Vote.updateHistoryAndReturnLockedStCeloInVoting will n… (#120)

* Make sure that Vote.updateHistoryAndReturnLockedStCeloInVoting will not run out of gas

* version update

* Update contracts/Vote.sol

Co-authored-by: soloseng <[email protected]>

* Update contracts/Vote.sol

Co-authored-by: soloseng <[email protected]>

* PR comments

* PR comments 2

* lint

* lint v2

---------

Co-authored-by: soloseng <[email protected]>

* Audit - Info fixes (#122)

* Audit fixes

* #31

* Audit comment (#119)

* V1 to V2 deployment scripts (#116) (#126)

* deposit + withdraw + partly transfer

* Possibly working

* StCelo token transfer

* Some tests + bug fixes

* Manager tests

* Working and tests running

* Comments

* yml update

* removal of HH console

* Comment updates

* Version update

* Minor changes

* added test when specific group does not have enough stCelo

* Withdraw dust from specific group

* deprecate specific group

* part of e2e test

* PR comments

* Rebalancing

* Rebalance tests

* Update contracts/Account.sol



* Update contracts/Manager.sol



* Some PR comments

* Default to default strategy

* Allow groups

* rename to allowed

* almost working :-)

* Tests working

* Rebalancing script working

* Activate and vote working

* simple e2e with rebalance

* e2e with transfer/rebalance working

* e2e done and working

* e2e comments updated

* Manager contract split to not to exceed allowed smart contract size

* Update contracts/Account.sol



* PR comments

* Tests

* versions

* Method ordering

* Some of PR comments

* separation of default strategy from manager

* comment

* Update contracts/Account.sol



* Update contracts/Manager.sol



* Update contracts/Manager.sol



* Update contracts/SpecificGroupStrategy.sol



* Some PR comments

* extend e2e test

* Minor comment fix

* Default strategy accounting

* Group health update

* PR comments

* rebalance back to manager

* PR comments 2

* e2e cleanup

* AddressSortedLinkedList added and simple tests are working

* All tests working

* Manager deposit tests working

* Finalize Revoke Task (#106)

* e2e working

* distributeWithdrawals during transfer

* sort tests

* all tests working

* tests working

* added tests

* lint

* removal of console

* test split + block unhealthy validator group

* Pr comments

* PR comments

* Pr comments

* sorting limit 1

* Max number of groups limitation for specific group

* Group health refactor

* lint

* mostly working

* V1 -> V2 test

* Rename activeGroups in default strategy

* overflow e2e test

* Update contracts/Manager.sol



* Update contracts/Manager.sol



* Update contracts/Manager.sol



* Update contracts/Manager.sol



* Pr comments

* updateGroupHealth added

* blacklisting of specific group strategies

* PR comments 2

* PR comments 3

* PR comments

* overflow refactoring

* overflow specific group when group limit reached

* rebalanceOverflow tests

* Update contracts/DefaultStrategy.sol



* Update contracts/DefaultStrategy.sol



* Update contracts/Manager.sol



* Update contracts/DefaultStrategy.sol



* Update contracts/DefaultStrategy.sol



* Update contracts/DefaultStrategy.sol



* Update contracts/DefaultStrategy.sol



* Pr comments

* Update contracts/SpecificGroupStrategy.sol



* Update contracts/SpecificGroupStrategy.sol



* Update contracts/Manager.sol



* Update contracts/Manager.sol



* Update contracts/Manager.sol



* Update contracts/Manager.sol



* PR comments 2

* sort helper

* PR comments

* Simplification of lesser and greater

* removal of comments

* PR comments

* PR comments

* PR comments

* Update contracts/DefaultStrategy.sol



* Update contracts/DefaultStrategy.sol



* Update contracts/Manager.sol



* Update contracts/Manager.sol



* Update contracts/SpecificGroupStrategy.sol



* Update contracts/DefaultStrategy.sol



* Update contracts/Manager.sol



* Update contracts/SpecificGroupStrategy.sol



* Update contracts/Manager.sol



* Update contracts/Manager.sol



* PR comments

* CELO vs stCELO tests

* healthy -> unhealthy -> healthy group e2e test

* Update of depositing to unhealthy specific strategy

* compiler warning fix

* Update group health deploy script

* PR comments

* utils fixes

* Fork somehow working

* Revert "Fork somehow working"

This reverts commit d5ac488.

* devchain working

* Deployment fix

* PR comments

* Unhealthy group deployment fix

* deployment script fixes

* multisig update

* update of scripts

* Introduce round robin to Default strategy (#109)

* Manager deposit tests working

* e2e working

* sort tests

* all tests working

* tests working

* added tests

* lint

* removal of console

* test split + block unhealthy validator group

* sorting limit 1

* Max number of groups limitation for specific group

* lint

* PR comments 2

* PR comments 3

* Update contracts/DefaultStrategy.sol



* Update contracts/DefaultStrategy.sol



* Update contracts/Manager.sol



* Update contracts/DefaultStrategy.sol



* Update contracts/DefaultStrategy.sol



* Update contracts/DefaultStrategy.sol



* Update contracts/DefaultStrategy.sol



* Pr comments

* PR comments 2

* sort helper

* PR comments

* Simplification of lesser and greater

* removal of comments

* PR comments

* PR comments

* Update contracts/DefaultStrategy.sol



* Update contracts/Manager.sol



* Update contracts/SpecificGroupStrategy.sol



* Update contracts/Manager.sol



* Update contracts/Manager.sol



* PR comments

* Handle overflow of validator groups (#112)

* mostly working

* V1 -> V2 test

* Rename activeGroups in default strategy

* overflow e2e test

* PR comments

* overflow refactoring

* overflow specific group when group limit reached

* rebalanceOverflow tests

* Update contracts/SpecificGroupStrategy.sol



* Update contracts/SpecificGroupStrategy.sol



* Update contracts/Manager.sol



* Update contracts/Manager.sol



* Update contracts/Manager.sol



* Update contracts/Manager.sol



* PR comments

* Update contracts/DefaultStrategy.sol



* Update contracts/DefaultStrategy.sol



* Update contracts/Manager.sol



* Update contracts/Manager.sol



* Update contracts/SpecificGroupStrategy.sol



* CELO vs stCELO tests

* healthy -> unhealthy -> healthy group e2e test

* compiler warning fix

* Update group health deploy script

* PR comments

* utils fixes

* Fork somehow working

* Revert "Fork somehow working"

This reverts commit d5ac488.

* Deployment fix

* PR comments

* Unhealthy group deployment fix

---------



---------




* PR comments

* removal of deployments

* removal of deployments 2

* bump the CI pipeline

---------

Co-authored-by: Martin <[email protected]>
Co-authored-by: soloseng <[email protected]>

* Alfajores release (#127)

* Alfajores release

* Vote proposal task

* PR comments

* Enable allow to vote over max number of tasks (#133)

* Enable allow to vote over max number of tasks

* alfajores vote update

* activation added to upgrade proposal

* Update of update script

* Fix + tests (#135)

* Fix + tests

* PR comments

* V2 mainnet deployment (#141)

* version update

---------

Co-authored-by: Martin <[email protected]>
Co-authored-by: soloseng <[email protected]>
  • Loading branch information
3 people authored Aug 14, 2023
1 parent 83a10e1 commit f05465c
Show file tree
Hide file tree
Showing 74 changed files with 20,718 additions and 1,605 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,15 @@ Note: `--destinations` is the target proxy contract whose implementation is bein
```
3. Insert returned values into submitProposal task (it can be found few lines above)

## Vote for governance proposal

``` bash
> yarn hardhat stakedCelo:manager:voteProposal --network [network] --proposal-id [governance proposal id] --yes [# of votes] --account [address]

# example
> yarn hardhat stakedCelo:manager:voteProposal --network alfajores --proposal-id 10 --yes 100 --no 0 --abstain 0 --account 0x456f41406B32c45D59E539e4BBA3D7898c3584dA
```
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md) for style and how to contribute.
Expand Down
2 changes: 1 addition & 1 deletion contracts/Account.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ contract Account is UUPSOwnableUpgradeable, UsingRegistryUpgradeable, Managed, I
* @param toVote Amount of CELO held by this contract intended to vote for a group.
* @param toWithdraw Amount of CELO that's scheduled for withdrawal.
* @param toWithdrawFor Amount of CELO that's scheduled for withdrawal grouped by beneficiary.
* @param toRevoke Amount of CELO that's scheduled to be revoked.
*/
struct ScheduledVotes {
uint256 toVote;
Expand Down Expand Up @@ -327,7 +328,6 @@ contract Account is UUPSOwnableUpgradeable, UsingRegistryUpgradeable, Managed, I
* @notice Starts withdrawal of CELO from `group`. If there is any unlocked CELO for the group,
* that CELO is used for immediate withdrawal. Otherwise, CELO is taken from pending and active
* votes, which are subject to the unlock period of LockedGold.sol.
* @dev Only callable by the Staked CELO contract, which must restrict which groups are valid.
* @param group The group to withdraw CELO from.
* @param beneficiary The recipient of the withdrawn CELO.
* @param lesserAfterPendingRevoke Used by Election's `revokePending`. This is the group that
Expand Down
6 changes: 0 additions & 6 deletions contracts/DefaultStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ contract DefaultStrategy is UUPSOwnableUpgradeable, Managed {
*/
event SortedFlagUpdated(bool update);

/**
* @notice Used when there isn't enough CELO voting for an account's strategy
* to fulfill a withdrawal.
*/
error CantWithdrawAccordingToStrategy();

/**
* @notice Used when attempting to activate a group that is already active.
* @param group The group's address.
Expand Down
14 changes: 12 additions & 2 deletions contracts/GroupHealth.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ contract GroupHealth is UUPSOwnableUpgradeable, UsingRegistryUpgradeable {
uint256
)
{
return (1, 1, 0, 0);
return (1, 1, 0, 1);
}

/**
Expand Down Expand Up @@ -222,7 +222,17 @@ contract GroupHealth is UUPSOwnableUpgradeable, UsingRegistryUpgradeable {
}

uint256 slashMultiplier;
(members, , , , , slashMultiplier, ) = validators.getValidatorGroup(group);
address[] memory originalMembers;
(originalMembers, , , , , slashMultiplier, ) = validators.getValidatorGroup(group);

members = new address[](originalMembers.length);

IAccounts accounts = getAccounts();

for (uint256 i = 0; i < originalMembers.length; i++) {
members[i] = accounts.getValidatorSigner(originalMembers[i]);
}

// check if group has no members
if (members.length == 0) {
return (false, members);
Expand Down
20 changes: 17 additions & 3 deletions contracts/RebasedStakedCelo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ contract RebasedStakedCelo is ERC20Upgradeable, UUPSOwnableUpgradeable {
* @param depositor The address of the depositor.
* @param amount The amount of stCELO deposited.
*/
event StakedCeloDeposited(address depositor, uint256 amount);
event StakedCeloDeposited(address indexed depositor, uint256 amount);

/**
* @notice Used when a withdrawal is successfully completed.
* @param withdrawer The address of the withdrawer.
* @param amount The amount of stCELO withdrawn.
*/
event StakedCeloWithdrawn(address withdrawer, uint256 amount);
event StakedCeloWithdrawn(address indexed withdrawer, uint256 amount);

/**
* @notice Used when the deposit amount is zero.
Expand Down Expand Up @@ -78,6 +78,11 @@ contract RebasedStakedCelo is ERC20Upgradeable, UUPSOwnableUpgradeable {
*/
error FailedWithdrawal(address withdrawer, uint256 amount);

/**
* Used when input amount of token is greater than total token amount.
*/
error InputLargerThanTotalAmount();

/**
* @notice Empty constructor for proxy implementation, `initializer` modifer ensures the
* implementation gets initialized.
Expand Down Expand Up @@ -163,7 +168,7 @@ contract RebasedStakedCelo is ERC20Upgradeable, UUPSOwnableUpgradeable {
uint256
)
{
return (1, 1, 1, 1);
return (1, 1, 1, 2);
}

/**
Expand Down Expand Up @@ -192,6 +197,11 @@ contract RebasedStakedCelo is ERC20Upgradeable, UUPSOwnableUpgradeable {
uint256 stCeloSupply = stakedCelo.totalSupply();
uint256 celoBalance = account.getTotalCelo();

uint256 rstSupply = totalSupply();
if (rstSupply < rstCeloAmount) {
revert InputLargerThanTotalAmount();
}

if (stCeloSupply == 0 || celoBalance == 0) {
return rstCeloAmount;
}
Expand All @@ -208,6 +218,10 @@ contract RebasedStakedCelo is ERC20Upgradeable, UUPSOwnableUpgradeable {
uint256 stCeloSupply = stakedCelo.totalSupply();
uint256 celoBalance = account.getTotalCelo();

if (stCeloSupply < stCeloAmount) {
revert InputLargerThanTotalAmount();
}

if (stCeloSupply == 0 || celoBalance == 0) {
return stCeloAmount;
}
Expand Down
6 changes: 3 additions & 3 deletions contracts/Vote.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ contract Vote is UUPSOwnableUpgradeable, UsingRegistryUpgradeable, Managed {
* @param abstainVotes The abstain votes.
*/
event ProposalVoted(
address voter,
uint256 proposalId,
address indexed voter,
uint256 indexed proposalId,
uint256 yesVotes,
uint256 noVotes,
uint256 abstainVotes
Expand Down Expand Up @@ -213,7 +213,7 @@ contract Vote is UUPSOwnableUpgradeable, UsingRegistryUpgradeable, Managed {
uint256
)
{
return (1, 1, 2, 0);
return (1, 1, 2, 1);
}

/**
Expand Down
11 changes: 11 additions & 0 deletions deploy/11_set_dependencies_on_default_strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { MULTISIG_ENCODE_PROPOSAL_PAYLOAD } from "../lib/tasksNames";
import { ADDRESS_ZERO } from "../test-ts/utils";
import { DefaultStrategy } from "../typechain-types/DefaultStrategy";
import { GroupHealth } from "../typechain-types/GroupHealth";
import { Manager } from "../typechain-types/Manager";

const parseValidatorGroups = (validatorGroupsString: string | undefined) =>
validatorGroupsString ? validatorGroupsString.split(",") : [];
Expand All @@ -33,6 +34,16 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
return;
}

const manager: Manager = await hre.ethers.getContract("Manager");
if ((await manager.callStatic.owner()) === multisig.address) {
console.log(
chalk.red(
`Manager is already owned by multisig - most probably this is update. It will be necessary to activate groups in update multisig proposal!`
)
);
return;
}

const defaultStrategyContract = await hre.ethers.getContract("DefaultStrategy");
const accountContract = await hre.ethers.getContract("Account");

Expand Down
Loading

0 comments on commit f05465c

Please sign in to comment.