Merge pull request #272 from Instadapp/Morpho-rewards

Rewards contract set up
This commit is contained in:
Thrilok kumar 2022-10-28 17:25:00 +05:30 committed by GitHub
commit 0f9e04b0c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 165 additions and 0 deletions

View File

@ -0,0 +1,25 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
contract Events {
event LogClaimedMorpho(
address account,
uint256 claimable,
uint256 setId
);
event LogClaimedAave(
address[] poolTokenAddresses,
bool tradeForMorphoToken,
uint256 amountOfRewards,
uint256 setId
);
event LogClaimedCompound(
address[] poolTokenAddresses,
bool tradeForMorphoToken,
uint256 amountOfRewards,
uint256 setId
);
}

View File

@ -0,0 +1,16 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
import "./interface.sol";
import { Basic } from "../../common/basic.sol";
abstract contract Helpers is Basic {
IMorphoCore public constant MORPHO_COMPOUND =
IMorphoCore(0x8888882f8f843896699869179fB6E4f7e3B58888);
IMorphoCore public constant MORPHO_AAVE =
IMorphoCore(0x777777c9898D384F785Ee44Acfe945efDFf5f3E0);
IMorphoRewardsDistributor public constant MORPHO_REWARDS =
IMorphoRewardsDistributor(0x3B14E5C73e0A56D607A8688098326fD4b4292135);
}

View File

@ -0,0 +1,17 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
interface IMorphoCore {
function claimRewards(
address[] calldata _tokenAddresses,
bool _tradeForMorphoToken
) external returns (uint256 _claimedAmount);
}
interface IMorphoRewardsDistributor {
function claim(
address _account,
uint256 _claimable,
bytes32[] calldata _proof
) external;
}

View File

@ -0,0 +1,107 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
import "./helpers.sol";
import "./events.sol";
/**
* @title Morpho Rewards.
* @dev Claim Morpho and Underlying Pool Rewards.
*/
abstract contract MorphoRewards is Helpers, Events {
/**
* @dev Claim Pending MORPHO Rewards.
* @notice Claims rewards.
* @param _account The address of the claimer.
* @param _claimable The overall claimable amount of token rewards.
* @param _proof The merkle proof that validates this claim.
*/
function claimMorpho(
address _account,
uint256 _claimable,
bytes32[] calldata _proof,
uint256 _setId
)
external
payable
returns (string memory _eventName, bytes memory _eventParam)
{
require(_proof.length > 0, "proofs-empty");
MORPHO_REWARDS.claim(_account, _claimable, _proof);
setUint(_setId, _claimable);
_eventName = "LogClaimedMorpho(address,uint256,uint256)";
_eventParam = abi.encode(_account, _claimable, _setId);
}
/**
* @dev Claim Underlying Pool Rewards.
* @notice Claims rewards for the given assets.
* @param _poolTokenAddresses The cToken addresses to claim rewards from.
* @param _tradeForMorphoToken Whether or not to trade reward tokens for MORPHO tokens.
* @param _setId Set ID for claimed amount(in COMP).
*/
function claimCompound(
address[] calldata _poolTokenAddresses,
bool _tradeForMorphoToken,
uint256 _setId
)
external
payable
returns (string memory _eventName, bytes memory _eventParam)
{
uint256 _amountOfRewards = MORPHO_COMPOUND.claimRewards(
_poolTokenAddresses,
_tradeForMorphoToken
);
setUint(_setId, _amountOfRewards);
_eventName = "LogClaimedCompound(address[],bool,uint256,uint256)";
_eventParam = abi.encode(
_poolTokenAddresses,
_tradeForMorphoToken,
_amountOfRewards,
_setId
);
}
/**
* @dev Claim Underlying Pool Rewards.
* @notice Claims rewards for the given assets.
* @param _poolTokenAddresses The assets to claim rewards from (aToken or variable debt token).
* @param _tradeForMorphoToken Whether or not to trade reward tokens for MORPHO tokens.
* @param _setId Set ID for claimed amount(in reward token).
*/
function claimAave(
address[] calldata _poolTokenAddresses,
bool _tradeForMorphoToken,
uint256 _setId
)
external
payable
returns (string memory _eventName, bytes memory _eventParam)
{
uint256 _amountOfRewards = MORPHO_AAVE.claimRewards(
_poolTokenAddresses,
_tradeForMorphoToken
);
setUint(_setId, _amountOfRewards);
_eventName = "LogClaimedAave(address[],bool,uint256,uint256)";
_eventParam = abi.encode(
_poolTokenAddresses,
_tradeForMorphoToken,
_amountOfRewards,
_setId
);
}
}
contract ConnectV2MorphoRewards is MorphoRewards {
string public constant name = "Morpho-Rewards-v1.0";
}