dsa-connectors/contracts/mainnet/connectors/compound/v3-rewards/main.sol

69 lines
2.1 KiB
Solidity
Raw Normal View History

2022-08-31 21:21:50 +00:00
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
/**
* @title Compound.
* @dev Rewards.
*/
2022-09-01 16:20:18 +00:00
import { TokenInterface } from "../../../common/interfaces.sol";
import { Stores } from "../../../common/stores.sol";
2022-08-31 21:21:50 +00:00
import { Helpers } from "./helpers.sol";
import { Events } from "./events.sol";
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 setId ID stores the amount of rewards claimed.
*/
function claimRewards(
address market,
uint256 setId
) public returns (string memory eventName_, bytes memory eventParam_) {
2022-09-06 15:23:54 +00:00
uint256 rewardsOwed = cometRewards.getRewardOwed(market, address(this)).owed;
cometRewards.claim(market, address(this), true);
2022-08-31 21:21:50 +00:00
setUint(setId, rewardsOwed);
2022-09-06 15:23:54 +00:00
eventName_ = "LogRewardsClaimed(address,address,uint256,uint256)";
eventParam_ = abi.encode(market, address(this), rewardsOwed, setId);
2022-08-31 21:21:50 +00:00
}
/**
* @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.
2022-09-06 15:23:54 +00:00
* @param owner The account of which the rewards are to be claimed.
2022-09-07 00:50:42 +00:00
* @param to The account where to transfer the claimed rewards.
2022-08-31 21:21:50 +00:00
* @param setId ID stores the amount of rewards claimed.
*/
2022-09-06 15:23:54 +00:00
function claimRewardsOnBehalfOf(
2022-08-31 21:21:50 +00:00
address market,
2022-09-06 15:23:54 +00:00
address owner,
2022-09-07 00:50:42 +00:00
address to,
2022-08-31 21:21:50 +00:00
uint256 setId
) public returns (string memory eventName_, bytes memory eventParam_) {
//in reward token decimals
2022-09-06 15:23:54 +00:00
uint256 rewardsOwed = cometRewards.getRewardOwed(market, owner).owed;
2022-09-07 00:50:42 +00:00
cometRewards.claimTo(market, owner, to, true);
2022-08-31 21:21:50 +00:00
setUint(setId, rewardsOwed);
2022-09-06 15:23:54 +00:00
eventName_ = "LogRewardsClaimedOnBehalf(address,address,address,uint256,uint256)";
2022-08-31 21:21:50 +00:00
eventParam_ = abi.encode(
market,
2022-09-06 15:23:54 +00:00
owner,
2022-09-07 00:50:42 +00:00
to,
2022-08-31 21:21:50 +00:00
rewardsOwed,
2022-09-06 15:23:54 +00:00
setId
2022-08-31 21:21:50 +00:00
);
}
}
contract ConnectV2CompoundV3Rewards is CompoundV3RewardsResolver {
string public name = "CompoundV3Rewards-v1.0";
}