Source Code
Overview
BTT Balance
More Info
ContractCreator
Multichain Info
N/A
| Transaction Hash |
Method
|
Block
|
From
|
To
|
Amount
|
||||
|---|---|---|---|---|---|---|---|---|---|
Latest 9 internal transactions
Loading...
Loading
Contract Name:
ElkFactoryHelper
Compiler Version
v0.8.19+commit.7dd6d404
Contract Source Code (Solidity)
/** *Submitted for verification at testnet.bttcscan.com on 2023-05-21 */ // SPDX-License-Identifier: BUSL-1.1 // // Copyright (c) 2023 ElkLabs // License terms: https://github.com/elkfinance/faas/blob/main/LICENSE // // Authors: // - Seth <[email protected]> // - Baal <[email protected]> // - Elijah <[email protected]> // - Snake <[email protected]> // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.0/contracts/utils/Address.sol // OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, "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"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, 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) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, 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) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or 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 { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // 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); } } } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.0/contracts/token/ERC20/extensions/draft-IERC20Permit.sol // 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); } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.0/contracts/token/ERC20/IERC20.sol // 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); } // File: contracts/interfaces/IStaking.sol // // Copyright (c) 2023 ElkLabs // License terms: https://github.com/elkfinance/faas/blob/main/LICENSE // // Authors: // - Seth <[email protected]> // - Baal <[email protected]> pragma solidity >=0.8.0; interface IStaking { /* ========== STATE VARIABLES ========== */ function stakingToken() external returns (IERC20); function totalSupply() external returns (uint256); function balances(address _account) external returns (uint256); /* ========== MUTATIVE FUNCTIONS ========== */ function stake(uint256 _amount) external; function withdraw(uint256 _amount) external; function exit() external; function recoverERC20( address _tokenAddress, address _recipient, uint256 _amount ) external; /* ========== EVENTS ========== */ // Emitted on staking event Staked(address indexed account, uint256 amount); // Emitted on withdrawal (including exit) event Withdrawn(address indexed account, uint256 amount); // Emitted on token recovery event Recovered( address indexed token, address indexed recipient, uint256 amount ); } // File: contracts/interfaces/IStakingFee.sol // // Copyright (c) 2023 ElkLabs // License terms: https://github.com/elkfinance/faas/blob/main/LICENSE // // Authors: // - Seth <[email protected]> // - Baal <[email protected]> pragma solidity >=0.8.0; interface IStakingFee is IStaking { /* ========== STATE VARIABLES ========== */ function feesUnit() external returns (uint256); function maxFee() external returns (uint256); function withdrawalFeeSchedule(uint256) external returns (uint256); function withdrawalFeesBps(uint256) external returns (uint256); function depositFeeBps() external returns (uint256); function collectedFees() external returns (uint256); function userLastStakedTime(address _user) external view returns (uint32); /* ========== VIEWS ========== */ function depositFee(uint256 _depositAmount) external view returns (uint256); function withdrawalFee( address _account, uint256 _withdrawalAmount ) external view returns (uint256); /* ========== MUTATIVE FUNCTIONS ========== */ function recoverFees(address _recipient) external; /* ========== EVENTS ========== */ // Emitted when fees are (re)configured event FeesSet( uint16 _depositFeeBps, uint16[] _withdrawalFeesBps, uint32[] _feeSchedule ); // Emitted when a deposit fee is collected event DepositFeesCollected(address indexed _user, uint256 _amount); // Emitted when a withdrawal fee is collected event WithdrawalFeesCollected(address indexed _user, uint256 _amount); // Emitted when fees are recovered by governance event FeesRecovered(uint256 _amount); } // File: contracts/interfaces/IStakingRewards.sol // // Copyright (c) 2023 ElkLabs // License terms: https://github.com/elkfinance/faas/blob/main/LICENSE // // Authors: // - Seth <[email protected]> // - Baal <[email protected]> pragma solidity >=0.8.0; interface IStakingRewards is IStakingFee { /* ========== STATE VARIABLES ========== */ function rewardTokens(uint256) external view returns (IERC20); function rewardTokenAddresses( address _rewardAddress ) external view returns (bool); function periodFinish() external view returns (uint256); function rewardsDuration() external view returns (uint256); function lastUpdateTime() external view returns (uint256); function rewardRates( address _rewardAddress ) external view returns (uint256); function rewardPerTokenStored( address _rewardAddress ) external view returns (uint256); // wallet address => token address => amount function userRewardPerTokenPaid( address _walletAddress, address _tokenAddress ) external view returns (uint256); function rewards( address _walletAddress, address _tokenAddress ) external view returns (uint256); /* ========== VIEWS ========== */ function lastTimeRewardApplicable() external view returns (uint256); function rewardPerToken( address _tokenAddress ) external view returns (uint256); function earned( address _tokenAddress, address _account ) external view returns (uint256); /* ========== MUTATIVE FUNCTIONS ========== */ function getReward(address _tokenAddress, address _recipient) external; function getRewards(address _recipient) external; // Must send reward before calling this! function startEmission( uint256[] memory _rewards, uint256 _duration ) external; function stopEmission(address _refundAddress) external; function recoverLeftoverReward( address _tokenAddress, address _recipient ) external; function addRewardToken(address _tokenAddress) external; function rewardTokenIndex( address _tokenAddress ) external view returns (int8); /* ========== EVENTS ========== */ // Emitted when a reward is paid to an account event RewardPaid( address indexed _token, address indexed _account, uint256 _reward ); // Emitted when a leftover reward is recovered event LeftoverRewardRecovered(address indexed _recipient, uint256 _amount); // Emitted when rewards emission is started event RewardsEmissionStarted(uint256[] _rewards, uint256 _duration); // Emitted when rewards emission ends event RewardsEmissionEnded(); } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.0/contracts/token/ERC20/utils/SafeERC20.sol // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; /** * @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"); } } } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.0/contracts/security/ReentrancyGuard.sol // OpenZeppelin Contracts (last updated v4.8.0) (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() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.0/contracts/utils/Context.sol // 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; } } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.0/contracts/access/Ownable.sol // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; /** * @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); } } // File: contracts/Staking.sol // // Copyright (c) 2023 ElkLabs // License terms: https://github.com/elkfinance/faas/blob/main/LICENSE // // Authors: // - Seth <[email protected]> // - Baal <[email protected]> // - Elijah <[email protected]> // - Snake <[email protected]> pragma solidity >=0.8.0; /** * Base contract implementing simple ERC20 token staking functionality (no staking rewards). */ contract Staking is ReentrancyGuard, Ownable, IStaking { using SafeERC20 for IERC20; /* ========== STATE VARIABLES ========== */ /// @notice Staking token interface IERC20 public immutable stakingToken; /// @notice Total supply of the staking token uint256 public totalSupply; /// @notice Account balances mapping(address => uint256) public balances; /* ========== CONSTRUCTOR ========== */ /// @param _stakingTokenAddress address of the token used for staking (must be ERC20) constructor(address _stakingTokenAddress) { require(_stakingTokenAddress != address(0), "E1"); stakingToken = IERC20(_stakingTokenAddress); } /** * @dev Stake tokens. * Note: the contract must have sufficient allowance for the staking token. * @param _amount amount to stake */ function stake(uint256 _amount) public nonReentrant { uint256 originalAmount = _amount; _amount = _beforeStake(msg.sender, _amount); require(_amount > 0 && originalAmount > 0, "E2"); // Check after the hook totalSupply += _amount; balances[msg.sender] += _amount; stakingToken.safeTransferFrom(msg.sender, address(this), originalAmount); emit Staked(msg.sender, _amount); } /** * @dev Withdraw previously staked tokens. * @param _amount amount to withdraw */ function withdraw(uint256 _amount) public nonReentrant { uint256 originalAmount = _amount; _amount = _beforeWithdraw(msg.sender, _amount); require( _amount > 0 && _amount <= balances[msg.sender] && originalAmount <= balances[msg.sender], "E3" ); // Check after the hook totalSupply -= originalAmount; balances[msg.sender] -= originalAmount; stakingToken.safeTransfer(msg.sender, _amount); emit Withdrawn(msg.sender, _amount); } /** * @dev Exit the farm, i.e., withdraw the entire token balance of the calling account */ function exit() external { _beforeExit(msg.sender); withdraw(balances[msg.sender]); } /* ========== RESTRICTED FUNCTIONS ========== */ /** * @dev Recover ERC20 tokens held in the contract. * Note: privileged governance function to recover tokens mistakenly sent to this contract address. * This function cannot be used to withdraw staking tokens. * @param _tokenAddress address of the token to recover * @param _recipient recovery address * @param _amount amount to withdraw * @ return withdrawn amount (may differ from input amount due to e.g., fees) */ function recoverERC20( address _tokenAddress, address _recipient, uint256 _amount ) external nonReentrant onlyOwner { require( _tokenAddress != address(stakingToken), "E4" ); _beforeRecoverERC20(_tokenAddress, _recipient, _amount); IERC20 token = IERC20(_tokenAddress); token.safeTransfer(_recipient, _amount); emit Recovered(_tokenAddress, _recipient, _amount); } /* ========== HOOKS ========== */ /** * @dev Internal hook called before staking (in the stake() function). * @ param _account staker address * @param _amount amount being staken * @return amount to stake (may be changed by the hook) */ function _beforeStake( address /*_account*/, uint256 _amount ) internal virtual returns (uint256) { return _amount; } /** * @dev Internal hook called before withdrawing (in the withdraw() function). * @ param _account withdrawer address * @param _amount amount being withdrawn * @return amount to withdraw (may be changed by the hook) */ function _beforeWithdraw( address /*_account*/, uint256 _amount ) internal virtual returns (uint256) { return _amount; } /** * @dev Internal hook called before exiting (in the exit() function). * Note: since exit() calls withdraw() internally, the _beforeWithdraw() hook fill fire too. * @param _account address exiting */ function _beforeExit(address _account) internal virtual {} /** * @dev Internal hook called before recovering tokens (in the recoverERC20() function). * @param _tokenAddress address of the token being recovered * @param _recipient recovery address * @param _amount amount being withdrawn */ function _beforeRecoverERC20( address _tokenAddress, address _recipient, uint256 _amount ) internal virtual {} } // File: contracts/StakingFee.sol // // Copyright (c) 2023 ElkLabs // License terms: https://github.com/elkfinance/faas/blob/main/LICENSE // // Authors: // - Seth <[email protected]> // - Baal <[email protected]> // - Elijah <[email protected]> // - Snake <[email protected]> pragma solidity >=0.8.0; /** * Contract implementing simple ERC20 token staking functionality and supporting deposit/withdrawal fees (no staking rewards). */ contract StakingFee is Staking, IStakingFee { using SafeERC20 for IERC20; /* ========== STATE VARIABLES ========== */ /// @notice Constant Fee Unit (1e4) uint256 public constant feesUnit = 10000; /// @notice Maximum fee (20%) uint256 public constant maxFee = 2000; /// @notice Schedule of withdrawal fees represented as a sorted array of durations /// @dev example: 10% after 1 hour, 1% after a day, 0% after a week => [3600, 86400] uint256[] public withdrawalFeeSchedule; /// @notice Withdrawal fees described in basis points (fee unit) represented as an array of the same length as withdrawalFeeSchedule /// @dev example: 10% after 1 hour, 1% after a day, 0% after a week => [1000, 100] uint256[] public withdrawalFeesBps; /// @notice Deposit (staking) fee in basis points (fee unit) uint256 public depositFeeBps; /// @notice Counter of collected fees uint256 public collectedFees; /// @notice Last staking time for each user mapping(address => uint32) public userLastStakedTime; /* ========== CONSTRUCTOR ========== */ /** * @param _stakingTokenAddress address of the token used for staking (must be ERC20) * @param _depositFeeBps deposit fee in basis points * @param _withdrawalFeesBps aligned to fee schedule * @param _withdrawalFeeSchedule assumes a sorted array */ constructor( address _stakingTokenAddress, uint16 _depositFeeBps, uint16[] memory _withdrawalFeesBps, uint32[] memory _withdrawalFeeSchedule ) Staking(_stakingTokenAddress) { _setFees(_depositFeeBps, _withdrawalFeesBps, _withdrawalFeeSchedule); } /* ========== VIEWS ========== */ /** * @dev Calculate the deposit fee for a given amount. * @param _depositAmount amount to stake * @return fee paid upon deposit */ function depositFee(uint256 _depositAmount) public view returns (uint256) { return depositFeeBps > 0 ? (_depositAmount * depositFeeBps) / feesUnit : 0; } /** * @dev Calculate the withdrawal fee for a given amount. * @param _account user wallet address * @param _withdrawalAmount amount to withdraw * @return fee paid upon withdrawal */ function withdrawalFee( address _account, uint256 _withdrawalAmount ) public view returns (uint256) { uint256 userLastStakedTimestampDiff = block.timestamp - userLastStakedTime[_account]; uint256 withdrawalFeeAmount; for (uint i = 0; i < withdrawalFeeSchedule.length; ++i) { if (userLastStakedTimestampDiff < withdrawalFeeSchedule[i]) { withdrawalFeeAmount = (_withdrawalAmount * withdrawalFeesBps[i]) / feesUnit; break; } } return withdrawalFeeAmount; } /* ========== RESTRICTED FUNCTIONS ========== */ /** * @dev Recover collected fees held in the contract. * Note: privileged function for governance * @param _recipient fee recovery address */ function recoverFees(address _recipient) external onlyOwner nonReentrant { _beforeRecoverFees(_recipient); uint256 previousFees = collectedFees; collectedFees = 0; emit FeesRecovered(previousFees); stakingToken.safeTransfer(_recipient, previousFees); } /* ========== PRIVATE FUNCTIONS ========== */ /** * @dev Configure the fees for this contract. * @param _depositFeeBps deposit fee in basis points * @param _withdrawalFeesBps withdrawal fees in basis points * @param _withdrawalFeeSchedule withdrawal fees schedule */ function _setFees( uint16 _depositFeeBps, uint16[] memory _withdrawalFeesBps, uint32[] memory _withdrawalFeeSchedule ) private { require(_withdrawalFeeSchedule.length == _withdrawalFeesBps.length && _withdrawalFeeSchedule.length <= 10 && _depositFeeBps <= maxFee, "E5"); uint32 lastFeeSchedule = 0; uint256 lastWithdrawalFee = maxFee + 1; for (uint i = 0; i < _withdrawalFeeSchedule.length; ++i) { require(_withdrawalFeeSchedule[i] > lastFeeSchedule, "E7"); require(_withdrawalFeesBps[i] < lastWithdrawalFee, "E8"); lastFeeSchedule = _withdrawalFeeSchedule[i]; lastWithdrawalFee = _withdrawalFeesBps[i]; } withdrawalFeeSchedule = _withdrawalFeeSchedule; withdrawalFeesBps = _withdrawalFeesBps; depositFeeBps = _depositFeeBps; emit FeesSet( _depositFeeBps, _withdrawalFeesBps, _withdrawalFeeSchedule ); } /* ========== HOOKS ========== */ /** * @dev Override _beforeStake() hook to collect the deposit fee and update associated state */ function _beforeStake( address _account, uint256 _amount ) internal virtual override returns (uint256) { uint256 fee = depositFee(_amount); userLastStakedTime[_account] = uint32(block.timestamp); if (fee > 0) { collectedFees += fee; emit DepositFeesCollected(_account, fee); } return super._beforeStake(_account, _amount - fee); } /** * @dev Override _beforeWithdrawl() hook to collect the withdrawal fee and update associated state */ function _beforeWithdraw( address _account, uint256 _amount ) internal virtual override returns (uint256) { uint256 fee = withdrawalFee(_account, _amount); if (fee > 0) { collectedFees += fee; emit WithdrawalFeesCollected(_account, fee); } return super._beforeWithdraw(_account, _amount - fee); } /** * @dev Internal hook called before recovering fees (in the recoverFees() function). * @param _recipient recovery address */ function _beforeRecoverFees(address _recipient) internal virtual {} } // File: contracts/StakingRewards.sol // // Copyright (c) 2023 ElkLabs // License terms: https://github.com/elkfinance/faas/blob/main/LICENSE // // Authors: // - Seth <[email protected]> // - Baal <[email protected]> // - Elijah <[email protected]> // - Snake <[email protected]> pragma solidity >=0.8.0; /** * Contract implementing simple ERC20 token staking functionality with staking rewards and deposit/withdrawal fees. */ contract StakingRewards is StakingFee, IStakingRewards { using SafeERC20 for IERC20; /* ========== STATE VARIABLES ========== */ /// @notice List of reward token interfaces IERC20[] public rewardTokens; /// @notice Reward token addresses (maps every reward token address to true, others to false) mapping(address => bool) public rewardTokenAddresses; /// @notice Timestamp when rewards stop emitting uint256 public periodFinish; /// @notice Duration for reward emission uint256 public rewardsDuration; /// @notice Last time the rewards were updated uint256 public lastUpdateTime; /// @notice Reward token rates (maps every reward token to an emission rate, i.e., how many tokens emitted per second) mapping(address => uint256) public rewardRates; /// @notice How many tokens are emitted per staked token mapping(address => uint256) public rewardPerTokenStored; /// @notice How many reward tokens were paid per user (token address => wallet address => amount) mapping(address => mapping(address => uint256)) public userRewardPerTokenPaid; /// @notice Accumulator of reward tokens per user (token address => wallet address => amount) mapping(address => mapping(address => uint256)) public rewards; /* ========== CONSTRUCTOR ========== */ /** * @param _stakingTokenAddress address of the token used for staking (must be ERC20) * @param _rewardTokenAddresses addresses the reward tokens (must be ERC20) * @param _rewardsDuration reward emission duration * @param _depositFeeBps deposit fee in basis points * @param _withdrawalFeesBps aligned to fee schedule * @param _withdrawalFeeSchedule assumes a sorted array */ constructor( address _stakingTokenAddress, address[] memory _rewardTokenAddresses, uint256 _rewardsDuration, uint16 _depositFeeBps, uint16[] memory _withdrawalFeesBps, uint32[] memory _withdrawalFeeSchedule ) StakingFee( _stakingTokenAddress, _depositFeeBps, _withdrawalFeesBps, _withdrawalFeeSchedule ) { require(_rewardTokenAddresses.length > 0, "E9"); // update reward data structures for (uint i = 0; i < _rewardTokenAddresses.length; ++i) { address tokenAddress = _rewardTokenAddresses[i]; _addRewardToken(tokenAddress); } rewardsDuration = _rewardsDuration; } /* ========== VIEWS ========== */ /** * @notice Return the last time rewards are applicable (the lowest of the current timestamp and the rewards expiry timestamp). * @return timestamp */ function lastTimeRewardApplicable() public view returns (uint256) { return block.timestamp < periodFinish ? block.timestamp : periodFinish; } /** * @notice Return the reward per staked token for a given reward token address. * @param _tokenAddress reward token address * @return amount of reward per staked token */ function rewardPerToken( address _tokenAddress ) public view returns (uint256) { if (totalSupply == 0) { return rewardPerTokenStored[_tokenAddress]; } return rewardPerTokenStored[_tokenAddress] + ((lastTimeRewardApplicable() - lastUpdateTime) * rewardRates[_tokenAddress] * 1e18) / totalSupply; } /** * @notice Return the total reward earned by a user for a given reward token address. * @param _tokenAddress reward token address * @param _account user wallet address * @return amount earned */ function earned( address _tokenAddress, address _account ) public view returns (uint256) { return (balances[_account] * (rewardPerToken(_tokenAddress) - userRewardPerTokenPaid[_tokenAddress][_account])) / 1e18 + rewards[_tokenAddress][_account]; } /* ========== MUTATIVE FUNCTIONS ========== */ /** * @dev claim the specified token reward for a staker * @param _tokenAddress the address of the reward token * @param _recipient the address of the staker that should receive the reward * @ return amount of reward received */ function getReward( address _tokenAddress, address _recipient ) public nonReentrant updateRewards(_recipient) { return _getReward(_tokenAddress, _recipient); } /** * @dev claim rewards for all the reward tokens for the staker * @param _recipient address of the recipient to receive the rewards */ function getRewards( address _recipient ) public nonReentrant updateRewards(_recipient) { for (uint i = 0; i < rewardTokens.length; ++i) { _getReward(address(rewardTokens[i]), _recipient); } } /** * @dev Start the emission of rewards to stakers. The owner must send reward tokens to the contract before calling this function. * Note: Can only be called by owner when the contract is not emitting rewards. * @param _rewards array of rewards amounts for each reward token * @param _duration duration in seconds for which rewards will be emitted */ function startEmission( uint256[] memory _rewards, uint256 _duration ) public virtual nonReentrant onlyOwner whenNotEmitting updateRewards(address(0)) { require(_duration > 0, "E10"); require(_rewards.length == rewardTokens.length, "E11"); _beforeStartEmission(_rewards, _duration); rewardsDuration = _duration; for (uint i = 0; i < rewardTokens.length; ++i) { IERC20 token = rewardTokens[i]; address tokenAddress = address(token); rewardRates[tokenAddress] = _rewards[i] / rewardsDuration; // Ensure the provided reward amount is not more than the balance in the contract. // This keeps the reward rate in the right range, preventing overflows due to // very high values of rewardRate in the earned and rewardsPerToken functions; // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow. uint256 balance = rewardTokens[i].balanceOf(address(this)); if (tokenAddress != address(stakingToken)) { require( rewardRates[tokenAddress] <= balance / rewardsDuration, "E3" ); } else { // Handle carefully where rewardsToken is the same as stakingToken (need to subtract total supply) require( rewardRates[tokenAddress] <= (balance - totalSupply) / rewardsDuration, "E3" ); } } lastUpdateTime = block.timestamp; periodFinish = block.timestamp + rewardsDuration; emit RewardsEmissionStarted(_rewards, _duration); } /** * @dev stop the reward emission process and transfer the remaining reward tokens to a specified address * Note: can only be called by owner when the contract is currently emitting rewards * @param _refundAddress the address to receive the remaining reward tokens */ function stopEmission( address _refundAddress ) external nonReentrant onlyOwner whenEmitting { _beforeStopEmission(_refundAddress); uint256 remaining = 0; if (periodFinish > block.timestamp) { remaining = periodFinish - block.timestamp; } periodFinish = block.timestamp; for (uint i = 0; i < rewardTokens.length; ++i) { IERC20 token = rewardTokens[i]; address tokenAddress = address(token); uint256 refund = rewardRates[tokenAddress] * remaining; if (refund > 0) { token.safeTransfer(_refundAddress, refund); } } emit RewardsEmissionEnded(); } /** * @dev recover leftover reward tokens and transfer them to a specified recipient * Note: can only be called by owner when the contract is not emitting rewards * @param _tokenAddress address of the reward token to be recovered * @param _recipient address to receive the recovered reward tokens */ function recoverLeftoverReward( address _tokenAddress, address _recipient ) external onlyOwner whenNotEmitting { require(totalSupply == 0, "E12"); if (rewardTokenAddresses[_tokenAddress]) { _beforeRecoverLeftoverReward(_tokenAddress, _recipient); IERC20 token = IERC20(_tokenAddress); uint256 amount = token.balanceOf(address(this)); if (amount > 0) { token.safeTransfer(_recipient, amount); } emit LeftoverRewardRecovered(_recipient, amount); } } /** * @dev add a reward token to the contract * Note: can only be called by owner when the contract is not emitting rewards * @param _tokenAddress address of the new reward token */ function addRewardToken( address _tokenAddress ) external onlyOwner whenNotEmitting { _addRewardToken(_tokenAddress); } /** * @dev Return the array index of the provided token address (if applicable) * @param _tokenAddress address of the LP token * @return the array index for _tokenAddress or -1 if it is not a reward token */ function rewardTokenIndex( address _tokenAddress ) public view returns (int8) { if (rewardTokenAddresses[_tokenAddress]) { for (uint i = 0; i < rewardTokens.length; ++i) { if (address(rewardTokens[i]) == _tokenAddress) { return int8(int256(i)); } } } return -1; } /* ========== PRIVATE FUNCTIONS ========== */ /** * @dev Get the reward amount of a token for a specific recipient * @param _tokenAddress address of the token * @param _recipient address of the recipient */ function _getReward(address _tokenAddress, address _recipient) private { require(msg.sender == owner() || msg.sender == _recipient, "E14"); require(rewardTokenAddresses[_tokenAddress], "E13"); uint256 reward = rewards[_tokenAddress][_recipient]; if (reward > 0) { rewards[_tokenAddress][_recipient] = 0; IERC20(_tokenAddress).safeTransfer(_recipient, reward); emit RewardPaid(_tokenAddress, _recipient, reward); } } /** * @dev Add a token as a reward token * @param _tokenAddress address of the token to be added as a reward token */ function _addRewardToken(address _tokenAddress) private { require(rewardTokens.length <= 15, "E15"); require(_tokenAddress != address(0), "E1"); if (!rewardTokenAddresses[_tokenAddress]) { rewardTokens.push(IERC20(_tokenAddress)); rewardTokenAddresses[_tokenAddress] = true; } } /* ========== HOOKS ========== */ /** * @dev Override _beforeStake() hook to ensure staking is only possible when rewards are emitting and update the rewards */ function _beforeStake( address _account, uint256 _amount ) internal virtual override whenEmitting updateRewards(_account) returns (uint256) { return super._beforeStake(_account, _amount); } /** * @dev Override _beforeExit() hook to claim all rewards for the account exiting */ function _beforeExit(address _account) internal virtual override { getRewards(_account); // getRewards calls updateRewards so we don't need to call it explicitly again here super._beforeExit(_account); } /** * @dev Override _beforeRecoverERC20() hook to prevent recovery of a reward token */ function _beforeRecoverERC20( address _tokenAddress, address _recipient, uint256 _amount ) internal virtual override { require(!rewardTokenAddresses[_tokenAddress], "E16"); super._beforeRecoverERC20(_tokenAddress, _recipient, _amount); } /** * @dev Internal hook called before starting the emission process (in the startEmission() function). * @param _rewards array of rewards per token. * @param _duration emission duration. */ function _beforeStartEmission( uint256[] memory _rewards, uint256 _duration ) internal virtual {} /** * @dev Internal hook called before stopping the emission process (in the stopEmission() function). * @param _refundAddress address to refund the remaining reward to */ function _beforeStopEmission(address _refundAddress) internal virtual {} /** * @dev Internal hook called before recovering leftover rewards (in the recoverLeftoverRewards() function). * @param _tokenAddress address of the token to recover * @param _recipient address to recover the leftover rewards to */ function _beforeRecoverLeftoverReward( address _tokenAddress, address _recipient ) internal virtual {} /* ========== MODIFIERS ========== */ /** * @dev Modifier to update rewards of a given account. * @param _account account to update rewards for */ modifier updateRewards(address _account) { for (uint i = 0; i < rewardTokens.length; ++i) { address tokenAddress = address(rewardTokens[i]); rewardPerTokenStored[tokenAddress] = rewardPerToken(tokenAddress); if (_account != address(0)) { rewards[tokenAddress][_account] = earned(tokenAddress, _account); userRewardPerTokenPaid[tokenAddress][_account] = rewardPerTokenStored[tokenAddress]; } } lastUpdateTime = lastTimeRewardApplicable(); _; } /** * @dev Modifier to check if rewards are emitting. */ modifier whenEmitting() { require(block.timestamp <= periodFinish, "E18"); _; } /** * @dev Modifier to check if rewards are not emitting. */ modifier whenNotEmitting() { require(block.timestamp > periodFinish, "E17"); _; } } // File: contracts/interfaces/IElkPair.sol // // Copyright (c) 2023 ElkLabs // License terms: https://github.com/elkfinance/faas/blob/main/LICENSE // // Authors: // - Seth <[email protected]> // - Baal <[email protected]> pragma solidity >=0.5.0; interface IElkPair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address _owner) external view returns (uint); function allowance( address _owner, address _spender ) external view returns (uint); function approve(address _spender, uint _value) external returns (bool); function transfer(address _to, uint _value) external returns (bool); function transferFrom( address _from, address _to, uint _value ) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address _owner) external view returns (uint); function permit( address _owner, address _spender, uint _value, uint _deadline, uint8 _v, bytes32 _r, bytes32 _s ) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn( address indexed sender, uint amount0, uint amount1, address indexed to ); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns ( uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast ); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address _to) external returns (uint liquidity); function burn(address _to) external returns (uint amount0, uint amount1); function swap( uint _amount0Out, uint _amount1Out, address _to, bytes calldata _data ) external; function skim(address _to) external; function sync() external; function initialize(address, address) external; } // File: contracts/interfaces/IElkDexOracle.sol // // Copyright (c) 2023 ElkLabs // License terms: https://github.com/elkfinance/faas/blob/main/LICENSE // // Authors: // - Seth <[email protected]> // - Baal <[email protected]> pragma solidity >=0.8.0; interface IElkDexOracle { struct Observation { uint timestamp; uint price0Cumulative; uint price1Cumulative; } function weth() external view returns (address); function factory() external view returns (address); function windowSize() external view returns (uint); function granularity() external view returns (uint8); function periodSize() external view returns (uint); function pairObservations( address _pair ) external view returns (Observation[] memory); function observationIndexOf(uint _timestamp) external view returns (uint); function update(address _tokenA, address _tokenB) external; function updateWeth(address _token) external; function consult( address _tokenIn, uint _amountIn, address _tokenOut ) external view returns (uint); function consultWeth( address _tokenIn, uint _amountIn ) external view returns (uint); } // File: contracts/interfaces/IFarmingRewards.sol // // Copyright (c) 2023 ElkLabs // License terms: https://github.com/elkfinance/faas/blob/main/LICENSE // // Authors: // - Seth <[email protected]> // - Baal <[email protected]> pragma solidity >=0.8.0; interface IFarmingRewards is IStakingRewards { /// @notice Represents a snapshot of an LP position at a given timestamp struct Position { uint112 amount0; uint112 amount1; uint32 blockTimestamp; } /* ========== STATE VARIABLES ========== */ function oracle() external returns (IElkDexOracle); function lpToken() external returns (IElkPair); function coverageTokenAddress() external returns (address); function coverageAmount() external returns (uint256); function coverageVestingDuration() external returns (uint256); function coverageRate() external returns (uint256); function coveragePerTokenStored() external returns (uint256); function userCoveragePerTokenPaid( address _tokenPaid ) external returns (uint256); function coverage(address _token) external returns (uint256); function lastStakedPosition( address _user ) external returns (uint112 amount0, uint112 amount1, uint32 blockTimeStamp); /* ========== VIEWS ========== */ function coveragePerToken() external view returns (uint256); function coverageEarned(address _account) external view returns (uint256); /* ========== MUTATIVE FUNCTIONS ========== */ function getCoverage(address _recipient) external; function startEmission( uint256[] memory _rewards, uint256 _coverage, uint256 _duration ) external; function recoverLeftoverCoverage(address _recipient) external; /* ========== EVENTS ========== */ // Emitted when the coverage is paid to an account event CoveragePaid(address indexed account, uint256 coverage); // Emitted when the leftover coverage is recovered event LeftoverCoverageRecovered(address indexed recipient, uint256 amount); } // File: contracts/FarmingRewards.sol // // Copyright (c) 2023 ElkLabs // License terms: https://github.com/elkfinance/faas/blob/main/LICENSE // // Authors: // - Seth <[email protected]> // - Baal <[email protected]> // - Elijah <[email protected]> // - Snake <[email protected]> pragma solidity >=0.8.0; /** * Contract implementing simple ERC20 token staking functionality with staking rewards, impermanent loss coverage, and deposit/withdrawal fees. */ contract FarmingRewards is StakingRewards, IFarmingRewards { using SafeERC20 for IERC20; /* ========== STATE VARIABLES ========== */ /// @notice Interface to the ElkDex pricing oracle on this blockchain IElkDexOracle public immutable oracle; /// @notice Interface to the LP token that is staked in this farm IElkPair public immutable lpToken; /// @notice Address of the coverage token address public coverageTokenAddress; /// @notice Total amount of coverage available (worst case max amount) uint256 public coverageAmount; /// @notice Time until a farmed position is fully covered against impermanent loss (100%) uint256 public coverageVestingDuration; /// @notice Rate of coverage vesting uint256 public coverageRate; /// @notice Coverage amount per token staked in the farm uint256 public coveragePerTokenStored; /// @notice How much coverage was paid per user (wallet address => amount) mapping(address => uint256) public userCoveragePerTokenPaid; /// @notice Accumulator of coverage tokens per user (wallet address => amount) mapping(address => uint256) public coverage; /// @notice Last farming position for a given user (wallet address => position) mapping(address => Position) public lastStakedPosition; /* ========== CONSTRUCTOR ========== */ /** * @param _oracleAddress address of the price oracle * @param _lpTokenAddress address of the staking LP token (must be an ElkDex LP) * @param _coverageTokenAddress address of the token that the coverage is paid in * @param _coverageAmount total amount of coverage * @param _coverageVestingDuration time it takes to vest 100% of the coverage (min. 1 day) * @param _rewardTokenAddresses addresses the reward tokens (must be ERC20) * @param _rewardsDuration reward emission duration * @param _depositFeeBps deposit fee in basis points * @param _withdrawalFeesBps aligned to fee schedule * @param _withdrawalFeeSchedule assumes a sorted array */ constructor( address _oracleAddress, address _lpTokenAddress, address _coverageTokenAddress, uint256 _coverageAmount, uint32 _coverageVestingDuration, address[] memory _rewardTokenAddresses, uint256 _rewardsDuration, uint16 _depositFeeBps, uint16[] memory _withdrawalFeesBps, uint32[] memory _withdrawalFeeSchedule ) StakingRewards( _lpTokenAddress, _rewardTokenAddresses, _rewardsDuration, _depositFeeBps, _withdrawalFeesBps, _withdrawalFeeSchedule ) { oracle = IElkDexOracle(_oracleAddress); lpToken = IElkPair(_lpTokenAddress); if (_coverageTokenAddress != address(0)) { require( lpToken.token0() == _coverageTokenAddress || lpToken.token1() == _coverageTokenAddress, "E19" ); require( _coverageVestingDuration >= 24 * 3600 && _coverageVestingDuration <= rewardsDuration, "E21" ); } require( lpToken.factory() == oracle.factory(), "E20" ); coverageTokenAddress = _coverageTokenAddress; coverageAmount = _coverageAmount; coverageVestingDuration = _coverageVestingDuration; } // Optimized version below /*function coveragePerToken() public view returns (uint256) { if (totalSupply == 0) { return coveragePerTokenStored; } return // does this work for non 18 dec tokens? rate = _coverage / rewardsDuration, here rate is converted back to 18 dec coveragePerTokenStored + ((lastTimeRewardApplicable() - lastUpdateTime) * coverageRate * 1e18) / totalSupply; }*/ /** * @dev Return the coverage per staked token (in coverage token amounts) * @return amount of coverage per staked token */ function coveragePerToken() public view returns (uint256) { return totalSupply == 0 ? coveragePerTokenStored : coveragePerTokenStored + (((lastTimeRewardApplicable() - lastUpdateTime) * coverageRate * 1e18) / totalSupply); } // Code below optimizes this version of the function /*function coverageEarned(address _account) public view returns(uint256) { if (coverageTokenAddress == address(0)) { return 0; } uint256 hodlValue = lpValueWeth(lastStakedPosition[_account]); if (hodlValue == 0) { // prevent division by zero below // equivalent check would be lastStakedPosition[_account].blockTimestamp > 0 return coverage[_account]; } uint256 outValue = lpValueWeth(position(balances[_account])); uint256 cappedCoverage = (balances[_account] * (coveragePerToken() - userCoveragePerTokenPaid[_account])) / 1e18; uint256 vested = vestedCoverage( hodlValue, outValue, lastStakedPosition[_account].blockTimestamp ); if (vested > cappedCoverage) { vested = cappedCoverage; } // amount * (hodl value - out value) / hodl value = amount * (1 - (out value / hodl value)) return (vested - (vested * outValue) / hodlValue) + coverage[_account]; }*/ /** * @dev Return the total coverage earned by a user. * @param _account user wallet address * @return coverage amount earned */ function coverageEarned(address _account) public view returns(uint256) { if (coverageTokenAddress == address(0)) { return 0; } Position memory lastStake = lastStakedPosition[_account]; uint256 hodlValue = lpValueWeth(lastStake); if (hodlValue == 0) { return coverage[_account]; } uint256 outValue = lpValueWeth(position(balances[_account])); uint256 balance = balances[_account]; uint256 cappedCoverage = (balance * (coveragePerToken() - userCoveragePerTokenPaid[_account])) / 1e18; uint256 vested = vestedCoverage(hodlValue, outValue, lastStake.blockTimestamp); return (vested > cappedCoverage ? cappedCoverage : vested) - (vested * outValue) / hodlValue + coverage[_account]; } /* ========== MUTATIVE FUNCTIONS ========== */ // Optimized version of this below /* function getCoverage( address _recipient ) public nonReentrant updateCoverage(_recipient) { require( msg.sender == owner() || msg.sender == _recipient, "E14" ); require(coverageTokenAddress != address(0), "E23"); uint256 cov = coverage[_recipient]; if (cov > 0) { coverage[_recipient] = 0; IERC20(coverageTokenAddress).safeTransfer(_recipient, cov); emit CoveragePaid(_recipient, cov); } } */ /** * @dev claim the coverage for a staker * @param _recipient the address of the staker that should receive the coverage * @ return the amount of reward received */ function getCoverage(address _recipient) public nonReentrant updateCoverage(_recipient) { require(msg.sender == owner() || msg.sender == _recipient, "E14"); require(coverageTokenAddress != address(0), "E23"); uint256 cov = coverage[_recipient]; if (cov == 0) return; coverage[_recipient] = 0; IERC20(coverageTokenAddress).safeTransfer(_recipient, cov); emit CoveragePaid(_recipient, cov); } /** * @dev Set the coverage parameters if none were set in the constructor. Gives the option for farm owners to change coverage tokens. * Note: Can't change coverage token if coverage is already accumulated * @param _tokenAddress address of token to be used for coverage emissions * @param _coverageAmount total amount of coverage token to emit * @param _coverageVestingDuration vesting period in seconds that users need to have staked to claim coverage */ function setCoverage(address _tokenAddress, uint256 _coverageAmount, uint32 _coverageVestingDuration) external onlyOwner whenNotEmitting { require(coveragePerTokenStored == 0, "E24"); require( (lpToken.token0() == _tokenAddress || lpToken.token1() == _tokenAddress) && (_coverageVestingDuration >= 24 * 3600) && (_coverageVestingDuration <= rewardsDuration), "E19" ); coverageTokenAddress = _tokenAddress; coverageAmount = _coverageAmount; coverageVestingDuration = _coverageVestingDuration; } // Override startEmission() so it calls the expanded function that includes the coverage amount /** * @dev Start the emission of rewards to stakers with no coverage. The owner must send reward tokens to the contract before calling this function. * Note: Can only be called by owner when the contract is not emitting rewards. * @param _rewards array of rewards amounts for each reward token * @param _duration duration in seconds for which rewards will be emitted */ function startEmission( uint256[] memory _rewards, uint256 _duration ) public override(StakingRewards, IStakingRewards) onlyOwner { return startEmission(_rewards, 0, _duration); } /** * @dev Start the emission of rewards to stakers. The owner must send reward and coverage tokens to the contract before calling this function. * Note: Can only be called by owner when the contract is not emitting rewards. * @param _rewards array of rewards amounts for each reward token * @param _coverage total amount of coverage provided to users (worst case max) * @param _duration duration in seconds for which rewards will be emitted (and coverage will be active) */ function startEmission( uint256[] memory _rewards, uint256 _coverage, uint256 _duration ) public onlyOwner updateCoverage(address(0)) { super.startEmission(_rewards, _duration); require( coverageVestingDuration <= rewardsDuration, "E22" ); // must check again coverageRate = _coverage / rewardsDuration; // rewardsDuration, not coverageVestingDuration which can be shorter! if (coverageTokenAddress != address(0) && _coverage > 0) { // Ensure the provided coverage amount is not more than the balance in the contract uint256 balance = IERC20(coverageTokenAddress).balanceOf( address(this) ); int8 tokenIndex = rewardTokenIndex(coverageTokenAddress); if (tokenIndex >= 0) { balance -= _rewards[uint256(int256(tokenIndex))]; } require( coverageRate <= balance / rewardsDuration, "E3" ); } } /** * @dev recover leftover coverage tokens and transfer them to a specified recipient * Note: can only be called by owner when the contract is not emitting rewards * @param _recipient address to receive the recovered coverage tokens */ function recoverLeftoverCoverage(address _recipient) public onlyOwner whenNotEmitting { require(totalSupply == 0 && coverageTokenAddress != address(0), "E12/E23"); _beforeRecoverLeftoverCoverage(_recipient); IERC20 token = IERC20(coverageTokenAddress); uint256 amount = token.balanceOf(address(this)); if (amount > 0) { token.safeTransfer(_recipient, amount); emit LeftoverCoverageRecovered(_recipient, amount); } } /* ========== PRIVATE FUNCTIONS ========== */ /** * @dev Return the LP position for a given amount of LP token. * @param _amount the amount of LP token * @return the corresponding LP position (amount0, amount1, timestamp) */ function position(uint256 _amount) private view returns (Position memory) { (uint112 reserve0, uint112 reserve1, uint32 timestamp) = lpToken.getReserves(); uint256 totalAmount = lpToken.totalSupply(); return Position(uint112((_amount * reserve0) / totalAmount), uint112((_amount * reserve1) / totalAmount), timestamp); } /** * @dev Return the value in WETH of the given LP position. * @param _position LP position * @return the value in WETH */ function lpValueWeth( Position memory _position ) private view returns (uint256) { return oracle.consultWeth(lpToken.token0(), _position.amount0) + oracle.consultWeth(lpToken.token1(), _position.amount1); } /** * @dev Return the vested coverage in coverage token amount for the given HODL and OUT values since the provided timestamp. * @param _hodlValue the value (in WETH) if the tokens making up the LP were kept unpaired * @param _outValue the value (in WETH) of the LP token position * @param _lastTimestamp the start timestamp (when the LP token position was created) * @return vested coverage in coverage token amount */ function vestedCoverage( uint256 _hodlValue, uint256 _outValue, uint32 _lastTimestamp ) private view returns (uint256) { uint256 timeElapsed = block.timestamp - _lastTimestamp; uint256 wethCov = _hodlValue > _outValue ? _hodlValue - _outValue : 0; uint256 tokenCoverage = wethCov == 0 ? 0 : oracle.consult(oracle.weth(), wethCov, coverageTokenAddress); if (timeElapsed >= coverageVestingDuration) { return tokenCoverage; } return (tokenCoverage * timeElapsed) / coverageVestingDuration; } /* ========== HOOKS ========== */ /** * @dev Override _beforeStake() hook to ensure staking updates the coverage */ function _beforeStake( address _account, uint256 _amount ) internal virtual override updateCoverage(_account) returns (uint256) { return super._beforeStake(_account, _amount); } /** * @dev Override _beforeWithdraw() hook to ensure withdrawing updates the coverage */ function _beforeWithdraw( address _account, uint256 _amount ) internal virtual override updateCoverage(_account) returns (uint256) { return super._beforeWithdraw(_account, _amount); } /** * @dev Override _beforeExit() hook to claim all coverage for the account exiting */ function _beforeExit(address _account) internal virtual override { if (coverageTokenAddress != address(0)) { getCoverage(_account); } super._beforeExit(_account); } /** * @dev Override _beforeRecoverERC20() hook to prevent recovery of a coverage token */ function _beforeRecoverERC20( address _tokenAddress, address _recipient, uint256 _amount ) internal virtual override { require( _tokenAddress != coverageTokenAddress, "E16" ); super._beforeRecoverERC20(_tokenAddress, _recipient, _amount); } // New hooks /** * @dev Internal hook called before recovering leftover coverage (in the recoverLeftoverCoverage() function). * @param _recipient address to recover the leftover coverage to */ function _beforeRecoverLeftoverCoverage( address _recipient ) internal virtual {} /* ========== MODIFIERS ========== */ /** * @dev Modifier to update the coverage of a given account. * @param _account account to update coverage for */ modifier updateCoverage(address _account) { if (coverageTokenAddress != address(0)) { coveragePerTokenStored = coveragePerToken(); lastUpdateTime = lastTimeRewardApplicable(); // it seems fine to redo this here oracle.update(lpToken.token0(), oracle.weth()); // update oracle for first token oracle.update(lpToken.token1(), oracle.weth()); // ditto for the second token if (_account != address(0)) { coverage[_account] = coverageEarned(_account); userCoveragePerTokenPaid[_account] = coveragePerTokenStored; lastStakedPosition[_account] = position(balances[_account]); // don't forget to reset the last position info } } _; } } // File: contracts/ElkFactoryHelper.sol // // Copyright (c) 2023 ElkLabs // License terms: https://github.com/elkfinance/faas/blob/main/LICENSE // // Authors: // - Seth <[email protected]> // - Baal <[email protected]> // - Elijah <[email protected]> // - Snake <[email protected]> pragma solidity >=0.8.0; /** * @title contains a helper function that creates new FarmingRewards contracts in the ElkFarmFactory * @notice this is a separate contract so that the FarmFactory contract is not too large */ library ElkFactoryHelper { /** * @notice creates a new FarmingRewards contract and transfers ownership to the provided farm manager * @param _abi the abi of the FarmingRewards contract * @param _salt the salt used to create the contract * @param _farmManager the address of the farm manager */ function createFarmContract( bytes memory _abi, bytes32 _salt, address _farmManager ) external returns (address addr) { bytes memory bytecode = abi.encodePacked( type(FarmingRewards).creationCode, _abi ); assembly { addr := create2(0, add(bytecode, 0x20), mload(bytecode), _salt) if iszero(extcodesize(addr)) { revert(0, 0) } } FarmingRewards(addr).transferOwnership(_farmManager); } }
Contract Creation Code
61585861003a600b82828239805160001a60731461002d57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe7300000000000000000000000000000000000000003014608060405260043610620000375760003560e01c8063c82e8b95146200003c575b600080fd5b8180156200004957600080fd5b50620000616200005b366004620001e0565b6200008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b600080604051806020016200009f9062000179565b601f1982820381018352601f909101166040819052620000c591908790602001620002e9565b6040516020818303038152906040529050838151602083016000f59150813b620000ee57600080fd5b6040517ff2fde38b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff848116600483015283169063f2fde38b90602401600060405180830381600087803b1580156200015857600080fd5b505af11580156200016d573d6000803e3d6000fd5b50505050509392505050565b615518806200030b83390190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b803573ffffffffffffffffffffffffffffffffffffffff81168114620001db57600080fd5b919050565b600080600060608486031215620001f657600080fd5b833567ffffffffffffffff808211156200020f57600080fd5b818601915086601f8301126200022457600080fd5b81358181111562000239576200023962000187565b604051601f8201601f19908116603f0116810190838211818310171562000264576200026462000187565b816040528281528960208487010111156200027e57600080fd5b82602086016020830137600060208483010152809750505050505060208401359150620002ae60408501620001b6565b90509250925092565b6000815160005b81811015620002da5760208185018101518683015201620002be565b50600093019283525090919050565b600062000302620002fb8386620002b7565b84620002b7565b94935050505056fe60e06040523480156200001157600080fd5b506040516200551838038062005518833981016040819052620000349162000a45565b600160005588858585858585838383836200004f336200043b565b6001600160a01b038116620000905760405162461bcd60e51b8152602060048201526002602482015261453160f01b60448201526064015b60405180910390fd5b6001600160a01b0316608052620000a98383836200048d565b505050506000855111620000e55760405162461bcd60e51b8152602060048201526002602482015261453960f01b604482015260640162000087565b60005b85518110156200013857600086828151811062000109576200010962000b4a565b6020026020010151905062000124816200068c60201b60201c565b50620001308162000b76565b9050620000e8565b505050600c919091555050506001600160a01b03808b1660a05289811660c052881615620002e857876001600160a01b031660c0516001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015620001ab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001d1919062000b92565b6001600160a01b031614806200025e5750876001600160a01b031660c0516001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200022d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000253919062000b92565b6001600160a01b0316145b620002925760405162461bcd60e51b815260206004820152600360248201526245313960e81b604482015260640162000087565b620151808663ffffffff1610158015620002b45750600c548663ffffffff1611155b620002e85760405162461bcd60e51b815260206004820152600360248201526245323160e81b604482015260640162000087565b60a0516001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000329573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200034f919062000b92565b6001600160a01b031660c0516001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000399573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620003bf919062000b92565b6001600160a01b031614620003fd5760405162461bcd60e51b815260206004820152600360248201526204532360ec1b604482015260640162000087565b5050601280546001600160a01b0319166001600160a01b039790971696909617909555505060139190915563ffffffff166014555062000c6b915050565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b81518151148015620004a15750600a815111155b8015620004b457506107d08361ffff1611155b620004e75760405162461bcd60e51b8152602060048201526002602482015261453560f01b604482015260640162000087565b600080620004f96107d0600162000bb7565b905060005b835181101562000612578263ffffffff1684828151811062000524576200052462000b4a565b602002602001015163ffffffff1611620005665760405162461bcd60e51b8152602060048201526002602482015261453760f01b604482015260640162000087565b818582815181106200057c576200057c62000b4a565b602002602001015161ffff1610620005bc5760405162461bcd60e51b815260206004820152600260248201526108a760f31b604482015260640162000087565b838181518110620005d157620005d162000b4a565b60200260200101519250848181518110620005f057620005f062000b4a565b602002602001015161ffff169150806200060a9062000b76565b9050620004fe565b508251620006289060049060208601906200078c565b5083516200063e906005906020870190620007e4565b5061ffff85166006556040517fab4c36b25b04e6f8ac9915203aba1048c17841782324a583e98128b8c1c964f3906200067d9087908790879062000bd3565b60405180910390a15050505050565b600954600f1015620006c75760405162461bcd60e51b815260206004820152600360248201526245313560e81b604482015260640162000087565b6001600160a01b038116620007045760405162461bcd60e51b8152602060048201526002602482015261453160f01b604482015260640162000087565b6001600160a01b0381166000908152600a602052604090205460ff1662000789576009805460018082019092557f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0180546001600160a01b0319166001600160a01b0384169081179091556000908152600a60205260409020805460ff191690911790555b50565b828054828255906000526020600020908101928215620007d2579160200282015b82811115620007d2578251829063ffffffff16905591602001919060010190620007ad565b50620007e092915062000828565b5090565b828054828255906000526020600020908101928215620007d2579160200282015b82811115620007d2578251829061ffff1690559160200191906001019062000805565b5b80821115620007e0576000815560010162000829565b80516001600160a01b03811681146200085757600080fd5b919050565b805163ffffffff811681146200085757600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715620008b257620008b262000871565b604052919050565b60006001600160401b03821115620008d657620008d662000871565b5060051b60200190565b600082601f830112620008f257600080fd5b815160206200090b6200090583620008ba565b62000887565b82815260059290921b840181019181810190868411156200092b57600080fd5b8286015b84811015620009515762000943816200083f565b83529183019183016200092f565b509695505050505050565b805161ffff811681146200085757600080fd5b600082601f8301126200098157600080fd5b81516020620009946200090583620008ba565b82815260059290921b84018101918181019086841115620009b457600080fd5b8286015b848110156200095157620009cc816200095c565b8352918301918301620009b8565b600082601f830112620009ec57600080fd5b81516020620009ff6200090583620008ba565b82815260059290921b8401810191818101908684111562000a1f57600080fd5b8286015b84811015620009515762000a37816200085c565b835291830191830162000a23565b6000806000806000806000806000806101408b8d03121562000a6657600080fd5b62000a718b6200083f565b995062000a8160208c016200083f565b985062000a9160408c016200083f565b975060608b0151965062000aa860808c016200085c565b60a08c01519096506001600160401b038082111562000ac657600080fd5b62000ad48e838f01620008e0565b965060c08d0151955062000aeb60e08e016200095c565b94506101008d015191508082111562000b0357600080fd5b62000b118e838f016200096f565b93506101208d015191508082111562000b2957600080fd5b5062000b388d828e01620009da565b9150509295989b9194979a5092959850565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006001820162000b8b5762000b8b62000b60565b5060010190565b60006020828403121562000ba557600080fd5b62000bb0826200083f565b9392505050565b8082018082111562000bcd5762000bcd62000b60565b92915050565b60006060820161ffff80871684526020606081860152828751808552608087019150828901945060005b8181101562000c1d57855185168352948301949183019160010162000bfd565b5050858103604087015286518082529082019350915080860160005b8381101562000c5d57815163ffffffff168552938201939082019060010162000c39565b509298975050505050505050565b60805160a05160c05161476c62000dac60003960008181610520015281816113800152818161141c0152818161176d0152818161190001528181611d2201528181611eb5015281816126a3015281816127cf015281816128f50152818161297f01528181612f3c015281816130cf0152818161353301526136c60152600081816106330152818161173e015281816117ef015281816118d10152818161198201528181611cf301528181611da401528181611e8601528181611f3701528181612674015281816127a001528181612ab801528181612ae701528181612f0d01528181612fbe015281816130a00152818161315101528181613504015281816135b50152818161369701526137480152600081816105c101528181610a1b01528181610cca015281816115b1015281816116ad0152613c18015261476c6000f3fe608060405234801561001057600080fd5b506004361061036d5760003560e01c80637aaeaf7f116101d3578063ab87982711610104578063ebe2b12b116100a2578063f2d176391161007c578063f2d1763914610831578063f2fde38b14610844578063f9cb1d0414610857578063f9ea07781461086057600080fd5b8063ebe2b12b146107a5578063ef2849b3146107ae578063f12297771461081e57600080fd5b8063ca423031116100de578063ca4230311461074c578063e13d87221461075f578063e70b9e2714610772578063e9fad8ee1461079d57600080fd5b8063ab87982714610727578063ad3bc54614610730578063c8f33c911461074357600080fd5b80638da5cb5b116101715780639ce43f901161014b5780639ce43f90146106a65780639e3582c8146106c6578063a694fc3a146106d9578063a7309d7d146106ec57600080fd5b80638da5cb5b146106835780639003adfe1461069457806399d531e11461069d57600080fd5b80637dc0d1d0116101ad5780637dc0d1d01461062e57806380faa57d146106555780638194c1781461065d57806387e7ed3a1461067057600080fd5b80637aaeaf7f146105ff5780637bb7bed1146106125780637beb3d9f1461062557600080fd5b8063415be3b5116102ad5780636b0916951161024b578063715018a611610225578063715018a6146105b457806372f702f3146105bc578063757767d7146105e357806379ee54f7146105ec57600080fd5b80636b091695146105635780636da9c58e146105765780637035ab981461058957600080fd5b8063502cd30f11610287578063502cd30f146104e857806354feec3e146105085780635fcbd2851461051b57806367c0d00f1461055a57600080fd5b8063415be3b5146104a7578063423c485a146104cd578063486e63b1146104e057600080fd5b8063211dc32d1161031a5780632e9f0602116102f45780632e9f06021461044b578063330244301461045e578063386a95251461047e5780633d3b26031461048757600080fd5b8063211dc32d1461040557806327e235e3146104185780632e1a7d4d1461043857600080fd5b806318160ddd1161034b57806318160ddd146103b65780631c03e6cc146103bf5780631db7efd8146103d257600080fd5b806301f59d161461037257806304a79e481461038e5780631171bda9146103a1575b600080fd5b61037b6107d081565b6040519081526020015b60405180910390f35b61037b61039c3660046142c3565b610873565b6103b46103af3660046142e0565b610a09565b005b61037b60025481565b6103b46103cd3660046142c3565b610b1c565b6103f56103e03660046142c3565b600a6020526000908152604090205460ff1681565b6040519015158152602001610385565b61037b610413366004614321565b610b67565b61037b6104263660046142c3565b60036020526000908152604090205481565b6103b461044636600461435a565b610c01565b6103b4610459366004614419565b610d32565b61037b61046c3660046142c3565b60186020526000908152604090205481565b61037b600c5481565b61037b6104953660046142c3565b600e6020526000908152604090205481565b6104ba6104b53660046142c3565b610d4a565b60405160009190910b8152602001610385565b61037b6104db36600461435a565b610dd0565b61037b610dfd565b61037b6104f63660046142c3565b60176020526000908152604090205481565b61037b61051636600461435a565b610e63565b6105427f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610385565b61037b60135481565b6103b4610571366004614321565b610e84565b6103b46105843660046142c3565b610f7a565b61037b610597366004614321565b601060209081526000928352604080842090915290825290205481565b6103b461109f565b6105427f000000000000000000000000000000000000000000000000000000000000000081565b61037b60145481565b6103b46105fa3660046142c3565b6110b3565b61037b61060d36600461445e565b6111ee565b61054261062036600461435a565b6112a4565b61037b61271081565b6105427f000000000000000000000000000000000000000000000000000000000000000081565b61037b6112ce565b6103b461066b36600461449c565b6112e5565b6103b461067e3660046142c3565b611558565b6001546001600160a01b0316610542565b61037b60075481565b61037b60155481565b61037b6106b43660046142c3565b600f6020526000908152604090205481565b61037b6106d436600461435a565b6115e3565b6103b46106e736600461435a565b6115f3565b6107126106fa3660046142c3565b60086020526000908152604090205463ffffffff1681565b60405163ffffffff9091168152602001610385565b61037b60065481565b6103b461073e3660046144de565b611707565b61037b600d5481565b6103b461075a3660046142c3565b611cbd565b601254610542906001600160a01b031681565b61037b610780366004614321565b601160209081526000928352604080842090915290825290205481565b6103b4612223565b61037b600b5481565b6107f26107bc3660046142c3565b6019602052600090815260409020546001600160701b0380821691600160701b810490911690600160e01b900463ffffffff1683565b604080516001600160701b03948516815293909216602084015263ffffffff1690820152606001610385565b61037b61082c3660046142c3565b612245565b6103b461083f366004614321565b6122e7565b6103b46108523660046142c3565b612469565b61037b60165481565b6103b461086e3660046142c3565b6124f6565b6012546000906001600160a01b031661088e57506000919050565b6001600160a01b0382166000908152601960209081526040808320815160608101835290546001600160701b038082168352600160701b82041693820193909352600160e01b90920463ffffffff1690820152906108eb82612670565b905080600003610913575050506001600160a01b031660009081526018602052604090205490565b6001600160a01b03841660009081526003602052604081205461093e90610939906128d1565b612670565b6001600160a01b038616600090815260036020908152604080832054601790925282205492935091670de0b6b3a764000090610978610dfd565b6109829190614542565b61098c9084614555565b610996919061456c565b905060006109a985858860400151612a7d565b6001600160a01b038916600090815260186020526040902054909150856109d08684614555565b6109da919061456c565b8383116109e757826109e9565b835b6109f39190614542565b6109fd919061458e565b98975050505050505050565b610a11612c21565b610a19612c7a565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b031603610a9f5760405162461bcd60e51b815260206004820152600260248201527f453400000000000000000000000000000000000000000000000000000000000060448201526064015b60405180910390fd5b610aaa838383612cd4565b82610abf6001600160a01b0382168484612d23565b826001600160a01b0316846001600160a01b03167ffff3b3844276f57024e0b42afec1a37f75db36511e43819a4f2a63ab7862b64884604051610b0491815260200190565b60405180910390a350610b176001600055565b505050565b610b24612c7a565b600b544211610b5b5760405162461bcd60e51b815260206004820152600360248201526245313760e81b6044820152606401610a96565b610b6481612d9f565b50565b6001600160a01b038083166000818152601160209081526040808320948616808452948252808320549383526010825280832094835293905291822054670de0b6b3a764000090610bb786612245565b610bc19190614542565b6001600160a01b038516600090815260036020526040902054610be49190614555565b610bee919061456c565b610bf8919061458e565b90505b92915050565b610c09612c21565b80610c143382612edc565b9150600082118015610c355750336000908152600360205260409020548211155b8015610c505750336000908152600360205260409020548111155b610c815760405162461bcd60e51b8152602060048201526002602482015261453360f01b6044820152606401610a96565b8060026000828254610c939190614542565b90915550503360009081526003602052604081208054839290610cb7908490614542565b90915550610cf190506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163384612d23565b60405182815233907f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5906020015b60405180910390a250610b646001600055565b610d3a612c7a565b610d4682600083611707565b5050565b6001600160a01b0381166000908152600a602052604081205460ff1615610dc75760005b600954811015610dc557826001600160a01b031660098281548110610d9557610d956145a1565b6000918252602090912001546001600160a01b031603610db55792915050565b610dbe816145b7565b9050610d6e565b505b50600019919050565b60008060065411610de2576000610bfb565b61271060065483610df39190614555565b610bfb919061456c565b6000600254600014610e5c57600254601554600d54610e1a6112ce565b610e249190614542565b610e2e9190614555565b610e4090670de0b6b3a7640000614555565b610e4a919061456c565b601654610e57919061458e565b905090565b5060165490565b60048181548110610e7357600080fd5b600091825260209091200154905081565b610e8c612c21565b8060005b600954811015610f5957600060098281548110610eaf57610eaf6145a1565b6000918252602090912001546001600160a01b03169050610ecf81612245565b6001600160a01b038083166000908152600f6020526040902091909155831615610f4857610efd8184610b67565b6001600160a01b03808316600081815260116020908152604080832094891680845294825280832095909555918152600f825283812054601083528482209382529290915291909120555b50610f52816145b7565b9050610e90565b50610f626112ce565b600d55610f6f8383613305565b50610d466001600055565b610f82612c21565b610f8a612c7a565b600b54421115610fc25760405162461bcd60e51b815260206004820152600360248201526208a62760eb1b6044820152606401610a96565b600042600b541115610fdf5742600b54610fdc9190614542565b90505b42600b5560005b60095481101561106a57600060098281548110611005576110056145a1565b60009182526020808320909101546001600160a01b0316808352600e909152604082205490925082919061103a908690614555565b90508015611056576110566001600160a01b0384168783612d23565b50505080611063906145b7565b9050610fe6565b506040517f9bad5e1e43bc35e89725967a54f4bc384078248a1ea5c315be3b260a68cbb17a90600090a150610b646001600055565b6110a7612c7a565b6110b16000613474565b565b6110bb612c21565b8060005b600954811015611188576000600982815481106110de576110de6145a1565b6000918252602090912001546001600160a01b031690506110fe81612245565b6001600160a01b038083166000908152600f60205260409020919091558316156111775761112c8184610b67565b6001600160a01b03808316600081815260116020908152604080832094891680845294825280832095909555918152600f825283812054601083528482209382529290915291909120555b50611181816145b7565b90506110bf565b506111916112ce565b600d5560005b6009548110156111e2576111d2600982815481106111b7576111b76145a1565b6000918252602090912001546001600160a01b031684613305565b6111db816145b7565b9050611197565b5050610b646001600055565b6001600160a01b03821660009081526008602052604081205481906112199063ffffffff1642614542565b90506000805b60045481101561129b576004818154811061123c5761123c6145a1565b906000526020600020015483101561128b5761271060058281548110611264576112646145a1565b90600052602060002001548661127a9190614555565b611284919061456c565b915061129b565b611294816145b7565b905061121f565b50949350505050565b600981815481106112b457600080fd5b6000918252602090912001546001600160a01b0316905081565b6000600b5442106112e05750600b5490565b504290565b6112ed612c7a565b600b5442116113245760405162461bcd60e51b815260206004820152600360248201526245313760e81b6044820152606401610a96565b601654156113745760405162461bcd60e51b815260206004820152600360248201527f45323400000000000000000000000000000000000000000000000000000000006044820152606401610a96565b826001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156113dc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061140091906145d0565b6001600160a01b031614806114a75750826001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611478573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061149c91906145d0565b6001600160a01b0316145b80156114bc5750620151808163ffffffff1610155b80156114d05750600c548163ffffffff1611155b61151c5760405162461bcd60e51b815260206004820152600360248201527f45313900000000000000000000000000000000000000000000000000000000006044820152606401610a96565b6012805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03949094169390931790925560135563ffffffff16601455565b611560612c7a565b611568612c21565b6007805460009091556040518181527f6857c770f3cb43e9c19050a37dd914ec876241c1f4b487d26a1d4f5d3054f49b9060200160405180910390a16115d86001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168383612d23565b50610b646001600055565b60058181548110610e7357600080fd5b6115fb612c21565b8061160633826134d3565b91506000821180156116185750600081115b6116645760405162461bcd60e51b815260206004820152600260248201527f45320000000000000000000000000000000000000000000000000000000000006044820152606401610a96565b8160026000828254611676919061458e565b9091555050336000908152600360205260408120805484929061169a90849061458e565b909155506116d590506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163330846138f4565b60405182815233907f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d90602001610d1f565b61170f612c7a565b6012546000906001600160a01b031615611b245761172b610dfd565b6016556117366112ce565b600d819055507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c640752d7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ed91906145d0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561184b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061186f91906145d0565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401600060405180830381600087803b1580156118b757600080fd5b505af11580156118cb573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c640752d7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa15801561195c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061198091906145d0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119de573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a0291906145d0565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401600060405180830381600087803b158015611a4a57600080fd5b505af1158015611a5e573d6000803e3d6000fd5b505050506001600160a01b03811615611b2457611a7a81610873565b6001600160a01b0382166000908152601860209081526040808320939093556016546017825283832055600390522054611ab3906128d1565b6001600160a01b0382166000908152601960209081526040918290208351815492850151949093015163ffffffff16600160e01b026001600160e01b036001600160701b03958616600160701b026001600160e01b0319909416959094169490941791909117919091169190911790555b611b2e8483613945565b600c546014541115611b825760405162461bcd60e51b815260206004820152600360248201527f45323200000000000000000000000000000000000000000000000000000000006044820152606401610a96565b600c54611b8f908461456c565b6015556012546001600160a01b031615801590611bac5750600083115b15611cb7576012546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015611bfa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c1e91906145ed565b601254909150600090611c39906001600160a01b0316610d4a565b905060008160000b12611c7157858160000b81518110611c5b57611c5b6145a1565b602002602001015182611c6e9190614542565b91505b600c54611c7e908361456c565b6015541115611cb45760405162461bcd60e51b8152602060048201526002602482015261453360f01b6044820152606401610a96565b50505b50505050565b611cc5612c21565b60125481906001600160a01b0316156120d957611ce0610dfd565b601655611ceb6112ce565b600d819055507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c640752d7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d7e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611da291906145d0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e2491906145d0565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401600060405180830381600087803b158015611e6c57600080fd5b505af1158015611e80573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c640752d7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f3591906145d0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fb791906145d0565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401600060405180830381600087803b158015611fff57600080fd5b505af1158015612013573d6000803e3d6000fd5b505050506001600160a01b038116156120d95761202f81610873565b6001600160a01b0382166000908152601860209081526040808320939093556016546017825283832055600390522054612068906128d1565b6001600160a01b0382166000908152601960209081526040918290208351815492850151949093015163ffffffff16600160e01b026001600160e01b036001600160701b03958616600160701b026001600160e01b0319909416959094169490941791909117919091169190911790555b6001546001600160a01b03163314806120fa5750336001600160a01b038316145b61212c5760405162461bcd60e51b8152602060048201526003602482015262114c4d60ea1b6044820152606401610a96565b6012546001600160a01b03166121845760405162461bcd60e51b815260206004820152600360248201527f45323300000000000000000000000000000000000000000000000000000000006044820152606401610a96565b6001600160a01b038216600090815260186020526040812054908190036121ab57506115d8565b6001600160a01b038084166000908152601860205260408120556012546121d491168483612d23565b826001600160a01b03167fef4696bdcf47e292773442e4169d670e1b2d0d3f5ceff2a5c1e236c10109ee808260405161220f91815260200190565b60405180910390a25050610b646001600055565b61222c33613d82565b336000908152600360205260409020546110b190610c01565b600060025460000361226d57506001600160a01b03166000908152600f602052604090205490565b6002546001600160a01b0383166000908152600e6020526040902054600d546122946112ce565b61229e9190614542565b6122a89190614555565b6122ba90670de0b6b3a7640000614555565b6122c4919061456c565b6001600160a01b0383166000908152600f6020526040902054610bfb919061458e565b6122ef612c7a565b600b5442116123265760405162461bcd60e51b815260206004820152600360248201526245313760e81b6044820152606401610a96565b600254156123765760405162461bcd60e51b815260206004820152600360248201527f45313200000000000000000000000000000000000000000000000000000000006044820152606401610a96565b6001600160a01b0382166000908152600a602052604090205460ff1615610d46576040516370a0823160e01b815230600482015282906000906001600160a01b038316906370a0823190602401602060405180830381865afa1580156123e0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061240491906145ed565b90508015612420576124206001600160a01b0383168483612d23565b826001600160a01b03167fcaa95c7b01f93ffe197f5e7316a1a2f387c5bfff8cb445095f2110ff5c1b29958260405161245b91815260200190565b60405180910390a250505050565b612471612c7a565b6001600160a01b0381166124ed5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610a96565b610b6481613474565b6124fe612c7a565b600b5442116125355760405162461bcd60e51b815260206004820152600360248201526245313760e81b6044820152606401610a96565b60025415801561254f57506012546001600160a01b031615155b61259b5760405162461bcd60e51b815260206004820152600760248201527f4531322f453233000000000000000000000000000000000000000000000000006044820152606401610a96565b6012546040516370a0823160e01b81523060048201526001600160a01b039091169060009082906370a0823190602401602060405180830381865afa1580156125e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061260c91906145ed565b90508015610b17576126286001600160a01b0383168483612d23565b826001600160a01b03167fcf018d466bd581a77eafe1429d5f079ea9a4a7363785b0561c51c9a8f2925c3c8260405161266391815260200190565b60405180910390a2505050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316631421f7307f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156126ff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061272391906145d0565b60208501516040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526001600160701b03166024820152604401602060405180830381865afa15801561277a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061279e91906145ed565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316631421f7307f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa15801561282b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061284f91906145d0565b855160405160e084901b6001600160e01b03191681526001600160a01b0390921660048301526001600160701b03166024820152604401602060405180830381865afa1580156128a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128c791906145ed565b610bfb919061458e565b604080516060810182526000808252602082018190529181019190915260008060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015612951573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612975919061461d565b92509250925060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129ff91906145ed565b9050604051806060016040528082866001600160701b031689612a229190614555565b612a2c919061456c565b6001600160701b0316815260200182856001600160701b031689612a509190614555565b612a5a919061456c565b6001600160701b031681526020018363ffffffff16815250945050505050919050565b600080612a9063ffffffff841642614542565b90506000848611612aa2576000612aac565b612aac8587614542565b905060008115612be5577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316638c86f1e47f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b6791906145d0565b60125460405160e084901b6001600160e01b03191681526001600160a01b0392831660048201526024810187905291166044820152606401602060405180830381865afa158015612bbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be091906145ed565b612be8565b60005b90506014548310612bfd579250612c1a915050565b601454612c0a8483614555565b612c14919061456c565b93505050505b9392505050565b600260005403612c735760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a96565b6002600055565b6001546001600160a01b031633146110b15760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610a96565b6012546001600160a01b0390811690841603612d185760405162461bcd60e51b815260206004820152600360248201526222989b60e91b6044820152606401610a96565b610b17838383613da5565b6040516001600160a01b038316602482015260448101829052610b179084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613df4565b600954600f1015612df25760405162461bcd60e51b815260206004820152600360248201527f45313500000000000000000000000000000000000000000000000000000000006044820152606401610a96565b6001600160a01b038116612e485760405162461bcd60e51b815260206004820152600260248201527f45310000000000000000000000000000000000000000000000000000000000006044820152606401610a96565b6001600160a01b0381166000908152600a602052604090205460ff16610b64576009805460018181019092557f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0180546001600160a01b03841673ffffffffffffffffffffffffffffffffffffffff1990911681179091556000908152600a60205260409020805460ff1916909117905550565b60125460009083906001600160a01b0316156132f357612efa610dfd565b601655612f056112ce565b600d819055507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c640752d7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fbc91906145d0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561301a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061303e91906145d0565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401600060405180830381600087803b15801561308657600080fd5b505af115801561309a573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c640752d7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa15801561312b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061314f91906145d0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156131ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131d191906145d0565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401600060405180830381600087803b15801561321957600080fd5b505af115801561322d573d6000803e3d6000fd5b505050506001600160a01b038116156132f35761324981610873565b6001600160a01b0382166000908152601860209081526040808320939093556016546017825283832055600390522054613282906128d1565b6001600160a01b0382166000908152601960209081526040918290208351815492850151949093015163ffffffff16600160e01b026001600160e01b036001600160701b03958616600160701b026001600160e01b0319909416959094169490941791909117919091169190911790555b6132fd8484613ed9565b949350505050565b6001546001600160a01b03163314806133265750336001600160a01b038216145b6133585760405162461bcd60e51b8152602060048201526003602482015262114c4d60ea1b6044820152606401610a96565b6001600160a01b0382166000908152600a602052604090205460ff166133c05760405162461bcd60e51b815260206004820152600360248201527f45313300000000000000000000000000000000000000000000000000000000006044820152606401610a96565b6001600160a01b038083166000908152601160209081526040808320938516835292905220548015610b17576001600160a01b038084166000818152601160209081526040808320948716835293905291822091909155613422908383612d23565b816001600160a01b0316836001600160a01b03167f540798df468d7b23d11f156fdb954cb19ad414d150722a7b6d55ba369dea792e8360405161346791815260200190565b60405180910390a3505050565b600180546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60125460009083906001600160a01b0316156138ea576134f1610dfd565b6016556134fc6112ce565b600d819055507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c640752d7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa15801561358f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135b391906145d0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa158015613611573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061363591906145d0565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401600060405180830381600087803b15801561367d57600080fd5b505af1158015613691573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c640752d7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015613722573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061374691906145d0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156137a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137c891906145d0565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401600060405180830381600087803b15801561381057600080fd5b505af1158015613824573d6000803e3d6000fd5b505050506001600160a01b038116156138ea5761384081610873565b6001600160a01b0382166000908152601860209081526040808320939093556016546017825283832055600390522054613879906128d1565b6001600160a01b0382166000908152601960209081526040918290208351815492850151949093015163ffffffff16600160e01b026001600160e01b036001600160701b03958616600160701b026001600160e01b0319909416959094169490941791909117919091169190911790555b6132fd8484613f58565b6040516001600160a01b0380851660248301528316604482015260648101829052611cb79085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401612d68565b61394d612c21565b613955612c7a565b600b54421161398c5760405162461bcd60e51b815260206004820152600360248201526245313760e81b6044820152606401610a96565b6000805b600954811015613a59576000600982815481106139af576139af6145a1565b6000918252602090912001546001600160a01b031690506139cf81612245565b6001600160a01b038083166000908152600f6020526040902091909155831615613a48576139fd8184610b67565b6001600160a01b03808316600081815260116020908152604080832094891680845294825280832095909555918152600f825283812054601083528482209382529290915291909120555b50613a52816145b7565b9050613990565b50613a626112ce565b600d5581613ab25760405162461bcd60e51b815260206004820152600360248201527f45313000000000000000000000000000000000000000000000000000000000006044820152606401610a96565b600954835114613b045760405162461bcd60e51b815260206004820152600360248201527f45313100000000000000000000000000000000000000000000000000000000006044820152606401610a96565b600c82905560005b600954811015613d2757600060098281548110613b2b57613b2b6145a1565b600091825260209091200154600c5486516001600160a01b0390921692508291879085908110613b5d57613b5d6145a1565b6020026020010151613b6f919061456c565b6001600160a01b0382166000908152600e60205260408120919091556009805485908110613b9f57613b9f6145a1565b6000918252602090912001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015613bf0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c1491906145ed565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614613cad57600c54613c5c908261456c565b6001600160a01b0383166000908152600e60205260409020541115613ca85760405162461bcd60e51b8152602060048201526002602482015261453360f01b6044820152606401610a96565b613d13565b600c54600254613cbd9083614542565b613cc7919061456c565b6001600160a01b0383166000908152600e60205260409020541115613d135760405162461bcd60e51b8152602060048201526002602482015261453360f01b6044820152606401610a96565b50505080613d20906145b7565b9050613b0c565b5042600d819055600c54613d3a9161458e565b600b556040517faab1f55dce0d0e628e283ce1061d0afccffcf61f9c14391c899b5952492ce82190613d6f9085908590614659565b60405180910390a150610d466001600055565b6012546001600160a01b031615613d9c57613d9c81611cbd565b610b6481614075565b6001600160a01b0383166000908152600a602052604090205460ff1615610b175760405162461bcd60e51b815260206004820152600360248201526222989b60e91b6044820152606401610a96565b6000613e49826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661407e9092919063ffffffff16565b805190915015610b175780806020019051810190613e6791906146a1565b610b175760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610a96565b600080613ee684846111ee565b90508015613f45578060076000828254613f00919061458e565b90915550506040518181526001600160a01b038516907fd0b34aaed5c558a8df736a5aaf9a49b539c4e86fb3ee5a1ac76e0bec23cbdd03906020015b60405180910390a25b6132fd84613f538386614542565b919050565b6000600b54421115613f925760405162461bcd60e51b815260206004820152600360248201526208a62760eb1b6044820152606401610a96565b8260005b60095481101561405f57600060098281548110613fb557613fb56145a1565b6000918252602090912001546001600160a01b03169050613fd581612245565b6001600160a01b038083166000908152600f602052604090209190915583161561404e576140038184610b67565b6001600160a01b03808316600081815260116020908152604080832094891680845294825280832095909555918152600f825283812054601083528482209382529290915291909120555b50614058816145b7565b9050613f96565b506140686112ce565b600d556132fd848461408d565b610b64816110b3565b60606132fd848460008561411e565b60008061409983610dd0565b6001600160a01b0385166000908152600860205260409020805463ffffffff19164263ffffffff1617905590508015613f455780600760008282546140de919061458e565b90915550506040518181526001600160a01b038516907f34f2a7363b1ef64b0b62a223c88cf3f54a68686acfcb9531d7deb46004f37c4690602001613f3c565b6060824710156141965760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610a96565b600080866001600160a01b031685876040516141b291906146e7565b60006040518083038185875af1925050503d80600081146141ef576040519150601f19603f3d011682016040523d82523d6000602084013e6141f4565b606091505b509150915061420587838387614210565b979650505050505050565b6060831561427f578251600003614278576001600160a01b0385163b6142785760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a96565b50816132fd565b6132fd83838151156142945781518083602001fd5b8060405162461bcd60e51b8152600401610a969190614703565b6001600160a01b0381168114610b6457600080fd5b6000602082840312156142d557600080fd5b8135612c1a816142ae565b6000806000606084860312156142f557600080fd5b8335614300816142ae565b92506020840135614310816142ae565b929592945050506040919091013590565b6000806040838503121561433457600080fd5b823561433f816142ae565b9150602083013561434f816142ae565b809150509250929050565b60006020828403121561436c57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b600082601f83011261439a57600080fd5b8135602067ffffffffffffffff808311156143b7576143b7614373565b8260051b604051601f19603f830116810181811084821117156143dc576143dc614373565b6040529384528581018301938381019250878511156143fa57600080fd5b83870191505b8482101561420557813583529183019190830190614400565b6000806040838503121561442c57600080fd5b823567ffffffffffffffff81111561444357600080fd5b61444f85828601614389565b95602094909401359450505050565b6000806040838503121561447157600080fd5b823561447c816142ae565b946020939093013593505050565b63ffffffff81168114610b6457600080fd5b6000806000606084860312156144b157600080fd5b83356144bc816142ae565b92506020840135915060408401356144d38161448a565b809150509250925092565b6000806000606084860312156144f357600080fd5b833567ffffffffffffffff81111561450a57600080fd5b61451686828701614389565b9660208601359650604090950135949350505050565b634e487b7160e01b600052601160045260246000fd5b81810381811115610bfb57610bfb61452c565b8082028115828204841417610bfb57610bfb61452c565b60008261458957634e487b7160e01b600052601260045260246000fd5b500490565b80820180821115610bfb57610bfb61452c565b634e487b7160e01b600052603260045260246000fd5b6000600182016145c9576145c961452c565b5060010190565b6000602082840312156145e257600080fd5b8151612c1a816142ae565b6000602082840312156145ff57600080fd5b5051919050565b80516001600160701b0381168114613f5357600080fd5b60008060006060848603121561463257600080fd5b61463b84614606565b925061464960208501614606565b915060408401516144d38161448a565b604080825283519082018190526000906020906060840190828701845b8281101561469257815184529284019290840190600101614676565b50505092019290925292915050565b6000602082840312156146b357600080fd5b81518015158114612c1a57600080fd5b60005b838110156146de5781810151838201526020016146c6565b50506000910152565b600082516146f98184602087016146c3565b9190910192915050565b60208152600082518060208401526147228160408501602087016146c3565b601f01601f1916919091016040019291505056fea264697066735822122081f8114000287dcb73524e2ac411aa335994df052164bfce6e0a1d00b35de2b364736f6c63430008130033a2646970667358221220ce65b3a2cae40b2887235ea3e59539fa65407f294e126c0868283267e199422664736f6c63430008130033
Deployed Bytecode
0x7340d4014b60dd73c7087d39b895aad2a6985781753014608060405260043610620000375760003560e01c8063c82e8b95146200003c575b600080fd5b8180156200004957600080fd5b50620000616200005b366004620001e0565b6200008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b600080604051806020016200009f9062000179565b601f1982820381018352601f909101166040819052620000c591908790602001620002e9565b6040516020818303038152906040529050838151602083016000f59150813b620000ee57600080fd5b6040517ff2fde38b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff848116600483015283169063f2fde38b90602401600060405180830381600087803b1580156200015857600080fd5b505af11580156200016d573d6000803e3d6000fd5b50505050509392505050565b615518806200030b83390190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b803573ffffffffffffffffffffffffffffffffffffffff81168114620001db57600080fd5b919050565b600080600060608486031215620001f657600080fd5b833567ffffffffffffffff808211156200020f57600080fd5b818601915086601f8301126200022457600080fd5b81358181111562000239576200023962000187565b604051601f8201601f19908116603f0116810190838211818310171562000264576200026462000187565b816040528281528960208487010111156200027e57600080fd5b82602086016020830137600060208483010152809750505050505060208401359150620002ae60408501620001b6565b90509250925092565b6000815160005b81811015620002da5760208185018101518683015201620002be565b50600093019283525090919050565b600062000302620002fb8386620002b7565b84620002b7565b94935050505056fe60e06040523480156200001157600080fd5b506040516200551838038062005518833981016040819052620000349162000a45565b600160005588858585858585838383836200004f336200043b565b6001600160a01b038116620000905760405162461bcd60e51b8152602060048201526002602482015261453160f01b60448201526064015b60405180910390fd5b6001600160a01b0316608052620000a98383836200048d565b505050506000855111620000e55760405162461bcd60e51b8152602060048201526002602482015261453960f01b604482015260640162000087565b60005b85518110156200013857600086828151811062000109576200010962000b4a565b6020026020010151905062000124816200068c60201b60201c565b50620001308162000b76565b9050620000e8565b505050600c919091555050506001600160a01b03808b1660a05289811660c052881615620002e857876001600160a01b031660c0516001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015620001ab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001d1919062000b92565b6001600160a01b031614806200025e5750876001600160a01b031660c0516001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200022d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000253919062000b92565b6001600160a01b0316145b620002925760405162461bcd60e51b815260206004820152600360248201526245313960e81b604482015260640162000087565b620151808663ffffffff1610158015620002b45750600c548663ffffffff1611155b620002e85760405162461bcd60e51b815260206004820152600360248201526245323160e81b604482015260640162000087565b60a0516001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000329573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200034f919062000b92565b6001600160a01b031660c0516001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000399573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620003bf919062000b92565b6001600160a01b031614620003fd5760405162461bcd60e51b815260206004820152600360248201526204532360ec1b604482015260640162000087565b5050601280546001600160a01b0319166001600160a01b039790971696909617909555505060139190915563ffffffff166014555062000c6b915050565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b81518151148015620004a15750600a815111155b8015620004b457506107d08361ffff1611155b620004e75760405162461bcd60e51b8152602060048201526002602482015261453560f01b604482015260640162000087565b600080620004f96107d0600162000bb7565b905060005b835181101562000612578263ffffffff1684828151811062000524576200052462000b4a565b602002602001015163ffffffff1611620005665760405162461bcd60e51b8152602060048201526002602482015261453760f01b604482015260640162000087565b818582815181106200057c576200057c62000b4a565b602002602001015161ffff1610620005bc5760405162461bcd60e51b815260206004820152600260248201526108a760f31b604482015260640162000087565b838181518110620005d157620005d162000b4a565b60200260200101519250848181518110620005f057620005f062000b4a565b602002602001015161ffff169150806200060a9062000b76565b9050620004fe565b508251620006289060049060208601906200078c565b5083516200063e906005906020870190620007e4565b5061ffff85166006556040517fab4c36b25b04e6f8ac9915203aba1048c17841782324a583e98128b8c1c964f3906200067d9087908790879062000bd3565b60405180910390a15050505050565b600954600f1015620006c75760405162461bcd60e51b815260206004820152600360248201526245313560e81b604482015260640162000087565b6001600160a01b038116620007045760405162461bcd60e51b8152602060048201526002602482015261453160f01b604482015260640162000087565b6001600160a01b0381166000908152600a602052604090205460ff1662000789576009805460018082019092557f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0180546001600160a01b0319166001600160a01b0384169081179091556000908152600a60205260409020805460ff191690911790555b50565b828054828255906000526020600020908101928215620007d2579160200282015b82811115620007d2578251829063ffffffff16905591602001919060010190620007ad565b50620007e092915062000828565b5090565b828054828255906000526020600020908101928215620007d2579160200282015b82811115620007d2578251829061ffff1690559160200191906001019062000805565b5b80821115620007e0576000815560010162000829565b80516001600160a01b03811681146200085757600080fd5b919050565b805163ffffffff811681146200085757600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715620008b257620008b262000871565b604052919050565b60006001600160401b03821115620008d657620008d662000871565b5060051b60200190565b600082601f830112620008f257600080fd5b815160206200090b6200090583620008ba565b62000887565b82815260059290921b840181019181810190868411156200092b57600080fd5b8286015b84811015620009515762000943816200083f565b83529183019183016200092f565b509695505050505050565b805161ffff811681146200085757600080fd5b600082601f8301126200098157600080fd5b81516020620009946200090583620008ba565b82815260059290921b84018101918181019086841115620009b457600080fd5b8286015b848110156200095157620009cc816200095c565b8352918301918301620009b8565b600082601f830112620009ec57600080fd5b81516020620009ff6200090583620008ba565b82815260059290921b8401810191818101908684111562000a1f57600080fd5b8286015b84811015620009515762000a37816200085c565b835291830191830162000a23565b6000806000806000806000806000806101408b8d03121562000a6657600080fd5b62000a718b6200083f565b995062000a8160208c016200083f565b985062000a9160408c016200083f565b975060608b0151965062000aa860808c016200085c565b60a08c01519096506001600160401b038082111562000ac657600080fd5b62000ad48e838f01620008e0565b965060c08d0151955062000aeb60e08e016200095c565b94506101008d015191508082111562000b0357600080fd5b62000b118e838f016200096f565b93506101208d015191508082111562000b2957600080fd5b5062000b388d828e01620009da565b9150509295989b9194979a5092959850565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006001820162000b8b5762000b8b62000b60565b5060010190565b60006020828403121562000ba557600080fd5b62000bb0826200083f565b9392505050565b8082018082111562000bcd5762000bcd62000b60565b92915050565b60006060820161ffff80871684526020606081860152828751808552608087019150828901945060005b8181101562000c1d57855185168352948301949183019160010162000bfd565b5050858103604087015286518082529082019350915080860160005b8381101562000c5d57815163ffffffff168552938201939082019060010162000c39565b509298975050505050505050565b60805160a05160c05161476c62000dac60003960008181610520015281816113800152818161141c0152818161176d0152818161190001528181611d2201528181611eb5015281816126a3015281816127cf015281816128f50152818161297f01528181612f3c015281816130cf0152818161353301526136c60152600081816106330152818161173e015281816117ef015281816118d10152818161198201528181611cf301528181611da401528181611e8601528181611f3701528181612674015281816127a001528181612ab801528181612ae701528181612f0d01528181612fbe015281816130a00152818161315101528181613504015281816135b50152818161369701526137480152600081816105c101528181610a1b01528181610cca015281816115b1015281816116ad0152613c18015261476c6000f3fe608060405234801561001057600080fd5b506004361061036d5760003560e01c80637aaeaf7f116101d3578063ab87982711610104578063ebe2b12b116100a2578063f2d176391161007c578063f2d1763914610831578063f2fde38b14610844578063f9cb1d0414610857578063f9ea07781461086057600080fd5b8063ebe2b12b146107a5578063ef2849b3146107ae578063f12297771461081e57600080fd5b8063ca423031116100de578063ca4230311461074c578063e13d87221461075f578063e70b9e2714610772578063e9fad8ee1461079d57600080fd5b8063ab87982714610727578063ad3bc54614610730578063c8f33c911461074357600080fd5b80638da5cb5b116101715780639ce43f901161014b5780639ce43f90146106a65780639e3582c8146106c6578063a694fc3a146106d9578063a7309d7d146106ec57600080fd5b80638da5cb5b146106835780639003adfe1461069457806399d531e11461069d57600080fd5b80637dc0d1d0116101ad5780637dc0d1d01461062e57806380faa57d146106555780638194c1781461065d57806387e7ed3a1461067057600080fd5b80637aaeaf7f146105ff5780637bb7bed1146106125780637beb3d9f1461062557600080fd5b8063415be3b5116102ad5780636b0916951161024b578063715018a611610225578063715018a6146105b457806372f702f3146105bc578063757767d7146105e357806379ee54f7146105ec57600080fd5b80636b091695146105635780636da9c58e146105765780637035ab981461058957600080fd5b8063502cd30f11610287578063502cd30f146104e857806354feec3e146105085780635fcbd2851461051b57806367c0d00f1461055a57600080fd5b8063415be3b5146104a7578063423c485a146104cd578063486e63b1146104e057600080fd5b8063211dc32d1161031a5780632e9f0602116102f45780632e9f06021461044b578063330244301461045e578063386a95251461047e5780633d3b26031461048757600080fd5b8063211dc32d1461040557806327e235e3146104185780632e1a7d4d1461043857600080fd5b806318160ddd1161034b57806318160ddd146103b65780631c03e6cc146103bf5780631db7efd8146103d257600080fd5b806301f59d161461037257806304a79e481461038e5780631171bda9146103a1575b600080fd5b61037b6107d081565b6040519081526020015b60405180910390f35b61037b61039c3660046142c3565b610873565b6103b46103af3660046142e0565b610a09565b005b61037b60025481565b6103b46103cd3660046142c3565b610b1c565b6103f56103e03660046142c3565b600a6020526000908152604090205460ff1681565b6040519015158152602001610385565b61037b610413366004614321565b610b67565b61037b6104263660046142c3565b60036020526000908152604090205481565b6103b461044636600461435a565b610c01565b6103b4610459366004614419565b610d32565b61037b61046c3660046142c3565b60186020526000908152604090205481565b61037b600c5481565b61037b6104953660046142c3565b600e6020526000908152604090205481565b6104ba6104b53660046142c3565b610d4a565b60405160009190910b8152602001610385565b61037b6104db36600461435a565b610dd0565b61037b610dfd565b61037b6104f63660046142c3565b60176020526000908152604090205481565b61037b61051636600461435a565b610e63565b6105427f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610385565b61037b60135481565b6103b4610571366004614321565b610e84565b6103b46105843660046142c3565b610f7a565b61037b610597366004614321565b601060209081526000928352604080842090915290825290205481565b6103b461109f565b6105427f000000000000000000000000000000000000000000000000000000000000000081565b61037b60145481565b6103b46105fa3660046142c3565b6110b3565b61037b61060d36600461445e565b6111ee565b61054261062036600461435a565b6112a4565b61037b61271081565b6105427f000000000000000000000000000000000000000000000000000000000000000081565b61037b6112ce565b6103b461066b36600461449c565b6112e5565b6103b461067e3660046142c3565b611558565b6001546001600160a01b0316610542565b61037b60075481565b61037b60155481565b61037b6106b43660046142c3565b600f6020526000908152604090205481565b61037b6106d436600461435a565b6115e3565b6103b46106e736600461435a565b6115f3565b6107126106fa3660046142c3565b60086020526000908152604090205463ffffffff1681565b60405163ffffffff9091168152602001610385565b61037b60065481565b6103b461073e3660046144de565b611707565b61037b600d5481565b6103b461075a3660046142c3565b611cbd565b601254610542906001600160a01b031681565b61037b610780366004614321565b601160209081526000928352604080842090915290825290205481565b6103b4612223565b61037b600b5481565b6107f26107bc3660046142c3565b6019602052600090815260409020546001600160701b0380821691600160701b810490911690600160e01b900463ffffffff1683565b604080516001600160701b03948516815293909216602084015263ffffffff1690820152606001610385565b61037b61082c3660046142c3565b612245565b6103b461083f366004614321565b6122e7565b6103b46108523660046142c3565b612469565b61037b60165481565b6103b461086e3660046142c3565b6124f6565b6012546000906001600160a01b031661088e57506000919050565b6001600160a01b0382166000908152601960209081526040808320815160608101835290546001600160701b038082168352600160701b82041693820193909352600160e01b90920463ffffffff1690820152906108eb82612670565b905080600003610913575050506001600160a01b031660009081526018602052604090205490565b6001600160a01b03841660009081526003602052604081205461093e90610939906128d1565b612670565b6001600160a01b038616600090815260036020908152604080832054601790925282205492935091670de0b6b3a764000090610978610dfd565b6109829190614542565b61098c9084614555565b610996919061456c565b905060006109a985858860400151612a7d565b6001600160a01b038916600090815260186020526040902054909150856109d08684614555565b6109da919061456c565b8383116109e757826109e9565b835b6109f39190614542565b6109fd919061458e565b98975050505050505050565b610a11612c21565b610a19612c7a565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b031603610a9f5760405162461bcd60e51b815260206004820152600260248201527f453400000000000000000000000000000000000000000000000000000000000060448201526064015b60405180910390fd5b610aaa838383612cd4565b82610abf6001600160a01b0382168484612d23565b826001600160a01b0316846001600160a01b03167ffff3b3844276f57024e0b42afec1a37f75db36511e43819a4f2a63ab7862b64884604051610b0491815260200190565b60405180910390a350610b176001600055565b505050565b610b24612c7a565b600b544211610b5b5760405162461bcd60e51b815260206004820152600360248201526245313760e81b6044820152606401610a96565b610b6481612d9f565b50565b6001600160a01b038083166000818152601160209081526040808320948616808452948252808320549383526010825280832094835293905291822054670de0b6b3a764000090610bb786612245565b610bc19190614542565b6001600160a01b038516600090815260036020526040902054610be49190614555565b610bee919061456c565b610bf8919061458e565b90505b92915050565b610c09612c21565b80610c143382612edc565b9150600082118015610c355750336000908152600360205260409020548211155b8015610c505750336000908152600360205260409020548111155b610c815760405162461bcd60e51b8152602060048201526002602482015261453360f01b6044820152606401610a96565b8060026000828254610c939190614542565b90915550503360009081526003602052604081208054839290610cb7908490614542565b90915550610cf190506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163384612d23565b60405182815233907f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5906020015b60405180910390a250610b646001600055565b610d3a612c7a565b610d4682600083611707565b5050565b6001600160a01b0381166000908152600a602052604081205460ff1615610dc75760005b600954811015610dc557826001600160a01b031660098281548110610d9557610d956145a1565b6000918252602090912001546001600160a01b031603610db55792915050565b610dbe816145b7565b9050610d6e565b505b50600019919050565b60008060065411610de2576000610bfb565b61271060065483610df39190614555565b610bfb919061456c565b6000600254600014610e5c57600254601554600d54610e1a6112ce565b610e249190614542565b610e2e9190614555565b610e4090670de0b6b3a7640000614555565b610e4a919061456c565b601654610e57919061458e565b905090565b5060165490565b60048181548110610e7357600080fd5b600091825260209091200154905081565b610e8c612c21565b8060005b600954811015610f5957600060098281548110610eaf57610eaf6145a1565b6000918252602090912001546001600160a01b03169050610ecf81612245565b6001600160a01b038083166000908152600f6020526040902091909155831615610f4857610efd8184610b67565b6001600160a01b03808316600081815260116020908152604080832094891680845294825280832095909555918152600f825283812054601083528482209382529290915291909120555b50610f52816145b7565b9050610e90565b50610f626112ce565b600d55610f6f8383613305565b50610d466001600055565b610f82612c21565b610f8a612c7a565b600b54421115610fc25760405162461bcd60e51b815260206004820152600360248201526208a62760eb1b6044820152606401610a96565b600042600b541115610fdf5742600b54610fdc9190614542565b90505b42600b5560005b60095481101561106a57600060098281548110611005576110056145a1565b60009182526020808320909101546001600160a01b0316808352600e909152604082205490925082919061103a908690614555565b90508015611056576110566001600160a01b0384168783612d23565b50505080611063906145b7565b9050610fe6565b506040517f9bad5e1e43bc35e89725967a54f4bc384078248a1ea5c315be3b260a68cbb17a90600090a150610b646001600055565b6110a7612c7a565b6110b16000613474565b565b6110bb612c21565b8060005b600954811015611188576000600982815481106110de576110de6145a1565b6000918252602090912001546001600160a01b031690506110fe81612245565b6001600160a01b038083166000908152600f60205260409020919091558316156111775761112c8184610b67565b6001600160a01b03808316600081815260116020908152604080832094891680845294825280832095909555918152600f825283812054601083528482209382529290915291909120555b50611181816145b7565b90506110bf565b506111916112ce565b600d5560005b6009548110156111e2576111d2600982815481106111b7576111b76145a1565b6000918252602090912001546001600160a01b031684613305565b6111db816145b7565b9050611197565b5050610b646001600055565b6001600160a01b03821660009081526008602052604081205481906112199063ffffffff1642614542565b90506000805b60045481101561129b576004818154811061123c5761123c6145a1565b906000526020600020015483101561128b5761271060058281548110611264576112646145a1565b90600052602060002001548661127a9190614555565b611284919061456c565b915061129b565b611294816145b7565b905061121f565b50949350505050565b600981815481106112b457600080fd5b6000918252602090912001546001600160a01b0316905081565b6000600b5442106112e05750600b5490565b504290565b6112ed612c7a565b600b5442116113245760405162461bcd60e51b815260206004820152600360248201526245313760e81b6044820152606401610a96565b601654156113745760405162461bcd60e51b815260206004820152600360248201527f45323400000000000000000000000000000000000000000000000000000000006044820152606401610a96565b826001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156113dc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061140091906145d0565b6001600160a01b031614806114a75750826001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611478573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061149c91906145d0565b6001600160a01b0316145b80156114bc5750620151808163ffffffff1610155b80156114d05750600c548163ffffffff1611155b61151c5760405162461bcd60e51b815260206004820152600360248201527f45313900000000000000000000000000000000000000000000000000000000006044820152606401610a96565b6012805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03949094169390931790925560135563ffffffff16601455565b611560612c7a565b611568612c21565b6007805460009091556040518181527f6857c770f3cb43e9c19050a37dd914ec876241c1f4b487d26a1d4f5d3054f49b9060200160405180910390a16115d86001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168383612d23565b50610b646001600055565b60058181548110610e7357600080fd5b6115fb612c21565b8061160633826134d3565b91506000821180156116185750600081115b6116645760405162461bcd60e51b815260206004820152600260248201527f45320000000000000000000000000000000000000000000000000000000000006044820152606401610a96565b8160026000828254611676919061458e565b9091555050336000908152600360205260408120805484929061169a90849061458e565b909155506116d590506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163330846138f4565b60405182815233907f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d90602001610d1f565b61170f612c7a565b6012546000906001600160a01b031615611b245761172b610dfd565b6016556117366112ce565b600d819055507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c640752d7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ed91906145d0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561184b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061186f91906145d0565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401600060405180830381600087803b1580156118b757600080fd5b505af11580156118cb573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c640752d7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa15801561195c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061198091906145d0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119de573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a0291906145d0565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401600060405180830381600087803b158015611a4a57600080fd5b505af1158015611a5e573d6000803e3d6000fd5b505050506001600160a01b03811615611b2457611a7a81610873565b6001600160a01b0382166000908152601860209081526040808320939093556016546017825283832055600390522054611ab3906128d1565b6001600160a01b0382166000908152601960209081526040918290208351815492850151949093015163ffffffff16600160e01b026001600160e01b036001600160701b03958616600160701b026001600160e01b0319909416959094169490941791909117919091169190911790555b611b2e8483613945565b600c546014541115611b825760405162461bcd60e51b815260206004820152600360248201527f45323200000000000000000000000000000000000000000000000000000000006044820152606401610a96565b600c54611b8f908461456c565b6015556012546001600160a01b031615801590611bac5750600083115b15611cb7576012546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015611bfa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c1e91906145ed565b601254909150600090611c39906001600160a01b0316610d4a565b905060008160000b12611c7157858160000b81518110611c5b57611c5b6145a1565b602002602001015182611c6e9190614542565b91505b600c54611c7e908361456c565b6015541115611cb45760405162461bcd60e51b8152602060048201526002602482015261453360f01b6044820152606401610a96565b50505b50505050565b611cc5612c21565b60125481906001600160a01b0316156120d957611ce0610dfd565b601655611ceb6112ce565b600d819055507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c640752d7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d7e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611da291906145d0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e2491906145d0565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401600060405180830381600087803b158015611e6c57600080fd5b505af1158015611e80573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c640752d7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f3591906145d0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fb791906145d0565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401600060405180830381600087803b158015611fff57600080fd5b505af1158015612013573d6000803e3d6000fd5b505050506001600160a01b038116156120d95761202f81610873565b6001600160a01b0382166000908152601860209081526040808320939093556016546017825283832055600390522054612068906128d1565b6001600160a01b0382166000908152601960209081526040918290208351815492850151949093015163ffffffff16600160e01b026001600160e01b036001600160701b03958616600160701b026001600160e01b0319909416959094169490941791909117919091169190911790555b6001546001600160a01b03163314806120fa5750336001600160a01b038316145b61212c5760405162461bcd60e51b8152602060048201526003602482015262114c4d60ea1b6044820152606401610a96565b6012546001600160a01b03166121845760405162461bcd60e51b815260206004820152600360248201527f45323300000000000000000000000000000000000000000000000000000000006044820152606401610a96565b6001600160a01b038216600090815260186020526040812054908190036121ab57506115d8565b6001600160a01b038084166000908152601860205260408120556012546121d491168483612d23565b826001600160a01b03167fef4696bdcf47e292773442e4169d670e1b2d0d3f5ceff2a5c1e236c10109ee808260405161220f91815260200190565b60405180910390a25050610b646001600055565b61222c33613d82565b336000908152600360205260409020546110b190610c01565b600060025460000361226d57506001600160a01b03166000908152600f602052604090205490565b6002546001600160a01b0383166000908152600e6020526040902054600d546122946112ce565b61229e9190614542565b6122a89190614555565b6122ba90670de0b6b3a7640000614555565b6122c4919061456c565b6001600160a01b0383166000908152600f6020526040902054610bfb919061458e565b6122ef612c7a565b600b5442116123265760405162461bcd60e51b815260206004820152600360248201526245313760e81b6044820152606401610a96565b600254156123765760405162461bcd60e51b815260206004820152600360248201527f45313200000000000000000000000000000000000000000000000000000000006044820152606401610a96565b6001600160a01b0382166000908152600a602052604090205460ff1615610d46576040516370a0823160e01b815230600482015282906000906001600160a01b038316906370a0823190602401602060405180830381865afa1580156123e0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061240491906145ed565b90508015612420576124206001600160a01b0383168483612d23565b826001600160a01b03167fcaa95c7b01f93ffe197f5e7316a1a2f387c5bfff8cb445095f2110ff5c1b29958260405161245b91815260200190565b60405180910390a250505050565b612471612c7a565b6001600160a01b0381166124ed5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610a96565b610b6481613474565b6124fe612c7a565b600b5442116125355760405162461bcd60e51b815260206004820152600360248201526245313760e81b6044820152606401610a96565b60025415801561254f57506012546001600160a01b031615155b61259b5760405162461bcd60e51b815260206004820152600760248201527f4531322f453233000000000000000000000000000000000000000000000000006044820152606401610a96565b6012546040516370a0823160e01b81523060048201526001600160a01b039091169060009082906370a0823190602401602060405180830381865afa1580156125e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061260c91906145ed565b90508015610b17576126286001600160a01b0383168483612d23565b826001600160a01b03167fcf018d466bd581a77eafe1429d5f079ea9a4a7363785b0561c51c9a8f2925c3c8260405161266391815260200190565b60405180910390a2505050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316631421f7307f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156126ff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061272391906145d0565b60208501516040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526001600160701b03166024820152604401602060405180830381865afa15801561277a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061279e91906145ed565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316631421f7307f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa15801561282b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061284f91906145d0565b855160405160e084901b6001600160e01b03191681526001600160a01b0390921660048301526001600160701b03166024820152604401602060405180830381865afa1580156128a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128c791906145ed565b610bfb919061458e565b604080516060810182526000808252602082018190529181019190915260008060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015612951573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612975919061461d565b92509250925060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129ff91906145ed565b9050604051806060016040528082866001600160701b031689612a229190614555565b612a2c919061456c565b6001600160701b0316815260200182856001600160701b031689612a509190614555565b612a5a919061456c565b6001600160701b031681526020018363ffffffff16815250945050505050919050565b600080612a9063ffffffff841642614542565b90506000848611612aa2576000612aac565b612aac8587614542565b905060008115612be5577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316638c86f1e47f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b6791906145d0565b60125460405160e084901b6001600160e01b03191681526001600160a01b0392831660048201526024810187905291166044820152606401602060405180830381865afa158015612bbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be091906145ed565b612be8565b60005b90506014548310612bfd579250612c1a915050565b601454612c0a8483614555565b612c14919061456c565b93505050505b9392505050565b600260005403612c735760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a96565b6002600055565b6001546001600160a01b031633146110b15760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610a96565b6012546001600160a01b0390811690841603612d185760405162461bcd60e51b815260206004820152600360248201526222989b60e91b6044820152606401610a96565b610b17838383613da5565b6040516001600160a01b038316602482015260448101829052610b179084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613df4565b600954600f1015612df25760405162461bcd60e51b815260206004820152600360248201527f45313500000000000000000000000000000000000000000000000000000000006044820152606401610a96565b6001600160a01b038116612e485760405162461bcd60e51b815260206004820152600260248201527f45310000000000000000000000000000000000000000000000000000000000006044820152606401610a96565b6001600160a01b0381166000908152600a602052604090205460ff16610b64576009805460018181019092557f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0180546001600160a01b03841673ffffffffffffffffffffffffffffffffffffffff1990911681179091556000908152600a60205260409020805460ff1916909117905550565b60125460009083906001600160a01b0316156132f357612efa610dfd565b601655612f056112ce565b600d819055507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c640752d7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fbc91906145d0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561301a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061303e91906145d0565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401600060405180830381600087803b15801561308657600080fd5b505af115801561309a573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c640752d7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa15801561312b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061314f91906145d0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156131ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131d191906145d0565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401600060405180830381600087803b15801561321957600080fd5b505af115801561322d573d6000803e3d6000fd5b505050506001600160a01b038116156132f35761324981610873565b6001600160a01b0382166000908152601860209081526040808320939093556016546017825283832055600390522054613282906128d1565b6001600160a01b0382166000908152601960209081526040918290208351815492850151949093015163ffffffff16600160e01b026001600160e01b036001600160701b03958616600160701b026001600160e01b0319909416959094169490941791909117919091169190911790555b6132fd8484613ed9565b949350505050565b6001546001600160a01b03163314806133265750336001600160a01b038216145b6133585760405162461bcd60e51b8152602060048201526003602482015262114c4d60ea1b6044820152606401610a96565b6001600160a01b0382166000908152600a602052604090205460ff166133c05760405162461bcd60e51b815260206004820152600360248201527f45313300000000000000000000000000000000000000000000000000000000006044820152606401610a96565b6001600160a01b038083166000908152601160209081526040808320938516835292905220548015610b17576001600160a01b038084166000818152601160209081526040808320948716835293905291822091909155613422908383612d23565b816001600160a01b0316836001600160a01b03167f540798df468d7b23d11f156fdb954cb19ad414d150722a7b6d55ba369dea792e8360405161346791815260200190565b60405180910390a3505050565b600180546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60125460009083906001600160a01b0316156138ea576134f1610dfd565b6016556134fc6112ce565b600d819055507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c640752d7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa15801561358f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135b391906145d0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa158015613611573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061363591906145d0565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401600060405180830381600087803b15801561367d57600080fd5b505af1158015613691573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c640752d7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015613722573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061374691906145d0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156137a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137c891906145d0565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401600060405180830381600087803b15801561381057600080fd5b505af1158015613824573d6000803e3d6000fd5b505050506001600160a01b038116156138ea5761384081610873565b6001600160a01b0382166000908152601860209081526040808320939093556016546017825283832055600390522054613879906128d1565b6001600160a01b0382166000908152601960209081526040918290208351815492850151949093015163ffffffff16600160e01b026001600160e01b036001600160701b03958616600160701b026001600160e01b0319909416959094169490941791909117919091169190911790555b6132fd8484613f58565b6040516001600160a01b0380851660248301528316604482015260648101829052611cb79085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401612d68565b61394d612c21565b613955612c7a565b600b54421161398c5760405162461bcd60e51b815260206004820152600360248201526245313760e81b6044820152606401610a96565b6000805b600954811015613a59576000600982815481106139af576139af6145a1565b6000918252602090912001546001600160a01b031690506139cf81612245565b6001600160a01b038083166000908152600f6020526040902091909155831615613a48576139fd8184610b67565b6001600160a01b03808316600081815260116020908152604080832094891680845294825280832095909555918152600f825283812054601083528482209382529290915291909120555b50613a52816145b7565b9050613990565b50613a626112ce565b600d5581613ab25760405162461bcd60e51b815260206004820152600360248201527f45313000000000000000000000000000000000000000000000000000000000006044820152606401610a96565b600954835114613b045760405162461bcd60e51b815260206004820152600360248201527f45313100000000000000000000000000000000000000000000000000000000006044820152606401610a96565b600c82905560005b600954811015613d2757600060098281548110613b2b57613b2b6145a1565b600091825260209091200154600c5486516001600160a01b0390921692508291879085908110613b5d57613b5d6145a1565b6020026020010151613b6f919061456c565b6001600160a01b0382166000908152600e60205260408120919091556009805485908110613b9f57613b9f6145a1565b6000918252602090912001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015613bf0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c1491906145ed565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614613cad57600c54613c5c908261456c565b6001600160a01b0383166000908152600e60205260409020541115613ca85760405162461bcd60e51b8152602060048201526002602482015261453360f01b6044820152606401610a96565b613d13565b600c54600254613cbd9083614542565b613cc7919061456c565b6001600160a01b0383166000908152600e60205260409020541115613d135760405162461bcd60e51b8152602060048201526002602482015261453360f01b6044820152606401610a96565b50505080613d20906145b7565b9050613b0c565b5042600d819055600c54613d3a9161458e565b600b556040517faab1f55dce0d0e628e283ce1061d0afccffcf61f9c14391c899b5952492ce82190613d6f9085908590614659565b60405180910390a150610d466001600055565b6012546001600160a01b031615613d9c57613d9c81611cbd565b610b6481614075565b6001600160a01b0383166000908152600a602052604090205460ff1615610b175760405162461bcd60e51b815260206004820152600360248201526222989b60e91b6044820152606401610a96565b6000613e49826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661407e9092919063ffffffff16565b805190915015610b175780806020019051810190613e6791906146a1565b610b175760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610a96565b600080613ee684846111ee565b90508015613f45578060076000828254613f00919061458e565b90915550506040518181526001600160a01b038516907fd0b34aaed5c558a8df736a5aaf9a49b539c4e86fb3ee5a1ac76e0bec23cbdd03906020015b60405180910390a25b6132fd84613f538386614542565b919050565b6000600b54421115613f925760405162461bcd60e51b815260206004820152600360248201526208a62760eb1b6044820152606401610a96565b8260005b60095481101561405f57600060098281548110613fb557613fb56145a1565b6000918252602090912001546001600160a01b03169050613fd581612245565b6001600160a01b038083166000908152600f602052604090209190915583161561404e576140038184610b67565b6001600160a01b03808316600081815260116020908152604080832094891680845294825280832095909555918152600f825283812054601083528482209382529290915291909120555b50614058816145b7565b9050613f96565b506140686112ce565b600d556132fd848461408d565b610b64816110b3565b60606132fd848460008561411e565b60008061409983610dd0565b6001600160a01b0385166000908152600860205260409020805463ffffffff19164263ffffffff1617905590508015613f455780600760008282546140de919061458e565b90915550506040518181526001600160a01b038516907f34f2a7363b1ef64b0b62a223c88cf3f54a68686acfcb9531d7deb46004f37c4690602001613f3c565b6060824710156141965760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610a96565b600080866001600160a01b031685876040516141b291906146e7565b60006040518083038185875af1925050503d80600081146141ef576040519150601f19603f3d011682016040523d82523d6000602084013e6141f4565b606091505b509150915061420587838387614210565b979650505050505050565b6060831561427f578251600003614278576001600160a01b0385163b6142785760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a96565b50816132fd565b6132fd83838151156142945781518083602001fd5b8060405162461bcd60e51b8152600401610a969190614703565b6001600160a01b0381168114610b6457600080fd5b6000602082840312156142d557600080fd5b8135612c1a816142ae565b6000806000606084860312156142f557600080fd5b8335614300816142ae565b92506020840135614310816142ae565b929592945050506040919091013590565b6000806040838503121561433457600080fd5b823561433f816142ae565b9150602083013561434f816142ae565b809150509250929050565b60006020828403121561436c57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b600082601f83011261439a57600080fd5b8135602067ffffffffffffffff808311156143b7576143b7614373565b8260051b604051601f19603f830116810181811084821117156143dc576143dc614373565b6040529384528581018301938381019250878511156143fa57600080fd5b83870191505b8482101561420557813583529183019190830190614400565b6000806040838503121561442c57600080fd5b823567ffffffffffffffff81111561444357600080fd5b61444f85828601614389565b95602094909401359450505050565b6000806040838503121561447157600080fd5b823561447c816142ae565b946020939093013593505050565b63ffffffff81168114610b6457600080fd5b6000806000606084860312156144b157600080fd5b83356144bc816142ae565b92506020840135915060408401356144d38161448a565b809150509250925092565b6000806000606084860312156144f357600080fd5b833567ffffffffffffffff81111561450a57600080fd5b61451686828701614389565b9660208601359650604090950135949350505050565b634e487b7160e01b600052601160045260246000fd5b81810381811115610bfb57610bfb61452c565b8082028115828204841417610bfb57610bfb61452c565b60008261458957634e487b7160e01b600052601260045260246000fd5b500490565b80820180821115610bfb57610bfb61452c565b634e487b7160e01b600052603260045260246000fd5b6000600182016145c9576145c961452c565b5060010190565b6000602082840312156145e257600080fd5b8151612c1a816142ae565b6000602082840312156145ff57600080fd5b5051919050565b80516001600160701b0381168114613f5357600080fd5b60008060006060848603121561463257600080fd5b61463b84614606565b925061464960208501614606565b915060408401516144d38161448a565b604080825283519082018190526000906020906060840190828701845b8281101561469257815184529284019290840190600101614676565b50505092019290925292915050565b6000602082840312156146b357600080fd5b81518015158114612c1a57600080fd5b60005b838110156146de5781810151838201526020016146c6565b50506000910152565b600082516146f98184602087016146c3565b9190910192915050565b60208152600082518060208401526147228160408501602087016146c3565b601f01601f1916919091016040019291505056fea264697066735822122081f8114000287dcb73524e2ac411aa335994df052164bfce6e0a1d00b35de2b364736f6c63430008130033a2646970667358221220ce65b3a2cae40b2887235ea3e59539fa65407f294e126c0868283267e199422664736f6c63430008130033
Deployed Bytecode Sourcemap
84009:888:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;84343:551;;;;;;;;;;-1:-1:-1;84343:551:0;;;;;:::i;:::-;;:::i;:::-;;;1666:42:1;1654:55;;;1636:74;;1624:2;1609:18;84343:551:0;;;;;;;;84479:12;84504:21;84559:33;;;;;;;;:::i;:::-;-1:-1:-1;;84559:33:0;;;;;;;;;;;;;;;;84528:94;;84559:33;84607:4;;84559:33;84528:94;;:::i;:::-;;;;;;;;;;;;;84504:118;;84716:5;84705:8;84699:15;84692:4;84682:8;84678:19;84675:1;84667:55;84659:63;;84758:4;84746:17;84736:75;;84794:1;84791;84784:12;84736:75;84834:52;;;;;:38;1654:55:1;;;84834:52:0;;;1636:74:1;84834:38:0;;;;;1609:18:1;;84834:52:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;84493:401;84343:551;;;;;:::o;-1:-1:-1:-;;;;;;;;:::o;14:184:1:-;66:77;63:1;56:88;163:4;160:1;153:15;187:4;184:1;177:15;203:196;271:20;;331:42;320:54;;310:65;;300:93;;389:1;386;379:12;300:93;203:196;;;:::o;404:1073::-;490:6;498;506;559:2;547:9;538:7;534:23;530:32;527:52;;;575:1;572;565:12;527:52;615:9;602:23;644:18;685:2;677:6;674:14;671:34;;;701:1;698;691:12;671:34;739:6;728:9;724:22;714:32;;784:7;777:4;773:2;769:13;765:27;755:55;;806:1;803;796:12;755:55;842:2;829:16;864:2;860;857:10;854:36;;;870:18;;:::i;:::-;945:2;939:9;913:2;999:13;;-1:-1:-1;;995:22:1;;;1019:2;991:31;987:40;975:53;;;1043:18;;;1063:22;;;1040:46;1037:72;;;1089:18;;:::i;:::-;1129:10;1125:2;1118:22;1164:2;1156:6;1149:18;1206:7;1199:4;1194:2;1190;1186:11;1182:22;1179:35;1176:55;;;1227:1;1224;1217:12;1176:55;1287:2;1280:4;1276:2;1272:13;1265:4;1257:6;1253:17;1240:50;1334:1;1327:4;1322:2;1314:6;1310:15;1306:26;1299:37;1355:6;1345:16;;;;;;;1408:4;1397:9;1393:20;1380:34;1370:44;;1433:38;1467:2;1456:9;1452:18;1433:38;:::i;:::-;1423:48;;404:1073;;;;;:::o;1721:322::-;1762:3;1800:5;1794:12;1824:1;1834:128;1848:6;1845:1;1842:13;1834:128;;;1945:4;1930:13;;;1926:24;;1920:31;1907:11;;;1900:52;1863:12;1834:128;;;-1:-1:-1;2017:1:1;1981:16;;2006:13;;;-1:-1:-1;1981:16:1;;1721:322;-1:-1:-1;1721:322:1:o;2048:261::-;2223:3;2248:55;2273:29;2298:3;2290:6;2273:29;:::i;:::-;2265:6;2248:55;:::i;:::-;2241:62;2048:261;-1:-1:-1;;;;2048:261:1:o
Swarm Source
ipfs://ce65b3a2cae40b2887235ea3e59539fa65407f294e126c0868283267e1994226
Loading...
Loading
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.