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

Governance factory #284

Merged
merged 63 commits into from
Oct 12, 2023
Merged

Governance factory #284

merged 63 commits into from
Oct 12, 2023

Conversation

baroooo
Copy link
Contributor

@baroooo baroooo commented Oct 11, 2023

Description

A factory contract that deploys and configures all token and governance related contracts.
It will be initiated by Celo governance.
Treasury and vesting contracts won't be created in this PR. Those changes will be added later.

Other changes

Airgrab's init function is updated to resolve triple circular dependence between token, locking and airgrab
Governor config is parameterized to keep all config in the Factory
Added TODO comments as reminders
The branch is based on locking-contracts branch so locking related changes can be ignored in this review (contracts/governance/locking, test/Locking, test/mocks, test/utils)

Tested

Tested with unit tests
The issue #275 aims to add integration tests that will test the main flows

Related issues

baroooo and others added 19 commits October 4, 2023 14:31
After a few iterations, we landed on a simple Airgrab scheme:
- With a list of <address>,<token amount> we generate a merkle tree and
record the root in the contract
- A user does KYC, gets the merkle proof from our backend and submits
the claim
- The contract verifies the merkle proof and KYC and locks the tokens on
behalf of the user for a predetermined cliff and slope.
- The airgrab has an endTimestamp after witch any leftover tokens in the
contract can be transferred to the treasury.

More details on specifics around the KYC can be extracted from the
comments in the code which contain links to documentation.

There is a single open question around how we encode the expected
credential from fractal. The expected credential is basically the set of
restrictions we want to enforce and it's a string that looks like
`"level:plus;residency_not:ca,us"`.
I currently provided that statically in the code and it's probably not
the final version that we want. But to parameterize in a naive way would
incur a big gas because we can only store it in storage, and not as an
immutable parameter because only immutable base types are allowed as of
now in solidity. If we want to parameterize it the approach I would take
would be to store a keccak of it as an immutable bytes32 parameter, and
provide the full string as a parameter to the claim function and when
verifying the credential we would first verify that the keccak matches
and then use it in the construction of the full credential. I'm not sure
if it's worth it or if it's fine to just come up with the value and keep
it static in line as is right now.

N/A

Yes

- Fixes #282

N/A

N/A

---------

Co-authored-by: baroooo <[email protected]>
@baroooo baroooo mentioned this pull request Oct 11, 2023
9 tasks
Copy link
Collaborator

@nvtaveras nvtaveras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few small comments but overall looks good. Would be nice to have a 2nd pass once the locking branch is merged to look at the clean diff

contracts/governance/Factory.sol Outdated Show resolved Hide resolved
// Airgrab configuration
uint32 public constant AIRGRAB_LOCK_SLOPE = 104; // Slope duration for the airgrabed tokens in weeks
uint32 public constant AIRGRAB_LOCK_CLIFF = 0; // Cliff duration for the airgrabed tokens
uint256 public constant AIRGRAB_DURATION = 365 days; // Duration for the airgrab
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of these comments are redundant given the variable names. Maybe only leave the ones that you think are not as clear or could provide additional context to the reader?

For example L56 seems like useful context:
uint256 public constant GOVERNOR_VOTING_DELAY = 1; // Voting start the next block


on another note, is the airgrab supposed to last one year?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, after one year remaining funds will be drained

// Governor configuration
uint256 public constant GOVERNOR_VOTING_DELAY = 1; // Voting start the next block
uint256 public constant GOVERNOR_VOTING_PERIOD = 120_960; // Voting period for the governor (7 days in blocks CELO)
uint256 public constant GOVERNOR_PROPOSAL_THRESHOLD = 1_000e18; // Proposal threshold for the governor
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can I verify that this value is correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test/utils/TestLocking.sol Outdated Show resolved Hide resolved
contracts/governance/Factory.sol Show resolved Hide resolved
contracts/governance/locking/LockingBase.sol Outdated Show resolved Hide resolved
test/governance/Factory.t.sol Show resolved Hide resolved
@baroooo baroooo merged commit 4817f47 into feat/tokenWork Oct 12, 2023
3 of 15 checks passed
@baroooo baroooo mentioned this pull request Oct 13, 2023
5 tasks
@chapati23 chapati23 deleted the feat/governance-factory branch November 30, 2023 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants