mirror of
https://github.com/Instadapp/dsa-connectors-2.0.git
synced 2024-07-29 21:57:39 +00:00
feat: add rewards claimed
This commit is contained in:
parent
fa430dc6a5
commit
db49f64236
|
@ -7,7 +7,8 @@ contract Events {
|
||||||
address fToken,
|
address fToken,
|
||||||
uint256 cycle,
|
uint256 cycle,
|
||||||
bytes32[] merkleProof,
|
bytes32[] merkleProof,
|
||||||
uint256 getId
|
uint256 rewardsClaimed,
|
||||||
|
uint256 setId
|
||||||
);
|
);
|
||||||
|
|
||||||
event LogClaimOnBehalf(
|
event LogClaimOnBehalf(
|
||||||
|
@ -16,6 +17,7 @@ contract Events {
|
||||||
address fToken,
|
address fToken,
|
||||||
uint256 cycle,
|
uint256 cycle,
|
||||||
bytes32[] merkleProof,
|
bytes32[] merkleProof,
|
||||||
uint256 getId
|
uint256 rewardsClaimed,
|
||||||
|
uint256 setId
|
||||||
);
|
);
|
||||||
}
|
}
|
|
@ -1,13 +1,17 @@
|
||||||
//SPDX-License-Identifier: MIT
|
//SPDX-License-Identifier: MIT
|
||||||
pragma solidity ^0.8.2;
|
pragma solidity ^0.8.2;
|
||||||
|
|
||||||
import { Basic } from "../../common/basic.sol";
|
import {Basic} from "../../common/basic.sol";
|
||||||
import { Events } from "./events.sol";
|
import {Events} from "./events.sol";
|
||||||
import { IFluidMerkleDistributor } from "./interface.sol";
|
import {IFluidMerkleDistributor} from "./interface.sol";
|
||||||
|
import {TokenInterface} from "../../common/interfaces.sol";
|
||||||
|
|
||||||
abstract contract FluidMerkle is Basic, Events {
|
abstract contract FluidMerkle is Basic, Events {
|
||||||
|
IFluidMerkleDistributor internal constant MERKLE_DISTRIBUTOR =
|
||||||
|
IFluidMerkleDistributor(address(0));
|
||||||
|
|
||||||
address private constant MERKLE_DISTRIBUTOR = address(0);
|
TokenInterface internal constant TOKEN =
|
||||||
|
TokenInterface(0x6f40d4A6237C257fff2dB00FA0510DeEECd303eb);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Claims rewards from Fluid merkle distributor contract
|
* @dev Claims rewards from Fluid merkle distributor contract
|
||||||
|
@ -15,23 +19,41 @@ abstract contract FluidMerkle is Basic, Events {
|
||||||
* @param fToken_ Address of fToken on which rewards are being distributed.
|
* @param fToken_ Address of fToken on which rewards are being distributed.
|
||||||
* @param cycle_ Current epoch cycle.
|
* @param cycle_ Current epoch cycle.
|
||||||
* @param merkleProof_ Merkle proof that validates this claim.
|
* @param merkleProof_ Merkle proof that validates this claim.
|
||||||
* @param getId_ Id to get the cumulative amount.
|
* @param setId_ Id to set the rewards received.
|
||||||
*/
|
*/
|
||||||
function claim(
|
function claim(
|
||||||
uint256 cumulativeAmount_,
|
uint256 cumulativeAmount_,
|
||||||
address fToken_,
|
address fToken_,
|
||||||
uint256 cycle_,
|
uint256 cycle_,
|
||||||
bytes32[] calldata merkleProof_,
|
bytes32[] calldata merkleProof_,
|
||||||
uint256 getId_
|
uint256 setId_
|
||||||
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
)
|
||||||
uint256 _amt = getUint(getId_, cumulativeAmount_);
|
external
|
||||||
|
payable
|
||||||
|
returns (string memory _eventName, bytes memory _eventParam)
|
||||||
|
{
|
||||||
|
uint256 rewardsBeforeBal_ = TOKEN.balanceOf(address(this));
|
||||||
|
|
||||||
IFluidMerkleDistributor distributorContract_ = IFluidMerkleDistributor(MERKLE_DISTRIBUTOR);
|
MERKLE_DISTRIBUTOR.claim(
|
||||||
|
address(this),
|
||||||
|
cumulativeAmount_,
|
||||||
|
fToken_,
|
||||||
|
cycle_,
|
||||||
|
merkleProof_
|
||||||
|
);
|
||||||
|
|
||||||
distributorContract_.claim(address(this), _amt, fToken_, cycle_, merkleProof_);
|
uint256 rewardsClaimed_ = TOKEN.balanceOf(address(this)) -
|
||||||
|
rewardsBeforeBal_;
|
||||||
|
|
||||||
_eventName = "LogClaim(uint256,address,uint256,bytes32[],uint256)";
|
_eventName = "LogClaim(uint256,address,uint256,bytes32[],uint256,uint256)";
|
||||||
_eventParam = abi.encode(_amt, fToken_, cycle_, merkleProof_, getId_);
|
_eventParam = abi.encode(
|
||||||
|
cumulativeAmount_,
|
||||||
|
fToken_,
|
||||||
|
cycle_,
|
||||||
|
merkleProof_,
|
||||||
|
rewardsClaimed_,
|
||||||
|
setId_
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,7 +62,7 @@ abstract contract FluidMerkle is Basic, Events {
|
||||||
* @param fToken_ Address of fToken on which rewards are being distributed.
|
* @param fToken_ Address of fToken on which rewards are being distributed.
|
||||||
* @param cycle_ Current epoch cycle.
|
* @param cycle_ Current epoch cycle.
|
||||||
* @param merkleProof_ Merkle proof that validates this claim.
|
* @param merkleProof_ Merkle proof that validates this claim.
|
||||||
* @param getId_ Id to get the cumulative amount.
|
* @param setId_ Id to set the rewards received.
|
||||||
*/
|
*/
|
||||||
function claimOnBehalf(
|
function claimOnBehalf(
|
||||||
address recipient_,
|
address recipient_,
|
||||||
|
@ -48,16 +70,35 @@ abstract contract FluidMerkle is Basic, Events {
|
||||||
address fToken_,
|
address fToken_,
|
||||||
uint256 cycle_,
|
uint256 cycle_,
|
||||||
bytes32[] calldata merkleProof_,
|
bytes32[] calldata merkleProof_,
|
||||||
uint256 getId_
|
uint256 setId_
|
||||||
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
)
|
||||||
uint256 _amt = getUint(getId_, cumulativeAmount_);
|
external
|
||||||
|
payable
|
||||||
|
returns (string memory _eventName, bytes memory _eventParam)
|
||||||
|
{
|
||||||
|
uint256 rewardsBeforeBal_ = TOKEN.balanceOf(recipient_);
|
||||||
|
|
||||||
IFluidMerkleDistributor distributorContract_ = IFluidMerkleDistributor(MERKLE_DISTRIBUTOR);
|
MERKLE_DISTRIBUTOR.claim(
|
||||||
|
recipient_,
|
||||||
|
cumulativeAmount_,
|
||||||
|
fToken_,
|
||||||
|
cycle_,
|
||||||
|
merkleProof_
|
||||||
|
);
|
||||||
|
|
||||||
distributorContract_.claim(recipient_, _amt, fToken_, cycle_, merkleProof_);
|
uint256 rewardsClaimed_ = TOKEN.balanceOf(recipient_) -
|
||||||
|
rewardsBeforeBal_;
|
||||||
|
|
||||||
_eventName = "LogClaimOnBehalf(address,uint256,address,uint256,bytes32[],uint256)";
|
_eventName = "LogClaimOnBehalf(address,uint256,address,uint256,bytes32[],uint256,uint256)";
|
||||||
_eventParam = abi.encode(recipient_, _amt, fToken_, cycle_, merkleProof_, getId_);
|
_eventParam = abi.encode(
|
||||||
|
recipient_,
|
||||||
|
cumulativeAmount_,
|
||||||
|
fToken_,
|
||||||
|
cycle_,
|
||||||
|
merkleProof_,
|
||||||
|
rewardsClaimed_,
|
||||||
|
setId_
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user