Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F/morpho claim #46

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions contracts/base/connectors/morpho-claim/events.sol
Original file line number Diff line number Diff line change
@@ -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
);
}
11 changes: 11 additions & 0 deletions contracts/base/connectors/morpho-claim/interfaces.sol
Original file line number Diff line number Diff line change
@@ -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);
}
59 changes: 59 additions & 0 deletions contracts/base/connectors/morpho-claim/main.sol
Original file line number Diff line number Diff line change
@@ -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 ConnectV2MorphoClaimBase is MorphoClaimConnector {
string public constant name = "Morpho-Claim-Base-v1.0";
}
11 changes: 11 additions & 0 deletions contracts/mainnet/connectors/morpho-claim/events.sol
Original file line number Diff line number Diff line change
@@ -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
);
}
11 changes: 11 additions & 0 deletions contracts/mainnet/connectors/morpho-claim/interfaces.sol
Original file line number Diff line number Diff line change
@@ -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);
}
59 changes: 59 additions & 0 deletions contracts/mainnet/connectors/morpho-claim/main.sol
Original file line number Diff line number Diff line change
@@ -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";
}