-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
805573a
commit 5bec34a
Showing
6 changed files
with
385 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// SPDX-License-Identifier: MIT | ||
// Disclaimer https://github.com/hats-finance/hats-contracts/blob/main/DISCLAIMER.md | ||
|
||
pragma solidity 0.8.16; | ||
|
||
import "@openzeppelin/contracts/proxy/Clones.sol"; | ||
import "./HATAirdrop.sol"; | ||
|
||
contract HATAirdropFactory { | ||
address public immutable implementation; | ||
event HATAirdropCreated(address indexed _hatAirdrop); | ||
|
||
constructor (address _implementation) { | ||
implementation = _implementation; | ||
} | ||
|
||
function createHATAirdrop( | ||
address _owner, | ||
string memory _merkleTreeIPFSRef, | ||
bytes32 _root, | ||
uint256 _startTime, | ||
uint256 _deadline, | ||
uint256 _lockEndTime, | ||
uint256 _periods, | ||
IERC20Upgradeable _token, | ||
ITokenLockFactory _tokenLockFactory | ||
) external returns (address result) { | ||
result = Clones.cloneDeterministic(implementation, keccak256(abi.encodePacked( | ||
_owner, | ||
_merkleTreeIPFSRef, | ||
_root, | ||
_startTime, | ||
_deadline, | ||
_lockEndTime, | ||
_periods, | ||
_token, | ||
_tokenLockFactory | ||
))); | ||
|
||
HATAirdrop(payable(result)).initialize( | ||
_owner, | ||
_merkleTreeIPFSRef, | ||
_root, | ||
_startTime, | ||
_deadline, | ||
_lockEndTime, | ||
_periods, | ||
_token, | ||
_tokenLockFactory | ||
); | ||
|
||
emit HATAirdropCreated(result); | ||
} | ||
|
||
function predictHATAirdropAddress( | ||
address _owner, | ||
string memory _merkleTreeIPFSRef, | ||
bytes32 _root, | ||
uint256 _startTime, | ||
uint256 _deadline, | ||
uint256 _lockEndTime, | ||
uint256 _periods, | ||
IERC20 _token, | ||
ITokenLockFactory _tokenLockFactory | ||
) public view returns (address) { | ||
return Clones.predictDeterministicAddress(implementation, keccak256(abi.encodePacked( | ||
_owner, | ||
_merkleTreeIPFSRef, | ||
_root, | ||
_startTime, | ||
_deadline, | ||
_lockEndTime, | ||
_periods, | ||
_token, | ||
_tokenLockFactory | ||
))); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
docs/dodoc/elin/contracts-upgradeable/utils/cryptography/MerkleProofUpgradeable.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# MerkleProofUpgradeable | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
*These functions deal with verification of Merkle Tree proofs. The tree and the proofs can be generated using our https://github.com/OpenZeppelin/merkle-tree[JavaScript library]. You will find a quickstart guide in the readme. WARNING: You should avoid using leaf values that are 64 bytes long prior to hashing, or use a hash function other than keccak256 for hashing leaves. This is because the concatenation of a sorted pair of internal nodes in the merkle tree could be reinterpreted as a leaf value. OpenZeppelin's JavaScript library generates merkle trees that are safe against this attack out of the box.* | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.