Overview
ETH Balance
ETH Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Name:
SwapRouter
Compiler Version
v0.6.12+commit.27d51765
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.6.10 <0.8.0; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "../interfaces/ISwapRouter.sol"; import "../interfaces/ITrancheIndexV2.sol"; import "../fund/ShareStaking.sol"; import "../interfaces/IWrappedERC20.sol"; import "../interfaces/IWstETH.sol"; /// @title Tranchess Swap Router /// @notice Router for stateless execution of swaps against Tranchess stable swaps contract SwapRouter is ISwapRouter, ITrancheIndexV2, Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; address public immutable wstETH; address public immutable stETH; constructor(address wstETH_) public { wstETH = wstETH_; stETH = wstETH_ == address(0) ? address(0) : IWstETH(wstETH_).stETH(); } event SwapAdded(address addr0, address addr1, address swap); mapping(address => mapping(address => IStableSwap)) private _swapMap; /// @dev Returns the swap for the given token pair and fee. The swap contract may or may not exist. function getSwap( address baseAddress, address quoteAddress ) public view override returns (IStableSwap) { (address addr0, address addr1) = baseAddress < quoteAddress ? (baseAddress, quoteAddress) : (quoteAddress, baseAddress); return _swapMap[addr0][addr1]; } function addSwap(address baseAddress, address quoteAddress, address swap) external onlyOwner { require( swap == address(0) || (baseAddress == IStableSwap(swap).baseAddress() && quoteAddress == IStableSwap(swap).quoteAddress()) ); // sanity check (address addr0, address addr1) = baseAddress < quoteAddress ? (baseAddress, quoteAddress) : (quoteAddress, baseAddress); _swapMap[addr0][addr1] = IStableSwap(swap); emit SwapAdded(addr0, addr1, swap); } receive() external payable {} function addLiquidity( address baseAddress, address quoteAddress, uint256 baseIn, uint256 quoteIn, uint256 minLpOut, uint256 version, uint256 deadline ) external payable override checkDeadline(deadline) { IStableSwap swap = getSwap(baseAddress, quoteAddress); if (quoteAddress == stETH) { swap = getSwap(baseAddress, wstETH); } require(address(swap) != address(0), "Unknown swap"); swap.fund().trancheTransferFrom( swap.baseTranche(), msg.sender, address(swap), baseIn, version ); if (msg.value > 0) { require(msg.value == quoteIn); // sanity check IWrappedERC20(quoteAddress).deposit{value: quoteIn}(); IERC20(quoteAddress).safeTransfer(address(swap), quoteIn); } else if (quoteAddress == stETH) { IERC20(stETH).safeTransferFrom(msg.sender, address(this), quoteIn); IERC20(stETH).approve(wstETH, quoteIn); quoteIn = IWstETH(wstETH).wrap(quoteIn); IERC20(wstETH).safeTransfer(address(swap), quoteIn); } else { IERC20(quoteAddress).safeTransferFrom(msg.sender, address(swap), quoteIn); } uint256 lpOut = swap.addLiquidity(version, msg.sender); require(lpOut >= minLpOut, "Insufficient output"); } function swapExactTokensForTokens( uint256 amountIn, uint256 minAmountOut, address[] calldata path, address recipient, address staking, uint256[] calldata versions, uint256 deadline ) external payable override checkDeadline(deadline) returns (uint256[] memory amounts) { require(path.length >= 2, "Invalid path"); require(versions.length == path.length - 1, "Invalid versions"); IStableSwap[] memory swaps; bool[] memory isBuy; (amounts, swaps, isBuy) = getAmountsOut(amountIn, path); require(amounts[amounts.length - 1] >= minAmountOut, "Insufficient output"); if (msg.value > 0) { require(msg.value == amounts[0]); // sanity check IWrappedERC20(path[0]).deposit{value: amounts[0]}(); IERC20(path[0]).safeTransfer(address(swaps[0]), amounts[0]); } else { if (isBuy[0]) { IERC20(path[0]).safeTransferFrom(msg.sender, address(swaps[0]), amounts[0]); } else { swaps[0].fund().trancheTransferFrom( swaps[0].baseTranche(), msg.sender, address(swaps[0]), amounts[0], versions[0] ); } } if (staking == address(0)) { _swap(amounts, swaps, isBuy, versions, recipient); } else { _swap(amounts, swaps, isBuy, versions, staking); ShareStaking(staking).deposit( swaps[swaps.length - 1].baseTranche(), amounts[amounts.length - 1], recipient, versions[versions.length - 1] ); } } function swapTokensForExactTokens( uint256 amountOut, uint256 maxAmountIn, address[] calldata path, address recipient, address staking, uint256[] calldata versions, uint256 deadline ) external payable override checkDeadline(deadline) returns (uint256[] memory amounts) { require(path.length >= 2, "Invalid path"); require(versions.length == path.length - 1, "Invalid versions"); IStableSwap[] memory swaps; bool[] memory isBuy; (amounts, swaps, isBuy) = getAmountsIn(amountOut, path); require(amounts[0] <= maxAmountIn, "Excessive input"); if (msg.value > 0) { require(msg.value == maxAmountIn); // sanity check IWrappedERC20(path[0]).deposit{value: amounts[0]}(); IERC20(path[0]).safeTransfer(address(swaps[0]), amounts[0]); } else { if (isBuy[0]) { IERC20(path[0]).safeTransferFrom(msg.sender, address(swaps[0]), amounts[0]); } else { swaps[0].fund().trancheTransferFrom( swaps[0].baseTranche(), msg.sender, address(swaps[0]), amounts[0], versions[0] ); } } if (staking == address(0)) { _swap(amounts, swaps, isBuy, versions, recipient); } else { _swap(amounts, swaps, isBuy, versions, staking); ShareStaking(staking).deposit( swaps[swaps.length - 1].baseTranche(), amountOut, recipient, versions[versions.length - 1] ); } // refund native token if (msg.value > amounts[0]) { (bool success, ) = msg.sender.call{value: msg.value - amounts[0]}(""); require(success, "Transfer failed"); } } function swapExactTokensForTokensUnwrap( uint256 amountIn, uint256 minAmountOut, address[] calldata path, address recipient, uint256[] calldata versions, uint256 deadline ) external override checkDeadline(deadline) returns (uint256[] memory amounts) { require(path.length >= 2, "Invalid path"); require(versions.length == path.length - 1, "Invalid versions"); IStableSwap[] memory swaps; bool[] memory isBuy; (amounts, swaps, isBuy) = getAmountsOut(amountIn, path); require(amounts[amounts.length - 1] >= minAmountOut, "Insufficient output"); if (isBuy[0]) { IERC20(path[0]).safeTransferFrom(msg.sender, address(swaps[0]), amounts[0]); } else { swaps[0].fund().trancheTransferFrom( swaps[0].baseTranche(), msg.sender, address(swaps[0]), amounts[0], versions[0] ); } _swap(amounts, swaps, isBuy, versions, address(this)); IWrappedERC20(path[path.length - 1]).withdraw(amounts[amounts.length - 1]); (bool success, ) = recipient.call{value: amounts[amounts.length - 1]}(""); require(success, "Transfer failed"); } function swapTokensForExactTokensUnwrap( uint256 amountOut, uint256 maxAmountIn, address[] calldata path, address recipient, uint256[] calldata versions, uint256 deadline ) external override checkDeadline(deadline) returns (uint256[] memory amounts) { require(path.length >= 2, "Invalid path"); require(versions.length == path.length - 1, "Invalid versions"); IStableSwap[] memory swaps; bool[] memory isBuy; (amounts, swaps, isBuy) = getAmountsIn(amountOut, path); require(amounts[0] <= maxAmountIn, "Excessive input"); if (isBuy[0]) { IERC20(path[0]).safeTransferFrom(msg.sender, address(swaps[0]), amounts[0]); } else { swaps[0].fund().trancheTransferFrom( swaps[0].baseTranche(), msg.sender, address(swaps[0]), amounts[0], versions[0] ); } _swap(amounts, swaps, isBuy, versions, address(this)); IWrappedERC20(path[path.length - 1]).withdraw(amountOut); (bool success, ) = recipient.call{value: amountOut}(""); require(success, "Transfer failed"); } function getAmountsOut( uint256 amount, address[] memory path ) public view override returns (uint256[] memory amounts, IStableSwap[] memory swaps, bool[] memory isBuy) { amounts = new uint256[](path.length); swaps = new IStableSwap[](path.length - 1); isBuy = new bool[](path.length - 1); amounts[0] = amount; for (uint256 i; i < path.length - 1; i++) { swaps[i] = getSwap(path[i], path[i + 1]); require(address(swaps[i]) != address(0), "Unknown swap"); if (path[i] == swaps[i].baseAddress()) { amounts[i + 1] = swaps[i].getQuoteOut(amounts[i]); } else { isBuy[i] = true; amounts[i + 1] = swaps[i].getBaseOut(amounts[i]); } } } function getAmountsIn( uint256 amount, address[] memory path ) public view override returns (uint256[] memory amounts, IStableSwap[] memory swaps, bool[] memory isBuy) { amounts = new uint256[](path.length); swaps = new IStableSwap[](path.length - 1); isBuy = new bool[](path.length - 1); amounts[amounts.length - 1] = amount; for (uint256 i = path.length - 1; i > 0; i--) { swaps[i - 1] = getSwap(path[i - 1], path[i]); require(address(swaps[i - 1]) != address(0), "Unknown swap"); if (path[i] == swaps[i - 1].baseAddress()) { isBuy[i - 1] = true; amounts[i - 1] = swaps[i - 1].getQuoteIn(amounts[i]); } else { amounts[i - 1] = swaps[i - 1].getBaseIn(amounts[i]); } } } function _swap( uint256[] memory amounts, IStableSwap[] memory swaps, bool[] memory isBuy, uint256[] calldata versions, address recipient ) private { for (uint256 i = 0; i < swaps.length; i++) { address to = i < swaps.length - 1 ? address(swaps[i + 1]) : recipient; if (!isBuy[i]) { swaps[i].sell(versions[i], amounts[i + 1], to, new bytes(0)); } else { swaps[i].buy(versions[i], amounts[i + 1], to, new bytes(0)); } } } modifier checkDeadline(uint256 deadline) { require(block.timestamp <= deadline, "Transaction too old"); _; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { 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 { emit OwnershipTransferred(_owner, address(0)); _owner = 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"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @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 `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount) external returns (bool); /** * @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); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @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' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @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 // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @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 * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // 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 // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 GSN 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 payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.6.10 <0.8.0; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/math/Math.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "../utils/SafeDecimalMath.sol"; import "../utils/CoreUtility.sol"; import "../interfaces/IFundV3.sol"; import "../interfaces/IChessController.sol"; import "../interfaces/IChessSchedule.sol"; import "../interfaces/ITrancheIndexV2.sol"; import "../interfaces/IVotingEscrow.sol"; contract ShareStaking is ITrancheIndexV2, CoreUtility { using Math for uint256; using SafeMath for uint256; using SafeDecimalMath for uint256; using SafeERC20 for IERC20; event Deposited(uint256 tranche, address account, uint256 amount); event Withdrawn(uint256 tranche, address account, uint256 amount); uint256 private constant MAX_ITERATIONS = 500; uint256 private constant REWARD_WEIGHT_B = 2; uint256 private constant REWARD_WEIGHT_R = 1; uint256 private constant REWARD_WEIGHT_Q = 3; uint256 private constant MAX_BOOSTING_FACTOR = 3e18; uint256 private constant MAX_BOOSTING_FACTOR_MINUS_ONE = MAX_BOOSTING_FACTOR - 1e18; IFundV3 public immutable fund; /// @notice The Chess release schedule contract. IChessSchedule public immutable chessSchedule; /// @notice The controller contract. IChessController public immutable chessController; IVotingEscrow private immutable _votingEscrow; /// @notice Timestamp when rewards start. uint256 public immutable rewardStartTimestamp; /// @dev Per-fund CHESS emission rate. The product of CHESS emission rate /// and weekly percentage of the fund uint256 private _rate; /// @dev Total amount of user shares, i.e. sum of all entries in `_balances`. uint256[TRANCHE_COUNT] private _totalSupplies; /// @dev Rebalance version of `_totalSupplies`. uint256 private _totalSupplyVersion; /// @dev Amount of shares staked by each user. mapping(address => uint256[TRANCHE_COUNT]) private _balances; /// @dev Rebalance version mapping for `_balances`. mapping(address => uint256) private _balanceVersions; /// @dev Mapping of rebalance version => split ratio. mapping(uint256 => uint256) private _historicalSplitRatio; /// @dev 1e27 * ∫(rate(t) / totalWeight(t) dt) from the latest rebalance till checkpoint. uint256 private _invTotalWeightIntegral; /// @dev Final `_invTotalWeightIntegral` before each rebalance. /// These values are accessed in a loop in `_userCheckpoint()` with bounds checking. /// So we store them in a fixed-length array, in order to make compiler-generated /// bounds checking on every access cheaper. The actual length of this array is stored in /// `_historicalIntegralSize` and should be explicitly checked when necessary. uint256[65535] private _historicalIntegrals; /// @dev Actual length of the `_historicalIntegrals` array, which always equals to the number of /// historical rebalances after `checkpoint()` is called. uint256 private _historicalIntegralSize; /// @dev Timestamp when checkpoint() is called. uint256 private _checkpointTimestamp; /// @dev Snapshot of `_invTotalWeightIntegral` per user. mapping(address => uint256) private _userIntegrals; /// @dev Mapping of account => claimable rewards. mapping(address => uint256) private _claimableRewards; uint256 private _workingSupply; mapping(address => uint256) private _workingBalances; constructor( address fund_, address chessSchedule_, address chessController_, address votingEscrow_, uint256 rewardStartTimestamp_ ) public { fund = IFundV3(fund_); chessSchedule = IChessSchedule(chessSchedule_); chessController = IChessController(chessController_); _votingEscrow = IVotingEscrow(votingEscrow_); rewardStartTimestamp = rewardStartTimestamp_; _checkpointTimestamp = block.timestamp; } function getRate() external view returns (uint256) { return _rate / 1e18; } /// @notice Return weight of given balance with respect to rewards. /// @param amountQ Amount of QUEEN /// @param amountB Amount of BISHOP /// @param amountR Amount of ROOK /// @param splitRatio Split ratio /// @return Rewarding weight of the balance function weightedBalance( uint256 amountQ, uint256 amountB, uint256 amountR, uint256 splitRatio ) public pure returns (uint256) { return amountQ .mul(REWARD_WEIGHT_Q) .multiplyDecimal(splitRatio) .add(amountB.mul(REWARD_WEIGHT_B)) .add(amountR.mul(REWARD_WEIGHT_R)) .div(REWARD_WEIGHT_Q); } function totalSupply(uint256 tranche) external view returns (uint256) { uint256 totalSupplyQ = _totalSupplies[TRANCHE_Q]; uint256 totalSupplyB = _totalSupplies[TRANCHE_B]; uint256 totalSupplyR = _totalSupplies[TRANCHE_R]; uint256 version = _totalSupplyVersion; uint256 rebalanceSize = _fundRebalanceSize(); if (version < rebalanceSize) { (totalSupplyQ, totalSupplyB, totalSupplyR) = _fundBatchRebalance( totalSupplyQ, totalSupplyB, totalSupplyR, version, rebalanceSize ); } if (tranche == TRANCHE_Q) { return totalSupplyQ; } else if (tranche == TRANCHE_B) { return totalSupplyB; } else { return totalSupplyR; } } function trancheBalanceOf(uint256 tranche, address account) external view returns (uint256) { uint256 amountQ = _balances[account][TRANCHE_Q]; uint256 amountB = _balances[account][TRANCHE_B]; uint256 amountR = _balances[account][TRANCHE_R]; if (tranche == TRANCHE_Q) { if (amountQ == 0 && amountB == 0 && amountR == 0) return 0; } else if (tranche == TRANCHE_B) { if (amountB == 0) return 0; } else { if (amountR == 0) return 0; } uint256 version = _balanceVersions[account]; uint256 rebalanceSize = _fundRebalanceSize(); if (version < rebalanceSize) { (amountQ, amountB, amountR) = _fundBatchRebalance( amountQ, amountB, amountR, version, rebalanceSize ); } if (tranche == TRANCHE_Q) { return amountQ; } else if (tranche == TRANCHE_B) { return amountB; } else { return amountR; } } function balanceVersion(address account) external view returns (uint256) { return _balanceVersions[account]; } function workingSupply() external view returns (uint256) { uint256 version = _totalSupplyVersion; uint256 rebalanceSize = _fundRebalanceSize(); if (version < rebalanceSize) { ( uint256 totalSupplyQ, uint256 totalSupplyB, uint256 totalSupplyR ) = _fundBatchRebalance( _totalSupplies[TRANCHE_Q], _totalSupplies[TRANCHE_B], _totalSupplies[TRANCHE_R], version, rebalanceSize ); return weightedBalance(totalSupplyQ, totalSupplyB, totalSupplyR, fund.splitRatio()); } else { return _workingSupply; } } function workingBalanceOf(address account) external view returns (uint256) { uint256 version = _balanceVersions[account]; uint256 rebalanceSize = _fundRebalanceSize(); uint256 workingBalance = _workingBalances[account]; // gas saver if (version < rebalanceSize || workingBalance == 0) { uint256[TRANCHE_COUNT] storage balance = _balances[account]; uint256 amountQ = balance[TRANCHE_Q]; uint256 amountB = balance[TRANCHE_B]; uint256 amountR = balance[TRANCHE_R]; if (version < rebalanceSize) { (amountQ, amountB, amountR) = _fundBatchRebalance( amountQ, amountB, amountR, version, rebalanceSize ); } return weightedBalance(amountQ, amountB, amountR, fund.splitRatio()); } else { return workingBalance; } } function _fundRebalanceSize() internal view returns (uint256) { return fund.getRebalanceSize(); } function _fundDoRebalance( uint256 amountQ, uint256 amountB, uint256 amountR, uint256 index ) internal view returns (uint256, uint256, uint256) { return fund.doRebalance(amountQ, amountB, amountR, index); } function _fundBatchRebalance( uint256 amountQ, uint256 amountB, uint256 amountR, uint256 fromIndex, uint256 toIndex ) internal view returns (uint256, uint256, uint256) { return fund.batchRebalance(amountQ, amountB, amountR, fromIndex, toIndex); } /// @dev Stake share tokens. A user could send QUEEN before deposit(). /// The contract first measures how much tranche share it has received, /// then transfer the rest from the user /// @param tranche Tranche of the share /// @param amount The amount to deposit /// @param recipient Address that receives deposit /// @param version The current rebalance version function deposit(uint256 tranche, uint256 amount, address recipient, uint256 version) external { _checkpoint(version); _userCheckpoint(recipient, version); _balances[recipient][tranche] = _balances[recipient][tranche].add(amount); uint256 oldTotalSupply = _totalSupplies[tranche]; _totalSupplies[tranche] = oldTotalSupply.add(amount); _updateWorkingBalance(recipient, version); uint256 spareAmount = fund.trancheBalanceOf(tranche, address(this)).sub(oldTotalSupply); if (spareAmount < amount) { // Retain the rest of share token (version is checked by the fund) fund.trancheTransferFrom( tranche, msg.sender, address(this), amount - spareAmount, version ); } else { require(version == _fundRebalanceSize(), "Invalid version"); } emit Deposited(tranche, recipient, amount); } /// @notice Unstake tranche tokens. /// @param tranche Tranche of the share /// @param amount The amount to withdraw /// @param version The current rebalance version function withdraw(uint256 tranche, uint256 amount, uint256 version) external { _checkpoint(version); _userCheckpoint(msg.sender, version); _balances[msg.sender][tranche] = _balances[msg.sender][tranche].sub( amount, "Insufficient balance to withdraw" ); _totalSupplies[tranche] = _totalSupplies[tranche].sub(amount); _updateWorkingBalance(msg.sender, version); // version is checked by the fund fund.trancheTransfer(tranche, msg.sender, amount, version); emit Withdrawn(tranche, msg.sender, amount); } /// @notice Transform share balance to a given rebalance version, or to the latest version /// if `targetVersion` is zero. /// @param account Account of the balance to rebalance /// @param targetVersion The target rebalance version, or zero for the latest version function refreshBalance(address account, uint256 targetVersion) external { uint256 rebalanceSize = _fundRebalanceSize(); if (targetVersion == 0) { targetVersion = rebalanceSize; } else { require(targetVersion <= rebalanceSize, "Target version out of bound"); } _checkpoint(rebalanceSize); _userCheckpoint(account, targetVersion); } /// @notice Return claimable rewards of an account till now. /// /// This function should be call as a "view" function off-chain to get /// the return value, e.g. using `contract.claimableRewards.call(account)` in web3 /// or `contract.callStatic.claimableRewards(account)` in ethers.js. /// @param account Address of an account /// @return Amount of claimable rewards function claimableRewards(address account) external returns (uint256) { uint256 rebalanceSize = _fundRebalanceSize(); _checkpoint(rebalanceSize); _userCheckpoint(account, rebalanceSize); return _claimableRewards[account]; } /// @notice Claim the rewards for an account. /// @param account Account to claim its rewards function claimRewards(address account) external { uint256 rebalanceSize = _fundRebalanceSize(); _checkpoint(rebalanceSize); _userCheckpoint(account, rebalanceSize); uint256 amount = _claimableRewards[account]; _claimableRewards[account] = 0; chessSchedule.mint(account, amount); _updateWorkingBalance(account, rebalanceSize); } /// @notice Synchronize an account's locked Chess with `VotingEscrow` /// and update its working balance. /// @param account Address of the synchronized account function syncWithVotingEscrow(address account) external { uint256 rebalanceSize = _fundRebalanceSize(); _checkpoint(rebalanceSize); _userCheckpoint(account, rebalanceSize); _updateWorkingBalance(account, rebalanceSize); } /// @dev Transform total supplies to the latest rebalance version and make a global reward checkpoint. /// @param rebalanceSize The number of existing rebalances. It must be the same as /// `fund.getRebalanceSize()`. function _checkpoint(uint256 rebalanceSize) private { uint256 timestamp = _checkpointTimestamp; if (timestamp >= block.timestamp) { return; } uint256 integral = _invTotalWeightIntegral; uint256 endWeek = _endOfWeek(timestamp); uint256 version = _totalSupplyVersion; uint256 rebalanceTimestamp; if (version < rebalanceSize) { rebalanceTimestamp = fund.getRebalanceTimestamp(version); } else { rebalanceTimestamp = type(uint256).max; } uint256 rate = _rate; uint256 totalSupplyQ = _totalSupplies[TRANCHE_Q]; uint256 totalSupplyB = _totalSupplies[TRANCHE_B]; uint256 totalSupplyR = _totalSupplies[TRANCHE_R]; uint256 weight = _workingSupply; uint256 timestamp_ = timestamp; // avoid stack too deep for (uint256 i = 0; i < MAX_ITERATIONS && timestamp_ < block.timestamp; i++) { uint256 endTimestamp = rebalanceTimestamp.min(endWeek).min(block.timestamp); if (weight > 0 && endTimestamp > rewardStartTimestamp) { integral = integral.add( rate .mul(endTimestamp.sub(timestamp_.max(rewardStartTimestamp))) .decimalToPreciseDecimal() .div(weight) ); } if (endTimestamp == rebalanceTimestamp) { uint256 oldSize = _historicalIntegralSize; _historicalIntegrals[oldSize] = integral; _historicalIntegralSize = oldSize + 1; integral = 0; (totalSupplyQ, totalSupplyB, totalSupplyR) = _fundDoRebalance( totalSupplyQ, totalSupplyB, totalSupplyR, version ); version++; { // Reset total weight boosting after the first rebalance uint256 splitRatio = fund.historicalSplitRatio(version); weight = weightedBalance(totalSupplyQ, totalSupplyB, totalSupplyR, splitRatio); _historicalSplitRatio[version] = splitRatio; } if (version < rebalanceSize) { rebalanceTimestamp = fund.getRebalanceTimestamp(version); } else { rebalanceTimestamp = type(uint256).max; } } if (endTimestamp == endWeek) { rate = chessSchedule.getRate(endWeek).mul( chessController.getFundRelativeWeight(address(this), endWeek) ); if (endWeek < rewardStartTimestamp && endWeek + 1 weeks > rewardStartTimestamp) { // Rewards start in the middle of the next week. We adjust the rate to // compensate for the period between `endWeek` and `rewardStartTimestamp`. rate = rate.mul(1 weeks).div(endWeek + 1 weeks - rewardStartTimestamp); } endWeek += 1 weeks; } timestamp_ = endTimestamp; } _checkpointTimestamp = block.timestamp; _invTotalWeightIntegral = integral; _rate = rate; if (_totalSupplyVersion != rebalanceSize) { _totalSupplies[TRANCHE_Q] = totalSupplyQ; _totalSupplies[TRANCHE_B] = totalSupplyB; _totalSupplies[TRANCHE_R] = totalSupplyR; _totalSupplyVersion = rebalanceSize; // Reset total working weight before any boosting if rebalance ever triggered _workingSupply = weight; } } /// @dev Transform a user's balance to a given rebalance version and update this user's rewards. /// /// In most cases, the target version is the latest version and this function cumulates /// rewards till now. When this function is called from `refreshBalance()`, /// `targetVersion` can be an older version, in which case rewards are cumulated till /// the end of that version (i.e. timestamp of the transaction triggering the rebalance /// with index `targetVersion`). /// /// This function should always be called after `_checkpoint()` is called, so that /// the global reward checkpoint is guarenteed up to date. /// @param account Account to update /// @param targetVersion The target rebalance version function _userCheckpoint(address account, uint256 targetVersion) private { uint256 oldVersion = _balanceVersions[account]; if (oldVersion > targetVersion) { return; } uint256 userIntegral = _userIntegrals[account]; uint256 integral; // This scope is to avoid the "stack too deep" error. { // We assume that this function is always called immediately after `_checkpoint()`, // which guarantees that `_historicalIntegralSize` equals to the number of historical // rebalances. uint256 rebalanceSize = _historicalIntegralSize; integral = targetVersion == rebalanceSize ? _invTotalWeightIntegral : _historicalIntegrals[targetVersion]; } if (userIntegral == integral && oldVersion == targetVersion) { // Return immediately when the user's rewards have already been updated to // the target version. return; } uint256 rewards = _claimableRewards[account]; uint256[TRANCHE_COUNT] storage balance = _balances[account]; uint256 weight = _workingBalances[account]; uint256 balanceQ = balance[TRANCHE_Q]; uint256 balanceB = balance[TRANCHE_B]; uint256 balanceR = balance[TRANCHE_R]; for (uint256 i = oldVersion; i < targetVersion; i++) { rewards = rewards.add( weight.multiplyDecimalPrecise(_historicalIntegrals[i].sub(userIntegral)) ); if (balanceQ != 0 || balanceB != 0 || balanceR != 0) { (balanceQ, balanceB, balanceR) = _fundDoRebalance(balanceQ, balanceB, balanceR, i); } userIntegral = 0; // Reset per-user weight boosting after the first rebalance weight = weightedBalance(balanceQ, balanceB, balanceR, _historicalSplitRatio[i + 1]); } rewards = rewards.add(weight.multiplyDecimalPrecise(integral.sub(userIntegral))); address account_ = account; // Fix the "stack too deep" error _claimableRewards[account_] = rewards; _userIntegrals[account_] = integral; if (oldVersion < targetVersion) { balance[TRANCHE_Q] = balanceQ; balance[TRANCHE_B] = balanceB; balance[TRANCHE_R] = balanceR; _balanceVersions[account_] = targetVersion; _workingBalances[account_] = weight; } } /// @dev Calculate working balance, which depends on the amount of staked tokens and veCHESS. /// Before this function is called, both `_checkpoint()` and `_userCheckpoint(account)` /// should be called to update `_workingSupply` and `_workingBalances[account]` to /// the latest rebalance version. /// @param account User address /// @param rebalanceSize The number of existing rebalances. It must be the same as /// `fund.getRebalanceSize()`. function _updateWorkingBalance(address account, uint256 rebalanceSize) private { uint256 splitRatio = _historicalSplitRatio[rebalanceSize]; if (splitRatio == 0) { // Read it from the fund in case that it's not initialized yet, e.g. when we reach here // for the first time and `rebalanceSize` is zero. splitRatio = fund.historicalSplitRatio(rebalanceSize); _historicalSplitRatio[rebalanceSize] = splitRatio; } uint256 weightedSupply = weightedBalance( _totalSupplies[TRANCHE_Q], _totalSupplies[TRANCHE_B], _totalSupplies[TRANCHE_R], splitRatio ); uint256[TRANCHE_COUNT] storage balance = _balances[account]; uint256 newWorkingBalance = weightedBalance( balance[TRANCHE_Q], balance[TRANCHE_B], balance[TRANCHE_R], splitRatio ); uint256 veBalance = _votingEscrow.balanceOf(account); if (veBalance > 0) { uint256 veTotalSupply = _votingEscrow.totalSupply(); uint256 maxWorkingBalance = newWorkingBalance.multiplyDecimal(MAX_BOOSTING_FACTOR); uint256 boostedWorkingBalance = newWorkingBalance.add( weightedSupply.mul(veBalance).multiplyDecimal(MAX_BOOSTING_FACTOR_MINUS_ONE).div( veTotalSupply ) ); newWorkingBalance = maxWorkingBalance.min(boostedWorkingBalance); } _workingSupply = _workingSupply.sub(_workingBalances[account]).add(newWorkingBalance); _workingBalances[account] = newWorkingBalance; } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.6.10 <0.8.0; interface IChessController { function getFundRelativeWeight(address account, uint256 timestamp) external returns (uint256); }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.6.10 <0.8.0; interface IChessSchedule { function getWeeklySupply(uint256 timestamp) external view returns (uint256); function getRate(uint256 timestamp) external view returns (uint256); function mint(address account, uint256 amount) external; function addMinter(address account) external; }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.6.10 <0.8.0; pragma experimental ABIEncoderV2; import "./ITwapOracleV2.sol"; interface IFundV3 { /// @notice A linear transformation matrix that represents a rebalance. /// /// ``` /// [ 1 0 0 ] /// R = [ ratioB2Q ratioBR 0 ] /// [ ratioR2Q 0 ratioBR ] /// ``` /// /// Amounts of the three tranches `q`, `b` and `r` can be rebalanced by multiplying the matrix: /// /// ``` /// [ q', b', r' ] = [ q, b, r ] * R /// ``` struct Rebalance { uint256 ratioB2Q; uint256 ratioR2Q; uint256 ratioBR; uint256 timestamp; } function tokenUnderlying() external view returns (address); function tokenQ() external view returns (address); function tokenB() external view returns (address); function tokenR() external view returns (address); function tokenShare(uint256 tranche) external view returns (address); function primaryMarket() external view returns (address); function primaryMarketUpdateProposal() external view returns (address, uint256); function strategy() external view returns (address); function strategyUpdateProposal() external view returns (address, uint256); function underlyingDecimalMultiplier() external view returns (uint256); function twapOracle() external view returns (ITwapOracleV2); function feeCollector() external view returns (address); function endOfDay(uint256 timestamp) external pure returns (uint256); function trancheTotalSupply(uint256 tranche) external view returns (uint256); function trancheBalanceOf(uint256 tranche, address account) external view returns (uint256); function trancheAllBalanceOf(address account) external view returns (uint256, uint256, uint256); function trancheBalanceVersion(address account) external view returns (uint256); function trancheAllowance( uint256 tranche, address owner, address spender ) external view returns (uint256); function trancheAllowanceVersion( address owner, address spender ) external view returns (uint256); function trancheTransfer( uint256 tranche, address recipient, uint256 amount, uint256 version ) external; function trancheTransferFrom( uint256 tranche, address sender, address recipient, uint256 amount, uint256 version ) external; function trancheApprove( uint256 tranche, address spender, uint256 amount, uint256 version ) external; function getRebalanceSize() external view returns (uint256); function getRebalance(uint256 index) external view returns (Rebalance memory); function getRebalanceTimestamp(uint256 index) external view returns (uint256); function currentDay() external view returns (uint256); function splitRatio() external view returns (uint256); function historicalSplitRatio(uint256 version) external view returns (uint256); function fundActivityStartTime() external view returns (uint256); function isFundActive(uint256 timestamp) external view returns (bool); function getEquivalentTotalB() external view returns (uint256); function getEquivalentTotalQ() external view returns (uint256); function historicalEquivalentTotalB(uint256 timestamp) external view returns (uint256); function historicalNavs(uint256 timestamp) external view returns (uint256 navB, uint256 navR); function extrapolateNav(uint256 price) external view returns (uint256, uint256, uint256); function doRebalance( uint256 amountQ, uint256 amountB, uint256 amountR, uint256 index ) external view returns (uint256 newAmountQ, uint256 newAmountB, uint256 newAmountR); function batchRebalance( uint256 amountQ, uint256 amountB, uint256 amountR, uint256 fromIndex, uint256 toIndex ) external view returns (uint256 newAmountQ, uint256 newAmountB, uint256 newAmountR); function refreshBalance(address account, uint256 targetVersion) external; function refreshAllowance(address owner, address spender, uint256 targetVersion) external; function shareTransfer(address sender, address recipient, uint256 amount) external; function shareTransferFrom( address spender, address sender, address recipient, uint256 amount ) external returns (uint256 newAllowance); function shareIncreaseAllowance( address sender, address spender, uint256 addedValue ) external returns (uint256 newAllowance); function shareDecreaseAllowance( address sender, address spender, uint256 subtractedValue ) external returns (uint256 newAllowance); function shareApprove(address owner, address spender, uint256 amount) external; function historicalUnderlying(uint256 timestamp) external view returns (uint256); function getTotalUnderlying() external view returns (uint256); function getStrategyUnderlying() external view returns (uint256); function getTotalDebt() external view returns (uint256); event RebalanceTriggered( uint256 indexed index, uint256 indexed day, uint256 navSum, uint256 navB, uint256 navROrZero, uint256 ratioB2Q, uint256 ratioR2Q, uint256 ratioBR ); event Settled(uint256 indexed day, uint256 navB, uint256 navR, uint256 interestRate); event InterestRateUpdated(uint256 baseInterestRate, uint256 floatingInterestRate); event BalancesRebalanced( address indexed account, uint256 version, uint256 balanceQ, uint256 balanceB, uint256 balanceR ); event AllowancesRebalanced( address indexed owner, address indexed spender, uint256 version, uint256 allowanceQ, uint256 allowanceB, uint256 allowanceR ); }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.6.10 <0.8.0; import "../interfaces/IFundV3.sol"; interface IStableSwapCore { function getQuoteOut(uint256 baseIn) external view returns (uint256 quoteOut); function getQuoteIn(uint256 baseOut) external view returns (uint256 quoteIn); function getBaseOut(uint256 quoteIn) external view returns (uint256 baseOut); function getBaseIn(uint256 quoteOut) external view returns (uint256 baseIn); function buy( uint256 version, uint256 baseOut, address recipient, bytes calldata data ) external returns (uint256 realBaseOut); function sell( uint256 version, uint256 quoteOut, address recipient, bytes calldata data ) external returns (uint256 realQuoteOut); } interface IStableSwap is IStableSwapCore { function fund() external view returns (IFundV3); function baseTranche() external view returns (uint256); function baseAddress() external view returns (address); function quoteAddress() external view returns (address); function allBalances() external view returns (uint256, uint256); function getOraclePrice() external view returns (uint256); function getCurrentD() external view returns (uint256); function getCurrentPriceOverOracle() external view returns (uint256); function getCurrentPrice() external view returns (uint256); function getPriceOverOracleIntegral() external view returns (uint256); function addLiquidity(uint256 version, address recipient) external returns (uint256); function removeLiquidity( uint256 version, uint256 lpIn, uint256 minBaseOut, uint256 minQuoteOut ) external returns (uint256 baseOut, uint256 quoteOut); function removeLiquidityUnwrap( uint256 version, uint256 lpIn, uint256 minBaseOut, uint256 minQuoteOut ) external returns (uint256 baseOut, uint256 quoteOut); function removeBaseLiquidity( uint256 version, uint256 lpIn, uint256 minBaseOut ) external returns (uint256 baseOut); function removeQuoteLiquidity( uint256 version, uint256 lpIn, uint256 minQuoteOut ) external returns (uint256 quoteOut); function removeQuoteLiquidityUnwrap( uint256 version, uint256 lpIn, uint256 minQuoteOut ) external returns (uint256 quoteOut); } /// @dev The interface shares the same function names as in `IStableSwapCore`; /// all getters are defined as non-view functions in order to parse and /// return the internal revert messages interface IStableSwapCoreInternalRevertExpected { function getQuoteOut(uint256 baseIn) external returns (uint256 quoteOut); function getQuoteIn(uint256 baseOut) external returns (uint256 quoteIn); function getBaseOut(uint256 quoteIn) external returns (uint256 baseOut); function getBaseIn(uint256 quoteOut) external returns (uint256 baseIn); function buy( uint256 version, uint256 baseOut, address recipient, bytes calldata data ) external returns (uint256 realBaseOut); function sell( uint256 version, uint256 quoteOut, address recipient, bytes calldata data ) external returns (uint256 realQuoteOut); }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.6.10 <0.8.0; import "./IStableSwap.sol"; interface ISwapRouter { function getSwap(address baseToken, address quoteToken) external view returns (IStableSwap); function getAmountsOut( uint256 amount, address[] memory path ) external view returns (uint256[] memory amounts, IStableSwap[] memory swaps, bool[] memory isBuy); function getAmountsIn( uint256 amount, address[] memory path ) external view returns (uint256[] memory amounts, IStableSwap[] memory swaps, bool[] memory isBuy); function addLiquidity( address baseToken, address quoteToken, uint256 baseDelta, uint256 quoteDelta, uint256 minMintAmount, uint256 version, uint256 deadline ) external payable; function swapExactTokensForTokens( uint256 amountIn, uint256 minAmountOut, address[] calldata path, address recipient, address staking, uint256[] calldata versions, uint256 deadline ) external payable returns (uint256[] memory amounts); function swapTokensForExactTokens( uint256 amountOut, uint256 maxAmountIn, address[] calldata path, address recipient, address staking, uint256[] calldata versions, uint256 deadline ) external payable returns (uint256[] memory amounts); function swapExactTokensForTokensUnwrap( uint256 amountIn, uint256 minAmountOut, address[] calldata path, address recipient, uint256[] calldata versions, uint256 deadline ) external returns (uint256[] memory amounts); function swapTokensForExactTokensUnwrap( uint256 amountOut, uint256 maxAmountIn, address[] calldata path, address recipient, uint256[] calldata versions, uint256 deadline ) external returns (uint256[] memory amounts); }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.6.10 <0.8.0; /// @notice Amounts of QUEEN, BISHOP and ROOK are sometimes stored in a `uint256[3]` array. /// This contract defines index of each tranche in this array. /// /// Solidity does not allow constants to be defined in interfaces. So this contract follows /// the naming convention of interfaces but is implemented as an `abstract contract`. abstract contract ITrancheIndexV2 { uint256 internal constant TRANCHE_Q = 0; uint256 internal constant TRANCHE_B = 1; uint256 internal constant TRANCHE_R = 2; uint256 internal constant TRANCHE_COUNT = 3; }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.6.10 <0.8.0; interface ITwapOracle { enum UpdateType { PRIMARY, SECONDARY, OWNER, CHAINLINK, UNISWAP_V2 } function getTwap(uint256 timestamp) external view returns (uint256); }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.6.10 <0.8.0; import "./ITwapOracle.sol"; interface ITwapOracleV2 is ITwapOracle { function getLatest() external view returns (uint256); }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.6.10 <0.8.0; pragma experimental ABIEncoderV2; interface IAddressWhitelist { function check(address account) external view returns (bool); } interface IVotingEscrowCallback { function syncWithVotingEscrow(address account) external; } interface IVotingEscrow { struct LockedBalance { uint256 amount; uint256 unlockTime; } function token() external view returns (address); function maxTime() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function totalSupply() external view returns (uint256); function balanceOfAtTimestamp( address account, uint256 timestamp ) external view returns (uint256); function getTimestampDropBelow( address account, uint256 threshold ) external view returns (uint256); function getLockedBalance(address account) external view returns (LockedBalance memory); }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.6.10 <0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IWrappedERC20 is IERC20 { function deposit() external payable; function withdraw(uint256 wad) external; }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.6.10 <0.8.0; interface IWstETH { function stETH() external view returns (address); function stEthPerToken() external view returns (uint256); function getWstETHByStETH(uint256 _stETHAmount) external view returns (uint256); function getStETHByWstETH(uint256 _wstETHAmount) external view returns (uint256); function wrap(uint256 _stETHAmount) external returns (uint256); function unwrap(uint256 _wstETHAmount) external returns (uint256); }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.6.10 <0.8.0; import "@openzeppelin/contracts/math/SafeMath.sol"; abstract contract CoreUtility { using SafeMath for uint256; /// @dev UTC time of a day when the fund settles. uint256 internal constant SETTLEMENT_TIME = 14 hours; /// @dev Return end timestamp of the trading week containing a given timestamp. /// /// A trading week starts at UTC time `SETTLEMENT_TIME` on a Thursday (inclusive) /// and ends at the same time of the next Thursday (exclusive). /// @param timestamp The given timestamp /// @return End timestamp of the trading week. function _endOfWeek(uint256 timestamp) internal pure returns (uint256) { return ((timestamp.add(1 weeks) - SETTLEMENT_TIME) / 1 weeks) * 1 weeks + SETTLEMENT_TIME; } }
// SPDX-License-Identifier: MIT // // Copyright (c) 2019 Synthetix // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. pragma solidity >=0.6.10 <0.8.0; import "@openzeppelin/contracts/math/SafeMath.sol"; library SafeDecimalMath { using SafeMath for uint256; /* Number of decimal places in the representations. */ uint256 private constant decimals = 18; uint256 private constant highPrecisionDecimals = 27; /* The number representing 1.0. */ uint256 private constant UNIT = 10 ** uint256(decimals); /* The number representing 1.0 for higher fidelity numbers. */ uint256 private constant PRECISE_UNIT = 10 ** uint256(highPrecisionDecimals); uint256 private constant UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR = 10 ** uint256(highPrecisionDecimals - decimals); /** * @return The result of multiplying x and y, interpreting the operands as fixed-point * decimals. * * @dev A unit factor is divided out after the product of x and y is evaluated, * so that product must be less than 2**256. As this is an integer division, * the internal division always rounds down. This helps save on gas. Rounding * is more expensive on gas. */ function multiplyDecimal(uint256 x, uint256 y) internal pure returns (uint256) { /* Divide by UNIT to remove the extra factor introduced by the product. */ return x.mul(y).div(UNIT); } function multiplyDecimalPrecise(uint256 x, uint256 y) internal pure returns (uint256) { /* Divide by UNIT to remove the extra factor introduced by the product. */ return x.mul(y).div(PRECISE_UNIT); } /** * @return The result of safely dividing x and y. The return value is a high * precision decimal. * * @dev y is divided after the product of x and the standard precision unit * is evaluated, so the product of x and UNIT must be less than 2**256. As * this is an integer division, the result is always rounded down. * This helps save on gas. Rounding is more expensive on gas. */ function divideDecimal(uint256 x, uint256 y) internal pure returns (uint256) { /* Reintroduce the UNIT factor that will be divided out by y. */ return x.mul(UNIT).div(y); } function divideDecimalPrecise(uint256 x, uint256 y) internal pure returns (uint256) { /* Reintroduce the UNIT factor that will be divided out by y. */ return x.mul(PRECISE_UNIT).div(y); } /** * @dev Convert a standard decimal representation to a high precision one. */ function decimalToPreciseDecimal(uint256 i) internal pure returns (uint256) { return i.mul(UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR); } /** * @dev Convert a high precision decimal to a standard decimal representation. */ function preciseDecimalToDecimal(uint256 i) internal pure returns (uint256) { uint256 quotientTimesTen = i.mul(10).div(UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR); if (quotientTimesTen % 10 >= 5) { quotientTimesTen = quotientTimesTen.add(10); } return quotientTimesTen.div(10); } /** * @dev Returns the multiplication of two unsigned integers, and the max value of * uint256 on overflow. */ function saturatingMul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; return c / a != b ? type(uint256).max : c; } function saturatingMultiplyDecimal(uint256 x, uint256 y) internal pure returns (uint256) { /* Divide by UNIT to remove the extra factor introduced by the product. */ return saturatingMul(x, y).div(UNIT); } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"wstETH_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"addr0","type":"address"},{"indexed":false,"internalType":"address","name":"addr1","type":"address"},{"indexed":false,"internalType":"address","name":"swap","type":"address"}],"name":"SwapAdded","type":"event"},{"inputs":[{"internalType":"address","name":"baseAddress","type":"address"},{"internalType":"address","name":"quoteAddress","type":"address"},{"internalType":"uint256","name":"baseIn","type":"uint256"},{"internalType":"uint256","name":"quoteIn","type":"uint256"},{"internalType":"uint256","name":"minLpOut","type":"uint256"},{"internalType":"uint256","name":"version","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"addLiquidity","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"baseAddress","type":"address"},{"internalType":"address","name":"quoteAddress","type":"address"},{"internalType":"address","name":"swap","type":"address"}],"name":"addSwap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"}],"name":"getAmountsIn","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"contract IStableSwap[]","name":"swaps","type":"address[]"},{"internalType":"bool[]","name":"isBuy","type":"bool[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"}],"name":"getAmountsOut","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"contract IStableSwap[]","name":"swaps","type":"address[]"},{"internalType":"bool[]","name":"isBuy","type":"bool[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"baseAddress","type":"address"},{"internalType":"address","name":"quoteAddress","type":"address"}],"name":"getSwap","outputs":[{"internalType":"contract IStableSwap","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"staking","type":"address"},{"internalType":"uint256[]","name":"versions","type":"uint256[]"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactTokensForTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256[]","name":"versions","type":"uint256[]"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactTokensForTokensUnwrap","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"maxAmountIn","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"staking","type":"address"},{"internalType":"uint256[]","name":"versions","type":"uint256[]"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapTokensForExactTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"maxAmountIn","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256[]","name":"versions","type":"uint256[]"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapTokensForExactTokensUnwrap","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"wstETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60c06040523480156200001157600080fd5b5060405162003a1438038062003a14833981810160405260208110156200003757600080fd5b505160006200004562000139565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506001600160601b0319606082901b166080526001600160a01b038116156200011f57806001600160a01b031663c1fe3e486040518163ffffffff1660e01b815260040160206040518083038186803b158015620000eb57600080fd5b505afa15801562000100573d6000803e3d6000fd5b505050506040513d60208110156200011757600080fd5b505162000122565b60005b60601b6001600160601b03191660a052506200013d565b3390565b60805160601c60a05160601c6138856200018f6000398061101752806112a252806112e75280611311528061272b525080610cae5280611055528061134052806113f3528061147652506138856000f3fe6080604052600436106100e15760003560e01c8063bbe8aade1161007f578063d06ca61f11610059578063d06ca61f1461067f578063ed3332c714610734578063f2fde38b1461076f578063fafcd09e146107a2576100e8565b8063bbe8aade146104a4578063beab724314610587578063c1fe3e481461066a576100e8565b8063715018a6116100bb578063715018a6146102f85780637ae06e581461030d5780638da5cb5b1461035b578063b42b2a5914610370576100e8565b80631f00ca74146100ed5780634aa07e641461028057806365e066fa146102b1576100e8565b366100e857005b600080fd5b3480156100f957600080fd5b506101a26004803603604081101561011057600080fd5b81359190810190604081016020820135600160201b81111561013157600080fd5b82018360208201111561014357600080fd5b803590602001918460208302840111600160201b8311171561016457600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610886945050505050565b60405180806020018060200180602001848103845287818151815260200191508051906020019060200280838360005b838110156101ea5781810151838201526020016101d2565b50505050905001848103835286818151815260200191508051906020019060200280838360005b83811015610229578181015183820152602001610211565b50505050905001848103825285818151815260200191508051906020019060200280838360005b83811015610268578181015183820152602001610250565b50505050905001965050505050505060405180910390f35b34801561028c57600080fd5b50610295610cac565b604080516001600160a01b039092168252519081900360200190f35b3480156102bd57600080fd5b506102f6600480360360608110156102d457600080fd5b506001600160a01b038135811691602081013582169160409091013516610cd0565b005b34801561030457600080fd5b506102f6610efd565b6102f6600480360360e081101561032357600080fd5b506001600160a01b03813581169160208101359091169060408101359060608101359060808101359060a08101359060c00135610fbb565b34801561036757600080fd5b50610295611590565b34801561037c57600080fd5b50610454600480360360c081101561039357600080fd5b813591602081013591810190606081016040820135600160201b8111156103b957600080fd5b8201836020820111156103cb57600080fd5b803590602001918460208302840111600160201b831117156103ec57600080fd5b919390926001600160a01b0383351692604081019060200135600160201b81111561041657600080fd5b82018360208201111561042857600080fd5b803590602001918460208302840111600160201b8311171561044957600080fd5b91935091503561159f565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610490578181015183820152602001610478565b505050509050019250505060405180910390f35b610454600480360360e08110156104ba57600080fd5b813591602081013591810190606081016040820135600160201b8111156104e057600080fd5b8201836020820111156104f257600080fd5b803590602001918460208302840111600160201b8311171561051357600080fd5b919390926001600160a01b0383358116936020810135909116929190606081019060400135600160201b81111561054957600080fd5b82018360208201111561055b57600080fd5b803590602001918460208302840111600160201b8311171561057c57600080fd5b919350915035611ad0565b610454600480360360e081101561059d57600080fd5b813591602081013591810190606081016040820135600160201b8111156105c357600080fd5b8201836020820111156105d557600080fd5b803590602001918460208302840111600160201b831117156105f657600080fd5b919390926001600160a01b0383358116936020810135909116929190606081019060400135600160201b81111561062c57600080fd5b82018360208201111561063e57600080fd5b803590602001918460208302840111600160201b8311171561065f57600080fd5b9193509150356120ed565b34801561067657600080fd5b50610295612729565b34801561068b57600080fd5b506101a2600480360360408110156106a257600080fd5b81359190810190604081016020820135600160201b8111156106c357600080fd5b8201836020820111156106d557600080fd5b803590602001918460208302840111600160201b831117156106f657600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955061274d945050505050565b34801561074057600080fd5b506102956004803603604081101561075757600080fd5b506001600160a01b0381358116916020013516612b49565b34801561077b57600080fd5b506102f66004803603602081101561079257600080fd5b50356001600160a01b0316612ba1565b3480156107ae57600080fd5b50610454600480360360c08110156107c557600080fd5b813591602081013591810190606081016040820135600160201b8111156107eb57600080fd5b8201836020820111156107fd57600080fd5b803590602001918460208302840111600160201b8311171561081e57600080fd5b919390926001600160a01b0383351692604081019060200135600160201b81111561084857600080fd5b82018360208201111561085a57600080fd5b803590602001918460208302840111600160201b8311171561087b57600080fd5b919350915035612cb5565b6060806060835167ffffffffffffffff811180156108a357600080fd5b506040519080825280602002602001820160405280156108cd578160200160208202803683370190505b509250600184510367ffffffffffffffff811180156108eb57600080fd5b50604051908082528060200260200182016040528015610915578160200160208202803683370190505b509150600184510367ffffffffffffffff8111801561093357600080fd5b5060405190808252806020026020018201604052801561095d578160200160208202803683370190505b509050848360018551038151811061097157fe5b60209081029190910101528351600019015b8015610ca4576109bc85600183038151811061099b57fe5b60200260200101518683815181106109af57fe5b6020026020010151612b49565b8360018303815181106109cb57fe5b60200260200101906001600160a01b031690816001600160a01b03168152505060006001600160a01b0316836001830381518110610a0557fe5b60200260200101516001600160a01b03161415610a58576040805162461bcd60e51b815260206004820152600c60248201526b0556e6b6e6f776e20737761760a41b604482015290519081900360640190fd5b826001820381518110610a6757fe5b60200260200101516001600160a01b0316630589a4786040518163ffffffff1660e01b815260040160206040518083038186803b158015610aa757600080fd5b505afa158015610abb573d6000803e3d6000fd5b505050506040513d6020811015610ad157600080fd5b505185516001600160a01b0390911690869083908110610aed57fe5b60200260200101516001600160a01b03161415610be3576001826001830381518110610b1557fe5b602002602001019015159081151581525050826001820381518110610b3657fe5b60200260200101516001600160a01b0316633a66ff97858381518110610b5857fe5b60200260200101516040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610b9457600080fd5b505afa158015610ba8573d6000803e3d6000fd5b505050506040513d6020811015610bbe57600080fd5b5051845185906000198401908110610bd257fe5b602002602001018181525050610c9b565b826001820381518110610bf257fe5b60200260200101516001600160a01b03166395d6abf8858381518110610c1457fe5b60200260200101516040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610c5057600080fd5b505afa158015610c64573d6000803e3d6000fd5b505050506040513d6020811015610c7a57600080fd5b5051845185906000198401908110610c8e57fe5b6020026020010181815250505b60001901610983565b509250925092565b7f000000000000000000000000000000000000000000000000000000000000000081565b610cd86130fe565b6001600160a01b0316610ce9611590565b6001600160a01b031614610d44576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381161580610e435750806001600160a01b0316630589a4786040518163ffffffff1660e01b815260040160206040518083038186803b158015610d8e57600080fd5b505afa158015610da2573d6000803e3d6000fd5b505050506040513d6020811015610db857600080fd5b50516001600160a01b038481169116148015610e435750806001600160a01b031663f0a0b44e6040518163ffffffff1660e01b815260040160206040518083038186803b158015610e0857600080fd5b505afa158015610e1c573d6000803e3d6000fd5b505050506040513d6020811015610e3257600080fd5b50516001600160a01b038381169116145b610e4c57600080fd5b600080836001600160a01b0316856001600160a01b031610610e6f578385610e72565b84845b6001600160a01b038083166000818152600160209081526040808320858716808552908352928190208054958b166001600160a01b0319909616861790558051938452908301919091528181019290925290519294509092507fdd55b8dde666839a1c633616ac6eaca4f388fe87a8672540c47685b634ddbdfa919081900360600190a15050505050565b610f056130fe565b6001600160a01b0316610f16611590565b6001600160a01b031614610f71576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b8080421115611007576040805162461bcd60e51b8152602060048201526013602482015272151c985b9cd858dd1a5bdb881d1bdbc81bdb19606a1b604482015290519081900360640190fd5b60006110138989612b49565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316886001600160a01b0316141561107c57611079897f0000000000000000000000000000000000000000000000000000000000000000612b49565b90505b6001600160a01b0381166110c6576040805162461bcd60e51b815260206004820152600c60248201526b0556e6b6e6f776e20737761760a41b604482015290519081900360640190fd5b806001600160a01b031663b60d42886040518163ffffffff1660e01b815260040160206040518083038186803b1580156110ff57600080fd5b505afa158015611113573d6000803e3d6000fd5b505050506040513d602081101561112957600080fd5b5051604080516369b459e360e01b815290516001600160a01b039283169263c01238d392908516916369b459e391600480820192602092909190829003018186803b15801561117757600080fd5b505afa15801561118b573d6000803e3d6000fd5b505050506040513d60208110156111a157600080fd5b5051604080516001600160e01b031960e085901b16815260048101929092523360248301526001600160a01b0385166044830152606482018b9052608482018890525160a480830192600092919082900301818387803b15801561120457600080fd5b505af1158015611218573d6000803e3d6000fd5b5050505060003411156112a05785341461123157600080fd5b876001600160a01b031663d0e30db0876040518263ffffffff1660e01b81526004016000604051808303818588803b15801561126c57600080fd5b505af1158015611280573d6000803e3d6000fd5b5061129b935050506001600160a01b038a1690508288613102565b6114b2565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316886001600160a01b0316141561149d5761130f6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016333089613159565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b1580156113a657600080fd5b505af11580156113ba573d6000803e3d6000fd5b505050506040513d60208110156113d057600080fd5b505060408051630ea598cb60e41b81526004810188905290516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163ea598cb09160248083019260209291908290030181600087803b15801561143b57600080fd5b505af115801561144f573d6000803e3d6000fd5b505050506040513d602081101561146557600080fd5b5051955061129b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168288613102565b6114b26001600160a01b038916338389613159565b6000816001600160a01b031663c95f9d0e86336040518363ffffffff1660e01b815260040180838152602001826001600160a01b0316815260200192505050602060405180830381600087803b15801561150b57600080fd5b505af115801561151f573d6000803e3d6000fd5b505050506040513d602081101561153557600080fd5b5051905085811015611584576040805162461bcd60e51b8152602060048201526013602482015272125b9cdd59999a58da595b9d081bdd5d1c1d5d606a1b604482015290519081900360640190fd5b50505050505050505050565b6000546001600160a01b031690565b606081804211156115ed576040805162461bcd60e51b8152602060048201526013602482015272151c985b9cd858dd1a5bdb881d1bdbc81bdb19606a1b604482015290519081900360640190fd5b6002871015611632576040805162461bcd60e51b815260206004820152600c60248201526b092dcecc2d8d2c840e0c2e8d60a31b604482015290519081900360640190fd5b6000198701841461167d576040805162461bcd60e51b815260206004820152601060248201526f496e76616c69642076657273696f6e7360801b604482015290519081900360640190fd5b6060806116bd8c8b8b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061274d92505050565b825192965090935091508b90859060001981019081106116d957fe5b6020026020010151101561172a576040805162461bcd60e51b8152602060048201526013602482015272125b9cdd59999a58da595b9d081bdd5d1c1d5d606a1b604482015290519081900360640190fd5b8060008151811061173757fe5b6020026020010151156117ad576117a8338360008151811061175557fe5b60200260200101518660008151811061176a57fe5b60200260200101518d8d600081811061177f57fe5b905060200201356001600160a01b03166001600160a01b0316613159909392919063ffffffff16565b61196e565b816000815181106117ba57fe5b60200260200101516001600160a01b031663b60d42886040518163ffffffff1660e01b815260040160206040518083038186803b1580156117fa57600080fd5b505afa15801561180e573d6000803e3d6000fd5b505050506040513d602081101561182457600080fd5b505182516001600160a01b039091169063c01238d390849060009061184557fe5b60200260200101516001600160a01b03166369b459e36040518163ffffffff1660e01b815260040160206040518083038186803b15801561188557600080fd5b505afa158015611899573d6000803e3d6000fd5b505050506040513d60208110156118af57600080fd5b50518451339086906000906118c057fe5b6020026020010151886000815181106118d557fe5b60200260200101518c8c60008181106118ea57fe5b905060200201356040518663ffffffff1660e01b815260040180868152602001856001600160a01b03168152602001846001600160a01b0316815260200183815260200182815260200195505050505050600060405180830381600087803b15801561195557600080fd5b505af1158015611969573d6000803e3d6000fd5b505050505b61197c8483838a8a306131b9565b8989600019810181811061198c57fe5b905060200201356001600160a01b03166001600160a01b0316632e1a7d4d856001875103815181106119ba57fe5b60200260200101516040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156119f857600080fd5b505af1158015611a0c573d6000803e3d6000fd5b505050506000886001600160a01b031685600187510381518110611a2c57fe5b6020908102919091010151604051600081818185875af1925050503d8060008114611a73576040519150601f19603f3d011682016040523d82523d6000602084013e611a78565b606091505b5050905080611ac0576040805162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b5050505098975050505050505050565b60608180421115611b1e576040805162461bcd60e51b8152602060048201526013602482015272151c985b9cd858dd1a5bdb881d1bdbc81bdb19606a1b604482015290519081900360640190fd5b6002881015611b63576040805162461bcd60e51b815260206004820152600c60248201526b092dcecc2d8d2c840e0c2e8d60a31b604482015290519081900360640190fd5b60001988018414611bae576040805162461bcd60e51b815260206004820152601060248201526f496e76616c69642076657273696f6e7360801b604482015290519081900360640190fd5b606080611bee8d8c8c8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061274d92505050565b825192965090935091508c9085906000198101908110611c0a57fe5b60200260200101511015611c5b576040805162461bcd60e51b8152602060048201526013602482015272125b9cdd59999a58da595b9d081bdd5d1c1d5d606a1b604482015290519081900360640190fd5b3415611d6c5783600081518110611c6e57fe5b60200260200101513414611c8157600080fd5b8a8a6000818110611c8e57fe5b905060200201356001600160a01b03166001600160a01b031663d0e30db085600081518110611cb957fe5b60200260200101516040518263ffffffff1660e01b81526004016000604051808303818588803b158015611cec57600080fd5b505af1158015611d00573d6000803e3d6000fd5b5050505050611d6782600081518110611d1557fe5b602002602001015185600081518110611d2a57fe5b60200260200101518d8d6000818110611d3f57fe5b905060200201356001600160a01b03166001600160a01b03166131029092919063ffffffff16565b611f82565b80600081518110611d7957fe5b602002602001015115611dc157611d673383600081518110611d9757fe5b602002602001015186600081518110611dac57fe5b60200260200101518e8e600081811061177f57fe5b81600081518110611dce57fe5b60200260200101516001600160a01b031663b60d42886040518163ffffffff1660e01b815260040160206040518083038186803b158015611e0e57600080fd5b505afa158015611e22573d6000803e3d6000fd5b505050506040513d6020811015611e3857600080fd5b505182516001600160a01b039091169063c01238d3908490600090611e5957fe5b60200260200101516001600160a01b03166369b459e36040518163ffffffff1660e01b815260040160206040518083038186803b158015611e9957600080fd5b505afa158015611ead573d6000803e3d6000fd5b505050506040513d6020811015611ec357600080fd5b5051845133908690600090611ed457fe5b602002602001015188600081518110611ee957fe5b60200260200101518c8c6000818110611efe57fe5b905060200201356040518663ffffffff1660e01b815260040180868152602001856001600160a01b03168152602001846001600160a01b0316815260200183815260200182815260200195505050505050600060405180830381600087803b158015611f6957600080fd5b505af1158015611f7d573d6000803e3d6000fd5b505050505b6001600160a01b038816611fa357611f9e8483838a8a8e6131b9565b6120dd565b611fb18483838a8a8d6131b9565b876001600160a01b031663e78f094983600185510381518110611fd057fe5b60200260200101516001600160a01b03166369b459e36040518163ffffffff1660e01b815260040160206040518083038186803b15801561201057600080fd5b505afa158015612024573d6000803e3d6000fd5b505050506040513d602081101561203a57600080fd5b505186518790600019810190811061204e57fe5b60200260200101518c8b8b60018e8e90500381811061206957fe5b905060200201356040518563ffffffff1660e01b815260040180858152602001848152602001836001600160a01b03168152602001828152602001945050505050600060405180830381600087803b1580156120c457600080fd5b505af11580156120d8573d6000803e3d6000fd5b505050505b5050509998505050505050505050565b6060818042111561213b576040805162461bcd60e51b8152602060048201526013602482015272151c985b9cd858dd1a5bdb881d1bdbc81bdb19606a1b604482015290519081900360640190fd5b6002881015612180576040805162461bcd60e51b815260206004820152600c60248201526b092dcecc2d8d2c840e0c2e8d60a31b604482015290519081900360640190fd5b600019880184146121cb576040805162461bcd60e51b815260206004820152601060248201526f496e76616c69642076657273696f6e7360801b604482015290519081900360640190fd5b60608061220b8d8c8c8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061088692505050565b825192965090935091508c90859060009061222257fe5b6020026020010151111561226f576040805162461bcd60e51b815260206004820152600f60248201526e115e18d95cdcda5d99481a5b9c1d5d608a1b604482015290519081900360640190fd5b341561231a578b341461228157600080fd5b8a8a600081811061228e57fe5b905060200201356001600160a01b03166001600160a01b031663d0e30db0856000815181106122b957fe5b60200260200101516040518263ffffffff1660e01b81526004016000604051808303818588803b1580156122ec57600080fd5b505af1158015612300573d6000803e3d6000fd5b505050505061231582600081518110611d1557fe5b612506565b8060008151811061232757fe5b602002602001015115612345576123153383600081518110611d9757fe5b8160008151811061235257fe5b60200260200101516001600160a01b031663b60d42886040518163ffffffff1660e01b815260040160206040518083038186803b15801561239257600080fd5b505afa1580156123a6573d6000803e3d6000fd5b505050506040513d60208110156123bc57600080fd5b505182516001600160a01b039091169063c01238d39084906000906123dd57fe5b60200260200101516001600160a01b03166369b459e36040518163ffffffff1660e01b815260040160206040518083038186803b15801561241d57600080fd5b505afa158015612431573d6000803e3d6000fd5b505050506040513d602081101561244757600080fd5b505184513390869060009061245857fe5b60200260200101518860008151811061246d57fe5b60200260200101518c8c600081811061248257fe5b905060200201356040518663ffffffff1660e01b815260040180868152602001856001600160a01b03168152602001846001600160a01b0316815260200183815260200182815260200195505050505050600060405180830381600087803b1580156124ed57600080fd5b505af1158015612501573d6000803e3d6000fd5b505050505b6001600160a01b038816612527576125228483838a8a8e6131b9565b612646565b6125358483838a8a8d6131b9565b876001600160a01b031663e78f09498360018551038151811061255457fe5b60200260200101516001600160a01b03166369b459e36040518163ffffffff1660e01b815260040160206040518083038186803b15801561259457600080fd5b505afa1580156125a8573d6000803e3d6000fd5b505050506040513d60208110156125be57600080fd5b50518f8c8b8b60001981018181106125d257fe5b905060200201356040518563ffffffff1660e01b815260040180858152602001848152602001836001600160a01b03168152602001828152602001945050505050600060405180830381600087803b15801561262d57600080fd5b505af1158015612641573d6000803e3d6000fd5b505050505b8360008151811061265357fe5b60200260200101513411156120dd576000336001600160a01b03168560008151811061267b57fe5b6020026020010151340360405180600001905060006040518083038185875af1925050503d80600081146126cb576040519150601f19603f3d011682016040523d82523d6000602084013e6126d0565b606091505b5050905080612718576040805162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b505050509998505050505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6060806060835167ffffffffffffffff8111801561276a57600080fd5b50604051908082528060200260200182016040528015612794578160200160208202803683370190505b509250600184510367ffffffffffffffff811180156127b257600080fd5b506040519080825280602002602001820160405280156127dc578160200160208202803683370190505b509150600184510367ffffffffffffffff811180156127fa57600080fd5b50604051908082528060200260200182016040528015612824578160200160208202803683370190505b509050848360008151811061283557fe5b60200260200101818152505060005b6001855103811015610ca45761287685828151811061285f57fe5b60200260200101518683600101815181106109af57fe5b83828151811061288257fe5b60200260200101906001600160a01b031690816001600160a01b03168152505060006001600160a01b03168382815181106128b957fe5b60200260200101516001600160a01b0316141561290c576040805162461bcd60e51b815260206004820152600c60248201526b0556e6b6e6f776e20737761760a41b604482015290519081900360640190fd5b82818151811061291857fe5b60200260200101516001600160a01b0316630589a4786040518163ffffffff1660e01b815260040160206040518083038186803b15801561295857600080fd5b505afa15801561296c573d6000803e3d6000fd5b505050506040513d602081101561298257600080fd5b505185516001600160a01b039091169086908390811061299e57fe5b60200260200101516001600160a01b03161415612a6d578281815181106129c157fe5b60200260200101516001600160a01b0316637b31ae648583815181106129e357fe5b60200260200101516040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015612a1f57600080fd5b505afa158015612a33573d6000803e3d6000fd5b505050506040513d6020811015612a4957600080fd5b50518451859060018401908110612a5c57fe5b602002602001018181525050612b41565b6001828281518110612a7b57fe5b602002602001019015159081151581525050828181518110612a9957fe5b60200260200101516001600160a01b031663e6d7059a858381518110612abb57fe5b60200260200101516040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015612af757600080fd5b505afa158015612b0b573d6000803e3d6000fd5b505050506040513d6020811015612b2157600080fd5b50518451859060018401908110612b3457fe5b6020026020010181815250505b600101612844565b6000806000836001600160a01b0316856001600160a01b031610612b6e578385612b71565b84845b6001600160a01b039182166000908152600160209081526040808320938516835292905220541695945050505050565b612ba96130fe565b6001600160a01b0316612bba611590565b6001600160a01b031614612c15576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116612c5a5760405162461bcd60e51b81526004018080602001828103825260268152602001806137da6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60608180421115612d03576040805162461bcd60e51b8152602060048201526013602482015272151c985b9cd858dd1a5bdb881d1bdbc81bdb19606a1b604482015290519081900360640190fd5b6002871015612d48576040805162461bcd60e51b815260206004820152600c60248201526b092dcecc2d8d2c840e0c2e8d60a31b604482015290519081900360640190fd5b60001987018414612d93576040805162461bcd60e51b815260206004820152601060248201526f496e76616c69642076657273696f6e7360801b604482015290519081900360640190fd5b606080612dd38c8b8b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061088692505050565b825192965090935091508b908590600090612dea57fe5b60200260200101511115612e37576040805162461bcd60e51b815260206004820152600f60248201526e115e18d95cdcda5d99481a5b9c1d5d608a1b604482015290519081900360640190fd5b80600081518110612e4457fe5b602002602001015115612e6757612e62338360008151811061175557fe5b613028565b81600081518110612e7457fe5b60200260200101516001600160a01b031663b60d42886040518163ffffffff1660e01b815260040160206040518083038186803b158015612eb457600080fd5b505afa158015612ec8573d6000803e3d6000fd5b505050506040513d6020811015612ede57600080fd5b505182516001600160a01b039091169063c01238d3908490600090612eff57fe5b60200260200101516001600160a01b03166369b459e36040518163ffffffff1660e01b815260040160206040518083038186803b158015612f3f57600080fd5b505afa158015612f53573d6000803e3d6000fd5b505050506040513d6020811015612f6957600080fd5b5051845133908690600090612f7a57fe5b602002602001015188600081518110612f8f57fe5b60200260200101518c8c6000818110612fa457fe5b905060200201356040518663ffffffff1660e01b815260040180868152602001856001600160a01b03168152602001846001600160a01b0316815260200183815260200182815260200195505050505050600060405180830381600087803b15801561300f57600080fd5b505af1158015613023573d6000803e3d6000fd5b505050505b6130368483838a8a306131b9565b8989600019810181811061304657fe5b905060200201356001600160a01b03166001600160a01b0316632e1a7d4d8d6040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561309b57600080fd5b505af11580156130af573d6000803e3d6000fd5b5050604051600092506001600160a01b038b1691508e908381818185875af1925050503d8060008114611a73576040519150601f19603f3d011682016040523d82523d6000602084013e611a78565b3390565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052613154908490613509565b505050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526131b3908590613509565b50505050565b60005b8551811015613500576000600187510382106131d857826131f0565b8682600101815181106131e757fe5b60200260200101515b90508582815181106131fe57fe5b60200260200101516133835786828151811061321657fe5b60200260200101516001600160a01b0316631033e4cd86868581811061323857fe5b905060200201358a856001018151811061324e57fe5b602002602001015184600067ffffffffffffffff8111801561326f57600080fd5b506040519080825280601f01601f19166020018201604052801561329a576020820181803683370190505b506040518563ffffffff1660e01b815260040180858152602001848152602001836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b838110156133025781810151838201526020016132ea565b50505050905090810190601f16801561332f5780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b15801561335157600080fd5b505af1158015613365573d6000803e3d6000fd5b505050506040513d602081101561337b57600080fd5b506134f79050565b86828151811061338f57fe5b60200260200101516001600160a01b0316639000ff098686858181106133b157fe5b905060200201358a85600101815181106133c757fe5b602002602001015184600067ffffffffffffffff811180156133e857600080fd5b506040519080825280601f01601f191660200182016040528015613413576020820181803683370190505b506040518563ffffffff1660e01b815260040180858152602001848152602001836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561347b578181015183820152602001613463565b50505050905090810190601f1680156134a85780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b1580156134ca57600080fd5b505af11580156134de573d6000803e3d6000fd5b505050506040513d60208110156134f457600080fd5b50505b506001016131bc565b50505050505050565b606061355e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166135ba9092919063ffffffff16565b8051909150156131545780806020019051602081101561357d57600080fd5b50516131545760405162461bcd60e51b815260040180806020018281038252602a815260200180613826602a913960400191505060405180910390fd5b60606135c984846000856135d3565b90505b9392505050565b6060824710156136145760405162461bcd60e51b81526004018080602001828103825260268152602001806138006026913960400191505060405180910390fd5b61361d8561372f565b61366e576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106136ad5780518252601f19909201916020918201910161368e565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461370f576040519150601f19603f3d011682016040523d82523d6000602084013e613714565b606091505b5091509150613724828286613735565b979650505050505050565b3b151590565b606083156137445750816135cc565b8251156137545782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561379e578181015183820152602001613786565b50505050905090810190601f1680156137cb5780820380516001836020036101000a031916815260200191505b509250505060405180910390fdfe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a26469706673582212209ba69bd16bb8ca35ba22d6539b47609a83bb2e6e47272c63b45564ab26a374e964736f6c634300060c00330000000000000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x6080604052600436106100e15760003560e01c8063bbe8aade1161007f578063d06ca61f11610059578063d06ca61f1461067f578063ed3332c714610734578063f2fde38b1461076f578063fafcd09e146107a2576100e8565b8063bbe8aade146104a4578063beab724314610587578063c1fe3e481461066a576100e8565b8063715018a6116100bb578063715018a6146102f85780637ae06e581461030d5780638da5cb5b1461035b578063b42b2a5914610370576100e8565b80631f00ca74146100ed5780634aa07e641461028057806365e066fa146102b1576100e8565b366100e857005b600080fd5b3480156100f957600080fd5b506101a26004803603604081101561011057600080fd5b81359190810190604081016020820135600160201b81111561013157600080fd5b82018360208201111561014357600080fd5b803590602001918460208302840111600160201b8311171561016457600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610886945050505050565b60405180806020018060200180602001848103845287818151815260200191508051906020019060200280838360005b838110156101ea5781810151838201526020016101d2565b50505050905001848103835286818151815260200191508051906020019060200280838360005b83811015610229578181015183820152602001610211565b50505050905001848103825285818151815260200191508051906020019060200280838360005b83811015610268578181015183820152602001610250565b50505050905001965050505050505060405180910390f35b34801561028c57600080fd5b50610295610cac565b604080516001600160a01b039092168252519081900360200190f35b3480156102bd57600080fd5b506102f6600480360360608110156102d457600080fd5b506001600160a01b038135811691602081013582169160409091013516610cd0565b005b34801561030457600080fd5b506102f6610efd565b6102f6600480360360e081101561032357600080fd5b506001600160a01b03813581169160208101359091169060408101359060608101359060808101359060a08101359060c00135610fbb565b34801561036757600080fd5b50610295611590565b34801561037c57600080fd5b50610454600480360360c081101561039357600080fd5b813591602081013591810190606081016040820135600160201b8111156103b957600080fd5b8201836020820111156103cb57600080fd5b803590602001918460208302840111600160201b831117156103ec57600080fd5b919390926001600160a01b0383351692604081019060200135600160201b81111561041657600080fd5b82018360208201111561042857600080fd5b803590602001918460208302840111600160201b8311171561044957600080fd5b91935091503561159f565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610490578181015183820152602001610478565b505050509050019250505060405180910390f35b610454600480360360e08110156104ba57600080fd5b813591602081013591810190606081016040820135600160201b8111156104e057600080fd5b8201836020820111156104f257600080fd5b803590602001918460208302840111600160201b8311171561051357600080fd5b919390926001600160a01b0383358116936020810135909116929190606081019060400135600160201b81111561054957600080fd5b82018360208201111561055b57600080fd5b803590602001918460208302840111600160201b8311171561057c57600080fd5b919350915035611ad0565b610454600480360360e081101561059d57600080fd5b813591602081013591810190606081016040820135600160201b8111156105c357600080fd5b8201836020820111156105d557600080fd5b803590602001918460208302840111600160201b831117156105f657600080fd5b919390926001600160a01b0383358116936020810135909116929190606081019060400135600160201b81111561062c57600080fd5b82018360208201111561063e57600080fd5b803590602001918460208302840111600160201b8311171561065f57600080fd5b9193509150356120ed565b34801561067657600080fd5b50610295612729565b34801561068b57600080fd5b506101a2600480360360408110156106a257600080fd5b81359190810190604081016020820135600160201b8111156106c357600080fd5b8201836020820111156106d557600080fd5b803590602001918460208302840111600160201b831117156106f657600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955061274d945050505050565b34801561074057600080fd5b506102956004803603604081101561075757600080fd5b506001600160a01b0381358116916020013516612b49565b34801561077b57600080fd5b506102f66004803603602081101561079257600080fd5b50356001600160a01b0316612ba1565b3480156107ae57600080fd5b50610454600480360360c08110156107c557600080fd5b813591602081013591810190606081016040820135600160201b8111156107eb57600080fd5b8201836020820111156107fd57600080fd5b803590602001918460208302840111600160201b8311171561081e57600080fd5b919390926001600160a01b0383351692604081019060200135600160201b81111561084857600080fd5b82018360208201111561085a57600080fd5b803590602001918460208302840111600160201b8311171561087b57600080fd5b919350915035612cb5565b6060806060835167ffffffffffffffff811180156108a357600080fd5b506040519080825280602002602001820160405280156108cd578160200160208202803683370190505b509250600184510367ffffffffffffffff811180156108eb57600080fd5b50604051908082528060200260200182016040528015610915578160200160208202803683370190505b509150600184510367ffffffffffffffff8111801561093357600080fd5b5060405190808252806020026020018201604052801561095d578160200160208202803683370190505b509050848360018551038151811061097157fe5b60209081029190910101528351600019015b8015610ca4576109bc85600183038151811061099b57fe5b60200260200101518683815181106109af57fe5b6020026020010151612b49565b8360018303815181106109cb57fe5b60200260200101906001600160a01b031690816001600160a01b03168152505060006001600160a01b0316836001830381518110610a0557fe5b60200260200101516001600160a01b03161415610a58576040805162461bcd60e51b815260206004820152600c60248201526b0556e6b6e6f776e20737761760a41b604482015290519081900360640190fd5b826001820381518110610a6757fe5b60200260200101516001600160a01b0316630589a4786040518163ffffffff1660e01b815260040160206040518083038186803b158015610aa757600080fd5b505afa158015610abb573d6000803e3d6000fd5b505050506040513d6020811015610ad157600080fd5b505185516001600160a01b0390911690869083908110610aed57fe5b60200260200101516001600160a01b03161415610be3576001826001830381518110610b1557fe5b602002602001019015159081151581525050826001820381518110610b3657fe5b60200260200101516001600160a01b0316633a66ff97858381518110610b5857fe5b60200260200101516040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610b9457600080fd5b505afa158015610ba8573d6000803e3d6000fd5b505050506040513d6020811015610bbe57600080fd5b5051845185906000198401908110610bd257fe5b602002602001018181525050610c9b565b826001820381518110610bf257fe5b60200260200101516001600160a01b03166395d6abf8858381518110610c1457fe5b60200260200101516040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610c5057600080fd5b505afa158015610c64573d6000803e3d6000fd5b505050506040513d6020811015610c7a57600080fd5b5051845185906000198401908110610c8e57fe5b6020026020010181815250505b60001901610983565b509250925092565b7f000000000000000000000000000000000000000000000000000000000000000081565b610cd86130fe565b6001600160a01b0316610ce9611590565b6001600160a01b031614610d44576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381161580610e435750806001600160a01b0316630589a4786040518163ffffffff1660e01b815260040160206040518083038186803b158015610d8e57600080fd5b505afa158015610da2573d6000803e3d6000fd5b505050506040513d6020811015610db857600080fd5b50516001600160a01b038481169116148015610e435750806001600160a01b031663f0a0b44e6040518163ffffffff1660e01b815260040160206040518083038186803b158015610e0857600080fd5b505afa158015610e1c573d6000803e3d6000fd5b505050506040513d6020811015610e3257600080fd5b50516001600160a01b038381169116145b610e4c57600080fd5b600080836001600160a01b0316856001600160a01b031610610e6f578385610e72565b84845b6001600160a01b038083166000818152600160209081526040808320858716808552908352928190208054958b166001600160a01b0319909616861790558051938452908301919091528181019290925290519294509092507fdd55b8dde666839a1c633616ac6eaca4f388fe87a8672540c47685b634ddbdfa919081900360600190a15050505050565b610f056130fe565b6001600160a01b0316610f16611590565b6001600160a01b031614610f71576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b8080421115611007576040805162461bcd60e51b8152602060048201526013602482015272151c985b9cd858dd1a5bdb881d1bdbc81bdb19606a1b604482015290519081900360640190fd5b60006110138989612b49565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316886001600160a01b0316141561107c57611079897f0000000000000000000000000000000000000000000000000000000000000000612b49565b90505b6001600160a01b0381166110c6576040805162461bcd60e51b815260206004820152600c60248201526b0556e6b6e6f776e20737761760a41b604482015290519081900360640190fd5b806001600160a01b031663b60d42886040518163ffffffff1660e01b815260040160206040518083038186803b1580156110ff57600080fd5b505afa158015611113573d6000803e3d6000fd5b505050506040513d602081101561112957600080fd5b5051604080516369b459e360e01b815290516001600160a01b039283169263c01238d392908516916369b459e391600480820192602092909190829003018186803b15801561117757600080fd5b505afa15801561118b573d6000803e3d6000fd5b505050506040513d60208110156111a157600080fd5b5051604080516001600160e01b031960e085901b16815260048101929092523360248301526001600160a01b0385166044830152606482018b9052608482018890525160a480830192600092919082900301818387803b15801561120457600080fd5b505af1158015611218573d6000803e3d6000fd5b5050505060003411156112a05785341461123157600080fd5b876001600160a01b031663d0e30db0876040518263ffffffff1660e01b81526004016000604051808303818588803b15801561126c57600080fd5b505af1158015611280573d6000803e3d6000fd5b5061129b935050506001600160a01b038a1690508288613102565b6114b2565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316886001600160a01b0316141561149d5761130f6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016333089613159565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b1580156113a657600080fd5b505af11580156113ba573d6000803e3d6000fd5b505050506040513d60208110156113d057600080fd5b505060408051630ea598cb60e41b81526004810188905290516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163ea598cb09160248083019260209291908290030181600087803b15801561143b57600080fd5b505af115801561144f573d6000803e3d6000fd5b505050506040513d602081101561146557600080fd5b5051955061129b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168288613102565b6114b26001600160a01b038916338389613159565b6000816001600160a01b031663c95f9d0e86336040518363ffffffff1660e01b815260040180838152602001826001600160a01b0316815260200192505050602060405180830381600087803b15801561150b57600080fd5b505af115801561151f573d6000803e3d6000fd5b505050506040513d602081101561153557600080fd5b5051905085811015611584576040805162461bcd60e51b8152602060048201526013602482015272125b9cdd59999a58da595b9d081bdd5d1c1d5d606a1b604482015290519081900360640190fd5b50505050505050505050565b6000546001600160a01b031690565b606081804211156115ed576040805162461bcd60e51b8152602060048201526013602482015272151c985b9cd858dd1a5bdb881d1bdbc81bdb19606a1b604482015290519081900360640190fd5b6002871015611632576040805162461bcd60e51b815260206004820152600c60248201526b092dcecc2d8d2c840e0c2e8d60a31b604482015290519081900360640190fd5b6000198701841461167d576040805162461bcd60e51b815260206004820152601060248201526f496e76616c69642076657273696f6e7360801b604482015290519081900360640190fd5b6060806116bd8c8b8b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061274d92505050565b825192965090935091508b90859060001981019081106116d957fe5b6020026020010151101561172a576040805162461bcd60e51b8152602060048201526013602482015272125b9cdd59999a58da595b9d081bdd5d1c1d5d606a1b604482015290519081900360640190fd5b8060008151811061173757fe5b6020026020010151156117ad576117a8338360008151811061175557fe5b60200260200101518660008151811061176a57fe5b60200260200101518d8d600081811061177f57fe5b905060200201356001600160a01b03166001600160a01b0316613159909392919063ffffffff16565b61196e565b816000815181106117ba57fe5b60200260200101516001600160a01b031663b60d42886040518163ffffffff1660e01b815260040160206040518083038186803b1580156117fa57600080fd5b505afa15801561180e573d6000803e3d6000fd5b505050506040513d602081101561182457600080fd5b505182516001600160a01b039091169063c01238d390849060009061184557fe5b60200260200101516001600160a01b03166369b459e36040518163ffffffff1660e01b815260040160206040518083038186803b15801561188557600080fd5b505afa158015611899573d6000803e3d6000fd5b505050506040513d60208110156118af57600080fd5b50518451339086906000906118c057fe5b6020026020010151886000815181106118d557fe5b60200260200101518c8c60008181106118ea57fe5b905060200201356040518663ffffffff1660e01b815260040180868152602001856001600160a01b03168152602001846001600160a01b0316815260200183815260200182815260200195505050505050600060405180830381600087803b15801561195557600080fd5b505af1158015611969573d6000803e3d6000fd5b505050505b61197c8483838a8a306131b9565b8989600019810181811061198c57fe5b905060200201356001600160a01b03166001600160a01b0316632e1a7d4d856001875103815181106119ba57fe5b60200260200101516040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156119f857600080fd5b505af1158015611a0c573d6000803e3d6000fd5b505050506000886001600160a01b031685600187510381518110611a2c57fe5b6020908102919091010151604051600081818185875af1925050503d8060008114611a73576040519150601f19603f3d011682016040523d82523d6000602084013e611a78565b606091505b5050905080611ac0576040805162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b5050505098975050505050505050565b60608180421115611b1e576040805162461bcd60e51b8152602060048201526013602482015272151c985b9cd858dd1a5bdb881d1bdbc81bdb19606a1b604482015290519081900360640190fd5b6002881015611b63576040805162461bcd60e51b815260206004820152600c60248201526b092dcecc2d8d2c840e0c2e8d60a31b604482015290519081900360640190fd5b60001988018414611bae576040805162461bcd60e51b815260206004820152601060248201526f496e76616c69642076657273696f6e7360801b604482015290519081900360640190fd5b606080611bee8d8c8c8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061274d92505050565b825192965090935091508c9085906000198101908110611c0a57fe5b60200260200101511015611c5b576040805162461bcd60e51b8152602060048201526013602482015272125b9cdd59999a58da595b9d081bdd5d1c1d5d606a1b604482015290519081900360640190fd5b3415611d6c5783600081518110611c6e57fe5b60200260200101513414611c8157600080fd5b8a8a6000818110611c8e57fe5b905060200201356001600160a01b03166001600160a01b031663d0e30db085600081518110611cb957fe5b60200260200101516040518263ffffffff1660e01b81526004016000604051808303818588803b158015611cec57600080fd5b505af1158015611d00573d6000803e3d6000fd5b5050505050611d6782600081518110611d1557fe5b602002602001015185600081518110611d2a57fe5b60200260200101518d8d6000818110611d3f57fe5b905060200201356001600160a01b03166001600160a01b03166131029092919063ffffffff16565b611f82565b80600081518110611d7957fe5b602002602001015115611dc157611d673383600081518110611d9757fe5b602002602001015186600081518110611dac57fe5b60200260200101518e8e600081811061177f57fe5b81600081518110611dce57fe5b60200260200101516001600160a01b031663b60d42886040518163ffffffff1660e01b815260040160206040518083038186803b158015611e0e57600080fd5b505afa158015611e22573d6000803e3d6000fd5b505050506040513d6020811015611e3857600080fd5b505182516001600160a01b039091169063c01238d3908490600090611e5957fe5b60200260200101516001600160a01b03166369b459e36040518163ffffffff1660e01b815260040160206040518083038186803b158015611e9957600080fd5b505afa158015611ead573d6000803e3d6000fd5b505050506040513d6020811015611ec357600080fd5b5051845133908690600090611ed457fe5b602002602001015188600081518110611ee957fe5b60200260200101518c8c6000818110611efe57fe5b905060200201356040518663ffffffff1660e01b815260040180868152602001856001600160a01b03168152602001846001600160a01b0316815260200183815260200182815260200195505050505050600060405180830381600087803b158015611f6957600080fd5b505af1158015611f7d573d6000803e3d6000fd5b505050505b6001600160a01b038816611fa357611f9e8483838a8a8e6131b9565b6120dd565b611fb18483838a8a8d6131b9565b876001600160a01b031663e78f094983600185510381518110611fd057fe5b60200260200101516001600160a01b03166369b459e36040518163ffffffff1660e01b815260040160206040518083038186803b15801561201057600080fd5b505afa158015612024573d6000803e3d6000fd5b505050506040513d602081101561203a57600080fd5b505186518790600019810190811061204e57fe5b60200260200101518c8b8b60018e8e90500381811061206957fe5b905060200201356040518563ffffffff1660e01b815260040180858152602001848152602001836001600160a01b03168152602001828152602001945050505050600060405180830381600087803b1580156120c457600080fd5b505af11580156120d8573d6000803e3d6000fd5b505050505b5050509998505050505050505050565b6060818042111561213b576040805162461bcd60e51b8152602060048201526013602482015272151c985b9cd858dd1a5bdb881d1bdbc81bdb19606a1b604482015290519081900360640190fd5b6002881015612180576040805162461bcd60e51b815260206004820152600c60248201526b092dcecc2d8d2c840e0c2e8d60a31b604482015290519081900360640190fd5b600019880184146121cb576040805162461bcd60e51b815260206004820152601060248201526f496e76616c69642076657273696f6e7360801b604482015290519081900360640190fd5b60608061220b8d8c8c8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061088692505050565b825192965090935091508c90859060009061222257fe5b6020026020010151111561226f576040805162461bcd60e51b815260206004820152600f60248201526e115e18d95cdcda5d99481a5b9c1d5d608a1b604482015290519081900360640190fd5b341561231a578b341461228157600080fd5b8a8a600081811061228e57fe5b905060200201356001600160a01b03166001600160a01b031663d0e30db0856000815181106122b957fe5b60200260200101516040518263ffffffff1660e01b81526004016000604051808303818588803b1580156122ec57600080fd5b505af1158015612300573d6000803e3d6000fd5b505050505061231582600081518110611d1557fe5b612506565b8060008151811061232757fe5b602002602001015115612345576123153383600081518110611d9757fe5b8160008151811061235257fe5b60200260200101516001600160a01b031663b60d42886040518163ffffffff1660e01b815260040160206040518083038186803b15801561239257600080fd5b505afa1580156123a6573d6000803e3d6000fd5b505050506040513d60208110156123bc57600080fd5b505182516001600160a01b039091169063c01238d39084906000906123dd57fe5b60200260200101516001600160a01b03166369b459e36040518163ffffffff1660e01b815260040160206040518083038186803b15801561241d57600080fd5b505afa158015612431573d6000803e3d6000fd5b505050506040513d602081101561244757600080fd5b505184513390869060009061245857fe5b60200260200101518860008151811061246d57fe5b60200260200101518c8c600081811061248257fe5b905060200201356040518663ffffffff1660e01b815260040180868152602001856001600160a01b03168152602001846001600160a01b0316815260200183815260200182815260200195505050505050600060405180830381600087803b1580156124ed57600080fd5b505af1158015612501573d6000803e3d6000fd5b505050505b6001600160a01b038816612527576125228483838a8a8e6131b9565b612646565b6125358483838a8a8d6131b9565b876001600160a01b031663e78f09498360018551038151811061255457fe5b60200260200101516001600160a01b03166369b459e36040518163ffffffff1660e01b815260040160206040518083038186803b15801561259457600080fd5b505afa1580156125a8573d6000803e3d6000fd5b505050506040513d60208110156125be57600080fd5b50518f8c8b8b60001981018181106125d257fe5b905060200201356040518563ffffffff1660e01b815260040180858152602001848152602001836001600160a01b03168152602001828152602001945050505050600060405180830381600087803b15801561262d57600080fd5b505af1158015612641573d6000803e3d6000fd5b505050505b8360008151811061265357fe5b60200260200101513411156120dd576000336001600160a01b03168560008151811061267b57fe5b6020026020010151340360405180600001905060006040518083038185875af1925050503d80600081146126cb576040519150601f19603f3d011682016040523d82523d6000602084013e6126d0565b606091505b5050905080612718576040805162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b505050509998505050505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6060806060835167ffffffffffffffff8111801561276a57600080fd5b50604051908082528060200260200182016040528015612794578160200160208202803683370190505b509250600184510367ffffffffffffffff811180156127b257600080fd5b506040519080825280602002602001820160405280156127dc578160200160208202803683370190505b509150600184510367ffffffffffffffff811180156127fa57600080fd5b50604051908082528060200260200182016040528015612824578160200160208202803683370190505b509050848360008151811061283557fe5b60200260200101818152505060005b6001855103811015610ca45761287685828151811061285f57fe5b60200260200101518683600101815181106109af57fe5b83828151811061288257fe5b60200260200101906001600160a01b031690816001600160a01b03168152505060006001600160a01b03168382815181106128b957fe5b60200260200101516001600160a01b0316141561290c576040805162461bcd60e51b815260206004820152600c60248201526b0556e6b6e6f776e20737761760a41b604482015290519081900360640190fd5b82818151811061291857fe5b60200260200101516001600160a01b0316630589a4786040518163ffffffff1660e01b815260040160206040518083038186803b15801561295857600080fd5b505afa15801561296c573d6000803e3d6000fd5b505050506040513d602081101561298257600080fd5b505185516001600160a01b039091169086908390811061299e57fe5b60200260200101516001600160a01b03161415612a6d578281815181106129c157fe5b60200260200101516001600160a01b0316637b31ae648583815181106129e357fe5b60200260200101516040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015612a1f57600080fd5b505afa158015612a33573d6000803e3d6000fd5b505050506040513d6020811015612a4957600080fd5b50518451859060018401908110612a5c57fe5b602002602001018181525050612b41565b6001828281518110612a7b57fe5b602002602001019015159081151581525050828181518110612a9957fe5b60200260200101516001600160a01b031663e6d7059a858381518110612abb57fe5b60200260200101516040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015612af757600080fd5b505afa158015612b0b573d6000803e3d6000fd5b505050506040513d6020811015612b2157600080fd5b50518451859060018401908110612b3457fe5b6020026020010181815250505b600101612844565b6000806000836001600160a01b0316856001600160a01b031610612b6e578385612b71565b84845b6001600160a01b039182166000908152600160209081526040808320938516835292905220541695945050505050565b612ba96130fe565b6001600160a01b0316612bba611590565b6001600160a01b031614612c15576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116612c5a5760405162461bcd60e51b81526004018080602001828103825260268152602001806137da6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60608180421115612d03576040805162461bcd60e51b8152602060048201526013602482015272151c985b9cd858dd1a5bdb881d1bdbc81bdb19606a1b604482015290519081900360640190fd5b6002871015612d48576040805162461bcd60e51b815260206004820152600c60248201526b092dcecc2d8d2c840e0c2e8d60a31b604482015290519081900360640190fd5b60001987018414612d93576040805162461bcd60e51b815260206004820152601060248201526f496e76616c69642076657273696f6e7360801b604482015290519081900360640190fd5b606080612dd38c8b8b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061088692505050565b825192965090935091508b908590600090612dea57fe5b60200260200101511115612e37576040805162461bcd60e51b815260206004820152600f60248201526e115e18d95cdcda5d99481a5b9c1d5d608a1b604482015290519081900360640190fd5b80600081518110612e4457fe5b602002602001015115612e6757612e62338360008151811061175557fe5b613028565b81600081518110612e7457fe5b60200260200101516001600160a01b031663b60d42886040518163ffffffff1660e01b815260040160206040518083038186803b158015612eb457600080fd5b505afa158015612ec8573d6000803e3d6000fd5b505050506040513d6020811015612ede57600080fd5b505182516001600160a01b039091169063c01238d3908490600090612eff57fe5b60200260200101516001600160a01b03166369b459e36040518163ffffffff1660e01b815260040160206040518083038186803b158015612f3f57600080fd5b505afa158015612f53573d6000803e3d6000fd5b505050506040513d6020811015612f6957600080fd5b5051845133908690600090612f7a57fe5b602002602001015188600081518110612f8f57fe5b60200260200101518c8c6000818110612fa457fe5b905060200201356040518663ffffffff1660e01b815260040180868152602001856001600160a01b03168152602001846001600160a01b0316815260200183815260200182815260200195505050505050600060405180830381600087803b15801561300f57600080fd5b505af1158015613023573d6000803e3d6000fd5b505050505b6130368483838a8a306131b9565b8989600019810181811061304657fe5b905060200201356001600160a01b03166001600160a01b0316632e1a7d4d8d6040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561309b57600080fd5b505af11580156130af573d6000803e3d6000fd5b5050604051600092506001600160a01b038b1691508e908381818185875af1925050503d8060008114611a73576040519150601f19603f3d011682016040523d82523d6000602084013e611a78565b3390565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052613154908490613509565b505050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526131b3908590613509565b50505050565b60005b8551811015613500576000600187510382106131d857826131f0565b8682600101815181106131e757fe5b60200260200101515b90508582815181106131fe57fe5b60200260200101516133835786828151811061321657fe5b60200260200101516001600160a01b0316631033e4cd86868581811061323857fe5b905060200201358a856001018151811061324e57fe5b602002602001015184600067ffffffffffffffff8111801561326f57600080fd5b506040519080825280601f01601f19166020018201604052801561329a576020820181803683370190505b506040518563ffffffff1660e01b815260040180858152602001848152602001836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b838110156133025781810151838201526020016132ea565b50505050905090810190601f16801561332f5780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b15801561335157600080fd5b505af1158015613365573d6000803e3d6000fd5b505050506040513d602081101561337b57600080fd5b506134f79050565b86828151811061338f57fe5b60200260200101516001600160a01b0316639000ff098686858181106133b157fe5b905060200201358a85600101815181106133c757fe5b602002602001015184600067ffffffffffffffff811180156133e857600080fd5b506040519080825280601f01601f191660200182016040528015613413576020820181803683370190505b506040518563ffffffff1660e01b815260040180858152602001848152602001836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561347b578181015183820152602001613463565b50505050905090810190601f1680156134a85780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b1580156134ca57600080fd5b505af11580156134de573d6000803e3d6000fd5b505050506040513d60208110156134f457600080fd5b50505b506001016131bc565b50505050505050565b606061355e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166135ba9092919063ffffffff16565b8051909150156131545780806020019051602081101561357d57600080fd5b50516131545760405162461bcd60e51b815260040180806020018281038252602a815260200180613826602a913960400191505060405180910390fd5b60606135c984846000856135d3565b90505b9392505050565b6060824710156136145760405162461bcd60e51b81526004018080602001828103825260268152602001806138006026913960400191505060405180910390fd5b61361d8561372f565b61366e576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106136ad5780518252601f19909201916020918201910161368e565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461370f576040519150601f19603f3d011682016040523d82523d6000602084013e613714565b606091505b5091509150613724828286613735565b979650505050505050565b3b151590565b606083156137445750816135cc565b8251156137545782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561379e578181015183820152602001613786565b50505050905090810190601f1680156137cb5780820380516001836020036101000a031916815260200191505b509250505060405180910390fdfe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a26469706673582212209ba69bd16bb8ca35ba22d6539b47609a83bb2e6e47272c63b45564ab26a374e964736f6c634300060c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : wstETH_ (address): 0x0000000000000000000000000000000000000000
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
Loading...
Loading
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.