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 market,
address indexed account, address indexed account,
uint256 indexed totalClaimedInWei, uint256 indexed totalClaimedInWei,
uint256 getId, uint256 setId
bool accrued
); );
event LogRewardsClaimedTo( event LogRewardsClaimedOnBehalf(
address indexed market, address indexed market,
address indexed account, address indexed owner,
address to, address manager,
uint256 indexed totalClaimedInWei, uint256 indexed totalClaimedInWei,
uint256 getId, uint256 setId
bool accrued
); );
} }

View File

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

View File

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