mirror of
https://github.com/Instadapp/dsa-connectors-2.0.git
synced 2024-07-29 21:57:39 +00:00
feat: add fluid merkle rewards claim connector
This commit is contained in:
parent
1400cf7b0e
commit
fa430dc6a5
21
contracts/mainnet/connectors/merkleDistributor/events.sol
Normal file
21
contracts/mainnet/connectors/merkleDistributor/events.sol
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
//SPDX-License-Identifier: MIT
|
||||||
|
pragma solidity ^0.8.2;
|
||||||
|
|
||||||
|
contract Events {
|
||||||
|
event LogClaim(
|
||||||
|
uint256 cumulativeAmount,
|
||||||
|
address fToken,
|
||||||
|
uint256 cycle,
|
||||||
|
bytes32[] merkleProof,
|
||||||
|
uint256 getId
|
||||||
|
);
|
||||||
|
|
||||||
|
event LogClaimOnBehalf(
|
||||||
|
address recipient_,
|
||||||
|
uint256 cumulativeAmount,
|
||||||
|
address fToken,
|
||||||
|
uint256 cycle,
|
||||||
|
bytes32[] merkleProof,
|
||||||
|
uint256 getId
|
||||||
|
);
|
||||||
|
}
|
12
contracts/mainnet/connectors/merkleDistributor/interface.sol
Normal file
12
contracts/mainnet/connectors/merkleDistributor/interface.sol
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
//SPDX-License-Identifier: MIT
|
||||||
|
pragma solidity ^0.8.2;
|
||||||
|
|
||||||
|
interface IFluidMerkleDistributor {
|
||||||
|
function claim(
|
||||||
|
address recipient_,
|
||||||
|
uint256 cumulativeAmount_,
|
||||||
|
address fToken_,
|
||||||
|
uint256 cycle_,
|
||||||
|
bytes32[] calldata merkleProof_
|
||||||
|
) external;
|
||||||
|
}
|
66
contracts/mainnet/connectors/merkleDistributor/main.sol
Normal file
66
contracts/mainnet/connectors/merkleDistributor/main.sol
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
//SPDX-License-Identifier: MIT
|
||||||
|
pragma solidity ^0.8.2;
|
||||||
|
|
||||||
|
import { Basic } from "../../common/basic.sol";
|
||||||
|
import { Events } from "./events.sol";
|
||||||
|
import { IFluidMerkleDistributor } from "./interface.sol";
|
||||||
|
|
||||||
|
abstract contract FluidMerkle is Basic, Events {
|
||||||
|
|
||||||
|
address private constant MERKLE_DISTRIBUTOR = address(0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Claims rewards from Fluid merkle distributor contract
|
||||||
|
* @param cumulativeAmount_ Total reward cumulated since reward inception.
|
||||||
|
* @param fToken_ Address of fToken on which rewards are being distributed.
|
||||||
|
* @param cycle_ Current epoch cycle.
|
||||||
|
* @param merkleProof_ Merkle proof that validates this claim.
|
||||||
|
* @param getId_ Id to get the cumulative amount.
|
||||||
|
*/
|
||||||
|
function claim(
|
||||||
|
uint256 cumulativeAmount_,
|
||||||
|
address fToken_,
|
||||||
|
uint256 cycle_,
|
||||||
|
bytes32[] calldata merkleProof_,
|
||||||
|
uint256 getId_
|
||||||
|
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||||
|
uint256 _amt = getUint(getId_, cumulativeAmount_);
|
||||||
|
|
||||||
|
IFluidMerkleDistributor distributorContract_ = IFluidMerkleDistributor(MERKLE_DISTRIBUTOR);
|
||||||
|
|
||||||
|
distributorContract_.claim(address(this), _amt, fToken_, cycle_, merkleProof_);
|
||||||
|
|
||||||
|
_eventName = "LogClaim(uint256,address,uint256,bytes32[],uint256)";
|
||||||
|
_eventParam = abi.encode(_amt, fToken_, cycle_, merkleProof_, getId_);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Claims rewards from Fluid merkle distributor contract
|
||||||
|
* @param cumulativeAmount_ Total reward cumulated since reward inception.
|
||||||
|
* @param fToken_ Address of fToken on which rewards are being distributed.
|
||||||
|
* @param cycle_ Current epoch cycle.
|
||||||
|
* @param merkleProof_ Merkle proof that validates this claim.
|
||||||
|
* @param getId_ Id to get the cumulative amount.
|
||||||
|
*/
|
||||||
|
function claimOnBehalf(
|
||||||
|
address recipient_,
|
||||||
|
uint256 cumulativeAmount_,
|
||||||
|
address fToken_,
|
||||||
|
uint256 cycle_,
|
||||||
|
bytes32[] calldata merkleProof_,
|
||||||
|
uint256 getId_
|
||||||
|
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||||
|
uint256 _amt = getUint(getId_, cumulativeAmount_);
|
||||||
|
|
||||||
|
IFluidMerkleDistributor distributorContract_ = IFluidMerkleDistributor(MERKLE_DISTRIBUTOR);
|
||||||
|
|
||||||
|
distributorContract_.claim(recipient_, _amt, fToken_, cycle_, merkleProof_);
|
||||||
|
|
||||||
|
_eventName = "LogClaimOnBehalf(address,uint256,address,uint256,bytes32[],uint256)";
|
||||||
|
_eventParam = abi.encode(recipient_, _amt, fToken_, cycle_, merkleProof_, getId_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contract ConnectV2FluidMerkleClaim is FluidMerkle {
|
||||||
|
string public constant name = "Fluid-Merkle-v1.0";
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user