Skip to content

Commit

Permalink
Merge pull request #563 from hats-finance/redeem-and-delegate-airdrop
Browse files Browse the repository at this point in the history
Redeem and delegate airdrop
  • Loading branch information
jellegerbrandy authored May 20, 2024
2 parents fd98486 + 3278c28 commit f1aa3e1
Show file tree
Hide file tree
Showing 18 changed files with 241 additions and 3,105 deletions.
24 changes: 23 additions & 1 deletion contracts/tge/HATAirdropFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "@openzeppelin/contracts/proxy/Clones.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./interfaces/IHATAirdrop.sol";
import "../interfaces/IHATToken.sol";

contract HATAirdropFactory is Ownable {
error RedeemDataArraysLengthMismatch();
Expand All @@ -17,17 +18,22 @@ contract HATAirdropFactory is Ownable {
using SafeERC20 for IERC20;

mapping(address => bool) public isAirdrop;
IHATToken public HAT;

event TokensWithdrawn(address indexed _owner, uint256 _amount);
event HATAirdropCreated(address indexed _hatAirdrop, bytes _initData, IERC20 _token, uint256 _totalAmount);

constructor (IHATToken _HAT) {
HAT = _HAT;
}

function withdrawTokens(IERC20 _token, uint256 _amount) external onlyOwner {
address owner = msg.sender;
_token.safeTransfer(owner, _amount);
emit TokensWithdrawn(owner, _amount);
}

function redeemMultipleAirdrops(IHATAirdrop[] calldata _airdrops, uint256[] calldata _amounts, bytes32[][] calldata _proofs) external {
function redeemMultipleAirdrops(IHATAirdrop[] calldata _airdrops, uint256[] calldata _amounts, bytes32[][] calldata _proofs) public {
if (_airdrops.length != _amounts.length || _airdrops.length != _proofs.length) {
revert RedeemDataArraysLengthMismatch();
}
Expand All @@ -46,6 +52,22 @@ contract HATAirdropFactory is Ownable {
}
}

function redeemAndDelegateMultipleAirdrops(
IHATAirdrop[] calldata _airdrops,
uint256[] calldata _amounts,
bytes32[][] calldata _proofs,
address _delegatee,
uint256 _nonce,
uint256 _expiry,
uint8 _v,
bytes32 _r,
bytes32 _s
) external {
redeemMultipleAirdrops(_airdrops, _amounts, _proofs);

HAT.delegateBySig(_delegatee, _nonce, _expiry, _v, _r, _s);
}

function createHATAirdrop(
address _implementation,
bytes calldata _initData,
Expand Down
Loading

0 comments on commit f1aa3e1

Please sign in to comment.