From bdf6f16307b62779c8a4c48efdbe10d44291e06f Mon Sep 17 00:00:00 2001 From: Samarendra Gouda Date: Mon, 9 Dec 2024 09:22:10 +0530 Subject: [PATCH 1/3] fix: add morpho claim connector mainnet --- .../connectors/morpho-claim/events.sol | 11 ++++ .../connectors/morpho-claim/interfaces.sol | 11 ++++ .../mainnet/connectors/morpho-claim/main.sol | 59 +++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 contracts/mainnet/connectors/morpho-claim/events.sol create mode 100644 contracts/mainnet/connectors/morpho-claim/interfaces.sol create mode 100644 contracts/mainnet/connectors/morpho-claim/main.sol diff --git a/contracts/mainnet/connectors/morpho-claim/events.sol b/contracts/mainnet/connectors/morpho-claim/events.sol new file mode 100644 index 0000000..1a0d995 --- /dev/null +++ b/contracts/mainnet/connectors/morpho-claim/events.sol @@ -0,0 +1,11 @@ +//SPDX-License-Identifier: MIT +pragma solidity ^0.8.2; + +contract Events { + event LogClaimed( + address distributor, + address rewardToken, + uint256 claimableAmount, + uint256 setId + ); +} diff --git a/contracts/mainnet/connectors/morpho-claim/interfaces.sol b/contracts/mainnet/connectors/morpho-claim/interfaces.sol new file mode 100644 index 0000000..e2215c7 --- /dev/null +++ b/contracts/mainnet/connectors/morpho-claim/interfaces.sol @@ -0,0 +1,11 @@ +//SPDX-License-Identifier: MIT +pragma solidity ^0.8.2; + +interface IMorphoDistributor { + function claim( + address account, + address reward, + uint256 claimable, + bytes32[] calldata proof + ) external returns (uint256 amount); +} diff --git a/contracts/mainnet/connectors/morpho-claim/main.sol b/contracts/mainnet/connectors/morpho-claim/main.sol new file mode 100644 index 0000000..9b02122 --- /dev/null +++ b/contracts/mainnet/connectors/morpho-claim/main.sol @@ -0,0 +1,59 @@ +//SPDX-License-Identifier: MIT +pragma solidity ^0.8.2; + +/** + * @title Morpho rewards claim connector. + */ + +import {Stores} from "../../common/stores.sol"; +import {Events} from "./events.sol"; +import {IMorphoDistributor} from "./interfaces.sol"; + +abstract contract MorphoClaimConnector is Stores, Events { + /** + * + * @param distributorAddress Rewards distributor address. + * @param rewardToken Reward token address. + * @param claimableAmount Claimable amount. + * @param proof Merkle proof. + * @param setId Set claim amount to setId. + */ + function claim( + address distributorAddress, + address rewardToken, + uint256 claimableAmount, + bytes32[] calldata proof, + uint256 setId + ) + external + payable + returns (string memory _eventName, bytes memory _eventParam) + { + require(proof.length > 0, "proofs-empty"); + + IMorphoDistributor distributor = IMorphoDistributor( + distributorAddress + ); + + uint256 claimAmount = distributor.claim( + address(this), + rewardToken, + claimableAmount, + proof + ); + + setUint(setId, claimAmount); + + _eventName = "LogClaimed(address,uint256,uint256,uint256)"; + _eventParam = abi.encode( + distributorAddress, + rewardToken, + claimAmount, + setId + ); + } +} + +contract ConnectV2MorphoClaim is MorphoClaimConnector { + string public constant name = "Morpho-Claim-v1.0"; +} From 3e7d9ba49f22e70c3a9679502e7f5d2413f61671 Mon Sep 17 00:00:00 2001 From: Samarendra Gouda Date: Mon, 9 Dec 2024 09:23:04 +0530 Subject: [PATCH 2/3] fix: add morpho claim connector base --- .../base/connectors/morpho-claim/events.sol | 11 ++++ .../connectors/morpho-claim/interfaces.sol | 11 ++++ .../base/connectors/morpho-claim/main.sol | 59 +++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 contracts/base/connectors/morpho-claim/events.sol create mode 100644 contracts/base/connectors/morpho-claim/interfaces.sol create mode 100644 contracts/base/connectors/morpho-claim/main.sol diff --git a/contracts/base/connectors/morpho-claim/events.sol b/contracts/base/connectors/morpho-claim/events.sol new file mode 100644 index 0000000..1a0d995 --- /dev/null +++ b/contracts/base/connectors/morpho-claim/events.sol @@ -0,0 +1,11 @@ +//SPDX-License-Identifier: MIT +pragma solidity ^0.8.2; + +contract Events { + event LogClaimed( + address distributor, + address rewardToken, + uint256 claimableAmount, + uint256 setId + ); +} diff --git a/contracts/base/connectors/morpho-claim/interfaces.sol b/contracts/base/connectors/morpho-claim/interfaces.sol new file mode 100644 index 0000000..e2215c7 --- /dev/null +++ b/contracts/base/connectors/morpho-claim/interfaces.sol @@ -0,0 +1,11 @@ +//SPDX-License-Identifier: MIT +pragma solidity ^0.8.2; + +interface IMorphoDistributor { + function claim( + address account, + address reward, + uint256 claimable, + bytes32[] calldata proof + ) external returns (uint256 amount); +} diff --git a/contracts/base/connectors/morpho-claim/main.sol b/contracts/base/connectors/morpho-claim/main.sol new file mode 100644 index 0000000..9b02122 --- /dev/null +++ b/contracts/base/connectors/morpho-claim/main.sol @@ -0,0 +1,59 @@ +//SPDX-License-Identifier: MIT +pragma solidity ^0.8.2; + +/** + * @title Morpho rewards claim connector. + */ + +import {Stores} from "../../common/stores.sol"; +import {Events} from "./events.sol"; +import {IMorphoDistributor} from "./interfaces.sol"; + +abstract contract MorphoClaimConnector is Stores, Events { + /** + * + * @param distributorAddress Rewards distributor address. + * @param rewardToken Reward token address. + * @param claimableAmount Claimable amount. + * @param proof Merkle proof. + * @param setId Set claim amount to setId. + */ + function claim( + address distributorAddress, + address rewardToken, + uint256 claimableAmount, + bytes32[] calldata proof, + uint256 setId + ) + external + payable + returns (string memory _eventName, bytes memory _eventParam) + { + require(proof.length > 0, "proofs-empty"); + + IMorphoDistributor distributor = IMorphoDistributor( + distributorAddress + ); + + uint256 claimAmount = distributor.claim( + address(this), + rewardToken, + claimableAmount, + proof + ); + + setUint(setId, claimAmount); + + _eventName = "LogClaimed(address,uint256,uint256,uint256)"; + _eventParam = abi.encode( + distributorAddress, + rewardToken, + claimAmount, + setId + ); + } +} + +contract ConnectV2MorphoClaim is MorphoClaimConnector { + string public constant name = "Morpho-Claim-v1.0"; +} From 6a75715e80d364d7cc9188eaef731abff85457f5 Mon Sep 17 00:00:00 2001 From: Samarendra Gouda Date: Wed, 11 Dec 2024 19:17:12 +0530 Subject: [PATCH 3/3] fix: name --- contracts/base/connectors/morpho-claim/main.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/base/connectors/morpho-claim/main.sol b/contracts/base/connectors/morpho-claim/main.sol index 9b02122..f0bf02d 100644 --- a/contracts/base/connectors/morpho-claim/main.sol +++ b/contracts/base/connectors/morpho-claim/main.sol @@ -54,6 +54,6 @@ abstract contract MorphoClaimConnector is Stores, Events { } } -contract ConnectV2MorphoClaim is MorphoClaimConnector { - string public constant name = "Morpho-Claim-v1.0"; +contract ConnectV2MorphoClaimBase is MorphoClaimConnector { + string public constant name = "Morpho-Claim-Base-v1.0"; }