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

Author Pre-Audit Merkle Distribution Contract #3148

Merged
merged 8 commits into from
Dec 13, 2021
Merged

Conversation

topocount
Copy link
Member

@topocount topocount commented Aug 20, 2021

This smart contract is very similar to Balancer's merkle-redeem smart
contract, plus the addition of a feature that allows for a delay before
allocations are live to be claimed.
The smart contract has a role system that allows for delegation of
allocation publishing and pausing roles.

This added functionality allows for more decentralized workflows and
potentially automation, since the powers of the account publishing
allocations are tightly scoped, and there is recourse with a delay period.

It might be worth adding a minimum_delay period that must be observed
by the SEEDER_ROLE holder and can be controlled by PAUSER_ROLE
holders.

Test Plan:
Unit tests for the smart contract are included.
The smart contract is fully covered, though coverage instrumentation
hasn't been set up.

Merge Plan

builds toward #3139

@topocount topocount requested review from wchargin and blueridger and removed request for wchargin and blueridger August 20, 2021 18:50
@topocount topocount changed the base branch from main to ci-cache August 23, 2021 19:23
Copy link
Member

@blueridger blueridger left a comment

Choose a reason for hiding this comment

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

I didn't review all files since it seems like many are copied. Which ones do you want review for right now?

@topocount
Copy link
Member Author

I didn't review all files since it seems like many are copied. Which ones do you want review for right now?

The smart contract and test files. Everything else is still WIP for the integration interface

Base automatically changed from ci-cache to main August 24, 2021 20:23
@topocount topocount force-pushed the merkle-integrations branch 2 times, most recently from 1b08563 to f9ad964 Compare August 27, 2021 16:44
@topocount topocount force-pushed the merkle-integrations branch 3 times, most recently from 27c6ee3 to 18984ae Compare September 9, 2021 18:48
@topocount topocount linked an issue Oct 29, 2021 that may be closed by this pull request
* Pause a Distribution indefinitely by resetting the merkle root to zero
* The distribution can be re-seeded with a new merkle root.
*/
function pauseDistribution(uint _distribution) external {
Copy link
Member Author

Choose a reason for hiding this comment

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

should be deleteDistribution

Copy link
Member Author

Choose a reason for hiding this comment

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

This is because we are setting the bytes to 0, even though we can effectively "undelete/unpause"


// Recorded Distributions
mapping(uint => bytes32) public distributionMerkleRoots;
mapping(uint => mapping(address => bool)) public claimed;
Copy link
Member Author

Choose a reason for hiding this comment

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

idea for post-expiry admin claims: after a configured timespan passes, the admin can reclaim unclaimed funds by users.

role. Responsible for publishing distributions on chain using the
`seedAllocations` function.
- `PAUSER_ROLE`: Manually assigned and managed by the `DEFAULT_ADMIN`
role. Responsible for pausing a distribution, which can be unpaused.
Copy link
Member

Choose a reason for hiding this comment

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

Might be good to note here that pausing happens by removal, and that the pauser is also responsible for the minimum delay.

implementation.

- A permissioned function to transfer undistributed funds out of the contract
- A global `MIN_DELAY` state variable that the `SEEDER_ROLE` must observe
Copy link
Member

Choose a reason for hiding this comment

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

this can be taken off this list.

@topocount topocount force-pushed the merkle-integrations branch 4 times, most recently from 13b4206 to 5f5090e Compare November 23, 2021 17:33
@topocount topocount changed the base branch from main to config-updates November 23, 2021 17:51
Base automatically changed from config-updates to accounting December 13, 2021 15:40
Base automatically changed from accounting to main December 13, 2021 15:51
This smart contract is very similar to Balancer's merkle-redeem smart
contract, plus the addition of a feature that allows for a delay before
allocations are live to be claimed.
The smart contract has a role system that allows for delegation of
allocation publishing and pausing roles.

This added functionality allows for a more decentralized workflows and
potentially automation, since the powers of the account publishing
allocations are tightly scoped, and there is recourse between the delay
period and pausability.

It might be worth adding a `minimum_delay` period that must be observed
by the `SEEDER_ROLE` holder and can be conrolled by `PAUSER_ROLE`
holders.

Test Plan:
Unit tests for the smart contract are included.
The smart contract is fully covered, though coverage instrumentation
hasn't been set up.
- added index details to slice getters
- Remove `PAUSER` remnants
- rename _week to _distribution
- rename liquidityProvider to _contributor
- rename `delayAllocation` to `delayDistribution` since claims
  are technically what is being delayed
Change The Delay to a Pause
--

The Delay is preserved for the Seed Role and now a global minimum delay
must be observed when calling `seedDistribution`

Add Delay Setter
--

The PAUSER_ROLE has the ability to modify the global `minDelay` in the
event that the distribution process changes.

test plan: unit tests added
Using 'merkletreejs' will allow us to utilize the latest, most secure
MerkleTree JS implementations. This is a widely used library for many
crypto projects. The API is very similar, but the construction is much
more versatile and requires some specific configuration, as reflected in
the changes to tests.

test plan: unit tests have been updated to utilize this new dependency.
Functionally, the method deletes the hash and is therefore not just
pausing the ability to claim against it.

test plan: unit tests updated
@topocount topocount merged commit b8110a1 into main Dec 13, 2021
@topocount topocount deleted the merkle-integrations branch December 13, 2021 16:36
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.

Write the MerkleDistribution smart contract
2 participants