文件 1 的 17:ACMasterChefSolidLizard.sol
pragma solidity ^0.8.0;
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol';
import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol';
import '@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol';
import './AutoCompoundVaultWithBurning.sol';
interface IFarm {
function deposit(uint256 amount, uint256 tokenId) external;
function withdraw(uint256 amount) external;
function getReward(address account, address[] memory tokens) external;
function withdrawAll() external;
function balanceOf(address _user) external view returns (uint256);
}
interface ISolidLizardRouter {
struct Route {
address from;
address to;
bool stable;
}
function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
Route[] memory routes,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function addLiquidity(
address _tokenA,
address _tokenB,
bool _stable,
uint256 _amountADesired,
uint256 _amountBDesired,
uint256 _amountAMin,
uint256 _amountBMin,
address _to,
uint256 _deadline
)
external
returns (
uint256 amountA,
uint256 amountB,
uint256 liquidity
);
}
interface IToken {
function stable() external view returns (bool);
}
contract ACMasterChefSolidLizard is AutoCompoundVaultWithBurning {
IUniswapV2Router02 public immutable liquidityRouter;
IERC20 public immutable token0;
IERC20 public immutable token1;
uint256 public tokenId = 0;
ISolidLizardRouter.Route[] public outputToLp0Route;
ISolidLizardRouter.Route[] public outputToLp1Route;
address public immutable lizarRouter = 0xF26515D5482e2C2FD237149bF6A653dA4794b3D0;
constructor(
string memory _name,
string memory _symbol,
uint256 _pid,
address[6] memory _addresses,
IUniswapV2Router02 _liquidityRouter
) ERC20(_name, _symbol) AutoCompoundVaultWithBurning(_pid, _addresses) {
token0 = IERC20(IUniswapV2Pair(_addresses[1]).token0());
token1 = IERC20(IUniswapV2Pair(_addresses[1]).token1());
liquidityRouter = _liquidityRouter;
token0.approve(address(liquidityRouter), type(uint256).max);
token1.approve(address(liquidityRouter), type(uint256).max);
}
function _earnToStake(uint256 _earnAmount) internal override {
uint256 halfEarnAmount = _earnAmount / 2;
if (earnToken != token0) {
_safeSwap(halfEarnAmount, address(earnToken), address(token0));
}
if (earnToken != token1) {
_safeSwap(_earnAmount - halfEarnAmount, address(earnToken), address(token1));
}
uint256 token0Amt = token0.balanceOf(address(this));
uint256 token1Amt = token1.balanceOf(address(this));
if (IERC20(token0).allowance(address(this), address(0xF26515D5482e2C2FD237149bF6A653dA4794b3D0)) < token0Amt) {
IERC20(token0).approve(address(0xF26515D5482e2C2FD237149bF6A653dA4794b3D0), token0Amt);
}
if (IERC20(token1).allowance(address(this), address(0xF26515D5482e2C2FD237149bF6A653dA4794b3D0)) < token1Amt) {
IERC20(token1).approve(address(0xF26515D5482e2C2FD237149bF6A653dA4794b3D0), token1Amt);
}
ISolidLizardRouter(0xF26515D5482e2C2FD237149bF6A653dA4794b3D0).addLiquidity(
address(token0),
address(token1),
IToken(address(stakeToken)).stable(),
token0Amt,
token1Amt,
1,
1,
address(this),
block.timestamp
);
}
function _safeSwap(
uint256 _amountIn,
address _tokenFrom,
address _tokenTo
) internal override {
if (IERC20(_tokenFrom).allowance(address(this), lizarRouter) < _amountIn) {
IERC20(_tokenFrom).approve(lizarRouter, type(uint256).max);
}
if (address(_tokenTo) == outputToLp0Route[outputToLp0Route.length - 1].to) {
ISolidLizardRouter(lizarRouter).swapExactTokensForTokens(
_amountIn,
1,
outputToLp0Route,
address(this),
block.timestamp
);
} else {
ISolidLizardRouter(lizarRouter).swapExactTokensForTokens(
_amountIn,
1,
outputToLp1Route,
address(this),
block.timestamp
);
}
}
function _farmDeposit(uint256 amount) internal override {
IFarm(masterChef).deposit(amount, tokenId);
}
function _farmWithdraw(uint256 amount) internal override {
IFarm(masterChef).withdraw(amount);
}
function _farmEmergencyWithdraw() internal override {
IFarm(masterChef).withdrawAll();
}
function _totalStaked() internal view override returns (uint256 amount) {
amount = IFarm(masterChef).balanceOf(address(this));
}
function _addAllawences() internal override {
IERC20(stakeToken).approve(masterChef, type(uint256).max);
token0.approve(address(liquidityRouter), type(uint256).max);
token1.approve(address(liquidityRouter), type(uint256).max);
}
function _removeAllawences() internal override {
IERC20(stakeToken).approve(masterChef, 0);
token0.approve(address(liquidityRouter), 0);
token1.approve(address(liquidityRouter), 0);
}
function _farmHarvest() internal override {
address[] memory tokens = new address[](1);
tokens[0] = address(earnToken);
IFarm(masterChef).getReward(address(this), tokens);
}
function setTokenId(uint256 _tokenId) external onlyOperator {
tokenId = _tokenId;
}
function setRoutes(
ISolidLizardRouter.Route[] calldata _outputToLp0Route,
ISolidLizardRouter.Route[] calldata _outputToLp1Route
) external onlyOperator {
delete outputToLp0Route;
delete outputToLp1Route;
for (uint256 i; i < _outputToLp0Route.length; ++i) {
outputToLp0Route.push(_outputToLp0Route[i]);
}
for (uint256 i; i < _outputToLp1Route.length; ++i) {
outputToLp1Route.push(_outputToLp1Route[i]);
}
}
}
文件 2 的 17:Address.sol
pragma solidity ^0.8.1;
library Address {
function isContract(address account) internal view returns (bool) {
return account.code.length > 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
) internal 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);
}
}
}
}
文件 3 的 17:AutoCompoundVaultWithBurning.sol
pragma solidity 0.8.9;
import '@openzeppelin/contracts/token/ERC20/ERC20.sol';
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import '@openzeppelin/contracts/security/ReentrancyGuard.sol';
import '@openzeppelin/contracts/security/Pausable.sol';
import '../interfaces/IWETH.sol';
import '../interfaces/IYieldWolf.sol';
import '../route-oracle/interfaces/IRouteOracle.sol';
abstract contract AutoCompoundVaultWithBurning is ERC20, ReentrancyGuard, Pausable {
using SafeERC20 for IERC20;
IYieldWolf public immutable yieldWolf;
address public immutable masterChef;
uint256 public immutable pid;
IERC20 public immutable stakeToken;
IERC20 public immutable earnToken;
address[] public extraEarnTokens;
mapping(address => bool) tokenRestricted;
address immutable WNATIVE;
IRouteOracle public immutable routeOracle;
bool public emergencyWithdrawn;
uint256 constant PERFORMANCE_FEE = 400;
uint256 constant BURNING_FEE = 400;
event Deposit(address indexed user, uint256 amount);
event Withdraw(address indexed user, uint256 amount);
event Earn();
event Farm();
event EmergencyWithdraw();
event TokenToEarn(address token);
event WrapNative();
event SetExtraEarnTokens(address[] _extraEarnTokens);
event SetTokenRestricted(address _address);
modifier onlyOwner() {
require(address(yieldWolf) == _msgSender(), 'onlyOwner: not allowed');
_;
}
modifier onlyOperator() {
require(yieldWolf.operators(msg.sender), 'onlyOperator: not allowed');
_;
}
function _farmDeposit(uint256 depositAmount) internal virtual;
function _farmWithdraw(uint256 withdrawAmount) internal virtual;
function _earnToStake(uint256 _earnAmount) internal virtual;
function _farmEmergencyWithdraw() internal virtual;
function _totalStaked() internal view virtual returns (uint256);
receive() external payable {}
constructor(uint256 _pid, address[6] memory _addresses) {
yieldWolf = IYieldWolf(_addresses[0]);
stakeToken = IERC20(_addresses[1]);
earnToken = IERC20(_addresses[2]);
masterChef = _addresses[3];
routeOracle = IRouteOracle(_addresses[4]);
WNATIVE = _addresses[5];
pid = _pid;
IERC20(stakeToken).approve(masterChef, type(uint256).max);
tokenRestricted[address(this)] = true;
tokenRestricted[address(earnToken)] = true;
tokenRestricted[address(stakeToken)] = true;
}
function deposit(address _user, uint256 _depositAmount) external virtual onlyOwner whenNotPaused {
uint256 stakeTokenAmount = stakeToken.balanceOf(address(this));
uint256 totalStakedBefore = _totalStaked() + stakeTokenAmount - _depositAmount;
_farmDeposit(stakeTokenAmount);
uint256 totalStakedAfter = _totalStaked() + stakeToken.balanceOf(address(this));
_depositAmount = totalStakedAfter - totalStakedBefore;
uint256 sharesAdded = _depositAmount;
uint256 _totalSupply = totalSupply();
if (totalStakedBefore > 0 && _totalSupply > 0) {
sharesAdded = (_depositAmount * _totalSupply) / totalStakedBefore;
}
_mint(_user, sharesAdded);
emit Deposit(_user, _depositAmount);
}
function withdraw(address _user, uint256 _withdrawAmount) external virtual onlyOwner nonReentrant {
require(_withdrawAmount > 0, 'withdraw: cannot be zero');
uint256 totalStakedOnFarm = _totalStaked();
uint256 stakeAmountBefore = stakeToken.balanceOf(address(this));
uint256 totalStake = totalStakedOnFarm + stakeAmountBefore;
uint256 sharesTotal = totalSupply();
uint256 userBalance = balanceOf(_user);
require(userBalance > 0, 'withdraw: no shares');
uint256 maxAmount = (userBalance * totalStake) / sharesTotal;
if (_withdrawAmount > maxAmount) {
_withdrawAmount = maxAmount;
}
uint256 sharesRemoved = (_withdrawAmount * sharesTotal - 1) / totalStake + 1;
if (sharesRemoved > sharesTotal) {
sharesRemoved = sharesTotal;
}
if (totalStakedOnFarm > 0) {
_farmWithdraw(_withdrawAmount);
uint256 totalWithdrawn = stakeToken.balanceOf(address(this)) - stakeAmountBefore;
if (_withdrawAmount > totalWithdrawn) {
_withdrawAmount = totalWithdrawn;
}
}
uint256 stakeBalance = stakeToken.balanceOf(address(this));
if (_withdrawAmount > stakeBalance) {
_withdrawAmount = stakeBalance;
}
_burn(_user, sharesRemoved);
stakeToken.safeTransfer(_user, _withdrawAmount);
emit Withdraw(_user, _withdrawAmount);
}
function farm() external virtual nonReentrant whenNotPaused {
_farm();
emit Farm();
}
function earn(address _bountyHunter) external virtual nonReentrant returns (uint256 bountyReward) {
if (paused()) {
return 0;
}
uint256 earnAmountBefore = earnToken.balanceOf(address(this));
_farmHarvest();
for (uint256 i; i < extraEarnTokens.length; ) {
address extraEarnToken = extraEarnTokens[i];
uint256 balanceExtraEarn = IERC20(extraEarnToken).balanceOf(address(this));
_trySafeSwap(balanceExtraEarn, extraEarnToken, address(earnToken));
unchecked {
i++;
}
}
uint256 earnAmountAfter = earnToken.balanceOf(address(this));
uint256 harvestAmount = earnAmountAfter - earnAmountBefore;
uint256 platformFee;
uint256 burningFee;
if (harvestAmount > 0) {
(bountyReward, platformFee, burningFee) = _distributeFees(harvestAmount, _bountyHunter);
}
uint256 earnAmount = earnAmountAfter - platformFee - bountyReward - burningFee;
_earnToStake(earnAmount);
_farm();
if (_bountyHunter != address(0)) {
emit Earn();
}
}
function pause() external virtual onlyOperator {
_removeAllawences();
_pause();
}
function unpause() external virtual onlyOperator {
require(!emergencyWithdrawn, 'unpause: cannot unpause after emergency withdraw');
_addAllawences();
_unpause();
}
function setExtraEarnTokens(address[] calldata _extraEarnTokens) external virtual onlyOperator {
require(_extraEarnTokens.length <= 5, 'setExtraEarnTokens: cap exceeded');
for (uint256 i; i < _extraEarnTokens.length; i++) {
require(
!tokenRestricted[_extraEarnTokens[i]] &&
_extraEarnTokens[i] != address(earnToken) &&
_extraEarnTokens[i] != address(stakeToken),
'setExtraEarnTokens: not allowed'
);
IERC20(_extraEarnTokens[i]).balanceOf(address(this));
}
extraEarnTokens = _extraEarnTokens;
emit SetExtraEarnTokens(_extraEarnTokens);
}
function setTokenRestricted(address _addr) external onlyOperator {
tokenRestricted[_addr] = true;
emit SetTokenRestricted(_addr);
}
function tokenToEarn(address _token) external virtual nonReentrant whenNotPaused onlyOperator {
uint256 amount = IERC20(_token).balanceOf(address(this));
require(!tokenRestricted[_token], 'tokenToEarn: not allowed');
if (amount > 0) {
_safeSwap(amount, _token, address(earnToken));
}
emit TokenToEarn(_token);
}
function wrapNative() external virtual {
uint256 balance = address(this).balance;
if (balance > 0) {
IWETH(WNATIVE).deposit{value: balance}();
}
emit WrapNative();
}
function totalStakeTokens() external view virtual returns (uint256) {
return _totalStaked() + stakeToken.balanceOf(address(this));
}
function emergencyWithdraw() external virtual onlyOperator {
if (!paused()) {
_pause();
}
emergencyWithdrawn = true;
_farmEmergencyWithdraw();
emit EmergencyWithdraw();
}
function _farm() internal virtual {
uint256 depositAmount = stakeToken.balanceOf(address(this));
_farmDeposit(depositAmount);
}
function _farmHarvest() internal virtual {
_farmDeposit(0);
}
function _distributeFees(uint256 _amount, address _bountyHunter)
internal
virtual
returns (
uint256 bountyReward,
uint256 platformFee,
uint256 burningFee
)
{
burningFee = (_amount * BURNING_FEE) / 10000;
platformFee = (_amount * PERFORMANCE_FEE) / 10000;
if (_bountyHunter != address(0)) {
bountyReward = platformFee / 10;
unchecked {
platformFee = platformFee - bountyReward;
}
earnToken.safeTransfer(_bountyHunter, bountyReward);
}
earnToken.safeTransfer(yieldWolf.feeAddress(), platformFee);
earnToken.safeTransfer(address(0x000000000000000000000000000000000000dEaD), burningFee);
}
function _addAllawences() internal virtual {
IERC20(stakeToken).approve(masterChef, type(uint256).max);
}
function _removeAllawences() internal virtual {
IERC20(stakeToken).approve(masterChef, 0);
for (uint256 i; i < extraEarnTokens.length; i++) {
IERC20(extraEarnTokens[i]).approve(masterChef, 0);
}
}
function _safeSwap(
uint256 _amountIn,
address _tokenFrom,
address _tokenTo
) internal virtual {
(address router, address nextToken, bytes memory sig) = routeOracle.resolveSwapExactTokensForTokens(
_amountIn,
_tokenFrom,
_tokenTo,
address(this)
);
require(router != address(this) && router != masterChef, '_safeSwap: invalid router');
if (router == address(stakeToken)) {
require(
!(sig[0] == 0xa9 && sig[1] == 0x05 && sig[2] == 0x9c && sig[3] == 0xbb) &&
!(sig[0] == 0x23 && sig[1] == 0xb8 && sig[2] == 0x72 && sig[3] == 0xdd) &&
!(sig[0] == 0x09 && sig[1] == 0x5e && sig[2] == 0xa7 && sig[3] == 0xb3),
'_safeSwap: not allowed'
);
}
if (IERC20(_tokenFrom).allowance(address(this), router) < _amountIn) {
IERC20(_tokenFrom).approve(router, type(uint256).max);
}
uint256 nextTokenBalanceBefore;
if (nextToken != address(0)) {
nextTokenBalanceBefore = IERC20(nextToken).balanceOf(address(this));
}
(bool success, ) = router.call(sig);
require(success, '_safeSwap: swap failed');
if (nextToken != address(0)) {
uint256 nextTokenAmount = IERC20(nextToken).balanceOf(address(this)) - nextTokenBalanceBefore;
_safeSwap(nextTokenAmount, nextToken, _tokenTo);
}
}
function _trySafeSwap(
uint256 _amountIn,
address _tokenFrom,
address _tokenTo
) internal virtual {
(address router, address nextToken, bytes memory sig) = routeOracle.resolveSwapExactTokensForTokens(
_amountIn,
_tokenFrom,
_tokenTo,
address(this)
);
require(router != address(this) && router != masterChef, '_trySafeSwap: invalid router');
if (router == address(stakeToken)) {
require(
!(sig[0] == 0xa9 && sig[1] == 0x05 && sig[2] == 0x9c && sig[3] == 0xbb) &&
!(sig[0] == 0x23 && sig[1] == 0xb8 && sig[2] == 0x72 && sig[3] == 0xdd) &&
!(sig[0] == 0x09 && sig[1] == 0x5e && sig[2] == 0xa7 && sig[3] == 0xb3),
'_trySafeSwap: not allowed'
);
}
if (IERC20(_tokenFrom).allowance(address(this), router) < _amountIn) {
IERC20(_tokenFrom).approve(router, type(uint256).max);
}
uint256 nextTokenBalanceBefore;
if (nextToken != address(0)) {
nextTokenBalanceBefore = IERC20(nextToken).balanceOf(address(this));
}
(bool success, ) = router.call(sig);
if (success && nextToken != address(0)) {
uint256 nextTokenAmount = IERC20(nextToken).balanceOf(address(this)) - nextTokenBalanceBefore;
_safeSwap(nextTokenAmount, nextToken, _tokenTo);
}
}
}
文件 4 的 17:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 5 的 17:ERC20.sol
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function decimals() public view virtual override returns (uint8) {
return 18;
}
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 to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, 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) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
function transferFrom(
address from,
address to,
uint256 amount
) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, _allowances[owner][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = _allowances[owner][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
function _transfer(
address from,
address to,
uint256 amount
) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
}
_balances[to] += amount;
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, 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 += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
_afterTokenTransfer(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);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
}
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
_afterTokenTransfer(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 _spendAllowance(
address owner,
address spender,
uint256 amount
) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
文件 6 的 17:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, 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 from,
address to,
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);
}
文件 7 的 17:IERC20Metadata.sol
pragma solidity ^0.8.0;
import "../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);
}
文件 8 的 17:IRouteOracle.sol
pragma solidity 0.8.9;
interface IRouteOracle {
function resolveSwapExactTokensForTokens(
uint256 amountIn,
address tokenFrom,
address tokenTo,
address recipient
)
external
view
returns (
address router,
address nextToken,
bytes memory sig
);
}
文件 9 的 17:IUniswapV2Factory.sol
pragma solidity >=0.5.0;
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
文件 10 的 17:IUniswapV2Pair.sol
pragma solidity >=0.5.0;
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
文件 11 的 17:IUniswapV2Router01.sol
pragma solidity >=0.6.2;
interface IUniswapV2Router01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountToken, uint amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB);
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountETH);
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}
文件 12 的 17:IUniswapV2Router02.sol
pragma solidity >=0.6.2;
import './IUniswapV2Router01.sol';
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
文件 13 的 17:IWETH.sol
pragma solidity 0.8.9;
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
interface IWETH is IERC20 {
function deposit() external payable;
function withdraw(uint256 wad) external;
}
文件 14 的 17:IYieldWolf.sol
pragma solidity 0.8.9;
interface IYieldWolf {
function operators(address addr) external returns (bool);
function feeAddress() external returns (address);
function stakedTokens(uint256 pid, address user) external view returns (uint256);
}
文件 15 的 17:Pausable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Pausable is Context {
event Paused(address account);
event Unpaused(address account);
bool private _paused;
constructor() {
_paused = false;
}
function paused() public view virtual returns (bool) {
return _paused;
}
modifier whenNotPaused() {
require(!paused(), "Pausable: paused");
_;
}
modifier whenPaused() {
require(paused(), "Pausable: not paused");
_;
}
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
文件 16 的 17:ReentrancyGuard.sol
pragma solidity ^0.8.0;
abstract contract ReentrancyGuard {
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
modifier nonReentrant() {
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
_status = _ENTERED;
_;
_status = _NOT_ENTERED;
}
}
文件 17 的 17:SafeERC20.sol
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../../../utils/Address.sol";
library SafeERC20 {
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) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_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");
}
}
}
{
"compilationTarget": {
"contracts/vaults/ACMasterChefSolidLizard.sol": "ACMasterChefSolidLizard"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"address[6]","name":"_addresses","type":"address[6]"},{"internalType":"contract IUniswapV2Router02","name":"_liquidityRouter","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":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[],"name":"Earn","type":"event"},{"anonymous":false,"inputs":[],"name":"EmergencyWithdraw","type":"event"},{"anonymous":false,"inputs":[],"name":"Farm","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"_extraEarnTokens","type":"address[]"}],"name":"SetExtraEarnTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_address","type":"address"}],"name":"SetTokenRestricted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"TokenToEarn","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":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"anonymous":false,"inputs":[],"name":"WrapNative","type":"event"},{"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":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","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":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_depositAmount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_bountyHunter","type":"address"}],"name":"earn","outputs":[{"internalType":"uint256","name":"bountyReward","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"earnToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"emergencyWithdrawn","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"extraEarnTokens","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"farm","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"liquidityRouter","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lizarRouter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"masterChef","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"outputToLp0Route","outputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bool","name":"stable","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"outputToLp1Route","outputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bool","name":"stable","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"routeOracle","outputs":[{"internalType":"contract IRouteOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_extraEarnTokens","type":"address[]"}],"name":"setExtraEarnTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bool","name":"stable","type":"bool"}],"internalType":"struct ISolidLizardRouter.Route[]","name":"_outputToLp0Route","type":"tuple[]"},{"components":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bool","name":"stable","type":"bool"}],"internalType":"struct ISolidLizardRouter.Route[]","name":"_outputToLp1Route","type":"tuple[]"}],"name":"setRoutes","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"setTokenId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_addr","type":"address"}],"name":"setTokenRestricted","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakeToken","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":"token0","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token1","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"tokenToEarn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalStakeTokens","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":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_withdrawAmount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"wrapNative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"yieldWolf","outputs":[{"internalType":"contract IYieldWolf","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]