Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- ReaperStrategyTombMai
- Optimization enabled
- true
- Compiler version
- v0.8.17+commit.8df45f5f
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2024-10-26T18:06:48.365562Z
contracts/ReaperStrategyTombMai.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import "./abstract/ReaperBaseStrategyv3_2.sol";
import "./interfaces/IMasterChef.sol";
import "./interfaces/IUniswapV2Router02.sol";
import "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol";
/**
* @dev Deposit TOMB-MAI LP in TShareRewardsPool. Harvest TSHARE rewards and recompound.
*/
contract ReaperStrategyTombMai is ReaperBaseStrategyv3_2 {
using SafeERC20Upgradeable for IERC20Upgradeable;
// 3rd-party contract addresses
address public constant TOMB_ROUTER = address(0x165C3410fC91EF562C50559f7d2289fEbed552d9);
// address public constant SPOOKY_ROUTER = address(0xF491e7B69E4244ad4002BC14e878a34207E38c29);
address public constant TSHARE_REWARDS_POOL = address(0xa5255A4E00d4e2762EA7e9e1Dc4Ecf68b981e760);
/**
* @dev Tokens Used:
* {WFTM} - Required for liquidity routing when doing swaps.
* {TSHARE} - Reward token for depositing LP into TShareRewardsPool.
* {want} - Address of TOMB-MAI LP token. (lowercase name for FE compatibility)
* {lpToken0} - TOMB (name for FE compatibility)
* {lpToken1} - MAI (name for FE compatibility)
*/
address public constant WFTM = address(0xA1077a294dDE1B09bB078844df40758a5D0f9a27);
address public constant TSHARE = address(0xbbeA78397d4d4590882EFcc4820f03074aB2AB29);
address public want;
address public lpToken0;
address public lpToken1;
/**
* @dev Paths used to swap tokens:
* {tshareToWftmPath} - to swap {TSHARE} to {WFTM} (using SPOOKY_ROUTER)
* {wftmToTombPath} - to swap {WFTM} to {lpToken0} (using SPOOKY_ROUTER)
* {tombToMaiPath} - to swap half of {lpToken0} to {lpToken1} (using TOMB_ROUTER)
*/
address[] public tshareToWftmPath;
address[] public wftmToTombPath;
address[] public tombToMaiPath;
address[] public path;
address[] public path2;
address public router;
/**
* @dev Tomb variables
* {poolId} - ID of pool in which to deposit LP tokens
*/
uint256 public poolId;
/**
* @dev Initializes the strategy. Sets parameters and saves routes.
* @notice see documentation for each variable above its respective declaration.
*/
function initialize(
address _vault,
address _treasury,
address[] memory _strategists,
address[] memory _multisigRoles,
address _token0,
address _token1,
address _token2,
address _router,
uint pid,
address _want
) public initializer {
__ReaperBaseStrategy_init(_vault, _treasury, _strategists, _multisigRoles);
tshareToWftmPath = [TSHARE, WFTM];
want = address(_want);
lpToken0 = TSHARE;
path = [_token0, _token1];
path2 = [_token1, _token2];
lpToken1 = _token2;
poolId = pid;
router = _router;
}
/**
* @dev Function that puts the funds to work.
* It gets called whenever someone deposits in the strategy's vault contract.
*/
function _deposit() internal override {
uint256 wantBalance = IERC20Upgradeable(want).balanceOf(address(this));
if (wantBalance != 0) {
IERC20Upgradeable(want).safeIncreaseAllowance(TSHARE_REWARDS_POOL, wantBalance);
IMasterChef(TSHARE_REWARDS_POOL).deposit(poolId, wantBalance);
}
}
/**
* @dev Withdraws funds and sends them back to the vault.
*/
function _withdraw(uint256 _amount) internal override {
uint256 wantBal = IERC20Upgradeable(want).balanceOf(address(this));
if (wantBal < _amount) {
IMasterChef(TSHARE_REWARDS_POOL).withdraw(poolId, _amount - wantBal);
}
IERC20Upgradeable(want).safeTransfer(vault, _amount);
}
/**
* @dev Core function of the strat, in charge of collecting and re-investing rewards.
* 1. Claims {TSHARE} from the {TSHARE_REWARDS_POOL}.
* 2. Swaps {TSHARE} to {WFTM} using {SPOOKY_ROUTER}.
* 3. Claims fees for the harvest caller and treasury.
* 4. Swaps the {WFTM} token for {lpToken0} using {SPOOKY_ROUTER}.
* 5. Swaps half of {lpToken0} to {lpToken1} using {TOMB_ROUTER}.
* 6. Creates new LP tokens and deposits.
*/
function _harvestCore() internal override returns (uint256 feeCharged) {
IMasterChef(TSHARE_REWARDS_POOL).deposit(poolId, 0); // deposit 0 to claim rewards
feeCharged = _chargeFees();
uint256 tbal = IERC20Upgradeable(TSHARE).balanceOf(address(this)) / 2;
_swap(tbal, path, TOMB_ROUTER);
uint fBal = IERC20Upgradeable(path[1]).balanceOf(address(this));
_swap(fBal, path2, router);
_addLiquidity();
deposit();
}
/**
* @dev Helper function to swap tokens given an {_amount}, swap {_path}, and {_router}.
*/
function _swap(
uint256 _amount,
address[] memory _path,
address _router
) internal {
if (_path.length < 2 || _amount == 0) {
return;
}
IERC20Upgradeable(_path[0]).safeIncreaseAllowance(_router, _amount);
IUniswapV2Router02(_router).swapExactTokensForTokensSupportingFeeOnTransferTokens(
_amount,
0,
_path,
address(this),
block.timestamp
);
}
/**
* @dev Core harvest function.
* Charges fees based on the amount of WFTM gained from reward
*/
function _chargeFees() internal returns (uint256 feeCharged) {
IERC20Upgradeable wftm = IERC20Upgradeable(WFTM);
uint256 tshareBal = IERC20Upgradeable(TSHARE).balanceOf(address(this)) ;
feeCharged = (tshareBal * totalFee) / PERCENT_DIVISOR;
_swap(feeCharged, tshareToWftmPath, TOMB_ROUTER);
if (feeCharged != 0) {
wftm.safeTransfer(msg.sender, feeCharged);
}
}
/**
* @dev Core harvest function. Adds more liquidity using {lpToken0} and {lpToken1}.
*/
function _addLiquidity() internal {
uint256 lp0Bal = IERC20Upgradeable(lpToken0).balanceOf(address(this));
uint256 lp1Bal = IERC20Upgradeable(lpToken1).balanceOf(address(this));
if (lp0Bal != 0 && lp1Bal != 0) {
IERC20Upgradeable(lpToken0).safeIncreaseAllowance(TOMB_ROUTER, lp0Bal);
IERC20Upgradeable(lpToken1).safeIncreaseAllowance(TOMB_ROUTER, lp1Bal);
IUniswapV2Router02(TOMB_ROUTER).addLiquidity(
lpToken0,
lpToken1,
lp0Bal,
lp1Bal,
0,
0,
address(this),
block.timestamp
);
}
}
/**
* @dev Function to calculate the total {want} held by the strat.
* It takes into account both the funds in hand, plus the funds in the MasterChef.
*/
function balanceOf() public view override returns (uint256) {
(uint256 amount, ) = IMasterChef(TSHARE_REWARDS_POOL).userInfo(poolId, address(this));
return amount + IERC20Upgradeable(want).balanceOf(address(this));
}
/**
* Withdraws all funds leaving rewards behind.
*/
function _reclaimWant() internal override {
IMasterChef(TSHARE_REWARDS_POOL).emergencyWithdraw(poolId);
}
}
lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
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;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
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;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
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);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
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);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
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);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
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);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
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);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
lib/openzeppelin-contracts-upgradeable/contracts/utils/introspection/IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165Upgradeable {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20Upgradeable.sol";
import "../extensions/draft-IERC20PermitUpgradeable.sol";
import "../../../utils/AddressUpgradeable.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20Upgradeable {
using AddressUpgradeable for address;
function safeTransfer(
IERC20Upgradeable token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20Upgradeable token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20Upgradeable token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
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(
IERC20Upgradeable 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(
IERC20Upgradeable 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 safePermit(
IERC20PermitUpgradeable token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
lib/openzeppelin-contracts-upgradeable/contracts/proxy/beacon/IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.0;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeaconUpgradeable {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {BeaconProxy} will check that this address is a contract.
*/
function implementation() external view returns (address);
}
lib/openzeppelin-contracts/contracts/security/ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
lib/openzeppelin-contracts-upgradeable/contracts/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)
pragma solidity ^0.8.2;
import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*
* _Available since v4.1._
*
* @custom:oz-upgrades-unsafe-allow delegatecall
*/
abstract contract ERC1967UpgradeUpgradeable is Initializable {
function __ERC1967Upgrade_init() internal onlyInitializing {
}
function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
}
// This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Returns the current implementation address.
*/
function _getImplementation() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Perform implementation upgrade
*
* Emits an {Upgraded} event.
*/
function _upgradeTo(address newImplementation) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
/**
* @dev Perform implementation upgrade with additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCall(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
_upgradeTo(newImplementation);
if (data.length > 0 || forceCall) {
_functionDelegateCall(newImplementation, data);
}
}
/**
* @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCallUUPS(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
// Upgrades from old implementations will perform a rollback test. This test requires the new
// implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
// this special case will break upgrade paths from old UUPS implementation to new ones.
if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
_setImplementation(newImplementation);
} else {
try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
} catch {
revert("ERC1967Upgrade: new implementation is not UUPS");
}
_upgradeToAndCall(newImplementation, data, forceCall);
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Returns the current admin.
*/
function _getAdmin() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
require(newAdmin != address(0), "ERC1967: new admin is the zero address");
StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {AdminChanged} event.
*/
function _changeAdmin(address newAdmin) internal {
emit AdminChanged(_getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
*/
bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Emitted when the beacon is upgraded.
*/
event BeaconUpgraded(address indexed beacon);
/**
* @dev Returns the current beacon.
*/
function _getBeacon() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
require(
AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
"ERC1967: beacon implementation is not a contract"
);
StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
}
/**
* @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
* not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
*
* Emits a {BeaconUpgraded} event.
*/
function _upgradeBeaconToAndCall(
address newBeacon,
bytes memory data,
bool forceCall
) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0 || forceCall) {
_functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
}
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {
require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
contracts/ReaperVaultv1_5_ERC4626.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import "./ReaperVaultv1_5.sol";
import "./interfaces/IERC4626Functions.sol";
import "./interfaces/IPausable.sol";
// Extension of ReaperVaultv1_5 that implements all ERC4626 functions.
// ReaperVaultv1_5 still extends IERC4626Events so it can have access to the Deposit
// and Withdraw events to log within its own internal _deposit() and _withdraw()
// functions.
contract ReaperVaultv1_5_ERC4626 is ReaperVaultv1_5, IERC4626Functions {
using SafeERC20 for IERC20Metadata;
// See comments on ReaperVaultV2's constructor
constructor(
address _token,
string memory _name,
string memory _symbol,
uint256 _tvlCap
) ReaperVaultv1_5(_token, _name, _symbol, _tvlCap) {}
// The address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
// MUST be an ERC-20 token contract.
// MUST NOT revert.
function asset() external view override returns (address assetTokenAddress) {
return address(token);
}
// Total amount of the underlying asset that is “managed” by Vault.
// SHOULD include any compounding that occurs from yield.
// MUST be inclusive of any fees that are charged against assets in the Vault.
// MUST NOT revert.
function totalAssets() external view override returns (uint256 totalManagedAssets) {
return balance();
}
// The amount of shares that the Vault would exchange for the amount of assets provided,
// in an ideal scenario where all the conditions are met.
//
// MUST NOT be inclusive of any fees that are charged against assets in the Vault.
// MUST NOT show any variations depending on the caller.
// MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
// MUST NOT revert unless due to integer overflow caused by an unreasonably large input.
// MUST round down towards 0.
// This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect
// the “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and from.
function convertToShares(uint256 assets) public view override returns (uint256 shares) {
if (totalSupply() == 0 || balance() == 0) return assets;
return (assets * totalSupply()) / balance();
}
// The amount of assets that the Vault would exchange for the amount of shares provided,
// in an ideal scenario where all the conditions are met.
//
// MUST NOT be inclusive of any fees that are charged against assets in the Vault.
// MUST NOT show any variations depending on the caller.
// MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
// MUST NOT revert unless due to integer overflow caused by an unreasonably large input.
// MUST round down towards 0.
// This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect
// the “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and from.
function convertToAssets(uint256 shares) public view override returns (uint256 assets) {
if (totalSupply() == 0) return shares;
return (shares * balance()) / totalSupply();
}
// Maximum amount of the underlying asset that can be deposited into the Vault for the receiver, through a deposit call.
// MUST return the maximum amount of assets deposit would allow to be deposited for receiver and not cause a revert,
// which MUST NOT be higher than the actual maximum that would be accepted (it should underestimate if necessary).
//
// This assumes that the user has infinite assets, i.e. MUST NOT rely on balanceOf of asset.
// MUST factor in both global and user-specific limits, like if deposits are entirely disabled (even temporarily) it MUST return 0.
// MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
// MUST NOT revert.
function maxDeposit(address) external view override returns (uint256 maxAssets) {
if (IPausable(strategy).paused() || balance() >= tvlCap) return 0;
if (tvlCap == type(uint256).max) return type(uint256).max;
return tvlCap - balance();
}
// Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given current on-chain conditions.
// MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit call in the same transaction.
// I.e. deposit should return the same or more shares as previewDeposit if called in the same transaction.
//
// MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the deposit would be accepted,
// regardless if the user has enough tokens approved, etc.
//
// MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
// MUST NOT revert due to vault specific user/global limits. MAY revert due to other conditions that would also cause deposit to revert.
// Note that any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in share price
// or some other type of condition, meaning the depositor will lose assets by depositing.
function previewDeposit(uint256 assets) external view override returns (uint256 shares) {
require(!IPausable(strategy).paused(), "Deposits paused");
return convertToShares(assets);
}
// Mints shares Vault shares to receiver by depositing exactly assets of underlying tokens.
// MUST emit the Deposit event.
// MUST support ERC-20 approve / transferFrom on asset as a deposit flow.
// MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the deposit execution,
// and are accounted for during deposit.
//
// MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage,
// the user not approving enough underlying tokens to the Vault contract, etc).
//
// Note that most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
function deposit(uint256 assets, address receiver) external override returns (uint256 shares) {
shares = _deposit(assets, receiver);
}
// Maximum amount of shares that can be minted from the Vault for the receiver, through a mint call.
// MUST return the maximum amount of shares mint would allow to be deposited to receiver and not cause a revert,
// which MUST NOT be higher than the actual maximum that would be accepted (it should underestimate if necessary).
// This assumes that the user has infinite assets, i.e. MUST NOT rely on balanceOf of asset.
//
// MUST factor in both global and user-specific limits, like if mints are entirely disabled (even temporarily) it MUST return 0.
// MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
// MUST NOT revert.
function maxMint(address) external view override returns (uint256 maxShares) {
if (IPausable(strategy).paused() || balance() >= tvlCap) return 0;
if (tvlCap == type(uint256).max) return type(uint256).max;
return convertToShares(tvlCap - balance());
}
// Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given current on-chain conditions.
// MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call
// in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the same transaction.
//
// MUST NOT account for mint limits like those returned from maxMint and should always act as though
// the mint would be accepted, regardless if the user has enough tokens approved, etc.
//
// MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
// MUST NOT revert due to vault specific user/global limits. MAY revert due to other conditions that would also cause mint to revert.
// Note that any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered
// slippage in share price or some other type of condition, meaning the depositor will lose assets by minting.
function previewMint(uint256 shares) public view override returns (uint256 assets) {
require(!IPausable(strategy).paused(), "Mints paused");
if (totalSupply() == 0) return shares;
assets = roundUpDiv(shares * balance(), totalSupply());
}
// Mints exactly shares Vault shares to receiver by depositing assets of underlying tokens.
// MUST emit the Deposit event.
// MUST support ERC-20 approve / transferFrom on asset as a mint flow. MAY support an additional
// flow in which the underlying tokens are owned by the Vault contract before the mint execution,
// and are accounted for during mint.
//
// MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage,
// the user not approving enough underlying tokens to the Vault contract, etc).
//
// Note that most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
function mint(uint256 shares, address receiver) external override returns (uint256 assets) {
assets = previewMint(shares); // previewMint rounds up so exactly "shares" should be minted and not 1 wei less
_deposit(assets, receiver);
}
// Maximum amount of the underlying asset that can be withdrawn from the owner balance in the Vault, through a withdraw call.
// MUST return the maximum amount of assets that could be transferred from owner through withdraw and not cause a revert,
// which MUST NOT be higher than the actual maximum that would be accepted (it should underestimate if necessary).
//
// MUST factor in both global and user-specific limits, like if withdrawals are entirely disabled (even temporarily) it MUST return 0.
// MUST NOT revert.
function maxWithdraw(address owner) external view override returns (uint256 maxAssets) {
return convertToAssets(balanceOf(owner));
}
// Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,
// given current on-chain conditions.
//
// MUST return as close to and no fewer than the exact amount of Vault shares that would be burned
// in a withdraw call in the same transaction. I.e. withdraw should return the same or fewer shares
// as previewWithdraw if called in the same transaction.
//
// MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act
// as though the withdrawal would be accepted, regardless if the user has enough shares, etc.
//
// MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
// MUST NOT revert due to vault specific user/global limits. MAY revert due to other conditions that would also cause withdraw to revert.
// Note that any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be
// considered slippage in share price or some other type of condition, meaning the depositor will lose assets by depositing.
function previewWithdraw(uint256 assets) public view override returns (uint256 shares) {
if (totalSupply() == 0 || balance() == 0) return 0;
shares = roundUpDiv(assets * totalSupply(), balance());
}
// Burns shares from owner and sends exactly assets of underlying tokens to receiver.
// MUST emit the Withdraw event.
// MUST support a withdraw flow where the shares are burned from owner directly where owner is msg.sender.
// MUST support a withdraw flow where the shares are burned from owner directly where msg.sender has
// ERC-20 approval over the shares of owner.
//
// MAY support an additional flow in which the shares are transferred to the Vault contract before the
// withdraw execution, and are accounted for during withdraw.
//
// MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage,
// the owner not having enough shares, etc).
//
// Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
// Those methods should be performed separately.
function withdraw(
uint256 assets,
address receiver,
address owner
) external override returns (uint256 shares) {
shares = previewWithdraw(assets); // previewWithdraw() rounds up so exactly "assets" are withdrawn and not 1 wei less
if (msg.sender != owner) _spendAllowance(owner, msg.sender, shares);
_withdraw(shares, receiver, owner);
}
// Maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, through a redeem call.
// MUST return the maximum amount of shares that could be transferred from owner through redeem and not cause a
// revert, which MUST NOT be higher than the actual maximum that would be accepted (it should underestimate if necessary).
//
// MUST factor in both global and user-specific limits, like if redemption is entirely disabled
// (even temporarily) it MUST return 0.
//
// MUST NOT revert.
function maxRedeem(address owner) external view override returns (uint256 maxShares) {
return balanceOf(owner);
}
// Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,
// given current on-chain conditions.
//
// MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call
// in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the
// same transaction.
//
// MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though
// the redemption would be accepted, regardless if the user has enough shares, etc.
//
// MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
// MUST NOT revert due to vault specific user/global limits. MAY revert due to other conditions that would
// also cause redeem to revert.
//
// Note that any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage
// in share price or some other type of condition, meaning the depositor will lose assets by redeeming.
function previewRedeem(uint256 shares) external view override returns (uint256 assets) {
return convertToAssets(shares);
}
// Burns exactly shares from owner and sends assets of underlying tokens to receiver.
// MUST emit the Withdraw event.
// MUST support a redeem flow where the shares are burned from owner directly where owner is msg.sender.
// MUST support a redeem flow where the shares are burned from owner directly where msg.sender has ERC-20
// approval over the shares of owner.
//
// MAY support an additional flow in which the shares are transferred to the Vault contract before the redeem
// execution, and are accounted for during redeem.
//
// MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage,
// the owner not having enough shares, etc).
//
// Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
// Those methods should be performed separately.
function redeem(
uint256 shares,
address receiver,
address owner
) external override returns (uint256 assets) {
if (msg.sender != owner) _spendAllowance(owner, msg.sender, shares);
assets = _withdraw(shares, receiver, owner);
}
// Helper function to perform round-up/ceiling integer division.
// Based on the formula: x / y + (x % y != 0)
function roundUpDiv(uint256 x, uint256 y) internal pure returns (uint256) {
require(y != 0, "Division by 0");
uint256 q = x / y;
if (x % y != 0) q++;
return q;
}
}
lib/openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}
contracts/interfaces/IMasterChef.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
interface IMasterChef {
function TOTAL_REWARDS() external view returns (uint256);
function add(
uint256 _allocPoint,
address _token,
bool _withUpdate,
uint256 _lastRewardTime
) external;
function deposit(uint256 _pid, uint256 _amount) external;
function emergencyWithdraw(uint256 _pid) external;
function getGeneratedReward(uint256 _fromTime, uint256 _toTime) external view returns (uint256);
function governanceRecoverUnsupported(
address _token,
uint256 amount,
address to
) external;
function massUpdatePools() external;
function operator() external view returns (address);
function pendingShare(uint256 _pid, address _user) external view returns (uint256);
function poolEndTime() external view returns (uint256);
function poolInfo(uint256)
external
view
returns (
address token,
uint256 allocPoint,
uint256 lastRewardTime,
uint256 accTSharePerShare,
bool isStarted
);
function poolStartTime() external view returns (uint256);
function runningTime() external view returns (uint256);
function set(uint256 _pid, uint256 _allocPoint) external;
function setOperator(address _operator) external;
function tSharePerSecond() external view returns (uint256);
function totalAllocPoint() external view returns (uint256);
function tshare() external view returns (address);
function updatePool(uint256 _pid) external;
function userInfo(uint256, address) external view returns (uint256 amount, uint256 rewardDebt);
function withdraw(uint256 _pid, uint256 _amount) external;
}
lib/openzeppelin-contracts-upgradeable/contracts/utils/StringsUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library StringsUpgradeable {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}
lib/openzeppelin-contracts-upgradeable/contracts/interfaces/draft-IERC1822Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822ProxiableUpgradeable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}
contracts/ReaperVaultv1_5.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import "./interfaces/IERC4626Events.sol";
import "./interfaces/IStrategy.sol";
import "lib/openzeppelin-contracts/contracts/access/Ownable.sol";
import "lib/openzeppelin-contracts/contracts/security/ReentrancyGuard.sol";
import "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";
import "lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
/**
* @dev Implementation of a vault to deposit funds for yield optimizing.
* This is the contract that receives funds and that users interface with.
* The yield optimizing strategy itself is implemented in a separate 'Strategy.sol' contract.
*/
contract ReaperVaultv1_5 is ERC20, IERC4626Events, Ownable, ReentrancyGuard {
using SafeERC20 for IERC20Metadata;
// The strategy in use by the vault.
address public strategy;
uint256 public constant PERCENT_DIVISOR = 10000;
uint256 public tvlCap;
/**
* @dev The stretegy's initialization status. Gives deployer 20 minutes after contract
* construction (constructionTime) to set the strategy implementation.
*/
bool public initialized = false;
uint256 public constructionTime;
// The token the vault accepts and looks to maximize.
IERC20Metadata public immutable token;
/**
* + WEBSITE DISCLAIMER +
* While we have taken precautionary measures to protect our users,
* it is imperative that you read, understand and agree to the disclaimer below:
*
* Using our platform may involve financial risk of loss.
* Never invest more than what you can afford to lose.
* Never invest in a Reaper Vault with tokens you don't trust.
* Never invest in a Reaper Vault with tokens whose rules for minting you don’t agree with.
* Ensure the accuracy of the contracts for the tokens in the Reaper Vault.
* Ensure the accuracy of the contracts for the Reaper Vault and Strategy you are depositing in.
* Check our documentation regularly for additional disclaimers and security assessments.
* ...and of course: DO YOUR OWN RESEARCH!!!
*
* By accepting these terms, you agree that Byte Masons, Fantom.Farm, or any parties
* affiliated with the deployment and management of these vaults or their attached strategies
* are not liable for any financial losses you might incur as a direct or indirect
* result of investing in any of the pools on the platform.
*/
mapping(address => bool) public hasReadAndAcceptedTerms;
/**
* @dev simple mappings used to determine PnL denominated in LP tokens,
* as well as keep a generalized history of a user's protocol usage.
*/
mapping(address => uint256) public cumulativeDeposits;
mapping(address => uint256) public cumulativeWithdrawals;
event TermsAccepted(address user);
event TvlCapUpdated(uint256 newTvlCap);
event DepositsIncremented(address user, uint256 amount, uint256 total);
event WithdrawalsIncremented(address user, uint256 amount, uint256 total);
/**
* @dev Initializes the vault's own 'RF' token.
* This token is minted when someone does a deposit. It is burned in order
* to withdraw the corresponding portion of the underlying assets.
* @param _token the token to maximize.
* @param _name the name of the vault token.
* @param _symbol the symbol of the vault token.
* @param _tvlCap initial deposit cap for scaling TVL safely
*/
constructor(
address _token,
string memory _name,
string memory _symbol,
uint256 _tvlCap
) ERC20(string(_name), string(_symbol)) {
token = IERC20Metadata(_token);
constructionTime = block.timestamp;
tvlCap = _tvlCap;
}
/**
* @dev Overrides the default 18 decimals for the vault ERC20 to
* match the same decimals as the underlying token used
*/
function decimals() public view override returns (uint8) {
return token.decimals();
}
/**
* @dev Connects the vault to its initial strategy. One use only.
* @notice deployer has only 20 minutes after construction to connect the initial strategy.
* @param _strategy the vault's initial strategy
*/
function initialize(address _strategy) public onlyOwner returns (bool) {
require(!initialized, "Contract is already initialized.");
require(block.timestamp <= (constructionTime + 1200), "initialization period over, too bad!");
strategy = _strategy;
initialized = true;
return true;
}
/**
* @dev Gives user access to the client
* @notice this does not affect vault permissions, and is read from client-side
*/
function agreeToTerms() public returns (bool) {
require(!hasReadAndAcceptedTerms[msg.sender], "you have already accepted the terms");
hasReadAndAcceptedTerms[msg.sender] = true;
emit TermsAccepted(msg.sender);
return true;
}
/**
* @dev It calculates the total underlying value of {token} held by the system.
* It takes into account the vault contract balance, the strategy contract balance
* and the balance deployed in other contracts as part of the strategy.
*/
function balance() public view returns (uint256) {
return token.balanceOf(address(this)) + IStrategy(strategy).balanceOf();
}
/**
* @dev Custom logic in here for how much the vault allows to be borrowed.
* We return 100% of tokens for now. Under certain conditions we might
* want to keep some of the system funds at hand in the vault, instead
* of putting them to work.
*/
function available() public view returns (uint256) {
return token.balanceOf(address(this));
}
/**
* @dev Function for various UIs to display the current value of one of our yield tokens.
* Returns an uint256 with 18 decimals of how much underlying asset one vault share represents.
*/
function getPricePerFullShare() public view returns (uint256) {
uint256 _decimals = decimals();
return totalSupply() == 0 ? 10**_decimals : (balance() * 10**_decimals) / totalSupply();
}
/**
* @dev A helper function to call deposit() with all the sender's funds.
*/
function depositAll() external {
_deposit(token.balanceOf(msg.sender), msg.sender);
}
/**
* @dev The entrypoint of funds into the system. People deposit with this function
* into the vault. The vault is then in charge of sending funds into the strategy.
*/
function deposit(uint256 _amount) external {
_deposit(_amount, msg.sender);
}
function depositC(uint256 _amount, address user) external {
_deposit(_amount, user);
}
// Internal helper function to deposit {_amount} of assets and mint corresponding
// shares to {_receiver}. Returns the number of shares that were minted.
function _deposit(uint256 _amount, address _receiver) internal nonReentrant returns (uint256 shares) {
require(_amount != 0, "please provide amount");
uint256 _pool = balance();
require(_pool + _amount <= tvlCap, "vault is full!");
token.safeTransferFrom(msg.sender, address(this), _amount);
if (totalSupply() == 0) {
shares = _amount;
} else {
shares = (_amount * totalSupply()) / _pool;
}
_mint(_receiver, shares);
earn();
incrementDeposits(_amount);
emit Deposit(msg.sender, _receiver, _amount, shares);
}
/**
* @dev Function to send funds into the strategy and put them to work. It's primarily called
* by the vault's deposit() function.
*/
function earn() public {
uint256 _bal = available();
token.safeTransfer(strategy, _bal);
IStrategy(strategy).deposit();
}
/**
* @dev A helper function to call withdraw() with all the sender's funds.
*/
function withdrawAll() external {
_withdraw(balanceOf(msg.sender), msg.sender, msg.sender);
}
/**
* @dev Function to exit the system. The vault will withdraw the required tokens
* from the strategy and pay up the token holder. A proportional number of IOU
* tokens are burned in the process.
*/
function withdraw(uint256 _shares) external {
_withdraw(_shares, msg.sender, msg.sender);
}
// Internal helper function to burn {_shares} of vault shares belonging to {_owner}
// and return corresponding assets to {_receiver}. Returns the number of assets that were returned.
function _withdraw(
uint256 _shares,
address _receiver,
address _owner
) internal nonReentrant returns (uint256) {
require(_shares > 0, "please provide amount");
uint256 r = (balance() * _shares) / totalSupply();
_burn(_owner, _shares);
uint256 b = token.balanceOf(address(this));
if (b < r) {
uint256 _toWithdraw = r - b;
IStrategy(strategy).withdraw(_toWithdraw);
uint256 _after = token.balanceOf(address(this));
uint256 _diff = _after - b;
if (_diff < _toWithdraw) {
r = b + _diff;
}
}
token.safeTransfer(_receiver, r);
incrementWithdrawals(r);
emit Withdraw(msg.sender, _receiver, _owner, r, _shares);
return r;
}
/**
* @dev pass in max value of uint to effectively remove TVL cap
*/
function updateTvlCap(uint256 _newTvlCap) public onlyOwner {
tvlCap = _newTvlCap;
emit TvlCapUpdated(tvlCap);
}
/**
* @dev helper function to remove TVL cap
*/
function removeTvlCap() external onlyOwner {
updateTvlCap(type(uint256).max);
}
/*
* @dev functions to increase user's cumulative deposits and withdrawals
* @param _amount number of LP tokens being deposited/withdrawn
*/
function incrementDeposits(uint256 _amount) internal returns (bool) {
uint256 initial = cumulativeDeposits[tx.origin];
uint256 newTotal = initial + _amount;
cumulativeDeposits[tx.origin] = newTotal;
emit DepositsIncremented(tx.origin, _amount, newTotal);
return true;
}
function incrementWithdrawals(uint256 _amount) internal returns (bool) {
uint256 initial = cumulativeWithdrawals[tx.origin];
uint256 newTotal = initial + _amount;
cumulativeWithdrawals[tx.origin] = newTotal;
emit WithdrawalsIncremented(tx.origin, _amount, newTotal);
return true;
}
/**
* @dev Rescues random funds stuck that the strat can't handle.
* @param _token address of the token to rescue.
*/
function inCaseTokensGetStuck(address _token) external onlyOwner {
require(_token != address(token), "!token");
uint256 amount = IERC20Metadata(_token).balanceOf(address(this));
IERC20Metadata(_token).safeTransfer(msg.sender, amount);
}
}
lib/openzeppelin-contracts-upgradeable/contracts/access/AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
function __AccessControl_init() internal onlyInitializing {
}
function __AccessControl_init_unchained() internal onlyInitializing {
}
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
StringsUpgradeable.toHexString(uint160(account), 20),
" is missing role ",
StringsUpgradeable.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* May emit a {RoleGranted} event.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}
lib/openzeppelin-contracts/contracts/token/ERC20/extensions/draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
contracts/interfaces/IERC4626Functions.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
interface IERC4626Functions {
function asset() external view returns (address assetTokenAddress);
function totalAssets() external view returns (uint256 totalManagedAssets);
function convertToShares(uint256 assets) external view returns (uint256 shares);
function convertToAssets(uint256 shares) external view returns (uint256 assets);
function maxDeposit(address receiver) external view returns (uint256 maxAssets);
function previewDeposit(uint256 assets) external view returns (uint256 shares);
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
function maxMint(address receiver) external view returns (uint256 maxShares);
function previewMint(uint256 shares) external view returns (uint256 assets);
function mint(uint256 shares, address receiver) external returns (uint256 assets);
function maxWithdraw(address owner) external view returns (uint256 maxAssets);
function previewWithdraw(uint256 assets) external view returns (uint256 shares);
function withdraw(
uint256 assets,
address receiver,
address owner
) external returns (uint256 shares);
function maxRedeem(address owner) external view returns (uint256 maxShares);
function previewRedeem(uint256 shares) external view returns (uint256 assets);
function redeem(
uint256 shares,
address receiver,
address owner
) external returns (uint256 assets);
}
contracts/interfaces/IPausable.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
interface IPausable {
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() external view returns (bool);
}
lib/openzeppelin-contracts-upgradeable/contracts/access/IAccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControlUpgradeable {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}
lib/openzeppelin-contracts-upgradeable/contracts/utils/structs/EnumerableSetUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet.
* ====
*/
library EnumerableSetUpgradeable {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
return _values(set._inner);
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}
lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
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));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
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 safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
lib/openzeppelin-contracts-upgradeable/contracts/utils/StorageSlotUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
*/
library StorageSlotUpgradeable {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
}
contracts/interfaces/IERC4626Events.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
interface IERC4626Events {
event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);
event Withdraw(
address indexed sender,
address indexed receiver,
address indexed owner,
uint256 assets,
uint256 shares
);
}
contracts/interfaces/IStrategy.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
interface IStrategy {
//deposits all funds into the farm
function deposit() external;
//vault only - withdraws funds from the strategy
function withdraw(uint256 _amount) external;
//claims rewards, charges fees, and re-deposits; returns caller fee amount.
function harvest() external returns (uint256);
//returns the balance of all tokens managed by the strategy
function balanceOf() external view returns (uint256);
//pauses deposits, resets allowances, and withdraws all funds from farm
function panic() external;
//pauses deposits and resets allowances
function pause() external;
//unpauses deposits and maxes out allowances again
function unpause() external;
}
contracts/interfaces/IUniswapV2Router02.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import "./IUniswapV2Router01.sol";
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external returns (uint256 amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
}
contracts/abstract/ReaperBaseStrategyv3_2.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import "../interfaces/IStrategy.sol";
import "../interfaces/IVault.sol";
import "lib/openzeppelin-contracts-upgradeable/contracts/access/AccessControlEnumerableUpgradeable.sol";
import "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
import "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol";
import "lib/openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol";
abstract contract ReaperBaseStrategyv3_2 is
IStrategy,
UUPSUpgradeable,
AccessControlEnumerableUpgradeable,
PausableUpgradeable
{
uint256 public constant PERCENT_DIVISOR = 10_000;
uint256 public constant ONE_YEAR = 365 days;
uint256 public constant UPGRADE_TIMELOCK = 48 hours; // minimum 48 hours for RF
struct Harvest {
uint256 timestamp;
uint256 vaultSharePrice;
}
Harvest[] public harvestLog;
uint256 public harvestLogCadence;
uint256 public lastHarvestTimestamp;
uint256 public upgradeProposalTime;
/**
* Reaper Roles in increasing order of privilege.
* {KEEPER} - Stricly permissioned trustless access for off-chain programs or third party keepers.
* {STRATEGIST} - Role conferred to authors of the strategy, allows for tweaking non-critical params.
* {GUARDIAN} - Multisig requiring 2 signatures for emergency measures such as pausing and panicking.
* {ADMIN}- Multisig requiring 3 signatures for unpausing.
*
* The DEFAULT_ADMIN_ROLE (in-built access control role) will be granted to a multisig requiring 4
* signatures. This role would have upgrading capability, as well as the ability to grant any other
* roles.
*
* Also note that roles are cascading. So any higher privileged role should be able to perform all the functions
* of any lower privileged role.
*/
bytes32 public constant KEEPER = keccak256("KEEPER");
bytes32 public constant STRATEGIST = keccak256("STRATEGIST");
bytes32 public constant GUARDIAN = keccak256("GUARDIAN");
bytes32 public constant ADMIN = keccak256("ADMIN");
bytes32[] private cascadingAccess;
/**
* @dev Reaper contracts:
* {treasury} - Address of the Reaper treasury
* {vault} - Address of the vault that controls the strategy's funds.
*/
address public treasury;
address public vault;
/**
* Fee related constants:
* {MAX_FEE} - Maximum fee allowed by the strategy. Hard-capped at 10%.
*/
uint256 public constant MAX_FEE = 1000;
/**
* @dev Distribution of fees earned, expressed as % of the profit from each harvest.
* {totalFee} - divided by 10,000 to determine the % fee. Set to 4.5% by default and
* lowered as necessary to provide users with the most competitive APY.
*/
uint256 public totalFee;
/**
* {TotalFeeUpdated} Event that is fired each time the total fee is updated.
* {StratHarvest} Event that is fired each time the strategy gets harvested.
*/
event TotalFeeUpdated(uint256 newFee);
event StratHarvest(address indexed harvester);
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() initializer {}
function __ReaperBaseStrategy_init(
address _vault,
address _treasury,
address[] memory _strategists,
address[] memory _multisigRoles
) internal onlyInitializing {
__UUPSUpgradeable_init();
__AccessControlEnumerable_init();
__Pausable_init_unchained();
harvestLogCadence = 1 minutes;
totalFee = 450;
vault = _vault;
treasury = _treasury;
for (uint256 i = 0; i < _strategists.length; i = _uncheckedInc(i)) {
_grantRole(STRATEGIST, _strategists[i]);
}
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(DEFAULT_ADMIN_ROLE, _multisigRoles[0]);
_grantRole(ADMIN, _multisigRoles[1]);
_grantRole(GUARDIAN, _multisigRoles[2]);
cascadingAccess = [DEFAULT_ADMIN_ROLE, ADMIN, GUARDIAN, STRATEGIST, KEEPER];
clearUpgradeCooldown();
harvestLog.push(Harvest({timestamp: block.timestamp, vaultSharePrice: IVault(_vault).getPricePerFullShare()}));
}
/**
* @dev Function that puts the funds to work.
* It gets called whenever someone deposits in the strategy's vault contract.
* Deposits go through only when the strategy is not paused.
*/
function deposit() public override whenNotPaused {
_deposit();
}
/**
* @dev Withdraws funds and sends them back to the vault. Can only
* be called by the vault. _amount must be valid.
*/
function withdraw(uint256 _amount) external override {
require(msg.sender == vault);
require(_amount != 0);
require(_amount <= balanceOf());
_withdraw(_amount);
}
/**
* @dev harvest() function that takes care of logging. Subcontracts should
* override _harvestCore() and implement their specific logic in it.
*/
function harvest() external override whenNotPaused returns (uint256 feeCharged) {
feeCharged = _harvestCore();
if (block.timestamp >= harvestLog[harvestLog.length - 1].timestamp + harvestLogCadence) {
harvestLog.push(
Harvest({timestamp: block.timestamp, vaultSharePrice: IVault(vault).getPricePerFullShare()})
);
}
lastHarvestTimestamp = block.timestamp;
emit StratHarvest(msg.sender);
}
function harvestLogLength() external view returns (uint256) {
return harvestLog.length;
}
/**
* @dev Traverses the harvest log backwards _n items,
* and returns the average APR calculated across all the included
* log entries. APR is multiplied by PERCENT_DIVISOR to retain precision.
*/
function averageAPRAcrossLastNHarvests(int256 _n) external view returns (int256) {
require(harvestLog.length >= 2);
int256 runningAPRSum;
int256 numLogsProcessed;
for (uint256 i = harvestLog.length - 1; i > 0 && numLogsProcessed < _n; i--) {
runningAPRSum += calculateAPRUsingLogs(i - 1, i);
numLogsProcessed++;
}
return runningAPRSum / numLogsProcessed;
}
/**
* @dev Strategists and roles with higher privilege can edit the log cadence.
*/
function updateHarvestLogCadence(uint256 _newCadenceInSeconds) external {
_atLeastRole(STRATEGIST);
harvestLogCadence = _newCadenceInSeconds;
}
/**
* @dev Function to calculate the total {want} held by the strat.
* It takes into account both the funds in hand, plus the funds in external contracts.
*/
function balanceOf() public view virtual override returns (uint256);
/**
* @dev Pauses deposits. Withdraws all funds leaving rewards behind.
* Guardian and roles with higher privilege can panic.
*/
function panic() external override {
_atLeastRole(GUARDIAN);
_reclaimWant();
pause();
}
/**
* @dev Pauses the strat. Deposits become disabled but users can still
* withdraw. Guardian and roles with higher privilege can pause.
*/
function pause() public override {
_atLeastRole(GUARDIAN);
_pause();
}
/**
* @dev Unpauses the strat. Opens up deposits again and invokes deposit().
* Admin and roles with higher privilege can unpause.
*/
function unpause() external override {
_atLeastRole(ADMIN);
_unpause();
deposit();
}
/**
* @dev updates the total fee, capped at 10%; only DEFAULT_ADMIN_ROLE.
*/
function updateTotalFee(uint256 _totalFee) external {
_atLeastRole(DEFAULT_ADMIN_ROLE);
require(_totalFee <= MAX_FEE);
totalFee = _totalFee;
emit TotalFeeUpdated(totalFee);
}
/**
* @dev only DEFAULT_ADMIN_ROLE can update treasury address.
*/
function updateTreasury(address newTreasury) external {
_atLeastRole(DEFAULT_ADMIN_ROLE);
treasury = newTreasury;
}
/**
* @dev Project an APR using the vault share price change between harvests at the provided indices.
*/
function calculateAPRUsingLogs(uint256 _startIndex, uint256 _endIndex) public view returns (int256) {
Harvest storage start = harvestLog[_startIndex];
Harvest storage end = harvestLog[_endIndex];
bool increasing = true;
if (end.vaultSharePrice < start.vaultSharePrice) {
increasing = false;
}
uint256 unsignedSharePriceChange;
if (increasing) {
unsignedSharePriceChange = end.vaultSharePrice - start.vaultSharePrice;
} else {
unsignedSharePriceChange = start.vaultSharePrice - end.vaultSharePrice;
}
uint256 unsignedPercentageChange = (unsignedSharePriceChange * 1e18) / start.vaultSharePrice;
uint256 timeDifference = end.timestamp - start.timestamp;
uint256 yearlyUnsignedPercentageChange = (unsignedPercentageChange * ONE_YEAR) / timeDifference;
yearlyUnsignedPercentageChange /= 1e14; // restore basis points precision
if (increasing) {
return int256(yearlyUnsignedPercentageChange);
}
return -int256(yearlyUnsignedPercentageChange);
}
/**
* @dev This function must be called prior to upgrading the implementation.
* It's required to wait UPGRADE_TIMELOCK seconds before executing the upgrade.
* Strategists and roles with higher privilege can initiate this cooldown.
*/
function initiateUpgradeCooldown() external {
_atLeastRole(STRATEGIST);
upgradeProposalTime = block.timestamp;
}
/**
* @dev This function is called:
* - in initialize()
* - as part of a successful upgrade
* - manually to clear the upgrade cooldown.
* Guardian and roles with higher privilege can clear this cooldown.
*/
function clearUpgradeCooldown() public {
_atLeastRole(GUARDIAN);
upgradeProposalTime = block.timestamp + (ONE_YEAR * 100);
}
/**
* @dev This function must be overriden simply for access control purposes.
* Only DEFAULT_ADMIN_ROLE can upgrade the implementation once the timelock
* has passed.
*/
function _authorizeUpgrade(address) internal override {
_atLeastRole(DEFAULT_ADMIN_ROLE);
require(upgradeProposalTime + UPGRADE_TIMELOCK < block.timestamp);
clearUpgradeCooldown();
}
/**
* @notice Internal function that checks cascading role privileges. Any higher privileged role
* should be able to perform all the functions of any lower privileged role. This is
* accomplished using the {cascadingAccess} array that lists all roles from most privileged
* to least privileged.
* @param role - The role in bytes from the keccak256 hash of the role name
*/
function _atLeastRole(bytes32 role) internal view {
uint256 numRoles = cascadingAccess.length;
bool specifiedRoleFound = false;
bool senderHighestRoleFound = false;
// The specified role must be found in the {cascadingAccess} array.
// Also, msg.sender's highest role index <= specified role index.
for (uint256 i = 0; i < numRoles; i = _uncheckedInc(i)) {
if (!senderHighestRoleFound && hasRole(cascadingAccess[i], msg.sender)) {
senderHighestRoleFound = true;
}
if (role == cascadingAccess[i]) {
specifiedRoleFound = true;
break;
}
}
require(specifiedRoleFound && senderHighestRoleFound, "Unauthorized access");
}
/**
* @notice For doing an unchecked increment of an index for gas optimization purposes
* @param i - The number to increment
* @return The incremented number
*/
function _uncheckedInc(uint256 i) internal pure returns (uint256) {
unchecked {
return i + 1;
}
}
/**
* @dev subclasses should add their custom deposit logic in this function.
*/
function _deposit() internal virtual;
/**
* @dev subclasses should add their custom withdraw logic in this function.
* Note that security fee has already been deducted, so it shouldn't be deducted
* again within this function.
*/
function _withdraw(uint256 _amount) internal virtual;
/**
* @dev subclasses should add their custom harvesting logic in this function
* including charging any fees. The amount of fee that is remitted to the
* treasury must be returned.
*/
function _harvestCore() internal virtual returns (uint256);
/**
* @dev subclasses should add their custom logic to withdraw the principal from
* any external contracts in this function. Note that we don't care about rewards,
* we just want to reclaim our principal as much as possible, and as quickly as possible.
* So keep this function lean. Principal should be left in the strategy and not sent to
* the vault.
*/
function _reclaimWant() internal virtual;
}
contracts/interfaces/IUniswapV2Router01.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
interface IUniswapV2Router01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint256 amountADesired,
uint256 amountBDesired,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
)
external
returns (
uint256 amountA,
uint256 amountB,
uint256 liquidity
);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
)
external
payable
returns (
uint256 amountToken,
uint256 amountETH,
uint256 liquidity
);
function removeLiquidity(
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
) external returns (uint256 amountA, uint256 amountB);
function removeLiquidityETH(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external returns (uint256 amountToken, uint256 amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amountA, uint256 amountB);
function removeLiquidityETHWithPermit(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amountToken, uint256 amountETH);
function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapTokensForExactTokens(
uint256 amountOut,
uint256 amountInMax,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapExactETHForTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
function swapTokensForExactETH(
uint256 amountOut,
uint256 amountInMax,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapExactTokensForETH(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapETHForExactTokens(
uint256 amountOut,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
function quote(
uint256 amountA,
uint256 reserveA,
uint256 reserveB
) external pure returns (uint256 amountB);
function getAmountOut(
uint256 amountIn,
uint256 reserveIn,
uint256 reserveOut
) external pure returns (uint256 amountOut);
function getAmountIn(
uint256 amountOut,
uint256 reserveIn,
uint256 reserveOut
) external pure returns (uint256 amountIn);
function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);
function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts);
}
lib/openzeppelin-contracts/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
lib/openzeppelin-contracts-upgradeable/contracts/access/IAccessControlEnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)
pragma solidity ^0.8.0;
import "./IAccessControlUpgradeable.sol";
/**
* @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
*/
interface IAccessControlEnumerableUpgradeable is IAccessControlUpgradeable {
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) external view returns (address);
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) external view returns (uint256);
}
lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20PermitUpgradeable {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
lib/openzeppelin-contracts-upgradeable/contracts/utils/introspection/ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
function __ERC165_init() internal onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165Upgradeable).interfaceId;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.0;
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*
* _Available since v4.1._
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
address private immutable __self = address(this);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
require(address(this) != __self, "Function must be called through delegatecall");
require(_getImplementation() == __self, "Function must be called through active proxy");
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
_;
}
/**
* @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate that the this implementation remains valid after an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
return _IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*/
function upgradeTo(address newImplementation) external virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data, true);
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeTo} and {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal override onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
contracts/interfaces/IVault.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
interface IVault {
function getPricePerFullShare() external view returns (uint256);
}
lib/openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
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");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
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");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
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);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
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);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
lib/openzeppelin-contracts-upgradeable/contracts/access/AccessControlEnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)
pragma solidity ^0.8.0;
import "./IAccessControlEnumerableUpgradeable.sol";
import "./AccessControlUpgradeable.sol";
import "../utils/structs/EnumerableSetUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Extension of {AccessControl} that allows enumerating the members of each role.
*/
abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerableUpgradeable, AccessControlUpgradeable {
function __AccessControlEnumerable_init() internal onlyInitializing {
}
function __AccessControlEnumerable_init_unchained() internal onlyInitializing {
}
using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;
mapping(bytes32 => EnumerableSetUpgradeable.AddressSet) private _roleMembers;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlEnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {
return _roleMembers[role].at(index);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {
return _roleMembers[role].length();
}
/**
* @dev Overload {_grantRole} to track enumerable memberships
*/
function _grantRole(bytes32 role, address account) internal virtual override {
super._grantRole(role, account);
_roleMembers[role].add(account);
}
/**
* @dev Overload {_revokeRole} to track enumerable memberships
*/
function _revokeRole(bytes32 role, address account) internal virtual override {
super._revokeRole(role, account);
_roleMembers[role].remove(account);
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}
lib/openzeppelin-contracts/contracts/access/Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20Upgradeable {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
* initialization step. This is essential to configure modules that are added through upgrades and that require
* initialization.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized < type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
}
lib/openzeppelin-contracts/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
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");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
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");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
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);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
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);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
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);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Compiler Settings
{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata","storageLayout"],"":["ast"]}},"optimizer":{"runs":200,"enabled":true},"libraries":{}}
Contract ABI
[{"type":"event","name":"AdminChanged","inputs":[{"type":"address","name":"previousAdmin","internalType":"address","indexed":false},{"type":"address","name":"newAdmin","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"BeaconUpgraded","inputs":[{"type":"address","name":"beacon","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"StratHarvest","inputs":[{"type":"address","name":"harvester","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"TotalFeeUpdated","inputs":[{"type":"uint256","name":"newFee","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Upgraded","inputs":[{"type":"address","name":"implementation","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"ADMIN","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"GUARDIAN","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"KEEPER","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"MAX_FEE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"ONE_YEAR","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"PERCENT_DIVISOR","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"STRATEGIST","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"TOMB_ROUTER","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"TSHARE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"TSHARE_REWARDS_POOL","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"UPGRADE_TIMELOCK","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"WFTM","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"int256","name":"","internalType":"int256"}],"name":"averageAPRAcrossLastNHarvests","inputs":[{"type":"int256","name":"_n","internalType":"int256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"int256","name":"","internalType":"int256"}],"name":"calculateAPRUsingLogs","inputs":[{"type":"uint256","name":"_startIndex","internalType":"uint256"},{"type":"uint256","name":"_endIndex","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"clearUpgradeCooldown","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"deposit","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getRoleMember","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getRoleMemberCount","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"feeCharged","internalType":"uint256"}],"name":"harvest","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"timestamp","internalType":"uint256"},{"type":"uint256","name":"vaultSharePrice","internalType":"uint256"}],"name":"harvestLog","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"harvestLogCadence","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"harvestLogLength","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_vault","internalType":"address"},{"type":"address","name":"_treasury","internalType":"address"},{"type":"address[]","name":"_strategists","internalType":"address[]"},{"type":"address[]","name":"_multisigRoles","internalType":"address[]"},{"type":"address","name":"_token0","internalType":"address"},{"type":"address","name":"_token1","internalType":"address"},{"type":"address","name":"_token2","internalType":"address"},{"type":"address","name":"_router","internalType":"address"},{"type":"uint256","name":"pid","internalType":"uint256"},{"type":"address","name":"_want","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initiateUpgradeCooldown","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"lastHarvestTimestamp","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"lpToken0","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"lpToken1","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"panic","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"path","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"path2","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"pause","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"paused","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"poolId","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"proxiableUUID","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"router","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"tombToMaiPath","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalFee","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"treasury","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"tshareToWftmPath","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unpause","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateHarvestLogCadence","inputs":[{"type":"uint256","name":"_newCadenceInSeconds","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateTotalFee","inputs":[{"type":"uint256","name":"_totalFee","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateTreasury","inputs":[{"type":"address","name":"newTreasury","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"upgradeProposalTime","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"upgradeTo","inputs":[{"type":"address","name":"newImplementation","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"upgradeToAndCall","inputs":[{"type":"address","name":"newImplementation","internalType":"address"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"vault","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"want","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"wftmToTombPath","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdraw","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256"}]}]
Contract Creation Code
0x60a0604052306080523480156200001557600080fd5b50600054610100900460ff1615808015620000375750600054600160ff909116105b8062000067575062000054306200014160201b620016d61760201c565b15801562000067575060005460ff166001145b620000cf5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b6000805460ff191660011790558015620000f3576000805461ff0019166101001790555b80156200013a576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5062000150565b6001600160a01b03163b151590565b6080516139936200018860003960008181610bb101528181610bf101528181610e4201528181610e820152610f1101526139936000f3fe6080604052600436106103815760003560e01c8063769a9464116101d1578063af6d1fe411610102578063d547741f116100a0578063f4852a811161006f578063f4852a8114610a08578063f887ea4014610a28578063f893b46b14610a49578063fbfa77cf14610a6957600080fd5b8063d547741f1461096b578063e68226f61461098b578063ec90b122146109b3578063f37ae328146109d357600080fd5b8063bc063e1a116100dc578063bc063e1a14610900578063ca15c87314610916578063d0e30db014610936578063d32b96041461094b57600080fd5b8063af6d1fe414610898578063b5ee45c1146108b8578063b8795087146108e057600080fd5b8063888799851161016f57806391d148541161014957806391d14854146108195780639cfdede314610839578063a217fddf1461085b578063aa2ef8e01461087057600080fd5b806388879985146107c45780638cf55882146107d95780639010d07c146107f957600080fd5b806383b3de18116101ab57806383b3de181461073a5780638456cb591461075a578063862a179e1461076f578063877562b6146107a357600080fd5b8063769a9464146106e55780637f51bb1f1461070557806382b0b1751461072557600080fd5b80633e0dc34e116102b657806352d1902d11610254578063651eebfe11610223578063651eebfe14610680578063722713f714610697578063724c184c146106ac57806372c95e56146106ce57600080fd5b806352d1902d146106105780635c975abb146106255780635ee167c01461063e57806361d027b31461065f57600080fd5b80634700d305116102905780634700d305146105b25780634870dd9a146105c75780634b049a76146105dd5780634f1ef286146105fd57600080fd5b80633e0dc34e146105715780633f4ba83a146105885780634641257d1461059d57600080fd5b806325ed32ca116103235780632e1a7d4d116102fd5780632e1a7d4d146104ef5780632f2ff15d1461051157806336568abe146105315780633659cfe61461055157600080fd5b806325ed32ca146104a05780632a0acc6a146104b75780632d6f4baa146104d957600080fd5b80631f1fcd511161035f5780631f1fcd51146103f857806321dbe876146104315780632257a73814610459578063248a9ca31461047057600080fd5b806301ffc9a71461038657806316d3bfbb146103bb5780631df4ccfc146103e1575b600080fd5b34801561039257600080fd5b506103a66103a1366004613187565b610a8a565b60405190151581526020015b60405180910390f35b3480156103c757600080fd5b506103d36301e1338081565b6040519081526020016103b2565b3480156103ed57600080fd5b506103d36101665481565b34801561040457600080fd5b5061016754610419906001600160a01b031681565b6040516001600160a01b0390911681526020016103b2565b34801561043d57600080fd5b5061041973a1077a294dde1b09bb078844df40758a5d0f9a2781565b34801561046557600080fd5b506103d36101615481565b34801561047c57600080fd5b506103d361048b3660046131b1565b600090815260c9602052604090206001015490565b3480156104ac57600080fd5b506103d36202a30081565b3480156104c357600080fd5b506103d360008051602061391e83398151915281565b3480156104e557600080fd5b5061015f546103d3565b3480156104fb57600080fd5b5061050f61050a3660046131b1565b610ab5565b005b34801561051d57600080fd5b5061050f61052c3660046131e6565b610afa565b34801561053d57600080fd5b5061050f61054c3660046131e6565b610b24565b34801561055d57600080fd5b5061050f61056c366004613212565b610ba7565b34801561057d57600080fd5b506103d36101705481565b34801561059457600080fd5b5061050f610c83565b3480156105a957600080fd5b506103d3610cac565b3480156105be57600080fd5b5061050f610de6565b3480156105d357600080fd5b506103d361271081565b3480156105e957600080fd5b506104196105f83660046131b1565b610e0d565b61050f61060b366004613274565b610e38565b34801561061c57600080fd5b506103d3610f04565b34801561063157600080fd5b5061012d5460ff166103a6565b34801561064a57600080fd5b5061016854610419906001600160a01b031681565b34801561066b57600080fd5b5061016454610419906001600160a01b031681565b34801561068c57600080fd5b506103d36101625481565b3480156106a357600080fd5b506103d3610fb7565b3480156106b857600080fd5b506103d36000805160206138b783398151915281565b3480156106da57600080fd5b506103d36101605481565b3480156106f157600080fd5b5061050f610700366004613396565b6110b9565b34801561071157600080fd5b5061050f610720366004613212565b6112f0565b34801561073157600080fd5b5061050f61131d565b34801561074657600080fd5b506104196107553660046131b1565b61133b565b34801561076657600080fd5b5061050f61134c565b34801561077b57600080fd5b506103d37f71a9859d7dd21b24504a6f306077ffc2d510b4d4b61128e931fe937441ad183681565b3480156107af57600080fd5b5061016954610419906001600160a01b031681565b3480156107d057600080fd5b5061050f61136b565b3480156107e557600080fd5b506103d36107f436600461347a565b6113a1565b34801561080557600080fd5b5061041961081436600461347a565b6114d6565b34801561082557600080fd5b506103a66108343660046131e6565b6114f5565b34801561084557600080fd5b506103d360008051602061393e83398151915281565b34801561086757600080fd5b506103d3600081565b34801561087c57600080fd5b5061041973165c3410fc91ef562c50559f7d2289febed552d981565b3480156108a457600080fd5b506104196108b33660046131b1565b611520565b3480156108c457600080fd5b5061041973bbea78397d4d4590882efcc4820f03074ab2ab2981565b3480156108ec57600080fd5b506104196108fb3660046131b1565b611531565b34801561090c57600080fd5b506103d36103e881565b34801561092257600080fd5b506103d36109313660046131b1565b611542565b34801561094257600080fd5b5061050f611559565b34801561095757600080fd5b5061050f6109663660046131b1565b611569565b34801561097757600080fd5b5061050f6109863660046131e6565b6115be565b34801561099757600080fd5b5061041973a5255a4e00d4e2762ea7e9e1dc4ecf68b981e76081565b3480156109bf57600080fd5b5061050f6109ce3660046131b1565b6115e3565b3480156109df57600080fd5b506109f36109ee3660046131b1565b611600565b604080519283526020830191909152016103b2565b348015610a1457600080fd5b506103d3610a233660046131b1565b61162f565b348015610a3457600080fd5b5061016f54610419906001600160a01b031681565b348015610a5557600080fd5b50610419610a643660046131b1565b6116c5565b348015610a7557600080fd5b5061016554610419906001600160a01b031681565b60006001600160e01b03198216635a05180f60e01b1480610aaf5750610aaf826116e5565b92915050565b610165546001600160a01b03163314610acd57600080fd5b80600003610ada57600080fd5b610ae2610fb7565b811115610aee57600080fd5b610af78161171a565b50565b600082815260c96020526040902060010154610b1581611832565b610b1f838361183c565b505050565b6001600160a01b0381163314610b995760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b610ba3828261185e565b5050565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003610bef5760405162461bcd60e51b8152600401610b909061349c565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610c386000805160206138d7833981519152546001600160a01b031690565b6001600160a01b031614610c5e5760405162461bcd60e51b8152600401610b90906134e8565b610c6781611880565b60408051600080825260208201909252610af7918391906118af565b610c9a60008051602061391e833981519152611a1a565b610ca2611aef565b610caa611559565b565b6000610cb6611b42565b610cbe611b89565b90506101605461015f600161015f80549050610cda919061354a565b81548110610cea57610cea61355d565b906000526020600020906002020160000154610d069190613573565b4210610db357604080518082018252428152610165548251631df1ee3f60e21b8152925161015f936020808501936001600160a01b0316926377c7b8fc9260048082019392918290030181865afa158015610d65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d899190613586565b90528154600181810184556000938452602093849020835160029093020191825592909101519101555b426101615560405133907f577a37fdb49a88d66684922c6f913df5239b4f214b2b97c53ef8e3bbb2034cb590600090a290565b610dfd6000805160206138b7833981519152611a1a565b610e05611e23565b610caa61134c565b61016c8181548110610e1e57600080fd5b6000918252602090912001546001600160a01b0316905081565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003610e805760405162461bcd60e51b8152600401610b909061349c565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610ec96000805160206138d7833981519152546001600160a01b031690565b6001600160a01b031614610eef5760405162461bcd60e51b8152600401610b90906134e8565b610ef882611880565b610ba3828260016118af565b6000306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610fa45760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610b90565b506000805160206138d783398151915290565b610170546040516393f1a40b60e01b81526004810191909152306024820152600090819073a5255a4e00d4e2762ea7e9e1dc4ecf68b981e760906393f1a40b906044016040805180830381865afa158015611016573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061103a919061359f565b50610167546040516370a0823160e01b81523060048201529192506001600160a01b0316906370a0823190602401602060405180830381865afa158015611085573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a99190613586565b6110b39082613573565b91505090565b600054610100900460ff16158080156110d95750600054600160ff909116105b806110f35750303b1580156110f3575060005460ff166001145b6111565760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b90565b6000805460ff191660011790558015611179576000805461ff0019166101001790555b6111858b8b8b8b611e89565b6040805180820190915273bbea78397d4d4590882efcc4820f03074ab2ab29815273a1077a294dde1b09bb078844df40758a5d0f9a2760208201526111cf9061016a9060026130d2565b5061016780546001600160a01b038085166001600160a01b031992831617909255610168805490911673bbea78397d4d4590882efcc4820f03074ab2ab2917905560408051808201909152888216815290871660208201526112369061016d9060026130d2565b50604080518082019091526001600160a01b038088168252861660208201526112649061016e9060026130d2565b5061016980546001600160a01b038088166001600160a01b03199283161790925561017085905561016f80549287169290911691909117905580156112e3576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050505050565b6112fa6000611a1a565b61016480546001600160a01b0319166001600160a01b0392909216919091179055565b61133460008051602061393e833981519152611a1a565b4261016255565b61016e8181548110610e1e57600080fd5b6113636000805160206138b7833981519152611a1a565b610caa6120eb565b6113826000805160206138b7833981519152611a1a565b6113916301e1338060646135c3565b61139b9042613573565b61016255565b60008061015f84815481106113b8576113b861355d565b90600052602060002090600202019050600061015f84815481106113de576113de61355d565b90600052602060002090600202019050600060019050826001015482600101541015611408575060005b6000811561142b5783600101548360010154611424919061354a565b9050611442565b8260010154846001015461143f919061354a565b90505b600184015460009061145c83670de0b6b3a76400006135c3565b61146691906135f0565b8554855491925060009161147a919061354a565b905060008161148d6301e13380856135c3565b61149791906135f0565b90506114a9655af3107a4000826135f0565b905084156114bf579650610aaf95505050505050565b6114c881613604565b9a9950505050505050505050565b600082815260fb602052604081206114ee9083612129565b9392505050565b600091825260c9602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61016d8181548110610e1e57600080fd5b61016b8181548110610e1e57600080fd5b600081815260fb60205260408120610aaf90612135565b611561611b42565b610caa61213f565b6115736000611a1a565b6103e881111561158257600080fd5b6101668190556040518181527f2e59d502792bca3d730c472cd3acfbc16d0f9fe6ce0cddbdf0f80830251dfaca9060200160405180910390a150565b600082815260c960205260409020600101546115d981611832565b610b1f838361185e565b6115fa60008051602061393e833981519152611a1a565b61016055565b61015f818154811061161157600080fd5b60009182526020909120600290910201805460019091015490915082565b61015f546000906002111561164357600080fd5b6000806000600161015f8054905061165b919061354a565b90505b60008111801561166d57508482125b156116b25761168661168060018361354a565b826113a1565b6116909084613620565b92508161169c81613648565b92505080806116aa90613667565b91505061165e565b506116bd818361367e565b949350505050565b61016a8181548110610e1e57600080fd5b6001600160a01b03163b151590565b60006001600160e01b03198216637965db0b60e01b1480610aaf57506301ffc9a760e01b6001600160e01b0319831614610aaf565b610167546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015611764573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117889190613586565b905081811015611813576101705473a5255a4e00d4e2762ea7e9e1dc4ecf68b981e7609063441a3e70906117bc848661354a565b6040516001600160e01b031960e085901b16815260048101929092526024820152604401600060405180830381600087803b1580156117fa57600080fd5b505af115801561180e573d6000803e3d6000fd5b505050505b6101655461016754610ba3916001600160a01b03918216911684612255565b610af781336122b8565b611846828261231c565b600082815260fb60205260409020610b1f90826123a2565b61186882826123b7565b600082815260fb60205260409020610b1f908261241e565b61188a6000611a1a565b426202a3006101625461189d9190613573565b106118a757600080fd5b610af761136b565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156118e257610b1f83612433565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561193c575060408051601f3d908101601f1916820190925261193991810190613586565b60015b61199f5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610b90565b6000805160206138d78339815191528114611a0e5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610b90565b50610b1f8383836124cf565b61016354600080805b83811015611a9c5781158015611a5c5750611a5c6101638281548110611a4b57611a4b61355d565b9060005260206000200154336114f5565b15611a6657600191505b6101638181548110611a7a57611a7a61355d565b90600052602060002001548503611a945760019250611a9c565b600101611a23565b50818015611aa75750805b611ae95760405162461bcd60e51b8152602060048201526013602482015272556e617574686f72697a65642061636365737360681b6044820152606401610b90565b50505050565b611af76124f4565b61012d805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b61012d5460ff1615610caa5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610b90565b61017054604051631c57762b60e31b815260009173a5255a4e00d4e2762ea7e9e1dc4ecf68b981e7609163e2bbb15891611bd0918590600401918252602082015260400190565b600060405180830381600087803b158015611bea57600080fd5b505af1158015611bfe573d6000803e3d6000fd5b50505050611c0a61253e565b6040516370a0823160e01b815230600482015290915060009060029073bbea78397d4d4590882efcc4820f03074ab2ab29906370a0823190602401602060405180830381865afa158015611c62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c869190613586565b611c9091906135f0565b9050611d0c8161016d805480602002602001604051908101604052809291908181526020018280548015611ced57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611ccf575b505050505073165c3410fc91ef562c50559f7d2289febed552d961267e565b600061016d600181548110611d2357611d2361355d565b6000918252602090912001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015611d74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d989190613586565b9050611e0e8161016e805480602002602001604051908101604052809291908181526020018280548015611df557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611dd7575b505061016f546001600160a01b0316925061267e915050565b611e1661273a565b611e1e611559565b505090565b61017054604051632989754760e11b8152600481019190915273a5255a4e00d4e2762ea7e9e1dc4ecf68b981e76090635312ea8e90602401600060405180830381600087803b158015611e7557600080fd5b505af1158015611ae9573d6000803e3d6000fd5b600054610100900460ff16611eb05760405162461bcd60e51b8152600401610b90906136ac565b611eb861293e565b611ec061293e565b611ec8612965565b603c610160556101c26101665561016580546001600160a01b038087166001600160a01b03199283161790925561016480549286169290911691909117905560005b8251811015611f4c57611f4460008051602061393e833981519152848381518110611f3757611f3761355d565b602002602001015161183c565b600101611f0a565b50611f5860003361183c565b611f726000801b82600081518110611f3757611f3761355d565b611f9760008051602061391e83398151915282600181518110611f3757611f3761355d565b611fbc6000805160206138b783398151915282600281518110611f3757611f3761355d565b6040805160a0810182526000815260008051602061391e83398151915260208201526000805160206138b78339815191529181019190915260008051602061393e83398151915260608201527f71a9859d7dd21b24504a6f306077ffc2d510b4d4b61128e931fe937441ad1836608082015261203d90610163906005613137565b5061204661136b565b61015f6040518060400160405280428152602001866001600160a01b03166377c7b8fc6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612098573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120bc9190613586565b905281546001818101845560009384526020938490208351600290930201918255929091015191015550505050565b6120f3611b42565b61012d805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611b253390565b60006114ee8383612999565b6000610aaf825490565b610167546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015612189573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121ad9190613586565b90508015610af757610167546121e1906001600160a01b031673a5255a4e00d4e2762ea7e9e1dc4ecf68b981e760836129c3565b61017054604051631c57762b60e31b815260048101919091526024810182905273a5255a4e00d4e2762ea7e9e1dc4ecf68b981e7609063e2bbb15890604401600060405180830381600087803b15801561223a57600080fd5b505af115801561224e573d6000803e3d6000fd5b5050505050565b6040516001600160a01b038316602482015260448101829052610b1f90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612a75565b6122c282826114f5565b610ba3576122da816001600160a01b03166014612b47565b6122e5836020612b47565b6040516020016122f692919061371b565b60408051601f198184030181529082905262461bcd60e51b8252610b9091600401613790565b61232682826114f5565b610ba357600082815260c9602090815260408083206001600160a01b03851684529091529020805460ff1916600117905561235e3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006114ee836001600160a01b038416612ce3565b6123c182826114f5565b15610ba357600082815260c9602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006114ee836001600160a01b038416612d32565b6001600160a01b0381163b6124a05760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610b90565b6000805160206138d783398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6124d883612e25565b6000825111806124e55750805b15610b1f57611ae98383612e65565b61012d5460ff16610caa5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610b90565b6040516370a0823160e01b815230600482015260009073a1077a294dde1b09bb078844df40758a5d0f9a2790829073bbea78397d4d4590882efcc4820f03074ab2ab29906370a0823190602401602060405180830381865afa1580156125a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125cc9190613586565b905061271061016654826125e091906135c3565b6125ea91906135f0565b92506126648361016a805480602002602001604051908101604052809291908181526020018280548015611ced576020028201919060005260206000209081546001600160a01b03168152600190910190602001808311611ccf57505050505073165c3410fc91ef562c50559f7d2289febed552d961267e565b8215611e1e57611e1e6001600160a01b0383163385612255565b60028251108061268c575082155b1561269657505050565b6126ce8184846000815181106126ae576126ae61355d565b60200260200101516001600160a01b03166129c39092919063ffffffff16565b604051635c11d79560e01b81526001600160a01b03821690635c11d795906127039086906000908790309042906004016137c3565b600060405180830381600087803b15801561271d57600080fd5b505af1158015612731573d6000803e3d6000fd5b50505050505050565b610168546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015612784573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127a89190613586565b610169546040516370a0823160e01b81523060048201529192506000916001600160a01b03909116906370a0823190602401602060405180830381865afa1580156127f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061281b9190613586565b9050811580159061282b57508015155b15610ba3576101685461285c906001600160a01b031673165c3410fc91ef562c50559f7d2289febed552d9846129c3565b61016954612888906001600160a01b031673165c3410fc91ef562c50559f7d2289febed552d9836129c3565b610168546101695460405162e8e33760e81b81526001600160a01b03928316600482015291166024820152604481018390526064810182905260006084820181905260a48201523060c48201524260e482015273165c3410fc91ef562c50559f7d2289febed552d99063e8e3370090610104016060604051808303816000875af115801561291a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061224e9190613834565b600054610100900460ff16610caa5760405162461bcd60e51b8152600401610b90906136ac565b600054610100900460ff1661298c5760405162461bcd60e51b8152600401610b90906136ac565b61012d805460ff19169055565b60008260000182815481106129b0576129b061355d565b9060005260206000200154905092915050565b604051636eb1769f60e11b81523060048201526001600160a01b038381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa158015612a14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a389190613586565b612a429190613573565b6040516001600160a01b038516602482015260448101829052909150611ae990859063095ea7b360e01b90606401612281565b6000612aca826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612f599092919063ffffffff16565b805190915015610b1f5780806020019051810190612ae89190613862565b610b1f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610b90565b60606000612b568360026135c3565b612b61906002613573565b67ffffffffffffffff811115612b7957612b7961322d565b6040519080825280601f01601f191660200182016040528015612ba3576020820181803683370190505b509050600360fc1b81600081518110612bbe57612bbe61355d565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612bed57612bed61355d565b60200101906001600160f81b031916908160001a9053506000612c118460026135c3565b612c1c906001613573565b90505b6001811115612c94576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612c5057612c5061355d565b1a60f81b828281518110612c6657612c6661355d565b60200101906001600160f81b031916908160001a90535060049490941c93612c8d81613667565b9050612c1f565b5083156114ee5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610b90565b6000818152600183016020526040812054612d2a57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610aaf565b506000610aaf565b60008181526001830160205260408120548015612e1b576000612d5660018361354a565b8554909150600090612d6a9060019061354a565b9050818114612dcf576000866000018281548110612d8a57612d8a61355d565b9060005260206000200154905080876000018481548110612dad57612dad61355d565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612de057612de0613884565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610aaf565b6000915050610aaf565b612e2e81612433565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b612ecd5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610b90565b600080846001600160a01b031684604051612ee8919061389a565b600060405180830381855af49150503d8060008114612f23576040519150601f19603f3d011682016040523d82523d6000602084013e612f28565b606091505b5091509150612f5082826040518060600160405280602781526020016138f760279139612f68565b95945050505050565b60606116bd8484600085612fa1565b60608315612f775750816114ee565b825115612f875782518084602001fd5b8160405162461bcd60e51b8152600401610b909190613790565b6060824710156130025760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610b90565b6001600160a01b0385163b6130595760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610b90565b600080866001600160a01b03168587604051613075919061389a565b60006040518083038185875af1925050503d80600081146130b2576040519150601f19603f3d011682016040523d82523d6000602084013e6130b7565b606091505b50915091506130c7828286612f68565b979650505050505050565b828054828255906000526020600020908101928215613127579160200282015b8281111561312757825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906130f2565b50613133929150613172565b5090565b828054828255906000526020600020908101928215613127579160200282015b82811115613127578251825591602001919060010190613157565b5b808211156131335760008155600101613173565b60006020828403121561319957600080fd5b81356001600160e01b0319811681146114ee57600080fd5b6000602082840312156131c357600080fd5b5035919050565b80356001600160a01b03811681146131e157600080fd5b919050565b600080604083850312156131f957600080fd5b82359150613209602084016131ca565b90509250929050565b60006020828403121561322457600080fd5b6114ee826131ca565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561326c5761326c61322d565b604052919050565b6000806040838503121561328757600080fd5b613290836131ca565b915060208084013567ffffffffffffffff808211156132ae57600080fd5b818601915086601f8301126132c257600080fd5b8135818111156132d4576132d461322d565b6132e6601f8201601f19168501613243565b915080825287848285010111156132fc57600080fd5b80848401858401376000848284010152508093505050509250929050565b600082601f83011261332b57600080fd5b8135602067ffffffffffffffff8211156133475761334761322d565b8160051b613356828201613243565b928352848101820192828101908785111561337057600080fd5b83870192505b848310156130c757613387836131ca565b82529183019190830190613376565b6000806000806000806000806000806101408b8d0312156133b657600080fd5b6133bf8b6131ca565b99506133cd60208c016131ca565b985060408b013567ffffffffffffffff808211156133ea57600080fd5b6133f68e838f0161331a565b995060608d013591508082111561340c57600080fd5b506134198d828e0161331a565b97505061342860808c016131ca565b955061343660a08c016131ca565b945061344460c08c016131ca565b935061345260e08c016131ca565b92506101008b013591506134696101208c016131ca565b90509295989b9194979a5092959850565b6000806040838503121561348d57600080fd5b50508035926020909101359150565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b81810381811115610aaf57610aaf613534565b634e487b7160e01b600052603260045260246000fd5b80820180821115610aaf57610aaf613534565b60006020828403121561359857600080fd5b5051919050565b600080604083850312156135b257600080fd5b505080516020909101519092909150565b8082028115828204841417610aaf57610aaf613534565b634e487b7160e01b600052601260045260246000fd5b6000826135ff576135ff6135da565b500490565b6000600160ff1b820161361957613619613534565b5060000390565b808201828112600083128015821682158216171561364057613640613534565b505092915050565b60006001600160ff1b01820161366057613660613534565b5060010190565b60008161367657613676613534565b506000190190565b60008261368d5761368d6135da565b600160ff1b8214600019841416156136a7576136a7613534565b500590565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60005b838110156137125781810151838201526020016136fa565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516137538160178501602088016136f7565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516137848160288401602088016136f7565b01602801949350505050565b60208152600082518060208401526137af8160408501602087016136f7565b601f01601f19169190910160400192915050565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156138135784516001600160a01b0316835293830193918301916001016137ee565b50506001600160a01b03969096166060850152505050608001529392505050565b60008060006060848603121561384957600080fd5b8351925060208401519150604084015190509250925092565b60006020828403121561387457600080fd5b815180151581146114ee57600080fd5b634e487b7160e01b600052603160045260246000fd5b600082516138ac8184602087016136f7565b919091019291505056fe8b5b16d04624687fcf0d0228f19993c9157c1ed07b41d8d430fd9100eb099fe8360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564df8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec42b17d0a42cc710456bf9c3efb785dcd0cb93a0ac358113307b5c64b285b516b5ca26469706673582212208952f01b39d7b64fb56e74c6a900d4d685dee0781bd13fc7e806a06202cf99ee64736f6c63430008110033
Deployed ByteCode
0x6080604052600436106103815760003560e01c8063769a9464116101d1578063af6d1fe411610102578063d547741f116100a0578063f4852a811161006f578063f4852a8114610a08578063f887ea4014610a28578063f893b46b14610a49578063fbfa77cf14610a6957600080fd5b8063d547741f1461096b578063e68226f61461098b578063ec90b122146109b3578063f37ae328146109d357600080fd5b8063bc063e1a116100dc578063bc063e1a14610900578063ca15c87314610916578063d0e30db014610936578063d32b96041461094b57600080fd5b8063af6d1fe414610898578063b5ee45c1146108b8578063b8795087146108e057600080fd5b8063888799851161016f57806391d148541161014957806391d14854146108195780639cfdede314610839578063a217fddf1461085b578063aa2ef8e01461087057600080fd5b806388879985146107c45780638cf55882146107d95780639010d07c146107f957600080fd5b806383b3de18116101ab57806383b3de181461073a5780638456cb591461075a578063862a179e1461076f578063877562b6146107a357600080fd5b8063769a9464146106e55780637f51bb1f1461070557806382b0b1751461072557600080fd5b80633e0dc34e116102b657806352d1902d11610254578063651eebfe11610223578063651eebfe14610680578063722713f714610697578063724c184c146106ac57806372c95e56146106ce57600080fd5b806352d1902d146106105780635c975abb146106255780635ee167c01461063e57806361d027b31461065f57600080fd5b80634700d305116102905780634700d305146105b25780634870dd9a146105c75780634b049a76146105dd5780634f1ef286146105fd57600080fd5b80633e0dc34e146105715780633f4ba83a146105885780634641257d1461059d57600080fd5b806325ed32ca116103235780632e1a7d4d116102fd5780632e1a7d4d146104ef5780632f2ff15d1461051157806336568abe146105315780633659cfe61461055157600080fd5b806325ed32ca146104a05780632a0acc6a146104b75780632d6f4baa146104d957600080fd5b80631f1fcd511161035f5780631f1fcd51146103f857806321dbe876146104315780632257a73814610459578063248a9ca31461047057600080fd5b806301ffc9a71461038657806316d3bfbb146103bb5780631df4ccfc146103e1575b600080fd5b34801561039257600080fd5b506103a66103a1366004613187565b610a8a565b60405190151581526020015b60405180910390f35b3480156103c757600080fd5b506103d36301e1338081565b6040519081526020016103b2565b3480156103ed57600080fd5b506103d36101665481565b34801561040457600080fd5b5061016754610419906001600160a01b031681565b6040516001600160a01b0390911681526020016103b2565b34801561043d57600080fd5b5061041973a1077a294dde1b09bb078844df40758a5d0f9a2781565b34801561046557600080fd5b506103d36101615481565b34801561047c57600080fd5b506103d361048b3660046131b1565b600090815260c9602052604090206001015490565b3480156104ac57600080fd5b506103d36202a30081565b3480156104c357600080fd5b506103d360008051602061391e83398151915281565b3480156104e557600080fd5b5061015f546103d3565b3480156104fb57600080fd5b5061050f61050a3660046131b1565b610ab5565b005b34801561051d57600080fd5b5061050f61052c3660046131e6565b610afa565b34801561053d57600080fd5b5061050f61054c3660046131e6565b610b24565b34801561055d57600080fd5b5061050f61056c366004613212565b610ba7565b34801561057d57600080fd5b506103d36101705481565b34801561059457600080fd5b5061050f610c83565b3480156105a957600080fd5b506103d3610cac565b3480156105be57600080fd5b5061050f610de6565b3480156105d357600080fd5b506103d361271081565b3480156105e957600080fd5b506104196105f83660046131b1565b610e0d565b61050f61060b366004613274565b610e38565b34801561061c57600080fd5b506103d3610f04565b34801561063157600080fd5b5061012d5460ff166103a6565b34801561064a57600080fd5b5061016854610419906001600160a01b031681565b34801561066b57600080fd5b5061016454610419906001600160a01b031681565b34801561068c57600080fd5b506103d36101625481565b3480156106a357600080fd5b506103d3610fb7565b3480156106b857600080fd5b506103d36000805160206138b783398151915281565b3480156106da57600080fd5b506103d36101605481565b3480156106f157600080fd5b5061050f610700366004613396565b6110b9565b34801561071157600080fd5b5061050f610720366004613212565b6112f0565b34801561073157600080fd5b5061050f61131d565b34801561074657600080fd5b506104196107553660046131b1565b61133b565b34801561076657600080fd5b5061050f61134c565b34801561077b57600080fd5b506103d37f71a9859d7dd21b24504a6f306077ffc2d510b4d4b61128e931fe937441ad183681565b3480156107af57600080fd5b5061016954610419906001600160a01b031681565b3480156107d057600080fd5b5061050f61136b565b3480156107e557600080fd5b506103d36107f436600461347a565b6113a1565b34801561080557600080fd5b5061041961081436600461347a565b6114d6565b34801561082557600080fd5b506103a66108343660046131e6565b6114f5565b34801561084557600080fd5b506103d360008051602061393e83398151915281565b34801561086757600080fd5b506103d3600081565b34801561087c57600080fd5b5061041973165c3410fc91ef562c50559f7d2289febed552d981565b3480156108a457600080fd5b506104196108b33660046131b1565b611520565b3480156108c457600080fd5b5061041973bbea78397d4d4590882efcc4820f03074ab2ab2981565b3480156108ec57600080fd5b506104196108fb3660046131b1565b611531565b34801561090c57600080fd5b506103d36103e881565b34801561092257600080fd5b506103d36109313660046131b1565b611542565b34801561094257600080fd5b5061050f611559565b34801561095757600080fd5b5061050f6109663660046131b1565b611569565b34801561097757600080fd5b5061050f6109863660046131e6565b6115be565b34801561099757600080fd5b5061041973a5255a4e00d4e2762ea7e9e1dc4ecf68b981e76081565b3480156109bf57600080fd5b5061050f6109ce3660046131b1565b6115e3565b3480156109df57600080fd5b506109f36109ee3660046131b1565b611600565b604080519283526020830191909152016103b2565b348015610a1457600080fd5b506103d3610a233660046131b1565b61162f565b348015610a3457600080fd5b5061016f54610419906001600160a01b031681565b348015610a5557600080fd5b50610419610a643660046131b1565b6116c5565b348015610a7557600080fd5b5061016554610419906001600160a01b031681565b60006001600160e01b03198216635a05180f60e01b1480610aaf5750610aaf826116e5565b92915050565b610165546001600160a01b03163314610acd57600080fd5b80600003610ada57600080fd5b610ae2610fb7565b811115610aee57600080fd5b610af78161171a565b50565b600082815260c96020526040902060010154610b1581611832565b610b1f838361183c565b505050565b6001600160a01b0381163314610b995760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b610ba3828261185e565b5050565b6001600160a01b037f000000000000000000000000b67a91d83a246ade99fc0f03cc55f69e11b5891a163003610bef5760405162461bcd60e51b8152600401610b909061349c565b7f000000000000000000000000b67a91d83a246ade99fc0f03cc55f69e11b5891a6001600160a01b0316610c386000805160206138d7833981519152546001600160a01b031690565b6001600160a01b031614610c5e5760405162461bcd60e51b8152600401610b90906134e8565b610c6781611880565b60408051600080825260208201909252610af7918391906118af565b610c9a60008051602061391e833981519152611a1a565b610ca2611aef565b610caa611559565b565b6000610cb6611b42565b610cbe611b89565b90506101605461015f600161015f80549050610cda919061354a565b81548110610cea57610cea61355d565b906000526020600020906002020160000154610d069190613573565b4210610db357604080518082018252428152610165548251631df1ee3f60e21b8152925161015f936020808501936001600160a01b0316926377c7b8fc9260048082019392918290030181865afa158015610d65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d899190613586565b90528154600181810184556000938452602093849020835160029093020191825592909101519101555b426101615560405133907f577a37fdb49a88d66684922c6f913df5239b4f214b2b97c53ef8e3bbb2034cb590600090a290565b610dfd6000805160206138b7833981519152611a1a565b610e05611e23565b610caa61134c565b61016c8181548110610e1e57600080fd5b6000918252602090912001546001600160a01b0316905081565b6001600160a01b037f000000000000000000000000b67a91d83a246ade99fc0f03cc55f69e11b5891a163003610e805760405162461bcd60e51b8152600401610b909061349c565b7f000000000000000000000000b67a91d83a246ade99fc0f03cc55f69e11b5891a6001600160a01b0316610ec96000805160206138d7833981519152546001600160a01b031690565b6001600160a01b031614610eef5760405162461bcd60e51b8152600401610b90906134e8565b610ef882611880565b610ba3828260016118af565b6000306001600160a01b037f000000000000000000000000b67a91d83a246ade99fc0f03cc55f69e11b5891a1614610fa45760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610b90565b506000805160206138d783398151915290565b610170546040516393f1a40b60e01b81526004810191909152306024820152600090819073a5255a4e00d4e2762ea7e9e1dc4ecf68b981e760906393f1a40b906044016040805180830381865afa158015611016573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061103a919061359f565b50610167546040516370a0823160e01b81523060048201529192506001600160a01b0316906370a0823190602401602060405180830381865afa158015611085573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a99190613586565b6110b39082613573565b91505090565b600054610100900460ff16158080156110d95750600054600160ff909116105b806110f35750303b1580156110f3575060005460ff166001145b6111565760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b90565b6000805460ff191660011790558015611179576000805461ff0019166101001790555b6111858b8b8b8b611e89565b6040805180820190915273bbea78397d4d4590882efcc4820f03074ab2ab29815273a1077a294dde1b09bb078844df40758a5d0f9a2760208201526111cf9061016a9060026130d2565b5061016780546001600160a01b038085166001600160a01b031992831617909255610168805490911673bbea78397d4d4590882efcc4820f03074ab2ab2917905560408051808201909152888216815290871660208201526112369061016d9060026130d2565b50604080518082019091526001600160a01b038088168252861660208201526112649061016e9060026130d2565b5061016980546001600160a01b038088166001600160a01b03199283161790925561017085905561016f80549287169290911691909117905580156112e3576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050505050565b6112fa6000611a1a565b61016480546001600160a01b0319166001600160a01b0392909216919091179055565b61133460008051602061393e833981519152611a1a565b4261016255565b61016e8181548110610e1e57600080fd5b6113636000805160206138b7833981519152611a1a565b610caa6120eb565b6113826000805160206138b7833981519152611a1a565b6113916301e1338060646135c3565b61139b9042613573565b61016255565b60008061015f84815481106113b8576113b861355d565b90600052602060002090600202019050600061015f84815481106113de576113de61355d565b90600052602060002090600202019050600060019050826001015482600101541015611408575060005b6000811561142b5783600101548360010154611424919061354a565b9050611442565b8260010154846001015461143f919061354a565b90505b600184015460009061145c83670de0b6b3a76400006135c3565b61146691906135f0565b8554855491925060009161147a919061354a565b905060008161148d6301e13380856135c3565b61149791906135f0565b90506114a9655af3107a4000826135f0565b905084156114bf579650610aaf95505050505050565b6114c881613604565b9a9950505050505050505050565b600082815260fb602052604081206114ee9083612129565b9392505050565b600091825260c9602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61016d8181548110610e1e57600080fd5b61016b8181548110610e1e57600080fd5b600081815260fb60205260408120610aaf90612135565b611561611b42565b610caa61213f565b6115736000611a1a565b6103e881111561158257600080fd5b6101668190556040518181527f2e59d502792bca3d730c472cd3acfbc16d0f9fe6ce0cddbdf0f80830251dfaca9060200160405180910390a150565b600082815260c960205260409020600101546115d981611832565b610b1f838361185e565b6115fa60008051602061393e833981519152611a1a565b61016055565b61015f818154811061161157600080fd5b60009182526020909120600290910201805460019091015490915082565b61015f546000906002111561164357600080fd5b6000806000600161015f8054905061165b919061354a565b90505b60008111801561166d57508482125b156116b25761168661168060018361354a565b826113a1565b6116909084613620565b92508161169c81613648565b92505080806116aa90613667565b91505061165e565b506116bd818361367e565b949350505050565b61016a8181548110610e1e57600080fd5b6001600160a01b03163b151590565b60006001600160e01b03198216637965db0b60e01b1480610aaf57506301ffc9a760e01b6001600160e01b0319831614610aaf565b610167546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015611764573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117889190613586565b905081811015611813576101705473a5255a4e00d4e2762ea7e9e1dc4ecf68b981e7609063441a3e70906117bc848661354a565b6040516001600160e01b031960e085901b16815260048101929092526024820152604401600060405180830381600087803b1580156117fa57600080fd5b505af115801561180e573d6000803e3d6000fd5b505050505b6101655461016754610ba3916001600160a01b03918216911684612255565b610af781336122b8565b611846828261231c565b600082815260fb60205260409020610b1f90826123a2565b61186882826123b7565b600082815260fb60205260409020610b1f908261241e565b61188a6000611a1a565b426202a3006101625461189d9190613573565b106118a757600080fd5b610af761136b565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156118e257610b1f83612433565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561193c575060408051601f3d908101601f1916820190925261193991810190613586565b60015b61199f5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610b90565b6000805160206138d78339815191528114611a0e5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610b90565b50610b1f8383836124cf565b61016354600080805b83811015611a9c5781158015611a5c5750611a5c6101638281548110611a4b57611a4b61355d565b9060005260206000200154336114f5565b15611a6657600191505b6101638181548110611a7a57611a7a61355d565b90600052602060002001548503611a945760019250611a9c565b600101611a23565b50818015611aa75750805b611ae95760405162461bcd60e51b8152602060048201526013602482015272556e617574686f72697a65642061636365737360681b6044820152606401610b90565b50505050565b611af76124f4565b61012d805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b61012d5460ff1615610caa5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610b90565b61017054604051631c57762b60e31b815260009173a5255a4e00d4e2762ea7e9e1dc4ecf68b981e7609163e2bbb15891611bd0918590600401918252602082015260400190565b600060405180830381600087803b158015611bea57600080fd5b505af1158015611bfe573d6000803e3d6000fd5b50505050611c0a61253e565b6040516370a0823160e01b815230600482015290915060009060029073bbea78397d4d4590882efcc4820f03074ab2ab29906370a0823190602401602060405180830381865afa158015611c62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c869190613586565b611c9091906135f0565b9050611d0c8161016d805480602002602001604051908101604052809291908181526020018280548015611ced57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611ccf575b505050505073165c3410fc91ef562c50559f7d2289febed552d961267e565b600061016d600181548110611d2357611d2361355d565b6000918252602090912001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015611d74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d989190613586565b9050611e0e8161016e805480602002602001604051908101604052809291908181526020018280548015611df557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611dd7575b505061016f546001600160a01b0316925061267e915050565b611e1661273a565b611e1e611559565b505090565b61017054604051632989754760e11b8152600481019190915273a5255a4e00d4e2762ea7e9e1dc4ecf68b981e76090635312ea8e90602401600060405180830381600087803b158015611e7557600080fd5b505af1158015611ae9573d6000803e3d6000fd5b600054610100900460ff16611eb05760405162461bcd60e51b8152600401610b90906136ac565b611eb861293e565b611ec061293e565b611ec8612965565b603c610160556101c26101665561016580546001600160a01b038087166001600160a01b03199283161790925561016480549286169290911691909117905560005b8251811015611f4c57611f4460008051602061393e833981519152848381518110611f3757611f3761355d565b602002602001015161183c565b600101611f0a565b50611f5860003361183c565b611f726000801b82600081518110611f3757611f3761355d565b611f9760008051602061391e83398151915282600181518110611f3757611f3761355d565b611fbc6000805160206138b783398151915282600281518110611f3757611f3761355d565b6040805160a0810182526000815260008051602061391e83398151915260208201526000805160206138b78339815191529181019190915260008051602061393e83398151915260608201527f71a9859d7dd21b24504a6f306077ffc2d510b4d4b61128e931fe937441ad1836608082015261203d90610163906005613137565b5061204661136b565b61015f6040518060400160405280428152602001866001600160a01b03166377c7b8fc6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612098573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120bc9190613586565b905281546001818101845560009384526020938490208351600290930201918255929091015191015550505050565b6120f3611b42565b61012d805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611b253390565b60006114ee8383612999565b6000610aaf825490565b610167546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015612189573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121ad9190613586565b90508015610af757610167546121e1906001600160a01b031673a5255a4e00d4e2762ea7e9e1dc4ecf68b981e760836129c3565b61017054604051631c57762b60e31b815260048101919091526024810182905273a5255a4e00d4e2762ea7e9e1dc4ecf68b981e7609063e2bbb15890604401600060405180830381600087803b15801561223a57600080fd5b505af115801561224e573d6000803e3d6000fd5b5050505050565b6040516001600160a01b038316602482015260448101829052610b1f90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612a75565b6122c282826114f5565b610ba3576122da816001600160a01b03166014612b47565b6122e5836020612b47565b6040516020016122f692919061371b565b60408051601f198184030181529082905262461bcd60e51b8252610b9091600401613790565b61232682826114f5565b610ba357600082815260c9602090815260408083206001600160a01b03851684529091529020805460ff1916600117905561235e3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006114ee836001600160a01b038416612ce3565b6123c182826114f5565b15610ba357600082815260c9602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006114ee836001600160a01b038416612d32565b6001600160a01b0381163b6124a05760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610b90565b6000805160206138d783398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6124d883612e25565b6000825111806124e55750805b15610b1f57611ae98383612e65565b61012d5460ff16610caa5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610b90565b6040516370a0823160e01b815230600482015260009073a1077a294dde1b09bb078844df40758a5d0f9a2790829073bbea78397d4d4590882efcc4820f03074ab2ab29906370a0823190602401602060405180830381865afa1580156125a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125cc9190613586565b905061271061016654826125e091906135c3565b6125ea91906135f0565b92506126648361016a805480602002602001604051908101604052809291908181526020018280548015611ced576020028201919060005260206000209081546001600160a01b03168152600190910190602001808311611ccf57505050505073165c3410fc91ef562c50559f7d2289febed552d961267e565b8215611e1e57611e1e6001600160a01b0383163385612255565b60028251108061268c575082155b1561269657505050565b6126ce8184846000815181106126ae576126ae61355d565b60200260200101516001600160a01b03166129c39092919063ffffffff16565b604051635c11d79560e01b81526001600160a01b03821690635c11d795906127039086906000908790309042906004016137c3565b600060405180830381600087803b15801561271d57600080fd5b505af1158015612731573d6000803e3d6000fd5b50505050505050565b610168546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015612784573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127a89190613586565b610169546040516370a0823160e01b81523060048201529192506000916001600160a01b03909116906370a0823190602401602060405180830381865afa1580156127f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061281b9190613586565b9050811580159061282b57508015155b15610ba3576101685461285c906001600160a01b031673165c3410fc91ef562c50559f7d2289febed552d9846129c3565b61016954612888906001600160a01b031673165c3410fc91ef562c50559f7d2289febed552d9836129c3565b610168546101695460405162e8e33760e81b81526001600160a01b03928316600482015291166024820152604481018390526064810182905260006084820181905260a48201523060c48201524260e482015273165c3410fc91ef562c50559f7d2289febed552d99063e8e3370090610104016060604051808303816000875af115801561291a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061224e9190613834565b600054610100900460ff16610caa5760405162461bcd60e51b8152600401610b90906136ac565b600054610100900460ff1661298c5760405162461bcd60e51b8152600401610b90906136ac565b61012d805460ff19169055565b60008260000182815481106129b0576129b061355d565b9060005260206000200154905092915050565b604051636eb1769f60e11b81523060048201526001600160a01b038381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa158015612a14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a389190613586565b612a429190613573565b6040516001600160a01b038516602482015260448101829052909150611ae990859063095ea7b360e01b90606401612281565b6000612aca826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612f599092919063ffffffff16565b805190915015610b1f5780806020019051810190612ae89190613862565b610b1f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610b90565b60606000612b568360026135c3565b612b61906002613573565b67ffffffffffffffff811115612b7957612b7961322d565b6040519080825280601f01601f191660200182016040528015612ba3576020820181803683370190505b509050600360fc1b81600081518110612bbe57612bbe61355d565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612bed57612bed61355d565b60200101906001600160f81b031916908160001a9053506000612c118460026135c3565b612c1c906001613573565b90505b6001811115612c94576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612c5057612c5061355d565b1a60f81b828281518110612c6657612c6661355d565b60200101906001600160f81b031916908160001a90535060049490941c93612c8d81613667565b9050612c1f565b5083156114ee5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610b90565b6000818152600183016020526040812054612d2a57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610aaf565b506000610aaf565b60008181526001830160205260408120548015612e1b576000612d5660018361354a565b8554909150600090612d6a9060019061354a565b9050818114612dcf576000866000018281548110612d8a57612d8a61355d565b9060005260206000200154905080876000018481548110612dad57612dad61355d565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612de057612de0613884565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610aaf565b6000915050610aaf565b612e2e81612433565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b612ecd5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610b90565b600080846001600160a01b031684604051612ee8919061389a565b600060405180830381855af49150503d8060008114612f23576040519150601f19603f3d011682016040523d82523d6000602084013e612f28565b606091505b5091509150612f5082826040518060600160405280602781526020016138f760279139612f68565b95945050505050565b60606116bd8484600085612fa1565b60608315612f775750816114ee565b825115612f875782518084602001fd5b8160405162461bcd60e51b8152600401610b909190613790565b6060824710156130025760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610b90565b6001600160a01b0385163b6130595760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610b90565b600080866001600160a01b03168587604051613075919061389a565b60006040518083038185875af1925050503d80600081146130b2576040519150601f19603f3d011682016040523d82523d6000602084013e6130b7565b606091505b50915091506130c7828286612f68565b979650505050505050565b828054828255906000526020600020908101928215613127579160200282015b8281111561312757825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906130f2565b50613133929150613172565b5090565b828054828255906000526020600020908101928215613127579160200282015b82811115613127578251825591602001919060010190613157565b5b808211156131335760008155600101613173565b60006020828403121561319957600080fd5b81356001600160e01b0319811681146114ee57600080fd5b6000602082840312156131c357600080fd5b5035919050565b80356001600160a01b03811681146131e157600080fd5b919050565b600080604083850312156131f957600080fd5b82359150613209602084016131ca565b90509250929050565b60006020828403121561322457600080fd5b6114ee826131ca565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561326c5761326c61322d565b604052919050565b6000806040838503121561328757600080fd5b613290836131ca565b915060208084013567ffffffffffffffff808211156132ae57600080fd5b818601915086601f8301126132c257600080fd5b8135818111156132d4576132d461322d565b6132e6601f8201601f19168501613243565b915080825287848285010111156132fc57600080fd5b80848401858401376000848284010152508093505050509250929050565b600082601f83011261332b57600080fd5b8135602067ffffffffffffffff8211156133475761334761322d565b8160051b613356828201613243565b928352848101820192828101908785111561337057600080fd5b83870192505b848310156130c757613387836131ca565b82529183019190830190613376565b6000806000806000806000806000806101408b8d0312156133b657600080fd5b6133bf8b6131ca565b99506133cd60208c016131ca565b985060408b013567ffffffffffffffff808211156133ea57600080fd5b6133f68e838f0161331a565b995060608d013591508082111561340c57600080fd5b506134198d828e0161331a565b97505061342860808c016131ca565b955061343660a08c016131ca565b945061344460c08c016131ca565b935061345260e08c016131ca565b92506101008b013591506134696101208c016131ca565b90509295989b9194979a5092959850565b6000806040838503121561348d57600080fd5b50508035926020909101359150565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b81810381811115610aaf57610aaf613534565b634e487b7160e01b600052603260045260246000fd5b80820180821115610aaf57610aaf613534565b60006020828403121561359857600080fd5b5051919050565b600080604083850312156135b257600080fd5b505080516020909101519092909150565b8082028115828204841417610aaf57610aaf613534565b634e487b7160e01b600052601260045260246000fd5b6000826135ff576135ff6135da565b500490565b6000600160ff1b820161361957613619613534565b5060000390565b808201828112600083128015821682158216171561364057613640613534565b505092915050565b60006001600160ff1b01820161366057613660613534565b5060010190565b60008161367657613676613534565b506000190190565b60008261368d5761368d6135da565b600160ff1b8214600019841416156136a7576136a7613534565b500590565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60005b838110156137125781810151838201526020016136fa565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516137538160178501602088016136f7565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516137848160288401602088016136f7565b01602801949350505050565b60208152600082518060208401526137af8160408501602087016136f7565b601f01601f19169190910160400192915050565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156138135784516001600160a01b0316835293830193918301916001016137ee565b50506001600160a01b03969096166060850152505050608001529392505050565b60008060006060848603121561384957600080fd5b8351925060208401519150604084015190509250925092565b60006020828403121561387457600080fd5b815180151581146114ee57600080fd5b634e487b7160e01b600052603160045260246000fd5b600082516138ac8184602087016136f7565b919091019291505056fe8b5b16d04624687fcf0d0228f19993c9157c1ed07b41d8d430fd9100eb099fe8360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564df8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec42b17d0a42cc710456bf9c3efb785dcd0cb93a0ac358113307b5c64b285b516b5ca26469706673582212208952f01b39d7b64fb56e74c6a900d4d685dee0781bd13fc7e806a06202cf99ee64736f6c63430008110033