mirror of
https://github.com/Instadapp/dsa-connectors-2.0.git
synced 2024-07-29 21:57:39 +00:00
feat: add merkle claim connector
This commit is contained in:
parent
d8aa7ee6b6
commit
c8b5cb0dcb
11
contracts/mainnet/connectors/merkle-claim/events.sol
Normal file
11
contracts/mainnet/connectors/merkle-claim/events.sol
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
//SPDX-License-Identifier: MIT
|
||||||
|
pragma solidity ^0.8.2;
|
||||||
|
|
||||||
|
contract Events {
|
||||||
|
event LogClaimed(
|
||||||
|
address merkleContract,
|
||||||
|
uint256 index,
|
||||||
|
uint256 amount,
|
||||||
|
uint256 setId
|
||||||
|
);
|
||||||
|
}
|
11
contracts/mainnet/connectors/merkle-claim/interfaces.sol
Normal file
11
contracts/mainnet/connectors/merkle-claim/interfaces.sol
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
//SPDX-License-Identifier: MIT
|
||||||
|
pragma solidity ^0.8.2;
|
||||||
|
|
||||||
|
interface IMerkleDistributor {
|
||||||
|
function claim(
|
||||||
|
uint256 index,
|
||||||
|
address account,
|
||||||
|
uint256 amount,
|
||||||
|
bytes32[] calldata merkleProof
|
||||||
|
) external;
|
||||||
|
}
|
44
contracts/mainnet/connectors/merkle-claim/main.sol
Normal file
44
contracts/mainnet/connectors/merkle-claim/main.sol
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
//SPDX-License-Identifier: MIT
|
||||||
|
pragma solidity ^0.8.2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @title Merkle rewards claiming connector.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Stores } from "../../common/stores.sol";
|
||||||
|
import { Events } from "./events.sol";
|
||||||
|
import { IMerkleDistributor } from "./interfaces.sol";
|
||||||
|
|
||||||
|
abstract contract MerkleClaimConnector is Stores, Events {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Claim Merkle Rewards.
|
||||||
|
* @param merkleContract Address on merkle distributor contract.
|
||||||
|
* @param index The node index to verify the merkle proof.
|
||||||
|
* @param amount The amount of reward to claim.
|
||||||
|
* @param setId ID stores the amount of rewards claimed.
|
||||||
|
*/
|
||||||
|
function claim(
|
||||||
|
address merkleContract,
|
||||||
|
uint256 index,
|
||||||
|
uint256 amount,
|
||||||
|
bytes32[] calldata merkleProof,
|
||||||
|
uint256 setId
|
||||||
|
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||||
|
require(merkleProof.length > 0, "proofs-empty");
|
||||||
|
|
||||||
|
IMerkleDistributor merkleDistribute = IMerkleDistributor(merkleContract);
|
||||||
|
|
||||||
|
merkleDistribute.claim(index, address(this), amount, merkleProof);
|
||||||
|
|
||||||
|
setUint(setId, amount);
|
||||||
|
|
||||||
|
_eventName = "LogMerkleClaimed(address,uint256,uint256,uint256)";
|
||||||
|
_eventParam = abi.encode(merkleContract, index, amount, setId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
contract ConnectV2MerkleClaim is MerkleClaimConnector {
|
||||||
|
string public constant name = "Merkle-claim-v0";
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user