-
Notifications
You must be signed in to change notification settings - Fork 0
Per-address option - using existing contracts #23
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
base: good-main
Are you sure you want to change the base?
Changes from all commits
5f25ba9
4c04fce
d46caaf
79cd6e9
ca1236d
52dec98
2e463cd
8fe43cc
be7be4c
fb34000
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [submodule "packages/hardhat/lib/forge-std"] | ||
| path = packages/hardhat/lib/forge-std | ||
| url = https://github.com/foundry-rs/forge-std |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // config/index.d.ts | ||
| export const merkleRoots: { [key: string]: string }; | ||
| export const campaignCIDs: { [key: string]: string }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity 0.8.21; | ||
|
|
||
| import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; | ||
|
|
||
| import { PerAddressContinuousVesting } from './abstract/PerAddressContinuousVesting.sol'; | ||
| import { MerkleSet } from './abstract/MerkleSet.sol'; | ||
|
|
||
| contract PerAddressContinuousVestingMerkle is PerAddressContinuousVesting, MerkleSet { | ||
|
|
||
| constructor( | ||
| IERC20 _token, // the token being claimed | ||
| uint256 _total, // the total claimable by all users | ||
| string memory _uri, // information on the sale (e.g. merkle proofs) | ||
| uint256 _voteFactor, // votes have this weight | ||
| bytes32 _merkleRoot, // the merkle root for claim membership (also used as salt for the fair queue delay time), | ||
| uint160 _maxDelayTime // the maximum delay time for the fair queue | ||
| ) | ||
| PerAddressContinuousVesting( | ||
| _token, | ||
| _total, | ||
| _uri, | ||
| _voteFactor, | ||
| _maxDelayTime, | ||
| uint160(uint256(_merkleRoot)) | ||
| ) | ||
| MerkleSet(_merkleRoot) | ||
| {} | ||
|
|
||
| function NAME() external pure override returns (string memory) { | ||
| return 'PerAddressContinuousVestingMerkle'; | ||
| } | ||
|
|
||
| function VERSION() external pure override returns (uint256) { | ||
| return 4; | ||
| } | ||
|
|
||
| function initializeDistributionRecord( | ||
| uint256 index, // the beneficiary's index in the merkle root | ||
| address beneficiary, // the address that will receive tokens | ||
| uint256 amount, // the total claimable by this beneficiary | ||
| uint256 start, // the start of the vesting period | ||
| uint256 cliff, // cliff time | ||
| uint256 end, // the end of the vesting period | ||
| bytes32[] calldata merkleProof | ||
| ) | ||
| external | ||
| validMerkleProof(keccak256(abi.encodePacked(index, beneficiary, amount, start, cliff, end)), merkleProof) | ||
| { | ||
| _initializeDistributionRecord(beneficiary, amount); | ||
| } | ||
|
|
||
| function claim( | ||
| uint256 index, // the beneficiary's index in the merkle root | ||
| address beneficiary, // the address that will receive tokens | ||
| uint256 totalAmount, // the total claimable by this beneficiary | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto - this doesn't seem right: need to put continuous vesting parameters (start, cliff, end) in every function that checks merkle proof since they are required to generate the leaf. |
||
| uint256 start, // the start of the vesting period | ||
| uint256 cliff, // cliff time | ||
| uint256 end, // the end of the vesting period | ||
| bytes32[] calldata merkleProof | ||
| ) | ||
| external | ||
| validMerkleProof(keccak256(abi.encodePacked(index, beneficiary, totalAmount, start, cliff, end)), merkleProof) | ||
| nonReentrant | ||
| { | ||
| // effects | ||
| uint256 claimedAmount = _executeClaim(beneficiary, totalAmount, new bytes(0)); | ||
| // interactions | ||
| _settleClaim(beneficiary, claimedAmount); | ||
| } | ||
|
|
||
| function setMerkleRoot(bytes32 _merkleRoot) external onlyOwner { | ||
| _setMerkleRoot(_merkleRoot); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity 0.8.21; | ||
|
|
||
| import { IERC20 } from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; | ||
|
|
||
| import { PerAddressTrancheVesting, Tranche } from './abstract/PerAddressTrancheVesting.sol'; | ||
| import { MerkleSet } from './abstract/MerkleSet.sol'; | ||
|
|
||
| contract PerAddressTrancheVestingMerkle is PerAddressTrancheVesting, MerkleSet { | ||
| constructor( | ||
| IERC20 _token, | ||
| uint256 _total, | ||
| string memory _uri, // information on the sale (e.g. merkle proofs) | ||
| uint256 _voteFactor, | ||
| bytes32 _merkleRoot, | ||
| uint160 _maxDelayTime // the maximum delay time for the fair queue | ||
| ) | ||
| PerAddressTrancheVesting( | ||
| _token, | ||
| _total, | ||
| _uri, | ||
| _voteFactor, | ||
| _maxDelayTime, | ||
| uint160(uint256(_merkleRoot)) | ||
| ) | ||
| MerkleSet(_merkleRoot) | ||
| {} | ||
|
|
||
| function NAME() external pure override returns (string memory) { | ||
| return 'PerAddressTrancheVestingMerkle'; | ||
| } | ||
|
|
||
| function VERSION() external pure override returns (uint256) { | ||
| return 4; | ||
| } | ||
|
|
||
| function initializeDistributionRecord( | ||
| uint256 index, // the beneficiary's index in the merkle root | ||
| address beneficiary, // the address that will receive tokens | ||
| uint256 amount, // the total claimable by this beneficiary | ||
cr-walker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Tranche[] calldata tranches, // the tranches for the beneficiary (users can have different vesting schedules) | ||
| bytes32[] calldata merkleProof | ||
| ) | ||
| external | ||
| validMerkleProof(keccak256(abi.encodePacked(index, beneficiary, amount, abi.encode(tranches))), merkleProof) | ||
| { | ||
| _initializeDistributionRecord(beneficiary, amount); | ||
| } | ||
|
|
||
| function claim( | ||
| uint256 index, // the beneficiary's index in the merkle root | ||
| address beneficiary, // the address that will receive tokens | ||
| uint256 totalAmount, // the total claimable by this beneficiary | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add tranche params
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above comment |
||
| // TODO: should we be providing the tranches already abi encoded to save gas? | ||
| Tranche[] calldata tranches, // the tranches for the beneficiary (users can have different vesting schedules) | ||
| bytes32[] calldata merkleProof | ||
| ) | ||
| external | ||
| validMerkleProof(keccak256(abi.encodePacked(index, beneficiary, totalAmount, abi.encode(tranches))), merkleProof) | ||
| nonReentrant | ||
| { | ||
| bytes memory data = abi.encode(tranches); | ||
| // effects | ||
| uint256 claimedAmount = _executeClaim(beneficiary, totalAmount, data); | ||
| // interactions | ||
| _settleClaim(beneficiary, claimedAmount); | ||
| } | ||
|
|
||
| function setMerkleRoot(bytes32 _merkleRoot) external onlyOwner { | ||
| _setMerkleRoot(_merkleRoot); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.