This commit is contained in:
Richa-iitr 2022-09-06 20:53:54 +05:30
parent e27d41d309
commit 0952ebbcb4
3 changed files with 26 additions and 35 deletions

View File

@ -7,16 +7,14 @@ contract Events {
address indexed market,
address indexed account,
uint256 indexed totalClaimedInWei,
uint256 getId,
bool accrued
uint256 setId
);
event LogRewardsClaimedTo(
event LogRewardsClaimedOnBehalf(
address indexed market,
address indexed account,
address to,
address indexed owner,
address manager,
uint256 indexed totalClaimedInWei,
uint256 getId,
bool accrued
uint256 setId
);
}

View File

@ -17,55 +17,48 @@ abstract contract CompoundV3RewardsResolver is Events, Helpers {
* @dev Claim rewards and interests accrued in supplied/borrowed base asset.
* @notice Claim rewards and interests accrued.
* @param market The address of the market.
* @param account The account of which the rewards are to be claimed.
* @param accrue Should accrue the rewards and interest before claiming.
* @param setId ID stores the amount of rewards claimed.
*/
function claimRewards(
address market,
address account,
bool accrue,
uint256 setId
) public returns (string memory eventName_, bytes memory eventParam_) {
uint256 rewardsOwed = cometRewards.getRewardOwed(market, account).owed;
cometRewards.claim(market, account, accrue);
uint256 rewardsOwed = cometRewards.getRewardOwed(market, address(this)).owed;
cometRewards.claim(market, address(this), true);
setUint(setId, rewardsOwed);
eventName_ = "LogRewardsClaimed(address,address,uint256,uint256,bool)";
eventParam_ = abi.encode(market, account, rewardsOwed, setId, accrue);
eventName_ = "LogRewardsClaimed(address,address,uint256,uint256)";
eventParam_ = abi.encode(market, address(this), rewardsOwed, setId);
}
/**
* @dev Claim rewards and interests accrued in supplied/borrowed base asset.
* @notice Claim rewards and interests accrued and transfer to dest address.
* @param market The address of the market.
* @param account The account of which the rewards are to be claimed.
* @param dest The account where to transfer the claimed rewards.
* @param accrue Should accrue the rewards and interest before claiming.
* @param owner The account of which the rewards are to be claimed.
* @param manager The account where to transfer the claimed rewards.
* @param setId ID stores the amount of rewards claimed.
*/
function claimRewardsTo(
function claimRewardsOnBehalfOf(
address market,
address account,
address dest,
bool accrue,
address owner,
address manager,
uint256 setId
) public returns (string memory eventName_, bytes memory eventParam_) {
//in reward token decimals
uint256 rewardsOwed = cometRewards.getRewardOwed(market, account).owed;
cometRewards.claimTo(market, account, dest, accrue);
uint256 rewardsOwed = cometRewards.getRewardOwed(market, owner).owed;
cometRewards.claimTo(market, owner, manager, true);
setUint(setId, rewardsOwed);
eventName_ = "LogRewardsClaimedTo(address,address,address,uint256,uint256,bool)";
eventName_ = "LogRewardsClaimedOnBehalf(address,address,address,uint256,uint256)";
eventParam_ = abi.encode(
market,
account,
dest,
owner,
manager,
rewardsOwed,
setId,
accrue
setId
);
}
}

View File

@ -325,7 +325,7 @@ describe("Compound III Rewards", function () {
signer: masterSigner,
connectors: instaConnectorsV2
});
const amount = ethers.utils.parseUnits("400", 6);
const amount = ethers.utils.parseUnits("400", 6);
const spells = [
{
connector: "COMPOUND-V3-TEST-A",
@ -355,7 +355,7 @@ describe("Compound III Rewards", function () {
{
connector: connector_,
method: "claimRewards",
args: [market, dsaWallet0.address, true, 0]
args: [market, 0]
}
];
@ -395,8 +395,8 @@ describe("Compound III Rewards", function () {
const spells = [
{
connector: connector_,
method: "claimRewardsTo",
args: [market, dsaWallet0.address, dsaWallet1.address, true, 0]
method: "claimRewardsOnBehalfOf",
args: [market, dsaWallet0.address, dsaWallet1.address, 0]
}
];
@ -429,8 +429,8 @@ describe("Compound III Rewards", function () {
const spells = [
{
connector: connector_,
method: "claimRewardsTo",
args: [market, dsaWallet0.address, dsaWallet1.address, true, 0]
method: "claimRewardsOnBehalfOf",
args: [market, dsaWallet0.address, dsaWallet1.address, 0]
}
];