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

feat: ClaimModuleV2 #56

Merged
merged 5 commits into from
Jan 8, 2025
Merged
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
70 changes: 70 additions & 0 deletions contracts/interfaces/IClaimV2Adapter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
Copyright 2020 Set Labs Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

SPDX-License-Identifier: Apache License, Version 2.0
*/

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import { ISetToken } from "../interfaces/ISetToken.sol";

pragma solidity 0.6.10;

/**
* @title IClaimV2Adapter
* @author Set Protocol (modified by Index Cooperative)
*
* Interface for claim adapters that support arbitrary claim data parameters.
* Extends the base IClaimAdapter functionality by allowing additional bytes data
* to be passed to claim calls.
*/
interface IClaimV2Adapter {

/**
* Generates the calldata for claiming tokens from the rewards pool
*
* @param _setToken the set token that is owed the tokens
* @param _rewardPool the rewards pool to claim from
* @param _claimData the claim data to use
*
* @return _subject the rewards pool to call
* @return _value the amount of ether to send in the call
* @return _calldata the calldata to use
*/
function getClaimCallData(
ISetToken _setToken,
address _rewardPool,
bytes calldata _claimData
) external view returns(address _subject, uint256 _value, bytes memory _calldata);

/**
* Gets the amount of unclaimed rewards
*
* @param _setToken the set token that is owed the tokens
* @param _rewardPool the rewards pool to check
*
* @return uint256 the amount of unclaimed rewards
*/
function getRewardsAmount(ISetToken _setToken, address _rewardPool) external view returns(uint256);

/**
* Gets the rewards token
*
* @param _rewardPool the rewards pool to check
*
* @return IERC20 the reward token
*/
function getTokenAddress(address _rewardPool) external view returns(IERC20);
}
72 changes: 72 additions & 0 deletions contracts/mocks/integrations/ClaimAdapterMockV2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// SPDX-License-Identifier: Apache License, Version 2.0
pragma solidity 0.6.10;

import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { ISetToken } from "../../interfaces/ISetToken.sol";
import { IClaimV2Adapter } from "../../interfaces/IClaimV2Adapter.sol";

contract ClaimAdapterMockV2 is ERC20, IClaimV2Adapter {
/* ============ State Variables ============ */
uint256 public rewards;
bytes public lastClaimData;

/* ============ Constructor ============ */
constructor() public ERC20("ClaimAdapterV2", "CLAIMV2") {}

/* ============ External Functions ============ */
function setRewards(uint256 _rewards) external {
rewards = _rewards;
}

function mint(bytes memory _claimData) external {
lastClaimData = _claimData;
_mint(msg.sender, rewards);
}

function getClaimCallData(
ISetToken _setToken,
address _rewardPool,
bytes memory _claimData
)
external
view
override
returns (address _subject, uint256 _value, bytes memory _callData)
{
// Quell compiler warnings about unused vars
_setToken;
_rewardPool;

bytes memory callData = abi.encodeWithSignature("mint(bytes)", _claimData);
return (address(this), 0, callData);
}

function getRewardsAmount(
ISetToken _setToken,
address _rewardPool
)
external
view
override
returns (uint256)
{
// Quell compiler warnings about unused vars
_setToken;
_rewardPool;

return rewards;
}

function getTokenAddress(address _rewardPool)
external
view
override
returns (IERC20)
{
// Quell compiler warnings about unused vars
_rewardPool;

return this;
}
}
Loading