mirror of
				https://github.com/Instadapp/dsa-connectors.git
				synced 2024-07-29 22:37:00 +00:00 
			
		
		
		
	rewards
This commit is contained in:
		
							parent
							
								
									ebc9e4cfde
								
							
						
					
					
						commit
						c2ae141388
					
				
							
								
								
									
										22
									
								
								contracts/mainnet/connectors/compound-rewards/events.sol
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								contracts/mainnet/connectors/compound-rewards/events.sol
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,22 @@
 | 
			
		|||
// SPDX-License-Identifier: MIT
 | 
			
		||||
pragma solidity ^0.7.6;
 | 
			
		||||
pragma experimental ABIEncoderV2;
 | 
			
		||||
 | 
			
		||||
contract Events {
 | 
			
		||||
	event LogRewardsClaimed(
 | 
			
		||||
		address indexed market,
 | 
			
		||||
		address indexed account,
 | 
			
		||||
		uint256 indexed totalClaimedInWei,
 | 
			
		||||
		uint256 getId,
 | 
			
		||||
		bool accrued
 | 
			
		||||
	);
 | 
			
		||||
 | 
			
		||||
	event LogRewardsClaimedTo(
 | 
			
		||||
		address indexed market,
 | 
			
		||||
		address indexed account,
 | 
			
		||||
		address to,
 | 
			
		||||
		uint256 indexed totalClaimedInWei,
 | 
			
		||||
		uint256 getId,
 | 
			
		||||
		bool accrued
 | 
			
		||||
	);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										13
									
								
								contracts/mainnet/connectors/compound-rewards/helpers.sol
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								contracts/mainnet/connectors/compound-rewards/helpers.sol
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
//SPDX-License-Identifier: MIT
 | 
			
		||||
pragma solidity ^0.7.0;
 | 
			
		||||
pragma abicoder v2;
 | 
			
		||||
 | 
			
		||||
import { TokenInterface } from "../../common/interfaces.sol";
 | 
			
		||||
import { DSMath } from "../../common/math.sol";
 | 
			
		||||
import { Basic } from "../../common/basic.sol";
 | 
			
		||||
import {  CometRewards } from "./interface.sol";
 | 
			
		||||
 | 
			
		||||
abstract contract Helpers is DSMath, Basic {
 | 
			
		||||
	CometRewards internal constant cometRewards =
 | 
			
		||||
		CometRewards(0x1B0e765F6224C21223AeA2af16c1C46E38885a40);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										37
									
								
								contracts/mainnet/connectors/compound-rewards/interface.sol
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								contracts/mainnet/connectors/compound-rewards/interface.sol
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,37 @@
 | 
			
		|||
//SPDX-License-Identifier: MIT
 | 
			
		||||
pragma solidity ^0.7.0;
 | 
			
		||||
pragma abicoder v2;
 | 
			
		||||
 | 
			
		||||
struct UserCollateral {
 | 
			
		||||
	uint128 balance;
 | 
			
		||||
	uint128 _reserved;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct RewardOwed {
 | 
			
		||||
	address token;
 | 
			
		||||
	uint256 owed;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface CometRewards {
 | 
			
		||||
	function claim(
 | 
			
		||||
		address comet,
 | 
			
		||||
		address src,
 | 
			
		||||
		bool shouldAccrue
 | 
			
		||||
	) external;
 | 
			
		||||
 | 
			
		||||
	function claimTo(
 | 
			
		||||
		address comet,
 | 
			
		||||
		address src,
 | 
			
		||||
		address to,
 | 
			
		||||
		bool shouldAccrue
 | 
			
		||||
	) external;
 | 
			
		||||
 | 
			
		||||
	function getRewardOwed(address comet, address account)
 | 
			
		||||
		external
 | 
			
		||||
		returns (RewardOwed memory);
 | 
			
		||||
 | 
			
		||||
	function rewardsClaimed(address cometProxy, address account)
 | 
			
		||||
		external
 | 
			
		||||
		view
 | 
			
		||||
		returns (uint256);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										75
									
								
								contracts/mainnet/connectors/compound-rewards/main.sol
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								contracts/mainnet/connectors/compound-rewards/main.sol
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,75 @@
 | 
			
		|||
//SPDX-License-Identifier: MIT
 | 
			
		||||
pragma solidity ^0.7.0;
 | 
			
		||||
pragma experimental ABIEncoderV2;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @title Compound.
 | 
			
		||||
 * @dev Rewards.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
import { TokenInterface } from "../../common/interfaces.sol";
 | 
			
		||||
import { Stores } from "../../common/stores.sol";
 | 
			
		||||
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 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);
 | 
			
		||||
 | 
			
		||||
		setUint(setId, rewardsOwed);
 | 
			
		||||
 | 
			
		||||
		eventName_ = "LogRewardsClaimed(address,address,uint256,uint256,bool)";
 | 
			
		||||
		eventParam_ = abi.encode(market, account, rewardsOwed, setId, accrue);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * @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 setId ID stores the amount of rewards claimed.
 | 
			
		||||
	 */
 | 
			
		||||
	function claimRewardsTo(
 | 
			
		||||
		address market,
 | 
			
		||||
		address account,
 | 
			
		||||
		address dest,
 | 
			
		||||
		bool accrue,
 | 
			
		||||
		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);
 | 
			
		||||
 | 
			
		||||
		setUint(setId, rewardsOwed);
 | 
			
		||||
 | 
			
		||||
		eventName_ = "LogRewardsClaimedTo(address,address,address,uint256,uint256,bool)";
 | 
			
		||||
		eventParam_ = abi.encode(
 | 
			
		||||
			market,
 | 
			
		||||
			account,
 | 
			
		||||
			dest,
 | 
			
		||||
			rewardsOwed,
 | 
			
		||||
			setId,
 | 
			
		||||
			accrue
 | 
			
		||||
		);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
contract ConnectV2CompoundV3Rewards is CompoundV3RewardsResolver {
 | 
			
		||||
	string public name = "CompoundV3Rewards-v1.0";
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user