编译器
0.6.12+commit.27d51765
文件 1 的 34:Address.sol
pragma solidity >=0.6.2 <0.8.0;
library Address {
function isContract(address account) internal view returns (bool) {
uint256 size;
assembly { size := extcodesize(account) }
return size > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
文件 2 的 34:ArbitartorVault.sol
pragma solidity 0.6.12;
import "./Interfaces.sol";
import "@openzeppelin/contracts-0.6/math/SafeMath.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-0.6/utils/Address.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol";
contract ArbitratorVault{
using SafeERC20 for IERC20;
using Address for address;
using SafeMath for uint256;
address public operator;
address public immutable depositor;
constructor(address _depositor)public
{
operator = msg.sender;
depositor = _depositor;
}
function setOperator(address _op) external {
require(msg.sender == operator, "!auth");
operator = _op;
}
function distribute(address _token, uint256[] calldata _toPids, uint256[] calldata _amounts) external {
require(msg.sender == operator, "!auth");
for(uint256 i = 0; i < _toPids.length; i++){
(,,,,address stashAddress,bool shutdown) = IDeposit(depositor).poolInfo(_toPids[i]);
require(shutdown==false,"pool closed");
IERC20(_token).safeTransfer(stashAddress, _amounts[i]);
}
}
}
文件 3 的 34:BaseRewardPool.sol
pragma solidity 0.6.12;
import "./Interfaces.sol";
import "./interfaces/MathUtil.sol";
import "@openzeppelin/contracts-0.6/math/SafeMath.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-0.6/utils/Address.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol";
contract BaseRewardPool {
using SafeMath for uint256;
using SafeERC20 for IERC20;
IERC20 public immutable rewardToken;
IERC20 public immutable stakingToken;
uint256 public constant duration = 7 days;
address public immutable operator;
address public immutable rewardManager;
uint256 public immutable pid;
uint256 public periodFinish = 0;
uint256 public rewardRate = 0;
uint256 public lastUpdateTime;
uint256 public rewardPerTokenStored;
uint256 public queuedRewards = 0;
uint256 public currentRewards = 0;
uint256 public historicalRewards = 0;
uint256 public constant newRewardRatio = 830;
uint256 private _totalSupply;
mapping(address => uint256) public userRewardPerTokenPaid;
mapping(address => uint256) public rewards;
mapping(address => uint256) private _balances;
address[] public extraRewards;
event RewardAdded(uint256 reward);
event Staked(address indexed user, uint256 amount);
event Withdrawn(address indexed user, uint256 amount);
event RewardPaid(address indexed user, uint256 reward);
event Transfer(address indexed from, address indexed to, uint256 value);
constructor(
uint256 pid_,
address stakingToken_,
address rewardToken_,
address operator_,
address rewardManager_
) public {
pid = pid_;
stakingToken = IERC20(stakingToken_);
rewardToken = IERC20(rewardToken_);
operator = operator_;
rewardManager = rewardManager_;
}
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual returns (uint256) {
return _balances[account];
}
function extraRewardsLength() external view returns (uint256) {
return extraRewards.length;
}
function addExtraReward(address _reward) external returns(bool){
require(msg.sender == rewardManager, "!authorized");
require(_reward != address(0),"!reward setting");
if(extraRewards.length >= 12){
return false;
}
extraRewards.push(_reward);
return true;
}
function clearExtraRewards() external{
require(msg.sender == rewardManager, "!authorized");
delete extraRewards;
}
modifier updateReward(address account) {
rewardPerTokenStored = rewardPerToken();
lastUpdateTime = lastTimeRewardApplicable();
if (account != address(0)) {
rewards[account] = earned(account);
userRewardPerTokenPaid[account] = rewardPerTokenStored;
}
_;
}
function lastTimeRewardApplicable() public view returns (uint256) {
return MathUtil.min(block.timestamp, periodFinish);
}
function rewardPerToken() public view returns (uint256) {
if (totalSupply() == 0) {
return rewardPerTokenStored;
}
return
rewardPerTokenStored.add(
lastTimeRewardApplicable()
.sub(lastUpdateTime)
.mul(rewardRate)
.mul(1e18)
.div(totalSupply())
);
}
function earned(address account) public view returns (uint256) {
return
balanceOf(account)
.mul(rewardPerToken().sub(userRewardPerTokenPaid[account]))
.div(1e18)
.add(rewards[account]);
}
function stake(uint256 _amount)
public
returns(bool)
{
_processStake(_amount, msg.sender);
stakingToken.safeTransferFrom(msg.sender, address(this), _amount);
emit Staked(msg.sender, _amount);
return true;
}
function stakeAll() external returns(bool){
uint256 balance = stakingToken.balanceOf(msg.sender);
stake(balance);
return true;
}
function stakeFor(address _for, uint256 _amount)
public
returns(bool)
{
_processStake(_amount, _for);
stakingToken.safeTransferFrom(msg.sender, address(this), _amount);
emit Staked(_for, _amount);
return true;
}
function _processStake(uint256 _amount, address _receiver) internal updateReward(_receiver) {
require(_amount > 0, 'RewardPool : Cannot stake 0');
for(uint i=0; i < extraRewards.length; i++){
IRewards(extraRewards[i]).stake(_receiver, _amount);
}
_totalSupply = _totalSupply.add(_amount);
_balances[_receiver] = _balances[_receiver].add(_amount);
emit Transfer(address(0), _receiver, _amount);
}
function withdraw(uint256 amount, bool claim)
public
updateReward(msg.sender)
returns(bool)
{
require(amount > 0, 'RewardPool : Cannot withdraw 0');
for(uint i=0; i < extraRewards.length; i++){
IRewards(extraRewards[i]).withdraw(msg.sender, amount);
}
_totalSupply = _totalSupply.sub(amount);
_balances[msg.sender] = _balances[msg.sender].sub(amount);
stakingToken.safeTransfer(msg.sender, amount);
emit Withdrawn(msg.sender, amount);
if(claim){
getReward(msg.sender,true);
}
emit Transfer(msg.sender, address(0), amount);
return true;
}
function withdrawAll(bool claim) external{
withdraw(_balances[msg.sender],claim);
}
function withdrawAndUnwrap(uint256 amount, bool claim) public returns(bool){
_withdrawAndUnwrapTo(amount, msg.sender, msg.sender);
if(claim){
getReward(msg.sender,true);
}
return true;
}
function _withdrawAndUnwrapTo(uint256 amount, address from, address receiver) internal updateReward(from) returns(bool){
for(uint i=0; i < extraRewards.length; i++){
IRewards(extraRewards[i]).withdraw(from, amount);
}
_totalSupply = _totalSupply.sub(amount);
_balances[from] = _balances[from].sub(amount);
IDeposit(operator).withdrawTo(pid,amount,receiver);
emit Withdrawn(from, amount);
emit Transfer(from, address(0), amount);
return true;
}
function withdrawAllAndUnwrap(bool claim) external{
withdrawAndUnwrap(_balances[msg.sender],claim);
}
function getReward(address _account, bool _claimExtras) public updateReward(_account) returns(bool){
uint256 reward = earned(_account);
if (reward > 0) {
rewards[_account] = 0;
rewardToken.safeTransfer(_account, reward);
IDeposit(operator).rewardClaimed(pid, _account, reward);
emit RewardPaid(_account, reward);
}
if(_claimExtras){
for(uint i=0; i < extraRewards.length; i++){
IRewards(extraRewards[i]).getReward(_account);
}
}
return true;
}
function getReward() external returns(bool){
getReward(msg.sender,true);
return true;
}
function processIdleRewards() external {
if (block.timestamp >= periodFinish && queuedRewards > 0) {
notifyRewardAmount(queuedRewards);
queuedRewards = 0;
}
}
function queueNewRewards(uint256 _rewards) external returns(bool){
require(msg.sender == operator, "!authorized");
_rewards = _rewards.add(queuedRewards);
if (block.timestamp >= periodFinish) {
notifyRewardAmount(_rewards);
queuedRewards = 0;
return true;
}
uint256 elapsedTime = block.timestamp.sub(periodFinish.sub(duration));
uint256 currentAtNow = rewardRate * elapsedTime;
uint256 queuedRatio = currentAtNow.mul(1000).div(_rewards);
if(queuedRatio < newRewardRatio){
notifyRewardAmount(_rewards);
queuedRewards = 0;
}else{
queuedRewards = _rewards;
}
return true;
}
function notifyRewardAmount(uint256 reward)
internal
updateReward(address(0))
{
historicalRewards = historicalRewards.add(reward);
if (block.timestamp >= periodFinish) {
rewardRate = reward.div(duration);
} else {
uint256 remaining = periodFinish.sub(block.timestamp);
uint256 leftover = remaining.mul(rewardRate);
reward = reward.add(leftover);
rewardRate = reward.div(duration);
}
currentRewards = reward;
lastUpdateTime = block.timestamp;
periodFinish = block.timestamp.add(duration);
emit RewardAdded(reward);
}
}
文件 4 的 34:BaseRewardPool4626.sol
pragma solidity 0.6.12;
import { BaseRewardPool, IDeposit } from "./BaseRewardPool.sol";
import { IERC4626, IERC20Metadata } from "./interfaces/IERC4626.sol";
import { IERC20 } from "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts-0.6/utils/ReentrancyGuard.sol";
import { SafeERC20 } from "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol";
contract BaseRewardPool4626 is BaseRewardPool, ReentrancyGuard, IERC4626 {
using SafeERC20 for IERC20;
address public override asset;
mapping (address => mapping (address => uint256)) private _allowances;
constructor(
uint256 pid_,
address stakingToken_,
address rewardToken_,
address operator_,
address rewardManager_,
address lptoken_
) public BaseRewardPool(pid_, stakingToken_, rewardToken_, operator_, rewardManager_) {
asset = lptoken_;
IERC20(asset).safeApprove(operator_, type(uint256).max);
}
function totalAssets() external view virtual override returns(uint256){
return totalSupply();
}
function deposit(uint256 assets, address receiver) public virtual override nonReentrant returns (uint256) {
IERC20(asset).safeTransferFrom(msg.sender, address(this), assets);
uint256 balBefore = stakingToken.balanceOf(address(this));
IDeposit(operator).deposit(pid, assets, false);
uint256 balAfter = stakingToken.balanceOf(address(this));
require(balAfter.sub(balBefore) >= assets, "!deposit");
_processStake(assets, receiver);
emit Deposit(msg.sender, receiver, assets, assets);
emit Staked(receiver, assets);
return assets;
}
function mint(uint256 shares, address receiver) external virtual override returns (uint256) {
return deposit(shares, receiver);
}
function withdraw(
uint256 assets,
address receiver,
address owner
) public virtual override nonReentrant returns (uint256) {
if (msg.sender != owner) {
_approve(owner, msg.sender, _allowances[owner][msg.sender].sub(assets, "ERC4626: withdrawal amount exceeds allowance"));
}
_withdrawAndUnwrapTo(assets, owner, receiver);
emit Withdraw(msg.sender, receiver, owner, assets, assets);
return assets;
}
function redeem(
uint256 shares,
address receiver,
address owner
) external virtual override returns (uint256) {
return withdraw(shares, receiver, owner);
}
function convertToShares(uint256 assets) public view virtual override returns (uint256) {
return assets;
}
function convertToAssets(uint256 shares) public view virtual override returns (uint256) {
return shares;
}
function maxDeposit(address ) public view virtual override returns (uint256) {
return type(uint256).max;
}
function previewDeposit(uint256 assets) external view virtual override returns(uint256){
return convertToShares(assets);
}
function maxMint(address owner) external view virtual override returns (uint256) {
return maxDeposit(owner);
}
function previewMint(uint256 shares) external view virtual override returns(uint256){
return convertToAssets(shares);
}
function maxWithdraw(address owner) public view virtual override returns (uint256) {
return balanceOf(owner);
}
function previewWithdraw(uint256 assets) public view virtual override returns(uint256 shares){
return convertToShares(assets);
}
function maxRedeem(address owner) external view virtual override returns (uint256) {
return maxWithdraw(owner);
}
function previewRedeem(uint256 shares) external view virtual override returns(uint256){
return previewWithdraw(shares);
}
function name() external view override returns (string memory) {
return string(
abi.encodePacked(IERC20Metadata(address(stakingToken)).name(), " Vault")
);
}
function symbol() external view override returns (string memory) {
return string(
abi.encodePacked(IERC20Metadata(address(stakingToken)).symbol(), "-vault")
);
}
function decimals() external view override returns (uint8) {
return 18;
}
function totalSupply() public view override(BaseRewardPool, IERC20) returns (uint256) {
return BaseRewardPool.totalSupply();
}
function balanceOf(address account) public view override(BaseRewardPool, IERC20) returns (uint256) {
return BaseRewardPool.balanceOf(account);
}
function transfer(address , uint256 ) external override returns (bool) {
revert("ERC4626: Not supported");
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC4626: approve from the zero address");
require(spender != address(0), "ERC4626: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function transferFrom(address , address , uint256 ) external override returns (bool) {
revert("ERC4626: Not supported");
}
}
文件 5 的 34:Booster.sol
pragma solidity 0.6.12;
import "./Interfaces.sol";
import "@openzeppelin/contracts-0.6/math/SafeMath.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-0.6/utils/Address.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts-0.6/utils/ReentrancyGuard.sol";
contract Booster is ReentrancyGuard {
using SafeERC20 for IERC20;
using Address for address;
using SafeMath for uint256;
address public immutable crv;
address public immutable voteOwnership;
address public immutable voteParameter;
uint256 public lockIncentive = 825;
uint256 public stakerIncentive = 825;
uint256 public earmarkIncentive = 50;
uint256 public platformFee = 0;
uint256 public constant MaxFees = 4000;
uint256 public constant FEE_DENOMINATOR = 10000;
address public owner;
address public feeManager;
address public poolManager;
address public immutable staker;
address public immutable minter;
address public rewardFactory;
address public stashFactory;
address public tokenFactory;
address public rewardArbitrator;
address public voteDelegate;
address public treasury;
address public stakerRewards;
address public lockRewards;
address public bridgeDelegate;
mapping(uint256 => uint256) public l2FeesHistory;
uint256 immutable epochLength = 1 weeks;
mapping(address => FeeDistro) public feeTokens;
struct FeeDistro {
address distro;
address rewards;
bool active;
}
bool public isShutdown;
struct PoolInfo {
address lptoken;
address token;
address gauge;
address crvRewards;
address stash;
bool shutdown;
}
PoolInfo[] public poolInfo;
mapping(address => bool) public gaugeMap;
uint256 public constant REWARD_MULTIPLIER_DENOMINATOR = 10000;
mapping(address => uint256) public getRewardMultipliers;
event Deposited(address indexed user, uint256 indexed poolid, uint256 amount);
event Withdrawn(address indexed user, uint256 indexed poolid, uint256 amount);
event PoolAdded(address lpToken, address gauge, address token, address rewardPool, address stash, uint256 pid);
event PoolShutdown(uint256 poolId);
event OwnerUpdated(address newOwner);
event FeeManagerUpdated(address newFeeManager);
event PoolManagerUpdated(address newPoolManager);
event FactoriesUpdated(address rewardFactory, address stashFactory, address tokenFactory);
event ArbitratorUpdated(address newArbitrator);
event VoteDelegateUpdated(address newVoteDelegate);
event RewardContractsUpdated(address lockRewards, address stakerRewards);
event FeesUpdated(uint256 lockIncentive, uint256 stakerIncentive, uint256 earmarkIncentive, uint256 platformFee);
event TreasuryUpdated(address newTreasury);
event FeeInfoUpdated(address feeDistro, address lockFees, address feeToken);
event FeeInfoChanged(address feeDistro, bool active);
constructor(
address _staker,
address _minter,
address _crv,
address _voteOwnership,
address _voteParameter
) public {
staker = _staker;
minter = _minter;
crv = _crv;
voteOwnership = _voteOwnership;
voteParameter = _voteParameter;
isShutdown = false;
owner = msg.sender;
voteDelegate = msg.sender;
feeManager = msg.sender;
poolManager = msg.sender;
treasury = address(0);
emit OwnerUpdated(msg.sender);
emit VoteDelegateUpdated(msg.sender);
emit FeeManagerUpdated(msg.sender);
emit PoolManagerUpdated(msg.sender);
}
function setOwner(address _owner) external {
require(msg.sender == owner, "!auth");
owner = _owner;
emit OwnerUpdated(_owner);
}
function setFeeManager(address _feeM) external {
require(msg.sender == owner, "!auth");
feeManager = _feeM;
emit FeeManagerUpdated(_feeM);
}
function setPoolManager(address _poolM) external {
require(msg.sender == poolManager, "!auth");
poolManager = _poolM;
emit PoolManagerUpdated(_poolM);
}
function setFactories(address _rfactory, address _sfactory, address _tfactory) external {
require(msg.sender == owner, "!auth");
stashFactory = _sfactory;
if(rewardFactory == address(0)){
rewardFactory = _rfactory;
tokenFactory = _tfactory;
emit FactoriesUpdated(_rfactory, _sfactory, _tfactory);
} else {
emit FactoriesUpdated(address(0), _sfactory, address(0));
}
}
function setArbitrator(address _arb) external {
require(msg.sender==owner, "!auth");
rewardArbitrator = _arb;
emit ArbitratorUpdated(_arb);
}
function setVoteDelegate(address _voteDelegate) external {
require(msg.sender==owner, "!auth");
voteDelegate = _voteDelegate;
emit VoteDelegateUpdated(_voteDelegate);
}
function setRewardContracts(address _rewards, address _stakerRewards) external {
require(msg.sender == owner, "!auth");
if(lockRewards == address(0)){
lockRewards = _rewards;
stakerRewards = _stakerRewards;
getRewardMultipliers[lockRewards] = REWARD_MULTIPLIER_DENOMINATOR;
emit RewardContractsUpdated(_rewards, _stakerRewards);
}
}
function setFeeInfo(address _feeToken, address _feeDistro) external nonReentrant {
require(msg.sender == owner, "!auth");
require(!isShutdown, "shutdown");
require(lockRewards != address(0) && rewardFactory != address(0), "!initialised");
require(_feeToken != address(0) && _feeDistro != address(0), "!addresses");
require(IFeeDistributor(_feeDistro).getTokenTimeCursor(_feeToken) > 0, "!distro");
if(feeTokens[_feeToken].distro == address(0)){
require(!gaugeMap[_feeToken], "!token");
if(_feeToken == crv){
feeTokens[crv] = FeeDistro({
distro: _feeDistro,
rewards: lockRewards,
active: true
});
emit FeeInfoUpdated(_feeDistro, lockRewards, crv);
} else {
require(IRewards(lockRewards).extraRewardsLength() < 10, "too many rewards");
address rewards = IRewardFactory(rewardFactory).CreateTokenRewards(_feeToken, lockRewards, address(this));
feeTokens[_feeToken] = FeeDistro({
distro: _feeDistro,
rewards: rewards,
active: true
});
emit FeeInfoUpdated(_feeDistro, rewards, _feeToken);
}
} else {
feeTokens[_feeToken].distro = _feeDistro;
emit FeeInfoUpdated(_feeDistro, address(0), _feeToken);
}
}
function updateFeeInfo(address _feeToken, bool _active) external {
require(msg.sender==owner, "!auth");
require(feeTokens[_feeToken].distro != address(0), "Fee doesn't exist");
feeTokens[_feeToken].active = _active;
emit FeeInfoChanged(_feeToken, _active);
}
function setFees(uint256 _lockFees, uint256 _stakerFees, uint256 _callerFees, uint256 _platform) external nonReentrant{
require(msg.sender==feeManager, "!auth");
uint256 total = _lockFees.add(_stakerFees).add(_callerFees).add(_platform);
require(total <= MaxFees, ">MaxFees");
require(_lockFees >= 300 && _lockFees <= 3500, "!lockFees");
require(_stakerFees >= 300 && _stakerFees <= 1500, "!stakerFees");
require(_callerFees >= 10 && _callerFees <= 100, "!callerFees");
require(_platform <= 200, "!platform");
lockIncentive = _lockFees;
stakerIncentive = _stakerFees;
earmarkIncentive = _callerFees;
platformFee = _platform;
emit FeesUpdated(_lockFees, _stakerFees, _callerFees, _platform);
}
function setTreasury(address _treasury) external {
require(msg.sender==feeManager, "!auth");
treasury = _treasury;
emit TreasuryUpdated(_treasury);
}
function setBridgeDelegate(address _bridgeDelegate) external {
require(msg.sender == feeManager, "!auth");
bridgeDelegate = _bridgeDelegate;
}
function setRewardMultiplier(address rewardContract, uint256 multiplier) external {
require(msg.sender == feeManager, "!auth");
require(multiplier <= REWARD_MULTIPLIER_DENOMINATOR * 2, "too high");
getRewardMultipliers[rewardContract] = multiplier;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
function addPool(address _lptoken, address _gauge, uint256 _stashVersion) external returns(bool){
require(msg.sender==poolManager && !isShutdown, "!add");
require(_gauge != address(0) && _lptoken != address(0),"!param");
require(feeTokens[_gauge].distro == address(0), "!gauge");
uint256 pid = poolInfo.length;
address token = ITokenFactory(tokenFactory).CreateDepositToken(_lptoken);
address newRewardPool = IRewardFactory(rewardFactory).CreateCrvRewards(pid,token,_lptoken);
address stash = IStashFactory(stashFactory).CreateStash(pid,_gauge,staker,_stashVersion);
poolInfo.push(
PoolInfo({
lptoken: _lptoken,
token: token,
gauge: _gauge,
crvRewards: newRewardPool,
stash: stash,
shutdown: false
})
);
gaugeMap[_gauge] = true;
if(stash != address(0)){
poolInfo[pid].stash = stash;
IStaker(staker).setStashAccess(stash,true);
IRewardFactory(rewardFactory).setAccess(stash,true);
}
getRewardMultipliers[newRewardPool] = REWARD_MULTIPLIER_DENOMINATOR;
emit PoolAdded(_lptoken, _gauge, token, newRewardPool, stash, pid);
return true;
}
function shutdownPool(uint256 _pid) external nonReentrant returns(bool){
require(msg.sender==poolManager, "!auth");
PoolInfo storage pool = poolInfo[_pid];
try IStaker(staker).withdrawAll(pool.lptoken,pool.gauge){
}catch{}
pool.shutdown = true;
gaugeMap[pool.gauge] = false;
emit PoolShutdown(_pid);
return true;
}
function shutdownSystem() external{
require(msg.sender == owner, "!auth");
isShutdown = true;
for(uint i=0; i < poolInfo.length; i++){
PoolInfo storage pool = poolInfo[i];
if (pool.shutdown) continue;
address token = pool.lptoken;
address gauge = pool.gauge;
try IStaker(staker).withdrawAll(token,gauge){
pool.shutdown = true;
}catch{}
}
}
function deposit(uint256 _pid, uint256 _amount, bool _stake) public nonReentrant returns(bool){
require(!isShutdown,"shutdown");
PoolInfo storage pool = poolInfo[_pid];
require(pool.shutdown == false, "pool is closed");
address lptoken = pool.lptoken;
IERC20(lptoken).safeTransferFrom(msg.sender, staker, _amount);
address gauge = pool.gauge;
require(gauge != address(0),"!gauge setting");
IStaker(staker).deposit(lptoken,gauge);
address stash = pool.stash;
if(stash != address(0)){
IStash(stash).stashRewards();
}
address token = pool.token;
if(_stake){
ITokenMinter(token).mint(address(this),_amount);
address rewardContract = pool.crvRewards;
IERC20(token).safeApprove(rewardContract,0);
IERC20(token).safeApprove(rewardContract,_amount);
IRewards(rewardContract).stakeFor(msg.sender,_amount);
}else{
ITokenMinter(token).mint(msg.sender,_amount);
}
emit Deposited(msg.sender, _pid, _amount);
return true;
}
function depositAll(uint256 _pid, bool _stake) external returns(bool){
address lptoken = poolInfo[_pid].lptoken;
uint256 balance = IERC20(lptoken).balanceOf(msg.sender);
deposit(_pid,balance,_stake);
return true;
}
function _withdraw(uint256 _pid, uint256 _amount, address _from, address _to) internal nonReentrant {
PoolInfo storage pool = poolInfo[_pid];
address lptoken = pool.lptoken;
address gauge = pool.gauge;
address token = pool.token;
ITokenMinter(token).burn(_from,_amount);
if (!pool.shutdown) {
IStaker(staker).withdraw(lptoken,gauge, _amount);
}
address stash = pool.stash;
if(stash != address(0) && !isShutdown && !pool.shutdown){
IStash(stash).stashRewards();
}
IERC20(lptoken).safeTransfer(_to, _amount);
emit Withdrawn(_to, _pid, _amount);
}
function withdraw(uint256 _pid, uint256 _amount) public returns(bool){
_withdraw(_pid,_amount,msg.sender,msg.sender);
return true;
}
function withdrawAll(uint256 _pid) public returns(bool){
address token = poolInfo[_pid].token;
uint256 userBal = IERC20(token).balanceOf(msg.sender);
withdraw(_pid, userBal);
return true;
}
function withdrawTo(uint256 _pid, uint256 _amount, address _to) external returns(bool){
address rewardContract = poolInfo[_pid].crvRewards;
require(msg.sender == rewardContract,"!auth");
_withdraw(_pid,_amount,msg.sender,_to);
return true;
}
function setVote(bytes32 _hash) external returns(bool){
require(msg.sender == voteDelegate, "!auth");
IStaker(staker).setVote(_hash, false);
return true;
}
function setDelegate(address _delegateContract, address _delegate, bytes32 _space) external{
require(msg.sender == voteDelegate, "!auth");
bytes memory data = abi.encodeWithSelector(bytes4(keccak256("setDelegate(bytes32,address)")), _space, _delegate);
IStaker(staker).execute(_delegateContract,uint256(0),data);
}
function vote(uint256 _voteId, address _votingAddress, bool _support) external returns(bool){
require(msg.sender == voteDelegate, "!auth");
require(_votingAddress == voteOwnership || _votingAddress == voteParameter, "!voteAddr");
IStaker(staker).vote(_voteId,_votingAddress,_support);
return true;
}
function voteGaugeWeight(address[] calldata _gauge, uint256[] calldata _weight ) external returns(bool){
require(msg.sender == voteDelegate, "!auth");
for(uint256 i = 0; i < _gauge.length; i++){
IStaker(staker).voteGaugeWeight(_gauge[i],_weight[i]);
}
return true;
}
function claimRewards(uint256 _pid, address _gauge) external returns(bool){
address stash = poolInfo[_pid].stash;
require(msg.sender == stash,"!auth");
IStaker(staker).claimRewards(_gauge);
return true;
}
function setGaugeRedirect(uint256 _pid) external returns(bool){
address stash = poolInfo[_pid].stash;
require(msg.sender == stash,"!auth");
address gauge = poolInfo[_pid].gauge;
bytes memory data = abi.encodeWithSelector(bytes4(keccak256("set_rewards_receiver(address)")), stash);
IStaker(staker).execute(gauge,uint256(0),data);
return true;
}
function _earmarkRewards(uint256 _pid) internal {
PoolInfo storage pool = poolInfo[_pid];
require(pool.shutdown == false, "pool is closed");
address gauge = pool.gauge;
uint256 crvBBalBefore = IERC20(crv).balanceOf(address(this));
uint256 crvVBalBefore = IERC20(crv).balanceOf(staker);
uint256 crvBalBefore = crvBBalBefore.add(crvVBalBefore);
IStaker(staker).claimCrv(gauge);
uint256 crvBalAfter = IERC20(crv).balanceOf(address(this));
uint crvBal = crvBalAfter.sub(crvBalBefore);
if(crvBalBefore > 0 && treasury != address(0)) {
IERC20(crv).transfer(treasury, crvBalBefore);
}
address stash = pool.stash;
if(stash != address(0)){
IStash(stash).claimRewards();
IStash(stash).processStash();
}
if (crvBal > 0) {
uint256 _lockIncentive = crvBal.mul(lockIncentive).div(FEE_DENOMINATOR);
uint256 _stakerIncentive = crvBal.mul(stakerIncentive).div(FEE_DENOMINATOR);
uint256 _callIncentive = crvBal.mul(earmarkIncentive).div(FEE_DENOMINATOR);
if(treasury != address(0) && treasury != address(this) && platformFee > 0){
uint256 _platform = crvBal.mul(platformFee).div(FEE_DENOMINATOR);
crvBal = crvBal.sub(_platform);
IERC20(crv).safeTransfer(treasury, _platform);
}
crvBal = crvBal.sub(_lockIncentive).sub(_callIncentive).sub(_stakerIncentive);
IERC20(crv).safeTransfer(msg.sender, _callIncentive);
address rewardContract = pool.crvRewards;
IERC20(crv).safeTransfer(rewardContract, crvBal);
IRewards(rewardContract).queueNewRewards(crvBal);
IERC20(crv).safeTransfer(lockRewards, _lockIncentive);
IRewards(lockRewards).queueNewRewards(_lockIncentive);
IERC20(crv).safeTransfer(stakerRewards, _stakerIncentive);
}
}
function earmarkRewards(uint256 _pid) external nonReentrant returns(bool){
require(!isShutdown,"shutdown");
_earmarkRewards(_pid);
return true;
}
function earmarkFees(address _feeToken) external nonReentrant returns(bool){
require(!isShutdown,"shutdown");
FeeDistro memory feeDistro = feeTokens[_feeToken];
require(feeDistro.active, "Inactive distro");
require(!gaugeMap[_feeToken], "Invalid token");
uint256 tokenBalanceVBefore = IERC20(_feeToken).balanceOf(staker);
uint256 tokenBalanceBBefore = IERC20(_feeToken).balanceOf(address(this));
uint256 tokenBalanceBefore = tokenBalanceBBefore.add(tokenBalanceVBefore);
IStaker(staker).claimFees(feeDistro.distro, _feeToken);
uint256 tokenBalanceAfter = IERC20(_feeToken).balanceOf(address(this));
uint256 feesClaimed = tokenBalanceAfter.sub(tokenBalanceBefore);
IERC20(_feeToken).safeTransfer(feeDistro.rewards, feesClaimed);
IRewards(feeDistro.rewards).queueNewRewards(feesClaimed);
return true;
}
function rewardClaimed(uint256 _pid, address _address, uint256 _amount) external returns(bool){
address rewardContract = poolInfo[_pid].crvRewards;
require(msg.sender == rewardContract || msg.sender == lockRewards, "!auth");
uint256 mintAmount = _amount.mul(getRewardMultipliers[msg.sender]).div(REWARD_MULTIPLIER_DENOMINATOR);
if(mintAmount > 0) {
ITokenMinter(minter).mint(_address, mintAmount);
}
return true;
}
function distributeL2Fees(uint256 _amount) external nonReentrant {
require(msg.sender == bridgeDelegate, "!auth");
uint256 totalIncentives = lockIncentive.add(stakerIncentive);
uint256 totalFarmed = _amount.mul(FEE_DENOMINATOR).div(totalIncentives);
uint256 eligibleForMint = totalFarmed.sub(_amount);
uint256 epoch = block.timestamp.div(epochLength);
l2FeesHistory[epoch] = l2FeesHistory[epoch].add(totalFarmed);
require(l2FeesHistory[epoch] <= 70000e18, "Too many L2 Fees");
uint256 _lockIncentive = _amount.mul(lockIncentive).div(totalIncentives);
uint256 _stakerIncentive = _amount.sub(_lockIncentive);
IERC20(crv).safeTransferFrom(bridgeDelegate, lockRewards, _lockIncentive);
IRewards(lockRewards).queueNewRewards(_lockIncentive);
IERC20(crv).safeTransferFrom(bridgeDelegate, stakerRewards, _stakerIncentive);
ITokenMinter(minter).mint(bridgeDelegate, eligibleForMint);
}
}
文件 6 的 34:Context.sol
pragma solidity >=0.6.0 <0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this;
return msg.data;
}
}
文件 7 的 34:ConvexMasterChef.sol
pragma solidity 0.6.12;
import { ReentrancyGuard } from "@openzeppelin/contracts-0.6/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts-0.6/math/SafeMath.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts-0.6/utils/Context.sol";
import "@openzeppelin/contracts-0.6/access/Ownable.sol";
import "./interfaces/IRewarder.sol";
contract ConvexMasterChef is Ownable, ReentrancyGuard {
using SafeMath for uint256;
using SafeERC20 for IERC20;
struct UserInfo {
uint256 amount;
uint256 rewardDebt;
}
struct PoolInfo {
IERC20 lpToken;
uint256 allocPoint;
uint256 lastRewardBlock;
uint256 accCvxPerShare;
IRewarder rewarder;
}
IERC20 public immutable cvx;
uint256 public immutable rewardPerBlock;
uint256 public constant BONUS_MULTIPLIER = 2;
PoolInfo[] public poolInfo;
mapping(address => bool) public isAddedPool;
mapping(uint256 => mapping(address => UserInfo)) public userInfo;
uint256 public totalAllocPoint = 0;
uint256 public immutable startBlock;
uint256 public immutable endBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event RewardPaid(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(
address indexed user,
uint256 indexed pid,
uint256 amount
);
constructor(
IERC20 _cvx,
uint256 _rewardPerBlock,
uint256 _startBlock,
uint256 _endBlock
) public {
cvx = _cvx;
isAddedPool[address(_cvx)] = true;
rewardPerBlock = _rewardPerBlock;
startBlock = _startBlock;
endBlock = _endBlock;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
function add(
uint256 _allocPoint,
IERC20 _lpToken,
IRewarder _rewarder
) public onlyOwner nonReentrant {
require(poolInfo.length < 32, "max pools");
require(!isAddedPool[address(_lpToken)], "add: Duplicated LP Token");
isAddedPool[address(_lpToken)] = true;
massUpdatePools();
uint256 lastRewardBlock = block.number > startBlock
? block.number
: startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(
PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accCvxPerShare: 0,
rewarder: _rewarder
})
);
}
function set(
uint256 _pid,
uint256 _allocPoint,
IRewarder _rewarder,
bool _updateRewarder
) public onlyOwner nonReentrant {
massUpdatePools();
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(
_allocPoint
);
require(totalAllocPoint > 0, "!alloc");
poolInfo[_pid].allocPoint = _allocPoint;
if(_updateRewarder){
poolInfo[_pid].rewarder = _rewarder;
}
}
function getMultiplier(uint256 _from, uint256 _to)
public
view
returns (uint256)
{
uint256 clampedTo = _to > endBlock ? endBlock : _to;
uint256 clampedFrom = _from > endBlock ? endBlock : _from;
return clampedTo.sub(clampedFrom);
}
function pendingCvx(uint256 _pid, address _user)
external
view
returns (uint256)
{
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accCvxPerShare = pool.accCvxPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(
pool.lastRewardBlock,
block.number
);
uint256 cvxReward = multiplier
.mul(rewardPerBlock)
.mul(pool.allocPoint)
.div(totalAllocPoint);
accCvxPerShare = accCvxPerShare.add(
cvxReward.mul(1e12).div(lpSupply)
);
}
return user.amount.mul(accCvxPerShare).div(1e12).sub(user.rewardDebt);
}
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cvxReward = multiplier
.mul(rewardPerBlock)
.mul(pool.allocPoint)
.div(totalAllocPoint);
pool.accCvxPerShare = pool.accCvxPerShare.add(
cvxReward.mul(1e12).div(lpSupply)
);
pool.lastRewardBlock = block.number;
}
function deposit(uint256 _pid, uint256 _amount) public nonReentrant {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user
.amount
.mul(pool.accCvxPerShare)
.div(1e12)
.sub(user.rewardDebt);
safeRewardTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(
address(msg.sender),
address(this),
_amount
);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accCvxPerShare).div(1e12);
IRewarder _rewarder = pool.rewarder;
if (address(_rewarder) != address(0)) {
_rewarder.onReward(_pid, msg.sender, msg.sender, 0, user.amount);
}
emit Deposit(msg.sender, _pid, _amount);
}
function withdraw(uint256 _pid, uint256 _amount) public nonReentrant {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accCvxPerShare).div(1e12).sub(
user.rewardDebt
);
safeRewardTransfer(msg.sender, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accCvxPerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
IRewarder _rewarder = pool.rewarder;
if (address(_rewarder) != address(0)) {
_rewarder.onReward(_pid, msg.sender, msg.sender, pending, user.amount);
}
emit RewardPaid(msg.sender, _pid, pending);
emit Withdraw(msg.sender, _pid, _amount);
}
function claim(uint256 _pid, address _account) external nonReentrant {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_account];
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accCvxPerShare).div(1e12).sub(
user.rewardDebt
);
safeRewardTransfer(_account, pending);
user.rewardDebt = user.amount.mul(pool.accCvxPerShare).div(1e12);
IRewarder _rewarder = pool.rewarder;
if (address(_rewarder) != address(0)) {
_rewarder.onReward(_pid, _account, _account, pending, user.amount);
}
emit RewardPaid(_account, _pid, pending);
}
function emergencyWithdraw(uint256 _pid) public nonReentrant {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
IRewarder _rewarder = pool.rewarder;
if (address(_rewarder) != address(0)) {
_rewarder.onReward(_pid, msg.sender, msg.sender, 0, 0);
}
}
function safeRewardTransfer(address _to, uint256 _amount) internal {
uint256 cvxBal = cvx.balanceOf(address(this));
if (_amount > cvxBal) {
cvx.safeTransfer(_to, cvxBal);
} else {
cvx.safeTransfer(_to, _amount);
}
}
}
文件 8 的 34:CrvDepositor.sol
pragma solidity 0.6.12;
import "./Interfaces.sol";
import "@openzeppelin/contracts-0.6/math/SafeMath.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-0.6/utils/Address.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol";
contract CrvDepositor{
using SafeERC20 for IERC20;
using Address for address;
using SafeMath for uint256;
address public immutable crvBpt;
address public immutable escrow;
uint256 private constant MAXTIME = 1 * 364 * 86400;
uint256 private constant WEEK = 7 * 86400;
uint256 public lockIncentive = 10;
uint256 public constant FEE_DENOMINATOR = 10000;
address public feeManager;
address public daoOperator;
address public immutable staker;
address public immutable minter;
uint256 public incentiveCrv = 0;
uint256 public unlockTime;
bool public cooldown;
constructor(
address _staker,
address _minter,
address _crvBpt,
address _escrow,
address _daoOperator
) public {
staker = _staker;
minter = _minter;
crvBpt = _crvBpt;
escrow = _escrow;
feeManager = msg.sender;
daoOperator = _daoOperator;
}
function setFeeManager(address _feeManager) external {
require(msg.sender == feeManager, "!auth");
feeManager = _feeManager;
}
function setDaoOperator(address _daoOperator) external {
require(msg.sender == daoOperator, "!auth");
daoOperator = _daoOperator;
}
function setFees(uint256 _lockIncentive) external{
require(msg.sender==feeManager, "!auth");
if(_lockIncentive >= 0 && _lockIncentive <= 30){
lockIncentive = _lockIncentive;
}
}
function setCooldown(bool _cooldown) external {
require(msg.sender == daoOperator, "!auth");
cooldown = _cooldown;
}
function initialLock() external{
require(!cooldown, "cooldown");
require(msg.sender==feeManager, "!auth");
uint256 vecrv = IERC20(escrow).balanceOf(staker);
if(vecrv == 0){
uint256 unlockAt = block.timestamp + MAXTIME;
uint256 unlockInWeeks = (unlockAt/WEEK)*WEEK;
IStaker(staker).release();
uint256 crvBalanceStaker = IERC20(crvBpt).balanceOf(staker);
IStaker(staker).createLock(crvBalanceStaker, unlockAt);
unlockTime = unlockInWeeks;
}
}
function _lockCurve() internal {
if(cooldown) {
return;
}
uint256 crvBalance = IERC20(crvBpt).balanceOf(address(this));
if(crvBalance > 0){
IERC20(crvBpt).safeTransfer(staker, crvBalance);
}
uint256 crvBalanceStaker = IERC20(crvBpt).balanceOf(staker);
if(crvBalanceStaker == 0){
return;
}
IStaker(staker).increaseAmount(crvBalanceStaker);
uint256 unlockAt = block.timestamp + MAXTIME;
uint256 unlockInWeeks = (unlockAt/WEEK)*WEEK;
if(unlockInWeeks.sub(unlockTime) >= WEEK){
IStaker(staker).increaseTime(unlockAt);
unlockTime = unlockInWeeks;
}
}
function lockCurve() external {
require(!cooldown, "cooldown");
_lockCurve();
if(incentiveCrv > 0){
ITokenMinter(minter).mint(msg.sender,incentiveCrv);
incentiveCrv = 0;
}
}
function deposit(uint256 _amount, bool _lock, address _stakeAddress) public {
depositFor(msg.sender, _amount, _lock, _stakeAddress);
}
function depositFor(address to, uint256 _amount, bool _lock, address _stakeAddress) public {
require(_amount > 0,"!>0");
require(!cooldown, "cooldown");
if(_lock){
IERC20(crvBpt).safeTransferFrom(msg.sender, staker, _amount);
_lockCurve();
if(incentiveCrv > 0){
_amount = _amount.add(incentiveCrv);
incentiveCrv = 0;
}
}else{
IERC20(crvBpt).safeTransferFrom(msg.sender, address(this), _amount);
uint256 callIncentive = _amount.mul(lockIncentive).div(FEE_DENOMINATOR);
_amount = _amount.sub(callIncentive);
incentiveCrv = incentiveCrv.add(callIncentive);
}
bool depositOnly = _stakeAddress == address(0);
if(depositOnly){
ITokenMinter(minter).mint(to,_amount);
}else{
ITokenMinter(minter).mint(address(this),_amount);
IERC20(minter).safeApprove(_stakeAddress,0);
IERC20(minter).safeApprove(_stakeAddress,_amount);
IRewards(_stakeAddress).stakeFor(to,_amount);
}
}
function deposit(uint256 _amount, bool _lock) external {
deposit(_amount,_lock,address(0));
}
function depositAll(bool _lock, address _stakeAddress) external{
uint256 crvBal = IERC20(crvBpt).balanceOf(msg.sender);
deposit(crvBal,_lock,_stakeAddress);
}
}
文件 9 的 34:DepositToken.sol
pragma solidity 0.6.12;
import "./Interfaces.sol";
import "@openzeppelin/contracts-0.6/math/SafeMath.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-0.6/utils/Address.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/ERC20.sol";
contract DepositToken is ERC20 {
using SafeERC20 for IERC20;
using Address for address;
using SafeMath for uint256;
address public operator;
constructor(
address _operator,
address _lptoken,
string memory _namePostfix,
string memory _symbolPrefix
)
public
ERC20(
string(
abi.encodePacked(ERC20(_lptoken).name(), _namePostfix)
),
string(abi.encodePacked(_symbolPrefix, ERC20(_lptoken).symbol()))
)
{
operator = _operator;
}
function mint(address _to, uint256 _amount) external {
require(msg.sender == operator, "!authorized");
_mint(_to, _amount);
}
function burn(address _from, uint256 _amount) external {
require(msg.sender == operator, "!authorized");
_burn(_from, _amount);
}
}
文件 10 的 34:ERC20.sol
pragma solidity >=0.6.0 <0.8.0;
import "../../utils/Context.sol";
import "./IERC20.sol";
import "../../math/SafeMath.sol";
contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
constructor (string memory name_, string memory symbol_) public {
_name = name_;
_symbol = symbol_;
_decimals = 18;
}
function name() public view virtual returns (string memory) {
return _name;
}
function symbol() public view virtual returns (string memory) {
return _symbol;
}
function decimals() public view virtual returns (uint8) {
return _decimals;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _setupDecimals(uint8 decimals_) internal virtual {
_decimals = decimals_;
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
文件 11 的 34:ExtraRewardStashV3.sol
pragma solidity 0.6.12;
import "./Interfaces.sol";
import "./interfaces/IRewardHook.sol";
import "@openzeppelin/contracts-0.6/math/SafeMath.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-0.6/utils/Address.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol";
contract ExtraRewardStashV3 {
using SafeERC20 for IERC20;
using Address for address;
using SafeMath for uint256;
address public immutable crv;
uint256 private constant maxRewards = 8;
uint256 public pid;
address public operator;
address public staker;
address public gauge;
address public rewardFactory;
mapping(address => uint256) public historicalRewards;
bool public hasRedirected;
bool public hasCurveRewards;
struct TokenInfo {
address token;
address rewardAddress;
}
mapping(address => TokenInfo) public tokenInfo;
address[] public tokenList;
address public rewardHook;
constructor(address _crv) public {
crv = _crv;
}
function initialize(uint256 _pid, address _operator, address _staker, address _gauge, address _rFactory) external {
require(gauge == address(0),"!init");
pid = _pid;
operator = _operator;
staker = _staker;
gauge = _gauge;
rewardFactory = _rFactory;
}
function getName() external pure returns (string memory) {
return "ExtraRewardStashV3.2";
}
function tokenCount() external view returns (uint256){
return tokenList.length;
}
function claimRewards() external returns (bool) {
require(msg.sender == operator, "!operator");
checkForNewRewardTokens();
if(!hasRedirected){
IDeposit(operator).setGaugeRedirect(pid);
hasRedirected = true;
}
if(hasCurveRewards){
IDeposit(operator).claimRewards(pid,gauge);
}
if(rewardHook != address(0)){
try IRewardHook(rewardHook).onRewardClaim(){
}catch{}
}
return true;
}
function checkForNewRewardTokens() internal {
for(uint256 i = 0; i < maxRewards; i++){
address token = ICurveGauge(gauge).reward_tokens(i);
if (token == address(0)) {
break;
}
if(!hasCurveRewards){
hasCurveRewards = true;
}
setToken(token);
}
}
function setExtraReward(address _token) external{
require(IDeposit(operator).owner() == msg.sender, "!owner");
require(tokenList.length < 4, "too many rewards");
setToken(_token);
}
function setRewardHook(address _hook) external{
require(IDeposit(operator).owner() == msg.sender, "!owner");
rewardHook = _hook;
}
function setToken(address _token) internal {
TokenInfo storage t = tokenInfo[_token];
if(t.token == address(0) && _token != crv){
t.token = _token;
(,,,address mainRewardContract,,) = IDeposit(operator).poolInfo(pid);
address rewardContract = IRewardFactory(rewardFactory).CreateTokenRewards(
_token,
mainRewardContract,
address(this));
t.rewardAddress = rewardContract;
tokenList.push(_token);
}
}
function stashRewards() external pure returns(bool){
return true;
}
function processStash() external returns(bool){
require(msg.sender == operator, "!operator");
uint256 tCount = tokenList.length;
for(uint i=0; i < tCount; i++){
TokenInfo storage t = tokenInfo[tokenList[i]];
address token = t.token;
if(token == address(0)) continue;
uint256 amount = IERC20(token).balanceOf(address(this));
if (amount > 0) {
historicalRewards[token] = historicalRewards[token].add(amount);
address rewards = t.rewardAddress;
if(rewards == address(0)) continue;
IERC20(token).safeTransfer(rewards, amount);
IRewards(rewards).queueNewRewards(amount);
}
}
return true;
}
}
文件 12 的 34:IERC20.sol
pragma solidity >=0.6.0 <0.8.0;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
文件 13 的 34:IERC20Metadata.sol
pragma solidity 0.6.12;
import { IERC20 } from "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol";
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
文件 14 的 34:IERC4626.sol
pragma solidity 0.6.12;
import { IERC20Metadata } from "./IERC20Metadata.sol";
abstract contract IERC4626 is IERC20Metadata {
event Deposit(
address indexed caller,
address indexed owner,
uint256 assets,
uint256 shares
);
event Withdraw(
address indexed caller,
address indexed receiver,
address indexed owner,
uint256 assets,
uint256 shares
);
function asset() external view virtual returns(address);
function totalAssets() external view virtual returns(uint256);
function deposit(uint256 assets, address receiver) external virtual returns(uint256 shares);
function mint(uint256 shares, address receiver) external virtual returns(uint256 assets);
function withdraw(uint256 assets, address receiver, address owner) external virtual returns(uint256 shares);
function redeem(uint256 shares, address receiver, address owner) external virtual returns(uint256 assets);
function convertToShares(uint256 assets) external view virtual returns(uint256 shares);
function convertToAssets(uint256 shares) external view virtual returns(uint256 assets);
function maxDeposit(address owner) external view virtual returns(uint256 maxAssets);
function previewDeposit(uint256 assets) external view virtual returns(uint256 shares);
function maxMint(address owner) external view virtual returns(uint256 maxShares);
function previewMint(uint256 shares) external view virtual returns(uint256 assets);
function maxWithdraw(address owner) external view virtual returns(uint256 maxAssets);
function previewWithdraw(uint256 assets) external view virtual returns(uint256 shares);
function maxRedeem(address owner) external view virtual returns(uint256 maxShares);
function previewRedeem(uint256 shares) external view virtual returns(uint256 assets);
}
文件 15 的 34:IGaugeController.sol
pragma solidity 0.6.12;
interface IGaugeController {
function get_gauge_weight(address _gauge) external view returns(uint256);
function vote_user_slopes(address,address) external view returns(uint256,uint256,uint256);
function vote_for_gauge_weights(address,uint256) external;
function add_gauge(address,int128,uint256) external;
}
文件 16 的 34:IProxyFactory.sol
pragma solidity 0.6.12;
interface IProxyFactory {
function clone(address _target) external returns(address);
}
文件 17 的 34:IRewardHook.sol
pragma solidity 0.6.12;
interface IRewardHook {
function onRewardClaim() external;
}
文件 18 的 34:IRewarder.sol
pragma solidity 0.6.12;
import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol";
interface IRewarder {
using SafeERC20 for IERC20;
function onReward(uint256 pid, address user, address recipient, uint256 sushiAmount, uint256 newLpAmount) external;
function pendingTokens(uint256 pid, address user, uint256 sushiAmount) external view returns (IERC20[] memory, uint256[] memory);
}
文件 19 的 34:Interfaces.sol
pragma solidity 0.6.12;
interface ICurveGauge {
function deposit(uint256) external;
function balanceOf(address) external view returns (uint256);
function withdraw(uint256) external;
function claim_rewards() external;
function reward_tokens(uint256) external view returns(address);
function rewarded_token() external view returns(address);
function lp_token() external view returns(address);
}
interface ICurveVoteEscrow {
function create_lock(uint256, uint256) external;
function increase_amount(uint256) external;
function increase_unlock_time(uint256) external;
function withdraw() external;
function smart_wallet_checker() external view returns (address);
function commit_smart_wallet_checker(address) external;
function apply_smart_wallet_checker() external;
}
interface IWalletChecker {
function check(address) external view returns (bool);
function approveWallet(address) external;
function dao() external view returns (address);
}
interface IVoting{
function vote(uint256, bool, bool) external;
function getVote(uint256) external view returns(bool,bool,uint64,uint64,uint64,uint64,uint256,uint256,uint256,bytes memory);
function vote_for_gauge_weights(address,uint256) external;
}
interface IMinter{
function mint(address) external;
}
interface IStaker{
function deposit(address, address) external returns (bool);
function withdraw(address) external returns (uint256);
function withdraw(address, address, uint256) external returns (bool);
function withdrawAll(address, address) external returns (bool);
function createLock(uint256, uint256) external returns(bool);
function increaseAmount(uint256) external returns(bool);
function increaseTime(uint256) external returns(bool);
function release() external returns(bool);
function claimCrv(address) external returns (uint256);
function claimRewards(address) external returns(bool);
function claimFees(address,address) external returns (uint256);
function setStashAccess(address, bool) external returns (bool);
function vote(uint256,address,bool) external returns(bool);
function voteGaugeWeight(address,uint256) external returns(bool);
function balanceOfPool(address) external view returns (uint256);
function operator() external view returns (address);
function execute(address _to, uint256 _value, bytes calldata _data) external returns (bool, bytes memory);
function setVote(bytes32 hash, bool valid) external;
function migrate(address to) external;
}
interface IRewards{
function stake(address, uint256) external;
function stakeFor(address, uint256) external;
function withdraw(address, uint256) external;
function exit(address) external;
function getReward(address) external;
function queueNewRewards(uint256) external;
function notifyRewardAmount(uint256) external;
function addExtraReward(address) external;
function extraRewardsLength() external view returns (uint256);
function stakingToken() external view returns (address);
function rewardToken() external view returns(address);
function earned(address account) external view returns (uint256);
}
interface IStash{
function stashRewards() external returns (bool);
function processStash() external returns (bool);
function claimRewards() external returns (bool);
function initialize(uint256 _pid, address _operator, address _staker, address _gauge, address _rewardFactory) external;
}
interface IFeeDistributor {
function claimToken(address user, address token) external returns (uint256);
function claimTokens(address user, address[] calldata tokens) external returns (uint256[] memory);
function getTokenTimeCursor(address token) external view returns (uint256);
}
interface ITokenMinter{
function mint(address,uint256) external;
function burn(address,uint256) external;
}
interface IDeposit{
function isShutdown() external view returns(bool);
function balanceOf(address _account) external view returns(uint256);
function totalSupply() external view returns(uint256);
function poolInfo(uint256) external view returns(address,address,address,address,address, bool);
function rewardClaimed(uint256,address,uint256) external;
function withdrawTo(uint256,uint256,address) external;
function claimRewards(uint256,address) external returns(bool);
function rewardArbitrator() external returns(address);
function setGaugeRedirect(uint256 _pid) external returns(bool);
function owner() external returns(address);
function deposit(uint256 _pid, uint256 _amount, bool _stake) external returns(bool);
}
interface ICrvDeposit{
function deposit(uint256, bool) external;
function lockIncentive() external view returns(uint256);
}
interface IRewardFactory{
function setAccess(address,bool) external;
function CreateCrvRewards(uint256,address,address) external returns(address);
function CreateTokenRewards(address,address,address) external returns(address);
function activeRewardCount(address) external view returns(uint256);
function addActiveReward(address,uint256) external returns(bool);
function removeActiveReward(address,uint256) external returns(bool);
}
interface IStashFactory{
function CreateStash(uint256,address,address,uint256) external returns(address);
}
interface ITokenFactory{
function CreateDepositToken(address) external returns(address);
}
interface IPools{
function addPool(address _lptoken, address _gauge, uint256 _stashVersion) external returns(bool);
function forceAddPool(address _lptoken, address _gauge, uint256 _stashVersion) external returns(bool);
function shutdownPool(uint256 _pid) external returns(bool);
function poolInfo(uint256) external view returns(address,address,address,address,address,bool);
function poolLength() external view returns (uint256);
function gaugeMap(address) external view returns(bool);
function setPoolManager(address _poolM) external;
}
interface IVestedEscrow{
function fund(address[] calldata _recipient, uint256[] calldata _amount) external returns(bool);
}
interface IRewardDeposit {
function addReward(address, uint256) external;
}
文件 20 的 34:MathUtil.sol
pragma solidity 0.6.12;
library MathUtil {
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
}
文件 21 的 34:Ownable.sol
pragma solidity >=0.6.0 <0.8.0;
import "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view virtual returns (address) {
return _owner;
}
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
文件 22 的 34:PoolManagerProxy.sol
pragma solidity 0.6.12;
import "./Interfaces.sol";
contract PoolManagerProxy{
address public immutable pools;
address public owner;
address public operator;
constructor(
address _pools,
address _owner
) public {
pools = _pools;
owner = _owner;
operator = msg.sender;
}
modifier onlyOwner() {
require(owner == msg.sender, "!owner");
_;
}
modifier onlyOperator() {
require(operator == msg.sender, "!op");
_;
}
function setOwner(address _owner) external onlyOwner{
owner = _owner;
}
function setOperator(address _operator) external onlyOwner{
operator = _operator;
}
function shutdownPool(uint256 _pid) external onlyOperator returns(bool){
return IPools(pools).shutdownPool(_pid);
}
function addPool(address _lptoken, address _gauge, uint256 _stashVersion) external onlyOperator returns(bool){
require(_gauge != address(0),"gauge is 0");
require(_lptoken != address(0),"lp token is 0");
bool gaugeExists = IPools(pools).gaugeMap(_gauge);
require(!gaugeExists, "already registered gauge");
gaugeExists = IPools(pools).gaugeMap(_lptoken);
require(!gaugeExists, "already registered lptoken");
return IPools(pools).addPool(_lptoken,_gauge,_stashVersion);
}
}
文件 23 的 34:PoolManagerSecondaryProxy.sol
pragma solidity 0.6.12;
import "./Interfaces.sol";
import "./interfaces/IGaugeController.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-0.6/math/SafeMath.sol";
contract PoolManagerSecondaryProxy{
using SafeMath for uint256;
address public immutable gaugeController;
address public immutable pools;
address public immutable booster;
address public owner;
address public operator;
bool public isShutdown;
mapping(address => bool) public usedMap;
constructor(
address _gaugeController,
address _pools,
address _booster,
address _owner
) public {
gaugeController = _gaugeController;
pools = _pools;
booster = _booster;
owner = _owner;
operator = msg.sender;
}
modifier onlyOwner() {
require(owner == msg.sender, "!owner");
_;
}
modifier onlyOperator() {
require(operator == msg.sender, "!op");
_;
}
function setOwner(address _owner) external onlyOwner{
owner = _owner;
}
function setOperator(address _operator) external onlyOwner{
operator = _operator;
}
function setUsedAddress(address[] memory usedList) external onlyOwner{
for(uint i=0; i < usedList.length; i++){
usedMap[usedList[i]] = true;
}
}
function shutdownSystem() external onlyOwner{
isShutdown = true;
}
function shutdownPool(uint256 _pid) external onlyOperator returns(bool){
(address lptoken, address depositToken,,,,bool isshutdown) = IPools(booster).poolInfo(_pid);
require(!isshutdown, "already shutdown");
uint256 beforeBalance = IERC20(lptoken).balanceOf(booster);
IPools(pools).shutdownPool(_pid);
uint256 afterBalance = IERC20(lptoken).balanceOf(booster);
require( afterBalance.sub(beforeBalance) >= IERC20(depositToken).totalSupply(), "supply mismatch");
return true;
}
function addPool(address _lptoken, address _gauge, uint256 _stashVersion) external onlyOperator returns(bool){
uint256 weight = IGaugeController(gaugeController).get_gauge_weight(_gauge);
require(weight > 0, "must have weight");
return _addPool(_lptoken, _gauge, _stashVersion);
}
function forceAddPool(address _lptoken, address _gauge, uint256 _stashVersion) external onlyOperator returns(bool){
require(!usedMap[_lptoken] && !usedMap[_gauge], "cant force used pool");
return _addPool(_lptoken, _gauge, _stashVersion);
}
function _addPool(address _lptoken, address _gauge, uint256 _stashVersion) internal returns(bool){
require(!isShutdown, "shutdown");
usedMap[_lptoken] = true;
usedMap[_gauge] = true;
return IPools(pools).addPool(_lptoken,_gauge,_stashVersion);
}
}
文件 24 的 34:PoolManagerV3.sol
pragma solidity 0.6.12;
import "./Interfaces.sol";
import "./interfaces/IGaugeController.sol";
contract PoolManagerV3{
address public immutable pools;
address public immutable gaugeController;
address public operator;
bool public protectAddPool;
constructor(
address _pools,
address _gaugeController,
address _operator
) public {
pools = _pools;
gaugeController = _gaugeController;
operator = _operator;
protectAddPool = true;
}
function setOperator(address _operator) external {
require(msg.sender == operator, "!auth");
operator = _operator;
}
function setProtectPool(bool _protectAddPool) external {
require(msg.sender == operator, "!auth");
protectAddPool = _protectAddPool;
}
function addPool(address _gauge) external returns(bool){
_addPool(_gauge,3);
return true;
}
function addPool(address _gauge, uint256 _stashVersion) external returns(bool){
_addPool(_gauge,_stashVersion);
return true;
}
function _addPool(address _gauge, uint256 _stashVersion) internal{
if(protectAddPool) {
require(msg.sender == operator, "!auth");
}
address lptoken = ICurveGauge(_gauge).lp_token();
IPools(pools).addPool(lptoken,_gauge,_stashVersion);
}
function forceAddPool(address _lptoken, address _gauge, uint256 _stashVersion) external returns(bool){
require(msg.sender==operator, "!auth");
return IPools(pools).forceAddPool(_lptoken, _gauge, _stashVersion);
}
function shutdownPool(uint256 _pid) external returns(bool){
require(msg.sender==operator, "!auth");
IPools(pools).shutdownPool(_pid);
return true;
}
}
文件 25 的 34:ReentrancyGuard.sol
pragma solidity >=0.6.0 <0.8.0;
abstract contract ReentrancyGuard {
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor () internal {
_status = _NOT_ENTERED;
}
modifier nonReentrant() {
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
_status = _ENTERED;
_;
_status = _NOT_ENTERED;
}
}
文件 26 的 34:RewardFactory.sol
pragma solidity 0.6.12;
import "./Interfaces.sol";
import "./BaseRewardPool4626.sol";
import "./VirtualBalanceRewardPool.sol";
import "@openzeppelin/contracts-0.6/math/SafeMath.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-0.6/utils/Address.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol";
contract RewardFactory {
using Address for address;
address public immutable operator;
address public immutable crv;
mapping (address => bool) private rewardAccess;
mapping(address => uint256[]) public rewardActiveList;
event RewardPoolCreated(address rewardPool, uint256 _pid, address depositToken);
event TokenRewardPoolCreated(address rewardPool, address token, address mainRewards, address operator);
event AccessChanged(address stash, bool hasAccess);
constructor(address _operator, address _crv) public {
operator = _operator;
crv = _crv;
}
function setAccess(address _stash, bool _status) external{
require(msg.sender == operator, "!auth");
rewardAccess[_stash] = _status;
emit AccessChanged(_stash, _status);
}
function CreateCrvRewards(uint256 _pid, address _depositToken, address _lptoken) external returns (address) {
require(msg.sender == operator, "!auth");
BaseRewardPool4626 rewardPool = new BaseRewardPool4626(_pid,_depositToken,crv,operator, address(this), _lptoken);
emit RewardPoolCreated(address(rewardPool), _pid, _depositToken);
return address(rewardPool);
}
function CreateTokenRewards(address _token, address _mainRewards, address _operator) external returns (address) {
require(msg.sender == operator || rewardAccess[msg.sender] == true, "!auth");
VirtualBalanceRewardPool rewardPool = new VirtualBalanceRewardPool(_mainRewards,_token,_operator);
address rAddress = address(rewardPool);
IRewards(_mainRewards).addExtraReward(rAddress);
emit TokenRewardPoolCreated(rAddress, _token, _mainRewards, _operator);
return rAddress;
}
}
文件 27 的 34:RewardHook.sol
pragma solidity 0.6.12;
import "@openzeppelin/contracts-0.6/utils/Address.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts-0.6/math/SafeMath.sol";
contract RewardHook{
using SafeERC20 for IERC20;
using Address for address;
using SafeMath for uint256;
address public immutable stash;
address public immutable rewardToken;
constructor(address _stash, address _reward) public {
stash = _stash;
rewardToken = _reward;
}
function onRewardClaim() external{
uint256 bal = IERC20(rewardToken).balanceOf(address(this));
IERC20(rewardToken).safeTransfer(stash,bal);
}
}
文件 28 的 34:SafeERC20.sol
pragma solidity >=0.6.0 <0.8.0;
import "./IERC20.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint256 value) internal {
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function _callOptionalReturn(IERC20 token, bytes memory data) private {
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
文件 29 的 34:SafeMath.sol
pragma solidity >=0.6.0 <0.8.0;
library SafeMath {
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b > a) return (false, 0);
return (true, a - b);
}
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a / b);
}
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a % b);
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) return 0;
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
return a / b;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: modulo by zero");
return a % b;
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
return a - b;
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a % b;
}
}
文件 30 的 34:StashFactoryV2.sol
pragma solidity 0.6.12;
import "./Interfaces.sol";
import "./interfaces/IProxyFactory.sol";
import "@openzeppelin/contracts-0.6/math/SafeMath.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-0.6/utils/Address.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol";
contract StashFactoryV2 {
using Address for address;
bytes4 private constant rewarded_token = 0x16fa50b1;
bytes4 private constant reward_tokens = 0x54c49fe9;
bytes4 private constant rewards_receiver = 0x01ddabf1;
address public immutable operator;
address public immutable rewardFactory;
address public immutable proxyFactory;
address public v1Implementation;
address public v2Implementation;
address public v3Implementation;
event StashCreated(address stash, uint256 stashVersion);
constructor(address _operator, address _rewardFactory, address _proxyFactory) public {
operator = _operator;
rewardFactory = _rewardFactory;
proxyFactory = _proxyFactory;
}
function setImplementation(address _v1, address _v2, address _v3) external{
require(msg.sender == IDeposit(operator).owner(),"!auth");
v1Implementation = _v1;
v2Implementation = _v2;
v3Implementation = _v3;
}
function CreateStash(uint256 _pid, address _gauge, address _staker, uint256 _stashVersion) external returns(address){
require(msg.sender == operator, "!authorized");
require(_gauge != address(0), "!gauge");
if(_stashVersion == uint256(3) && IsV3(_gauge)){
require(v3Implementation!=address(0),"0 impl");
address stash = IProxyFactory(proxyFactory).clone(v3Implementation);
IStash(stash).initialize(_pid,operator,_staker,_gauge,rewardFactory);
emit StashCreated(stash, _stashVersion);
return stash;
}else if(_stashVersion == uint256(1) && IsV1(_gauge)){
require(v1Implementation!=address(0),"0 impl");
address stash = IProxyFactory(proxyFactory).clone(v1Implementation);
IStash(stash).initialize(_pid,operator,_staker,_gauge,rewardFactory);
emit StashCreated(stash, _stashVersion);
return stash;
}else if(_stashVersion == uint256(2) && !IsV3(_gauge) && IsV2(_gauge)){
require(v2Implementation!=address(0),"0 impl");
address stash = IProxyFactory(proxyFactory).clone(v2Implementation);
IStash(stash).initialize(_pid,operator,_staker,_gauge,rewardFactory);
emit StashCreated(stash, _stashVersion);
return stash;
}
bool isV1 = IsV1(_gauge);
bool isV2 = IsV2(_gauge);
bool isV3 = IsV3(_gauge);
require(!isV1 && !isV2 && !isV3,"stash version mismatch");
return address(0);
}
function IsV1(address _gauge) private returns(bool){
bytes memory data = abi.encode(rewarded_token);
(bool success,) = _gauge.call(data);
return success;
}
function IsV2(address _gauge) private returns(bool){
bytes memory data = abi.encodeWithSelector(reward_tokens,uint256(0));
(bool success,) = _gauge.call(data);
return success;
}
function IsV3(address _gauge) private returns(bool){
bytes memory data = abi.encodeWithSelector(rewards_receiver,address(0));
(bool success,) = _gauge.call(data);
return success;
}
}
文件 31 的 34:TokenFactory.sol
pragma solidity 0.6.12;
import "./Interfaces.sol";
import "./DepositToken.sol";
import "@openzeppelin/contracts-0.6/math/SafeMath.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-0.6/utils/Address.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol";
contract TokenFactory {
using Address for address;
address public immutable operator;
string public namePostfix;
string public symbolPrefix;
event DepositTokenCreated(address token, address lpToken);
constructor(
address _operator,
string memory _namePostfix,
string memory _symbolPrefix
) public {
operator = _operator;
namePostfix = _namePostfix;
symbolPrefix = _symbolPrefix;
}
function CreateDepositToken(address _lptoken) external returns(address){
require(msg.sender == operator, "!authorized");
DepositToken dtoken = new DepositToken(operator,_lptoken,namePostfix,symbolPrefix);
emit DepositTokenCreated(address(dtoken), _lptoken);
return address(dtoken);
}
}
文件 32 的 34:VirtualBalanceRewardPool.sol
pragma solidity 0.6.12;
import "./Interfaces.sol";
import "./interfaces/MathUtil.sol";
import "@openzeppelin/contracts-0.6/math/SafeMath.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-0.6/utils/Address.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol";
abstract contract VirtualBalanceWrapper {
using SafeMath for uint256;
using SafeERC20 for IERC20;
IDeposit public immutable deposits;
constructor(address deposit_) internal {
deposits = IDeposit(deposit_);
}
function totalSupply() public view returns (uint256) {
return deposits.totalSupply();
}
function balanceOf(address account) public view returns (uint256) {
return deposits.balanceOf(account);
}
}
contract VirtualBalanceRewardPool is VirtualBalanceWrapper {
using SafeERC20 for IERC20;
IERC20 public immutable rewardToken;
uint256 public constant duration = 7 days;
address public immutable operator;
uint256 public periodFinish = 0;
uint256 public rewardRate = 0;
uint256 public lastUpdateTime;
uint256 public rewardPerTokenStored;
uint256 public queuedRewards = 0;
uint256 public currentRewards = 0;
uint256 public historicalRewards = 0;
uint256 public constant newRewardRatio = 830;
mapping(address => uint256) public userRewardPerTokenPaid;
mapping(address => uint256) public rewards;
event RewardAdded(uint256 reward);
event Staked(address indexed user, uint256 amount);
event Withdrawn(address indexed user, uint256 amount);
event RewardPaid(address indexed user, uint256 reward);
constructor(
address deposit_,
address reward_,
address op_
) public VirtualBalanceWrapper(deposit_) {
rewardToken = IERC20(reward_);
operator = op_;
}
modifier updateReward(address account) {
rewardPerTokenStored = rewardPerToken();
lastUpdateTime = lastTimeRewardApplicable();
if (account != address(0)) {
rewards[account] = earned(account);
userRewardPerTokenPaid[account] = rewardPerTokenStored;
}
_;
}
function lastTimeRewardApplicable() public view returns (uint256) {
return MathUtil.min(block.timestamp, periodFinish);
}
function rewardPerToken() public view returns (uint256) {
if (totalSupply() == 0) {
return rewardPerTokenStored;
}
return
rewardPerTokenStored.add(
lastTimeRewardApplicable()
.sub(lastUpdateTime)
.mul(rewardRate)
.mul(1e18)
.div(totalSupply())
);
}
function earned(address account) public view returns (uint256) {
return
balanceOf(account)
.mul(rewardPerToken().sub(userRewardPerTokenPaid[account]))
.div(1e18)
.add(rewards[account]);
}
function stake(address _account, uint256 amount)
external
updateReward(_account)
{
require(msg.sender == address(deposits), "!authorized");
emit Staked(_account, amount);
}
function withdraw(address _account, uint256 amount)
public
updateReward(_account)
{
require(msg.sender == address(deposits), "!authorized");
emit Withdrawn(_account, amount);
}
function getReward(address _account) public updateReward(_account){
uint256 reward = earned(_account);
if (reward > 0) {
rewards[_account] = 0;
rewardToken.safeTransfer(_account, reward);
emit RewardPaid(_account, reward);
}
}
function getReward() external{
getReward(msg.sender);
}
function donate(uint256 _amount) external returns(bool){
IERC20(rewardToken).safeTransferFrom(msg.sender, address(this), _amount);
queuedRewards = queuedRewards.add(_amount);
}
function queueNewRewards(uint256 _rewards) external{
require(msg.sender == operator, "!authorized");
_rewards = _rewards.add(queuedRewards);
if (block.timestamp >= periodFinish) {
notifyRewardAmount(_rewards);
queuedRewards = 0;
return;
}
uint256 elapsedTime = block.timestamp.sub(periodFinish.sub(duration));
uint256 currentAtNow = rewardRate * elapsedTime;
uint256 queuedRatio = currentAtNow.mul(1000).div(_rewards);
if(queuedRatio < newRewardRatio){
notifyRewardAmount(_rewards);
queuedRewards = 0;
}else{
queuedRewards = _rewards;
}
}
function notifyRewardAmount(uint256 reward)
internal
updateReward(address(0))
{
historicalRewards = historicalRewards.add(reward);
if (block.timestamp >= periodFinish) {
rewardRate = reward.div(duration);
} else {
uint256 remaining = periodFinish.sub(block.timestamp);
uint256 leftover = remaining.mul(rewardRate);
reward = reward.add(leftover);
rewardRate = reward.div(duration);
}
currentRewards = reward;
lastUpdateTime = block.timestamp;
periodFinish = block.timestamp.add(duration);
emit RewardAdded(reward);
}
}
文件 33 的 34:VoterProxy.sol
pragma solidity 0.6.12;
import "./Interfaces.sol";
import "@openzeppelin/contracts-0.6/math/SafeMath.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-0.6/utils/Address.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol";
contract VoterProxy {
using SafeERC20 for IERC20;
using Address for address;
using SafeMath for uint256;
address public mintr;
address public immutable crv;
address public immutable crvBpt;
address public immutable escrow;
address public gaugeController;
address public rewardDeposit;
address public withdrawer;
address public owner;
address public operator;
address public depositor;
mapping (address => bool) private stashPool;
mapping (address => bool) private protectedTokens;
mapping (bytes32 => bool) private votes;
bytes4 constant internal EIP1271_MAGIC_VALUE = 0x1626ba7e;
event VoteSet(bytes32 hash, bool valid);
constructor(
address _mintr,
address _crv,
address _crvBpt,
address _escrow,
address _gaugeController
) public {
mintr = _mintr;
crv = _crv;
crvBpt = _crvBpt;
escrow = _escrow;
gaugeController = _gaugeController;
owner = msg.sender;
protectedTokens[_crv] = true;
protectedTokens[_crvBpt] = true;
}
function getName() external pure returns (string memory) {
return "BalancerVoterProxy";
}
function setOwner(address _owner) external {
require(msg.sender == owner, "!auth");
owner = _owner;
}
function setRewardDeposit(address _withdrawer, address _rewardDeposit) external {
require(msg.sender == owner, "!auth");
withdrawer = _withdrawer;
rewardDeposit = _rewardDeposit;
}
function setSystemConfig(address _gaugeController, address _mintr) external returns (bool) {
require(msg.sender == owner, "!auth");
gaugeController = _gaugeController;
mintr = _mintr;
return true;
}
function setOperator(address _operator) external {
require(msg.sender == owner, "!auth");
require(operator == address(0) || IDeposit(operator).isShutdown() == true, "needs shutdown");
operator = _operator;
}
function setDepositor(address _depositor) external {
require(msg.sender == owner, "!auth");
depositor = _depositor;
}
function setStashAccess(address _stash, bool _status) external returns(bool){
require(msg.sender == operator, "!auth");
if(_stash != address(0)){
stashPool[_stash] = _status;
}
return true;
}
function setVote(bytes32 _hash, bool _valid) external {
require(msg.sender == operator, "!auth");
votes[_hash] = _valid;
emit VoteSet(_hash, _valid);
}
function isValidSignature(bytes32 _hash, bytes memory) public view returns (bytes4) {
if(votes[_hash]) {
return EIP1271_MAGIC_VALUE;
} else {
return 0xffffffff;
}
}
function deposit(address _token, address _gauge) external returns(bool){
require(msg.sender == operator, "!auth");
if(protectedTokens[_token] == false){
protectedTokens[_token] = true;
}
if(protectedTokens[_gauge] == false){
protectedTokens[_gauge] = true;
}
uint256 balance = IERC20(_token).balanceOf(address(this));
if (balance > 0) {
IERC20(_token).safeApprove(_gauge, 0);
IERC20(_token).safeApprove(_gauge, balance);
ICurveGauge(_gauge).deposit(balance);
}
return true;
}
function withdraw(IERC20 _asset) external returns (uint256 balance) {
require(msg.sender == withdrawer, "!auth");
require(protectedTokens[address(_asset)] == false, "protected");
balance = _asset.balanceOf(address(this));
_asset.safeApprove(rewardDeposit, 0);
_asset.safeApprove(rewardDeposit, balance);
IRewardDeposit(rewardDeposit).addReward(address(_asset), balance);
return balance;
}
function withdraw(address _token, address _gauge, uint256 _amount) public returns(bool){
require(msg.sender == operator, "!auth");
uint256 _balance = IERC20(_token).balanceOf(address(this));
if (_balance < _amount) {
_amount = _withdrawSome(_gauge, _amount.sub(_balance));
_amount = _amount.add(_balance);
}
IERC20(_token).safeTransfer(msg.sender, _amount);
return true;
}
function withdrawAll(address _token, address _gauge) external returns(bool){
require(msg.sender == operator, "!auth");
uint256 amount = balanceOfPool(_gauge).add(IERC20(_token).balanceOf(address(this)));
withdraw(_token, _gauge, amount);
return true;
}
function _withdrawSome(address _gauge, uint256 _amount) internal returns (uint256) {
ICurveGauge(_gauge).withdraw(_amount);
return _amount;
}
function createLock(uint256 _value, uint256 _unlockTime) external returns(bool){
require(msg.sender == depositor, "!auth");
IERC20(crvBpt).safeApprove(escrow, 0);
IERC20(crvBpt).safeApprove(escrow, _value);
ICurveVoteEscrow(escrow).create_lock(_value, _unlockTime);
return true;
}
function increaseAmount(uint256 _value) external returns(bool){
require(msg.sender == depositor, "!auth");
IERC20(crvBpt).safeApprove(escrow, 0);
IERC20(crvBpt).safeApprove(escrow, _value);
ICurveVoteEscrow(escrow).increase_amount(_value);
return true;
}
function increaseTime(uint256 _value) external returns(bool){
require(msg.sender == depositor, "!auth");
ICurveVoteEscrow(escrow).increase_unlock_time(_value);
return true;
}
function release() external returns(bool){
require(msg.sender == depositor, "!auth");
ICurveVoteEscrow(escrow).withdraw();
return true;
}
function vote(uint256 _voteId, address _votingAddress, bool _support) external returns(bool){
require(msg.sender == operator, "!auth");
IVoting(_votingAddress).vote(_voteId,_support,false);
return true;
}
function voteGaugeWeight(address _gauge, uint256 _weight) external returns(bool){
require(msg.sender == operator, "!auth");
IVoting(gaugeController).vote_for_gauge_weights(_gauge, _weight);
return true;
}
function claimCrv(address _gauge) external returns (uint256){
require(msg.sender == operator, "!auth");
uint256 _balance = 0;
try IMinter(mintr).mint(_gauge){
_balance = IERC20(crv).balanceOf(address(this));
IERC20(crv).safeTransfer(operator, _balance);
}catch{}
return _balance;
}
function claimRewards(address _gauge) external returns(bool){
require(msg.sender == operator, "!auth");
ICurveGauge(_gauge).claim_rewards();
return true;
}
function claimFees(address _distroContract, address _token) external returns (uint256){
require(msg.sender == operator, "!auth");
IFeeDistributor(_distroContract).claimToken(address(this), _token);
uint256 _balance = IERC20(_token).balanceOf(address(this));
IERC20(_token).safeTransfer(operator, _balance);
return _balance;
}
function balanceOfPool(address _gauge) public view returns (uint256) {
return ICurveGauge(_gauge).balanceOf(address(this));
}
function execute(
address _to,
uint256 _value,
bytes calldata _data
) external returns (bool, bytes memory) {
require(msg.sender == operator,"!auth");
(bool success, bytes memory result) = _to.call{value:_value}(_data);
require(success, "!success");
return (success, result);
}
}
文件 34 的 34:cCrv.sol
pragma solidity 0.6.12;
import "./Interfaces.sol";
import "@openzeppelin/contracts-0.6/math/SafeMath.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-0.6/utils/Address.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts-0.6/token/ERC20/ERC20.sol";
contract cvxCrvToken is ERC20 {
using SafeERC20 for IERC20;
using Address for address;
using SafeMath for uint256;
address public operator;
constructor(string memory _nameArg, string memory _symbolArg)
public
ERC20(
_nameArg,
_symbolArg
)
{
operator = msg.sender;
}
function setOperator(address _operator) external {
require(msg.sender == operator, "!auth");
operator = _operator;
}
function mint(address _to, uint256 _amount) external {
require(msg.sender == operator, "!authorized");
_mint(_to, _amount);
}
function burn(address _from, uint256 _amount) external {
require(msg.sender == operator, "!authorized");
_burn(_from, _amount);
}
}
{
"compilationTarget": {
"convex-platform/contracts/contracts/BaseRewardPool4626.sol": "BaseRewardPool4626"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"uint256","name":"pid_","type":"uint256"},{"internalType":"address","name":"stakingToken_","type":"address"},{"internalType":"address","name":"rewardToken_","type":"address"},{"internalType":"address","name":"operator_","type":"address"},{"internalType":"address","name":"rewardManager_","type":"address"},{"internalType":"address","name":"lptoken_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Withdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[{"internalType":"address","name":"_reward","type":"address"}],"name":"addExtraReward","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"asset","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"clearExtraRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"convertToAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"convertToShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"duration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"earned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"extraRewards","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"extraRewardsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReward","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"bool","name":"_claimExtras","type":"bool"}],"name":"getReward","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"historicalRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastTimeRewardApplicable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastUpdateTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"maxMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"maxRedeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"maxWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"newRewardRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"operator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"periodFinish","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"previewDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"previewMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"previewRedeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"previewWithdraw","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"processIdleRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_rewards","type":"uint256"}],"name":"queueNewRewards","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"queuedRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerTokenStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stake","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakeAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_for","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stakeFor","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakingToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userRewardPerTokenPaid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"claim","type":"bool"}],"name":"withdraw","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"claim","type":"bool"}],"name":"withdrawAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"claim","type":"bool"}],"name":"withdrawAllAndUnwrap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"claim","type":"bool"}],"name":"withdrawAndUnwrap","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]